The C API includes C functions and callbacks, as well as platform-specific widgets and controls.
The C functions include are grouped by the API type: Standard, Intermediate and Extended API.
The C API functions can also be used with the C++ API, providing additional functionality that is not available via the C++ bindings. When C API functions are used in C++, the GLG_C_CONST_CHAR_PTR macro may be set to 1 before the GlgApi.h file is included to use constant strings (const char *).
Displaying a GLG Drawing in a Program
A GLG drawing can be displayed by using either the platform-independent GLG Generic API or one of the native widgets and controls:
- If the Generic API is used, the same code can be compiled and used on either Windows or Linux/Unix.
On Linux, an application that uses the Generic API may be built with either the GTK or legacy X11 version of the GLG library.
Click on this link for an example of using the Generic API.
Most of the GLG Demos and Examples also use the Generic API.
- Several native widgets and controls are provided for both Windows and Linux/Unix:
- GtkGlg Widget provides a native GTK-based GLG widget that can be used in the GTK environment on Linux.
- GlgWrapper Widget provides an X11 widget that is used by legacy X11-based applications on Linux/Unix.
- GLG Custom Control provides a Windows Custom Control for embedding GLG drawings in the Win32-based applications.
See GtkmmGlgWidget, GlgWrapperC and GlgControlC for the C++ versions of the native widgets and controls.
Regardless of the way the GLG drawing is displayed (the GLG Generic API or a native container), the rest of the GLG-related application logic is the same, which promotes code sharing between different deployment platforms.
Animating a Drawing with RealTime Data
The drawing can be updates with live data using either resources or tags:
- Resources are hierarchical and can be used to set properties of specific objects in the drawing when the content of the drawing is known in advance. The GlgSetDResource, GlgSetSResource and GlgSetGResource functions may be used by a program to set drawing resources.
- Tags are global and can be used to animate an arbitrary drawing without knowing its content or resource hierarchy. Tags can be assigned by end users in the GLG HMI Configurator or the GLG Builder to specify the tag source of the process database used to animate a particular dynamic parameter. At run time, an application can query a list of tags defined in the drawing and use information in each tag to obtain data from the process database, animating the drawing with the retrieved data.
The GlgSetDTag, GlgSetSTag, GlgSetGTag and GlgCreateTagList functions may be used by a program to update the drawing using tags. The SimpleViewer/SingleThreaded/C/GlgViewer.c file in the GLG installation directory provides an example of querying and updating the drawing using tags.
Handling User Interaction
Input callback is the primary way user interaction is handled in a GLG application. The callback is added to a drawing's viewport using GlgAddCallback.
Trace callback may be used to handle native window system events.
Include file: GlgApi.h