GLG C++ Bindings

C++ bindings allow you to use the GLG Toolkit with C++ applications as a C++ class library. The bindings are implemented in such a way that every GLG object may be used as a C++ object, and other C++ classes may be derived from it as needed. The source code for the C++ bindings is provided, allowing compiling and using the bindings with any C++ compiler. The underlying GLG library does not depend on a C++ compiler used and may be used with any of them.

As with the GLG C API, the C++ bindings provide you with several ways of using them. If you are programming in a Motif or a Microsoft Windows environment, you can use native features of the corresponding platform, such as GlgWrapperC Widget C++ class for Motif or MFC CWnd derived GlgControlC Class on Microsoft Windows.

If you want to write a cross-platform C++ program that can be compiled without changes in ether Unix or Windows environment, you may use GLG Object C++ class, which uses the generic window-platform independent API of the Toolkit. The InitialDraw() method of the class provides a platform-independent API for creating a window with a GLG drawing displayed inside it.

Using GLG Objects

No matter which C++ API you use in your application, platform-specific or generic, you are always dealing with the main GlgObjectC C++ class. In the Motif environment, the GlgWrapperC widget class is derived from the GlgObjectC class and inherits its methods. In Microsoft Windows environment, the GlgControlC class is derived from CWnd to inherit its window functionality, but it has a viewport object of the GlgObjectC class as it's publicly accessible attribute that provides GLG functionality.

The GlgObjectC class is the central class of the GLG C++ API. It keeps an object ID of the associated GLG object as one of its data members, in the same way as MFC's CWnd class keep a window ID of the associated window.

The GlgObjectC class has several constructors, allowing several ways of creating of the associated GLG object: by loading it from a file, loading from a generated memory image, or by referencing a named resource inside another GLG object.

There is also a default constructor with no arguments, which creates a GlgObjectC class with a NULL GLG object. The GLG object may be associated with this instance of the class later, by using several available Load() methods, which allow loading it from a file, memory image or associating a reference of some named resource of another object. If a Load() method is used for a class instance which already has an associated GLG object, it is dissociated from the previous object and associated with the new one.

The GlgObjectC class also provides an overloaded assignment operator, which associates the left hand side class instance with a reference to the same GLG object of the right hand class instance. Any previous associations are discarded.

There are type converters to and from GlgObject ID, which allows assigning the GlgObject ID to a class and using both the GlgObject ID and the instance of the GlgObjectC class interchangeably.

The GlgObject ID is used as a return value of some methods of the class, allowing you to avoid returning temporary instances of the class or class pointers, both of which may lead to memory leaks or dangling pointers. The GlgObject return value may then be assigned to an instance of the class as in the following example:

GlgObjectC car( "car.g" );
GlgObjectC wheel = car.GetResourceObject( "Wheel0" );

In this example, the object from "car.g" drawing file gets loaded and associated with a car class instance. Then the first wheel of the car gets associated with the wheel class instance. The above example may be rewritten using constructors only:

GlgObjectC car( "car.g" );
GlgObjectC wheel( car, "Wheel0" );

Notice that the wheel class instance is associated with an GLG object which is the part of another object. You cannot add that wheel object to the car object again, because it is already a part of it. You can use the Copy() method to create a new copy of a wheel object and associate that new copy with the class instance:

wheel.Copy();
wheel.SetResource( "Name", "SpareWheel" ); // Use distinct name
car.Add( wheel );

The same thing can also be accomplished by using a copy constructor:

{
GlgObjectC spare_wheel( wheel );
spare_wheel.SetResource( "Name", "SpareWheel" );
car.Add( spare_wheel );
}

Automatic Referencing and Dereferencing

The GlgObjectC class provides automatic referencing and dereferencing of the associated GLG object, freeing the developer from keeping track of temporary objects. For example, the spare_wheel object in the above example gets automatically dereferenced in its destructor when it goes out of scope after being added to a car.

There are also explicit Reference() and Dereference() methods as well as overloaded increment and decrement operators providing the same functionality. Note that these methods should not be normally used and are provided only for some special complex programming cases.

Also note that calling the Deference() method explicitly without referencing the object before that may cause destruction of the object and the invalid GLG object ID.

Comparison Operators

