photon_widget_ref
photon_widget_ref
Widget Reference
Publishing history
December 1996 First edition
April 1998 Second edition
QNX, Photon microGUI, and Neutrino are registered trademarks, and Jump Gate Connectivity is a trademark, of QNX Software Systems in certain jurisdictions.
All other trademarks and registered trademarks belong to their respective owners.
Contents
2 Widgets 15
Widget hierarchy 17
Common widget flags 18
What’s in a widget description? 22
AwFileSelect 26
AwMessage 33
PtArc 38
PtBasic 43
PtBezier 56
PtBitmap 60
PtBkgd 69
PtButton 79
PtCalendar 86
PtClock 98
PtComboBox 109
PtComboBoxListClose() 123
PtComboBoxListOpen() 124
PtCompound 125
PtContainer 128
PtDBContainer 139
PtDivider 143
PtEllipse 151
PtFileSel 154
PtFSAddAfter() 178
PtFSAddFirst() 179
PtFSAllItems() 181
PtFSAllocItem() 182
PtFSClearSelection() 185
PtFSDamageItem() 186
PtFSExpandParents() 187
PtFSFolderCollapse() 188
PtFSFolderExpand() 189
PtFSFreeAllItems() 190
PtFSFreeItems() 191
PtFSGetCurrent() 192
PtFSGetSelIndexes() 193
PtFSGoto() 194
PtFSItemIndex() 195
PtFSRemoveChildren() 196
PtFSRemoveItem() 197
PtFSRemoveList() 198
PtFSRootItem() 199
PtFSSelect() 200
PtFSSelectedItems() 201
PtFSSetSelIndexes() 202
PtFSShow() 203
PtFSUnselect() 204
PtFSUnselectNonBrothers() 205
PtFontSel 206
PtGauge 212
PtGenList 218
PtGenListCreateTextBalloon() 236
PtGenListItem t 238
PtGenListSetColumnBalloon() 240
PtGenTree 241
PtGenTreeItem t 248
PtGraphic 251
PtGrid 276
PtGroup 281
PtHtml 289
PtHtmlLink() 309
PtHtmlTitle() 310
PtIcon 311
PtLabel 316
PtLine 333
PtList 337
PtListAddItems() 351
PtListDeleteAllItems() 352
PtListDeleteItemPos() 353
PtListDeleteItems() 354
PtListGotoPos() 355
PtListItemExists() 356
PtListItemPos() 357
PtListRemovePositions() 358
PtListReplaceItemPos() 359
PtListReplaceItems() 360
PtListSelectPos() 361
PtListShowPos() 362
PtListUnselectPos() 363
PtMenu 364
PtMenuBar 382
PtMenuButton 386
PtMessage 392
PtMessageGetWindow() 397
PtMultiText 398
PtMultiLines t 429
PtMultiTextAttributes t 431
PtMultiTextCallback t, PtMultiTextControl t,
PtMultiTextInfo t 433
PtMultiTextCreateAttributes() 435
PtMultiTextGetAttributes() 436
PtMultiTextInfo() 440
PtMultiTextLine t 443
PtMultiTextModifyAttributes() 445
PtMultiTextModifyText() 447
PtMultiTextQuery t 449
PtMultiTextSegment t 451
PtNumeric 453
PtNumericFloat 462
PtNumericInteger 470
PtOnOffButton 477
PtPane 482
PtPixel 486
PtPolygon 489
PtPrintSel 494
PtRaw 501
PtRect 509
PtRegion 513
PtScrollArea 521
PtScrollbar 534
PtSeparator 545
PtSlider 549
PtTab 561
PtTerminal 566
PtTerminalCharset t, PtTerminalCharsets t 605
PtTerminalCopy() 608
PtTerminalCreateCsXlat() 609
PtTerminalDefaultCharsets() 611
PtTerminalFont() 612
PtTerminalGetKeys() 614
PtTerminalGetSelection() 616
PtTerminalName() 617
PtTerminalPasteClipboard() 618
PtTerminalPasteSelection() 619
PtTerminalPut(), PtTerminalPutc(), PtTerminalPuts() 620
PtTerminalSelectWord() 622
PtText 623
PtTextCallback t, PtTextControl t,
PtTextControlInfo t 653
PtTextGetSelection() 655
PtTextModifyText() 656
PtTextSetSelection() 658
PtTimer 660
PtToggleButton 663
PtTree 671
PtTreeAddAfter() 686
PtTreeAddFirst() 688
PtTreeAddImages() 690
PtTreeAllItems() 691
PtTreeAllocItem() 693
PtTreeClearSelection() 695
PtTreeCollapse() 696
PtTreeExpand() 697
PtTreeFreeAllItems() 699
PtTreeFreeItems() 700
PtTreeGetCurrent() 701
PtTreeGetSelIndexes() 702
PtTreeGoto() 704
PtTreeItem t 705
PtTreeItemIndex() 707
PtTreeModifyItem() 708
PtTreeRemoveChildren() 710
PtTreeRemoveItem() 712
PtTreeRemoveList() 714
PtTreeRootItem() 716
PtTreeSelect() 717
PtTreeSelectedItems() 718
PtTreeSetSelIndexes() 720
PtTreeShow() 721
PtTreeUnselect() 723
PtTreeUnselectNonBrothers() 724
PtTty 725
PtTtyShell() 743
PtUpDown 744
PtWidget 753
PtWindow 770
PtWindowFocus() 793
PtWindowGetState() 795
PtWindowToBack() 797
PtWindowToFront() 799
RtMeter 801
RtProgress 816
RtTrend 820
RtTrendChangeData(), RtTrendChangeTrendData() 832
Glossary 835
Index 857
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.
For: See:
Information about data structures Global Data Structures
A diagram of the widget class hierarchy Widgets
Descriptions of common flags Widgets
An alphabetical list of all flags Widgets
An overview of what’s in a widget Widgets
description
Descriptions of widget classes Widgets
Explanations of Photon terms Glossary
Since widgets inherit a lot of behavior from their parent classes, you
should make yourself familiar with the fundamental classes:
PtWidget, PtBasic, PtContainer, and so on.
PtBalloonCallback t
Balloon callback structure
PtCallback t
Regular callback structure
PtCallbackInfo t
Specific callback information
PtHotkeyCallback t
Hotkey handler structure
PtRawCallback t
Event handler structure
PhEvent t An event
PhEventRegion t
Emitter and collector of an event
PhRegion t A region
PhRegionDataHdr t
Data that’s attached to a region
PhWindowEvent t
A window action
PtInputCallbackProc t
Pointer to a input callback function
PtSignalProc t
Pointer to a signal-handling function
Synopsis:
typedef struct Pt balloon callback {
PtWidget t *widget;
void (*event f )( PtWidget t *wgt,
void *data,
PtCallbackInfo t *cbinfo);
} PtBalloonCallback t;
Description:
The PtBalloonCallback t structure lets you attach a balloon
callback to a widget’s container. The container invokes the specified
function whenever a balloon action is warranted.
This structure contains at least the following members:
Classification:
Photon
See also:
PtCallbackInfo t, PtContainer
Synopsis:
typedef struct Pt callback {
int (*event f )( PtWidget t *, void *,
PtCallbackInfo t * );
void *data;
} PtCallback t;
Description:
The PtCallback t structure lets you specify a widget’s callbacks
when you call PtCreateWidget() or PtAddCallbacks().
This structure contains at least:
Callback functions
A callback function takes the following arguments:
PtWidget t *widget
A pointer to the widget instance that invoked the callback.
void *client data
The data from the PtCallback t structure.
PtCallbackInfo t *cbinfo
A pointer to a common Photon callback structure. The structure
provides information related to the widget callback being
invoked, the Photon event, and some widget-specific callback
data. The format of the data varies with the widget class and
callback type. For more information, see PtCallbackInfo t.
Classification:
Photon
See also:
PtBalloonCallback t, PtCallbackInfo t,
PtHotkeyCallback t, PtRawCallback t
ApInfo t, PtAddCallbacks(), PtCreateWidget() in the Photon
Library Reference
“Manipulating callbacks in your code” in the Creating Widgets in
Application Code chapter of the Photon Programmer’s Guide.
Synopsis:
typedef struct Pt callback info {
unsigned long reason;
unsigned long reason subtype;
PhEvent t *event;
void *cbdata;
} PtCallbackInfo t;
Description:
The PtCallbackInfo t structure is the third argument passed to all
callback functions. You can use this structure to determine why
callbacks occurred and to get the specific callback information.
The structure contains at least the following members:
reason The reason why this callback was invoked. For example,
if the user caused the widget to invoke its
Pt CB ACTIVATE callback, then reason would be
Pt CB ACTIVATE.
reason subtype
If there are different ways to invoke the callback, this
member indicates which one.
Classification:
Photon
See also:
PtBalloonCallback t, PtCallback t, PtHotkeyCallback t,
PtRawCallback t
PhEvent t in the Photon Library Reference
Synopsis:
typedef struct Pt hotkey callback {
unsigned short key sym cap;
short flags;
unsigned long key mods;
PtWidget t *widget;
void *data;
int (*event f )( PtWidget t *, void *,
PtCallbackInfo t * );
} PtHotkeyCallback t;
Description:
The PtHotkeyCallback t structure lets you specify hotkeys or
hotkey handlers, or both, for various widgets. It contains at least the
following members:
key mods Key modifiers that must be active for the key to be
considered a hotkey. If the
Classification:
Photon
See also:
PtBalloonCallback t, PtCallback t, PtCallbackInfo t,
Pt CB HOTKEY (PtWidget), PtRawCallback t
Synopsis:
typedef struct Pt raw callback {
unsigned long event mask;
int (*event f )( PtWidget t *, void *,
PtCallbackInfo t * );
void *data;
} PtRawCallback t;
Description:
The PtRawCallback t structure lets you specify event handlers for
various widgets. You use this structure when setting the Pt CB RAW
resource of any widget (see PtWidget) or calling
PtAddEventHandler().
This structure contains at least the following members:
Classification:
Photon
See also:
PtBalloonCallback t, PtCallback t, PtCallbackInfo t,
Pt CB RAW (PtWidget), PtHotkeyCallback t
Widget hierarchy
PtWidget AwFileSelect
AwMessage
PtBasic PtBitmap
PtCalendar
PtClock
PtContainer PtCompound PtComboBox
PtDivider
PtGenList PtGenTree PtFileSel
PtTree
PtList
PtMenuButton
PtMultiText
PtNumeric PtNumericFloat
PtNumericInteger
PtDBContainer
PtFontSel
PtGroup PtMenu
PtMenuBar
PtMessage
PtHtml
PtPane PtBkgd
PtPrintSel
PtRegion
PtScrollArea
PtTerminal PtTty
PtUpDown
PtWindow PtIcon
PtGauge PtSlider
RtProgress
PtGraphic PtArc
PtBezier
PtEllipse
PtLine
PtPixel
PtPolygon
PtRect
PtGrid
PtLabel PtButton PtTab
PtMenuLabel
PtText
PtToggleButton PtOnOffButton
PtRaw
PtScrollbar
PtSeparator
RtMeter
RtTrend
PtTimer
continued. . .
continued. . .
continued. . .
continued. . .
Class hierarchy
The ancestral classes a widget inherits its resources and behavior
from.
PhAB icon
The icon in PhAB’s widget bar for the widget.
Public header
The name of the header file containing the resource manifests, data
structures, and defines associated with the widget class.
Description
How to use the widget. This section may include sample code as well
as an example of the widget’s appearance.
New resources
The new resources introduced by this widget class. The “New
resources” table for each widget contains the following columns of
information:
Inherited resources
The specific resources a widget class inherits from its ancestors, or in
the case of a compound widget, from its exported subordinate
children. The default values that a widget class inherits can be
overridden. The Inherited resources table contains the following
columns of information:
The value in the Default override column may start with |=, as in the
following example:
This symbol indicates that the flags listed are added to the resource
without destroying any flags already set in it (i.e. the new flags and
the default value are combined in an OR operation).
A &=˜ symbol means that one or more flags are cleared. In the
following example, the Pt SELECTABLE flag is added to the resource
and the Pt HIGHLIGHTED flag is cleared:
Convenience functions
The functions you can use to control the widget once it has been
created.
Class hierarchy:
PtWidget → AwFileSelect
PhAB icon:
None — instantiated by PhAB’s File Selector module.
Public header:
<photon/AwFileSelect.h>
Description:
The AwFileSelect widget displays itself as a dialog to provide
basic file open/save functionality for an application.
File Selector
Directory Path
/home/stever/phab/others/src
Files Directories
Makefile
Usemsg home
abHfiles stever
abOfiles phab
abSfiles others
abdefine.h src
abevents.h default
abimport.h
ablinks.h
abmain.c
abplatform
abvars.h
Selection File Spec
Open Cancel
An AwFileSelect widget.
{
char *home dir;
PtArg t args[2];
return( Pt CONTINUE );
}
If you’re using the widget to save a file, you can also specify the
filename to use by setting the Aw ARG FILE NAME resource.
The dialog contains two action buttons to give the user an indication
of what the dialog is going to do:
You can change the text for the buttons by setting the
Aw ARG ACTION TEXT or Aw ARG CANCEL TEXT resources. For
example, if the dialog is being used to save a file, you should change
Aw ARG ACTION TEXT to Save.
When the user activates the file selection by clicking on the Action
button, the Aw CB FS ACTION callback is invoked. This callback
passes widget data to indicate the directory, filename and filespec
values at the time the file selection was activated. You can access this
data in the callback by casting the callback data as follows:
New resources:
continued. . .
The initial directory path before the dialog is displayed. The widget
uses this value to open the directory and display the files and folders
in the appropriate lists.
Use this resource to set a default file name. It can also be used to
extract the file name in the action callback.
A filter that limits the files displayed in the file list. It’s typically used
when an application wants to show certain types of files. For example,
a graphical file viewer might set the file specification to *.gif to
limit the files to GIF files. The file specification has no effect on the
folder display list.
Aw CB FS ACTION
C type Pt type Default
PtCallback t * Link NULL
A list of callbacks invoked when the user clicks on the action button
or double-clicks on a file in the file list. The application should use
these callbacks to perform the selected file operation.
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
reason Aw CB FS ACTION
reason subtype
0 (not used)
Aw CB FS CANCEL
C type Pt type Default
PtCallback t * Link NULL
A list of callbacks invoked when the user cancels the dialog in any
way. This includes clicking on the Cancel button or closing the dialog.
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
reason Aw CB FS CANCEL
reason subtype
0 (not used)
Inherited resources:
This widget is self-contained and doesn’t use any resources inherited
from PtWidget.
Class hierarchy:
PtWidget → AwMessage
PhAB icon:
None — instantiated by PhAB’s Message module.
Public header:
<photon/AwMessage.h>
Description:
AwMessage displays a text-based message in a popup window. The
message can include up to three optional buttons, allowing the user to
select a course of action.
Ok
An AwMessage widget.
New resources:
The labels for the three optional buttons that are displayed below the
message. If no label is provided for Aw ARG MSG BUTTON1, the
default of Ok is used. If no label is provided for the other two buttons,
they default to NULL, which means they won’t be displayed. These
defaults are useful for messages that simply provide information.
Yes No Cancel
You can assign a keyboard shortcut to each button. Simply place & in
front of the character that will act as the shortcut. For example, if you
specify &Save, the S will be underlined in the button. To select the
button, the user can press s or S.
The number of the default button (1, 2 or 3), which can be selected by
pressing Enter. The default button is initially given focus.
Callback functions that will be invoked if the user selects one of the
buttons. These resources correspond with the buttons by number. So,
for example, if the user selects the button labeled with
Aw ARG MSG BUTTON1, Aw CB MSG BUTTON1 is invoked.
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
event The raw event that caused the the callback to be invoked.
Inherited resources:
This widget is self-contained and doesn’t use any resources inherited
from PtWidget.
Class hierarchy:
PtWidget → PtBasic → PtGraphic → PtArc
PhAB icon:
Public header:
<photon/PtArc.h>
Description:
You can create an elliptical arc using the PtArc widget. The arc is
defined by:
¯ the origin
¯ an ellipse
¯ a start angle
¯ an end angle
¯ Pt ARC PIE — draws the arc inscribed by the points with lines
drawn from the two end points to the centroid of the arc, creating a
pie-slice
¯ Pt ARC CHORD — draws the arc inscribed by the points with the
chord connecting the two end points closing the curve.
New resources:
The start angle in tenths of a degree. If this angle is 0, the arc starts on
the horizon, to the right of the center. Angles increase in a
counter-clockwise direction.
Pt ARC CHORD
Curve with ends connected by a straight line.
Pt ARC CURVE
Curve only.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic
PhAB icon:
Public header:
<photon/PtBasic.h>
Description:
The PtBasic superclass provides basic resources for all widgets. It
provides the fundamental callbacks for:
¯ getting/losing focus
¯ activating
¯ toggle buttons
¯ autohighlighting
¯ margins
¯ border colors
¯ draw color
¯ fill color
¯ fill pattern
only when the pointer button is pressed, not when the button is
released or held down.
New resources:
continued. . .
Pt ARG COLOR
C type Pt type Default
PgColor t Scalar Pg BLACK
☞ If you set this resource to a nonzero value, the widget library has to
work with a nonrectangular widget. It might take longer to draw the
widget, and you might notice some flickering. You can reduce the
flickering by placing the widget inside a PtDBContainer.
The amount of vertical space between the widget’s canvas and the
widget’s border. The canvas is the valid drawing area of the widget
and is inside all borders and margins.
The amount of horizontal space between the widget’s canvas and the
widget’s border. The canvas is the valid drawing area of the widget
and is inside all borders and margins.
Pt CB ACTIVATE
C type Pt type Default
PtCallback t * Link NULL
Pt CB ARM
C type Pt type Default
PtCallback t * Link NULL
cbdata NULL.
Pt CB DISARM
C type Pt type Default
PtCallback t * Link NULL
cbdata NULL.
Pt CB GOT FOCUS
C type Pt type Default
PtCallback t * Link NULL
A callback list invoked when a widget gets the focus or its focus
status changes (e.g. a child widget gets focus from its parent or the
cbdata NULL.
Pt CB LOST FOCUS
C type Pt type Default
PtCallback t * Link NULL
A list of callbacks that the widget calls when it loses input focus.
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
cbdata NULL.
Pt CB MENU
C type Pt type Default
PtCallback t * Link NULL
A list of callbacks that the widget calls when the user presses the right
mouse button while the pointer is on top of the widget.
cbdata NULL.
Pt CB REPEAT
C type Pt type Default
PtCallback t * Link NULL
cbdata NULL.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
Class hierarchy:
PtWidget → PtBasic → PtGraphic → PtBezier
PhAB icon:
Public header:
<photon/PtBezier.h>
Description:
The PtBezier class draws a Bézier curve via PgDrawBezier().
New resources:
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtBitmap
PhAB icon:
Public header:
<photon/PtBitmap.h>
Description:
PtBitmap draws a bitmap. PtBitmap can be set, unset, or made
unselectable. You can use it either in groups, button bars, menu bars,
or as a single button.
4 9 T A J
4 9 T A J
Bitmapped images.
New resources:
Pt ARG BITMAP BALLOON POSITION unsigned short Scalar Pt BITMAP BALLOON RIGHT
By default, when a user pauses the pointer over this widget, the
widget will display a small yellow balloon. If you want to change the
look or default text of the balloon, you can use this resource to
override the default value supplied by the default inflate function.
Here’s a prototype of a sample inflate function:
int position,
char *text,
char *font,
PgColor t fill color,
PgColor t text color );
where:
In your function, you can either use the supplied values, or ignore
them and use values of your own.
Indicates where the bitmap text will pop up. Possible values:
The bitmap data. Each bit represents a single pixel and each
horizontal line must be rounded up to a multiple of 8 bits. For more
information, see PgDrawBitmap(). To control the dimensions of the
bitmap, use Pt ARG AREA or Pt ARG DIM.
Possible values:
The default setting for this resource is 0; that is, no flags are set.
The background color that the widget uses when it becomes armed
(that it, when it’s pressed in). Pt ARG BMP SET BG FILL must be
set to Pt TRUE for this resource to be used.
This resource defines the armed bitmap data. The format of the data is
the same as in Pt ARG BITMAP DATA (see above).
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtPane → PtBkgd
PhAB icon:
Public header:
<photon/PtBkgd.h>
Description:
The PtBkgd widget provides various background layouts.
A background image.
New resources:
before providing the image to the widget. If you do this, the memory
used for the image is released when the widget is unrealized or
destroyed.
☞ Remember that this is an Alloc resource. When you set this resource,
the widget copies the PhImage t structure but not the data pointed to
by the members of the structure. After setting this resource, you can
free() the PhImage t if you don’t need it, but don’t free() the
members of it.
¯ Pt BKGD HORIZONTAL
¯ Pt BKGD VERTICAL
Pt BKGD CENTER
Draw the image once and center it within the
container.
If you set this resource to zero, tiling will be disabled and the image
will be drawn once at the top-left corner.
Pt BKGD HUE
Pt BKGD SATURATION
Pt BKGD BRIGHTNESS
These types let you display color gradients. The type you
choose affects how the resources are interpreted.
In general, you specify the range of values for the background
type you choose and enter only the “to” value for the other
resources. So, for example, if you chose Pt BKGD HUE, you
would enter both the “to” and “from” values for Pt BKGD HUE
but only the “to” values for Pt BKGD SATURATION and
Pt BKGD BRIGHTNESS.
The smoothness of the gradient is determined by
Pt ARG BKGD STEPS and Pt ARG BKGD MIX.
Pt BKGD PIXMAP
Pt BKGD IMAGE
These types let you display picture backgrounds.
You can use the Pt BKGD PIXMAP type for small pictures
drawn by hand where you need the background fill color to
show through. If you select this type, the widget uses the
Pt ARG BKGD PIXMAP resource.
You use the Pt BKGD IMAGE type primarily to display images
imported from other sources. If you select this type, the widget
uses the Pt ARG BKGD IMAGE resource.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtLabel → PtButton
PhAB icon:
Public header:
<photon/PtButton.h>
Description:
The PtButton class draws a button. Buttons let you initiate an action
within the application. Clicking the button invokes an application
callback.
Cancel
A PtButton widget.
Creating pushbuttons
A pushbutton is like a button you might find on a calculator or a
control panel. The label is displayed within the button. The widget
itself is shaded to appear like a raised button. When you click on the
button, the shading is reversed to make it appear as though the button
is recessed. The label inside the button is usually a text string and/or
icon representing the action that’s performed when the button is
pressed.
You use the PtButton widget class to create pushbutton widgets.
You specify a label for the pushbutton in the same way as for
PtLabel widgets.
Pushbutton behavior
A pushbutton is usually associated with a command to be performed
— when you click on the pushbutton, the command is executed. For
more information, see PtBasic.
Visual feedback
A visual cue is displayed when a pushbutton is armed. Usually the
pushbutton is shaded so that the button appears recessed. The original
appearance is restored once the pushbutton has been disarmed or
activated.
You can also configure a pushbutton so that the background of the
widget is filled with a different color to provide more noticeable
feedback when the button is armed. Use the Pt ARG ARM COLOR
resource to set the fill color for armed pushbuttons. This resource is
ignored if the Pt ARG ARM FILL resource hasn’t been set to
Pt TRUE.
When the pushbutton is displaying an image, you may want the image
to change when the pushbutton is armed. This is useful if you want to
change the color of the icon displayed or change the actual image,
such as changing a mail box icon from one with the flag up to one
with the flag down. It you wish to change only the color, the
Pt ARG ARM COLOR can be set when the image is a bitmap with
backfill turned on. The arm color will be used in place of the widget’s
fill color.
To display a different image entirely when the button is armed, use
the Pt ARG ARM DATA resource. When the Pt ARG LABEL TYPE
resource (see PtLabel) is set to an image type, this resource is
consulted to see if an alternate image is available for displaying when
the pushbutton is armed. If the data points to an image, that image is
displayed when the button gets armed.
New resources:
The background color used when the button is armed (pressed in).
Contains a pointer. If the label type (Pt ARG LABEL TYPE — see
PtLabel) is Pt Z STRING, this resource points to a text string. If the
label type is Pt IMAGE, this resource points to a PhImage t
structure. For more information, see PtLabel.
Set the flags member of the PhImage t structure to:
before providing the image to the widget. If you do this, the memory
used for the image is released when the widget is unrealized or
destroyed.
☞ Remember that this is an Alloc resource. When you set this resource,
the widget copies the PhImage t structure but not the data pointed to
by the members of the structure. After setting this resource, you can
free() the PhImage t if you don’t need it, but don’t free() the
members of it.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtCalendar
PhAB icon:
Pt Calenda
Public header:
<photon/PtCalendar.h>
Description:
PtCalendar draws a calendar showing the day of the week, month
and year. The user can interactively change the date and browse other
months and years. The calendar is drawn on a per-month basis and
can be drawn with or without a grid.
A PtCalendar widget.
New resources:
The color used to display the next and previous month’s days.
The color used for any highlighted days in the calendar (see
Pt ARG CALENDAR HIGHLIGHT).
The color used for the names of the days of the week (see
Pt ARG CALENDAR WDAY NAMES).
The font used for the next and previous month’s days.
The font used for any highlighted days in the calendar (see
Pt ARG CALENDAR HIGHLIGHT).
The font used for the names of the days of the week (see
Pt ARG CALENDAR WDAY NAMES).
A long used to set bits that represent days of the current month to
highlight. For example, 0x1 means that day 1 is highlighted and 0x3
means that days 1 and 2 are highlighted.
The highlighted days are displayed using the values of
Pt ARG CALENDAR COLOR4 and Pt ARG CALENDAR FONT4.
The color used for the buttons used for moving to the next and
previous months.
Element Value
0 January
1 February
2 March
3 April
4 May
5 June
6 July
7 August
8 September
9 October
10 November
11 December
The array should contain 12 elements. If you set more, the extras are
discarded. If you set fewer, the above elements are used for the
missing ones.
Element Value
0 Su
1 Mo
continued. . .
Element Value
2 Tu
3 We
4 Th
5 Fr
6 Sa
The array should contain 7 elements. If you set more, the extras are
discarded. If you set fewer, the above elements are used for the
missing ones.
The color used for the buttons used for moving to next and previous
years.
Pt CB CALENDAR SELECT
C type Pt type Default
PtCallback t * Link NULL
reason subtype
0 (not used).
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtClock
PhAB icon:
Pt Clock
Public header:
<photon/PtClock.h>
Description:
A PtClock draws a clock and can optionally update its display
periodically (about once a second) to reflect the current time.
New resources:
continued. . .
The fill color of the clock’s face (applicable only for analog clocks).
The color of the line drawn around the clock face (applicable only for
analog clocks).
Pt CLOCK 24 HOUR
Use a 24-hour display rather than conventional 12-hour format.
This flag overrides Pt CLOCK SHOW AMPM.
The font to use. For analog clocks, this applies to the numbers on the
face (if displayed). For digital clocks, this applies to the entire display.
The current hour setting for the clock (reflecting the current system
clock setting if Pt CLOCK TRACK TIME is set). This value is in
24-hour format. When setting this resource, a value of
Pt CLOCK CURRENT causes the clock to assume the current system
time setting.
Offset the clock setting by this amount when displaying the hours
field.
The current minute setting for the clock (reflecting the current system
clock setting if Pt CLOCK TRACK TIME is set). When setting this
resource, a value of Pt CLOCK CURRENT causes the clock to assume
the current system time setting.
Offset the clock setting by this amount when displaying the minutes
field.
The current second setting for the clock (reflecting the current system
clock setting if Pt CLOCK TRACK TIME is set). When setting this
resource, a value of Pt CLOCK CURRENT causes the clock to assume
the current system time setting.
Offset the clock setting by this amount when displaying the seconds
field.
The separator to use between the hours and minutes field (applicable
only for digital clocks; LED clocks always use a colon). Only the first
character of the string is used.
The color to use when drawing the separator character between hours
and minutes.
Pt CLOCK DIGITAL
A numeric display (using system fonts).
Pt CLOCK LED
A scalable display that resembles conventional LED/LCD
digital clocks.
Pt CLOCK ANALOG
An analog clock with hands.
A list of callbacks invoked when the time on the clock changes. This
occurs once a second if Pt CLOCK SHOW SECONDS is set, otherwise
once every minute when the minute changes.
event The event that caused the callback. If event is NULL, the
callback was invoked because the time setting was
changed programmatically using a called to
PtSetResources().
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtCompound →
PtComboBox
PhAB icon:
Public header:
<photon/PtComboBox.h>
Description:
The PtComboBox class provides a widget that’s built from two
exported subordinate widgets: PtList and PtText.
Friday Friday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
You can type in the text field or choose a predefined entry from the
list. The list can be either:
To select an item using the mouse, either click on an item or drag the
the pointer down the list and release the mouse button when the
correct item is highlighted. You can select only one item. If you drag
the mouse, the list can be scrolled.
A blocking mechanism lets PtComboBox block the inheritance of
certain resources from its subordinate widgets. This prevents any
actions that would negatively affect the look and behavior of a
PtComboBox widget. For more information, see the “Exported
subordinate children” section.
Callbacks
The following callbacks are associated with the text part of the
PtComboBox and are invoked as described for PtText:
¯ Pt CB ACTIVATE
¯ Pt CB MODIFY NOTIFY
¯ Pt CB MODIFY VERIFY
¯ Pt CB MOTION NOTIFY
¯ Pt CB MOTION VERIFY
¯ Pt CB TEXT CHANGED
The following callbacks are associated with the list part of the
PtComboBox and are invoked as described for PtList:
¯ Pt CB LIST INPUT
¯ Pt CB SELECTION
¯ Pt CB CBOX ACTIVATE
¯ Pt CB CBOX CLOSE
New resources:
Possible values:
Pt COMBOBOX STATIC
Make the list field is made static and remove the drop button. If
this bit is off, the list field is visible only when the drop button
is pressed. Default is not set.
Pt COMBOBOX TOP
Place the list field above the text field. If this bit is off, the list
field will be placed below the text field. Note: if there isn’t
enough space between the text field and the edge of the screen
the list may appear on the opposite side of the text field.
Pt CB CBOX ACTIVATE
C type Pt type Default
PtCallback t * Link NULL
A list of callbacks that the widget invokes when the list is activated
(i.e opened).
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
Pt CB CBOX CLOSE
C type Pt type Default
PtCallback t * Link NULL
A list of callbacks that are invoked when the user closes the
combobox’s list.
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
Inherited resources:
If PtComboBox modifies an inherited resource, the “Default override”
column indicates the new value. If PtComboBox inherits a resource
from one of its exported subordinate children, the default value
assigned by the subordinate widget is inherited too; the “Default
override” column shows this default value.
continued. . .
continued. . .
continued. . .
continued. . .
continued. . .
Convenience functions:
The PtComboBox widget and its exported subordinate PtList and
PtText children define various convenience functions that make it
easier to use the combo box once it’s been created. Here’s a brief
overview:
PtComboBoxListOpen()
Open a combobox list.
PtComboBoxListClose()
Close an open combobox list.
PtListAddItems()
Adds one or more items to the list at a specified position.
PtListDeleteAllItems()
Removes all the items from the list.
PtListDeleteItems()
Deletes items in the list by name.
PtListDeleteItemPos()
Deletes a range of items by position.
PtListItemExists()
Determines whether or not an item exists within the list.
PtListItemPos()
Determines the position of an item within the list.
PtListRemovePositions()
Deletes items at specified positions.
PtListReplaceItemPos()
Replaces items by position number.
PtListReplaceItems()
Replaces items by item text.
PtTextGetSelection()
Gets the selected range from a PtText widget.
PtTextModifyText()
Modifies the contents of a PtText widget.
PtTextSetSelection()
Sets the selected range for a PtText widget.
Synopsis:
int PtComboBoxListClose( PtWidget t *widget );
Description:
This function closes the list in a PtComboBox widget.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtComboBoxListOpen()
Synopsis:
int PtComboBoxListOpen( PtWidget t *widget );
Description:
This function opens/drops down the list in a PtComboBox widget.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtComboBoxListClose()
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtCompound
PhAB icon:
None — not normally instantiated.
Public header:
<photon/PtCompound.h>
Description:
The PtCompound superclass provides the ability to combine widgets
into a compound. A compound widget can export its subordinate
children to let you get and set their resources, or it can block access to
them to provide a “canned” appearance.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer
PhAB icon:
None — not normally instantiated.
Public header:
<photon/PtContainer.h>
Description:
The PtContainer superclass provides anchoring, layout, and
geometry management for all container widgets. It also redirects
certain events — such as button press, release, repeat, and keys — to
the child that has focus.
New resources:
Pt BALLOONS ON
If a child widget has been assigned a balloon, pop up the
balloon as soon as the mouse pointer passes over the child
widget; otherwise delay the pop up for 1.25 seconds.
The four values in this structure determine the anchor offsets of each
of the container’s sides. (An anchor offset is the distance between the
anchoring side of the parent and corresponding side of the child.)
Depending on the anchor flags you specify, the offsets will be either
absolute or relative.
This resource controls the look and behavior of the container. Valid
bits include:
Pt DISABLE BALLOONS
Prevent balloons from being inflated in this or any child
container.
Pt HOTKEY TERMINATOR
Prevent hotkey searches from going to parents of this container.
Note that this flag works only if it’s set in a disjoint
container-class widget.
Pt HOTKEYS FIRST
Key events that reach this container are processed as hotkeys
before being passed to any children. If the key is a hotkey, the
event is consumed and isn’t passed to any children. Normally
the key is passed to the children and, if not consumed, is
processed as a hotkey.
Pt AUTO EXTENT
Cause the container to reextent when any of its children are
realized, moved, or resized.
Pt ENABLE CUA
Allow CUA keys to function in this container (and its children).
Pt CB BALLOONS
C type Pt type Default
PtBalloonCallback t * Link NULL
reason subtype
A value of Pt INFLATE BALLOON when the balloon
should be displayed, or Pt POP BALLOON when the
balloon should be removed.
Pt CB FILTER
C type Pt type Default
PtRawCallback t * Link NULL
☞ These callbacks are invoked before the event is passed to the child.
Contrast this resource with the Pt CB RAW resource defined for
PtWidget.
reason Pt CB FILTER
reason subtype
0 (not used).
PtRawCallback t cb;
PtArg t arg;
Pt CB RESIZE
A list of callbacks that the container invokes when its size changes.
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
reason Pt CB RESIZE
reason subtype
0 (not used).
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtDBContainer
PhAB icon:
t DBCont ain
Public header:
<photon/PtDBContainer.h>
Description:
The Double Buffer container creates a memory context and forces all
its children’s draws to be directed to that context. The resulting image
is then drawn as an image to the default draw context. The result is
flicker-free widgets/animations. The PtDBContainer widget uses a
block of shared memory large enough to hold an image the size of its
canvas and will also cause the render shared library to be loaded if not
already present.
New resources:
Pm PHS CONTEXT
Keeps the image in the Photon draw stream (PHS) as long as
possible
Pm IMAGE CONTEXT
Draws to the memory image immediately
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtCompound →
PtDivider
PhAB icon:
Public header:
<photon/PtDivider.h>
Description:
The PtDivider widget is a container that lays out its children like a
one-row or one-column PtGroup widget, but allows the user to resize
the children by dragging “handles” placed between the children.
Divider
handles
Divider handles
Two PtDivider widgets: one contains a scroll area and two lists, the other
contains some buttons.
New resources:
Possible values:
Pt DIVIDER NORESIZE
Don’t resize the children, just invoke the callback.
Pt DIVIDER RESIZE BOTH
Resize both widgets: the one to the left and to the right (or
above and below) the dragged handle. If this flag isn’t set, only
the left child will be resized and the right child will be moved.
Pt DIVIDER INVISIBLE
Never display the drag outline. This flag is useful mainly when
Pt DIVIDER NORESIZE is also set.
short from The left side or top of the child, depending on the
divider’s orientation.
Pt CB DIVIDER DRAG
C type Pt type Default
PtCallback t * Link NULL
A list of callbacks that are invoked after each drag event received by
the widget.
If the widget has the Pt CALLBACKS ACTIVE bit set in its
Pt ARG FLAGS resource, these callbacks are also invoked when the
size of a child is changed by a call to PtSetResources().
Inherited resources:
If PtDivider modifies an inherited resource, the “Default override”
column indicates the new value. If PtDivider inherits a resource
from PtGroup, the default value assigned by PtGroup is inherited
too; the “Default override” column shows this default value.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtGraphic → PtEllipse
PhAB icon:
Public header:
<photon/PtEllipse.h>
Description:
The PtEllipse class draws an ellipse.
A PtEllipse widget.
The bounding box of the ellipse, which determines its height and
width, is defined by two points. To set these points, use the
Pt ARG POINTS resource. These points are relative to the widget’s
Pt ARG ORIGIN. For more information, see PtGraphic.
If you don’t set these points, Pt ARG DIM determines the height and
width (see PtWidget).
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtCompound →
PtGenList → PtGenTree → PtFileSel
PhAB icon:
Public header:
<photon/PtFileSel.h>
Description:
The PtFileSel widget is a tree where items can be files, directories,
links to files or directories, or custom entries.
/usr/photon
appbuilder
apps
bin
ODrivers
crt
11
Aplib_s11
Pa.pc
Pg.IGS
Pg.chips
A PtFileSel widget.
user. Users can also use the widget to navigate a filesystem and
choose their own file and directory.
The items in the PtFileSel widget are displayed with images to
show what type of file they are. Directory items are expandable and
can show the files, directories and links under them. To expand and
collapse items, you can use the mouse or these keys:
PtGenTreeItem t gen
Used internally
short opened
A value that indicates whether the given directories’
children have already been allocated or not:
¯ Pt FS NEW DIR — an unallocated directory
¯ Pt FS OLD DIR — an allocated directory
..
ODrivers
crt
11
Aplib_s11
Pa.pc
Pg.IGS
Pg.chips
Pg.chipsdc
Pg.cirrblit
Pg.cirrnblit
In this mode, you can also turn on the “key seek” flag,
Pt FS SEEK KEY, which lets you use the keyboard to search for
a file. In this mode, the widget selects the next file or directory
whose name starts with a character that you type. The search is
case-sensitive and wraps to the top of the list if the character
isn’t found. Whenever you press a key, the
Pt CB FS SELECTION callback is invoked with a
reason subtype of Pt LIST SELECTION BROWSE.
The widget also has a useful feature in that it will display file
information including name, size, date, permissions, owner and
group. You can use the Pt ARG FS FORMAT resource to set the
amount and order of information displayed. A PtDivider widget is
automatically included in the file selector, along with a label for each
column you request.
If you want to override the default headers, create a PtDivider of
your own, add appropriate PtLabel widgets to it, and make the
divider a child of the file selector. The information you requested will
be displayed in the proper columns.
For example, if you create a PtDivider with the headings
“Filename”, “File size”, and “Modification time” as a child of a
PtFileSel widget and set the Pt ARG FS FORMAT to nsd, the
PtFileSel items would contain the name, size, and date information
in the proper columns, but your divider would be displayed.
By default, when you expand an item (directory) for the first time, the
directory is read and items are allocated. After this, when you
collapse and expand the item, the information is stored in memory to
remove the delay of reading a directory. You can refresh an item at
any time by using the Pt ARG FS REFRESH resource. You can also
set the Pt FS FREE ON COLLAPSE flag to cause a directory to be
re-read every time it’s expanded. Every time a new root directory is
set, all the previous items are freed.
If you plan to add items to the PtFileSel widget yourself by using
the PtFSAllocItem(), PtFSAddFirst(), and PtFSAddAfter()
convenience functions, you should have a state callback
(Pt CB FS STATE, subtype = Pt FS STATE START) that returns
Pt END.
☞ If you’re in tree mode and you get a state callback that is one of your
items (i.e. not from a filesystem), you should deal with the
expansion/collapse and return Pt END from the callback to prevent
PtFileSel from trying to find the item in the filesystem.
If you’re in single-level mode and you get a state callback for one of
your items (i.e. not from a filesystem), you should deal with the
expansion; it’s your responsibility to free all the previous items.
Return Pt END from the callback as mentioned above.
Examples
In the examples below, Pt FS ALL FLAGS is a value containing all the
flag bits. It’s used for a mask.
To display only directories, in tree mode:
...
PtSetArg(&args[0], Pt ARG FS FLAGS, Pt FS SHOW DIRS,
Pt FS ALL FLAGS);
PtSetArg(&args[1], Pt ARG FS ROOT DIR, "/", 0);
PtSetArg(&args[2], Pt ARG AREA, area, 0);
PtCreateWidget(PtFileSel, NULL, 3, args);
...
...
PtSetArg(&args[0], Pt ARG FS FLAGS,
Pt FS SINGLE LEVEL|Pt FS SHOW FILES| \
Pt FS KEY SEEK, Pt FS ALL FLAGS);
PtSetArg(&args[1], Pt ARG FS ROOT DIR, "/", 0);
PtSetArg(&args[2], Pt ARG AREA, area, 0);
PtCreateWidget(PtFileSel, NULL, 3, args);
...
...
PtSetArg(&args[0], Pt ARG FS FLAGS,
Pt FS SHOW DIRS|Pt FS SINGLE LEVEL,
Pt FS ALL FLAGS);
PtSetArg(&args[1], Pt ARG FS ROOT DIR, "/", 0);
PtSetArg(&args[2], Pt ARG AREA, area, 0);
PtCreateWidget(PtFileSel, NULL, 3, args);
...
...
PtSetArg(&args[0], Pt ARG FS FLAGS,
Pt FS SHOW DIRS|Pt FS SHOW FILES,
Pt FS ALL FLAGS);
PtSetArg(&args[1], Pt ARG FS ROOT DIR, "/", 0);
PtSetArg(&args[2], Pt ARG AREA, area, 0);
PtCreateWidget(PtFileSel, NULL, 3, args);
...
To show only hidden files (that is, a file whose name begins with a “.”
and isn’t normally displayed):
...
item = PtFSGetCurrent(fs);
if (item == NULL)
return(Pt CONTINUE);
it = (PtFileSelCallback t *)(info->cbdata);
Pt BLOCKED);
PtSetArg(&args[1], Pt ARG CURSOR TYPE,
Ph CURSOR INHERIT, 0);
}
PtSetResources(widget, 2, args);
return (Pt CONTINUE);
}
int main(void)
{
PtArg t args[10];
PtCallback t cb, cb2;
PhDim t win dim = { 300, 300 };
PhArea t area;
PtFileSelItem t *item;
area.size.w = 60;
area.size.h = 20;
area.pos.x = 230;
area.pos.y = 250;
cb.event f = quit;
PtSetArg( &args[0], Pt ARG AREA, &area, 0 );
PtSetArg( &args[1], Pt ARG TEXT STRING, "Quit", 0);
PtSetArg( &args[2], Pt CB ACTIVATE, &cb, 0);
button = PtCreateWidget( PtButton, window, 3, args );
PtRealizeWidget( window );
PtMainLoop();
return EXIT SUCCESS;
}
New resources:
continued. . .
Pt ARG FS FLAGS
C type Pt type Default
ulong t Scalar Pt FS SHOW DIRS | Pt FS SHOW FILES
Flags that control the appearance and behavior of the file selector:
Pt FS SHOW DIRS
Show directories.
Pt FS SHOW FILES
Show files.
Pt FS SHOW HIDDEN
Show hidden files or directories. This flag must be combined
with Pt FS SHOW FILES and/or Pt FS SHOW DIRS. A hidden
file or directory is one whose name begins with a period (.).
Pt FS SHOW ERRORS
Show files that had a read error.
Pt FS FREE ON COLLAPSE
Free items on every collapse. This means that every time an
item expands, all its child items are re-read from the disk.
Pt FS SINGLE LEVEL
Single-level mode, instead of tree mode. Directories and
possibly files are shown in one level with a .. item for moving
up directory levels.
Pt FS SEEK KEY
Keyboard seek mode, valid only for single-level mode. Type
characters to seek an item.
Pt ARG FS FORMAT
C type Pt type Default
char * String NULL
A string that’s used to set the order and amount of file information
displayed and optionally the initial size (in pixels) of each column
shown. The following information can be displayed for each item in
the widget by including the corresponding letter in the
Pt ARG FS FORMAT string:
To display: Specify:
name n
size (in bytes) s
size (in kbytes) k
date d
permissions p
owner o
group g
The s and k options are mutually exclusive. If you try to set both, the
first one found in the string is used and the other is ignored. The
maximum number of characters is 6; any extra ones are ignored.
If you wish to display only the filename and no divider at the top, set
this resource to NULL. To set the size of the column, specify a number
of pixels before the corresponding letter. For example, if you want to
have the name (100 pixels wide) and the date (200 pixels wide)
displayed, set the Pt ARG FS FORMAT resource as follows:
following constants are used to index into this array (the order shown
is the order the images appear in the array):
¯ Pt FS FILE — files
¯ Pt FS ERROR — errors
If you don’t want to change an image, specify NULL for that array
element. For example, to change the file image, set the Pt FS FILE
entry of the array to the image pointer and set all others to NULL.
For example, to change the Pt FS DIR OP and Pt FS FILE images:
PhImage t *images[7];
// assume you fill the below image structures
PhImage t new open image, new file image;
...
images[Pt FS DIR OP] = &new open image;
images[Pt FS DIR CL] = NULL;
images[Pt FS DLINK OP] = NULL;
images[Pt FS DLINK CL] = NULL;
images[Pt FS FILE] = &new file image;
images[Pt FS FLINK] = NULL;
images[Pt FS ERROR] = NULL;
before providing the images to the widget. If you do this, the memory
used for the images is released when the widget is unrealized or
destroyed.
Pt ARG FS REFRESH
C type Pt type Default
PtFileSelItem t * Pointer NULL
The root directory for the File Selector. The default value is NULL or
none.
Pt CB FS BKGD HANDLER
continued. . .
reason subtype
One of:
¯ Pt FS NEW ITEM — a new item is being added to the
widget; see below.
¯ Pt FS OLD ITEM — the PtFileSel widget is doing
intensive work and you may want to process events.
char name[] The name of the item being added to the widget.
If this callback returns Pt END, the item isn’t added. If you wish to
translate an item to another encoding, you should use PxTranslate...
functions to do so, copy the new string into name, and return
Pt CONTINUE. You may also wish to process events.
int
handler cb( PtWidget t *widget, void *data,
PtCallbackInfo t *info)
{
PtArg t args[1];
PtFileSelBkgdCallback t *it = (void *) info->cbdata;
int srctaken = 0, dstmade = 0;
char dst[NAME MAX * 3] = {""};
PtBkgdHandlerProcess();
return(Pt CONTINUE);
}
Pt CB FS SELECTION
C type Pt type Default
PtCallback t * Link NULL
reason Pt CB FS SELECTION
reason subtype
Depending on the selection mode, this is one of:
¯ Pt LIST SELECTION FINAL
¯ Pt LIST SELECTION BROWSE
¯ Pt LIST SELECTION CANCEL
Pt CB FS STATE
C type Pt type Default
PtCallback t * Link NULL
reason Pt CB FS STATE
reason subtype
Pt TREE COLLAPSING or Pt TREE EXPANDING.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Convenience functions:
The PtFileSel widget defines several convenience functions that
make it easier to use the file selector once it’s been created. Here’s a
brief overview:
PtFileSelection()
Creates a file-selector dialog similar to the
AWFileSelect widget. See the Photon Library
Reference.
PtFSAddAfter()
Inserts an item after the specified item.
PtFSAddFirst()
Adds a root item to the widget.
PtFSAllItems() Fills a buffer with pointers to all items.
PtFSAllocItem()
Creates an item for a file-selector widget.
PtFSClearSelection()
Clears the selection.
PtFSDamageItem()
Redraws an item.
PtFSExpandParents()
If any ancestors of the given item are collapsed, this
function tries to expand them.
PtFSFolderCollapse()
Collapses an expandable item (directory).
PtFSFolderExpand()
Expands an expandable item (directory).
PtFSFreeAllItems()
Unlinks and frees all items.
PtFSFreeItems()
Frees an unlinked item.
PtFSGetCurrent()
Gets the current item.
PtFSGetSelIndexes()
Fills a buffer with indexes.
PtFSItemIndex()
Calculates the index of the specified item.
PtFSRemoveChildren()
Unlinks all the children of a given item.
PtFSRemoveItem()
Unlinks an item.
PtFSRemoveList()
Unlinks the root item.
PtFSRootItem()
Returns the first root item of the file selector.
PtFSSelectedItems()
Fills a buffer with item pointers.
PtFSSetSelIndexes()
Sets the selection indexes.
PtFSUnselect()
Unselects the specified item.
PtFSUnselectNonBrothers()
Unselects all items that aren’t siblings of the
specified item.
Synopsis:
void PtFSAddAfter( PtWidget t *fs,
PtFileSelItem t *item,
PtFileSelItem t *brother );
Description:
This function inserts a list of items linked with the brother field.
PtFSAddAfter() assumes that item points to a list of items. The fs
variable points to a PtFileSel widget. The new items are added to
the specified file selector below the specified brother. This function
may be called with a NULL fs argument, as long as brother points to
an item that isn’t attached to any file selector widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFSAddFirst()
Synopsis:
void PtFSAddFirst( PtWidget t *fs,
PtFileSelItem t *item,
PtFileSelItem t *parent );
Description:
This function adds a list of items 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 the item is
added at the root level of the file selector before any existing items at
the root level. This is what happens when the Pt ARG FS ROOT DIR
resource is set.
This function may be called with a NULL fs argument, as long as
parent points to an item that isn’t attached to any file selector widget.
PtFSAddFirst() automatically sets the Pt TREE ITEM EXPANDABLE
flag in the parent item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFSAddAfter(), PtFSRootItem()
Synopsis:
PtFileSelItem t **PtFSAllItems(
PtWidget t *widget,
PtFileSelItem t **buffer );
Description:
This function fills a buffer with pointers to all items in the widget. If
buffer==NULL, the function allocates a buffer using malloc(), and the
buffer will be NULL-terminated. If buffer isn’t NULL, the function
won’t add a NULL to the end of it.
Returns:
A pointer to the buffer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtFileSelItem t * PtFSAllocItem(
PtFileSelWidget t *fs,
int type,
char const *info );
Description:
This function can be used to create a PtFileSelItem t for the
PtFileSel widget. It’s useful if your application can display items
that aren’t physically part of the filesystem. The parameters are as
follows:
Returns:
The allocated item pointer if successful, or NULL if an error occurred.
Examples:
Suppose you wish to add your own item. In the state callback you can
check the item’s fullpath to see if it’s the one you want to deal with
and if so, add your own items afterwards. Just return Pt END from the
Pt FS STATE START callback to prevent the widget from doing the
expansion.
// state callback, will use the reason to block the widget for
// large directory opens
int state cb( PtWidget t *widget,
struct fs dialog modal *user,
PtCallbackInfo t *info)
{
PtArg t args[3];
PtFileSelCallback t *it;
PtFileSelItem t *new item;
it = (PtFileSelCallback t *)(info->cbdata);
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtFSClearSelection( PtWidget t *widget );
Description:
This function clears the selection.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtFSDamageItem( PtWidget t *fs,
PtFileSelItem t *item );
Description:
Call this function to redraw an item when its data has changed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtFSExpandParents( PtWidget t *fs,
PtFileSelItem t *item,
PhEvent t *event );
Description:
This function tries to expand any collapsed ancestors of the given
item. The event is passed to PtFSFolderExpand().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtFSFolderCollapse( PtWidget t *fs,
PtFileSelItem t *item,
PhEvent t *event );
Description:
This function collapses the given item. The item must be expandable,
i.e. a directory item. The fs argument must point to the file selector
that contains the item or be NULL if the item doesn’t belong to any
file selector.
If fs isn’t NULL, its Pt CB FS STATE callback is invoked. The event
argument is the event that’s passed to the callback.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtFSFolderExpand( PtWidget t *fs,
PtFileSelItem t *item,
PhEvent t *event );
Description:
This function expands the given item. The fs argument must point to
the file selector that contains the item or be NULL if the item doesn’t
belong to any file selector.
If fs isn’t NULL, its Pt CB FS STATE callback is invoked. The event
argument is the event that’s passed to the callback. If the item isn’t
expanded, the return value will reflect that.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtFSFreeAllItems( PtWidget t const *fs );
Description:
This function unlinks and frees all items in the PtFileSel widget.
Note that this function is called automatically when a PtFileSel
widget is destroyed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtFSFreeItems( PtFileSelItem t *item );
Description:
This function frees the subtree item (the item together with its
brothers and their children). The function assumes that the items
don’t belong to any file selector — use the PtFSRemoveChildren(),
PtFSRemoveItem(), or PtFSRemoveList() function to remove the
subtree items from a file selector widget before freeing the subtree.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtFileSelItem t *PtFSGetCurrent(
PtWidget t const *widget );
Description:
This function returns a pointer to the current item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
unsigned short *PtFSGetSelIndexes(
PtWidget t *widget,
unsigned short *buffer );
Description:
This function fills a buffer with indexes of all the selected items in the
PtFileSel widget. The first item in the widget has an index of 1, not
0.
If buffer is NULL, the function allocates a buffer using malloc(), and
the buffer is zero-terminated.
If buffer is non-NULL, the function adds zero to the end only if there
are no selected items in the widget.
Returns:
A pointer to the buffer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtFSGoto( PtWidget t *fs,
PtFileSelItem t *item );
Description:
This function sets the current item and (if necessary) the current
position so that the new current item is visible. If item is NULL, there
will be no current item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtFSItemIndex( PtFileSelWidget t const *fs,
PtFileSelItem t const *item );
Description:
This function calculates the index of the given item within the fs. 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:
PtFileSelItem t *PtFSRemoveChildren(
PtFileSelItem t *item );
Description:
This function unlinks all the children of the specified item and returns
the pointer to the first of them. You can then give the pointer to the
PtFSFreeItems() function.
This function won’t collapse the item. If the children are visible,
NULL is returned. Call PtFSFolderCollapse() before
PtFSRemoveItem() to make sure that the item is collapsed.
Returns:
A pointer to the first child removed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtFSRemoveItem( PtWidget t *fs,
PtFileSelItem t *item );
Description:
This function unlinks the given item together with its children from its
parent and brothers (if any) and sets the item->parent and
item->brother fields to NULL.
The fs argument must point to the PtFileSel widget containing the
item, or be NULL if the item doesn’t belong to any file selector.
☞ If fs is NULL and the item has no parent but has a previous brother,
the function won’t be able to find the previous brother and will unlink
the item from its brother. The function does nothing if item->parent
and fs are both NULL.
PtFSRemoveItem() 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 PtFSRemoveList( PtWidget t *fs,
PtFileSelItem t *first );
Description:
This function unlinks the item first and its brothers (together with
their children) from their parent (and previous brother) and sets their
parent fields to NULL.
The fs argument must point to the PtFileSel widget that contains
the items, or be NULL if the items don’t belong to any file selector.
☞ If fs is NULL and first has no parent but has a previous brother, the
function won’t be able to find the previous brother and won’t be able
unlink first from its previous brother.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtFileSelItem t *PtFSRootItem(
PtFileSelWidget t const *fs );
Description:
This function returns a pointer to the first root item.
Returns:
A pointer to the first root item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtFSSelect( PtWidget t *widget,
PtFileSelItem t *item );
Description:
This function selects the given item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtFileSelItem t **PtFSSelectedItems(
PtWidget t *widget,
PtFileSelItem t **buffer );
Description:
This function fills a buffer with pointers to the currently selected
items:
Returns:
A pointer to the buffer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtFSSetSelIndexes( PtWidget t *widget,
const unsigned short *buffer,
int count );
Description:
This function sets the selection indexes. The function 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 indexes or indexes that are out of range.
☞ If the selection mode is Pt RANGE MODE, only the first index and the
count are used.
Returns:
The number of items selected.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtFSShow( PtWidget t *widget,
PtFileSelItem t *item );
Description:
This function sets the current position so that the given item is visible.
If item is NULL, the function does nothing. This allows you to do
something like this:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtFSUnselect( PtWidget t *widget,
PtFileSelItem t *item );
Description:
This function unselects the given item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtFSUnselectNonBrothers(
PtWidget t *widget,
PtFileSelItem t *item );
Description:
This function unselects all the items that aren’t siblings of the given
item. If item is NULL, the current item is used.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtFontSel
PhAB icon:
Public header:
<photon/PtFontSel.h>
Description:
The PtFontSel widget allows user selection of a font family, style,
and size. It provides a combobox for selecting the family, an editable
combobox for selecting the font size, and buttons for selecting bold,
italic, and anti-aliased styles.
Helvetica
AaBbCcXxYyZ z
A PtFontSel widget.
New resources:
Flags to filter the inclusion of font families in the selection dialog (see
PtFontSelection() in the Photon Library Reference). These flags may
be ORed together — the value Pt FONTSEL ALL FONTS is provided
to override this filtering:
The name of the initial font. This resource also reflects the currently
selected font.
Pt CB FONT MODIFY
C type Pt type Default
PtCallback t * Link NULL
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Convenience functions:
The PtFontSel class defines the following convenience function:
PtFontSelection()
Display a modal dialog for selecting a font. See the Photon
Library Reference.
Class hierarchy:
PtWidget → PtBasic → PtGauge
PhAB icon:
None — not normally instantiated.
Public header:
<photon/PtGauge.h>
Description:
The PtGauge superclass provides common resources for gauge-like
widgets, which are capable of displaying a range of values.
New resources:
Possible values:
Pt SHOW VALUE
Indicates whether or not the value of the gauge will be
displayed.
Pt VALUE XOR
XOR the value display with the background (i.e. invert the fill
of the type face).
Pt GAUGE MAX ON TOP
Pt GAUGE MAX ON RIGHT
Pt GAUGE MAX ON LEFT
Pt GAUGE MAX ON BOTTOM
The position of the maximum value.
The default setting for this resource is 0; that is, no flags have been
set.
The font used for displaying the value, title, and any other text.
¯ Pt HORIZONTAL
¯ Pt VERTICAL
Text prefixed to the value displayed. For example, Red: would result
in Red:35.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtCompound →
PtGenList
PhAB icon:
None — not normally instantiated.
Public header:
<photon/PtGenList.h>
Description:
The PtGenList class is a superclass for creating list widgets. It’s
discussed in more detail in Building Custom Widgets.
PtGenList handles a vertical, left-aligned list of rectangular items
that may have different sizes. You can select one or more items,
depending on the selection policy (see Pt ARG SELECTION MODE).
PtGenListItem t is the data structure used for the items.
A PtGenList widget can have one child, provided it’s a PtDivider
widget. In this case, PtGenList attaches a callback to the child so
that the columns are set automatically to match the children of
PtDivider The items are drawn below the PtDivider widget.
Some child classes of PtGenList, such as PtList and PtTree, use
Tab characters as column separators.
Using scrollbars
The PtGenList widget creates a scroll bar if the list’s area isn’t large
enough to display all the items in the list. By default, the scroll bar is
displayed only when necessary. This behavior is controlled by the
Pt LIST SCROLLBAR ALWAYS and (the default)
Pt LIST SCROLLBAR AS REQUIRED bits in the
Pt ARG LIST FLAGS resource.
You can set or get a limited number of resources (mainly the colors)
for the child PtScrollbar widget by using the list’s
Pt ARG LIST SB RES resource.
Mouse actions
Mouse actions depend on the current selection mode.
Keyboard actions
Keyboard actions depend on the current selection mode.
Key Action
Enter Result depends on value of Pt ARG SELECTION MODE
↑ Previous item
↓ Next item
Pg Up Previous page
Pg Dn Next page
Home First item
End Last item
New resources:
continued. . .
short flags; The flags define the alignment of the text. The
possible values are:
¯ Pt LIST COLUMN LEFT
Flags that control the appearance and behavior of the list. The
possible values are:
Pt LIST NOBLIT Don’t blit when the Pt ARG TOP ITEM POS
resource is changed.
Pt LIST SNAP Make the list snap to fit the number of items. Note
that the Pt LIST SNAP flag is cleared automatically
if the items in the list don’t have equal heights.
would be:
PtArg t tmp;
PtSetArg( &tmp, Pt ARG LIST SB RES, args, N );
PtGetResources( list, 1, &tmp );
If you drag in a list and move outside the widget, the list scrolls at a
rate determined by the number of “button repeats”. This resource
specifies the number of button repeats that must be received before
scrolling occurs. The default value is 2. To make the scrolling faster,
set this resource to 1; to make scrolling slower, set this resource to a
larger number.
The fill color for selected items. See PgColor t in the Photon
Library Reference.
Pt RANGE MODE
To select a range of items the user points to the first item, drags
to the last item in the range, then releases the mouse button.
When the user is dragging the mouse, the list can be scrolled.
You can OR one of these values with zero or more of the following
flags, which describe how the mouse and keyboard should work:
Note that zero isn’t a valid value for the selection mode, neither is a
mixture of predefined and compose values.
The “predefined” selection modes are equivalent to the following
compose modes:
The text color for selected items. See PgColor t in the Photon
Library Reference.
The item index that appears at the top of the list. (The first item is 1.)
Note that unless the widget has been held (using PtContainerHold()),
setting the Pt ARG TOP ITEM POS resource will cause the widget to
draw if damaged and possibly blit afterwards. The widget doesn’t blit
when its fill color is set to Pg TRANSPARENT.
Pt CB SCROLL MOVE
C type Pt type Default
PtCallback t * Link NULL
unsigned action;
A value indicating what happened — see
below.
int position; A value corresponding to the handle’s
location.
Pt SCROLL DECREMENT
The scrollbar handle position has been decreased by one
increment.
Pt SCROLL INCREMENT
The handle position has been increased by one increment.
Pt SCROLL PAGE INCREMENT
The handle position has been increased by one page.
Pt SCROLL TO MAX
The handle has been moved to the maximum value.
Pt SCROLL TO MIN
The handle has been moved to the minimum value.
Pt SCROLL DRAGGED
The handle is being dragged.
Pt SCROLL RELEASED
The handle has been released after having been dragged.
Pt SCROLL SET
The change of position is the result of a call to PtSetResources()
and the widget has the Pt CALLBACKS ACTIVE bit set in its
Pt ARG FLAGS resource.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Convenience functions:
Most of PtGenList’s convenience functions are useful only if you’re
creating a custom list widget; they’re described in the Creating a List
Widget chapter of the Building Custom Widget manual.
The following convenience functions and data structure are useful
when working with descendants of PtGenList:
PtGenListCreateTextBalloon()
Create a popup balloon for an item in the list.
PtGenListItem t
PtGenList item structure
PtGenListSetColumnBalloon()
Adjust the balloon text to correspond to a given column.
Synopsis:
PtWidget t *PtGenListCreateTextBalloon(
PtWidget t *widget,
PtWidget t *parent,
const PhArea t *area,
const char *string,
int column,
const char *font);
Description:
This function creates a PtLabel widget to be used as a popup
balloon for a list item. The arguments are as follows:
font Font for the label. If this is NULL, the font used for the
PtGenList widget is used.
Returns:
A pointer to the PtLabel widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
typedef struct Pt genlist item {
unsigned flags;
PhDim t size;
PtGenListItem t *next, *prev;
} PtGenListItem t;
Description:
This data structure describes an item in a PtGenList widget.
next, prev The widget uses these links to find the next and
previous items in the list.
Classification:
Photon
See also:
PtGenList, PtGenTree, PtGenTreeItem t, PtList,
PtTreeItem t
Building Custom Widgets
Synopsis:
PhArea t *PtGenListSetColumnBalloon(
PhArea t *area,
PtListColumn t const *column );
Description:
This function adjusts the area argument so that it corresponds to the
given column rather than the entire item. If column is NULL, area
won’t be modified.
Returns:
A pointer to the adjusted area.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtCompound →
PtGenList → PtGenTree
PhAB icon:
None — not normally instantiated.
Public header:
<photon/PtGenTree.h>
Description:
The PtGenTree widget displays a tree of items. When the user
expands an item, another list of items drops down from it. Additional
items can be added to an expandable item when it’s about to be
expanded. Expanded items can be collapsed, which results in the
exclusion of items from the displayed list.
The tree can actually be a “forest” — the widget can contain multiple
items at the root level. The root items are always visible (included on
the displayed list) because they don’t have a parent that could be
collapsed.
You can build a tree (or a “forest”) that isn’t linked to any widget and
then add the whole tree to a widget as a root or subtree. Alternatively,
you can add each item to the widget tree separately, but once the
widget is realized, you’ll have to use PtHold() and PtUpdate() to
avoid multiple redraws.
PtGenTreeItem t is the data structure used for the items. For more
information about this class, see Building Custom Widgets.
New resources:
Pt TREE TO RIGHT
Extend the items to the right edge of the widget.
Pt TREE TO LEFT
Extend the item background to the left edge.
PtGenTreeItem t *item;
For mouse events, the item pointed to
by the mouse or NULL if the mouse
doesn’t point to an item. For key
events, the item that is going to be the
current item after the event is normally
processed by the widget.
unsigned index;
The index of the item.
PhPoint t pos;
Pointer position relative to the item.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
continued. . .
Convenience functions:
PtGenTree’s convenience functions are useful only if you’re creating
a custom tree widget; they’re described in the Creating a Tree Widget
chapter of the Building Custom Widget manual.
PtGenTree defines the following data structure:
PtGenTreeItem t
PtGenTree item structure
Synopsis:
typedef struct Pt gentree item {
PtGenListItem t list;
struct Pt gentree item *father,
*son,
*brother;
PhDim t dim;
} PtGenTreeItem t;
Description:
This data structure describes an item in a PtGenTree widget.
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.
Classification:
Photon
See also:
PtGenList, PtGenListItem t, PtGenTree, PtTreeItem t
Building Custom Widgets
Class hierarchy:
PtWidget → PtBasic → PtGraphic
PhAB icon:
None — not normally instantiated.
Public header:
<photon/PtGraphic.h>
Description:
The PtGraphic superclass provides the common resources used by
all graphic widgets. Graphical widgets provide attributes for color,
fills, patterns, line thickness, joins, and much more.
When you want to incorporate simple, static drawings in your
interface, use the widgets subclassed to PtGraphic.
¯ lines
¯ rectangles
¯ ellipses
¯ arcs
¯ polylines
¯ points
You can build up a drawing by creating one widget for each of the
graphical primitives you need. You should create the widgets from
back to front, so that their stacking order is correct and they
consequently appear correct when drawn to the screen. You should
also place the widgets in a container widget (such as PtPane).
For explanations of the values you may specify for these resources,
see the documentation for PgSetStrokeCap() and PgSetStrokeJoin().
Most of the graphics primitives can also be configured to draw a
closed curve. When this is done, the interior of the primitive may also
be filled using the fill color and style associated with the widget to
determine. These fill attributes are specified using the following
resources defined by the PtBasic widget class:
Creating a drawing
To create a drawing composed of several graphical widgets, you
should first create a container-class widget to place the widgets in.
Normally, you set the border width and margins of the container to
zero.
At this point, you may create the graphics primitives and position
them within the container widget. You may choose to position and
size the graphics widgets in one of several ways, but the simplest is to
place them all at position (0,0), which is adequate for most purposes.
The origin resource, Pt ARG ORIGIN, provides a reference point or
datum for all the primitives added to the container-class widget. This
If you know the overall dimensions of the drawing, you may want to
explicitly set the dimensions of the graphics widgets as you create
them. You might also want to set the dimensions if you want to have a
standard symbol clipped to obtain a new shape. The figure below
illustrates how a five-pointed star will be drawn when
Pt ARG ORIGIN is set to (50,50) and the dimensions of the widget
are fixed at 101 x 101 pixels. The star will be constructed from this
set of points:
{(95, -31), (-58, 81), (0, -100), (58, 81), (-95, -31)}
Note the resulting bounding box of the widget as well as the origin of
If you don’t need special clipping, however, you should use the
graphics widget’s resize policy or another geometry management
mechanism to determine the widget’s size. The default resize policy
for graphics is Pt RESIZE ...AS REQUIRED for both the width and
height. To fix the dimensions of the widget as shown in the case
above, you have to override the default resize policy. For more
information, see the Pt ARG RESIZE FLAGS resource in the
description of PtWidget.
double ys = height;
PtWidget t *child = PtWidgetChildFront(wgt);
if (old extents)
{
xs = xs / old extents->w;
ys = ys / old extents->h;
newdim = *dim;
newdim.w *= xs;
newdim.h *= ys;
child = PtWidgetBrotherBehind(child);
}
}
return Pt CONTINUE;
}
when the parent resizes the sub-drawing within the resize callback
invoked on the parent.
A scaling function is required for all the graphics primitives. This
function calculates x and y scale factors based on the extents passed
in the call data. It then scales the Pt ARG ORIGIN resource and each
point in the Pt ARG POINTS array by the scale factors. the scaling
function doesn’t try to modify the scale factor to preserve a particular
aspect ratio because this has already been done by its parent’s resize
function. The scaling function is attached to the Pt CB RESCALE
callback of each graphics widget after the widget is created.
The scaling function must be called with new scale factors in both the
x and y directions. The simplest way to get the scale factors is to get
the container widget’s old and new dimensions. The scale factors can
then be expressed as the ratio between the old and new dimensions.
The sample callback function below shows a simple function for
rescaling graphics primitives. As with the resize function given
previously, the widget’s current dimensions are obtained from the
closure passed to the callback function as client data.
int rescale( PtWidget t *wgt, void *client data,
PtCallbackInfo t *info)
{
PhDim t *old extents = (PhDim t *)client data;
PhArea t *area = (PhArea t *)info->cbdata;
PhDim t *dim;
PhPoint t *points;
PhPoint t neworg, *org;
short *npoints;
PtArg t arg[3];
xs = xs / old extents->w;
ys = ys / old extents->h;
neworg.x = org->x * xs;
neworg.y = org->y * ys;
Taken together with the resizing function given previously, this can be
used to create a rescalable picture as in the example below. This
example creates a drawing using a PtGroup and populates it with
three ellipses and an arc to create a simple happy face.
main(int argc, char *argv[])
{
PtAppContext t app;
PtArg t args[8];
int nargs;
PtWidget t *window, *container widget, *widget;
PhPoint t face[] = { {0,0}, {100,100} };
PhPoint t eye[] = { {0,0}, {6,10} };
PhPoint t mouth[] = { {0,0}, {79,49} };
PhPoint t org;
PhDim t *dim;
int resize(PtWidget t *, void *,
PtCallbackInfo t *);
int rescale(PtWidget t *, void *,
PtCallbackInfo t *);
int realized(PtWidget t *, void *,
PtCallbackInfo t *);
nargs = 0;
dim = (PhDim t *)malloc(sizeof(PhDim t));
PtSetArg(&args[nargs], Pt ARG POINTS, face,
sizeof(face)/sizeof(face[0]));
nargs++;
PtSetArg(&args[nargs], Pt ARG FILL COLOR, Pg YELLOW, 0);
nargs++;
widget = PtCreateWidget(PtEllipse, container widget, nargs, args);
PtAddCallback(widget, Pt CB REALIZED, realized, dim);
PtAddCallback(widget, Pt CB RESCALE, rescale, dim);
nargs = 0;
dim = (PhDim t *)malloc(sizeof(PhDim t));
org.x = 10;
org.y = 30;
PtSetArg(&args[nargs], Pt ARG POINTS, mouth,
sizeof(mouth)/sizeof(mouth[0])); nargs++;
PtSetArg(&args[nargs], Pt ARG ORIGIN, &org, 0);
nargs++;
PtSetArg(&args[nargs], Pt ARG ARC START, 2300, 0);
nargs++;
PtSetArg(&args[nargs], Pt ARG ARC END, 3100, 0);
nargs++;
PtSetArg(&args[nargs], Pt ARG ARC TYPE, Pt ARC CHORD, 0);
nargs++;
PtSetArg(&args[nargs], Pt ARG FILL COLOR, Pg BLACK, 0);
nargs++;
widget = PtCreateWidget(PtArc, container widget, nargs, args);
PtAddCallback(widget, Pt CB REALIZED, realized, dim);
PtAddCallback(widget, Pt CB RESCALE, rescale, dim);
nargs = 0;
dim = (PhDim t *)malloc(sizeof(PhDim t));
org.x = 27;
org.y = 30;
PtSetArg(&args[nargs], Pt ARG POINTS, eye,
sizeof(eye)/sizeof(eye[0]));
nargs++;
PtSetArg(&args[nargs], Pt ARG ORIGIN, &org, 0);
nargs++;
PtSetArg(&args[nargs], Pt ARG FILL COLOR, Pg BLACK, 0);
nargs++;
widget = PtCreateWidget(PtEllipse, container widget, nargs, args);
PtAddCallback(widget, Pt CB REALIZED, realized, dim);
PtAddCallback(widget, Pt CB RESCALE, rescale, dim);
PtRealizeWidget(window);
PtMainLoop();
}
info = info;
To do this, calculate the two scale factors and use the minimum of the
two:
xs = new.x / old.x;
ys = new.x / old.x;
s = min(xs, ys);
Then scale the old dimensions by the value s to get the desired new
dimensions:
desired.x = s * old.x;
desired.y = s * old.x;
Now call the scaling function with the scale factors expressed by the
two dimensions, old, and desired.
You can easily modify the resize and scaling callback functions given
above to preserve the aspect ratio of all or part of a drawing. To do so,
change the closure to a structure that contains the widget dimensions
and change the callback functions accordingly.
The closure should also have a flag indicating whether or not the
aspect ratio is to be preserved. You could then add the following lines
after the calculation of the xs and ys scale factors:
The aspect ratio of the entire drawing in our happy face example can
be preserved by setting the preserve aspect flag on the closure for the
PtGroup widget alone.
return graphic;
}
PtCallbackInfo t *info)
{
PtArg t args[2];
PhDim t factor;
PhDim t *dim;
PhRect t rect;
Graphic *self = widget to graphic(w);
PhPoint t org;
PhPoint t *points;
int n;
PtBasicWidgetCanvas(PtWidgetParent(w), &rect);
factor = *dim;
return ( Pt CONTINUE );
}
PtBasicWidgetCanvas(PtWidgetParent(w), &prect);
PtBasicWidgetCanvas(w, &rect);
pos = self->pos;
dim = self->dim;
/* this is superfluous */
dim.w = ( dim.w * factor.w ) / 100;
dim.h = ( dim.h * factor.h ) / 100;
if (g)
{
pos = g->pos;
dim = g->dim;
child = PtWidgetBrotherBehind(child);
}
return ( Pt CONTINUE );
}
Graphic *graphic;
Graphic smiley = {{0,0}, {100,100}, {0,0}, NULL, 0};
Graphic face = {{0,0}, {100,100}, {0,0}, &face pts,
sizeof(face pts)/sizeof(face pts[0])};
Graphic left eye = {{27,30}, {7,11}, {0,0}, &eye pts,
sizeof(eye pts)/sizeof(eye pts[0])};
Graphic right eye = {{67,30}, {7,11}, {0,0}, &eye pts,
sizeof(eye pts)/sizeof(eye pts[0])};
Graphic mouth = {{10,30}, {80,50}, {0,0}, &mouth pts,
sizeof(mouth pts)/sizeof(mouth pts[0])};
dim.x = 200;
dim.y = 200;
PtSetArg(&args[0], Pt ARG DIM, &dim, 0);
graphic = &smiley;
nargs = 0;
PtSetArg(&args[nargs], Pt ARG ANCHOR FLAGS,
Pt LEFT ANCHORED LEFT|Pt RIGHT ANCHORED RIGHT|
Pt TOP ANCHORED TOP|Pt BOTTOM ANCHORED BOTTOM,
Pt IS ANCHORED); nargs++;
PtSetArg(&args[nargs], Pt ARG ANCHOR OFFSETS,
&offsets, 0); nargs++;
PtSetArg(&args[nargs], Pt ARG GROUP ORIENTATION,
Pt GROUP ASIS, 0); nargs++;
PtSetArg(&args[nargs], Pt ARG USER DATA, &graphic,
sizeof (Graphic *)); nargs++;
PtSetArg(&args[nargs], Pt ARG POS, &smiley.pos, 0);
nargs++;
PtSetArg(&args[nargs], Pt ARG DIM, &smiley.dim, 0);
nargs++;
drawing = PtCreateWidget(PtGroup, window, nargs, args);
PtAddCallback(drawing, Pt CB RESIZE, resize cb, NULL);
graphic = &face;
nargs = 0;
PtSetArg(&args[nargs], Pt ARG FILL COLOR, Pg YELLOW, 0);
nargs++;
PtSetArg(&args[nargs], Pt ARG USER DATA, &graphic,
sizeof (Graphic *)); nargs++;
PtSetArg(&args[nargs], Pt ARG POS, &face.pos, 0);
nargs++;
PtSetArg(&args[nargs], Pt ARG DIM, &face.dim, 0);
nargs++;
widget = PtCreateWidget(PtEllipse, drawing, nargs, args);
PtAddCallback(widget, Pt CB RESCALE, rescale cb, NULL);
graphic = &mouth;
nargs = 0;
PtSetArg(&args[nargs], Pt ARG ARC START, 2300, 0);
nargs++;
PtSetArg(&args[nargs], Pt ARG ARC END, 3100, 0);
nargs++;
PtSetArg(&args[nargs], Pt ARG ARC TYPE, Pt ARC CHORD, 0);
nargs++;
PtSetArg(&args[nargs], Pt ARG FILL COLOR, Pg BLACK, 0);
nargs++;
PtSetArg(&args[nargs], Pt ARG USER DATA, &graphic,
sizeof (Graphic *)); nargs++;
PtSetArg(&args[nargs], Pt ARG POS, &mouth.pos, 0);
nargs++;
PtSetArg(&args[nargs], Pt ARG DIM, &mouth.dim, 0);
nargs++;
widget = PtCreateWidget(PtArc, drawing, nargs, args);
PtAddCallback(widget, Pt CB RESCALE, rescale cb, NULL);
PtRealizeWidget(window);
PtMainLoop();
It’s important to realize the effect that the position, origin, and
positional coordinates have when rescaling the widget. This will
affect how you choose to use these resources when you create the
graphics widgets and how you scale these resources in your resizing
and scaling functions.
The sample resizing function shown here modifies the position of each
of its children, and the sample scaling function modifies the origin
and all the points that define the primitive. This makes the positions
of all sub-drawing and primitives scale along with the drawing itself.
Since the widget’s origin and position allow independent control over
the widget’s position in addition to its size, you have maximum
flexibility in rescaling drawings. To rescale the drawing’s elements
without altering their positions, scale the points that define the
primitive and leave the position and origin alone.
In general, you should alter the widget’s position to affect the position
of the bounding box for the primitive that it will be clipped to. Use
the origin to translate the primitive so that part of it will be clipped.
!
CAUTION: You should always scale graphics based on their original
set of points. If you don’t use the original points, the aspect will be
lost after scaling.
New resources:
continued. . .
An array of bytes that describes the on and off bits for stroke
operations.
A scaling factor that’s applied to each of the bits in the dash list to
determine the number of pixels for each dash. For information on
setting this factor, see PgSetStrokeDash() in the Photon Library
Reference.
Possible values:
Pt FLOAT POS
Adjusts the position and origin of the widget, but leaves the
graphic in place relative to the widget’s parent. The upper left
corner of the widget’s canvas will be at the upper left corner of
the bounding box described by the point array. Depending on
its resize policy, the widget may resize to fit the rendering.
Pt FLOAT ORIGIN
Adjusts the origin of the graphic, but leaves the widget in place
relative to its parent. The upper left corner of the bounding box
described by the point array will be at the upper left corner of
the widget’s canvas.
The default setting of this resource is 0; that is, no flags have been set.
Defines how the ends of thick lines are drawn; see PgSetStrokeCap().
Possible values:
¯ Pg BUTT CAP
¯ Pg ROUND CAP
¯ Pg SQUARE CAP
¯ Pg BEVEL JOIN
¯ Pg BUTT JOIN
¯ Pg MITER JOIN
¯ Pg ROUND JOIN
¯ Pg QROUND JOIN (quick rounded join)
Pt ARG ORIGIN
C type Pt type Default
PhPoint t Struct 0,0
An offset from the upper left corner of the widget’s canvas. The
graphic will be rendered with its origin at:
Pt ARG POINTS
C type Pt type Default
PhPoint t *, short Array NULL
Pt CB RESCALE
C type Pt type Default
PtCallback t * Link NULL
reason Pt CB RESCALE
reason subtype
0 (not used).
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtGrid
PhAB icon:
Public header:
<photon/PtGrid.h>
Description:
PtGrid draws a grid pattern via PgDrawGrid().
A PtGrid widget.
New resources:
continued. . .
An array of bytes that describes the on and off bits for stroke
operations (see PgSetStrokeDash() in the Library Reference).
Defines how the ends of thick lines are drawn; see PgSetStrokeCap()
in the Photon Library Reference. Possible values:
¯ Pg BUTT CAP
¯ Pg ROUND CAP
¯ Pg SQUARE CAP
¯ Pg BEVEL JOIN
¯ Pg BUTT JOIN
¯ Pg MITER JOIN
¯ Pg ROUND JOIN
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtGroup
PhAB icon:
None — use PhAB’s Group Together button in the speedbar:
Public header:
<photon/PtGroup.h>
Description:
The PtGroup class inherits the functionality of a container and
actively manages the geometry of its children: the children are
arranged in rows, columns, or a matrix, and PtGroup may give them
exclusive-selection behavior.
A group of buttons.
New resources:
Possible values:
Pt GROUP EXCLUSIVE
Allow only one child to be set at a time.
Pt GROUP NO KEYS
Prevent the group from using any keys (e.g. arrows).
The default setting of this resource is 0; that is, no flags have been set.
☞ Don’t set the Pt GROUP EQUAL SIZE ... and Pt GROUP STRETCH ...
flags for the same direction — the group will expand every time its
extent is calculated.
Determines how the children are aligned within the group. The
children retain their relative positions to each other. Possible values:
Possible values:
Pt GROUP ASIS
Don’t align children.
Pt GROUP HORIZONTAL
Align children in a row.
Pt GROUP VERTICAL
Align children in a column.
Not used for an “as is” group; see Pt ARG GROUP ORIENTATION,
above.
Determines how the children are aligned within the group. The
children retain their relative positions to each other. Possible values:
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtHtml
PhAB icon:
Public header:
<photon/PtHtml.h>
Description:
The PtHtml widget displays files containing the Hypertext Markup
Language (HTML).
Bookset overview
User’s Guide
If you’re using Photon for the first time, this guide is your starting point.
It tells you how to start Photon, move around in the workspace, and
use Photon applications.
A PtHtml widget.
Elements
The following table summarizes the HTML elements and attributes
supported by the PtHtml class.
For some of the elements, the end tag is optional and is indicated by
square brackets.
The attributes are shown with the possible attribute values. Where
more than one option is shown, one of them must be selected.
continued. . .
continued. . .
Entities
The PtHtml widget supports the standard HTML 1.0 and ISO-8859
character entities. An entity starts with an ampersand, is followed by
the entity name, and ends with a semicolon (e.g. © is rendered
as ).
PtHtml also supports the following entities:
Supporting images
To have the PtHtml widget support images, include code similar to
the following example somewhere in your program (e.g. in the
application’s init file):
/* image headers */
#define PX IMAGE MODULES
#define PX GIF SUPPORT
#define PX BMP SUPPORT
#include <photon/PxImage.h>
This will cause the code for displaying GIF and BMP images to be
linked into your program. For more information, see PxLoadImage()
in the Photon Library Reference.
Printing
To support printing, the html widget has a special page mode, which
you can set in the Pt ARG HTML FLAGS resource. When in page
mode, the widget tries to do a clean page break when the height of the
current page is greater than the vertical display area. The loaded file is
then divided into one or more pages.
The number of pages can be read from the Pt ARG HTML PAGES
resource. To display a particular page, you can set the
Pt ARG HTML PAGE N resource. To print the current page, you can
use the standard widget-printing mechanisms.
New resources:
continued. . .
continued. . .
The width of the inside border surrounding the canvas of the widget,
and the width of the border of the scrollbars. The width of the outside
border of the widget is set using the Pt ARG BORDER WIDTH
resource.
The RGB color value used to draw the background of the HTML
page.
Flags for changing the behavior of the widget. The possible values
are:
¯ Pt HTML PAGE MODE — put the widget into page mode for
printing.
For more information, see “Printing,” above.
When the widget is in page mode (i.e. Pt HTML PAGE MODE is set in
Pt ARG HTML FLAGS), this resource holds the current page number.
You can set this resource to display a particular page. For more
information, see “Printing,” above.
The horizontal position (in pixels) of the top-left hand corner of the
viewport relative to the rendered HTML page. Horizontal scrolling
changes the x position.
The vertical position (in pixels) of the top-left hand corner of the
viewport relative to the rendered HTML page. Vertical scrolling
changes the y position.
When the widget is in page mode (i.e. Pt HTML PAGE MODE is set in
Pt ARG HTML FLAGS), this resource holds the number of pages in
the current document. For more information, see “Printing,” above.
The RGB color value used to draw the slider of the scrollbars.
The RGB color value used to draw the trough of the scrollbars.
¯ Pt ALWAYS
¯ Pt NEVER
¯ Pt ALWAYS
¯ Pt NEVER
The width of the vertical scrollbar and the height of the horizontal
scrollbar, in pixels.
Pt CB HTML ERROR
C type Pt type Default
PtCallback t * Link NULL
A list of callbacks the widget invokes when the given URL can’t be
opened.
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
A list of callbacks that the widget invokes after loading an HTML file.
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
Pt CB HTML IMAGE
C type Pt type Default
PtCallback t * Link NULL
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Convenience functions:
The following convenience functions are defined by the PtHtml class
for accessing some of the data in the HTML file. Here’s a brief
overview:
Synopsis:
char * PtHtmlLink( PtWidget t *widget,
char *rel );
Description:
This function searches the current HTML file for the given widget,
looking for a <LINK> tag whose REL attribute matches the rel
argument. If the <LINK> tag is found, the function returns a pointer to
a string containing the href attribute.
For example, PtHtmlLink() would return the string sample.html if
called with the rel argument set to the string previous with the
following link tag in the HTML file:
Returns:
A pointer to the filename for the requested link, or NULL if the link
couldn’t be found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
char * PtHtmlTitle( PtWidget t * widget );
Description:
This function returns a pointer to a string containing the title of the
HTML file or NULL.
For example, PtHtmlTitle() returns the string This is the title
if the HTML file currently loaded by the widget has the following title
tag:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtWindow → PtIcon
PhAB icon:
None — use PhAB’s Icon module.
Public header:
<photon/PtIcon.h>
Description:
A PtIcon widget behaves like a window, providing a container for
image or bitmap widgets. Normally two icon images are placed into a
PtIcon — a large 43¢43 icon for display through the Photon
Desktop Manager, and a small 15¢15 icon for display in the PDM
Taskbar.
An icon.
Use PhAB’s Icon module instead of this widget. See “Icon modules”
in the Working with Modules chapter of the Photon Programmer’s
Guide.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtLabel
PhAB icon:
Public header:
<photon/PtLabel.h>
Description:
The PtLabel class provides a text string, bitmap, or image for
labeling other widgets. When you use PtLabel to display a bitmap
or image, you can have text pop up in a balloon to provide further
meaning to the image.
Enter string:
Creating labels
You create labels using the PtLabel widget class. You can use text
and images for the label. The default label type is a null-terminated
text string.
To specify the type of label you want, you must use the
Pt ARG LABEL TYPE resource. The possible values for this resource
are:
Pt TEXT IMAGE
The label will display an image and text. The
positioning of these two elements relative to each
other is determined by the
Pt ARG BALLOON POSITION resource.
The data for the label is specified in different ways for each type.
Different resources are used for the label data for different label types.
This is particularly useful when you wish to switch quickly between
image labels and text labels, so you can give the user a choice
between using icons and textual descriptions of operations.
At the push of a button, the user can switch your interface from an
iconic representation of commands (like the palette in the Photon
Application Builder) to a textual representation of the same labels.
The label is switched from an icon to text simply by changing the
label type resource.
Text labels
When the label type is textual, the label widget gets the text to be
displayed from the Pt ARG TEXT STRING resource.
To specify the font the label should be drawn with when text labels
are used, set the resource Pt ARG TEXT FONT to the name of the
font you want.
The label widget defines its own margins in addition to the margin
width defined by the PtBasic widget class. There are separate left,
right, top, and bottom margins, which are specified using these
resources:
These margins are cumulative, so that the actual margin of one edge
of the widget is the corresponding resource value added to the margin
width.
The text label may be aligned independently to the left or right
margin, or centered horizontally within the margins of the widget.
The Pt ARG HORIZONTAL ALIGNMENT resource controls this
behavior. The values to specify for this horizontal alignment are:
You can also control the vertical alignment, i.e. whether the text is
aligned to the widget’s top or bottom margin, or centered vertically
between the two margins. The Pt ARG VERTICAL ALIGNMENT
resource controls this behavior. The values to specify for the vertical
alignment are:
Normally, the text displayed in the label widget will be aligned to the
widget’s top and left margins. The baseline is calculated by adding
the ascender of the label font to the top margin. When text is aligned
to the bottom of the widget, the baseline is calculated by subtracting
the descender of the label font from the widget’s bottom margin.
You can align the baselines of labels drawn with different fonts by
selecting bottom alignment for each of the widgets and choosing
appropriate margins for them. In this case, make sure you specify a
widget height large enough to accommodate the height of the largest
font used.
The desired baseline for your aligned widgets will be adjusted by the
size of the maximum descender of all the fonts used. For each label,
add the difference between this descender and the descender of that
label’s font, then add this difference to the widget’s bottom margin.
Keep track of this value so that you can recalculate the correct margin
setting if you want to change the base margin or the font later on.
bpl The number of bytes used to encode each scan line. This
depends on the image type and size.
palette The color lookup table for determining the color of each
pixel in the image.
Balloons
Balloons are a very handy feature of the PtLabel widget class. You
use a balloon to display a line of text when the user’s pointer pauses
on top of a widget for more than a second.
This can be very useful in an application with a lot of labels or buttons
containing iconic images. Whenever the user pauses on an icon, a
little text box will pop up beside it to display the name or action the
icon represents.
To use balloons with label class widgets:
The Pt ARG TEXT STRING resource defines the text displayed in the
balloon. If the entire string is visible within the widget, you probably
don’t need to set the Pt SHOW BALLOON flag. If the label has been
New resources:
continued. . .
Lets you underline the accelerator key within the widget’s text string.
You typically use this resource for hotkeys.
Indicates where the label text will pop up. If Pt ARG LABEL TYPE is
Pt TEXT IMAGE, this reource controls the positioning of the text and
image elements relative to each other. Possible values:
¯ Pt BALLOON INPLACE
¯ Pt BALLOON TOP
¯ Pt BALLOON LEFT
¯ Pt BALLOON RIGHT
¯ Pt BALLOON BOTTOM
¯ Pt LEFT
¯ Pt CENTER
¯ Pt RIGHT
By default, when a user pauses the pointer over this widget, the
widget will display a small yellow balloon. If you want to change the
look or default text of the balloon, you can use this resource to
override the default inflate function.
Here’s a prototype of the inflate function:
PtWidget t * InflateBalloon( PtWidget t *window,
PtWidget t *widget,
int position,
char *text,
char *font,
PgColor t fill color,
PgColor t text color );
where:
You can use the supplied values in your inflate function or ignore
them and use your own values.
☞ Remember that this is an Alloc resource. When you set this resource,
the widget copies the PhImage t structure but not the data pointed to
by the members of the structure. After setting this resource, you can
free() the PhImage t if you don’t need it, but don’t free() the
members of it.
Possible values:
Pt BACKFILL TEXT
If this is set, the widget fills the text background with the
widget’s fill color before rendering the text.
Pt TEXT IMAGE
Display the image and text of the label. The
positioning of these two elements relative to each
other is determined by the
Pt ARG BALLOON POSITION resource.
The amount of space between the bottom of the label’s canvas and the
canvas defined by the basic widget.
The amount of space between the left side of the label’s canvas and
the canvas defined by the basic widget.
The amount of space between the right side of the label’s canvas and
the canvas defined by the basic widget.
The amount of space between the top of the label’s canvas and the
canvas defined by the basic widget.
The font used for the label’s text string; see PgSetFont().
Pt ARG UNDERLINE1
C type Pt type Default
unsigned short Scalar Pg BLACK
Pt ARG UNDERLINE2
C type Pt type Default
unsigned short Scalar Pg TRANSPARENT
The underline color for the second line (used to create thick or
beveled underlines).
¯ Pt NO ULINE
¯ Pt DOUBLE ULINE (use with underline color)
¯ Pt SINGLE ULINE (use with underline color)
¯ Pt ULINE ETCHED IN (use with border color)
¯ Pt ULINE ETCHED OUT (use with border color)
¯ Pt TOP
¯ Pt CENTER
¯ Pt BOTTOM
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtGraphic → PtLine
PhAB icon:
Public header:
<photon/PtLine.h>
Description:
The PtLine widget is used to create line primitives.
A PtLine widget.
Pt ARG ORIGIN
Origin for the line’s coordinate space.
Pt ARG POINTS
The line’s start and end points. If you don’t set these points, no
line is rendered.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtCompound →
PtGenList → PtList
PhAB icon:
Public header:
<photon/PtList.h>
Description:
The PtList class displays a scrolling list of text items. You can
select one or more items, depending on the selection policy.
Item 1
Item 2
Item 3
Limitations
PtList widgets have a few limitations:
¯ They display only text. If you want to display an image to the left
of each item, use a PtTree instead.
¯ All items are in the same font.
¯ All unselected items are the same color
With both methods, the Tab character is used in the item strings as a
column separator.
☞ Even if you use columns, each line in the list remains a single item.
When you click on any part of the line, the entire line is selected —
having columns doesn’t make the list into a spreadsheet.
Creating lists
If you know the list of available choices when you create the list, you
can specify it using the Pt ARG ITEMS resource. This resource takes
an array of null-terminated strings.
You should establish the selection policy for the list when it’s created.
The resource that controls the selection policy is
Pt ARG SEL MODE.
The default selection policy is browse selection mode, which is the
more user-friendly of the two selection modes that allow a single
selection.
PtArg t args[1];
short *num, i;
char **items = NULL;
Selection notification
The list widget uses the Pt CB SELECTION callback to notify your
application whenever the user has made a new selection. The cbdata
passed to the callback always contains a pointer to a
PtListCallback t structure. The selection policy in effect on the
widget at the time of the callback determines which members of the
structure are valid.
The mode member of the callback data structure indicates the
selection mode that caused the callback to be invoked.
Each index in the array refers to the original array of items maintained
by the Pt ARG ITEMS resource.
New resources:
Pt ARG ITEMS
C type Pt type Default
char **, short Array NULL
A function that inflates a balloon for the item the pointer is on.
PtListBalloonF t is a function type:
return
PtGenListCreateTextBalloon(
widget, parent,
PtGenListSetColumnBalloon ( area, col ),
item, coln, font);
Pt CB LIST INPUT
C type Pt type Default
PtCallback t * Link NULL
A list of callbacks that the widget invokes on each mouse and key
event. Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
PhPoint t pos;
Mouse position relative to the item
(valid only for mouse events).
char * item; For mouse events, the item under the
cursor. For key events, the item that
will be the current item after the event
is processed normally.
unsigned index;
The index of that item (the first item on
the list has an index of 1).
int consumed; Initially set to Pt CONTINUE. The
callback function can suppress normal
handling of the event by setting this
field to another value. In the case of key
events, a value of Pt END causes the
event to be consumed, while Pt HALT
passes the event to the parent widget.
Mouse events are always consumed.
Pt CB SELECTION
C type Pt type Default
PtCallback t * Link NULL
A list of callbacks that the widget invokes whenever the user selects
an item from the list. Each callback is passed a PtCallbackInfo t
structure that contains at least the following members:
reason subtype
This value depends on the value of
Pt ARG SELECTION MODE. In general, the value of
reason subtype is:
¯ Pt LIST SELECTION FINAL when the mouse button is
released inside the widget or the Enter is pressed
(selection is accepted).
¯ Pt LIST SELECTION CANCEL when the mouse button
is released outside the widget (previous state restored).
¯ Pt LIST SELECTION BROWSE when the mouse button
is held down, the space bar is used to select an item, or
arrow keys are being used to scroll through the list (a
selection is in the process of being made).
unsigned mode
The selection mode.
char *item The item just selected; see below.
int item len The length of the item, in bytes.
int item pos The position of the item in the array of
items in the list.
char **sel items
The list of selected items.
ushort t *sel array
An array of the selected positions within
the list.
int sel item count
The number of items in the sel items list
and the sel array list.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Convenience functions:
The PtList widget defines several convenience functions that make
it easier to use the list once it’s been created. Here’s a brief overview:
PtListAddItems()
Add one or more items to the list at a specified position.
PtListDeleteAllItems()
Remove all the items from the list.
PtListDeleteItemPos()
Delete a range of items by position.
PtListDeleteItems()
Delete items in the list by name.
PtListGotoPos()
Make the item at the specified position the current item and
display it.
PtListItemExists()
Determine whether or not an item exists within the list.
PtListItemPos()
Determine the position of an item within the list.
PtListRemovePositions()
Remove the items at the specified positions.
PtListReplaceItemPos()
Replace items by position number.
PtListReplaceItems()
Replace items by item text.
PtListSelectPos()
Select the item at the specified position.
PtListShowPos()
Display the item at the specified position.
PtListUnselectPos()
Unselect the item at the specified position.
Synopsis:
int PtListAddItems( PtWidget t *widget,
const char **items,
int item count,
unsigned int position );
Description:
This function lets you add one or more items to a list widget at a
specified position. The items argument points to an array of items and
item count indicates the number of strings in the array.
List positions start at 1, not 0. The 0 position indicates the last
position in the list; specifying this position appends the item or items
to the end of the list.
If you add new items in between existing items, the rest of the items
are moved down the list.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtListDeleteAllItems( PtWidget t *widget );
Description:
This function deletes all the items from a list.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtListDeleteItems(), PtListDeleteItemPos(), PtListRemovePositions()
Synopsis:
int PtListDeleteItemPos( PtWidget t *widget,
int item count,
int position );
Description:
This function deletes item count items from the list, starting from
position. The first item in the widget has an index of 1, not 0.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtListDeleteAllItems(), PtListDeleteItems(), PtListRemovePositions()
Synopsis:
int PtListDeleteItems( PtWidget t *widget,
const char **items,
int item count );
Description:
This function deletes each item in the items array from the list. The
item count argument indicates the number of strings in the array.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtListDeleteAllItems(), PtListDeleteItemPos(),
PtListRemovePositions()
Synopsis:
void PtListGotoPos( PtWidget t *widget,
int pos );
Description:
This function sets the current item and (if necessary) the current
position so that the new current item is visible. The first item in the
widget has an index of 1. If pos is 0, there will be no current item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtListShowPos()
Synopsis:
int PtListItemExists( PtWidget t *widget,
const char *item );
Description:
This function performs a linear search on the list for the specified
item.
Returns:
1 The item exists in the list.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtListItemPos()
Synopsis:
int PtListItemPos( PtWidget t *widget,
const char *item );
Description:
This function performs a linear search on the list for the specified
item. If it finds the item, the function returns the item’s position.
Otherwise, it returns 0.
Returns:
n The position of the item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtListItemExists()
Synopsis:
int PtListRemovePositions(
PtWidget t *widget,
const unsigned short *pos list,
int pos count );
Description:
This function deletes the item at each position specified in the array
pos list. The first item in the widget has an index of 1, not 0. The
pos count argument specifies the number of entries in the pos list
array.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtListDeleteAllItems(), PtListDeleteItemPos(), PtListDeleteItems()
Synopsis:
int PtListReplaceItemPos( PtWidget t *widget,
const char **new items,
int item count,
int position );
Description:
This function replaces item count items in the list with new items.
The position argument tells the function where to start. The first item
in the widget has an index of 1, not 0.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtListReplaceItems()
Synopsis:
int PtListReplaceItems( PtWidget t *widget,
const char **old items,
const char **new items,
int item count );
Description:
This function searches the entire list for each item in old items. Every
occurrence of each item found is replaced with the corresponding
new item. The search continues until item count is reached.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtListReplaceItemPos()
Synopsis:
void PtListSelectPos( PtWidget t *widget,
int pos );
Description:
This function selects the item at the given position. The first item in
the widget has an index of 1, not 0.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtListUnselectPos()
Synopsis:
void PtListShowPos( PtWidget t *widget,
int pos );
Description:
This function scrolls the list pointed to by widget to make the item
with the position given by pos visible. The first item in the widget has
an index of 1, not 0.
If the item is already visible, this function does nothing.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtListGotoPos()
Synopsis:
void PtListUnselectPos( PtWidget t *widget,
int pos );
Description:
This function unselects the item at the given position. The first item in
the widget has an index of 1, not 0.
PtListUnselectPos() has no effect if the Pt ARG SELECTION MODE
resource is set to Pt SELECTION MODE RANGE.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtListSelectPos()
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtGroup → PtMenu
PhAB icon:
None — use PhAB’s Menu module.
Public header:
<photon/PtMenu.h>
Description:
The PtMenu class provides popup and pulldown menus. Menus work
in either press-drag-release or click-move-click mode.
New Ctrl+N
Open... Ctrl+O
Save Ctrl+S
Save As...
Close
Import Files
Exit Ctrl+X
To make menu items selectable by the user, you must set the
Pt SELECTABLE flag in Pt ARG FLAGS (see PtWidget). PtMenu
will then set up callbacks on its children to alter their behavior where
necessary, thus ensuring that the children operate as the user expects.
For example, the children will automatically highlight in
press-drag-release mode.
If a menu item has a PtMenu widget as a child, and that child has the
Pt MENU CHILD bit set in its Pt ARG MENU FLAGS resource, the
child behaves as a submenu and will be realized when necessary.
Menus display a list of possible selections and allow the user to
choose one of them. The selections displayed in a menu are usually
pushbuttons that activate application functions, but they may also be
used to display toggle buttons, cascaded menu buttons that invoke
submenus, or any other selectable widget.
Most applications will have a menu bar (usually a PtMenuBar
widget), a horizontal bar across the top of the application window.
The menu bar will have a number of entries within it. Each of these
entries is a menu button with an associated pull-down menu. A menu
button appears as a label until it’s selected. When the menu button is
selected, the button’s border is etched so that it takes on the same 3-D
appearance as a pushbutton.
A menu button is selected by clicking it. This causes the pulldown
menu associated with the menu button to be activated or dropped
down.
A menu may also be activated or popped up in response to an event
such as a pointer-button press inside another type of widget. Known
as a popup menu, this type of menu normally appears at the current
pointer position.
¯ press-drag-release
¯ click-stay
Creating menus
To get either a pull-down or a popup menu, you must create a menu
pane. This container holds all the items in the menu. The pane is what
is actually displayed when the menu is activated.
You use the PtMenu widget class to create menu panes. The
Pt ARG MENU FLAGS resource controls the menu pane’s behavior
and appearance.
You use these flags to control:
You can specify a menu title to be displayed at the top of the menu
pane when the menu is activated. You can also specify the title’s font.
You use the Pt ARG MENU TITLE and
Pt ARG MENU TITLE FONT resources to specify these two title
attributes.
If you specify a title for the menu, it will appear visually distinct from
the menu’s selections by means of a separator placed below the title.
You can use the Pt ARG MENU TEXT FONT resource to control
what font is used for displaying menu items. This resource overrides
the normal default font for text items placed in the menu.
Sizing
Normally, the menu pane will be made wide enough to fit the widest
menu item placed within it, and all the menu items will be made this
size as well. The Pt MENU AUTO flag in the Pt ARG MENU FLAGS
resource controls menu sizing..
If you want to explicitly control the sizes of the menu items, you can
clear this flag — it’s then your responsibility to set the dimensions of
each menu item.
Lifetime
Pulldown menus
To create a pulldown menu, you must create the menu pane as a child
of the menu button. You must also attach a callback to the menu
button that pulls down the menu in response to a button press.
Attach the callback to the Pt CB ARM or Pt CB MENU callback list
so that both press-drag-release and click-stay modes will work, then
provide the pointer to the menu widget as the client data for the
callback.
Your callback must position the menu beneath the menu button and
make it appear. To do this, call PtPositionMenu() with the menu
widget as the first parameter, passing a NULL pointer as the second
parameter. This function determines the correct position for the menu,
knowing that its parent is a menu button. After this you can make the
menu appear by calling PtRealizeWidget(). For more information
about these functions, see the Photon Library Reference.
The following function can be used to display the pulldown menu:
int
postMenu( PtWidget t *w, void *client data,
PtCallbackInfo t *info)
{
if (client data)
{
PtWidget t *menu = (PtWidget t *)client data;
PtPositionMenu(menu, NULL);
PtRealizeWidget(menu);
}
return Pt CONTINUE;
}
In this example, the create file items() function creates the menu
items in the file menu.
Popup menus
Popup menus are frequently used in an application’s work area. Often
this area is not a container widget. In this case, you won’t create the
menu as a child of the work area itself. Instead, create the menu as a
child of the work area’s parent.
As with pulldown menus, you have to provide a callback function or
event handler to activate your popup menu. This callback has to
position the menu and make it appear.
If the widget that you wish to associate with the popup menu doesn’t
have a Pt CB ARM or Pt CB MENU callback list, the simplest way
to activate the menu is to associate an event handler with button-press
events. Provide the menu pointer to the event handler as client data.
The event handler should make sure that the appropriate menu button
was pressed before activating the menu.
The event handler should position the menu with a call to
PtPositionMenu(). In this case, it should pass the Photon event from
the PtCallbackInfo t structure as the second parameter to the
function. This identifies the pointer position where the menu should
be placed.
The following function illustrates how a popup menu can be activated:
int
postMenu( PtWidget t *w, void *client data,
PtCallbackInfo t *info)
{
PhEvent t *event = info ? info->event : NULL;
PhPointerEvent t *ptr = event ? (PhPointerEvent t *)
PhGetData(event) : NULL;
PtPositionMenu(menu, event);
PtRealizeWidget(menu);
}
return Pt CONTINUE;
}
The following code illustrates how you can create a popup and
activate it using the above function:
Cascaded menus
If you place a menu button in a menu pane and create a menu pane as
its child, you’ll get a cascaded submenu. Unlike pulldown menus or
popup menus, you don’t have to attach any callbacks to activate
submenus — they’re handled automatically.
You must, however, set a flag on the submenu’s menu pane to indicate
that it is a submenu. Set the Pt MENU CHILD flag on the
Pt ARG MENU FLAGS resource. If you want the submenu to appear
to the right of its parent — the conventional way that submenus
cascade — you’ll also have to set the Pt MENU RIGHT flag in the
menu button’s Pt ARG BUTTON TYPE resource.
We can now look at the create file items() function in our previous
example to see how it creates a cascaded submenu:
void create file items(PtWidget t *parent)
{
PtArg t arg[3];
PtWidget t *importButton, *importMenu;
PtCallback t quit callbacks[] = { {quit cb, NULL} };
PtCallback t noop[] = { {nop cb, NULL} };
int
post menu cb(PtWidget t *w, void *client data, PtCallbackInfo t *info)
{
PtArg t arg[4];
void *data;
PhArea t *area;
unsigned short *border;
unsigned short *flags;
if (client data)
{
PtWidget t *menu = (PtWidget t *)client data;
PtPositionMenu(menu, NULL);
PtRealizeWidget(menu);
}
return Pt CONTINUE;
}
int
popup menu cb(PtWidget t *w, void *client data, PtCallbackInfo t *info)
{
PhEvent t *event = info ? info->event : NULL;
PhPointerEvent t *ptr = event ? (PhPointerEvent t *)
PhGetData
(event) : NULL;
w = w;
PtPositionMenu(menu, event);
PtRealizeWidget(menu);
}
return Pt CONTINUE;
int
nop cb(PtWidget t *w, void *client data,
PtCallbackInfo t *info)
{
PtArg t arg[1];
char *text;
if (text)
printf("Pushed the %s button\n", text);
return Pt CONTINUE;
}
int
quit cb(PtWidget t *w, void *client data, PtCallbackInfo t *info)
{
w = w; client data = client data; info = info;
exit(0);
return Pt CONTINUE;
}
PtRealizeWidget(window);
workarea.w = 300;
workarea.h = 200;
pos.x = 0;
pos.y = group size->h + 2 * 2;
PtRealizeWidget(raw);
dim.w = workarea.w;
dim.h = workarea.h + group size->h + 2 * 2;
PtSetArg(&arg[0], Pt ARG DIM, &dim, 0);
PtSetResources(window, 1, arg);
PtMainLoop();
}
New resources:
continued. . .
Pt MENU AUTO
Make all items the same width.
Pt MENU TRANSIENT
Destroy menu on closing. The menu might be destroyed before
the selected menu item’s callback is invoked.
Pt MENU CHILD
Allow this menu to override its parent menu.
The font used for PtLabel-based menu items; see PgSetFont() in the
Photon Library Reference. This resource overrides the normal default
font for text items placed in the menu.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtGroup →
PtMenuBar
PhAB icon:
Public header:
<photon/PtMenuBar.h>
Description:
The PtMenuBar class provides alignment of menu buttons and cursor
key navigation through menus.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtCompound →
PtMenuButton
PhAB icon:
Public header:
<photon/PtMenuButton.h>
Description:
The PtMenuButton class displays text or images with optional
accelerator key text. Menu buttons are used to present menus from
within menu bars or other menus.
File
A PtMenuButton widget.
If you want an accelerator key, set the Pt ARG ACCEL KEY resource
that’s inherited from PtLabel. For example:
narg = 0;
PtSetArg (&args [narg++], Pt ARG TEXT STRING, "File", 0);
PtSetArg (&args [narg++], Pt ARG ACCEL KEY, "F", 0);
PtCreateWidget (PtMenuButton, database.menu, narg, args);
New resources:
Possible values:
Pt MENU TEXT
Display the accelerator text, if it’s defined.
Pt MENU RIGHT
Display the submenu to the right of the button.
Pt MENU DOWN
Display the submenu below the button.
Pt ARG OFFSET
C type Pt type Default
unsigned short Scalar 0
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtMessage
PhAB icon:
None — use PhAB’s Message module.
Public header:
<photon/PtMessage.h>
Description:
The PtMessage widget displays a text-based message in a popup
window. The message can include up to three optional buttons,
allowing the user to select a course of action.
Yes No Cancel
A PtMessage widget.
New resources:
continued. . .
The labels for the three optional buttons that are displayed below the
message. If no value is provided for Pt ARG MSG BUTTON1, the
default label of “Ok” is used. If no label is provided for the other two
buttons, they default to NULL, which means they won’t be displayed.
These defaults are useful for messages that simply provide
information.
You can assign a keyboard shortcut to each button. Simply place & in
front of the character that will act as the shortcut. For example, if you
specify &Save, the S will be underlined in the button. To select the
button, the user can press s or S.
Note that the function PtAskQuestion() duplicates the functionality of
the above example. For more information, see the Photon Library
Reference. This function also makes the PtMessage dialog work as a
modal dialog.
The number of the button that Esc is bound to. If the value is 0 (the
default), the Esc is disabled; otherwise the callback for the specified
button is invoked when Esc is pressed.
event The raw event that caused the the callback to be invoked.
Inherited resources:
Although this widget is a subclass of the PtContainer superclass,
the only inherited resource it uses is Pt ARG POS for positioning the
message:
Convenience functions:
The PtMessage widget defines a convenience function that makes it
easier to use the widget once it’s been created. Here’s a brief
overview:
PtMessageGetWindow()
Get the widget pointer to the message’s window
Synopsis:
PtWidget t *PtMessageGetWindow( PtWidget t const *widget );
Description:
This function retrieves a pointer to a PtMessage widget’s window.
Returns:
A pointer to the window, or NULL if widget doesn’t point to a
PtMessage widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtCompound →
PtMultiText
PhAB icon:
Public header:
<photon/PtMultiText.h>
Description:
The PtMultiText widget class provides display and entry of
multilined stylized text.
A PtMultiText widget.
Features
The MultiText widget provides many features that make it ideal for
multilined data entry fields or as the basis for an editor:
¯ range selection
¯ tab expansion
¯ anchoring
All these features can be controlled via the widget’s resources and
convenience functions. For example, to force the widget to wrap long
lines at word boundaries, set the Pt EMT WORD bit of the
Pt ARG MULTITEXT WRAP FLAGS resource:
Setting text
You can set the contents of the text buffer using the
Pt ARG TEXT STRING, Pt ARG TEXT SUBSTRING, or
Pt ARG MULTITEXT SEGMENTS resources, or the
PtTextModifyText() or PtMultiTextModifyText() convenience
functions. The PtMultiText widget automatically wraps the text
according to the wrap flags and displays scrollbars if the
Pt ARG SCROLLBAR X DISPLAY and/or
Pt ARG SCROLLBAR Y DISPLAY resources allow for them.
If you set the text using the Pt ARG TEXT STRING resource, the new
text replaces the entire text buffer of the widget, and all the lines of
text are drawn using the same attributes. The font is the one specified
by the Pt ARG TEXT FONT resource inherited from PtLabel. The
text foreground and background colors are taken from the values of
the Pt ARG COLOR and Pt ARG FILL COLOR resources.
If you set the text using Pt ARG TEXT SUBSTRING, only the
specified portion of the text buffer is affected. Text can be deleted
and/or inserted. The text inserted is drawn with the same attributes as
the text at the insertion point.
Text attributes
You can control the following attributes of a range of text:
¯ font
¯ text color
¯ background color
There are several methods for setting the attributes that affect a given
range of text:
¯ Change the attributes of a range of text that’s already there via the
Pt ARG MULTITEXT RANGE ATTRIBUTES resource or the
PtTextModifyText() convenience function. The attributes are set
with the PtMultiTextAttributes t structure.
¯ Define the ranges of text in advance (along with the associated set
of attributes) and place them in the text buffer by setting the
Pt ARG MULTITEXT SEGMENTS resource. This is an easy way
to initialize the PtMultiText widget with a catchy message.
When setting the text and attributes via the
Pt ARG MULTITEXT SEGMENTS resource, you provide the
resource with an array of PtMultiLines t structures. Each
element of the array has a text string and an associated set of
attributes that are used when displaying the text.
#include <stdio.h>
#include <stdlib.h>
#include <Pt.h>
#include <Ph.h>
PtMultiLines t hello[] = {
{ "Hello\n", Pt DEFAULT FONT, Pt DEFAULT COLOR,
Pt INHERIT COLOR },
{ "World!", "time24", Pg BLUE, Pt INHERIT COLOR }
};
main() {
PtWidget t *window;
PtArg t args[2];
int nargs = 0;
PhDim t dim = { 300, 150 };
PtRealizeWidget( window );
PtMainLoop();
}
#include <stdio.h>
#include <stdlib.h>
#include <Pt.h>
#include <Ph.h>
main()
{
PtWidget t *window, *mtext;
PtArg t args[2];
int nargs = 0;
PhDim t dim = { 300, 150 };
PtMultiTextAttributes t attr;
PtRealizeWidget( window );
PtMainLoop();
}
PtMultiTextAttributes t attr;
int start, end;
This code segment first determines the start and end of the text
selection by calling PtTextGetSelection(). This gives the start and end
positions to use in a subsequent call to PtMultiTextModifyAttributes().
The following example shows how to change the font of the text
selection to helv14 using the
Pt ARG MULTITEXT RANGE ATTRIBUTES resource.
PtMultiTextAttributes t attr;
PtMultiTextControl t mtc;
PtTextCallback t tc
Text control structure used to control the modification of text.
This is always present in the modification callbacks of PtText
or PtMultiText widgets. The members of
PtTextCallback t (also known as PtTextControl t) are:
PtMultiTextAttributes t *attributes
This structure describes a set of attributes. See
PtMultiTextAttributes t.
PtMultiTextSegment t *seg
Valid only in callbacks from the PtMultiText widget. It
points to the segment of text that’s involved in the modification
that caused the callback. See PtMultiTextSegment t.
If you implement editing functions that allow operations that alter the
attributes of fonts in text ranges, you should always obtain the current
attributes in effect at the start of each range and make changes based
on those.
2 Check the event to see if the appropriate event type caused the
callback to be invoked (i.e. a pointer-button press).
You can refine this technique further by changing the callback so that
it registers only an event handler that invokes the action associated
with the hypertext link, then deregisters itself. This lets you define
more complex behavior (e.g. proper “activate” behavior for the link).
In this case, the link is followed only if the user releases the pointer
button when the pointer is over the link.
When dealing with structured text such as hypertext, it’s a good idea
to break the text down into nodes. Define a data structure for these
nodes, defining the type of node and any data associated with the
node. Create a range of text for each node, attaching a pointer to the
node as the Pt MT TAG attribute for the range, and add the range to
the widget. The text’s original structure can be obtained in callbacks
by looking at the tag in the attributes member of the callback data
structure.
The following illustrates a simple node structure, allowing either plain
text or a hypertext link:
int
follow link(PtWidget t *widget, void *client data,
PtCallbackInfo t *info)
{
PtMultiTextCallback t *cbs =
(PtTextCallback t *)info->cbdata;
void
init text(PtWidget t *text)
{
PtMultiTextAttributes t reg, hyper;
int nlines;
PtMultiTextCreateAttributes(®);
PtMultiTextCreateAttributes(&hyper);
hyper.text color = Pg DGREEN;
for (nlines = 0; nlines < sizeof(lines)/
sizeof(lines[0]); nlines++)
{
PtMultiTextAttributes t *attr =
lines[nlines].node.type == tnHyper ? &hyper
: ®
Widget dimensions
As for all widgets, Pt ARG DIM holds the dimensions of a
PtMultiText widget. For example, suppose you have a multitext
widget that can show four lines of text. If the user types more than
four lines, say six lines, the widget displays a scrollbar to let the user
know there are more than lines. Querying Pt ARG DIM gives the
dimension of the four lines of text.
If you need to determine the dimensions of the entire text — the six
lines in our example — you’ll need to calculate it as described below:
Use the Pt ARG MULTITEXT QUERY LINE resource to query the
first line (line 1). This gives you information in the form of a
PtMultiTextQuery t structure, which contains a pointer to a
PtMultiTextLine t structure. The PtMultiTextLine t
The lines are organized as a linked list, using the next and previous
pointers in the PtMultiTextLine t structure. Traverse all the lines
until the next pointer is NULL, calculating:
When you’ve examined all the lines, you’ll have the “virtual
dimensions” of the text input area (i.e. the area that the text would
occupy if it had enough room to do so)
If you have only one font in the PtMultiText widget, the method of
finding the dimensions can be simplified. For example, to find the
virtual height, calculate the height of the first line and multiply it by
the number of lines.
New resources:
continued. . .
see
below)
Pt ARG MULTITEXT SEGMENTS PtMultiLines t, short Array None
(write-
only)
Pt ARG MULTITEXT TABS int, int Array {20}
Pt ARG MULTITEXT TOP LINE long Scalar 1
Pt ARG MULTITEXT WRAP FLAGS short Flag See
below
Pt ARG MULTITEXT X SCROLL POS short Scalar 0
Pt ARG MULTITEXT Y SCROLL POS long Scalar 1
Pt ARG SCROLLBAR X DISPLAY unsigned short Scalar Pt NEVER
continued. . .
Set the bottom line (top line + number of visible lines -1).
Flags that affect the appearance and behavior of the widget. The valid
bits are:
Pt EMT AUTOINDENT
When Enter is pressed, the new line is indented to match the
previous line by duplicating any leading whitespace characters.
The line number of the last line in the buffer. The first line is line 1,
not 0.
¯ Pt MT FONT
¯ Pt MT FOREGROUND
¯ Pt MT TEXT COLOR
¯ Pt MT BACKGROUND
¯ Pt MT BACKGROUND COLOR
¯ Pt MT TAG
¯ Pt MT FLAGS
Specifies the number of rows. Setting this resource sets the widget’s
height dimension based on the height of the current font and number
of rows specified. There’s no default value for this resource because
the widget initially uses its dimension to determine the number of
rows.
Set or get the top line or vertical scroll position, in lines (where the
first line is line 1).
This resource controls how the multitext widget wraps. The possible
values are:
Pt EMT WORD
Wrap on word breaks.
Pt EMT CHAR
Wrap at the end of the line.
Pt EMT NEWLINE
Wrap on carriage returns.
If both the word and character wrap flags are on, word wrapping is
applied.
(The same as Pt ARG MULTITEXT TOP LINE.) Set or get the top
line or vertical scroll position in lines. (The first line is line 1.)
¯ Pt NEVER (default)
¯ Pt AS REQUIRED
¯ Pt ALWAYS
¯ Pt NEVER (default)
¯ Pt AS REQUIRED
¯ Pt ALWAYS
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
continued. . .
Pt CB ACTIVATE
Pt CB ACTIVATE is inherited from PtBasic, but its behavior is
different for a PtMultiText widget. Each callback is passed a
PtCallbackInfo t structure that contains at least the following
members:
reason Pt CB ACTIVATE
reason subtype
Indicates why the callback was invoked:
¯ 0 — the user clicked on the widget and it has
Pt SELECTABLE set in its Pt ARG FLAGS.
¯ Pt EDIT ACTIVATE — the user pressed Enter in the
text field.
¯ Pt CHANGE ACTIVATE — the text was modified, the
widget lost focus, and Pt CHANGE ACTIVATE is set in
the widget’s Pt ARG TEXT FLAGS (inherited from
PtText).
Pt CB MODIFY VERIFY
Pt CB MODIFY VERIFY (Pt CB MODIFY NOTIFY), is inherited
from PtText, but the cbdata member of the callback information is
different for a PtMultiText widget.
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
Pt CB MOTION VERIFY
Pt CB MOTION VERIFY (Pt CB MODIFY NOTIFY), is inherited
from PtText, but the cbdata member of the callback information is
different for a PtMultiText widget.
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
¯ The application set a resource on this widget that affects the cursor
position.
Or:
Convenience functions:
The PtMultiText widget defines several convenience functions and
data structures that make it easier to use the widget once it’s been
created. Here’s a brief overview:
PtMultiLines t
Structure for setting multiline text and attributes
PtMultiTextAttributes t
Attributes for multiline text
PtMultiTextCallback t, PtMultiTextControl t
Information passed to PtMultiText callbacks
PtMultiTextCreateAttributes()
Initializes a multitext attribute structure.
PtMultiTextGetAttributes()
Gets the attributes of a PtMultiText widget.
PtMultiTextInfo()
Gets character/line information from a PtMultiText widget.
PtMultiTextInfo t
Information passed to PtMultiText callbacks
PtMultiTextLine t
Information about a line of text in a PtMultiText
PtMultiTextModifyAttributes()
Modifies the attributes of a PtMultiText widget.
PtMultiTextModifyText()
Modifies the contents of a PtMultiText widget.
PtMultiTextQuery t
Structure for getting information about a line or character
PtMultiTextSegment t
Information about a segment of text in a PtMultiText
PtTextGetSelection()
Gets the selected range from a PtText widget.
PtTextModifyText()
Modifies the contents of a PtText widget.
PtTextSetSelection()
Sets the selected range for a PtText widget.
Synopsis:
typedef struct
{
char * string;
char * font;
PgColor t text color;
PgColor t background color;
} PtMultiLines t;
Description:
This structure is used to specify multiline text and its attributes. An
array composed of of this structure can be passed to the
PtMultiText widget’s Pt ARG MULTITEXT SEGMENTS resource.
The members include:
Pt INHERIT FONT
Use the same font as the previous range.
Pt DEFAULT FONT
Use the value of the Pt ARG TEXT FONT
resource.
Pt INHERIT COLOR
Use the same color as the previous range.
Pt DEFAULT COLOR
Use the value of the Pt ARG COLOR resource.
background color
The color used as a background for the text. This must
be set to a valid color (i.e. a variable of type
PgColor t) or one of the following special values:
Pt INHERIT COLOR
Use the same color as the previous range.
Pt DEFAULT COLOR
Use the value of the Pt ARG FILL COLOR
resource.
Classification:
Photon
See also:
PtMultiText, PtMultiTextAttributes t
Synopsis:
typedef struct
{
char * font;
PgColor t text color;
PgColor t background color;
int flags;
void * tag;
} PtMultiTextAttributes t;
Description:
This structure describes a set of attributes for multiline text:
Pt INHERIT FONT
Use the same font as the previous range.
Pt DEFAULT FONT
Use the value of the Pt ARG TEXT FONT
resource.
☞
To make text bold/italic, change the font to a bold/italic typeface.
Pt INHERIT COLOR
Use the same color as the previous range.
Pt DEFAULT COLOR
Use the value of the Pt ARG COLOR resource.
background color
The color used as a background for the text. This must
be set to a valid color (i.e. a variable of type
PgColor t) or one of the following special values:
Pt INHERIT COLOR
Use the same color as the previous range.
Pt DEFAULT COLOR
Use the value of the Pt ARG FILL COLOR
resource.
Classification:
Photon
See also:
PtMultiText, PtMultiTextInfo()
Description:
PtMultiTextCallback t, PtMultiTextControl t, and
PtMultiTextInfo t are different names for the same structure.
They’re used in callbacks for the PtMultiText widgets as well as to
specify actions or request data. The members of these structures are:
Classification:
Photon
Synopsis:
PtMultiTextAttributes t *
PtMultiTextCreateAttributes(
PtMultiTextAttributes t *attrs);
Description:
This function initializes the specified PtMultiTextAttributes t
structure to default values. If you don’t specify a
PtMultiTextAttributes t structure, one is allocated and
initialized.
Returns:
A pointer to the initialized attributes structure, or NULL if no memory
was available.
Examples:
See PtMultiTextGetAttributes().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTextGetSelection(), PtTextModifyText(), PtTextSetSelection(),
PtMultiTextAttributes t
Synopsis:
PtMultiTextAttributes t *
PtMultiTextGetAttributes(
PtWidget t *widget,
int char offset,
PtMultiTextAttributes t *attributes,
int *start,
int *end );
Description:
This function sets the provided PtMultiTextAttributes t
structure to the attributes found at char offset.
If you provide the integers for start and end, the function sets these
parameters to the character offsets that mark the beginning and end of
the segment that contains char offset. Both start and end are 0-based.
So, for example, if start returns as 0, it indicates the first character in
the widget’s text buffer.
Returns:
A pointer to the provided PtMultiTextAttributes t structure, or
NULL if the specified widget is NULL or isn’t a PtMultiText
widget.
Examples:
/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
/* Toolkit headers */
#include <Ph.h>
#include <Pt.h>
#include <Ap.h>
/* Local headers */
#include "editor.h"
#include "abimport.h"
#include "proto.h"
int
save( PtWidget t *widget, ApInfo t *apinfo,
PtCallbackInfo t *cbinfo )
{
PtArg t argt;
FILE *fp;
char *text;
PtMultiTextAttributes t attrs;
int start = 0, end = 0, len;
return Pt CONTINUE;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtMultiTextCreateAttributes(), PtTextGetSelection(),
PtTextModifyText(), PtTextSetSelection(),
PtMultiTextAttributes t
Synopsis:
int PtMultiTextInfo( PtWidget t *widget,
int query type,
int *char offset,
int *line num,
PtMultiTextLine t *line,
int *start,
int *end,
int *length,
PtMultiTextSegment t *seg,
PtMultiTextAttributes t *attrs);
Description:
This function gets information about a character or line within a
PtMultiText widget.
Using the information returned in the provided integers and in the
PtMultiTextLine t, PtMultiTextSegment t, and
PtMultiTextAttributes t structures, you can determine:
☞ The returned data may not remain valid for very long, so you should
use it immediately!
¯ line num must point to an instance of an int that specifies the line
number on which information will be collected (the widget’s first
line is line 1, its second is line 2, and so on)
¯ line num will be set to the last line if the widget has fewer than
line num lines
¯ char offset will be set to the last character if the widget has fewer
than char offset characters
Here’s what the function will return when you provide a pointer to
any of the following parameters:
You could use this function to scroll to a specific line. For example, if
you set Pt ARG CURSOR POSITION to the offset of a character on
line 35, the widget will scroll to line 35. (The PtMultiText widget
will scroll as necessary, horizontally and vertically, to make the cursor
visible).
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTextGetSelection(), PtTextModifyText(), PtTextSetSelection(),
PtMultiTextAttributes t
Synopsis:
typedef struct Pt emt text line
{
unsigned int first char;
unsigned int byte offset;
ushort t num chars;
PhRect t extent;
PtMultiTextSegment t *segment;
struct Pt emt text line *prev;
struct Pt emt text line *next;
} PtMultiTextLine t;
Description:
The PtMultiTextLine t structure describes a line of text as
displayed in a PtMultiText widget.
The members include:
first char The index into the entire string of the first character on
the line.
byte offset The offset into the entire string of the first character on
the line, in bytes.
Classification:
Photon
See also:
PtMultiText, PtMultiTextInfo(), PtMultiTextSegment t
Synopsis:
void PtMultiTextModifyAttributes(
PtWidget t *widget,
int start,
int end,
PtMultiTextAttributes t const *attrs,
int attributes mask );
Description:
This function applies attributes to a range of characters within the
specified PtMultiText widget. All characters from start up to, but
not including, end are affected.
The attributes that this function applies are taken from the provided
PtMultiTextAttributes t structure. Only the attributes specified
in attributes mask are applied. The valid bits for this mask are:
¯ Pt MT FONT
¯ Pt MT FOREGROUND
¯ Pt MT TEXT COLOR
¯ Pt MT BACKGROUND
¯ Pt MT BACKGROUND COLOR
¯ Pt MT TAG
¯ Pt MT FLAGS
Examples:
See PtMultiTextGetAttributes().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTextGetSelection(), PtTextModifyText(), PtTextSetSelection(),
PtMultiTextAttributes t
Synopsis:
void PtMultiTextModifyText(
PtWidget t *widget,
int start,
int end,
int insert pos,
char *text,
int length,
PtMultiTextAttributes t const *attrs,
int attributes mask );
Description:
This function modifies the contents and attributes of a PtMultiText
widget.
If start doesn’t equal end, then:
¯ all characters from start up to but not including end are deleted
¯ the widget’s current insert position is set to the lesser of start and
end
¯ no text is deleted
¯ the widget’s current insert position is set to insert pos; if insert pos
equals -1, the current insert position is set to the end of the
widget’s text buffer.
Once the current insert position is set, the function inserts length
characters from text. It does this regardless of the widget’s insertion
mode. If length is 0, no text is inserted.
Here’s what happens after the function inserts the text into the
segment that contains the current insert position:
2 The text is separated into its own segment, but keeps its
inherited values.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTextGetSelection(), PtTextModifyText(), PtTextSetSelection(),
PtMultiTextAttributes t
Synopsis:
typedef struct
{
int character number;
int line number;
PtMultiTextLine t *line;
PtMultiTextSegment t *segment;
char *character;
} PtMultiTextQuery t;
Description:
This structure is used to get information about a specified line or
character in a PtMultiText widget. It’s used when getting the
Pt ARG MULTITEXT QUERY CHARACTER or
Pt ARG MULTITEXT QUERY LINE resource. When getting these
resources, the len member of the PtArg t structure indicates the
character or line to be queried. When you get call PtGetResources(),
the members of the PtMultiTextQuery t structure are filled in:
character number
The index into the string of the character queried.
Characters are numbered from 0.
line number The index of the line queried. Lines are numbered
from 1.
Classification:
Photon
See also:
PtMultiText, PtMultiTextSegment t, PtMultiTextLine t
Synopsis:
typedef struct Pt emt text segment
{
PtMultiTextAttributes t attrs;
int first char;
int num chars;
struct Pt emt text segment *prev;
struct Pt emt text segment *next;
} PtMultiTextSegment t;
Description:
This structure that describes a segment of text in a PtMultiText
widget. A segment is a block of text for which some attributes (such
as color and font) are set. Its members are:
Classification:
Photon
See also:
PtMultiText, PtMultiTextAttributes t
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtCompound →
PtNumeric
PhAB icon:
None — not normally instantiated.
Public header:
<photon/PtNumeric.h>
Description:
PtNumeric is a parent class for all numeric widgets. It creates a
PtText widget and a PtUpDown widget to allow the user to interact
with the widget. It also creates some of the base functionality of
numeric widgets.
New resources:
continued. . .
Pt NUMERIC HEXADECIMAL
Display the value as a hexadecimal number (applies only to
PtNumericInteger).
Pt NUMERIC WRAP
Wrap numbers from minimum to maximum and from
maximum to minimum.
The spacing, in pixels, between the text field and the up/down buttons.
Valid flags:
Pt CHANGE ACTIVATE
If the text is changed and the widget loses focus,
invoke the Pt CB ACTIVATE callback with the
Pt CHANGE ACTIVATE subtype. For more
information, see the description of
Pt CB ACTIVATE in “Inherited resources” for
PtText.
Pt CURSOR VISIBLE
Display the cursor. Default is on.
Pt INSERT MODE
Toggle insert/replace mode. Default is insert (on).
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtCompound →
PtNumeric → PtNumericFloat
PhAB icon:
t NumericFl
Public header:
<photon/PtNumericFloat.h>
Description:
The PtNumericFloat class is a numeric widget that allows you to
enter floating-point values between given minimum and maximum
values.
17.98
A PtNumericFloat widget.
New resources:
continued. . .
Pt CB NUMERIC CHANGED
C type Pt type Default
PtCallback t * Link NULL
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
continued. . .
continued. . .
Pt CB ACTIVATE
If cbinfo->reason subtype is Pt NUMERIC ACTIVATE, the
callback was invoked because the user changed the value and
pressed Enter while in PtNumericFloat’s text field.
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtCompound →
PtNumeric → PtNumericInteger
PhAB icon:
Public header:
<photon/PtNumericInteger.h>
Description:
The PtNumericInteger class lets the user specify integer values
between given minimum and maximum values.
27
A PtNumericInteger widget.
New resources:
Pt CB NUMERIC CHANGED
C type Pt type Default
PtCallback t * Link NULL
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
continued. . .
Pt CB ACTIVATE
If cbinfo->reason subtype is Pt NUMERIC ACTIVATE, the
callback was invoked because the user changed the value and
pressed Enter while in PtNumericInteger’s text field.
Class hierarchy:
PtWidget -> PtBasic -> PtLabel -> PtToggleButton ->
PtOnOffButton
PhAB icon:
Public header:
<photon/PtOnOffButton.h>
Description:
A PtOnOffButton widget displays an on/off button that can be set
or unset. Instances of this class of widget are typically used in
exclusive or nonexclusive groups.
About demo
On/Off Button
A PtOnOffButton widget.
New resources:
Indicates the current state of the on/off button. If the button is off, this
resource has a value of 0; if the button is on, this resource has a
nonzero value.
A list of callbacks that the widget invokes when the state of the on/off
button changes.
These callbacks are also invoked whenever a call to PtSetResources()
changes the state of the button, provided the Pt CALLBACKS ACTIVE
flag is set (see the description of Pt ARG FLAGS under PtWidget).
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
reason subtype
0 (not used).
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtPane
PhAB icon:
Public header:
<photon/PtPane.h>
Description:
PtPane is a container widget that provides anchoring and layout for
its children. Any child widgets that extend beyond the canvas of the
PtPane widget are clipped. You should find this widget useful for
screen layouts.
AppBuilder Preference Settings
General
Gen er a l Pr ef er en ces
Colors
Speedbar: On Off
Dragging
Print Command:
Done
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtGraphic → PtPixel
PhAB icon:
Public header:
<photon/PtPixel.h>
Description:
The PtPixel widget may be used to draw a set of points. The array
of points, Pt ARG POINTS specifies a number of points to be drawn
using the widget’s drawing attributes. These points are relative to the
widget’s Pt ARG ORIGIN. For more information, see PtGraphic.
Each point in the Pt ARG POINTS array is a position at which a point
is to be drawn. The points are drawn independently of each other (i.e.
they’re not connected).
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtGraphic → PtPolygon
PhAB icon:
Public header:
<photon/PtPolygon.h>
Description:
The PtPolygon widget may be used to draw a set of connected line
segments, called a “polyline”, from the vertices of the line segments.
You can produce a polygon using this widget by specifying that the
curve must be closed. This is controlled by the
Pt ARG POLYGON FLAGS resource.
You can use the flags to specify:
New resources:
Pg POLY STROKE
Stroke (outline) the polygon.
Pg POLY RELATIVE
Use relative coordinates to draw the polygon. Each
point is relative to the previous point.
The default setting of this resource is 0; that is, no flags have been set.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtPrintSel
PhAB icon:
Public header:
<photon/PtPrintSel.h>
Description:
The PtPrintSel widget lets a user select a printer, change its
properties, and optionally select a range of pages and the number of
copies to print.
Select a Printer
A PtPrintSel widget.
New resources:
¯ Pt PRINTSEL ALL PANES — if this flag is set, all the panes of the
print selector are displayed; if cleared, the Print Range and Copies
panes aren’t displayed.
Pt CB PRINT PROPS
C type Pt type Default
PtCallback t * Link NULL
reason subtype
Defines the Properties action:
Pt PRINTSEL PROPERTIES
The Properties button was selected. You might use
this callback to block access to the print selector’s
window while the Properties dialog is open (the
PtPrintSel widget blocks itself automatically).
Pt PRINTSEL ADDNEW
No printer has been installed. By default, this
callback invokes the Printer Installation program,
prsetup. See the Printing chapter in the User’s
Guide.
Pt PRINTSEL RETURN
The user has closed the Properties dialog. You
might use this callback to unblock access to the
print selector’s window (the PtPrintSel widget
unblocks itself automatically).
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Convenience functions:
The PtPrintSel class defines the following convenience function:
PtPrintSelection()
Display a modal dialog for initiating printing. See the Photon
Library Reference.
Class hierarchy:
PtWidget → PtBasic → PtRaw
PhAB icon:
Public header:
<photon/PtRaw.h>
Description:
The PtRaw class provides you with widget that lets you use the
Photon graphics drawing functions.
☞ The PtRaw class provides a good starting point for creating custom
widgets. However, custom widgets require their own Initialization,
Extent, and Connect methods in addition to a Draw method. Since the
PtRaw widget is typically used for drawing, the Draw function PtRaw
supports is described in detail in this chapter. If you’d like more
information about when to use an Initialization, Extent, or Connect
function, see the Building Custom Widgets manual.
With a PtRaw canvas, you can draw using raw Photon graphics
primitives without completely losing what you’ve drawn when the
widget is damaged. If the widget is damaged, the application is
notified so that it may redraw whatever it had previously drawn.
You must refresh the contents of the canvas whenever they become
damaged. This is necessary because Photon doesn’t keep track of the
widget’s raw contents for you. It’s more efficient to allow the
application programmer to maintain the original data structure and
re-render the contents of the canvas. If a significant amount of time
must be expended rendering the contents of the canvas, it’s better to
render them into an image and copy the image into the canvas when it
is damaged.
Draw function
The PtRaw widget defines a drawing function,
Pt ARG RAW DRAW F, which is invoked any time the contents of the
canvas have to be refreshed due to damage.
☞ Don’t call the drawing function directly from your program. Instead,
damage the widget by calling PtDamageWidget(), and let the library
call the drawing function.
The drawing function you provide for the canvas gets two arguments
when it’s invoked:
For simple situations where the widget’s contents don’t change, you
could put the drawing primitives in the draw function directly. But it’s
more likely that the contents will change dynamically. In this case,
you should create a data structure, or model, that defines the contents
of the canvas.
Place a pointer to this data structure in the Pt ARG USER DATA
resource of the PtRaw widget, so that it can be obtained easily by
your draw function. This function should be able to walk the data
structure you’ve provided and to render the contents of the canvas
based on that information.
You should also set a translation to compensate for the raw widget’s
margins. The edge of the margins is given as the rectangle’s upper-left
corner given by the PtBasicWidgetCanvas() function. Add the
rectangle’s upper-left corner to any translation you wish to perform on
the model and pass this value to PgSetTranslation().
This function takes two parameters. The second parameter should be
set to the constant Pg RELATIVE. When rendering your model, scale
the values by your scale factor. The coordinates will automatically be
translated by the amount you specified in the call to
PgSetTranslation().
The simple example below shows a drawing function that fills the
entire canvas with blue:
void raw draw(PtWidget t *widget, PhTile t *damage)
{
PhRect t rect;
PtBasicWidgetCanvas(widget, &rect);
PgSetFillColor(Pg BLUE);
PgDrawRect(&rect, Pg DRAW FILL);
}
Pt ARG COLOR resource and the fill color to the value specified in
the Pt ARG FILL COLOR resource.
PtRaw lets you combine widgets and Pg* functions. You should use
this widget to cover any area in which “raw drawing” is to take place.
The draw function you specify for this widget will be called whenever
the area needs repair.
The coordinates for the Pg* calls made within the draw function are
relative to the canvas of PtRaw’s parent. The draw function must
handle its own clipping and highlighting.
If the draw function changes clipping (PtClipAdd()) or the current
translation (PgSetTranslation()) they must be restored before the draw
function returns.
Here’s an example of setting up and using a PtRaw widget:
pos.x = 220;
dim.w = 200, dim.h = 200;
n=0;
PtSetArg( &args[n], Pt ARG DIM, &dim, 0 );n++;
PtSetArg( &args[n], Pt ARG POS, &pos, 0 );n++;
PtSetArg( &args[n], Pt ARG RAW DRAW F, &draw, 1 );n++;
PtSetArg( &args[n], Pt ARG BORDER WIDTH, 2, 0 );n++;
PtSetArg( &args[n], Pt ARG FLAGS, Pt TRUE,
Pt SELECTABLE | Pt HIGHLIGHTED );n++;
PtSetArg( &args[n], Pt CB ARM, &aback, 1 );n++;
PtCreateWidget(PtRaw, NULL, n, &args[0] );
.
.
.
damage = damage;
For more information, see the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide.
New resources:
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtGraphic → PtRect
PhAB icon:
Public header:
<photon/PtRect.h>
Description:
A PtRect widget draws a single rectangle whose bounding box is
defined by two points. To set these points, use the Pt ARG POINTS
resource. These points are relative to the widget’s Pt ARG ORIGIN.
For more information, see PtGraphic.
If you don’t set Pt ARG POINTS, the rectangle defaults to the size
defined by Pt ARG POS and Pt ARG DIM (see PtWidget).
A PtRect widget.
New resources:
Defines the number of pixels used for rounding the corners of the
rectangle.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtRegion
PhAB icon:
None — must be instantiated with PtCreateWidget().
Public header:
<photon/PtRegion.h>
Description:
PtRegion is ideal for controlling a region without foregoing the
convenience of the Photon widget library interface. With PtRegion,
you can control a region without having to modify the standard main
loop function.
☞ ¯ For more information about the data associated with a region, see
PhRegion t in the Photon Library Reference.
¯ For changes to this widget’s resource to take effect, you must set
the corresponding bit in Pt ARG REGION FIELDS.
New resources:
continued. . .
¯ Ph WINDOW REGION
¯ Ph GRAFX REGION
¯ Ph PTR REGION
¯ Ph KBD REGION
¯ Ph PRINT REGION
¯ Ph INPUTGROUP REGION
¯ Ph AUXPTR REGION
¯ Ph FORCE FRONT
¯ Ph FOLLOW IG SIZE
¯ Ph FORCE BOUNDARY
¯ Ph NO COMPRESSION
¯ Ph CURSOR SET
For changes to this resource to take effect, you must set the
corresponding bit in Pt ARG REGION FIELDS.
Defines which region (rid) this region will be opened behind. The
specified region becomes the brother in front. A value of 0 makes the
region the frontmost child of its parent when created. For changes to
this resource to take effect, you must set the corresponding bit in
Pt ARG REGION FIELDS.
Associates the region with the specified input group. For changes to
this resource to take effect, you must set the corresponding bit in
Pt ARG REGION FIELDS.
Define which events this region is opaque to. For changes to this
resources to take effect, you must set the corresponding bit(s) in
Pt ARG REGION FIELDS.
Specifies the owner of the region. For changes to this resource to take
effect, you must set the corresponding bit in
Pt ARG REGION FIELDS.
Specifies the ID (rid) of the region that will be this region’s parent.
For changes to this resource to take effect, you must set the
corresponding bit in Pt ARG REGION FIELDS.
Define which events this region is sensitive to. For changes to this
resources to take effect, you must set the corresponding bit(s) in
Pt ARG REGION FIELDS.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtScrollArea
PhAB icon:
Public header:
<photon/PtScrollArea.h>
Description:
A PtScrollArea widget combines one or more scrollbar widgets
and an area that provides a viewport onto a virtual display area. The
virtual display area is a container for other widgets. Typically, the
virtual area is larger than the viewing area; the scrollbar widgets let
you bring any part of the virtual area into view.
Max Vert 0
Posit ion Vert 0
Increment Vert 10
Max Horz 0
Posit ion Horz 0
Increment Horz 10
Scrollbar Horz Display Pt _NEVER
Scrollbar Vert Display Pt _ALWAYS
ScrollArea Flags 0x0
Anchor Flags 0xf 00
Cont ainer Flags 0x0
Color: Pen
Color: Fill
Border W idth 1
Color: Top Border
Color: Bot t om Border
Scrolling notification
When the user moves either the vertical or horizontal scrollbar to
change the viewport’s position, a callback may be invoked to notify
the application that the viewport has been moved. You may use this to
keep two related viewports synchronized with each other by
monitoring both viewports and updating the position of the alternate
viewport when one of them scrolls. See “Scrolling control” below.
The callbacks provided by the PtScrollArea class and their
meanings are:
Scrolling control
The scrollbars provided by the scrollable area let the user vary the
position of the viewport between (0,0) and (xmax, ymax), where xmax
and ymax are the maximum positions in x and y. These are equal to
the virtual area’s size in the specified dimension minus the viewport’s
size in that dimension.
Layout
Scrollable areas always use absolute positioning for the layout of their
children.
AND
New resources:
continued. . .
These flags control the behavior of the scroll area. Valid bits include:
The number of pixels that the widget will scroll when the user clicks
the horizontal arrow buttons.
The number of pixels that the widget will scroll when the user clicks
the vertical arrow buttons.
The width (in pixels) of the total scrollable area. This is the widget’s
virtual width. To specify the displayed portion of this scrollable area,
use Pt ARG AREA.
The height (in pixels) of the total scrollable area. This is the widget’s
virtual height. To specify the displayed portion of this scrollable area,
use Pt ARG AREA.
Pt AS REQUIRED
Display if the visible dimension is less than the
virtual dimension.
Pt AS REQUIRED
Display if the visible dimension is less than the
virtual dimension.
The width (in pixels) of the vertical scrollbar. The minimum width is
6 pixels. If this resource is set to 0, the default width of 15 pixels is
used.
Pt CB SCROLLED X, Pt CB SCROLLED Y
C type Pt type Default
PtCallback t * Link NULL
The list of callbacks that the PtScrollArea widget invokes when its
scrollbars are moved.
If the widget has the Pt CALLBACKS ACTIVE bit set in its
Pt ARG FLAGS resource, these callbacks are also invoked when the
positions of the scrollbars are changed by a call to PtSetResources().
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
reason Pt CB SCROLLED X or
Pt CB SCROLLED Y.
Pt SCROLL DECREMENT
The scrollbar has been decreased by one
increment.
Pt SCROLL INCREMENT
The scrollbar has been increased by one
increment.
Pt SCROLL PAGE INCREMENT
The scrollbar has been increased by one
page.
Pt SCROLL PAGE DECREMENT
The scrollbar has been decreased by one
page.
Pt SCROLL TO MAX
The slider part of the scrollbar has been
moved to the maximum value.
Pt SCROLL TO MIN
The slider has been moved to the minimum
value.
Pt SCROLL DRAGGED
The slider part is being dragged.
Pt SCROLL RELEASED
The slider part has been released after having
been dragged.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtScrollbar
PhAB icon:
Public header:
<photon/PtScrollbar.h>
Description:
A PtScrollbar widget provides a scrollbar. It returns values (via
callbacks) that indicate a value within the provided range.
A PtScrollbar widget.
Mouse actions
When the mouse button is pressed, the result depends on the location
of the pointer.
Keyboard actions
New resources:
Pt ARG DIRECTION
C type Pt type Default
int Boolean Off
Pt ARG INCREMENT
C type Pt type Default
long Scalar 1
The value the widget will scroll by when the user clicks the arrow
buttons.
Pt ARG MAXIMUM
C type Pt type Default
int Scalar 19
Pt ARG MINIMUM
C type Pt type Default
int Scalar 0
Pt ARG ORIENTATION
C type Pt type Default
int Boolean Pt VERTICAL
¯ Pt HORIZONTAL
¯ Pt VERTICAL
Flags that control the appearance and behavior of the scrollbar. The
valid bits are:
Pt SCROLLBAR FOCUSED
Cause the scrollbar to be rendered as if it has focus even if it
doesn’t. This is useful in applications where one widget collects
keystrokes and directs specific keys to other widgets.
Pt SCROLLBAR HORIZONTAL
Make the scrollbar horizontal instead of vertical.
This flag is also set or cleared when you set the
Pt ARG ORIENTATION resource.
Pt SCROLLBAR INVERTED
Place the maximum at the bottom of a vertical scrollbar or the
right of a horizontal one.
Pt SCROLLBAR SHOW ARROWS
Display arrow buttons at the ends of the trough.
Pt CB SCROLL MOVE
C type Pt type Default
PtCallback t * Link NULL
The list of callbacks that the scrollbar invokes when the scroll
position changes.
If the widget has the Pt CALLBACKS ACTIVE bit set in its
Pt ARG FLAGS resource, this callback is also invoked when the
position of the scrollbar is changed by a call to PtSetResources().
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
reason subtype
0 (not used).
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtSeparator
PhAB icon:
Public header:
<photon/PtSeparator.h>
Description:
PtSeparator provides a separator line with various styles. You
should find it handy when creating menus.
New Ctrl+N
Open... Ctrl+O
Save Ctrl+S
Save As...
Close
Import Files
Exit Ctrl+X
New resources:
Pt SEP ORIENTATION
If this bit is Pt SEP VERTICAL, the separator will be vertical. If
this bit is Pt SEP HORIZONTAL, the separator will be
horizontal.
Possible values:
¯ Pt SINGLE LINE
¯ Pt DOUBLE LINE
¯ Pt SINGLE DASH LINE
¯ Pt DOUBLE DASH LINE
¯ Pt ETCHED IN
¯ Pt ETCHED OUT
¯ Pt NOLINE
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtGauge → PtSlider
PhAB icon:
Public header:
<photon/PtSlider.h>
Description:
A PtSlider widget serves as a numerical input mechanism that
allows the user to choose values within a specified range from
minimum to maximum.
100
A PtSlider widget.
Mouse actions
When the user presses the mouse button, the result depends on the
location of the pointer.
Keyboard actions
where:
New resources:
Valid flags:
The label string that’s placed at the bottom or right of the slider,
depending on the orientation.
The label string that’s placed at the top or left of the slider, depending
on the orientation.
The location of the minimum value for the slider: on the top or
bottom if the slider is vertical; on the left or right if the slider is
horizontal. The possible values are:
Pt CB SLIDER MOVE
C type Pt type Default
PtCallback t * Link NULL
A list of callbacks that the slider invokes when the handle position
changes.
If the widget has the Pt CALLBACKS ACTIVE bit set in its
Pt ARG FLAGS resource, these callbacks are also invoked when the
handle position is changed by a call to PtSetResources().
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
reason subtype
0 (not used).
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtLabel → PtButton → PtTab
PhAB icon:
Pt Tab
Public header:
<photon/PtTab.h>
Description:
The PtTab class draws a tab such as is found on a file folder.
Clicking the tab invokes an application callback.
¯ Group the tabs together and set the Pt GROUP EXCLUSIVE bit in
the PtGroup widget’s Pt ARG GROUP FLAGS resource. This
flag allows only one of the tabs to be set at a time.
¯ Use other PtGroup flags and resources to make the tabs the same
size, aligned horizontally, and so on. For more information, see
“Aligning widgets using groups” in the Geometry Management
chapter of the Photon Programmer’s Guide.
¯ Place the tabs at the top of a PtPane or some other container. Use
the same border width for the tabs and the container, and line up
the top of the container’s border with the top of the bevel on the
tab.
New resources:
Flags that affect how the widget appears. The only bit defined is:
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtTerminal
PhAB icon:
Public header:
<photon/PtTerm.h>
Description:
The PtTerminal class provides a text window emulating a character
terminal.
Pg.svga phrelay.110
Pg.svgadc psh
Pg.tvg9470 pterm
Pg.vga4 pv
Pg.wd pwm
Pg.xga pwmclock
Photon pwmopts
Photon.slib snapshot
Photon.slib11 web.server
acalib webclient
bdf_2_phf winview
colorbar
$
A PtTerminal widget.
¯ scrolling
Fonts
Application programs set the Pt ARG TERM FONT resource to set
an explicit font name or the Pt ARG TERM FONT INDEX resource
to choose a font from the list of supported fonts,
Pt ARG TERM FONT LIST.
If the Pt TERM KBFONT bit is set in Pt ARG TERM RESIZE FL, the
user can select a font using the keyboard:
The Pt TERM KBFORCE flag affects any resizing that occurs when
the above keychords are used:
¯ If this flag isn’t set, the above keystrokes simply set the
Pt ARG TERM FONT INDEX resource.
¯ If the flag is set, the [ and ] keys adjust the window size to keep the
terminal size (rows/columns) while the < and > keys attempt to
adjust the terminal size within the current window size.
If the Pt TERM OPFONT flag is set, the font can be changed by escape
sequences:
¯ If the font is set using the Pt ARG TERM FONT resource and the
new font name is equal to one of the names on the current font list,
the Pt ARG TERM FONT INDEX resource is set to the index of
that list item. When the Pt ARG TERM FONT LIST resource is
set, the widget also attempts to find the current font name on the
list and set the index.
¯ If the font list contains an invalid font name, the
Pt ARG TERM FONT INDEX resource can be set to its index but
the current font isn’t changed.
Character sets
PtTerminal uses two 8-bit character sets:
Geometry
There are four groups of resources that affect a terminal widget’s
geometry:
Resizing
The next series of characters provide the details, starting with the
character x or y to specify direction (horizontal or vertical). The next
character can be one of the following:
Character Meaning
- The value is decreasing.
+ The value is increasing.
= The value didn’t change (used only when the size or
margin is changing).
For example, xsym would adjust the number of columns (xs) and the
margin height (ym).
Before any adjustments specified by the string are done,
Pt ARG TERM MARGINS resource is reset to the
Pt ARG MARGIN HEIGHT and/or Pt ARG MARGIN WIDTH
values.
Adjusting the dimension is always successful, while adjusting size or
margin isn’t always sufficient — size is limited and must be a
multiple of the font size, and margin must be nonnegative.
After the adjustments specified by the string are done, the dimension
is adjusted to make sure that the new values are coherent. Thus,
Size limits
Other resources that may affect geometry are the size limits:
When a limit is being set to a value that makes the current size
invalid, the current size is adjusted. If a minimum is set to a value
larger than the corresponding maximum, then both the maximum and
the current size are also set to this value.
The opposite is also true: if a maximum is changed, the
corresponding minimum may be adjusted. This means that if you
want to set the limits and size to arbitrary values regardless of their
current values, the limits should be set before the size.
The minimum size (together with font and margins) determines also
minimal values for the Pt ARG DIM resource. There is no upper limit
for the dimensions because there is no upper limit for the
Pt ARG TERM MARGINS resource.
Console emulation
A PtSetResources() call for the Pt ARG TERM CONSOLE resource
works in a manner similar to the console write() function.
First, the application should fill a PtTerminalConsoleWrite t
structure with data corresponding to arguments of the console write()
function. The pointer to the structure is the argument of the
PtSetArg() macro. The PtSetResources() function transfers actual
screen data from the buffer given by the application to the widget’s
screen buffer. Then a damage event is generated in order to display
the new data. The function doesn’t check whether offset and length
given by the application don’t exceed the size of the buffer.
A PtGetResources() call for the Pt ARG TERM CONSOLE resource
directly returns a pointer to the buffer. If the application wishes to get
the contents of a specific fragment of the screen, it must calculate the
offset to the desired position in the buffer and copy the data.
Color coding
The Pt ARG TERM COLOR TABLE resource is an array used by the
widget for mapping color numbers into Photon PgColor t color
values. Color numbers are indexes into this array. The default array
has 16 elements corresponding to 16 standard CGA colors.
The Pt ARG FILL COLOR (see PtBasic) defines the color of the
margins.
The background color of the terminal defaults to black — or whatever
the Pt ARG TERM COLOR TABLE resource defines as entry 0. If
you want a different background color, you can either change the
color table or set the background color by sending appropriate escape
sequences to the terminal using PtTerminalPut() The latter is
probably safer if the widget is a PtTty that will be running arbitrary
programs in it; programs that use color might look odd if the colors in
the color table differ from the default values too much.
Scrolling optimization
New resources:
Pt ARG TERM DRAW MODES unsigned char Flag Pt TERM SCROLL RFSH
Pt ARG TERM FONT char * String "pcterm14"
Pt ARG TERM FONT INDEX short Scalar -1
Pt ARG TERM FONT LIST char **, short Array NULL,
0
continued. . .
continued. . .
Color table used for display. Converts color numbers used internally
to actual Photon color values. Color numbers are indexes into this
array. The default array has 16 elements corresponding to 16 standard
CGA colors:
Index Color
0 BLACK
1 BLUE
continued. . .
Index Color
2 GREEN
3 CYAN
4 RED
5 MAGENTA
6 BROWN
7 WHITE (light grey)
8 BRIGHT BLACK (dark grey)
9 BRIGHT BLUE
10 BRIGHT GREEN
11 BRIGHT CYAN
12 BRIGHT RED
13 BRIGHT MAGENTA
14 BRIGHT BROWN (yellow)
15 BRIGHT WHITE
This resource can be used for accessing the “video memory” of the
widget. For more information, see the “Console emulation” part of
the “Description” section above.
¯ short r
¯ short c
For more information, see the “Drawing and scrolling” part of the
“Description” section above.
The name of the font used for display. For more information, see the
“Fonts” part of the “Description” section above.
Position of the current font on the font list, or -1 if the current font
isn’t on the list. Can be used to choose a font from the list, but cannot
be explicitly set to -1.
When this resource is being set, the meaning of the value argument of
the PtSetArg() macro depends on whether the len argument is zero or
nonzero:
The actual width and height of the widget’s margins. These values are
equal to or greater than values of Pt ARG MARGIN WIDTH and
Pt ARG MARGIN HEIGHT resources. For more information, see the
“Geometry” part of the “Description” section above.
¯ short r
¯ short c
¯ short r
¯ short c
The protocol:
0 QNX4
1 ANSI
Bit flags that affect terminal widget’s resizing. Valid values are:
where:
first, last Two positions that define the selected area. If selected
by the mouse, first is the position of the press and last is
the position of the release. The PtTerminalRowCol t
structure contains the following members:
¯ short r
¯ short c
¯ short r
¯ short c
Pt CB TERM APP
C type Pt type Default
PtCallback t * Link NULL
reason subtype
The character or number defining the type of escape
sequence.
event NULL
The value of the reason subtype field is the ASCII code of the
character that indicates the escape sequence type, and the cbdata field
points to the <string>.
These callbacks should return Pt CONTINUE.
Pt CB TERM FONT
C type Pt type Default
PtCallback t * Link NULL
event NULL
Pt CB TERM INPUT
C type Pt type Default
PtCallback t * Link NULL
reason subtype
Can be one of:
The widget issues this callback on every keystroke unless both Ctrl
and Alt modifiers are pressed.
When text is being pasted from the clipboard, the callback subtype is
set to Pt TERM PASTE INPUT if the buffer has been allocated with the
malloc() function. A callback function can take over the responsibility
for freeing the buffer by changing the subtype to
Pt TERM PASTE NF INPUT.
These callbacks should return Pt CONTINUE.
Pt CB TERM OPTIONS
C type Pt type Default
PtCallback t * Link NULL
reason subtype
0 if options have been changed via widget resources, or 1
if options have been changed by an escape sequence.
event NULL
Pt CB TERM RESIZE
C type Pt type Default
PtCallback t * Link NULL
event NULL
Pt CB TERM RESIZED
C type Pt type Default
PtCallback t * Link NULL
event NULL
Pt CB TERM SCRLBK
C type Pt type Default
PtCallback t * Link NULL
reason subtype
0
event NULL
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
In QNX mode:
ESC S
In ANSI mode:
ESC [ 8 ]
Convenience functions:
The PtTerminal widget defines several convenience functions and
data structures that make it easier to use the terminal once it’s been
created. Here’s a brief overview:
PtTerminalCharset t, PtTerminalCharsets t
Character sets used by PtTerminal
PtTerminalCopy()
Copy the current selection to the clipboard.
PtTerminalCreateCsXlat().
Create a translation table for PtTerminal’s character sets.
PtTerminalDefaultCharsets():
Get the default character sets used by PtTerminal.
PtTerminalFont()
Examine a font.
PtTerminalGetKeys()
Get the terminal line-editing keys.
PtTerminalGetSelection()
Get a copy of the current selection.
PtTerminalName()
Get the terminal’s termcap/terminfo name.
PtTerminalPasteClipboard()
Paste the contents of the clipboard into the terminal.
PtTerminalPasteSelection()
Paste the current selection into the terminal.
PtTerminalPut(), PtTerminalPutc(), PtTerminalPuts()
Output text to the terminal.
PtTerminalSelectWord()
Select a word.
typedef struct {
PtTerminalCharset t const *AnsiCharset;
PtTerminalCharset t const *InternalCharset;
PtTerminalCharset t const *FontTranslation;
...
} PtTerminalCharsets t;
Description:
The PtTerminalCharset t and PtTerminalCharsets t
structures define character sets used internally and externally by
PtTerminal.
if ( ch < 0x80 )
return ch; /* ch is an ASCII character */
else {
if ( ch >= cs->first && ch <= cs->last
&& ( result = cs->table[ cs - cs->first ] ) != L’\0’ )
/* ch is mapped to a Unicode value */
return result;
else
/* ch is an illegal value */
return NO MAPPING DEFINED;
}
}
to display the 8-bit internal code internal char. Note that if you want
the widget to use Unicode, FontTranslation should point to the same
character set as InternalCharset.
If FontTranslation is NULL, the font is assumed to be compatible with
the internal character set, and no mapping is used.
Classification:
Photon
Synopsis:
void PtTerminalCopy( PtWidget t *widget,
PhEvent t *event );
Description:
This function copies the current selection in the given PtTerminal
widget to the clipboard. The event parameter is used to select the
input group (see PhClipboardCopyString() in the Photon Library
Reference).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtTerminalCsXlatData t *PtTerminalCreateCsXlat(
PtTerminalCharsets t const *csets );
Description:
This function creates a translation table for the character sets used by
PtTerminal. The PtTerminalCsXlatData t structure is for
internal use only; you must use this function to create it.
The csets argument is a pointer to a PtTerminalCharsets t
structure that defines the character sets and their translation.
Returns:
A pointer to a PtTerminalCsXlatData t structure that you can
use to set the Pt ARG TERM CHARSETS resource of a PtTerminal
widget.
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PtTerminal, Pt ARG TERM CHARSETS,
PtTerminalCharsets t
Synopsis:
const PtTerminalCharsets t *
PtTerminalDefaultCharsets( void );
Description:
This function returns a pointer to the tables that define the default
character sets used by PtTerminal.
Returns:
A pointer to the tables.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTerminal, PtTerminalCharsets t
Synopsis:
char *PtTerminalFont( const char *font,
PhDim t *size,
PhPoint t *offs );
Description:
This function makes sure that the given font exists and is a
fixed-width font. It returns an allocated copy of the name. If the
appropriate font doesn’t exist, PtTerminalFont() returns NULL.
This function stores information about the font’s geometry at
locations pointed to by size and offs:
¯ If size isn’t NULL, the width and height of the character cell are
stored in *size.
¯ If offs isn’t NULL, the function stores in *offs the position that
should be given to a drawing function in order to draw the
character cell starting at position (0, 0).
If the specified font doesn’t exist, the information about the default
font is returned.
Returns:
An allocated copy of the font name, or NULL if the appropriate font
doesn’t exist.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtTerminalGetKeys( int protocol,
struct termios *buf );
Description:
This function fills the following items of the buf ->c cc array with
values appropriate for the given protocol:
¯ VPREFIX
¯ VSUFFIX
¯ VLEFT
¯ VRIGHT
¯ VUP
¯ VDOWN
¯ VINS
¯ VDEL
¯ VHOME
¯ VEND
The other fields of the structure are not modified. For more
information, see the Pt ARG TERM PROTOCOL resource associated
with the PtTerminal widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
char *PtTerminalGetSelection( PtWidget t *widget );
Description:
This function returns a copy of the current selection (or NULL if
there’s no selection).
☞ It’s the caller’s responsibility to free() the buffer when it’s no longer
needed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
const char *PtTerminalName( int protocol );
Description:
This function returns a terminal name (one of qnxm or qansi-m),
based on the given protocol.
For more information, see the Pt ARG TERM PROTOCOL resource
associated with the PtTerminal widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtTerminalPasteClipboard( PtWidget t *widget,
PhEvent t *event );
Description:
This function pastes the contents of the clipboard into the terminal’s
“keyboard” by invoking the Pt CB TERM INPUT callback. The
given event is passed to the callback functions. If event isn’t NULL,
event->input group also selects the clipboard (see
PhClipboardPasteString() in the Photon Library Reference).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtTerminalPasteSelection( PtWidget t *widget,
PhEvent t *event );
Description:
This function pastes the current selection into the terminal’s
“keyboard” by invoking the Pt CB TERM INPUT callback. The
given event is passed to the callback functions.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Description:
These functions output characters to the terminal widget.
Returns:
0 Success.
Errors:
EINVAL The widget is not a terminal widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtTerminalSelectWord(
PtWidget t *widget,
PtTerminalRowCol t const *pos );
Description:
This function selects a word containing the character at the specified
position (or the cursor position if pos is NULL).
The PtTerminalRowCol t structure contains the following
members:
¯ short r
¯ short c
Returns:
1 Done.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Class hierarchy:
PtWidget → PtBasic → PtLabel → PtText
PhAB icon:
Public header:
<photon/PtText.h>
Description:
The Photon text widgets let you type textual information into a
text-entry box. Basic editing features are provided so you can alter
text that has been entered. A point-and-click model of editing is also
supported so that blocks of text can be operated on as a unit.
A PtText widget.
Interaction model
The text entered in the text widget is either inserted into or overwrites
the existing text, depending on the insertion mode. The location
where text is inserted or replaced is visually represented by a cursor.
Selecting text
Clicking the mouse button once changes the cursor location to the
character position nearest the pointer location. Dragging the pointer
with the button pressed causes a range of text to be selected as the
object of a subsequent operation. The selected range of text, which
begins at the cursor position and ends at the pointer location, is
highlighted by inverting the foreground and background colors used
to display the text. Releasing the button completes the range selection.
The range of text selected can be extended by dragging with the Shift
key pressed. The selected range of text is changed to the text between
the current cursor position and the pointer location. The extension of
the range of text is completed when the button is released.
Any character you type after a range of text has been selected replaces
the selected range. A string specified by the application may also
replace the selected range.
Setting text
You can set the widget’s text using the Pt ARG TEXT STRING
resource. You must give this resource a null-terminated C string as a
value.
#include <Pt.h>
nargs = 0;
area.pos.y = 15;
PtSetArg(&args[nargs++], Pt ARG POS, &area.pos, 0);
PtSetArg(&args[nargs++], Pt ARG DIM, &area.size, 0);
PtSetArg(&args[nargs++], Pt ARG TEXT STRING,
"hello, world...", 0);
PtCreateWidget(PtText, window, nargs, args);
PtRealizeWidget(window);
PtMainLoop();
}
Getting text
Replacing text
Pt CB MODIFY VERIFY
Called before any changes are made to the text.
Pt CB MODIFY NOTIFY (also known as Pt CB TEXT CHANGED)
Called after a change.
Validation
nargs = 0;
PtSetArg(&args[nargs], Pt ARG TEXT STRING, "Enter Text:", 0);
nargs++;
label = PtCreateWidget(PtLabel, window, nargs, args);
PtExtentWidget(label);
PtWidgetExtent(label, &extent);
pos.x = extent.lr.x + 4;
pos.y = 0;
nargs = 0;
PtSetArg(&args[nargs], Pt ARG COLUMNS, 20, 0); nargs++;
PtSetArg(&args[nargs], Pt ARG POS, &pos, 0); nargs++;
text = PtCreateWidget(PtText, window, nargs, args);
PtAddCallback(text, Pt CB MODIFY VERIFY, allcaps, NULL);
PtRealizeWidget(window);
PtMainLoop();
}
if (cbs->text == NULL)
return Pt CONTINUE;
return Pt CONTINUE;
}
You can prevent the text from being added to the widget by setting the
doit member of the PtTextCallback t structure to zero or by
setting the length member to zero.
☞ Setting the length to 0 stops the widget from inserting the text; it
doesn’t prevent any deletion included in the modification.
Handling deletions
¯ If length is zero, then no text replaces the deleted range — the user
most likely pressed the Delete key or the destructive backspace
key.
¯ If new insert is less than cur insert, the user pressed the
destructive backspace key.
¯ If new insert equals cur insert, the user pressed the Delete key.
#include <Pt.h>
#include <stdio.h>
#include <stdlib.h>
nargs = 0;
PtSetArg(&args[nargs++], Pt ARG MARGIN HEIGHT, 4, 0);
if ((window = PtAppInit(NULL, &argc, argv, nargs,
args)) == NULL)
exit(EXIT FAILURE);
nargs = 0;
PtSetArg( &args[nargs++], Pt ARG TEXT STRING,
"Enter Text:", 0);
label = PtCreateWidget(PtLabel, NULL, nargs, args);
PtExtentWidget(label);
PtWidgetExtent(label, &extent);
pos = extent.lr;
pos.x += 4;
pos.y = 0;
nargs = 0;
PtSetArg(&args[nargs++], Pt ARG POS, &pos, 0);
PtSetArg(&args[nargs++], Pt ARG COLUMNS, 20, 0);
displayed text = PtCreateWidget(PtText, NULL, nargs, args);
PtAddCallback(displayed text, Pt CB MODIFY VERIFY,
update passwd, NULL);
PtAddCallback(displayed text, Pt CB ACTIVATE,
check passwd, NULL);
pos.x = -1000;
nargs = 0;
PtSetArg(&args[nargs++], Pt ARG POS, &pos, 0);
offscreen text = PtCreateWidget(PtText, NULL, nargs, args);
PtRealizeWidget(window);
PtMainLoop();
}
return Pt CONTINUE;
}
return Pt CONTINUE;
}
String changes
After the user has entered the new text into the widget, the
Pt CB TEXT CHANGED or Pt CB MODIFY NOTIFY callback list
is invoked. You can use this callback to keep track of changes after
they’ve been made. This is useful in form-filling applications and text
editors to determine if the contents of the text buffer are “dirty” (i.e.
they’ve been modified by the user).
This callback uses the same text modification callback structure as the
Pt CB MODIFY VERIFY callback. The text member of this structure
contains a UTF-8 string indicating the current contents of the text
widget (i.e. the entire text buffer).
An example of using this callback in form-filling applications is to
provide a visual cue to the user to indicate that one or more fields
within the form have changed. The user then knows that the pending
changes won’t take effect until they’re applied — usually by pressing
an Apply or OK button.
To use this callback in this way:
1 Create the form, including the Apply and Cancel buttons. The
Apply button should have the Pt GHOST and Pt BLOCKED bits
set in its Pt ARG FLAGS resource to give it an inactive or
disabled appearance.
Focus callbacks
The text widget provides callbacks that tell the application either that
the text widget has gained or lost focus.
The text widget gains focus when the user either clicks on the text
widget or presses the Tab key to move from another text field into this
one.
When the text widget obtains the focus by either of these two means,
any callbacks defined in the Pt CB GOT FOCUS callback list for the
widget are called. This is useful if the application wishes to alter the
appearance of a text widget that the user is entering text into, or to
The reason member given in the callback info for this callback is
Pt CB MOTION VERIFY. The event member indicates the type of
action that caused the callback to be invoked.
You can determine the type of action that caused the callback to be
invoked by making a comparison on the event member. If it’s set to
NULL, the callback was invoked as a result of an application function
call. Otherwise, the callback was invoked as a result of a user action
(such as a pointer button press or keypress event).
The event member is a pointer to a PhEvent t structure describing
the user action. To differentiate between a pointer event and a
keypress event, look at the type of that event.
Activate callback
The PtText widget provides an activate callback, Pt CB ACTIVATE,
that’s invoked when one of the following occurs:
¯ The user presses the Enter key within the widget. This signals that
any changes to the field are complete and the application can use
the new value.
The reason subtype in the callback information is
Pt EDIT ACTIVATE. The callback data is a pointer to the same
text-modification callback structure as used by the
text-modification callbacks. The text member of that structure
contains a UTF-8 string indicating the contents of the buffer.
¯ The text was modified, the widget has lost focus, and
Pt CHANGE ACTIVATE is set in the widget’s
Pt ARG TEXT FLAGS.
The reason subtype in the callback information is
Pt CHANGE ACTIVATE. The callback data is a pointer to the same
text-modification callback structure as used by the
text-modification callbacks. The text member of that structure
contains a UTF-8 string indicating the contents of the buffer.
the dialog. In other words, for a prompt dialog, entering a new value
in the text field and pressing the Enter key has the same effect as
pressing the dialog’s OK button after entering the new value.
Edit masks
The PtText widget provides an edit mask that allows a pattern to be
specified for the text entered into the text field. Any characters the
user enters must conform to this pattern or they’ll be rejected.
☞ Edit masks can be difficult to use and aren’t very flexible. It’s better to
use a Pt CB MODIFY VERIFY callback than an edit mask to
constrain input.
continued. . .
Mouse actions
If the user: The widget:
Presses the mouse button Gets input focus
Presses the mouse button and drags the Extends the text selection
mouse
Releases the mouse button Ends the text selection
Keyboard actions
If the user presses: The widget:
Any character Inserts the typed character
→ Moves the cursor to the right
← Moves the cursor to the left
Home Moves the cursor to the beginning of the
line
End Moves the cursor to the end of the line
Shift – → Extends the text selection to the right
Shift – ← Extends the text selection to the left
Shift – Home Extends the text selection to the beginning
of the line
Shift – End Extends the text selection to the end of the
line
Backspace Deletes the previous character
Delete Deletes the current character
Enter Processes the text
Tab Moves the cursor to the next text field
Shift – Tab Moves the cursor to the previous text field
Ctrl – → Moves the cursor to the next word
Ctrl – ← Moves the cursor to the previous word
Ins Toggles between insert and replace modes
New resources:
Pt ARG COLUMNS
C type Pt type Default
short Scalar 0
The number of “M” characters that fit in the field horizontally. The
widget uses this resource only if the width component of the
Pt ARG DIM resource is 0.
A string that serves as an input filter for the text field. Each character
in the string determines the acceptable input for the corresponding
character position in the text field. The edit mask can contain the
following:
X Any character.
d Alphanumeric characters.
☞ Edit masks can be difficult to use and aren’t very flexible. It’s better to
use a Pt CB MODIFY VERIFY callback than an edit mask to verify
input.
When setting...
The value is a pointer to an instance of a PtTextControl t
structure. The start pos and end pos members of the structure
indicate the range of text to be highlighted (selected). When
you set the resource, if end pos is -1 or beyond the end of the
string, it’s set to the last character position of the widget’s text.
The doit member is always set to 1.
When getting...
The value is an address of a PtTextControl t pointer. The
start pos and end pos members hold the currently highlighted
Valid flags:
Pt CHANGE ACTIVATE
If the text is changed and the widget loses focus,
invoke the Pt CB ACTIVATE callback with the
Pt CHANGE ACTIVATE subtype.
For more information, see the description of
Pt CB ACTIVATE in “Inherited resources,” below.
Pt CURSOR VISIBLE
Display the cursor. Default is on.
Pt INSERT MODE
Toggle insert/replace mode. Default is insert (on).
This resource can be used to get or set a substring of the widget’s text.
It’s a complex resource, so it needs special handling:
When setting...
The value is a pointer to an instance of a PtTextControl t
structure that defines which characters are to be deleted and
which are to be inserted. The following members are used:
¯ start pos — the beginning of the range to delete, or -1 if no
text is being deleted.
A list of callbacks that the widget invokes after the value of the text
string changes.
reason subtype
0 (not used).
Pt CB MODIFY VERIFY
C type Pt type Default
PtCallback t * Link NULL
A list of callbacks that the widget invokes before the value of the text
string changes. To alter the input to the widget, you can modify the
members of the callback structure.
If the widget has the Pt CALLBACKS ACTIVE bit set in its
Pt ARG FLAGS resource, this callback is also invoked when the text
is changed by a call to PtSetResources() or to a text widget function
such as PtTextModifyText().
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
reason subtype
0 (not used).
Pt CB MOTION NOTIFY
C type Pt type Default
PtCallback t * Link NULL
reason subtype
0 (not used).
Pt CB MOTION VERIFY
C type Pt type Default
PtCallback t * Link NULL
reason subtype
0 (not used).
cbdata A pointer to a PtTextCallback t structure that
contains at least the following members:
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Pt CB ACTIVATE
Pt CB ACTIVATE is inherited from PtBasic, but its behavior is
different for a PtText widget. Each callback is passed a
PtCallbackInfo t structure that contains at least the following
members:
reason Pt CB ACTIVATE
reason subtype
Indicates why the callback was invoked:
¯ 0 — the user clicked on the widget and it has
Pt SELECTABLE set in its Pt ARG FLAGS.
¯ Pt EDIT ACTIVATE — the user pressed Enter in the
text field.
¯ Pt CHANGE ACTIVATE — the text was modified, the
widget lost focus, and Pt CHANGE ACTIVATE is set in
the widget’s Pt ARG TEXT FLAGS.
Convenience functions:
The PtText widget defines several convenience functions and data
structures that make it easier to use the widget once it’s been created.
Here’s a brief overview:
PtTextCallback t, PtTextControl t,
PtTextControlInfo t
Information passed to PtText callbacks
PtTextGetSelection()
Gets the selected range from a PtText widget.
PtTextModifyText()
Modifies the contents of a PtText widget.
PtTextSetSelection()
Sets the selected range for a PtText widget.
Synopsis:
typedef struct Pt text callback {
int start pos;
int end pos;
int cur insert;
int new insert;
int length;
short reserved;
char *text;
int doit;
} PtTextCallback t;
typedef PtTextCallback t PtTextControl t;
typedef PtTextControl t PtTextControlInfo t;
Description:
PtTextCallback t, PtTextControl t, and
PtTextControlInfo t are different names for the same structure.
They’re used in callbacks for PtText widgets as well as to specify
actions or request data. The members of these structures are:
cur insert The character position where the cursor was located at
the time of the change.
new insert The character position where the cursor will be located
after the change.
Classification:
Photon
See also:
PtMultiTextCallback t
Synopsis:
int PtTextGetSelection( PtWidget t *widget,
int *start,
int *end );
Description:
This function gets the currently selected range from a PtText widget.
It returns the number of characters currently selected and sets the
provided integers to the actual range. All characters from start up to
but not including end are currently selected.
Both start and end are 0-based. So, for example, if start returns as 0,
it indicates the first character in the widget’s text buffer.
Returns:
The number of characters currently selected, or -1 if the specified
widget isn’t a PtText widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtText, PtTextSetSelection()
Synopsis:
int PtTextModifyText( PtWidget t *widget,
int start,
int end,
int insert pos,
char const *text,
int length );
Description:
This function modifies the contents of a PtText widget.
If start doesn’t equal end, then:
¯ All characters from start up to, but not including, end are deleted.
¯ The widget’s current insert position is set to the lesser of start and
end.
¯ No text is deleted.
Both start and end are 0-based. So, for example, if start is 0, it
indicates the first character in the widget’s text buffer.
Once the current insert position is set, the function inserts length
characters from text. It does this regardless of the widget’s insert
mode. If length is zero, no text is inserted.
This function causes a nondestructive deselect before attempting the
changes. If the widget has the Pt CALLBACKS ACTIVE bit set in its
Pt ARG FLAGS resource, it then invokes its
Pt CB MODIFY VERIFY callbacks, if any. These callbacks might do
one of the following:
Returns:
1 The widget’s text was changed.
0 No change occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtTextSetSelection( PtWidget t *widget,
int *start,
int *end );
Description:
This function sets the selected range for a PtText. When the
function completes successfully, start and end contain the range
actually selected (start < end). These values may differ from the
original values you specified if:
¯ The range you specified exceeded the bounds of the widget’s text.
Both start and end are 0-based. So, for example, if start is 0, it
indicates the first character in the widget’s text buffer.
This function causes a nondestructive deselect of the currently
selected range, if there is one.
Here’s how a selected range behaves:
¯ If the user moves the text cursor (via arrow keys or a mouse click),
the range is deselected nondestructively.
¯ If the user performs an action that would modify the widget’s text
in any way, the range is deleted and replaced by the user’s input. If
that input is Del or a delete backspace (DBS on many keyboards),
the range is simply deleted.
Returns:
The number of characters successfully selected (which may be 0 if
*start equals *end or if *start and *end are both greater than the
number of characters in the widget), or -1 if the specified widget isn’t
a PtText widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtText, PtTextGetSelection()
Class hierarchy:
PtWidget → PtTimer
PhAB icon:
Public header:
<photon/PtTimer.h>
Description:
A PtTimer widget invokes a callback after an initial and repeated
time period. The time period is given in milliseconds. This widget is
intended to provide a non-accurate, resourceless time base for the
application. Setting the Pt ARG TIMER INITIAL resource to 0 or
unrealizing the widget disables the timer.
New resources:
continued. . .
Time in milliseconds for the repeat rate of the timer once the initial
time period has expired.
Pt CB TIMER ACTIVATE
C type Pt type Default
PtCallback t * Link NULL
A list of callbacks that the widget invokes when the timer has expired.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
Class hierarchy:
PtWidget → PtBasic → PtLabel → PtToggleButton
PhAB icon:
Public header:
<photon/PtToggleButton.h>
Description:
A PtToggleButton widget is like a toggle switch, although it
behaves like a button. It has on and off states, and pressing the button
inverts the current state of the button.
Unset: Set:
Pt_ONE_OF_MANY Pt_ONE_OF_MANY
Pt_N_OF_MANY Pt_N_OF_MANY
Pt_ROUND Pt_ROUND
Pt_RADIO Pt_RADIO
Pt_TICK Pt_TICK
Pt_CHECK Pt_CHECK
A toggle button is displayed as a button with its label beside it. The
button is either set or unset. Normally the button will appear recessed
when it’s set. You can control this appearance with the
Pt ARG SET COLOR resource, which specifies the fill color for the
button’s interior when the button is set. This resource is ignored if the
value of the Pt ARG SET FILL resource isn’t set to Pt TRUE.
To determine whether or not the button is set, check the:
"Button 3", 0 ) ;
button3 = PtCreateWidget (PtToggleButton, group,
1, argt ) ;
PtRealizeWidget ( group ) ;
You can use the same callback for all the buttons, but how do you
determine which one is selected? There are several ways:
¯ If you create the buttons in code (instead of in PhAB), you can pass
a unique value in the client data argument to the callback routine.
New resources:
continued. . .
The background color used when the button is set (pressed in).
Pt ARG SPACING
C type Pt type Default
unsigned short Scalar 4
The distance in pixels between the toggle indicator and the text label.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtCompound →
PtGenList → PtGenTree → PtTree
PhAB icon:
Public header:
<photon/PtTree.h>
Description:
The PtTree widget displays a tree of items that collapse or expand
according to the user’s selections. PtTree assumes that each tree
item contains two images and a string.
Photon microGUI
Building Custom Widgets
Installation & Configuration
About This Guide
Basic Installation
Configuring Photon
Photon Utilities
Photon Applications
Troubleshooting
Library Reference
Programmer’s Guide
User’s Guide
Widget Reference
QNX 4.23
The Photon Helpviewer uses a PtTree widget to give you quick access to
documentation.
With both methods, the Tab character is used in the item strings as a
column separator.
☞ Even if you use columns, each line in the tree remains a single item.
When you select any part of the line, the entire line is selected —
having columns doesn’t make the tree into a spreadsheet.
The array of all available images is actually stored within the widget’s
Pt ARG TREE IMAGES resource, and the items contain only indexes
into this array. The item structure, PtTreeItem t, also contains a
“user data” pointer that isn’t used by the widget. Note that there are
some functions that free items. None of these functions attempts to
free the user data.
The items should be allocated using the PtTreeAllocItem() function.
This function uses the font and image list stored in the tree widget to
determine the item’s dimensions. This means that between creating an
item and adding it to the widget, you mustn’t change the widget’s font
or images. The tree widget passed to PtTreeAllocItem() must be the
same widget that the item will be added to. The PtTree widget will
free all its items automatically when it’s destroyed.
Use PtTreeAddFirst() and PtTreeAddAfter() to build a tree. For
example, suppose you wanted to build the following tree:
Item 1
Item 2
Item 2a
Item 3
PtTreeItem t *item,*brother;
char *text;
PtTreeAddFirst(tree wgt,item,NULL);
brother = item;
New resources:
A function that inflates a balloon for the item the pointer is on.
PtTreeBalloonF t is a function type:
return
PtGenListCreateTextBalloon(
widget, parent,
PtGenListSetColumnBalloon ( area, column ),
item->string, coln, font);
A list of images that can be displayed with tree items. For more
information about the image structure, see PhImage t in the Photon
Library Reference.
before providing the images to the widget. If you do this, the memory
used for the images is released when the widget is destroyed or
Pt ARG TREE IMAGES is set.
Pt CB TREE SELECTION
C type Pt type Default
PtCallback t * Link NULL
reason subtype
This value depends on the selection mode. One of:
¯ Pt LIST SELECTION FINAL
¯ Pt LIST SELECTION BROWSE
¯ Pt LIST SELECTION CANCEL
Pt CB TREE STATE
C type Pt type Default
PtCallback t * Link NULL
reason subtype
Pt TREE COLLAPSING or Pt TREE EXPANDING.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
continued. . .
Convenience functions:
The PtTree widget defines the following convenience functions that
make it easier to use the tree once it’s been created:
PtTreeAddAfter()
Insert an item after the specified item
PtTreeAddFirst()
Add a root item to the widget, or adds an item as
the first child of a specified item
PtTreeAddImages()
Add images to the PtTree widget’s image list
PtTreeAllItems() Fill a buffer with pointers to all items
PtTreeAllocItem()
Allocate a new item
PtTreeClearSelection()
Clear the selection
PtTreeCollapse()
Collapse an expandable item
PtTreeFreeAllItems()
Unlink and free all items
PtTreeFreeItems()
Free an unlinked item
PtTreeGetCurrent()
Get the current item
PtTreeGetSelIndexes()
Fill a buffer with indexes of selected items
PtTreeItemIndex()
Calculate the index of the specified item
PtTreeModifyItem()
Change item resources
PtTreeRemoveChildren()
Unlink the children of the specified item
PtTreeRemoveItem()
Unlink an item
PtTreeRemoveList()
Unlink the given item and any siblings that follow
PtTreeRootItem()
Return the first root item of the tree
PtTreeSelectedItems()
Fill a buffer with pointers to the selected items
PtTreeSetSelIndexes()
Set the selection indexes
PtTreeUnselect()
Unselect the specified item
PtTreeUnselectNonBrothers()
Unselect all items that aren’t siblings of the
specified item
Synopsis:
void PtTreeAddAfter( PtWidget t *tree,
PtTreeItem t *item,
PtTreeItem t *brother );
Description:
This function inserts a list of trees linked with the brother member of
the PtTreeItem t structure.
PtTreeAddAfter() assumes that item points to a list of trees. The tree
variable points to a PtTree widget. The new items are added to the
specified tree below the specified brother:
item tree tree
B 1 1
2 brother 2 brother
3 A item
C
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeAddFirst(), PtTreeAllocItem(), PtTreeFreeAllItems(),
PtTreeFreeItems(), PtTreeItem t
Synopsis:
void PtTreeAddFirst( PtWidget t *tree,
PtTreeItem t *item,
PtTreeItem t *parent );
Description:
This function adds a list of trees linked with the brother member of
the PtTreeItem t structure.
The parent argument identifies the parent item for the added items.
The new items will be added in front of any existing children of the
parent item:
item tree tree
B 1 parent 1 parent
2 A item
3
2
3
The parent argument may also be NULL, in which case the item will
be 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.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeAddAfter(), PtTreeAllocItem(), PtTreeFreeAllItems(),
PtTreeFreeItems(), PtTreeItem t, PtTreeRootItem(),
Synopsis:
int PtTreeAddImages( PtWidget t *widget,
PhImage t const *images,
int n );
Description:
This function adds n images to the widget’s image list. The function
returns the index of the first of the added items, which is the same as
the number of images on the list (before the new ones were added).
The widget makes its own copy of the PhImage t structures, but it
doesn’t copy the palettes or image data pointed to by members of the
structures.
Returns:
The index of the first of the added items.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree
PhImage t in the Photon Library Reference
Synopsis:
PtTreeItem t **PtTreeAllItems(
PtWidget t *widget,
PtTreeItem 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.
Examples:
PtTreeItem t *item, **buf;
free( buf );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeGetCurrent(), PtTreeGetSelIndexes(),
PtTreeItem t, PtTreeSelectedItems(), PtTreeSetSelIndexes()
Synopsis:
PtTreeItem t *PtTreeAllocItem(
PtWidget t const *tree,
const char *string,
short set img,
short unset img );
Description:
This function allocates a new item. The item’s string is copied from
string.
The set img argument is the index of the image that’s displayed when
the item is set, and unset img is the image displayed when it isn’t set.
An item is considered set if its flags masked with the
Pt ARG TREE IMGMASK resource of the widget give a nonzero
value.
The image must be already present in the widget: if an index given to
the PtTreeAllocItem() function isn’t smaller than the current image
count, it’s changed to -1. A value of -1 means “no image.”
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeAddAfter(), PtTreeAddFirst(), PtTreeAddImages(),
PtTreeFreeAllItems(), PtTreeFreeItems(), PtTreeItem t,
PtTreeModifyItem()
Synopsis:
void PtTreeClearSelection( PtWidget t *widget );
Description:
This function clears the selection.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeGetCurrent(), PtTreeGetSelIndexes(), PtTreeGoto(),
PtTreeSelect(), PtTreeSelectedItems(), PtTreeSetSelIndexes(),
PtTreeUnselect(), PtTreeUnselectNonBrothers()
Synopsis:
void PtTreeCollapse( PtWidget t *tree,
PtTreeItem 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 != NULL, the Pt CB TREE STATE callback will be invoked.
The event argument is the event that will be passed to the callback.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeExpand(), PtTreeGetCurrent(), PtTreeGoto(),
PtTreeItem t, PtTreeShow()
Synopsis:
int PtTreeExpand( PtWidget t *tree,
PtTreeItem 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 Pt CB TREE STATE callback is invoked. The
event argument is the event that will be passed to the callback. If the
callback function prevents the expansion by setting the expand field in
the callback structure to a nonzero value, the function will return that
value. A value of 0 means successful expansion.
Returns:
A value of zero on successful expansion, otherwise the value that
prevented the expansion.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeCollapse(), PtTreeGetCurrent(), PtTreeGoto(),
PtTreeItem t, PtTreeShow()
Synopsis:
void PtTreeFreeAllItems( PtWidget t *tree );
Description:
This function unlinks and frees all items in the tree widget. Note that
this function is called automatically when the PtTree widget is being
deleted.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeAllocItem(), PtTreeFreeItems(),
PtTreeRemoveChildren(), PtTreeRemoveItem(), PtTreeRemoveList()
Synopsis:
void PtTreeFreeItems( PtTreeItem t *item );
Description:
This function frees the subtrees (the item together with its brothers
and their children). The function assumes that the items don’t belong
to any tree — use the PtTreeRemoveChildren(), PtTreeRemoveItem(),
or PtTreeRemoveList() function to remove the subtree from a tree
widget before freeing the subtrees.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeAllocItem(), PtTreeFreeAllItems(),
PtTreeRemoveChildren(), PtTreeRemoveItem(), PtTreeRemoveList()
Synopsis:
PtTreeItem t *PtTreeGetCurrent(
const PtWidget t *widget );
Description:
This function returns a pointer to the current item in the given
PtTree widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeClearSelection(), PtTreeGetSelIndexes(),
PtTreeGoto(), PtTreeItem t, PtTreeRootItem(), PtTreeSelect(),
PtTreeSelectedItems(), PtTreeSetSelIndexes(), PtTreeShow(),
PtTreeUnselect(), PtTreeUnselectNonBrothers()
Synopsis:
unsigned short *PtTreeGetSelIndexes(
PtWidget t *widget,
unsigned short *buffer );
Description:
This function fills a buffer with indexes of all the selected items in the
PtTree widget. The first item in the widget has an index of 1, not 0.
Returns:
A pointer to the buffer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeClearSelection(), PtTreeGetCurrent(), PtTreeGoto(),
PtTreeItem t, PtTreeRootItem(), PtTreeSelect(),
PtTreeSelectedItems(), PtTreeSetSelIndexes(), PtTreeShow(),
PtTreeUnselect(), PtTreeUnselectNonBrothers()
Synopsis:
int PtTreeGoto( PtWidget t *list,
PtTreeItem 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.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeClearSelection(), PtTreeGetCurrent(), PtTreeGoto(),
PtTreeItem t, PtTreeRootItem(), PtTreeSelect(),
PtTreeSelectedItems(), PtTreeSetSelIndexes(), PtTreeShow(),
PtTreeUnselect(), PtTreeUnselectNonBrothers()
Synopsis:
typedef struct Pt tree item {
PtGenTreeItem t gen;
short set img, unset img;
void *data;
char string[1];
} PtTreeItem t;
Description:
This data structure describes an item in a PtTree. The members
include at least:
set img The index into the tree’s Pt ARG TREE IMAGES
resource of the image that’s displayed when the item is
set. An item is considered set if its flags masked with
the tree’s Pt ARG TREE IMGMASK resource give a
nonzero value.
unset img The index of the image displayed when the item isn’t
set.
Classification:
Photon
See also:
PtGenList, PtGenTree, PtGenTreeItem t, PtTree,
PtTreeAddAfter(), PtTreeAddFirst(), PtTreeAllItems(),
PtTreeAllocItem(), PtTreeFreeItems(), PtTreeGetCurrent(),
PtTreeItemIndex(), PtTreeModifyItem(), PtTreeRemoveItem(),
PtTreeRootItem(), PtTreeSelectedItems()
Synopsis:
int PtTreeItemIndex( const PtTreeWidget t *list,
const PtTreeItem t *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 item, or 0 if it belongs to a collapsed subtree.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeAllItems(), PtTreeGetSelIndexes(), PtTreeItem t
Synopsis:
PtTreeItem t *PtTreeModifyItem( PtWidget t *tree,
PtTreeItem t *item,
const char *string,
short sel img,
short unsel img );
Description:
This function changes item resources.
¯ The set img argument is the index of the image that’s displayed
when the item is set, and unset img is the image displayed when it
isn’t set. An item is considered set if its flags masked with the
Pt ARG TREE IMGMASK resource of the widget give a nonzero
value.
☞ Don’t use this function to modify an item that hasn’t yet been added
to the tree.
Returns:
The new address of the item.
☞ This address may differ from the old one if the new string is longer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeAllocItem(), PtTreeItem t, PtTreeItemIndex()
Synopsis:
PtTreeItem t *PtTreeRemoveChildren(
PtTreeItem t *item );
Description:
This function unlinks all the children of the specified item and returns
the pointer to the first of them:
tree tree returned pointer
A item A C
B D
Returns:
A pointer to the first of the removed children, or NULL if the children
are visible.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeAddAfter(), PtTreeAddFirst(), PtTreeAllocItem(),
PtTreeFreeAllItems(), PtTreeFreeItems(), PtTreeItem t,
PtTreeModifyItem(), PtTreeRemoveItem(), PtTreeRemoveList()
Synopsis:
void PtTreeRemoveItem( PtWidget t *tree,
PtTreeItem t *item );
Description:
This function unlinks the given item together with its children from its
parent and brothers (if any) and sets the item->gen.father and
item->gen.brother fields to NULL:
tree tree item
A A B
B item C
The tree argument must point to the PtTree widget containing the
item, or be NULL if the item doesn’t belong to any tree.
Note that if tree is NULL and the item has no parent but has a previous
brother, then the function can’t find the previous brother and unlinks
the item from its brother. The function does nothing if
item->gen.father and tree are NULL.
PtTreeRemoveItem() never clears the Pt TREE ITEM EXPANDABLE
flag in the item’s parent.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeAddAfter(), PtTreeAddFirst(), PtTreeAllocItem(),
PtTreeFreeAllItems(), PtTreeFreeItems(), PtTreeItem t,
PtTreeModifyItem(), PtTreeRemoveChildren(), PtTreeRemoveList()
Synopsis:
void PtTreeRemoveList( PtWidget t *tree,
PtTreeItem t *first );
Description:
This function unlinks the item first and its brothers (together with
their children) from their parent (and previous brother) and sets their
parent fields to NULL:
tree tree first
A A B
B first C
The tree argument must point to the PtTree widget that contains the
items, or be NULL if the items don’t belong to any tree.
Note that if tree==NULL and first has no parent but has a previous
brother, then the function won’t be able to find the previous brother
and won’t be able unlink first from its previous brother.
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PtTree, PtTreeAddAfter(), PtTreeAddFirst(), PtTreeAllocItem(),
PtTreeFreeAllItems(), PtTreeFreeItems(), PtTreeItem t,
PtTreeModifyItem(), PtTreeRemoveChildren(), PtTreeRemoveItem()
Synopsis:
PtTreeItem t *PtTreeRootItem(
PtTreeWidget t const *tree );
Description:
This function returns a pointer to the first root item in the given
PtTree widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeAddAfter(), PtTreeAddFirst(), PtTreeAllItems(),
PtTreeFreeAllItems(), PtTreeFreeItems(), PtTreeGetCurrent(),
PtTreeGoto(), PtTreeItem t, PtTreeSelect(), PtTreeShow()
Synopsis:
void PtTreeSelect( PtWidget t *widget,
PtTreeItem t *item );
Description:
This function selects the given item.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeClearSelection(), PtTreeGetCurrent(),
PtTreeGetSelIndexes(), PtTreeGoto(), PtTreeItem t,
PtTreeSelectedItems(), PtTreeSetSelIndexes(), PtTreeUnselect(),
PtTreeUnselectNonBrothers()
Synopsis:
PtTreeItem t **PtTreeSelectedItems(
PtWidget t *widget,
PtTreeItem t **buffer );
Description:
This function fills a buffer with pointers to the tree’s selected items:
Returns:
A pointer to the buffer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeClearSelection(), PtTreeGetCurrent(),
PtTreeGetSelIndexes(), PtTreeGoto(), PtTreeItem t,
PtTreeSelect(), PtTreeSetSelIndexes(), PtTreeUnselect(),
PtTreeUnselectNonBrothers()
Synopsis:
int PtTreeSetSelIndexes(
PtWidget t *widget,
const unsigned short *buffer,
int count );
Description:
This function sets the selection indexes. The function 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 indexes or indexes out of range.
Note that if the selection mode is Pt RANGE MODE, only the first
index and the count are used.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeClearSelection(), PtTreeGetCurrent(),
PtTreeGetSelIndexes(), PtTreeGoto(), PtTreeItem t,
PtTreeSelect(), PtTreeSelectedItems(), PtTreeUnselect(),
PtTreeUnselectNonBrothers()
Synopsis:
int PtTreeShow( PtWidget t *widget,
PtTreeItem 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:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeClearSelection(), PtTreeCollapse(), PtTreeExpand(),
PtTreeGetCurrent(), PtTreeGetSelIndexes(), PtTreeGoto(),
PtTreeItem t, PtTreeRootItem(), PtTreeSelect()
Synopsis:
void PtTreeUnselect( PtWidget t *widget,
PtTreeItem t *item );
Description:
This function unselects the given item belonging to the given PtTree
widget.
Note that PtTreeUnselect() doesn’t support the Pt RANGE MODE
selection mode.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTree, PtTreeClearSelection(), PtTreeGetCurrent(),
PtTreeGetSelIndexes(), PtTreeGoto(), PtTreeItem t,
PtTreeSelect(), PtTreeSelectedItems(), PtTreeSetSelIndexes(),
PtTreeUnselectNonBrothers()
Synopsis:
void PtTreeUnselectNonBrothers(
PtWidget t *widget,
PtTreeItem t *item );
Description:
This function unselects 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
See also:
PtTree, PtTreeClearSelection(), PtTreeGetCurrent(),
PtTreeGetSelIndexes(), PtTreeGoto(), PtTreeItem t,
PtTreeSelect(), PtTreeSelectedItems(), PtTreeSetSelIndexes(),
PtTreeUnselect()
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtTerminal →
PtTty
PhAB icon:
Public header:
<photon/PtTty.h>
Description:
A PtTty widget is a PtTerminal attached to a device. The device
output is passed to the terminal, but also can be caught with the
Pt CB TTY OUTPUT callback.
0 33 //61/*/Dev32.pty.423D 20r RECV 0 12k 16k
1 40 //61/bin/Fsys.aha4scsi 22r RECV 0 73k 5193k
0 48 //61/bin/Csc2 21r RECV 0 49k 5877k
0 59 //135/bin/sh 24r RECV 0 16k 53k
0 67 //135/*/bin/Pq.m64 10o RECV 0 16k 20k
2 106 //135/*/bin/Photon 29o RECV 0 36k 6688k
2 109 //135/*/bin/phfont 10o WAIT -1 16k 28k
4 4035 //135/*/crt/m64bios.ms 10o REPLY 20 34k 45k
$
If the widget has the Pt GETS FOCUS flag set in its Pt ARG FLAGS
resource, keyboard input to the widget (as well as mouse events) are
redirected to the device. The Pt ARG TTY INPUT resource can also
be used to simulate keyboard input.
☞ The widget opens its pty and starts its command as soon as you set
Pt ARG TTY CMD or Pt ARG TTY ARGV, even if the widget hasn’t
yet been realized. By default, the command continues to run if you
unrealize the widget.
Since the widget looks at the current value of those resources when
spawning the command, changing their values after a command has
been spawned doesn’t affect the command that’s already running.
Make sure that those resources have correct values before you set
Pt ARG TTY CMD or Pt ARG TTY ARGV.
Here’s an example:
/* Have we succeeded? */
PtSetArg( &arg, Pt ARG TTY FD, 0, 0 );
PtGetResources( ABW tty, 1, &arg );
if ( arg.value == -1 )
PtTerminalPuts( "Unable to find a pty\r\n" );
else {
/* Run a program on the pseudo tty.
* NULL is more or less a shortcut for
* "char *argv[] = { "/bin/sh", NULL };",
* except it runs *your* shell rather than always /bin/sh.
*/
PtSetArg( &arg, Pt ARG TTY ARGV, NULL, 0 );
PtSetResources( ABW tty, 1, &arg );
/* Have we succeeded? */
PtSetArg( &arg, Pt ARG TTY PID, NULL, 0 );
PtGetResources( ABW tty, 1, &arg );
if ( arg.value == 0 )
PtTerminalPuts( "Unable to spawn the shell\r\n" );
}
☞ PhAB doesn’t know that these resources are order-dependent. Set the
resources in the correct order. If you suspect that the order isn’t
correct, set all the order-dependent resources to their default values,
and then set them again in the correct order.
New resources:
continued. . .
When this resource is being set, the widget spawns a process on the
device. The resource value must be the pointer to a NULL-terminated
array of pointers to strings. These strings are used for the program
name and arguments.
The first string in the array specifies the program to execute. If it
doesn’t contain a slash character, the PATH environment variable is
used to search for the program.
If the Pt TTY ARGV0 flag is set (which is the default), the first string
is also used as the first argument to the new process (argv[0]). If the
flag is clear, the argument list is assumed to start from the second item
of the array passed as the resource value. This allows to run a program
whose argv[0] entry is different from the actual name of the program.
If the list is NULL or contains too few non-NULL elements (the
minimum is one when the Pt TTY ARGV0 flag is set and two when
it’s clear), the user’s shell is spawned. If the Pt TTY ARGV0 flag is
clear and the list is NULL or empty, this is a login shell.
All the flags and resources described under Pt ARG TTY CMD,
except the Pt TTY ARGV0 flag, have the same effect when this
resource is set.
The buffer that’s used by the widget for reading data from the device
and passing them to the PtTerminalPut() function. If this resource is
set, both the address and the length of a buffer must be given. The
widget then uses the given buffer. Several widgets may share a
common buffer, provided that none of them attaches a callback that
could cause a recursive invocation of the PtTerminalPut() function.
The length of the buffer used by the widget for reading data from the
device. If this resource is set, the widget allocates a buffer.
When this resource is being set, the widget spawns a process on the
device.
If the resource value is a NULL or points to an empty string, the user’s
shell is spawned. If the resource is a nonempty string, the widget
spawns the user’s shell with two arguments: -c and the resource
string. In either case, if the Pt TTY ARGV0 flag is clear, the shell is
started as a login shell.
The current device size. It can differ from the terminal widget’s size,
depending on the Pt ARG TTY FLAGS resource. The
PtTerminalRowCol t structure contains the following members:
¯ short r
¯ short c
The exit status of the process spawned on the device. The value can
be examined using the POSIX macros described in the C Library
Reference, under waitpid(). The value is valid only after the child
process has terminated.
Pt ARG TTY FD
C type Pt type Default
int Scalar -1
When this resource is set, the widget attaches itself to the given file
descriptor. The descriptor must be a character device open in a mode
that allows reading. Using a value of -1 forces the widget to detach
from any device it’s attached to.
When this resource is read, the current file descriptor is returned. If
the widget isn’t attached to any device, -1 is returned.
This number defines (as a bitmask) the set of file descriptors that the
widget sets for a new process started when the Pt ARG TTY CMD or
Pt ARG TTY ARGV resource is set. The default value 7 means that
the PtTty widget’s device is available as descriptors 0, 1 and 2. Only
the ten low-order bits are used because the redirection is done using
the iov[] member of the PtSpawnOptions t structure, which has
ten elements.
The current “master” file descriptor. It’s equal to the Pt ARG TTY FD
resource unless the device has been opened using the
Pt ARG TTY PSEUDO resource, in which case this is the descriptor
of the “master” size of the pty.
When this resource is set, the widget opens the given pathname for
reading and writing and attaches itself to the open device. The
pathname must be a character device.
The descriptor is greater than 2 and has the FD CLOEXEC flag set.
When this resource is read, the pathname of the current device is
returned. If the widget isn’t attached to any device or was attached
using the Pt ARG TTY FD resource, NULL is returned.
Zero or the process ID of the process that has been spawned on the
device. The only value to which this resource can be explicitly set is
zero, meaning “Forget about that process.” If this resource is nonzero
when the device is closed (e.g. when the widget is being destroyed), a
SIGHUP signal is sent to the process group of the child process.
After opening the pseudo tty, the stty entry of the “slave”device is set
to default modes. The editing keys are set according to the current
value of the Pt ARG TERM PROTOCOL resource. If the protocol is
changed with the same call to PtSetResources() that opens the pseudo
tty, the order of the argument list is significant.
Both descriptors opened in this mode are greater than 2 and have the
FD CLOEXEC flag set.
are used. For more information about this structure, see PtSpawn() in
the Photon Library Reference.
Pt CB TTY DEVSIZE
C type Pt type Default
PtCallback t * Link NULL
event NULL
Pt CB TTY OUTPUT
C type Pt type Default
PtCallback t * Link NULL
event NULL
Pt CB TTY TERMINATED
C type Pt type Default
PtCallback t * Link NULL
event NULL
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
continued. . .
continued. . .
Convenience functions:
The PtTty widget defines the following convenience functions:
Synopsis:
const char PtTtyShell( void );
Description:
The PtTtyShell() function returns either the value of the SHELL
environment variable or, if SHELL is undefined, the user’s default
shell defined in the passwd file.
This string is used by the PtTty widget to start the user’s shell (see
Pt ARG TTY CMD and Pt ARG TTY ARGV resources to PtTty).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtUpDown
PhAB icon:
Public header:
<photon/PtUpDown.h>
Description:
The PtUpDown widget creates vertical or horizontal
increment/decrement buttons. It lets you increase or decrease a value.
A PtUpDown widget.
By default, the buttons display images of arrows, but you can use
other images if necessary. You can also specify the armed data, the
image displayed when the user presses one of the buttons.
The Pt CB ACTIVATE,Pt CB ARM, Pt CB DISARM, and
Pt CB REPEAT callbacks for the buttons have a subtype that
indicates which button was pressed.
New resources:
continued. . .
before providing the image to the widget. If you do this, the memory
used for the image is released when the widget is unrealized or
destroyed.
Pt HIGHLIGHTED
Highlight the widget with a beveled or etched
rectangle. The appearance of the rectangle depends
on the Pt ARG BORDER WIDTH,
Pt ARG TOP BORDER COLOR, and
Pt ARG BOT BORDER COLOR resources.
Pt ETCH HIGHLIGHT
Highlight the widget with an etched-line style
(normally, a beveled rectangle is used).
Pt CLIP HIGHLIGHT
Clip the corners of the rectangle that highlights the
widget.
¯ Pt HIGHLIGHTED
¯ Pt ETCH HIGHLIGHT
¯ Pt CLIP HIGHLIGHT
The amount of vertical space between the outermost border and the
inner images.
The amount of horizontal space between the outermost border and the
inner images.
¯ Pt VERTICAL
¯ Pt HORIZONTAL
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Pt ARG FLAGS
Only the following flags are supported for this widget:
¯ Pt HIGHLIGHTED
¯ Pt ETCH HIGHLIGHT
¯ Pt CLIP HIGHLIGHT
Pt CB ACTIVATE
Pt CB ARM
Pt CB DISARM
Pt CB REPEAT
These callbacks are passed a PtCallbackInfo t structure
that contains at least the following members:
ulong t reason;
ulong t reason subtype;
PhEvent t *event;
void *cbdata;
Class hierarchy:
PtWidget
PhAB icon:
None — not normally instantiated.
Public header:
<photon/PtWidget.h>
Description:
PtWidget is the fundamental superclass. All widgets belong to a
subclass of PtWidget.
New resources:
continued. . .
Pt ARG AREA
C type Pt type Default
PhArea t Struct 0,0,0,0
The x, y, height, and width values for the widget. This resource isn’t
displayed in PhAB; PhAB sets it automatically when you move or
size the widget.
PhPoint t size1;
PhPoint t offset1;
PgColor t color1;
char bytesperline1;
PhPoint t size2;
PhPoint t offset2;
PgColor t color2;
char bytesperline2;
char Spare[14];
char images[1];
} PhCursorDef t;
bytesperline1 The number of bytes per line for the first bitmap
plane.
bytesperline2 The number of bytes per line for the second bitmap
plane.
This resource can’t be edited in PhAB. You can draw the cursor as a
PtBitmap widget and have the application turn it into a
PhCursorDef t structure at runtime. For example:
PtArg t args[2];
memset( d, 0, sizeof(*d) );
d->size1.x = d->size2.x = BMP WIDTH;
d->size1.y = d->size2.y = BMP HEIGHT;
d->bytesperline1 = d->bytesperline2 = BMP BPL;
d->color1 = ab->colors[0];
d->color2 = ab->colors[1];
memcpy( d->images, ab->data[0], BMP SIZE );
memcpy( d->images + BMP SIZE, ab->data[1], BMP SIZE );
PtSetArg( &args[0], Pt ARG CURSOR TYPE, Ph CURSOR BITMAP , 0 );
PtSetArg( &args[2], Pt ARG BITMAP CURSOR, d, len );
PtSetResources( ABW base, 2, args );
free( d );
The thickness of the widget’s border. This must not exceed 15 pixels.
Ph CURSOR INHERIT
Inherit the cursor, not from the class hierarchy, but from the
family hierarchy, that is, from the way your application nests
the widgets. The cursor might even be inherited from the
Photon server itself.
Ph CURSOR BITMAP
Use the bitmap stored in Pt ARG BITMAP CURSOR for the
cursor.
Pt ARG DATA
C type Pt type Default
void * Alloc NULL
Pt ARG DIM
C type Pt type Default
PhDim t Struct 0,0
Pt ARG EFLAGS
C type Pt type Default
unsigned short Flag 0
Pt CONSUME EVENTS
The widget will consume any event encountered whether or not
an action was performed as a result of that event.
Pt INTERNAL HELP
Help information for the widget is displayed in a balloon, not in
the Helpviewer. See the chapter on Context-Sensitive Help in
the Photon Programmer’s Guide.
Pt DAMAGE PARENT
If the widget is damaged for any reason, propagate the damage
to its parent.
Pt ARG FLAGS
C type Pt type Default
long Flag 0
Pt CALLBACKS ACTIVE
For a few widgets, setting resources will cause
relevant callbacks to be invoked if this bit is set.
Otherwise callbacks are not invoked as a result of
setting resources. If a callback relies on this flag,
its description says so explicitly.
For example, if this bit is set for a PtDivider and
you use PtSetResources() to change the size of one
of its children, the Pt CB DIVIDER DRAG
callback is invoked.
Pt ALL BUTTONS
Indicates that any mouse button can activate the
widget. Default is the left button only.
Pt AUTOHIGHLIGHT
Causes the widget to highlight and get focus when
the cursor enters its extent, and to unhighlight and
lose focus when the cursor leaves.
Pt DAMAGED (read-only)
Indicates that the widget requires repair.
Pt DAMAGE FAMILY (read-only)
Indicates that the widget and all its children will be
repaired.
Pt DELAY REALIZE
Prevents the widget from becoming realized unless
it’s explicitly realized with PtRealizeWidget().
Pt DESTROYED (read-only)
The widget has been marked for destruction.
Pt ETCH HIGHLIGHT
Highlights the widget with an etched-line style
(normally, a beveled rectangle is used).
Pt FREE MEMORY
Indicates whether or not the widget may free
memory associated with any of its pointers. For
example, if this flag is set for a PtLabel widget
with an image structure and you destroy the
widget, the library frees the image memory as well
as the label’s image structure.
Using this bit might cause problems if, for example, more than one
☞ widget uses the same image. It’s better to use the image’s flags to
indicate which of the image’s allocated members should be freed. For
more information, see PhImage t in the Photon Library Reference.
Pt FOCUS RENDER
Draws a dotted line around the widget when it gets
focus.
Pt GETS FOCUS
Allows the widget to be granted focus when
appropriate.
Pt HIGHLIGHTED
Highlights the widget with a beveled or etched
rectangle. The appearance of the rectangle depends
on the Pt ARG BORDER WIDTH,
Pt ARG TOP BORDER COLOR, and
Pt ARG BOT BORDER COLOR resources.
Pt IN FLUX (read-only)
Indicates that a call to PtContainerHold() has been
made on the widget.
Pt OBSCURED (read-only)
Indicates that the widget is completely covered by
one other widget, or it’s completely beyond its
parent container’s canvas.
Pt OPAQUE (read-only)
Indicates that this widget completely obscures
everything behind it and inside its extent.
Pt PROCREATED (read-only)
Indicates that the widget is a procreated child of a
compound widget.
Pt REALIZED (read-only)
Indicates that the widget is realized.
Pt REALIZING (read-only)
Indicates that the widget is in the process of being
realized.
Pt SELECTABLE
Indicates that the user can select (repeat, arm,
disarm, and activate) this widget. The widget will
usually provide visual feedback when selected.
Pt SELECT NOREDRAW
Indicates that the widget won’t change its
appearance when set or unset. This is meaningful
only when the widget is selectable.
The default setting of this resource is 0; that is, no flags have been set.
For more information, see the PxHelp*() functions and the chapter on
Context-Sensitive Help in the Photon Programmer’s Guide.
Pt ARG POS
C type Pt type Default
PhPoint t Struct 0,0
Defines the x and y values for the widget. This resource isn’t
displayed in PhAB; PhAB sets it automatically when you move the
widget.
¯ Pt RESIZE X AS REQUIRED
¯ Pt RESIZE X ALWAYS
¯ Pt RESIZE X INITIAL
¯ Pt RESIZE X BITS
¯ Pt RESIZE Y AS REQUIRED
¯ Pt RESIZE Y ALWAYS
¯ Pt RESIZE Y INITIAL
¯ Pt RESIZE Y BITS
¯ Pt RESIZE XY ALWAYS
¯ Pt RESIZE XY AS REQUIRED
¯ Pt RESIZE XY INITIAL
¯ Pt RESIZE XY BITS
Note that each ...BITS flag is a mask that represents all the bits of that
type.
The default setting of this resource is 0; that is, no resize policy is in
effect.
A widget’s resize policy deals solely with the widget’s renderable
data. For a button, the data is its text; for a container, the data is its
children. Any rendered data that doesn’t fit within the widget’s canvas
is clipped.
If no resize policy is in effect, the widget’s size is unbounded; it may
be made as large or small as specified via Pt ARG DIM or
Pt ARG AREA.
If a resize policy is in effect, the widget will grow or shrink to honor
that policy. If the policy is ...ALWAYS, the widget will resize itself to
fit its data — the dimensions specified via Pt ARG DIM or
Pt ARG AREA won’t apply. If the policy is ...AS REQUIRED, the
widget will resize itself to fit its data only if its current canvas size is
inadequate to contain that data. In other words, it will grow, but won’t
shrink, to fit its data.
If the widget has the ...INITIAL bit set, the resize policy will be
applied only once each time the widget is realized. This bit is
meaningful only in concert with ...ALWAYS or ...AS REQUIRED.
For more information about resize policies, see the Geometry
Management chapter of the Photon Programmer’s Guide.
Pt CB BLOCKED
C type Pt type Default
PtCallback t * Link NULL
reason Pt CB BLOCKED
cbdata NULL
Pt CB DESTROYED
The callbacks that the widget invokes when it is destroyed. You’ll find
this resource useful for cleaning up variables or memory associated
with the widget.
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
reason Pt CB DESTROYED
Pt CB HOTKEY
C type Pt type Default
PtHotkeyCallback t * Link NULL
reason Pt CB HOTKEY
where:
Pt CB RAW
C type Pt type Default
PtRawCallback t * Link NULL
A list of raw callbacks that the widget invokes if the raw event it
receives matches the event mask provided in the PtRawCallback t
structure.
☞ These callbacks are invoked after the widget has processed the event,
and then only for events that the widget doesn’t consume. Contrast
this with the Pt CB FILTER resource defined by PtContainer.
reason Pt CB RAW
Pt CB REALIZED
C type Pt type Default
PtCallback t * Link NULL
reason Pt CB REALIZED
Pt CB UNREALIZED
C type Pt type Default
PtCallback t * Link NULL
reason Pt CB UNREALIZED
Class hierarchy:
PtWidget → PtBasic → PtContainer → PtWindow
PhAB icon:
None — use PhAB’s Window or Dialog module.
Public header:
<photon/PtWindow.h>
Description:
The PtWindow class provides an application window and a standard
appearance for all other windows. Windows are always managed by
the Photon Window Manager (the PtForwardWindowEvent() function
sends window events to the Window Manager).
File
A PtWindow widget.
invoked from the window menu or from one of the window controls.
You can also have your application notified when the user has
requested a window management function, regardless of whether or
not the Window Manager will perform that function.
You can set the string displayed in the window’s title bar with the
Pt ARG WINDOW TITLE resource. You should set the resource to
the string to be displayed.
You control the elements displayed in the window frame using the
Pt ARG WINDOW RENDER FLAGS resource. Enable or disable a
window-frame element by setting or clearing the appropriate bit:
Element Bit
Border Ph WM RENDER BORDER
Resize handles Ph WM RENDER RESIZE
Title bar Ph WM RENDER TITLE
Window menu Ph WM RENDER MENU
Minimize button Ph WM RENDER MIN
Maximize Button Ph WM RENDER MAX
Close Button Ph WM RENDER CLOSE
Help Button Ph WM RENDER HELP
¯ Ph WM RENDER ASAPP
¯ Ph WM RENDER ASICON
You can use the following four resources to control the minimum and
maximum sizes that the Window Manager will allow the user to resize
the window:
Ph WM TOFRONT
Move the window to the front of the window
stacking order.
Ph WM CONSWITCH
Move the window within the Photon coordinate
space so that it remains in the same position on the
screen when the workspace is moved in response
to a console-switch request.
Ph WM TERMINATE
Terminate the application. This operation is used
for graceful shutdown of the windowing system.
You may also tell the Window Manager to notify the application after
it has done a Window Manager operation. This behavior is controlled
by the Pt ARG WINDOW NOTIFY FLAGS resource. This resource
consists of the same set of flags as the
Pt ARG WINDOW MANAGED FLAGS resource.
Setting a flag in this resource tells the Window Manager that it should
send an event to the application whenever the corresponding
operation is performed on the window widget. The event sent to the
application is handled by the window callback for the window widget.
The window callback list belongs to the Pt CB WINDOW resource.
The callback data for this callback consists of a pointer to a window
event structure, PhWindowEvent t (described in the Photon Library
Reference).
Application icons
The PtIcon class provides an icon widget, a specialized form of
PtWindow widget. An icon is the same as a PtWindow widget in all
regards except for the following:
used to render the icon. For more information about the PhImage t
structure, see the Photon Library Reference.
There are two ways to associate the PtIcon widget with a window.
You can either:
¯ Create the PtIcon widget by itself and use the PtIcon instance
pointer as a resource value for the Pt ARG ICON WINDOW,
which you can set for the window at any time. You’ll also need to
set the Ph WM RENDER ASICON flag in the window’s render
flags.
memset(&area, 0, sizeof(area));
area.size.w = 14;
area.size.h = 14;
PtSetArg( &args[0], Pt ARG DIM, &area.size, 0 );
PtSetArg( &args[1], Pt ARG FILL COLOR, Pg GREY, 0 );
icon = PtCreateWidget( PtIcon, window, 2, args );
PtRealizeWidget( window );
scroll area beneath the menu bar. As with the menu bar, this widget
should have its right side anchored to the right side of the main
window. The bottom of the widget should also be anchored to the
bottom of the main window.
The geometry management issues of layout, sizing, and anchoring of
children are discussed in more detail in the Photon Programmer’s
Guide.
Creating subwindows
Some parts of the UI such as tool bars, palettes, or dialogs may reside
outside the main application window in windows of their own. These
windows are usually subwindows of the main application window.
A subwindow is obtained by creating a window widget as the child of
another window widget. A subwindow cannot be placed behind its
parent. The subwindows associated with a window are also iconified
as a group whenever the window itself is iconified.
New resources:
continued. . .
continued. . .
The maximum width of the widget. If this is set to 0, the default value
specified by the window manager is used.
The minimum height of the widget. If this is set to 0, the default value
specified by the window manager is used.
The minimum width of the widget. If this is set to 0, the default value
specified by the window manager is used.
The color of the window’s frame when the window has focus. This
overrides the color specified by the window manager.
Defines the root topic path for the window. For more information, see
the PxHelp*() functions in the Photon Library Reference and the
Context-Sensitive Help chapter of the Photon Programmer’s Guide.
The color of the window’s frame when the window doesn’t have
focus. This overrides the color specified by the window manager.
continued. . .
(for that, use Pt ARG WINDOW MANAGED FLAGS). You can set
any of the bits listed for Pt ARG WINDOW MANAGED FLAGS.
Ph WM RENDER ASAPP
Render the window as an application.
Ph WM RENDER ASICON
Render it as an icon.
Ph WM RENDER BORDER
Put a border around the window.
Ph WM RENDER CLOSE
If the window has a title bar, include a close button.
Ph WM RENDER HELP
If the window has a title bar, include a help button.
Ph WM RENDER MAX
If the window has a title bar, include a maximize button.
Ph WM RENDER MIN
If the window has a title bar, include a minimize button.
Ph WM RENDER MENU
If the window has a title bar, include a menu button.
Ph WM RENDER RESIZE
If the window has a border, add resize handles.
Ph WM RENDER TITLE
If the window has a border, add a title bar.
Controls what state the window will appear in when it is opened. You
can set one of the following:
Ph WM STATE ISALTKEY
Pass Alt function-key combinations to the application.
Ph WM STATE ISBACKDROP
Open as the workspace backdrop. See
Pt ARG WINDOW MANAGED FLAGS.
Ph WM STATE ISFRONT
Open the base window in front of the windows of all
applications. Child windows will open behind the last forced
Ph WM STATE ISHIDDEN
Open as a normal window but don’t display it.
Ph WM STATE ISMAX
Open as a maximized window.
Ph WM STATE ISFOCUS
Grant focus to the window when it’s opened if the cursor focus
option to the Window Manager is disabled (default is enabled).
Ph WM STATE ISBLOCKED
Block input to the window.
☞ You can change the state by setting Pt ARG WINDOW STATE before
the window is realized. After it’s been realized, you’ll need to call
PtForwardWindowEvent() or PtForwardWindowTaskEvent().
The string that the Window Manager displays in the title bar.
The color of the window’s title (i.e. the text). This overrides the color
specified by the window manager.
Pt CB WINDOW
C type Pt type Default
PtCallback t * Link NULL
The list of callbacks that the widget invokes when it receives an event
from the Window Manager. See Pt ARG WINDOW NOTIFY FLAGS.
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
reason Pt CB WINDOW
reason subtype
0 (not used).
Pt CB WINDOW CLOSING
C type Pt type Default
PtCallback t * Link NULL
The list of callbacks that the widget invokes when the window is
being closed. It’s invoked before the window’s region is removed.
reason subtype
0 (not used).
Pt CB WINDOW OPENING
C type Pt type Default
PtCallback t * Link NULL
The list of callbacks that the widget invokes when the window is
being opened. If you want to resize the window and want anchoring
to be in effect, do it in this type of callback.
reason subtype
0 (not used)
cbdata NULL
Pt CB WINDOW TRANSPORT
C type Pt type Default
PtCallback t * Link NULL
The list of callbacks that the widget invokes when the window is
being transported through a Jump Gate.
Each callback is passed a PtCallbackInfo t structure that
contains at least the following members:
reason subtype
Not used
event The Ph EV WM event that triggered this callback.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Convenience functions:
The PtWindow widget defines the following convenience functions:
PtWindowFocus()
Gives a window focus.
PtWindowGetState()
Returns the current state of a window.
PtWindowToBack()
Moves a window to the back of the workspace.
PtWindowToFront()
Brings a window to the front and gives it focus.
Synopsis:
int PtWindowFocus( PtWidget t *widget );
Description:
This function lets your application give focus to the specified window
widget. To do this, the function sends a message to the Window
Manager, telling it to give the window focus. The Window Manager
may change consoles if the specified window isn’t in the current
console.
Returns:
0 Successful completion.
Examples:
PtWidget t *my window;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWindowToBack(), PtWindowToFront()
PtForwardWindowEvent() in the Photon Library Reference
Synopsis:
long PtWindowGetState( PtWidget t *widget )
Description:
This function returns the current state of the window pointed to by the
widget variable:
State Description
Ph WM STATE ISHIDDEN The window is hidden.
Ph WM STATE ISMAX The window is maximized.
Ph WM STATE ISBACKDROP The window is a backdrop.
Ph WM STATE ISTASKBAR The window is a taskbar.
Ph WM STATE ISICONIFIED The window is iconified.
Ph WM STATE ISFRONT The window is the frontmost in
the family.
Ph WM STATE ISFOCUS The window has focus.
Returns:
The current state of the window, or -1 if the widget isn’t a PtWindow
or PtIcon widget, or the window wasn’t realized.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
continued. . .
Safety
Thread No
Synopsis:
void PtWindowToBack( PtWidget t *widget );
Description:
This function moves the specified window widget and all its child
windows to the back of the workspace. To do this, the function sends
a message to the Window Manager.
Examples:
PtWidget t *my window;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWindowFocus(), PtWindowToFront()
PtForwardWindowEvent(), PtWidgetToBack(), PtWidgetToFront() in
the Photon Library Reference
Synopsis:
void PtWindowToFront( PtWidget t *widget );
Description:
This function brings the specified window widget and all its child
windows to the front of the workspace and gives the front window
focus. To do this, the function sends a message to the Window
Manager. The Window Manager may switch consoles if the specified
window isn’t within the current workspace.
Examples:
PtWidget t *my window;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWindowToBack(), PtWindowFocus()
PtForwardWindowEvent(), PtWidgetToBack(), PtWidgetToFront() in
the Photon Library Reference
Class hierarchy:
PtWidget → PtBasic → RtMeter
PhAB icon:
Public header:
<photon/realtime/RtMeter.h>
Description:
The RtMeter widget is drawn as a half circle with divisional ticks at
1/4, 1/2, and 3/4 of the arc.
100
An RtMeter widget.
Programatically
The Rt ARG METER NEEDLE POSITION resource can be
used to set the needle position programmatically.
The widget bases its size on the text size and the specified
dimensions. If the given dimensions are too small, it sizes itself
appropriately based on the resize policy. The height of the widget
depends on the radius of the meter, which in turn depends on the X
dimension and text sizes.
...
PhArea t area = { { 10, 10 }, { 200, 200 } };
...
PtSetArg(&args[0], Pt ARG AREA, &area, 0);
PtCreateWidget(RtMeter, parent, 1, args)
...
1000
...
PhArea t area = { { 10, 10 }, { 200, 200 } };
PtCallback t cb[1] = { {moved cb, NULL} };
...
PhArea t area = { { 10, 10 }, { 200, 200 } };
PtCallback t cb[1] = { {moved cb, NULL} };
You’ll notice that as you move the needle on the widget, there’s very
little flickering. This is because when the needle moves it’s merely
erased and then drawn at the new position. However, if you create a
meter with Pg TRANSPARENT as a fill color, you’ll notice more
flickering because the needle can’t merely be erased — the
background must be drawn as well. In this case, flickering is reduced
by calculating a bounding rectangle for the needle and redrawing only
that rectangle. The most flickering (redraw) occurs when the needle is
at 45° or 135°.
mydata = info->cbdata;
itoa(mydata->position, pos, 10);
itoa(mydata->severity, sev, 10);
// draw the meter with 3 arcs and a callback for meter moved
n = 0;
PtSetArg( &args[n++], Pt ARG AREA, &meter area, 0 );
n = 0;
sev area.pos.x -= 60;
PtSetArg( &args[n++], Pt ARG AREA, &sev area, 0 );
PtSetArg( &args[n++], Pt ARG TEXT STRING, "Severity:", 0);
PtCreateWidget( PtLabel, window, n, args );
n = 0;
pos area.pos.x -= 60;
PtSetArg( &args[n++], Pt ARG AREA, &pos area, 0 );
PtSetArg( &args[n++], Pt ARG TEXT STRING, "Position:", 0);
PtCreateWidget( PtLabel, window, n, args );
n = 0;
PtSetArg( &args[n++], Pt ARG AREA, &quit area, 0 );
PtSetArg( &args[n++], Pt ARG TEXT STRING, "Quit", 0);
PtSetArg( &args[n++], Pt CB ACTIVATE, &callbacks[1], 0);
quit = PtCreateWidget( PtButton, window, n, args );
PtRealizeWidget( window );
PtMainLoop();
}
New resources:
continued. . .
The color for the center circle, outline of the meter, and divisional
ticks.
The increment used when the keyboard is used to move the meter’s
needle. Every press of the assigned keys will move the meter this
distance.
The maximum needle position; also the value drawn as the maximum.
The minimum needle position; also the value drawn as the minimum.
The number of severity arcs (levels) that the meter displays. This
must be 1, 2, or 3. If this resource is set higher than 3, only 3 arcs are
displayed.
Rt CB METER MOVED
C type Pt type Default
PtCallback t * Link NULL
event The event that caused the callback. If event is NULL, then
the callback was invoked because the
Rt ARG METER NEEDLE POSITION resource was set.
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
continued. . .
Class hierarchy:
PtWidget → PtBasic → PtGauge → RtProgress
PhAB icon:
Public header:
<photon/realtime/RtProgress.h>
Description:
The RtProgress widget draws a progress bar and (optionally) the
corresponding value in front of it.
55%
An RtProgress bar.
The bar can be either a single bar, growing continuously as the value
is changed, or it can consist of a number of divisions of equal size.
New resources:
The gap (in pixels) between the progress bar and the text (if the text
isn’t on top of the bar).
Inherited resources:
If the widget modifies an inherited resource, the “Default override”
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
Class hierarchy:
PtWidget → PtBasic → RtTrend
PhAB icon:
Public header:
<photon/realtime/RtTrend.h>
Description:
An RtTrend widget displays a trend graph. The data is displayed as a
set of connected points that shift in a specified direction and at the
rate at which data is fed in.
An RtTrend widget.
New resources:
The attributes that the trend may have. This resource is an array of
structures of type RtTrendAttr t, which contains at least the
following member:
To set the colors for all the trends at once, specify a list of mappings
of trends onto colors and use 0 for the trend number.
In order to set this resource, you must use the arguments to PtSetArg()
in an unusual way; the value argument points to the value of the
resource, as usual, but len is used for the trend number, not the size of
value. Thus, to set the attributes for all trends at the same time, set
PtSetArg’s len argument to 0 and have the value argument point to an
array of RtTrendAttr t structures.
For example, the following code fragment sets up the color list, and
sets the colors to be used for three trends.
int trend color array[4] = {Pg GREEN, Pg RED,
Pg YELLOW, Pg BLUE};
RtTrendAttr t one attr, several attr[3];
PtArg t args[2];
PtWidget t trend widget;
.
.
.
To set an attribute for a given trend, set PtSetArg’s len argument to the
number of that trend, and have the value argument point to a single
structure of type RtTrendAttr t. For example, the following would
change the color of trend 2 to Pg GREEN:
one attr.map = 1;
PtSetArg (&args[0], Rt ARG TREND ATTRIBUTES,
&one attr, 2);
PtSetResources (trend widget, 1, args);
☞ It isn’t possible to set the color of trend 0 alone, as setting the len
argument of PtSetArg() to 0 specifies that you want to set the color
index for all the trends.
The list of colors that the trend may use. To assign one of these colors
to a trend, use the Rt ARG TREND ATTRIBUTES resource.
☞ The first color in this list is always the same as Pt ARG COLOR.
The data displayed by the trends. This resource is used to set the data;
it can’t be used to extract the data from the trends.
When you want to add data to a trend, your application should set the
value argument to PtSetArg() with a pointer to a data buffer that
contains the new data points. The application must also set the len
parameter to the number of new data points being added to the trend.
If the widget is displaying multiple trends, the data buffer must
contain the new data for each trend: data for the first trend is followed
by data for the second trend, and so on. The application must set len
to be the total number of points being added, not the number of points
per trend.
If you set the value parameter to NULL, the trend’s display will be
cleared.
If you wish to replace some of the data for one trend, call
RtTrendChangeTrendData(). To replace data in all trends, call
RtTrendChangeData().
Rt GRID FORCE
Draw a grid even if the graphics device doesn’t support
hardware blitting. Some flickering may occur.
Rt TREND HORIZONTAL
Make the trends horizontal.
The number of grid lines along the x axis; in other words, the number
of vertical lines. The grid is displayed only if Rt GRID is set in
Rt ARG TREND FLAGS.
The number of grid lines along the y axis; in other words, the number
of horizontal lines. The grid is displayed only if Rt GRID is set in
Rt ARG TREND FLAGS.
The distance between data points displayed on the screen. The default
is 1. Note that if the increment is too large, the data won’t be plotted
correctly. Generally, you should use this resource only if you need a
coarse-grained display.
Defines the range of palette entries the widget uses for drawing if the
grid is displayed. This is useful if you have more than one RtTrend
widget and you want to make sure their palette entries don’t overlap.
Each RtTrend widget uses:
Inherited resources:
If the widget modifies an inherited resource, the "Default override"
column indicates the new value. This modification affects any
subclasses of the widget.
continued. . .
Convenience functions:
The RtTrend widget defines the following convenience functions
that make it easier to use the widget once it’s been created:
RtTrendChangeData()
Replace some samples for all trends
RtTrendChangeTrendData()
Replace some samples for one trend
Description:
These functions allow you to replace some samples in one or more
trends, without touching other data or other trends in the widget.
☞ These functions are used to replace data that is already in a trend, not
to add data to the end of the trends.
¯ ...
¯ the data for the first trend is put into the first nsamples places of
newdata, followed by those for trend 2, 3 and so on.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
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.
! PtScrollArea 526
enabling
“set” state 762 PtContainer 132
Pt CB ACTIVATE 49 PtText 633
PtTextSetSelection() 658
RtMeter 809
autohighlighting 759
A AwFileSelect See PtFileSel
instead
accelerators 323
AwFileSelectCallback t 30,
menu items 364
31
activation
AwMessage See PtMessage
any mouse button 759
instead
defined 44
Pt CB ACTIVATE 48, 665
anchor flags 129, 131
and resize flags 138 B
anchor offsets 129, 130
arc widget See PtArc Bézier curve widget See
area 754 PtBezier
arming background
defined 44 color 46
Pt CB ARM 50 pattern 47
arrow keys widget See PtBkgd
disabling balloons
PtGroup 282 callback 133
FD CLOEXEC 734
file folder widget See PtTab
file selector widget See G
PtFileSel
fill gauge widget See PtGauge
color 46 generic list widget See
pattern 47 PtGenList
filter callback 134 generic tree widget See
flags PtGenTree
anchor 129, 131 ghosting 48, 761
common, summarized 18 graphics
container 132 bandwidth threshold 46
line widget See PtLine making actions the same for all
lines, dashed 270 buttons 45, 759
list widget right button action 44, 761
superclass See PtGenList Pt CB MENU 44, 53
text items See PtList multiline text widget See
with text-entry field See PtMultiText
PtComboBox multiple choice widget See
PtComboBox
multiple-select mode 227
M
margins N
height 47
width 48 navigation See CUA (Common
matrix widget See PtGroup User Access)
memory context 139, 140 numeric widget
memory, freeing floating-point See
automatically 760 PtNumericFloat
when destroying a widget 766 integer See
menu PtNumericInteger
enabling mouse button 761 range of values See
item, indicating 761 PtSlider
Pt CB MENU 44, 53 superclass See PtNumeric
menu bar widget See PtMenuBar
menu button widget See
PtMenuButton
O
menu widget See PtMenu
message widget See PtMessage obscuring 761
meter widget See RtMeter on/off button widget See
mouse PtOnOffButton
left button actions 44 opacity 761
click count 49
Pt CB ACTIVATE 48, 665
Pt CB ARM 50
Pt CB DISARM 51 P
pane widget See PtPane
Pt ARG TERM RESIZE STR 570, Pt ARG TOP ITEM POS 230, 238
573, 590 Pt ARG TRANS PATTERN 48
Pt ARG TERM ROWS 570, 571, Pt ARG TREE BALLOON 675
590, 598, 599 Pt ARG TREE FLAGS
Pt ARG TERM SCRLBK COUNT PtGenTree 242, 248
590 PtTree 682
Pt ARG TERM SCRLBK LIMIT Pt ARG TREE IMAGES 673, 676
590 Pt ARG TREE IMGMASK 676
Pt ARG TERM SCRLBK POS Pt ARG TTY ARGV 729
591 Pt ARG TTY BUFFER 730
Pt ARG TERM SCROLL 575, 591 Pt ARG TTY BUFLEN 730
Pt ARG TERM SELECTION 591 Pt ARG TTY CMD 729, 730
Pt ARG TERM SIZE 570–572, Pt ARG TTY DEVSIZE 731
593, 598, 599 Pt ARG TTY EXIT STATUS 731,
Pt ARG TERM VISUAL BELL 738
593 Pt ARG TTY FD 732
Pt ARG TEXT CURSOR WIDTH Pt ARG TTY FDSET 732
641 Pt ARG TTY FLAGS 732
Pt ARG TEXT FLAGS 420, 634, Pt ARG TTY INPUT 733
641, 650 Pt ARG TTY INPUT WRITTEN
Pt ARG TEXT FONT 734
PtLabel 317, 328 Pt ARG TTY MFD 734
PtMultiText 400, 429, 431 Pt ARG TTY PATH 734
Pt ARG TEXT HIGHLIGHT BACKGROUND COLOR Pt ARG TTY PID 730, 735
642 Pt ARG TTY PRI 735
Pt ARG TEXT HIGHLIGHT TEXT COLOR Pt ARG TTY PSEUDO 735
642 Pt ARG TTY SPAWN OPTIONS
Pt ARG TEXT STRING 736
PtLabel 317, 321, 329 Pt ARG UNDERLINE1 329
PtMultiText 400, 413 Pt ARG UNDERLINE2 329
Pt ARG TEXT SUBSTRING Pt ARG UNDERLINE TYPE 329
PtMultiText 400 Pt ARG UPDOWN ARM DATA BOTTOM
PtText 642 745
Pt ARG TIMER INITIAL 661 Pt ARG UPDOWN ARM DATA LEFT
Pt ARG TIMER REPEAT 661 745
Pt ARG TOP BORDER COLOR Pt ARG UPDOWN ARM DATA RIGHT
48 745
Pt
ARG TTY FDSET 732 color, right 746
ARG TTY FLAGS 732
Pt color, top 749
ARG TTY INPUT 733
Pt inner, customizing 748
ARG TTY INPUT WRITTEN
Pt roundness 748
734 buttons
Pt ARG TTY MFD 734 images, armed 745
Pt ARG TTY PATH 734 images, normal 746
Pt ARG TTY PID 730, 735 spacing between 749
Pt ARG TTY PRI 735 events, blocking 747
Pt ARG TTY PSEUDO 735 flags 747
Pt ARG TTY SPAWN OPTIONS focus, granting 747
736 highlighting
Pt CB TTY DEVSIZE 736 clipping 747
Pt CB TTY OUTPUT 737 enabling 747
Pt CB TTY TERMINATED etched 747
738 margin
shell, returning name of 743 height 748
spawn options 736 width 748
TERM 731 orientation 749
widget, resizing Pt ARG FLAGS 748, 751
automatically 733 Pt ARG UPDOWN ARM DATA BOTTOM
Pt TTY ARGV0 729, 730, 733 745
Pt TTY BUF PRIVATE 733 Pt ARG UPDOWN ARM DATA LEFT
Pt TTY DEVFORCE 733 745
Pt TTY DEVLIMIT 733 Pt ARG UPDOWN ARM DATA RIGHT
Pt TTY DEVRESIZE 732 745
PtTtyOutput t 737 Pt ARG UPDOWN ARM DATA TOP
Pt TTY SETENV 731, 733 745
PtTtyShell() 743 Pt ARG UPDOWN BOTTOM BORDER COLOR
Pt TTY TERMRESIZE 733 746
Pt ULINE ETCHED IN 329 Pt ARG UPDOWN DATA BOTTOM
Pt ULINE ETCHED OUT 329 746
PtUpDown 744 Pt ARG UPDOWN DATA LEFT
background color 746 746
borders Pt ARG UPDOWN DATA RIGHT
color, bottom 746 746
color, left 749
U X
unrealizing x, y coordinates 754, 763
Pt CB UNREALIZED 769
up/down button widget See
PtUpDown
UPDOWN BOTTOM 752
UPDOWN LEFT 752
UPDOWN RIGHT 752
UPDOWN TOP 752
URL (Universal Resource
Locator) 303
user-defined data 665, 765
V
vector graphics 252
rescaling 256
viewport widget See
PtScrollArea
W
wedge 40
widget See also PtWidget
contributed xix
description, contents of 22