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

#include <GUIOptions.hh>

Inheritance diagram for GUIOptions:
Inheritance graph
Collaboration diagram for GUIOptions:
Collaboration graph

Public Types

enum  ToolbarLayout { TEXT , ICON , BOTH }
 

Public Member Functions

 GUIOptions (std::string name)
 
 GUIOptions (const GUIOptions &old)
 
 GUIOptions (const ObjectState *state)
 
virtual ~GUIOptions ()
 
bool hasFileName () const
 
std::string fileName () const
 
void setFileName (const std::string &fileName)
 
virtual void validate () const
 
virtual void loadState (const ObjectState *state)
 
virtual ObjectStatesaveState () const
 
bool fullScreen () const
 
int windowWidth () const
 
int windowHeight () const
 
int xPosition () const
 
int yPosition () const
 
bool toolbarVisibility () const
 
ToolbarLayout toolbarLayout () const
 
void setFullScreen (bool fullScreen)
 
void setWindowSize (int width, int height)
 
void setWindowPosition (int x, int y)
 
void setToolbarVisibility (bool visible)
 
void setToolbarLayout (ToolbarLayout layout)
 
void addKeyboardShortcut (KeyboardShortcut *shortcut)
 
void addToolbarButton (ToolbarButton *button)
 
void addSeparator (int position)
 
void deleteKeyboardShortcut (KeyboardShortcut *shortcut)
 
void deleteToolbarButton (ToolbarButton *button)
 
void deleteSeparator (int position)
 
KeyboardShortcutkeyboardShortcut (const std::string commandName) const
 
KeyboardShortcutfirstShortcut () const
 
KeyboardShortcutnextShortcut () const
 
ToolbarButtonfirstToolbarButton () const
 
ToolbarButtonnextToolbarButton () const
 
int firstSeparator () const
 
int nextSeparator () const
 
void clearModified ()
 
bool isModified () const
 
wxToolBar * createToolbar (wxWindow *parent, CommandRegistry &registry, const wxString &iconsPath)
 
- Public Member Functions inherited from Serializable
virtual ~Serializable ()
 

Static Public Attributes

static const std::string TOOLBAR_SEPARATOR = "-- separator --"
 Toolbar separator name.
 
static const std::string OSNAME_OPTIONS = "options"
 ObjectState name for the options.
 
static const std::string OSKEY_FULL_SCREEN = "fscreen"
 ObjectState attribute key for full screen feature.
 
static const std::string OSKEY_WINDOW_WIDTH = "wwidth"
 ObjectState attribute key for window width.
 
static const std::string OSKEY_WINDOW_HEIGHT = "wheight"
 ObjectState attribute key for window height.
 
static const std::string OSKEY_X_POS = "xpos"
 ObjectState attribute key for window x position.
 
static const std::string OSKEY_Y_POS = "ypos"
 ObjectState attribute key for window y position.
 
static const std::string OSKEY_TOOLBAR_VISIBILITY = "tbvisib"
 ObjectState attribute key for toolbar visibility.
 
static const std::string OSKEY_TOOLBAR_LAYOUT = "tblayout"
 ObjectState attribute key for toolbar layout.
 
static const std::string OSVALUE_TEXT = "text"
 ObjectState attribute value for text layout.
 
static const std::string OSVALUE_ICON = "icon"
 ObjectState attribute value for icon layout.
 
static const std::string OSVALUE_BOTH = "both"
 ObjectState attribute value for text & icon layout.
 
static const std::string OSNAME_SEPARATOR = "separator"
 ObjectState name for separator.
 
static const std::string OSKEY_POSITION = "pos"
 ObjectState attribute key for separator position.
 

Protected Member Functions

void deleteAllKeyboardShortcuts ()
 
void deleteAllToolbarButtons ()
 

Private Types

typedef std::vector< int > SeparatorTable
 Table for the toolbar separator positions.
 
typedef std::vector< KeyboardShortcut * > KSTable
 Table for keyboard shortcuts.
 
typedef std::vector< ToolbarButton * > TBTable
 Table for toolbar buttons.
 

Private Attributes

std::string fileName_
 File name assigned to these options.
 
bool fullScreen_
 If true, the application window will open in full screen mode.
 
int windowWidth_
 Default width of the window.
 
int windowHeight_
 Default height of the window.
 
int xPosition_
 Default x position of left side of the application window.
 
int yPosition_
 Default y position of the upper side of the application window.
 
bool toolbarVisibility_
 If true, the toolbar is visible.
 
ToolbarLayout toolbarLayout_
 Layout of the toolbar.
 
SeparatorTable toolbarSeparators_
 Toolbar separators.
 
KSTable keyboardShortcuts_
 Keyboard shortcuts.
 
TBTable toolbarButtons_
 Toolbar buttons.
 
KSTable::const_iterator ksIter_
 Iterator used in firstShortcut and nextShortcut functions.
 
TBTable::const_iterator tbIter_
 Iterator used in firstToolbarButton and nextToolbarButton functions.
 
SeparatorTable::const_iterator separatorIter_
 Iterator used in firstSeparator and nextSeparator functions.
 
bool modified_
 Indicates whether the options are modified or not.
 
std::string name_
 Name of the options.
 

Detailed Description

Represents the options of a GUI.

Base class for GUI options. This class provides handling of options common to all GUIs. If a GUI needs application specific options, specialized options class can be derived from this class. See design documentation for details. This class implements the Serializable interface because the options are going to be stored in an xml configuration file.

Definition at line 58 of file GUIOptions.hh.

Member Typedef Documentation

◆ KSTable

