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

GTK window derived button class. More...

#include <WinGtkMenu.h>

Inheritance diagram for rnr::WinGtkButton:
rnr::WinButton

Public Member Functions

 WinGtkButton (WinButtonType eType, int nEvent, WidgetState eInitState, AlignOp eAlign, const std::string &strAltText, const std::string &strTagNormal, const std::string &strToolTipNormal="", const std::string &strTagActive="", const std::string &strToolTipActive="")
 WinGtkButton initialization constructor. More...
 
 WinGtkButton (const WinGtkButton &src)
 WinGtkButton copy constructor. More...
 
virtual ~WinGtkButton ()
 Destructor.
 
virtual void * getNormalImageWidget ()
 Get the normal icon image widget. More...
 
virtual void * getActiveImageWidget ()
 Get the active icon image widget. More...
 
- Public Member Functions inherited from rnr::WinButton
 WinButton (WinButtonType eType, int nEvent, WidgetState eInitState, AlignOp eAlign, const std::string &strAltText, const std::string &strTagNormal, const std::string &strToolTipNormal="", const std::string &strTagActive="", const std::string &strToolTipActive="")
 WinButton initialization constructor. More...
 
 WinButton (const WinButton &src)
 WinButton copy constructor. More...
 
virtual ~WinButton ()
 Destructor.
 
void * getCurrentImageWidget ()
 Get the icon image widget associated with the current button state. More...
 
std::string getCurrentLabel ()
 Get the text label associated with the current button state. More...
 
std::string getCurrentToolTip ()
 Get the tooltip associated with the current button state. More...
 

Protected Member Functions

GtkWidget * loadIcon (const std::string &strIconPath)
 Load icon image from file. More...
 
- Protected Member Functions inherited from rnr::WinButton
void copy (const WinButton *pSrc)
 Deep copy of source to this. More...
 

Protected Attributes

GtkWidget * m_wImgNormal
 normal state menu button icon
 
GtkWidget * m_wImgActive
 active state menu button icon
 
- Protected Attributes inherited from rnr::WinButton
WinButtonType m_eType
 button type
 
int m_nEvent
 button push "mouse click" event
 
WidgetState m_eInitState
 initial button widget state
 
WidgetState m_eState
 current button widget state
 
AlignOp m_eAlign
 left or right alignment
 
std::string m_strAltText
 alternate text for icon(s)
 
std::string m_strTagNormal
 button icon for normal state
 
std::string m_strToolTipNormal
 button tooltip for normal state
 
std::string m_strTagActive
 button icon for active state
 
std::string m_strToolTipActive
 button tooltip for active state
 

Friends

class WinGtkButtonMenu
 

Detailed Description

GTK window derived button class.

Definition at line 82 of file WinGtkMenu.h.

Constructor & Destructor Documentation

rnr::WinGtkButton::WinGtkButton ( WinButtonType  eType,
int  nEvent,
WidgetState  eInitState,
AlignOp  eAlign,
const std::string &  strAltText,
const std::string &  strTagNormal,
const std::string &  strToolTipNormal = "",
const std::string &  strTagActive = "",
const std::string &  strToolTipActive = "" 
)

WinGtkButton initialization constructor.

Parameters
eTypeButton type.
nEventEvent associated with button press (and id).
eInitStateButton widget initial state. See GUI Widget State.
eAlignButton alignment. See rnmpwin_align.
strAltTextButton alternative text string.
strTagNormalButton visual tag for normal state. Either icon path or text string label.
strToolTipNormalButton tooltip for normal state.
strTagActiveButton visual tag for active state. Either icon path or text string label. Empty for no tag.
strToolTipActiveButton tooltip for active state.

Referenced by rnr::WinGtkButtonMenu::addImageButton(), and rnr::WinGtkButtonMenu::addLabelButton().

WinGtkButton::WinGtkButton ( const WinGtkButton src)

WinGtkButton copy constructor.

Parameters
srcSource button item.

Definition at line 105 of file WinGtkMenu.cxx.

References loadIcon(), rnr::WinButton::m_eType, rnr::WinButton::m_strTagActive, rnr::WinButton::m_strTagNormal, m_wImgActive, m_wImgNormal, and rnr::WinButtonTypeImage.

105  : WinButton(src)
106 {
107  if( m_eType == WinButtonTypeImage )
108  {
111  }
112  else
113  {
114  m_wImgNormal = NULL;
115  m_wImgActive = NULL;
116  }
117 }
WinButtonType m_eType
button type
Definition: WinMenu.h:201
GtkWidget * m_wImgActive
active state menu button icon
Definition: WinGtkMenu.h:151
WinButton(WinButtonType eType, int nEvent, WidgetState eInitState, AlignOp eAlign, const std::string &strAltText, const std::string &strTagNormal, const std::string &strToolTipNormal="", const std::string &strTagActive="", const std::string &strToolTipActive="")
WinButton initialization constructor.
Definition: WinMenu.h:115
std::string m_strTagNormal
button icon for normal state
Definition: WinMenu.h:207
button has image(s)
Definition: WinMenu.h:83
GtkWidget * loadIcon(const std::string &strIconPath)
Load icon image from file.
Definition: WinGtkMenu.cxx:132
GtkWidget * m_wImgNormal
normal state menu button icon
Definition: WinGtkMenu.h:150
std::string m_strTagActive
button icon for active state
Definition: WinMenu.h:209

Member Function Documentation

virtual void* rnr::WinGtkButton::getActiveImageWidget ( )
inlinevirtual

Get the active icon image widget.

Returns
Returns (possibly NULL) pointer to image widget (gui toolkit specific).

Reimplemented from rnr::WinButton.

Definition at line 142 of file WinGtkMenu.h.

References m_wImgActive.

143  {
144  return m_wImgActive;
145  }
GtkWidget * m_wImgActive
active state menu button icon
Definition: WinGtkMenu.h:151
virtual void* rnr::WinGtkButton::getNormalImageWidget ( )
inlinevirtual

Get the normal icon image widget.

Returns
Returns (possibly NULL) pointer to image widget (gui toolkit specific).

Reimplemented from rnr::WinButton.

Definition at line 131 of file WinGtkMenu.h.

References m_wImgNormal.

132  {
133  return m_wImgNormal;
134  }
GtkWidget * m_wImgNormal
normal state menu button icon
Definition: WinGtkMenu.h:150
GtkWidget * WinGtkButton::loadIcon ( const std::string &  strIconPath)
protected

Load icon image from file.

Note
For best visualization, the icons should be 48x48 pixels.
Parameters
strIconPathIcon file path.
Returns
Returns pointer to GtkImage widget if icon successfully loaded, else returns NULL.

Definition at line 132 of file WinGtkMenu.cxx.

Referenced by WinGtkButton().

133 {
134  GtkWidget *wBttnImg;
135 
136  if( access(strIconPath.c_str(), F_OK|R_OK) != 0 )
137  {
138  LOGSYSERROR("%s: %s(errno=%d)", strIconPath.c_str());
139  return NULL;
140  }
141 
142  // never returns null - will return "broken" icon instead
143  wBttnImg = gtk_image_new_from_file(strIconPath.c_str());
144 
145  // menu item owns this widget
146  gtk_widget_ref(wBttnImg);
147 
148  return wBttnImg;
149 }

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