The IsNull() method returns TRUE if there is no GLG object associated with the class instance ( NULL GlgObjectC ID). There is also an overloaded logical negation operator which performs the same function: !object yields TRUE when the there is no associated GLG object.

Notice an interesting usage of double negation: !!object returns TRUE when there is a GLG object associated with the class instance.

The Same() method of the GlgObjectC class provides a logical equality operator: it returns TRUE if the instances of the class is associated with the same GLG object as the instance of the class passed as a parameter.

Using Input and Selection Callbacks

The input and selection callbacks are virtual methods of all three main GLG API classes: GlgObjectC , GlgWrapperC and GlgControlC . To use these callbacks, derive your class from any of these classes and provide your implementation of Input() and Selection() callbacks that overrides the ones of the base class. Use the EnableCallbacks() method of the base class to enable the callbacks. Refer to the programming examples described below for more details.

Miscellaneous Utility Classes

The GlgSessionC class handles initialization of the GLG Toolkit. One instance of this class has to be created to initialize the Toolkit. In some cases the initialization may be skipped, as describer later.

In the Motif environment, the Toolkit is initialized automatically when the Create() method of the Wrapper Widget class is invoked.

In the Microsoft Windows environment, the toolkit is initialized automatically if a .dll version of the library is used, or when a Create() method of the GlgControlC class is invoked.

In both cases, the initialization may be skipped only if there are no other GLG calls were issued before invoking the Create() method. An explicit initialization is mandatory when the Generic C++ API is used. It is always safe to use explicit initialization in either case.

The MainLoop() method of the GlgSessionC class also provides a generic interface to the window system specific event loop.

The GlgLinkC class is derived from the GlgObjectC class and provides additional ICC functionality for communicating between GLG processes using link objects. The class provides methods for establishing a link to a GLG ICC viewport server. The rest of functionality for setting resources and updating through a link is inherited from it's base GlgObjectC class.

Programming Examples

The tree demo and network demos in the DEMOS directory come with complete source code and may be used as examples of using the C++ API. There are also some other C++ examples in the examples directory.

C++ API Files and Libraries

The C++ API consists of the following files:

GlgClass.h

Include file, located in the GLG include directory, declares all GLG C++ classes.

GlgClass.cpp

Source file, located in the GLG source directory (named "src"), has to be compiled with the project.

stdafx.h

Include stub file, is needed on UNIX only to make the source code generic. It allows you to get around the special handling that Visual C++ provides for this file in case of precompiled headers.

No additional libraries are required for GLG C++ bindings.

Standard and Extended API

If you don't have the Extended API library, you have to define the GLG_DISABLE_CPLUS_EXTENDED_API symbol before including the GlgClass.h file. Passing this defined symbol to a compiler using -D option provides the most convenient way of doing it. In the Visual C++ environment, define this symbol in the project settings.

List of Classes and Methods in the GLG C++ Bindings

GlgSessionC

Provides an interface for initializing the GLG Toolkit.

Data Members:
GlgAppContext app_context;

Application context returned by GlgInit().

Methods:
GlgSessionC( void );

Default constructor.

GlgSessionC( GlgBoolean initialized, GlgAppContext application_context, int argc = 0, char ** argv = NULL );

Constructor: calls GlgInit().

virtual ~GlgSessionC( void );

Destructor.

GlgAppContext GetAppContext( void );

Returns the application context.

GlgBoolean MainLoop( void );

Provides a generic interface to the event loop.

void Create( GlgBoolean initialized = False,
GlgAppContext application_context = NULL, int argc = 0,
char ** argv = NULL );

Calls GlgInit() .

GlgObjectC

This is the main class of the GLG C++ bindings. It has the functionality of the regular and Extended API.

Data Members:
GlgObject glg_obj;

An object ID of associated GLG object.

GlgObject suspend_obj;

Suspension information object. Is not NULL if the object was suspended for editing.

Methods:
GlgObjectC( void );

Default constructor: Creates a null object.

GlgObjectC( GlgObjectType type, char * name = NULL,
GlgAnyType data1 = NULL, GlgAnyType data2 = NULL,
GlgAnyType data3 = NULL, GlgAnyType data4 = NULL );

Constructor: creates a new object of the type using default attributes.

GlgObjectC( char * filename );

