GLG Toolkit, C / C++ API Library  Version 4.5
GtkGlg Widget

Linux only: A native GTK Widget that can be used in the GTK environment. More...

Detailed Description

Linux only: A native GTK Widget that can be used in the GTK environment.

The widget allows embedding GLG drawings into the GTK interface hierarchy.

Creating GtkGlg Widget

To use the widget, include gtkglg.h file in your source code. The widget is created using gtk_glg_new, then using gtk_glg_set_viewport to assign the viewport that contains the widget's drawing:

GtkWidget * glg_widget = gtk_glg_new(); /* Create a GtkGlg widget. */
gtk_widget_set_size_request( glg_widget, 400, 350 ); /* Set min size */
GlgObject viewport = GlgLoadWidgetFromFile( "controls.g" ); /* Load GLG drawing to be displayed in the widget. */
gtk_glg_set_viewport( glg_widget, viewport ); /* Assign the drawing to the widget. */
GlgDropObject( viewport ); /* Drop: viewport was referenced by the widget. */
struct GlgObjectData * GlgObject
Opaque GlgObject type that represents all GLG objects in the GLG C API.
Definition: GlgApi.h:3376
GlgObject GlgLoadWidgetFromFile(char *filename)
Loads a GLG widget from a GLG drawing file or a URL.
void gtk_glg_set_viewport(GtkWidget *glg_widget, GlgObject viewport)
Assigns a drawing viewport to the widget.
GtkWidget * gtk_glg_new(void)
Creates a new GtkGlg widget.
void GlgDropObject(GlgObject object)
Decrements an object's reference count.

The integration/gtk3_glg_native/glg_example.c directory of the GLG installation on Linux provide an example of using the GtkGlg Widget in a GTK application.

Include file: gtk_glg.h

Macros

#define GTK_GLG(obj)    G_TYPE_CHECK_INSTANCE_CAST( obj, GTK_TYPE_GLG, GtkGlg )
 Typecast to the GtkGlg Widget. More...
 
#define GTK_IS_GLG(obj)    ( G_TYPE_CHECK_INSTANCE_TYPE( obj, GTK_TYPE_GLG ) )
 Checks if the object instance is a GtkGlg Widget. More...
 

Functions

void gtk_glg_add_callback (GtkWidget *glg_widget, GlgCallbackType type, GlgCallbackProc callback, GlgAnyType client_data)
 Adds a callback function to the widget. More...
 
GlgObject gtk_glg_get_viewport (GtkWidget *glg_widget)
 Queries a viewport assigned to the widget. More...
 
GtkWidget * gtk_glg_new (void)
 Creates a new GtkGlg widget. More...
 
void gtk_glg_set_viewport (GtkWidget *glg_widget, GlgObject viewport)
 Assigns a drawing viewport to the widget. More...
 
void gtk_glg_toolkit_init (int argc, char *argv[])
 Optional: Initializes GLG Toolkit using applicable command-line options. More...
 

Macro Definition Documentation

◆ GTK_GLG

#define GTK_GLG (   obj)     G_TYPE_CHECK_INSTANCE_CAST( obj, GTK_TYPE_GLG, GtkGlg )

Typecast to the GtkGlg Widget.

Parameters
objThe object instance.
Returns
A pointer to the GtkGlg Widget.

◆ GTK_IS_GLG

#define GTK_IS_GLG (   obj)     ( G_TYPE_CHECK_INSTANCE_TYPE( obj, GTK_TYPE_GLG ) )

Checks if the object instance is a GtkGlg Widget.

Parameters
objThe object instance.
Returns
True if the object instance is a GtkGlg Widget or False otherwise.

Function Documentation

◆ gtk_glg_add_callback()

void gtk_glg_add_callback ( GtkWidget *  glg_widget,
GlgCallbackType  type,
GlgCallbackProc  callback,
GlgAnyType  client_data 
)

Adds a callback function to the widget.

This method may be invoked at any time during the widget's lifetime. The widget will attach the callback to its viewport at the appropriate time before the viewport's drawing hierarchy as set up.

Parameters
glg_widgetThe widget to add a callback to.
typeSpecifies the type of a callback to be added:
callbackSpecifies a callback function to be called.
client_dataSpecifies client data to be passed to the callback function when it is called.

This function adds the specified callback to the widget. A callback is a user-supplied function that is called by the GLG Toolkit upon some action:

  • Input callback is invoked when an input widgets, such as a slider or a toggle, receives some user input. It is also invoked when an object in the viewport is selected.
  • Select callback is invoked when a user selects an object in the widget's drawing area.
  • Trace callback is invoked for every native windowing system event received by the viewport or its child viewports and may be used to handle these events.
  • Hierarchy callback may be used to initialize loaded subdrawings.

See GlgInputCallback, GlgSelectCallback, GlgTraceCallback and GlgHierarchyCallback for the description of the available callback types.

Only one callback of each callback type may be added to an individual widget. Any subsequent invocations of this function with the same callback type will overwrite the previous value of the callback.

Several callbacks may be added to different viewports on different levels of the drawing hierarchy. The GlgAddCallback function may be used to add callbacks to the children viewports inside the widget's top level viewport. However, only the first encountered callback on the lowest level of the hierarchy will be called. For example, if an input callback is attached to the widget's top level viewport and its child viewport, only the child viewport's callback will be invoked when input event occurs in the child viewport.

The viewport's ProcessMouse attribute controls processing of the mouse selection events and tooltips inside the viewport and its child viewports.

See the Callback Events section of the Handling User Input and Other Events chapter of the GLG Programming Reference Manual for more information.

◆ gtk_glg_get_viewport()

GlgObject gtk_glg_get_viewport ( GtkWidget *  glg_widget)

Queries a viewport assigned to the widget.

Parameters
glg_widgetThe widget instance.
Returns
The top level viewport containing the widget's drawing.

◆ gtk_glg_new()

GtkWidget* gtk_glg_new ( void  )

Creates a new GtkGlg widget.

Returns
Pointer to the created widget.

◆ gtk_glg_set_viewport()

void gtk_glg_set_viewport ( GtkWidget *  glg_widget,
GlgObject  viewport 
)

Assigns a drawing viewport to the widget.

Parameters
glg_widgetThe widget instance.
viewportA viewport object containing the drawing that will be displayed inside the widget.

This function references the viewport object using GlgReferenceObject.

◆ gtk_glg_toolkit_init()

void gtk_glg_toolkit_init ( int  argc,
char *  argv[] 
)

Optional: Initializes GLG Toolkit using applicable command-line options.

Parameters
argcSpecifies the number of command line parameters.
argvSpecifies the command line parameter list.