typedef std::vector<KeyboardShortcut*> GUIOptions::KSTable
private

Table for keyboard shortcuts.

Definition at line 164 of file GUIOptions.hh.

◆ SeparatorTable

typedef std::vector<int> GUIOptions::SeparatorTable
private

Table for the toolbar separator positions.

Definition at line 162 of file GUIOptions.hh.

◆ TBTable

typedef std::vector<ToolbarButton*> GUIOptions::TBTable
private

Table for toolbar buttons.

Definition at line 166 of file GUIOptions.hh.

Member Enumeration Documentation

◆ ToolbarLayout

Layout of the buttons in the toolbar.

Enumerator
TEXT 

Buttons contains only text.

ICON 

Buttons contains only icon.

BOTH 

Buttons contains text and icon.

Definition at line 64 of file GUIOptions.hh.

64 {
65 TEXT, ///< Buttons contains only text.
66 ICON, ///< Buttons contains only icon.
67 BOTH ///< Buttons contains text and icon.
68 };
@ 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

Constructor & Destructor Documentation

◆ GUIOptions() [1/3]

GUIOptions::GUIOptions ( std::string  name)

Constructor.

Definition at line 68 of file GUIOptions.cc.

68 :
69 fullScreen_(false), windowWidth_(400), windowHeight_(400), xPosition_(0),
71 modified_(false), name_(name) {
72}
int xPosition_
Default x position of left side of the application window.
int windowHeight_
Default height of the window.
bool toolbarVisibility_
If true, the toolbar is visible.
int windowWidth_
Default width of the window.
ToolbarLayout toolbarLayout_
Layout of the toolbar.
bool modified_
Indicates whether the options are modified or not.
int yPosition_
Default y position of the upper side of the application window.
bool fullScreen_
If true, the application window will open in full screen mode.
std::string name_
Name of the options.

◆ GUIOptions() [2/3]

GUIOptions::GUIOptions ( const GUIOptions old)

Copy constructor.

This constructor creates identical options with the given options class.

Definition at line 93 of file GUIOptions.cc.

93 : Serializable() {
94
103 modified_ = old.modified_;
104
105#ifdef KB_SC_EDITING
106 // deep copy keyboard shortcuts
107 for (KSTable::const_iterator iter = old.keyboardShortcuts_.begin();
108 iter != old.keyboardShortcuts_.end(); iter++) {
109
110 keyboardShortcuts_.push_back(new KeyboardShortcut(**iter));
111 }
112#endif
113
114 // deep copy toolbar buttons
115 for (TBTable::const_iterator iter = old.toolbarButtons_.begin();
116 iter != old.toolbarButtons_.end(); iter++) {
117 toolbarButtons_.push_back(new ToolbarButton(**iter));
118 }
119}
KSTable keyboardShortcuts_
Keyboard shortcuts.
SeparatorTable toolbarSeparators_
Toolbar separators.
TBTable toolbarButtons_
Toolbar buttons.

References fullScreen_, keyboardShortcuts_, modified_, toolbarButtons_, toolbarLayout_, toolbarSeparators_, toolbarVisibility_, windowHeight_, windowWidth_, xPosition_, and yPosition_.

◆ GUIOptions() [3/3]

GUIOptions::GUIOptions ( const ObjectState state)

Constructor.

Loads the state from the given ObjectState tree.

Parameters
stateThe ObjectState tree.
Exceptions
ObjectStateLoadingExceptionIf the given ObjectState tree is invalid.

Definition at line 84 of file GUIOptions.cc.

84 : modified_(false) {
85 loadState(state);
86}
virtual void loadState(const ObjectState *state)

References loadState().

Here is the call graph for this function:

◆ ~GUIOptions()

GUIOptions::~GUIOptions ( )
virtual

Destructor.

Definition at line 125 of file GUIOptions.cc.

125 {
128}
void deleteAllKeyboardShortcuts()
void deleteAllToolbarButtons()

References deleteAllKeyboardShortcuts(), and deleteAllToolbarButtons().

Here is the call graph for this function:

Member Function Documentation

◆ addKeyboardShortcut()

void GUIOptions::addKeyboardShortcut ( KeyboardShortcut shortcut)

Adds a keyboard shortcut.

Parameters
shortcutKeyboard shortcut to be added.

Definition at line 280 of file GUIOptions.cc.

280 {
281 keyboardShortcuts_.push_back(shortcut);
282 modified_ = true;
283}

References keyboardShortcuts_, and modified_.

Referenced by Proxim::createDefaultOptions(), ProDe::createDefaultOptions(), loadState(), and OptionsDialog::writeOptions().

◆ addSeparator()

void GUIOptions::addSeparator ( int  position)

Adds a separator to the toolbar to the given position.

Parameters
positionNumber of the slot left side of which the separator is drawn.

Definition at line 305 of file GUIOptions.cc.

305 {
306 toolbarSeparators_.push_back(position);
307 modified_ = true;
308}

References modified_, and toolbarSeparators_.

Referenced by Proxim::createDefaultOptions(), ProDe::createDefaultOptions(), loadState(), and OptionsDialog::writeOptions().

◆ addToolbarButton()

void GUIOptions::addToolbarButton ( ToolbarButton button)

Adds the given button to the toolbar.

Parameters
buttonButton to be added.

Definition at line 292 of file GUIOptions.cc.

292 {
293 toolbarButtons_.push_back(button);
294 modified_ = true;
295}

References modified_, and toolbarButtons_.

Referenced by Proxim::createDefaultOptions(), ProDe::createDefaultOptions(), loadState(), and OptionsDialog::writeOptions().

