OpenASIP 2.2
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
OptionsDialog Class Reference

#include <OptionsDialog.hh>

Inheritance diagram for OptionsDialog:
Inheritance graph
Collaboration diagram for OptionsDialog:
Collaboration graph

Classes

struct  Shortcut
 

Public Member Functions

 OptionsDialog (wxWindow *parent, GUIOptions &options, CommandRegistry &commandRegisry)
 
virtual ~OptionsDialog ()
 

Protected Member Functions

void addPage (wxPanel *page, const wxString &title)
 
virtual void readOptions ()
 
virtual void writeOptions ()
 

Protected Attributes

wxNotebook * notebook_
 Notebook containing dialog pages.
 

Private Types

enum  {
  ID_NOTEBOOK = 10000 , ID_HELP , ID_BROWSE , ID_KB_SC_LIST ,
  ID_EDIT_KB_SC , ID_DELETE_KB_SC , ID_TOOLBAR_LIST , ID_TOOL_DOWN ,
  ID_TOOL_UP , ID_TOOL_INSERT , ID_TOOL_REMOVE , ID_COMMAND_LIST ,
  ID_TOOLBAR_CONTENTS , ID_TEXT , ID_LABEL_TOOLBAR_CONTENTS
}
 

Private Member Functions

virtual wxSizer * createContents (wxWindow *parent, bool callFit, bool set_sizer)
 
void readCommands ()
 
void initialize ()
 
void onShortcutSelection (wxListEvent &event)
 
void onToolbarSelection (wxListEvent &event)
 
void onCommandSelection (wxListEvent &event)
 
void onDeleteShortcut (wxCommandEvent &event)
 
void onActivateShortcut (wxListEvent &event)
 
void onEditShortcut (wxCommandEvent &event)
 
void onShortcutRightClick (wxListEvent &event)
 
void onInsertTool (wxCommandEvent &event)
 
void onRemoveTool (wxCommandEvent &event)
 
void onMoveTool (wxCommandEvent &event)
 
void onOK (wxCommandEvent &event)
 
void onHelp (wxCommandEvent &event)
 
void setTexts ()
 
virtual bool TransferDataToWindow ()
 
wxSizer * createKBShortcutPage (wxWindow *parent, bool callFit, bool set_sizer)
 
wxSizer * createToolbarPage (wxWindow *parent, bool callFit, bool set_sizer)
 
ShortcutselectedShortcut ()
 

Private Attributes

wxWindow * parent_
 parent window of the dialog
 
GUIOptionsoptions_
 current editor options
 
wxListCtrl * shortcutList_
 Keyboard shortcut list control.
 
wxListCtrl * toolbarList_
 Toolbar buttons list control.
 
wxListCtrl * commandList_
 List control for commands not in the toolbar.
 
int choice_
 
std::vector< Shortcut * > shortcuts_
 Keyboard shortcuts.
 
std::vector< std::string > toolbar_
 Toolbar buttons and separators.
 
CommandRegistrycommandRegistry_
 Command registry containing available commands for shortcuts.
 

Static Private Attributes

static const wxString COMMAND_COLUMN_TITLE = _T("Command")
 Title of the keyboard shortcut list command name column.
 
static const wxString SHORTCUT_COLUMN_TITLE = _T("Shortcut")
 Title of the keyboard shortcut list shortcut column.
 
static const wxString TOOLBAR_BUTTONS_COLUMN_TITLE = _T("Toolbar")
 Title of the toolbar tab toolbar button list.
 
static const wxString AVAILABLE_COMMANDS_COLUMN_TITLE = _T("Commands")
 Title of the toolbar tab available commands list.
 
static const wxString CONTENTS_ICONS = _T("Icons")
 Text fot the toolbar contents choicer icon-mode item.
 
static const wxString CONTENTS_BOTH = _T("Both")
 Text for the toolbar contents choicer icon&text mode item.
 
static const wxString CONTENTS_TEXT = _T("Text")
 Text for the toolbar contents choicer text-mode item.
 
static const wxString EDIT_BUTTON_LABEL = _T("Edit...")
 Label for Edit-button.
 
static const wxString DELETE_BUTTON_LABEL = _T("Delete")
 Label for delete-button.
 

Detailed Description

Dialog for editing GUIOptions.

