PtGetResource()

Retrieve one resource value for a widget

Synopsis:

#define PtGetResource( widget, type, value, len ) …

Arguments:

widget
A pointer to the widget whose resource you want to set.
type
The resource manifest (e.g. Pt_ARG_COLOR).
value
The address of a pointer to the appropriate data type (see the “New resources” tables in the Photon Widget Reference).
len
Depends on the resource type.

Library:

ph

Description:

This macro sets a pointer to a resource value within the specified widget.

PtGetResource() doesn't support the nonpointer method of getting resources. For information on getting and setting resources, see the Manipulating Resources in Application Code chapter of the Photon Programmer's Guide.


Caution: Because PtGetResource() returns a pointer directly into the internals of the widget, don't modify the resource value directly. If you wish to retrieve the value of a given resource and then modify that value:
  1. Get the resource.
  2. Copy the resource to a temporary variable.
  3. Modify the temporary variable.
  4. Using the modified copy, set the resource.

Returns:

0
Success.
-1
An error occurred.

Examples:

Determine whether or not a widget is highlighted:

unsigned long    *flags;
PtWidget_t       *widget;

PtGetResource( widget, Pt_ARG_FLAGS, &flags, 0 );

printf( "Highlighted: %s\n", 
        *flags & Pt_HIGHLIGHTED ? "Yes":"No" );

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PtArg_t, Pt_ARG(), PtGetResources(), PtSetArg(), PtSetResource(), PtSetResources()

Manipulating Resources in Application Code chapter of the Photon Programmer's Guide.