OpenASIP  2.0
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
ToolbarButton Class Reference

#include <ToolbarButton.hh>

Inheritance diagram for ToolbarButton:
Inheritance graph
Collaboration diagram for ToolbarButton:
Collaboration graph

Public Member Functions

 ToolbarButton (int slot, const std::string &action)
 
 ToolbarButton (const ObjectState *state)
 
 ToolbarButton (const ToolbarButton &old)
 
virtual ~ToolbarButton ()
 
std::string action () const
 
int slot () const
 
void loadState (const ObjectState *state)
 
ObjectStatesaveState () const
 
- Public Member Functions inherited from Serializable
virtual ~Serializable ()
 

Static Public Attributes

static const std::string OSNAME_TOOLBAR_BUTTON = "tbbutton"
 ObjectState name for ToolbarButton. More...
 
static const std::string OSKEY_SLOT = "slot"
 ObjectState attribute key for slot position. More...
 
static const std::string OSKEY_ACTION = "action"
 ObjectState attribute key for action name. More...
 

Private Attributes

int slot_
 Number of the slot in which this toolbar button is. More...
 
std::string action_
 Name of the action performed by this toolbar button. More...
 

Detailed Description

This class repsesents a toolbar button. It contains information which action is performed by the button and where the button is placed in the toolbar. This class implements the Serializable interface because toolbar button configurations are serialized in the configuration file.

Definition at line 48 of file ToolbarButton.hh.

Constructor & Destructor Documentation

◆ ToolbarButton() [1/3]

ToolbarButton::ToolbarButton ( int  slot,
const std::string &  action 
)

Constructor.

Parameters
slotNumber of the slot in which the button is placed.
actionName of the action performed by the button.

Definition at line 50 of file ToolbarButton.cc.

52  :
54 }

◆ ToolbarButton() [2/3]

ToolbarButton::ToolbarButton ( const ObjectState state)

Constructor.

Loads the state from the given ObjectsState object.

Definition at line 62 of file ToolbarButton.cc.

62  {
63  loadState(state);
64 }

References loadState().

Here is the call graph for this function:

◆ ToolbarButton() [3/3]

ToolbarButton::ToolbarButton ( const ToolbarButton old)

Copy constructor.

Definition at line 70 of file ToolbarButton.cc.

70  :
71  Serializable() {
72  slot_ = old.slot_;
73  action_ = old.action_;
74 }

References action_, and slot_.

◆ ~ToolbarButton()

ToolbarButton::~ToolbarButton ( )
virtual

Destructor.

Definition at line 80 of file ToolbarButton.cc.

80  {
81 }

Member Function Documentation

◆ action()

std::string ToolbarButton::action ( ) const

Returns the name of the action performed by the button.

Returns
Name of the action performed by the button.

Definition at line 90 of file ToolbarButton.cc.

90  {
91  return action_;
92 }

References action_.

Referenced by GUIOptions::createToolbar(), OptionsDialog::readOptions(), and MainFrame::updateUI().

◆ loadState()

void ToolbarButton::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.

Definition at line 114 of file ToolbarButton.cc.

114  {
115  string procName = "ToolbarButton::loadState";
116 
117  if (state->name() != OSNAME_TOOLBAR_BUTTON) {
118  throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
119  }
120 
121  try {
122  slot_ = state->intAttribute(OSKEY_SLOT);
124  } catch (...) {
125  throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
126  }
127 }

References action_, ObjectState::intAttribute(), ObjectState::name(), OSKEY_ACTION, OSKEY_SLOT, OSNAME_TOOLBAR_BUTTON, slot_, and ObjectState::stringAttribute().

Referenced by ToolbarButton().

Here is the call graph for this function:

◆ saveState()

ObjectState * ToolbarButton::saveState ( ) const
virtual

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

Returns
The created ObjectState object.

Implements Serializable.

Definition at line 135 of file ToolbarButton.cc.

135  {
137  state->setAttribute(OSKEY_SLOT, slot_);
139  return state;
140 }

References action_, OSKEY_ACTION, OSKEY_SLOT, OSNAME_TOOLBAR_BUTTON, ObjectState::setAttribute(), and slot_.

Referenced by GUIOptions::saveState().

Here is the call graph for this function:

◆ slot()

int ToolbarButton::slot ( ) const

Returns the position of the slot which contains the button.

Returns
Position of the slot which contains the button.

Definition at line 101 of file ToolbarButton.cc.

101  {
102  return slot_;
103 }

References slot_.

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

Member Data Documentation

◆ action_

std::string ToolbarButton::action_
private

Name of the action performed by this toolbar button.

Definition at line 72 of file ToolbarButton.hh.

Referenced by action(), loadState(), saveState(), and ToolbarButton().

◆ OSKEY_ACTION

const string ToolbarButton::OSKEY_ACTION = "action"
static

◆ OSKEY_SLOT

const string ToolbarButton::OSKEY_SLOT = "slot"
static

◆ OSNAME_TOOLBAR_BUTTON

const string ToolbarButton::OSNAME_TOOLBAR_BUTTON = "tbbutton"
static

◆ slot_

int ToolbarButton::slot_
private

Number of the slot in which this toolbar button is.

Definition at line 70 of file ToolbarButton.hh.

Referenced by loadState(), saveState(), slot(), and ToolbarButton().


The documentation for this class was generated from the following files:
ToolbarButton::slot_
int slot_
Number of the slot in which this toolbar button is.
Definition: ToolbarButton.hh:70
ToolbarButton::OSKEY_ACTION
static const std::string OSKEY_ACTION
ObjectState attribute key for action name.
Definition: ToolbarButton.hh:55
ToolbarButton::action
std::string action() const
Definition: ToolbarButton.cc:90
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
ObjectStateLoadingException
Definition: Exception.hh:551
Serializable
Definition: Serializable.hh:44
ObjectState
Definition: ObjectState.hh:59
ToolbarButton::loadState
void loadState(const ObjectState *state)
Definition: ToolbarButton.cc:114
ToolbarButton::OSNAME_TOOLBAR_BUTTON
static const std::string OSNAME_TOOLBAR_BUTTON
ObjectState name for ToolbarButton.
Definition: ToolbarButton.hh:51
ToolbarButton::slot
int slot() const
Definition: ToolbarButton.cc:101
ObjectState::name
std::string name() const
ToolbarButton::OSKEY_SLOT
static const std::string OSKEY_SLOT
ObjectState attribute key for slot position.
Definition: ToolbarButton.hh:53
ToolbarButton::action_
std::string action_
Name of the action performed by this toolbar button.
Definition: ToolbarButton.hh:72
ObjectState::intAttribute
int intAttribute(const std::string &name) const
Definition: ObjectState.cc:276
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100