This class allows modification of options in the GUIOptions class. If an application uses custom options class derived from the GUIOptions class, this class can be used as a base class for the application specific options dialog. To customize the derived dialog, override readOptions and writeOptions. Controls for modifying the application specific options can be added by creating a wxPanel containing the controls, and adding it to the dialog as a tab using the addPage method.

Definition at line 60 of file OptionsDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_NOTEBOOK 
ID_HELP 
ID_BROWSE 
ID_KB_SC_LIST 
ID_EDIT_KB_SC 
ID_DELETE_KB_SC 
ID_TOOLBAR_LIST 
ID_TOOL_DOWN 
ID_TOOL_UP 
ID_TOOL_INSERT 
ID_TOOL_REMOVE 
ID_COMMAND_LIST 
ID_TOOLBAR_CONTENTS 
ID_TEXT 
ID_LABEL_TOOLBAR_CONTENTS 

Definition at line 141 of file OptionsDialog.hh.

Constructor & Destructor Documentation

◆ OptionsDialog()

OptionsDialog::OptionsDialog ( wxWindow *  parent,
GUIOptions options,
CommandRegistry commandRegistry 
)

The Constructor.

Parameters
parentParent window of the dialog.
optionsOptions to be modified.
commandRegistryCommand registry containing available commands.

Definition at line 118 of file OptionsDialog.cc.

121 :
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}
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
wxListCtrl * commandList_
List control for commands not in the toolbar.
GUIOptions & options_
current editor options
virtual void readOptions()
wxWindow * parent_
parent window of the dialog
wxListCtrl * shortcutList_
Keyboard shortcut list control.
CommandRegistry & commandRegistry_
Command registry containing available commands for shortcuts.
wxNotebook * notebook_
Notebook containing dialog pages.
wxListCtrl * toolbarList_
Toolbar buttons list control.

◆ ~OptionsDialog()

OptionsDialog::~OptionsDialog ( )
virtual

The Destructor.

Definition at line 140 of file OptionsDialog.cc.

140 {
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}
std::vector< Shortcut * > shortcuts_
Keyboard shortcuts.

References shortcuts_.

Member Function Documentation

◆ addPage()

void OptionsDialog::addPage ( wxPanel *  page,
const wxString &  title 
)
protected

Adds a new tab to the options dialog.

This function can be used to add tabs for modifying application specific options.

Parameters
pageTab to add.
titleTitle of the tab.

Definition at line 756 of file OptionsDialog.cc.

756 {
757 page->Reparent(notebook_);
758 notebook_->InsertPage(0, page, title, true);
759}

References notebook_.

◆ createContents()

wxSizer * OptionsDialog::createContents ( wxWindow *  parent,
bool  call_fit,
bool  set_sizer 
)
privatevirtual

Creates the dialog contents.

This function was initially generated by wxDesigner.

Returns
Main sizer of the created contents.
Parameters
parentThe dialog window.
call_fitIf true, fits the contents inside the dialog.
set_sizerIf true, sets the main sizer as dialog contents.

Definition at line 772 of file OptionsDialog.cc.

773 {
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}
wxSizer * createToolbarPage(wxWindow *parent, bool callFit, bool set_sizer)
wxSizer * createKBShortcutPage(wxWindow *parent, bool callFit, bool set_sizer)

References createKBShortcutPage(), createToolbarPage(), ID_HELP, and ID_NOTEBOOK.

Referenced by initialize().

Here is the call graph for this function:

◆ createKBShortcutPage()

wxSizer * OptionsDialog::createKBShortcutPage ( wxWindow *  parent,
bool  call_fit,
bool  set_sizer 
)
private

Creates the 'Keyboard Shotcut' page for the dialog.

This function was initially generated by wxDesigner.

Returns
Main sizer of the created contents.
Parameters
parentThe dialog window.
call_fitIf true, fits the contents inside the dialog.
set_sizerIf true, sets the main sizer as dialog contents.

Definition at line 836 of file OptionsDialog.cc.

837 {
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}

References ID_DELETE_KB_SC, ID_EDIT_KB_SC, and ID_KB_SC_LIST.

Referenced by createContents().

◆ createToolbarPage()

wxSizer * OptionsDialog::createToolbarPage ( wxWindow *  parent,
bool  call_fit,
bool  set_sizer 
)
private

Creates the 'Toolbar' page for the dialog.

This function was generated by wxDesigner.

Returns
Main sizer of the created contents.
Parameters
parentThe dialog window.
call_fitIf true, fits the contents inside the dialog.
set_sizerIf true, sets the main sizer as dialog contents.

