|
GLG Toolkit, JavaScript Library
Version 4.6
|
This group contains methods for querying objects, their properties and relations to other objects. More...
This group contains methods for querying objects, their properties and relations to other objects.
Functions | |
| GlgObject | CreatePointArray (GlgControlPointType type) |
| ADVANCED: Creates and returns an array containing all control points of the object. More... | |
| GlgObject | CreateResourceList (boolean list_named_res, boolean list_def_attr, boolean list_aliases) |
| Returns a list of the object's resources. More... | |
| static String | CreateResourcePath (GlgObject object, GlgObject parent) |
| Returns a relative resource path that can be used to access the object as a resource of the parent object. More... | |
| Object | FindObjects (GlgObjectMatchType match_type, boolean find_parents, boolean include_top_object, boolean find_first_match, boolean search_inside, boolean search_drawable_only, GlgObjectType object_type, String object_name, String resource_name, GlgObject object_id, Function custom_match, boolean search_templates, boolean dont_add_matches) |
| Finds either one or all parents or children of the object that match the supplied search criteria. More... | |
| GlgObject | GetAction (GlgActionType action_type, GlgTriggerType trigger_type, int button, GlgArmedStateType armed_state, GlgDoubleClickStateType double_click_state, String action, String subaction, boolean enabled_only) |
| Returns the first found action with the matching parameters attached to the object. More... | |
| GlgObject | GetAlarmObject (String alarm_label, boolean single_alarm) |
| Retrieves an alarm object with a specified alarm label inside the object the method is invoked on. More... | |
| GlgCube | GetBox () |
| Returns the object's bounding box extent in screen coordinates. More... | |
| int | GetNumParents () |
| ADVANCED: Returns number of the object's parents. More... | |
| GlgObject | GetObjectViewport (boolean heavy_weight, boolean self) |
| Returns parent viewport of the drawable object. More... | |
| GlgObject | GetParent () |
| ADVANCED: Returns the object's parent object, if one exists, or an array of all parents for constrained data objects. More... | |
| GlgObject | GetParentViewport (boolean heavy_weight) |
| Returns parent viewport of the drawable object. More... | |
| Object | GetResource (String resource_name) |
| Deprecated, use GetNativeComponent: Returns an ID of a native resource. More... | |
| GlgObject | GetResourceObject (String resource_name) |
| Finds and returns a named resource or an attribute of the object. More... | |
| GlgObject | GetTagObject (String search_string, boolean by_name, boolean unique_tags, boolean single_tag, GlgTagType tag_type_mask) |
| Retrieves a tag object with a specified tag name, data tag source, or export tag category inside the object the method is invoked on. More... | |
| boolean | HasTag (String tag_name, GlgTagType tag_type_mask) |
| Checks if a data or export tag with a specified tag name exists inside the object the method is invoked on. More... | |
| boolean | IsDrawable () |
| Checks if the object is drawable. More... | |
| GlgObject | QueryTags (GlgTagType tag_type_mask) |
| Returns a group of all tags of the requested tag type defined in the object. More... | |
| void | TraverseObjects (Function enter_func, Function exit_func) |
| Traverses the object hierarchy of the object and invokes the supplied functions on the object itself and all its subobjects, including object attributes. More... | |
| boolean | UnconstrainObject () |
| Unconstrains the object's attribute or the object's point. More... | |
| GlgObject CreatePointArray | ( | GlgControlPointType | type | ) |
ADVANCED: Creates and returns an array containing all control points of the object.
| type | The type of points to be returned:
|
| GlgObject CreateResourceList | ( | boolean | list_named_res, |
| boolean | list_def_attr, | ||
| boolean | list_aliases | ||
| ) |
Returns a list of the object's resources.
| list_named_res | Include named resources if true. |
| list_def_attr | Include default attributes if true. The resource objects referred to by the default resource names are not actually included in the list. Instead a dummy scalar data object (type D) is included whose name is the same as the default attribute. |
| list_aliases | Include aliases if true. The resource objects referred to by the aliases are not included in the list. Instead a dummy scalar data object (type D) is included whose name is the same as the alias. |
The list_named_res, list_def_attr and list_aliases parameters let you choose whether the returned array should include named resources, default attributes, aliases or any combination of the above.
The returned array has one entry for each resource. The entries are not sorted and are listed in the order of the occurrence inside their category. The named resources (if any) are listed first, then default resources and finally the aliases.
For named resources, the entries are the resource objects themselves. For default resources and aliases, the entries are dummy scalar data objects named after the default attributes or aliases. For both types of entries, the name of the entry object is the name of the resource listed.
The following code fragment shows how to print the list of an object's resources:
The method returns resource list on only one level of the resource hierarchy. To see the resource lists of the returned resources, invoke CreateResourceList recursively using one of the following techniques:
Returns a relative resource path that can be used to access the object as a resource of the parent object.
| object | The object whose resource path is being queried. The object must be named. |
| parent | The parent object relative to which the resource path is evaluated. It must have its HasResources flag set. |
| Object FindObjects | ( | GlgObjectMatchType | match_type, |
| boolean | find_parents, | ||
| boolean | include_top_object, | ||
| boolean | find_first_match, | ||
| boolean | search_inside, | ||
| boolean | search_drawable_only, | ||
| GlgObjectType | object_type, | ||
| String | object_name, | ||
| String | resource_name, | ||
| GlgObject | object_id, | ||
| Function | custom_match, | ||
| boolean | search_templates, | ||
| boolean | dont_add_matches | ||
| ) |
Finds either one or all parents or children of the object that match the supplied search criteria.
| match_type | Specifies a bitwise mask of the object matching criteria. The following criteria are supported:
All of the criteria in the mask must be true in order for an object to match. |
| find_parents | Controls search direction:
|
| include_top_object |
|
| find_first_match |
|
| search_inside |
|
| search_drawable_only |
|
| object_type | Object type for the object type search. Only objects of this type will be matched. |
| object_name | Object name for the object name search. Only objects with this name will be matched. |
| resource_name | Resource name for the RESOURCE_MATCH. "resource search". Only objects that have a resource at the resource path specified by resource_name will be matched. The resource pointed to by the resource path must be an object. |
| object_id | An object to be matched for the OBJECT_ID_MATCH "object ID match". Only the specified object will be matched. This type of search can be used to find out if the specified object is either a child or a parent of the object the method is invoked on. |
| custom_match | A function that will be invoked for each object to provide custom matching logic. The function must have the following type signature: boolean custom_match( GlgObject object );
where:
The function should return true if a match was detected, |
| search_templates |
This flag is ignored when the search is performed before hierarchy setup, when the instances have not yet been loaded, and only the templates are available. |
| dont_add_matches |
|
| GlgObject GetAction | ( | GlgActionType | action_type, |
| GlgTriggerType | trigger_type, | ||
| int | button, | ||
| GlgArmedStateType | armed_state, | ||
| GlgDoubleClickStateType | double_click_state, | ||
| String | action, | ||
| String | subaction, | ||
| boolean | enabled_only | ||
| ) |
Returns the first found action with the matching parameters attached to the object.
| action_type | An action type. If zero (0), actions of any type will be considered. |
| trigger_type | A trigger type. If zero (0), actions with any trigger type will be considered. |
| button | A mouse button. If zero (0), actions that are activated by any mouse button will be considered. |
| armed_state | The setting of the action's ProcessArmed attribute, see GlgArmedStateType. |
| double_click_state | The setting of an action's DoubleClick attribute, see GlgDoubleClickStateType. |
| action | The input action string for action objects with INPUT_TRIGGER trigger. If null, action objects with any input action string will be considered. |
| subaction | Specifies input subaction string for action objects with INPUT_TRIGGER trigger. If null, action objects with any input subaction string will be considered. |
| enabled_only | If true, only actions enabled by the settings of their Enabled attribute will be considered. |
| GlgObject GetAlarmObject | ( | String | alarm_label, |
| boolean | single_alarm | ||
| ) |
Retrieves an alarm object with a specified alarm label inside the object the method is invoked on.
The search string can contain wildcards to retrieve a list of alarms matching the specified alarm label pattern.
| alarm_label | A string or a pattern for the search (may include ? and wildcards). |
| single_alarm | Defines a single alarm (true) or multiple alarm (false) mode. |
The GetElement and GetSize methods may be used to handle the returned group object.
| GlgCube GetBox | ( | ) |
Returns the object's bounding box extent in screen coordinates.
For efficiency, if the returned object is not null, it can be returned to the internal cache via the object's x ReleaseToCache method.
The object box may be converted to world coordinates by using the sequence of the GetDrawingMatrix, CreateInversedMatrix and TransformPoint methods.
| int GetNumParents | ( | ) |
ADVANCED: Returns number of the object's parents.
This method is used to determine the type of the return value of the GetParent method and must be called after the hierarchy is created.
For constrained objects, the method returns a number greater than 1.
| GlgObject GetObjectViewport | ( | boolean | heavy_weight, |
| boolean | self | ||
| ) |
Returns parent viewport of the drawable object.
| heavy_weight | Controls the type of a parent viewport to be returned.
|
| self |
|
The object's hierarchy must be set up to use this method, otherwise an error message is generated and null is returned.
| GlgObject GetParent | ( | ) |
ADVANCED: Returns the object's parent object, if one exists, or an array of all parents for constrained data objects.
For constrained data objects, there may be more than one parent object. In this case, the method returns an array of parent objects. GetNumParents may be used to determine the type of the return value.
The returned array of parents is an internal object which should not be modified and is destroyed when the object's hierarchy is reset. To keep it around, create a copy using SHALLOW_CLONE, which prevents array's elements from being modified by the GLG internals.
This method must be called after the hierarchy is created.
| GlgObject GetParentViewport | ( | boolean | heavy_weight | ) |
Returns parent viewport of the drawable object.
| heavy_weight | Controls the type of a parent viewport to be returned.
|
The object's hierarchy must be set up to use this method, otherwise an error message is generated and null is returned.
| Object GetResource | ( | String | resource_name | ) |
Deprecated, use GetNativeComponent:
Returns an ID of a native resource.
| resource_name | Specifies the resource path of a native resource. |
This method was used in previous releases to get IDs of native objects used to render the viewport's drawing.
The method is deprecated, use GetNativeComponent.
| GlgObject GetResourceObject | ( | String | resource_name | ) |
Finds and returns a named resource or an attribute of the object.
| resource_name | A resource path to access the resource object inside the object the method is invoked on. It may use object names or default attribute names. |
This method finds and returns a named resource or an attribute of the object. It cannot be used to access attributes that are not objects, such as an object's Name.
If the resource is not found, the method returns null. No error message is generated in this case, so this method can be used to query if a resource exists.
| GlgObject GetTagObject | ( | String | search_string, |
| boolean | by_name, | ||
| boolean | unique_tags, | ||
| boolean | single_tag, | ||
| GlgTagType | tag_type_mask | ||
| ) |
Retrieves a tag object with a specified tag name, data tag source, or export tag category inside the object the method is invoked on.
The search string can contain wildcards to retrieve a list of tags matching the specified tag name, tag source or category pattern.
| search_string | A string or a pattern for the search (may include the ? and * wildcards). |
| by_name | If true, the search is performed by matching the tag names, otherwise the search is done by matching the tag sources for data tags or matching the tag categories for export tags. |
| unique_tags | Controls if only one tag is included in case there are multiple data tags with the same TagName or TagSource (is ignored in the single tag mode and when searching for export tags):
|
| single_tag | Defines the single tag (true) or multiple tag (false) mode. In the single tag mode, the first found tag object of the highest priority matching the search criteria will be returned. Input tags are prioritized over output tags, and enabled tags over disabled tags. |
| tag_type_mask | Defines the type of tags to query: data tags or export tags. For export tags, tag type constants may be combined with bitwise OR to query multiple subtypes of export tags. |
The GetElement and GetSize methods may be used to handle the returned group object in the multiple tag mode.
| boolean HasTag | ( | String | tag_name, |
| GlgTagType | tag_type_mask | ||
| ) |
Checks if a data or export tag with a specified tag name exists inside the object the method is invoked on.
| tag_name | Specifies the TagName to query. |
| tag_type_mask | Defines the type of tags to query: For export tags, tag type constants may be combined with bitwise OR to query multiple subtypes of export tags. |
| boolean IsDrawable | ( | ) |
Checks if the object is drawable.
Drawable objects can be placed directly in a drawing area, have control points and a bounding box, have the Visibility attribute and can contain custom properties, actions and aliases.
For a Chart object, the Chart itself is drawable, but its Plot objects are not.
| GlgObject QueryTags | ( | GlgTagType | tag_type_mask | ) |
Returns a group of all tags of the requested tag type defined in the object.
| tag_type_mask | Defines the type of tags to query: For export tags, tag type constants may be combined with bitwise OR to query multiple subtypes of export tags. |
Each element of the returned group is an attribute object that has a tag attached. The GetElement and GetSize methods may be used to handle the returned group object.
| void TraverseObjects | ( | Function | enter_func, |
| Function | exit_func | ||
| ) |
Traverses the object hierarchy of the object and invokes the supplied functions on the object itself and all its subobjects, including object attributes.
One function is invoked when entering an object and another when exiting it.
| enter_func | A custom traversal function that will be invoked for each traversed object to perform a custom action before traversing its subobjects. The function must have the following type signature: boolean enter_action( GlgObject object );
where:
The function's return result is used to modify the traversal: if the function returns false for a subobject, traversal of objects inside the subobject will not be performed. |
| exit_func | An optional function that will be invoked for each traversed object to perform a custom action after traversing its subobjects. If null is supplied as the value of the exit_func parameter, the exit function will not be used. The function must have the same type signature as enter_action and must always return true. |
| boolean UnconstrainObject | ( | ) |
Unconstrains the object's attribute or the object's point.
| attribute | The attribute or point object to be unconstrained. |
This method removes any constraints applied to an attribute object. Any changes made to the object while it was constrained to another object are permanent and will be in effect even after the constraints are removed. The removal of the constraints only means that changes to this object are no longer copied to the other objects to which it was once constrained.
If any of the objects which are using this attribute object (or any objects with attributes constrained to it) have already been drawn, an error message will be generated. You should either unconstrain object attributes before drawing the object or use the SuspendObject and ReleaseObject methods to temporarily suspend a drawn object for editing.