Constructor: loads an object from a file.

GlgObjectC( long object_data[], long object_data_size );

Constructor: loads an object from a generated memory image.

GlgObjectC( GlgObjectC& object,
GlgCloneType clone_type = GLG_FULL_CLONE );

Copy constructor: creates a copy of the object. The type of copying is defined by a clone_type parameter. Default type is GLG_FULL_CLONE.

GlgObjectC( GlgObjectC& object, char * res_name );

Constructor: associates with a named resource object inside another and references it.

GlgObjectC( GlgObject object );

Constructor: creates a C++ class from GlgObject to allow assigning GlgObject to a GlgObjectC object class:

GlgObjectC object = GetResourceObject( ... );
GlgObjectC( GlgObjectC * object );

Constructor: creates a C++ class from a GlgObjectC pointer. This constructor is needed by some C++ compilers for proper handling of temporary objects.

virtual ~GlgObjectC( void );

Destructor: Deletes or dereferences the GLG object.

operator GlgObject( void );

Type converter to GlgObject .

GlgObjectC& operator= ( const GlgObjectC& object );

Assignment operator: associates the GLG object and references it.

GlgObjectC& operator++( void ); // prefix ++
GlgObjectC& operator++( int ); // postfix ++
GlgObjectC& operator--( void ); // prefix --
GlgObjectC& operator--( int ); // postfix --

Overloaded ++; --, both infix and postfix. Overloaded to reference/dereference.

void Reference( void );
void Drop( void );

Explicit reference/dereference.

GlgBoolean Save( char * filename );

Saves the associated GLG object into a file.

GlgBoolean Load( char * filename, char * object_name = NULL );

Explicit Load() . Replaces the associated GLG object with the loaded one. Two sets of overloaded load functions: one for loading the whole drawing or its named components, and another for extracting just the "$Widget" viewport.

Loads an object from a file. If object_name is not NULL , extracts and loads just that named resource of the object.

GlgBoolean Load( void * object_data, long object_data_size,
char * object_name = NULL );

Loads an object from a generated memory image.

GlgBoolean Load( GlgObjectC& object, char * object_name = NULL );

Associates with an object inside another object and references it. If object_name is NULL , uses the parameter object itself.

GlgBoolean LoadWidget( char * filename );

Loads a "$Widget" viewport from a file.

GlgBoolean LoadWidget( void * object_data, long object_data_size );

Loads a "$Widget" viewport from a generated memory image.

GlgBoolean LoadWidget( GlgObjectC& object );

Loads a "$Widget" viewport from another object.

void LoadNullObject( void );

Dissociates and sets the GLG object ID to NULL .

void Create( GlgObjectType type, char * name = NULL,
GlgAnyType data1 = NULL, GlgAnyType data2 = NULL,
GlgAnyType data3 = NULL, GlgAnyType data4 = NULL );

Replace the current object with a created object.

void Copy( GlgCloneType clone_type = GLG_FULL_CLONE );

Replace the current object with a copy of it.

GlgBoolean GetResource( char * res_name, double * value ); // D-type
GlgBoolean GetResource( char * res_name, char ** s_value ); // S-type
GlgBoolean GetResource( char * res_name, double * x_value,
double * y_value, double * z_value ); // G-type
GlgBoolean GetTag( char * tag_name, double * value ); // D-type
GlgBoolean GetTag( char * tag_name, char ** s_value ); // S-type
GlgBoolean GetTag( char * tag_name, double * x_value,
double * y_value, double * z_value ); // G-type

Get resource or tag values.

GlgBoolean SetResource( char * res_name, double value ); // D-type
GlgBoolean SetResource( char * res_name, char * s_value ); // S-type
GlgBoolean SetResource( char * res_name, double x_value, double y_value,
double z_value); // G-type
GlgBoolean SetResource( char * res_name, double value, GlgBoolean if_changed ); // D-type
GlgBoolean SetResource( char * res_name, char * s_value, GlgBoolean if_changed ); // S-type
GlgBoolean SetResource( char * res_name, double x_value, double y_value,
double z_value, GlgBoolean if_changed ); // G-type
GlgBoolean SetTag( char * tag_name, double value, GlgBoolean if_changed ); // D-type
GlgBoolean SetTag( char * tag_name, char * s_value, GlgBoolean if_changed ); // S-type
GlgBoolean SetTag( char * tag_name, double x_value, double y_value,
double z_value, GlgBoolean if_changed ); // G-type