Definition at line 877 of file OptionsDialog.cc.

878 {
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}

References ID_COMMAND_LIST, ID_LABEL_TOOLBAR_CONTENTS, ID_TOOL_DOWN, ID_TOOL_INSERT, ID_TOOL_REMOVE, ID_TOOL_UP, ID_TOOLBAR_CONTENTS, and ID_TOOLBAR_LIST.

Referenced by createContents().

◆ initialize()

void OptionsDialog::initialize ( )
private

Initializes the dialog widgets.

Definition at line 156 of file OptionsDialog.cc.

156 {
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}
static const wxString CONTENTS_BOTH
Text for the toolbar contents choicer icon&text mode item.
static const wxString CONTENTS_ICONS
Text fot the toolbar contents choicer icon-mode item.
virtual wxSizer * createContents(wxWindow *parent, bool callFit, bool set_sizer)
static const wxString CONTENTS_TEXT
Text for the toolbar contents choicer text-mode item.
static const wxString TOOLBAR_BUTTONS_COLUMN_TITLE
Title of the toolbar tab toolbar button list.
static const wxString AVAILABLE_COMMANDS_COLUMN_TITLE
Title of the toolbar tab available commands list.
static const wxString SHORTCUT_COLUMN_TITLE
Title of the keyboard shortcut list shortcut column.
static const wxString COMMAND_COLUMN_TITLE
Title of the keyboard shortcut list command name column.

References AVAILABLE_COMMANDS_COLUMN_TITLE, COMMAND_COLUMN_TITLE, commandList_, CONTENTS_BOTH, CONTENTS_ICONS, CONTENTS_TEXT, createContents(), ID_COMMAND_LIST, ID_DELETE_KB_SC, ID_EDIT_KB_SC, ID_KB_SC_LIST, ID_TOOL_DOWN, ID_TOOL_INSERT, ID_TOOL_REMOVE, ID_TOOL_UP, ID_TOOLBAR_CONTENTS, ID_TOOLBAR_LIST, SHORTCUT_COLUMN_TITLE, shortcutList_, TOOLBAR_BUTTONS_COLUMN_TITLE, and toolbarList_.

Here is the call graph for this function:

◆ onActivateShortcut()

void OptionsDialog::onActivateShortcut ( wxListEvent &  event)
private

Handles left mouse button double click on the shortcut list.

Definition at line 474 of file OptionsDialog.cc.

474 {
475 wxCommandEvent dummy;
477}
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
void onEditShortcut(wxCommandEvent &event)

References dummy, and onEditShortcut().

Here is the call graph for this function:

◆ onCommandSelection()

void OptionsDialog::onCommandSelection ( wxListEvent &  event)
private

Disables and enables 'Insert' button in the 'Toolbar' page

If a command is selected, button is enabled. If no command is selected the button is disabled.

Parameters
eventListEvent, which may have changed the selection.

Definition at line 706 of file OptionsDialog.cc.

706 {
707 if (commandList_->GetSelectedItemCount() != 1) {
708 FindWindow(ID_TOOL_INSERT)->Disable();
709 return;
710 }
711 FindWindow(ID_TOOL_INSERT)->Enable();
712 event.Skip();
713}

References commandList_, and ID_TOOL_INSERT.

◆ onDeleteShortcut()

void OptionsDialog::onDeleteShortcut ( wxCommandEvent &  event)
private

Removes keyboard shortcut for the selected command.

Definition at line 454 of file OptionsDialog.cc.

454 {
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}
#define assert(condition)
virtual bool TransferDataToWindow()

References assert, shortcutList_, shortcuts_, and TransferDataToWindow().

Here is the call graph for this function:

◆ onEditShortcut()

void OptionsDialog::onEditShortcut ( wxCommandEvent &  event)
private

Prompts for a new keyboard shortcut for the selected command with ShortcutDialog.

Definition at line 502 of file OptionsDialog.cc.

502 {
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}
Shortcut * selectedShortcut()

References OptionsDialog::Shortcut::name, selectedShortcut(), OptionsDialog::Shortcut::shortcut, shortcuts_, and TransferDataToWindow().

Referenced by onActivateShortcut().

Here is the call graph for this function:

◆ onHelp()

void OptionsDialog::onHelp ( wxCommandEvent &  event)
private

Opens the help for the dialog from the user manual.

Definition at line 742 of file OptionsDialog.cc.

742 {
743}

◆ onInsertTool()

