appkit  1.5.1
RoadNarrows Robotics Application Kit
rnr::WinGtkButtonMenu Class Reference

GTK window derived button menu class. More...

#include <WinGtkMenu.h>

Inheritance diagram for rnr::WinGtkButtonMenu:
rnr::WinButtonMenu

Public Member Functions

 WinGtkButtonMenu (const std::string &strIconPath=WinIconDirDft)
 WinGtkButtonMenu initialization constructor. More...
 
virtual ~WinGtkButtonMenu ()
 WinGtkButtonMenu destructor.
 
virtual bool addImageButton (int nEvent, WidgetState eInitState, AlignOp eAlign, const std::string &strAltText, const std::string &strIconNormal, const std::string &strToolTipNormal="", const std::string &strIconActive="", const std::string &strToolTipActive="")
 Add button with image to menu. More...
 
virtual bool addLabelButton (int nEvent, WidgetState eInitState, AlignOp eAlign, const std::string &strLabelNormal, const std::string &strToolTipNormal="", const std::string &strLabelActive="", const std::string &strToolTipActive="")
 Add button with text label to menu. More...
 
- Public Member Functions inherited from rnr::WinButtonMenu
 WinButtonMenu (const std::string &strIconPath=WinIconDirDft)
 WinButtonMenu initialization constructor. More...
 
virtual ~WinButtonMenu ()
 WinButtonMenu destructor.
 
void appendIconDir (const std::string &strIconDir)
 Append directory to icon search path. More...
 
void prependIconDir (const std::string &strIconDir)
 Prepend directory to icon search path. More...
 
void setIconPath (const std::string &strIconPath)
 Set icon search path. More...
 
std::string getIconPath ()
 Get icon search path. More...
 
virtual void bind (Win *pWin)
 Bind the button menu to the given window. More...
 
virtual void unbind ()
 Unbind the menu from the currently bound window.
 
int getCurrentEvent ()
 Get the current button menu event. More...
 
int setCurrentEvent (int nNewEvent)
 Set the current button menu event. More...
 
int getPreviousEvent ()
 Get the previous menu event. More...
 
size_t getNumMenuButtons ()
 Get the current number of menu items;. More...
 
WidgetState getButtonState (int nEvent)
 Get the given button state. More...
 
void setButtonState (int nEvent, WidgetState eNewState)
 Set the given button state. More...
 
void setButtonStateList (const std::string &strEvent,...)
 Set the states of the given buttons. More...
 
void resetAllButtonStates ()
 Reset all menu buttons states to their initial states.
 

Additional Inherited Members

- Public Types inherited from rnr::WinButtonMenu
typedef std::map< int, WinButton * > MapBttns_T
 map of added menu buttons
 
- Protected Member Functions inherited from rnr::WinButtonMenu
std::string makeIconPath (const std::string &strIconFile)
 Make icon image file path. More...
 
void changeButtonState (WinButton *pButton, WidgetState eNewState)
 Change the state and gui look of the given button. More...
 
- Static Protected Member Functions inherited from rnr::WinButtonMenu
static void onMenuButtonClick (int nEvent, void *user_data)
 Menu button press callback. More...
 
- Protected Attributes inherited from rnr::WinButtonMenu
Winm_pWin
 menus are bound to this window
 
std::string m_strIconPath
 icon directories search path
 
int m_nCurrentEvent
 current (user) menu event
 
int m_nPreviousEvent
 previous (user) menu event
 
MapBttns_T m_mapButtons
 menu button map
 

Detailed Description

GTK window derived button menu class.

Buttons with icons or text are placed on the left or right side of the application window. Each icon is associated with an application defined event.

Definition at line 178 of file WinGtkMenu.h.

Constructor & Destructor Documentation

rnr::WinGtkButtonMenu::WinGtkButtonMenu ( const std::string &  strIconPath = WinIconDirDft)
inline

WinGtkButtonMenu initialization constructor.

Parameters
strIconPathIcon path of search directories.

Definition at line 187 of file WinGtkMenu.h.