Set resource or tag values.

GlgBoolean SetResource( char * res_name, char * format, double value );
GlgBoolean SetResource( char * res_name, char * format, double value, GlgBoolean if_changed );
GlgBoolean SetTag( char * tag_name, char * format, double value, GlgBoolean if_changed );

Set S resource or tag from a double value according to the specified format.

GlgBoolean SetResource( char * res_name, GlgObjectC& object );

Set resource from object.

GlgBoolean HasResourceObject( char * res_name );
GlgBoolean HasTagObject( char * tag_name );

Checks is a named resource or tag exists.

GlgObject CreateTagList( GlgBoolean unique_tags );

Creates and returns a list of the object tags.

GlgObject GetGlgObject( void );

Returns an object ID of the associated GLG object.

void SetGlgObject( GlgObject object );

Low-level object manipulation function: sets the associated GLG object.

GlgBoolean IsNull( void );
GlgBoolean operator!( void );

NULL check to use after Load/GetResourceObject/etc.

GlgBoolean Same( GlgObjectC& object );

Returns TRUE if the object refers to the same object ID as the parameter object.

void InitialDraw( void );
void SetupHierarchy( void );
void ResetHierarchy( void );
GlgBoolean Reset( void );

Other viewport-related GLG API functions.

GlgBoolean Sync( void );
GlgBoolean Update( void );

Update/Sync viewports and links.

void EnableCallback( GlgCallbackType callback_type,
GlgObject callback_viewport = NULL );

Enables selection and input callbacks of the object. If callback_viewport is not NULL, adds GLG callbacks to it, otherwise adds it to this object (which must be a viewport).

virtual void Input( GlgObjectC& callback_viewport, GlgObjectC& message );
virtual void Select( GlgObjectC& callback_viewport, char ** name_array );
virtual void Trace( GlgObjectC& callback_viewport, GlgTraceCBStruct * trace_info );
virtual void Trace2( GlgObjectC& callback_viewport, GlgTraceCBStruct * trace_info );

Virtual callback functions to be overridden by a derived class.

GlgBoolean SetZoom( char * res_name, GlgLong type, double value )

Performs a zoom or pan operation specified by the type parameter. If the res_name parameter is null, the viewport itself is zoomed. Otherwise, the zoom operation will be performed on its child viewport specified by the res_name parameter. The value parameter defines the zoom factor or pan distance. Refer to GlgSetZoom on page 71 for a complete list of all zoom and pan types.

GlgBoolean SetGISZoom( char * res_name, GlgObjectC& gis_object, char * gis_name )

Sets or resets a viewport's GIS Zoom Mode. If the GIS zoom mode is set, any zooming and panning operations invoked by the GlgSetZoom method will zoom and pan the map displayed in the viewport's GIS object instead of being applied to the viewport's drawing. If the res_name parameter is null, the GIS zoom mode of the viewport itself will be set. Otherwise, the GIS zoom mode will be set for its child viewport specified by the res_name parameter. If the gis_name parameter is not null, it specifies the resource path of the GIS object relative to the gis_object parameter, or relative to the viewport if the gis_object parameter is null. The method may be invoked with gis_object=null and gis_name=null to reset the GIS zoom mode.

GlgBoolean Print( char * filename="out.ps",
double x=-1000., double y=-1000.,
double width = 2000., double height = 2000.,
GlgBoolean portrait = True, GlgBoolean stretch = True );

Printing method.

GlgBoolean SaveImage( char * res_name, char * filename, GlgImageFormat format )

Method for saving an image of the visible area of the drawing's viewport.

GlgBoolean SaveImageCustom( char * res_name, char * filename, GlgImageFormat format,
GlgLong x, GlgLong y, GlgLong width, GlgLong height, GlgLong gap )

Method for saving an unclipped image of the whole drawing.

void MetaDraw( char * filename="out.meta",
double x=-1000., double y=-1000.,
double width = 2000., double height = 2000.,
GlgBoolean portrait = True, GlgBoolean stretch = True );

GLG Metafile support.