void OptionsDialog::onInsertTool ( wxCommandEvent &  event)
private

Adds a toolbar button for the command selected in the command list.

Definition at line 548 of file OptionsDialog.cc.

548 {
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}
std::vector< std::string > toolbar_
Toolbar buttons and separators.
static std::string toString(const wxString &source)

References commandList_, toolbar_, WxConversion::toString(), and TransferDataToWindow().

Here is the call graph for this function:

◆ onMoveTool()

void OptionsDialog::onMoveTool ( wxCommandEvent &  event)
private

Moves selected tool up or down in the toolbar button list.

Definition at line 585 of file OptionsDialog.cc.

585 {
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}

References assert, ID_TOOL_DOWN, ID_TOOL_UP, toolbar_, toolbarList_, and TransferDataToWindow().

Here is the call graph for this function:

◆ onOK()

void OptionsDialog::onOK ( wxCommandEvent &  event)
private

Validates input in the controls, and updates the options.

Definition at line 722 of file OptionsDialog.cc.

722 {
723
724 if (!Validate()) {
725 return;
726 }
727
728 if (!TransferDataFromWindow()) {
729 return;
730 }
731
732 writeOptions();
733
734 EndModal(wxID_OK);
735}
virtual void writeOptions()

References writeOptions().

Here is the call graph for this function:

◆ onRemoveTool()

void OptionsDialog::onRemoveTool ( wxCommandEvent &  event)
private

Removes the selected toolbar button from the toolbar button list.

Definition at line 566 of file OptionsDialog.cc.

566 {
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}

References assert, toolbar_, toolbarList_, and TransferDataToWindow().

Here is the call graph for this function:

◆ onShortcutRightClick()

void OptionsDialog::onShortcutRightClick ( wxListEvent &  event)
private

Opens a pop-up menu when right mouse button was pressed.

Parameters
eventInformation about right mouse click event.

Definition at line 661 of file OptionsDialog.cc.

661 {
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}
static const wxString EDIT_BUTTON_LABEL
Label for Edit-button.
static const wxString DELETE_BUTTON_LABEL
Label for delete-button.

References DELETE_BUTTON_LABEL, EDIT_BUTTON_LABEL, ID_DELETE_KB_SC, ID_EDIT_KB_SC, and shortcutList_.

◆ onShortcutSelection()

void OptionsDialog::onShortcutSelection ( wxListEvent &  event)
private

Disables and enables Edit and Delete buttons under the keyboard shortcut.

If a shortcut is selected, buttons are enabled. If no shortcut is selected the buttons are disabled.

Parameters
eventListEvent, which may have changed the selection.

Definition at line 643 of file OptionsDialog.cc.

643 {
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}

References ID_DELETE_KB_SC, ID_EDIT_KB_SC, and shortcutList_.

◆ onToolbarSelection()

void OptionsDialog::onToolbarSelection ( wxListEvent &  event)
private

Disables and enables Up, Down and Remove buttons in the 'Toolbar' page.

If a toolbar item is selected, buttons are enabled. If no item is selected the buttons are disabled.

Parameters
eventListEvent, which may have changed the selection.

Definition at line 683 of file OptionsDialog.cc.

683 {
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}

References ID_TOOL_DOWN, ID_TOOL_REMOVE, ID_TOOL_UP, and toolbarList_.

◆ readCommands()

void OptionsDialog::readCommands ( )
private

Adds available commands to the keyboard shortcut list and toolbar tool list.

Reads commands fromt the command registry.

Definition at line 351 of file OptionsDialog.cc.

351 {
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}
GUICommand * firstCommand()
GUICommand * nextCommand()
std::string name() const
Definition GUICommand.cc:99
virtual int id() const =0

References commandRegistry_, CommandRegistry::firstCommand(), GUICommand::id(), OptionsDialog::Shortcut::id, GUICommand::name(), OptionsDialog::Shortcut::name, CommandRegistry::nextCommand(), OptionsDialog::Shortcut::shortcut, and shortcuts_.

Here is the call graph for this function:

◆ readOptions()

void OptionsDialog::readOptions ( )
protectedvirtual

Reads the options in options_ to dialog attributes.

Definition at line 208 of file OptionsDialog.cc.

