![]() |
appkit
1.5.1
RoadNarrows Robotics Application Kit
|
WinGtk window derived class. More...
#include <WinGtk.h>
Classes | |
| struct | BttnInfo_T |
Public Member Functions | |
| WinGtk (const std::string &strWinName, int nWidth, int nHeight, bool bDecorate=true) | |
| Default initialization constructor. More... | |
| virtual | ~WinGtk () |
| Destructor. | |
| virtual const char * | getGuiToolkitName () |
| Get GUI toolkit name. More... | |
| virtual void | setLookAndFeel (const std::string &strKey, const std::string &strVal) |
| Set GUI look and feel value. More... | |
| virtual GdkColor * | getLookAndFeelGdkColor (const std::string &strKey) |
| Get the GUI look and feel GDK color. More... | |
| virtual PangoFontDescription * | getLookAndFeelFont (const std::string &strKey) |
| Get the GUI look and feel Pango font description. More... | |
| virtual void | show () |
| Show/refresh all gui widgets in window. | |
| virtual void | showCvImage (cv::Mat &img, uint_t uImgIndex=0) |
| Show a OpenCV image on the workspace. More... | |
| virtual void | showPageRef (int nPageId) |
| Show page reference number. More... | |
| virtual void | showPageRef (const std::string &strPageRef) |
| Show page reference. More... | |
| virtual void | showStatus (const char *sFmt,...) |
| Show status message. More... | |
| virtual void | clearStatus () |
| Clear status message. | |
| virtual int | waitKey (int delay) |
| Wait for keypress or timeout. More... | |
| virtual void | waitMouse (int delay) |
| Wait for timeout or registered mouse event. More... | |
| virtual void | wait (int delay) |
| Wait for timeout. More... | |
| virtual bool | addImageButton (int nBttnId, AlignOp eAlign, const std::string &strIconPath, const std::string &strAltText, const std::string &strToolTip="") |
| Add a button with an image to window button menu. More... | |
| virtual bool | addImageButton (int nBttnId, AlignOp eAlign, void *wBttnImg, const std::string &strAltText, const std::string &strToolTip="") |
| Add a button with a GTK image widget to window button menu. More... | |
| virtual bool | addLabelButton (int nBttnId, AlignOp eAlign, const std::string &strLabel, const std::string &strToolTip="") |
| Add a button with a label to window button menu. More... | |
| virtual bool | addButton (int nBttnId, AlignOp eAlign, GtkWidget *wBttn) |
| Add a GTK button widget to window button menu. More... | |
| virtual bool | replaceButtonImage (int nBttnId, const std::string &strIconPath, const std::string &strToolTip="") |
| Replace existing button image with new image. More... | |
| virtual bool | replaceButtonImage (int nBttnId, void *wBttnImg, const std::string &strToolTip="") |
| Replace existing button image with new GTK image widget. More... | |
| virtual bool | replaceButtonLabel (int nBttnId, const std::string &strLabel, const std::string &strToolTip="") |
| Replace existing button label with new label. More... | |
| virtual bool | removeButton (int nBttnId) |
| Remove a button from a menu. More... | |
| virtual void | removeAllButtons () |
| Remove all buttons from all menus. | |
| virtual bool | showButtonState (int nBttnId, WidgetState eBttnState) |
| Show a button's widget state. More... | |
| virtual void | initWorkspace () |
| Initialize window's workspace to hold a GTK toolkit widget tree. More... | |
| virtual void | initWorkspaceAsGtk () |
| Initialize window's workspace to hold a GTK widget tree. More... | |
| virtual uint_t | initWorkspaceAsCvImage () |
| Initialize the workspace as a display to show OpenCV images. More... | |
| virtual void | initWorkspaceAsGstWin (const cv::Size &sizeVidWin) |
| Initialize the workspace as a window display to show GStreamer video/images. More... | |
| virtual uint_t | addWorkspaceCvImageDisplay (void *wContainer) |
| Add an OpenCV display widget to the container widget. More... | |
| virtual void | removeWorkspaceCvImageDisplay (uint_t uImgIndex) |
| Remove OpenCV display widget from workspace. More... | |
| virtual void | showWorkspace () |
| Show/refresh all gui widgets in workspace. | |
| virtual void | eraseWorkspace () |
| Remove all widgets contained in the window's workspace container. More... | |
| GtkWidget * | getMainWidget () |
| Get the top-level main widget. More... | |
| GtkWindow * | getMainWindowWidget () |
| Get the top-level main window. More... | |
| GtkWidget * | getWorkspaceVBox () |
| Get the window's workspace top vertical box container widget. More... | |
| GtkWidget * | getExtraVBox () |
| Get the window's workspace extra vertical box container widget. More... | |
| GtkWidget * | getGstWin () |
| Get GStreamer X-Window widget. More... | |
Public Member Functions inherited from rnr::Win | |
| Win (const std::string &strWinName, int nWidth, int nHeight, bool bDecorate=true) | |
| Windowing class initialization constructor. More... | |
| virtual | ~Win () |
| Destructor. | |
| virtual std::string | getLookAndFeel (const std::string &strKey) |
| Get the GUI look and feel value. More... | |
| cv::Size | getWorkspaceSize () |
| Get the window's workspace size. More... | |
| ulong_t | getGstXid () |
| Get GStreamer X-Window id. More... | |
| void | registerCvImageMouseCallback (MouseCbFunc_T funcCb, void *param, uint_t uImgIndex=0) |
| Register application mouse event callback. More... | |
| void | unregisterCvImageMouseCallback (uint_t uImgIndex=0) |
| Unregister application mouse event callback. More... | |
| void | registerKeyboardCallback (KeyCbFunc_T funcCb, void *param) |
| Register application keyboard press event callback. More... | |
| void | unregisterKeyboardCallback () |
| Unregister application keyboard press event callback. | |
| void | registerButtonClickCallback (BttnCbFunc_T funcCb, void *param) |
| Register application button click event callback. More... | |
| void | unregisterButtonClickCallback () |
| Unregister application button click event callback. | |
Protected Types | |
| typedef std::map< int, BttnInfo_T > | MapBttns_T |
| button map type | |
| typedef std::map< std::string, GdkColor > | MapGdkColor_T |
| color map type | |
| typedef std::map< std::string, PangoFontDescription * > | MapPangoFont_T |
| font map type | |
Protected Types inherited from rnr::Win | |
| typedef std::map< std::string, std::string > | MapLookFeel_T |
Protected Member Functions | |
| int | getBttnMenuIdx (AlignOp eAlign) |
| Get button menu index from alignment enum. More... | |
| bool | findBttn (int nBttnId, MapBttns_T::iterator &pos) |
| Find button. More... | |
| void | convertLookAndFeelDefaults () |
| Convert Look and Feel defaults to native GTK/GDK values. | |
| virtual void | configureCvImage (uint_t uImgIndex) |
| Configure OpenCV image widget. More... | |
Protected Member Functions inherited from rnr::Win | |
| void | setLookAndFeelDefaults () |
| Set look and feel standard set defaults. | |
Static Protected Member Functions | |
| static void | onRemoveWidget (GtkWidget *w, gpointer user_data) |
| Remove widget callback handler. More... | |
| static gboolean | onAlarm (gpointer user_data) |
| Timeout expiry callback handler. More... | |
| static gboolean | onKeyPress (GtkWidget *w, GdkEventKey *event, gpointer *user_data) |
| Keyboard press event callback handler. More... | |
| static gboolean | onMouseCvImage (GtkWidget *w, GdkEventKey *event, gpointer *user_data) |
| Mouse event on OpenCV Image widget workspace callback handler. More... | |
| static void | onButtonClick (GtkWidget *w, gpointer *user_data) |
| Button press event handler. More... | |
| static void | onRealizeGstWin (GtkWidget *w, gpointer user_data) |
| Realize GStreamer video window callback. More... | |
Protected Attributes | |
| GtkWidget * | m_wMain |
| main widget | |
| GtkWindow * | m_wWindowMain |
| main widnow widget | |
| GtkWidget * | m_wContainer |
| top container widget (hbox) | |
| GtkWidget * | m_wBttnMenu [NumOfButtonMenus] |
| left menu container widget | |
| GtkWidget * | m_wWorkspace |
| middle workspace container widget | |
| GtkWidget * | m_wExtraVBox |
| extra vertical box | |
| GtkWidget * | m_wIcon |
| workspace identifying icon | |
| GtkWidget * | m_wStatusFrame |
| holds page reference and status bar | |
| GtkWidget * | m_wPageRef |
| workflow page reference | |
| GtkWidget * | m_wStatusBar |
| status message bar | |
| GtkWidget * | m_wCvImage [MaxCvImages] |
| CvImage widgets. | |
| GtkWidget * | m_wCvImageBox [MaxCvImages] |
| CvImage box containers. | |
| GtkWidget * | m_wGstWin |
| GstWin container widget. | |
| CvSize | m_sizeCvImage [MaxCvImages] |
| size of shown CvImage | |
| CvPoint | m_ptCvImageOrig [MaxCvImages] |
| origin of shown CvImage | |
| MapBttns_T | m_mapBttns [NumOfButtonMenus] |
| left/right map of menu buttons. | |
| MapGdkColor_T | m_mapColors |
| look and feel color map | |
| MapPangoFont_T | m_mapFonts |
| look and feel font map | |
Protected Attributes inherited from rnr::Win | |
| std::string | m_strWinName |
| window name (and title) | |
| int | m_nWinWidth |
| window width | |
| int | m_nWinHeight |
| window height | |
| bool | m_bDecorate |
| do [not] decorate window | |
| CvRect | m_rectWorkspace |
| workspace bounding rectangle | |
| ulong_t | m_uGstWinXid |
| GstWin container X window id. | |
| uint_t | m_uLastKey |
| last pressed keyboard code | |
| bool | m_bMouseEvent |
| was a mouse event (click, drag, etc) | |
| MouseCbFunc_T | m_funcMouseCb [MaxCvImages] |
| registered mouse cb func | |
| void * | m_dataMouseCb [MaxCvImages] |
| registered mouse cb data | |
| KeyCbFunc_T | m_funcKeyCb |
| registered keyboard callback func | |
| void * | m_dataKeyCb |
| registered keyboard callback data | |
| BttnCbFunc_T | m_funcBttnCb |
| registered menu button callback func | |
| void * | m_dataBttnCb |
| registered menu button callback data | |
| MapLookFeel_T | m_mapLookFeel |
| look and feel map | |
Additional Inherited Members | |
Static Public Attributes inherited from rnr::Win | |
| static const int | MaxCvImages = 4 |
| max workspace images/video | |
| static const int | NumOfButtonMenus = 2 |
| left and right menus | |
WinGtk window derived class.
The WinGtk class uses the GTK (GIMP Toolkit) libraries for creating the graphical user interfaces.
| WinGtk::WinGtk | ( | const std::string & | strWinName, |
| int | nWidth, | ||
| int | nHeight, | ||
| bool | bDecorate = true |
||
| ) |
Default initialization constructor.
| strWinName | Window name. |
| nWidth | Window width in pixels. |
| nHeight | Window height in pixels. |
| bDecorate | Do [not] decorate window with title, border, etc. Windowing system specific. |
Definition at line 94 of file WinGtk.cxx.
References rnr::AlignOpLeft, rnr::AlignOpRight, convertLookAndFeelDefaults(), getBttnMenuIdx(), m_mapColors, rnr::Win::m_nWinHeight, rnr::Win::m_nWinWidth, rnr::Win::m_rectWorkspace, rnr::Win::m_strWinName, m_wBttnMenu, m_wContainer, m_wCvImage, m_wCvImageBox, m_wExtraVBox, m_wGstWin, m_wMain, m_wPageRef, m_wStatusBar, m_wStatusFrame, m_wWindowMain, m_wWorkspace, rnr::Win::MaxCvImages, and onKeyPress().
|
virtual |
Add a GTK button widget to window button menu.
| nBttnId | Unique button id. |
| eAlign | Menu item icon alignment. See rnmpwin_align. |
| wBttn | Button widget. |
Definition at line 568 of file WinGtk.cxx.
References findBttn(), getBttnMenuIdx(), m_mapBttns, rnr::WinGtk::BttnInfo_T::m_nBttnId, rnr::WinGtk::BttnInfo_T::m_pWin, rnr::WinGtk::BttnInfo_T::m_wBttn, m_wBttnMenu, m_wMain, onButtonClick(), and replaceButtonImage().
Referenced by addLabelButton(), show(), and wait().
|
virtual |
Add a button with an image to window button menu.
If the image fails to load, the alternate text is display instead.
| nBttnId | Window unique button id. |
| eAlign | Menu item icon alignment. See rnmpwin_align |
| strIconPath | Path to icon image file. |
| strAltText | Button alternate text. |
| strToolTip | Optional button tool tip text. |
Implements rnr::Win.
|
virtual |
Add a button with a GTK image widget to window button menu.
| nBttnId | Window unique button id. |
| eAlign | Menu item icon alignment. See rnmpwin_align |
| wBttnImg | Button image widget (GtkWidget *). |
| strAltText | Button alternate text. |
| strToolTip | Optional button tool tip text. |
Implements rnr::Win.
|
virtual |
Add a button with a label to window button menu.
| nBttnId | Window unique button id. |
| eAlign | Menu item icon alignment. See rnmpwin_align |
| strLabel | Button text label. |
| strToolTip | Optional button tool tip text. |
Implements rnr::Win.
Definition at line 539 of file WinGtk.cxx.
References addButton(), and m_mapColors.
Referenced by show(), and wait().
|
virtual |
Add an OpenCV display widget to the container widget.
The container widget must be added to the window workspace by the application to keep the widget control correct.
| wContainer | Pointer to (derived) GTK_BOX container widget. |
Implements rnr::Win.
Definition at line 880 of file WinGtk.cxx.
References configureCvImage(), m_ptCvImageOrig, m_sizeCvImage, m_wCvImage, m_wCvImageBox, and rnr::Win::MaxCvImages.
Referenced by initWorkspace().
|
protectedvirtual |
Configure OpenCV image widget.
| uImgIndex | Image instance. |
Definition at line 971 of file WinGtk.cxx.
References m_mapColors, m_wCvImage, m_wMain, and onMouseCvImage().
Referenced by addWorkspaceCvImageDisplay(), findBttn(), and initWorkspaceAsCvImage().
|
virtual |
Remove all widgets contained in the window's workspace container.
Implements rnr::Win.
Definition at line 930 of file WinGtk.cxx.
References m_wCvImage, m_wCvImageBox, m_wWorkspace, rnr::Win::MaxCvImages, and onRemoveWidget().
Referenced by initWorkspaceAsCvImage(), initWorkspaceAsGstWin(), initWorkspaceAsGtk(), and showWorkspace().
|
inlineprotected |
Find button.
| nBttnId | Unique button id. |
| pos | Position iterator. Set to end(), if no button found. |
Definition at line 578 of file WinGtk.h.
References configureCvImage(), convertLookAndFeelDefaults(), onAlarm(), onButtonClick(), onKeyPress(), onMouseCvImage(), onRealizeGstWin(), and onRemoveWidget().
Referenced by addButton(), replaceButtonLabel(), and showButtonState().
|
inlineprotected |
Get button menu index from alignment enum.
| eAlign | Alignment enumuration. |
Definition at line 565 of file WinGtk.h.
References rnr::AlignOpRight.
Referenced by addButton(), and WinGtk().
|
inline |
Get the window's workspace extra vertical box container widget.
This widget is between the worksapce vertical box and the status line and is contained within the workspace. It is only visible if the application adds gui elements to it.
Definition at line 500 of file WinGtk.h.
References m_wExtraVBox.
|
inline |
|
inlinevirtual |
Get GUI toolkit name.
Reimplemented from rnr::Win.
Definition at line 116 of file WinGtk.h.
References setLookAndFeel().
|
inlinevirtual |
Get the GUI look and feel Pango font description.
| strKey | Key. |
Definition at line 156 of file WinGtk.h.
References m_mapFonts.
|
inlinevirtual |
Get the GUI look and feel GDK color.
| strKey | Key. |
Definition at line 137 of file WinGtk.h.
References m_mapColors.
|
inline |
|
inline |
Get the top-level main window.
Definition at line 476 of file WinGtk.h.
References m_wWindowMain.
|
inline |
Get the window's workspace top vertical box container widget.
Definition at line 486 of file WinGtk.h.
References m_wWorkspace.
|
inlinevirtual |
Initialize window's workspace to hold a GTK toolkit widget tree.
All previous gui elements are erased.
Implements rnr::Win.
Definition at line 377 of file WinGtk.h.
References addWorkspaceCvImageDisplay(), initWorkspaceAsCvImage(), initWorkspaceAsGstWin(), initWorkspaceAsGtk(), and removeWorkspaceCvImageDisplay().
|
virtual |
Initialize the workspace as a display to show OpenCV images.
This is a convinience function to use if only one image widget is contained in the workspace.
Alternately, for a mixed workspace of GTK widgets and up to MaxCvImages(4) OpenCV images, the follow functions are available:
Use
to display an OpenCv image.
All previous gui elements are erased.
Implements rnr::Win.
Definition at line 800 of file WinGtk.cxx.
References configureCvImage(), eraseWorkspace(), m_ptCvImageOrig, rnr::Win::m_rectWorkspace, m_sizeCvImage, m_wCvImage, m_wCvImageBox, and m_wWorkspace.
Referenced by initWorkspace().
|
virtual |
Initialize the workspace as a window display to show GStreamer video/images.
GStreamer automatically displays video/images via the GTK callback mechanism, so no show function is required.
This is a convinience function to use if only one stream is contained in the workspace.
All previous gui elements are erased.
Implements rnr::Win.
Definition at line 839 of file WinGtk.cxx.
References eraseWorkspace(), m_mapColors, rnr::Win::m_uGstWinXid, m_wGstWin, m_wWorkspace, onRealizeGstWin(), and showWorkspace().
Referenced by initWorkspace().
|
virtual |
Initialize window's workspace to hold a GTK widget tree.
All previous gui elements are erased.
Definition at line 794 of file WinGtk.cxx.
References eraseWorkspace().
Referenced by initWorkspace().
|
staticprotected |
Timeout expiry callback handler.
The supplied user data is set to 1 (true).
| user_data | Pointer to user supplied expiry flag. |
Definition at line 996 of file WinGtk.cxx.
Referenced by findBttn(), wait(), waitKey(), and waitMouse().
|
staticprotected |
Button press event handler.
If registered, the application callback function will be called.
| w | Button widget. |
| user_data | Button information |
Definition at line 1127 of file WinGtk.cxx.
References rnr::Win::m_bMouseEvent, rnr::Win::m_dataBttnCb, rnr::Win::m_funcBttnCb, rnr::WinGtk::BttnInfo_T::m_nBttnId, and rnr::WinGtk::BttnInfo_T::m_pWin.
Referenced by addButton(), and findBttn().
|
staticprotected |
Keyboard press event callback handler.
If registered, the application callback function will be called.
| w | Widget where keyboard event occurred. |
| event | Keyboard event. |
| user_data | Supplied user data (this). |
Definition at line 1002 of file WinGtk.cxx.
References rnr::Win::m_dataKeyCb, rnr::Win::m_funcKeyCb, and rnr::Win::m_uLastKey.
Referenced by findBttn(), and WinGtk().
|
staticprotected |
Mouse event on OpenCV Image widget workspace callback handler.
The workspace must be set as an CvImage workspace.
If registered, the application callback function will be called.
The pixel coordinates are contrained to any shown OpenCv image with the origin at the image origin. Mouse events outside the image return nopoint().
| w | CvImage widget where mouse event occurred. |
| event | Mouse event. |
| user_data | Supplied user data (this). |
Definition at line 1037 of file WinGtk.cxx.
References rnr::Win::m_bMouseEvent, rnr::Win::m_dataMouseCb, rnr::Win::m_funcMouseCb, m_sizeCvImage, m_wCvImage, and rnr::Win::MaxCvImages.
Referenced by configureCvImage(), and findBttn().
|
staticprotected |
Realize GStreamer video window callback.
Once the window has been realized, the X-Window id can be obtained. The id is critical for rendering gst video and images to the gtk widget.
| w | Gtk draw widget where video will be overlaied. |
| user_data | Supplied user data (this). |
Definition at line 1138 of file WinGtk.cxx.
References rnr::Win::m_uGstWinXid, and m_wGstWin.
Referenced by findBttn(), and initWorkspaceAsGstWin().
|
staticprotected |
Remove widget callback handler.
| w | Widget to be removed. |
| user_data | Any supplied callback data (parent container widget). |
Definition at line 990 of file WinGtk.cxx.
Referenced by eraseWorkspace(), and findBttn().
|
virtual |
Remove a button from a menu.
| nBttnId | Unique button id. |
Implements rnr::Win.
Definition at line 696 of file WinGtk.cxx.
References m_mapBttns, m_wBttnMenu, and m_wMain.
Referenced by show().
|
virtual |
Remove OpenCV display widget from workspace.
| uImgIndex | Image instance. |
Implements rnr::Win.
Definition at line 918 of file WinGtk.cxx.
References m_wCvImage, m_wCvImageBox, and rnr::Win::MaxCvImages.
Referenced by initWorkspace().
|
virtual |
Replace existing button image with new image.
| nBttnId | Unique button id. |
| strIconPath | Path to icon image file. |
| strToolTip | Optional button tool tip text. If empty, then the current tooltip, if any, is used. |
Implements rnr::Win.
Referenced by addButton(), and show().
|
virtual |
Replace existing button image with new GTK image widget.
| nBttnId | Unique button id. |
| wBttnImg | New button image widget (GtkWidget *). |
| strToolTip | Optional button tool tip text. If empty, then the current tooltip, if any, is used. |
Implements rnr::Win.
|
virtual |
Replace existing button label with new label.
| nBttnId | Unique button id. |
| strLabel | Button text label. |
| strToolTip | Optional button tooltip text. If empty, then the current tooltip, if any, is used. |
Implements rnr::Win.
Definition at line 670 of file WinGtk.cxx.
References findBttn(), and m_wMain.
Referenced by show().
|
virtual |
Set GUI look and feel value.
| strKey | Key. |
| strVal | Value. |
Reimplemented from rnr::Win.
Definition at line 276 of file WinGtk.cxx.
References m_mapBttns, m_mapColors, m_mapFonts, m_wMain, m_wPageRef, m_wStatusBar, m_wStatusFrame, m_wWorkspace, rnr::Win::NumOfButtonMenus, rnr::Win::setLookAndFeel(), and showWorkspace().
Referenced by getGuiToolkitName().
|
virtual |
Show a button's widget state.
| nBttnId | Unique button id. |
| eBttnState | New button state. See rnmpwin_itemstate. |
Implements rnr::Win.
Definition at line 763 of file WinGtk.cxx.
References findBttn(), rnr::WidgetStateActive, rnr::WidgetStateDisabled, and rnr::WidgetStateNormal.
Referenced by show().
|
virtual |
Show a OpenCV image on the workspace.
The workspace must contain a CvImage prior to calling this function.
| pImg | Pointer to image. |
| uImgIndex | Image instance. |
Implements rnr::Win.
Definition at line 331 of file WinGtk.cxx.
References m_ptCvImageOrig, rnr::Win::m_rectWorkspace, m_sizeCvImage, m_wCvImage, and rnr::Win::MaxCvImages.
Referenced by show().
|
virtual |
Show page reference number.
| nPageRef | Page reference number. |
Implements rnr::Win.
Definition at line 357 of file WinGtk.cxx.
References m_wPageRef.
Referenced by show().
|
virtual |
|
virtual |
Show status message.
| sFmt | Format string. |
| ... | Variable arguments. |
Implements rnr::Win.
Definition at line 378 of file WinGtk.cxx.
References m_wStatusBar.
Referenced by show().
|
virtual |
Wait for timeout.
GTK widgets can be updated during this wait.
| delay | Timeout delay in millseconds > 0. |
Implements rnr::Win.
Definition at line 464 of file WinGtk.cxx.
References addButton(), addImageButton(), addLabelButton(), m_mapColors, and onAlarm().
Referenced by show().
|
virtual |
Wait for keypress or timeout.
GTK widgets can be updated during this wait.
| delay | Timeout delay in millseconds. Set to 0 for no timeout. |
Implements rnr::Win.
Definition at line 402 of file WinGtk.cxx.
References rnr::Win::m_uLastKey, and onAlarm().
Referenced by show().
|
virtual |
Wait for timeout or registered mouse event.
Window widgets can be updated during this wait.
| delay | Timeout delay in millseconds > 0. |
Implements rnr::Win.
Definition at line 440 of file WinGtk.cxx.
References rnr::Win::m_bMouseEvent, and onAlarm().
Referenced by show().