OpenASIP 2.2
Loading...
Searching...
No Matches
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
43class CommandRegistry;
44class wxToolBar;
45class wxWindow;
46class 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 */
58class GUIOptions : public Serializable {
59public:
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);
99
101 void addToolbarButton(ToolbarButton* button);
102 void addSeparator(int position);
103
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
155protected:
158
159private:
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.
200 /// Name of the options.
201 std::string name_;
202};
203
204#endif
virtual ~GUIOptions()
int xPosition_
Default x position of left side of the application window.
KSTable keyboardShortcuts_
Keyboard shortcuts.
static const std::string OSKEY_X_POS
ObjectState attribute key for window x position.
int windowHeight_
Default height of the window.
bool toolbarVisibility_
If true, the toolbar is visible.
int windowWidth() const
void addKeyboardShortcut(KeyboardShortcut *shortcut)
void setToolbarVisibility(bool visible)
std::vector< int > SeparatorTable
Table for the toolbar separator positions.
void deleteSeparator(int position)
virtual void loadState(const ObjectState *state)
std::vector< KeyboardShortcut * > KSTable
Table for keyboard shortcuts.
TBTable::const_iterator tbIter_
Iterator used in firstToolbarButton and nextToolbarButton functions.
void addToolbarButton(ToolbarButton *button)
void setFullScreen(bool fullScreen)
void deleteAllKeyboardShortcuts()
virtual ObjectState * saveState() const
void setWindowPosition(int x, int y)
ToolbarButton * nextToolbarButton() const
int firstSeparator() const
wxToolBar * createToolbar(wxWindow *parent, CommandRegistry &registry, const wxString &iconsPath)
static const std::string OSKEY_POSITION
ObjectState attribute key for separator position.
KeyboardShortcut * firstShortcut() const
KeyboardShortcut * nextShortcut() const
int windowWidth_
Default width of the window.
int yPosition() const
void addSeparator(int position)
ToolbarLayout toolbarLayout_
Layout of the toolbar.
SeparatorTable::const_iterator separatorIter_
Iterator used in firstSeparator and nextSeparator functions.
bool hasFileName() const
static const std::string OSVALUE_BOTH
ObjectState attribute value for text & icon layout.
bool fullScreen() const
bool modified_
Indicates whether the options are modified or not.
int yPosition_
Default y position of the upper side of the application window.
ToolbarLayout toolbarLayout() const
static const std::string OSKEY_WINDOW_WIDTH
ObjectState attribute key for window width.
static const std::string TOOLBAR_SEPARATOR
Toolbar separator name.
void deleteKeyboardShortcut(KeyboardShortcut *shortcut)
void deleteAllToolbarButtons()
int xPosition() const
static const std::string OSVALUE_TEXT
ObjectState attribute value for text layout.
KSTable::const_iterator ksIter_
Iterator used in firstShortcut and nextShortcut functions.
virtual void validate() const
int windowHeight() const
void clearModified()
static const std::string OSKEY_TOOLBAR_VISIBILITY
ObjectState attribute key for toolbar visibility.
@ 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
bool toolbarVisibility() const
static const std::string OSNAME_OPTIONS
ObjectState name for the options.
static const std::string OSKEY_FULL_SCREEN
ObjectState attribute key for full screen feature.
bool fullScreen_
If true, the application window will open in full screen mode.
int nextSeparator() const
void deleteToolbarButton(ToolbarButton *button)
SeparatorTable toolbarSeparators_
Toolbar separators.
std::string fileName() const
std::string fileName_
File name assigned to these options.
void setFileName(const std::string &fileName)
static const std::string OSKEY_TOOLBAR_LAYOUT
ObjectState attribute key for toolbar layout.
void setToolbarLayout(ToolbarLayout layout)
TBTable toolbarButtons_
Toolbar buttons.
std::string name_
Name of the options.
std::vector< ToolbarButton * > TBTable
Table for toolbar buttons.
KeyboardShortcut * keyboardShortcut(const std::string commandName) const
static const std::string OSKEY_WINDOW_HEIGHT
ObjectState attribute key for window height.
static const std::string OSNAME_SEPARATOR
ObjectState name for separator.
bool isModified() const
void setWindowSize(int width, int height)
static const std::string OSKEY_Y_POS
ObjectState attribute key for window y position.
static const std::string OSVALUE_ICON
ObjectState attribute value for icon layout.
ToolbarButton * firstToolbarButton() const