208 {
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 }
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}
ToolbarButton * nextToolbarButton() const
int firstSeparator() const
KeyboardShortcut * firstShortcut() const
KeyboardShortcut * nextShortcut() const
ToolbarLayout toolbarLayout() const
static const std::string TOOLBAR_SEPARATOR
Toolbar separator name.
@ TEXT
Buttons contains only text.
Definition GUIOptions.hh:65
@ BOTH
Buttons contains text and icon.
Definition GUIOptions.hh:67
@ ICON
Buttons contains only icon.
Definition GUIOptions.hh:66
int nextSeparator() const
ToolbarButton * firstToolbarButton() const
std::string action() const
int slot() const
std::string action() const
static wxString toWxString(const std::string &source)

References KeyboardShortcut::action(), ToolbarButton::action(), assert, GUIOptions::BOTH, CONTENTS_BOTH, CONTENTS_ICONS, CONTENTS_TEXT, GUIOptions::firstSeparator(), GUIOptions::firstShortcut(), GUIOptions::firstToolbarButton(), GUIOptions::ICON, ID_TOOLBAR_CONTENTS, GUIOptions::nextSeparator(), GUIOptions::nextShortcut(), GUIOptions::nextToolbarButton(), options_, OptionsDialog::Shortcut::shortcut, shortcuts_, ToolbarButton::slot(), GUIOptions::TEXT, toolbar_, GUIOptions::TOOLBAR_SEPARATOR, GUIOptions::toolbarLayout(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ selectedShortcut()

OptionsDialog::Shortcut * OptionsDialog::selectedShortcut ( )
private

Returns pointer to the shortcut selected in the shortcut list.

Returns
NULL if no shortcut is selected.

Definition at line 486 of file OptionsDialog.cc.

486 {
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}

References shortcutList_, and shortcuts_.

Referenced by onEditShortcut().

◆ setTexts()

void OptionsDialog::setTexts ( )
private

◆ TransferDataToWindow()

bool OptionsDialog::TransferDataToWindow ( )
privatevirtual

Transfers data from dialog attributes to controls in the dialog.

Returns
False if the transfer failed.

Definition at line 370 of file OptionsDialog.cc.

370 {
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}
static std::string toString(const T &source)

References commandList_, shortcutList_, shortcuts_, toolbar_, GUIOptions::TOOLBAR_SEPARATOR, toolbarList_, Conversion::toString(), and WxConversion::toWxString().

Referenced by onDeleteShortcut(), onEditShortcut(), onInsertTool(), onMoveTool(), and onRemoveTool().

Here is the call graph for this function:

◆ writeOptions()

void OptionsDialog::writeOptions ( )
protectedvirtual

Writes the options from dialog attributes to the current options object.

Definition at line 286 of file OptionsDialog.cc.

286 {
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) {
335 } else {
336 ToolbarButton* button = new ToolbarButton(slot, (*iter));
338 }
339 slot++;
340 }
341}
void addKeyboardShortcut(KeyboardShortcut *shortcut)
void deleteSeparator(int position)
void addToolbarButton(ToolbarButton *button)
void addSeparator(int position)
void deleteKeyboardShortcut(KeyboardShortcut *shortcut)
void deleteToolbarButton(ToolbarButton *button)
void setToolbarLayout(ToolbarLayout layout)

References GUIOptions::addKeyboardShortcut(), GUIOptions::addSeparator(), GUIOptions::addToolbarButton(), assert, GUIOptions::BOTH, CONTENTS_BOTH, CONTENTS_ICONS, CONTENTS_TEXT, GUIOptions::deleteKeyboardShortcut(), GUIOptions::deleteSeparator(), GUIOptions::deleteToolbarButton(), GUIOptions::firstSeparator(), GUIOptions::firstShortcut(), GUIOptions::firstToolbarButton(), GUIOptions::ICON, ID_TOOLBAR_CONTENTS, options_, GUIOptions::setToolbarLayout(), shortcuts_, GUIOptions::TEXT, toolbar_, and GUIOptions::TOOLBAR_SEPARATOR.

Referenced by onOK(), and ProDeOptionsDialog::onOK().

Here is the call graph for this function:

Member Data Documentation

◆ AVAILABLE_COMMANDS_COLUMN_TITLE

const wxString OptionsDialog::AVAILABLE_COMMANDS_COLUMN_TITLE = _T("Commands")
staticprivate

Title of the toolbar tab available commands list.

Definition at line 166 of file OptionsDialog.hh.

Referenced by initialize().

◆ choice_

int OptionsDialog::choice_
private

Definition at line 130 of file OptionsDialog.hh.

◆ COMMAND_COLUMN_TITLE

