|
GLG Toolkit, C / C++ API Library
Version 4.6
|
This group contains miscellaneous utility functions. More...
This group contains miscellaneous utility functions.
Functions | |
| GlgLong | GlgAddTimeOut (GlgAppContext context, GlgLong interval, GlgTimerProc callback, GlgAnyType client_data) |
| Adds an interval timer in a platform-independent way. More... | |
| GlgLong | GlgAddWorkProc (GlgAppContext context, GlgWorkProc work_proc, GlgAnyType client_data) |
| Adds a work procedure in a platform-independent way. More... | |
| void | GlgBell (GlgObject viewport) |
| Produces an audio bell in a platform-independent way. More... | |
| char * | GlgCreateRelativePath (char *base_path, char *filename, GlgBoolean return_null_if_not_found, GlgBoolean check_if_exists) |
| Creates a filepath relative to the specified base path and provides options for checking if the path points to an existing file. More... | |
| char * | GlgFindFile (char *filename, char *path, GlgBoolean check_glg_path) |
| Searches for a file, first in the current directory, then in the specified directory and then in the GLG search path. More... | |
| char * | GlgGetDir (char *path) |
| Returns the directory portion of the specified path. More... | |
| char * | GlgGetExePath (void) |
| Returns the path of the program's executable. More... | |
| GlgBoolean | GlgGetLParameter (char *name, GlgLong *value) |
| Queries a value of a global parameter. More... | |
| GlgLong | GlgGetMajorVersion (void) |
| Returns the library's major version number. More... | |
| GlgLong | GlgGetMinorVersion (void) |
| Returns the library's minor version number. More... | |
| GlgAnyType | GlgGetNativeComponent (GlgObject object, char *resource_name, GlgComponentQueryType type) |
| ADVANCED: Returns an ID of a native windowing system component used to render the viewport. More... | |
| char * | GlgGetRelativePath (char *base_path, char *filename) |
| Creates a filepath relative to the specified base path. More... | |
| GlgBoolean | GlgGetTime (GlgULong *sec, GlgULong *microsec) |
| Returns number of seconds and microseconds since the Epoch. More... | |
| char * | GlgGetURLCB (char *request, void *reserved) |
| Fetches data from a URL and saves it in a temporary file. More... | |
| GlgObject | GlgParseArgs (char *program_name, char *args_string, GlgLong *argc, char ***argv) |
| This function is used by the GlgMain generic program entry point on Windows to parse command-line arguments. More... | |
| void | GlgPrintObjectCountChanges (void) |
| Prints object count changes since the last call to this function. More... | |
| void | GlgPrintObjectCounts (void) |
| Prints total object count for each of the GLG object types. More... | |
| double | GlgRand (double low, double high) |
| Generates a random number in a platform-independent way. More... | |
| void | GlgRemoveTimeOut (GlgLong id) |
| Removes a timer procedure. More... | |
| void | GlgRemoveWorkProc (GlgLong id) |
| Removes a work procedure. More... | |
| GlgBoolean | GlgResetSizeConstraint (GlgObject text_obj) |
| Forces GLG_FIT_TO_BOX_TEXT Text objects with a constrained SizeConstraint attribute to renegotiate their font size. More... | |
| GlgBoolean | GlgSetCursorType (GlgObject viewport, char *resource_name, GlgCursorType cursor_type) |
| Sets cursor for a drawing or one of its child viewports. More... | |
| GlgGetURLCallback | GlgSetGetURLCallback (GlgGetURLCallback callback) |
| Installs a custom callback used to fetch data from URLs. More... | |
| GlgBoolean | GlgSetLParameter (char *name, GlgLong value) |
| Sets a value of a global parameter. More... | |
| void | GlgSleep (GlgLong millisec) |
| Suspends application execution for a specified interval in a platform independent way. More... | |
| GlgBoolean | GlgSync (GlgObject viewport) |
| Flushes the windowing system output to the display. More... | |
| GlgLong GlgAddTimeOut | ( | GlgAppContext | context, |
| GlgLong | interval, | ||
| GlgTimerProc | callback, | ||
| GlgAnyType | client_data | ||
| ) |
Adds an interval timer in a platform-independent way.
| context | The application context returned by GlgInit. |
| interval | Time interval in milliseconds. |
| callback | A callback function to be called when the time expires. |
| client_data | Client data to be passed to the callback when it is called. |
This function adds a callback function which is called when the specified time interval expires. See GlgTimerProc for the timer callback prototype.
The interval timer is called only once and is removed immediately after it has been called. GlgRemoveTimeOut may be used to remove an active timeout. If you want the timer procedure to be called continuously, the timer callback itself should call GlgAddTimeOut.
| GlgLong GlgAddWorkProc | ( | GlgAppContext | context, |
| GlgWorkProc | work_proc, | ||
| GlgAnyType | client_data | ||
| ) |
Adds a work procedure in a platform-independent way.
| context | The application context returned by GlgInit. |
| work_proc | A work procedure function to be called repeatedly. |
| client_data | Client data to be passed to the work procedure when it is called. |
This function adds a work procedure. A work procedure is a function to be called repeatedly while the application is waiting for an event. See GlgWorkProc for the work procedure prototype.
If a work procedure returns True, it is removed and will not be called again. If it returns false, it will be called continuously until the application calls the GlgRemoveWorkProc function.
Several work procedures may be added to be performed one at a time. Work procedures must return quickly to avoid response time delays.
| void GlgBell | ( | GlgObject | viewport | ) |
Produces an audio bell in a platform-independent way.
| viewport | Specifies a viewport or a light viewport. This viewport object must be displayed; it specifies the display at which to produce the bell. On Windows, this parameter is ignored and may be NULL. |
| char* GlgCreateRelativePath | ( | char * | base_path, |
| char * | filename, | ||
| GlgBoolean | return_null_if_not_found, | ||
| GlgBoolean | check_if_exists | ||
| ) |
Creates a filepath relative to the specified base path and provides options for checking if the path points to an existing file.
| base_path | Specifies a base path. If NULL, the path of the program's executable will be used. Note: For Linux/Unix platforms, passing argc and argv to GlgInit (or to the GlgSessionC constructor in C++) is required to identify the path of the executable when base_path is NULL. |
| filename | A filename or a relative filepath. If an absolute path is specified, it will be used as is. |
| return_null_if_not_found | Controls the return value in case when check_if_exists=True and the targeted file or directory does not exist. If True, NULL is returned, otherwise a copy of the filename string is returned. |
| check_if_exists | Specifies if the function should check if the file or directory pointed to by the created relative path exists. |
This function is an extended version of GlgGetRelativePath that checks if the file exists and provides additional options for handing non-existent files.
If filename specifies an absolute path, it will be used as is. Otherwise, GlgCreateRelativePath extracts the directory portion of base_path using GlgGetDir and appends filename. If base_path is a directory path that does not point to an existing directory, it must end with '/', or either '/' or '\' on Windows.
If check_if_exists=True, the function checks is the created file path points to an existing file and handles it depending on the setting of the return_null_if_not_found parameter. If check_if_exists=False, the created file path is returned without any checking.
| char* GlgFindFile | ( | char * | filename, |
| char * | path, | ||
| GlgBoolean | check_glg_path | ||
| ) |
Searches for a file, first in the current directory, then in the specified directory and then in the GLG search path.
| filename | A relative filename to search for. If an absolute path is specified, it will be used as is. |
| path | If not NULL, specifies a directory to be searched before using the GLG search path. |
| check_glg_path | If True, the GLG search path will be included in the search. |
Searches for a file specified by filename, first in the current directory, then in the directory provided by the path parameter and then in the GLG search path.
If the file was found, the function returns its file path, otherwise it returns a copy of the filename parameter. The returned file path can be passed to fopen to open the file.
| char* GlgGetDir | ( | char * | path | ) |
Returns the directory portion of the specified path.
| path | A file or directory path. |
The filename is the last component after the last file separator (a forward slash on Linux/Unix, either a forward or backward slash on Windows). A trailing file separator is not removed from the returned string.
If NULL is passed as the path parameter, NULL will be returned. An allocated string representing a current directory ("./" or ".\" on Windows) will be returned if an empty string is passed as path.
A copy of the path string will be returned without changing it (except for an added trailing file separator, if needed) if:
| char* GlgGetExePath | ( | void | ) |
Returns the path of the program's executable.
This function provides a cross-platform way to retrieve the executable's path across both Windows and Linux/Unix systems.
Note: For Linux/Unix platforms, passing argc and argv to GlgInit (or to the GlgSessionC constructor in C++) is required to identify the path of the executable.
| GlgBoolean GlgGetLParameter | ( | char * | name, |
| GlgLong * | value | ||
| ) |
Queries a value of a global parameter.
| name | Parameter name. |
| value | A pointer used to return a parameter's value. |
Refer to the Appendix D: Global Parameters section of the GLG Programming Reference Manual for information on available global parameters.
| GlgLong GlgGetMajorVersion | ( | void | ) |
Returns the library's major version number.
The GLG_MAJOR_VERSION macro also provides the major version number.
| GlgLong GlgGetMinorVersion | ( | void | ) |
Returns the library's minor version number.
The GLG_MINOR_VERSION macro also provides the minor version number.
| GlgAnyType GlgGetNativeComponent | ( | GlgObject | object, |
| char * | resource_name, | ||
| GlgComponentQueryType | type | ||
| ) |
ADVANCED: Returns an ID of a native windowing system component used to render the viewport.
The function provides an access to native windowing components used to render the viewport, making it possible to set their windowing system specific properties.
| object | A viewport or a viewport's parent. |
| resource_name | A resource path for accessing the child viewport inside its parent. Use NULL when the object parameter specifies the viewport. |
| type | The type of a component to retrieve:
|
| char* GlgGetRelativePath | ( | char * | base_path, |
| char * | filename | ||
| ) |
Creates a filepath relative to the specified base path.
| base_path | Specifies a base path. If NULL, the path of the program's executable will be used. Note: For Linux/Unix platforms, passing argc and argv to GlgInit (or to the GlgSessionC constructor in C++) is required to identify the path of the executable when base_path is NULL. |
| filename | A filename or a relative filepath. If an absolute path is specified, it will be returned as is. |
If filename specifies an absolute path, it will be returned as is. Otherwise, GlgGetRelativePath extracts the directory portion of base_path using GlgGetDir, appends filename and returns the resulting string. If base_path is a directory path that does not point to an existing directory, it must end with '/', or either '/' or '\' on Windows.
| GlgBoolean GlgGetTime | ( | GlgULong * | sec, |
| GlgULong * | microsec | ||
| ) |
Returns number of seconds and microseconds since the Epoch.
| sec | A pointer used to return the number of seconds. |
| microsec | A pointer used to return the number of microseconds. |
| char* GlgGetURLCB | ( | char * | request, |
| void * | reserved | ||
| ) |
Fetches data from a URL and saves it in a temporary file.
By default, this function is used for fetching URLs for the GLG editors on all platforms, as well as for the GLG C API runtime on Windows. GlgSetGetURLCallback may be used to activate the default callback for the GLG C API runtime on Linux:
GlgSetGetURLCallback( GlgGetURLCB );
To use it on Linux, the GLG_WGET_PATH environment variable should be set and contain the path to the wget command that will used for fetching URLs.
| request | The URL string to fetch the data from, or NULL to delete the previously fetched temporary file. |
| reserved | This parameter is reserved for future implementations and must be null. |
When GlgGetURLCB is invoked to fetch the next URL, it deletes a temporary file containing the previously fetched URL.
This function is used by the GlgMain generic program entry point on Windows to parse command-line arguments.
| program_name | The path to the program executable. If NULL, GlgGetExePath will be used to obtain the path. |
| args_string | A command line string containing all command-line parameters (the lpCmdLine parameter of WinMain). |
| argc | A pointer to the returned number of parsed command-line arguments. |
| argv | A pointer to the returned argv list of parsed command-line arguments. |
| void GlgPrintObjectCountChanges | ( | void | ) |
Prints object count changes since the last call to this function.
This function may be used to diagnose memory and object leaks.
On Windows, object counts output is stored in the glg_error.log file. On Linux/Unix, the output is also printed to stdout.
| void GlgPrintObjectCounts | ( | void | ) |
Prints total object count for each of the GLG object types.
This function may be used to diagnose memory and object leaks.
On Windows, object counts output is stored in the glg_error.log file. On Linux/Unix, the output is also printed to stdout.
| double GlgRand | ( | double | low, |
| double | high | ||
| ) |
Generates a random number in a platform-independent way.
| low | The low range of the generated random number. |
| high | The high range of the generated random number. |
This function produces a random number in the specified range by using the platform's rand function.
| void GlgRemoveTimeOut | ( | GlgLong | id | ) |
Removes a timer procedure.
| id | The ID of a timer procedure to be removed. The ID was returned by GlgAddTimeOut. |
This function removes an active timer. If the timer has already been removed and is not active, the results are undefined.
| void GlgRemoveWorkProc | ( | GlgLong | id | ) |
Removes a work procedure.
| id | The ID of a work procedure to be removed. The ID was returned by GlgAddWorkProc. |
This function removes an active work procedure. If the work procedure has already been removed and is not active, the results are undefined.
| GlgBoolean GlgResetSizeConstraint | ( | GlgObject | text_obj | ) |
Forces GLG_FIT_TO_BOX_TEXT Text objects with a constrained SizeConstraint attribute to renegotiate their font size.
| text_obj | A Text object of the GLG_FIT_TO_BOX_TEXT subtype that has a constrained SizeConstraint attribute. |
| GlgBoolean GlgSetCursorType | ( | GlgObject | viewport, |
| char * | resource_name, | ||
| GlgCursorType | cursor_type | ||
| ) |
Sets cursor for a drawing or one of its child viewports.
| viewport | A viewport object or a viewport's parent. |
| resource_name | The resource path of a child viewport to set the cursor of, or NULL to set the cursor of the viewport specified by the viewport parameter. The resource path is relative to the object specified by the viewport parameter. |
| cursor_type | One of the system cursor types to be used:
|
This function uses a subset of cursor types that can be used in a cross-platform way. On Windows, GlgSetCursor can be used to use all available Windows cursor types.
The specified cursor will be used when the mouse moves inside the viewport the cursor is assigned to. In the GTK version of the GLG library on Linux, the cursor will be changed for the top window that contains the viewport.
The drawing's hierarchy must be set up in order to set cursor type.
| GlgGetURLCallback GlgSetGetURLCallback | ( | GlgGetURLCallback | callback | ) |
Installs a custom callback used to fetch data from URLs.
URLs may be used to load drawing files from remote servers, as well as to use map server installed at a remote web server. See GlgGetURLCB for details of the default URL fetching callback.
| callback | A custom callback to use for fetching URLs. |
| GlgBoolean GlgSetLParameter | ( | char * | name, |
| GlgLong | value | ||
| ) |
Sets a value of a global parameter.
| name | Parameter name. |
| value | Parameter value. |
Refer to the Appendix D: Global Parameters section of the GLG Programming Reference Manual for information on available global parameters.
| void GlgSleep | ( | GlgLong | millisec | ) |
Suspends application execution for a specified interval in a platform independent way.
| millisec | Sleep interval in milliseconds. |
| GlgBoolean GlgSync | ( | GlgObject | viewport | ) |
Flushes the windowing system output to the display.
If OpenGL is used, it also flushes OpenGL buffers. In X11, it also waits for all requests to be processed.
| viewport | The viewport object whose buffers will be flushed. |