OpenASIP  2.0
OptionsDialog.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file OptionsDialog.cc
26  *
27  * Implementation of OptionsDialog class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <string>
34 #include <wx/wx.h>
35 #include <wx/notebook.h>
36 #include <wx/listctrl.h>
37 #include <wx/valgen.h>
38 #include <wx/spinctrl.h>
39 #include <boost/format.hpp>
40 
41 #include "OptionsDialog.hh"
42 #include "GUIOptions.hh"
43 #include "WxConversion.hh"
44 #include "CommandRegistry.hh"
45 #include "GUICommand.hh"
46 #include "ErrorDialog.hh"
47 #include "Conversion.hh"
48 #include "ToolbarButton.hh"
50 #include "WidgetTools.hh"
51 #include "GUITextGenerator.hh"
52 
53 using boost::format;
54 using std::string;
55 using std::vector;
56 
57 const wxString OptionsDialog::COMMAND_COLUMN_TITLE = _T("Command");
58 const wxString OptionsDialog::SHORTCUT_COLUMN_TITLE = _T("Shortcut");
59 const wxString OptionsDialog::TOOLBAR_BUTTONS_COLUMN_TITLE = _T("Toolbar");
60 const wxString OptionsDialog::AVAILABLE_COMMANDS_COLUMN_TITLE = _T("Commands");
61 const wxString OptionsDialog::CONTENTS_ICONS = _T("Icons");
62 const wxString OptionsDialog::CONTENTS_BOTH = _T("Both");
63 const wxString OptionsDialog::CONTENTS_TEXT = _T("Text");
64 const wxString OptionsDialog::EDIT_BUTTON_LABEL = _T("Edit...");
65 const wxString OptionsDialog::DELETE_BUTTON_LABEL = _T("Delete");
66 
67 // See http://tce.cs.tut.fi/cgi-bin/tce-bugzilla/show_bug.cgi?id=96
68 // Keyboard shortcut editing hasn't been working probably since
69 // the wxWidgets 2.4/2.6 times (2004 or so). It just does not get
70 // the keyboard events. Might be due to the modality somehow. There
71 // are some bug reports on MacOS/Cocoa wx2.8 of not getting the events
72 // on modal subwindows. Disabling it until it gets fixed/rewritten.
73 //#define KB_SC_EDITING
74 
75 BEGIN_EVENT_TABLE(OptionsDialog, wxDialog)
77 #ifdef KB_SC_EDITING
79 #endif
86 
87 #ifdef KB_SC_EDITING
88  EVT_LIST_ITEM_FOCUSED(ID_KB_SC_LIST, OptionsDialog::onShortcutSelection)
89  EVT_LIST_DELETE_ITEM(ID_KB_SC_LIST, OptionsDialog::onShortcutSelection)
93  EVT_MENU(ID_EDIT_KB_SC, OptionsDialog::onEditShortcut)
94  EVT_MENU(ID_DELETE_KB_SC, OptionsDialog::onDeleteShortcut)
95  EVT_LIST_ITEM_RIGHT_CLICK(ID_KB_SC_LIST, OptionsDialog::onShortcutRightClick)
96 #endif
97 
98  EVT_LIST_ITEM_FOCUSED(ID_TOOLBAR_LIST, OptionsDialog::onToolbarSelection)
99  EVT_LIST_DELETE_ITEM(ID_TOOLBAR_LIST, OptionsDialog::onToolbarSelection)
102 
103  EVT_LIST_ITEM_FOCUSED(ID_COMMAND_LIST, OptionsDialog::onCommandSelection)
104  EVT_LIST_DELETE_ITEM(ID_COMMAND_LIST, OptionsDialog::onCommandSelection)
107 
108  // too long lines to keep doxygen quiet
110 
111 /**
112  * The Constructor.
113  *
114  * @param parent Parent window of the dialog.
115  * @param options Options to be modified.
116  * @param commandRegistry Command registry containing available commands.
117  */
119  wxWindow* parent,
121  CommandRegistry& commandRegistry):
122  wxDialog(parent, -1, _T(""), wxDefaultPosition, wxSize(500, 300),
123  (wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)),
124  parent_(parent), options_(options), shortcutList_(NULL),
125  toolbarList_(NULL), commandList_(NULL), commandRegistry_(commandRegistry) {
126 
127  initialize();
128 
129  readCommands();
130  readOptions();
131  SetMinSize(wxSize(420, 300));
132 
133  notebook_ = dynamic_cast<wxNotebook*>(FindWindow(ID_NOTEBOOK));
134 }
135 
136 
137 /**
138  * The Destructor.
139  */
141 #ifdef KB_SC_EDITING
142  // delete shortcut list
143  vector<Shortcut*>::iterator i = shortcuts_.begin();
144  for (; i != shortcuts_.end(); i++) {
145  delete (*i);
146  }
147  shortcuts_.clear();
148 #endif
149 }
150 
151 
152 /**
153  * Initializes the dialog widgets.
154  */
155 void
157 
158  createContents(this, true, true);
159 
160  toolbarList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_TOOLBAR_LIST));
161  commandList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_COMMAND_LIST));
162  shortcutList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_KB_SC_LIST));
163 
164 #ifdef KB_SC_EDITING
165  // Create keyboard shortcut list columns.
166  wxListCtrl* shortcutList =
167  dynamic_cast<wxListCtrl*>(FindWindow(ID_KB_SC_LIST));
168  shortcutList->InsertColumn(
169  0, COMMAND_COLUMN_TITLE, wxLIST_FORMAT_LEFT, 190);
170  shortcutList_->InsertColumn(
171  1, SHORTCUT_COLUMN_TITLE, wxLIST_FORMAT_LEFT, 150);
172 #endif
173  // Create toolbar buttons list column.
174  wxListCtrl* toolbarList =
175  dynamic_cast<wxListCtrl*>(FindWindow(ID_TOOLBAR_LIST));
176  toolbarList->InsertColumn(
177  0, TOOLBAR_BUTTONS_COLUMN_TITLE, wxLIST_FORMAT_LEFT, 180);
178 
179  // Create available buttons list column.
180  wxListCtrl* commandList =
181  dynamic_cast<wxListCtrl*>(FindWindow(ID_COMMAND_LIST));
182  commandList->InsertColumn(
183  0, AVAILABLE_COMMANDS_COLUMN_TITLE, wxLIST_FORMAT_LEFT, 180);
184 
185  FindWindow(ID_TOOL_DOWN)->Disable();
186  FindWindow(ID_TOOL_UP)->Disable();
187  FindWindow(ID_TOOL_INSERT)->Disable();
188  FindWindow(ID_TOOL_REMOVE)->Disable();
189 #ifdef KB_SC_EDITING
190  FindWindow(ID_EDIT_KB_SC)->Disable();
191  FindWindow(ID_DELETE_KB_SC)->Disable();
192 #endif
193 
194  wxChoice* contentsChoicer =
195  dynamic_cast<wxChoice*>(FindWindow(ID_TOOLBAR_CONTENTS));
196 
197  // choicer texts
198  contentsChoicer->Append(CONTENTS_ICONS);
199  contentsChoicer->Append(CONTENTS_BOTH);
200  contentsChoicer->Append(CONTENTS_TEXT);
201 }
202 
203 
204 /**
205  * Reads the options in options_ to dialog attributes.
206  */
207 void
209 
210  // read and set the toolbar layout
211  wxChoice* contentsChoice =
212  dynamic_cast<wxChoice*>(FindWindow(ID_TOOLBAR_CONTENTS));
213 
215  contentsChoice->SetStringSelection(CONTENTS_TEXT);
216  } else if (options_.toolbarLayout() == GUIOptions::ICON) {
217  contentsChoice->SetStringSelection(CONTENTS_ICONS);
218  } else if (options_.toolbarLayout() == GUIOptions::BOTH) {
219  contentsChoice->SetStringSelection(CONTENTS_BOTH);
220  } else {
221  assert(false);
222  }
223 
224 #ifdef KB_SC_EDITING
225  // read keyboard shortcuts
227  while (shortcut != NULL) {
228 
229  // find the shortcut list item for the command
230  Shortcut* listItem = NULL;
231  vector<Shortcut*>::iterator i = shortcuts_.begin();
232  for (; i != shortcuts_.end(); i++) {
233  if ((*i)->name == shortcut->action()) {
234  listItem = (*i);
235  }
236  }
237  if (listItem == NULL) {
238  wxString message = _T("Unknown command in options:\n");
239  message.Append(WxConversion::toWxString(shortcut->action()));
240  ErrorDialog dialog(this, message);
241  dialog.ShowModal();
242  } else {
243  listItem->shortcut = new KeyboardShortcut(*shortcut);
244  }
245  shortcut = options_.nextShortcut();
246  }
247 #endif
248 
249  bool found = true;
250  int slot = 0;
251 
252  // read toolbar buttons and separators
253  while (found) {
254 
255  found = false;
256 
257  // check if a toolbar button exists for the slot
259  while (tool != NULL) {
260  if (tool->slot() == slot) {
261  // button found for the slot, add it
262  toolbar_.push_back(tool->action());
263  found = true;
264  }
265  tool = options_.nextToolbarButton();
266  }
267 
268  // check if a separator exists for the slot
269  int separator = options_.firstSeparator();
270  while (separator != -1) {
271  if (separator == slot) {
272  // separator found for the slot, add it
274  found = true;
275  }
276  separator = options_.nextSeparator();
277  }
278  slot++;
279  }
280 }
281 
282 /**
283  * Writes the options from dialog attributes to the current options object.
284  */
285 void
287 
288  // set the toolbar layout
289  wxChoice* contentsChoice =
290  dynamic_cast<wxChoice*>(FindWindow(ID_TOOLBAR_CONTENTS));
291 
292  if (contentsChoice->GetStringSelection() == CONTENTS_TEXT) {
294  } else if (contentsChoice->GetStringSelection() == CONTENTS_ICONS) {
296  } else if (contentsChoice->GetStringSelection() == CONTENTS_BOTH) {
298  } else {
299  assert(false);
300  }
301 
302 #ifdef KB_SC_EDITING
303  // delete all old shortcuts
304  while (options_.firstShortcut() != NULL) {
306  }
307 #endif
308 
309  // delete all old toolbar buttons
310  while (options_.firstToolbarButton() != NULL) {
312  }
313 
314  // delete all old toolbar separators
315  while (options_.firstSeparator() != -1) {
317  }
318 
319 #ifdef KB_SC_EDITING
320  // add all keyboard shortcuts and toolbar buttons
321  vector<Shortcut*>::iterator i = shortcuts_.begin();
322  for (; i != shortcuts_.end(); i++) {
323  if ((*i)->shortcut != NULL) {
324  options_.addKeyboardShortcut((*i)->shortcut);
325  }
326  }
327 #endif
328 
329  // add all toolbar buttons and separators
330  int slot = 0;
331  vector<string>::iterator iter = toolbar_.begin();
332  for (; iter != toolbar_.end(); iter++) {
333  if ((*iter) == GUIOptions::TOOLBAR_SEPARATOR) {
334  options_.addSeparator(slot);
335  } else {
336  ToolbarButton* button = new ToolbarButton(slot, (*iter));
337  options_.addToolbarButton(button);
338  }
339  slot++;
340  }
341 }
342 
343 
344 /**
345  * Adds available commands to the keyboard shortcut list and toolbar tool
346  * list.
347  *
348  * Reads commands fromt the command registry.
349  */
350 void
353  while (command != NULL) {
354  Shortcut* shortcut = new Shortcut;
355  shortcut->id = command->id();
356  shortcut->name = command->name();
357  shortcut->shortcut = NULL;
358  shortcuts_.push_back(shortcut);
359  command = commandRegistry_.nextCommand();
360  }
361 }
362 
363 
364 /**
365  * Transfers data from dialog attributes to controls in the dialog.
366  *
367  * @return False if the transfer failed.
368  */
369 bool
371 
372  toolbarList_->DeleteAllItems();
373  commandList_->DeleteAllItems();
374 
375  vector<Shortcut*>::iterator i = shortcuts_.begin();
376 #ifdef KB_SC_EDITING
377  shortcutList_->DeleteAllItems();
378  // Update keyboard shortcut list.
379  for (; i != shortcuts_.end(); i++) {
380  shortcutList_->InsertItem(
381  shortcutList_->GetItemCount(),
382  WxConversion::toWxString((*i)->name));
383  // add shortcut to the second column if one exists
384  if ((*i)->shortcut != NULL) {
385 
386  string keyName = "";
387 
388  // set the name of the key
389  if ((*i)->shortcut->key() > 32 && (*i)->shortcut->key() < 127) {
390  // character key
391  keyName = Conversion::toString((*i)->shortcut->key());
392  } else if ((*i)->shortcut->key() == 127) {
393  // delete key
394  keyName = "DEL";
395  } else if ((*i)->shortcut->fKey() != 0) {
396  // function key
397  keyName = "F"+Conversion::toString((*i)->shortcut->fKey());
398  }
399 
400  wxString key = WxConversion::toWxString(keyName);
401 
402  if ((*i)->shortcut->alt()) {
403  key.Prepend(_T("ALT - "));
404  }
405  if ((*i)->shortcut->ctrl()) {
406  key.Prepend(_T("CTRL - "));
407  }
408  shortcutList_->SetItem(shortcutList_->GetItemCount()-1,
409  1, key);
410  }
411  }
412 
413 #endif
414 
415  // Update toolbar button lists.
416  vector<string>::iterator iter = toolbar_.begin();
417  for (; iter != toolbar_.end(); iter++) {
418  toolbarList_->InsertItem(toolbarList_->GetItemCount(),
419  WxConversion::toWxString((*iter)));
420  }
421 
422  // update commands list
423  commandList_->InsertItem(
425 
426  bool inToolbar;
427  i = shortcuts_.begin();
428  for (; i != shortcuts_.end(); i++) {
429 
430  inToolbar = false;
431 
432  // check if command is already in the toolbar
433  iter = toolbar_.begin();
434  for (; iter != toolbar_.end(); iter++) {
435  if ((*i)->name == (*iter)) {
436  inToolbar = true;
437  }
438  }
439 
440  // add command to the list if it wasn't in the toolbar
441  if (!inToolbar) {
442  commandList_->InsertItem(commandList_->GetItemCount(),
443  WxConversion::toWxString((*i)->name));
444  }
445  }
446  return true;
447 }
448 
449 
450 /**
451  * Removes keyboard shortcut for the selected command.
452  */
453 void
455  vector<Shortcut*>::iterator iter = shortcuts_.begin();
456  for (int i = 0; i < shortcutList_->GetItemCount(); i++) {
457  if (shortcutList_->GetItemState(i, wxLIST_STATE_SELECTED) != 0) {
458  // delete selected shortcut
459  delete (*iter)->shortcut;
460  (*iter)->shortcut = NULL;
462  return;
463  }
464  iter++;
465  }
466  assert(false);
467 }
468 
469 
470 /**
471  * Handles left mouse button double click on the shortcut list.
472  */
473 void
475  wxCommandEvent dummy;
477 }
478 
479 
480 /**
481  * Returns pointer to the shortcut selected in the shortcut list.
482  *
483  * @return NULL if no shortcut is selected.
484  */
487  vector<Shortcut*>::iterator iter = shortcuts_.begin();
488  for (int i = 0; i < shortcutList_->GetItemCount(); i++) {
489  if (shortcutList_->GetItemState(i, wxLIST_STATE_SELECTED) != 0) {
490  return (*iter);
491  }
492  iter++;
493  }
494  return NULL;
495 }
496 
497 /**
498  * Prompts for a new keyboard shortcut for the selected command with
499  * ShortcutDialog.
500  */
501 void
503 
504  bool newShortcut = false;
505 
506  Shortcut* selected = selectedShortcut();
507  if (selected == NULL) {
508  return;
509  }
510 
511  // edit selected shortcut
512  KeyboardShortcut* shortcut = selected->shortcut;
513  if (shortcut == NULL) {
514  newShortcut = true;
515  shortcut = new KeyboardShortcut(
516  selected->name, 0, false, false, char(0));
517  }
518 
519  KeyboardShortcutDialog dialog(this, shortcut);
520  if (dialog.ShowModal() == wxID_OK) {
521 
522  vector<Shortcut*>::iterator di = shortcuts_.begin();
523  for (; di != shortcuts_.end(); di++) {
524  if ((*di)->name == selected->name) {
525  (*di)->shortcut = shortcut;
526  } else if (((*di)->shortcut != NULL) &&
527  ((*di)->shortcut->equals(*shortcut))) {
528 
529  // Shortcut with the same key-combination exists, delete it.
530  delete (*di)->shortcut;
531  (*di)->shortcut = NULL;
532  }
533  }
534 
536  } else if (newShortcut) {
537  // Shortcut adding cancelled.
538  delete shortcut;
539  }
540  return;
541 }
542 
543 
544 /**
545  * Adds a toolbar button for the command selected in the command list.
546  */
547 void
548 OptionsDialog::onInsertTool(wxCommandEvent&) {
549  // search for the selected command and add it to the toolbar
550  for (int i = 0; i < commandList_->GetItemCount(); i++) {
551  if (commandList_->GetItemState(i, wxLIST_STATE_SELECTED) != 0) {
552  string selected =
553  WxConversion::toString(commandList_->GetItemText(i));
554  toolbar_.push_back(selected);
555 
556  }
557  }
559 }
560 
561 
562 /**
563  * Removes the selected toolbar button from the toolbar button list.
564  */
565 void
566 OptionsDialog::onRemoveTool(wxCommandEvent&) {
567  vector<string>::iterator iter = toolbar_.begin();
568  for (int i = 0; i < toolbarList_->GetItemCount(); i++) {
569  // search selected list item
570  if (toolbarList_->GetItemState(i, wxLIST_STATE_SELECTED) != 0) {
571  toolbar_.erase(iter);
572  break;
573  }
574  assert(iter != toolbar_.end());
575  iter++;
576  }
578 }
579 
580 
581 /**
582  * Moves selected tool up or down in the toolbar button list.
583  */
584 void
585 OptionsDialog::onMoveTool(wxCommandEvent& event) {
586 
587  int selected = -1;
588  // search the selected command in the toolbar button list
589  for (int i = 0; i < toolbarList_->GetItemCount(); i++) {
590  if (toolbarList_->GetItemState(i, wxLIST_STATE_SELECTED) != 0) {
591  selected = i;
592  }
593  }
594 
595  assert(selected != -1);
596 
597  // move tool up
598  if (event.GetId() == ID_TOOL_UP) {
599  if (selected == 0) {
600  // tool already at the top
601  return;
602  }
603  string above = toolbar_[selected-1];
604  toolbar_[selected-1] = toolbar_[selected];
605  toolbar_[selected] = above;
606  }
607 
608  // move tool down
609  if (event.GetId() == ID_TOOL_DOWN) {
610  if (selected == int(toolbar_.size())-1) {
611  // toolbar already at the bottom
612  return;
613  }
614  string below = toolbar_[selected+1];
615  toolbar_[selected+1] = toolbar_[selected];
616  toolbar_[selected] = below;
617  }
618 
620 
621  long setItem = -1;
622  if (event.GetId() == ID_TOOL_UP) {
623  setItem = selected - 1;
624  } else if (event.GetId() == ID_TOOL_DOWN) {
625  setItem = selected + 1;
626  }
627 
628  toolbarList_->SetItemState(setItem, wxLIST_STATE_SELECTED,
629  wxLIST_STATE_SELECTED);
630  toolbarList_->EnsureVisible(setItem);
631 }
632 
633 
634 /**
635  * Disables and enables Edit and Delete buttons under the keyboard shortcut.
636  *
637  * If a shortcut is selected, buttons are enabled. If no shortcut is selected
638  * the buttons are disabled.
639  *
640  * @param event ListEvent, which may have changed the selection.
641  */
642 void
644  if (shortcutList_->GetSelectedItemCount() != 1) {
645  FindWindow(ID_DELETE_KB_SC)->Disable();
646  FindWindow(ID_EDIT_KB_SC)->Disable();
647  return;
648  }
649  FindWindow(ID_DELETE_KB_SC)->Enable();
650  FindWindow(ID_EDIT_KB_SC)->Enable();
651  event.Skip();
652 }
653 
654 
655 /**
656  * Opens a pop-up menu when right mouse button was pressed.
657  *
658  * @param event Information about right mouse click event.
659  */
660 void
662 
663  shortcutList_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
664  wxLIST_STATE_SELECTED);
665 
666  wxMenu* contextMenu = new wxMenu();
667 
668  contextMenu->Append(ID_EDIT_KB_SC, EDIT_BUTTON_LABEL);
669  contextMenu->Append(ID_DELETE_KB_SC, DELETE_BUTTON_LABEL);
670  shortcutList_->PopupMenu(contextMenu, event.GetPoint());
671 }
672 
673 
674 /**
675  * Disables and enables Up, Down and Remove buttons in the 'Toolbar' page.
676  *
677  * If a toolbar item is selected, buttons are enabled. If no item is
678  * selected the buttons are disabled.
679  *
680  * @param event ListEvent, which may have changed the selection.
681  */
682 void
684  if (toolbarList_->GetSelectedItemCount() != 1) {
685  FindWindow(ID_TOOL_UP)->Disable();
686  FindWindow(ID_TOOL_DOWN)->Disable();
687  FindWindow(ID_TOOL_REMOVE)->Disable();
688  return;
689  }
690  FindWindow(ID_TOOL_UP)->Enable();
691  FindWindow(ID_TOOL_DOWN)->Enable();
692  FindWindow(ID_TOOL_REMOVE)->Enable();
693  event.Skip();
694 }
695 
696 
697 /**
698  * Disables and enables 'Insert' button in the 'Toolbar' page
699  *
700  * If a command is selected, button is enabled. If no command is selected
701  * the button is disabled.
702  *
703  * @param event ListEvent, which may have changed the selection.
704  */
705 void
707  if (commandList_->GetSelectedItemCount() != 1) {
708  FindWindow(ID_TOOL_INSERT)->Disable();
709  return;
710  }
711  FindWindow(ID_TOOL_INSERT)->Enable();
712  event.Skip();
713 }
714 
715 
716 
717 
718 /**
719  * Validates input in the controls, and updates the options.
720  */
721 void
722 OptionsDialog::onOK(wxCommandEvent&) {
723 
724  if (!Validate()) {
725  return;
726  }
727 
728  if (!TransferDataFromWindow()) {
729  return;
730  }
731 
732  writeOptions();
733 
734  EndModal(wxID_OK);
735 }
736 
737 
738 /**
739  * Opens the help for the dialog from the user manual.
740  */
741 void
742 OptionsDialog::onHelp(wxCommandEvent&) {
743 }
744 
745 
746 /**
747  * Adds a new tab to the options dialog.
748  *
749  * This function can be used to add tabs for modifying application specific
750  * options.
751  *
752  * @param page Tab to add.
753  * @param title Title of the tab.
754  */
755 void
756 OptionsDialog::addPage(wxPanel* page, const wxString& title) {
757  page->Reparent(notebook_);
758  notebook_->InsertPage(0, page, title, true);
759 }
760 
761 /**
762  * Creates the dialog contents.
763  *
764  * This function was initially generated by wxDesigner.
765  *
766  * @return Main sizer of the created contents.
767  * @param parent The dialog window.
768  * @param call_fit If true, fits the contents inside the dialog.
769  * @param set_sizer If true, sets the main sizer as dialog contents.
770  */
771 wxSizer*
773  wxWindow *parent, bool call_fit, bool set_sizer) {
774 
775  wxFlexGridSizer *item0 = new wxFlexGridSizer( 1, 0, 0 );
776  item0->AddGrowableCol( 0 );
777  item0->AddGrowableRow( 0 );
778 
779  wxNotebook *item2 = new wxNotebook( parent, ID_NOTEBOOK, wxDefaultPosition, wxSize(570,-1), 0 );
780 #if !wxCHECK_VERSION(2,5,2)
781  wxNotebookSizer *item1 = new wxNotebookSizer( item2 );
782 #else
783  wxWindow *item1 = item2;
784 #endif
785 
786 #ifdef KB_SC_EDITING
787  wxPanel *item4 = new wxPanel( item2, -1 );
788  OptionsDialog::createKBShortcutPage( item4, true, true );
789  item2->AddPage( item4, wxT("Keyboard Shortcuts") );
790 #endif
791 
792  wxPanel *item5 = new wxPanel( item2, -1 );
793  OptionsDialog::createToolbarPage( item5, true, true );
794  item2->AddPage( item5, wxT("Toolbar") );
795 
796  item0->Add( item1, 0, wxGROW|wxALL, 5 );
797 
798  wxGridSizer *item6 = new wxGridSizer( 2, 0, 0 );
799 
800  wxButton *item7 = new wxButton( parent, ID_HELP, wxT("&Help..."), wxDefaultPosition, wxDefaultSize, 0 );
801  item6->Add( item7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
802 
803  wxBoxSizer *item8 = new wxBoxSizer( wxHORIZONTAL );
804 
805  wxButton *item9 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
806  item8->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
807 
808  wxButton *item10 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
809  item8->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
810 
811  item6->Add( item8, 0, wxALL, 5 );
812 
813  item0->Add( item6, 0, wxGROW|wxLEFT|wxRIGHT, 5 );
814 
815  if (set_sizer)
816  {
817  parent->SetSizer( item0 );
818  if (call_fit)
819  item0->SetSizeHints( parent );
820  }
821 
822  return item0;
823 }
824 
825 
826 /**
827  * Creates the 'Keyboard Shotcut' page for the dialog.
828  *
829  * This function was initially generated by wxDesigner.
830  * @return Main sizer of the created contents.
831  * @param parent The dialog window.
832  * @param call_fit If true, fits the contents inside the dialog.
833  * @param set_sizer If true, sets the main sizer as dialog contents.
834  */
835 wxSizer*
837  wxWindow *parent, bool call_fit, bool set_sizer) {
838 
839  wxFlexGridSizer *item0 = new wxFlexGridSizer( 1, 0, 0 );
840  item0->AddGrowableCol( 0 );
841  item0->AddGrowableRow( 0 );
842 
843  wxListCtrl *item1 = new wxListCtrl( parent, ID_KB_SC_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxSUNKEN_BORDER );
844  item0->Add( item1, 0, wxGROW|wxALL, 5 );
845 
846  wxBoxSizer *item2 = new wxBoxSizer( wxHORIZONTAL );
847 
848  wxButton *item3 = new wxButton( parent, ID_EDIT_KB_SC, wxT("Edit"), wxDefaultPosition, wxDefaultSize, 0 );
849  item2->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
850 
851  wxButton *item4 = new wxButton( parent, ID_DELETE_KB_SC, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
852  item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
853 
854  item0->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
855 
856  if (set_sizer) {
857  parent->SetSizer( item0 );
858  if (call_fit)
859  item0->SetSizeHints( parent );
860  }
861 
862  return item0;
863 }
864 
865 
866 /**
867  * Creates the 'Toolbar' page for the dialog.
868  *
869  * This function was generated by wxDesigner.
870  *
871  * @return Main sizer of the created contents.
872  * @param parent The dialog window.
873  * @param call_fit If true, fits the contents inside the dialog.
874  * @param set_sizer If true, sets the main sizer as dialog contents.
875  */
876 wxSizer*
878  wxWindow *parent, bool call_fit, bool set_sizer) {
879 
880  wxFlexGridSizer *item0 = new wxFlexGridSizer( 1, 0, 0 );
881  item0->AddGrowableCol( 0 );
882  item0->AddGrowableRow( 0 );
883 
884  wxFlexGridSizer *item1 = new wxFlexGridSizer( 3, 0, 0 );
885  item1->AddGrowableCol( 0 );
886  item1->AddGrowableCol( 2 );
887  item1->AddGrowableRow( 0 );
888 
889  wxFlexGridSizer *item2 = new wxFlexGridSizer( 1, 0, 0 );
890  item2->AddGrowableCol( 0 );
891  item2->AddGrowableRow( 0 );
892 
893  wxListCtrl *item3 = new wxListCtrl( parent, ID_TOOLBAR_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
894  item2->Add( item3, 0, wxGROW|wxALL, 5 );
895 
896  wxBoxSizer *item4 = new wxBoxSizer( wxHORIZONTAL );
897 
898  wxButton *item5 = new wxButton( parent, ID_TOOL_UP, wxT("&Up"), wxDefaultPosition, wxSize(50,-1), 0 );
899  item4->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
900 
901  wxButton *item6 = new wxButton( parent, ID_TOOL_DOWN, wxT("&Down"), wxDefaultPosition, wxSize(50,-1), 0 );
902  item4->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
903 
904  item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
905 
906  item1->Add( item2, 0, wxGROW|wxALL, 5 );
907 
908  wxBoxSizer *item7 = new wxBoxSizer( wxVERTICAL );
909 
910  wxButton *item8 = new wxButton( parent, ID_TOOL_INSERT, wxT("&Insert"), wxDefaultPosition, wxDefaultSize, 0 );
911  item7->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
912 
913  wxButton *item9 = new wxButton( parent, ID_TOOL_REMOVE, wxT("&Remove"), wxDefaultPosition, wxDefaultSize, 0 );
914  item7->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
915 
916  item1->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
917 
918  wxFlexGridSizer *item10 = new wxFlexGridSizer( 1, 0, 0 );
919  item10->AddGrowableCol( 0 );
920  item10->AddGrowableRow( 0 );
921 
922  wxListCtrl *item11 = new wxListCtrl( parent, ID_COMMAND_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
923  item10->Add( item11, 0, wxGROW|wxALL, 5 );
924 
925  item1->Add( item10, 0, wxGROW|wxALL, 5 );
926 
927  item0->Add( item1, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5 );
928 
929  wxBoxSizer *item12 = new wxBoxSizer( wxHORIZONTAL );
930 
931  wxStaticText *item13 = new wxStaticText( parent, ID_LABEL_TOOLBAR_CONTENTS, wxT("Contents:"), wxDefaultPosition, wxDefaultSize, 0 );
932  item12->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
933 
934  wxString *strs14 = (wxString*) NULL;
935  wxChoice *item14 = new wxChoice( parent, ID_TOOLBAR_CONTENTS, wxDefaultPosition, wxSize(150,-1), 0, strs14, 0 );
936  item12->Add( item14, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
937 
938  item0->Add( item12, 0, wxALIGN_CENTER|wxALL, 5 );
939 
940  if (set_sizer)
941  {
942  parent->SetSizer( item0 );
943  if (call_fit)
944  item0->SetSizeHints( parent );
945  }
946 
947  return item0;
948 }
OptionsDialog::shortcutList_
wxListCtrl * shortcutList_
Keyboard shortcut list control.
Definition: OptionsDialog.hh:124
ToolbarButton.hh
WxConversion::toWxString
static wxString toWxString(const std::string &source)
ToolbarButton::action
std::string action() const
Definition: ToolbarButton.cc:90
OptionsDialog::ID_TOOLBAR_LIST
@ ID_TOOLBAR_LIST
Definition: OptionsDialog.hh:148
EVT_LIST_ITEM_ACTIVATED
FUImplementationDialog::onAddExternalPort FUImplementationDialog::onDeleteExternalPort FUImplementationDialog::onArchPortSelection FUImplementationDialog::onArchPortActivation FUImplementationDialog::onExternalPortActivation FUImplementationDialog::onParameterSelection EVT_LIST_ITEM_ACTIVATED(ID_PARAMETER_LIST, FUImplementationDialog::onParameterActivation) EVT_LIST_ITEM_DESELECTED(ID_PARAMETER_LIST
CommandRegistry.hh
GUIOptions::addToolbarButton
void addToolbarButton(ToolbarButton *button)
Definition: GUIOptions.cc:292
OptionsDialog::initialize
void initialize()
Definition: OptionsDialog.cc:156
OptionsDialog.hh
OptionsDialog::writeOptions
virtual void writeOptions()
Definition: OptionsDialog.cc:286
OptionsDialog::ID_TOOL_REMOVE
@ ID_TOOL_REMOVE
Definition: OptionsDialog.hh:152
OptionsDialog::ID_EDIT_KB_SC
@ ID_EDIT_KB_SC
Definition: OptionsDialog.hh:146
OptionsDialog::onHelp
void onHelp(wxCommandEvent &event)
Definition: OptionsDialog.cc:742
OptionsDialog::Shortcut
Definition: OptionsDialog.hh:111
GUIOptions::ICON
@ ICON
Buttons contains only icon.
Definition: GUIOptions.hh:66
GUIOptions.hh
OptionsDialog::readCommands
void readCommands()
Definition: OptionsDialog.cc:351
GUIOptions::deleteSeparator
void deleteSeparator(int position)
Definition: GUIOptions.cc:358
ToolbarButton
Definition: ToolbarButton.hh:48
WidgetTools.hh
OptionsDialog::AVAILABLE_COMMANDS_COLUMN_TITLE
static const wxString AVAILABLE_COMMANDS_COLUMN_TITLE
Title of the toolbar tab available commands list.
Definition: OptionsDialog.hh:166
OptionsDialog::SHORTCUT_COLUMN_TITLE
static const wxString SHORTCUT_COLUMN_TITLE
Title of the keyboard shortcut list shortcut column.
Definition: OptionsDialog.hh:162
GUICommand::name
std::string name() const
Definition: GUICommand.cc:99
OptionsDialog
Definition: OptionsDialog.hh:60
FindWindow
Definition: FindWindow.hh:49
GUIOptions::nextSeparator
int nextSeparator() const
Definition: GUIOptions.cc:485
OptionsDialog::TransferDataToWindow
virtual bool TransferDataToWindow()
Definition: OptionsDialog.cc:370
GUIOptions::TOOLBAR_SEPARATOR
static const std::string TOOLBAR_SEPARATOR
Toolbar separator name.
Definition: GUIOptions.hh:127
Conversion::toString
static std::string toString(const T &source)
OptionsDialog::commandRegistry_
CommandRegistry & commandRegistry_
Command registry containing available commands for shortcuts.
Definition: OptionsDialog.hh:138
GUICommand.hh
GUIOptions::BOTH
@ BOTH
Buttons contains text and icon.
Definition: GUIOptions.hh:67
assert
#define assert(condition)
Definition: Application.hh:86
OptionsDialog::DELETE_BUTTON_LABEL
static const wxString DELETE_BUTTON_LABEL
Label for delete-button.
Definition: OptionsDialog.hh:177
GUICommand
Definition: GUICommand.hh:43
OptionsDialog::ID_KB_SC_LIST
@ ID_KB_SC_LIST
Definition: OptionsDialog.hh:145
OptionsDialog::toolbar_
std::vector< std::string > toolbar_
Toolbar buttons and separators.
Definition: OptionsDialog.hh:135
KeyboardShortcutDialog
Definition: KeyboardShortcutDialog.hh:44
ErrorDialog
Definition: ErrorDialog.hh:42
OptionsDialog::Shortcut::name
std::string name
Name of the command.
Definition: OptionsDialog.hh:112
ErrorDialog.hh
OptionsDialog::CONTENTS_BOTH
static const wxString CONTENTS_BOTH
Text for the toolbar contents choicer icon&text mode item.
Definition: OptionsDialog.hh:170
Conversion.hh
GUIOptions::toolbarLayout
ToolbarLayout toolbarLayout() const
Definition: GUIOptions.cc:205
dummy
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
OptionsDialog::onMoveTool
void onMoveTool(wxCommandEvent &event)
Definition: OptionsDialog.cc:585
OptionsDialog::createToolbarPage
wxSizer * createToolbarPage(wxWindow *parent, bool callFit, bool set_sizer)
Definition: OptionsDialog.cc:877
OptionsDialog::notebook_
wxNotebook * notebook_
Notebook containing dialog pages.
Definition: OptionsDialog.hh:75
GUIOptions::firstShortcut
KeyboardShortcut * firstShortcut() const
Definition: GUIOptions.cc:397
CommandRegistry
Definition: CommandRegistry.hh:47
ToolbarButton::slot
int slot() const
Definition: ToolbarButton.cc:101
GUIOptions::addSeparator
void addSeparator(int position)
Definition: GUIOptions.cc:305
OptionsDialog::ID_NOTEBOOK
@ ID_NOTEBOOK
Definition: OptionsDialog.hh:142
OptionsDialog::onCommandSelection
void onCommandSelection(wxListEvent &event)
Definition: OptionsDialog.cc:706
OptionsDialog::addPage
void addPage(wxPanel *page, const wxString &title)
Definition: OptionsDialog.cc:756
KeyboardShortcut::action
std::string action() const
Definition: KeyboardShortcut.cc:137
OptionsDialog::ID_TOOLBAR_CONTENTS
@ ID_TOOLBAR_CONTENTS
Definition: OptionsDialog.hh:154
GUIOptions::TEXT
@ TEXT
Buttons contains only text.
Definition: GUIOptions.hh:65
OptionsDialog::onRemoveTool
void onRemoveTool(wxCommandEvent &event)
Definition: OptionsDialog.cc:566
OptionsDialog::ID_DELETE_KB_SC
@ ID_DELETE_KB_SC
Definition: OptionsDialog.hh:147
GUIOptions::firstToolbarButton
ToolbarButton * firstToolbarButton() const
Definition: GUIOptions.cc:432
OptionsDialog::onShortcutSelection
void onShortcutSelection(wxListEvent &event)
Definition: OptionsDialog.cc:643
GUIOptions::addKeyboardShortcut
void addKeyboardShortcut(KeyboardShortcut *shortcut)
Definition: GUIOptions.cc:280
OptionsDialog::onToolbarSelection
void onToolbarSelection(wxListEvent &event)
Definition: OptionsDialog.cc:683
OptionsDialog::onOK
void onOK(wxCommandEvent &event)
Definition: OptionsDialog.cc:722
OptionsDialog::onEditShortcut
void onEditShortcut(wxCommandEvent &event)
Definition: OptionsDialog.cc:502
GUIOptions::setToolbarLayout
void setToolbarLayout(ToolbarLayout layout)
Definition: GUIOptions.cc:268
OptionsDialog::TOOLBAR_BUTTONS_COLUMN_TITLE
static const wxString TOOLBAR_BUTTONS_COLUMN_TITLE
Title of the toolbar tab toolbar button list.
Definition: OptionsDialog.hh:164
EVT_LIST_ITEM_SELECTED
FUImplementationDialog::onAddExternalPort FUImplementationDialog::onDeleteExternalPort FUImplementationDialog::onArchPortSelection FUImplementationDialog::onArchPortActivation EVT_LIST_ITEM_SELECTED(ID_EXTERNAL_PORT_LIST, FUImplementationDialog::onExternalPortSelection) EVT_LIST_ITEM_ACTIVATED(ID_EXTERNAL_PORT_LIST
CommandRegistry::nextCommand
GUICommand * nextCommand()
Definition: CommandRegistry.cc:120
OptionsDialog::onInsertTool
void onInsertTool(wxCommandEvent &event)
Definition: OptionsDialog.cc:548
GUITextGenerator.hh
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
KeyboardShortcut
Definition: KeyboardShortcut.hh:50
GUIOptions
Definition: GUIOptions.hh:58
OptionsDialog::EDIT_BUTTON_LABEL
static const wxString EDIT_BUTTON_LABEL
Label for Edit-button.
Definition: OptionsDialog.hh:175
OptionsDialog::onActivateShortcut
void onActivateShortcut(wxListEvent &event)
Definition: OptionsDialog.cc:474
OptionsDialog::ID_LABEL_TOOLBAR_CONTENTS
@ ID_LABEL_TOOLBAR_CONTENTS
Definition: OptionsDialog.hh:156
GUIOptions::nextToolbarButton
ToolbarButton * nextToolbarButton() const
Definition: GUIOptions.cc:449
KeyboardShortcutDialog.hh
GUIOptions::nextShortcut
KeyboardShortcut * nextShortcut() const
Definition: GUIOptions.cc:414
OptionsDialog::CONTENTS_TEXT
static const wxString CONTENTS_TEXT
Text for the toolbar contents choicer text-mode item.
Definition: OptionsDialog.hh:172
OptionsDialog::ID_TOOL_DOWN
@ ID_TOOL_DOWN
Definition: OptionsDialog.hh:149
GUIOptions::deleteKeyboardShortcut
void deleteKeyboardShortcut(KeyboardShortcut *shortcut)
Definition: GUIOptions.cc:317
EVT_LIST_ITEM_DESELECTED
FUImplementationDialog::onAddExternalPort FUImplementationDialog::onDeleteExternalPort FUImplementationDialog::onArchPortSelection EVT_LIST_ITEM_DESELECTED(ID_ARCH_PORT_LIST, FUImplementationDialog::onArchPortSelection) EVT_LIST_ITEM_ACTIVATED(ID_ARCH_PORT_LIST
EVT_BUTTON
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
OptionsDialog::readOptions
virtual void readOptions()
Definition: OptionsDialog.cc:208
GUIOptions::firstSeparator
int firstSeparator() const
Definition: GUIOptions.cc:468
OptionsDialog::onShortcutRightClick
void onShortcutRightClick(wxListEvent &event)
Definition: OptionsDialog.cc:661
OptionsDialog::COMMAND_COLUMN_TITLE
static const wxString COMMAND_COLUMN_TITLE
Title of the keyboard shortcut list command name column.
Definition: OptionsDialog.hh:160
OptionsDialog::toolbarList_
wxListCtrl * toolbarList_
Toolbar buttons list control.
Definition: OptionsDialog.hh:126
OptionsDialog::createKBShortcutPage
wxSizer * createKBShortcutPage(wxWindow *parent, bool callFit, bool set_sizer)
Definition: OptionsDialog.cc:836
OptionsDialog::shortcuts_
std::vector< Shortcut * > shortcuts_
Keyboard shortcuts.
Definition: OptionsDialog.hh:133
OptionsDialog::~OptionsDialog
virtual ~OptionsDialog()
Definition: OptionsDialog.cc:140
OptionsDialog::selectedShortcut
Shortcut * selectedShortcut()
Definition: OptionsDialog.cc:486
WxConversion.hh
GUICommand::id
virtual int id() const =0
CommandRegistry::firstCommand
GUICommand * firstCommand()
Definition: CommandRegistry.cc:104
OptionsDialog::Shortcut::shortcut
KeyboardShortcut * shortcut
A keyboard shortcut.
Definition: OptionsDialog.hh:114
OptionsDialog::createContents
virtual wxSizer * createContents(wxWindow *parent, bool callFit, bool set_sizer)
Definition: OptionsDialog.cc:772
OptionsDialog::options_
GUIOptions & options_
current editor options
Definition: OptionsDialog.hh:122
OptionsDialog::ID_TOOL_UP
@ ID_TOOL_UP
Definition: OptionsDialog.hh:150
OptionsDialog::commandList_
wxListCtrl * commandList_
List control for commands not in the toolbar.
Definition: OptionsDialog.hh:128
GUIOptions::deleteToolbarButton
void deleteToolbarButton(ToolbarButton *button)
Definition: GUIOptions.cc:337
WxConversion::toString
static std::string toString(const wxString &source)
OptionsDialog::onDeleteShortcut
void onDeleteShortcut(wxCommandEvent &event)
Definition: OptionsDialog.cc:454
OptionsDialog::ID_HELP
@ ID_HELP
Definition: OptionsDialog.hh:143
OptionsDialog::Shortcut::id
int id
ID of the command.
Definition: OptionsDialog.hh:113
OptionsDialog::ID_TOOL_INSERT
@ ID_TOOL_INSERT
Definition: OptionsDialog.hh:151
OptionsDialog::ID_COMMAND_LIST
@ ID_COMMAND_LIST
Definition: OptionsDialog.hh:153
END_EVENT_TABLE
END_EVENT_TABLE() using namespace IDF
OptionsDialog::CONTENTS_ICONS
static const wxString CONTENTS_ICONS
Text fot the toolbar contents choicer icon-mode item.
Definition: OptionsDialog.hh:168