const wxString OptionsDialog::COMMAND_COLUMN_TITLE = _T("Command")
staticprivate

Title of the keyboard shortcut list command name column.

Definition at line 160 of file OptionsDialog.hh.

Referenced by initialize().

◆ commandList_

wxListCtrl* OptionsDialog::commandList_
private

List control for commands not in the toolbar.

Definition at line 128 of file OptionsDialog.hh.

Referenced by initialize(), onCommandSelection(), onInsertTool(), and TransferDataToWindow().

◆ commandRegistry_

CommandRegistry& OptionsDialog::commandRegistry_
private

Command registry containing available commands for shortcuts.

Definition at line 138 of file OptionsDialog.hh.

Referenced by readCommands().

◆ CONTENTS_BOTH

const wxString OptionsDialog::CONTENTS_BOTH = _T("Both")
staticprivate

Text for the toolbar contents choicer icon&text mode item.

Definition at line 170 of file OptionsDialog.hh.

Referenced by initialize(), readOptions(), and writeOptions().

◆ CONTENTS_ICONS

const wxString OptionsDialog::CONTENTS_ICONS = _T("Icons")
staticprivate

Text fot the toolbar contents choicer icon-mode item.

Definition at line 168 of file OptionsDialog.hh.

Referenced by initialize(), readOptions(), and writeOptions().

◆ CONTENTS_TEXT

const wxString OptionsDialog::CONTENTS_TEXT = _T("Text")
staticprivate

Text for the toolbar contents choicer text-mode item.

Definition at line 172 of file OptionsDialog.hh.

Referenced by initialize(), readOptions(), and writeOptions().

◆ DELETE_BUTTON_LABEL

const wxString OptionsDialog::DELETE_BUTTON_LABEL = _T("Delete")
staticprivate

Label for delete-button.

Definition at line 177 of file OptionsDialog.hh.

Referenced by onShortcutRightClick().

◆ EDIT_BUTTON_LABEL

const wxString OptionsDialog::EDIT_BUTTON_LABEL = _T("Edit...")
staticprivate

Label for Edit-button.

Definition at line 175 of file OptionsDialog.hh.

Referenced by onShortcutRightClick().

◆ notebook_

wxNotebook* OptionsDialog::notebook_
protected

Notebook containing dialog pages.

Definition at line 75 of file OptionsDialog.hh.

Referenced by addPage().

◆ options_

GUIOptions& OptionsDialog::options_
private

current editor options

Definition at line 122 of file OptionsDialog.hh.

Referenced by readOptions(), and writeOptions().

◆ parent_

wxWindow* OptionsDialog::parent_
private

parent window of the dialog

Definition at line 120 of file OptionsDialog.hh.

◆ SHORTCUT_COLUMN_TITLE

const wxString OptionsDialog::SHORTCUT_COLUMN_TITLE = _T("Shortcut")
staticprivate

Title of the keyboard shortcut list shortcut column.

Definition at line 162 of file OptionsDialog.hh.

Referenced by initialize().

◆ shortcutList_

wxListCtrl* OptionsDialog::shortcutList_
private

Keyboard shortcut list control.

Definition at line 124 of file OptionsDialog.hh.

Referenced by initialize(), onDeleteShortcut(), onShortcutRightClick(), onShortcutSelection(), selectedShortcut(), and TransferDataToWindow().

◆ shortcuts_

std::vector<Shortcut*> OptionsDialog::shortcuts_
private

◆ toolbar_

std::vector<std::string> OptionsDialog::toolbar_
private

Toolbar buttons and separators.

Definition at line 135 of file OptionsDialog.hh.

Referenced by onInsertTool(), onMoveTool(), onRemoveTool(), readOptions(), TransferDataToWindow(), and writeOptions().

◆ TOOLBAR_BUTTONS_COLUMN_TITLE

const wxString OptionsDialog::TOOLBAR_BUTTONS_COLUMN_TITLE = _T("Toolbar")
staticprivate

Title of the toolbar tab toolbar button list.

Definition at line 164 of file OptionsDialog.hh.

Referenced by initialize().

◆ toolbarList_

wxListCtrl* OptionsDialog::toolbarList_
private

Toolbar buttons list control.

Definition at line 126 of file OptionsDialog.hh.

Referenced by initialize(), onMoveTool(), onRemoveTool(), onToolbarSelection(), and TransferDataToWindow().


The documentation for this class was generated from the following files: