Routines for Open Inventor/Xt compatibility. More...
#include <Inventor/Xt/SoXt.h>
Static Public Member Functions | |
static SoWidget | init (const char *appName, const char *className="Inventor") |
static void | init (SoWidget topLevelWidget) |
static bool | isInitialized () |
static void | finish () |
static int | mainLoop () |
static void | exit (int returnCode=0) |
static void | nextEvent (XtAppContext appContext, XEvent *event) |
static Boolean | dispatchEvent (XEvent *event) |
static XtAppContext | getAppContext () |
static Display * | getDisplay () |
static SoWidget | getTopLevelWidget () |
static void | show (SoWidget widget) |
static void | hide (SoWidget widget) |
static XmString | encodeString (char *s) |
static char * | decodeString (XmString xs) |
static void | setWidgetSize (SoWidget w, const SbVec2s &size) |
static SbVec2s | getWidgetSize (SoWidget w) |
static SoWidget | getShellWidget (SoWidget w) |
static void | createSimpleErrorDialog (SoWidget widget, char *dialogTitle, char *errorStr1, char *errorStr2=NULL) |
static void | getPopupArgs (Display *d, int scr, ArgList args, int *n) |
static void | registerColormapLoad (SoWidget widget, SoWidget shell) |
static void | addColormapToShell (SoWidget widget, SoWidget shell) |
static void | removeColormapFromShell (SoWidget widget, SoWidget shell) |
Deprecated | |
| |
static SoDEPRECATED SoWidget | threadInit (const char *appName, const char *className="Inventor") |
static SoDEPRECATED void | threadInit (SoWidget topLevelWidget) |
Routines for Open Inventor/Xt compatibility.
The SoXt class initializes Open Inventor for use with the Xt toolkit and Motif. SoXt::init() must be called in order for Open Inventor to work properly with Xt SoXt::finish() should be called to clean up static memory allocations.
SoXt::mainLoop() must be called in order for extension device events to be passed to Open Inventor render areas. The other methods are convenience functions.
Refer to the SoXtComponent reference pages for examples on how this class should be used when using Open Inventor Xt components.
static void SoXt::addColormapToShell | ( | SoWidget | widget, | |
SoWidget | shell | |||
) | [static] |
Convenience routine to insert the given widget colormap onto the supplied shell widget.
This will not replace the existing installed colormaps (or list of windows), but instead insert the new colormap first into the existing list using XGetWMColormapWindows () and XSetWMColormapWindows ().
static void SoXt::createSimpleErrorDialog | ( | SoWidget | widget, | |
char * | dialogTitle, | |||
char * | errorStr1, | |||
char * | errorStr2 = NULL | |||
) | [static] |
Convenience routine which brings a simple Xt error dialog box displaying the given error string(s) and window title.
The OK button, which destroys the dialog, is the only button displayed.
static char* SoXt::decodeString | ( | XmString | xs | ) | [static] |
Convenience routine for decoding an XmString back to a character string.
encodeString() is used for encoding a character string as an XmString . ( XmString is a Motif string). The application is responsible for freeing up the memory pointed to by the return value. Use free () to free a character pointer.
Dispatches the passed event to a handler.
This returns TRUE if a handler was found, else it returns FALSE.
static XmString SoXt::encodeString | ( | char * | s | ) | [static] |
Convenience routine for encoding a character string as an XmString .
decodeString() is used for decoding an XmString back to a character string. ( XmString is a Motif string). The application is responsible for freeing up the memory pointed to by the return value. Use XmStringFree () to free an XmString .
static void SoXt::exit | ( | int | returnCode = 0 |
) | [static] |
Tells the main event loop to exit with a return code.
After this function has been called, the mainLoop() function returns returnCode. If the event loop is not running, this function does nothing.
By convention, a returnCode of 0 means success, and any non-zero value indicates an error.
static void SoXt::finish | ( | ) | [static] |
Frees Open Inventor's internal static memory allocations.
This avoids false positives from memory leak checking software. We recommend calling this method and it should be the last Open Inventor method called by the application. This method calls SoDB::finish(), SoNodeKit::finish(), and SoInteraction::finish().
Note: Open Inventor objects should be destroyed before you call this method.
For example:
Wrong Open Inventor Ending | Safe Open Inventor Endings | ||
void main() { SoWidget myW = SoXt::init(""); SoXtExaminerViewer viewer(myW); .... .... SoXt::mainLoop(); SoXt::finish(); } |
| ||
SoXt doesn't end properly: SoXtExaminerViewer is destroyed after the finish() method has been called. | The SoXtExaminerViewer (that uses OpenInventor) is destroyed before calling the finish() method. |
static XtAppContext SoXt::getAppContext | ( | ) | [static] |
This method is included for portability only.
static Display* SoXt::getDisplay | ( | ) | [static] |
This method is included for portability only.
static void SoXt::getPopupArgs | ( | Display * | d, | |
int | scr, | |||
ArgList | args, | |||
int * | n | |||
) | [static] |
Convenience routine which gets visual args for the popup planes.
These args can then be passed in to XmCreatePulldownMenu () or XmCreatePopupMenu () to create menus in the popup planes. addColormapToShell() has to be called on the main popup window to set the proper color map.
static SoWidget SoXt::getShellWidget | ( | SoWidget | w | ) | [static] |
Convenience routine which will return the topmost window containing the given widget.
The widget tree is traversed up until the last widget is found using GetParent .
static SoWidget SoXt::getTopLevelWidget | ( | ) | [static] |
Returns information based on the initial widget returned by or passed to init.
static SbVec2s SoXt::getWidgetSize | ( | SoWidget | w | ) | [static] |
Convenience routine to get the size of the given window.
static void SoXt::hide | ( | SoWidget | widget | ) | [static] |
Convenience routine to hide the passed widget.
This includes any children the window may have.
static void SoXt::init | ( | SoWidget | topLevelWidget | ) | [static] |
This alternate form of init allows the application to initialize Xt.
The passed widget should be the top level widget returned from the Xt initialization. This method will call SoDB::init(), SoNodeKit::init(), and SoInteraction::init().
static SoWidget SoXt::init | ( | const char * | appName, | |
const char * | className = "Inventor" | |||
) | [static] |
This is called to initialize Open Inventor and Xt, and bind Open Inventor with X events handling so that Open Inventor sensors will work correctly.
This returns the top level shell widget. This method calls SoDB::init(), SoNodeKit::init(), and SoInteraction::init() and creates an initial window.
static bool SoXt::isInitialized | ( | ) | [static] |
Returns TRUE if SoXt module is currently initialized.
static int SoXt::mainLoop | ( | ) | [static] |
Enters the main event loop and waits until exit() is called.
Returns the value that was passed to exit().
It calls nextEvent() and dispatchEvent() to retrieve and dispatch events.
static void SoXt::nextEvent | ( | XtAppContext | appContext, | |
XEvent * | event | |||
) | [inline, static] |
Gets the nextEvent by calling XtAppNextEvent().
The appContext can be had by calling SoXt::getAppContext().
static void SoXt::registerColormapLoad | ( | SoWidget | widget, | |
SoWidget | shell | |||
) | [static] |
Convenience routine which will register map/unmap callbacks to load and unload the pulldown menu color map right before the menu is about to be posted.
This should be called when creating pulldown or popup menus in the overlays. This will make sure that the right color map is loaded into the shell widget (to make the pulldown/popup look right) and remove it when no longer needed (to make sure the OpenGL overlay widget color map is correctly loaded for 8 bit machines).
static void SoXt::removeColormapFromShell | ( | SoWidget | widget, | |
SoWidget | shell | |||
) | [static] |
Convenience routine to remove the given widget colormap from the supplied shell widget.
static void SoXt::setWidgetSize | ( | SoWidget | w, | |
const SbVec2s & | size | |||
) | [static] |
Convenience routine to set the size of the given window.
static void SoXt::show | ( | SoWidget | widget | ) | [static] |
Convenience routine to show the passed widget.
This includes any children the window may have.
static SoDEPRECATED void SoXt::threadInit | ( | SoWidget | topLevelWidget | ) | [static] |
static SoDEPRECATED SoWidget SoXt::threadInit | ( | const char * | appName, | |
const char * | className = "Inventor" | |||
) | [static] |