GLG Toolkit, C / C++ API Library  Version 4.5
8. Info

Detailed Description

Modules

 Performance Optimization
 
 Container Objects
 

Simple Array

A Simple Array is a GLG dynamic array object that can be used to hold a variable number of elements, but, unlike a Container, cannot be added to the drawing to draw its elements.

The Simple Array functions have the same functionality as the corresponding container functions of the Intermediate and Extended APIs, but can be used when only the Standard API is available.

These functions work only with with a Simple Array created by GlgArrayCreate and can't be used to add or delete objects from the drawing. The Simple Array functions can't be used in place of the corresponding container functions of the Intermediate and Extended APIs for accessing GLG Container objects.

Custom Interaction Handlers

The Toolkit provides a number of stock interaction handlers, such as GlgButton, GlgSlider, etc. Custom interaction handlers may be developed to be used in the GLG editors as well as in the application at run time.

A custom handler implements an application-specific logic for handling user interaction and is associated with a viewport in a GLG drawing the same way as the stock interaction handlers. In GLG editors, a custom handler is attached to a viewport or a light viewport by assigning the handler name as a value of the viewport's Handler attribute. To avoid error messages in case the custom handler is implemented only in the runtime application code, the custom handler name should start with the $ character, for example "$SampleHandler".

Custom interaction handler code implements a single handler entry point function that will be invoked with different parameters to handle handler initialization and user interaction. The handler is installed by registering this function as a named handler using the GlgAddHandler function, which takes the handler name and its entry point as parameters:

GlgAddHandler( "$TestHandler", TestHandler );
void GlgAddHandler(char *handler_name, GlgHandler func)
Registers a custom interaction handler.

This activates the custom handler in the application at run time.

Using Custom Handlers in the Graphics Builder

To activate the handler in GLG editors, the handler's code can be added to the GLG Editor Custom Options DLL described in the OEM Editor Extensions, Custom Editor Options and Dialogs DLL section of the OEM Customization chapter of the GLG User's Guide and Builder Reference Manual.

Sample Implementation

Sample source code of a custom interaction handler is provided by the src/SampleHandler/SampleHandler.c file in the GLG installation directory.

The sample code is also integrated into the GLG Editor Custom Option DLL to make the sample handler active inside GLG editors. To test the sample handler in the Graphics Builder, run the following script:

  • On Linux/Unix:
    <glg_dir>/editor_extensions/custom_option_example/run_option_example</i>

  • On Windows:
    <glg_dir>\editor_extensions\custom_option_example\run_option_example.bat
then load the sample_handler.g drawing into the Graphics Builder from one of the following locations:

<GLG_DIR>/editor_extensions/custom_option_example/sample_handler.g
<GLG_DIR>/src/SampleHandler/sample_handler.g

Start the prototype mode using the Run, Start menu option, then press the Skip Command button. Click on the buttons to interact with the handler: it will count clicks, and will also trace and display mouse coordinates.