GlgBoolean Print( CDC * dc, double x=-1000., double y=-1000.,
double width = 2000., double height = 2000.,
GlgBoolean portrait = True, GlgBoolean stretch = True );

MICROSOFT WINDOWS ONLY: Native windows printing, GLG controlled page layout.

void OnPrint( CDC * dc );

MICROSOFT WINDOWS ONLY: Native window printing, windows-controlled page layout.

void OnDrawMetafile( CDC * dc );

MICROSOFT WINDOWS ONLY: Native window printing with clipping disabled.

GlgAnyType SendMessage( char * res_name, char * message, GlgAnyType param1,
GlgAnyType param2, GlgAnyType param3, GlgAnyType param4 )

Sends a message specified by the message parameter. If the res_name parameter is null, the message is sent to the object itself. Otherwise, the message is sent to the object's child specified by the res_name parameter. The param<n> arguments define additional parameters of the message depending on the message type.

Extended API
GlgObject GetResourceObject( char * res_name );

Explicit GetResourceObject() . The return value may be assigned to a GlgObjectC class.

GlgBoolean SetResourceObject( char * res_name, GlgObjectC& o_value );

Sets the new value of the object's attribute specified by the res_name . It is used for attaching Custom Property objects and aliases .

GlgObject GetTagObject( char * tag_name, GlgBoolean unique_tags, GlgBoolean single_tag )

Finds a single tag or creates a list of tags matching the wildcard. In a single tag mode, returns the first found tag with the tag name. The unique_tags controls if only one tag is included in case there are multiple tags with the same name. It is ignored in the single tag mode. The return value may be assigned to a GlgObjectC class.

GlgBoolean SetXform( GlgObjectC& xform );

Adds a transformation to the object.

GlgObject GetParent( GlgLong * num_parents );

Gets a parent object or array of parents if num_parents > 1.

GlgCube * GetBoxPtr( void );

Returns 3D bounding box of an object.

GlgObject GetDrawingMatrix( void );

Returns a drawing matrix object used to render the object.

void SuspendObject( void );
void ReleaseObject( void );

Suspends or releases the object.

GlgObject CreateResourceList( GlgBoolean list_named, GlgBoolean list_default, GlgBoolean list_aliases );

Returns a list of resources of the object.

GlgBoolean MoveObject( GlgCoordType coord_type, GlgPoint * start_point, GlgPoint * end_point );

Moves an object by the specified vector.

GlgBoolean MoveObjectBy( GlgCoordType coord_type, double x, double y, double z );

Moves an object by the specified X, Y and Z distances.

GlgBoolean ScaleObject( GlgCoordType coord_type, GlgPoint * center, double x, double y, double z );

Scales an object relative to the center by the specified X, Y and Z scale factors.

GlgBoolean RotateObject( GlgCoordType coord_type, GlgPoint * center, double x, double y, double z );

Rotates an object around the specified center by the specified X, Y and Z angles.

GlgBoolean PositionObject( GlgCoordType coord_type, GlgLong anchoring,
double x, double y, double z );

Positions an object at the specified location using the specified anchoring.

GlgBoolean FitObject( GlgCoordType coord_type, GlgCube * box );

Fits the object to the specified area.

GlgBoolean LayoutObjects( GlgObject sel_elem, GlgLayoutType type, double distance,
GlgBoolean use_box )

Perform requested layout operation. Refer to The GLG Extended API on page 97 for more details.

GlgBoolean ScreenToWorld( GlgBoolean inside_vp, GlgPoint * in_point, GlgPoint * out_point );

Converts a point coordinates from the screen to the GLG world coordinate system. The inside_vp flag must be set to GlgTrue for viewport objects to convert to the world coordinate system inside the viewport.

GlgBoolean WorldToScreen( GlgBoolean inside_vp, GlgPoint * in_point, GlgPoint * out_point );

Converts a point coordinates from the GLG world to the screen coordinate system. The inside_vp flag must be set to GlgTrue for viewport objects to convert from the world coordinate system inside the viewport.

Attribute Objects
GlgBoolean ConstrainObject( GlgObjectC& to_attribute );
GlgBoolean UnconstrainObject( void );

Constrain or unconstrain the attribute object.

Matrix Objects
GlgObject InverseMatrix( void );

