|
GLG Toolkit, C / C++ API Library
Version 4.5
|
This group contains functions for accessing elements inside GLG container objects. More...
This group contains functions for accessing elements inside GLG container objects.
Container Functions of the Extended API can be used to add or delete objects from the container at run time.
GLG Container objects include Dynamic Array, List and Vector objects.
The following composite objects are also containers and may be used as the container parameter of the Container Functions:
When a container object is created, one of the creation parameters is the type of elements it will contain: GLG_OBJECT, GLG_STRING, GLG_LONG, GLG_ALLOCATED_POINTER or GLG_NON_DRAWABLE_OBJECT (see GlgContainerType for more information).
Container objects that contain GLG_OBJECT, GLG_STRING and GLG_ALLOCATED_POINTER elements manage them when the elements are added or deleted:
When element values for the GLG_STRING, GLG_LONG and GLG_ALLOCATED_POINTER containers are passed as the object parameter of the Container Functions, they can be cast to the GlgObject type to avoid compiler warnings.
There are three types of containers:
There are two flavors of container functions:
The Extended API provides additional functions for adding and deleting elements of a container.
The Simple Array functions of the Standard API may be used to utilize a dynamic array functionality without the Intermediate and Extended APIs.
Functions | |
| GlgBoolean | GlgContainsObject (GlgObject container, GlgObject object) |
| Checks if object belongs to a container. More... | |
| GlgObject | GlgFindObject (GlgObject container, GlgAnyType object, GlgSearchType search_type, GlgAnyType reserved) |
| A generic find function that finds an object in a container. More... | |
| GlgObject | GlgGetElement (GlgObject container, GlgLong index) |
| Returns the object at the specified position in a container. More... | |
| GlgLong | GlgGetIndex (GlgObject container, GlgObject object) |
| Returns index of the first occurrence of an object in a container. More... | |
| GlgObject | GlgGetNamedObject (GlgObject container, char *name) |
| Finds an object with the specified name inside the container of GLG objects and returns it. More... | |
| GlgLong | GlgGetSize (GlgObject container) |
| Returns size of a container object. More... | |
| GlgLong | GlgGetStringIndex (GlgObject container, char *string) |
| Returns index of the first occurrence of a string in a container of the GLG_STRING type. More... | |
| void | GlgInverse (GlgObject container) |
| Inverses the order of elements inside a container object. More... | |
| GlgBoolean | GlgIsAt (GlgObject container, GlgPositionType position) |
| Checks the position of the iteration pointer (the current element of the container). More... | |
| GlgObject | GlgIterate (GlgObject container) |
| Traverses the container object's elements in the forward direction. More... | |
| GlgObject | GlgIterateBack (GlgObject container) |
| Traverses the container object's elements in the backward direction. More... | |
| GlgBoolean | GlgReorderElement (GlgObject container, GlgLong old_index, GlgLong new_index) |
| Changes an element's position inside a container. More... | |
| void | GlgSetEnd (GlgObject container) |
| Initializes the container object for the backward traversing. More... | |
| void | GlgSetStart (GlgObject container) |
| Initializes the container object for the forward traversing. More... | |
| GlgBoolean GlgContainsObject | ( | GlgObject | container, |
| GlgObject | object | ||
| ) |
| GlgObject GlgFindObject | ( | GlgObject | container, |
| GlgAnyType | object, | ||
| GlgSearchType | search_type, | ||
| GlgAnyType | reserved | ||
| ) |
A generic find function that finds an object in a container.
Use GlgContainsObject, GlgGetNamedObject, GlgGetElement or GlgGetIndex convenience functions for specialized tasks.
This function searches for an object based on the specified name, index, or object ID. If the object is found, the function modifies the container's internal position pointer to point to the found object and returns the object; otherwise it leaves the position pointer intact and returns NULL.
Note:The container's position pointer may be affected by another GlgFindObject call, as well as by GlgAddObject, GlgDeleteObject and other functions that search for a container element. Any function using the position pointer (GLG_CURRENT access type) must be called immediately after the GlgFindObject call before any other call which may affect the position pointer.
| container | A container object. |
| object | The container element to search for. Depending on the search type, it may be an object ID, object name, or object's index in the container's object list. |
| search_type | The search type
|
| reserved | A reserved parameter for future extensions; must be NULL. |
Returns the object at the specified position in a container.
| container | A container object. |
| index | The object's position inside the container. |
If the specified index is invalid, an error message is generated and NULL is returned.
While the function provides the Intermediate API functionality, it is also available in the Standard API when used with a group object returned by GlgCreateTagList.
Returns size of a container object.
| container | A container object. |
For a viewport or group object, the size is the number of objects in the viewport or group. For a polygon, the size is the number of vertices.
While the function provides the Intermediate API functionality, it is also available in the Standard API when used with a group object returned by GlgCreateTagList.
Returns index of the first occurrence of a string in a container of the GLG_STRING type.
| container | A container object. |
| string | The string content to search for using strcmp. |
| void GlgInverse | ( | GlgObject | container | ) |
| GlgBoolean GlgIsAt | ( | GlgObject | container, |
| GlgPositionType | position | ||
| ) |
Checks the position of the iteration pointer (the current element of the container).
| container | A container object. |
| position | The position that is being checked. |
True if the container's current position pointer matches the specified position:
Traverses the container object's elements in the forward direction.
| container | A container object. |
GlgIterate advances the iteration pointer and returns the next element of the container.
GlgSetStart must be used to initialize the container for iterating before GlgIterate is invoked the first time. The add, delete and search operations affect the iteration state and should not be performed on the container while it is being iterated.
To perform a safe iteration that is not affected by the add and delete operations, a copy of the container can be created using the GlgCloneObject function with the GLG_SHALLOW_CLONE clone type. The shallow copy will return a new container with a list of objects IDs, and it can be safely iterated while objects are added or deleted from the original container.
Alternatively, GlgGetElement can be used to traverse elements of the container using an element index, which is not affected by the search operations on the container.
The following coding example shows how to iterate all objects in a container using GlgIterate:
Traverses the container object's elements in the backward direction.
| container | A container object. |
GlgIterateBack decrements the iteration pointer and returns the previous element of the container.
GlgSetEnd must be used to initialize the container for backward iteration before GlgIterateBack is invoked the first time. The add, delete and search operations affect the iteration state and should not be performed on the container while it is being iterated.
To perform a safe iteration that is not affected by the add and delete operations, a copy of the container can be created using the GlgCloneObject function with the GLG_SHALLOW_CLONE clone type. The shallow copy will return a new container with a list of objects IDs, and it can be safely iterated while objects are added or deleted from the original container.
Alternatively, GlgGetElement can be used to traverse elements of the container using an element index, which is not affected by the search operations on the container.
The following coding example shows how to iterate all objects in a container in the backward direction using GlgIterateBack:
| GlgBoolean GlgReorderElement | ( | GlgObject | container, |
| GlgLong | old_index, | ||
| GlgLong | new_index | ||
| ) |
Changes an element's position inside a container.
| container | A container object. |
| old_index | The index of an element to be reordered. |
| new_index | A new element position. |
This function moves the element at the old_index to the new_index position inside the container. It generates an error message and returns False if indexes are out of range.
GTK Note: GTK doesn't have a notion of windows' Z order. While the GLG driver tries to maintain the window order as much as possible, windows' Z order may not be correct when a mix of the DrawingArea viewports and native widget viewports (such as a text entry, a combo box, etc.) is displayed in the GTK version of the Toolkit on Linux. This may be the reason why viewports reordered with GlgReorderElement do not appear in the requested Z order.
| void GlgSetEnd | ( | GlgObject | container | ) |
Initializes the container object for the backward traversing.
| container | A container object. |
The function sets the current position pointer past the last element of the container, preparing the container object for the backward traversing with GlgIterateBack.
| void GlgSetStart | ( | GlgObject | container | ) |
Initializes the container object for the forward traversing.
| container | A container object. |
The function sets the current position pointer before the first element of the container, preparing the container object for the forward traversing with GlgIterate.