Superclass for all widgets
PtWidget
Immediate subclasses:
For more information, see the diagram of the widget hierarchy.
None — not normally instantiated.
<photon/PtWidget.h>
PtWidget is the fundamental superclass. All widgets belong to a subclass of PtWidget.
Geometry refers to the size and location of the widget. The following resources let you set and get the widget's geometry in various ways:
These resources aren't displayed in PhAB's control panel; you can use the pointer to change a widget's size and location, or you can edit the values in PhAB's toolbar. Setting one of these resources causes the others to be updated automatically.
You can store arbitrary data in a widget by using these resources:
If you use Pt_ARG_POINTER, you can have several widgets pointing at the same data. If you free the data, you'll need to make sure that no widgets still refer to it.
There's another resource, Pt_ARG_DATA, that sounds like it can be used for storing user data, but it can't. It's used internally by PhAB applications and compound widgets. |
Resource | C type | Pt type | Default |
---|---|---|---|
Pt_ARG_ANCHOR_FLAGS | unsigned | Flag | 0 |
Pt_ARG_ANCHOR_OFFSETS | PhRect_t | Struct | 0, 0, 0, 0 |
Pt_ARG_AREA | PhArea_t | Struct | 0,0,0,0 |
Pt_ARG_BEVEL_WIDTH | unsigned short | Scalar | 2 |
Pt_ARG_BITMAP_CURSOR | PhCursorDef_t * | Alloc | NULL |
Pt_ARG_CURSOR_COLOR | PgColor_t | Scalar | Ph_CURSOR_DEFAULT_COLOR |
Pt_ARG_CURSOR_TYPE | unsigned short | Scalar | Ph_CURSOR_INHERIT |
Pt_ARG_DATA | void * | Alloc | NULL |
Pt_ARG_DIM | PhDim_t | Struct | 0,0 |
Pt_ARG_EFLAGS | unsigned long | Flag | 0 |
Pt_ARG_EXTENT | PhRect_t | Struct | 0,0,0,0 |
Pt_ARG_FLAGS | long | Flag | 0 |
Pt_ARG_GRID_LAYOUT_DATA | PtGridLayoutData_t * | Struct | NULL |
Pt_ARG_HEIGHT | unsigned short | Scalar | 0 |
Pt_ARG_HELP_TOPIC | char * | String | NULL |
Pt_ARG_LAYOUT_DATA | void * | Struct | NULL |
Pt_ARG_MAXIMUM_DIM | PhDim_t | Struct | 0,0 |
Pt_ARG_MINIMUM_DIM | PhDim_t | Struct | 0,0 |
Pt_ARG_POINTER | void * | Pointer | NULL |
Pt_ARG_POS | PhPoint_t | Struct | 0,0 |
Pt_ARG_RESIZE_FLAGS | long | Flag | 0 |
Pt_ARG_ROW_LAYOUT_DATA | PtRowLayoutData_t * | Struct | NULL |
Pt_ARG_USER_DATA | void * | Alloc | NULL |
Pt_ARG_WIDTH | unsigned short | Scalar | 0 |
Pt_CB_BLOCKED | PtCallback_t * | Link | NULL |
Pt_CB_DESTROYED | PtCallback_t * | Link | NULL |
Pt_CB_DND | PtCallback_t * | Link | NULL |
Pt_CB_FILTER | PtRawCallback_t * | Link | NULL |
Pt_CB_HOTKEY | PtHotkeyCallback_t * | Link | NULL |
Pt_CB_IS_DESTROYED | PtCallback_t * | Link | NULL |
Pt_CB_OUTBOUND | PtCallback_t * | Link | NULL |
Pt_CB_RAW | PtRawCallback_t * | Link | NULL |
Pt_CB_REALIZED | PtCallback_t * | Link | NULL |
Pt_CB_UNREALIZED | PtCallback_t * | Link | NULL |
C type | Pt type | Default |
---|---|---|
unsigned | Flag | 0 |
This resource specifies how the widget is anchored to its parent. The possible values are:
If the resize policy conflicts with the anchors, the Pt_ARG_RESIZE_FLAGS override Pt_ARG_ANCHOR_OFFSETS and Pt_ARG_ANCHOR_FLAGS. |
For more information about anchors, see the Geometry Management chapter of the Photon Programmer's Guide.
C type | Pt type | Default |
---|---|---|
PhRect_t | Struct | 0, 0, 0, 0 |
The four values in this PhRect_t structure (see the Photon Library Reference) determine the anchor offsets of each of the widget's sides. (An anchor offset is the distance between the anchoring side of the parent and corresponding side of the child.)
The Pt_ARG_ANCHOR_OFFSETS resource isn't displayed in PhAB because PhAB sets it automatically. |
If a side is anchored, its anchor offsets, if explicitly specified, override Pt_ARG_AREA and Pt_ARG_DIM.
Only offsets that have a corresponding bit set in the Pt_ARG_ANCHOR_FLAGS resource are applied. For example, let's say you have a Pt_ARG_ANCHOR_OFFSETS resource of (5,10,20,25) with absolute anchoring and a Pt_ARG_ANCHOR_FLAGS resource of Pt_LEFT_ANCHORED_LEFT | Pt_RIGHT_ANCHORED_RIGHT | Pt_TOP_ANCHORED_TOP | Pt_BOTTOM_ANCHORED_BOTTOM. In that case, the pane's extent will be:
This remains true even as the parent is resized.
If the resize policy conflicts with the anchors, the Pt_ARG_RESIZE_FLAGS override Pt_ARG_ANCHOR_OFFSETS and Pt_ARG_ANCHOR_FLAGS. |
C type | Pt type | Default |
---|---|---|
PhArea_t | Struct | 0,0,0,0 |
A PhArea_t structure (see the Photon Library Reference) that contains the x, y, height, and width values for the widget. For related resources, see the “Geometry” section, above.
You can edit this resource in PhAB's toolbar, not the control panel; PhAB also sets it automatically when you move or size the widget.
C type | Pt type | Default |
---|---|---|
unsigned short | Scalar | 2 |
The width of the widget's bevel if the widget is highlighted and is to draw a bevel (see Pt_ARG_FLAGS, below, and the Pt_ARG_BASIC_FLAGS resource defined for PtBasic).
C type | Pt type | Default |
---|---|---|
PhCursorDef_t * | Alloc | NULL |
Defines bitmaps for the cursor when the cursor type (Pt_ARG_CURSOR_TYPE) is set to Ph_CURSOR_BITMAP. You can't edit this resource in PhAB.
The widget automatically sets the hdr member of the PhCursorDef_t structure. For information, see the Photon Library Reference.
C type | Pt type | Default |
---|---|---|
PgColor_t | Scalar | Ph_CURSOR_DEFAULT_COLOR |
The color of the pointer when it's inside the widget. See PgColor_t in the Photon Library Reference.
C type | Pt type | Default |
---|---|---|
unsigned short | Scalar | Ph_CURSOR_INHERIT |
The type of cursor:
By default, bitmap cursors aren't inherited by a widget's child regions.
To change this, set Pt_ARG_CURSOR_TYPE to:
Ph_CURSOR_BITMAP & ~Ph_CURSOR_NO_INHERIT |
For other cursor definitions, see the cursor type table in PhCharacterCursorDescription_t.
C type | Pt type | Default |
---|---|---|
void * | Alloc | NULL |
This resource is used internally by PhAB applications as well as by compound widgets. It isn't displayed in PhAB. For more information, see Building Custom Widgets.
If you want to store arbitrary data in a widget, use its Pt_ARG_POINTER or Pt_ARG_USER_DATA resource. See “Storing arbitrary user data,” above. |
C type | Pt type | Default |
---|---|---|
PhDim_t | Struct | 0,0 |
A PhDim_t structure (see the Photon Library Reference) that defines the height and width values for the widget. For related resources, see the “Geometry” section, above.
You can edit this resource in PhAB's toolbar, not the control panel; PhAB also sets it automatically when you size the widget.
C type | Pt type | Default |
---|---|---|
unsigned long | Flag | 0 |
Extended flags inherited by all widgets:
C type | Pt type | Default |
---|---|---|
PhRect_t | Struct | 0,0,0,0 |
A PhRect_t structure (see the Photon Library Reference) that contains the extent of the widget, a rectangle that specifies the upper-left and lower-right corners of the widget. For related resources, see the “Geometry” section, above.
A widget's extent isn't normally calculated until the widget is realized. You can force a widget to calculate its extent by calling PtExtentWidget() — see the Photon Library Reference. |
C type | Pt type | Default |
---|---|---|
long | Flag | 0 |
Common flags used by all widgets. Except for those indicated as read-only, these flags are all read/write.
The flags include:
For example, if this bit is set for a PtDivider and you use PtSetResources() to change the size of one of its children, the Pt_CB_DIVIDER_DRAG callback is invoked.
The default setting of this resource is 0; that is, no flags have been set.
C type | Pt type | Default |
---|---|---|
PtGridLayoutData_t * | Struct | NULL |
A PtGridLayoutData_t structure that defines additional layout data for the widget when its container widget uses a PtGridLayout type layout.
PtGridLayoutData_t has at least these members:
Combination of the following flags:
You can use PtGridLayoutDataDflts to initialize your copy of PtGridLayoutData_t. It has the following values:
|
For more information about using layouts and layout resources, see Using Layouts in Geometry Management in the Photon Programmer's Guide.
C type | Pt type | Default |
---|---|---|
unsigned short | Scalar | 0 |
The height of the widget. For related resources, see the “Geometry” section, above.
You can edit this resource in PhAB's toolbar, not the control panel; PhAB also sets it automatically when you size the widget.
C type | Pt type | Default |
---|---|---|
char * | String | NULL |
The meaning of this resource depends on the bits set in Pt_ARG_EFLAGS:
For more information, see the PtHelp*() functions and the chapter on Context-Sensitive Help in the Photon Programmer's Guide.
C type | Pt type | Default |
---|---|---|
void * | Struct | NULL |
This resource provides a convenient method to get or set either of the Pt_ARG_*_LAYOUT_DATA resources.
When you set this resource using PtSetResource() or PtSetArg(), set the value argument to a pointer to the layout data structure you want to use. This can be one of:
You can optionally set the len argument to a pointer to the layout type that corresponds to the data structure (that is, PtRowLayout or PtGridLayout). If you set len to NULL, the layout data structure for the current layout is set. In this case, make sure that the data structure corresponds to the correct layout type, or your application might crash.
For more information about using layouts and layout resources, see Using Layouts in Geometry Management in the Photon Programmer's Guide.
C type | Pt type | Default |
---|---|---|
PhDim_t | Struct | 0,0 |
A PhDim_t structure (see the Photon Library Reference) that defines the maximum size that a widget can be. For related resources, see the “Geometry” section, above.
C type | Pt type | Default |
---|---|---|
PhDim_t | Struct | 0,0 |
A PhDim_t structure (see the Photon Library Reference) that defines the minimum size that a widget can be. For related resources, see the “Geometry” section, above.
C type | Pt type | Default |
---|---|---|
void * | Pointer | NULL |
A pointer to any data that you want to associate with the widget.
For a comparison between this resource and Pt_ARG_USER_DATA, see “Storing arbitrary user data,” above.
C type | Pt type | Default |
---|---|---|
PhPoint_t | Struct | 0,0 |
A PhPoint_t structure that stores the x and y coordinates for the widget. For related resources, see the “Geometry” section, above.
You can edit this resource in PhAB's toolbar, not the control panel; PhAB also sets it automatically when you move the widget.
C type | Pt type | Default |
---|---|---|
long | Flag | 0 |
Controls a widget's resize policy in both the x and y directions. Possible values:
Note that each ...BITS flag is a mask that represents all the bits of that type.
The default setting of this resource is 0; that is, no resize policy is in effect.
A widget's resize policy deals solely with the widget's renderable data. For a button, the data is its text; for a container, the data is its children. Any rendered data that doesn't fit within the widget's canvas is clipped.
If no resize policy is in effect, the widget's size is unbounded; it may be made as large or small as specified via Pt_ARG_DIM or Pt_ARG_AREA.
If a resize policy is in effect, the widget grows or shrinks to honor that policy. If the policy is ...ALWAYS, the widget resizes itself to fit its data—the dimensions specified via Pt_ARG_DIM or Pt_ARG_AREA don't apply. If the policy is ...AS_REQUIRED, the widget resizes itself to fit its data only if its current canvas size is inadequate to contain that data. In other words, it grows, but doesn't shrink, to fit its data.
If the widget has the ...INITIAL bit set, the resize policy is applied only once each time the widget is realized. This bit is meaningful only in concert with ...ALWAYS or ...AS_REQUIRED.
If the resize policy conflicts with the anchors, the Pt_ARG_RESIZE_FLAGS override Pt_ARG_ANCHOR_OFFSETS and Pt_ARG_ANCHOR_FLAGS. |
For more information about resize policies, see the Geometry Management chapter of the Photon Programmer's Guide.
C type | Pt type | Default |
---|---|---|
PtRowLayoutData_t * | Struct | NULL |
A PtRowLayoutData_t structure that defines additional layout data for the widget when its container widget uses a PtRowLayout type layout.
PtRowLayoutData_t has at least these members:
Combination of the following flags:
You can use PtRowLayoutDataDflts to initialize your copy of PtRowLayoutData_t. It has the following values:
|
For more information about using layouts and layout resources, see Using Layouts in Geometry Management in the Photon Programmer's Guide.
C type | Pt type | Default |
---|---|---|
void * | Alloc | NULL |
Data that you want to store in the widget's internal memory.
For a comparison between this resource and Pt_ARG_POINTER, see “Storing arbitrary user data,” above.
C type | Pt type | Default |
---|---|---|
unsigned short | Scalar | 0 |
The width of the widget. For related resources, see the “Geometry” section, above.
You can edit this resource in PhAB's toolbar, not the control panel; PhAB also sets it automatically when you size the widget.
C type | Pt type | Default |
---|---|---|
PtCallback_t * | Link | NULL |
A list of PtCallback_t structures that define the callbacks that the widget invokes whenever it must ignore an event due to being blocked.
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
These callbacks should return Pt_CONTINUE.
C type | Pt type | Default |
---|---|---|
PtCallback_t * | Link | NULL |
A list of PtCallback_t structures that define the callbacks invoked when the widget is marked for destruction and is no longer visible. You can use these callbacks, for example, to adjust the appearance of the widgets around the one being destroyed.
In contrast, the Pt_CB_IS_DESTROYED callbacks are invoked when the widget's resources are actually being released. |
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
These callbacks should return Pt_CONTINUE.
C type | Pt type | Default |
---|---|---|
PtCallback_t * | Link | NULL |
A list of PtCallback_t structures that define the callbacks called when a drag-and-drop (Ph_EV_DNDROP) event is received. For more information, see the Drag and Drop chapter of the Photon Programmer's Guide.
A widget doesn't have to have Pt_SELECTABLE set in its Pt_ARG_FLAGS for its Pt_CB_DND callbacks to be invoked. |
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
The following members are valid only when the reason_subtype is Ph_EV_DND_DROP:
The following member is meaningful only when the reason_subtype is Ph_EV_DND_ENTER:
Otherwise the library automatically acknowledges the ENTER event based on the number of data items selected from the drag-and-drop event via PtDndSelect().
The PtTransportCtrl_t structure also includes:
Additional data is passed to Pt_CB_DND callbacks for these widget classes: |
A drag-and-drop recipient typically calls PtDndSelect() when the reason_subtype is Ph_EV_DND_ENTER, and handles the data when the reason_subtype is Ph_EV_DND_DROP. The other subtypes can be generally ignored.
For more information, see the Drag and Drop chapter of the Photon Programmer's Guide.
C type | Pt type | Default |
---|---|---|
PtRawCallback_t * | Link | NULL |
A list of raw callbacks invoked when an event that matches the provided event mask is to be passed to the widget.
These callbacks are invoked before the event is processed by the widget. Contrast this resource with Pt_CB_RAW. |
Because the Pt_CB_FILTER callback is called before the widget processes the event, it gives you the opportunity to decide if the event should be ignored, discarded, or processed by the widget. The return code from the callback indicates what is to happen to the event.
You can add a Pt_CB_FILTER callback to a widget in your application's code by calling PtAddFilterCallback() or PtAddFilterCallbacks(). For more information about this callback, see “Event handlers” in the Events chapter of the Photon Programmer's Guide.
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
These callbacks should return one of:
C type | Pt type | Default |
---|---|---|
PtHotkeyCallback_t * | Link | NULL |
A list of PtHotkeyCallback_t structures. If the widget receives a key event that matches a structure's key cap and key modifiers, the widget calls the function specified in that structure. If a function isn't specified, the widget invokes its Pt_CB_ACTIVATE callback list with a reason_subtype of Pt_CB_HOTKEY.
A hotkey isn't invoked if any ancestor of the widget that owns it is blocked. |
You can add a Pt_CB_HOTKEY callback to a widget in your application's code by calling PtAddHotkeyHandler(). For more information about this callback, see “Hotkey callbacks” in the Editing Resources and Callbacks in PhAB chapter of the Photon Programmer's Guide.
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
These callbacks should return Pt_CONTINUE.
C type | Pt type | Default |
---|---|---|
PtCallback_t * | Link | NULL |
A list of PtCallback_t structures that define the callbacks invoked when the widget's resources are being released. You'll find this resource useful for cleaning up variables or memory associated with the widget.
In contrast, the Pt_CB_DESTROYED callbacks are invoked when the widget is marked for destruction and is no longer visible. |
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
These callbacks should return Pt_CONTINUE.
C type | Pt type | Default |
---|---|---|
PtCallback_t * | Link | NULL |
A list of PtCallback_t structures that define the callbacks invoked when you press the pointer button on the widget and then move out of the “hot spot” with the button still depressed.
This callback is particularly useful for initiating drag or drag-and-drop operations. For more information, see the Drag and Drop chapter of the Photon Programmer's Guide.
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
PhPointerEvent_t *ptr = (PhPointerEvent_t *)PhGetData( cbinfo->event );
These callbacks should return Pt_CONTINUE.
C type | Pt type | Default |
---|---|---|
PtRawCallback_t * | Link | NULL |
A list of PtRawCallback_t structures that defines the raw callbacks that the widget invokes if the event it receives matches the event mask provided in the PtRawCallback_t structure.
These callbacks are invoked after the widget has processed the event, even if the widget's class methods consume it. Contrast this with the Pt_CB_FILTER resource, which is invoked before the widget processes the event. |
You can add a Pt_CB_RAW callback to a widget in your application's code by calling PtAddEventHandler() or PtAddEventHandlers(). For more information about this callback, see “Event handlers” in the Events chapter of the Photon Programmer's Guide.
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
These callbacks should return one of:
C type | Pt type | Default |
---|---|---|
PtCallback_t * | Link | NULL |
A list of PtCallback_t structures that define the callbacks that the widget invokes whenever it is realized.
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
These callbacks should return Pt_CONTINUE.
C type | Pt type | Default |
---|---|---|
PtCallback_t * | Link | NULL |
A list of PtCallback_t structures that define the callbacks that the widget invokes whenever it's unrealized.
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
These callbacks should return Pt_CONTINUE.