photon_custom_widgets
photon_custom_widgets
Publishing history
December 1996 First edition
April 1998 Second edition
QNX and Photon microGUI are registered trademarks of QNX Software Systems in certain jurisdictions. All other trademarks and registered trademarks
belong to their respective owners.
Contents
1 Overview 1
Subclassing widgets 4
Design considerations 4
A quick look at a widget 6
Widget header file 7
Widget source file 8
Types of widgets 11
Class hierarchy 11
Basic widgets 11
Container widgets 12
Compound widgets 13
Child constraints 29
Child redirection 30
Compound widgets 30
Exporting subordinate widgets 32
3 Anatomy of a Widget 33
Defining resources 35
Resource manifests 35
PtResourceRec t resource records 37
Defining the widget class 47
Widget class structure 47
Widget class resource table 51
PtBasic class resource additions 53
Class methods 55
Defaults method 56
Initialization method 56
Extent method 58
Connection method 60
Realization method 62
Draw method 62
Unrealization method 65
Destruction method 67
Set Resources method 67
Get Resources method 68
Got Focus method 68
Lost Focus method 69
Calc Opaque Rect method 70
Widget actions 71
Raw callback list 72
Container widget anatomy 74
Child-constraint support 74
Child-redirector function 78
Fundamental methods 79
Functions 116
PtGenList 116
Class hierarchy 116
Class extensions 116
Methods 117
Widget actions 121
Resource definitions 122
Functions 123
PtGenTree 125
Class hierarchy 125
Class extensions 125
Methods 126
Widget actions 128
Resource definitions 128
Functions 129
PtLabel 129
Class hierarchy 129
Methods 129
Widget actions 131
Resource definitions 131
Functions 132
PtGraphic 133
Class hierarchy 133
Methods 133
Widget actions 135
Resource definitions 135
Functions 135
PtGauge 136
Class hierarchy 136
Methods 136
Widget actions 137
Resource definitions 137
Functions 138
PtSuperClassGenListDraw() 181
PtSuperClassGenListInflate() 182
PtSuperClassGenListKey() 183
PtSuperClassGenListMouse() 184
PtSuperClassGenListSelect() 185
PtGenTreeSelectedItems() 217
PtGenTreeSetSelIndexes() 218
PtGenTreeShow() 219
PtGenTreeUnselect() 220
PtGenTreeUnselectNonBrothers() 221
PtSuperClassGenTreeDrawItem() 222
PtSuperClassGenTreeItemState() 223
PtCalcRegion() 257
PtChildBoundingBox() 259
PtClipAdd() 260
PtClipRemove() 262
PtCompoundRedirect() 263
PtContainerChildRedirect() 264
PtContainerDeregister() 266
PtContainerRegister() 267
PtCoreChangeRegion() 268
PtCreateWidgetClass() 270
PtDamageExposed() 273
PtDestroyCallbackList() 275
PtDestroyHotkeyCallbacks() 276
PtDestroyRawCallbacks() 277
PtFindNextWidgetData() 278
PtFindResourceRecord() 280
PtFindWidgetData() 282
PtGetAnchoredExtent() 283
PtGetStruct() 285
PtInvokeCallbackList() 287
PtInvokeResizeCallbacks() 288
PtMoveResizeWidget() 289
PtRemoveWidgetData() 290
PtResizePolicy() 291
PtSetExtentFromArea() 292
PtSetStruct() 293
PtSetValue() 295
PtSuperClassCalcOpaque() 296
PtSuperClassChildCreated() 297
PtSuperClassChildDestroyed() 298
PtSuperClassChildGettingFocus() 299
PtSuperClassChildGettingResources() 300
PtSuperClassChildLosingFocus() 301
PtSuperClassChildMovedResized() 302
PtSuperClassChildRealized() 303
PtSuperClassChildSettingResources() 304
PtSuperClassChildUnrealized() 305
PtSuperClassConnect(), PtSuperClassConnectFrom() 306
PtSuperClassDraw() 307
PtSuperClassExtent() 309
PtSuperClassGetResources() 311
PtSuperClassGotFocus() 312
PtSuperClassInit(), PtSuperClassInitFrom() 313
PtSuperClassLostFocus() 314
PtSuperClassRawEvent(), PtSuperClassRawEventFrom() 315
PtSuperClassRealized() 316
PtSuperClassSetResources() 317
PtUpdateVisibility() 319
PtWidgetAbove() 320
Index 347
Typographical conventions
Throughout this manual, we use certain typographical conventions to
distinguish technical terms. In general, the conventions we use
conform to those found in IEEE POSIX publications. The following
table summarizes our conventions:
Reference Example
Code examples if( stream == NULL )
Command options -lR
Commands make
Environment variables PATH
File and pathnames /dev/null
Function names exit()
Keyboard chords Ctrl – Alt – Delete
Keyboard input something you type
Keyboard keys Enter
Program output login:
Programming constants NULL
Programming data types unsigned short
Programming literals 0xFF, "message string"
Variable names stdin
User-interface components Cancel
We use an arrow (→) in directions for accessing menu items, like this:
!
CAUTION: Cautions tell you about commands or procedures that
may have unwanted or undesirable side effects.
In this chapter. . .
Subclassing widgets 4
Design considerations 4
A quick look at a widget 6
Types of widgets 11
When you build an application, you typically use the standard widgets
provided with the Photon widget library. But occasionally you’ll have
a reason for not using these standard widgets.
For example, Photon widgets require a fair amount of memory, so if
you’re drawing a diagram having several PtRect, PtLine and
PtPolygon widgets, it might be better to create a single widget that
can draw the entire diagram using Pg*() graphic primitives.
Another reason for creating a custom widget is the need for a user
interface object whose features aren’t supported by standard widgets.
In this case, you have three options:
¯ Use the raw widget, PtRaw — see the Raw Drawing and
Animation chapter of the Photon Programmer’s Guide.
¯ The widget can take advantage of the Photon widget engine, which
has several features available only to widgets (e.g. automatic
routing of events to the appropriate widgets, which allows widgets
to automatically redraw and repair themselves when required).
Subclassing widgets
Building a custom widget is also known as subclassing a widget
because widgets are always built as descendants of existing widget
superclasses. Subclassing lets you enhance or modify the behavior
associated with an existing widget superclass, provided you
understand how the superclass is implemented. The Using Widget
Superclasses chapter describes the most common widget superclasses.
!
CAUTION:
If you’ll be adding a custom widget to the Photon Application Builder
(PhAB) widget palette, there are a few special design considerations
you must be aware of. Before you begin designing your widget, read
the Binding Widgets into PhAB chapter.
Design considerations
Part of building a custom widget involves deciding what it will look
like and how the user will interact with it. You’ll need to decide on
the resources that control the widget and pick an appropriate widget
superclass to start with.
Widget actions
If your widget will be interactive, you’ll have to
determine which Photon events your widget will be
sensitive to. These events must be set up in the
class-creation function.
You can have all events go through the same
function, or you can define a function for each event
type. The functions that handle events should read
the event data and take the appropriate action. For
example, a click on your widget might change its
internal state. If appropriate, your widget may need
to be damaged so a subsequent redraw operation can
reflect the widget’s new state.
¯ a source code file, which contains the widget’s class structure and
the actual code to implement the widget. This code includes
methods, class-level functions that define how the widget
initializes itself, draws itself, calculates its extent, and so on.
The following diagram depicts the header and source code files for a
simple example of a widget, ShadowedBox.
Widget header file Widget source file
ShadowedBox.h ShadowedBox.c
Resource
declarations
Class methods
Instance structure
Class-creation function
This sample widget will draw a shadowed box, define a resource for
changing the color of the shadow, and define a resource for specifying
the offset of the shadow.
This sample widget will be subclassed as follows:
PtWidget → PtBasic → ShadowedBox
Since ShadowedBox will be a subclass of PtBasic, it will inherit all
the resources and behavior of this standard Photon widget.
#include <Pt.h>
/* widget resources */
#define SBW SHADOW COLOR Pt RESOURCE( Pt USER( 0 ), 0 )
#define SBW SHADOW OFFSET Pt RESOURCE( Pt USER( 0 ), 1 )
The header file also defines an external reference to the widget class
pointer.
#include "ShadowedBox.h"
/* prototype declarations */
PtWidgetClass t *CreateShadowedBoxClass( void );
//
// ShadowedBox defaults function
//
static void shadowedbox dflts( PtWidget t *widget )
{
ShadowedBoxWidget *sb = ( ShadowedBoxWidget * ) widget;
PtBasicWidget t *basic = ( PtBasicWidget t * ) widget;
//
// ShadowedBox draw function
//
//
// ShadowedBox class creation function
//
PtWidgetClass t *CreateShadowedBoxClass( void )
{
// define our resources
static PtResourceRec t resources[] = {
SBW SHADOW COLOR, Pt CHANGE REDRAW, 0,
Pt ARG IS NUMBER( ShadowedBoxWidget, shadow color ), 0,
SBW SHADOW OFFSET, Pt CHANGE RESIZE REDRAW, 0,
Pt ARG IS NUMBER( ShadowedBoxWidget, shadow offset ), 0,
};
Section Example
Header files #include "ShadowedBox.h"
Class pointer PtWidgetClassRef t *ShadowedBox
declaration
Method functions shadowedbox dflts(), shadowedbox draw()
continued. . .
Section Example
Class-creation CreateShadowedBoxClass()
function
Types of widgets
The Photon library supplies a number of widget classes that can be
used as the basis for custom widgets. To make this easy to
understand, we’ve categorized widgets into three general types:
¯ Basic
¯ Container
¯ Compound
Class hierarchy
All Photon widgets are based on the PtWidget core widget class. It
defines the characteristics common to all standard widgets, such as
position and dimension. Even if your widget is different from any
other widget, it will still inherit the features of the PtWidget widget
class. Most custom widgets, however, will be subclassed under one of
the other widget superclasses.
Basic widgets
Basic widgets are single-entity objects. They don’t contain other
widgets and aren’t built from other widgets. An example would be a
button widget.
Button widgets.
You can’t put other widgets inside a button, and the button itself isn’t
built from other widgets. Our sample ShadowedBox widget is a basic
widget.
Although we call them “basic” widgets, this is only a classification
and doesn’t imply that they can’t be powerful. In fact, one of the most
complex widgets in the Photon library, PtText, is a basic widget.
Container widgets
Container widgets can have other widgets as children. Containers
have the option of managing the geometry of their children (e.g.
PtGroup) or leaving the widgets as they are (e.g. PtPane).
The PtContainer class extends the PtBasic class definition to
include many new methods for controlling and reacting to the widget
children placed inside the container. Using these new methods, a
container could, for example, detect when a new child is added and
automatically resize itself to accommodate the new widget.
Widget children can be selectively blocked by a redirector function.
This is useful when you want to create a widget that accepts only
specific widgets as children (e.g. PtMenuBar accepts only
PtMenuButton widgets as children). All other widgets are redirected
to the container’s parent widget. This causes them to be created at the
same level as the container instead of as a child of the container.
Containers also add anchoring features that allow children to be
anchored to their parent.
None Center
Done
Center Tile Tile
Alternate Disable
Compound widgets
Compound widgets are built from exported subordinate widgets. The
exporting mechanism allows access to the underlying widgets using
their resources and convenience functions. This reduces the need to
duplicate every subordinate widget resource in the compound
widget’s resource list.
You have to set up resources only for new functionality or for
resolving conflicts when more than one of the same widget class has
been exported. A blocking mechanism lets compound widgets block
access to any of the subordinate resources. This lets you prevent any
actions that would adversely affect the look and behavior of the
compound widget.
Since the PtCompound class is a descendant of PtContainer, it
inherits all the functionality of a container widget. This means
compound widgets can be anchored and can support child widgets
other than the ones they’re built from. Since this feature isn’t usually
desired, you can use a compound widget’s redirector function to
automatically reject the addition of unwanted widgets.
A good example of a compound widget is PtComboBox — it’s built
using the PtText and PtList widget classes and adds its own
functionality.
Raw event
A compound widget.
In this chapter. . .
Basic widgets 17
Container widgets 28
Compound widgets 30
This chapter examines the life cycle of a basic widget using the
ShadowedBox widget as an example. We’ll show you how to create,
use, and destroy this widget. We’ll also outline the life cycle
differences between basic, container, and compound widgets.
Basic widgets
If we were building an application and wanted to use the custom
ShadowedBox widget (a “basic” widget), we would simply create it
by calling PtCreateWidget():
PtWidget t *box;
PhArea t area = { 10, 10, 100, 100 };
PtArg t args[2];
Resources array
The static array resources defines the class resources. The class
resources are accessed through a table of resources unique to
the ShadowedBox class.
Widget class array
The static array args defines the ShadowedBox class. It defines
ShadowedBox’s class methods and its table of resources.
The args array is passed to PtCreateWidgetClass() as follows:
//
// ShadowedBox defaults function
//
static void shadowedbox dflts( PtWidget t *widget )
{
ShadowedBoxWidget *sb = ( ShadowedBoxWidget * ) widget;
PtBasicWidget t *basic = ( PtBasicWidget t * ) widget;
The first resource manifest, Pt ARG AREA, sets the widget area
(position and size). Because this resource isn’t defined by the
ShadowedBox class, it’s handled by the first superclass that defines
Pt ARG AREA (i.e. PtWidget).
The second resource manifest SBW SHADOW COLOR is handled by
the ShadowedBox class. Because ShadowedBox doesn’t define a
method for setting the resource value, the Photon widget library takes
care of assigning a new value to this instance structure member (i.e.
the value is changed from the default, Pg BLACK, to Pg BLUE).
Finally, PtCreateWidget() returns the widget pointer and the
application receives access to a newly created instance of the
ShadowedBox class:
Processing methods
Before we get into a detailed discussion of the individual methods
used in a widget class, we need to look at their usage in general. Class
methods can be chained up or down or inherited.
When a method is chained, the method of each class in the widget
hierarchy is executed. Execution can start at the lowest class (e.g.
ShadowedBox) in the hierarchy and go up, or at the highest class (i.e.
PtWidget) and go down.
Some chained methods can be stopped. This means any class in the
hierarchy can stop the chaining process to prevent the superclass or
subclassed methods from being executed. When chaining is stopped,
Inherited methods.
continued. . .
Method Processing
Got Focus Inherited
Lost Focus Inherited
Calc Opaque Rect Inherited
Initialization method
This is the first class method called during the realization process.
This method is chained up; the Initialization method of the
ShadowedBox class would be called first, followed by the
Initialization method of the PtBasic class, ending with PtWidget’s
Initialization method.
Extent method
This inherited method is used to determine the exact size of the
widget based on default values and/or the widget’s position, size,
margins, borders, and highlighting information, as set by the program.
An Extent method isn’t defined for ShadowedBox, so the Extent
method is inherited from the PtBasic superclass.
Connection method
The Connection method is chained up. It’s used primarily for creating
any Photon regions needed by a widget. Due to its simplicity, the
ShadowedBox widget doesn’t require any regions — a superclass
method will create regions for ShadowedBox only if needed (e.g. a
custom cursor is defined).
Realization method
The Realization method is used to adjust any region attributes prior to
the actual drawing of a widget. Because ShadowedBox doesn’t define
a Realization method, it’s inherited from a superclass.
Draw method
This is the last class method called during the realization process. It’s
used to render a widget on the screen. This method can be inherited,
but since ShadowedBox defines its own Draw method (shown
below), it’s executed instead of a superclass’s Draw method:
//
// ShadowedBox draw function
//
static void shadowedbox draw( PtWidget t *widget, PhTile t *damage )
{
ShadowedBoxWidget *sb = ( ShadowedBoxWidget * ) widget;
PtBasicWidget t *basic = ( PtBasicWidget t * ) widget;
PhRect t shadow rect, rect;
PgColor t color;
Let’s look at the code in more detail. From the function declaration:
☞ The program can use the damage list to make intelligent decisions
about what to draw. However, drawing operations for most widgets
are minimal and any extra processing might not be worthwhile.
The rest of the code in the Draw method determines the widget’s
position and size based on its area and margins, and then draws a
shadowed box using low-level Photon Pg*() graphics functions.
Before leaving the Draw method, the clipping we added is removed
by calling PtClipRemove().
When the draw buffer is flushed later on, the widget appears on the
screen.
Destroying a widget
The widget must handle its own destruction. This process involves:
¯ unrealizing the widget
¯ destroying the widget
Unrealization method
The purpose of this method is to undo everything of consequence
done during realization. The Unrealization method is responsible for:
¯ removing any open regions owned by a widget
¯ erasing the widget from the screen through the widget library
¯ making the widget noninteractive
This method is chained up. Since the ShadowedBox class doesn’t
define an Unrealization method, PtBasic’s Unrealization method
will be called, followed by PtWidget’s Unrealization method.
Destruction method
This method is responsible for releasing any system resources used by
a widget but not referenced by a widget resource. Like the
Unrealization method, it’s chained up. This lets all classes in the
hierarchy release system resources in turn.
Other methods
The remaining class methods aren’t described in this section, but you
should now have a general understanding of the overall process. The
Anatomy of a Widget chapter describes these methods in detail. Let’s
now look at some of the additional requirements for container and
compound classes.
Container widgets
The life cycle of a container widget is similar to that of a basic
widget. The main difference is that container widgets must support
widget children, including the following features:
¯ anchoring
¯ child constraints
¯ child redirection
Anchoring
If container widgets are already realized or in the process of being
realized, they’re automatically anchored by the widget library.
Child Child
Child Child
Anchoring
Child constraints
The container class extends the PtBasic class definition with a
number of child-constraint methods. These methods let a container
adjust itself automatically according to any changes made to its
children. These child-constraint methods include:
¯ Child Created
¯ Child Realized
¯ Child Moved/Resized
¯ Child Unrealized
¯ Child Destroyed
Any child-constraint method a container will support must have its bit
set in cntr->flags or the method won’t be invoked.
Child redirection
A custom container class can optionally provide a child-redirector
function to restrict certain widget classes from being added to the
container. This function allows the container to redirect parentage to
other widgets inside or outside the container itself. The
child-redirector function is usually defined at the end of the Default
method. For example:
Compound widgets
The compound class is used to design widgets made from other
widgets. The compound class is a subclass of the container class, so it
The exporting mechanism lets users set and get the resources of
subordinate widgets by treating the compound widget as if it actually
were the subordinate widget.
A good example is the PtComboBox widget — it’s built from a text
widget and a list widget. It also defines its own behavior by supplying
a pull-down button beside the text widget for accessing the list widget.
You can change the subordinate widgets inside a compound widget
using the resources defined for the subordinate widgets. For example,
you could change the PtText widget inside a PtComboBox widget
by using the widget pointer of the PtCompound widget as follows:
PtArg t args[1];
In this chapter. . .
Defining resources 35
Defining the widget class 47
Class methods 55
Widget actions 71
Container widget anatomy 74
Compound widget anatomy 81
Defining resources
There are two steps to defining the resources of your widget class
(aside from deciding what they should be in the first place):
Resource manifests
Define the resources to introduce for a widget class (i.e. the resources
that don’t already exist in any of the widget superclasses). This is
done in the widget’s header file (e.g. PtButton.h) as a series of
#define statements:
/*
* PtButton public
*/
/* Resources */
#define Pt ARG ARM COLOR Pt RESOURCE( 6, 0 )
type member
The value (manifest) to which this record is connected through a
widget instance member. For example, Pt ARG FLAGS.
mod f member
The function to call when this resource is being set by the user. This
member recognizes several special convenience values other than the
address of a function. Special values include:
Pt CHANGE INVISIBLE
Set the widget member but otherwise leave the widget
unaffected.
Pt CHANGE REDRAW
Change the widget member and damage the widget (this causes
a redraw).
Pt CHANGE INTERIOR
Same as Pt CHANGE REDRAW, except the widget’s canvas
alone is damaged (the borders aren’t redrawn).
Pt CHANGE RESIZE
Change the widget structure member and flag the widget for
resize. The resize is held off until the end of the
PtSetResources() call in case other Pt CHANGE RESIZE-type
resources are set in the same call. The resize is performed via
PtMoveResizeWidget(), and the Extent method of the widget
class is called.
Pt CHANGE RESIZE REDRAW
Same as Pt CHANGE RESIZE, but forces a redraw even if the
widget’s dimensions or extent aren’t changed.
Pt CHANGE PREVENT
Don’t change the widget structure member and don’t affect the
widget. Indicates a read-only resource.
Pt CHANGE CANVAS
Invalidate the widget’s canvas so that it’s recalculated the next
time it’s requested. Additionally, resize the widget.
Pt CHANGE CANVAS REDRAW
The same as Pt CHANGE CANVAS, but force the widget to be
redrawn even if its canvas and extent aren’t changed.
query f member
The function to call when this resource is being queried via
PtGetResources(). If no function is provided (i.e query f is NULL),
the resource is reported in the normal manner (see PtSetArg() and
PtGetResources() in the Photon Library Reference).
Pt QUERY PREVENT
Prevents access to the resource. Any pointers provided are set
to NULL. Indicates a write-only resource.
¯ the offset from the address of the widget structure to the member
to get/set
The following macros make using arg value and arg len more
convenient:
¯ Pt ARG IS NUMBER
¯ Pt ARG IS FLAGS
¯ Pt ARG IS STRING
¯ Pt ARG IS STRUCT
¯ Pt ARG IS POINTER
¯ Pt ARG IS ALLOC
¯ Pt ARG IS LINK
¯ Pt ARG IS BOOLEAN
¯ Pt ARG IS ARRAY
The sections that follow describe the values of the arg value and
arg len members for each type of resource. For most resources,
arg len isn’t used; unless mentioned otherwise below, set it to 0.
Scalar resources
Flags resources
For Flags resources, the “mask” isn’t part of the resource — it’s just a
way of telling the resource-setting API which bits the application
wants to preserve.
String resources
Struct resources
These are widget members that are of a fixed size. When setting such
resources, you pass a pointer to the value, and the value is copied into
the widget structure. This type is useful for structures, as well as other
data types that won’t fit into a long (such as float or double).
Pointer resources
Alloc resources
Space is allocated for the resource, with the size specified by the
application; see the note above.
Link resources
The structure must start with a “next” pointer. Space is allocated for
the resource; see the note above.
Callback resources
The structure must start with a “next” pointer. Space is allocated for
the resource; see the note above.
Boolean resources
The arg len is the bitmask. It’s not stored anywhere in the widget —
it’s just a constant that determines in which bit of the widget structure
the resource is stored.
Array resources
The size of each array element is the size of the type pointed to by
member1. Space is allocated for the resource; see the note above.
Examples
Now let’s look at some sample resource declarations. First let’s look
back at our original widget example, the ShadowedBox widget. It
defines two resources in the header file:
/* widget resources */
#define SBW SHADOW COLOR Pt RESOURCE( Pt USER( 0 ), 0 )
#define SBW SHADOW OFFSET Pt RESOURCE( Pt USER( 0 ), 1 )
The source code file defines the table of resources, which connects the
resources to the widget class:
¯ The next member, 0, is the query f member, which tells the library
how this resource should be retrieved. It can be one of:
- 0, which causes the widget library to retrieve the resource based
on the information provided by the arg value and arg len bit
fields
- a function within the source file
- Pt QUERY PREVENT
Now let’s look at a more detailed example. In the widget header file
we have:
/* widget resources */
#define MW ARG MY CHARACTER Pt RESOURCE( Pt USER(1), 0 )
#define MW ARG MY STRING Pt RESOURCE( Pt USER(1), 1 )
#define MW ARG MY SHORT Pt RESOURCE( Pt USER(1), 2 )
#define MW ARG MY FLAGS Pt RESOURCE( Pt USER(1), 3 )
#define MW ARG MY FLAG BIT Pt RESOURCE( Pt USER(1), 4 )
#define MW ARG MY POINT ARRAY Pt RESOURCE( Pt USER(1), 5 )
#define MW ARG MY TAG DATA Pt RESOURCE( Pt USER(1), 6 )
#define MW CB MY CALLBACK Pt RESOURCE( Pt USER(1), 7 )
if( argt->value )
// The address of a pointer to a short is in argt->value
*(short **)argt->value = &mw->my short;
else
argt->value = (long) mw->my short;
return Pt TRUE;
/* The only time one would return Pt FALSE is if no data
is given as a result of the query */
}
For more examples of resources and mod f()/query f() functions, see
the /qnx4/phtk/src/widgets and /qnx4/phtk/src/contrib
directories, which contain many widget examples and templates.
PtWidgetClass t *superclass
A pointer to the superclass of this widget class.
This value defines the superclass this class inherits
from. If a widget class is at the top of the
hierarchy, this pointer is NULL.
PtResourceRec t *resources
An array of resources the widget class handles
directly when a user calls PtSetResources() or
PtGetResources().
unsigned num resources
The number of resources in the resources array.
PtRawCallbackList t *callbacks
The list of widget actions (raw callbacks) for the
widget class. If a function in the callback list has
an event mask matching the event being handled,
that function is invoked.
PhSoul t widget souls
Used for managing the memory associated with
instances of this widget class.
When defining a custom widget class, you can extend the definition of
its superclass with new “class-level” methods and/or callbacks. For
example, the PtWidget class is extended by PtBasic, which adds
new class methods for providing focus notification. This was done as
shown in the following excerpt from the PtBasic.h header file:
#define Pt SET GOT FOCUS F (Pt ARG IS POINTER(PtBasicWidgetClass t,got focus f))
#define Pt SET LOST FOCUS F (Pt ARG IS POINTER(PtBasicWidgetClass t,lost focus f))
#define Pt SET CALC OPAQUE F (Pt ARG IS POINTER(PtBasicWidgetClass t,calc opaque f))
Let’s look at the class resource table from our ShadowedBox example
in more detail:
Pt SET VERSION Tells the widget library what style this widget is.
For your widgets, this value is always at least 110
(110 corresponds to Photon 1.10 style).
Pt SET STATE LEN
Defines the length of the widget instance structure.
Class methods
This section describes the role and responsibilities of the class
methods defined in the widget class structure. The fundamental
methods defined by PtWidget are:
¯ Defaults
¯ Initialization
¯ Extent
¯ Connection
¯ Realization
¯ Draw
¯ Unrealization
¯ Destruction
¯ Set Resources
¯ Get Resources
¯ Got Focus
¯ Lost Focus
These are the methods you write to define the functionality of your
widget. Not all methods need to be defined and coded by a widget
class; they can be inherited from a superclass. Almost all widgets
need at least the Draw method, since the primary purpose of building
a custom widget is to draw something.
Defaults method
Type: Chained down, unstoppable
This method sets the default values for all widget instance structure
members. It’s called during the creation of a widget instance (call to
PtCreateWidget()). When a widget instance is first created, all
members of the instance structure are zeroed out and then the
Defaults method for each parent class (starting from PtWidget at the
top) are called in sequence from top to bottom. This allows the
lower-level classes to override the default values set by the parent
classes in the hierarchy. Here’s an example showing how to initialize
PtBasic variables:
widget->border width = 2;
widget->cursor color = Ph CURSOR DEFAULT COLOR;
widget->resize flags |= Pt RESIZE XY AS REQUIRED;
basic->color = Pg BLACK;
basic->fill color = Pg GREY;
basic->top border color = Pg WHITE;
basic->bot border color = Pg DGREY;
basic->flags = Pt DAMAGE ON FOCUS;
}
Initialization method
Type: Chained up, stoppable
This is the first method called when a widget is realizing (call to
PtRealizeWidget()). The Initialization method does final checks to
ensure the widget is “extentable.” This check ensures all members
used in the subsequent Extent method are correctly assigned.
}
return Pt CONTINUE;
}
Extent method
Type: Inherited
This is the second method called during the realization of a widget
(call to PtRealizeWidget()). The Extent method is responsible for
determining the widget’s screen real estate (bounding box) with
regard to its resize policy. The Extent method is called frequently
during the life of a widget — whenever the widget is moved or
resized, or resources marked as Pt CHANGE RESIZE or
Pt CHANGE RESIZE REDRAW are modified.
The following are examples of these types of resources, as defined by
the PtWidget class:
static PtResourceRec t resources[] = {
{ Pt ARG AREA, Pt CHANGE RESIZE, 0,
Pt ARG IS STRUCT(PtWidget t, area) },
4 Call
PtSuperClassExtent( PtBasic, widget)
Connection method
Type: Chained up, stoppable
This is the third method called during the realization of a widget (call
to PtRealizeWidget()). The Connection method creates any required
Photon regions. Generally, it isn’t necessary to explicitly create your
own region since the Connection method of PtWidget does this for
you.
However, it may be beneficial to create your own region if you need to
modify the region based on the current environment. For example,
PtMenu widgets have to modify a region whenever they’re displayed:
if( wp )
{
wp = PtFindDisjoint( wp );
if (PtWidgetIsClassMember( wp, PtWindow ))
((PtContainerWidget t *)wp)->last focus = NULL;
if( !( PtWindowGetState( wp ) & Ph WM STATE ISFOCUS ) ) {
PtWindowFocus( wp );
}
}
}
Realization method
Type: Inherited
This method is called after a widget has been realized. Its function is
similar to that of the Pt CB REALIZED callback, but unlike the
Pt CB REALIZED callback, it can’t be accessed by any developer
using your widget.
This method is used primarily by compound widgets to perform any
postrealize operations, such as realizing any subordinate widgets that
couldn’t be realized to this point. It’s the last method to be called
prior to the Draw method, and it’s invoked just prior to the user’s
Pt CB REALIZED callbacks. For more information, see the section
on “Compound widget anatomy.”
Draw method
Type: Inherited
This is the last method called during the realization process. The
Draw method is used to render the widget on the screen during
The following code excerpt (from PtArc) shows how setting the
Pt UCLIP bit in the widget’s resize flags affects clipping:
PgSetClipping()
PgSetMultiClip()
PgSetUserClip()
These are used by the library. The only safe way
of changing clipping in a widget’s Draw method is
to use PtClipAdd() and PtClipRemove() (see the
Widget Building Library API chapter).
PgSetDrawMode()
PgSetPlaneMask()
PgSetStrokeCap()
PgSetTranslation()
PgSetUnderline()
These aren’t set by the library, but widgets assume
they’re set to their default values. If your Draw
method changes any of them, you have to restore
it.
PgSetPalette()
PgSetFillDither()
PgSetFillTransPat()
PgSetStrokeTransPat()
PgSetTextTransPat()
PgSetStrokeWidth()
PgSetStrokeDash()
PgSetStrokeDither()
PgSetStrokeJoin()
These are automatically reset to the default after a
widget’s Draw method returns. It’s safe to change
them.
PgSetFillColor()
PgSetStrokeColor()
PgSetTextColor()
PgSetFillXORColor()
PgSetStrokeXORColor()
PgSetTextXORColor()
There’s no default for these. Set them as needed
before drawing and don’t worry about restoring
them.
For more information about these functions, see the Photon Library
Reference.
Unrealization method
Type: Chained up
This method is called when a widget is being unrealized. The
Unrealization method is responsible for removing any regions created
by a widget (widget->rid is removed automatically by the PtWidget
class’s Unrealization method). The Unrealization method should free
any memory that would be reallocated during the realization process.
if(label->balloon widget)
PtDestroyWidget( label->balloon widget );
bcalls.widget = widget;
bcalls.event f = label balloon callback;
Destruction method
Type: Chained up, unstoppable
This method is called when a widget is being destroyed by the
application. The Destruction method is responsible for releasing all
resources allocated by a widget class during its lifetime. The
Destruction method doesn’t deal with memory allocated by a widget’s
superclass, because each class is responsible for freeing its own
memory. Here’s an example taken from the code for PtButton:
static int button destroy( PtWidget t *widget )
{
PtButtonWidget t *button = (PtButtonWidget t *)widget;
cbinfo.cbdata = NULL;
}else
PtDamageWidget( widget );
cbinfo.reason subtype = 0;
cbinfo.event = event;
cbinfo.cbdata = NULL;
if( widget->flags & Pt AUTOHIGHLIGHT )
{
PtSetArg( &arg, Pt ARG FLAGS, 0, Pt HIGHLIGHTED );
PtSetResources( widget, 1, &arg );
cbinfo.reason = Pt CB DISARM;
PtInvokeCallbackList( basic->disarm, widget, &cbinfo );
}
cbinfo.reason = Pt CB LOST FOCUS;
PtInvokeCallbackList( basic->lost focus, widget, &cbinfo );
return Pt CONTINUE;
}
widget->flags |= Pt OPAQUE;
basic opaque rect( widget );
}
}
Widget actions
Widget actions are used to make a widget interactive. For example,
when you click a button widget, you can see it press in and then pop
out again. This is achieved by setting up raw callbacks sensitive to
specific Photon events. The way a widget interacts with events defines
the widget’s behavior.
The callbacks list, Pt SET RAW CALLBACKS (see the “Widget class
resource table” section earlier in this chapter), defines a widget’s
response if it’s different from the behavior of its superclasses. This
method is defined in the same manner as Pt CB RAW. The primary
difference is that the class’s raw callback list is invoked before the
user’s raw callback list. Here’s an excerpt from the code for PtBasic:
static PtRawCallback t callback = {
In the example above, whenever the widget receives one of the four
events (Ph EV BUT PRESS, Ph EV BUT RELEASE,
Ph EV BUT REPEAT, or Ph EV BOUNDARY), the basic callback()
function is invoked. This function can check the event type and act
accordingly.
For clarity, let’s walk through a simplified description of the “click”
process of a PtButton widget.
First, PtButton receives the Ph EV BUT PRESS event. The widget
interprets the press event, changes the widget flags to Pt SET (possibly
causing the widget to be damaged and redrawn), and then invokes the
Pt CB ARM callback.
When the user releases the mouse button, PtButton receives a
Ph EV BUT RELEASE release event. The widget clears the Pt SET
flag and then invokes the Pt CB DISARM and Pt CB ACTIVATE
callbacks.
The action PtButton takes when the button is released is a little
more complicated, because the widget actually doing the work is
PtBasic, not PtButton. The PtButton class doesn’t define any
raw callbacks because the handling done by PtBasic is sufficient.
The PtBasic class handles the common Photon arm, disarm, repeat,
activate, and menu callbacks for all widgets.
data,cbinfo;
cbi.reason = Pt CB TIMER ACTIVATE;
if( timer->state == Pt TIMER INITIAL )
cbi.reason subtype = Pt TIMER INITIAL;
else
cbi.reason subtype = Pt TIMER REPEAT;
timer->state = Pt TIMER REPEAT;
PtInvokeCallbackList( timer->activate, widget, &cbi );
if( timer->msec repeat && timer->state == Pt TIMER REPEAT )
PtTimerArm( widget, timer->msec repeat );
return( Pt CONTINUE );
}
//
// PtTimer class-creation function
//
Child-constraint support
Container widgets extend the PtBasic widget class definition with a
number of constraint methods. These methods allow the container to
adjust itself automatically according to changes made to its children.
The container class extension is shown in the example code below
(taken from the PtContainer.h header file):
typedef struct Pt container widget class {
PtBasicWidgetClass t basic;
void (*child created f)( ... );
int (*child settingresource f)( ... );
int (*child gettingresource f)( ... );
void (*child realized f)( ... );
void (*child unrealized f)( ... );
void (*child destroyed f)( ... );
For convenience, the Photon widget building library lets you call
these methods from a superclass using the provided functions. For
more information, see the Widget Building Library API chapter.
PtWidget t *child )
{
PtCallback t callback = { group exclusive callback,
NULL };
PtGroupUnion t *group = (PtGroupUnion t *)widget;
PtArg t argt[2];
int n = 0;
callback.data = widget;
if( group->basic.activate ) {
PtSetArg( &argt[n++], Pt CB ACTIVATE,
&group->basic.activate->cb, 0 );
}
if( group->group.group flags & Pt GROUP EXCLUSIVE ) {
PtSetArg( &argt[n++], Pt CB ACTIVATE, &callback, 0 );
}
if( n )
PtSetResources( child, n, argt );
}
Child-redirector function
Container widgets provide a mechanism for redirecting child widgets
as they are added to a container. You can use this mechanism to
prevent certain widget classes from being added as direct children or
redirect those children to other containers within the container (this
feature is typically used by PtCompound widgets).
The child-redirector function is specified in the Defaults method and
indicates where children should be attached in the widget hierarchy.
Redirection is achieved by calling the PtContainerChildRedirect()
function, which passes the name of the redirector function.
The arguments to the redirector function are a widget pointer and the
class type of the widget being added to the container. Using this
information, the redirector function determines whether to accept the
widget into the container or redirect the widget to another container,
such as the parent of the container widget.
A good example is the PtMenuBar widget. This widget accepts only
PtMenuButton widgets. Its Defaults method could be written
something like this:
PtContainerChildRedirect( widget, menubar redirect );
The widget returned by the function becomes the parent for the
widget being added.
You can use PtCompoundRedirect() as the default child-redirector
function for any containers that won’t accept other widgets.
PtCompoundRedirect() redirects child creation to the parent of the
container widget. This causes a new widget to become a sibling of the
container widget rather than a child of the container widget.
Fundamental methods
When using container widgets, you must provide a number of
container-specific processes within the fundamental methods in
addition to those common to every widget.
Defaults method
To enable the container-constraint methods, set the appropriate bits in
container->flags. You can turn on all bits as follows:
Only the constraint methods whose bits are on are invoked. If you
turn a bit on and the corresponding constraint method is undefined,
the bit is ignored. For example:
For each bit set in the flag, you should provide a constraint method in
the argument list of the class-creation function:
☞ The Common User Access (CUA) mechanism built into the Photon
library automatically passes focus around the application. If you want
to prevent widgets inside the container from getting focus, set the
Pt BLOCK CUA FOCUS flag. The PtMenuBar widget does this (i.e.
you can’t press the Tab key to move the focus from a widget outside a
menubar to a widget inside a menubar).
Extent method
This method is responsible for determining the “screen real estate” of
a widget. Anchoring is applied in this method. Widgets subclassed
under PtContainer normally call the Extent method of
PtContainer to do the final extent calculation and anchor the
widget according to its anchor flags. When a widget’s extent has been
calculated, its widget->extent valid flag should be set to Pt TRUE.
The following example demonstrates how to handle anchoring if you
choose to not let the PtContainer class do it for you (see also
PtSuperClassExtent()):
// minimize flicker.
PtStartFlux( widget );
if( widget->parent && widget->parent->extent valid
&& (ctnr->anchor flags & Pt IS ANCHORED ) &&
!( widget->class rec->flags &
(Pt DISJOINT|Pt DISCONTINUOUS) ) )
PtAnchorWidget( widget );
else
if( !(ctnr->anchor flags & Pt ANCHORS LOCKED ) &&
memcmp( &widget->area.size, &area.size,
sizeof(PhDim t) ) )
for( wlp = ctnr->ctnrs; wlp; wlp = next )
{
next = wlp->next;
if( ((PtContainerWidget t *)wlp->widget)->anchor flags &
Pt IS ANCHORED )
PtAnchorWidget( wlp->widget );
}
PtEndFlux( widget );
Realization method
If your container creates any subordinate widgets with the
Pt DELAY REALIZE flag set, they can be realized in the Realization
method.
//
// PtComboBox class-creation function
//
};
Blocking resources
The exporting mechanism provides a resource-blocking mechanism.
You can selectively block resources, making them inaccessible to
subordinate widgets.
Suppose you’ve built a compound widget comprising an exported
PtSlider widget, and you want the slider thumb to stay the same
size always — blocking access to the Pt ARG SLIDER SIZE resource
would prevent the slider from being resized.
You may also find that you have more than one occurrence of a single
type of widget as subordinate widget. For example, your widget
might have a vertical and a horizontal scrollbar. In this case, you
should block Pt ARG SCROLL POSITION and create two new
resources: Pt ARG X SCROLL POSITION and
Pt ARG Y SCROLL POSITION. The Set Resources method for each
would set the Pt ARG SCROLL POSITION resource of the
appropriate subordinate scrollbar widget.
Compound redirection
The PtCompound class provides a standard child-redirector function
called PtCompoundRedirect(). This function prevents the user from
creating widgets in your compound widget and redirects the user’s
widget to another container instead. To target another widget, redirect
child creation at the end of the Defaults method after all subordinate
widgets have been created. For example:
Static void defaults( PtWidget t *)
{
.
.
.
PtContainerChildRedirect( widget, PtCompoundRedirect );
return;
}
if( ( parent =
PtValidParent( samp->scroll area,
widget->class ref ) ) == widget )
return PtWidgetParent( widget );
return( parent );
/*
* Returning samp->scroll area would allow the child
* to be created as a direct child of samp->scroll area.
* This may be undesirable, as scroll area is a container
* widget that redirects its children.
*/
}
Fundamental methods
Compound widgets require a few fundamental methods in addition to
those common to every widget.
Defaults method
For compound widgets, all exported subordinate widgets must be
created in the Defaults method. To export widgets, set the following
in the class-creation function:
Pt SET SUBORDINATES
An array of offsets to the subordinate widget pointers.
Pt SET NUM SUBORDINATES
The number of entries in the array.
☞ Your custom widget shouldn’t set its own Pt ARG DATA resource
because this resource is used internally by the Photon libraries. It is
safe to set it in your widget’s subordinate children.
n = 0;
PtSetArg( &args[n], Pt ARG BORDER WIDTH, 0, 0 ); n++;
PtSetArg( &args[n], Pt ARG MARGIN HEIGHT, 2, 0 ); n++;
PtSetArg( &args[n], Pt ARG MARGIN WIDTH, 2, 0 ); n++;
PtSetArg( &args[n], Pt ARG FLAGS, Pt PROCREATED,
Pt PROCREATED ); n++;
PtSetArg( &args[n], Pt ARG DATA, &widget,
sizeof( widget ) );n++;
PtSetArg( &args[n], Pt CB TEXT CHANGED, &callback, 1); n++;
PtSetArg( &args[n], Pt CB MODIFY VERIFY, &callback, 1); n++;
PtSetArg( &args[n], Pt CB MOTION VERIFY, &callback, 1); n++;
n = 0;
callback.event f = combobox list callback;
callback.data = (void*)widget;
PtSetArg( &args[n], Pt ARG BORDER WIDTH,
combobox->combobox.border width, 0 ); n++;
PtSetArg( &args[n], Pt ARG SCROLLBAR WIDTH,
combobox->combobox.butn size.w, 0 ); n++;
PtSetArg( &args[n], Pt ARG SEL MODE,
Pt SELECTION MODE SINGLE | Pt SELECTION MODE AUTO,
0 ); n++;
PtSetArg( &args[n], Pt ARG FLAGS,
Pt PROCREATED | Pt DELAY REALIZE,
Pt GETS FOCUS | Pt ETCH HIGHLIGHT
| Pt PROCREATED | Pt DELAY REALIZE );n++;
PtSetArg( &args[n], Pt CB SELECTION, &callback, 1 );n++;
PtSetArg( &args[n], Pt CB LIST INPUT, &callback, 1 );n++;
PtSetArg( &args[n], Pt ARG DATA, &widget,
sizeof( widget ) );n++;
combobox->combobox.list wgt = PtCreateWidget( PtList, widget,
n, args );
n = 0;
callback.event f = combobox action;
callback.data = (void*)widget;
PtSetArg( &args[n], Pt CB ARM, &callback, 1 ); n++;
PtSetResources( combobox->combobox.text wgt, n, args );
Realization method
The Realization method is the last class-member function called
before the Draw method. It’s where you realize subordinate widgets
created in the Defaults method. Here’s an example from
PtComboBox:
Destruction method
The Destruction method must destroy any redirected callback lists of
exported subordinates having callback resources set on them.
In this chapter. . .
PtWidget 95
PtBasic 99
PtContainer 105
PtCompound 114
PtGenList 116
PtGenTree 125
PtLabel 129
PtGraphic 133
PtGauge 136
PtWidget
The PtWidget superclass provides the fundamental functionality of
all Photon widgets.
Class hierarchy
PtWidget
Class flags
Pt RECTANGULAR
Methods
PtWidget defines the class methods described below.
Defaults method
None.
Initialization method
None.
Extent method
Calculates the extent of the widget without accounting for borders or
margins. The extent is calculated based on the widget’s position
(Pt ARG POS) and dimension (Pt ARG DIM). For disjoint widgets
(e.g. PtWindow widgets), the position is assumed to be (0, 0).
Connection method
Determines if the widget needs a region, and if so, what events the
region should be opaque and/or sensitive to.
If the widget has a bitmap cursor defined, it’s set up as region data. If
the widget already has a region, that region is updated with the
opaque/sense and region data. This is done through
PhRegionChange().
If the widget doesn’t have a region but one is required, it’s created
through PhRegionOpen().
Finally, if the widget isn’t a window, any hotkey callbacks attached to
the widget are registered with the nearest disjoint parent (of
PtWindow class). This is done through PtSetResources().
Realization method
None.
Unrealization method
If the widget has a region, the region is closed. All descendants
(widget->rid members) are set to 0. If the widget isn’t a window, any
attached hotkey callbacks are detached from its disjoint parent.
The extent of this widget is damaged on the parent. All children of
this widget are unrealized. Any of these widgets having a
constraining parent with Pt SET CHILD UNREALIZED F defined has
that function invoked. Any of these having a Pt CB UNREALIZED
callback chain has that callback chain invoked (from the top down).
Destruction method
Called when a widget instance is being removed. Frees
widget->widget data. Any memory automatically allocated by a
resource is released (this memory shouldn’t be freed in the
Destruction method). Any resources you free must have the pointer
set to NULL to prevent the widget engine from freeing the memory a
second time. The following resource types automatically allocate and
release memory:
¯ Pt ARG IS ALLOC
¯ Pt ARG IS ARRAY
¯ Pt ARG IS LINK
¯ Pt ARG IS STRING
Widget actions
None.
Resource definitions
Pt ARG AREA, Pt CHANGE RESIZE, 0,
Pt ARG IS STRUCT( PtWidget t, area ), 0,
Functions
static core modify cursor()
Sets the resource via direct assignment and if realized, sets the
Ph REGION CURSOR bit in widget->flags. If this flag is on
when the PtUpdate() function is called (see the Photon Library
Reference), a PhRegionChange() will be performed to change
the region’s cursor or create a region if one doesn’t exist.
int PtModifyFlags()
Knocks down the read-only flag bits from the mask and applies
the remaining flag to widget->flags. A change in the following
flag bits may cause the widget to change:
Pt AUTOHIGHLIGHT
Requires a region and sensitivity to
Ph EV BOUNDARY events via PhRegionChange() or
the Connection method of PtWidget.
Pt ETCH HIGHLIGHT
Resize by setting the Pt WIDGET RESIZE bit in
widget->flags.
Pt SET If Pt SELECT NOREDRAW isn’t set in the widget
flags, the widget will force a redraw by calling
PtDamageWidget().
Pt HIGHLIGHTED
The widget will force a redraw by calling
PtDamageWidget().
PtBasic
Provides fundamental Photon widget behavior and callbacks.
Class hierarchy
PtWidget → PtBasic
Class extensions
The PtBasic widget adds three class-level methods to fundamental
widget functionality. For complete descriptions, see “Class methods”
in the Anatomy of a Widget chapter.
#define Pt SET GOT FOCUS F (Pt ARG IS POINTER(PtBasicWidgetClass t,got focus f))
#define Pt SET LOST FOCUS F (Pt ARG IS POINTER(PtBasicWidgetClass t,lost focus f))
#define Pt SET CALC OPAQUE F (Pt ARG IS POINTER(PtBasicWidgetClass t,calc opaque f))
Methods
PtBasic defines the class methods described below.
Defaults method
widget->border width = 2;
widget->cursor color = Ph CURSOR DEFAULT COLOR;
widget->resize flags |= Pt RESIZE XY AS REQUIRED;
basic->color = Pg BLACK;
basic->fill color = Pg GREY;
basic->top border color = Pg WHITE;
basic->bot border color = Pg DGREY;
basic->flags = Pt DAMAGE ON FOCUS;
Initialization method
None.
Extent method
Invokes the Extent method of PtWidget via PtSuperClassExtent().
The resulting extent is then adjusted to account for borders and
margins.
The Extent method calculates the widget’s opaque rectangle and
determines whether the widget’s Pt OPAQUE flag is set. The opaque
rectangle, widget->opaque, indicates:
Connection method
Checks the PtBasic class structure member calc opaque f . If not
NULL, the function is invoked. The calc opaque f() function is
responsible for setting or clearing a widget’s Pt OPAQUE flag. If the
widget has a rectangular area blocking anything beneath, the
Pt OPAQUE flag should be set and widget->opaque rect should
identify that rectangular area. Otherwise, the Pt OPAQUE flag should
be cleared.
Realization method
Inherited from PtWidget.
Draw method
PtBasic’s Draw method draws a rectangle filled with the current fill
color. The widget’s border is rendered if the Pt HIGHLIGHTED bit of
the widget flags is set and the border width is greater than 0.
If the Pt SET bit is set, the border is rendered inverted (i.e. the top
border color is used to draw the bottom border and vice versa).
PtBasic’s Draw method also handles focus rendering.
Unrealization method
None.
Destruction method
None.
Widget actions
PtBasic is sensitive to the following events:
Ph EV BUT PRESS
The widget sets/clears Pt SET flags, invokes Pt CB ARM (and
possibly Pt CB ACTIVATE if a toggle button is selected) and
Pt CB MENU (if the right mouse button is pressed).
Ph EV BUT REPEAT
The widget invokes the Pt CB REPEAT callbacks.
Ph EV BUT RELEASE
The widget invokes the Pt CB DISARM callbacks. If a real
release (as opposed to a phantom release) is received, the
widget also invokes Pt CB ACTIVATE.
Ph EV BOUNDARY
The widget manages highlighting of widgets with the
Pt AUTOHIGHLIGHT flag set.
Resource definitions
Pt ARG BORDER WIDTH, Pt CHANGE RESIZE, 0,
Pt ARG IS NUMBER( PtWidget t, border width ), 0,
Functions
static void basic modify flags()
For Pt ARG FLAGS, this function:
¯ recalculates the opaque rectangle if a highlighting flag is
changing
¯ damages the widget if the Pt GHOST flag is changing
¯ lets any other flag changes be handled via
PtSuperClassSetResources()
void basic modify()
Sets the fill color and roundness values. Invokes the Connection
method of PtBasic (which invokes the Calc Opaque Rect
PtContainer
This superclass provides a new origin, clipping, and constraints for
widget children. If you’re creating a widget with children, we
recommend you make your widget a subclass of PtContainer or
one of its subclasses.
Class hierarchy
PtWidget → PtBasic → PtContainer
Class extensions
typedef struct Pt container widget class {
PtBasicWidgetClass t basic;
void (*child created f)( PtWidget t *widget,
PtWidget t *child );
int (*child settingresource f)(PtWidget t *widget,
PtWidget t *child, PtArg t *argt);
int (*child gettingresource f)(PtWidget t *widget,
PtWidget t *child, PtArg t *argt );
void (*child realized f)( PtWidget t *widget,
PtWidget t *child );
void (*child unrealized f)( PtWidget t *widget,
PtWidget t *child );
void (*child destroyed f)( PtWidget t *widget,
PtWidget t *child );
void (*child move resize f)( PtWidget t *widget,
PtWidget t *child, PhArea t *current area,
PhRect t *current extent, PhArea t *old area,
Methods
PtContainer defines the class methods described below.
Defaults method
PtBasicWidget t *basic = (PtBasicWidget t *)widget;
PtContainerWidget t *ctnr =(PtContainerWidget t *)widget;
widget->border width = 0;
widget->resize flags &= ˜Pt RESIZE XY BITS;
ctnr->anchor flags = Pt ANCHORS INVALID;
ctnr->flags = Pt CANVAS INVALID;
PtSetParentWidget( widget );
Initialization method
Registers with its parent for anchoring services. Registration is done
via PtContainerRegister().
Extent method
Finds the bounding box of widget children and applies its resize
policy. The extent is calculated, and if the canvas is different as a
result, all registered child containers are anchored. If the extent or
canvas is different, the resize callback list of the widget is invoked.
See PtSuperClassExtent() for a sample Extent method of a container.
Connection method
None.
Realization method
None.
Draw method
Inherited from PtBasic.
Unrealization method
Deregisters a widget from its parent. Destroys the current balloon
and sets it to NULL (if not NULL already).
Destruction method
Deregisters a widget from its parent.
Widget actions
Raw callbacks are supported for Ph EV BUT PRESS,
Ph EV BUT RELEASE, Ph EV BUT REPEAT, and Ph EV KEY events.
If there are callbacks in the Pt CB FILTER callback chain having an
event mask that matches the current event type, those callbacks are
invoked. If the value returned by a filter callback is greater than 0, that
value is returned. If there are balloons registered with this container,
the balloon list is checked to determine if a balloon needs to be
inflated and/or deflated.
If the event is a Ph EV KEY event, the event is given to the focused
child of the container, if there is one. If the event isn’t consumed by
the container, the hotkey chain of the nearest disjoint parent is
processed to see if the key is a hotkey. If a matching hotkey definition
is found, the hotkey callback is invoked and the event is consumed (by
returning Pt END).
¯ the current intersecting widget has the Pt GETS FOCUS flag set
then focus is given to that widget and event->processing flags has its
Ph DIRECTED FOCUS bit set. If the return from PtEventHandler()
was Pt END, the event is considered consumed and Pt END is
returned.
An extra step is performed if the event is a press and Pt ->current is
NULL: the absorbing widget is recorded for the purposes of delivering
phantom releases to the appropriate widget at a later time.
Once the event has been consumed or there are no more intersecting
events, Pt END is returned. Otherwise, absorbed is returned.
Resource definitions
static const PtRawCallback t callback = {
Pt EV REDIRECTED, container callback, NULL
};
static const PtResourceRec t resources[] = {
// overridden resources
Pt ARG AREA, container modify area, 0,
Pt ARG IS STRUCT( PtWidget t, area ), 0,
Pt ARG DIM, container modify area, 0,
Pt ARG IS STRUCT( PtWidget t, area.size ), 0,
Pt ARG POS, container modify area, 0,
Pt ARG IS STRUCT( PtWidget t, area.pos ), 0,
Pt ARG RESIZE FLAGS, container modify area, 0,
Pt ARG IS FLAGS( PtWidget t, resize flags ), 0,
// new resources
Pt ARG ANCHOR OFFSETS, container modify area, 0,
Pt ARG IS STRUCT( PtContainerWidget t,
anchor offset), 0,
Pt ARG ANCHOR FLAGS, container modify area, 0,
Pt ARG IS NUMBER( PtContainerWidget t,
anchor flags ), 0,
Pt ARG FOCUS, container modify, 0,
Pt ARG IS POINTER( PtContainerWidget t, focus ), 0,
Pt CB RESIZE, Pt CHANGE INVISIBLE, 0,
Pt ARG IS CALLBACK LIST( PtContainerWidget t,
resize ), 0,
Pt CB BALLOONS, container set balloons, 0,
Pt ARG IS LINK( PtContainerWidget t, balloons ), 0,
Pt ARG CONTAINER FLAGS, container modify flags, 0,
Pt ARG IS FLAGS( PtContainerWidget t, flags ), 0,
Pt CB FILTER, Pt CHANGE INVISIBLE, 0,
Pt ARG IS LINK( PtContainerWidget t, filters ), 0,
};
Functions
container modify area()
If area, pos, or dim is being modified, the container’s anchors
are invalidated and unlocked:
container->flags |= Pt ANCHORS INVALID;
container->flags &= ˜Pt ANCHORS LOCKED;
container modify()
static void container modify( PtWidget t *widget,
PtArg t *arg )
{
PtContainerWidget t *container =
(PtContainerWidget t *)widget;
PhEvent t event;
if (( container->focus ==
(PtWidget t *)arg->value )
|| ( !arg->value )
|| (((PtWidget t *)arg->value)->parent !=
widget))
return;
PtCompound
This class is used for creating widgets whose functionality (in part) is
derived from exported subordinate widgets.
Class hierarchy
PtWidget → PtBasic → PtContainer → PtCompound
Class extensions
typedef struct Pt compound class {
PtContainerClass t container;
ushort t num subordinates;
ushort t *subordinates;
ushort t num blocked resources;
ulong t *blocked resources;
} PtCompoundClass t;
Pt SET SUBORDINATES
An array of offsets to widget pointers to subordinate widgets.
These widgets must be created in the compound widget’s
Defaults method.
Pt SET NUM BLOCKED RESOURCES
Indicates the number of resources to block.
Methods
PtCompound defines the class methods described below.
Defaults method
Inherits all defaults from PtContainer.
Initialization method
None.
Extent method
Inherited from PtContainer.
Connection method
None.
Realization method
None.
Draw method
Inherited from PtContainer.
Unrealization method
None.
Destruction method
Destroys the redirected callback lists of exported subordinates having
callback resources set on them.
Widget actions
None.
Resource definitions
None.
Functions
None.
PtGenList
This class is used for creating list widgets.
Class hierarchy
PtWidget → PtBasic → PtContainer → PtCompound →
PtGenList
Class extensions
typedef void PtGenListDrawF t(
PtGenListWidget t *widget, PtGenListItem t *item,
unsigned index,unsigned nitems, PhRect t *where
);
Methods
PtGenList defines the class methods described below.
Defaults method
widget->flags
|= Pt HIGHLIGHTED | Pt ETCH HIGHLIGHT | Pt SET
| Pt GETS FOCUS | Pt FOCUS RENDER;
widget->eflags &= ˜Pt DAMAGE ON FOCUS;
widget->resize flags &= ˜Pt RESIZE XY BITS;
widget->border width = 2;
list->flags = Pt LIST SCROLLBAR AS REQUIRED;
list->sel mode = Pt BROWSE MODE;
list->scroll rate = 2;
list->selection fill color = Pg BLUE;
list->selection text color = Pg WHITE;
list->balloon bg = Pg BALLOONCOLOR;
list->balloon fg = Pg BLACK;
list->font = strdup( "helv12" );
basic->margin width =
basic->margin height = 0;
basic->flags &= ˜Pt DAMAGE ON FOCUS;
list->slider width = 15;
list->top item = 1;
Initialization method
None.
Extent method
If a PtDivider widget is the child, the Extent method:
Connection method
None.
Realization method
Realizes the scrollbar if necessary and registers a balloon callback
with the parent.
Draw method
Renders the widget’s border, margins, and (possibly) background.
Then the List Draw method is called to draw the list.
Unrealization method
Deregisters a balloon callback with the parent.
Destruction method
None.
Widget actions
PtGenList is sensitive to the following events:
¯ Ph EV KEY
¯ Ph EV BUT PRESS
¯ Ph EV BUT RELEASE
¯ Ph EV BUT REPEAT
The callback function invokes the List Key or List Mouse method and
performs the selection.
Resource definitions
{ Pt ARG AREA, arg resize, NULL,
Pt ARG IS STRUCT( PtWidget t, area )
},
{ Pt ARG DIM, arg resize, NULL,
Pt ARG IS STRUCT( PtWidget t, area.size )
},
{ Pt ARG POS, arg resize, NULL,
Pt ARG IS STRUCT( PtWidget t, area.pos )
},
{ Pt ARG MARGIN HEIGHT, arg resize, NULL,
Pt ARG IS NUMBER( PtGenListWidget t, bot margin )
},
{ Pt ARG MARGIN WIDTH, arg resize, NULL,
Pt ARG IS NUMBER( PtGenListWidget t, margin width )
},
{ Pt ARG LIST FLAGS, arg flags, NULL,
Pt ARG IS FLAGS( PtGenListWidget t, flags )
},
{ Pt ARG LIST FONT, arg font, NULL,
Pt ARG IS STRING( PtGenListWidget t, font )
},
{ Pt ARG SCROLLBAR WIDTH, arg resize, NULL,
Pt ARG IS NUMBER( PtGenListWidget t, slider width )
},
{ Pt ARG SELECTION MODE, arg selmode, NULL,
Pt ARG IS NUMBER( PtGenListWidget t, sel mode )
},
{ Pt ARG TOP ITEM POS, arg top pos, NULL,
Pt ARG IS NUMBER( PtGenListWidget t, top item )
},
{ Pt ARG VISIBLE COUNT, Pt CHANGE PREVENT, NULL,
Pt ARG IS NUMBER( PtGenListWidget t, displayed count )
},
{ Pt ARG SELECTION FILL COLOR, Pt CHANGE REDRAW, NULL,
Functions
static void arg resize()
This function:
¯ adjusts the number of displayed items
¯ resizes the scrollbar
¯ adjusts the Pt ARG DIVIDER OFFSET resource of the
widget pointed to by list->divider
static void arg font()
This function:
¯ allocates a copy of the new font name and frees the old string
¯ stores the height of the new font in list->font height
static void arg top pos()
This function:
¯ calculates a new range of displayed items
¯ blits some of the currently visible items to their new
positions (blits only the items that will remain visible after
the change)
¯ adjusts the scrollbar position
¯ invokes the Pt CB SCROLL MOVE callback
static void arg selmode()
This function:
¯ clears the current selection
¯ if the new value is valid, sets list->sel mode,
list->sel xmode, and list->sel flags
static void arg flags()
For Pt ARG LIST FLAGS, this function:
¯ adjusts the Pt BLOCKED flag of the scrollbar if the
Pt LIST INACTIVE flag is changed
¯ adjusts the Pt GETS FOCUS flag of the scrollbar if the
Pt LIST SCROLLBAR GETS FOCUS flag is changed
¯ adjusts list->sel xmode and list->sel flags if the
Pt LIST NON SELECT flag is changed
PtGenTree
This class is used for creating tree widgets.
Class hierarchy
PtWidget → PtBasic → PtContainer → PtCompound →
PtGenList → PtGenTree
Class extensions
typedef void PtGenTreeDrawItemF t(
PtGenTreeWidget t *wgt, PtGenTreeItem t *item,
PhRect t const *where, int lmargin, int rmargin
);
Methods
PtGenTree defines the class methods described below.
Defaults method
tree->flags = Pt TREE HAS BUTTONS | Pt TREE HAS LINES |
Pt TREE ROOT LINES;
tree->list.gflags = Pt GEN LIST SHOW DAMAGED |
Pt GEN LIST ITEM BACKGROUND;
Initialization method
None.
Extent method
Inherited from PtGenList.
Connection method
None.
Realization method
None.
Draw method
Inherited from PtGenList.
Unrealization method
None.
Destruction method
None.
Widget actions
None.
Resource definitions
{ Pt ARG TREE FLAGS, arg flags, NULL,
Pt ARG IS FLAGS( PtGenTreeWidget t, flags )
},
{ Pt CB GEN TREE INPUT, Pt CHANGE INVISIBLE, NULL,
Pt ARG IS CALLBACK LIST( PtGenTreeWidget t, input cb )
} };
Functions
static void arg flags()
This function:
¯ adjusts list->gflags if the Pt TREE TO RIGHT flag has
changed
¯ damages the widget or marks it for resizing
PtLabel
The PtLabel class provides fundamental multiline-text string and
image handling.
Class hierarchy
PtWidget → PtBasic → PtLabel
Methods
PtLabel defines the class methods described below.
Defaults method
widget->flags |= Pt FOCUS RENDER;
widget->resize flags |= Pt RESIZE XY AS REQUIRED;
label->basic.fill color = Pg TRANSPARENT;
label->font = strdup( "helv12" );
label->flags |= Pt LABEL SELECT SHIFT;
label->uline1 = Pg BLACK;
label->uline2 = Pg TRANSPARENT;
label->uline type =(ushort t) Pt NO ULINE;
label->type = Pt Z STRING;
label->basic.margin width = 2;
label->basic.margin height = 2;
label->margin top = 0;
label->margin bottom = 0;
label->margin left = 0;
label->margin right = 0;
label->h alignment = Pt LEFT;
label->v alignment = Pt CENTER;
label->string = strdup("");
label->inflate f = PtInflateBalloon;
Initialization method
None.
Extent method
Determines the required canvas size based on the widget’s text string
or image data in conjunction with label->type (Pt Z STRING,
Pt TEXT IMAGE ), margins, etc. The Extent method also takes into
account multiple lines of text and underlining.
Connection method
If label->flags has the Pt SHOW BALLOON flag set, a balloon
callback is attached to the parent widget.
Realization method
Inherited from PtBasic.
Draw method
Calls the Draw method of PtBasic via PtSuperClassDraw(). Draws
the text in the label using the specified font, color, etc.
Unrealization method
If this label has a balloon displayed (label->balloon widget != NULL),
that widget is destroyed. If label->flags has the Pt SHOW BALLOON
flag set, it detaches the balloon callback from the parent.
Destruction method
If widget->flags has the Pt FREE MEMORY flag set, any memory used
for the label’s image and palette is freed.
Widget actions
None.
Resource definitions
Pt ARG HORIZONTAL ALIGNMENT, Pt CHANGE REDRAW, 0,
Pt ARG IS NUMBER( PtLabelWidget t, h alignment ), 0,
Functions
static int label modify flags( PtWidget t *widget,
PtArg t *argt );
cleared, the balloon callback is detached from the parent. The value
of label->flags is based on argt->value and argt->len. This is
typically done as follows:
label->flags = (label->flags & ˜argt->len) | argt->value;
This frees the current string, allocates enough space for the new
string, copies in the new string, flags the widget to be resized
(widget->flags |= Pt WIDGET RESIZE;), and damages the widget.
If a balloon is displayed, the balloon is destroyed and a new balloon is
inflated with the new string. If label->flags has the
Pt BALLOON AS REQUIRED bit set, the new balloon will be created
only if the label will be clipped by its parent.
PtGraphic
This class provides standard graphic resources such as
Pt ARG POINTS and Pt ARG ORIGIN.
Class hierarchy
PtWidget → PtBasic → PtGraphic
Methods
PtGraphic defines the class methods described below.
Defaults method
static void graphic dflts( PtWidget t *widget )
{
PtGraphicWidget t *graphic =
(PtGraphicWidget t *)widget;
graphic->basic.margin width = 0;
graphic->basic.fill color = Pg TRANSPARENT;
graphic->npoints = 0;
graphic->point array = NULL;
}
Initialization method
None.
Extent method
Determines the render rectangle for the graphic widget, given the
area, point array, and current settings of graphic flags.
Connection method
None.
Realization method
None.
Draw method
Inherited from PtBasic.
Unrealization method
None.
Destruction method
None.
Widget actions
None.
Resource definitions
static PtResourceRec t resources[] = {
Pt ARG AREA, graphic modify area, 0,
Pt ARG IS STRUCT( PtWidget t, area ), 0,
Pt ARG DIM, graphic modify area, 0,
Pt ARG IS STRUCT( PtWidget t, area.size ), 0,
Pt ARG DASH LIST, Pt CHANGE REDRAW, 0,
Pt ARG IS ARRAY( PtGraphicWidget t, dash list ),
Pt ARG IS NUMBER( PtGraphicWidget t, dash len ),
Pt ARG GRAPHIC FLAGS, Pt CHANGE RESIZE, 0,
Pt ARG IS FLAGS( PtGraphicWidget t, flags ),0,
Pt ARG LINE WIDTH, Pt CHANGE RESIZE REDRAW, 0,
Pt ARG IS NUMBER( PtGraphicWidget t,
line width ), 0,
Pt ARG LINE JOIN, Pt CHANGE REDRAW, 0,
Pt ARG IS NUMBER( PtGraphicWidget t,
line join ), 0,
Pt ARG LINE CAP, Pt CHANGE REDRAW, 0,
Pt ARG IS NUMBER( PtGraphicWidget t, line cap ), 0,
Pt ARG ORIGIN, Pt CHANGE RESIZE REDRAW, 0,
Pt ARG IS STRUCT( PtGraphicWidget t, origin ), 0,
Pt ARG POINTS, Pt CHANGE RESIZE REDRAW, 0,
Pt ARG IS ARRAY( PtGraphicWidget t, point array),
Pt ARG IS NUMBER( PtGraphicWidget t, npoints),
Pt CB RESCALE, Pt CHANGE INVISIBLE, 0,
Pt ARG IS LINK( PtGraphicWidget t, rescale ) |
Pt ARG PARM(sizeof( PtCallback t)), 0,
Pt ARG DASH SCALE, Pt CHANGE REDRAW, 0,
Pt ARG IS NUMBER( PtGraphicWidget t,
dash scale ), 0,
};
Functions
graphic modify area()
Updates the widget’s area or dimension and invokes the
Pt CB RESCALE callback.
PtGauge
This class provides standard gauge resources such as maximum,
minimum, and orientation.
Class hierarchy
PtWidget → PtBasic → PtGauge
Methods
PtGauge defines the class methods described below.
Defaults method
static void gauge dflts( PtWidget t *widget )
{
PtGaugeWidget t *gauge = (PtGaugeWidget t *)widget;
static const char helv12[] = "helv12";
Initialization method
None.
Extent method
Inherited from PtBasic.
Connection method
None.
Realization method
None.
Draw method
Inherited from PtBasic.
Unrealization method
None.
Destruction method
None.
Widget actions
None.
Resource definitions
static const PtResourceRec t resources[] = {
Pt ARG GAUGE FLAGS, Pt CHANGE INVISIBLE, 0,
Pt ARG IS FLAGS( PtGaugeWidget t, flags ), 0,
Pt ARG GAUGE FONT, Pt CHANGE INVISIBLE, 0,
Pt ARG IS STRING( PtGaugeWidget t, font ), 0,
Pt ARG GAUGE MINIMUM, Pt CHANGE INVISIBLE, 0,
Pt ARG IS NUMBER( PtGaugeWidget t, minimum ), 0,
Pt ARG GAUGE MAXIMUM, Pt CHANGE INVISIBLE, 0,
Pt ARG IS NUMBER( PtGaugeWidget t, maximum ), 0,
Pt ARG GAUGE VALUE, Pt CHANGE INVISIBLE, 0,
Pt ARG IS NUMBER( PtGaugeWidget t, value ), 0,
Pt ARG GAUGE ORIENTATION, Pt CHANGE INVISIBLE, 0,
Pt ARG IS NUMBER( PtGaugeWidget t, orientation ), 0,
};
Functions
None.
In this chapter. . .
Overview 141
Convenience functions 149
PtGenListAddItems() 153
PtGenListAllItems() 155
PtGenListClearSelection() 156
PtGenListDamageItem() 157
PtGenListDrawBackground() 158
PtGenListDrawString() 159
PtGenListFirstItem() 161
PtGenListGetCurrent() 162
PtGenListGetSelIndexes() 163
PtGenListGoto() 164
PtGenListHold() 165
PtGenListItemIndex() 166
PtGenListItemRealloc() 167
PtGenListLastItem() 168
PtGenListLockItem() 169
PtGenListRelease() 170
PtGenListRemoveItems() 171
PtGenListResize() 173
PtGenListSelect() 174
PtGenListSelectedItems() 175
PtGenListSetGflags() 176
PtGenListSetSelIndexes() 177
PtGenListShow() 178
PtGenListUnlockItem() 179
PtGenListUnselect() 180
PtSuperClassGenListDraw() 181
PtSuperClassGenListInflate() 182
PtSuperClassGenListKey() 183
PtSuperClassGenListMouse() 184
PtSuperClassGenListSelect() 185
Overview
The Photon library provides the generic list widget class PtGenList
for creating custom list widgets. The PtGenList class displays a
vertical list of any number of items. A user can select one or more
items from this list, depending on the selection policy.
The child class shouldn’t override the Draw method or consume
mouse or key events. Instead, it should define a List Draw method for
drawing and may define a Mouse and/or Key Event method if
additional handling of those event types is required. Usually, the child
class will also define a Selection method that will be called by the
PtGenList event handler.
Item structure
The PtGenList class never allocates or frees items. This is the
responsibility of the child class. The PtGenList class expects each
item to be represented by a PtGenListItem t structure.
When you call a PtGenList*() convenience function, you give it a
pointer to the PtGenListItem t structure as an item. When
PtGenList calls one of your methods, it provides a pointer to the
PtGenListItem t structure as an item.
Since a child class will most likely need additional data describing the
item, it will usually define its item as a structure whose first member
is PtGenListItem t. This makes conversions to and from
PtGenListItem t easy.
The child class is responsible for allocating items and adding them to
the widget. Before adding an item to the widget, the members of the
item structure should be set to the required values. After the item has
been added to the widget, the PtGenListItem t structure shouldn’t
be modified directly — convenience functions can be used instead.
The PtGenListItem t structure is defined as follows:
}
PtGenListItem t;
size Width and height of the item. If the child class needs
to modify the size of an item after it has been added to
the widget, it should use the PtGenListLockItem() and
PtGenListUnlockItem() convenience functions. If the
widget has columns, the widths of the items are
ignored.
next, prev The widget uses these links to find the next and
previous items in the list. These links shouldn’t be
modified after the item has been added to the widget.
The next link is used for linking items before they’re
added to a widget (see PtGenListAddItems()).
¯ Pt SELECTION MODE(
Pt SELECTION MODE MULTIPLE )
¯ Pt SELECTION MODE(
Pt SELECTION MODE RANGE )
cur ndx The index of the current item (the first item on the
list has an index of 1).
Methods
The methods described in this section are defined in the PtGenList
class.
PtGenListWidget t *widget
The widget pointer.
PtGenListItem t *items
A pointer to the first item that needs to be redrawn.
unsigned index
The index of the item to be redrawn (the first item on the list has
an index of 1).
unsigned nitems
The number of items the function should look at.
PhRect t *where
The extent of the items (the function is allowed to modify the
PhRect t structure pointed to by where).
PtGenListWidget t *widget
The widget pointer.
PtGenListItem t *item
The item under the mouse cursor.
unsigned index
The index of that item (the first item on the list has an index of
1).
PhRect t *where
Mouse position relative to the item (the function is allowed to
modify the PhPoint t structure pointed to by where).
Pt CONTINUE
The PtGenList class will normally process the data
contained in the PhKeyEvent t structure (see the
Photon Library Reference. Note that the class’s raw
callbacks are allowed to modify the contents of that
structure.
Pt END The widget will ignore the event and the class’s raw
callbacks will return Pt CONTINUE immediately.
PtGenListWidget t *widget
The widget pointer.
PtGenListItem t *newcur
The new current item (if the event is processed
normally).
int index The index of that item (the first item on the list has an
index of 1).
PtGenListWidget t *list
The widget pointer.
PtGenListItem t *item
In Pt SELECTION MODE RANGE selection mode,
the first selected item. In other modes, the item that
has been selected or unselected.
int index The index of that item (the first item on the list has
an index of 1).
PtWidget t *widget
The list widget.
PtWidget t *parent
The parent widget for the balloon.
PtGenListItem t *item
The item under the mouse pointer.
unsigned index
The index of that item (the first item on the list has
an index of 1).
int column The index of the column under the mouse pointer, or
-1 if the pointer isn’t on a column or the widget has
no columns.
PhArea t *area
The area (relative to the parent widget)
corresponding to the entire item. Use
PtGenListSetColumnBalloon() to adjust the area to
the specified column if you’re not using
PtGenListCreateTextBalloon(). These functions are
described in the Photon Widget Reference.
Convenience functions
The PtGenList class defines the following convenience functions:
PtGenListAddItems()
Add items to a list.
PtGenListAllItems()
Get pointers to all the items in a list.
PtGenListClearSelection()
Clear the selection.
PtGenListDamageItem()
Redraw an item when its data has been changed.
PtGenListDrawBackground()
Draw the background of a list.
PtGenListDrawString()
Draw a string.
PtGenListFirstItem()
Return a pointer to the first item in a list.
PtGenListGetCurrent()
Return a pointer to the current item in a list.
PtGenListGetSelIndexes()
Get the indexes of the selected items.
PtGenListGoto()
Set the current item so that the new current item is visible.
PtGenListHold()
Prevent visible repair of a list widget.
PtGenListItemIndex()
Find the index of an item.
PtGenListItemRealloc()
Reallocate memory for an item.
PtGenListLastItem()
Return a pointer to the last item in a list.
PtGenListLockItem()
Lock an item so it can be resized.
PtGenListRelease()
Release a hold on visible repairs of a list widget.
PtGenListRemoveItems()
Remove items from a list.
PtGenListResize()
Resize a list widget.
PtGenListSelect()
Select an item in a list.
PtGenListSelectedItems()
Get pointers to the selected items.
PtGenListSetGflags()
Modify the gflags field of the widget.
PtGenListSetSelIndexes()
Set the selection indexes.
PtGenListShow()
Set the current position so a given item is visible.
PtGenListUnlockItem()
Unlock an item so it can be updated.
PtGenListUnselect()
Unselect an item in a list.
PtSuperClassGenListDraw()
Invoke the Draw List method in a superclass.
PtSuperClassGenListInflate()
Invoke the List Inflate method in a superclass.
PtSuperClassGenListKey()
Invoke the List Key method in a superclass.
PtSuperClassGenListMouse()
Invoke the List Mouse method in a superclass.
PtSuperClassGenListSelect()
Invoke the List Select method in a superclass.
Synopsis:
void PtGenListAddItems( PtWidget t *list,
PtGenListItem t *items,
PtGenListItem t *after );
Description:
This function adds items to a widget. The arguments are:
items A list linked with the next field (the prev field is ignored).
after If after is NULL, add the items at the beginning of the list.
If after isn’t NULL, it must point to an item in the widget
and items will be added after that item.
items will become the selected range. The current item will be either
the first or last item in this range, depending on the setting of the
Pt LIST ITEM CURRENT flag of the first selected item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtGenListItem t **PtGenListAllItems(
PtWidget t *widget,
PtGenListItem t **buffer );
Description:
This function fills the given buffer with pointers to all the list items.
If buffer is NULL, the function allocates a buffer by calling malloc(),
and the buffer is NULL-terminated (or zero-terminated). It’s the
caller’s responsibility to free the buffer when it’s no longer needed.
If buffer isn’t NULL, the function doesn’t add a NULL or zero to the
end.
Returns:
A pointer to a buffer containing pointers to all the items in the list, or
NULL.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenListClearSelection( PtWidget t *widget );
Description:
This function clears the selection.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenListDamageItem( PtWidget t *list,
PtGenListItem t *item );
Description:
Call this function to redraw the item when its data has been changed.
If the size changes too, use PtGenListLockItem() and
PtGenListUnlockItem() instead.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenListDrawBackground(
PtWidget t *list,
PtGenListItem t const *items,
unsigned nitems,
PhRect t const *where,
int lmarg,
int rmarg );
Description:
This function can be used by a child class of PtGenList for drawing
the background. If the Pt GEN LIST SHOW DAMAGED bit is set in
list->gflags, the function draws only the background for damaged
items.
The values of the list, items, nitems, and where arguments should be
the same as those used to call the List Draw method. The lmarg and
rmarg arguments define additional “margins” — by setting them to a
positive value, you can shorten the selection bar.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenListDrawString( PtWidget t *list,
const char *string,
PhRect t const *where,
int lmarg,
int rmarg );
Description:
This function can be used by a child class of PtGenList for drawing
strings. The list and where arguments should be the same as those
used to call the List Draw method. The string argument is the string
to display. Any Tab characters in the string are interpreted as column
separators.
The where argument defines the rectangle in which the text will be
positioned. The x values for the rectangle should be the same as those
used in the where argument of the List Draw method. The y values
define the vertical position of the string to be drawn between the given
values.
The lmarg and rmarg arguments define additional margins. The value
of lmarg is added to the from value of the first column, and rmarg is
subtracted from the to value of the last column. If the widget doesn’t
have columns, the width of the widget’s canvas is used as a column.
Examples:
Here’s an excerpt showing the List Draw method of a widget (taken
from PtList):
short bot;
bot = where->ul.y + items->size.h;
if ( items->flags & Pt LIST ITEM DAMAGED ) {
where->lr.y = bot - 1;
PgSetTextColor(
items->flags & Pt LIST ITEM SELECTED
? glist->selection text color
: basic->color
);
PtGenListDrawString( glist, STRING(items), where,
0, 0 );
}
where->ul.y = bot;
items = items->next;
} while ( --nitems );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtGenListItem t *PtGenListFirstItem(
PtWidget t const *list );
Description:
This function returns a pointer to the first item in the list.
Returns:
A pointer to the first item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtGenListItem t *PtGenListGetCurrent(
PtWidget t const *widget );
Description:
This function returns a pointer to the current item.
Returns:
A pointer to the current item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
unsigned short *PtGenListGetSelIndexes(
PtWidget t *widget,
unsigned short *buffer );
Description:
This function fills the given buffer with the indexes of the currently
selected items. The first item in the widget has an index of 1, not 0.
If buffer is NULL, the function will allocate a buffer using malloc(),
and the buffer will be NULL-terminated (or zero-terminated). It’s the
caller’s responsibility to free the buffer when it’s no longer needed.
If buffer isn’t NULL, the function adds a NULL to the end only if there
are no selected items.
Returns:
A pointer to the buffer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenListGoto( PtWidget t *list,
PtGenListItem t *item );
Description:
This function sets the current item and (if necessary) the current
position so that the new current item is visible. If you pass item as
NULL, there won’t be a current item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenListHold( PtWidget t *widget );
Description:
This function is a list-aware version of the PtHold() function. After a
call to PtGenListHold(), the PtGenListDamageItem() function simply
sets the Pt LIST ITEM DAMAGED flag in the item instead of calling
PtDamageExtent().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtGenListRelease()
Synopsis:
int PtGenListItemIndex(
PtWidget t const *list,
PtGenListItem t const *item );
Description:
This function calculates the index of the given item within the list.
The index of the first item is 1.
Returns:
The index of the given item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtGenListItem t *PtGenListItemRealloc(
PtGenListItem t *item,
PtWidget t *list,
size t size );
Description:
This function isn’t used by the PtGenList widget itself. It may be
used to reallocate memory if the item was allocated using malloc().
The given size should include the size of the PtGenListItem t
structure. If the item is moved to a different address by the realloc()
function, PtGenListItemRealloc() will repair the list links.
Returns:
A pointer to the reallocated item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtGenListItem t *PtGenListLastItem(
PtWidget t const *list );
Description:
This function returns a pointer to the last item in the list.
Returns:
A pointer to the last item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenListLockItem( PtWidget t *list,
PtGenListItem t *item );
Description:
Use this function if the size field of a list item must be changed. A call
to PtGenListLockItem() is needed first to save the old size of the item
before the item can be modified. The PtGenListUnlockItem() function
should be called last to update and resize or redisplay the widget if
necessary.
☞ Only one item per widget can be locked at a time. If you resize a large
number of items, set all sizes and then call PtGenListResize().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenListRelease( PtWidget t *widget );
Description:
This function is a list-aware version of PtRelease().
After a call to PtGenListHold(), PtGenListDamageItem() simply sets
the Pt LIST ITEM DAMAGED flag in the item instead of calling
PtDamageExtent().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtGenListHold()
Synopsis:
PtGenListItem t *PtGenListRemoveItems(
PtWidget t *list,
PtGenListItem t *first,
PtGenListItem t *last );
Description:
This function removes the given sublist list from the PtGenList
widget. If first or last is a NULL pointer, the first or last items of the
entire list will be used. Both arguments may point to the same item,
but last must not precede first in the list.
The function returns the first removed item (or NULL if the list was
empty). The function inserts NULL in the next field of the last
removed item and the prev field of the first removed item. This
ensures the returned value (if not NULL) will always point to the first
item of a NULL-terminated, double-linked list. No other fields in any
of the removed items are modified.
If the current item is removed, there won’t be a current item on the list
unless the selection mode is Pt SELECTION MODE RANGE and only
part of the selected range is removed. In this case, the current item is
set to the first or last of the remaining selected items.
Returns:
The first removed item; NULL if the list was empty.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
continued. . .
Safety
Thread No
Synopsis:
void PtGenListResize( PtWidget t *widget );
Description:
This function resizes the given list widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtGenListLockItem(), PtGenListUnlockItem()
Synopsis:
void PtGenListSelect( PtWidget t *widget,
PtGenListItem t *item );
Description:
This function selects the given item in the list.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtGenListItem t **PtGenListSelectedItems(
PtWidget t *widget,
PtGenListItem t **buffer );
Description:
This function fills the given buffer with pointers to the currently
selected items.
If buffer is NULL, the function will allocate a buffer using malloc(),
and the buffer will be NULL-terminated (or zero-terminated). It’s the
caller’s responsibility to free the buffer when it’s no longer needed.
If buffer isn’t NULL, the function adds a NULL to the end only if there
are no selected items.
Returns:
A pointer to the buffer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
unsigned PtGenListSetGflags( PtWidget t *widget,
unsigned value,
unsigned mask );
Description:
This function modifies the gflags field of the widget. The bits defined
by mask will be set to the value defined by value.
Returns:
The old value of gflags.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtGenListSetSelIndexes(
PtWidget t *widget,
const unsigned short *buffer
int count );
Description:
This function lets you set the selection indexes. It assumes that buffer
points to a sorted array of indexes. The first item in the widget has an
index of 1, not 0.
The function returns the number of items that have been actually
selected, which may be smaller than count if the array isn’t sorted or
contains duplicate or out-of-range indexes.
Returns:
The number of items actually selected.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenListShow( PtWidget t *list,
PtGenListItem t *item );
Description:
This function sets the current position so that the given item is visible.
If you pass item as NULL, the function will do nothing. This allows
you to do something like this:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenListUnlockItem( PtWidget t *list,
PtGenListItem t *item );
Description:
Use this function if the size field of a list item must be changed. A call
to PtGenListLockItem() is needed first to save the old size of the item
before the item can be modified. The PtGenListUnlockItem() function
should be called last to update and resize or redisplay the widget if
necessary.
☞ Only one item per widget can be locked at a time. If you resize a large
number of items, set all sizes and then call PtGenListResize().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenListUnselect( PtWidget t *widget,
PtGenListItem t *item );
Description:
This function unselects the given item. PtGenListUnselect() has no
effect in the Pt SELECTION MODE RANGE selection mode.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtSuperClassGenListDraw(
PtWidgetClassRef t *cref ,
PtWidget t *widget,
PtGenListItem t *item,
unsigned index,
unsigned nitems,
PhRect t *where );
Description:
This function can be used to invoke the List Draw method of the class
defined by cref .
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtWidget t *PtSuperClassGenListInflate(
PtWidgetClassRef t *cref ,
PtWidget t *wgt,
PtWidget t *parent,
PtGenListItem t *item,
unsigned index,
int column,
PhArea t *area );
Description:
This function can be used to invoke the List Inflate method of the
class defined by cref .
Returns:
A widget pointer to the balloon instance created by this function.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtSuperClassGenListKey(
PtWidgetClassRef t *cref ,
PtWidget t *wgt,
PhEvent t *ev,
PhKeyEvent t *kev,
PtGenListItem t *newcur,
unsigned newpos );
Description:
This function can be used to invoke the List Key method of the class
defined by cref .
Returns:
A nonzero value if the key event was consumed, 0 otherwise.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtSuperClassGenListMouse(
PtWidgetClassRef t *cref ,
PtWidget t *wgt,
PtGenListItem t *item,
unsigned index,
PhPoint t *where,
PhEvent t *ev );
Description:
This function can be used to invoke the List Mouse method of the
class defined by cref .
Returns:
A nonzero value if the event was consumed, 0 otherwise.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtSuperClassGenListSelect(
PtWidgetClassRef t *cref ,
PtWidget t *wgt,
PtGenListItem t *item,
int pos,
int nitems,
int subtype,
PhEvent t *ev );
Description:
This function can be used to invoke the List Select method of the class
defined by cref .
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
In this chapter. . .
Overview 189
Convenience functions 192
PtGenTreeAddAfter() 195
PtGenTreeAddFirst() 196
PtGenTreeAllItems() 197
PtGenTreeClearSelection() 198
PtGenTreeCollapse() 199
PtGenTreeDamageItem() 200
PtGenTreeExpand() 201
PtGenTreeExpandParents() 202
PtGenTreeFreeAllItems() 203
PtGenTreeFreeItems() 204
PtGenTreeGetCurrent() 205
PtGenTreeGetSelIndexes() 206
PtGenTreeGoto() 207
PtGenTreeItemIndex() 208
PtGenTreeItemRealloc() 209
PtGenTreeItemResize() 210
PtGenTreeRemoveChildren() 211
PtGenTreeRemoveItem() 212
PtGenTreeRemoveList() 213
PtGenTreeResize() 214
PtGenTreeRootItem() 215
PtGenTreeSelect() 216
PtGenTreeSelectedItems() 217
PtGenTreeSetSelIndexes() 218
PtGenTreeShow() 219
PtGenTreeUnselect() 220
PtGenTreeUnselectNonBrothers() 221
PtSuperClassGenTreeDrawItem() 222
PtSuperClassGenTreeItemState() 223
Overview
The PtGenTree class is a subclass of PtGenList. You can use a
PtGenTree widget to display a hierarchy of items as lists in a tree.
When an item in the hierarchy has an item or list of items below it,
that item can be expanded. An expanded item drops a list to reveal all
items in the next level below. An expanded item can be collapsed.
When an expandable item is collapsed, the list rolls up and its items
are concealed. An item can be marked as expandable even if it doesn’t
have a list of items below it — you can add the list of items just
before the expandable item is expanded.
Any PtGenTree widget can contain multiple items at the root level,
which contains the first level of items to display. Root-level items
have no other items/levels above them — they represent the top of the
hierarchy.
A child class of PtGenTree isn’t supposed to define a List Draw
method. Instead, it should define a Tree Draw Item method that will
be called by the List Draw method of PtGenTree.
Item structure
The item structure used by PtGenTree is defined as follows:
typedef struct Pt gentree item {
PtGenListItem t list;
struct Pt gentree item *father, *son, *brother;
PhDim t dim;
}
PtGenTreeItem t;
dim The size of the item, excluding the tree ornaments (lines and
button).
When an item is added to the widget, the widget calculates
item->list.size based on the size specified in item->dim, the
minimum height of the item, and the item’s position in the
tree. The height of an item in a tree widget is always an even
number of pixels — if you specify an odd number for the
height in the dim field, a gap of at least one pixel will be
displayed between the current item and any other item
directly below.
Methods
Tree Draw Item method
The List Draw method calls the Tree Draw Item method with the
following arguments:
PtGenTreeWidget t *widget
The widget pointer.
PtGenTreeItem t *item
A pointer to the item that needs to be redrawn.
PhRect t const *where
The extent of the item.
PtGenTreeWidget t *widget
The widget pointer.
PtGenTreeItem t *item
A pointer to the item that is being collapsed or
expanded.
PhEvent t *event
The event argument to PtGenTreeExpand() or
PtGenTreeCollapse().
actual expansion. After the function returns, the widget will display a
list of items in the expanded branch.
If an item in the list has its Pt TREE ITEM EXPANDED flag set, the
items below will be displayed too. The Tree Item State method can
return a value other than Pt CONTINUE to prevent expansion —
PtGenTreeExpand() returns this value.
If reason is Pt TREE COLLAPSING, the item has been collapsed. Its
branches are concealed and the Tree Item State method can free the
associated items.
Convenience functions
The PtGenTree class defines the following convenience functions:
PtGenTreeAddAfter()
Add items after a given item.
PtGenTreeAddFirst()
Add items in front of any existing items.
PtGenTreeAllItems()
Get pointers to all the items in the tree.
PtGenTreeClearSelection()
Clear the selection.
PtGenTreeCollapse()
Collapse a subtree.
PtGenTreeDamageItem()
Redraw an item when its data has changed.
PtGenTreeExpand()
Expand a given subtree.
PtGenTreeExpandParents()
Expand any collapsed ancestors of a given item.
PtGenTreeFreeAllItems()
Free all the items in a tree.
PtGenTreeFreeItems()
Free the items in a subtree.
PtGenTreeGetCurrent()
Get a pointer to the current item.
PtGenTreeGetSelIndexes()
Get the indexes of the selected items.
PtGenTreeGoto()
Set the current item and position so that a given item is visible.
PtGenTreeItemIndex()
Calculate the index of a given item.
PtGenTreeItemRealloc()
Reallocate an item.
PtGenTreeItemResize()
Resize an item.
PtGenTreeRemoveChildren()
Unlink all the children of a given item.
PtGenTreeRemoveItem()
Remove a given item and its children from its parents and
siblings.
PtGenTreeRemoveList()
Remove a given items and its siblings from their parent.
PtGenTreeResize()
Resize many items.
PtGenTreeRootItem()
Get a pointer to the first root item.
PtGenTreeSelect()
Select a given item.
PtGenTreeSelectedItems()
Get pointers to the selected items.
PtGenTreeSetSelIndexes()
Set the selection indexes.
PtGenTreeShow()
Set the current position so that a given item is visible.
PtGenTreeUnselect()
Unselect a given item.
PtGenTreeUnselectNonBrothers()
Unselect all items that aren’t siblings of a given item.
PtSuperClassGenTreeDrawItem()
Invoke the Tree Draw Item method of a given superclass.
PtSuperClassGenTreeItemState()
Invoke the Tree Item State method of a superclass.
Synopsis:
void PtGenTreeAddAfter( PtWidget t *tree,
PtGenTreeItem t *items,
PtGenTreeItem t *brother );
Description:
This function inserts a list of trees linked with the brother field.
PtGenTreeAddAfter() assumes that items points to a list of trees. The
tree variable points to a PtGenTree widget. The new items are added
to the specified tree below the specified brother.
This function may be called with a NULL tree argument, as long as
brother points to an item that isn’t attached to any tree widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenTreeAddFirst( PtWidget t *tree,
PtGenTreeItem t *item,
PtGenTreeItem t *parent );
Description:
This function adds a list of trees linked with the brother field. The
parent argument identifies the parent item for the added items. The
new items are added in front of any existing children of the parent
item.
The parent argument may also be NULL, in which case item is added
at the root level of the tree before any existing items at the root level.
This function may be called with a NULL tree argument, as long as
parent points to an item that isn’t attached to any tree widget.
PtGenTreeAddFirst() automatically sets the
Pt TREE ITEM EXPANDABLE flag in the parent item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtGenTreeItem t **PtGenTreeAllItems(
PtWidget t *widget,
PtGenTreeItem t **buffer );
Description:
This function fills a buffer with pointers to all items in the widget. If
buffer is NULL, the function allocates a buffer using malloc() and the
buffer is NULL-terminated. If buffer isn’t NULL, the function doesn’t
add a NULL at the end.
Returns:
A pointer to the buffer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenTreeClearSelection( PtWidget t *widget );
Description:
This function clears the selection.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenTreeCollapse( PtWidget t *tree,
PtGenTreeItem t *item,
PhEvent t *event );
Description:
This function collapses the given subtree item. The tree argument
must point to the tree that contains the item or be NULL if the item
doesn’t belong to any tree.
If tree isn’t NULL, the Tree Item State method of that widget is called.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenTreeDamageItem( PtWidget t *tree,
PtGenTreeItem t *item );
Description:
Call this function to redraw the given item when its data has changed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtGenTreeExpand( PtWidget t *tree,
PtGenTreeItem t *item,
PhEvent t *event );
Description:
This function expands the given subtree item. The tree argument must
point to the tree that contains the item or be NULL if the item doesn’t
belong to any tree.
If tree isn’t NULL, the Tree Item State method of that widget is called.
If it returns a value other than Pt CONTINUE, the item isn’t expanded
and PtGenTreeExpand() returns the same value.
Returns:
The value returned by the Tree Item State method.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtGenTreeExpandParents( PtWidget t *tree,
PtGenTreeItem t *item,
PhEvent t *event );
Description:
If any ancestors of the given item are collapsed, this function attempts
to expand them.
Returns:
The value returned by the Tree Item State method.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenTreeFreeAllItems( PtWidget t *tree );
Description:
This function unlinks and frees all items in the tree widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenTreeFreeItems( PtGenTreeItem t *item );
Description:
This function frees the subtree item, together with its siblings and
their children. The function assumes that the items don’t belong to
any tree. (Use PtGenTreeRemoveItem(), PtGenTreeRemoveList(), or
PtGenTreeRemoveChildren() to remove the subtree before freeing it.)
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtGenTreeItem t *PtGenTreeGetCurrent(
const PtWidget t *widget );
Description:
This function returns a pointer to the current item.
Returns:
A pointer to the current item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
unsigned short *PtGenTreeGetSelIndexes(
PtWidget t *widget,
unsigned short *buffer );
Description:
This function fills a buffer with indexes of all the selected items in the
widget. The first item in the widget has an index of 1, not 0.
If buffer is NULL, the function will allocate a buffer using malloc(),
and the buffer will be zero-terminated.
If buffer isn’t NULL, the function adds a NULL to the end only if there
are no selected items.
Returns:
A pointer to the buffer containing the indexes.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtGenTreeGoto( PtWidget t *tree,
PtGenTreeItem t *item );
Description:
This function sets the current item and (if necessary) the current
position so that the new current item is visible. If you pass item as
NULL, there will be no current item.
PtGenTreeGoto() can be called with an item whose ancestor is
collapsed, in which case the ancestor is expanded.
Returns:
The value returned by the Tree Item State method.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtGenTreeItemIndex(
const PtWidget t *tree,
const PtGenTreeTtem t *item );
Description:
This function calculates the index of the given item within the tree.
The index of the first item is 1.
Returns:
The index of the item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtGenTreeItem t *PtGenTreeItemRealloc(
PtGenTreeItem t *item,
PtWidget t *tree,
size t newsize );
Description:
This function should be used to reallocate an item. It will repair any
links damaged if the realloc() function moves the item to a different
address. The tree argument must point to the tree that contains the
item or be NULL if the item doesn’t belong to any tree.
Returns:
A pointer to the reallocated item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenTreeItemResize( PtGenTreeItem t *item,
PtWidget t *tree );
Description:
This function is used to resize one item. It should be called after the
dimensions of an item (item->dim) have been changed. You don’t
need to call this function if item doesn’t belong to any tree or if a
subtree containing the item is collapsed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtGenTreeItem t *PtGenTreeRemoveChildren(
PtGenTreeItem t *item );
Description:
This function unlinks all the children of the given item and returns the
pointer to the first of them. You can then give the pointer to
PtGenTreeFreeItems().
This function doesn’t collapse the item. If the children are visible,
NULL is returned. Call PtGenTreeCollapse() before
PtGenTreeRemoveItem() to make sure the item is collapsed.
Returns:
A pointer to the first unlinked child.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenTreeRemoveItem( PtWidget t *tree,
PtGenTreeItem t *item );
Description:
This function unlinks the given item (together with its children) from
its parent and brothers (if any) and sets item->parent and
item->brother to NULL. The tree argument must point to the
PtGenTree widget containing item or be NULL if item doesn’t
belong to any tree.
If tree is NULL and item has no parent but has a previous sibling, then
PtGenTreeRemoveItem() isn’t able to find the previous sibling and
unlinks item from its sibling. The function does nothing if
item->parent and tree are NULL.
PtGenTreeRemoveItem() never clears the
Pt TREE ITEM EXPANDABLE flag in the item’s parent.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenTreeRemoveList( PtWidget t *tree,
PtGenTreeItem t *first );
Description:
This function unlinks the item first and its siblings (together with their
children) from their parent (and previous sibling) and sets their parent
fields to NULL. The tree argument must point to the widget that
contains the items or be NULL if the items don’t belong to any tree.
If tree is NULL and first has no parent but has a previous sibling,
PtGenTreeRemoveList() can’t find the previous sibling and can’t
unlink first from its previous sibling.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenTreeResize( PtWidget t *widget );
Description:
This function is used to resize many items. You should call it after the
size field of a number of tree items has changed — modify item->dim
directly in all items, then call PtGenTreeResize() once.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtGenTreeItem t *PtGenTreeRootItem(
PtWidget t const *tree );
Description:
This function returns a pointer to the first root item of the tree.
Returns:
A pointer to the first root item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenTreeSelect( PtWidget t *widget,
PtGenTreeItem t *item );
Description:
This function selects the given item. As with other PtGenTree*()
functions, the tree argument should be set to NULL if item doesn’t
belong to a widget.
If tree isn’t NULL and none of item’s ancestors is collapsed,
PtGenListSelect() is called. If tree is NULL or some of the ancestors
of the item are collapsed, PtGenTreeSelect() simply sets the
Pt LIST ITEM SELECTED flag in the item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtGenTreeItem t **PtGenTreeSelectedItems(
PtWidget t *widget,
PtGenTreeItem t **buffer );
Description:
This function fills a buffer with pointers to the currently selected
items. If buffer is NULL, the function allocates a buffer using
malloc(), and the buffer is NULL-terminated.
If buffer isn’t NULL, the function adds a NULL to the end only if there
are no selected items.
Returns:
A pointer to the buffer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtGenTreeSetSelIndexes(
PtWidget t *widget,
unsigned short const *buffer,
int count );
Description:
This function sets the selection indexes. It assumes that buffer points
to a sorted array of indexes. The first item in the widget has an index
of 1, not 0.
The function returns the number of items that have been actually
selected, which may be smaller than count if the array isn’t sorted or
contains duplicate or out-of-range indexes.
When the selection mode is Pt SELECTION MODE RANGE, only the
first index and the count are used.
Returns:
The number of items actually selected.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtGenTreeShow( PtWidget t *widget,
PtGenTreeItem t *item );
Description:
This function sets the current position so that the given item is visible.
If you pass item as NULL, the function does nothing. This allows you
to do something like this:
Returns:
The value returned by the Tree Item State method.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenTreeUnselect( PtWidget t *widget,
PtGenTreeItem t *item );
Description:
This function unselects the given item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtGenTreeUnselectNonBrothers(
PtWidget t *wgt,
PtGenTreeItem t *item );
Description:
This function deselects all the items that aren’t siblings of the given
item. If you pass item as NULL, the current item is used.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtSuperClassGenTreeDrawItem(
PtWidgetClassRef t *cref ,
PtWidget t *wgt,
PtGenTreeItem t *item,
PhRect t const *where,
int lmargin,
int rmargin );
Description:
This function invokes the Tree Draw Item method of the class defined
by cref .
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtSuperClassGenTreeItemState(
PtWidgetClassRef t *cref ,
PtWidget t *wgt,
PtGenTreeItem t *item,
PhEvent t *event,
int reason );
Description:
This function invokes the Tree Item State method of the class defined
by cref .
Returns:
The value returned by the specified Tree Item State method.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
In this chapter. . .
Widget design considerations 227
Creating an icon for the PhAB widget bar 228
Creating a widget description table 230
Adding the widget palette file to PhAB 241
☞ Since PhAB hasn’t been linked to include your custom widget, PhAB
won’t be able to display it. Instead, PhAB will display a default
widget (PtBasic or PtContainer) in its place for visual feedback
and dimensions.
The Control Panel will let you access all the resources and callbacks
you defined in the widget description table for your custom widget,
but they won’t take effect until you actually run the application.
¯ Single-value resources
Single-value resources
PhAB has builtin editors for handling certain types of single-value
resources. It also provides multiple-value editors for some resource
types. If you design your resources to use the types supported by
PhAB, developers will be able to use the widget in PhAB easily. If
you define resources that have no associated editor in PhAB,
developers will be able to set and use these resources only through
application code. The list of currently supported types can be found in
the section on “Creating a widget description table.”
☞ If you’re using Watcom 10.6 or later, the MYOBJ object list will be
defined in the indOfiles file.
w=class name
Example:
w=ShadowedBox
h=number of levels
highest class name
[next highest class name]
.
.
.
custom widget class name
Example:
h=3
PtWidget
PtBasic
ShadowedBox
Example:
r=SBW SHADOW COLOR,Shadow Color,5000000,0,1,crgb,0x0
r=Pt ARG HORIZONTAL ALIGNMENT,Horizontal Alignment,3000,0,1,short,2,3
Pt LEFT,0
Pt RIGHT,1
Pt CENTER,2
☞ Don’t create resource entries for the Pt ARG POS and Pt ARG DIM
resources. All widgets must support these, so PhAB handles them
internally.
default value This is the default value in the widget code itself.
It’s very important for this value to exactly match
the real default value in the widget, because PhAB
doesn’t generate resource entries in the module
files if it seems the resource matches the default
value. This keeps the size of the module file to a
minimum. If the default value you specify doesn’t
match, the widget may not behave as expected
because a required resource setting will be missing
from the module file.
description,value
where description is the text that PhAB is to display in the editor, and
value is the corresponding value.
Pointer-to-function resources
For a resource that’s a pointer to a function (i.e. type is code),
additional info specifies the number of following lines that define the
function’s prototype. The prototype should contain an @ in place of
the function name, but no terminating semicolon.
The default value specifies the code that will be used for the function
body whenever PhAB generates a function for the resource. If the
code will fit on the line and doesn’t contain any commas, you can
specify it directly as default value. Otherwise, put the code on the
lines that follow the function prototype, and set default value to be
the number of lines of code.
Here are some examples:
r=ARG SIMPLEFUNCTION,A function,5000001,5000001,1,return 0;,1
int @( void )
)
return
PtGenListCreateTextBalloon(
widget, parent,
PtGenListSetColumnBalloon( area, column ),
item, coln, font
);
Example:
c=Pt CB ACTIVATE,Activate,2009,0
k=Pt CB HOTKEY,Hotkey,1010,0
e=Pt CB RAW,Raw Event,1011,0
i=widget[,from[,to]]
n=widget[,from[,to]]
b=Container
t=number
Example:
t=2
The type definition tells PhAB how this widget should be created. For
example, if t=1, PhAB automatically creates the widget as soon as
the user clicks in the module. This is because type 1 indicates the
widget has a preset size. A value of t=2 means the user can drag out
the size when creating the widget.
Valid values for number range from 1 through 6 and have the
following meanings:
Example:
s=0xe914,0xe914
This setting defines the look of the cursor when the widget is being
created in PhAB. The value you choose for a cursor style setting (s=)
will depend on the value you specify for the create type setting (t=).
For consistency with other widgets in PhAB, we recommend that you
assign cursor style values according to the table below:
definition 2
.
.
.
definition n
¯ resource number
¯ resource type
¯ resource value
For example:
// Resizable example.
d=ShadowedBox,1
1005
dim
1,1
// Preset example.
d=PtPrintSel,1
1005
dim
418,285
!
CAUTION: You must always give a widget a default value and
starting dimension. If you don’t, you’ll get unexpected results.
If t=1 or t=4, set the dim resource to the preset size. If the value is
anything else, set dim to 1,1. The dim resource is defined as
“width,height” in pixels.
3 Add a line for your new palette to the palette definition file,
palette.def. The syntax of the entry is:
p=palette file name,description
(e.g. p=mywidgets,My Custom Widgets).
PtAddWidgetData()
Add data to the widget data chain
PtAnchorWidget()
Anchor the provided widget
PtApplyAnchors()
Anchor a container and its children
PtAttemptResize()
Adjust the size of a widget
PtCalcAnchorOffsets()
Calculate anchor offsets
PtChildBoundingBox()
Calculate a widget’s canvas and its children’s
bounding boxes
PtCompoundRedirect()
Redirect widgets to a parent
PtContainerChildRedirect()
Set the pointer to the child-redirector function
PtContainerDeregister()
Deregister a container from its parent
PtContainerRegister()
Register a container with its parent
PtCoreChangeRegion()
Determine if a region is required
PtCreateWidgetClass()
Create a widget class
PtDamageExposed()
Damage the specified widgets
PtDestroyCallbackList()
Free the specified callbacks
PtDestroyHotkeyCallbacks()
Free the specified hotkey callbacks
PtDestroyRawCallbacks()
Free the specified raw callbacks
PtFindNextWidgetData()
Find the next appropriate data block
PtFindResourceRecord()
Find the record associated with a resource
PtFindWidgetData()
Find the first data block of a given type and subtype
PtGetAnchoredExtent()
Calculate a new anchor rectangle
PtInvokeCallbackList()
Invoke a callback list
PtInvokeResizeCallbacks()
Invoke the resize callbacks of the specified
container
PtMoveResizeWidget()
Synchronize a widget’s extent
PtRemoveWidgetData()
Remove data from the widget data chain
PtResizePolicy()
Determine whether a widget has a resize policy
PtSetExtentFromArea()
Calculate the extent of a widget
PtSetStruct() Set the specified resource
PtSetValue() Set the value of a resource using mod f
PtSuperClassCalcOpaque()
Call the Calc Opaque Rect method of the specified
superclass
PtSuperClassChildCreated()
Invoke a Child Created method
PtSuperClassChildDestroyed()
Invoke a Child Destroyed method
PtSuperClassChildGettingFocus()
Invoke a Child Getting Focus method
PtSuperClassChildGettingResources()
Invoke a Child Getting Resources method
PtSuperClassChildLosingFocus()
Invoke a Child Losing Focus method
PtSuperClassChildMovedResized()
Invoke a Child Moved/Resized method
PtSuperClassChildRealized()
Invoke a Child Realized method
PtSuperClassChildSettingResources()
Invoke a Child Setting Resources method
PtSuperClassChildUnrealized()
Invoke a Child Unrealized method
PtSuperClassConnect(), PtSuperClassConnectFrom()
Invoke the Connection method of the specified
widget class
PtSuperClassDraw()
Invoke the Draw method of the specified superclass
PtSuperClassExtent()
Invoke the Extent method of the specified
superclass
PtSuperClassGetResources()
Get the specified resource
PtSuperClassGotFocus()
Invoke the Got Focus method of the specified
superclass
PtSuperClassInit(), PtSuperClassInitFrom()
Invoke the Initialize method of the specified widget
class
PtSuperClassLostFocus()
Invoke the Lost Focus method of the specified
superclass
PtSuperClassRawEvent(), PtSuperClassRawEventFrom()
Invoke the raw callback list of the specified widget
class
PtSuperClassRealized()
Invoke the Realization method of the specified
widget class
PtSuperClassSetResources()
Set resources
PtUpdateVisibility()
Tell the widget library about a change in visibility
PtWidgetAbove()
Identify the position of a widget in the hierarchy
relative to another widget
Synopsis:
int PtAddWidgetData( PtWidget t *widget,
PtWidgetClassRef t *type,
long subtype,
void *data );
Description:
This function adds a piece of data to the widget data chain. The data
provided must be in a block of memory allocated by malloc(). This
data can be retrieved by calling PtFindWidgetData() or
PtFindNextWidgetData().
The widget argument points to the widget whose chain the data
should be added to. The type is the class of the widget adding the
data. The subtype is used to discriminate between multiple blocks of
data added by the same widget class. The subtype shouldn’t be -1, as
this value has special meaning when searching for a specific block
within the widget data chain. The data argument is a pointer to the
data to be added to the widget data chain.
Returns:
0 on success; -1 if an error occurred (e.g. out of memory).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFindWidgetData(), PtFindNextWidgetData(),
PtRemoveWidgetData()
Synopsis:
void PtAnchorWidget( PtWidget t *widget );
Description:
This function anchors the provided widget. If the widget’s anchor
offsets have yet to be calculated, they’re calculated along with the
anchor offsets for all child containers. No other action takes place.
If the widget’s anchor offsets have been calculated, the widget and all
its children’s dimensions are adjusted to honor their anchor flags.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtApplyAnchors(), PtCalcAnchorOffsets()
Synopsis:
int PtApplyAnchors( PtWidget t *container );
Description:
This function performs any necessary anchoring on the provided
container widget and all its registered children.
Returns:
1 Successful completion.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAnchorWidget(), PtContainerDeregister(), PtContainerRegister()
Synopsis:
int PtAttemptResize( PtWidget t *widget,
PhRect t const *canvas,
PhRect t const *render );
Description:
This function adjusts the size of the widget based on the differences
between canvas and render and on the widget’s resize flags.
The widget’s actual size is modified (widget->area.size). If the resize
policy of the widget prevents PtAttemptResize() from adjusting the
widget’s size (i.e. the canvas won’t fit within the provided render
rectangle), PtAttemptResize() sets the Pt UCLIP bit of the widget’s
resize flags. If this bit is set, the widget’s Draw method should apply
clipping via PtClipAdd() prior to rendering its data.
Returns:
1 Successful completion.
0 No resize occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgExtentText(), PtChildBoundingBox(), PtClipAdd(),
PtClipRemove(), PtWidgetCanvas()
Synopsis:
void PtCalcAnchorOffsets( PtWidget t *container,
PhRect t const * anchor rect );
Description:
This function calculates the anchor offsets for the given container
widget based on its current anchor flags, its parent’s canvas rectangle,
and the provided anchor rect.
The container’s anchor offsets are calculated such that a subsequent
call to PtGetAnchoredExtent() yields a corrected new anchor rect
with respect to the canvas rectangle of the parent and the anchor flags
in effect.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAnchorWidget(), PtApplyAnchors(), PtGetAnchoredExtent()
Synopsis:
int PtCalcRegion( unsigned int *fields,
PtWidget t *widget,
PhRegion t *region,
PhRect t *rect );
Description:
This function determines whether or not the given widget needs a
region and stores information about the region in the structure pointed
to by region.
The fields argument specifies which fields of the structure pointed to
by region the function should fill in. For more information about the
fields, see PhRegionOpen() in the Photon Library Reference.
The rectangle for the region is stored in the structure pointed to by
rect.
Returns:
0 The widget doesn’t need a region.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRegionOpen()
Synopsis:
PhRect t *PtChildBoundingBox( PtWidget t *widget,
PhRect t *canvas,
PhRect t *render );
Description:
This function calculates the canvas of widget and finds the bounding
box of widget’s children relative to the origin of the parent’s position.
If the canvas parameter isn’t NULL, it’s set to the canvas rectangle of
the PtBasic-class level for the specified widget.
The render parameter is set to this bounding box and is also the
returned pointer. The render parameter must be provided.
Returns:
A pointer to the render rectangle.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtBasicWidgetCanvas(), PtSuperClassExtent()
Synopsis:
int PtClipAdd( PtWidget t *widget,
PhRect t *rect );
Description:
This function adds a clipping rectangle to the clipping stack. The
rectangle added to the clipping stack is the intersection of the last
rectangle on the stack and the provided rectangle rect.
Prior to entering a widget’s Draw method, the canvas rectangle
derived from the PtBasic-class level is pushed onto the clipping
stack. This prevents any children from drawing beyond the canvas of
the parent container.
A widget can, however, draw beyond its own canvas or extent unless
additional clipping is performed. PtAttemptResize() will set the
Pt UCLIP bit of a widget’s resize flags if the widget requires additional
clipping (to prevent it from drawing beyond its own canvas).
Returns:
The current level of stack clipping.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAttemptResize(), PtClipRemove(), PtWidgetCanvas()
Synopsis:
int PtClipRemove();
Description:
This function pops the last clipping rectangle off the clipping stack.
Returns:
The current level of stack clipping.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAttemptResize(), PtClipAdd(), PtWidgetCanvas()
Synopsis:
PtWidget t *PtCompoundRedirect(
PtWidget t *container,
PtWidgetClassRef t *child cref );
Description:
This function returns the parent of a compound widget, making the
compound widget seem like a simple widget (i.e. users can’t place
widgets inside container).
This is especially useful for rejecting widgets or redirecting widgets
to subordinate containers (e.g. PtScrollArea does this).
This redirector function can be added to a custom compound widget
by calling PtContainerChildRedirect().
Returns:
A pointer to the parent of the given compound widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerChildRedirect()
Synopsis:
int PtContainerChildRedirect(
PtWidget t *container,
PtWidget t *(*redirect)(
PtWidget t *container,
PtWidgetClassRef t *child class ref ));
Description:
This function sets the provided container’s child-redirector function
to the given redirect function. The child-redirector function is invoked
whenever a user attempts to create a widget within the immediate
child of container.
The container parameter in the callback must be a pointer to the
container itself. The child class ref pointer points to the child’s class
reference, which indicates what class of widget is being created.
The PtWidget t * return type of your redirector function will be
used as the ultimate parent of the newly created widget.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCompoundRedirect()
Synopsis:
void PtContainerDeregister( PtWidget t *container );
Description:
This function deregisters container from its parent. This prevents
container from being included in anchoring operations.
The deregister operation is done by PtContainer’s Unrealization
method. If you override PtContainer’s Unrealization method, you
should call PtContainerDeregister() to remove container from its
parent’s list of children before any anchoring is applied.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerRegister()
Synopsis:
void PtContainerRegister( PtWidget t *container );
Description:
This function registers container with its parent for anchoring.
Anchoring is done by PtContainer’s Extent method. If you override
this method and want to use PtContainer’s anchoring mechanism,
you must register each widget instance in your Extent method.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerDeregister()
Synopsis:
void PtCoreChangeRegion( unsigned int fields,
PtWidget t *widget );
Description:
This function examines the current state of widget with respect to
fields and determines if widget requires a region. If a region is
required, PtCoreChangeRegion() determines what attributes (e.g.
sensitivity) are required.
PtCoreChangeRegion() may call one of the following functions with
appropriate attributes:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRegionChange(), PhRegionOpen(), PhWindowChange()
Synopsis:
PtWidgetClass t *PtCreateWidgetClass(
PtWidgetClassRef t *superclass ref ,
unsigned int size,
unsigned int num args,
PtArg t const *args );
Description:
This function creates a new widget class based on superclass ref . If
the specified superclass hasn’t yet been created, it’s created now.
The arguments are as follows:
superclass ref
The class reference of the superclass this class is to be
a subclass of.
size The size of the new widget class. If this is 0, the size of
the superclass is used; if nonzero, it must be at least as
large as the superclass.
If the size parameter is zero, the new class is the same size as the
specified superclass. Otherwise size bytes are allocated for the new
class. The specified superclass is then copied into the newly allocated
class (inheritance). The version, resources, num resources, callbacks,
dflts f , connect f , init f , unrealize f , and destroy f members are
cleared because they shouldn’t be inherited.
Returns:
A pointer to the newly created class:
Examples:
This example is from the ShadowedBox sample widget.
//
// ShadowedBox class-creation function
//
PtWidgetClass t *PtCreateBasicClass( void )
{
static const PtResourceRec t resources[] =
{
{ SBW SHADOW COLOR, Pt CHANGE REDRAW, 0,
Pt ARG IS NUMBER( ShadowedBoxWidget, shadow color ) },
{ SBW SHADOW OFFSET, Pt CHANGE REDRAW, 0,
Pt ARG IS NUMBER( ShadowedBoxWidget, shadow offset ) }
};
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtDamageExposed( PtWidget t *widget,
PhTile t *tile );
Description:
This function damages the list of rectangles given in tile on the parent
of widget. The tile list should include rectangles relative to the
widget’s origin. The damage may extend beyond the extent of the
widget.
Examples:
To redraw a transparent widget due to a data change:
tile = PhGetTile();
PtWidgetExtent( widget, &tile->rect );
tile->next = NULL;
PtDamageExposed( widget, tile );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetTile()
Synopsis:
int PtDestroyCallbackList(
PtCallbackList t **cbp );
Description:
This function frees the entire callback list pointed to by cbp. The cbp
argument is set to NULL when PtDestroyCallbackList() is successful.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDestroyHotkeyCallbacks(), PtDestroyRawCallbacks()
Synopsis:
void PtDestroyHotkeyCallbacks( PtWidget t *widget );
Description:
This function frees all hotkey callbacks connected to widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDestroyCallbackList(), PtDestroyRawCallbacks()
Synopsis:
void PtDestroyRawCallbacks( PtWidget t *widget );
Description:
This function frees all raw callbacks connected to widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDestroyCallbackList(), PtDestroyHotkeyCallbacks()
Synopsis:
void * PtFindNextWidgetData(
PtWidget t *widget,
PtDataHdr t *data node,
PtWidgetClassRef t *type,
long subtype,
PtDataHdr t ** node )
Description:
This function (starting from data node) finds the next widget data
block that matches the type and subtype provided. If data node is
NULL, the first instance of data that matches the type and subtype
provided will be found. If type is NULL, any type will match. If
subtype is -1, any subtype will match.
If node is provided, it’s set to point to the widget data node that
contained the returned data, so you can continue the search from that
node.
Returns:
A void pointer to the widget data, or NULL if it wasn’t found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddWidgetData(), PtFindWidgetData(), PtRemoveWidgetData()
Synopsis:
PtResourceRec t const * PtFindResourceRecord(
long type,
PtWidgetClass t const *a class );
Description:
This function finds the resource record for the resource given by type
in the a class class or any of its superclasses. This function may be
used in your own Set Resource/Get Resource methods.
Returns:
A pointer to a resource record, or NULL if an error occurred.
Examples:
my label setcolor( PtWidget t *widget, PgColor t color )
{
PtResourceRec t *res rec;
PtArg t argt;
PtSetArg( &argt, Pt ARG COLOR, color, 0 );
// This should actually check for NULL failure
res rec = PtFindResourceRecord( Pt ARG COLOR,
PtLabel->wclass );
PtSetValue( widget, res rec, &argt );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSetValue()
Synopsis:
void * PtFindWidgetData(
PtWidget t *widget,
PtWidgetClassRef t *type,
long subtype,
PtDataHdr t ** node );
Description:
This function finds the first widget data block that matches the type
and subtype provided. If type is NULL, any type will match. If
subtype is -1, any subtype will match.
If node is provided, it’s set to point to the widget data node that
contained the returned data, so you can continue the search from that
node.
Returns:
A void pointer to the widget data, or NULL if it wasn’t found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddWidgetData(), PtFindNextWidgetData(),
PtRemoveWidgetData()
Synopsis:
int PtGetAnchoredExtent( PtWidget t *container,
PhRect t const *old anchor rect,
PhRect t *new anchor rect );
Description:
This function calculates a new anchor rectangle new anchor rect
using the canvas rectangle derived from the PtBasic-class level and
the anchor flags and offsets associated with container.
The anchor flags and anchor offsets are calculated by
PtCalcAnchorOffsets(). All parameters must be provided. The
new anchor rect argument is used only if PtGetAnchoredExtent()
returns a value of 1.
Returns:
0 An error occurred — the widget shouldn’t be anchored (i.e. it
isn’t a container widget); there’s no anchor flags set; or
new anchor rect == old anchor rect.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCalcAnchorOffsets()
Synopsis:
int PtGetStruct( char *base,
PtResourceRec t const *mod,
PtArg t *arg );
Description:
This function retrieves the resource specified by arg from the widget
at address base as described by mod.
If the value and len members of arg are non-NULL, they’re assumed
to contain the addresses of pointers of the type appropriate for the
resource. The pointers are set to point to the resource’s value in the
widget’s internal memory.
If either of the value and len members of arg is NULL, the retrieved
resources are stored in these members.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSetStruct(), PtSuperClassGetResources(),
PtSuperClassSetResources()
Synopsis:
int PtInvokeCallbackList( PtCallbackList t *cb list,
PtWidget t *widget,
PtCallbackInfo t *cbinfo );
Description:
This function invokes the provided callback list cb list.
The widget argument is passed as the first parameter to each callback
in the list. The cb data member of each item in the list is passed as
the second parameter. The cbinfo argument is passed to each callback
in the list as the third parameter.
Returns:
A return status from the callback list:
¯ Pt CONTINUE
¯ Pt HALT
¯ Pt END
If the returned status is Pt END, have your function consume the event
(i.e. return Pt END).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtInvokeResizeCallbacks( PtWidget t *container );
Description:
This function sets up a cbinfo structure and invokes the resize
callbacks attached to the specified container. If the provided
container widget isn’t a subclass of PtContainer, no action is
performed.
Returns:
0 Successful completion.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtMoveResizeWidget( PtWidget t *widget,
unsigned blit );
Description:
This function synchronizes a widget’s extent with its position and size
resources. Any region adjustments, blits, or damages are performed
automatically.
This function calls the widget’s Extent method to calculate its new
extent. The value of blit can be:
0 No blit.
Pt BLIT FORCE
Always blit (may cause unexpected effects).
Returns:
0 No action.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtRemoveWidgetData(
PtWidget t *widget,
PtWidgetClassRef t *type,
long subtype );
Description:
This function removes a piece of data from the widget data chain and
frees the memory allocated for the data.
The widget argument points to the widget whose chain the data
should be removed from. The type is the class of the widget removing
the data. The subtype is used to discriminate between multiple blocks
of data added by the same widget class.
Returns:
0 if the data was found and released; -1 if it couldn’t be found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddWidgetData(), PtFindWidgetData(), PtFindNextWidgetData()
Synopsis:
int PtResizePolicy( PtWidget t *widget );
Description:
This function determines whether a resize policy is currently in effect
for the specified widget.
Returns:
0 No resize policy.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PhRect t * PtSetExtentFromArea(
PtWidget t *widget,
PhArea t const *area,
PhRect t *extent );
Description:
This function calculates the extent rectangle of widget and places the
result in extent. The extent is calculated based on area and the
widget’s borders only (i.e. no anchoring or resize policy is enforced).
Returns:
A pointer to the extent rectangle.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtSetStruct( char *base,
PtResourceRec t const *mod,
PtArg t const *arg );
Description:
This function sets the resource specified by arg on the widget at
address base in the manner described by mod. The arg argument
indicates which resource to modify as well as the value to modify that
resource with. The mod argument is a resource record that describes
the type of resource being modified.
Unlike PtSetValue(), PtSetStruct() doesn’t examine the mod f
member of mod (e.g. for a Pt CHANGE RESIZE flag). It sets the
appropriate structure members based on mod->value and mod->len.
If you want to do the extra widget processing as well as set the
appropriate structure members, use PtSetValue(). For a cleaner
solution, consider using PtSuperClassSetResources().
Returns:
0 No change.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtGetStruct(), PtSetValue(), PtSuperClassGetResources(),
PtSuperClassSetResources()
Synopsis:
int PtSetValue( PtWidget t *widget,
PtResourceRec t const *mod,
PtArg t const *args );
Description:
This function sets the value of a particular resource using the
information provided in mod including the mod f member.
Consider calling PtSuperClassSetResources() for a cleaner solution.
To set structure members without any further action, use PtSetStruct().
Returns:
0 Nothing has changed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSetStruct(), PtSuperClassSetResources()
Synopsis:
void PtSuperClassCalcOpaque(
PtWidgetClassRef t *cref ,
PtWidget t *widget );
Description:
This function calls the Calc Opaque Rect method of the specified
superclass. Typically, this function calculates the rectangle
representing the portion of the widget that isn’t transparent and sets or
clears the widget’s Pt OPAQUE flag.
The opaque rectangle for a widget is usually its canvas rectangle or
the canvas rectangle derived from its PtBasic-class level.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtSuperClassChildCreated(
PtWidgetClassRef t *cref ,
PtWidget t *widget,
PtWidget t *child );
Description:
This function invokes the Child Created method of the container class
specified by cref . The widget argument is a pointer to the widget
whose Child Created method is being invoked. The child argument is
a pointer to the newly created widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtSuperClassChildDestroyed(
PtWidgetClassRef t *cref ,
PtWidget t *widget,
PtWidget t *child );
Description:
This function invokes the Child Destroyed method of the container
class specified by cref . The widget argument is a pointer to the widget
whose Child Destroyed method is being invoked. The child argument
is a pointer to the widget that has just been destroyed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtSuperClassChildGettingFocus(
PtWidgetClassRef t *cref ,
PtWidget t *widget,
PtWidget t *child,
PhEvent t *event );
Description:
This function invokes the Child Getting Focus method of the
container class specified by cref . The widget argument is a pointer to
the widget whose child is getting focus. The child argument is a
pointer to the widget that’s getting focus. The event argument is the
event that’s causing the change in focus.
Returns:
Pt END The container prevented the child from having
focus.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Description:
This function invokes the Child Getting Resources method of the
container class specified by cref . The widget argument is a pointer to
the widget whose child is having one of its resources set. The child
argument is a pointer to the widget that’s having one of its resources
set. The argt argument describes the resource being set and what its
new value will be.
Returns:
Pt END The container prevented the resource query from
receiving further processing — the container may
have already satisfied the query.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtSuperClassChildLosingFocus(
PtWidgetClassRef t *cref ,
PtWidget t *widget,
PtWidget t *child,
PhEvent t *event );
Description:
This function invokes the Child Losing Focus method of the container
class specified by cref . The widget argument is a pointer to the widget
whose child is losing focus. The child argument is a pointer to the
widget that’s losing focus. The event argument is the event that’s
causing the change in focus.
Returns:
Pt END The container prevented the child from losing
focus.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtSuperClassChildMovedResized(
PtWidgetClassRef t *cref ,
PtWidget t *widget,
PtWidget t *child,
PhArea t *current area,
PhRect t *current extent,
PhArea t *old area,
PhRect t *old extent );
Description:
This function invokes the Child Moved Resized method of the
container class specified by cref . The widget argument is a pointer to
the widget whose child was resized. The child argument is a pointer
to the widget that was resized.
The current area argument is the widget’s current area (after the
resize). The current extent argument is the widget’s current extent
(after the resize).
The old area argument is the widget’s old area (before the resize).
The old extent argument is the widget’s old extent (before the resize).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtSuperClassChildRealized(
PtWidgetClassRef t *cref ,
PtWidget t *widget,
PtWidget t *child );
Description:
This function invokes the Child Realized method of the container
class specified by cref . The widget argument is a pointer to the widget
whose Child Realized method is being invoked. The child argument is
a pointer to the widget that has been realized.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Description:
This function invokes the Child Setting Resources method of the
container class specified by cref . The widget argument is a pointer to
the widget whose child is having one of its resources set. The child
argument is a pointer to the widget that’s having one of its resources
set. The argt argument describes the resource being set and what its
new value will be.
Returns:
Pt END The container prevented any further changes to the
resource — the container may have already
applied the change to the child.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtSuperClassChildUnrealized(
PtWidgetClassRef t *cref ,
PtWidget t *widget,
PtWidget t *child );
Description:
This function invokes the Child Unrealized method of the container
class specified by cref . The widget argument is a pointer to the widget
whose Child Unrealized method is being invoked. The child argument
is a pointer to the widget that has just been unrealized.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
int PtSuperClassConnectFrom(
PtWidgetClassRef t *cref ,
PtWidget t *widget );
Description:
PtSuperClassConnect() invokes the Connection method of the
specified widget class cref .
PtSuperClassConnectFrom() calls the Connection methods of all
superclasses starting with the superclass specified by cref .
Returns:
Pt CONTINUE
The connection callback chain can continue
Pt HALT or Pt END
The connection callbacks should stop.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtSuperClassDraw( PtWidgetClassRef t *wc ref ,
PtWidget t *widget,
PhTile t const *damage );
Description:
This function invokes the Draw method of the specified superclass
wc ref . Use this function to save code and complexity in your
subclass’s Draw method.
Examples:
static void my draw( PtWidget t *widget, PhTile t *damage )
{
// draw fill & borders as needed.
PtSuperClassDraw( PtBasic, widget, damage );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
continued. . .
Safety
Thread No
Synopsis:
void PtSuperClassExtent( PtWidgetClassRef t *wc ref ,
PtWidget t *widget );
Description:
This function invokes the Extent method of the specified superclass
wc ref .
The PtLabel class’s Extent method handles multiline text (with
underlining and margins) and the resize policy.
The PtContainer class’s Extent method handles the resize policy
and anchoring for subclasses of PtContainer.
The PtGraphic class’s Extent method calculates an extent based on
an array of points, line weight, origin, and resize policy.
Examples:
To have a widget honor a minimum x dimension resource:
static void my container extent( PtWidget t *widget )
{
MyWidget t *mw = (MyWidget t *)widget;
PhRect t canvas, render, old extent;
// Apply anchoring.
PtApplyAnchors( widget );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtSuperClassGetResources(
PtWidgetClassRef t *wc ref ,
PtWidget t *widget,
int num args,
PtArg t *args );
Description:
This function gets resources given by num args and args in the
manner defined by wc ref . This is extremely helpful when overriding
the query f member of an overridden resource.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtSuperClassGotFocus( PtWidgetClassRef t *cref ,
PtWidget t *widget,
PhEvent t *event );
Description:
This function invokes the Got Focus method of the superclass
specified by cref .
The PtBasic class’s Got Focus method is the method that normally
invokes the widget’s Got Focus method or the user-level Got Focus
callback.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Description:
PtSuperClassInit() invokes the Initialize method of the specified
widget class cref .
PtSuperClassInitFrom() calls the Initialize method of all superclasses
starting with the superclass specified by cref . When
PtSuperClassInitFrom() is used in a Initialize method, Pt END should
be returned.
Returns:
Pt CONTINUE
The Initialization method chain can continue.
Pt HALT or Pt END
The Initialization method chaining should stop.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtSuperClassLostFocus(
PtWidgetClassRef t *cref ,
PtWidget t *widget,
PhEvent t *event );
Description:
This function invokes the Lost Focus method of the superclass
specified by cref .
The PtBasic class’s Lost Focus method is the one that normally
invokes the widget’s Lost Focus method or the user-level Lost Focus
callback.
Returns:
The maximum value returned by the Lost Focus callback chain.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
int PtSuperClassRawEventFrom(
PtWidgetClassRef t *cref ,
PtWidget t *widget,
void *data,
PtCallbackInfo t *cbinfo );
Description:
PtSuperClassRawEvent() invokes the raw callback list of the specified
widget class.
PtSuperClassRawEventFrom() calls the raw callback lists of all
superclasses starting with the superclass specified by cref . When
PtSuperClassRawEventFrom() is used in a class’s raw callback, the
callback should return Pt END.
Returns:
Pt END if the event was consumed, Pt CONTINUE if it wasn’t.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtSuperClassRealized( PtWidgetClassRef t *cref ,
PtWidget t *widget );
Description:
This function invokes the Realization method of the specified widget
class cref .
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtSuperClassSetResources(
PtWidgetClassRef t *wc ref ,
PtWidget t *widget,
int num args,
PtArg t const *args )
Description:
This function sets the resources given by num args and args in the
manner defined by wc ref . This is extremely helpful when overriding
the query f member of an overridden resource.
Returns:
The number of resources set.
Examples:
my modify area( PtWidget t *widget, PtArg t *argt )
{
MyWidget t *mw = (MyWidget t *)widget;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtUpdateVisibility( PtWidget t *widget,
PhRect t *rect );
Description:
This function tells the widget library that a change has occurred that
may affect the visibility of widgets that intersect with the provided
rect in the given container widget. This change may make the
intersecting widgets completely obscured, completely unobscured, or
partially obscured. This information is used to optimize refreshing the
screen:
¯ Widgets that are completely unobscured are drawn and don’t cause
widgets above them to be repaired (a completely unobscured
widget has no intersecting widgets above it).
Returns:
0 on success; -1 if widget isn’t a container.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtWidget t * PtWidgetAbove( PtWidget t *root,
PtWidget t *widget );
Description:
This function returns the widget in front of widget, provided the
returned widget isnt any higher in the hierarchy than root.
Returns:
A pointer to the widget above, or root if there isnt one; NULL if
widget is the same as root, or widget is NULL.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetBrotherBehind(), PtWidgetBrotherInFront(),
PtWidgetChildBack(), PtWidgetChildFront(), PtWidgetFamily(),
PtWidgetParent(), PtWidgetTree(), PtWidgetTreeTraverse()
¯ Never call Pg... functions from anywhere except the Draw method.
accelerator
See hotkey.
activate
A widget is usually activated when you release a mouse button while
pointing at an armed widget.
active window
The window that currently has focus.
anchor offset
The absolute or proportional distance between the edges of a
container-class child widget and the parent widget it’s anchored to.
anchor
A constraint mechanism used to manage what happens to a
container-class child widget when its parent is expanded or
contracted. For example, a pane that’s anchored to the sides of a
window expands or contracts as the window’s size is changed.
application region
A region that belongs to a Photon application (as opposed to a Photon
system process, such as the window manager, graphics drivers, etc.).
An application region is usually placed behind the device region.
Also called a window region.
argument list
An array of type PtArg t used when setting and getting widget
resources.
arm
A widget is usually armed when you press a mouse button while
pointing at it.
backdrop
An image that’s displayed as a background on your screen.
backdrop region
A region placed behind all windows to display a background image.
balloon
A small box that pops up to define or explain part of the user interface.
A balloon is displayed when the pointer pauses over a widget.
bitmap
A color picture consisting of one or more bitplanes.
bitplane
An array of bits representing pixels of a single color in a bitmap.
blit
An operation that moves an area of the screen.
callback
A callback function or a callback resource.
callback function
Code connecting an application’s user interface to its code. For
example, a callback is invoked when you press a button.
callback resource
A resource that specifies a list of functions and their client data to be
called when a certain action occurs.
canvas
The part of a widget that’s used for drawing. For PtWidget, this is
the area inside the widget’s borders. For PtBasic and its
descendants, the canvas is the area inside the widget’s border and
class
See widget class.
class hierarchy
The relationships between all of the widget classes.
client data
Any arbitrary data the application may need to provide to a callback
function.
clipping list
An array of rectangles used to restrict output to a particular area.
clipping rectangle
A rectangle used to restrict output to a particular area.
CMY value
A color expressed as levels of cyan, magenta, and yellow.
CMYK value
A color expressed as levels of cyan, magenta, yellow, and black.
color depth
The number of bits per pixel for a screen or pixmap.
compose sequence
A sequence of key presses that can be used to type a character that
might not appear on the keyboard.
console
One of nine virtual screens on the desktop. Also called a workspace.
consume
When a widget has processed an event and prevents another widget
from interacting with the event, the first widget is said to have
consumed the event.
container
A widget that can have other widgets as children. For example,
PtWindow, PtGroup, and PtPane.
cooked event
A key or pointer event that has been assigned a location in the Photon
event space. Also called a focused event.
CUA
Common User Access — a standard that defines how you can change
keyboard focus.
cursor
An indicator of a position on a screen, such as a pointer or an
insertion point in a text field.
damaged
Whenever a widget needs to be redisplayed due to a change in the
window (e.g. the widget is changed, moved, or realized), it’s said to
be damaged.
DayMinder
A Photon application that you can use to organize your daily schedule
and activities.
dead key
A key that, when pressed, doesn’t produce a symbol, but initiates a
compose sequence.
default placement
The placement of a region when no siblings are specified. The
opposite of specific placement.
desktop
The virtual screen provided by the Photon Desktop Manager. The
desktop consists of nine consoles or workspaces.
desktop manager
See Photon Desktop Manager.
device region
The region located in the middle of the event space, with application
regions behind it and driver regions in front of it.
dialog module
A PhAB module similar to a window module, except that a dialog
module can have only one instance per process.
direct-color
A color scheme in which each pixel is represented by an RGB value.
Contrast palette-based.
disjoint parent
A disjoint widget that’s the ancestor of another widget.
disjoint widget
A widget that can exist without a parent. If a disjoint widget has a
parent, it can exist outside its parent’s canvas. For example,
PtWindow, PtMenu, and PtRegion are disjoint widgets, but
PtButton, PtBkgd, and PtRect aren’t.
A disjoint widget owns regions that aren’t children of its parent’s
regions. Any clipping set by the parent of a disjoint widget isn’t
applied to the disjoint widget. The regions of disjoint widgets are
sensitive and opaque to expose events.
dithering
A process whereby pixels of two colors are combined to create a
texture or a blended color.
ditto
A QNX utility that lets you attach a local console or terminal to a
remote console. See also phditto.
draw context
A structure that defines the flow of the draw stream. The default draw
context emits draw events to graphics drivers. Print contexts and
memory contexts are types of draw contexts.
draw stream
A series of draw events.
driver region
A region created by a driver, usually placed in front of the device
region.
encapsulation driver
A program that displays Photon graphical output inside another
windowing system such as the X Window System.
event
A data structure that represents an interaction between you and an
application or between applications. Events travel through the event
space either toward you or away (i.e. toward the root region).
event compression
The merging of events such that the application sees only their latest
values. The application doesn’t have to process many unnecessary
events.
event handler
A callback function that lets an application respond directly to Photon
events, such as dragging events.
event mask
A set of event types that are or interest to an event handler. When
one of these events occurs, the event handler is invoked.
event space
An abstract, three-dimensional space that contains regions — from
the root region at the back to the graphics region at the front. You sit
outside the event space, looking in from the front. Events travel
through the event space either toward the root region or toward you.
exposure
Occurs when a region is destroyed, resized, or moved. Expose events
are sent to applications to inform them when the contents of their
regions need to be redisplayed.
extent
A rectangle that describes the outermost edges of a widget.
File Manager
The Photon File Manager (PFM), an application used to maintain and
organize files and directories.
focus
A widget that has focus will receive any key events collected by its
window.
focus region
A region placed just behind the device region by the Photon
Window Manager that lets it intercept key events and direct them to
the active window.
focused event
A key or pointer event that has been assigned a location in the Photon
event space. Also called a cooked event.
folder
In the Photon File Manager, a metaphor for a directory.
GC
See graphics context.
geometry negotiation
The process of determining the layout for a widget and its
descendants, which depends on the widget’s layout policy, any size
set for the widget, and the dimensions and desired positions of each of
the widget’s children.
graphics driver
A program that places a region that’s sensitive to draw events on the
user’s side of the device region, collects draw events, and renders the
graphical information on the screen.
Helpviewer
A Photon application for viewing online documentation.
hotkey
A special key or keychord that invokes an action (such as a menu
item) without actually selecting a widget. Also called an accelerator.
Contrast keyboard shortcut.
hotspot
The part of the pointer that corresponds to the coordinates reported
for the pointer (e.g. the intersection of crosshairs, or the tip of the
arrow of the basic pointer).
HSB
Hue-Saturation-Brightness color model.
HSV
Hue-Saturation-Value color model.
icon module
A PhAB module that holds the icons used by the Photon Desktop
Manager for launch buttons and by the Photon Window Manager for
the taskbar.
image
A rectangular array of color values, where each color value represents
a single pixel. See also direct-color and palette-based.
initialization function
In a PhAB application, a function that’s called before any widgets are
created.
input driver
A program that emits, and is the source of, key and pointer events.
input group
A set of input and output devices. There’s typically one input group
per user.
instance
A member of a class; for example, “Lassie” is an instance of the class
“dog.” In Photon, an instance is usually a widget instance. When an
instance is created, the initial values of its resources are assigned.
instance name
In PhAB, a string that identifies a particular instance of a widget so
that the instance can be accessed in an application’s code.
instantiation
The action of creating an instance of a widget class in an application.
internal link
A PhAB mechanism that lets a developer access a PhAB module
directly from an application’s code.
Image Viewer
A Photon application (pv) that displays images.
Jump Gate
A mechanism that “transports” an application from one QNX node to
another.
key modifier
A flag in a key event that indicates the state of the corresponding
modifier key when another key was pressed.
keyboard driver
A program that gets information from the keyboard hardware, builds
Photon key events, and emits them towards the root region.
keyboard shortcut
A key that selects a menu item. The shortcut works only if the menu
is displayed. Contrast hotkey.
language database
A file that contains the text strings used in a PhAB application; a
language database makes it easier to create multilingual applications
with PhAB’s language editor.
link callback
A mechanism that connects different parts of a PhAB application. For
example, a link callback can be invoked to display a dialog when a
button is pressed.
margin
The area between a widget’s border and canvas.
memory context
A draw context in which Photon draw events are directed to memory
for future displaying on the screen, as opposed to a printer (print
context) or to the screen directly (the default draw context).
menu module
A PhAB module used to create a menu.
Message Pad
A Photon application that lets you post notes on your computer’s
screen or send them to other users over the network.
method
A function that’s internal to a widget class and invoked under specific
conditions (e.g. to draw the widget). Methods are provided as
pointers to functions in widget class records.
modifier key
A key (such as Shift, Alt, or Ctrl) used to change the meaning of
another key.
module
An object in PhAB that holds an application’s widgets. PhAB
modules include windows, menus, icons, pictures, and dialogs.
mouse driver
A program that gets information from the pointer hardware, builds
Photon raw pointer events, and emits them towards the root region.
opaque
The state of a region with regard to events. If a region is opaque to an
event type, any event of that type that intersects with the region has its
rectangle set adjusted to clip out the intersecting area.
palette
An array of colors. A hard palette is in hardware; a soft palette is in
software.
palette-based
A color scheme in which each pixel is represented by an index into a
palette. Contrast direct-color.
PDM
See Photon Desktop Manager.
PDR
See Press-drag-release.
PFM
See Photon File Manager.
PhAB
Photon Application Builder. Visual design tool that generates the
code required to implement a user interface.
phditto
A utility that accesses the Photon workspace on a remote node. See
also ditto.
Phindows
Photon in Windows. An application that accesses Photon from a
Microsoft Windows environment.
PhinX
Photon in X. An application that accesses Photon from an X Window
System environment.
Photon Terminal
An application (pterm) that emulates a character-mode terminal in a
Photon window.
phsac
A utility that displays system activity.
picture module
A PhAB module that contains an arrangement of widgets that can be
displayed in another widget or used as a widget database.
pixmap
A bitmap or image.
plane mask
A mask used to restrict graphics operations to affect only a subset of
color bits.
point source
A single-point rectangle set used as the source of an event.
pointer
An object on the screen that tracks the position of a pointing device
(e.g. a mouse, tablet, track-ball, or joystick). Photon has several
pointers indicating various states: Basic, Busy, Help, Move, Resize,
I-beam, No-input.
Press-drag-release (PDR)
A method of selecting a menu item by pressing down a mouse button
while pointing to a menu button, dragging until the desired item is
highlighted, and releasing the mouse button.
print context
A draw context in which Photon draw events are directed to a file, as
opposed to the screen (the default draw context) or to memory
(memory context).
printer driver
A program that converts Photon draw stream format into a format
suitable for some printers, including PostScript, Hewlett-Packard
PCL, and Canon.
procreated widget
A widget created by another widget (as opposed to an application),
such as the PtList and PtText created by a PtComboBox. Also
known as a subordinate child.
pterm
A Photon Terminal; an application that emulates a character-mode
terminal in a Photon window.
pulse
A small message that doesn’t require a reply; used for asynchronous
communication with a Photon application.
pv
See Image Viewer.
PWM
See Photon Window Manager.
raw event
An input event that hasn’t been assigned a location in the Photon
event space. Also called an unfocused event.
raw-event callback
A function that lets an application respond directly to Photon events
such as dragging events. Also called an event handler.
realize
To display a widget and its descendants, possibly making them
interactive.
rectangle set
An array of nonoverlapping rectangles associated with an event.
region
A rectangular area within the Photon event space that’s used by an
application for collecting and emitting events.
resize policy
A rule that governs how a widget resizes itself when its contents
change.
resource
An attribute of a widget, such as fill color, dimensions, or a callback
list.
root region
The region at the very back of the Photon event space.
sensitive
The state of a region with regard to events. If a region is sensitive to a
particular type of event, the region’s owner collects a copy of any
such event that intersects with the region.
setup function
A function that’s called after a PhAB module is created.
Snapshot
A Photon application for capturing images of the screen.
specific placement
The placement of a region when one or more siblings are specified.
The opposite of default placement.
subordinate child
A widget created by another widget (as opposed to an application),
such as the PtList and PtText created by a PtComboBox. Also
known as a procreated widget.
Taskbar
An area in which the Photon Window Manager displays icons
representing the applications that are currently running.
tile
A data structure used to build linked lists of rectangles, such as a list
of the damaged parts of an interface.
topic path
Help information identified by a string of titles that are separated by
slashes.
topic root
A topic path that’s used as a starting point for locating help topics.
topic tree
A hierarchy of help information.
translation file
A file containing translated strings for a PhAB application. There’s
one translation file per language supported by the application.
unfocused event
See raw event.
Unicode
The ISO/IEC 10646 16-bit encoding scheme for representing the
characters used in most languages.
UTF-8
The encoding for Unicode characters, where each character is
represented by one, two, or three bytes.
vsin
A utility that displays system information.
widget
A component (e.g. a pushbutton) in a graphical user interface.
widget class
A template for widgets that perform similar functions and provide the
same public interface. For example, PtButton is a widget class.
widget database
In PhAB, a module containing widgets that can be copied at any time
into a window, dialog, or other container.
widget family
A hierarchy of widget instances. For example, a window and the
widgets it contains.
widget instance
See instance.
Window Manager
See Photon Window Manager.
window module
A PhAB module that’s instantiated as a PtWindow widget.
window region
A region that belongs to an application window.
work procedure
A function that’s invoked when there are no Photon events pending
for an application.
workspace
See console.
workspace menu
A configurable menu that’s displayed when you press or click the
right mouse button while pointing at the background of the screen.
A C
anchors 12 Calc Opaque Rect method 70, 296
container widgets 28, 107, 309 inheriting 23
invalidating 111 PtBasic 52, 53, 70, 102
Extent method 80, 107, 309 PtCompound 116
PtAnchorWidget() 252 PtContainer 108
PtApplyAnchors() 253 PtGauge 137
PtCalcAnchorOffsets() 256 PtGenList 119
PtContainerDeregister() 266 PtGenTree 127
PtContainerRegister() 267 PtGraphic 135
PtGetAnchoredExtent() 283 PtLabel 131
PtSetExtentFromArea() 292 callbacks 5, 236
PtSuperClassExtent() 309 balloon 119, 130, 132
attributes See resources class-level See methods
common 72
describing in PhAB 230, 236
freeing 275
B hotkey 96, 98, 109, 236
freeing 276
basic widgets 11. See also inheriting 237
PtBasic invoking 287
behavior Pt ARG IS CALLBACK 40
defining in widget class 5 Pt ARG IS CALLBACK LIST
inheriting from superclass 5 40, 42, 97
Pt CB ACTIVATE 72, 103
D PtContainer 107
PtGauge 137
Defaults method 50, 51, 56, 85 PtGenList 119
chaining 22 PtGenTree 126
compound widgets 32 PtGraphic 134
PtBasic 100 PtLabel 130
PtComboBox 84, 88 repairing damage 27
PtCompound 88, 115 ShadowedBox 24, 54
PtContainer 78, 79, 87, 106 using the Pg library safely 64
PtGauge 136
PtGenList 118
PtGenTree 126
PtGraphic 133 E
PtLabel 129
PtMenuBar 78 events
PtWidget 95 Connection method 96
ShadowedBox 10, 19, 54 consuming 105
Destruction method 27, 40, 50, 51, expose 49
67 focusing 110
chaining 22 handling in widget class 5
PtBasic 102 mask 109
PtButton 67 Ph EV BOUNDARY 72, 99
PtCompound 91, 115 Ph EV BUT PRESS 72, 102,
PtContainer 107 109
PtGauge 137 Ph EV BUT RELEASE 72, 103,
PtGenList 119 109
PtGenTree 126 Ph EV BUT REPEAT 72, 102,
PtGraphic 134 109
PtLabel 130 Ph EV KEY 109
PtWidget 96 Pt CB FILTER 109
Draw method 20, 50, 51, 55, 59, Pt CB RAW 71
62, 254, 307, 323 Pt CONSUME EVENTS 105
inheriting 22 PtEventHandler() 110
list widgets 141, 143, 144 PtGenList 121, 146, 147
PtBasic 101 Pt SET RAW CALLBACKS 103
PtButton 63 PtSuperClassRawEvent() 103,
PtCompound 115 315
G
F
Get Resources method 51, 68
focus 101 inheriting 22
Common User Access PtCompound 91
(CUA) 80 PtFindResourceRecord() 280
getting 23, 30, 53, 68, 75, 77, Got Focus method 68, 312
102, 110 inheriting 23
preventing 80 PtBasic 52, 53, 102
PtGenList 119 PtButton 68
losing 23, 30, 53, 69, 75, 77, PtCompound 116
102 PtContainer 108
PtGenList 119 PtGauge 137
Ph DIRECTED FOCUS 110 PtGenTree 126
Ph EV KEY 109 PtGraphic 134
PtBasic 4 PtLabel 131
Pt CHILD GETTING FOCUS 77
Pt SET 72, 99, 101, 102 Pt SET RAW CALLBACKS 51, 71,
PtSetArg() 38 103, 122
Pt SET BLOCKED RESOURCES 83, Pt SET REALIZED F 51
115 Pt SET RESOURCES 51, 54
Pt SET CALC OPAQUE F 53 PtSetResources() 38, 51, 96, 323
Pt SET CHILD CREATED F 75 Pt SET SETRESOURCES F 51
Pt SET CHILD DESTROYED F 75 Pt SET STATE LEN 51, 54
Pt SET CHILD GETTING FOCUS F PtSetStruct() 98, 293, 295
75 Pt SET SUBORDINATES 83, 88,
Pt SET CHILD GETTINGRESOURCE F 114
75 Pt SET UNREALIZE F 51
Pt SET CHILD LOSING FOCUS F PtSetValue() 293, 295
75 Pt SET VERSION 51, 54
Pt SET CHILD MOVED RESIZED F Pt SHOW BALLOON 130, 132
75 PtSuperClassCalcOpaque() 131,
Pt SET CHILD REALIZED F 75 296
Pt SET CHILD SETTINGRESOURCE F PtSuperClassChildCreated() 297
75 PtSuperClassChildDestroyed() 298
Pt SET CHILD UNREALIZED F 75, PtSuperClassChildGettingFocus() 299
96 PtSuperClassChildGettingResources()
Pt SET CONNECT F 51 300
Pt SET DESTROY F 51 PtSuperClassChildLosingFocus() 301
Pt SET DFLTS F 51, 54 PtSuperClassChildMovedResized() 302
Pt SET DRAW F 51, 54 PtSuperClassChildRealized() 303
Pt SET EXTENT F 51 PtSuperClassChildSettingResources()
PtSetExtentFromArea() 292 304
PtSET FLAGS 51, 54 PtSuperClassChildUnrealized() 305
Pt SET GETRESOURCES F 51 PtSuperClassConnect() 306
Pt SET GOT FOCUS F 53 PtSuperClassConnectFrom() 306
Pt SET INIT F 51 PtSuperClassDraw() 25, 130, 307
Pt SET LOST FOCUS F 53 PtSuperClassExtent() 100, 107,
Pt SET NUM BLOCKED RESOURCES 118, 309
83, 114 PtSuperClassGenListDraw() 181
Pt SET NUM RESOURCES 51, 54 PtSuperClassGenListInflate() 182
Pt SET NUM SUBORDINATES 82, PtSuperClassGenListKey() 183
88, 114 PtSuperClassGenListMouse() 184
PtSuperClassGenListSelect() 185
W freeing 67, 96
freeing memory 40
widgets Get Resources method 68,
actions 51, 71 91
adding to PhAB 227–241 getting 85
basic 11 inheriting 5, 237
categories 11 manifests 36
classes numbers 36
defining 47–54 PtBasic 103
methods 55–71 Pt CLEAN RESOURCES 49
compound 13 PtContainer 111
container 12 PtCreateWidget() 20
data chain 250, 278, 282, 290 PtFindResourceRecord()
description table 230 280
designing 4 PtGauge 137
handling events 51, 71 PtGenList 122
instantiating 17 PtGenTree 128
life cycle 17 PtGetStruct() 285
main components 6 PtGraphic 135
managing children 12 Pt INDEX RESOURCES 49
reasons to customize 3 PtLabel 131
redirecting 13 Pt NO INHERITED RESOURCES
repairing damage 27 50
resources PtSetStruct() 293
blocking 12, 13, 31, 82, 83, PtSetValue() 295
86, 114, 115 PtSuperClassChildGettingResources()
causing damage 27 300
Child Getting Resource PtSuperClassChildSettingResources()
method 77 304
Child Setting Resource PtSuperClassGetResources()
method 77 311
class resource table 51 PtSuperClassSetResources()
default values in PhAB 239 317
defining 5, 19, 35 Pt UNCLEAN RESOURCES
describing in PhAB 230, 49
232 records 37
editing in PhAB 227, 228