OpenASIP  2.0
GUIOptions.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 GUIOptions.hh
26  *
27  * Declaration of class GUIOptions.
28  *
29  * @author Lasse Laasonen 2003 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_GUI_OPTIONS_HH
34 #define TTA_GUI_OPTIONS_HH
35 
36 #include <string>
37 #include <vector>
38 
39 #include "Serializable.hh"
40 #include "KeyboardShortcut.hh"
41 #include "ToolbarButton.hh"
42 
43 class CommandRegistry;
44 class wxToolBar;
45 class wxWindow;
46 class wxString;
47 
48 /**
49  * Represents the options of a GUI.
50  *
51  * Base class for GUI options. This class provides handling of options common
52  * to all GUIs. If a GUI needs application specific options, specialized
53  * options class can be derived from this class. See design documentation for
54  * details.
55  * This class implements the Serializable interface because the options are
56  * going to be stored in an xml configuration file.
57  */
58 class GUIOptions : public Serializable {
59 public:
60 
61  /**
62  * Layout of the buttons in the toolbar.
63  */
65  TEXT, ///< Buttons contains only text.
66  ICON, ///< Buttons contains only icon.
67  BOTH ///< Buttons contains text and icon.
68  };
69 
70  GUIOptions(std::string name);
71  GUIOptions(const GUIOptions& old);
72  GUIOptions(const ObjectState* state);
73 
74  virtual ~GUIOptions();
75 
76  bool hasFileName() const;
77  std::string fileName() const;
78  void setFileName(const std::string& fileName);
79 
80  virtual void validate() const;
81 
82  virtual void loadState(const ObjectState* state);
83  virtual ObjectState* saveState() const;
84 
85 
86  bool fullScreen() const;
87  int windowWidth() const;
88  int windowHeight() const;
89  int xPosition() const;
90  int yPosition() const;
91  bool toolbarVisibility() const;
93 
94  void setFullScreen(bool fullScreen);
95  void setWindowSize(int width, int height);
96  void setWindowPosition(int x, int y);
97  void setToolbarVisibility(bool visible);
98  void setToolbarLayout(ToolbarLayout layout);
99 
100  void addKeyboardShortcut(KeyboardShortcut* shortcut);
101  void addToolbarButton(ToolbarButton* button);
102  void addSeparator(int position);
103 
105  void deleteToolbarButton(ToolbarButton* button);
106  void deleteSeparator(int position);
107 
108  KeyboardShortcut* keyboardShortcut(const std::string commandName) const;
111 
114 
115  int firstSeparator() const;
116  int nextSeparator() const;
117 
118  void clearModified();
119  bool isModified() const;
120 
121  wxToolBar* createToolbar(
122  wxWindow* parent,
123  CommandRegistry& registry,
124  const wxString& iconsPath);
125 
126  /// Toolbar separator name.
127  static const std::string TOOLBAR_SEPARATOR;
128  /// ObjectState name for the options.
129  static const std::string OSNAME_OPTIONS;
130  /// ObjectState attribute key for full screen feature.
131  static const std::string OSKEY_FULL_SCREEN;
132  /// ObjectState attribute key for window width.
133  static const std::string OSKEY_WINDOW_WIDTH;
134  /// ObjectState attribute key for window height.
135  static const std::string OSKEY_WINDOW_HEIGHT;
136  /// ObjectState attribute key for window x position.
137  static const std::string OSKEY_X_POS;
138  /// ObjectState attribute key for window y position.
139  static const std::string OSKEY_Y_POS;
140  /// ObjectState attribute key for toolbar visibility.
141  static const std::string OSKEY_TOOLBAR_VISIBILITY;
142  /// ObjectState attribute key for toolbar layout.
143  static const std::string OSKEY_TOOLBAR_LAYOUT;
144  /// ObjectState attribute value for text layout.
145  static const std::string OSVALUE_TEXT;
146  /// ObjectState attribute value for icon layout.
147  static const std::string OSVALUE_ICON;
148  /// ObjectState attribute value for text & icon layout.
149  static const std::string OSVALUE_BOTH;
150  /// ObjectState name for separator.
151  static const std::string OSNAME_SEPARATOR;
152  /// ObjectState attribute key for separator position.
153  static const std::string OSKEY_POSITION;
154 
155 protected:
158 
159 private:
160 
161  /// Table for the toolbar separator positions.
162  typedef std::vector<int> SeparatorTable;
163  /// Table for keyboard shortcuts.
164  typedef std::vector<KeyboardShortcut*> KSTable;
165  /// Table for toolbar buttons
166  typedef std::vector<ToolbarButton*> TBTable;
167 
168  /// File name assigned to these options.
169  std::string fileName_;
170  /// If true, the application window will open in full screen mode.
172  /// Default width of the window.
174  /// Default height of the window.
176  /// Default x position of left side of the application window.
178  /// Default y position of the upper side of the application window.
180  /// If true, the toolbar is visible.
182  /// Layout of the toolbar.
184  /// Toolbar separators.
186  /// Keyboard shortcuts.
188  /// Toolbar buttons.
190 
191  /// Iterator used in firstShortcut and nextShortcut functions.
192  mutable KSTable::const_iterator ksIter_;
193  /// Iterator used in firstToolbarButton and nextToolbarButton functions.
194  mutable TBTable::const_iterator tbIter_;
195  /// Iterator used in firstSeparator and nextSeparator functions.
196  mutable SeparatorTable::const_iterator separatorIter_;
197 
198  /// Indicates whether the options are modified or not.
199  bool modified_;
200  /// Name of the options.
201  std::string name_;
202 };
203 
204 #endif
GUIOptions::OSNAME_SEPARATOR
static const std::string OSNAME_SEPARATOR
ObjectState name for separator.
Definition: GUIOptions.hh:151
GUIOptions::OSNAME_OPTIONS
static const std::string OSNAME_OPTIONS
ObjectState name for the options.
Definition: GUIOptions.hh:129
GUIOptions::name_
std::string name_
Name of the options.
Definition: GUIOptions.hh:201
GUIOptions::xPosition_
int xPosition_
Default x position of left side of the application window.
Definition: GUIOptions.hh:177
GUIOptions::ksIter_
KSTable::const_iterator ksIter_
Iterator used in firstShortcut and nextShortcut functions.
Definition: GUIOptions.hh:192
ToolbarButton.hh
GUIOptions::deleteAllKeyboardShortcuts
void deleteAllKeyboardShortcuts()
Definition: GUIOptions.cc:745
GUIOptions::modified_
bool modified_
Indicates whether the options are modified or not.
Definition: GUIOptions.hh:199
GUIOptions::KSTable
std::vector< KeyboardShortcut * > KSTable
Table for keyboard shortcuts.
Definition: GUIOptions.hh:164
GUIOptions::clearModified
void clearModified()
Definition: GUIOptions.cc:502
GUIOptions::setWindowSize
void setWindowSize(int width, int height)
Definition: GUIOptions.cc:229
GUIOptions::addToolbarButton
void addToolbarButton(ToolbarButton *button)
Definition: GUIOptions.cc:292
GUIOptions::toolbarLayout_
ToolbarLayout toolbarLayout_
Layout of the toolbar.
Definition: GUIOptions.hh:183
GUIOptions::saveState
virtual ObjectState * saveState() const
Definition: GUIOptions.cc:700
GUIOptions::OSKEY_POSITION
static const std::string OSKEY_POSITION
ObjectState attribute key for separator position.
Definition: GUIOptions.hh:153
Serializable
Definition: Serializable.hh:44
GUIOptions::yPosition
int yPosition() const
Definition: GUIOptions.cc:183
GUIOptions::OSKEY_FULL_SCREEN
static const std::string OSKEY_FULL_SCREEN
ObjectState attribute key for full screen feature.
Definition: GUIOptions.hh:131
GUIOptions::ICON
@ ICON
Buttons contains only icon.
Definition: GUIOptions.hh:66
GUIOptions::deleteSeparator
void deleteSeparator(int position)
Definition: GUIOptions.cc:358
ObjectState
Definition: ObjectState.hh:59
ToolbarButton
Definition: ToolbarButton.hh:48
GUIOptions::nextSeparator
int nextSeparator() const
Definition: GUIOptions.cc:485
GUIOptions::OSKEY_TOOLBAR_VISIBILITY
static const std::string OSKEY_TOOLBAR_VISIBILITY
ObjectState attribute key for toolbar visibility.
Definition: GUIOptions.hh:141
GUIOptions::TOOLBAR_SEPARATOR
static const std::string TOOLBAR_SEPARATOR
Toolbar separator name.
Definition: GUIOptions.hh:127
GUIOptions::setToolbarVisibility
void setToolbarVisibility(bool visible)
Definition: GUIOptions.cc:256
GUIOptions::deleteAllToolbarButtons
void deleteAllToolbarButtons()
Definition: GUIOptions.cc:754
GUIOptions::createToolbar
wxToolBar * createToolbar(wxWindow *parent, CommandRegistry &registry, const wxString &iconsPath)
Definition: GUIOptions.cc:768
GUIOptions::BOTH
@ BOTH
Buttons contains text and icon.
Definition: GUIOptions.hh:67
GUIOptions::keyboardShortcut
KeyboardShortcut * keyboardShortcut(const std::string commandName) const
Definition: GUIOptions.cc:377
GUIOptions::ToolbarLayout
ToolbarLayout
Definition: GUIOptions.hh:64
KeyboardShortcut.hh
GUIOptions::SeparatorTable
std::vector< int > SeparatorTable
Table for the toolbar separator positions.
Definition: GUIOptions.hh:162
GUIOptions::TBTable
std::vector< ToolbarButton * > TBTable
Table for toolbar buttons.
Definition: GUIOptions.hh:166
GUIOptions::OSKEY_Y_POS
static const std::string OSKEY_Y_POS
ObjectState attribute key for window y position.
Definition: GUIOptions.hh:139
GUIOptions::loadState
virtual void loadState(const ObjectState *state)
Definition: GUIOptions.cc:645
GUIOptions::toolbarLayout
ToolbarLayout toolbarLayout() const
Definition: GUIOptions.cc:205
GUIOptions::setWindowPosition
void setWindowPosition(int x, int y)
Definition: GUIOptions.cc:243
GUIOptions::fullScreen
bool fullScreen() const
Definition: GUIOptions.cc:139
GUIOptions::OSKEY_WINDOW_HEIGHT
static const std::string OSKEY_WINDOW_HEIGHT
ObjectState attribute key for window height.
Definition: GUIOptions.hh:135
GUIOptions::toolbarButtons_
TBTable toolbarButtons_
Toolbar buttons.
Definition: GUIOptions.hh:189
GUIOptions::firstShortcut
KeyboardShortcut * firstShortcut() const
Definition: GUIOptions.cc:397
CommandRegistry
Definition: CommandRegistry.hh:47
GUIOptions::addSeparator
void addSeparator(int position)
Definition: GUIOptions.cc:305
GUIOptions::OSVALUE_ICON
static const std::string OSVALUE_ICON
ObjectState attribute value for icon layout.
Definition: GUIOptions.hh:147
GUIOptions::OSVALUE_BOTH
static const std::string OSVALUE_BOTH
ObjectState attribute value for text & icon layout.
Definition: GUIOptions.hh:149
GUIOptions::isModified
bool isModified() const
Definition: GUIOptions.cc:513
GUIOptions::TEXT
@ TEXT
Buttons contains only text.
Definition: GUIOptions.hh:65
GUIOptions::fileName
std::string fileName() const
Definition: GUIOptions.cc:621
GUIOptions::windowWidth
int windowWidth() const
Definition: GUIOptions.cc:150
GUIOptions::firstToolbarButton
ToolbarButton * firstToolbarButton() const
Definition: GUIOptions.cc:432
GUIOptions::tbIter_
TBTable::const_iterator tbIter_
Iterator used in firstToolbarButton and nextToolbarButton functions.
Definition: GUIOptions.hh:194
GUIOptions::setFileName
void setFileName(const std::string &fileName)
Definition: GUIOptions.cc:632
GUIOptions::OSKEY_X_POS
static const std::string OSKEY_X_POS
ObjectState attribute key for window x position.
Definition: GUIOptions.hh:137
GUIOptions::addKeyboardShortcut
void addKeyboardShortcut(KeyboardShortcut *shortcut)
Definition: GUIOptions.cc:280
GUIOptions::xPosition
int xPosition() const
Definition: GUIOptions.cc:172
GUIOptions::setToolbarLayout
void setToolbarLayout(ToolbarLayout layout)
Definition: GUIOptions.cc:268
GUIOptions::~GUIOptions
virtual ~GUIOptions()
Definition: GUIOptions.cc:125
GUIOptions::validate
virtual void validate() const
Definition: GUIOptions.cc:529
GUIOptions::keyboardShortcuts_
KSTable keyboardShortcuts_
Keyboard shortcuts.
Definition: GUIOptions.hh:187
GUIOptions::windowHeight_
int windowHeight_
Default height of the window.
Definition: GUIOptions.hh:175
Serializable.hh
KeyboardShortcut
Definition: KeyboardShortcut.hh:50
GUIOptions
Definition: GUIOptions.hh:58
GUIOptions::nextToolbarButton
ToolbarButton * nextToolbarButton() const
Definition: GUIOptions.cc:449
GUIOptions::nextShortcut
KeyboardShortcut * nextShortcut() const
Definition: GUIOptions.cc:414
GUIOptions::deleteKeyboardShortcut
void deleteKeyboardShortcut(KeyboardShortcut *shortcut)
Definition: GUIOptions.cc:317
GUIOptions::OSKEY_WINDOW_WIDTH
static const std::string OSKEY_WINDOW_WIDTH
ObjectState attribute key for window width.
Definition: GUIOptions.hh:133
GUIOptions::firstSeparator
int firstSeparator() const
Definition: GUIOptions.cc:468
GUIOptions::OSVALUE_TEXT
static const std::string OSVALUE_TEXT
ObjectState attribute value for text layout.
Definition: GUIOptions.hh:145
GUIOptions::hasFileName
bool hasFileName() const
Definition: GUIOptions.cc:607
GUIOptions::toolbarSeparators_
SeparatorTable toolbarSeparators_
Toolbar separators.
Definition: GUIOptions.hh:185
GUIOptions::fileName_
std::string fileName_
File name assigned to these options.
Definition: GUIOptions.hh:169
GUIOptions::fullScreen_
bool fullScreen_
If true, the application window will open in full screen mode.
Definition: GUIOptions.hh:171
GUIOptions::windowHeight
int windowHeight() const
Definition: GUIOptions.cc:161
GUIOptions::setFullScreen
void setFullScreen(bool fullScreen)
Definition: GUIOptions.cc:216
GUIOptions::separatorIter_
SeparatorTable::const_iterator separatorIter_
Iterator used in firstSeparator and nextSeparator functions.
Definition: GUIOptions.hh:196
GUIOptions::OSKEY_TOOLBAR_LAYOUT
static const std::string OSKEY_TOOLBAR_LAYOUT
ObjectState attribute key for toolbar layout.
Definition: GUIOptions.hh:143
GUIOptions::toolbarVisibility
bool toolbarVisibility() const
Definition: GUIOptions.cc:194
GUIOptions::GUIOptions
GUIOptions(std::string name)
Definition: GUIOptions.cc:68
GUIOptions::deleteToolbarButton
void deleteToolbarButton(ToolbarButton *button)
Definition: GUIOptions.cc:337
GUIOptions::yPosition_
int yPosition_
Default y position of the upper side of the application window.
Definition: GUIOptions.hh:179
GUIOptions::toolbarVisibility_
bool toolbarVisibility_
If true, the toolbar is visible.
Definition: GUIOptions.hh:181
GUIOptions::windowWidth_
int windowWidth_
Default width of the window.
Definition: GUIOptions.hh:173