appkit  1.5.1
RoadNarrows Robotics Application Kit
WinGtkMenu.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: RoadNarrows Robotics Application Tool Kit
4 //
5 // Link: https://github.com/roadnarrows-robotics/rnr-sdk
6 //
7 // Library: librnr_wingtk
8 //
9 // File: WinGtkMenu.h
10 //
11 /*! \file
12  *
13  * $LastChangedDate: 2013-05-03 07:45:13 -0600 (Fri, 03 May 2013) $
14  * $Rev: 2904 $
15  *
16  * \brief RoadNarrows Robotics GTK derived window button menu interface.
17  *
18  * \author Robin Knight (robin.knight@roadnarrows.com)
19  * \author Daniel Packard (daniel@roadnarrows.com)
20  *
21  * \par Copyright
22  * \h_copy 2011-2017. RoadNarrows LLC.\n
23  * http://www.roadnarrows.com\n
24  * All Rights Reserved
25  */
26 /*
27  * @EulaBegin@
28  *
29  * Permission is hereby granted, without written agreement and without
30  * license or royalty fees, to use, copy, modify, and distribute this
31  * software and its documentation for any purpose, provided that
32  * (1) The above copyright notice and the following two paragraphs
33  * appear in all copies of the source code and (2) redistributions
34  * including binaries reproduces these notices in the supporting
35  * documentation. Substantial modifications to this software may be
36  * copyrighted by their authors and need not follow the licensing terms
37  * described here, provided that the new terms are clearly indicated in
38  * all files where they apply.
39  *
40  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
41  * OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
42  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
43  * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
44  * EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
45  * THE POSSIBILITY OF SUCH DAMAGE.
46  *
47  * THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
48  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
49  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
50  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
51  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
52  *
53  * @EulaEnd@
54  */
55 ////////////////////////////////////////////////////////////////////////////////
56 
57 #ifndef _RNR_WIN_GTK_BUTTON_MENU_H
58 #define _RNR_WIN_GTK_BUTTON_MENU_H
59 
60 #include <string>
61 
62 #include "rnr/rnrconfig.h"
63 
64 #include <gtk/gtk.h>
65 
66 #include "rnr/appkit/Win.h"
67 #include "rnr/appkit/WinGtk.h"
68 #include "rnr/appkit/WinMenu.h"
69 
70 /*!
71  * \brief RoadNarrows Robotics
72  */
73 namespace rnr
74 {
75  //...........................................................................
76  // Class WinGtkButton
77  //...........................................................................
78 
79  /*!
80  * \brief GTK window derived button class.
81  */
82  class WinGtkButton : public WinButton
83  {
84  public:
85 
86  /*!
87  * \brief WinGtkButton initialization constructor.
88  *
89  * \param eType Button type.
90  * \param nEvent Event associated with button press (and id).
91  * \param eInitState Button widget initial state.
92  * See \ref rnrwin_widgetstate.
93  * \param eAlign Button alignment. See \ref rnmpwin_align.
94  * \param strAltText Button alternative text string.
95  * \param strTagNormal Button visual tag for normal state.
96  * Either icon path or text string label.
97  * \param strToolTipNormal Button tooltip for normal state.
98  * \param strTagActive Button visual tag for active state.
99  * Either icon path or text string label.
100  * Empty for no tag.
101  * \param strToolTipActive Button tooltip for active state.
102  */
104  int nEvent,
105  WidgetState eInitState,
106  AlignOp eAlign,
107  const std::string &strAltText,
108  const std::string &strTagNormal,
109  const std::string &strToolTipNormal = "",
110  const std::string &strTagActive = "",
111  const std::string &strToolTipActive = "");
112 
113  /*!
114  * \brief WinGtkButton copy constructor.
115  *
116  * \param src Source button item.
117  */
118  WinGtkButton(const WinGtkButton &src);
119 
120  /*!
121  * \brief Destructor.
122  */
123  virtual ~WinGtkButton();
124 
125  /*!
126  * \brief Get the normal icon image widget.
127  *
128  * \return Returns (possibly NULL) pointer to image widget
129  * (gui toolkit specific).
130  */
131  virtual void *getNormalImageWidget()
132  {
133  return m_wImgNormal;
134  }
135 
136  /*!
137  * \brief Get the active icon image widget.
138  *
139  * \return Returns (possibly NULL) pointer to image widget
140  * (gui toolkit specific).
141  */
142  virtual void *getActiveImageWidget()
143  {
144  return m_wImgActive;
145  }
146 
147  friend class WinGtkButtonMenu;
148 
149  protected:
150  GtkWidget *m_wImgNormal; ///< normal state menu button icon
151  GtkWidget *m_wImgActive; ///< active state menu button icon
152 
153  /*!
154  * \brief Load icon image from file.
155  *
156  * \note For best visualization, the icons should be 48x48 pixels.
157  *
158  * \param strIconPath Icon file path.
159  *
160  * \return Returns pointer to GtkImage widget if icon successfully loaded,
161  * else returns NULL.
162  */
163  GtkWidget *loadIcon(const std::string &strIconPath);
164  };
165 
166 
167  //...........................................................................
168  // Class WinGtkButtonMenu
169  //...........................................................................
170 
171  /*!
172  * \brief GTK window derived button menu class.
173  *
174  * Buttons with icons or text are placed on the left or right side of the
175  * application window. Each icon is associated with an application defined
176  * event.
177  */
179  {
180  public:
181 
182  /*!
183  * \brief WinGtkButtonMenu initialization constructor.
184  *
185  * \param strIconPath Icon path of search directories.
186  */
187  WinGtkButtonMenu(const std::string &strIconPath=WinIconDirDft) :
188  WinButtonMenu(strIconPath)
189  {
190  }
191 
192  /*!
193  * \brief WinGtkButtonMenu destructor.
194  */
195  virtual ~WinGtkButtonMenu() { }
196 
197  /*!
198  * \brief Add button with image to menu.
199  *
200  * \note Buttons are added to window only at bind() time.
201  *
202  * \param nEvent Unique event (and id) associated with button
203  * press.
204  * \param eInitState Button widget initial state.
205  * See \ref rnrwin_widgetstate.
206  * \param eAlign Button alignment. See \ref rnmpwin_align.
207  * \param strAltText Button alternative text string.
208  * \param strIconNormal Button icon image file name for normal state.
209  * \param strToolTipNormal Button tooltip for normal state.
210  * \param strIconActive Button icon image file name for active state.
211  * Empty for no icon.
212  * \param strToolTipActive Button tooltip for active state.
213  *
214  * \return Returns true on success, false otherwise.
215  */
216  virtual bool addImageButton(int nEvent,
217  WidgetState eInitState,
218  AlignOp eAlign,
219  const std::string &strAltText,
220  const std::string &strIconNormal,
221  const std::string &strToolTipNormal = "",
222  const std::string &strIconActive = "",
223  const std::string &strToolTipActive = "");
224 
225  /*!
226  * \brief Add button with text label to menu.
227  *
228  * \note Buttons are added to window only at bind() time.
229  *
230  * \param nEvent Unique event (and id) associated with button
231  * press.
232  * \param eInitState Button widget initial state.
233  * See \ref rnrwin_widgetstate.
234  * \param eAlign Button alignment. See \ref rnmpwin_align.
235  * \param strLabelNormal Button text label for normal state.
236  * \param strToolTipNormal Button tooltip for normal state.
237  * \param strLabelActive Button text label for active state.
238  * Empty for no label.
239  * \param strToolTipActive Button tooltip for active state.
240  *
241  * \return Returns true on success, false otherwise.
242  */
243  virtual bool addLabelButton(int nEvent,
244  WidgetState eInitState,
245  AlignOp eAlign,
246  const std::string &strLabelNormal,
247  const std::string &strToolTipNormal = "",
248  const std::string &strLabelActive = "",
249  const std::string &strToolTipActive = "");
250 
251  protected:
252  };
253 
254 } // namespace
255 
256 
257 #endif // _RNR_WIN_GTK_BUTTON_MENU_H
WidgetState
Definition: Win.h:129
WinButtonType
Window button types.
Definition: WinMenu.h:81
Window button menu base class.
Definition: WinMenu.h:232
virtual ~WinGtkButtonMenu()
WinGtkButtonMenu destructor.
Definition: WinGtkMenu.h:195
virtual void * getActiveImageWidget()
Get the active icon image widget.
Definition: WinGtkMenu.h:142
WinGtkButtonMenu(const std::string &strIconPath=WinIconDirDft)
WinGtkButtonMenu initialization constructor.
Definition: WinGtkMenu.h:187
RoadNarrows Robotics GTK derived WinGtk window class interface.
GtkWidget * m_wImgActive
active state menu button icon
Definition: WinGtkMenu.h:151
RoadNarrows Robotics Win abstract base class interface.
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.
RoadNarrows Robotics base window button menu interface.
GTK window derived button menu class.
Definition: WinGtkMenu.h:178
virtual ~WinGtkButton()
Destructor.
Definition: WinGtkMenu.cxx:119
AlignOp
Definition: Win.h:81
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
Window button base class.
Definition: WinMenu.h:94
GTK window derived button class.
Definition: WinGtkMenu.h:82
virtual void * getNormalImageWidget()
Get the normal icon image widget.
Definition: WinGtkMenu.h:131
RoadNarrows Robotics.
Definition: Camera.h:74