34 #include <wx/statline.h>
35 #include <wx/valgen.h>
36 #include <wx/spinctrl.h>
37 #include <boost/format.hpp>
86 wxDialog(parent, -1, _T(""), wxDefaultPosition),
92 minAddressSizer_(NULL),
93 maxAddressSizer_(NULL),
96 createContents(
this,
true,
true);
104 wxTextValidator(wxFILTER_ASCII, &name_));
106 wxGenericValidator(&width_));
112 bitWidthSpinCtrl_ =
dynamic_cast<wxSpinCtrl*
>(
FindWindow(ID_BIT_WIDTH));
117 TransferDataToWindow();
139 format fmt = prodeTexts->
text(
183 width_ = as_->width();
185 minControl_->setValue(as_->start());
186 maxControl_->setValue(as_->end());
190 idNumbers_ = as_->numericalIds();
195 dynamic_cast<wxSpinCtrl*
>(
FindWindow(ID_WIDTH))->SetValue(width_);
197 wxCommandEvent
dummy;
201 wxSpinEvent dummySpin;
204 return wxWindow::TransferDataToWindow();
212 assert (idListCtrl_ != NULL);
213 idListCtrl_->DeleteAllItems();
215 for (std::set<unsigned>::iterator it = idNumbers_.begin();
216 it != idNumbers_.end(); ++it) {
217 idListCtrl_->InsertItem(
232 if (!TransferDataFromWindow()) {
250 if (trimmedName != as_->name()) {
255 as_->machine()->addressSpaceNavigator();
256 for (
int i = 0; i < navigator.
count(); i++) {
257 string asName = navigator.
item(i)->name();
258 if (trimmedName == asName) {
263 format an_as = prodeTexts->
text(
269 message % trimmedName % an_as.str() %
machine.str() % as.str();
278 as_->setName(trimmedName);
279 as_->setWidth(width_);
280 unsigned int minAddr = minControl_->unsignedValue();
281 unsigned int maxAddr = maxControl_->unsignedValue();
282 as_->setAddressBounds(minAddr, maxAddr);
284 if (!as_->setNumericalIds(idNumbers_)) {
303 if (!TransferDataFromWindow()) {
306 wxString trimmedName = name_.Trim(
false).Trim(
true);
307 if (trimmedName == _T(
"")) {
320 if (minControl_->unsignedValue() >= maxControl_->unsignedValue()) {
321 minControl_->setValue(maxControl_->unsignedValue() - 1);
331 if (maxControl_->unsignedValue() <= minControl_->unsignedValue()) {
332 maxControl_->setValue(minControl_->unsignedValue() + 1);
335 bitWidthSpinCtrl_->SetValue(bitWidth);
353 unsigned maxAddress =
static_cast<unsigned>(
354 pow(2, bitWidthSpinCtrl_->GetValue()) - 1u);
355 maxControl_->setValue(maxAddress);
357 wxCommandEvent
dummy;
368 unsigned spinId =
static_cast<unsigned>(idSpinCtrl_->GetValue());
371 if (!isFreeId(spinId)) {
376 idNumbers_.insert(spinId);
391 for (
int i = 0; i < idListCtrl_->GetSelectedItemCount(); ++i) {
392 itemIndex = idListCtrl_->GetNextItem(
393 itemIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
396 if (itemIndex >= 0) {
397 wxString idText = idListCtrl_->GetItemText(itemIndex);
399 if (idText.ToLong(&
id)) {
400 idNumbers_.erase(
id);
410 onIdListSelection(dummy2);
420 unsigned spinId =
static_cast<unsigned>(idSpinCtrl_->GetValue());
423 if (isFreeId(spinId)) {
437 if (idListCtrl_->GetSelectedItemCount() < 1) {
451 assert (machine_ != NULL);
452 std::set<unsigned>::iterator it;
455 it = idNumbers_.find(
id);
456 if (it != idNumbers_.end()) {
461 machine_->addressSpaceNavigator();
464 for (
int i = 0; i < asNavigator.
count(); i++) {
471 if (it != ids.end()) {
495 wxWindow *parent,
bool call_fit,
bool set_sizer) {
497 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
499 wxFlexGridSizer *item1 =
new wxFlexGridSizer( 2, 0, 0 );
501 wxStaticBox *item3 =
new wxStaticBox( parent, -1, wxT(
"Name:") );
502 wxStaticBoxSizer *item2 =
new wxStaticBoxSizer( item3, wxVERTICAL );
505 wxTextCtrl *item4 =
new wxTextCtrl(parent, ID_NAME, wxT(
""), wxDefaultPosition, wxSize(160,-1), 0);
506 item2->Add( item4, 0, wxGROW|wxALL, 5 );
508 item1->Add( item2, 0, wxGROW|wxALL, 5 );
510 wxStaticBox *item6 =
new wxStaticBox( parent, -1, wxT(
"Min-Address") );
511 wxStaticBoxSizer *item5 =
new wxStaticBoxSizer( item6, wxVERTICAL );
512 minAddressSizer_ = item5;
516 item5->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
518 item1->Add( item5, 0, wxGROW|wxALL, 5 );
520 wxStaticBox *item9 =
new wxStaticBox( parent, -1, wxT(
"Width:") );
521 wxStaticBoxSizer *item8 =
new wxStaticBoxSizer( item9, wxVERTICAL );
524 wxSpinCtrl *item10 =
new wxSpinCtrl(parent, ID_WIDTH, wxT(
"1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 10000, 1, wxT(
"Spin"));
525 item8->Add( item10, 0, wxGROW|wxALL, 5 );
527 item1->Add( item8, 0, wxGROW|wxALL, 5 );
529 wxStaticBox *item12 =
new wxStaticBox( parent, -1, wxT(
"Max-Address") );
530 wxStaticBoxSizer *item11 =
new wxStaticBoxSizer( item12, wxVERTICAL );
531 maxAddressSizer_ = item11;
535 item11->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
537 wxBoxSizer *bitSizer =
new wxBoxSizer(wxHORIZONTAL);
539 wxStaticText *bitText =
new wxStaticText(parent, -1, wxT(
"Bits:"));
540 bitSizer->Add( bitText, 0, wxGROW|wxALL, 5 );
542 wxSpinCtrl *bitWidth =
new wxSpinCtrl( parent, ID_BIT_WIDTH, wxT(
"1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 10000, 1);
543 bitSizer->Add( bitWidth, 0, wxGROW|wxALL, 5 );
545 item11->Add( bitSizer, 0, wxGROW|wxALL, 5 );
547 item1->Add( item11, 0, wxGROW|wxALL, 5 );
550 wxStaticBox *itemIdBox =
new wxStaticBox(parent, -1, wxT(
"ID number:"));
551 wxStaticBoxSizer *itemIdSizer =
new wxStaticBoxSizer(itemIdBox,
553 idSizer_ = itemIdSizer;
555 wxListCtrl *itemIdListCtrl =
new wxListCtrl( parent, ID_ID_LIST,
558 wxLC_REPORT|wxSUNKEN_BORDER );
559 idSizer_->Add( itemIdListCtrl, 0, wxALIGN_CENTER|wxALL, 5 );
560 idListCtrl_ = itemIdListCtrl;
561 idListCtrl_->InsertColumn(0, _(
"ID"));
563 wxBoxSizer *sizerOnRight =
new wxBoxSizer(wxVERTICAL);
565 wxSpinCtrl *itemIdSpinCtrl =
new wxSpinCtrl( parent, ID_SPIN_ID, wxT(
"0"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 2147483647, 1, wxT(
"Spin") );
566 sizerOnRight->Add( itemIdSpinCtrl, 0, wxGROW|wxALL, 5 );
567 idSpinCtrl_ = itemIdSpinCtrl;
569 wxButton *addButton =
new wxButton( parent, ID_ADD_ID, wxT(
"Add"), wxDefaultPosition, wxDefaultSize, 0 );
570 sizerOnRight->Add( addButton, 0, wxALIGN_CENTER|wxALL, 5 );
572 wxButton *deleteButton =
new wxButton( parent, ID_DELETE_ID, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
573 sizerOnRight->Add( deleteButton, 0, wxALIGN_CENTER|wxALL, 5 );
575 idSizer_->Add( sizerOnRight, 0, wxALIGN_CENTER|wxALL, 5 );
576 item1->Add( idSizer_, 0, wxGROW|wxALL, 5 );
578 assert (idSizer_ != NULL);
579 assert (idListCtrl_ != NULL);
580 assert (idSpinCtrl_ != NULL);
583 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
585 wxStaticLine *item14 =
new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
586 item0->Add( item14, 0, wxGROW|wxALL, 5 );
588 wxGridSizer *item15 =
new wxGridSizer( 2, 0, 0 );
590 wxButton *item16 =
new wxButton( parent, ID_HELP, wxT(
"&Help"), wxDefaultPosition, wxDefaultSize, 0 );
591 item15->Add( item16, 0, wxALL, 5 );
593 wxBoxSizer *item17 =
new wxBoxSizer( wxHORIZONTAL );
595 wxButton *item18 =
new wxButton( parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
596 item17->Add( item18, 0, wxALIGN_CENTER, 5 );
598 wxButton *item19 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
599 item17->Add( item19, 0, wxALIGN_CENTER|wxALL, 5 );
601 item15->Add( item17, 0, wxALL, 5 );
603 item0->Add( item15, 0, wxGROW, 5 );
607 parent->SetSizer( item0 );
609 item0->SetSizeHints( parent );