Superclass for all widgets
PtWidget
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.
Resource | C type | Pt type | Default |
---|---|---|---|
Pt_ARG_AREA | PhArea_t | Struct | 0,0,0,0 |
Pt_ARG_BITMAP_CURSOR | PhCursorDef_t * | Alloc | NULL |
Pt_ARG_BORDER_WIDTH | unsigned short | Scalar | 2 |
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 short | Flag | 0 |
Pt_ARG_FLAGS | long | Flag | 0 |
Pt_ARG_HELP_TOPIC | char * | String | NULL |
Pt_ARG_POS | PhPoint_t | Struct | 0,0 |
Pt_ARG_RESIZE_FLAGS | long | Flag | 0 |
Pt_ARG_USER_DATA | void * | Alloc | NULL |
Pt_CB_BLOCKED | PtCallback_t * | Link | NULL |
Pt_CB_DESTROYED | PtCallback_t * | Link | NULL |
Pt_CB_HOTKEY | PtHotkeyCallback_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 |
---|---|---|
PhArea_t | Struct | 0,0,0,0 |
The x, y, height, and width values for the widget. This resource isn't displayed in PhAB; PhAB sets it automatically when you move or size the widget.
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.
The PhCursorDef_t structure is defined as follows:
typedef struct Ph_cursor_def { PhRegionDataHdr_t hdr; PhPoint_t size1; PhPoint_t offset1; PgColor_t color1; char bytesperline1; PhPoint_t size2; PhPoint_t offset2; PgColor_t color2; char bytesperline2; char Spare[14]; char images[1]; } PhCursorDef_t;
The members are:
This resource can't be edited in PhAB. You can draw the cursor as a PtBitmap widget and have the application turn it into a PhCursorDef_t structure at runtime. For example:
PtArg_t args[2]; ApDBase_t *db = ApOpenDBase( ABM_db ); ApBitmap_t *ab = ApGetBitmapRes( bmpdb, "bitmap" ); unsigned len = sizeof(*d) + 2 * BMP_SIZE; PhCursorDef_t *d = malloc( len ); memset( d, 0, sizeof(*d) ); d->size1.x = d->size2.x = BMP_WIDTH; d->size1.y = d->size2.y = BMP_HEIGHT; d->bytesperline1 = d->bytesperline2 = BMP_BPL; d->color1 = ab->colors[0]; d->color2 = ab->colors[1]; memcpy( d->images, ab->data[0], BMP_SIZE ); memcpy( d->images + BMP_SIZE, ab->data[1], BMP_SIZE ); PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP , 0 ); PtSetArg( &args[2], Pt_ARG_BITMAP_CURSOR, d, len ); PtSetResources( ABW_base, 2, args ); free( d );
C type | Pt type | Default |
---|---|---|
unsigned short | Scalar | 2 |
The thickness of the widget's border. This must not exceed 15 pixels.
C type | Pt type | Default |
---|---|---|
PgColor_t | Scalar | Ph_CURSOR_DEFAULT_COLOR |
The color of the pointer when it's inside the widget.
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 <photon/PhCursor.h>.
C type | Pt type | Default |
---|---|---|
void * | Alloc | NULL |
This resource is used internally by the Photon libraries as well as by compound widgets. It isn't displayed in PhAB. For more information, see the Building Custom Widgets guide.
If you want to store arbitrary data in a widget, use its Pt_ARG_USER_DATA resource. |
C type | Pt type | Default |
---|---|---|
PhDim_t | Struct | 0,0 |
The height and width values for the widget.
This resource isn't displayed in PhAB; PhAB sets it automatically when you size the widget.
C type | Pt type | Default |
---|---|---|
unsigned short | Flag | 0 |
Extended flags inherited by all widgets:
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. Possible values:
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.
Using this bit might cause problems if, for example, more than one widget uses the same image. It's better to use the image's flags to indicate which of the image's allocated members should be freed. For more information, see PhImage_t in the Photon Library Reference. |
The default setting of this resource is 0; that is, no flags have been set.
C type | Pt type | Default |
---|---|---|
char * | String | NULL |
The meaning of this resource depends on the Pt_ARG_EFLAGS extended flags:
For more information, see the PxHelp*() functions and the chapter on Context-Sensitive Help in the Photon Programmer's Guide.
C type | Pt type | Default |
---|---|---|
PhPoint_t | Struct | 0,0 |
Defines the x and y values for the widget. This resource isn't displayed in PhAB; PhAB 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 will grow or shrink to honor that policy. If the policy is ...ALWAYS, the widget will resize itself to fit its data-the dimensions specified via Pt_ARG_DIM or Pt_ARG_AREA won't apply. If the policy is ...AS_REQUIRED, the widget will resize itself to fit its data only if its current canvas size is inadequate to contain that data. In other words, it will grow, but won't shrink, to fit its data.
If the widget has the ...INITIAL bit set, the resize policy will be applied only once each time the widget is realized. This bit is meaningful only in concert with ...ALWAYS or ...AS_REQUIRED.
C type | Pt type | Default |
---|---|---|
void * | Alloc | NULL |
Attaches an arbitrary user-defined data structure to the widget.
C type | Pt type | Default |
---|---|---|
PtCallback_t * | Link | NULL |
A list of 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 |
The callbacks that the widget invokes when it is destroyed. You'll find this resource useful for cleaning up variables or memory associated with the widget.
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 |
---|---|---|
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 will call the function specified in that structure. If a function isn't specified, the widget invokes its Pt_CB_ACTIVATE callback list.
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:
unsigned short key_sym_cap; short flags; unsigned long key_mods; PtWidget_t *widget; void * data; void * (event_f)( PtWidget_t *, void *, PtCallbackInfo_t *);
where:
These callbacks should return Pt_CONTINUE.
C type | Pt type | Default |
---|---|---|
PtRawCallback_t * | Link | NULL |
A list of raw callbacks that the widget invokes if the raw event it receives matches the event mask provided in the PtRawCallback_t structure.
These callbacks are invoked after the widget has processed the event, and then only for events that the widget doesn't consume. Contrast this with the Pt_CB_FILTER resource defined by PtContainer. |
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 "Manipulating event handlers in your code" in the Creating Widgets in Application Code 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 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 callbacks that the widget invokes whenever it is unrealized.
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
These callbacks should return Pt_CONTINUE.