latest version v1.9 - last update 10 Apr 2010 |
This class encapsulates all signals and calls of the GTK library. More...
#include <ltiGtkWidget.h>
Public Member Functions | |
mainGTKWindow (bool setConfigDlg=true) | |
mainGTKWindow (const mainGTKWindow &other) | |
virtual | ~mainGTKWindow () |
void | init (void) |
virtual bool | useParameters (viewerBase::parameters &par) |
virtual void | changeGeometryRequest (const bool request=true) |
virtual bool | redraw () |
virtual bool | drawData () |
virtual void | hideData () |
void | createWindow () |
void | setPosition (const point &p, const bool withinGtkThread) |
point | getPosition () const |
void | setSize (const point &p, const bool withinGtkThread) |
point | getSize () const |
void | destroyWindow () |
const image & | getDisplayedData () const |
mainGTKWindow & | copy (const mainGTKWindow &other) |
virtual mainGTKWindow * | clone () const |
void | lock () |
void | unlock () |
Protected Member Functions | |
void | generateXbuffer (const image &img, GtkWidget *widget, GdkEventExpose *event) |
void | showXbuffer (GtkWidget *widget) |
rgbPixel | intToRgb (const guint32 &rgb) const |
Members to be reimplemented | |
virtual void | dataToImage (image &img) |
virtual void | drawReady () |
virtual void | prepareParameters () |
virtual bool | validData () |
virtual void | indicateDataHide () |
virtual void | windowDestructionHandler () |
virtual void | mouseMovedHandler (const int &button, const point &pos, const bool shift, const bool ctrl) |
virtual void | mouseButtonHandler (const int &button, const point &pos, const bool shift, const bool ctrl, const bool pressed) |
virtual void | keyPressedHandler (const bool shift, const bool ctrl, const int key) |
virtual void | keyReleasedHandler (const bool shift, const bool ctrl, const int key) |
Protected Attributes | |
viewerBase::parameters * | param |
configGTKDialog * | options |
image | theImage |
bool | busy |
mutex | theLock |
semaphore | syncEnd |
bool | dataChanged |
guchar * | xbuffer |
int | xbuffer_rows |
int | xbuffer_cols |
std::string | winName |
point | winSize |
point | winPosition |
bool | geometryChangeRq |
gint | timerTag |
Static Protected Attributes | |
static const point | borderWidth |
Tools and information flags | |
| |
int | mouseButtonPressed |
point | lastMousePos |
void | setStatusBar (const char *str) |
GTK+ Widgets | |
| |
GtkWidget * | window |
GtkWidget * | scrolledWindow |
GtkWidget * | statusBar |
guint | statusBarContextId |
GtkWidget * | darea |
GtkWidget * | eventBox |
guint32 | rgbToInt (const int &r, const int &g, const int &b) const |
GTK+ callback functions | |
| |
void | createWindowLocal () |
void | mouseMovedEventLocal (GtkWidget *widget, GdkEventMotion *event) |
virtual void | buttonPressedEventLocal (GtkWidget *widget, GdkEventButton *event) |
virtual void | keyPressedEventLocal (GtkWidget *widget, GdkEventKey *event) |
virtual void | keyReleasedEventLocal (GtkWidget *widget, GdkEventKey *event) |
virtual gboolean | dareaExposeLocal (GtkWidget *widget, GdkEventExpose *event) |
static gint | delete_event (GtkWidget *widget, GdkEvent *event, gpointer data) |
static gint | destroyWndTimeout (gpointer data) |
static void | destroy (GtkWidget *widget, gpointer data) |
static gint | show (gpointer data) |
static gint | hide (gpointer data) |
static gint | createWindowTimeout (gpointer data) |
static gint | mouseMovedEvent (GtkWidget *widget, GdkEventMotion *event, gpointer data) |
static gint | geometryChanged (GtkWidget *widget, GdkEventConfigure *event, gpointer data) |
static gint | buttonPressedEvent (GtkWidget *widget, GdkEventButton *event, gpointer data) |
static gint | keyPressedEvent (GtkWidget *widget, GdkEventKey *event, gpointer data) |
static gint | keyReleasedEvent (GtkWidget *widget, GdkEventKey *event, gpointer data) |
static gboolean | dareaExpose (GtkWidget *widget, GdkEventExpose *event, gpointer data) |
This class encapsulates all signals and calls of the GTK library.
lti::mainGTKWindow::mainGTKWindow | ( | bool | setConfigDlg = true |
) |
default constructor
lti::mainGTKWindow::mainGTKWindow | ( | const mainGTKWindow & | other | ) |
copy constructor
virtual lti::mainGTKWindow::~mainGTKWindow | ( | ) | [virtual] |
destructor
static gint lti::mainGTKWindow::buttonPressedEvent | ( | GtkWidget * | widget, | |
GdkEventButton * | event, | |||
gpointer | data | |||
) | [static, protected] |
function called when any mouse button has been pressed.
virtual void lti::mainGTKWindow::buttonPressedEventLocal | ( | GtkWidget * | widget, | |
GdkEventButton * | event | |||
) | [protected, virtual] |
called by buttonPressedEvent()
virtual void lti::mainGTKWindow::changeGeometryRequest | ( | const bool | request = true |
) | [virtual] |
update geometry the next time
virtual mainGTKWindow* lti::mainGTKWindow::clone | ( | ) | const [virtual] |
clone this window
Reimplemented in lti::viewer::mainWindow, lti::viewer::mainWndChannelFixed, lti::viewer::mainWndChannelFloat, lti::viewer::mainWndVector, and lti::viewer::mainWndImage.
mainGTKWindow& lti::mainGTKWindow::copy | ( | const mainGTKWindow & | other | ) |
copy this window (only the actual data will be copied.
The display queue will not be copied!
void lti::mainGTKWindow::createWindow | ( | ) |
creates new window
void lti::mainGTKWindow::createWindowLocal | ( | ) | [protected] |
called by createWindow to create a window
static gint lti::mainGTKWindow::createWindowTimeout | ( | gpointer | data | ) | [static, protected] |
creates new window timeout (this will be called when the time has come to create the window).
static gboolean lti::mainGTKWindow::dareaExpose | ( | GtkWidget * | widget, | |
GdkEventExpose * | event, | |||
gpointer | data | |||
) | [static, protected] |
gtk-callback funtion to redraw the image been displayed.
This function just calls the dareaExposeLocal()
virtual gboolean lti::mainGTKWindow::dareaExposeLocal | ( | GtkWidget * | widget, | |
GdkEventExpose * | event | |||
) | [protected, virtual] |
This function redraws the image been displayed.
virtual void lti::mainGTKWindow::dataToImage | ( | image & | img | ) | [protected, virtual] |
This method is the one where your data should be drawn.
You just need to draw on the "theImage" attribute image.
Reimplemented in lti::viewer::mainWindow, lti::viewer::mainWndChannelFixed, lti::viewer::mainWndChannelFloat, lti::viewer::mainWndVector, and lti::viewer::mainWndImage.
static gint lti::mainGTKWindow::delete_event | ( | GtkWidget * | widget, | |
GdkEvent * | event, | |||
gpointer | data | |||
) | [static, protected] |
called when the user selects the "close window" button on the window
static void lti::mainGTKWindow::destroy | ( | GtkWidget * | widget, | |
gpointer | data | |||
) | [static, protected] |
call-back funtion to indicate the end of the whole gtk-application.
This function will end the gtk main-event-loop!
void lti::mainGTKWindow::destroyWindow | ( | ) |
destroy the window
static gint lti::mainGTKWindow::destroyWndTimeout | ( | gpointer | data | ) | [static, protected] |
timeout gtk-callback function, called when the window must be destroyed.
This static function just call the instance member destroyWindow().
virtual bool lti::mainGTKWindow::drawData | ( | ) | [virtual] |
generate an event which will show the data
Reimplemented in lti::viewer::mainWindow.
virtual void lti::mainGTKWindow::drawReady | ( | ) | [protected, virtual] |
This method is called as soon as all data has been drawn.
You can use it to send a message to another widget or object, in order to allow further actions. The default implementation does nothing.
Reimplemented in lti::viewer::mainWindow.
void lti::mainGTKWindow::generateXbuffer | ( | const image & | img, | |
GtkWidget * | widget, | |||
GdkEventExpose * | event | |||
) | [protected] |
generate xbuffer from an image
static gint lti::mainGTKWindow::geometryChanged | ( | GtkWidget * | widget, | |
GdkEventConfigure * | event, | |||
gpointer | data | |||
) | [static, protected] |
callback function called when the window size or position are changed.
const image& lti::mainGTKWindow::getDisplayedData | ( | ) | const |
return a lti::image with the data being displayed.
Used by the save image routines!
point lti::mainGTKWindow::getPosition | ( | ) | const |
get position of the window
point lti::mainGTKWindow::getSize | ( | ) | const |
get size of the window
static gint lti::mainGTKWindow::hide | ( | gpointer | data | ) | [static, protected] |
timeout gtk-callback function, called when a new image must be hide!
virtual void lti::mainGTKWindow::hideData | ( | ) | [virtual] |
generate an event which will hide the data
virtual void lti::mainGTKWindow::indicateDataHide | ( | ) | [protected, virtual] |
this method will be called to invalidate the data.
Usually will set a few pointers to NULL to indicate that the window has been hidden, and no valid data is keeped in this class any more.
Reimplemented in lti::viewer::mainWindow.
void lti::mainGTKWindow::init | ( | void | ) |
initialize values for the constructor
rgbPixel lti::mainGTKWindow::intToRgb | ( | const guint32 & | rgb | ) | const [protected] |
unpack an gtk-integer into a rgb pixel
static gint lti::mainGTKWindow::keyPressedEvent | ( | GtkWidget * | widget, | |
GdkEventKey * | event, | |||
gpointer | data | |||
) | [static, protected] |
function called when any key has been pressed.
virtual void lti::mainGTKWindow::keyPressedEventLocal | ( | GtkWidget * | widget, | |
GdkEventKey * | event | |||
) | [protected, virtual] |
function called when any key has been pressed.
virtual void lti::mainGTKWindow::keyPressedHandler | ( | const bool | shift, | |
const bool | ctrl, | |||
const int | key | |||
) | [protected, virtual] |
this method is called when a key is pressed while the viewer window is active.
shift | true if the shift-key has been pressed while moving the mouse. | |
ctrl | true if the control-key has been pressed while moving the mouse. | |
key | integer value containing the key code. You can find symbol definitions for the values used here in the file <gdk/gdkkeysym.h> |
Reimplemented in lti::viewer::mainWindow.
static gint lti::mainGTKWindow::keyReleasedEvent | ( | GtkWidget * | widget, | |
GdkEventKey * | event, | |||
gpointer | data | |||
) | [static, protected] |
function called when any key has been pressed.
virtual void lti::mainGTKWindow::keyReleasedEventLocal | ( | GtkWidget * | widget, | |
GdkEventKey * | event | |||
) | [protected, virtual] |
function called when any key has been pressed.
virtual void lti::mainGTKWindow::keyReleasedHandler | ( | const bool | shift, | |
const bool | ctrl, | |||
const int | key | |||
) | [protected, virtual] |
this method is called when a key is released while the viewer window is active.
shift | true if the shift-key has been pressed while moving the mouse. | |
ctrl | true if the control-key has been pressed while moving the mouse. | |
key | integer value containing the key code. You can find symbol definitions for the values used here in the file <gdk/gdkkeysym.h> |
Reimplemented in lti::viewer::mainWindow.
void lti::mainGTKWindow::lock | ( | ) |
lock internal data
virtual void lti::mainGTKWindow::mouseButtonHandler | ( | const int & | button, | |
const point & | pos, | |||
const bool | shift, | |||
const bool | ctrl, | |||
const bool | pressed | |||
) | [protected, virtual] |
this method is called when a mouse button is pressed.
button | which button is pressed (0 means none, 1 left button, 3 right button) | |
pos | actual position of mouse pointer | |
shift | true if the shift-key has been pressed while moving the mouse. | |
ctrl | true if the control-key has been pressed while moving the mouse. | |
pressed | true if the button was pressed, false if the button was released. |
Reimplemented in lti::viewer::mainWindow.
static gint lti::mainGTKWindow::mouseMovedEvent | ( | GtkWidget * | widget, | |
GdkEventMotion * | event, | |||
gpointer | data | |||
) | [static, protected] |
callback function called when the mouse is moved and a mouse button has been pressed.
This function just calls the mouseMovedEventLocal()
void lti::mainGTKWindow::mouseMovedEventLocal | ( | GtkWidget * | widget, | |
GdkEventMotion * | event | |||
) | [protected] |
method called by mouseMovedEvent() when the mouse has been moved.
This will show on the status bar the mouse pointer position and the value of the image at this position.
virtual void lti::mainGTKWindow::mouseMovedHandler | ( | const int & | button, | |
const point & | pos, | |||
const bool | shift, | |||
const bool | ctrl | |||
) | [protected, virtual] |
this method is called when a mouse button is pressed and the mouse moved.
button | which button is pressed (0 means none, 1 left button, 3 right button) | |
pos | actual position of mouse pointer | |
shift | true if the shift-key has been pressed while moving the mouse. | |
ctrl | true if the control-key has been pressed while moving the mouse. |
Reimplemented in lti::viewer::mainWindow.
virtual void lti::mainGTKWindow::prepareParameters | ( | ) | [protected, virtual] |
Prepare the parameters before the configuration dialog is started.
This member gets some information of the displayed data into the informational attributes of the parameters instance. It is called just before opening the settings dialog, and is the proper place to update the mentioned informational data.
Reimplemented in lti::viewer::mainWindow, lti::viewer::mainWndChannelFixed, lti::viewer::mainWndChannelFloat, lti::viewer::mainWndVector, and lti::viewer::mainWndImage.
virtual bool lti::mainGTKWindow::redraw | ( | ) | [virtual] |
similar to drawData, but used by other widgets (like the configuration dialog) to force new image display
guint32 lti::mainGTKWindow::rgbToInt | ( | const int & | r, | |
const int & | g, | |||
const int & | b | |||
) | const [protected] |
convert the three color components red, green and blue in a guint32 used by the gtk-color maps.
r | red component (between 0 and 255) | |
g | green component (between 0 and 255) | |
b | blue component (between 0 and 255) |
void lti::mainGTKWindow::setPosition | ( | const point & | p, | |
const bool | withinGtkThread | |||
) |
set position of the window
void lti::mainGTKWindow::setSize | ( | const point & | p, | |
const bool | withinGtkThread | |||
) |
set size of the window
void lti::mainGTKWindow::setStatusBar | ( | const char * | str | ) | [protected] |
write the given string into the status bar
static gint lti::mainGTKWindow::show | ( | gpointer | data | ) | [static, protected] |
timeout gtk-callback function, called when a new image must be displayed!
This function will stop the timeout automatically, if there are no more images or objects to be displayed.
void lti::mainGTKWindow::showXbuffer | ( | GtkWidget * | widget | ) | [protected] |
generate xbuffer from an image
void lti::mainGTKWindow::unlock | ( | ) |
unlock internal data
virtual bool lti::mainGTKWindow::useParameters | ( | viewerBase::parameters & | par | ) | [virtual] |
set the display parameters
virtual bool lti::mainGTKWindow::validData | ( | ) | [protected, virtual] |
Indicate if there are valid data to show.
This method must check if the provided data is ready to be shown, i.e. if the dataToImage() can be already be used to draw the data.
Reimplemented in lti::viewer::mainWindow.
virtual void lti::mainGTKWindow::windowDestructionHandler | ( | ) | [protected, virtual] |
window destruction handler.
This method is called when the window is destroyed. You don't need to call GTK hide methods or stuff like that, because the enclosing application will take care on these matters. Just finalize tasks you started that should be active as long as the widget window does.
A typical use for this method is un-locking keyboard or mouse mutexes that wait for the user. If he closes the window without giving any information, these mutexes will remain locked, blocking some other threads. This method is the proper place to un-lock them.
Reimplemented in lti::viewer::mainWindow.
const point lti::mainGTKWindow::borderWidth [static, protected] |
extra width needed for the scrollbars
bool lti::mainGTKWindow::busy [protected] |
GtkWidget* lti::mainGTKWindow::darea [protected] |
drawing area that holds the image
bool lti::mainGTKWindow::dataChanged [protected] |
if the data has changed, this variable is true
GtkWidget* lti::mainGTKWindow::eventBox [protected] |
event box to capture mouse and button events
bool lti::mainGTKWindow::geometryChangeRq [protected] |
geometry change request from user
point lti::mainGTKWindow::lastMousePos [protected] |
last position of the mouse in the window.
int lti::mainGTKWindow::mouseButtonPressed [protected] |
mouse being pressed.
This attribute will contain always the status of the mouse buttons. The values will usually be:
Nothing : 0 Left button : 1 Middle button: 2 Right button : 3 Wheel Up : 4 Wheel Down : 5
configGTKDialog* lti::mainGTKWindow::options [protected] |
the statistics and displaying options dialog
viewerBase::parameters* lti::mainGTKWindow::param [protected] |
GtkWidget* lti::mainGTKWindow::scrolledWindow [protected] |
the scrolled window
GtkWidget* lti::mainGTKWindow::statusBar [protected] |
the status bar
guint lti::mainGTKWindow::statusBarContextId [protected] |
context id of the status bar
semaphore lti::mainGTKWindow::syncEnd [protected] |
semaphore used to synchronize destruction of the widgets
image lti::mainGTKWindow::theImage [protected] |
the data which is been actually displayed.
mutex lti::mainGTKWindow::theLock [protected] |
data lock.
Used to protect the data against parallel access
gint lti::mainGTKWindow::timerTag [protected] |
GtkWidget* lti::mainGTKWindow::window [protected] |
the main dialog window
std::string lti::mainGTKWindow::winName [protected] |
name of this window!
point lti::mainGTKWindow::winPosition [protected] |
position of the window
point lti::mainGTKWindow::winSize [protected] |
size of the window
guchar* lti::mainGTKWindow::xbuffer [protected] |
buffer of image being displayed!
int lti::mainGTKWindow::xbuffer_cols [protected] |
number of columns of the xbuffer
int lti::mainGTKWindow::xbuffer_rows [protected] |
number of rows of the xbuffer