◆ clearModified()

void GUIOptions::clearModified ( )

Clears the modified flag.

The isModified method returns false after calling this method.

Definition at line 502 of file GUIOptions.cc.

502 {
503 modified_ = false;
504}

References modified_.

Referenced by Proxim::loadOptions(), and ProDe::OnInit().

◆ createToolbar()

wxToolBar * GUIOptions::createToolbar ( wxWindow *  parent,
CommandRegistry registry,
const wxString &  iconsPath 
)

Creates a toolbar defined in the options.

Parameters
parentParent window of the created toolbar.
registryCommand registry containing the toolbar commands.
iconPathPath of the toolbar icon files.
Returns
A new toolbar corresponding to the one defined in the options.

Definition at line 768 of file GUIOptions.cc.

770 {
771
772 int layout = toolbarLayout();
773 long style = 0;
774
775 // check toolbar layout from options
776 if (layout == GUIOptions::BOTH) {
777 style = wxTB_HORIZONTAL | wxNO_BORDER | wxTB_TEXT;
778 } else if (layout == GUIOptions::ICON) {
779 style = wxTB_HORIZONTAL | wxNO_BORDER;
780 } else if (layout == GUIOptions::TEXT) {
781 style = wxTB_HORIZONTAL | wxNO_BORDER | wxTB_TEXT | wxTB_NOICONS;
782 } else {
783 assert(false);
784 }
785
786 // create a new toolbar
787 wxToolBar* toolbar = new wxToolBar(
788 parent, -1, wxDefaultPosition, wxDefaultSize, style);
789
790 bool found = true;
791 int slot = 0;
792 wxBitmap icon;
793
794 // Add buttons and separators for each slot, until a slot without
795 // button or separator is found.
796 while (found) {
797
798 found = false;
799
800 // check if a toolbar button exists for the slot
802 while (tool != NULL) {
803 if (tool->slot() == slot) {
804 // button found for the slot, add it
805 found = true;
806
807 wxString iconPath = iconsPath;
808 iconPath.Append(WxConversion::toWxString(
810 iconPath.Append(
812 registry.commandIcon(tool->action())));
813
814 if (!icon.LoadFile(iconPath, wxBITMAP_TYPE_PNG)) {
815 std::cerr << "Toolbar icon file "
816 << WxConversion::toString(iconPath)
817 << " not found!"
818 << std::endl;
819
820 icon.Create(32, 32);
821 }
822
823 toolbar->AddTool(registry.commandId(tool->action()),
825 registry.commandShortName(tool->action())),
826 icon, wxNullBitmap, wxITEM_NORMAL,
828 tool->action()),
830 tool->action()));
831 found = true;
832 // disable button if command is not executable at the moment
833 if (!registry.isEnabled(tool->action())) {
834 toolbar->EnableTool(registry.commandId(tool->action()),
835 false);
836 }
837 }
838 tool = nextToolbarButton();
839 }
840
841
842 // check if a separator exists for the slot
843 int separator = firstSeparator();
844 while (separator != -1) {
845 if (separator == slot) {
846 // separator found for the slot, add it
847 toolbar->AddSeparator();
848 found = true;
849 }
850 separator = nextSeparator();
851 }
852 slot++;
853 }
854
855 toolbar->Realize();
856 return toolbar;
857}
#define assert(condition)
bool isEnabled(const std::string command)
int commandId(const std::string name) const
std::string commandIcon(const std::string name) const
std::string commandShortName(const std::string name) const
static const std::string DIRECTORY_SEPARATOR
ToolbarButton * nextToolbarButton() const
int firstSeparator() const
ToolbarLayout toolbarLayout() const
int nextSeparator() const
ToolbarButton * firstToolbarButton() const
int slot() const
std::string action() const
static wxString toWxString(const std::string &source)
static std::string toString(const wxString &source)

