33 #include <boost/format.hpp>
36 #include <wx/statline.h>
37 #include <wx/listctrl.h>
80 wxDialog(parent, -1, _T(""), wxDefaultPosition),
82 templateName_(_T("")) {
84 createContents(
this,
true,
true);
86 templateList_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_TEMPLATE_LIST));
87 slotList_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_SLOT_LIST));
90 wxTextValidator(wxFILTER_ASCII, &templateName_));
116 format fmt = prodeTexts->
text(
157 wxListCtrl* templateList =
158 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_TEMPLATE_LIST));
161 wxLIST_FORMAT_LEFT, 160);
164 wxListCtrl* slotList =
165 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_SLOT_LIST));
168 wxLIST_FORMAT_LEFT, 100);
171 wxLIST_FORMAT_LEFT, 100);
174 wxLIST_FORMAT_LEFT, 50);
186 templateList_->DeleteAllItems();
188 machine_->instructionTemplateNavigator();
189 for (
int i = 0; i < navigator.
count(); i++) {
190 templateList_->InsertItem(
194 return wxDialog::TransferDataToWindow();
205 slotList_->DeleteAllItems();
219 for (
int i = 0; i < busNavigator.
count(); i++) {
222 Bus* slot = busNavigator.
item(i);
224 slotList_->InsertItem(
232 slotList_->SetItem(0, 1, name);
237 slotList_->SetItem(0, 2, width);
243 machine_->immediateSlotNavigator();
244 for (
int i = 0; i < immsNavigator.
count(); i++) {
250 slotList_->InsertItem(
256 slotList_->SetItem(0, 1, name);
261 slotList_->SetItem(0, 2, width);
265 onSlotSelection(
dummy);
274 if (templateList_->GetSelectedItemCount() == 0) {
288 if (slotList_->GetSelectedItemCount() == 1) {
303 delete selectedTemplate();
304 TransferDataToWindow();
306 onTemplateSelection(
dummy);
318 item = templateList_->GetNextItem(
319 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
326 machine_->instructionTemplateNavigator().item(item);
350 if (!TransferDataFromWindow()) {
368 machine_->instructionTemplateNavigator();
370 if (navigator.
hasItem(trimmedName)) {
381 message % trimmedName % a_tmplate.str() %
machine.str() %
388 templateName_ = _T(
"");
389 TransferDataToWindow();
399 if (!TransferDataFromWindow()) {
402 wxString trimmedName = templateName_.Trim(
false).Trim(
true);
403 if (trimmedName == _T(
"")) {
417 if (selectedTemplate() == NULL) {
423 machine_->immediateUnitNavigator();
425 if (iuNavigator.
count() == 0) {
436 bool available =
false;
440 for (
int i = 0; i < busNavigator.
count(); i++) {
441 if (!selectedTemplate()->usesSlot(busNavigator.
item(i)->name())) {
449 machine_->immediateSlotNavigator();
450 for (
int i = 0; i < immsNavigator.
count(); i++) {
451 if (!selectedTemplate()->usesSlot(immsNavigator.
item(i)->name())) {
457 if (available ==
false) {
477 selectedTemplate()->removeSlot(selectedSlot());
488 selectedTemplate()->templateSlot(selectedSlot()) );
506 wxWindow *parent,
bool call_fit,
bool set_sizer) {
508 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
510 wxBoxSizer *item1 =
new wxBoxSizer( wxHORIZONTAL );
512 wxStaticBox *item3 =
new wxStaticBox( parent, -1, wxT(
"Instruction Templates:") );
513 wxStaticBoxSizer *item2 =
new wxStaticBoxSizer( item3, wxVERTICAL );
514 templateSizer_ = item2;
516 wxListCtrl *item4 =
new wxListCtrl( parent, ID_TEMPLATE_LIST, wxDefaultPosition, wxSize(160,200), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
517 item2->Add( item4, 0, wxGROW|wxALL, 5 );
519 wxBoxSizer *item5 =
new wxBoxSizer( wxHORIZONTAL );
521 wxStaticText *item6 =
new wxStaticText( parent, ID_LABEL_NAME, wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
522 item5->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
524 wxTextCtrl *item7 =
new wxTextCtrl( parent, ID_NAME, wxT(
""), wxDefaultPosition, wxSize(120,-1), 0 );
525 item5->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
527 item2->Add( item5, 0, wxGROW|wxALL, 5 );
529 wxBoxSizer *item8 =
new wxBoxSizer( wxHORIZONTAL );
531 wxButton *item9 =
new wxButton( parent, ID_ADD_TEMPLATE, wxT(
"Add"), wxDefaultPosition, wxDefaultSize, 0 );
532 item8->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
534 wxButton *item10 =
new wxButton( parent, ID_DELETE_TEMPLATE, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
535 item8->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
537 item2->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
539 item1->Add( item2, 0, wxGROW|wxALL, 5 );
541 wxStaticBox *item12 =
new wxStaticBox( parent, -1, wxT(
"Template Slots:") );
542 wxStaticBoxSizer *item11 =
new wxStaticBoxSizer( item12, wxVERTICAL );
545 wxListCtrl *item13 =
new wxListCtrl( parent, ID_SLOT_LIST, wxDefaultPosition, wxSize(250,245), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
546 item11->Add( item13, 0, wxGROW|wxALL, 5 );
548 wxBoxSizer *item14 =
new wxBoxSizer( wxHORIZONTAL );
550 wxButton *item15 =
new wxButton( parent, ID_ADD_SLOT, wxT(
"Add..."), wxDefaultPosition, wxDefaultSize, 0 );
551 item14->Add( item15, 0, wxALIGN_CENTER|wxALL, 5 );
553 wxButton *item16 =
new wxButton( parent, ID_EDIT_SLOT, wxT(
"Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
554 item14->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
556 wxButton *item17 =
new wxButton( parent, ID_DELETE_SLOT, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
557 item14->Add( item17, 0, wxALIGN_CENTER|wxALL, 5 );
559 item11->Add( item14, 0, wxALIGN_CENTER|wxALL, 5 );
561 item1->Add( item11, 0, wxGROW|wxALL, 5 );
563 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
565 wxStaticLine *item18 =
new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
566 item0->Add( item18, 0, wxGROW|wxALL, 5 );
568 wxGridSizer *item19 =
new wxGridSizer( 2, 0, 0 );
570 wxButton *item20 =
new wxButton( parent, ID_HELP, wxT(
"&Help"), wxDefaultPosition, wxDefaultSize, 0 );
571 item19->Add( item20, 0, wxALL, 5 );
573 wxBoxSizer *item21 =
new wxBoxSizer( wxHORIZONTAL );
575 wxButton *item22 =
new wxButton( parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
576 item21->Add( item22, 0, wxALIGN_CENTER|wxALL, 5 );
578 wxButton *item23 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
579 item21->Add( item23, 0, wxALIGN_CENTER|wxALL, 5 );
581 item19->Add( item21, 0, wxALL, 5 );
583 item0->Add( item19, 0, wxGROW, 5 );
587 parent->SetSizer( item0 );
589 item0->SetSizeHints( parent );