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>
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) {
131 SetMinSize(wxSize(420, 300));
133 notebook_ =
dynamic_cast<wxNotebook*
>(
FindWindow(ID_NOTEBOOK));
143 vector<Shortcut*>::iterator i =
shortcuts_.begin();
166 wxListCtrl* shortcutList =
168 shortcutList->InsertColumn(
174 wxListCtrl* toolbarList =
176 toolbarList->InsertColumn(
180 wxListCtrl* commandList =
182 commandList->InsertColumn(
194 wxChoice* contentsChoicer =
211 wxChoice* contentsChoice =
227 while (shortcut != NULL) {
231 vector<Shortcut*>::iterator i =
shortcuts_.begin();
233 if ((*i)->name == shortcut->
action()) {
237 if (listItem == NULL) {
238 wxString message = _T(
"Unknown command in options:\n");
259 while (tool != NULL) {
260 if (tool->
slot() == slot) {
270 while (separator != -1) {
271 if (separator == slot) {
289 wxChoice* contentsChoice =
294 }
else if (contentsChoice->GetStringSelection() ==
CONTENTS_ICONS) {
296 }
else if (contentsChoice->GetStringSelection() ==
CONTENTS_BOTH) {
321 vector<Shortcut*>::iterator i =
shortcuts_.begin();
323 if ((*i)->shortcut != NULL) {
331 vector<string>::iterator iter =
toolbar_.begin();
332 for (; iter !=
toolbar_.end(); iter++) {
353 while (command != NULL) {
355 shortcut->
id = command->
id();
375 vector<Shortcut*>::iterator i =
shortcuts_.begin();
384 if ((*i)->shortcut != NULL) {
389 if ((*i)->shortcut->key() > 32 && (*i)->shortcut->key() < 127) {
392 }
else if ((*i)->shortcut->key() == 127) {
395 }
else if ((*i)->shortcut->fKey() != 0) {
402 if ((*i)->shortcut->alt()) {
403 key.Prepend(_T(
"ALT - "));
405 if ((*i)->shortcut->ctrl()) {
406 key.Prepend(_T(
"CTRL - "));
416 vector<string>::iterator iter =
toolbar_.begin();
417 for (; iter !=
toolbar_.end(); iter++) {
434 for (; iter !=
toolbar_.end(); iter++) {
435 if ((*i)->name == (*iter)) {
455 vector<Shortcut*>::iterator iter =
shortcuts_.begin();
457 if (
shortcutList_->GetItemState(i, wxLIST_STATE_SELECTED) != 0) {
459 delete (*iter)->shortcut;
460 (*iter)->shortcut = NULL;
475 wxCommandEvent
dummy;
487 vector<Shortcut*>::iterator iter =
shortcuts_.begin();
489 if (
shortcutList_->GetItemState(i, wxLIST_STATE_SELECTED) != 0) {
504 bool newShortcut =
false;
507 if (selected == NULL) {
513 if (shortcut == NULL) {
516 selected->
name, 0,
false,
false,
char(0));
520 if (dialog.ShowModal() == wxID_OK) {
522 vector<Shortcut*>::iterator di =
shortcuts_.begin();
524 if ((*di)->name == selected->
name) {
525 (*di)->shortcut = shortcut;
526 }
else if (((*di)->shortcut != NULL) &&
527 ((*di)->shortcut->equals(*shortcut))) {
530 delete (*di)->shortcut;
531 (*di)->shortcut = NULL;
536 }
else if (newShortcut) {
550 for (
int i = 0; i <
commandList_->GetItemCount(); i++) {
551 if (
commandList_->GetItemState(i, wxLIST_STATE_SELECTED) != 0) {
567 vector<string>::iterator iter =
toolbar_.begin();
568 for (
int i = 0; i <
toolbarList_->GetItemCount(); i++) {
570 if (
toolbarList_->GetItemState(i, wxLIST_STATE_SELECTED) != 0) {
589 for (
int i = 0; i <
toolbarList_->GetItemCount(); i++) {
590 if (
toolbarList_->GetItemState(i, wxLIST_STATE_SELECTED) != 0) {
603 string above =
toolbar_[selected-1];
610 if (selected ==
int(
toolbar_.size())-1) {
614 string below =
toolbar_[selected+1];
623 setItem = selected - 1;
625 setItem = selected + 1;
628 toolbarList_->SetItemState(setItem, wxLIST_STATE_SELECTED,
629 wxLIST_STATE_SELECTED);
663 shortcutList_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
664 wxLIST_STATE_SELECTED);
666 wxMenu* contextMenu =
new wxMenu();
728 if (!TransferDataFromWindow()) {
758 notebook_->InsertPage(0, page, title,
true);
773 wxWindow *parent,
bool call_fit,
bool set_sizer) {
775 wxFlexGridSizer *item0 =
new wxFlexGridSizer( 1, 0, 0 );
776 item0->AddGrowableCol( 0 );
777 item0->AddGrowableRow( 0 );
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 );
783 wxWindow *item1 = item2;
787 wxPanel *item4 =
new wxPanel( item2, -1 );
789 item2->AddPage( item4, wxT(
"Keyboard Shortcuts") );
792 wxPanel *item5 =
new wxPanel( item2, -1 );
794 item2->AddPage( item5, wxT(
"Toolbar") );
796 item0->Add( item1, 0, wxGROW|wxALL, 5 );
798 wxGridSizer *item6 =
new wxGridSizer( 2, 0, 0 );
800 wxButton *item7 =
new wxButton( parent,
ID_HELP, wxT(
"&Help..."), wxDefaultPosition, wxDefaultSize, 0 );
801 item6->Add( item7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
803 wxBoxSizer *item8 =
new wxBoxSizer( wxHORIZONTAL );
805 wxButton *item9 =
new wxButton( parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
806 item8->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
808 wxButton *item10 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
809 item8->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
811 item6->Add( item8, 0, wxALL, 5 );
813 item0->Add( item6, 0, wxGROW|wxLEFT|wxRIGHT, 5 );
817 parent->SetSizer( item0 );
819 item0->SetSizeHints( parent );
837 wxWindow *parent,
bool call_fit,
bool set_sizer) {
839 wxFlexGridSizer *item0 =
new wxFlexGridSizer( 1, 0, 0 );
840 item0->AddGrowableCol( 0 );
841 item0->AddGrowableRow( 0 );
843 wxListCtrl *item1 =
new wxListCtrl( parent,
ID_KB_SC_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxSUNKEN_BORDER );
844 item0->Add( item1, 0, wxGROW|wxALL, 5 );
846 wxBoxSizer *item2 =
new wxBoxSizer( wxHORIZONTAL );
848 wxButton *item3 =
new wxButton( parent,
ID_EDIT_KB_SC, wxT(
"Edit"), wxDefaultPosition, wxDefaultSize, 0 );
849 item2->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
851 wxButton *item4 =
new wxButton( parent,
ID_DELETE_KB_SC, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
852 item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
854 item0->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
857 parent->SetSizer( item0 );
859 item0->SetSizeHints( parent );
878 wxWindow *parent,
bool call_fit,
bool set_sizer) {
880 wxFlexGridSizer *item0 =
new wxFlexGridSizer( 1, 0, 0 );
881 item0->AddGrowableCol( 0 );
882 item0->AddGrowableRow( 0 );
884 wxFlexGridSizer *item1 =
new wxFlexGridSizer( 3, 0, 0 );
885 item1->AddGrowableCol( 0 );
886 item1->AddGrowableCol( 2 );
887 item1->AddGrowableRow( 0 );
889 wxFlexGridSizer *item2 =
new wxFlexGridSizer( 1, 0, 0 );
890 item2->AddGrowableCol( 0 );
891 item2->AddGrowableRow( 0 );
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 );
896 wxBoxSizer *item4 =
new wxBoxSizer( wxHORIZONTAL );
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 );
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 );
904 item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
906 item1->Add( item2, 0, wxGROW|wxALL, 5 );
908 wxBoxSizer *item7 =
new wxBoxSizer( wxVERTICAL );
910 wxButton *item8 =
new wxButton( parent,
ID_TOOL_INSERT, wxT(
"&Insert"), wxDefaultPosition, wxDefaultSize, 0 );
911 item7->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
913 wxButton *item9 =
new wxButton( parent,
ID_TOOL_REMOVE, wxT(
"&Remove"), wxDefaultPosition, wxDefaultSize, 0 );
914 item7->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
916 item1->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
918 wxFlexGridSizer *item10 =
new wxFlexGridSizer( 1, 0, 0 );
919 item10->AddGrowableCol( 0 );
920 item10->AddGrowableRow( 0 );
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 );
925 item1->Add( item10, 0, wxGROW|wxALL, 5 );
927 item0->Add( item1, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5 );
929 wxBoxSizer *item12 =
new wxBoxSizer( wxHORIZONTAL );
931 wxStaticText *item13 =
new wxStaticText( parent,
ID_LABEL_TOOLBAR_CONTENTS, wxT(
"Contents:"), wxDefaultPosition, wxDefaultSize, 0 );
932 item12->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
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 );
938 item0->Add( item12, 0, wxALIGN_CENTER|wxALL, 5 );
942 parent->SetSizer( item0 );
944 item0->SetSizeHints( parent );