187  :
188  WinButtonMenu(strIconPath)
189  {
190  }
WinButtonMenu(const std::string &strIconPath=WinIconDirDft)
WinButtonMenu initialization constructor.
Definition: WinMenu.h:243

Member Function Documentation

bool WinGtkButtonMenu::addImageButton ( int  nEvent,
WidgetState  eInitState,
AlignOp  eAlign,
const std::string &  strAltText,
const std::string &  strIconNormal,
const std::string &  strToolTipNormal = "",
const std::string &  strIconActive = "",
const std::string &  strToolTipActive = "" 
)
virtual

Add button with image to menu.

Note
Buttons are added to window only at bind() time.
Parameters
nEventUnique event (and id) associated with button press.
eInitStateButton widget initial state. See GUI Widget State.
eAlignButton alignment. See rnmpwin_align.
strAltTextButton alternative text string.
strIconNormalButton icon image file name for normal state.
strToolTipNormalButton tooltip for normal state.
strIconActiveButton icon image file name for active state. Empty for no icon.
strToolTipActiveButton tooltip for active state.
Returns
Returns true on success, false otherwise.

Reimplemented from rnr::WinButtonMenu.

Definition at line 156 of file WinGtkMenu.cxx.

References rnr::WinButtonTypeImage, rnr::WinButtonTypeLabel, and rnr::WinGtkButton::WinGtkButton().

164 {
165  // button associated with the given event already exists
166  if( m_mapButtons.find(nEvent) != m_mapButtons.end() )
167  {
168  return false;
169  }
170 
171  string strIconPathNormal = makeIconPath(strIconNormal);
172  string strIconPathActive = makeIconPath(strIconActive);
173 
174  // add image button
175  if( !strIconPathNormal.empty() )
176  {
178  nEvent,
179  eInitState,
180  eAlign,
181  strAltText,
182  strIconPathNormal,
183  strToolTipNormal,
184  strIconPathActive,
185  strToolTipActive);
186 
187  }
188 
189  // no image, make an label button instead
190  else
191  {
193  nEvent,
194  eInitState,
195  eAlign,
196  "",
197  strAltText,
198  strToolTipNormal);
199  }
200 
201  return true;
202 }
MapBttns_T m_mapButtons
menu button map
Definition: WinMenu.h:486
button has text label(s)
Definition: WinMenu.h:84
button has image(s)
Definition: WinMenu.h:83
GTK window derived button class.
Definition: WinGtkMenu.h:82
std::string makeIconPath(const std::string &strIconFile)
Make icon image file path.
Definition: WinMenu.cxx:275
bool WinGtkButtonMenu::addLabelButton ( int  nEvent,
WidgetState  eInitState,
AlignOp  eAlign,
const std::string &  strLabelNormal,
const std::string &  strToolTipNormal = "",
const std::string &  strLabelActive = "",
const std::string &  strToolTipActive = "" 
)
virtual

Add button with text label to menu.

Note
Buttons are added to window only at bind() time.
Parameters
nEventUnique event (and id) associated with button press.
eInitStateButton widget initial state. See GUI Widget State.
eAlignButton alignment. See rnmpwin_align.
strLabelNormalButton text label for normal state.
strToolTipNormalButton tooltip for normal state.
strLabelActiveButton text label for active state. Empty for no label.
strToolTipActiveButton tooltip for active state.
Returns
Returns true on success, false otherwise.

Reimplemented from rnr::WinButtonMenu.

Definition at line 204 of file WinGtkMenu.cxx.

References rnr::WinButtonTypeLabel, and rnr::WinGtkButton::WinGtkButton().

211 {
212  // button associated with the given event already exists
213  if( m_mapButtons.find(nEvent) != m_mapButtons.end() )
214  {
215  return false;
216  }
217 
218  // add label button
220  nEvent,
221  eInitState,
222  eAlign,
223  "",
224  strLabelNormal,
225  strToolTipNormal,
226  strLabelActive,
227  strToolTipNormal);
228 
229  return true;
230 }
MapBttns_T m_mapButtons
menu button map
Definition: WinMenu.h:486
button has text label(s)
Definition: WinMenu.h:84
GTK window derived button class.
Definition: WinGtkMenu.h:82

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