OpenASIP  2.0
OptionsDialog.hh
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.hh
26  *
27  * Declaration 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 #ifndef TTA_OPTIONS_DIALOG_HH
34 #define TTA_OPTIONS_DIALOG_HH
35 
36 #include <string>
37 #include <wx/wx.h>
38 #include <wx/notebook.h>
39 #include <wx/listctrl.h>
40 #include <wx/spinctrl.h>
41 #include <vector>
42 
43 class ToolbarButton;
44 class KeyboardShortcut;
45 class GUIOptions;
46 class wxListCtrl;
47 class CommandRegistry;
48 
49 /**
50  * Dialog for editing GUIOptions.
51  *
52  * This class allows modification of options in the GUIOptions class.
53  * If an application uses custom options class derived from the GUIOptions
54  * class, this class can be used as a base class for the application specific
55  * options dialog. To customize the derived dialog, override readOptions and
56  * writeOptions. Controls for modifying the application specific options can
57  * be added by creating a wxPanel containing the controls, and adding it to
58  * the dialog as a tab using the addPage method.
59  */
60 class OptionsDialog : public wxDialog {
61 public:
63  wxWindow* parent,
65  CommandRegistry& commandRegisry);
66 
67  virtual ~OptionsDialog();
68 
69 protected:
70  void addPage(wxPanel* page, const wxString& title);
71  virtual void readOptions();
72  virtual void writeOptions();
73 
74  /// Notebook containing dialog pages.
75  wxNotebook* notebook_;
76 
77 
78 private:
79 
80  virtual wxSizer* createContents(
81  wxWindow* parent, bool callFit, bool set_sizer);
82 
83  void readCommands();
84  void initialize();
85 
86  void onShortcutSelection(wxListEvent& event);
87  void onToolbarSelection(wxListEvent& event);
88  void onCommandSelection(wxListEvent& event);
89 
90  void onDeleteShortcut(wxCommandEvent& event);
91  void onActivateShortcut(wxListEvent& event);
92  void onEditShortcut(wxCommandEvent& event);
93  void onShortcutRightClick(wxListEvent& event);
94  void onInsertTool(wxCommandEvent& event);
95  void onRemoveTool(wxCommandEvent& event);
96  void onMoveTool(wxCommandEvent& event);
97  void onOK(wxCommandEvent& event);
98  void onHelp(wxCommandEvent& event);
99  void setTexts();
100 
101  virtual bool TransferDataToWindow();
102 
103  wxSizer* createKBShortcutPage(
104  wxWindow* parent, bool callFit, bool set_sizer);
105  wxSizer* createToolbarPage(
106  wxWindow* parent, bool callFit, bool set_sizer);
107 
108  /**
109  * Describes a keyboard shortcut.
110  */
111  struct Shortcut {
112  std::string name; ///< Name of the command.
113  int id; ///< ID of the command.
114  KeyboardShortcut* shortcut; ///< A keyboard shortcut.
115  };
116 
118 
119  /// parent window of the dialog
120  wxWindow* parent_;
121  /// current editor options
123  /// Keyboard shortcut list control.
124  wxListCtrl* shortcutList_;
125  /// Toolbar buttons list control.
126  wxListCtrl* toolbarList_;
127  /// List control for commands not in the toolbar.
128  wxListCtrl* commandList_;
129  // Toolbar contents choicer item variable
130  int choice_;
131 
132  /// Keyboard shortcuts.
133  std::vector<Shortcut*> shortcuts_;
134  /// Toolbar buttons and separators.
135  std::vector<std::string> toolbar_;
136 
137  /// Command registry containing available commands for shortcuts.
139 
140  // control IDs
141  enum {
142  ID_NOTEBOOK = 10000,
157  };
158 
159  /// Title of the keyboard shortcut list command name column.
160  static const wxString COMMAND_COLUMN_TITLE;
161  /// Title of the keyboard shortcut list shortcut column.
162  static const wxString SHORTCUT_COLUMN_TITLE;
163  /// Title of the toolbar tab toolbar button list.
164  static const wxString TOOLBAR_BUTTONS_COLUMN_TITLE;
165  /// Title of the toolbar tab available commands list.
166  static const wxString AVAILABLE_COMMANDS_COLUMN_TITLE;
167  /// Text fot the toolbar contents choicer icon-mode item.
168  static const wxString CONTENTS_ICONS;
169  /// Text for the toolbar contents choicer icon&text mode item.
170  static const wxString CONTENTS_BOTH;
171  /// Text for the toolbar contents choicer text-mode item.
172  static const wxString CONTENTS_TEXT;
173 
174  /// Label for Edit-button.
175  static const wxString EDIT_BUTTON_LABEL;
176  /// Label for delete-button.
177  static const wxString DELETE_BUTTON_LABEL;
178 
179  /// The event table for the controls of the dialog.
180  DECLARE_EVENT_TABLE()
181 };
182 
183 #endif
OptionsDialog::shortcutList_
wxListCtrl * shortcutList_
Keyboard shortcut list control.
Definition: OptionsDialog.hh:124
OptionsDialog::ID_TOOLBAR_LIST
@ ID_TOOLBAR_LIST
Definition: OptionsDialog.hh:148
OptionsDialog::initialize
void initialize()
Definition: OptionsDialog.cc:156
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
OptionsDialog::readCommands
void readCommands()
Definition: OptionsDialog.cc:351
ToolbarButton
Definition: ToolbarButton.hh:48
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
OptionsDialog
Definition: OptionsDialog.hh:60
OptionsDialog::TransferDataToWindow
virtual bool TransferDataToWindow()
Definition: OptionsDialog.cc:370
OptionsDialog::commandRegistry_
CommandRegistry & commandRegistry_
Command registry containing available commands for shortcuts.
Definition: OptionsDialog.hh:138
OptionsDialog::DELETE_BUTTON_LABEL
static const wxString DELETE_BUTTON_LABEL
Label for delete-button.
Definition: OptionsDialog.hh:177
OptionsDialog::OptionsDialog
OptionsDialog(wxWindow *parent, GUIOptions &options, CommandRegistry &commandRegisry)
Definition: OptionsDialog.cc:118
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
OptionsDialog::Shortcut::name
std::string name
Name of the command.
Definition: OptionsDialog.hh:112
OptionsDialog::ID_TEXT
@ ID_TEXT
Definition: OptionsDialog.hh:155
OptionsDialog::CONTENTS_BOTH
static const wxString CONTENTS_BOTH
Text for the toolbar contents choicer icon&text mode item.
Definition: OptionsDialog.hh:170
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
CommandRegistry
Definition: CommandRegistry.hh:47
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
OptionsDialog::ID_TOOLBAR_CONTENTS
@ ID_TOOLBAR_CONTENTS
Definition: OptionsDialog.hh:154
OptionsDialog::onRemoveTool
void onRemoveTool(wxCommandEvent &event)
Definition: OptionsDialog.cc:566
OptionsDialog::ID_DELETE_KB_SC
@ ID_DELETE_KB_SC
Definition: OptionsDialog.hh:147
OptionsDialog::setTexts
void setTexts()
OptionsDialog::onShortcutSelection
void onShortcutSelection(wxListEvent &event)
Definition: OptionsDialog.cc:643
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
OptionsDialog::TOOLBAR_BUTTONS_COLUMN_TITLE
static const wxString TOOLBAR_BUTTONS_COLUMN_TITLE
Title of the toolbar tab toolbar button list.
Definition: OptionsDialog.hh:164
OptionsDialog::onInsertTool
void onInsertTool(wxCommandEvent &event)
Definition: OptionsDialog.cc:548
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
KeyboardShortcut
Definition: KeyboardShortcut.hh:50
GUIOptions
Definition: GUIOptions.hh:58
OptionsDialog::ID_BROWSE
@ ID_BROWSE
Definition: OptionsDialog.hh:144
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
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
OptionsDialog::readOptions
virtual void readOptions()
Definition: OptionsDialog.cc:208
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::parent_
wxWindow * parent_
parent window of the dialog
Definition: OptionsDialog.hh:120
OptionsDialog::~OptionsDialog
virtual ~OptionsDialog()
Definition: OptionsDialog.cc:140
OptionsDialog::selectedShortcut
Shortcut * selectedShortcut()
Definition: OptionsDialog.cc:486
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
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
OptionsDialog::choice_
int choice_
Definition: OptionsDialog.hh:130
OptionsDialog::CONTENTS_ICONS
static const wxString CONTENTS_ICONS
Text fot the toolbar contents choicer icon-mode item.
Definition: OptionsDialog.hh:168