References ToolbarButton::action(), assert, BOTH, CommandRegistry::commandIcon(), CommandRegistry::commandId(), CommandRegistry::commandShortName(), FileSystem::DIRECTORY_SEPARATOR, firstSeparator(), firstToolbarButton(), ICON, CommandRegistry::isEnabled(), nextSeparator(), nextToolbarButton(), ToolbarButton::slot(), TEXT, toolbarLayout(), WxConversion::toString(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ deleteAllKeyboardShortcuts()

void GUIOptions::deleteAllKeyboardShortcuts ( )
protected

Deletes all the keyboard shortcuts.

Definition at line 745 of file GUIOptions.cc.

745 {
747}
static void deleteAllItems(SequenceType &aSequence)

References SequenceTools::deleteAllItems(), and keyboardShortcuts_.

Referenced by loadState(), ProDeOptions::loadState(), and ~GUIOptions().

Here is the call graph for this function:

◆ deleteAllToolbarButtons()

void GUIOptions::deleteAllToolbarButtons ( )
protected

Deletes all the toolbar buttons.

Definition at line 754 of file GUIOptions.cc.

References SequenceTools::deleteAllItems(), and toolbarButtons_.

Referenced by loadState(), ProDeOptions::loadState(), and ~GUIOptions().

Here is the call graph for this function:

◆ deleteKeyboardShortcut()

void GUIOptions::deleteKeyboardShortcut ( KeyboardShortcut shortcut)

Deletes the given keyboard shortcut.

Parameters
shortcutThe keyboard shortcut to be deleted.

Definition at line 317 of file GUIOptions.cc.

317 {
318 KSTable::iterator iter = keyboardShortcuts_.begin();
319 while (iter != keyboardShortcuts_.end()) {
320 if (*iter == shortcut) {
321 keyboardShortcuts_.erase(iter);
322 delete shortcut;
323 modified_ = true;
324 return;
325 }
326 iter++;
327 }
328}

References keyboardShortcuts_, and modified_.

Referenced by OptionsDialog::writeOptions().

◆ deleteSeparator()

void GUIOptions::deleteSeparator ( int  position)

Deletes a separator from the given position.

Parameters
positionThe slot position left side of which the separator is deleted.

Definition at line 358 of file GUIOptions.cc.

358 {
359 SeparatorTable::iterator iter = toolbarSeparators_.begin();
360 while (iter != toolbarSeparators_.end()) {
361 if (*iter == position) {
362 toolbarSeparators_.erase(iter);
363 modified_ = true;
364 return;
365 }
366 iter++;
367 }
368}

References modified_, and toolbarSeparators_.

Referenced by OptionsDialog::writeOptions().

◆ deleteToolbarButton()

void GUIOptions::deleteToolbarButton ( ToolbarButton button)

Deletes the given toolbar button.

Parameters
buttonThe toolbar button to be deleted.

Definition at line 337 of file GUIOptions.cc.

337 {
338 TBTable::iterator iter = toolbarButtons_.begin();
339 while (iter != toolbarButtons_.end()) {
340 if (*iter == button) {
341 toolbarButtons_.erase(iter);
342 delete button;
343 modified_ = true;
344 return;
345 }
346 iter++;
347 }
348}

References modified_, and toolbarButtons_.

Referenced by OptionsDialog::writeOptions().

◆ fileName()

string GUIOptions::fileName ( ) const

Returns the file name assigned to these options.

Returns
The file name assigned to these options.

Definition at line 621 of file GUIOptions.cc.

621 {
622 return fileName_;
623}
std::string fileName_
File name assigned to these options.

References fileName_.

Referenced by setFileName().

◆ firstSeparator()

int GUIOptions::firstSeparator ( ) const

Returns position of the first toolbar separator. Position is the position of the slot left side of which the separator is. If there are no separators, returns -1.

Returns
Position of the first toolbar separator.

Definition at line 468 of file GUIOptions.cc.

468 {
470 if (separatorIter_ != toolbarSeparators_.end()) {
471 return *separatorIter_;
472 } else {
473 return -1;
474 }
475}
SeparatorTable::const_iterator separatorIter_
Iterator used in firstSeparator and nextSeparator functions.

References separatorIter_, and toolbarSeparators_.

Referenced by createToolbar(), OptionsDialog::readOptions(), and OptionsDialog::writeOptions().

◆ firstShortcut()

KeyboardShortcut * GUIOptions::firstShortcut ( ) const

Returns the first keyboard shortcut. If there are no keyboard shortcuts, returns null pointer.

Returns
The first keyboard shortcut.

Definition at line 397 of file GUIOptions.cc.

397 {
398 ksIter_ = keyboardShortcuts_.begin();
399 if (ksIter_ != keyboardShortcuts_.end()) {
400 return *ksIter_;
401 } else {
402 return NULL;
403 }
404}
KSTable::const_iterator ksIter_
Iterator used in firstShortcut and nextShortcut functions.

References keyboardShortcuts_, and ksIter_.

Referenced by OptionsDialog::readOptions(), and OptionsDialog::writeOptions().

◆ firstToolbarButton()

ToolbarButton * GUIOptions::firstToolbarButton ( ) const

Returns the first toolbar button. Returns null pointer if there are no toolbar buttons.

Returns
The first toolbar button.

Definition at line 432 of file GUIOptions.cc.

432 {
433 tbIter_ = toolbarButtons_.begin();
434 if (tbIter_ != toolbarButtons_.end()) {
435 return *tbIter_;
436 } else {
437 return NULL;
438 }
439}
TBTable::const_iterator tbIter_
Iterator used in firstToolbarButton and nextToolbarButton functions.

References tbIter_, and toolbarButtons_.

Referenced by createToolbar(), OptionsDialog::readOptions(), validate(), and OptionsDialog::writeOptions().

◆ fullScreen()

bool GUIOptions::fullScreen ( ) const

Returns true, if the application window opens in full screen mode as default, otherwise false.

Returns
True, if the application window opens in full screen mode as default, otherwise false.

Definition at line 139 of file GUIOptions.cc.

139 {
140 return fullScreen_;
141}

References fullScreen_.

Referenced by setFullScreen().

◆ hasFileName()

bool GUIOptions::hasFileName ( ) const

Checks whether these options has file name assigned.

Returns
True if these options has file name assigned, otherwise false.

Definition at line 607 of file GUIOptions.cc.

607 {
608 if (fileName_ == "") {
609 return false;
610 }
611 return true;
612}

References fileName_.

◆ isModified()

bool GUIOptions::isModified ( ) const

Returns true if the options are modified.

Returns
True if the options are modified.

Definition at line 513 of file GUIOptions.cc.

513 {
514 return modified_;
515}

References modified_.

◆ keyboardShortcut()

KeyboardShortcut * GUIOptions::keyboardShortcut ( const std::string  commandName) const

Returns keyboard shortcut for the command with given name.

Parameters
commandNameName of the command to search shortcut for.
Returns
NULL if a shortcut doesn't exist for the command.

Definition at line 377 of file GUIOptions.cc.

377 {
378
379 KSTable::const_iterator iter = keyboardShortcuts_.begin();
380
381 for (; iter != keyboardShortcuts_.end(); iter++) {
382 if ((*iter)->action() == commandName) {
383 return *iter;
384 }
385 }
386
387 return NULL;
388}

References keyboardShortcuts_.

◆ loadState()

void GUIOptions::loadState ( const ObjectState state)
virtual

Loads the state of the object from the given ObjectState object.

Parameters
stateObjectState from which the state is loaded.
Exceptions
ObjectStateLoadingExceptionIf the given ObjectState instance is invalid.

Implements Serializable.

Reimplemented in ProDeOptions.

Definition at line 645 of file GUIOptions.cc.

645 {
646 const string procName = "GUIOptions::loadState";
647
648 if (state->name() != OSNAME_OPTIONS) {
649 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
650 }
651
652 try {
659
660 string layout = state->stringAttribute(OSKEY_TOOLBAR_LAYOUT);
661 if (layout == OSVALUE_TEXT) {
663 } else if (layout == OSVALUE_ICON) {
665 } else if (layout == OSVALUE_BOTH) {
667 } else {
668 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
669 }
670
671 // get toolbar separators, keyboard shortcuts and toolbar buttons
672 for (int i = 0; i < state->childCount(); i++) {
673 ObjectState* child = state->child(i);
674 if (child->name() == OSNAME_SEPARATOR) {
676
677 } else if (child->name() ==
680 } else if (child->name() == ToolbarButton::OSNAME_TOOLBAR_BUTTON) {
682 } else {
683 throw ObjectStateLoadingException(__FILE__, __LINE__,
684 procName);
685 }
686 }
687 } catch (...) {
690 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
691 }
692}
static const std::string OSKEY_X_POS
ObjectState attribute key for window x position.
void addKeyboardShortcut(KeyboardShortcut *shortcut)
void addToolbarButton(ToolbarButton *button)
static const std::string OSKEY_POSITION
ObjectState attribute key for separator position.
void addSeparator(int position)
static const std::string OSVALUE_BOTH
ObjectState attribute value for text & icon layout.
static const std::string OSKEY_WINDOW_WIDTH
ObjectState attribute key for window width.
static const std::string OSVALUE_TEXT
ObjectState attribute value for text layout.
static const std::string OSKEY_TOOLBAR_VISIBILITY
ObjectState attribute key for toolbar visibility.
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.
static const std::string OSKEY_TOOLBAR_LAYOUT
ObjectState attribute key for toolbar layout.
static const std::string OSKEY_WINDOW_HEIGHT
ObjectState attribute key for window height.
static const std::string OSNAME_SEPARATOR
ObjectState name for separator.
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.
static const std::string OSNAME_KEYBOARD_SHORTCUT
ObjectState name for keyboard shortcut.
ObjectState * child(int index) const
std::string stringAttribute(const std::string &name) const
int intAttribute(const std::string &name) const
std::string name() const
int childCount() const
static const std::string OSNAME_TOOLBAR_BUTTON
ObjectState name for ToolbarButton.

References addKeyboardShortcut(), addSeparator(), addToolbarButton(), BOTH, ObjectState::child(), ObjectState::childCount(), deleteAllKeyboardShortcuts(), deleteAllToolbarButtons(), fullScreen_, ICON, ObjectState::intAttribute(), ObjectState::name(), OSKEY_FULL_SCREEN, OSKEY_POSITION, OSKEY_TOOLBAR_LAYOUT, OSKEY_TOOLBAR_VISIBILITY, OSKEY_WINDOW_HEIGHT, OSKEY_WINDOW_WIDTH, OSKEY_X_POS, OSKEY_Y_POS, KeyboardShortcut::OSNAME_KEYBOARD_SHORTCUT, OSNAME_OPTIONS, OSNAME_SEPARATOR, ToolbarButton::OSNAME_TOOLBAR_BUTTON, OSVALUE_BOTH, OSVALUE_ICON, OSVALUE_TEXT, ObjectState::stringAttribute(), TEXT, toolbarLayout_, toolbarVisibility_, windowHeight_, windowWidth_, xPosition_, and yPosition_.

Referenced by GUIOptions(), and ProDeOptions::loadState().

Here is the call graph for this function:

◆ nextSeparator()

int GUIOptions::nextSeparator ( ) const

Returns always position of the next toolbar separator. If there are no more separators, returns -1.

Returns
Position of the next toolbar separator.

Definition at line 485 of file GUIOptions.cc.

485 {
488 if (separatorIter_ != toolbarSeparators_.end()) {
489 return *separatorIter_;
490 } else {
491 return -1;
492 }
493}

References assert, separatorIter_, and toolbarSeparators_.

Referenced by createToolbar(), and OptionsDialog::readOptions().

◆ nextShortcut()

KeyboardShortcut * GUIOptions::nextShortcut ( ) const

Returns the always the next keyboard shortcut after firstShortcut has been called. Returns null pointer after the last keyboard shortcut.

Returns
The next keyboard shortcut.

Definition at line 414 of file GUIOptions.cc.

414 {
416 ksIter_++;
417 if (ksIter_ != keyboardShortcuts_.end()) {
418 return *ksIter_;
419 } else {
420 return NULL;
421 }
422}

References assert, keyboardShortcuts_, and ksIter_.

Referenced by OptionsDialog::readOptions().

◆ nextToolbarButton()

ToolbarButton * GUIOptions::nextToolbarButton ( ) const

Returns always the next toolbar button after the firstToolbarButton has been called.

Returns
The next toolbar button.

Definition at line 449 of file GUIOptions.cc.

449 {
451 tbIter_++;
452 if (tbIter_ != toolbarButtons_.end()) {
453 return *tbIter_;
454 } else {
455 return NULL;
456 }
457}

References assert, tbIter_, and toolbarButtons_.

Referenced by createToolbar(), OptionsDialog::readOptions(), and validate().

◆ saveState()

ObjectState * GUIOptions::saveState ( ) const
virtual

Creates an ObjectState object and saves the state of the object into it.

Returns
The created ObjectState object.

Implements Serializable.

Reimplemented in ProDeOptions.

Definition at line 700 of file GUIOptions.cc.

700 {
701
703
710
711 if (toolbarLayout_ == TEXT) {
713 } else if (toolbarLayout_ == ICON) {
715 } else {
717 }
718
719 // add toolbar separators
720 for (int i = 0; i < (int)toolbarSeparators_.size(); i++) {
721 ObjectState* separator = new ObjectState(OSNAME_SEPARATOR);
722 state->addChild(separator);
724 }
725
726 // add keyboard shortcuts
727 for (int i = 0; i < (int)keyboardShortcuts_.size(); i++) {
729 state->addChild(sc->saveState());
730 }
731
732 // add toolbar buttons
733 for (int i = 0; i < (int)toolbarButtons_.size(); i++) {
734 ToolbarButton* button = toolbarButtons_[i];
735 state->addChild(button->saveState());
736 }
737
738 return state;
739}
ObjectState * saveState() const
void setAttribute(const std::string &name, const std::string &value)
void addChild(ObjectState *child)
ObjectState * saveState() const

References ObjectState::addChild(), fullScreen_, ICON, keyboardShortcuts_, OSKEY_FULL_SCREEN, OSKEY_POSITION, OSKEY_TOOLBAR_LAYOUT, OSKEY_TOOLBAR_VISIBILITY, OSKEY_WINDOW_HEIGHT, OSKEY_WINDOW_WIDTH, OSKEY_X_POS, OSKEY_Y_POS, OSNAME_OPTIONS, OSNAME_SEPARATOR, OSVALUE_BOTH, OSVALUE_ICON, OSVALUE_TEXT, KeyboardShortcut::saveState(), ToolbarButton::saveState(), ObjectState::setAttribute(), TEXT, toolbarButtons_, toolbarLayout_, toolbarSeparators_, toolbarVisibility_, windowHeight_, windowWidth_, xPosition_, and yPosition_.

Referenced by ProDeOptions::saveState().

Here is the call graph for this function:

◆ setFileName()

void GUIOptions::setFileName ( const std::string &  fileName)

Sets the file name assigned into these options.

Parameters
fileNameThe file name assigned into these options.

Definition at line 632 of file GUIOptions.cc.

632 {
634}
std::string fileName() const

References fileName(), and fileName_.

Referenced by Proxim::createDefaultOptions(), Proxim::loadOptions(), and ProDe::OnInit().

Here is the call graph for this function:

◆ setFullScreen()

void GUIOptions::setFullScreen ( bool  fullScreen)

Sets or unsets the default full screen mode of the application window.

Parameters
fullScreenIf true, the full screen mode is set, otherwise unset.

Definition at line 216 of file GUIOptions.cc.

216 {
218 modified_ = true;
219}
bool fullScreen() const

References fullScreen(), fullScreen_, and modified_.

Referenced by ProDe::createDefaultOptions().

Here is the call graph for this function:

◆ setToolbarLayout()

void GUIOptions::setToolbarLayout ( ToolbarLayout  layout)

Sets the layout of the toolbar buttons.

Parameters
layoutLayout of the toolbar buttons.

Definition at line 268 of file GUIOptions.cc.

268 {
269 toolbarLayout_ = layout;
270 modified_ = true;
271}

References modified_, and toolbarLayout_.

Referenced by Proxim::createDefaultOptions(), ProDe::createDefaultOptions(), and OptionsDialog::writeOptions().

◆ setToolbarVisibility()

void GUIOptions::setToolbarVisibility ( bool  visible)

Sets the visibility mode of the toolbar.

Parameters
visibleIf true, the toolbar is visible, otherwise it is hidden.

Definition at line 256 of file GUIOptions.cc.

256 {
257 toolbarVisibility_ = visible;
258 modified_ = true;
259}

References modified_, and toolbarVisibility_.

Referenced by Proxim::createDefaultOptions(), and ProDe::createDefaultOptions().

◆ setWindowPosition()

void GUIOptions::setWindowPosition ( int  x,
int  y 
)

Sets the default position of the window.

Parameters
xX-coordinate of left side of the application window.
yY-coordinate of upper side of the application window.

Definition at line 243 of file GUIOptions.cc.

243 {
244 xPosition_ = x;
245 yPosition_ = y;
246 modified_ = true;
247}

References modified_, xPosition_, and yPosition_.

Referenced by ProDe::createDefaultOptions().

◆ setWindowSize()

void GUIOptions::setWindowSize ( int  width,
int  height 
)

Sets the default application window size.

Parameters
widthPixel width of the window.
heightPixel height of the window.

Definition at line 229 of file GUIOptions.cc.

229 {
230 windowWidth_ = width;
231 windowHeight_ = height;
232 modified_ = true;
233}

References modified_, windowHeight_, and windowWidth_.

Referenced by ProDe::createDefaultOptions().

◆ toolbarLayout()

GUIOptions::ToolbarLayout GUIOptions::toolbarLayout ( ) const

Returns the layout mode of the toolbar.

Returns
Layout mode of the toolbar.

Definition at line 205 of file GUIOptions.cc.

205 {
206 return toolbarLayout_;
207}

References toolbarLayout_.

Referenced by createToolbar(), and OptionsDialog::readOptions().

◆ toolbarVisibility()

bool GUIOptions::toolbarVisibility ( ) const

Returns true if the toolbar is visible by default, otherwise false.

Returns
True if the toolbar is visible by default, otherwise false.

Definition at line 194 of file GUIOptions.cc.

194 {
195 return toolbarVisibility_;
196}

References toolbarVisibility_.

◆ validate()

void GUIOptions::validate ( ) const
virtual

Validates the state of the options.

Checks that there is no gaps in toolbar item positions and no two items at the same position. Additionally checks that there is no same keyboard shortcuts for several actions and no two keyboard shortcuts for the same action.

Exceptions
InvalidDataIf the options are in invalid state.

Definition at line 529 of file GUIOptions.cc.

529 {
530 const string procName = "GUIOptions::validate";
531 int buttons = toolbarButtons_.size();
532 int separators = toolbarSeparators_.size();
533
534 // check that there is no gaps in toolbar item positions
535 for (int i = 0; i < buttons + separators; i++) {
536 bool buttonfound = false;
537 bool separatorfound = false;
539 while (button != NULL) {
540 if (button->slot() == i) {
541 if (buttonfound) {
542 string errorMsg = "There is at least two toolbar items ";
543 errorMsg += "at position \'" + Conversion::toString(i) +
544 "\'.";
545 throw InvalidData(__FILE__, __LINE__, procName,
546 errorMsg);
547 }
548 buttonfound = true;
549 }
550 button = nextToolbarButton();
551 }
552
553 for (int sepIndex = 0; sepIndex < separators; sepIndex++) {
554 if (toolbarSeparators_[sepIndex] == i) {
555 if (separatorfound || buttonfound) {
556 string errorMsg = "There is at least two toolbar items ";
557 errorMsg += "at position \'" + Conversion::toString(i) +
558 "\'.";
559 throw InvalidData(__FILE__, __LINE__, procName,
560 errorMsg);
561 }
562 separatorfound = true;
563 }
564 }
565
566 if (!buttonfound && !separatorfound) {
567 string errorMsg = "There is no separator or button at slot "
568 "position \'" + Conversion::toString(i) + "\'.";
569 throw InvalidData(__FILE__, __LINE__, procName, errorMsg);
570 }
571
572 }
573
574 // check that there is no same keyboard shortcuts for several actions and
575 // no two keyboard shortcuts for same action
576 KSTable::const_iterator ksIter = keyboardShortcuts_.begin();
577 while (ksIter != keyboardShortcuts_.end()) {
578 KeyboardShortcut* observable = *ksIter;
579 string action = observable->action();
580 KSTable::const_iterator seekerIter = keyboardShortcuts_.begin();
581
582 while (seekerIter != keyboardShortcuts_.end()) {
583 KeyboardShortcut* sc = *seekerIter;
584 if (action == sc->action() && sc != observable) {
585 string errorMsg = "Action \'" + action + "\' is assigned for"
586 + " two or more keyboard shortcuts.";
587 throw InvalidData(__FILE__, __LINE__, procName, errorMsg);
588 }
589 if (observable->equals(*sc) && observable != sc) {
590 string errorMsg = "Same keyboard shortcut is used for \'" +
591 observable->action() + "\' and \'" + sc->action() +
592 "\' actions.";
593 throw InvalidData(__FILE__, __LINE__, procName, errorMsg);
594 }
595 seekerIter++;
596 }
597 ksIter++;
598 }
599}
static std::string toString(const T &source)
bool equals(const KeyboardShortcut &sc) const
std::string action() const

References KeyboardShortcut::action(), KeyboardShortcut::equals(), firstToolbarButton(), keyboardShortcuts_, nextToolbarButton(), ToolbarButton::slot(), toolbarButtons_, toolbarSeparators_, and Conversion::toString().

Referenced by Proxim::loadOptions(), and ProDe::OnInit().

Here is the call graph for this function:

◆ windowHeight()

int GUIOptions::windowHeight ( ) const

Returns the default height of the application window.

Returns
The default height of the application window.

Definition at line 161 of file GUIOptions.cc.

161 {
162 return windowHeight_;
163}

References windowHeight_.

Referenced by ProDe::OnInit().

◆ windowWidth()

int GUIOptions::windowWidth ( ) const

Returns the default width of the application window.

Returns
The default width of the application window.

Definition at line 150 of file GUIOptions.cc.

150 {
151 return windowWidth_;
152}

References windowWidth_.

Referenced by ProDe::OnInit().

◆ xPosition()

int GUIOptions::xPosition ( ) const

Returns the default x position of left side of the application window.

Returns
The default x position of left side of the application window.

Definition at line 172 of file GUIOptions.cc.

172 {
173 return xPosition_;
174}

References xPosition_.

Referenced by ProDe::OnInit().

◆ yPosition()

int GUIOptions::yPosition ( ) const

Returns the default y position of upper side of the application window.

Returns
The default y position of upper side of the application window.

Definition at line 183 of file GUIOptions.cc.

183 {
184 return yPosition_;
185}

References yPosition_.

Referenced by ProDe::OnInit().

Member Data Documentation

◆ fileName_

std::string GUIOptions::fileName_
private

File name assigned to these options.

Definition at line 169 of file GUIOptions.hh.

Referenced by fileName(), hasFileName(), and setFileName().

◆ fullScreen_

bool GUIOptions::fullScreen_
private

If true, the application window will open in full screen mode.

Definition at line 171 of file GUIOptions.hh.

Referenced by fullScreen(), GUIOptions(), loadState(), saveState(), and setFullScreen().

◆ keyboardShortcuts_

KSTable GUIOptions::keyboardShortcuts_
private

◆ ksIter_

KSTable::const_iterator GUIOptions::ksIter_
mutableprivate

Iterator used in firstShortcut and nextShortcut functions.

Definition at line 192 of file GUIOptions.hh.

Referenced by firstShortcut(), and nextShortcut().

◆ modified_

bool GUIOptions::modified_
private

◆ name_

std::string GUIOptions::name_
private

Name of the options.

Definition at line 201 of file GUIOptions.hh.

◆ OSKEY_FULL_SCREEN

const string GUIOptions::OSKEY_FULL_SCREEN = "fscreen"
static

◆ OSKEY_POSITION

const string GUIOptions::OSKEY_POSITION = "pos"
static

ObjectState attribute key for separator position.

Definition at line 153 of file GUIOptions.hh.

Referenced by GUIOptionsSerializer::convertToConfigFileFormat(), loadState(), saveState(), and GUIOptionsSerializer::setToolbarProperties().

◆ OSKEY_TOOLBAR_LAYOUT

const string GUIOptions::OSKEY_TOOLBAR_LAYOUT = "tblayout"
static

◆ OSKEY_TOOLBAR_VISIBILITY

const string GUIOptions::OSKEY_TOOLBAR_VISIBILITY = "tbvisib"
static

◆ OSKEY_WINDOW_HEIGHT

const string GUIOptions::OSKEY_WINDOW_HEIGHT = "wheight"
static

◆ OSKEY_WINDOW_WIDTH

const string GUIOptions::OSKEY_WINDOW_WIDTH = "wwidth"
static

◆ OSKEY_X_POS

const string GUIOptions::OSKEY_X_POS = "xpos"
static

◆ OSKEY_Y_POS

const string GUIOptions::OSKEY_Y_POS = "ypos"
static

◆ OSNAME_OPTIONS

const string GUIOptions::OSNAME_OPTIONS = "options"
static

ObjectState name for the options.

Definition at line 129 of file GUIOptions.hh.

Referenced by GUIOptionsSerializer::convertToOptionsObjectFormat(), loadState(), and saveState().

◆ OSNAME_SEPARATOR

const string GUIOptions::OSNAME_SEPARATOR = "separator"
static

◆ OSVALUE_BOTH

const string GUIOptions::OSVALUE_BOTH = "both"
static

ObjectState attribute value for text & icon layout.

Definition at line 149 of file GUIOptions.hh.

Referenced by GUIOptionsSerializer::convertToOptionsObjectFormat(), loadState(), saveState(), and GUIOptionsSerializer::setToolbarProperties().

◆ OSVALUE_ICON

const string GUIOptions::OSVALUE_ICON = "icon"
static

◆ OSVALUE_TEXT

const string GUIOptions::OSVALUE_TEXT = "text"
static

◆ separatorIter_

SeparatorTable::const_iterator GUIOptions::separatorIter_
mutableprivate

Iterator used in firstSeparator and nextSeparator functions.

Definition at line 196 of file GUIOptions.hh.

Referenced by firstSeparator(), and nextSeparator().

◆ tbIter_

TBTable::const_iterator GUIOptions::tbIter_
mutableprivate

Iterator used in firstToolbarButton and nextToolbarButton functions.

Definition at line 194 of file GUIOptions.hh.

Referenced by firstToolbarButton(), and nextToolbarButton().

◆ TOOLBAR_SEPARATOR

const string GUIOptions::TOOLBAR_SEPARATOR = "-- separator --"
static

Toolbar separator name.

Definition at line 127 of file GUIOptions.hh.

Referenced by OptionsDialog::readOptions(), OptionsDialog::TransferDataToWindow(), and OptionsDialog::writeOptions().

◆ toolbarButtons_

TBTable GUIOptions::toolbarButtons_
private

◆ toolbarLayout_

ToolbarLayout GUIOptions::toolbarLayout_
private

Layout of the toolbar.

Definition at line 183 of file GUIOptions.hh.

Referenced by GUIOptions(), loadState(), saveState(), setToolbarLayout(), and toolbarLayout().

◆ toolbarSeparators_

SeparatorTable GUIOptions::toolbarSeparators_
private

Toolbar separators.

Definition at line 185 of file GUIOptions.hh.

Referenced by addSeparator(), deleteSeparator(), firstSeparator(), GUIOptions(), nextSeparator(), saveState(), and validate().

◆ toolbarVisibility_

bool GUIOptions::toolbarVisibility_
private

If true, the toolbar is visible.

Definition at line 181 of file GUIOptions.hh.

Referenced by GUIOptions(), loadState(), saveState(), setToolbarVisibility(), and toolbarVisibility().

◆ windowHeight_

int GUIOptions::windowHeight_
private

Default height of the window.

Definition at line 175 of file GUIOptions.hh.

Referenced by GUIOptions(), loadState(), saveState(), setWindowSize(), and windowHeight().

◆ windowWidth_

int GUIOptions::windowWidth_
private

Default width of the window.

Definition at line 173 of file GUIOptions.hh.

Referenced by GUIOptions(), loadState(), saveState(), setWindowSize(), and windowWidth().

◆ xPosition_

int GUIOptions::xPosition_
private

Default x position of left side of the application window.

Definition at line 177 of file GUIOptions.hh.

Referenced by GUIOptions(), loadState(), saveState(), setWindowPosition(), and xPosition().

◆ yPosition_

int GUIOptions::yPosition_
private

Default y position of the upper side of the application window.

Definition at line 179 of file GUIOptions.hh.

Referenced by GUIOptions(), loadState(), saveState(), setWindowPosition(), and yPosition().


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