Creates and returns a new matrix.

void TransformPoint( GlgPoint * in_point, GlgPoint * out_point );

Transforms point using the GLG matrix object associated with this class instance.

void GetMatrixData( GlgMatrixData * matrix_data );

Queries matrix coefficients.

void SetMatrixData( GlgMatrixData * matrix_data );

Sets matrix coefficients.

Container Functionality
GlgBoolean IsContainer( void );

Returns TRUE if the associated GLG object is a GLG container (viewport,

void SetStart( void );

Initializes container for traversing.

GlgObject Iterate( void );

Returns the next subobject of the associated container object.

GlgLong GetSize( void );

Returns the size of the associated container object.

GlgBoolean AddToTop( GlgObjectC& object );
GlgBoolean AddToBottom( GlgObjectC& object );
GlgBoolean AddAt( GlgObjectC& object, GlgLong index );

Add object to container.

GlgBoolean DeleteTopObject( void );
GlgBoolean DeleteBottomObject( void );
GlgBoolean DeleteObjectAt( GlgLong index );
GlgBoolean DeleteObject( GlgObjectC& object );

Delete this object from container.

GlgObject ReorderElement( GlgLong old_index, GlgLong new_index );

Reorder elements of the container.

GlgBoolean ContainsObject( GlgObjectC& object );
GlgObject GetElement( GlgLong index );
GlgObject GetNamedObject( char * name );
GlgLong GetIndex( GlgObjectC& object );
GlgLong GetStringIndex( char * string );

Search functions for finding elements of a container.

void Inverse();

Inverses the order of container's elements.

GlgLinkC

GlgLinkC is subclassed from GlgObjectC to inherit SetResource() and GetResource() and other methods. Provides methods for establishing links between GLG processes by using GLG ICC. Some inherited methods of extended API are not implemented yet for links. Note also that there is a type converter to GlgObject that is inherited from GlgObjectC.

Methods:
GlgLinkC( void );

Default constructor: creates a null link object.

GlgLinkC( char * display_name, char * server_name );

Constructor: creates a link object and connects it to a named GLG ICC Server.

GlgLinkC( GlgObjectC& object );

Constructor: creates a link from a GlgObjectC class:
GlgObjectC some_object;
GlgLinkC link = some_object;

GlgLinkC( GlgObject object );

Constructor: creates a link from a GlgObject .

GlgLinkC( GlgLinkC& object );

Copy constructor. The server connection is not copied.

virtual ~GlgLinkC( void );

Destructor, calls GlgDestroyLink() .

Connect( char * display_name, char * server_name );

Establish a connection to a named GLG ICC Server.

Disconnect( void );

Explicit link closing, calls GlgDestroyLink().

GlgLinkC& operator= ( const GlgLinkC& object );

Assignment operator, the server connection is not copied.

GlgBoolean IsActive();

Interface to GlgLinkActive : returns TRUE is the link is active.

GlgControlC (Microsoft Windows Only)

MFC CWnd derived class providing a window for displaying a GLG drawing.

Data Members:
GlgObjectC viewport;

An object ID of the associated GLG viewport object with the drawing.

Methods:
GlgControlC( void );

Default constructor: creates an empty control.

virtual ~GlgControlC( void );

Destructor. Destroys the window and dereferences the viewport object.

void Create( char * drawing_file, CWnd * parent,
char * control_name = "GlgControl", CRect * in_rect = NULL,
int IDC_id = 0 );

Create control's window, load drawing from a file.

void Create( void * drawing_image, long image_size, CWnd * parent,
char * control_name = "GlgControl", CRect * in_rect = NULL,
int IDC_id = 0 );

Create control's window, load drawing from a generated memory image.

void Create( GlgObjectC& object, CWnd * parent,
char * control_name = "GlgControl",
CRect * in_rect = NULL, int IDC_id = 0 );

Create control's window, use the "$Widget" viewport of another object as a drawing.

void InitialDraw();

Draw the graphics the first time.

GlgBoolean Update( void );

Update the displayed graphics.

void SetDrawing( char * filename );

Change the drawing, load a new drawing from a file.

void SetDrawing( void * drawing_image, long drawing_image_size );

Change the drawing, load a new drawing from a generated memory image.

void SetDrawing( GlgObjectC& object );

Change the drawing, use the "$Widget" viewport of another object as a new drawing.

virtual void EnableCallback( GlgCallbackType callback_type,
GlgObject callback_viewport = NULL );

Enables selection and input callbacks of the control. If callback_viewport is not NULL , adds GLG callbacks to it, otherwise adds it to the control's viewport.

virtual void Input( GlgObjectC& callback_viewport,
GlgObjectC& message );
virtual void Select( GlgObjectC& callback_viewport, char ** name_array );
virtual void Trace( GlgObjectC& callback_viewport, GlgTraceCBStruct * trace_info );
virtual void Trace2( GlgObjectC& callback_viewport, GlgTraceCBStruct * trace_info );

Virtual callback functions to be overridden by a derived class.

void Print( CDC * pDC, DWORD dwFlags );

Native Windows print method.

GlgObject GetViewport( void );

Returns an object ID of the control's viewport.

GlgWrapperC (X Windows Only)

C++ wrapper around the GlgWrapper widget. It is a subclass of a GlgObjectC and inherits GLG API and GLG Extended API from it. Note that the GetViewport() method has to be called explicitly after the widget has been realized and before any API functions are used. The GlgGetViewport() method associates a viewport object with the instance of a class. While the widget is being realized, the widget creates a viewport. The viewport is set to NULL initially and its object ID has to be obtained from the widget after the widget has been realized. Since the widget may be realized by its parent, it is difficult to encapsulate GetViewport () functionality into the GlgWrapperC class so that it is transparent to the user. Trying to do so causes a lot of code duplication and will lead to problems in the future, so invoking this call is left as the responsibility of the user.

Data Members:
Widget widget;
Methods:
GlgWrapperC( void );

Default constructor: creates an empty wrapper widget with no drawing.

virtual ~GlgWrapperC( void );

Destructor. Destroys the wrapper widget. Be careful to set the widget to NULL if it is destroyed by destroying its parent to avoid XtDestroyWidget() being called with an invalid widget ID.

void Create( char * filename, Widget parent, char * widget_name = "GlgWrapper",
long width = 400, long height = 300 );

Create the widget, load drawing from a file.

void Create( void * image_data, long image_data_size, Widget parent,
char * widget_name = "GlgWrapper", long width = 400,
long height = 300 );

Create the widget, load drawing from a generated memory image.

void Create( GlgObjectC& object, Widget parent,
char * widget_name = "GlgWrapper",
long width = 400, long height = 300 );

Create the widget, use the "$Widget" viewport of another object as a drawing.

The following collection of SetDrawing() methods change the drawing using a particular wrapper widget resource. The actual drawing displayed is still subject to the priority of a particular wrapper widget drawing resource. Setting the drawing by using one of the SetDrawing() functions may interfere with others.

void SetDrawing( char * filename );

Load a new drawing from a file (uses XtNglgDrawingFile resource).

void SetDrawing( void * image_data, long image_data_size );

Load a new drawing from a generated memory image ( uses XtNglgDrawingImage resource).

void SetDrawing( GlgObjectC& object );

Use the "$Widget" viewport of another object as a new drawing (uses XtNglgDrawingObject resource).

Widget GetWidget( void );

Returns a widget id.

GlgObject GetViewport();

Associates a viewport object of the wrapper widget with the instance of the class after the widget has been realized.

void EnableCallback( GlgCallbackType callback_type,
GlgObject callback_viewport = NULL );

Enables selection and input callbacks of the control. If callback_viewport is not NULL, adds GLG callbacks to it, otherwise adds it to the widget's viewport.

virtual void Input( GlgObjectC& callback_viewport, GlgObjectC& message );
virtual void Select( GlgObjectC& callback_viewport, char ** name_array );
virtual void Trace( GlgObjectC& callback_viewport, GlgTraceCBStruct * trace_info );
virtual void Trace2( GlgObjectC& callback_viewport, GlgTraceCBStruct * trace_info );

Virtual callback functions to be overridden by a derived class.

void SetXtResource( String xt_res_name, char * res_value );
void GetXtResource( String xt_res_name, char ** res_value_ptr );

Set and get Xt resources of string type (is primarily used with XtNglgHResource * and XtNglgVResource * resources).