photon_lib_ref
photon_lib_ref
Library 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
1 Summary of Entries 1
Categories 3
Entries arranged by category 7
Background processing 7
Bitmaps and Images 7
Blitting 8
Characters, translating 8
Clipboard operations 9
Clipping 9
Colors — converting and parsing 10
Configuration files 11
Coordinates, translating 12
Cursors/pointers 13
Data chains 13
Dragging 13
Draw contexts 14
Drawing attributes 14
Events 16
Font handling 17
Geometry 18
Graphical contexts 19
Input/Output events 19
Interprocess Communication (IPC) 20
Jump Gates 21
Key events, translating 21
Memory contexts 21
Messages and questions 22
Modal dialogs 22
Modules 23
Multibyte-character strings 23
Online help 24
Photon Application Builder functions 24
Photon services, connecting and disconnecting 25
Primitive drawing routines 25
Printing 27
Processes 27
Regions 28
Shared memory 29
Signals 29
Strings, translating 29
System information 30
Text 30
Tiles 30
Wide characters 31
Widgets 31
Window Manager 60
2 Ap — PhAB 63
ApAddClass() 66
ApAppendTranslation() 68
ApBitmap t 70
ApCloseDBase() 72
ApCopyWidget() 74
ApCreateModule() 76
ApCreateWidget() 80
ApCreateWidgetFamily() 83
ApDeleteWidget() 86
ApError() 88
ApFreeBitmapRes() 91
ApGetBitmapRes() 93
ApGetImageRes() 96
ApGetInstance() 98
ApGetItemText() 100
ApGetTextRes() 102
ApGetWidgetPtr() 104
ApInfo t 106
ApInstanceName() 108
ApModifyItemState() 110
ApModifyItemText() 112
ApModuleFunction() 114
ApModuleLocation() 116
ApModuleParent() 118
ApName() 120
ApOpenDBase(), ApOpenDBaseFile() 122
ApResClose() 124
ApSaveDBaseFile() 125
ApSetTranslation() 127
ApWidget() 129
mbstrnlen() 142
mbstrrchr() 144
5 Pg — Graphics 175
PgBackgroundShadings() 178
PgBlueValue() 179
PgClearDrawBuffer() 180
PgClearTranslation() 182
PgCMY() 183
PgColor t 185
PgColorHSV t 187
PgColorMatch() 188
PgCreateGC() 189
PgDefaultFill() 190
PgDefaultGC() 191
PgDefaultMode() 192
PgDefaultStroke() 193
PgDefaultText() 194
PgDestroyGC() 195
PgDrawArc() 196
PgDrawBevelBox(), PgDrawIBevelBox() 200
PgDrawBeveled() 203
PgDrawBezier(), PgDrawBeziermx() 207
PgDrawBitmap(), PgDrawBitmapmx() 210
PgDrawEllipse() 213
PgDrawGrid() 216
PgDrawImage(), PgDrawImagemx() 218
PgDrawLine(), PgDrawILine() 221
PgDrawPhImagemx() 223
PgDrawPixel(), PgDrawIPixel() 225
PgDrawPixelArray(), PgDrawPixelArraymx() 226
PgDrawPolygon(), PgDrawPolygonmx() 228
PgDrawRect(), PgDrawIRect() 232
PgDrawRepBitmap(), PgDrawRepBitmapmx() 235
PgDrawRepImage(), PgDrawRepImagemx() 239
PgDrawRoundRect() 242
PgDrawSpan(), PgDrawSpanmx() 245
PgDrawString(), PgDrawStringmx() 248
PgDrawText(), PgDrawTextmx(), PgDrawTextChars() 250
PgDrawTextArea() 255
PgDrawTImage(), PgDrawTImagemx() 257
PgDrawTrend(), PgDrawTrendmx() 259
PgExtentText() 262
PgFlush(), PgFFlush() 264
PgGetGC() 266
PgGetPalette() 267
PgGray() 268
PgGrayValue() 270
PgGreenValue() 271
PgHSV() 272
PgHSV2RGB() 275
PgRedValue() 276
PgRGB() 277
PgRGB2HSV() 279
PgSetClipping() 281
PgSetDrawBufferSize() 283
PgSetDrawMode() 285
PgSetFillColor() 287
PgSetFillDither() 289
PgSetFillTransPat() 293
PgSetFillXORColor() 295
PgSetFont() 297
PgSetGC() 299
PgSetMultiClip() 300
PgSetPalette() 302
PgSetPlaneMask() 305
PgSetRegion() 307
PgSetStrokeCap() 308
PgSetStrokeColor() 310
PgSetStrokeDash() 311
PgSetStrokeDither() 314
PgSetStrokeJoin() 316
PgSetStrokeTransPat() 319
PgSetStrokeWidth(), PgSetStrokeFWidth() 320
PgSetStrokeXORColor() 322
PgSetTextColor() 323
PgSetTextDither() 324
PgSetTextTransPat() 326
PgSetTextXORColor() 327
PgSetTranslation() 328
PgSetUnderline() 330
PgSetUserClip(), PgSetUserClipAbsolute() 332
PgShmemAttach() 334
PgShmemCleanup() 336
PgShmemCreate() 338
PgShmemDestroy() 340
PgShmemDetach() 341
6 Ph — Photon 343
PhAddMergeTiles() 346
PhArea t 348
PhAttach() 349
PhBlit() 353
PhChannelAttach() 355
PhClipboardCopy() 357
PhClipboardCopyString() 359
PhClipboardPasteFinish() 361
PhClipboardPasteStart() 362
PhClipboardPasteString() 364
PhClipboardPasteType() 366
PhClipboardPasteTypeN() 368
PhClipHeader 370
PhClipTilings() 371
PhCoalesceTiles() 373
PhCopyTiles() 374
PhDCGetCurrent() 375
PhDCSetCurrent() 376
PhDetach() 379
PhDeTranslateTiles() 380
PhDim t 381
PhEvent t 382
PhEventArm() 400
PhEventEmit() 401
PhEventEmitmx() 404
PhEventNext() 407
PhEventPeek() 409
PhEventRead() 411
PhEventRegion t 414
PhFreeTiles() 415
PhGetConnectId() 416
PhGetConnectInfo() 417
PhGetData() 419
PhGetMsgSize() 420
PhGetRects() 422
PhGetTile() 423
PhImage t 424
PhInitDrag() 430
PhIntersectTilings() 433
PhKeyEvent t 434
PhKeyToMb() 438
PhLibVersion() 439
PhMakeGhostBitmap() 441
PhMakeTransBitmap() 442
PhMergeTiles() 446
PhMoveCursorAbs() 447
PhMoveCursorRel() 449
PhPoint t 451
PhQueryCursor() 452
PhQueryRids() 455
PhQuerySystemInfo() 459
PhReattach() 461
PhRect t 463
PhRectsToTiles() 464
PhRegion t 465
PhRegionChange() 470
PhRegionClose() 472
PhRegionDataFindType() 473
PhRegionDataHdr t 474
PhRegionOpen() 476
PhRegionQuery() 481
PhReleaseImage() 483
PhSortTiles() 485
PhTile t 486
PhTilesToRects() 487
PhTimerArm() 488
PhTo8859 1() 490
PhTranslateTiles() 491
PhWindowChange() 492
PhWindowClose() 494
PhWindowEvent t 495
PhWindowOpen() 499
PhWindowQueryVisible() 501
7 Pm — Memory 503
PmMemCreateMC() 506
PmMemFlush() 510
PmMemReleaseMC() 512
PmMemSetChunkSize() 513
PmMemSetMaxBufSize() 514
PmMemSetType() 515
PmMemStart() 516
PmMemStop() 518
8 Pp — Printing 519
PpLoadPrinter() 522
PpPrintClose() 524
PpPrintCreatePC() 526
PpPrintGetPC() 528
PpPrintNewPage() 532
PpPrintOpen() 534
PpPrintReleasePC() 536
PpPrintSetPC() 537
PpPrintStart() 543
PpPrintStop() 546
PpPrintWidget() 547
PtChannelCreate() 610
PtChildType() 611
PtClearWidget() 613
PtConsoleSwitch() 615
PtContainerBox() 617
PtContainerFindFocus() 619
PtContainerFocusNext() 620
PtContainerFocusPrev() 622
PtContainerGiveFocus() 624
PtContainerHit() 629
PtContainerHold() 631
PtContainerNullFocus() 633
PtContainerRelease() 635
PtCreateWidget() 637
PtDamageExtent() 639
PtDamageWidget() 641
PtDestroyWidget() 643
PtDeTranslateRect() 645
PtEndFlux() 646
PtEventHandler() 648
PtExtentWidget() 649
PtExtentWidgetFamily() 650
PtFdProcF t, PtFdProc t 651
PtFileSelection() 652
PtFindChildClass() 661
PtFindChildClassMember() 663
PtFindContainer() 665
PtFindData() 666
PtFindDisjoint() 667
PtFindFocusChild() 669
PtFindGuardian() 670
PtFindNextData() 672
PtFlush() 674
PtFontSelection() 675
PtForwardWindowEvent() 678
PtForwardWindowTaskEvent() 680
PtFrameSize() 682
PtGetAbsPosition() 684
PtGetControlFlags() 685
PtGetParent() 686
PtGetParentWidget() 688
PtGetRcvidPid() 689
PtGetResources() 691
PtGlobalFocusNext() 693
PtGlobalFocusNextContainer() 694
PtGlobalFocusNextFrom() 695
PtGlobalFocusPrev() 697
PtGlobalFocusPrevContainer() 698
PtGlobalFocusPrevFrom() 699
PtHit() 701
PtHold() 702
PtInflateBalloon() 704
PtInit() 706
PtInputCallbackProcF t, PtInputCallbackProc t 708
PtIsFluxing() 709
PtIsFocused() 710
PtLabelWidgetCanvas() 711
PtMainLoop() 713
PtMessageBox() 714
PtModalEnd() 715
PtModalStart() 716
PtNextTopLevelWidget() 719
PtPositionMenu() 720
PtPrintSelection() 721
PtProcessEvent() 724
PtPulseArmFd() 725
PtPulseArmPid() 727
PtPulseDeliver() 729
PtPulseDisarm() 731
PtQuerySystemInfo() 732
PtRealizeWidget() 734
PtReattach() 736
PtRectIntersect() 738
PtRectUnion() 739
PtRelease() 740
PtRemoveCallback() 741
PtRemoveCallbacks() 743
PtRemoveData() 745
PtRemoveEventHandler() 747
PtRemoveEventHandlers() 749
PtRemoveHotkeyHandler() 750
PtReParentWidget() 752
PtReRealizeWidget() 754
PtResizeEventMsg() 755
PtSendEventToWidget() 757
PtSetAreaFromExtent() 759
PtSetAreaFromWidgetCanvas() 761
PtSetArg() 762
PtSetParentWidget() 764
PtSetResources() 766
PtSignalProcF t, PtSignalProc t 768
PtSpawn() 769
PtSpawnDeleteCallback() 772
PtSpawnSetCallback() 773
PtSpawnWait() 774
PtStartFlux() 776
PtSyncPhoton() 777
PtSyncWidget() 779
PtTimerArm() 780
PtTranslateRect() 781
PtUnlinkData() 782
PtUnrealizeWidget() 783
PtUpdate() 784
PtValidParent() 785
PtWidgetArea() 787
PtWidgetBrotherBehind() 788
PtWidgetBrotherInFront() 789
PtWidgetCanvas() 790
PtWidgetChildBack() 792
PtWidgetChildFront() 794
PtWidgetClass() 795
PtWidgetClassFlags() 797
PtWidgetDim() 799
PtWidgetExtent() 800
PtWidgetFamily() 802
PtWidgetFlags() 804
PtWidgetHelpHit() 805
PtWidgetInsert() 806
PtWidgetIsClass() 808
PtWidgetIsClassMember() 810
PtWidgetIsRealized() 812
PtWidgetOffset() 813
PtWidgetParent() 815
PtWidgetRid() 817
PtWidgetSkip() 818
PtWidgetToBack() 820
PtWidgetToFront() 822
PtWidgetTree() 824
PtWidgetTreeTraverse() 826
PtWidgetVisibleExtent() 830
PtWindowConsoleSwitch() 831
PtWorkProcF t, PtWorkProc t 832
10 Px — Extended 833
PxConfigClose() 836
PxConfigDeleteEntry() 837
PxConfigDeleteSection() 838
PxConfigForceEmptySection() 840
PxConfigNextSection() 842
PxConfigNextString() 844
PxConfigOpen() 846
PxConfigReadBool() 849
PxConfigReadChar() 851
PxConfigReadInt() 853
PxConfigReadLong() 855
PxConfigReadShort() 857
PxConfigReadString() 859
PxConfigSection() 861
PxConfigWriteBool() 862
PxConfigWriteChar() 864
PxConfigWriteInt() 866
PxConfigWriteLong() 868
PxConfigWriteShort() 870
PxConfigWriteString() 872
PxCRC() 874
PxHelpQuit() 875
PxHelpSearch() 876
PxHelpTopic() 879
PxHelpTopicRoot() 881
PxHelpTopicTree() 882
PxHelpUrl() 884
PxHelpUrlRoot() 886
PxLoadImage() 887
PxTerminalBuildCharsets() 895
PxTerminalLoadCharsets() 897
PxTerminalSaveCharsets() 899
PxTranslateFromUTF() 901
PxTranslateList() 904
PxTranslateSet() 906
PxTranslateStateFromUTF() 909
PxTranslateStateToUTF() 911
PxTranslateToUTF() 913
PxTranslateUnknown() 916
11 wc — Wide-Character 919
wctolower() 922
Glossary 923
Index 945
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.
¯ Summary of Entries
¯ Ap — PhAB
¯ mbstr — Multibyte-Character
¯ Pf — Font Server
¯ Pg — Graphics
¯ Ph — Photon
¯ Pm — Memory
¯ Pp — Printing
¯ Pt — Widget Toolkit
¯ Px — Extended
¯ wc — Wide-Character
¯ Glossary
☞ ¯ For functions that deal with specific widgets, see the Widget
Reference.
¯ For functions that deal with creating widget classes, see Building
Custom Widgets.
Assumptions
We assume the following:
¯ You already know the basics of using Photon. If not, see the
Photon User’s Guide.
In this chapter. . .
Categories 3
Entries arranged by category 7
☞ ¯ For datatypes and functions that deal with specific widgets, see the
Widget Reference.
¯ For functions that deal with creating widget classes, see Building
Custom Widgets.
Categories
The following categories have been used to group the datatypes and
functions:
¯ Background processing
¯ Blitting
¯ Characters, translating
¯ Clipboard operations
¯ Clipping
¯ Configuration files
¯ Coordinates, translating
¯ Cursors/pointers
¯ Data chains
¯ Dragging
¯ Draw contexts
¯ Drawing attributes
- Fill attributes
- Stroke (line) attributes
¯ Events
¯ Font handling
¯ Geometry
¯ Graphical contexts
¯ Input/Output events
¯ Jump Gates
¯ Memory contexts
¯ Modal dialogs
¯ Modules
¯ Multibyte-character strings
¯ Online help
¯ Printing
¯ Processes
¯ Regions
¯ Shared memory
¯ Signals
¯ Strings, translating
¯ System information
¯ Text
¯ Tiles
¯ Wide characters
¯ Widgets:
- Callbacks and hotkey handlers
- Class hierarchy
- Creating and destroying
- Custom widgets
- Damaging
- Databases
- Family hierarchy
- Finding in an area
- Focus
- Geometry
- Library initialization
- Menus
- PtComboBox
- PtFileSel
- PtGenList
- PtGenTree
- PtHtml
- PtList
- PtMessage
- PtMultiText
- PtTerminal
- PtText
- PtTree
- PtTty
- PtWindow
- Realizing and unrealizing
- Resources
- RtTrend
- Updates — forcing and holding off
¯ Window Manager
PtAppRemoveWorkProc()
Remove a WorkProc processing function
PtWorkProcF t, PtWorkProc t
Pointer to a work procedure function
PgDrawImage(), PgDrawImagemx()
Draw an image
PgDrawPhImagemx()
Draw an image that’s contained in a PhImage t
structure
PgDrawTImage(), PgDrawTImagemx()
Draw an image with a transparency mask
PgDrawRepBitmap(), PgDrawRepBitmapmx()
Draw a bitmap several times
PgDrawRepImage(), PgDrawRepImagemx()
Draw an image several times
PhMakeGhostBitmap()
Create a ghost bitmap for an image
PhMakeTransBitmap()
Create a transparency mask for an image
PhReleaseImage()
Release allocated members of an image structure
PxCRC() Calculate a CRC for a block of data
PxLoadImage()
Read or query a graphic file
Blitting
PhBlit() Blit an area within a region
Characters, translating
PxTerminalBuildCharsets()
Create character set tables based on translation tables
PxTerminalLoadCharsets()
Load character-set information from a file
PxTerminalSaveCharsets()
Save character-set information in a file
PxTranslateFromUTF()
Translate characters from Unicode UTF-8
PxTranslateList()
Create a list of all supported character translations
PxTranslateSet()
Install a new character set translation
PxTranslateStateFromUTF()
Translate characters from UTF-8, using an internal state buffer
PxTranslateStateToUTF()
Translate characters to UTF-8, using an internal state buffer
PxTranslateToUTF()
Translate characters to UTF-8
PxTranslateUnknown()
Control how unknown encodings are handled
Clipboard operations
PhClipboardCopy()
Copy data to the clipboard
PhClipboardCopyString()
Copy string-only data to the clipboard
PhClipboardPasteFinish()
Release all memory associated with a paste operation
PhClipboardPasteStart()
Begin a paste operation
PhClipboardPasteString()
Paste string-only data from the clipboard
PhClipboardPasteType()
Search clipboard for an entry by type
PhClipboardPasteTypeN()
Search clipboard for an entry by order
PhClipHeader
Clipboard header structure
Clipping
PgSetClipping()
Limit the extent of drawing
PgSetMultiClip()
Set a list of rectangles to clip drawing
PgSetUserClip()
Restrict subsequent draws
PgSetUserClipAbsolute()
Restrict subsequent draws
PtWidgetVisibleExtent()
Calculate the visible portion of a widget
Configuration files
PxConfigClose()
Close the current configuration file
PxConfigDeleteEntry()
Delete an entry from a configuration file
PxConfigDeleteSection()
Delete a section from a configuration file
PxConfigForceEmptySection()
Create an empty section in a configuration file
PxConfigNextSection()
Seek the beginning of the next section of a configuration file
PxConfigNextString()
Get the next entry in the current section
PxConfigOpen()
Open a configuration file
PxConfigReadBool()
Read a Boolean value from a configuration file
PxConfigReadChar()
Read a character parameter from a configuration file
PxConfigReadInt()
Read an integer parameter from a configuration file
PxConfigReadLong()
Read a long integer parameter from a configuration file
PxConfigReadShort()
Read a short integer parameter from a configuration file
PxConfigReadString()
Read a string parameter from a configuration file
PxConfigSection()
Seek the start of a given section in a configuration file
PxConfigWriteBool()
Write a Boolean parameter in a configuration file
PxConfigWriteChar()
Write a character parameter in a configuration file
PxConfigWriteInt()
Write an integer parameter in a configuration file
PxConfigWriteLong()
Write a long integer parameter in a configuration file
PxConfigWriteShort()
Write a short integer parameter in a configuration file
PxConfigWriteString()
Write a string parameter in a configuration file
Coordinates, translating
PgClearTranslation()
Restore the current translation to the default
PgSetTranslation()
Translate draw commands horizontally and vertically
PtDeTranslateRect()
Detranslate a rectangle (subtract offset)
PtTranslateRect()
Translate a rectangle (add offset)
Cursors/pointers
PhMoveCursorAbs()
Move cursor to absolute position
PhMoveCursorRel()
Move cursor to relative position
PhQueryCursor()
Collect cursor information
Data chains
PtAddData() Add data to the provided data chain
PtFindData() Find the first data block of a given type and subtype
PtFindNextData()
Find the next data block of a given type and subtype
PtRemoveData()
Remove a link from a data chain
PtUnlinkData() Remove the provided data link from the data chain
Dragging
PhInitDrag() Initiate a drag operation
Draw contexts
PhDCGetCurrent()
Get the currently active Draw Context
PhDCSetCurrent()
Set the currently active Draw Context
Drawing attributes
General attributes
PgSetDrawMode()
Set draw mode
PgSetPalette() Set the color palette
PgSetPlaneMask()
Protect video memory from being modified
Fill attributes
PgSetFillColor()
Set exact fill color
PgSetFillDither()
Set specific dither pattern and colors
PgSetFillTransPat()
Set draw transparency
PgSetFillXORColor()
Set a color for XOR drawing
PgSetStrokeDash()
Set dashed lines
PgSetStrokeDither()
Apply a color pattern to outlines
PgSetStrokeFWidth()
Set line thickness
PgSetStrokeJoin()
Set how lines are joined
PgSetStrokeTransPat()
Use a masking pattern to set draw transparency on outlines
PgSetStrokeXORColor()
Use the XOR of a color to draw outlines
PgSetStrokeWidth()
Set line thickness
Text attributes
PgSetFont() Set text font
PgSetTextColor()
Set text color
PgSetTextDither()
Set text dither pattern
PgSetTextTransPat()
Set draw transparency
PgSetTextXORColor()
Set a color for XOR drawing
PgSetUnderline()
Set colors for underlining text
Events
PhEvent t Data structure describing an event
PhEventEmitmx()
Emit an event when the event-specific data isn’t
contiguous in memory
PhEventRegion t
Emitter and collector of an event
PhWindowEvent t
Data structure describing a window action
PtAddEventHandler()
Add a single Pt CB RAW entry to a widget
PtAddEventHandlers()
Add several Pt CB RAW entries to a widget
PtBkgdHandlerProcess()
Process all outstanding Photon events
PtEventHandler()
Determine the widgets involved in an event
PtForwardWindowEvent()
Forward a window event
PtRemoveEventHandler()
Remove a single Pt CB RAW entry from a widget
PtRemoveEventHandlers()
Remove several Pt CB RAW entries from a widget
PtResizeEventMsg()
Resize the event buffer
PtSendEventToWidget()
Give an event to a widget
Font handling
PfAttach() Attach to a font server
PfExtentComponents()
Calculate the extent of a text string and invoke a
callback
PfFractionalExtentText()
Calculate the extent rectangle of a text string,
using fractional scaling
PfFractionalRenderText()
Render a string, using fractional scaling, via a
callback function
PfUnloadMetrics()
Unload metric information for the given font
PtFontSelection()
Create a font-selection dialog
Geometry
PhArea t Position and dimensions of a rectangular area
Graphical contexts
PgClearDrawBuffer()
Reset the current draw buffer
PgCreateGC() Allocate a graphics context
PgDefaultFill() Reset fill attribute to its default value
PgDefaultGC() Reset all graphics context attributes to their default
system values
PgDefaultMode()
Reset draw mode and plane mask to their default
values
PgDefaultStroke()
Reset stroke attribute to its system default
PgDefaultText() Reset text attribute to its system default
PgDestroyGC() Release resources of a graphics context
PgFlush(), PgFFlush()
Explicitly flush the current draw buffer
PgGetGC() Get current graphics context
PgSetDrawBufferSize()
Resize a draw buffer
PgSetGC() Set current graphics context
PgSetRegion() Determine which region will emit draw events
Input/Output events
PtAppAddFd() Add a file-descriptor function
PtAppAddFdPri()
Add a file-descriptor function, specifying a
priority
PtAppRemoveFd()
Remove a file-descriptor function
PtAppSetFdMode()
Change the mode that’s of interest to an FD
handler
PtFdProcF t, PtFdProc t
Pointer to a file-descriptor function
PtChannelCreate()
Make sure the widget library is using a channel
PtGetRcvidPid()
Get the process ID (PID) from the receive ID (RCVID)
PtInputCallbackProcF t, PtInputCallbackProc t
Pointer to a input callback function
PtPulseArmFd()
Create a pulse message to be sent to another process
PtPulseArmPid()
Create a pulse message to be sent to another process
PtPulseDeliver()
Send a pulse to another process
PtPulseDisarm()
Release resources allocated for a pulse message
Jump Gates
PtReattach() Send an application through the jump gate
Memory contexts
PmMemCreateMC()
Create a memory context
PmMemReleaseMC()
Release a memory context
PmMemSetChunkSize()
Set the increment for growing a memory context’s
draw buffer
PmMemSetMaxBufSize()
Set the maximum size of a memory context’s draw
buffer
PmMemSetType()
Set the type of a memory context
PtAskQuestion()
Display a question and request a response from the user
PtMessageBox()
Pop up a message box
Modal dialogs
PtModalEnd() Terminate modal-window processing
PtProcessEvent()
Standard Photon event-handling function
Modules
These functions can be used only by applications made with the
Photon Application Builder.
ApCreateModule()
Create an instance of modules built with PhAB
ApGetInstance()
Get the module link instance pointer for a widget
ApGetWidgetPtr()
Get the instance pointer for a widget in a given
module
ApModuleFunction()
Specify the setup function for a PhAB internal link
callback
ApModuleLocation()
Specify the module location for a PhAB internal link
ApModuleParent()
Specify the parent for a window module
Multibyte-character strings
mbstrblen() Find the number of multibyte characters in part of a
string
Online help
PtWidgetHelpHit()
Find the first widget at a given position that has a
help topic
ApInstanceName()
Return the widget’s instance name string
PgDrawBevelBox(), PgDrawIBevelBox()
Draw a beveled box
PgDrawBeveled()
Draw a beveled rectangle or arrow
PgDrawBezier(), PgDrawBeziermx()
Draw a stroked and/or filled Bézier curve
PgDrawBitmap(), PgDrawBitmapmx()
Draw a bitmap
PgDrawEllipse()
Draw an ellipse
PgDrawImage(), PgDrawImagemx()
Draw an image
PgDrawLine(), PgDrawILine()
Draw a single line
PgDrawPixel(), PgDrawIPixel()
Draw a single point
PgDrawPixelArray(), PgDrawPixelArraymx()
Draw multiple points
PgDrawPolygon(), PgDrawPolygonmx()
Draw a stroked and/or filled polygon
PgDrawRect(), PgDrawIRect()
Draw a rectangle
PgDrawRepBitmap(), PgDrawRepBitmapmx()
Draw a bitmap several times
PgDrawRepImage(), PgDrawRepImagemx()
Draw an image several times
PgDrawRoundRect()
Draw a rounded rectangle
PgDrawSpan(), PgDrawSpanmx()
Draw a list of spans
PgDrawString(), PgDrawStringmx()
Draw a string of characters
PgDrawText(), PgDrawTextmx()
Draw text
PgDrawTextArea()
Draw text within an area
PgDrawTextChars()
Draw the specified number of text characters
PgDrawTrend(), PgDrawTrendmx()
Draw a trend graph
Printing
PpLoadPrinter() Initialize a print context with information for a
given printer
PpPrintCreatePC()
Create a print context
PpPrintNewPage()
Place a page break in the draw stream for a print
context
PpPrintReleasePC()
Release a print context
PtPrintSelection()
Create a print-selection dialog
Processes
PtSpawn() Spawn a new process
PtSpawnDeleteCallback()
Remove a child-termination callback
PtSpawnSetCallback()
Change the callback in a PtSpawn() control structure
PtSpawnWait()
Spawn a process and wait for its termination
Regions
PhQueryRids() Get a list of regions
PhRegion t A region
PhRegionChange()
Change the definition of a region
PhRegionClose()
Remove a region
PhRegionDataFindType()
Find a data type within a region’s data
PhRegionDataHdr t
Data that’s attached to a region
PhRegionQuery()
Retrieve information about a region
PtQuerySystemInfo()
Query the system for information
Shared memory
PgShmemAttach()
Record a shared memory reference
PgShmemCleanup()
Remove shared memory references
PgShmemCreate()
Create a block of shared memory
PgShmemDestroy()
Remove a block of shared memory
PgShmemDetach()
Remove a shared memory reference
Signals
PtAppAddSignalProc()
Add Photon signalling to a context
PtAppRemoveSignal()
Remove specific signal handling from a context
PtAppRemoveSignalProc()
Remove Photon signalling from a context
PtSignalProcF t, PtSignalProc t
Pointer to a signal-handling function
Strings, translating
ApAppendTranslation()
Append external translation files to an application’s translation
list
ApGetTextRes()
Get a translated text string from a widget database
ApSetTranslation()
Change the current translation to another language
System information
PhGetConnectId()
Get the connection ID of the calling process
PhGetConnectInfo()
Get information about a Photon channel
PhQueryCursor()
Collect cursor information
PhQuerySystemInfo()
Query the system for information about a given region
PtQuerySystemInfo()
Query the system for information about a given widget
Text
PgExtentText()
Calculate the extent of a string of text
Tiles
PhAddMergeTiles()
Merge two list tiles, eliminating overlap
PhCoalesceTiles()
Combine a list of tiles
PhDeTranslateTiles()
Subtract x and y offsets from the vertices of a list
of tiles
PhIntersectTilings()
Determine the intersection of two lists of tiles
PhTranslateTiles()
Add x and y offsets to the vertices of a list of tiles
Wide characters
wctolower() Return the lowercase equivalent of a wide character
Widgets
Callbacks and hotkey handlers
PtAddCallback()
Add a single callback entry to a callback list
PtAddCallbacks()
Add several callback entries to a callback list
PtAddEventHandler()
Add a single Pt CB RAW entry to a widget
PtAddEventHandlers()
Add several Pt CB RAW entries to a widget
PtAddHotkeyHandler()
Add a single hotkey handler entry to a widget
PtBalloonCallback t
Balloon callback structure — see the Photon Widget Reference
PtCallback t
Regular callback structure — see the Photon Widget Reference
PtCallbackInfo t
Specific callback information — see the Photon Widget
Reference
PtHotkeyCallback t
Hotkey handler structure — see the Photon Widget Reference
PtRawCallback t
Event handler structure — see the Photon Widget Reference
PtRemoveCallback()
Remove a single callback entry from a callback list
PtRemoveCallbacks()
Remove several callback entries from a callback list
PtRemoveEventHandler()
Remove a single Pt CB RAW entry from a widget
PtRemoveEventHandlers()
Remove several Pt CB RAW entries from a widget
PtRemoveHotkeyHandler()
Remove a single hotkey handler entry from a widget
Class hierarchy
PtWidgetClass()
Return the class of a widget
PtWidgetIsClass()
Determine whether a widget is a specific class type
PtWidgetIsClassMember()
Determine whether a widget belongs to a specified class
PtClearWidget()
Destroy all widgets within a container
PtCreateWidget()
Create a widget
PtDestroyWidget()
Remove a widget from the widget hierarchy
PtInflateBalloon()
Create a balloon widget
Custom widgets
These functions are described in the Building Custom Widgets.
PtAddWidgetData()
Add data to the widget data chain
PtAnchorWidget()
Anchor the provided widget
PtApplyAnchors()
Anchor a widget and its children
PtAttemptResize()
Adjust the size of a widget
PtCalcAnchorOffsets()
Update the anchoring values (rules) for the given
widget
PtChildBoundingBox()
Calculate a widget’s canvas and its children’s
bounding boxes
PtCompoundRedirect()
Redirect widgets to a parent
PtContainerChildRedirect()
Set the pointer to the child-redirector function
PtContainerDeregister()
Deregister a container from its parent
PtContainerRegister()
Register a container with its parent
PtCoreChangeRegion()
Determine if a region is required
PtCreateWidgetClass()
Create a widget class
PtDamageExposed()
Damage the specified widgets
PtDestroyCallbackList()
Free the specified callbacks
PtDestroyHotkeyCallbacks()
Free the specified hotkey callbacks
PtDestroyRawCallbacks()
Free the specified raw callbacks
PtFindNextWidgetData()
Find the next appropriate data block
PtFindResourceRecord()
Find the record associated with a resource
PtFindWidgetData()
Find the first data block of a given type and subtype
PtGetAnchoredExtent()
Calculate a new anchor rectangle
PtInvokeCallbackList()
Invoke a callback list
PtInvokeResizeCallbacks()
Invoke the resize callbacks of the specified
container
PtMoveResizeWidget()
Synchronize a widget’s extent
PtRemoveWidgetData()
Remove data from the widget data chain
PtResizePolicy()
Determine whether a widget has a resize policy
PtSetExtentFromArea()
Calculate the extent of a widget
PtSetStruct() Set the specified resource
PtSetValue() Set the value of a resource using mod f
PtSuperClassCalcOpaque()
Call the Calc Opaque Rect method of the specified
superclass
PtSuperClassChildCreated()
Invoke a Child Created method
PtSuperClassChildDestroyed()
Invoke a Child Destroyed method
PtSuperClassChildGettingFocus()
Invoke a Child Getting Focus method
PtSuperClassChildGettingResources()
Invoke a Child Getting Resources method
PtSuperClassChildLosingFocus()
Invoke a Child Losing Focus method
PtSuperClassChildMovedResized()
Invoke a Child Moved/Resized method
PtSuperClassChildRealized()
Invoke a Child Realized method
PtSuperClassChildSettingResources()
Invoke a Child Setting Resources method
PtSuperClassChildUnrealized()
Invoke a Child Unrealized method
PtSuperClassConnect(), PtSuperClassConnectFrom()
Invoke the Connection method of the specified
widget class
PtSuperClassDraw()
Invoke the Draw method of the specified superclass
PtSuperClassExtent()
Invoke the Extent method of the specified
superclass
PtSuperClassGetResources()
Get the specified resource
PtSuperClassGotFocus()
Invoke the Got Focus method of the specified
superclass
PtSuperClassInit(), PtSuperClassInitFrom()
Invoke the Initialize method of the specified widget
class
PtSuperClassLostFocus()
Invoke the Lost Focus method of the specified
superclass
PtSuperClassRawEvent(), PtSuperClassRawEventFrom()
Invoke the raw callback list of the specified widget
class
PtSuperClassRealized()
Invoke the Realization method of the specified
widget class
PtSuperClassSetResources()
Set resources
PtUpdateVisibility()
Tell the widget library about a change in visibility
PtWidgetAbove()
Identify the position of a widget in the hierarchy
relative to another widget
Damaging widgets
PtDamageExtent()
Mark an area of a widget as damaged so that it will
be redrawn
PtDamageWidget()
Mark a widget as damaged so it will be redrawn
Databases
These functions can be used only by applications made with the
Photon Application Builder.
ApCreateWidget()
Create a widget by copying it from a PhAB widget
database
ApCreateWidgetFamily()
Create a widget by copying it from a PhAB widget
database
ApDeleteWidget()
Remove widgets from a widget database
ApFreeBitmapRes()
Free a bitmap resource structure
ApGetBitmapRes()
Extract bitmap data from a widget in a widget
database
ApGetImageRes()
Extract the image data from a widget in a widget
database
ApGetTextRes() Get a translated text string from a widget database
ApOpenDBase() Open a picture module as a widget database
ApOpenDBaseFile()
Open a picture module as a widget database
ApSaveDBaseFile()
Save a widget database as an external file
Family hierarchy
PtChildType() Determine the relationship between two widgets
PtCreateWidget()
Create a widget
PtFindChildClass()
Find the first child that matches the specified class
PtFindChildClassMember()
Find the first child that’s a subclass of the specified
class
PtFindContainer()
Return the nearest container parent
PtFindFocusChild()
Find the closest focusable child widget
PtFindGuardian()
Find the widget responsible for another widget’s
actions
PtGetParent() Find the nearest widget with the same parent class
PtGetParentWidget()
Return the current default widget parent
PtNextTopLevelWidget()
Get a pointer to the next top-level widget
PtReParentWidget()
“Reparent” a widget to a new container
PtSetParentWidget()
Set the current parent widget
PtWidgetBrotherBehind()
Get the brother behind a widget
PtWidgetBrotherInFront()
Get the brother in front of a widget
PtWidgetChildBack()
Get the child that’s farthest back in a container
PtWidgetChildFront()
Get the child at the very front of a container
PtWidgetFamily()
Traverse the widget hierarchy
PtWidgetParent()
Get a widget’s parent
PtWidgetToBack()
Move a widget behind all its brothers
PtWidgetToFront()
Move a widget in front of all its brothers
PtWidgetTreeTraverse()
Walk the widget family hierarchy from front to
back
PtContainerHit()
Find the nth widget in an area
Focus
PtContainerFindFocus()
Find the widget that currently has focus
PtContainerFocusNext()
Give focus to the next Pt GETS FOCUS widget
within the same container
PtContainerFocusPrev()
Give focus to the previous Pt GETS FOCUS widget
within the same container
PtContainerGiveFocus()
Give focus to a widget
PtContainerNullFocus()
Truncate the focus chain at the specified widget
PtFindFocusChild()
Find the closest focusable child widget
PtGlobalFocusNext()
Give focus to next widget
PtGlobalFocusNextContainer()
Give focus to another container’s widget
PtGlobalFocusNextFrom()
Give focus to the next widget behind the specified
widget
PtGlobalFocusPrev()
Give focus to previous widget
PtGlobalFocusPrevContainer()
Give focus to widget in previous container
PtGlobalFocusPrevFrom()
Give focus to widget previous to the specified
widget
Geometry
PtBasicWidgetCanvas()
Determine the PtBasic canvas for a widget
PtCalcAbsPosition()
Calculate the position of a widget based on a position and
another widget
PtExtentWidget()
Force a widget to calculate its extent
PtExtentWidgetFamily()
Force a widget and its children to calculate their extents
PtGetAbsPosition()
Get the absolute position of a widget
PtLabelWidgetCanvas()
Determine the PtLabel canvas for a widget
PtSetAreaFromExtent()
Set the extent of a widget
PtSetAreaFromWidgetCanvas()
Set the canvas of a widget
PtWidgetArea()
Retrieve a copy of a widget’s area
PtWidgetCanvas()
Determine the PtWidget canvas for a widget
PtWidgetDim()
Retrieve a copy of a widget’s dimension
PtWidgetExtent()
Get a widget’s extent
PtWidgetOffset()
Find the offset of a widget’s origin from its disjoint parent
PtWidgetVisibleExtent()
Calculate the visible portion of a widget
Library initialization
PtAppInit() Initialize an application and create the main window
PtInit() Initialize the widget library
Menus
These functions can be used only with menu modules created in
PhAB:
ApGetItemText()
Get the text for a menu item
ApModifyItemState()
Modify the state of menu items
ApModifyItemText()
Modify the text for a menu item
PtPositionMenu()
Set a menu’s position
PtComboBox
These functions are described in the Photon Widget Reference.
PtComboBoxListOpen()
Open a combobox list
PtComboBoxListClose()
Close an open combobox list
PtFileSel
These functions are described in the Photon Widget Reference.
PtFSAddAfter()
Insert an item after the specified item
PtFSAddFirst()
Add a root item to the widget
PtFSAllocItem()
Create an item for a file-selector widget
PtFSClearSelection()
Clear the selection
PtFSDamageItem()
Redraw an item
PtFSExpandParents()
If any ancestors of the given item are collapsed, this
function tries to expand them.
PtFSFolderCollapse()
Collapse an expandable item (directory)
PtFSFolderExpand()
Expand an expandable item (directory)
PtFSFreeAllItems()
Unlink and free all items
PtFSFreeItems()
Free an unlinked item
PtFSGetCurrent()
Get the current item
PtFSGetSelIndexes()
Fill a buffer with indexes
PtFSItemIndex()
Calculate the index of the specified item
PtFSRemoveChildren()
Unlink all the children of a given item
PtFSRemoveItem()
Unlink an item
PtFSRemoveList()
Unlink the root item
PtFSRootItem()
Return the first root item of the file selector
PtFSSelectedItems()
Fill a buffer with item pointers
PtFSSetSelIndexes()
Set the selection indexes
PtFSUnselect()
Unselect the specified item
PtFSUnselectNonBrothers()
Unselect all items that aren’t siblings of the specified
item
PtGenList
These functions are described in the Photon Widget Reference.
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
PtGenListAddItems()
Add items to a list
PtGenListAllItems()
Get pointers to all the items in a list
PtGenListClearSelection()
Clear the selection
PtGenListDamageItem()
Redraw an item when its data has been changed
PtGenListDrawBackground()
Draw the background of a list
PtGenListDrawString()
Draw a string
PtGenListFirstItem()
Return a pointer to the first item in a list
PtGenListGetCurrent()
Return a pointer to the current item in a list
PtGenListGetSelIndexes()
Get the indexes of the selected items
PtGenListGoto()
Set the current item so that the new current item is visible
PtGenListHold()
Prevent visible repair of a list widget
PtGenListItemIndex()
Find the index of an item
PtGenListItemRealloc()
Reallocate memory for an item
PtGenListLastItem()
Return a pointer to the last item in a list
PtGenListLockItem()
Lock an item so it can be resized
PtGenListRelease()
Release a hold on visible repairs of a list widget
PtGenListRemoveItems()
Remove items from a list
PtGenListResize()
Resize a list widget
PtGenListSelect()
Select an item in a list
PtGenListSelectedItems()
Get pointers to the selected items
PtGenListSetGflags()
Modify the gflags field of the widget
PtGenListSetSelIndexes()
Set the selection indexes
PtGenListShow()
Set the current position so a given item is visible
PtGenListUnlockItem()
Unlock an item so it can be updated
PtGenListUnselect()
Unselect an item in a list
PtSuperClassGenListDraw()
Invoke the Draw List method in a superclass
PtSuperClassGenListInflate()
Invoke the List Inflate method in a superclass
PtSuperClassGenListKey()
Invoke the List Key method in a superclass
PtSuperClassGenListMouse()
Invoke the List Mouse method in a superclass
PtSuperClassGenListSelect()
Invoke the List Select method in a superclass
PtGenTree
This data structure is described in the Photon Widget Reference.
PtGenTreeItem t
PtGenTree item structure
PtGenTreeAddAfter()
Add items after a given item
PtGenTreeAddFirst()
Add items in front of any existing items
PtGenTreeAllItems()
Get pointers to all the items in the tree
PtGenTreeClearSelection()
Clear the selection
PtGenTreeCollapse()
Collapse a subtree
PtGenTreeDamageItem()
Redraw an item when its data has changed
PtGenTreeExpand()
Expand a given subtree
PtGenTreeExpandParents()
Expand any collapsed ancestors of a given item
PtGenTreeFreeAllItems()
Free all the items in a tree
PtGenTreeFreeItems()
Free the items in a subtree
PtGenTreeGetCurrent()
Get a pointer to the current item
PtGenTreeGetSelIndexes()
Get the indexes of the selected items
PtGenTreeGoto()
Set the current item and position so that a given item is visible
PtGenTreeItemIndex()
Calculate the index of a given item
PtGenTreeItemRealloc()
Reallocate an item
PtGenTreeItemResize()
Resize an item
PtGenTreeRemoveChildren()
Unlink all the children of a given item
PtGenTreeRemoveItem()
Remove a given item and its children from its parents and
siblings
PtGenTreeRemoveList()
Remove a given items and its siblings from their parent
PtGenTreeResize()
Resize many items
PtGenTreeRootItem()
Get a pointer to the first root item
PtGenTreeSelect()
Select a given item
PtGenTreeSelectedItems()
Get pointers to the selected items
PtGenTreeSetSelIndexes()
Set the selection indexes
PtGenTreeShow()
Set the current position so that a given item is visible
PtGenTreeUnselect()
Unselect a given item
PtGenTreeUnselectNonBrothers()
Unselect all items that aren’t siblings of a given item
PtSuperClassGenTreeDrawItem()
Invoke the Tree Draw Item method of a given superclass
PtSuperClassGenTreeItemState()
Invoke the Tree Item State method of a superclass
PtHtml
These functions are described in the Photon Widget Reference.
PtList
These functions are described in the Photon Widget Reference.
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
PtMessage
This function is described in the Photon Widget Reference.
PtMessageGetWindow()
Get the widget pointer to the message’s window
PtMultiText
These functions are described in the Photon Widget Reference.
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()
Initialize a multitext attribute structure
PtMultiTextGetAttributes()
Get the attributes of a PtMultiText widget
PtMultiTextInfo()
Get 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()
Modify the attributes of a PtMultiText widget
PtMultiTextModifyText()
Modify 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
PtTerminal
These functions are described in the Photon Widget Reference.
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
PtText
These functions are described in the Photon Widget Reference.
PtTextCallback t, PtTextControl t,
PtTextControlInfo t
Information passed to PtText callbacks
PtTextGetSelection()
Get the selected range from a PtText widget
PtTextModifyText()
Modify the contents of a PtText widget
PtTextSetSelection()
Set the selected range for a PtText widget
PtTree
These functions are described in the Photon Widget Reference.
PtTreeAddAfter()
Insert an item after the specified item
PtTreeAddFirst()
Add a root item to the widget, or add an item as the
first child of a specified item
PtTreeAddImages()
Add images to the PtTree’s widgets image list
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
PtTreeGoto() Set the current item
PtTreeItem t PtTree item structure
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
PtTreeSelect() Select the specified item
PtTreeSelectedItems()
Fill a buffer with pointers to the selected items
PtTreeSetSelIndexes()
Set the selection indexes
PtTreeShow() Set the position so that the specified item is visible
PtTreeUnselect()
Unselect the specified item
PtTreeUnselectNonBrothers()
Unselect all items that aren’t siblings of the
specified item
PtTty
This function is described in the Photon Widget Reference.
PtWindow
These functions are described in the Photon Widget Reference.
PtWindowFocus()
Give a window focus
PtWindowGetState()
Return the current state of a window
PtWindowToBack()
Move a window to the back of the workspace
PtWindowToFront()
Bring a window to the front and gives it focus
Resources
PtArg t Which resource is affected when you get or set
resources
PtGetControlFlags()
Get the flags from the Pt control structure
PtGetResources()
Retrieve one or more resource values for a widget
PtSetResources()
Set one or more resources for a widget
PtWidgetClassFlags()
Retrieve a widget’s class structure flags
PtWidgetFlags()
Retrieve a widget’s flags
RtTrend
These functions are described in the Photon Widget Reference.
RtTrendChangeData()
Replace some samples for all trends
RtTrendChangeTrendData()
Replace some samples for one trend
PtContainerRelease()
Decrement the hold count for a widget
PtSyncPhoton()
Synchronize Photon
PtSyncWidget()
Synchronize a widget
Window Manager
PhWindowChange()
Modify the attributes of a window’s region
PhWindowClose()
Close a window
PhWindowQueryVisible()
Query a visible extent
PhWindowOpen()
Create a window region
PtConsoleSwitch()
Switch to another virtual console
PtForwardWindowEvent()
Forward a window event
PtForwardWindowTaskEvent()
Forward a window event to a task
PtWindowConsoleSwitch()
Switch to the console a given window’s displayed
on
This chapter describes the functions and data structures that are
associated with the Photon Application Builder (PhAB).
Synopsis:
#include <Ap.h>
int ApAddClass(
char const * class name string,
PtWidgetClassRef t * const *wgt class);
Description:
This function lets you indicate which widget classes you’re likely to
encounter when you call ApOpenDBaseFile(). The class name string
is the name of the class (for example, "PtButton"). The wgt class is
a predefined widget class; specify the name of the class preceded by
an ampersand (for example, &PtButton).
When you link your application, only those widgets it needs are
linked into it. If you access widgets that aren’t in your application
because they’re in an external database, you must add them to your
internal class table so that they can be linked in at compile time.
Any widgets used when you build a PhAB application are
automatically included in the internal class table (see the generated
abmain.c file). When you use widgets from an external database,
PhAB doesn’t know which widgets you need to access, so you’ll have
to use this function to include them.
Returns:
0 Success
Examples:
base setup ( ... )
{
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApOpenDBaseFile()
Accessing PhAB Modules from Code chapter of the Photon
Programmer’s Guide
Synopsis:
#include <Ap.h>
Description:
This function is used to append external translation files to the
application’s translation list. It takes the translation file identified by
filename, appends the lang extension and looks for the translation file
in the directory defined by the ABLPATH environment variable. If
lang extension is NULL, the current language extension is used.
This is useful when you want to share common text strings among
many different applications. Essentially, you create a standalone
application that contains a single picture module (widget database) of
text strings. Then you use the PhAB Language Editor to translate the
strings in this module. Once the database is created and translated,
you can access it from another application.
Returns:
0 Success
Examples:
Assuming ABLPATH has been set to
/usr/photon/translations:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApOpenDBase(), ApOpenDBaseFile(), ApSetTranslation(),
ApGetTextRes()
Synopsis:
#include <Ap.h>
typedef struct {
short nplanes;
short nbytes;
PgColor t *colors;
char **data;
} ApBitmap t;
Description:
This data structure describes a PhAB bitmap. The members include at
least:
data The bitmap image data. The format of the data is a series
of 1-bit-per-pixel planes.
Classification:
Photon
See also:
ApFreeBitmapRes(), ApGetBitmapRes()
Synopsis:
#include <Ap.h>
Description:
ApCloseDBase() closes a widget database that has been opened with
ApOpenDBase() or ApOpenDBaseFile().
Closing a widget database deallocates its memory. If you’re finished
using a widget database, close it to free up the memory.
Returns:
0 Successful completion
Examples:
ApDBase t *mydbase;
ApCloseDBase( mydbase );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApOpenDBase(), ApOpenDBaseFile()
Accessing PhAB Modules from Code chapter of the Photon
Programmer’s Guide
Synopsis:
#include <Ap.h>
Description:
ApCopyWidget() copies a widget from one PhAB widget database to
another. The from name parameter indicates which widget to copy
from the database, and to name lets you rename the copy. Only one
widget can be copied at a time. If you copy a container-class widget,
only the container widget is copied, not its children.
Returns:
0 Success.
-1 Failure.
Examples:
ApDBase t *from dbase, *to dbase;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApOpenDBase(), ApOpenDBaseFile(), ApSaveDBaseFile()
Synopsis:
#include <Ap.h>
int ApCreateModule(
ApEventLink t const *link callback,
PtWidget t *widget,
PtCallbackInfo t *cbinfo );
Description:
ApCreateModule() is used to manually create instances of modules
built with PhAB. It’s used differently when creating a picture module;
see “Usage with picture modules,” below.
Returns:
¯ If there are no setup functions associated with the internal link:
Pt CONTINUE
Success.
-1 An error occurred.
¯ If there are any setup functions associated with the internal link,
ApCreateModule() returns the value returned by the last one called:
Pt CONTINUE
Normal return value.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApModuleLocation(), ApModuleFunction(), ApModuleParent()
“Module setup functions” in the Working with Code chapter, and
“Picture modules” in the Working with Modules chapter of the
Programmer’s Guide.
Synopsis:
#Include <Ap.h>
Description:
This function is used to create widgets by copying a widget from a
PhAB widget database. This is very useful when you need to create
many instances of the same widget. For example, a file manager may
want to draw a file folder for each directory it displays.
The widget is created as a child of the default parent, which is usually
the most recently created container. To change the default parent, call
PtSetParentWidget().
wgt name the instance name of one of the widgets inside the
database
Returns:
A pointer to the widget created for wgt name, or NULL on failure.
Examples:
ApDBase t *mydbase;
PtArg t args[2];
ApCloseDBase( mydbase );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApCloseDBase(), ApCreateWidgetFamily(), ApOpenDBase(),
ApOpenDBaseFile(), ApSaveDBaseFile(), PtCreateWidget(),
PtSetParentWidget()
Accessing PhAB Modules from Code chapter of the Photon
Programmer’s Guide
Synopsis:
#Include <Ap.h>
PtWidget t *ApCreateWidgetFamily(
ApDBase t const *db,
char const *wgt name,
int x,
int y,
int nargs,
PtArg t const *args );
Description:
This function is used to create widgets by copying a widget family
from a PhAB widget database. This is very useful when you need to
create many instances of the same widget. For example, a file
manager may want to draw a file folder for each directory it displays.
The root of the widget family is created as a child of the default
parent, which is usually the most recently created container. To
change the default parent, call PtSetParentWidget().
wgt name the instance name of one of the widgets inside the
database
Returns:
A pointer to the widget created for wgt name, or NULL on failure.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApCloseDBase(), ApCreateWidget(), ApOpenDBase(),
ApOpenDBaseFile(), ApSaveDBaseFile(), PtCreateWidget(),
PtSetParentWidget()
Synopsis:
#include <Ap.h>
Description:
ApDeleteDBWidget() removes the widget named wgt name from the
widget database indicated by db. Only a single widget is deleted with
this function; if a container widget is deleted, its child widgets remain
in the database.
Returns:
0 Successful completion
-1 Failure
Examples:
ApDBase t *my dbase;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApCopyWidget(), ApOpenDBase(), ApOpenDBaseFile(),
ApSaveDBaseFile()
Accessing PhAB Modules from Code chapter of the Photon
Programmer’s Guide
Synopsis:
#include <Ap.h>
Description:
ApError() displays an error message dialog on the screen. This is a
modeless dialog that doesn’t wait for a user response. It displays a
formatted error message and a single OK button for acknowledgment.
The arguments are:
error message
The error text to be displayed.
¯ app prefix
¯ error message
¯ location, if specified
Examples:
If you call ApError() as follows, specifying the location,
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAskQuestion()
PtMessage in the Widget Reference
Synopsis:
void ApFreeBitmapRes (ApBitmap t *bitmap);
Description:
This function frees a bitmap resource structure returned by
ApGetBitmapRes(). It doesn’t free the bitmap planes or colors
because they point back into the widget database.
Examples:
ApBitmap t *bitmap;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApBitmap t, ApGetBitmapRes()
Accessing PhAB Modules from Code chapter of the Photon
Programmer’s Guide
Synopsis:
#include <Ap.h>
ApBitmap t *ApGetBitmapRes(
ApDBase t const *dbase,
char const *wgt name );
Description:
This function lets you extract bitmap images from a PtBitmap
widget in a PhAB widget database.
The dbase argument points to a widget database opened with either
ApOpenDBase() or ApOpenDBaseFile(). The wgt name argument is
the instance name of one of the widgets inside the database.
This function doesn’t give you the height and width of the extracted
image. You must use the extracted bitmap data in another PtBitmap
widget that has the exact same dimensions.
This function is mainly used to perform simple animation. You can
create a series of tiles, using PtBitmap widgets of the same
dimensions, in a PhAB widget database; to create the animation,
cycle through the tiles by pulling out the bitmaps in sequence,
updating another PtBitmap widget that is visible within the
application window.
Depending on the size of the bitmaps being used and the background
colors, the animation will be relatively free of flicker. To get the best
look and performance out of your animations, we recommend that
you use PtLabel widgets and images rather than PtBitmap widgets,
especially if the bitmaps are fairly large (that is, greater than 64
pixels); see ApGetImageRes().
Returns:
A pointer to the bitmap data structure (see ApBitmap t), or NULL if
the widget or data couldn’t be found.
Examples:
This example replaces the image stored in a bitmap widget. For this
example to work, the old and new bitmaps must have the same
dimensions, number of colors/planes, and order of colors.
ApBitmap t *bitmap;
PtArg t args[1];
if ( bitmap ) {
PtSetArg( &args[0], Pt ARG BITMAP DATA,
bitmap->data, 0 );
PtSetResources( ABW bitmap wgt, 1, args );
}
ApCloseDBase( mydbase );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApBitmap t, ApFreeBitmapRes(), ApGetImageRes(),
ApOpenDBase(), ApOpenDBaseFile(), ApCloseDBase()
Accessing PhAB Modules from Code chapter of the Photon
Programmer’s Guide
Synopsis:
#include <Ap.h>
PhImage t *ApGetImageRes(
ApDBase t const *dbase,
char const *wgt name );
Description:
ApGetImageRes() lets you extract images from a widget in a PhAB
widget database.
The dbase argument is the widget database pointer returned from
ApOpenDBase(). The wgt name argument is the name of widget
within the database that has the image you’re trying to extract.
This function is mainly used to perform simple animation. You can
create a series of tiles, using any widget that supports images, in a
PhAB widget database; to create the animation, cycle through the tiles
by pulling out the images in sequence, updating another widget that is
visible within the application window.
Returns:
A pointer to a PhImage t structure, or NULL if the widget or image
data couldn’t be found.
☞ This function returns a pointer into the widget database; don’t close
the database while still using the image. If you must close the widget
database, do the following first:
Examples:
PhImage t *image;
PtArg t args[1];
if ( image ) {
PtSetArg( &args[0], Pt ARG LABEL DATA,
image, sizeof( *image ) );
PtSetResources( ABW label wgt, 1, args );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetBitmapRes(), ApOpenDBase(), ApOpenDBaseFile(),
PgDrawPhImagemx(), PhImage t, PhReleaseImage(),
PhMakeGhostBitmap(), PhMakeTransBitmap(), PxLoadImage()
“Animation” in the Raw Drawing and Animation chapter, and the
Accessing PhAB Modules from Code chapter of the Photon
Programmer’s Guide
Synopsis:
#include <Ap.h>
Description:
ApGetInstance() is used to obtain the widget’s module link instance
pointer. For most modules, PhAB generates manifests that let you
access the widgets within that module directly, provided only one
instance of the module exists at a time.
Because window modules allow you to have multiple instances, you
can’t always use the direct access manifests; the manifest will only be
valid for the last instance of the window. For windows, you may need
either to save the module link instance pointer when creating the
window, or to use this function within the callback to determine the
origin of the callback.
Returns:
The module link instance pointer for the widget, or NULL if it cannot
be determined.
Examples:
PtArg t args[1];
return( Pt CONTINUE );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetWidgetPtr()
Synopsis:
#include <Ap.h>
Description:
ApGetItemText() is used to extract the text of a menu item in a PhAB
menu module. The menu argument is a pointer to a PhAB menu link
structure. The item name argument is the ABN name of the menu
item, as generated by PhAB. If a language translation is in effect, the
translated string is returned rather than the default text built into the
application.
Returns:
A pointer to a text string or translated text, or NULL if the ABN name
is invalid.
!
CAUTION: Don’t free the returned text string, or your application
will crash.
Examples:
text = ApGetItemText( &mymenu, ABN item1 );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApModifyItemText()
Synopsis:
#include <Ap.h>
Description:
ApGetTextRes() extracts the translated text string from the database
identified by db using name as the widget instance name identifier.
Returns:
The translated text string if successful, NULL if not found, or name or
db if invalid.
Examples:
ApDBase t *mydbase;
char *string;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetBitmapRes(), ApGetImageRes(), ApOpenDBase(),
ApOpenDBaseFile()
Accessing PhAB Modules from Code chapter of the Photon
Programmer’s Guide
Synopsis:
#include <Ap.h>
Description:
ApGetWidgetPtr() is used to obtain the widget’s instance pointer
within the specified link instance. For most modules, PhAB generates
manifests that let you access the widgets within the module directly,
provided only one instance of the module exists at a time.
Because window modules allow you to have multiple instances you
can’t always use the direct access manifests; the manifest will only be
valid for the last instance of the window. For windows, you may need
either to save the link instance pointer when creating the window, or
to use this function to find the correct link instance for the callback.
Once you determine the module link instance, you’ll need to extract
the widget pointer from it.
The wgt name argument is the ABN name value of the widget. PhAB
automatically generates these name values for you when you generate
your code.
Returns:
A pointer to the the widget within the module link instance, or NULL
if one was not found.
Examples:
PtArg t args[1];
return( Pt CONTINUE );
}
☞ If you compare this example with the one for ApGetInstance(), you’ll
notice a subtle difference. This example modifies a specific widget
identified by ABN mywidget, while the other example modifies any
widget affected by the callback.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetInstance()
Synopsis:
#include <Ap.h>
typedef struct {
short reason;
PtWidget t *widget;
} ApInfo t;
Description:
This structure is used as the second argument to most functions
generated by PhAB, including code callbacks and module-setup
functions.
The possible values for reason are:
Value Description
ABR PRE REALIZE Pre-realize setup function
ABR POST REALIZE Post-realize setup function
ABR CODE Code-type callback
ABR DONE Done-type callback
ABR CANCEL Cancel-type callback
Classification:
Photon
See also:
ApWidget()
PtCallback t in the Photon Widget Reference
“Module setup functions” and “Code-callback functions” in the
Working with Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Description:
ApInstanceName() returns a widget’s instance string name if it’s
defined. The string name is the name given to the widget in the
Widget Instance Name field of the Control Panel. By default, string
names are not saved with the widget, in order to save memory.
To embed string names in the widget, you must enable this feature:
Returns:
The widget’s instance name string, or NULL if the widget doesn’t
have string name data attached.
Examples:
my callback( PtWidget t *widget, ... )
{
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
#include <Ap.h>
Description:
ApModifyItemState() modifies the state of menu items in a PhAB
menu module. The arguments are:
state The state you want to set for the menu items:
¯ AB ITEM DIM - disabled
¯ AB ITEM NORMAL - enabled and not set
¯ AB ITEM SET - set on (toggle item)
You can call ApModifyItemState() at any time to set the menu item
states and the effect will be seen when the menu is displayed. This
lets you set menu item states as soon as conditions within your
application change.
Returns:
1 Successful completion
Examples:
In this example, mymenu is a pointer to the address of the menu name,
which is equivalent to the instance name for the menu module.
/* Dim the ABN opt1, ABN opt2, and ABN opt3 menu items. */
ApModifyItemState( &mymenu, AB ITEM DIM, ABN opt1, ABN opt2,
ABN opt3, NULL );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetItemText(), ApModifyItemText()
“Enabling, disabling, or toggling menu items” in the Working with
Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Description:
ApModifyItemText() modifies the text for a menu item in a PhAB
menu module. The arguments are:
You can call ApModifyItemText() at any time to set the menu item text
and the effect will be seen when the menu is displayed. This allows to
you set menu item text as soon as conditions within your application
change.
Returns:
0 The item number isn’t valid.
1 Success.
Examples:
In this example, mymenu is a pointer to the address of the menu name,
which is equivalent to the instance name for the menu module.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetItemText(), ApModifyItemState()
“Changing menu-item text” in the Working with Code chapter of the
Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Description:
ApModuleFunction() is used to specify the setup function for a PhAB
internal link callback. The realize flags argument indicates when the
setup function should be called:
¯ AB FUNC BOTH
When you create an internal link callback, PhAB lets you specify the
setup function. ApModuleFunction() lets you change that setup
function. The new function is retained until changed again.
Examples:
ApModuleFunction( ABM mydialog, setup module, AB FUNC BOTH );
ApCreateModule( ABM mydialog, NULL, NULL );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApCreateModule()
Synopsis:
#Include <Ap.h>
Description:
ApModuleLocation() is used to specify the module location for a
PhAB internal link. The loc type is one of the following:
¯ AB LOC CENTER
The x offset and y offset pixel values are applied to the location
determined from the loc type. For example, if you want a dialog to
appear 100 pixels from the top right edge of the screen, set the x offset
to -100 and the loc type to AB LOC TOP RIGHT.
When you create an internal link in PhAB, you can set the location.
This function lets you change that value if required. The new location
will remain in effect until changed again.
Examples:
/* place the module in the center of the screen */
ApModuleLocation( ABM mydialog, AB LOC CENTER, 0, 0 );
ApCreateModule( ABM mydialog, NULL, NULL );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
#Include <Ap.h>
Description:
ApModuleParent() lets you specify the parent module for a Window
module. The parent is one of the following:
AB NO PARENT
The window module should have no parent. The
widget argument is ignored.
Examples:
Change my window to have no parent at all:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
#include <Ap.h>
Description:
ApName() returns a PhAB name value for the specified widget. This
name value can be compared with the global name values PhAB
generates for your application code. These name values make it easier
to access and compare widgets in callback functions. It also lets you
use the same callback function for more than one widget.
Returns:
A PhAB name value, or -1 if the widget doesn’t have a name.
Examples:
my callback( PtWidget t *widget, ... )
{
if ( ApName( widget ) == ABN widget1 ) {
/* do widget1 processing */
} else {
if ( ApName( widget ) == ABN widget2 ) {
/* do widget2 processing */
} else {
/* do something else? */
}
}
}
☞ ABN widget1 and ABN widget2 are name values generated by PhAB
for widgets in your application with instance names of widget1 and
widget2.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
ApDBase t *ApOpenDBase(
ApEventLink t const *link callback );
Description:
These functions open a module as a widget database:
Returns:
A pointer to a PhAB picture database structure, or NULL for failure.
Examples:
ApDBase t *mydbase;
PtArg t args[2];
ApCloseDBase( mydbase );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApAddClass(), ApCreateWidget(), ApCreateWidgetFamily()
Accessing PhAB Modules from Code chapter of the Photon
Programmer’s Guide
Synopsis:
void ApResClose ( void );
Description:
All PhAB applications have module resource records bound into the
executable. A PhAB application opens its own binary file to access
these records, and keeps the file open for better performance until the
application loses focus. Once the file is closed, it isn’t reopened
unless a module record is required.
If your application has only a single base window or dialogs that are
infrequently used, you can force the binary file to be closed by calling
this function. This reduces the number of file descriptors in use, as
well as freeing resources used for accessing other nodes in a
networking environment.
Examples:
In the post-realize callback of the base window:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
#include <Ap.h>
Description:
ApSaveDBaseFile() saves a widget database as an external file. Both
internally bound widget databases and previously loaded external
widget databases can be saved as external files.
Returns:
0 Successful completion
-1 Failure
Examples:
/* Open a PhAB picture database, delete my icon,
and save the database again. */
ApDBase t *my dbase;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApCloseDBase(), ApCopyWidget(), ApDeleteWidget(),
ApOpenDBase(), ApOpenDBaseFile()
Accessing PhAB Modules from Code chapter of the Photon
Programmer’s Guide
Synopsis:
#include <Ap.h>
Description:
ApSetTranslation() changes the current translation file to the one
defined by lang ext. If lang ext is NULL, the translation is set to the
default (i.e. the original language used in the application). If the
extension pointed to by lang ext is invalid, the translation file isn’t
changed.
When you run your application outside of PhAB, it looks for the
translation files as follows:
Returns:
0 Successful completion.
Examples:
/* Set the current translation to German: */
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApAppendTranslation(), ApOpenDBase(), ApOpenDBaseFile(),
ApGetTextRes()
Synopsis:
#include <Ap.h>
Description:
ApWidget() is used within module setup functions to determine the
widget that initiated the link callback.
Returns:
A pointer to the initiating widget.
Examples:
mysetup function( ..., PtCallbackInfo t cbinfo ) {
if (ApName(ApWidget(cbinfo)) == ABN widget1) {
/* setup based on widget1 */
} else {
if (ApName(ApWidget(cbinfo)) == ABN widget2) {
/* setup based on widget2 */
} else {
/* common setup */
}
}
return( Pt CONTINUE );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
For another method of determining the widget that initiated a link
callback, see the ApInfo t structure.
The Photon libraries provide multibyte string functions that are useful
if you’re using multibyte-character strings. Use the functions
described in this chapter instead of the usual 8-bit-character functions
such as strlen().
Synopsis:
#include <photon/PhProto.h>
Description:
The mbstrblen() function returns the number of multibyte characters
made up of max bytes bytes in the string text, and sets bytes to the
number of bytes used to compose the number of multibyte characters
returned.
The width argument must be the maximum number of bytes used to
represent a single character, or 0 to accept the default value of 3.
The bytes argument won’t equal max bytes if there are fewer than
max bytes bytes in the string, or if the last byte doesn’t fall at the end
of a multibyte character.
Returns:
The number of multibyte characters made up of max bytes bytes in
the string text.
Classification:
Photon
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
See also:
mbstrlen(), mbstrnlen()
Synopsis:
#include <photon/PhProto.h>
Description:
The mbstrchr() function searches for a character in string that
matches mbchar. If such a match occurs in string, count (if provided)
is set to the number of multibyte characters the matching character is
from the beginning of the string. For example, if mbchar matches the
first character in string, count is set to 0. If mbchar matches the
second character in string, count is set to 1.
A pointer to the beginning of the matching character within string is
returned. If no match is found, the function returns NULL and doesn’t
change count.
Returns:
A pointer to the matching character, if found, or NULL if not found
Examples:
#include <Pt.h>
main()
{
char string[] = "Hello there: äîòéü found";
char mbchar[] = "é";
int count;
char *p;
Classification:
Photon
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
See also:
mbstrnchr(), mbstrrchr()
Synopsis:
#include <photon/PhProto.h>
Description:
The mbstrlen() function returns the number of multibyte characters in
the string text, and sets bytes to the number of bytes in text.
The char width must be set to the maximum number of bytes used to
represent a single character. Setting char width to 0 will use the
maximum character width.
Returns:
The number of multibyte characters in the string.
Classification:
Photon
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
See also:
mbstrblen(), mbstrnlen()
Synopsis:
#include <photon/PhProto.h>
Description:
This function searches for a multibyte character in string that matches
mbchar. The match must occur in the first num multibyte characters.
If such a match is found, count (if provided) is set to the number of
multibyte characters the matching character is from the beginning of
the string. For example, if mbchar matches the first character in
string, count is set to 0. If mbchar matches the second character in
string, count is set to 1.
Returns:
A pointer to the beginning of the matching character within string. If
no match is found within num characters, the function returns NULL
and doesn’t change count.
Examples:
Search the first 5 multibyte characters for a match to the provided
UTF-8 character:
#include <Pt.h>
main()
{
char string[] = "Hello there: äîòéü found";
char mbchar[] = "é";
int count;
char *p;
else
printf( " Not found " );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
See also:
mbstrchr(), mbstrrchr()
Synopsis:
#include <photon/PhProto.h>
Description:
This function compares len multibyte characters from str1 with str2.
The char width parameter must be set to the maximum number of
bytes used to represent a single character.
Returns:
An integer less than, equal to, or greater than zero, indicating that str1
is less than, equal to, or greater than str2.
Classification:
Photon
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
Synopsis:
#include <photon/PhProto.h>
Description:
The mbstrnlen() function returns the number of bytes occupied by
max len characters in the string text.
The char width parameter must be set to the maximum number of
bytes used to represent a single character or 0 to accept the default
value of 3.
The num parameter is set to the number of characters formed by the
number of bytes returned. This will be different from max len if there
are fewer than max len multibyte characters in text.
Returns:
The number of bytes occupied by max len characters in the string text.
Classification:
Photon
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
See also:
mbstrblen(), mbstrnlen()
Synopsis:
#include <photon/PhProto.h>
Description:
This function searches backwards from start char to string base
(inclusive) for a multibyte character that matches mbchar. If such a
match is found, count (if provided) is set to the number of multibyte
characters the matching character is from the start of the search. For
example, if mbchar matches the start char character in string, count
is set to 0. If mbchar matches the previous character in string, count
is set to 1.
A pointer to the beginning of the matching character within
string base is returned. If no match is found, the function returns
NULL and doesn’t change count.
Note that start char doesn’t need to be on a character boundary.
Returns:
A pointer to the matched character, or NULL if none was found.
Examples:
Search from the end of a string for a match to the provided UTF-8
character:
#include <Pt.h>
main()
{
char string[] = "Hello there: äîòéü found";
char mbchar[] = "é";
int count;
char *p;
Classification:
Photon
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
See also:
mbstrchr(), mbstrnchr()
Synopsis:
#include <photon/Pf.h>
Description:
This function attaches to the font server. The device parameter
specifies the prefix name of the server; if it’s NULL, the prefix is the
value in the PHFONT environment variable, or /dev/phfont if this
isn’t set. The size parameter specifies the size of a shared-memory
region to set up between the task and the server for returning text
bitmaps (normally required only by graphics drivers). If this is -1, the
value of the PHFONTMEM environment variable is used; if 0, no
such memory region is created.
This routine is normally called by PhAttach() as part of the standard
Photon initialization sequence. This routine is also automatically
invoked by the Pf library when it detects that the font server has been
restarted. The font control structure pointer is stored in the global
Photon Ph control structure as Ph ->font.
Instead of calling this function directly, set the two environment
variables (PHFONT and PHFONTMEM) to the new values before
performing standard Photon initialization.
Returns:
A pointer to an internal control structure if successful, NULL
otherwise.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
#include <photon/Pf.h>
Description:
This function detaches the task from the font server. The pf parameter
must be the control structure returned by a previous call to PfAttach().
All memory used by this structure is also released, including any
shared-memory region and local metrics code.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
#include <photon/Pf.h>
PhRect t *PfExtentComponents(
PhRect t *extent,
PhPoint t const *pos,
const char *font,
const char *str,
int len,
void (*func)(PhRect t *,
const char *,
const char *, int) );
Description:
This function calculates the extent of a text string as per
PfExtentText(), and also invokes a user callback function func for each
component of the string (a run of characters sourced from a single
font).
This facility is used by the phrelay utility to determine which font
files have to be downloaded to the remote system in order to correctly
render a string.
The callback function is passed an extent rectangle, the filename of
the font required, and the string and length of the character run.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfExtentText()
Synopsis:
#include <photon/Pf.h>
Description:
This function calculates the extent rectangle of a text string. The base
font is given by font; this determines the ascender/descender values of
the extent. The width is dependent on the string — the actual font
used by characters within the string may be different than this base
font (as specified in the fontext and fontmap files).
The string str is a Unicode, multibyte string of len bytes. If len is 0,
strlen(str) is assumed.
The text extent is returned in a rectangle, with ul.x being the left
bearing, lr.x-min(ul.x,0)+1 the right, ul.y the ascender, and
lr.y the descender. The baseline of the font is at position y=0; the
width of the string.
The resulting extent is offset by the point passed in pos. If this is
NULL, no offset is applied.
If metrics for the base font have been loaded locally (see
PfLoadMetrics()) then this extent may be calculated internally;
otherwise a request is sent to the font server.
Returns:
A pointer to the extent rectangle (extent) if successful, NULL
otherwise.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfFractionalExentText(), PfLoadMetrics(), PgExtentText()
Synopsis:
#include <photon/Pf.h>
PhRect t *PfFractionalExtentText(
PhRect t *extent,
PhPoint t const *pos,
const char *font,
long xsize,
long ysize,
const char *str,
int len);
Description:
This function calculates the extent rectangle of a text string. The base
font is given by font; this determines the ascender/descender values of
the extent. The xsize and ysize arguments define the size of the font in
16.16 fixed-point format.
☞ This function is valid only for scalable fonts. No font mappings are
performed.
Returns:
A pointer to the extent rectangle (extent) if successful, NULL
otherwise.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfExtentText(), PfFractionalRenderText(), PfLoadMetrics(),
PgExtentText()
Synopsis:
#include <photon/Pf.h>
int PfFractionalRenderText(
const char *font,
long xsize,
long ysize,
const char *str,
int len,
PhPoint t const *pos,
PhRect t const *clip,
void (*func)( const PhPoint t *,
const FontRender *));
Description:
This function renders the given string via a user callback function.
The base font is given by font. The xsize and ysize arguments define
the size of the font in 16.16 fixed-point format.
The actual fonts used by the string depend on the characters in it and
the information in the fontext and fontmap files. The string str is a
Unicode, multibyte string of len bytes. If len is 0, strlen(str) is
assumed.
The text is to be rendered at the location specified by pos, and clipped
to the rectangle specified by clip. If clip is NULL, it’s ignored. The
font server performs coarse character clipping only.
When a request to construct the bitmap is sent to the font server, the
string bitmap is returned, for efficiency, in the shared-memory region
created through the initial call to PfAttach().
This function is normally used only by graphics drivers, but may be
useful for application programs that have to obtain text bitmap data
directly.
The user callback function func() is called with the desired pen
location and the metrics of the bitmap. If the entire bitmap doesn’t fit
in the allocated memory, multiple calls to the font server and the user
function can be made, advancing the pen as appropriate between calls.
The FontRender metrics structure contains at least the following
members:
PhPoint t size
The bounding size of the bitmap (in pixels).
PhPoint t offset
The offset of the bitmap (the upper-left of the extent).
short bpp The number of bits per pixel (1 for normal output, 4
for anti-aliased).
unsigned char *bmptr
A pointer to the bitmap data (stored row-wise).
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
#include <photon/Pf.h>
Description:
This routine is useful for obtaining arbitrary character glyphs, such as
cursors. The PfGlyph() function obtains from the base font the
metrics and/or bitmap for the character specified by symbol. When
metrics is non-NULL, it must point to a FontRender structure that
will be filled in with the character metrics (see PfRenderText()).
When bitmap is non-NULL, it must point to an area of size bytes that
the character bitmap will be placed in. It may be rendered as a
bitmap/image in conjunction with the metrics information. The actual
font used to supply the character will be placed in the string pointed
to by fontused if non-NULL.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PfRenderText()
Synopsis:
#include <photon/Pf.h>
Description:
This function preloads a font (from disk into memory) within the font
server in order to speed up subsequent use of that font. By default, a
font is loaded only when required by a PgExtentText() or
PgDrawText() call. The font parameter specifies the name of the
desired font (e.g. helv12).
The flags parameter consists of zero or more of the
PHFONT LOAD METRICS or PHFONT LOAD IMAGES flags, which
indicate if the font metrics and/or bitmaps should be preloaded. If no
flags are specified, the validity of the input font name is checked.
If fontused is non-NULL, the string it points to will be set to the real
name of the font, which may be different than the input if the font is
unknown or mapped as an alias to another font (via the fontmap file).
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PgExtentText(), PgDrawText()
Synopsis:
#include <photon/Pf.h>
Description:
This function loads metric information for the given font from the
font server into memory and links this font into a list of available
local metrics.
Subsequent text extents of this base font, involving characters solely
within this font, will be performed locally by the task itself rather than
by the font server. This may result in faster operation of
extent-intensive tasks, such as HTML viewers, at a cost of about 1400
bytes of memory per font (for a standard font that defines characters
0x20-0xFF).
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
#include <photon/Pf.h>
Description:
This function gets information about the font specified by font after
first mapping font to a valid font name (if appropriate). The
FontQueryInfo structure pointed to by info is filled in. It contains at
least:
FontDescription desc
Textual name of the font family (e.g. Helvetica).
short size Point size of the font.
Returns:
0 Successful completion.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
#include <photon/Pf.h>
Description:
This function constructs a list of all fonts that may be used to render
the character specified by the symbol parameter. For example, use
’A’ to get a list of normal/Latin fonts, or 0x3A9 (omega) to get a list
of Greek fonts. (See PkKeyDef.h or ISO/EIC 10646-1 for a list of
symbols.)
The list of fonts is further filtered by the flags parameter, which may
contain any combination of the following:
The entries in the list are of type FontDetails, and contain the
following fields:
FontDescription desc
Textual name of the font family (e.g. Helvetica).
short losize Lowest point size available for this font. If losize
and hisize are both 0, the font is scalable.
short hisize Highest point size available for this font. If hisize
and losize are both 0, the font is scalable.
unsigned short flags
Various stylistic/attribute flags for this font family:
¯ PHFONT INFO PROP — proportional-width
font.
¯ PHFONT INFO FIXED — fixed-width font.
¯ PHFONT INFO PLAIN — plain/regular style.
¯ PHFONT INFO BOLD — bold style.
¯ PHFONT INFO ITALIC — italic style.
¯ PHFONT INFO BLDITC — bold italic style.
Returns:
The number of matching fonts found, or -1 on error.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFontSel (in the Photon Widget Reference)
Synopsis:
#include <photon/Pf.h>
int PfRenderText(
const char *font,
const char *str,
int len,
PhPoint t const *pos,
PhRect t const *clip,
void (*func)( const PhPoint t *,
const FontRender *));
Description:
This function renders the given string via a user callback function.
The base font is given by font. The actual fonts used by the string
depend on the characters in it and the information in the fontext and
fontmap files. The string str is a Unicode, multibyte string of len
bytes. If len is 0, strlen(str) is assumed.
The text is to be rendered at the location specified by pos, and clipped
to the rectangle specified by clip. If clip is NULL, it’s ignored. The
font server performs coarse character clipping only.
When a request to construct the bitmap is sent to the font server, the
string bitmap is returned, for efficiency, in the shared-memory region
created through the initial call to PfAttach().
This function is normally used only by graphics drivers, but may be
useful for application programs that have to obtain text bitmap data
directly.
The user callback function func() is called with the desired pen
location and the metrics of the bitmap. If the entire bitmap doesn’t fit
in the allocated memory, multiple calls to the font server and the user
function can be made, advancing the pen as appropriate between calls.
The FontRender metrics structure contains at least the following
members:
PhPoint t size
The bounding size of the bitmap (in pixels).
PhPoint t offset
The offset of the bitmap (the upper-left of the extent).
short bpp The number of bits per pixel (1 for normal output, 4
for anti-aliased).
unsigned char *bmptr
A pointer to the bitmap data (stored row-wise).
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfFractionalRenderText()
Synopsis:
#include <photon/Pf.h>
Description:
This function unloads the local metrics for the given font from
memory and releases any memory used for their storage. Subsequent
text extents of this base font are resolved by the font server rather than
being performed locally.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
☞ Instead of calling the Pg* functions directly, you should use widgets
whenever possible because widgets handle interaction with the user
and look after redrawing themselves when damaged. If you need to
do raw drawing, create a PtRaw
widget, and call the drawing primitives in its draw function. For more
information, see the Raw Drawing and Animation
chapter of the Photon Programmer’s Guide.
Synopsis:
void PgBackgroundShadings(PgColor t bg,
PgColor t *ts,
PgColor t *bs);
Description:
This function calculates the top and bottom shading colors that may
be used in a border to give an object a 3D appearance. Where possible
(based on the brightness of the background color), the top border
color will be lighter than the background and the bottom border color
will be darker than the background. Either of ts or bs may be NULL if
that component isn’t required.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PgBlueValue( PgColor t color );
Description:
This macro extracts the blue color component from a composite color
value (a PgColor t type). The result is between 0 and 255.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Caveats:
PgBlueValue() is a macro.
See also:
PgCMY(), PgGreenValue(), PgHSV(), PgRedValue() PgRGB(),
PgSetFillColor(), PgSetFillDither()
Synopsis:
void PgClearDrawBuffer( void );
Description:
This function resets the current draw buffer without flushing.
Examples:
/*
* Draw the following group of 3 lines
*/
PgDrawILine( 100, 100, 200, 300 );
PgDrawILine( 200, 300, 700, 700 );
PgDrawILine( 700, 700, 0, 0 );
PgFlush();
/*
* Don’t draw the following group of 3 lines
*/
PgDrawILine( 50, 100, 50, 300 );
PgDrawILine( 300, 20, 30, 700 );
PgDrawILine( 500, 700, 0, 100 );
PgClearDrawBuffer();
PgFlush();
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgFlush(), PgSetDrawBufferSize()
Synopsis:
void PgClearTranslation( void );
Description:
This function restores the current translation to the default (0,0).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgSetTranslation()
Synopsis:
PgColor t PgCMY( int C, int M, int Y );
Description:
This macro converts cyan, magenta, and yellow values into a
PgColor t structure. It lets you approximate print-industry colors.
The values for C, M, and Y range from 0 to 255. If you set all three
arguments to 0, the color is white; if you set all three to 255, the color
is black.
Returns:
A composite color value.
Examples:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor t, PgBlueValue(), PgGreenValue(), PgHSV(),
PgRedValue(), PgRGB(), PgSetFillColor(), PgSetFillDither()
Synopsis:
unsigned long PgColor t;
Description:
The PgColor t type definition describes a composite color value.
The lowest 8 bits contain the blue value, the next 8 bits contain the
green value, and the next 8 bits after that the red value:
Pg BLACK Pg MAGENTA
Pg DGRAY Pg CYAN
Pg MGRAY Pg DGREEN
Pg GRAY Pg DCYAN
Pg WHITE Pg DBLUE
Pg RED Pg BROWN
Pg GREEN Pg PURPLE
Pg BLUE Pg CELIDON
Pg YELLOW
Pg DEVICE COLOR
Interprets up to the least significant 24 bits as the value to put
into video memory.
Pg TRANSPARENT
Subsequent draw events won’t be rendered.
Pg VGA0 Pg VGA8
Pg VGA1 Pg VGA9
Pg VGA2 Pg VGAA
Pg VGA3 Pg VGAB
Pg VGA4 Pg VGAC
Pg VGA5 Pg VGAD
Pg VGA6 Pg VGAE
Pg VGA7 Pg VGAF
Classification:
Photon
See also:
PgBlueValue(), PgCMY(), PgColorHSV t PgGreenValue(),
PgHSV2RGB(), PgRedValue(), PgRGB(), PgRGB2HSV(),
PgSetFillColor(), PgSetFillDither(), PgSetStrokeColor(),
PgSetStrokeDither(), PgSetTextColor(), PgSetTextDither()
Synopsis:
typedef struct {
unsigned short hue;
unsigned char sat, vid;
} PgColorHSV t;
Description:
The PgColorHSV t structure describes a hue-saturation-value color.
It’s used to convert a color defined as red, green, and blue into HSV. It
contains at least the following members:
Classification:
Photon
See also:
PgColor t, PgHSV(), PgHSV2RGB(), PgRGB2HSV()
Synopsis:
int PgColorMatch(int n,
PgColor t const *in,
PgColor t *out);
Description:
This function queries the graphics driver for the best color matches
for a number of color values. This is particularly useful with a
palette-based graphics driver.
An array of n colors from the in array is passed to the driver, which
selects the closest match for each color and returns these in the out
array.
With a true or direct color driver, the color is returned unchanged.
With a palette-based driver, the closest color is found by computing
within a RGB color cube the Cartesian distance between the color and
each palette entry, and selecting the closest entry of a similar intensity.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PhGC t *PgCreateGC( int unused );
Description:
This function allocates a graphics context. A graphics context
contains the entire draw state, including color, clipping, and current
region.
Returns:
A pointer to a graphics context, or NULL if an error occurs.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDestroyGC(), PgSetDrawBufferSize(), PgSetGC()
Synopsis:
void PgDefaultFill( PhGC t *GC );
Description:
This function resets the fill attribute portion of the provided graphics
context to its system default.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultGC(), PgDefaultText(), PgDefaultMode(),
PgDefaultStroke()
Synopsis:
void PgDefaultGC( PhGC t *GC );
Description:
This function resets all attributes of the provided graphics context to
their system defaults.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultMode(), PgDefaultFill(), PgDefaultText(),
PgDefaultStroke()
Synopsis:
void PgDefaultMode( PhGC t *GC );
Description:
This function resets the draw mode and plane mask portions of the
provided graphics context to their system defaults.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultGC(), PgDefaultFill(), PgDefaultText(), PgDefaultStroke(),
PgSetDrawMode(), PgSetPlaneMask()
Synopsis:
void PgDefaultStroke( PhGC t *GC );
Description:
This function resets the stroke attribute portion of the provided
graphics context to its system default.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultGC(), PgDefaultFill(), PgDefaultText(), PgDefaultMode()
Synopsis:
void PgDefaultText( PhGC t *GC );
Description:
This function resets the text attribute portion of the provided graphics
context to system defaults.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultGC(), PgDefaultFill(), PgDefaultMode(),
PgDefaultStroke()
Synopsis:
void PgDestroyGC( PhGC t *GC );
Description:
This function releases any resources consumed by the specified
graphics context. If the draw buffer for that context contains draw
commands, the buffer is flushed before it’s released.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgCreateGC(), PgGetGC(), PgSetGC()
Synopsis:
int PgDrawArc( PhPoint t const *center,
PhPoint t const *radii,
unsigned int start,
unsigned int end,
int flags );
Description:
This function builds a command in the draw buffer to draw an arc.
The center argument defines the arc’s center, and radii defines the
arc’s x and y radii.
The start and end arguments define the start and end angles (both
arguments are specified in bi-grads; see below). The arc is drawn
counter-clockwise, from the start angle to the end angle. To draw a
complete circle, make the two angles equal to each other. An angle of
0 bi-grads is on the horizon to the right of the center.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state and
the draw command.
Examples:
The following example:
DrawFillArc() {
PhPoint t c = { 80, 60 };
PhPoint t r = { 72, 52 };
PgSetFillColor( Pg RED );
PgDrawArc( &c, &r, 0x0000, 0x4000, Pg DRAW FILL |
Pg ARC CHORD);
PgSetFillColor( Pg YELLOW );
PgDrawArc( &c, &r, 0x5555, 0x9555, Pg DRAW FILL |
Pg ARC PIE);
PgSetStrokeColor( Pg WHITE );
PgSetFillColor( Pg PURPLE );
PgDrawArc( &c, &r, 0xAAAA, 0xEAAA,
Pg DRAW FILL STROKE | Pg ARC PIE);
}
will draw:
DrawStrokeArc() {
PhPoint t c = { 80, 60 };
PhPoint t r = { 72, 52 };
PgSetStrokeColor( Pg WHITE );
PgDrawArc( &c, &r, 0x0000, 0x4000, Pg DRAW STROKE |
Pg ARC CHORD );
PgSetStrokeColor( Pg YELLOW );
PgDrawArc( &c, &r, 0x5555, 0x9555, Pg DRAW STROKE |
Pg ARC PIE );
PgSetStrokeColor( Pg YELLOW );
PgDrawArc( &c, &r, 0xAAAA, 0xEAAA, Pg DRAW STROKE |
Pg ARC );
}
will draw:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
To draw stroked arcs, see also:
Description:
These functions build a command in the draw buffer to draw a
beveled box. This box is used for the outlines of buttons and panes.
The upper and left edges of the box are drawn in the current stroke
color; the lower and right edges are drawn in the secondary color. The
width argument determines the thickness of the lines.
When you increase the thickness, the lines grow toward the middle of
the beveled box. The maximum width is given by Pg BEVEL MAX.
The flags argument must be one of the following:
-1 The draw buffer is too small to hold the current draw state and
the draw command.
Examples:
The following example:
DrawBevelBox() {
PhRect t r = { 8, 8, 152, 112 };
PgSetFillColor( Pg GREY );
PgSetStrokeColor( Pg WHITE );
PgDrawBevelBox( &r, Pg DGREY, 4,
Pg DRAW FILL STROKE );
}
will draw:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Systems
See also:
PgDrawBeveled(), PgDrawRect(), PgSetFillColor(),
PgSetFillDither(), PgSetFillTransPat(), PgSetStrokeColor(),
PgSetStrokeDither(), PgSetStrokeTransPat()
Synopsis:
int PgDrawBeveled( PhRect t const *rect,
PhPoint t const *radii,
PgColor t secondary,
short width,
int flags );
Description:
This function builds a command in the draw buffer to draw a beveled
rectangle or arrow. The rect parameter defines the area that the object
will fill. The flags parameter defines how the object will be drawn,
and includes options for defining the types of corners that it will have.
The upper and left edges of the object are drawn in the current stroke
color; the lower and right edges are drawn in the secondary color.
The width argument determines the thickness of the lines. When you
increase the thickness, the lines grow toward the middle of the
beveled object.
The flags argument must be one of the following:
Pg BEVEL CLIP
Draw a box with clipped corners. The radii argument
determines how much each corner is clipped.
Pg BEVEL ROUND
Draw a box with rounded corners. The radii argument
determines how much each corner is rounded.
Pg BEVEL SQUARE
Draw a box with square corners (default). The radii argument
isn’t used with this option. The corners will look like those
created by PgDrawBevelBox().
Pg BEVEL AUP
Draw an arrow pointing up. The radii argument isn’t used with
this option.
Pg BEVEL ADOWN
Draw an arrow pointing down. The radii argument isn’t used
with this option.
Pg BEVEL ALEFT
Draw an arrow pointing left. The radii argument isn’t used with
this option.
Pg BEVEL ARIGHT
Draw an arrow pointing right. The radii argument isn’t used
with this option.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state and
the draw command.
Examples:
The following example:
DrawBeveled() {
PhRect t rc = { 8, 8, 152, 56 };
PhRect t rr = { 8, 64, 152, 112 };
PhPoint t pc = { 8, 8 };
PhPoint t pr = { 12, 12 };
PgSetFillColor( Pg GREY );
PgSetStrokeColor( Pg WHITE );
PgDrawBeveled( &rc, &pc, Pg DGREY, 2,
Pg DRAW FILL STROKE | Pg BEVEL CLIP );
PgDrawBeveled( &rr, &pr, Pg DGREY, 2,
Pg DRAW FILL STROKE | Pg BEVEL ROUND );
}
will draw:
PgSetFillColor( Pg GREY );
PgSetStrokeColor( Pg WHITE );
PgDrawBeveled( &rup, NULL, Pg DGREY, 1,
Pg DRAW FILL STROKE | Pg BEVEL AUP );
PgDrawBeveled( &rdown, NULL, Pg DGREY, 1,
Pg DRAW FILL STROKE | Pg BEVEL ADOWN );
PgDrawBeveled( &rleft, NULL, Pg DGREY, 1,
Pg DRAW FILL STROKE | Pg BEVEL ALEFT );
PgDrawBeveled( &rright, NULL, Pg DGREY, 1,
Pg DRAW FILL STROKE | Pg BEVEL ARIGHT );
}
will draw:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawBevelBox(), PgDrawRect(), PgDrawIRect(),
PgDrawRoundRect(), PgSetFillColor(), PgSetFillDither(),
PgSetFillTransPat(), PgSetStrokeColor(), PgSetStrokeDither(),
PgSetStrokeTransPat()
Synopsis:
int PgDrawBezier( PhPoint t const *ptr,
int num,
PhPoint t const *pos,
int flags );
Description:
These functions build a command in the draw buffer to draw a
multisegment Bézier curve from an array of points.
Each Bézier curve is defined by 4 points. The last point of a curve
becomes the first point of the next curve. The first and fourth points
are anchor points; the line passes through these. The second and third
points are control points; the curve is “pulled” toward these points.
The flags argument must be one of the following:
☞ If you call the “mx” form of this function, the data isn’t physically
copied into the draw buffer. Instead, a pointer to the array is stored
until the draw buffer is flushed. Make sure you call PgFlush() before
you modify the point array.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state, the
draw command, and the data. Increase the size of the draw
buffer or decrease the number of points.
Examples:
The following example:
DrawFillStrokeBezier() {
PhPoint t o = { 0, 0 };
PhPoint t p[] = {43, 71, -92, -18, 344, -6, 20, 99};
will draw:
The dotted lines show where the control points are relative to the
anchor points.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawPolygon(), PgFlush()
To draw stroked Bézier curves, see also:
PgSetStrokeColor(), PgSetStrokeCap(), PgSetStrokeDash(),
PgSetStrokeDither(), PgSetStrokeJoin(), PgSetStrokeWidth()
To draw filled Bézier curves, see also:
PgSetFillColor(), PgSetFillDither(), PgSetFillTransPat()
Description:
These functions build a command in the draw buffer to draw a bitmap.
The function starts the bitmap at pos and extends it down and to the
right according to size.
The bpl argument indicates the number of bytes per line of image data
(that is, the offset from one line of data to the next). To calculate the
size of the data transferred to the graphics driver, multiply bpl by
size.y. You can determine the size and bpl arguments with the value
returned by a PxLoadImage() call.
The data pointed to by ptr is one bit per pixel. If the pixel value is 1,
the pixel is drawn with the color set by PgSetTextColor() or
PgSetTextDither(). If the pixel value is 0, the pixel is drawn as
transparent unless you’ve set flags to Pg BACK FILL. With
Pg BACK FILL, the pixel is drawn with the color set by
PgSetFillColor() or PgSetFillDither(). The pixels are drawn most
significant bit first.
The tag argument is used for data caching by programs such as
phrelay. This argument is ignored if you set it to 0. To calculate a
tag value, use PxCRC().
☞ If you call the “mx” form of this function, the data isn’t physically
copied into the draw buffer. Instead, a pointer to the array is stored
until the draw buffer is flushed. Make sure you call PgFlush() before
you modify the bitmap.
If the data is in shared memory, the mx form of this function will
automatically pass a shared memory reference instead of the bitmap.
Returns:
0 Successful completion
-1 The draw buffer is too small to hold the current draw state, the
draw command, and one pixel line of the image. Increase the
size of the draw buffer or decrease the width of the image.
Examples:
The following example:
PhPoint t TestBitmapSize = { 64, 64 };
int TestBitmapBPL = 8;
char TestBitmap[64*8] = { "512 bytes of bitmap data" };
DrawSimpleBitmap() {
PhPoint t p = { 8, 8 };
PgSetTextColor( Pg WHITE );
PgDrawBitmap( TestBitmap, 0, &p,
&TestBitmapSize, TestBitmapBPL, 0 );
}
will draw:
Systems
PhPoint t p = { 8, 8 };
PgSetTextColor( Pg WHITE );
PgSetFillColor( Pg PURPLE );
PgDrawBitmap( TestBitmap, Pg BACK FILL, &p,
&TestBitmapSize, TestBitmapBPL, 0 );
}
will draw:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawRepBitmap(), PgFlush(), PgSetFillColor(), PgSetFillDither(),
PgSetTextColor(), PgSetTextDither(), PgShmemCreate(), PxCRC(),
PxLoadImage()
Synopsis:
int PgDrawEllipse( PhPoint t const *center,
PhPoint t const *radii,
unsigned int flags );
Description:
This function builds a command in the draw buffer to draw an ellipse.
The center argument defines the ellipse’s center and radii defines its x
and y radii.
The flags argument must be one of the following:
To have the function interpret the center and radii arguments as the
upper-left and lower-right coordinates respectively, OR flags with
Pg EXTENT BASED.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state and
the draw command.
Examples:
The following example:
DrawStrokeElli() {
PhPoint t c = { 80, 60 };
PhPoint t r = { 72, 52 };
PgSetStrokeColor( Pg WHITE );
PgDrawEllipse( &c, &r, Pg DRAW STROKE );
}
will draw:
PgSetFillColor( Pg PURPLE );
PgDrawEllipse( &c, &r, Pg DRAW FILL );
}
will draw:
PgSetFillColor( Pg PURPLE );
PgSetStrokeColor( Pg WHITE );
will draw:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawRoundRect(), PgSetFillColor(), PgSetFillDither(),
PgSetFillTransPat(), PgSetStrokeColor(), PgSetStrokeDither(),
PgSetStrokeTransPat()
Synopsis:
int PgDrawGrid( PhRect t const *r,
PhPoint t const *g );
Description:
This function fills the rectangle specified by r with the number of
divisions specified by g. The number of lines drawn equals the
number of divisions plus 1.
This function builds a draw command to draw the grid. The size of
the grid is defined by the r argument with g.x+1 vertical lines and
g.y+1 horizontal lines. If g.x is 0, no vertical lines are drawn; if g.y is
0, no horizontal lines are drawn.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state and
the draw command.
Examples:
The following example uses PgDrawGrid() to make a grid of 8
squares by 8 squares; each square is 8 by 8 pixels:
void GridStandard() {
PhRect t r = { 8, 8, 72, 72 };
PhPoint t g = { 8, 8 };
PgSetStrokeColor( Pg WHITE );
PgDrawGrid( &r, &g );
}
void GridTicks() {
PhRect t r = { 8, 24, 108, 28 };
PhPoint t g = { 20, 0 };
PgSetStrokeColor( Pg WHITE );
PgDrawGrid( &r, &g );
r.ul.y-=1;
r.lr.y+=1;
g.x=4;
PgSetStrokeWidth( 3 );
PgSetStrokeCap( Pg POINT CAP );
PgDrawGrid( &r, &g );
PgSetStrokeWidth( 0 );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgSetStrokeColor(), PgSetStrokeWidth()
Synopsis:
int PgDrawImage( void const *ptr,
int type,
PhPoint t const *pos,
PhDim t const *size,
int bpl,
long tag );
Description:
These functions build a command in the draw buffer to draw an
image. The functions start the image at pos and extend it down and to
the right according to size.
The bpl argument indicates the number of bytes per line of image data
(that is, the offset from one line of data to the next).
To calculate the size of the data transferred to the graphics driver,
multiply bpl by size.y. You can determine the size and bpl arguments
with the value returned by PxLoadImage().
The tag argument is used for data caching by programs such as
phrelay. To calculate the tag, use PxCRC(). This argument is
ignored if you set it to 0.
The type argument controls how the image data pointed to by ptr is
interpreted by the graphics driver. For information on the different
types of images, see PhImage t.
☞ If you call the “mx” form of this function, the data isn’t physically
copied into the draw buffer. Instead, a pointer to the array is stored
until the draw buffer is flushed. Make sure you call PgFlush() before
you modify the image.
If the data is in shared memory, the mx form of this function will
automatically pass a shared memory reference instead of the image.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state, the
draw command, and one pixel line of the image. Increase the
size of the draw buffer or decrease the width of the image.
Examples:
The following example:
PhImage t *pimage;
InitPalImage() {
if (pimage != NULL) return;
if ((pimage = PxLoadImage( "mackface.bmp", NULL )) == NULL) {
perror( "Unable to load image" );
return;
}
}
DrawPalImage() {
PhPoint t p = { 0, 0 };
InitPalImage();
if (pimage == NULL) return;
if ((pimage->palette != NULL) && (pimage->colors > 0))
PgSetPalette( pimage->palette, 0, 0, pimage->colors,
Pg PALSET SOFT, 0 );
PgDrawImage( pimage->image, pimage->type, &p,
&pimage->size, pimage->bpl, 0 );
}
will draw:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawTImage(), PgFlush(), PgSetFillColor(), PgSetPalette(),
PgShmemCreate(), PhMakeTransBitmap(), PxCRC(), PxLoadImage()
Synopsis:
int PgDrawLine( PhPoint t const *p1,
PhPoint t const *p2 );
Description:
These functions build a command in the draw buffer to draw a line.
Note that PgDrawLine() requires two pointers to PhPoint t,
whereas PgDrawILine() takes individual arguments.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state and
the draw command.
Examples:
The following example:
DrawLines() {
PgSetStrokeColor( Pg RED );
PgDrawILine( 8, 8, 152, 8 );
PgSetStrokeColor( Pg GREEN );
PgDrawILine( 8, 8, 152, 60 );
PgSetStrokeColor( Pg YELLOW );
PgDrawILine( 8, 8, 152, 112 );
}
will draw:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgSetStrokeCap(), PgSetStrokeColor(), PgSetStrokeDash(),
PgSetStrokeDither(), PgSetStrokeJoin(), PgSetStrokeWidth()
Synopsis:
int PgDrawPhImagemx( PhPoint t const *pos,
PhImage t const *image,
int flags );
Description:
This function draws the provided image at position pos. The image
parameter must be a pointer to a PhImage t structure that defines the
image to be rendered. If the image has a transparency mask, it’s used.
The currently defined valid bits for the flags parameter are:
Pg GHOST or Pt GHOST
Render the image using the ghost bitmap as a transparency
mask.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetImageRes(), PhImage t, PhMakeGhostBitmap(),
PhMakeTransBitmap(), PhReleaseImage(), PxLoadImage()
Synopsis:
int PgDrawPixel( PhPoint t const *pt );
Description:
These functions build a command in the draw buffer to draw a pixel.
For PgDrawPixel(), the pt argument points to a pixel location; for
PgDrawIPixel(), x and y specify the location.
Returns:
0 Successful completion
-1 The draw buffer is too small to hold the current draw state, the
draw command, and the data. Increase the size of the draw
buffer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawPixelArray(), PgDrawPixelArraymx(), PgFlush(),
PgSetStrokeColor(), PgSetStrokeDither()
Synopsis:
int PgDrawPixelArray( PhPoint t const *ptr,
int num,
PhPoint t const *pos );
Description:
These functions build a command in the draw buffer to draw an array
of pixels. The ptr argument points to an array of pixel locations; num
indicates how many points to draw; and the value of pos is added to
every pixel location.
☞ If you call the “mx” form of this function, the data isn’t physically
copied into the draw buffer. Instead, a pointer to the array is stored
until the draw buffer is flushed. Make sure you call PgFlush() before
you modify the pixel array.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state, the
draw command, and the data. Increase the size of the draw
buffer or decrease the number of points.
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PgDrawPixel(), PgDrawIPixel(), PgFlush(), PgSetStrokeColor(),
PgSetStrokeDither()
Description:
These functions build a command in the draw buffer to draw a
polygon from an array of points, pointed to by ptr, with num entries.
☞ The array of points must fit in the draw buffer, even if you use
PgDrawPolygonmx().
Pg DRAW STROKE
Draw a stroked polygon.
Pg DRAW FILL
Draw a filled polygon.
☞ If you call the “mx” form of this function, the data isn’t physically
copied into the draw buffer. Instead, a pointer to the array is stored
until the draw buffer is flushed. Make sure you call PgFlush() before
you modify the point array.
Returns:
0 Successful completion
-1 The draw buffer is too small to hold the current draw state, the
draw command, and the data. Increase the size of the draw
buffer or decrease the number of points.
Examples:
The following example:
DrawFillStrokePoly() {
PhPoint t o = { 0, 0 };
PhPoint t p[] = { 80, 8, 120, 120, 16, 32,
136, 32, 40, 120 };
PgSetStrokeColor( Pg WHITE );
PgSetFillColor( Pg PURPLE );
PgDrawPolygon( &p, 5, &o, Pg DRAW FILL STROKE |
Pg CLOSED );
}
will draw:
Systems
PgSetStrokeColor( Pg WHITE );
PgSetFillColor( Pg PURPLE );
PgDrawPolygon( &p, 5, &o, Pg DRAW FILL STROKE |
Pg CLOSED |
Pg RELATIVE );
}
will draw:
PgSetStrokeColor( Pg WHITE );
PgSetFillColor( Pg PURPLE );
PgDrawPolygon( &p, 5, &o, Pg DRAW FILL STROKE );
}
will draw:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgFlush()
To draw stroked polygons, see also:
PgSetStrokeColor(), PgSetStrokeCap(), PgSetStrokeDash(),
PgSetStrokeDither(), PgSetStrokeJoin(), PgSetStrokeWidth()
To draw filled polygons, see also:
PgSetFillColor(), PgSetFillDither(), PgSetFillTransPat()
Synopsis:
int PgDrawRect( PhRect t const *rect,
unsigned int flags );
Description:
These functions build a command in the draw buffer to draw a
rectangle. Note that PgDrawRect() requires a pointer to a PhRect t
structure whereas PgDrawIRect() takes individual arguments.
The flags argument must be one of the following:
Pg DRAW STROKE
Draw as a line.
Pg DRAW FILL
Fill the rectangle.
Pg DRAW FILL STROKE
Fill the rectangle, then stroke it.
For PgDrawIRect(), ulx and uly are the coordinates of the upper-left
corner, and lrx and lry are those for the lower-right.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state and
the draw command.
Examples:
The following example:
DrawFillRect() {
PgSetFillColor( Pg PURPLE );
PgDrawIRect( 8, 8, 152, 112, Pg DRAW FILL );
}
will draw:
will draw:
will draw:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawBeveled(), PgDrawRoundRect(), PgSetFillColor(),
PgSetFillDither(), PgSetFillTransPat()
Description:
These functions build a command in the draw buffer to repeatedly
draw the bitmap pointed to by ptr. For an explanation of bitmaps, see
PgDrawBitmap().
These functions:
¯ Draw the first bitmap at pos and the next bitmap space.x pixels to
the right.
¯ Draw the bitmap rep.x times in the x direction and rep.y times in
the y direction.
¯ Draw each row of bitmaps space.y pixels below the previous row.
☞ If you call the “mx” form of this function, the data isn’t physically
copied into the draw buffer. Instead, a pointer to the bitmap is stored
until the draw buffer is flushed. Make sure you call PgFlush() before
you modify the bitmap.
If the data is in shared memory, the mx form of this function
automatically passes a shared memory reference instead of the
bitmap.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state, the
draw command, and one pixel line of the image. Increase the
size of the draw buffer, or decrease the width of the image.
Examples:
The following example:
DrawRepBitmap() {
PhPoint t p = { -32, -32 };
PhPoint t rep = { 5, 3 };
PgSetTextColor( Pg WHITE );
PgDrawRepBitmap( TestBitmap, 0, &p,
&TestBitmapSize, TestBitmapBPL,
&rep, &TestBitmapSize, 0 );
}
draws:
space.x = TestBitmapSize.x * 2;
space.y = TestBitmapSize.y * 2;
PgSetTextColor( Pg WHITE );
PgDrawRepBitmap( TestBitmap, Pg REPBM ALTERNATE, &p,
&TestBitmapSize, TestBitmapBPL,
&rep, &space, 0 );
}
draws:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawBitmap(), PgDrawRepImage(), PgDrawRepImagemx(),
PgFlush(), PgSetFillColor(), PgSetFillDither(), PgSetTextColor(),
PgSetTextDither(), PxCRC(), PxLoadImage()
Description:
The PgDrawRepImage() and PgDrawRepImagemx() functions build a
command in the draw buffer to repeatedly draw the image pointed to
by ptr. These functions:
¯ Draw the first image at pos and the next image space.x pixels to
the right.
¯ Draw the image rep.x times in the x direction and rep.y times in
the y direction.
¯ Draw each row of images space.y pixels below the previous row.
Software Systems
The bpl argument indicates the number of bytes per line of image data
(that is, the offset from one line of data to the next). To calculate the
size of the data transferred to the graphics driver, multiply bpl by
size.y. You can determine the size and bpl arguments with the value
returned by PxLoadImage().
The tag argument is used for data caching by programs such as
phrelay. To calculate the tag, use PxCRC(). This argument is
ignored if you set it to 0.
☞ If you call the “mx” form of this function, the data isn’t physically
copied into the draw buffer. Instead, a pointer to the image is stored
until the draw buffer is flushed. Make sure you call PgFlush() before
you modify the image.
If the data is in shared memory, the mx form of this function
automatically passes a shared memory reference instead of the image.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state, the
draw command, and one pixel line of the image. Increase the
size of the draw buffer, or decrease the width of the image.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PgDrawRoundRect( PhRect t const *rect,
PhPoint t const *radii,
unsigned flags );
Description:
This function builds a command in the draw buffer to draw a rounded
rectangle. The rect argument defines the extent of the rectangle and
radii defines the roundness of the corners, in pixels.
The flags argument must be one of the following:
Since the value of radii is truncated to the size of the rectangle, you
should find this function useful for drawing ellipses within a
rectangular area (see example below).
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state and
the draw command.
Examples:
The following example:
DrawStrokeRRect() {
PhRect t rect = { 8, 8, 152, 112 };
PhPoint t radii = { 32, 32 };
PgSetStrokeColor( Pg WHITE );
PgDrawRoundRect( &rect, &radii, Pg DRAW STROKE );
}
will draw:
PgSetFillColor( Pg PURPLE );
PgDrawRoundRect( &rect, &radii, Pg DRAW FILL );
}
will draw:
PgSetFillColor( Pg PURPLE );
PgSetStrokeColor( Pg WHITE );
PgDrawRoundRect( &rect, &radii, Pg DRAW FILL STROKE );
}
will draw:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawBeveled(), PgDrawIRect(), PgDrawRect(), PgSetFillColor(),
PgSetFillDither(), PgSetFillTransPat()
Synopsis:
int PgDrawSpan( PgSpan t const *ptr,
int num,
PhPoint t const *pos,
int flags );
Description:
These low-level draw primitives let you render complex shapes not
supported by the Photon graphics drivers.
The functions draw a list of spans. The spans are defined as a list of
PgSpan t records. Here are the members of PgSpan t:
short y y position
☞ If you call the “mx” form of this function, the data isn’t physically
copied into the draw buffer. Instead, a pointer to the list of spans is
stored until the draw buffer is flushed. Make sure you call PgFlush()
before you modify the list.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state, the
draw command and the data. Increase the size of the draw
buffer, or decrease the number of points.
Examples:
The following example:
void DrawSpan() {
PgSpan t spans[152];
PgSpan t *sp = spans;
PhPoint t p = { 12, 10 };
int i, v, n=0;
will draw:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawPolygon(), PgSetFillColor(), PgSetStrokeColor(),
PgSetTextColor(), PgFlush()
Synopsis:
int PgDrawString( char const *ptr,
PhPoint t const *pos );
Description:
These convenience functions for PgDrawText() and PgDrawTextmx()
calculate the length of the string internally using strlen(). They then
pass the string, along with its length, its position, and a flags setting of
0, to the corresponding text function.
☞ If you call the “mx” form of this function, the data isn’t physically
copied into the draw buffer. Instead, a pointer to the string is stored
until the draw buffer is flushed. Make sure you call PgFlush() before
you modify the text.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state, the
draw command, and the data. Increase the size of the draw
buffer, or decrease the size of the string.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawText(), PgDrawTextArea(), PgFlush(), PgSetTextColor(),
PgSetTextDither(), PgSetTextTransPat(), PgSetTextXORColor(),
PgSetUnderline(), PhPoint t
strlen() (in the C Library Reference)
Description:
Each of these functions builds a command in the draw buffer to draw
the text indicated by ptr at location pos.
The len parameter specifies the number of bytes required to store the
string. For pure ASCII strings (characters 0 to 127), this is the number
of characters. For multibyte strings, len may be larger than the
number of characters. For double-byte strings, len is twice the
number of characters.
By default, the function assumes that all strings consist of multibyte
characters that conform to the ISO/IEC 10646-1 UTF-1 multibyte
format. However, if Pg TEXT WIDECHAR is set, the function
assumes each character is represented by 2 bytes that conform to the
ISO/IEC 10646-1 UCS-2 double-byte format.
By default, the text is left-aligned (Pg TEXT LEFT), and the text is
drawn with pos->y as its baseline. You can set flags to a combination
of:
Pg TEXT WIDECHAR
The text is specified as wide characters. Each
character is represented by 16 bits.
Pg TEXT LEFT Left align text to pos (text is drawn to the right).
Pg TEXT RIGHT Right align text to pos (text is drawn to the left).
Pg TEXT CENTER
Center text horizontally on pos.
Pg TEXT BOTTOM
Bottom align text to pos (text is drawn above).
Pg TEXT MIDDLE
Center text vertically on pos.
☞ If you call the “mx” forms of these functions, the data isn’t physically
copied into the draw buffer. Instead, a pointer to the string is stored
until the draw buffer is flushed. Make sure you call PgFlush() before
you modify the text.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state, the
draw command and the data. Increase the size of the draw
buffer, or decrease the size of the string.
Examples:
The following example:
DrawSimpleText() {
char *s = "Hello World!";
PhPoint t p = { 8, 30 };
PgSetFont( "helv18" );
PgSetTextColor( Pg WHITE );
PgDrawText( s, strlen( s ), &p, 0 );
}
will draw:
Hello W orld!
PgSetFont( "helv18" );
PgSetTextColor( Pg WHITE );
PgSetFillColor( Pg PURPLE );
PgDrawText( s, strlen( s ), &p, Pg BACK FILL );
}
will draw:
Hello W orld!
PgSetFont( "helv18" );
PgSetTextColor( Pg WHITE );
PgSetUnderline( Pg RED, Pg TRANSPARENT, 0 );
PgDrawText( s, strlen( s ), &p, 0 );
PgSetUnderline( Pg TRANSPARENT, Pg TRANSPARENT, 0 );
}
will draw:
Hello W orld!
PgSetFont( "helv18" );
PgSetTextColor( Pg WHITE );
PgSetFillColor( Pg PURPLE );
PgSetUnderline( Pg RED, Pg TRANSPARENT, 0 );
PgDrawText( s, strlen( s ), &p, Pg BACK FILL );
PgSetUnderline( Pg TRANSPARENT, Pg TRANSPARENT, 0 );
}
will draw:
Hello W orld!
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawString(), PgFlush(), PgSetFillColor(), PgSetFillDither(),
PgSetFillTransPat(), PgSetFont(), PgSetTextColor(),
PgSetTextDither(), PgSetTextTransPat(), PgSetTextXORColor(),
PgSetUnderline(), PhPoint t
Synopsis:
int PgDrawTextArea( char const *ptr,
int len,
PhRect t const *rect,
int flags );
Description:
This function draws text within an area. This area is clipped to the
dimensions of the rectangle specified by rect.
By default, the text is left-aligned (Pg TEXT LEFT), and the text is
drawn with its baseline centered inside the drawing area.
The flags can be a combination of:
Pg TEXT WIDECHAR
The text is specified as wide characters. Each
character is represented by 16 bits.
Pg TEXT CENTER
Center text horizontally within rect.
Pg TEXT BOTTOM
Align text to bottom edge of rect (rect->lr.y).
Pg TEXT MIDDLE
Center text vertically within rect.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Caveats:
PgDrawTextArea() doesn’t work in any context that involves the
render library, such as printing or Phindows. If your application needs
to use the render library, you should:
See also:
PgDrawString(), PgDrawText(), PgFlush(), PgSetFillColor(),
PgSetFillDither(), PgSetFillTransPat(), PgSetFont(),
PgSetTextColor(), PgSetTextDither(), PgSetTextTransPat(),
PgSetTextXORColor(), PgSetUnderline(), PgSetUserClip(),
PgSetUserClipAbsolute(), PhRect t
Description:
These functions build a command in the draw buffer to draw an image
with a transparency mask. These functions take the same parameters
as PgDrawImage() and PgDrawImagemx() with two additions,
TransPtr and TransBPL.
Systems
Returns:
0 Successful completion
-1 The draw buffer is too small to hold the current draw state, the
draw command, and one pixel line of the image. Increase the
size of the draw buffer or decrease the width of the image.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawImage(), PhImage t, PhMakeTransBitmap()
Synopsis:
int PgDrawTrend( short const *ptr,
PhPoint t const *pos,
int num,
int delta,
int buflen,
int bufoff ,
unsigned flags );
Description:
These functions build a command in the draw buffer to draw a trend
graph.
The ptr argument points to an array of short values. Each of these
values is used as either the x or the y coordinate; the other coordinate
is calculated by adding delta to the previous value.
For example, if flags is Pg TREND VERT, the coordinates would be
calculated as follows:
The pos argument defines the origin of the trend graph and the num
argument controls the number of values to be drawn.
The flags argument controls how the trend will be drawn. It must be
one of the following:
Pg TREND HORIZ
Draw a horizontal graph. The ptr values become the y axis and
the delta values are added to the x coordinate.
Pg TREND VERT
Draw a vertical graph. The ptr values become the x axis and the
delta values are added to the y coordinate.
The buflen and bufoff arguments aren’t currently used, and must be
set to 0 for future compatibility.
☞ If you call the “mx” form of this function, the data isn’t physically
copied into the draw buffer. Instead, a pointer to the array is stored
until the draw buffer is flushed. Make sure you call PgFlush() before
you modify the array.
If the data is in shared memory, the mx form of this function will
automatically pass a shared memory reference instead of the array.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state, the
draw command and the data. Increase the size of the draw
buffer, or decrease the number of points.
Examples:
The following example:
void HTrend() {
short data[512];
PhPoint t p = { 0, 80 };
int i;
will draw:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawPolygon(), PgSetStrokeColor(), PgSetStrokeWidth(),
PgFlush()
Synopsis:
PhRect t *PgExtentText( PhRect t *extent,
PhPoint t const *pos,
char const *font,
char const *str,
unsigned n );
Description:
This function determines the extent that would be occupied if str were
rendered at pos, using font. The extent information is returned in both
extent and in the return value for the function. If you pass extent as
NULL, the function returns NULL.
The function calculates the extent of the first n characters of the
string. To have the function calculate the extent of the entire string,
set n to zero. If you pass pos as NULL, it’s assumed to be (0,0).
Returns:
A pointer to a PhRect t structure, or NULL if an error occurred.
Examples:
The following fragment determines the extent of a string drawn with
the helv18BI font:
PhRect t extent;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawText(), PgSetFont()
Synopsis:
int PgFlush( void );
Description:
These functions flush the current draw buffer and then clear it. Most
applications call PgFlush(); you need to call PgFFlush() only if you
need to specify the type of draw event.
Normally, you set flags to Ph NORMAL DRAW; this is the same as
calling PgFlush(). But if your application has received an expose
event with a subtype of Ph CAPTURE EXPOSE, you should
encapsulate your drawing events by calling
PgFFlush( Ph START DRAW );
after the entire exposed region has been redrawn. If you’re using
widgets, PtEventHandler() makes both these calls automatically.
Any function that builds a command in the draw buffer calls
PgFlush() automatically when the draw buffer becomes full.
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
/*
* Place a group of 3 lines in the draw buffer
*/
PgDrawILine( 100, 100, 200, 300 );
PgDrawILine( 200, 300, 700, 700 );
/*
* Emit a draw event that contains those 3 lines
*/
PgFlush();
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgClearDrawBuffer(), PgSetDrawBufferSize(), PhEvent t
Synopsis:
PhGC t *PgGetGC( void );
Description:
This function gets the current graphics context.
Returns:
A pointer to the current graphics context.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgCreateGC(), PgDestroyGC(), PgSetGC()
Synopsis:
int PgGetPalette(PgColor t *palette);
Description:
This function queries the graphics driver for the current palette. A
palette is an array of Pg MAX PALETTE (256) RGB colors. The
palette parameter must be a pointer to a suitably-sized array, which
will be filled with the color values representing the current palette.
This function is useful for graphical image utilities such as pv, which
can perform improved dithering with knowledge of the graphics
palette.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PgColor t PgGray( int level );
Description:
This macro converts a gray value into a PgColor t structure.
The level argument ranges from 0 (black) to 255 (white). Intermediate
values produce various shades of gray. For a complete description of
composite color values, see PgSetFillColor().
Returns:
A composite color value.
Examples:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgBlueValue(), PgCMY(), PgGreenValue(), PgHSV(), PgRedValue(),
PgRGB(), PgSetFillColor(), PgSetFillDither()
Synopsis:
int PgGrayValue( PgColor t color );
Description:
This macro converts a color into its corresponding level of gray. The
calculation is based on 30% red, 59% green, and 11% blue, resulting
in a value between 0 and 255.
Returns:
The gray component of the color.
Examples:
// Convert pal[i] into monochrome
pal[i] = PgGray( PgGrayValue( pal[i] ) );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgBlueValue(), PgCMY(), PgGreenValue(), PgHSV(), PgRedValue(),
PgRGB(), PgSetFillColor(), PgSetFillDither()
Synopsis:
int PgGreenValue( PgColor t color );
Description:
This macro extracts the green color component from a composite
color value (a PgColor t type). The result is between 0 and 255.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Caveats:
PgGreenValue() is a macro.
See also:
PgBlueValue(), PgCMY(), PgHSV(), PgRedValue() PgRGB(),
PgSetFillColor(), PgSetFillDither()
Synopsis:
PgColor t PgHSV( unsigned H, int S, int V );
Description:
This function converts hue, saturation, and value into a PgColor t
structure.
A color circle is divided into 65536 gradations (called binary
gradations or bi-grads). Hue is in bi-grads, starting with red at 0 (0
degrees), green at 0x5555 (120 degrees), and blue at 0xAAAA (240
degrees):
Hue Color
0x0000 Red
0x2AAA Yellow
0x5555 Green
0x8000 Cyan
0xAAAA Blue
0xD555 Magenta
0xFFFF Almost red
Saturation Effect
0 Gray
128 Muted
255 Pure color
Value Effect
0 Black
128 Dark
255 Full brightness
Returns:
A composite color value.
Examples:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgBlueValue(), PgCMY(), PgGreenValue(), PgHSV2RGB(),
PgRedValue(), PgRGB(), PgRGB2HSV(), PgSetFillColor(),
PgSetFillDither()
Synopsis:
PgColor t PgHSV2RGB( PgColorHSV t hsv color );
Description:
This function converts hue-saturation-value colors to composite color
values.
If you write a color selection function that allows the user to change
RGB and HSV values, you should maintain the RGB and HSV values
separately. If the user changes the HSV value, you would use
PgHSV2RGB() to calculate the new RGB value. For example:
Returns:
A composite color value.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor t, PgColorHSV t, PgHSV(), PgRGB2HSV(),
PgSetFillColor()
Synopsis:
int PgRedValue( PgColor t color );
Description:
This macro extracts the red color component from a composite color
value (a PgColor t type). The result is between 0 and 255.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Caveats:
PgRedValue() is a macro.
See also:
PgBlueValue(), PgCMY(), PgGreenValue(), PgHSV(), PgRGB(),
PgSetFillColor(), PgSetFillDither()
Synopsis:
PgColor t PgRGB( int R, int G, int B );
Description:
This macro converts red, green, and blue values into a composite
color value (a PgColor t type). The values for red, green, and blue
range from 0 to 255. If you set all three arguments to 0, the color is
black; if you set all three to 255, the color is white.
Examples:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgBlueValue(), PgCMY(), PgGreenValue(), PgHSV(), PgRedValue(),
PgSetFillColor(), PgSetFillDither()
Synopsis:
PgColorHSV t PgRGB2HSV( PgColor t rgb color );
Description:
This function converts composite color values into
hue-saturation-value.
If you write a color selection function that allows the user to change
RGB and HSV values, you should maintain the RGB and HSV values
separately. So if the user changes the RGB value, you would use
PgRGB2HSV() to calculate the new HSV value. For example:
☞ When you convert RGB values into HSV, colors close to black, white,
or gray might not convert to correct hue values.
Returns:
A hue-saturation-value value.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor t, PgColorHSV t, PgHSV(), PgHSV2RGB(),
PgSetFillColor()
Synopsis:
void PgSetClipping( unsigned short n,
PhRect t const *rects );
Description:
This function lets you limit the extent of drawing by specifying which
rectangles to draw in. Note that you can never draw outside of the
current region.
The n argument contains the number of clip rectangles; rects contains
an array of n clip rectangles, relative to the origin of the current
region. To reset the clipping rectangle to the full size of the region,
you should pass 0 rectangles.
All subsequent draws will be clipped to the intersection of the
clipping rectangles set by PgSetClipping(), PgSetMultiClip(), and
PgSetUserClip(), and PgSetRegion().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgFlush(), PgSetMultiClip(), PgSetRegion(), PgSetUserClip(),
PhAttach(), PhReattach()
PtClipAdd(), PtClipRemove() in the Building Custom Widgets guide.
Synopsis:
int PgSetDrawBufferSize(
unsigned short cmd buf len );
Description:
This function resizes the current draw buffer. The default size,
allocated with every PhAttach(), is at least 1K. The draw buffer stores
all drawing data except for data stored in shared memory.
If the draw buffer contains unflushed data when this function is called,
the function will flush the data before reallocating the buffer.
Returns:
0 Success.
-1 An error occurred.
Examples:
// Allocate a 16K draw buffer
PgSetDrawBufferSize( 16 * 1024 );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgClearDrawBuffer(), PgFlush(), PhAttach(), PhGetMsgSize()
Synopsis:
int PgSetDrawMode( int mode );
Description:
This function controls how pixels are combined with video memory.
You can set mode to one of the following:
☞ The effect of this function depends on the physical video mode. If the
video mode is “true color,” the RGB value being drawn will modify
the RGB value of the pixel that’s in video memory. If the video mode
is palette based, the palette index of the draw color will modify the
palette index of the pixel that’s in video memory.
To facilitate XOR drawing, you can use the special draw color
Pg INVERT COLOR. This color remains highly visible regardless of
video mode (see PgSetFillColor()). If the video mode is true color,
the graphics driver will XOR the screen pixels with pure white. If the
video mode is palette based, the driver will invert the pixel index.
Returns:
The previous drawing mode.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultFill(), PgDefaultMode(), PgSetFillColor(),
PgSetFillDither(), PgSetFillTransPat(), PgSetFillXORColor(),
PgSetStrokeColor(), PgSetStrokeDither(), PgSetStrokeTransPat(),
PgSetStrokeXORColor(), PgSetTextColor(), PgSetTextDither(),
PgSetTextTransPat(), PgSetTextXORColor()
Synopsis:
PgColor t PgSetFillColor( PgColor t color );
Description:
This function sets the fill color used for subsequent draws. If the
driver doesn’t support 24-bit color, it selects the nearest color
available to the one requested. If you OR the color with
Pg MIX COLOR, most drivers try to mix two available colors to
produce the requested color.
This function overrides the color defined by PgSetFillDither().
Returns:
The previous color.
Examples:
// Set draw color to white
PgSetFillColor( Pg WHITE );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgCMY(), PgColor t, PgDefaultFill(), PgGray(), PgHSV(),
PgRGB(), PgSetDrawMode(), PgSetFillDither(), PgSetFillTransPat(),
PgSetFillXORColor(), PgSetStrokeColor(), PgSetTextColor()
Synopsis:
void PgSetFillDither( PgColor t c1,
PgColor t c0,
PgPattern t pat );
Description:
This function combines two colors according to the pattern defined by
pat and applies the pattern to fills.
The c1 argument represents the color used for “on” bits in the dither
pattern and c0 represents the color used for “off” bits. The driver
always selects the colors closest to c1 and c0.
The dither pattern is an array of 8 bytes, aligned with the upper-left
corner of the application’s region. This pattern repeats itself every 8
pixels horizontally and every 8 pixels vertically.
This function overrides the color defined by the appropriate
PgSetFillColor() function. For basic colors, see PgColor t.
At least the following patterns are defined in <photon/Pg.h>:
Examples:
// Set the fill to be black with every 8th
// vertical line being white
PgSetFillDither( Pg WHITE, Pg BLACK, Pg PAT VERT8 );
DithersListStruct DithersList[] = {
"Pg PAT DEFAULT", Pg PAT DEFAULT,
"Pg PAT HALF", Pg PAT HALF,
"Pg PAT BACK HALF", Pg PAT BACK HALF,
"Pg PAT CHECKB8", Pg PAT CHECKB8,
"Pg PAT CHECKB4", Pg PAT CHECKB4,
"Pg PAT DIAMOND", Pg PAT DIAMOND,
"Pg PAT HORIZ8", Pg PAT HORIZ8,
"Pg PAT HORIZ4", Pg PAT HORIZ4,
"Pg PAT HORIZ2", Pg PAT HORIZ2,
"Pg PAT VERT8", Pg PAT VERT8,
"Pg PAT VERT4", Pg PAT VERT4,
"Pg PAT VERT2", Pg PAT VERT2,
"Pg PAT DIAGF8", Pg PAT DIAGF8,
"Pg PAT DIAGF4", Pg PAT DIAGF4,
"Pg PAT DIAGB8", Pg PAT DIAGB8,
"Pg PAT DIAGB4", Pg PAT DIAGB4,
"Pg PAT BRICK", Pg PAT BRICK,
"Pg PAT WEAVE", Pg PAT WEAVE,
"Pg PAT RXHATCH8", Pg PAT RXHATCH8,
"Pg PAT RXHATCH4", Pg PAT RXHATCH4,
"Pg PAT RXHATCH2", Pg PAT RXHATCH2,
"Pg PAT DXHATCH8", Pg PAT DXHATCH8,
"Pg PAT DXHATCH4", Pg PAT DXHATCH4,
};
#define DithersListNum \
(sizeof( DithersList ) / sizeof( DithersListStruct ) )
#define DithersListCHeight 20
#define DithersListWinY (DithersListNum*DithersListCHeight)
Dithers() {
DithersListStruct *DLPtr = DithersList;
PhPoint t p;
PhRect t r;
int i, y;
PgSetFont( "helv14b" );
PgSetTextColor( Pg BLACK );
PgSetStrokeColor( Pg BLACK );
for (y=i=0; i<DithersListNum;
i++, y+=DithersListCHeight, DLPtr++) {
p.x = 2;
p.y = y+14;
PgDrawText( DLPtr->name,
strlen( DLPtr->name ), &p, 0 );
PgSetFillDither( Pg WHITE, Pg DBLUE, DLPtr->p );
r.ul.x = 160; r.lr.x = 320;
r.ul.y = y; r.lr.y = y+DithersListCHeight;
PgDrawRect( &r, Pg DRAW FILL STROKE );
}
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgCMY(), PgColor t, PgDefaultFill(), PgGray(), PgHSV(),
PgRGB(), PgSetFillColor(), PgSetFillTransPat(),
PgSetFillXORColor(), PgSetStrokeDither(), PgSetTextDither()
Synopsis:
void PgSetFillTransPat( PgPattern t pat );
Description:
This function sets a masking pattern and applies it to fills. You should
use it in combination with PgSetFillColor() or PgSetFillDither().
This function uses the same patterns as PgSetFillDither(), To disable
transparency and draw normally, specify the Pg PAT DEFAULT
pattern.
Examples:
// let background show through for half the pixels
PgSetFillTransPat( Pg PAT HALF );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultFill(), PgSetDrawMode(), PgSetFillColor(),
PgSetFillDither(), PgSetFillXORColor(), PgSetStrokeTransPat(),
PgSetTextTransPat()
Synopsis:
void PgSetFillXORColor( PgColor t frgd,
PgColor t bkgd );
Description:
This function sets the draw color for fills. When an application XORs
this color with the color bkgd, the result is the color frgd.
Since XOR is a reflexive function, frgd and bkgd may be reversed.
Examples:
The following example:
DrawXOR() {
char *s = "Hello World!";
PhPoint t p = { 8, 30 };
PhRect t r;
PgSetFont( "helv18" );
PgSetTextColor( Pg YELLOW );
PgSetFillColor( Pg PURPLE );
PgDrawText( s, strlen( s ), &p, Pg BACK FILL );
PgExtentText( &r, &p, "helv18", s, strlen( s ) );
r.lr.x -= (r.lr.x - r.ul.x) / 2;
PgSetDrawMode( Pg DRAWMODE XOR );
PgSetFillXORColor( Pg YELLOW, Pg PURPLE );
PgDrawRect( &r, Pg DRAW FILL );
PgSetDrawMode( Pg DRAWMODE OPAQUE );
}
will draw:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor t, PgDefaultFill(), PgSetDrawMode(), PgSetFillColor(),
PgSetFillDither(), PgSetFillTransPat(), PgSetStrokeXORColor(),
PgSetTextXORColor()
Synopsis:
void PgSetFont( char const *font file );
Description:
This function sets the font for text subsequently drawn with
PgDrawText() or PgDrawString(). Font names are in the format:
face size [style]
where face refers to the face of the font. For example:
cour Courier
helv Helvetica
ncen New Century Schoolbook
time Times Roman
lu Lucida
lut Lucida Terminal
lub Lucida Bright
swiss Swiss 721 (a scalable font)
a anti-aliased
b bold
i italic
Examples:
// use Helvetica, 12p, Normal
PgSetFont( "helv12" );
// use Helvetica, 14p, Bold Italic
PgSetFont( "helv14bi" );
// use Times Roman, 24p, Italic
PgSetFont( "time24i" );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawString(), PgDrawText(), PgSetFillColor(), PgSetFillDither(),
PgSetFillTransPat(), PgSetUnderline()
Synopsis:
PhGC t *PgSetGC( PhGC t *GC );
Description:
This function sets the current graphics context to GC.
Returns:
A pointer to the previous graphics context.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgCreateGC(), PgDestroyGC(), PgGetGC()
Synopsis:
int PgSetMultiClip( int num,
PhRect t const *clip list );
Description:
This function sets a list of rectangles to clip subsequent drawing
operations. The rectangles are always relative to the origin of the
current region. To disable this clipping, set clip list to NULL or num
to 0.
All subsequent drawing operations will be clipped to the intersection
of the clipping rectangles set by PgSetClipping(), PgSetMultiClip(),
and PgSetUserClip().
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgSetClipping(), PgSetUserClip(), PgSetClipping(), PgSetUserClip()
Synopsis:
int PgSetPalette( PgColor t const *palette,
long palette id,
short first color,
short num colors,
int flags,
long tag );
Description:
This function sets the palette for subsequent draw commands. The
palette can be either the graphics driver’s palette, or a private
hardware or software palette. The palette argument points to a static
buffer containing the palette; first color denotes the first color to set,
and num colors defines how many palette entries to set.
The graphics driver uses the palette id tag for caching. If the
palette id is 0, the tag will be used, as long as it is not 0 as well. If
palette id and tag are both 0, your region’s unique number is used as
the palette ID. To have the graphics driver release a cached palette, set
num colors to -1,
A palette can operate in one of several modes. To determine the
mode, set flags to one of the following:
Pg PALSET HARD
Used primarily for palette-based images; see PhImage t.
Setting this palette type changes the physical palette. All colors
set with a PgSet...Color() function will be chosen from this
palette, for this process only. Other processes will continue to
choose colors from the global palette and may appear incorrect.
When you release the hardware palette, the other processes will
return to their previous colors without being redrawn. You
should always release the hardware palette when your window
loses focus.
You can OR the above palette types with Pg PALSET FORCE EXPOSE
to force an expose from the graphics driver. This is useful when
changing palettes; the expose causes all applications to redraw with
the new palette.
The tag argument is used for data caching by programs such as
phrelay. To calculate the tag, use PxCRC(). This argument is
ignored if you set it to 0.
Returns:
0 Success.
-1 The draw buffer is too small to hold the current draw state and
the draw command.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawImage(), PgSetFillColor(), PgSetStrokeColor(),
PgSetTextColor(), PhImage t, PxCRC()
Synopsis:
unsigned long PgSetPlaneMask( unsigned long mask);
Description:
This function protects planes of video memory from being modified.
Each bit in the specified mask corresponds to a plane of video
memory: a value of 0 enables access to the plane, a value of 1 protects
the plane.
☞ The effect of this function depends on the physical video mode. If the
video mode is “true color,” the mask will protect parts of the RGB
value of the pixel that’s in video memory. If the video mode is palette
based, the mask will protect parts of the palette index of the pixel
that’s in video memory.
This function works only on some 8-bit drivers.
Returns:
The previous mask.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultMode(), PgSetFillColor(), PgSetStrokeColor(),
PgSetTextColor()
Synopsis:
void PgSetRegion( PhRid t rid );
Description:
This function determines which region will emit subsequent draw
events. It also resets the clipping rectangle to the full size of the
region. Note that all draws are clipped to the region that emits them.
If the draw buffer contains unflushed data when this function is called,
the function will flush the data before changing the current region.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgFlush(), PgSetClipping()
Synopsis:
int PgSetStrokeCap( int cap );
Description:
This function determines how the ends of thick lines are drawn. You
can set cap to one of the following:
Pg_BUTT_CAP
Pg_POINT_CAP
Pg_ROUND_CAP
Pg_SQUARE_CAP
☞ The dotted lines in the above examples were added to illustrate how
the caps relate to the original lines; they don’t normally appear.
Returns:
The previous cap value.
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PgDefaultStroke(), PgDrawEllipse(), PgDrawLine(),
PgDrawPolygon(), PgDrawRect(), PgDrawRoundRect(),
PgSetDrawMode(), PgSetStrokeDash(), PgSetStrokeDither(),
PgSetStrokeJoin(), PgSetStrokeTransPat(), PgSetStrokeWidth(),
PgSetStrokeXORColor(),
Synopsis:
PgColor t PgSetStrokeColor( PgColor t color );
Description:
This function sets the stroke color used for subsequent draws.
If the driver doesn’t support 24-bit color, it selects the nearest color
available to the one requested. If you OR the color with
Pg MIX COLOR, most drivers try to mix two available colors to
produce the requested color.
This function overrides the color defined by PgSetStrokeDither().
Returns:
The previous color.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgCMY(), PgColor t, PgDefaultStroke(), PgGray(), PgHSV(),
PgRGB(), PgSetDrawMode(), PgSetFillColor(), PgSetStrokeCap(),
PgSetStrokeDash(), PgSetStrokeDither(), PgSetStrokeJoin(),
PgSetStrokeTransPat(), PgSetStrokeWidth(), PgSetStrokeXORColor(),
PgSetTextColor()
Synopsis:
void PgSetStrokeDash( unsigned char const *DashList,
int ListLen,
long DashScale );
Description:
This function defines a dash list that’s used to draw lines. The
DashList argument points to an array of up to 16 characters. The
values alternate between stroke values and space values: the first
value defines a stroke length, the next defines a space length, the next
after that defines a stroke length, and so on.
The values in DashList are scaled by the DashScale argument, which
is 16.16 fixed point. The upper 16 bits are the integer part and the
lower 16 the fractional part. The fractional part is in 65536ths, not
10ths, 100ths, etc.
For example, to specify a decimal scaling factor of 1.5:
Examples:
The following example:
typedef struct {
char *name;
int l;
char *p;
} DashListStruct;
DashListStruct DashList[] = {
"solid", 0, NULL,
"dotted", 1, "\1",
"bigger dots", 1, "\2",
"dashed", 2, "\10\4",
"long dash", 2, "\40\4",
"dash dot dot", 6, "\40\2\1\2\1\2",
"long pattern", 16,
"\3\2\5\2\10\2\13\2\15\2\13\2\10\2\5\2",
"complex", 7, "\20\1\14\2\11\3\6",
};
#define DashListNum \
(sizeof( DashList ) / sizeof( DashListStruct ))
#define DashListCHeight 20
#define DashListWinY \
(DashListNum*DashListCHeight)
Dashes() {
DashListStruct *DLPtr = DashList;
PhPoint t p;
PhRect t r;
int i, y;
PgSetFont( "helv14b" );
PgSetTextColor( Pg WHITE );
PgSetStrokeColor( Pg WHITE );
for (y=i=0; i<DashListNum; i++,
y+=DashListCHeight, DLPtr++) {
p.x = 2;
p.y = y+14;
PgDrawText( DLPtr->name, strlen( DLPtr->name ),
&p, 0 );
PgSetStrokeDash( DLPtr->p, DLPtr->l, 0x10000 );
PgSetFillDither( Pg WHITE, Pg DBLUE, DLPtr->p );
PgDrawILine( 100, y+(DithersListCHeight/2),
320, y+(DithersListCHeight/2) );
}
}
will draw:
solid
dotted
bigger dots
dashed
long dash
dash dot dot
long pattern
complex
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultStroke(), PgDrawLine(), PgDrawPolygon(), PgDrawRect(),
PgSetDrawMode(), PgSetStrokeCap(), PgSetStrokeDither(),
PgSetStrokeJoin(), PgSetStrokeTransPat(), PgSetStrokeWidth(),
PgSetStrokeXORColor()
Synopsis:
void PgSetStrokeDither( PgColor t c1,
PgColor t c0,
PgPattern t pat );
Description:
This function combines two colors according to the pattern defined by
pat and applies the pattern to outlines.
The c1 argument represents the color used for “on” bits in the dither
pattern and c0 represents the color used for “off” bits. The driver
always selects the colors closest to c1 and c0.
The dither pattern is an array of 8 bytes, aligned with the upper-left
corner of the application’s region. This pattern repeats itself every 8
pixels horizontally and every 8 pixels vertically. For a sample of
dither patterns, see PgSetFillDither().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgCMY(), PgColor t, PgDefaultStroke(), PgGray(), PgHSV(),
PgRGB(), PgSetDrawMode(), PgSetFillDither(), PgSetStrokeCap(),
PgSetStrokeColor(), PgSetStrokeDash(), PgSetStrokeJoin(),
PgSetStrokeTransPat(), PgSetStrokeWidth(), PgSetStrokeXORColor(),
PgSetTextDither()
Synopsis:
int PgSetStrokeJoin( int join );
Description:
This function determines how thick lines are connected. You can set
join to one of the following:
Pg_BEVEL_JOIN
Pg_BUTT_JOIN
Pg_MITER_JOIN
Pg_QROUND_JOIN
Pg_ROUND_JOIN
☞ The dotted lines in the above examples were added to illustrate how
the joints relate to the original lines; they do not normally appear.
Returns:
The previous join value.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultStroke(), PgDrawEllipse(), PgDrawLine(),
PgDrawPolygon(), PgDrawRect(), PgDrawRoundRect(),
PgSetDrawMode(), PgSetStrokeCap(), PgSetStrokeColor(),
PgSetStrokeDash(), PgSetStrokeDither() PgSetStrokeTransPat(),
PgSetStrokeWidth(), PgSetStrokeXORColor(),
Synopsis:
void PgSetStrokeTransPat( PgPattern t pat );
Description:
This function sets a masking pattern and applies it to outlines. You
should use it in combination with PgSetStrokeColor() or
PgSetStrokeDither().
This function uses the same patterns as PgSetFillDither(). To disable
transparency and draw normally, specify the Pg PAT DEFAULT
pattern.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultStroke(), PgSetDrawMode(), PgSetFillTransPat(),
PgSetStrokeCap(), PgSetStrokeColor(), PgSetStrokeDash(),
PgSetStrokeDither(), PgSetStrokeJoin(), PgSetStrokeWidth(),
PgSetStrokeXORColor(), PgSetTextTransPat()
Description:
These functions set the thickness of lines.
If you call PgSetStrokeWidth(), the width argument takes an integer
that indicates the width of the line in pixels. But if you call
PgSetStrokeFWidth(), the width argument takes a pixel width
multiplied by 65,536 (0x10000). For example, specifying a value of
0x80000 will set the line width to 8 pixels.
Returns:
The previous width.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Caveats:
We don’t recommend using a line width greater than one pixel. Some
graphics drivers might give unexpected results.
Synopsis:
void PgSetStrokeXORColor( PgColor t frgd,
PgColor t bkgd );
Description:
This function sets the draw color for outlines. When an application
XORs this color with the color bkgd, the result is the color frgd.
Since XOR is a reflexive function, frgd and bkgd may be reversed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor t, PgDefaultStroke(), PgSetDrawMode(),
PgSetFillXORColor(), PgSetStrokeCap(), PgSetStrokeColor(),
PgSetStrokeDash(), PgSetStrokeDither(), PgSetStrokeJoin(),
PgSetStrokeTransPat(), PgSetStrokeWidth(), PgSetTextXORColor()
Synopsis:
PgColor t PgSetTextColor( PgColor t color );
Description:
This function sets the color used for text and bitmaps in subsequent
draws.
If the driver doesn’t support 24-bit color, it selects the nearest color
available to the one requested. If you OR the color with
Pg MIX COLOR, most drivers try to mix two available colors to
produce the requested color.
This function overrides the color defined by PgSetTextDither().
Returns:
The previous color.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgCMY(), PgColor t, PgDefaultText(), PgDrawString(),
PgDrawText(), PgDrawTextArea(), PgExtentText(), PgGray(),
PgHSV(), PgRGB(), PgSetDrawMode(), PgSetFillColor(),
PgSetStrokeColor(), PgSetTextDither(), PgSetTextTransPat(),
PgSetTextXORColor(), PgSetUnderline()
Synopsis:
void PgSetTextDither( PgColor t c1,
PgColor t c0,
PgPattern t pat );
Description:
This function combines two colors according to the pattern defined by
pat and applies the pattern to text and bitmaps.
The c1 argument represents the color used for “on” bits in the dither
pattern and c0 represents the color used for “off” bits. The driver
always selects the colors closest to c1 and c0.
The dither pattern is an array of 8 bytes, aligned with the upper-left
corner of the application’s region. This pattern repeats itself every 8
pixels horizontally and every 8 pixels vertically. For a sample of
dither patterns, see PgSetFillDither().
This function overrides the color defined by PgSetTextColor(). For
basic colors, see PgColor t.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor t, PgDefaultText(), PgDrawString(), PgDrawText(),
PgDrawTextArea(), PgExtentText(), PgGray(), PgHSV(), PgRGB(),
PgSetDrawMode(), PgSetFillDither(), PgSetStrokeDither(),
Synopsis:
void PgSetTextTransPat( PgPattern t pat );
Description:
This function sets a masking pattern and applies it to text and
bitmaps. You should use it in combination with PgSetTextColor() or
PgSetTextDither().
This function uses the same patterns as PgSetFillDither(). To disable
transparency and draw normally, specify the Pg PAT DEFAULT
pattern.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultText(), PgDrawString(), PgDrawText(), PgDrawTextArea(),
PgExtentText(), PgGray(), PgHSV(), PgRGB(), PgSetDrawMode(),
PgSetFillTransPat(), PgSetStrokeTransPat(), PgSetTextColor(),
PgSetTextDither(), PgSetTextXORColor(), PgSetUnderline()
Synopsis:
void PgSetTextXORColor( PgColor t frgd,
PgColor t bkgd );
Description:
This function sets the draw color for text and bitmaps. When an
application XORs this color with the color bkgd, the result is the color
frgd.
Since XOR is a reflexive function, frgd and bkgd may be reversed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor t, PgDefaultText(), PgDrawString(), PgDrawText(),
PgDrawTextArea(), PgExtentText(), PgSetDrawMode(),
PgSetFillXORColor(), PgSetStrokeXORColor(), PgSetTextColor(),
PgSetTextDither(), PgSetTextTransPat(), PgSetUnderline()
Synopsis:
void PgSetTranslation ( PhPoint t const *translation,
int flags );
Description:
This function causes all subsequent draw commands to be translated
by translation->x pixels horizontally and translation->y pixels
vertically. The default translation is (0,0). You can set flags to:
Examples:
Draw a square from (100,100) to (200,200):
PhPoint t translation;
PgSetFillColor( Pg RED );
translation.x = translation.y = 100;
PgSetTranslation( &translation, Pg RELATIVE );
PgDrawIRect( 0, 0, 100, 100, Pg DRAW FILL );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgClearTranslation()
Synopsis:
void PgSetUnderline( PgColor t c1,
PgColor t c2,
int flags );
Description:
This function sets the color or colors used for underlining text:
c1 c2 Underline
Pg TRANSPARENT N/A Disabled
Any color Pg TRANSPARENT Single underline
Any color Any color Double underline
¯ PgDrawString()
¯ PgDrawText()
¯ PgDrawTextArea()
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PgColor t, PgDefaultText(), PgDrawString(), PgDrawText(),
PgDrawTextArea(), PgExtentText(), PgSetDrawMode(),
PgSetTextColor(), PgSetTextDither(), PgSetTextTransPat(),
PgSetTextXORColor()
Synopsis:
void PgSetUserClip( PhRect t const *ClipRect );
Description:
These functions restrict all subsequent draws to the area defined by
ClipRect. To disable the user clipping rectangle, pass ClipRect as
NULL.
PgSetUserClip() sets the user clipping rectangle relative to the current
translation whereas PgSetUserClipAbsolute() sets the rectangle
independent of the current translation.
The user clipping area is set independent of the clipping that’s set by
PgSetClipping() and PgSetMultiClip().
All subsequent draws will be clipped to the intersection of the
clipping rectangles set by PgSetClipping(), PgSetMultiClip(), and
PgSetUserClip().
Unlike PgSetClipping(), these functions don’t flush the draw buffer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
continued. . .
Safety
Thread No
See also:
PgClearTranslation(), PgSetClipping(), PgSetMultiClip(),
PgSetTranslation(), PhAttach(), PhReattach(), PgSetRegion()
Synopsis:
int PgShmemAttach( char const *name,
unsigned long size,
void *addr );
Description:
This function records a reference to an existing block of shared
memory (that is, a block created with shm open(), sized with ltrunc(),
and mapped into the process’s address space with mmap()).
PgShmemCleanup() is called automatically by atexit() when your
program terminates normally. If your program terminates abnormally,
it should call PgShmemCleanup() explicitly.
Returns:
0 Successful completion.
Errors:
See the errors for shm open() in the C Library Reference.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawBitmapmx(), PgDrawImagemx(), PgShmemCleanup(),
PgShmemCreate(), PgShmemDestroy(), PgShmemDetach()
shm open(), ltrunc(), mmap() in the C Library Reference
Synopsis:
void PgShmemCleanup();
Description:
This function removes all shared memory references defined with
PgShmemCreate() and PgShmemAttach(). If the block was created
with PgShmemCreate(), the block will be unlinked.
PgShmemCleanup() is called automatically by atexit() when your
program terminates normally. If your program terminates abnormally,
it should call PgShmemCleanup() explicitly.
Examples:
This code fragment shows how you can use PgShmemCleanup() in a
signal handler:
main( ... ) {
.
.
.
signal( SIGTERM, ExitCleanup );
signal( SIGHUP, ExitCleanup );
signal( SIGQUIT, ExitCleanup );
signal( SIGINT, ExitCleanup );
/* main loop */
.
.
.
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgShmemAttach(), PgShmemCreate()
atexit() in the C Library Reference
Synopsis:
void *PgShmemCreate( unsigned long size,
char const *name );
Description:
This function creates a block of shared memory. The size argument
determines the size of the block.
If you pass name as NULL, this function will generate a unique name
in the form Pg########; this is the preferred mode of operation. If
you pass a name, make sure that it isn’t already in use.
☞ You must use the “mx” form of a draw function to pass the shared
memory reference. Otherwise, the data is copied into the draw event.
Returns:
A local pointer to shared memory. If an error occurs, it returns NULL
and sets errno.
Errors:
See the errors for shm open() in the C Library Reference.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
continued. . .
Safety
Thread No
See also:
PgDrawBitmapmx(), PgDrawImagemx(), PgShmemAttach(),
PgShmemCleanup(), PgShmemDestroy(), PgShmemDetach()
Synopsis:
int PgShmemDestroy( void *addr );
Description:
This function removes a block of shared memory created with
PgShmemCreate() The block is referenced by the address returned
from PgShmemCreate().
Returns:
0 Successful completion.
Errors:
See the errors for shm unlink() in the C Library Reference.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgShmemCreate()
Synopsis:
int PgShmemDetach( void *addr );
Description:
This function removes a shared memory reference previously attached
with PgShmemAttach().
Returns:
0 Successful completion.
Errors:
See the errors for shm unlink() in the C Library Reference.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgShmemAttach()
Synopsis:
PhTile t * PhAddMergeTiles( PhTile t *tiles,
PhTile t *add tiles,
int *added );
Description:
PhAddMergeTiles() merges the list of tiles pointed to by add tiles into
the list pointed to by tiles and returns a pointer to the resulting list.
This function makes sure that the tiles don’t overlap.
Returns:
A pointer to the merged list. This isn’t always the same as the tiles
pointer.
☞ Don’t free() the list of tiles; instead, use PhFreeTiles() to return the
tiles to the internal pool.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhClipTilings(), PhCoalesceTiles(), PhCopyTiles(),
PhDeTranslateTiles(), PhFreeTiles(), PhGetTile(),
Synopsis:
typedef struct Ph area {
PhPoint t pos;
PhDim t size;
} PhArea t;
Description:
The PhArea t structure describes the position and dimensions of a
rectangular area. It’s used extensively by the widget (Pt*()) functions
(see the Photon Widget Reference). This structure contains at least the
following members:
Classification:
Photon
See also:
PhDim t, PhPoint t
Synopsis:
struct Ph ctrl *PhAttach(
char const *name,
PhChannelParms t const *parms );
Description:
This function opens a communications channel to a Photon Manager.
The channel becomes the current channel.
☞ The application must call the PhAttach() function before it calls any
other Photon functions. Both PtInit() and PtAppInit() invoke this
function.
mpid t proxy;
unsigned long max q entries;
unsigned long flags;
where:
proxy Your own proxy instead of the one that the channel
would otherwise obtain. This member is valid
only if you set the Ph NO PROXY bit in flags.
Returns:
A pointer to a control structure.
Examples:
promiscuous call( void )
{
struct Ph ctrl *ph1, *ph2, *ph3;
PhReattach( ph1 );
printf( "ph1 is the current channel again\n" );
PhDetach( ph1 );
printf( "there is no current channel\n" );
PhReattach( ph3 );
printf( "ph3 is the current channel again\n" );
PhDetach( ph2 );
PhDetach( ph3 );
printf( "all Photon channels closed\n" );
return( 0 );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgSetDrawBufferSize(), PhDetach(), PhEventNext(), PhEventArm(),
PhEventRead(), PhGetMsgSize(), PhReattach(), PtInit(), PtAppInit()
Synopsis:
int PhBlit( PhRid t rid,
const PhRect t *rect,
const PhPoint t *offset );
Description:
This function “blits” the area that is defined by rect and whose origin
is defined by the origin of the region specified by rid. The area is
blitted by the given offset. Other windows aren’t affected by the blit.
Returns:
0 Success.
Examples:
PhRect t rect = { 10,10,20,20};
PhPoint t offset = { -5, 5 };
PhRect t exposed = { 15, 10, 20, 15 };
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetRid()
Synopsis:
int PhChannelAttach( int channel,
int connection,
struct sigevent t const *event );
Description:
Use this function if you want the library to create a channel or use a
channel that you’ve created.
Returns:
A channel ID, or -1 on error (errno is set).
Errors:
EBUSY A channel is already attached and chid is nonzero
and differs from the current channel ID, or
connection isn’t -1 and differs from the currently
used connection
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PhClipboardCopy( unsigned short ig,
int n,
PhClipHeader const clip[] );
Description:
This function copies data to the clipboard. Each input group has its
own private clipboard, which can be selected through the ig
parameter. You can determine the current input group as follows:
¯ If you have the event that triggered the clipboard operation, use its
input group (e.g. cbinfo->event->input group) if it’s nonzero.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PhClipboardCopy(), PhClipboardCopyString(),
PhClipboardPasteFinish(), PhClipboardPasteStart(),
PhClipboardPasteString(), PhClipboardPasteType(),
PhClipboardPasteTypeN(), PhClipHeader
Synopsis:
int PhClipboardCopyString( unsigned short ig,
const char *string );
Description:
This function is a simple cover function for copying string-only data
to the clipboard. It builds a PhClipHeader entry:
¯ If you have the event that triggered the clipboard operation, use its
input group (e.g. cbinfo->event->input group) if it’s nonzero.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhClipboardCopy(), PhClipboardPasteFinish(),
PhClipboardPasteStart(), PhClipboardPasteString(),
PhClipboardPasteType(), PhClipboardPasteTypeN(), PhClipHeader
Synopsis:
void PhClipboardPasteFinish( void *cbdata );
Description:
This function releases all memory associated with the current paste
operation (begun with PhClipboardPasteStart()). The cbdata
argument is the pointer returned by PhClipboardPasteStart().
PhClipboardPasteFinish() function should be called only after all
paste operations have been completed and the required data has been
extracted from the clipboard.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhClipboardCopy(), PhClipboardCopyString(),
PhClipboardPasteStart(), PhClipboardPasteString(),
PhClipboardPasteType(), PhClipboardPasteTypeN(), PhClipHeader
Synopsis:
void *PhClipboardPasteStart( unsigned short ig );
Description:
Call this function to begin a paste operation from the clipboard
associated with the given input group ig. You can determine the
current input group as follows:
¯ If you have the event that triggered the clipboard operation, use its
input group (e.g. cbinfo->event->input group) if it’s nonzero.
Returns:
A pointer to an internal structure describing the clipboard data, or
NULL if an error occurred. The pointer must be passed to
PhClipboardPasteType() and PhClipboardPasteFinish().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhClipboardCopy(), PhClipboardCopyString(),
PhClipboardPasteFinish(), PhClipboardPasteString(),
PhClipboardPasteType(), PhClipboardPasteTypeN(), PhClipHeader
Synopsis:
char *PhClipboardPasteString( unsigned short ig );
Description:
This function is a simple cover function for pasting string-only data
from the clipboard. The function calls PhClipboardPasteStart(),
requests data of type TEXT using PhClipboardPasteType(), and
finishes with PhClipboardPasteFinish().
Each input group has its own private clipboard, which you can select
through the ig parameter. You can determine the current input group
as follows:
¯ If you have the event that triggered the clipboard operation, use its
input group (e.g. cbinfo->event->input group) if it’s nonzero.
Returns:
A pointer to the text string extracted from the clipboard, or NULL if
there was no available data or an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
continued. . .
Safety
Thread No
See also:
PhClipboardCopy(), PhClipboardCopyString(),
PhClipboardPasteFinish(), PhClipboardPasteStart(),
PhClipboardPasteType(), PhClipboardPasteTypeN(), PhClipHeader
strdup(), free() in the QNX 4 C Library Reference
Synopsis:
PhClipHeader *PhClipboardPasteType(
void *cbdata,
PhClipType type );
Description:
This function searches the clipboard data for an entry of the specified
type (an 8-character string, such as TEXT). The cbdata argument is the
pointer returned by PhClipboardPasteStart().
Returns:
A pointer to a header structure describing the requested data, or NULL
if no matching type was located on the clipboard. For more
information, see PhClipHeader.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhClipboardCopy(), PhClipboardCopyString(),
PhClipboardPasteFinish(), PhClipboardPasteStart(),
PhClipboardPasteString(), PhClipboardPasteTypeN(),
PhClipHeader
Synopsis:
PhClipHeader *PhClipboardPasteTypeN( void *cbdata,
int n);
Description:
This function searches the clipboard data for the nth entry and returns
a header structure to it. This allows clipboard-viewing applications to
obtain all data types from the clipboard without prior knowledge of
the types.
The cbdata argument is the pointer returned by
PhClipboardPasteStart().
Returns:
A pointer to a header structure describing the requested data, or NULL
if no matching type was located on the clipboard. For more
information, see PhClipHeader.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhClipboardCopy(), PhClipboardCopyString(),
PhClipboardPasteFinish(), PhClipboardPasteStart(),
PhClipboardPasteString(), PhClipboardPasteType(), PhClipHeader
Synopsis:
typedef char PhClipType[8];
typedef struct {
PhClipType type;
unsigned short length;
void *data;
} PhClipHeader;
Description:
This data structure describes clipboard data. Its members include:
Classification:
Photon
See also:
PhClipboardCopy(), PhClipboardCopyString(),
PhClipboardPasteFinish(), PhClipboardPasteStart(),
PhClipboardPasteString(), PhClipboardPasteType(),
PhClipboardPasteTypeN()
Synopsis:
PhTile t *PhClipTilings(
PhTile t *tiles,
PhTile t const * const clip tiles,
PhTile t **intersection );
Description:
This function clips the list of tiles pointed to by clip tiles from the list
pointed to by tiles. If intersection isn’t NULL, it’s set to point to the
list of intersections that are clipped out of the tiles list.
The clip tiles list isn’t modified.
☞ Don’t free() a list of tiles; instead, use PhFreeTiles() to return the tiles
to the internal pool.
Returns:
A pointer to the clipped list of tiles, or NULL if clip tiles encompasses
tiles.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAddMergeTiles(), PhCoalesceTiles(), PhCopyTiles(),
PhDeTranslateTiles(), PhFreeTiles(), PhGetTile(),
PhIntersectTilings(), PhMergeTiles(), PhRectsToTiles(),
PhSortTiles(), PhTile t, PhTilesToRects(), PhTranslateTiles()
Synopsis:
PhTile t * PhCoalesceTiles( PhTile t *tiles );
Description:
PhCoalesceTiles() combines the tiles in the list pointed to by tiles as
much as possible. This function works best on a sorted, merged list of
tiles.
☞ Don’t free() the list of tiles; instead, use PhFreeTiles() to return the
tiles to the internal pool.
Returns:
A pointer to the list, which is always the same as the pointer given.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAddMergeTiles(), PhClipTilings(), PhCopyTiles(),
PhDeTranslateTiles(), PhFreeTiles(), PhGetTile(),
PhIntersectTilings(), PhMergeTiles(), PhRectsToTiles(),
PhSortTiles(), PhTile t, PhTilesToRects(), PhTranslateTiles()
Synopsis:
PhTile t * PhCopyTiles( PhTile t const * const tile );
Description:
This function creates a copy of the list of tiles pointed to by tile.
☞ Don’t free() the list of tiles; instead, use PhFreeTiles() to return the
tiles to the internal pool.
Returns:
A pointer to the copy.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAddMergeTiles(), PhClipTilings(), PhCoalesceTiles(),
PhDeTranslateTiles(), PhFreeTiles(), PhGetTile(),
PhIntersectTilings(), PhMergeTiles(), PhRectsToTiles(),
PhSortTiles(), PhTile t, PhTilesToRects(), PhTranslateTiles()
Synopsis:
PhDrawContext t *PhDCGetCurrent( void );
Description:
This function returns a pointer to the currently active draw context,
which may be a print context, memory context, or draw context.
Returns:
A pointer to the currently active draw context.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhDCSetCurrent()
Synopsis:
PhDrawContext t *PhDCSetCurrent(
void *draw context );
Description:
This function makes the provided draw context active. Calling this
function with NULL makes the default draw context active. The
default draw context emits draws to graphics drivers via Photon.
A draw context is anything that defines the flow of the draw stream.
Print Contexts and Memory contexts are types of draw contexts — it
may help to think of them as specialized subclasses of the draw
context.
Contexts that may be set using this function:
Draw contexts There’s usually only one basic draw context per
application. Draw contexts are used to deliver the
draw stream to graphics drivers via Photon.
Memory contexts
created via PmMemCreateMC(). Memory contexts
are used to draw into memory to build images for
manipulation or display.
Returns:
The old draw context, or NULL if the new context can’t be made
current (active), in which case errno has specifics of the error.
Examples:
In the following example, the print context pc is made active by
calling PpPrintStart(). PpPrintStart() returns the context that the
print context is replacing. The returned context is stored to enable us
to restore the context that was active at the time we decided to start
printing.
PhDrawContext t *dc;
PpPrintContext t *pc;
PmMemoryContext t *mc;
...
if( ( dc = PpPrintStart( pc ) ) == -1 )
{
perror( "unable to activate print context" );
}
else{
// do print stuff
PhDCSetCurrent( dc );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhDCGetCurrent(), PmMemCreateMC(), PpPrintCreatePC(),
PpPrintStart()
Synopsis:
int PhDetach( struct Ph ctrl *Ph );
Description:
This function frees all resources consumed by the Photon channel Ph.
If Ph is the current channel, no current channel will exist after this
function is called.
Ph is a pointer to a Photon control structure returned by a previous
call to PhAttach().
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
See PhAttach().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAttach(), PhReattach()
Synopsis:
PhTile t * PhDeTranslateTiles(
PhTile t *tile,
PhPoint t const *point subtract );
Description:
This function subtracts the coordinates of point subtract from the
vertices of each tile in the list pointed to by tile.
☞ Don’t free() the list of tiles; instead, use PhFreeTiles() to return the
tiles to the internal pool.
Returns:
The same pointer as tile.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAddMergeTiles(), PhClipTilings(), PhCoalesceTiles(),
PhCopyTiles(), PhFreeTiles(), PhGetTile(), PhIntersectTilings(),
PhMergeTiles(), PhRectsToTiles(), PhSortTiles(), PhTile t,
PhTilesToRects(), PhTranslateTiles()
Synopsis:
typedef struct Ph dim {
unsigned short w, h;
} PhDim t;
Description:
The PhDim t structure defines the dimensions of an area. It contains
at least the following members:
Classification:
Photon
See also:
PhArea t, PhPoint t
Synopsis:
typedef struct Ph event {
unsigned long type;
unsigned short subtype;
unsigned short processing flags;
PhEventRegion t emitter;
PhEventRegion t collector;
unsigned short input group;
unsigned short flags;
unsigned long timestamp;
PhPoint t translation;
unsigned short num rects;
unsigned short data len;
} PhEvent t;
Description:
The PhEvent t structure describes an event. It contains at least the
following members:
¯ Ph EV SERVICE
¯ Ph EV SYSTEM
¯ Ph EV TIMER
¯ Ph EV WM
These types are described below. The event type
determines how the data associated with the event is
interpreted.
Ph EVENT ABSOLUTE
Forces the rectangle set associated with the
event to be relative to the root region’s origin.
By default, the coordinates of the rectangle set
are relative to the origin of the emitting region.
Ph EVENT DIRECT
Emits the event directly from emitter to
collector.
Ph EVENT INCLUSIVE
Emits the event first to the emitting region and
then through the event space. Using this flag,
an application can guarantee that the emitter
sees the event (assuming the emitter is sensitive
to that event type).
Ph EMIT TOWARD
Emits the event toward the user. By default,
events are emitted away from the user.
data len The length of the data associated with the event.
Since event data is optional, you can set data len to 0
when there’s no data. To extract the data from an
event, see PhGetData().
Ph EV BOUNDARY
Ph EV PTR ENTER
Emitted when the pointer enters a region. By default, enter
events are emitted to the frontmost region that’s under the
pointer, but only if that region is opaque or sensitive to
Ph EV EXPOSE events.
An application can still force the Photon Manager to emit
boundary events to the frontmost region under the pointer even
if that region isn’t sensitive or opaque to Ph EV EXPOSE. To do
so, the application sets the region’s Ph FORCE BOUNDARY flag
(see the description of PhRegion t).
Before entering a region, the pointer usually first enters the ancestors
☞ of that region. But with some pointing devices (for example,
touchscreens), the pointer may bypass the ancestors and enter the
region directly. If this happens, the Photon Manager emits an enter
event to the region as well as to its ancestors.
Ph EV PTR LEAVE
Emitted when the pointer leaves a region. A leave condition
occurs only when the pointer enters a region that’s not a child of
the previously entered region. (Child regions are always located
within the bounds of their parents. Thus, the pointer doesn’t
have to leave a parent to enter its child.)
Ph EV PTR STEADY
Emitted when the pointer remains motionless for 1.25 seconds.
Another Ph EV PTR STEADY won’t be emitted until the user
moves the pointer and then lets it remain motionless again.
Ph EV PTR UNSTEADY
Emitted when the pointer is moved after a Ph EV PTR STEADY
is emitted. Another Ph EV PTR UNSTEADY won’t be emitted
until the user allows the pointer to remain motionless and then
moves it again.
Ph EV BUT PRESS
PhPoint t pos
Indicates the untranslated, absolute position of the
current pointer focus. As a rule, you should use the
event’s rectangle set to determine coordinate positions.
However, for situations that demand absolute
Ph EV BUT RELEASE
Ph EV RELEASE REAL
Emitted at the current position of the pointer (that is, where the
user actually released the button).
Ph EV RELEASE PHANTOM
Emitted where the user pressed the button.
Ph EV RELEASE ENDCLICK
Emitted when multiclicks are no longer possible, i.e. when the
user moves the mouse or stops clicking for a while.
Ph EV BUT REPEAT
Ph EV COVERED
Ph EV DRAG
Ph EV DRAG BOUNDARY
Emitted when rect hits a boundary. The flags member of the
PhDragEvent t structure specifies which boundary.
Ph EV DRAG COMPLETE
When the user completes the drag operation, the device region
emits a Ph EV DRAG event with this subtype toward the root
region so that the initiating application collects the event. This
event is direct.
Ph EV DRAG INIT
To initiate a drag operation, an application must emit a
Ph EV DRAG event with this subtype to the device region. The
Photon Manager takes care of the user’s interaction with the
screen pointer and the drag outline.
The PhInitDrag() function, which emits Ph EV DRAG INIT,
provides a convenient way to initiate drag operations.
Ph EV DRAG START
Emitted when the server begins the drag operation.
Ph EV DRAW
unsigned long id
An ID number that’s unique for each application in this Photon
space. The Pg functions set this number, which is used to
optimize drawing operations.
Ph EV EXPOSE
Ph NORMAL EXPOSE
Emitted when a region is moved, resized, or removed from the
event space. This is the most common type of expose.
Ph CAPTURE EXPOSE
Emitted by an application (typically a printer driver) that wishes
to receive an encapsulated draw event starting with:
Ph GRAPHIC EXPOSE
Emitted by a graphics driver. This subtype indicates that no
region was moved, removed, or resized to generate the expose
event.
Ph EV INFO
Ph EV INVALIDATE SYSINFO
Emitted by Photon as regions are moved, created, or
destroyed. The application must ask Photon for
updated system information should a need for this
information arise. This is handled automatically by
the widget library. The event data is NULL.
Ph EV KEY
Emitted when a key state changes (for example, the user presses or
releases a key). This event’s rectangle set consists of a point source
that indicates the current focus. The event data is a PhKeyEvent t
structure.
The processing flags member of the PhEvent t structure for this
event type also include:
Ph NOT CUAKEY
Force PtContainer not to use the key for traversal (CUA).
Ph NOT HOTKEY
Force PtContainer not to treat the key as a hotkey.
Emitted when the user moves the pointing device while pressing a
button. This event’s rectangle set consists of a point source that
indicates the current pointer focus. The event data is a
PhPointerEvent t structure (see Ph EV BUT PRESS). The buttons
member indicates which buttons the user is pressing.
Emitted when the user moves the pointing device without pressing a
button. This event’s rectangle set consists of a point source that
indicates the current pointer focus. The event data is a
PhPointerEvent t structure (see Ph EV BUT PRESS).
Ph EV SERVICE
Ph EV REMOTE WM
Handled by relay-type services such as phrelay.
Normally only emitted by a Window Manager to
synchronize a remote Window Manager’s state. The
event data is a PhRemoteWMEvent t structure that
contains at least the following members:
cursor rectangle is
defined by this
structure’s rectangle
member.
Ph FEP NORECT
Invalidate rectangle
in FEP service.
Ph FEP ACTIVATE
Request activation
of FEP filter.
Ph FEP DEACTIVATE
Request
deactivation of FEP
filter.
long len Not used.
PhRect t rect The cursor rectangle relative to the
event rectangle.
long num rids The number of regions that are
parents of this region (the region
owned by the currently focused
widget). An array of num rids RIDs
should be appended to the event
data. The first RID in this list should
be the RID of the focused widget;
otherwise num rids should be set to
0.
Ph EV SYSTEM
PhPoint t origin
Origin of the region, relative to its parent rid.
PhRect t rect
Its rectangle, relative to its origin.
ulong t fields
A set of bits indicating which fields of the
PhRegion t structure were modified:
Ph EV TIMER
unsigned msec
unsigned zero
PhEventRegion t region
Ph EV WM
Both the Window Manager and applications can emit this event. The
Window Manager emits this event when an application has asked to
be notified. An application can emit this event to communicate to the
Window Manager regarding windows.
Ph EV WM can have the following subtype:
Ph EV WM EVENT
The rectangle set of the event has no useful value. The event
data is a PhWindowEvent t structure.
Classification:
Photon
See also:
PhGetData(), PhGetRects(), PhKeyEvent t, PhWindowEvent t
Events chapter of the Photon Programmer’s Guide
Synopsis:
int PhEventArm( void );
Description:
This function arms the current Photon channel so that the channel will
trigger the application’s event proxy when an event becomes
available. If an event is already available, the proxy is triggered
immediately.
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
See PhEventRead().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAttach(), PhEventNext(), PhEventPeek(), PhEventRead()
Synopsis:
int PhEventEmit( PhEvent t const *event,
PhRect t const *rects,
void const *data );
Description:
This function emits the event described by the given PhEvent t
structure. The rects argument points to an array of PhRect t
structures that define the rectangles associated with the event, and
data points to variable-length event-specific data.
If event->num rects isn’t 0, then rects must point to an array of
event->num rects valid rectangles.
If event->data len isn’t 0, then data must point to a buffer of at least
event->data len bytes.
The collector and translation fields in the PhEvent t structure are
filled in only after a copy of the event is enqueued to an application.
Returns:
0 Success
These return codes are useful for applications that spend most of their
time emitting events and want to retrieve an event only if there’s one
pending for them.
Examples:
The following example emits an expose event from the device region.
Because the event will cover the entire event space, any visible part of
the event space will be refreshed:
#include <stdio.h>
#include <time.h>
#include <Ph.h>
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEventEmitmx(), PhEventNext(), PhEventPeek(), PhEventRead(),
PtSendEventToWidget()
“Emitting events” in the Events chapter of the Photon Programmer’s
Guide.
Synopsis:
int PhEventEmitmx( PhEvent t const *event,
PhRect t const *rects,
int mxparts,
iov t *mx );
Description:
This function provides an alternative to PhEventEmit(). You’ll find it
useful when the event-specific data isn’t contiguous in memory.
PhEventEmitmx() is used internally by PgFlush() (which emits a draw
event) to avoid copying large amounts of variable-length data, such as
bitmaps, into the draw buffer. Instead of copying the data, the library
builds mx entries to that data and then passes the mx entry list to
PhEventEmitmx(), which in turn emits the draw event.
The mx argument points to an array of mx entries, and mxparts
contains the number of mx entries pointed to by mx. You should leave
the first 3 mx entries blank; these will be filled in by the
PhEventEmitmx() call. You’re free to use the remaining entries to
build a description of the data to be attached to the event.
The event argument points to the standard event data structure and
rects points to an array of rectangles. For the restrictions that apply to
rects and to the attached data, see PhEventEmit().
Returns:
0 Successful completion.
These return codes are useful for applications that spend most of their
time emitting events and want to retrieve an event only if there’s one
pending for them.
Examples:
The following example emits a pointer press event. (A PhEventEmit()
call would be just as efficient and slightly more convenient...)
#include <stdio.h>
#include <time.h>
#include <Ph.h>
fprintf( stderr,
"Could not attach a Photon channel.\n");
exit( EXIT FAILURE );
}
event.type = Ph EV BUT PRESS;
event.subtype = 0;
event.src.rid = Ph DEV RID;
event.flags = 0;
event.num rects = 1;
event.data len = sizeof( ptr event );
rect.ul.x = rect.lr.x = 100;
rect.ul.y = rect.lr.y = 200;
ptr event.flags = 0;
ptr event.buttons = Ph BUTTON SELECT;
setmx( &mx[3], &ptr event, sizeof( ptr event ) );
PhEventEmitmx( &event, &rect, 4, mx );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgFlush(), PhEventEmit()
Sendmx(), setmx() (in the C Library Reference)
Synopsis:
int PhEventNext( void *buffer,
unsigned size );
Description:
This function provides a completely synchronous event-notification
mechanism. It causes the application to become REPLY-blocked on
the currently attached Photon channel until an event occurs.
If the application’s event queue contains an event when this call is
made, Photon replies immediately with that event.
Returns:
Ph EVENT MSG
Successful completion.
Ph RESIZE MSG
The Ph DYNAMIC BUFFER flag was set in PhAttach(), and
there’s a pending Photon event that’s larger than the client’s
event buffer. This event that indicates how large the client’s
buffer needs to be to receive the entire event message.
-1 An error occurred.
Examples:
#define EVENT SIZE sizeof( PhEvent t ) + 1000
if( initialize() == -1 )
exit( EXIT FAILURE );
while( 1 ) {
switch( PhEventNext( event, EVENT SIZE ) ) {
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAttach(), PhEventPeek(), PhEventRead(), PhGetMsgSize()
Synopsis:
int PhEventPeek( void *buffer,
unsigned size );
Description:
This function lets you check if an event is pending on the current
Photon channel:
Returns:
Ph EVENT MSG
Successful completion.
Ph RESIZE MSG
The Ph DYNAMIC BUFFER flag was set in PhAttach(), and
there’s a pending Photon event that’s larger than the client’s
event buffer. This event that indicates how large the client’s
buffer needs to be to receive the entire event message.
-1 An error occurred.
Examples:
#define EVENT SIZE sizeof( PhEvent t ) + 1000
PhEvent t *event;
if( initialize() == -1 )
exit( EXIT FAILURE );
while( go ) {
if(( ++count & 15) == 0) {
PgFlush();
switch( PhEventPeek( event, EVENT SIZE ) {
case Ph EVENT MSG:
PtEventHandler( event );
break;
case -1:
perror( "PhEventPeek failed" );
break;
}
}
iterate graphics process();
}
exit( 0 );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAttach(), PhEventArm(), PhEventNext(), PhEventRead()
Synopsis:
int PhEventRead( pid t pid,
void *buffer,
unsigned size );
Description:
This function provides an asynchronous event-notification
mechanism. You’ll find it useful for applications that need to interact
with Photon but also need to collect proxies or messages from other
processes.
Typically, this function is called with the pid returned by Receive() to
see if the message received was a proxy triggered by Photon.
If pid is the application’s event proxy, PhEventRead() retrieves the
event and rearms Photon. Otherwise, it returns 0. (The event proxy
was attached automatically by a previous call to PhAttach().)
Photon may close a region (for example, via the window manager)
before you read the pending event. As a result, PhEventRead() may
indicate that no event is pending even though you were notified
otherwise. In this case, PhEventRead() returns -1 and sets errno to
ENOMSG.
You must call PhAttach() and PhEventArm() before the first call to
this function.
Returns:
Ph EVENT MSG
Successful completion.
Ph RESIZE MSG
The Ph DYNAMIC BUFFER flag was set in PhAttach(), and
there’s a pending Photon event that’s larger than the client’s
event buffer. This event that indicates how large the client’s
buffer needs to be to receive the entire event message.
0 No message was available.
-1 An error occurred.
Examples:
#define EVENT SIZE sizeof( PhEvent t ) + 1000
if( initialize() == -1 )
exit( EXIT FAILURE );
while( 1 ) {
pid = Receive( 0, &msg, sizeof( msg ) );
switch( PhEventRead( pid, event, EVENT SIZE ) ) {
case Ph EVENT MSG:
PtEventHandler( event );
break;
case 0:
process app msg( &msg );
break;
case -1:
perror( "PhEventRead failed" );
break;
}
}
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAttach(), PhEventArm(), PhEventNext(), PhEventPeek()
Receive() in the C Library Reference.
Synopsis:
typedef struct Ph event region {
PhRid t rid;
long handle;
} PhEventRegion t;
Description:
The PhEventRegion t structure describes the emitter and the
collector of events. It contains at least the following members:
Classification:
Photon
See also:
PhEvent t
Synopsis:
void PhFreeTiles( PhTile t * tile);
Description:
This function returns the given list of tiles to the internal tile pool.
Photon maintains an internal pool of tiles because they’re frequently
used, and using a pool reduces the amount of time spent allocating
and freeing the tiles. Use PhGetTile() to get a tile from the pool, and
this function to return a list of tiles to the pool. Don’t free() a
PhTile t structure.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAddMergeTiles(), PhClipTilings(), PhCoalesceTiles(),
PhCopyTiles(), PhDeTranslateTiles(), PhGetTile(),
PhIntersectTilings(), PhMergeTiles(), PhRectsToTiles(),
PhSortTiles(), PhTile t, PhTilesToRects(), PhTranslateTiles()
Synopsis:
PhConnectId t PhGetConnectId( void );
Description:
This function returns the connection ID of the calling process.
Returns:
The connection ID of the calling process, or -1 on error.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetConnectInfo()
Synopsis:
PhConnectId t PhGetConnectInfo(
PhConnectId t coid,
PhConnectInfo t *buf );
Description:
This function fills *buf with information about the specified Photon
channel. If coid is zero, information about the calling process is
returned. If it isn’t zero but doesn’t match any existing channel, then
the next monotonically greater channel ID is used. If coid is greater
than any existing channel ID, -1 is returned and errno is set to ESRCH.
The PhConnectInfo t structure includes at least the following:
Returns:
The channel ID (the same as buf->id), or -1 if the call fails.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetConnectId()
Synopsis:
void *PhGetData( PhEvent t const *event );
Description:
This function returns a pointer to an event-specific data structure. For
a complete description of the data structures returned with each event
type, see the description of the PhEvent t structure.
You can determine the size of the data from event->data len.
Returns:
A pointer to an event-specific data structure.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEvent t, PhGetRects()
Synopsis:
unsigned PhGetMsgSize( PhEvent t const *event buf );
Description:
This function returns the size of buffer necessary to contain the event
that couldn’t fit into the current buffer. You typically use this function
after PhEventRead(), PhEventPeek(), or PhEventNext() has returned a
value of Ph RESIZE MSG.
These functions can return Ph RESIZE MSG only if the application set
the Ph DYNAMIC BUFFER flag when it attached the Photon channels;
see PhAttach().
Returns:
The size of the buffer required to accommodate the entire event.
Examples:
The following fragment shows how you can use PhGetMsgSize() to
maintain a dynamic event buffer:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAttach(), PhEventNext(), PhEventPeek(), PhEventRead()
Synopsis:
PhRect t *PhGetRects( PhEvent t const *event );
Description:
This function gets the rectangle set associated with the specified
event. The number of rectangles in the event’s rectangle set is given
by event->num rects.
In the case of an expose event, this function returns a pointer to the
list of rectangles that need to be repaired. In the case of a pointer
event, only one rectangle is associated with the event — the one
associated with the current position of the pointer.
For more information on the meaning of the rectangle set for different
event types, see the event types described for the PhEvent t
structure.
Returns:
A pointer to the rectangles associated with the event.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEvent t, PhGetData()
Synopsis:
PhTile t *PhGetTile( void );
Description:
Photon maintains an internal pool of tiles because tiles are frequently
used, and using the pool reduces the amount of time allocating and
freeing the tiles. This function retrieves a tile from the internal tile
pool. The tile isn’t initialized.
☞ Don’t free() the tile; instead, use PhFreeTiles() to return the tile to the
pool.
Returns:
A pointer to the new tile, or NULL if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAddMergeTiles(), PhClipTilings(), PhCoalesceTiles(),
PhCopyTiles(), PhDeTranslateTiles(), PhFreeTiles(),
PhIntersectTilings(), PhMergeTiles(), PhRectsToTiles(),
PhSortTiles(), PhTile t, PhTilesToRects(), PhTranslateTiles()
Synopsis:
typedef struct PhImage
{
int type;
ulong t image tag;
int bpl;
PhDim t size;
ulong t palette tag;
int colors;
int xscale;
int yscale;
char format;
char flags;
char ghost bpl;
char spare1;
char *ghost bitmap;
int mask bpl;
char *mask bm;
PgColor t *palette;
char *image;
} PhImage t;
Description:
The PhImage t structure describes the data and characteristics of an
image. When you give an image to a PtLabel subclass widget, this
is the structure you must provide. To get a pointer to this structure,
use PxLoadImage(). To free the allocated members of this structure,
call PhReleaseImage().
The structure contains at least the following members:
int type The graphic type. For more info, see the
discussion on the type argument in
PgDrawImage().
Image types
The types of image are:
the lower half. These pixel values index directly into the current
palette. If no palette is set, the function chooses colors from the
global palette.
RRRR.RRRR.GGGG.GGGG.BBBB.BBBB
xRRR.RRGG.GGGB.BBBB
RRRR.RGGG.GGGB.BBBB
xxxx.RRRR.GGGG.BBBB
For convenience, you can AND Pg IMAGE CLASS MASK with the
image type to determine the image’s class:
Classification:
Photon
See also:
ApGetImageRes(), PgDrawPhImagemx(), PhMakeGhostBitmap(),
PhMakeTransBitmap(), PhReleaseImage(), PmMemCreateMC(),
PmMemFlush(), PxLoadImage()
Synopsis:
int PhInitDrag( PhRid t rid,
unsigned flags,
const PhRect t *rect,
const PhRect t *boundary,
unsigned int input group,
const PhDim t *min,
const PhDim t *max,
const PhDim t *step );
Description:
This function starts a drag. Normally, when the drag has completed,
the application collects a Ph EV DRAG event that describes the results
of the operation. But if the application closes the region that has
initiated the drag operation, the operation completes without returning
a Ph EV DRAG event.
The flags argument determines how the drag operation will behave.
Defined values:
Ph TRACK LEFT
Left edge of drag rectangle tracks pointer.
Ph TRACK RIGHT
Right edge of drag rectangle tracks pointer.
Ph TRACK TOP
Top edge of drag rectangle tracks pointer.
Ph TRACK BOTTOM
Bottom edge of drag rectangle tracks pointer.
Ph TRACK DRAG
All edges of drag rectangle track pointer.
Ph DRAG TRACK
Emit drag events to track the drag, but don’t rubber-band.
Ph DRAG NOBUTTON
Start the drag even if no buttons are held down.
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
drag lower left( PhRect t *rect, PhRect t *boundary,
PtCallbackInfo t *cbinfo )
{
PhInitDrag( my region, Ph TRACK LEFT | Ph TRACK BOTTOM,
rect, boundary,
cbinfo->event->input group,
NULL, NULL, NULL );
}
switch( cbinfo->event->type )
{
case Ph EV DRAG:
drag = (PhDragEvent t *)PhGetData( cbinfo->event );
rect = &drag->rect;
// drag rectangle in ABSOLUTE coordinates.
PtTranslateRect( rect,
&cbinfo->event->translation );
// rect is now relative to the region the drag
// was initiated on.
...
}
...
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEvent t, PhGetData(), PtTranslateRect()
“Dragging” in the Events chapter of the Photon Programmer’s Guide
Synopsis:
PhTile t *PhIntersectTilings(
PhTile t const * const tile1,
PhTile t const * const tile2,
unsigned short *num intersect tiles );
Description:
This function creates a new list of tiles that’s the intersection of the
lists pointed to by tile1 and tile2. The original lists aren’t modified.
Returns:
A pointer to the new list, or NULL if there’s no intersection.
☞ Don’t free() the list of tiles; instead, use PhFreeTiles() to return the
tiles to the internal pool.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAddMergeTiles(), PhClipTilings(), PhCoalesceTiles(),
PhCopyTiles(), PhDeTranslateTiles(), PhFreeTiles(), PhGetTile(),
PhMergeTiles(), PhRectsToTiles(), PhSortTiles(), PhTile t,
PhTilesToRects(), PhTranslateTiles()
Synopsis:
typedef struct Ph ev key data {
unsigned long key mods;
unsigned long key flags;
unsigned long key cap;
unsigned long key sym;
unsigned char key scan;
unsigned char key zero1;
unsigned short key zero2;
PhPoint t pos;
unsigned short button state;
} PhKeyEvent t;
Description:
This structure describes a key event. It includes at least:
key mods Some keys (e.g. Shift or Num Lock) modify other
keys. When a modifier key is pressed or released, it’s
evaluated through a table and the key mods field is
updated accordingly. This evaluation is done before
the key event is sent.
The key mod is a combination of the following bits:
¯ Pk KM Shift
¯ Pk KM Ctrl
¯ Pk KM Alt
¯ Pk KM AltGr
¯ Pk KM Shl3 — not used.
¯ Pk KM Mod6 — not used.
¯ Pk KM Mod7 — not used.
¯ Pk KM Mod8 — not used.
¯ Pk KM Shift Lock
¯ Pk KM Ctrl Lock
¯ Pk KM Alt Lock
¯ Pk KM AltGr Lock
¯ Pk KM Shl3 Lock — not used.
¯ Pk KM Mod6 Lock — not used.
¯ Pk KM Mod7 Lock — not used.
¯ Pk KM Mod8 Lock — not used.
¯ Pk KM Caps Lock
¯ Pk KM Num Lock
¯ Pk KM Scroll Lock
If the Shift key is pressed, the Shift modifier is on; if
it’s released, the Shift modifier is off. Because some
keys occur twice on the keyboard, a key release
doesn’t guarantee that the corresponding modifier is
off — the matching key may still be pressed.
key cap The unique scan code produced by the key, without
any modifiers. This member is valid only if
Pk KF Cap Valid is set in the key flags.
key sym The value of the key with modifiers applied to it.
This member is valid only if Pk KF Sym Valid is set
in the key flags.
This field holds the value that’s used for text entry; it
can also be used in a switch statement to determine
a key’s function.
key scan The hardware-dependent scan code for the key. This
member is valid only if Pk KF Scan Valid is set in the
key flags.
Classification:
Photon
See also:
PhEvent t
Events chapter of the Photon Programmer’s Guide
Synopsis:
int PhKeyToMb( char *buffer,
PhKeyEvent t const *keyevent );
Description:
This function stores, in buffer, a valid UTF-8 char array for the given
key event, if one exists.
Returns:
The number of bytes in the UTF-8 code, or -1 if there’s no valid
UTF-8 code for the given event.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetData(), PhTo8859 1()
<photon/PkKeyDef.h>
Synopsis:
unsigned PhLibVersion( void );
Library:
ph
Description:
This function returns the version of the Photon library that you’re
using.
You can use Ph LIB VERSION (defined in <PhT.h>) to determine the
library version when you’re compiling or running your application.
Returns:
The version number of the Photon libraries, expressed as:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
“Photon libraries” in the Introduction chapter of the Photon
Programmer’s Guide
Synopsis:
int PhMakeGhostBitmap( PhImage t *image );
Description:
This function takes a PhImage t pointer and creates a ghost bitmap
for the image. The ghost bitmap is stored in the image’s data structure.
The image argument must point to a valid PhImage t structure. It
can point to a regular or transparent image.
The ghost image is used when either Pt GHOST or Pg GHOST is
passed as a flag to PgDrawPhImagemx().
Returns:
0 The image was successfully created.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhImage t
Synopsis:
int PhMakeTransBitmap( PhImage t *image,
PgColor t trans color );
Description:
This function creates a transparent bitmap or transparency mask for
the given image, provided there isn’t one already.
The trans color argument is the color in the image’s palette to be
made transparent. If more than one entry in the palette contains this
color, the first one found is used. You can pass an index into the
palette as trans color by ORing it with Pg INDEX COLOR. For
example:
if ( PhMakeTransBitmap( my image,
n | Pg INDEX COLOR ) == 0 )
{
.
.
.
}
Returns:
0 Success.
-1 An error occurred.
Examples:
/*
* This is code for a PhAB application that demonstrates
* how to make a transparency mask for an image. This
* also shows how to take that image and to put it into
* a label widget and to draw it into a PtRaw’s canvas.
*/
/* 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 "abimport.h"
#include "proto.h"
ApDBase t *database;
PhImage t trans image;
/*
* Setup function for the base window
*/
int
base window setup( PtWidget t *link instance,
ApInfo t *apinfo,
PtCallbackInfo t *cbinfo )
{
PhImage t *imgptr;
PtArg t arg;
return( Pt CONTINUE );
}
/*
* Draw function (Pt ARG RAW DRAW F) for a PtRaw widget
*/
void
raw draw f( PtWidget t *widget, PhTile t *damage )
{
PhPoint t pos = {0, 0};
PhRect t rect;
damage = damage;
// Do our drawing...
PgDrawPhImagemx( &pos, &trans image, 0 );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawPhImagemx(), PhImage t
Synopsis:
PhTile t * PhMergeTiles( PhTile t *tiles );
Description:
This function removes all overlap from the list of tiles pointed to by
tiles.
Returns:
The same pointer as tiles.
☞ Don’t free() the list of tiles; instead, use PhFreeTiles() to return the
tiles to the internal pool.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAddMergeTiles(), PhClipTilings(), PhCoalesceTiles(),
PhCopyTiles(), PhDeTranslateTiles(), PhFreeTiles(), PhGetTile(),
PhIntersectTilings(), PhRectsToTiles(), PhSortTiles(), PhTile t,
PhTilesToRects(), PhTranslateTiles()
Synopsis:
void PhMoveCursorAbs( int input group,
int x,
int y );
Description:
This function moves the cursor for input group to the absolute
coordinates specified by x and y.
You can determine the current input group as follows:
¯ If you have the event that triggered the clipboard operation, use its
input group (e.g. cbinfo->event->input group) if it’s nonzero.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhMoveCursorRel(), PhQueryCursor()
Synopsis:
void PhMoveCursorRel( int input group,
int x,
int y );
Description:
This function moves the cursor for input group to the coordinates
specified by x and y relative to the current cursor position.
You can determine the current input group as follows:
¯ If you have the event that triggered the clipboard operation, use its
input group (e.g. cbinfo->event->input group) if it’s nonzero.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhMoveCursorAbs(), PhQueryCursor()
Synopsis:
typedef struct Ph point {
short x, y;
} PhPoint t;
Description:
The PhPoint t structure describes the coordinates of a single point.
It contains at least the following members:
x X-axis coordinate.
y Y-axis coordinate.
Classification:
Photon
See also:
PhArea t, PhDim t
Synopsis:
int PhQueryCursor( unsigned short ig,
PhCursorInfo t *buf );
Description:
This function collects information about the cursor for input group ig
and places this information in the provided structure pointed to by
buf .
You can determine the current input group as follows:
¯ If you have the event that triggered the clipboard operation, use its
input group (e.g. cbinfo->event->input group) if it’s nonzero.
PhPoint t pos
Last position, in absolute coordinates.
PhRid t region
Region that currently contains the cursor.
PhRid t ig region
Region representing the input group.
PgColor t color
Cursor color.
PhPoint t last press
Location of last Ph EV BUT PRESS event.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhMoveCursorAbs(), PhMoveCursorRel()
Synopsis:
int PhQueryRids( unsigned flags,
PhRid t rid,
unsigned input group,
unsigned type,
unsigned sense,
PhRid t emitter,
const PhRect t *rect,
PhRid t rids[],
int num );
Description:
This function builds a list of up to num regions in the rids array. The
other parameters specify which regions are to be included in the list:
¯ Ph EV SYSTEM
¯ Ph EV WM
¯ Ph EV BUT REPEAT
¯ Ph EV RAW
¯ Ph EV TIMER
¯ Ph EV LB SYSTEM
¯ Ph EV SERVICE
¯ Ph EV INFO
Set sense to 0 (i.e. all bits off) to consider regions
regardless of their sensitivity.
Returns:
The number of regions found, or -1 if an error occurred.
☞ If this function returns -1, check errno. If it’s ENOMSG, there are no
pending Photon events; this isn’t really an error.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PhSysInfo t * PhQuerySystemInfo(
PhRid t rid,
PhRect t const *rect,
PhSysInfo t *sysinfo );
Description:
This function queries the system for information for the region with
the given rid:
¯ system bandwidth
¯ pointing devices
¯ keyboard devices
Returns:
A pointer to the PhSysInfo t structure passed to the function, or
NULL if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtQuerySystemInfo()
For a description of PhSysInfo t and the information it provides,
see PhT.h and “System information” in the Regions chapter of the
Programmer’s Guide.
Synopsis:
struct Ph ctrl *PhReattach( struct Ph ctrl *Ph );
Description:
This function lets you change the current Photon channel if more than
one channel has been opened. The function flushes the draw buffer
before changing the channel.
The Ph argument points to a Photon control structure returned by a
previous call to PhAttach().
If Ph is NULL, this function simply returns a pointer to the current
Photon control structure.
Returns:
Returns a pointer to the previous Photon channel.
Examples:
See PhAttach().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAttach(), PhDetach()
Synopsis:
typedef struct Ph rect {
PhPoint t ul, lr;
} PhRect t;
Description:
The PhRect t structure describes the coordinates of a rectangle. It
contains at least the following members:
ul Upper-left corner.
lr Lower-right corner.
Classification:
Photon
See also:
PhPoint t
Synopsis:
PhTile t * PhRectsToTiles( PhRect t *rects,
int num rects );
Description:
This function creates a list of tiles from the array of rectangles pointed
to by rects, with num rects entries.
Returns:
A pointer to the list of tiles.
☞ Don’t free() the list of tiles; instead, use PhFreeTiles() to return the
tiles to the internal pool.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAddMergeTiles(), PhClipTilings(), PhCoalesceTiles(),
PhCopyTiles(), PhDeTranslateTiles(), PhFreeTiles(), PhGetTile(),
PhIntersectTilings(), PhMergeTiles(), PhSortTiles(), PhTile t,
PhTilesToRects(), PhTranslateTiles()
Synopsis:
typedef struct Ph region {
PhRid t rid;
long handle;
PhConnectId t owner;
ulong t flags;
ushort t state;
unsigned long events sense;
unsigned long events opaque;
PhPoint t origin;
PhRid t parent,
child,
bro in front,
bro behind;
PgColor t cursor color;
ushort t input group;
ushort t data len;
unsigned long zero[2];
ushort t cursor type;
} PhRegion t;
Description:
The PhRegion t structure describes a region. It contains at least the
following members:
PhRid t rid This region’s ID. The Photon Manager assigns this
when the region is opened.
Ph FORCE BOUNDARY
Forces the Photon Manager to
emit Ph EV BOUNDARY events
to this region. If you don’t set
this flag, the Photon Manager
determines if the region should
PhPoint t origin
Determines the region’s origin relative to its
parent’s origin. All coordinates returned in events
and elsewhere in this structure are relative to origin.
In almost all cases, the coordinates used by the API
functions are relative to the origin of the caller’s
region. However, when emitting events, the
application may use absolute coordinates by setting
the Ph EVENT ABSOLUTE flag.
PhRid t parent
Indicates the region’s parent.
PhRid t child Indicates the frontmost child region (that is, closest
to the user). If no child regions exist, the Photon
Manager sets child to -1.
Classification:
Photon
See also:
PgSetRegion(), PhRegionChange(), PhRegionClose(),
PhRegionDataFindType(), PhRegionDataHdr t, PhRegionOpen(),
PhRegionQuery()
Regions chapter of the Photon Programmer’s Guide
Synopsis:
int PhRegionChange( unsigned long fields,
unsigned long flags,
PhRegion t const *info,
PhRect t const *rect,
void const *data );
Description:
This function changes the definition of the region specified by
info->rid. The fields argument describes which fields in the info
structure are to be changed — for more information, see
PhRegionOpen().
The rect argument points to the rectangle associated with the region,
and data points to data associated with the region. If you don’t
specify the region’s rectangle and data in the fields argument, you can
set rect and data to NULL.
The data consists of one or more PhRegionDataHdr t structures,
each followed immediately by the appropriate type of data. This data
is merged into any existing region data, replacing the blocks of the
same types as given in data.
The flags argument controls whether or not an expose event will be
emitted to this region, when necessary. You can OR the following into
flags:
Ph EXPOSE REGION
If part of the region becomes exposed, send a Ph EV EXPOSE
event to the region.
Ph EXPOSE FAMILY
If part of the region becomes exposed, send a Ph EV EXPOSE
event to the region’s descendants.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRegion t, PhRegionClose(), PhRegionDataHdr t,
PhRegionOpen()
Synopsis:
int PhRegionClose( PhRid t rid );
Description:
This function removes the specified region from the current Photon
Manager. If the specified region has child regions, they’re removed as
well.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRegion t, PhRegionChange(), PhRegionOpen()
Synopsis:
PhRegionDataHdr t *
PhRegionDataFindType(
PhRegion t const *region,
PhRegionDataHdr t const *data,
short type);
Description:
This function finds the specified type of data within the provided
region’s data block. For a list of types, see the description of
PhRegionDataHdr t.
Returns:
A pointer to a PhRegionDataHdr t structure that matches the
specified data type. If no data entries within the region’s data block
match the specified type, the function returns NULL.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRegion t, PhRegionDataHdr t, PhRegionChange(),
PhRegionQuery()
Synopsis:
typedef struct Ph region data hdr {
unsigned short len;
unsigned short type;
} PhRegionDataHdr t;
Description:
The PhRegionDataHdr t structure describes data that’s attached to
a region. It includes at least the following members:
type The type of data, which indicates the data structure used:
Type Structure
Ph RDATA WINDOW PhWindowInfo t
Ph RDATA CURSOR PhCursorDef t
Ph RDATA IG PhIgRegionData t
Ph RDATA GFXINFO PhGrafxRegionData t
Ph RDATA KBDINFO PhKbdRegionData t
Ph RDATA PTRINFO PhPtrRegionData t
Ph RDATA WMCONFIG WmConfig t
Ph RDATA GFXDETAIL PhGrafxDetail t
Ph RDATA INPMGRINFO Internal use only
Ph RDATA CLIPBOARD PhClipHeader
Ph RDATA USER User-defined
Classification:
Photon
See also:
PhRegion t, PhRegionDataFindType()
Synopsis:
PhRid t PhRegionOpen( unsigned fields,
PhRegion t const *info,
PhRect t const *rect,
void const *data );
Description:
This function opens a new region. The fields argument describes
which members specified by info will be used. If some fields aren’t
specified, the function sets the corresponding members of the new
region to their defaults.
The info argument is a template region used when opening the new
region. You must set the parent member of info; Photon fills in the
other family members.
The rect argument points to the rectangle associated with the region,
and data points to the data associated with the region.
continued. . .
Returns:
A positive region ID, or -1 if an error occurred.
Examples:
The following example opens a region out of the root region. The new
region will sense any mouse motion events that pass through it, and
draw a rectangle at the current position of the pointer. If the user
clicks in the region, the program will terminate. If a window manager
is running, this region will be in front of the window manager. The
window manager won’t be aware of the region.
#include <stdio.h>
#include <Ph.h>
memset(®ion, 0, sizeof(region));
/* Wish to have pointer motion
* events enqueued to us.
*/
region.events sense = Ph EV PTR MOTION |
Ph EV BUT RELEASE;
rect.ul.x = rect.ul.y = 0;
rect.lr.x = rect.lr.y = 200;
return 0;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgSetRegion(), PhAttach(), PhRegion t, PhRegionChange(),
PhRegionClose()
Synopsis:
int PhRegionQuery( PhRid t rid,
PhRegion t *region,
PhRect t *rect,
void *data,
unsigned data len );
Description:
This function returns information about the region identified by rid.
Upon completion, region and rect contain a description of the region.
If the region has data attached to it, then the data, up to data len
bytes, is copied into data. This data may consist of smaller blocks of
data of different types, each preceded by a PhRegionDataHdr t
structure. To find a specific type of data in the region’s data, call
PhRegionDataFindType().
Returns:
0 Success.
-1 An error occurred.
Examples:
The following example gets information about the device region:
PhRegion t region; PhRect t rect;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRegion t, PhRegionChange(), PhRegionOpen()
Synopsis:
void PhReleaseImage( PhImage t *image );
Description:
This function releases the allocated members of the PhImage t
pointed to by image, based on the value of image->flags. The valid
flags are:
¯ Ph RELEASE IMAGE
¯ Ph RELEASE PALETTE
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetImageRes(), PgDrawPhImagemx(), PhImage t,
PhMakeGhostBitmap(), PhMakeTransBitmap(), PmMemCreateMC(),
PmMemFlush(), PxLoadImage()
Synopsis:
PhTile t * PhSortTiles( PhTile t *tiles );
Description:
This function sorts the given list of tiles by the y coordinate then the x
coordinate. Sorting a list of tiles usually results in a smaller merged
list.
☞ Don’t free() the list of tiles; instead, use PhFreeTiles() to return the
tiles to the internal pool.
Returns:
The same pointer as tiles.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAddMergeTiles(), PhClipTilings(), PhCoalesceTiles(),
PhCopyTiles(), PhDeTranslateTiles(), PhFreeTiles(), PhGetTile(),
PhIntersectTilings(), PhMergeTiles(), PhRectsToTiles(), PhTile t,
PhTilesToRects(), PhTranslateTiles()
Synopsis:
typedef struct Ph tile {
PhRect t rect;
struct Ph tile *next;
} PhTile t;
Description:
The PhTile t structure is used to build linked lists of rectangles. It
includes at least the following members:
Classification:
Photon
See also:
PhAddMergeTiles(), PhClipTilings(), PhCoalesceTiles(),
PhCopyTiles(), PhDeTranslateTiles(), PhFreeTiles(), PhGetTile(),
PhIntersectTilings(), PhMergeTiles(), PhRectsToTiles(),
PhSortTiles(), PhTilesToRects(), PhTranslateTiles()
Synopsis:
PhRect t * PhTilesToRects( PhTile t *tiles,
int *num rects );
Description:
This function allocates an array of num rects PhRect t structures
and fills it with the rectangles described by the list of tiles pointed to
by tiles.
☞ Don’t free() the list of tiles; instead, use PhFreeTiles() to return the
tiles to the internal pool.
Returns:
A pointer to the array of rectangles.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAddMergeTiles(), PhClipTilings(), PhCoalesceTiles(),
PhCopyTiles(), PhDeTranslateTiles(), PhFreeTiles(), PhGetTile(),
PhIntersectTilings(), PhMergeTiles(), PhRectsToTiles(),
PhSortTiles(), PhTile t, PhTranslateTiles()
Synopsis:
int PhTimerArm ( PhRid t rid,
long handle,
unsigned msec );
Description:
The PhTimerArm() arms a timer event on the region specified by rid
to be triggered after msec milliseconds. The handle argument is
returned in the timer event. See PhT.h for information about the
timer event structure.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTimerArm()
Synopsis:
int PhTo8859 1( PhKeyEvent t const *keyevent );
Description:
This function returns a valid ISO8859-1 code for the given key event,
if one exists. If there’s no valid ISO8859-1 code for the given event,
the function returns -1.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetData(), PhKeyToMb()
<photon/PkKeyDef.h>
Synopsis:
PhTile t * PhTranslateTiles(
PhTile t *tile,
PhPoint t const *point add );
Description:
This function adds the coordinates of point add to the vertices of each
tile in the list pointed to by tile.
☞ Don’t free() the list of tiles; instead, use PhFreeTiles() to return the
tiles to the internal pool.
Returns:
The same pointer as tile.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAddMergeTiles(), PhClipTilings(), PhCoalesceTiles(),
PhCopyTiles(), PhDeTranslateTiles(), PhFreeTiles(), PhGetTile(),
PhIntersectTilings(), PhMergeTiles(), PhRectsToTiles(),
PhSortTiles(), PhTile t, PhTilesToRects()
Synopsis:
int PhWindowChange(
unsigned fields,
unsigned flags,
const PhRegion t *region,
const PhRect t *rect,
const PhWindowInfo t *win info );
Description:
This function allows you to modify the attributes and window
information of a window’s region. The Window Manager is notified
of this change and will respond accordingly.
Ph EXPOSE REGION
If part of the region becomes exposed, send a Ph EV EXPOSE
event to the region.
Ph EXPOSE FAMILY
If part of the region becomes exposed, send a Ph EV EXPOSE
event to the region’s descendants.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhWindowOpen(), PhRegionClose()
See PhWm.h for a description of PhWindowInfo t.
Synopsis:
int PhWindowClose( PhRid t window rid );
Description:
This function closes a window with the given region ID, window rid,
previously opened by PhWindowOpen().
Returns:
0 Successful completion.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhWindowOpen()
Synopsis:
typedef struct Ph window event {
ulong t event f ;
ulong t state f ;
PhRid t rid;
PhPoint t pos;
PhDim t size;
ushort t event state;
ushort t input group;
ulong t rsvd[4];
} PhWindowEvent t;
Description:
Using the PhWindowEvent t structure, your application can
determine what kind of window action just occurred, or can tell the
window manager to perform a specific action on its behalf.
This structure contains at least the following members:
PhDim t size Indicates the width and height of the window. This
member is only for Ph WM BACKDROP,
Ph WM MAX, Ph WM RESIZE, and
Ph WM RESTORE events.
Classification:
Photon
See also:
PtForwardWindowEvent(), PtForwardWindowTaskEvent()
Window Management chapter of the Photon Programmer’s Guide.
Synopsis:
PhRid t PhWindowOpen(
unsigned fields,
const PhRegion t *region,
const PhRect t *rect,
const PhWindowInfo t *win info );
Description:
This function creates a window region that will be managed by the
Window Manager in the Photon event space. The Window Manager
will provide a region to act as a frame in addition to the region created
by the calling application.
The fields argument describes which members specified by region
will be used. If some fields aren’t specified, the function sets the
corresponding members of the new region to their default values.
The region argument is a template region used when opening the new
region. You must set the parent member of region; Photon fills in the
other family members.
The rect argument points to the rectangle associated with the region,
and win info points to a description of the window’s attributes, as
specified in the PhWindowInfo t structure (see PhWm.h).
Returns:
The region ID of the new window’s interior (not the RID of the
frame).
If an error occurred, this function returns:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhWindowChange(), PhRegionChange(), PhWindowClose(),
PhRegionOpen()
See PhWm.h for a description of PhWindowInfo t.
Synopsis:
int PhWindowQueryVisible( unsigned flag,
PhRid t rid,
unsigned input group,
PhRect t *rect );
Description:
If rid is zero, this function calculates the visible extent based on the
region type specified in flag.
If rid is nonzero, PhWindowQueryVisible() calculates the visible
extent by finding every region intersecting with rid that matches the
region type specified in flag.
The input group argument indicates which input group the visible
extent must intersect with:
¯ If you have an event, use its input group field if it’s nonzero.
¯ If you don’t have an event, use the value of the PHIG environment
variable (if defined and nonzero).
¯ As a last resort, specify an input group of 1.
Ph QUERY GRAPHICS
Return a graphics driver rectangle.
Ph QUERY INPUT GROUP
Return input group’s rectangle.
Ph QUERY EXACT
The visible extent that the function finds must match both
input group and rid; otherwise, rid is a hint.
Ph QUERY IG POINTER
Use the current location of input group’s pointer (rid is
ignored).
Ph QUERY IG REGION
Use input group’s rectangle.
Returns:
0 The rect argument is valid.
Examples:
Determine the absolute coordinates of the current console:
PhRect t extent;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PmMemoryContext t * PmMemCreateMC(
PhImage t *mc image,
PhDim t *dim,
PhPoint t *translation );
Description:
This function creates a memory context. A memory context is used to
draw into a local memory image buffer. You must create a memory
context before calling any other Photon Memory (Pm) functions. The
memory context provides definition, control, and access to the
memory image.
The parameters for this function are:
Returns:
A pointer to the new memory context, or NULL if there isn’t enough
memory to allocate one.
Examples:
/* pmmemtobutton.c
*/
#include <mem.h>
#include <photon/PhRender.h>
#include <Pt.h>
image->size = *dim;
image->image = PgShmemCreate(
dim->w * dim->h * bytes per pixel,
NULL );
PtRealizeWidget( window );
PtMainLoop();
void
create image( PhImage t *image, PhDim t *dim )
{
PhPoint t translation = { 0, 0 }, center, radii;
PmMemoryContext t *mc;
PmMemStart( mc );
// now all drawing goes into the memory context
PmMemReleaseMC( mc );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgShmemCreate(), PgShmemDestroy(), PhImage t, PmMemFlush(),
PmMemReleaseMC()
“Flickerless animation” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Synopsis:
int PmMemFlush( PmMemoryContext t *mc,
PhImage t *image );
Description:
This function forces any unprocessed draw-stream commands to be
processed. Then, the PhImage t structure pointed to by image is
filled in with information from the memory image. The image can
then be rendered via any of the PgDrawImage*() or
PgDrawPhImagemx() functions.
Returns:
0 Success.
Examples:
See PmMemCreateMC().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhImage t
“Flickerless animation” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Synopsis:
void PmMemReleaseMC( PmMemoryContext t *mc );
Description:
This function releases the draw context, and shuts down and frees any
resources created by the provided memory context.
If the provided memory context is active at the time of this call, the
default draw context automatically becomes the current draw context.
Examples:
See PmMemCreateMC().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PmMemCreateMC()
“Flickerless animation” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Synopsis:
void PmMemSetChunkSize( PmMemoryContext t *mc,
int size );
Description:
This function sets the increment to be used when growing the
memory context’s draw buffer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PmMemCreateMC(), PmMemReleaseMC(), PmMemSetMaxBufSize(),
PmMemSetType()
“Flickerless animation” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Synopsis:
void PmMemSetMaxBufSize( PmMemoryContext t *mc,
int size );
Description:
This function sets the maximum size that the memory context’s draw
buffer will grow to. The larger the buffer, the less often a flush will be
required, and the faster the application will be. The default size of the
draw buffer is 4K.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PmMemCreateMC(), PmMemReleaseMC(), PmMemSetChunkSize(),
PmMemSetType()
“Flickerless animation” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Synopsis:
void PmMemSetType( PmMemoryContext t *mc,
int type );
Description:
This function sets the type of the memory context pointed to by mc.
The valid types are:
Pm PHS CONTEXT
Renders the draw buffer to image only when necessary (i.e.
when the draw buffer is full, or PmMemFlush() is explicitly
called). Otherwise, the only effect a flush has is to expand the
draw buffer when necessary.
Pm IMAGE CONTEXT
The draw stream is rendered to the image on every flush.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PmMemCreateMC(), PmMemReleaseMC(), PmMemSetChunkSize(),
PmMemSetMaxBufSize()
“Flickerless animation” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Synopsis:
PhDrawContext t * PmMemStart(
PmMemoryContext t *mc );
Description:
This function makes the provided memory context mc active. That is,
from this point until the memory context is deactivated, everything
drawn becomes part of the memory image.
All subsequent Photon draw commands are routed through this
memory context until:
Returns:
A pointer to the previously active draw context, or NULL if the
provided context couldn’t be made active — see errno for details.
Errors:
ENOMEM There wasn’t enough memory for the context’s work
buffers.
Examples:
See PmMemCreateMC().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PmMemCreateMC(), PmMemReleaseMC(), PmMemStop()
“Flickerless animation” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Synopsis:
PhDrawContext t * PmMemStop(
PmMemoryContext t *mc );
Description:
This function deactivates the memory context mc, if it’s active,
making the default draw context active. This means that draw
commands are sent to Photon (i.e. draws will no longer be affecting
the memory image).
Returns:
The mc argument if the memory context was successfully deactivated,
or NULL if it wasn’t active at the time of this call.
Examples:
See PmMemCreateMC().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PmMemCreateMC(), PmMemReleaseMC(), PmMemStart()
“Flickerless animation” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Synopsis:
int PpLoadPrinter( PpPrintContext t *pc,
char const *name );
Description:
This function initializes the provided print context with the printer file
information for the printer section named name. If name isn’t
provided, this function loads the attributes of the default printer as
specified in the printer files. The files used by this function are:
¯ $HOME/.photon/print/config
¯ $PHOTON PATH/print/printers
/usr/photon
Before Photon 1.13.
/qnx4/photon
Photon 1.13 or later.
Returns:
0 Success.
Examples:
PpPrintContext t *pc = PpPrintCreatePC();
PpLoadPrinter( pc, "PostScript Printer");
PpPrintOpen( pc );
PpPrintStart( pc );
// Draw stuff
PpPrintStop( pc );
PpPrintClose( pc );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PpPrintClose( PpPrintContext t *pc );
Description:
This function completes the current print job for the provided print
context, pc. If the print context is active, it’s deactivated as if
PpPrintStop() had been called.
When this function returns, the printed output has been generated and
sent to the destination specified in the print context.
Returns:
0 Success.
Examples:
See PpPrintStart().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpPrintCreatePC(), PpPrintGetPC(), PpPrintNewPage(),
PpPrintOpen(), PpPrintReleasePC(), PpPrintSetPC(),
PpPrintStart(), PpPrintStop(), PpPrintWidget()
Synopsis:
PpPrintContext t *PpPrintCreatePC( void );
Description:
This function creates a print context. You must create a print context
before calling any other Photon Print (Pp) functions.
The print context describes all aspects of a print job required by the
printing functions and the print drivers: Pp.pcl, Pp.ps, Pp.epc2,
and so on.
Returns:
A pointer to the new print context, or NULL if there isn’t enough
memory to allocate one.
Examples:
See PpPrintStart().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpPrintClose(), PpPrintGetPC(), PpPrintNewPage(), PpPrintOpen(),
PpPrintReleasePC(), PpPrintSetPC(), PpPrintStart(), PpPrintStop(),
PpPrintWidget(), PtPrintSelection()
Synopsis:
void * PpPrintGetPC( PpPrintContext t *pc,
int member,
const void ** const data);
Description:
Use this function to query the attributes of a print context.
☞ Don’t extract values directly from the data structure. Your application
might not work if the structure changes in the future.
Member Data
Pp PC NAME address of a char * (string)
Pp PC LOCATION address of a char * (string)
Pp PC DEVICE address of a char * (string)
Pp PC DRIVER address of a char * (string)
Pp PC NONPRINT MARGINS address of a PhRect t *
continued. . .
Member Data
Pp PC PROP APP address of a char * (string)
Pp PC PREVIEW APP address of a char * (string)
Pp PC FILENAME address of a char * (string)
Pp PC COMMENT address of a char * (string)
Pp PC DATE address of a char * (string)
Pp PC USER ID address of a char * (string)
Pp PC PAGE RANGE address of a char * (string)
Pp PC SOURCE OFFSET address of a PhPoint t *
Pp PC SOURCE SIZE address of a PhDim t *
Pp PC SOURCE RESOLUTION address of a PhDim t *
Pp PC SOURCE COLORS address of a ulong t *
Pp PC SCALE address of a PhPoint t *
Pp PC MARGINS address of a PhRect t *
Pp PC INTENSITY address of a ulong t *
Pp PC PRINTER RESOLUTION address of a PhDim t *
Pp PC PAPER SIZE address of a PhDim t *
Pp PC COLLATING MODE address of a char * ( value )
Pp PC DITHERING address of a char * ( value )
Pp PC COPIES address of a char * ( value )
Pp PC ORIENTATION address of a char * ( value )
Pp PC DUPLEX address of a char * ( value )
Pp PC PAPER TYPE address of a char * ( value )
Pp PC PAPER SOURCE address of a char * ( value )
continued. . .
Member Data
Pp PC INKTYPE address of a char * ( value )
Pp PC COLOR MODE address of a char * ( value )
Pp PC DO PREVIEW address of a char * ( value )
Pp PC JOB NAME address of a char * (string)
Pp PC CONTROL address of a PpPCControl t *
Returns:
A pointer to the requested data, or NULL if an unrecognized member
was specified.
Examples:
int get it( PtWidget t *widget, ApInfo t *apinfo,
PtCallbackInfo t *cbinfo )
PhDim t *dim;
void *pc data;
PpPrintContext t *pc;
pc = PpPrintCreatePC();
// A string:
PpPrintGetPC( pc, Pp PC NAME, &pc data );
printf( "printer: %s\n", (char *)pc data );
// A structure ( PhDim t ):
PpPrintGetPC( pc, Pp PC PAPER SIZE, &pc data );
printf( "paper height: %d, width: %d\n",
((PhDim t *)pc data)->h, ((PhDim t *)pc data)->w );
// A long value:
PpPrintGetPC( pc, Pp PC INTENSITY, &pc data );
printf( "intensity: %ld\n", *(long *)pc data );
PpPrintReleasePC( pc );
return Pt CONTINUE;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpPrintClose(), PpPrintCreatePC(), PpPrintGetPC(),
PpPrintNewPage(), PpPrintReleasePC(), PpPrintSetPC(),
PpPrintStart(), PpPrintStop(), PpPrintWidget()
Synopsis:
int PpPrintNewPage( PpPrintContext t *pc );
Description:
This function places a New Page command in the draw stream for the
specified print context, pc, followed by all the changes made to the
print context since PpPrintNewPage() was called or the print context
was opened (initialized).
If the print context isn’t currently active, PpPrintStart() is called
before the New Page command is inserted. The draw context that was
active when the call was made is restored before PpPrintNewPage()
returns.
Returns:
0 Success.
Examples:
See PpPrintStart().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpPrintClose(), PpPrintCreatePC(), PpPrintGetPC(),
PpPrintOpen(), PpPrintReleasePC(), PpPrintSetPC(),
PpPrintStart(), PpPrintStop(), PpPrintWidget()
Synopsis:
int PpPrintOpen( PpPrintContext t *pc );
Description:
This function initializes the current print job. This includes opening
the destination device or file and writing out the print-start command
and any modified portions of the print context.
The pc argument is a pointer to the print context for the print job. This
must have been created by PpPrintCreatePC(), and may have been
configured by calls to PpPrintSetPC(), or by the PtPrintSel widget.
You normally call this function after setting up the print context with
PpPrintSetPC() and/or the PtPrintSelection() convenience function.
If the Pp PC DEVICE or Pp PC FILENAME member of the print
context isn’t specified, the printer in Pp PC NAME is used to
determine the print destination. If Pp PC NAME isn’t specified either,
the default printer definition is used. If a print destination still isn’t set
in the print context, PpPrintOpen() fails and errno is set to ESRCH.
Returns:
0 Success.
Errors:
ESRCH No output target is specified in the print context and no
printer definition could be found
Examples:
See PpPrintStart().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpPrintClose(), PpPrintCreatePC(), PpPrintGetPC(),
PpPrintNewPage(), PpPrintReleasePC(), PpPrintSetPC(),
PpPrintStart(), PpPrintStop(), PpPrintWidget()
Synopsis:
void PpPrintReleasePC( PpPrintContext t *pc );
Description:
This function releases the draw context, shuts down, and frees the
resources used by the provided print context.
If the provided print context’s draw context is the current draw
context, the default draw context automatically becomes the current
draw context.
Examples:
See PpPrintStart().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpPrintClose(), PpPrintCreatePC(), PpPrintGetPC(),
PpPrintNewPage(), PpPrintOpen(), PpPrintSetPC(), PpPrintStart(),
PpPrintStop(), PpPrintWidget()
Synopsis:
int PpPrintSetPC( PpPrintContext t *pc,
int mod level,
int lock,
int member,
void const * const data);
Description:
This function provides a mechanism to modify the attributes of a print
context.
Member Data
Pp PC NAME String
Pp PC LOCATION String
Pp PC DEVICE String
Pp PC DRIVER String
Pp PC NONPRINT MARGINS PhRect t *
Pp PC PROP APP String
Pp PC PREVIEW APP String
Pp PC FILENAME String
Pp PC COMMENT String
Pp PC DATE String
Pp PC USER ID String
Pp PC PAGE RANGE String
Pp PC SOURCE OFFSET PhPoint t *
Pp PC SOURCE SIZE PhDim t *
continued. . .
Member Data
Pp PC SOURCE RESOLUTION PhPoint t *
Pp PC SOURCE COLORS int *
Pp PC SCALE PhPoint t *
Pp PC MARGINS PhRect t *
Pp PC INTENSITY int *
Pp PC PRINTER RESOLUTION PhPoint t *
Pp PC PAPER SIZE PhDim t *
Pp PC COLLATING MODE char *
Pp PC DITHERING char *
Pp PC COPIES char *
Pp PC ORIENTATION char *
Pp PC DUPLEX char *
Pp PC PAPER TYPE char *
Pp PC PAPER SOURCE char *
Pp PC INKTYPE char *
Pp PC COLOR MODE char *
Pp PC DO PREVIEW char *
Pp PC JOB NAME String
Pp PC CONTROL Read only: see PpPrintGetPC()
Returns:
0 Success.
Errors:
EPERM The specified member was set by a modification level
that supersedes mod level:
INTERACTIVE PC supersedes
INITIAL PC, which supersedes
PRINTER LOCAL, which supersedes
PRINTER GLOBAL
For example,
Examples:
set my apps Pp prefs( PpPrintContext t *pc )
{
char do preview = 1, duplex = some value;
PpPrintSetPC( pc, INITIAL PC, 0,
Pp PC DO PREVIEW, &do preview );
PpPrintSetPC( pc, INITIAL PC, 0,
Pp PC DUPLEX, &duplex );
PpPrintSetPC( pc, INITIAL PC, 0,
Pp PC COMMENT,
"Hey, this is a comment!" );
// etc...
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpPrintClose(), PpPrintCreatePC(), PpPrintGetPC(),
PpPrintNewPage(), PpPrintOpen(), PpPrintReleasePC(),
PpPrintStart(), PpPrintStop(), PpPrintWidget()
Printing in the Programmer’s Guide
Synopsis:
PhDrawContext t *PpPrintStart(
PpPrintContext t *pc );
Description:
This function makes the provided print context pc active (i.e. from
this point until the print context is deactivated, everything drawn is
part of the printed output). The print context is initialized if this hasn’t
already been done by a call to PpPrintOpen().
All subsequent Photon draw commands are routed through this print
context until:
You can print widgets by damaging them and then calling PtFlush().
Returns:
A pointer to the previously active draw context, or NULL if the print
context couldn’t be made active — see errno for the specific error.
Errors:
ESRCH No output target is specified in the print context and no
printer definition could be found
Examples:
To print the contents of a scroll area:
...
pc = PpPrintCreatePC();
return Pt CONTINUE;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpPrintClose(), PpPrintCreatePC(), PpPrintGetPC(),
PpPrintNewPage(), PpPrintOpen(), PpPrintReleasePC(),
PpPrintSetPC(), PpPrintStop(), PpPrintWidget()
Synopsis:
void PpPrintStop( PpPrintContext t *pc );
Description:
This function deactivates the print context pc, if it’s active, making the
default draw context active. This means that draw commands are sent
to Photon (i.e. printing is turned off).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpPrintClose(), PpPrintCreatePC(), PpPrintGetPC(),
PpPrintNewPage(), PpPrintOpen(), PpPrintReleasePC(),
PpPrintSetPC(), PpPrintStart(), PpPrintWidget()
Synopsis:
void PpPrintWidget( PpPrintContext t *pc,
PtWidget t *widget,
PhPoint t const *trans,
PhRect t const *clip rect,
ulong t opt );
Description:
This function prints the specified widget using the provided print
context. The arguments are:
Examples:
#include <Ph.h>
#include <Pt.h>
main()
{
int n;
PhArea t area, sev area = {0,0,400,400};
PpPrintContext t *pc;
PtInit( NULL );
pc = PpPrintCreatePC();
PpPrintOpen( pc );
n = 0;
PtSetArg( &args[n++], Pt ARG AREA, &sev area, 0 );
PtSetArg( &args[n++], Pt ARG FILL COLOR, Pg BLUE, 0);
button = PtCreateWidget( PtButton, NULL, n, args );
PpPrintStart( pc );
PtWidgetArea( button, &area);
PpPrintWidget( pc, button,
&area.pos,
NULL,
Pt PP RESIZE PC );
PtFlush();
PpPrintStop( pc );
PtMainLoop();
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpPrintClose(), PpPrintCreatePC(), PpPrintGetPC(),
PpPrintNewPage(), PpPrintOpen(), PpPrintReleasePC(),
PpPrintSetPC(), PpPrintStart(), PpPrintStop()
Printing in the Programmer’s Guide
Synopsis:
void PtAddCallback( PtWidget t *widget,
unsigned long callback type,
PtCallbackF t *callback,
void *data );
Description:
This function adds a callback to the callback list indicated by
callback type (e.g. Pt CB ACTIVATE).
Pt CB HOTKEY
PtAddHotkeyHandler()
Examples:
activated( PtWidget t *widget, void *data,
PtCallbackInfo t *info)
{
//suppress compiler warnings concerning unused arguments.
widget = widget, data = data, info = info;
exit( 0 );
}
main()
{
PtArg t argt;
PtWidget t *window, *widget;
PtRealizeWidget( window );
PtMainLoop();
//unnecessary
PtRemoveCallback( button, Pt CB ACTIVATE,
activated, NULL );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddCallbacks(), PtAddEventHandler(), PtAddEventHandlers(),
PtAddHotkeyHandler(), PtRemoveCallback(), PtRemoveCallbacks()
Creating Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
void PtAddCallbacks( PtWidget t *widget,
unsigned long callback type,
PtCallback t const *callback defs,
unsigned int num callbacks );
Description:
This function adds the number of callbacks specified by
num callbacks to the callback list specified by callback type (e.g.
Pt CB ACTIVATE).
Pt CB HOTKEY
PtAddHotkeyHandler()
Examples:
PtWidget t *widget
PtCallback t callbacks[]={
my first callback, NULL ,
my second callback, "Number 2",
my last callback, NULL
};
.
.
.
PtAddCallbacks( widget, Pt CB ACTIVATE, callbacks, 3 );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddCallback(), PtAddEventHandler(), PtAddEventHandlers(),
PtAddHotkeyHandler(), PtRemoveCallback(), PtRemoveCallbacks(),
Creating Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
int PtAddData( PtDataHdr t **ptr,
long type,
long subtype,
void *data,
long len,
PtDataRemoveF t *remove );
Description:
This function adds a piece of data to the provided data chain. The data
provided must be in a block of memory created by malloc(). This data
can be retrieved by calling PtFindData(), or PtFindNextData().
The arguments are:
ptr The address of the pointer to the chain the data should be
added to.
Returns:
0 on success, or -1 if an error (e.g. out of memory) occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFindData(), PtFindNextData(), PtRemoveData(), PtUnlinkData()
Synopsis:
void PtAddEventHandler( PtWidget t *widget,
unsigned long event mask,
PtCallbackF t *callback,
void *data );
Description:
This function adds the specified callback to the Pt CB RAW callback
list that belongs to widget. The widget invokes this callback whenever
an event type that matches one of the bits in event mask intersects
with the widget.
The callback argument points to a function that takes this form:
Examples:
PtWidget t *widget;
PtRawCallback t callbacks[] = {
Ph EV PTR MOTION BUTTON,
motion button callback,
NULL,
Ph EV BUT PRESS | Ph EV BUT RELEASE,
start end callback,
"some data"
}
...
//add both event handlers
PtAddEventHandlers( widget, callbacks, 2 );
...
//remove both event handlers
PtRemoveEventHandlers( widget, callbacks, 2 );
...
//add the motion button event handler
PtAddEventHandler( widget, Ph EV PTR MOTION BUTTON,
motion button callback, NULL );
...
//remove the motion button event handler
PtRemoveEventHandler( widget, Ph EV PTR MOTION BUTTON,
motion button callbacks, NULL )
...
//add both event handlers
PtAddEventHandlers( widget, callbacks, 2 );
...
//remove the motion button event handler
PtRemoveEventHandler( widget, Ph EV PTR MOTION BUTTON,
motion button callbacks, NULL )
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtRemoveEventHandler(), PtAddCallback(), PtAddCallbacks(),
PtAddEventHandlers(), PtAddHotkeyHandler()
Synopsis:
void PtAddEventHandlers(
PtWidget t *widget,
PtRawCallback t const *callback defs,
unsigned int num handlers );
Description:
This function adds the number of event handlers specified by
num handlers to the Pt CB RAW callback list that belongs to widget.
The callback defs argument contains the address of an array of
PtRawCallback t structures. See <PtT.h>.
Examples:
See PtAddEventHandler().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtRemoveEventHandlers(), PtAddCallback(), PtAddCallbacks(),
PtAddEventHandler(), PtAddHotkeyHandler()
Synopsis:
void PtAddHotkeyHandler( PtWidget t *widget,
unsigned key sym cap,
unsigned key mods,
short flags,
void *data,
PtCallbackF t *callback );
Description:
This function adds the specified callback to the Pt CB HOTKEY
callback list that belongs to the specified widget. The widget will
invoke this callback whenever all three of the following conditions are
met:
Pt HOTKEY SYM
Interpret key sym cap as a key sym; the default is to interpret it
as a key cap.
Hotkey entries are stacked. As a result, the last hotkey attached is the
first to be checked.
If a hotkey callback is triggered, the key event is consumed and no
other hotkey callbacks will be invoked. If callback is NULL, the
widget’s Pt CB ACTIVATE callback list is invoked when the hotkey is
pressed.
Note the following:
Hotkeys are handled at the window level. So if two widgets within the
same window happen to register the same hotkey definition, only the
callback for the last duplicate hotkey is invoked.
Hotkey callbacks are automatically registered when the owner widget
is realized, and automatically removed when the owner widget is
unrealized.
Examples:
PtWidget t *widget1, *widget2, *widget3, *window;
.
.
.
// add a hotkey to the window on the key sym
// for Escape.
PtAddHotkeyHandler( widget1, Pk 1, 0,
Pt HOTKEY IGNORE MODS,
NULL, one callback );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtRemoveHotkeyHandler(), PtAddCallback(), PtAddCallbacks(),
PtAddEventHandler(), PtAddEventHandlers()
Synopsis:
int PtAppAddFd( PtAppContext t app,
int fd,
unsigned mode,
PtFdProc t fun,
void *data);
Description:
These functions install an “FD function” that will inform the
application about device events.
The app argument is the address of the application context, a structure
that manages all the data associated with this application. For Photon
1.1x, this must be specified as NULL, so that the default context is
used.
The mode argument defines what kind of conditions the application is
interested in:
The fd and data arguments will have the same value as the fd and data
arguments to PtAppAddFd(). The mode argument will indicate which
conditions were actually met.
If the fun function returns a value other than Pt CONTINUE, it will be
removed automatically from the list of fd functions.
There are other flags that you can add to the mode argument to
PtAppAddFd(). They can be used for optimizing the performance by
avoiding unnecessary messages. Note that these flags aren’t
necessarily implemented for both QNX 4 and Neutrino; if a flag isn’t
implemented, it’s defined as zero.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppCreatePulse(), PtAppRemoveFd(), PtAppSetFdMode()
“Other I/O mechanisms” in the Interprocess Communication and
Lengthy Operations chapter of the Programmer’s Guide
Synopsis:
PtInputId t *PtAppAddInput(
PtAppContext t app context,
pid t pid,
PtInputCallbackProc t input func,
void *data );
Description:
This routine adds a function to a PtMainLoop() input-event
processing chain.
The app argument is the address of the application context, a structure
that manages all the data associated with this application. For Photon
1.1x, this must be specified as NULL, so that the default context is
used.
The input function is executed whenever the application receives a
message from process pid. If pid is negative, it’s the ID of a Photon
pulse.
If you specify a pid of 0, the input function will be called for every
non-Photon event message that’s received, but only if there’s no input
function that catches messages from the sending pid specifically.
The rcvid argument that the input function will get may have a
different value:
¯ Under QNX 4, the rcvid is the same as the PID, and the
PtGetRcvidPid() function is a macro that returns its argument:
#define PtGetRcvidPid( pid ) (pid)
Returns:
A pointer to a PtInputId t structure that uniquely identifies the
specified input function for the given application context. If an error
occurs, the function returns NULL.
Examples:
// From /qnx4/phtk/apps/msgpass register name.c
int
msg handler( void *data, pid t rcvid,
void *message, ushort t size)
{
struct msg s
{
unsigned type;
unsigned color;
} *msg;
/****************************************************/
/*** The following function would normally ***/
/*** be placed in an AppBuilder Init function. ***/
/*** See Application menu, Startup Info. The ***/
/*** function is set up here as a button callback ***/
/*** to clarify the sample’s operation. ***/
/****************************************************/
int
register name( PtWidget t *widget, void *data,
PtCallbackInfo t *cbinfo )
{
PtArg t args[5];
PtInputId t *ipid;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtMainLoop(), PtAppRemoveInput(), PtSetParentWidget(),
PtResizeEventMsg()
“Receiving QNX messages” in the Interprocess Communication and
Lengthy Operations chapter of the Programmer’s Guide
Synopsis:
int PtAppAddSignalProc( PtAppContext t app,
sigset t const *set,
PtSignalProc t func,
void *data);
Description:
This function adds Photon signal handling to the context app.
The app argument is the address of the application context, a structure
that manages all the data associated with this application. For Photon
1.1x, this must be specified as NULL, so that the default context is
used.
All signals in the set set are trapped and directed to a function that
synchronizes with the Photon widget library and, at the next safe
point, invokes the user-supplied function func().
The user callback function is declared as follows:
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppRemoveSignal(), PtAppRemoveSignalProc()
Interprocess Communication and Lengthy Operations in the Photon
Programmer’s Guide
Synopsis:
PtWorkProcId t *PtAppAddWorkProc(
PtAppContext t app context,
PtWorkProc t work func,
void *data );
Description:
This function adds a WorkProc entry to the WorkProc (background)
process stack. The entry becomes the current WorkProc entry.
☞ WorkProc functions don’t run concurrently; only the one at the top of
the stack runs.
When there are no events pending from Photon, the current WorkProc
entry’s function is invoked by PtMainLoop().
The app argument is the address of the application context, a structure
that manages all the data associated with this application. For Photon
1.1x, this must be specified as NULL, so that the default context is
used.
The work func argument points to the WorkProc function to be
invoked when no Photon events are pending. The function takes this
form:
int (*work func)(void *data)
You can declare the function to be of type PtWorkProcF t to take
advantage of the compiler’s type-checking.
Returns:
A pointer to a PtWorkProcId t structure that identifies the specified
WorkProc entry for the given application context. If an error occurs,
the function returns NULL.
Examples:
This example comes from the Rebound demo, which you’ll find in
/qnx4/phtk/apps/rebound. These are the callbacks that start and
stop the rebounding work procedure, rebound process(), which is in
src/rb process.
if(stopped) {
if ( delay value == 0 ) {
if ( !bkgd id ) // is one running?
bkgd id = PtAppAddWorkProc( NULL, rebound process,
ABW rb pane );
PtSetArg( &args[0], Pt ARG TIMER INITIAL, 0, 0 );
PtSetResources( ABW timer wgt, 1, args );
} else {
if ( bkgd id )
PtAppRemoveWorkProc( NULL, bkgd id );
PtSetArg( &args[0], Pt ARG TIMER INITIAL, 1, 0 );
PtSetArg( &args[1], Pt ARG TIMER REPEAT,
SPEED MULTIPLY*delay value, 0 );
PtSetResources( ABW timer wgt, 2, args );
}
stopped = 0;
}
return( Pt CONTINUE );
}
if ( bkgd id ) {
PtAppRemoveWorkProc( NULL, bkgd id );
bkgd id = NULL;
}
PtSetArg( &args[0], Pt ARG TIMER INITIAL, 0, 0 );
PtSetResources( ABW timer wgt, 1, args );
stopped = 1;
return( Pt CONTINUE );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtMainLoop(), PtAppRemoveWorkProc(), PtSetParentWidget()
Synopsis:
pid t PtAppCreatePulse( PtAppContext t app,
int priority );
Description:
This function creates a Photon pulse. Under QNX 4, a proxy is
created. Under Neutrino, a pulse or realtime signal will be used.
The app argument is the address of the application context, a structure
that manages all the data associated with this application. For Photon
1.1x, this must be specified as NULL, so that the default context is
used.
The priority parameter specifies the priority of the pulse. If priority is
-1, the pulse’s priority is the same as that of the calling process.
Returns:
A pulse PID (a negative value that’s guaranteed never to be -1), or 0 if
an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppDeletePulse(), PtAppPulseTrigger(), PtChannelCreate(),
PtPulseArmFd(), PtPulseArmPid(), PtPulseDeliver(),
PtPulseDisarm()
Synopsis:
int PtAppDeletePulse( PtAppContext t app,
pid t pulse pid );
Description:
This function deletes the Photon pulse identified by pulse pid (and the
proxy in QNX 4). The pulse pid identifies a pulse created by
PtAppCreatePulse().
The app argument is the address of the application context, a structure
that manages all the data associated with this application. For Photon
1.1x, this must be specified as NULL, so that the default context is
used.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppCreatePulse(), PtAppPulseTrigger(), PtChannelCreate(),
PtPulseArmFd(), PtPulseArmPid(), PtPulseDeliver(),
PtPulseDisarm()
Interprocess Communication and Lengthy Operations in the Photon
Programmer’s Guide
Synopsis:
PtWidget t *PtAppInit( PtAppContext t *app context,
int *argc,
char **argv,
int num args,
PtArg t const *args );
Description:
This function:
¯ Creates a main window using the num args and args arguments —
these are the same arguments passed to PtCreateWidget().
Returns:
A pointer to the main window, or NULL if an error occurs.
Examples:
See PtContainerGiveFocus().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAttach(), PtCreateWidget(), PtInit(), PtMainLoop()
Synopsis:
int PtAppPulseTrigger( PtAppContext t app,
pid t pulse );
Description:
This function allows an application to deliver a pulse to itself:
¯ In QNX 4, the value of pulse must match the pulse PID exactly.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppCreatePulse(), PtAppDeletePulse(), PtChannelCreate(),
PtPulseArmFd(), PtPulseArmPid(), PtPulseDeliver(),
PtPulseDisarm()
Interprocess Communication and Lengthy Operations in the Photon
Programmer’s Guide
Synopsis:
int PtAppRemoveFd( PtAppContext t app, int fd );
Description:
This function removes an FD function, fd, from the of input handlers
for the application.
The app argument is the address of the application context, a structure
that manages all the data associated with this application. For Photon
1.1x, this must be specified as NULL, so that the default context is
used.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddFd(), PtAppAddFdPri(), PtAppSetFdMode()
“Other I/O mechanisms” in the Interprocess Communication and
Lengthy Operations chapter of the Programmer’s Guide
Synopsis:
void PtAppRemoveInput( PtAppContext t app context,
PtInputId t *input id );
Description:
This routine removes an input entry from the input-event processing
chain.
The app context argument indicates which application context the
input entry will be removed from. If you specify NULL, the function
will try to remove the entry from the default context.
The input id argument points to a PtInputId t structure that
describes the input entry to be removed. (This structure was returned
by a previous call to PtAppAddInput().)
Examples:
See PtAppAddInput().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddInput(), PtMainLoop()
“Receiving QNX messages” in the Interprocess Communication and
Lengthy Operations chapter of the Programmer’s Guide
Synopsis:
int PtAppRemoveSignal( PtAppContext t app,
sigset t const *set,
PtSignalProc t proc,
void *data );
Description:
This function removes Photon signal handling from the context app:
¯ If set is NULL, this function removes all items that match proc and
data.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddSignalProc(), PtAppRemoveSignalProc()
Interprocess Communication and Lengthy Operations in the
Programmer’s Guide
Synopsis:
int PtAppRemoveSignalProc( PtAppContext t app,
sigset t const *set);
Description:
This function removes Photon signal handling from the context app.
All signals in the set set which were previously trapped are set back to
the default handler (SIG DFL), and any outstanding notification of
these signals is canceled.
!
CAUTION: This function will remove any handlers for the given
signals used internally by the libraries. You should use
PtAppRemoveSignal() instead.
Returns:
0
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddSignalProc(), PtAppRemoveSignal()
Interprocess Communication and Lengthy Operations in the
Programmer’s Guide
Synopsis:
void PtAppRemoveWorkProc(
PtAppContext t app context,
PtWorkProcId t *WorkProc id );
Description:
This routine removes a WorkProc function from the WorkProc
event-processing stack.
The app context argument indicates which application context the
WorkProc function will be removed from. To remove the entry from
the default context, specify NULL.
The WorkProc id argument points to a PtWorkProcId t structure
that describes the WorkProc entry to be removed. (This structure was
returned by a previous call to PtAppAddWorkProc().)
Examples:
See PtAppAddWorkProc().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddWorkProc(), PtMainLoop()
Synopsis:
int PtAppSetFdMode( PtAppContext t app,
int fd,
unsigned mode );
Description:
This function changes the mode that’s of intereset to the handler for
the given file descriptor, fd.
The app argument is the address of the application context, a structure
that manages all the data associated with this application. For Photon
1.1x, this must be specified as NULL, so that the default context is
used.
The mode argument defines what kind of conditions the application is
interested in:
Returns:
0 Success.
Errors:
EINVAL The fd or mode argument is invalid.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddFd(), PtAppAddFdPri(), PtAppRemoveFd()
“Other I/O mechanisms” in the Interprocess Communication chapter
of the Photon Programmer’s Guide
Synopsis:
typedef struct Pt arg entry {
long type;
long value;
long len;
} PtArg t;
Description:
You use the PtArg t structure extensively when dealing with widget
resources. It’s the first argument in the PtSetArg() macro.
This structure contains at least the following members:
value Either the value to set the resource to or, if you’re querying
the resource, the address of a pointer.
Classification:
Photon
See also:
Pt ARG(), PtCreateWidget(), PtGetResources() PtSetArg(),
PtSetResources()
Manipulating Resources in Application Code chapter of the Photon
Programmer’s Guide.
Synopsis:
#define Pt ARG( type, value, len ) { ... }
Description:
This macro lets you have statically initialized argument lists as an
alternative to using PtSetArg(). For example, instead of:
PhPoint t pos;
PtArg t args[ 2 ];
pos.x = 100;
pos.y = 150;
This makes adding or removing items easier and safer because the
compiler counts the items in the array for you. And as a bonus, it
generates less code than the first version.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Caveats:
Pt ARG() is a macro.
See also:
PtArg t, PtGetResources(), PtSetArg(), PtSetResources()
Manipulating Resources in Application Code chapter of the Photon
Programmer’s Guide.
Synopsis:
int PtAskQuestion( PtWidget t *parent,
char const *title,
char const *question,
char const *font,
char const *btn1,
char const *btn2,
char const *btn3,
int def btn );
Description:
This function displays a dialog that asks the user a question and that
contains up to three buttons so the user can answer the question. The
function works modally, which means that it processes Photon events
and won’t return until the user chooses a reply.
The title argument defines a title for the dialog. If you don’t want a
title, set the argument to NULL.
The question argument lets you specify the question you want to ask.
The font argument lets you choose the font for the question text; the
default is helv12.
The btn1, btn2, and btn3 arguments let you specify the text of buttons
1, 2, and 3. Buttons 2 and 3 are optional, so if you don’t want to
display one or both of these, set the corresponding argument to NULL.
All three button-text arguments let you to define shortcut keys.
Simply place & in front of the character that will act as the shortcut.
For example, if you specify &Yes, the Y will be underlined in the
button. To select the button, the user can press y or Y.
The def btn argument specifies the number of the button that will act
as the default when the user presses Enter. The text of the default
button is always displayed in bold.
Note that the user can change the default by pressing Tab.
Returns:
The number of the button the user selected.
Examples:
switch( PtAskQuestion( base wgt, NULL,
"File has not been saved. Save it?",
"helv14", "&Save", "&Discard",
"&Cancel", 1 ) ) {
case 1: /* yes */
/* save and return back */
if ( Pt HALT == file save( widget, data,
cbinfo ) )
return;
break;
case 2: /* no */
/* continue processing */
break;
case 3: /* cancel */
/* return back */
return;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApError()
PtMessage in the Widget Reference
Synopsis:
PhRect t *PtBasicWidgetCanvas(
PtWidget t *widget,
PhRect t *canvas rect );
Description:
This function determines the canvas rectangle for the specified
widget’s PtBasic-class level. This canvas rectangle describes the
area inside the widget’s border and margins. The canvas rect
argument should point to an instance of a PhRect t structure; if you
pass canvas rect as NULL, the function returns NULL.
Returns:
A pointer to the canvas of the PtBasic widget. If an error occurs, the
function returns NULL.
Examples:
Return the rectangle inside PtWidget’s border:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtLabelWidgetCanvas(), PtWidgetCanvas(), PtWidgetExtent()
Synopsis:
void PtBkgdHandlerProcess( void );
Description:
This function processes all outstanding Photon events, calling
PtProcessEvent() for each event. You should call this routine
periodically during a costly or complex processing loop when you
won’t be giving control to the widget library. This gives the widget
library an opportunity to redraw widgets that have been damaged or
exposed if, for example, the user drags a window around.
Examples:
{
int done = 0;
while ( !done )
{
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
Synopsis:
int PtCalcAbsPosition( PtWidget t *reference,
PhPoint t const *pos,
PhDim t const *dim,
PhPoint t *new pos );
Description:
This function calculates the position of a new widget with dimensions
dim, according to the reference widget and pos values passed.
The reference argument is a pointer to a widget you wish to position
the new widget relative to. The pos argument is an offset from the
reference widget or from the top left corner of the screen. The dim
argument gives the dimensions of the new widget to be positioned and
must not be NULL. The new pos argument must be a pointer to a
PhPoint t structure. The calculated position is stored in it.
The position is calculated as follows:
Returns:
0 Success
Examples:
If you have a main application window and want to center a dialog on
it, you could do the following:
...
// make a main window
window = PtAppInit( &app, &argc, argv, n args, args );
...
err = PtCalcAbsPosition(window, NULL, &dim, &pos);
...
// Create the dialog and position it at ’pos’ --
// it will be centered on the window.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtChannelCreate( void );
Description:
In QNX 4, this function simply returns 1.
In Neutrino, this function makes sure that the widget library is using a
channel (rather than realtime signals) for notification. It returns the
channel number (or -1 on failure).
Returns:
There’s no such thing as a channel in QNX 4, so this function simply
returns 1.
In Neutrino, this function returns the channel number, or -1 on failure.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtChildType( PtWidget t *parent,
PtWidget t *child );
Description:
This function returns Pt IMMEDIATE CHILD if the provided child is
the immediate child of parent or Pt SUBORDINATES CHILD if the
child is a child of a procreated child of parent. Otherwise Pt FALSE is
returned.
Returns:
Pt IMMEDIATE CHILD
The provided child is the immediate child of parent.
Pt SUBORDINATES CHILD
The child is a child of a procreated child of parent.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetBrotherBehind(), PtWidgetBrotherInFront(),
PtWidgetChildBack(), PtWidgetChildFront(), PtWidgetParent()
Synopsis:
int PtClearWidget(PtWidget t *widget);
Description:
This function destroys all the widgets within the specified
container-class widget. If the specified widget isn’t a container, no
action is taken.
Returns:
0 Successful completion.
Examples:
main()
{
PtWidget t *group, *window;
PtArg t argt;
PtArg t argts[3];
PhPoint t pos ={ 10,10 };
PtInit( NULL );
PtSetArg( &argt, Pt ARG POS, &pos, 0 );
window = PtCreateWidget( PtWindow, parent, 1, &argt );
PtRealizeWidget( window );
PtContainerHold( group );
PtClearWidget( group );
PtContainerRelease( group );
PtMainLoop();
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerHold(), PtContainerRelease(), PtDestroyWidget(),
PtExtentWidget(), PtWidgetChildBack()
Synopsis:
int PtConsoleSwitch( int console );
Description:
This function causes PWM to switch the current display to the virtual
console console (where console is a number in the range 0 to 8):
0 1 2
3 4 5
6 7 8
Virtual consoles are numbered from 0 through 8, with 0 at the top left,
and 8 at the lower right. The coordinates of the top left corner of
console 0 are (0,0). The coordinates of the other consoles depend on
your screen size.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWindowConsoleSwitch()
Synopsis:
PtWidget t * PtContainerBox( PtWidget t *container,
PtWidget t *start,
PhRect t const *rect );
Description:
This function returns a pointer to the first widget within the specified
container that intersects with the provided rectangle.
The widget identified by start tells the function where to start looking
for intersections. First, the function checks start’s brother behind.
Then, it then checks the brother behind that, and so on.
Returns:
If no widget after start intersects with rect or if the provided container
pointer doesn’t actually point to a container, the function returns
NULL.
Examples:
PtWidget t *target widget, *my pane;
...
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetRects(), PtContainerHit(), PtWidgetChildFront()
Synopsis:
PtWidget t *PtContainerFindFocus(
PtWidget t *family member );
Description:
This function finds the focused widget for the widget hierarchy that
contains family member.
Returns:
A pointer to the currently focused widget, or NULL if family member
is passed as NULL.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerGiveFocus(), PtContainerNullFocus(),
PtContainerFocusNext(), PtContainerFocusPrev(),
PtGlobalFocusNext(), PtGlobalFocusNextFrom(),
PtGlobalFocusPrev(), PtGlobalFocusPrevFrom(), PtIsFocused()
Synopsis:
PtWidget t *PtContainerFocusNext(
PtWidget t *widget,
PhEvent t *event );
Description:
This function gives focus to the next widget that has Pt GETS FOCUS
set in its Pt ARG FLAGS and is in the same container as the currently
focused widget in widget’s family. If no widget has the
Pt GETS FOCUS flag set, the container’s focus is nullified (that is,
none of its children will have focus).
The event argument contains the event that’s passed to the lost-focus
callback of the widget losing focus and to the got-focus callback of
the widget getting focus.
If event isn’t provided, a NULL event is generated for you.
Returns:
A pointer to the newly focused widget.
Examples:
See PtContainerGiveFocus().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerFocusPrev(), PtContainerGiveFocus(),
PtContainerNullFocus()
Synopsis:
PtWidget t *PtContainerFocusPrev(
PtWidget t *widget,
PhEvent t *event );
Description:
This function gives focus to the previous widget that has
Pt GETS FOCUS set in its Pt ARG FLAGS and is in the same
container as the currently focused widget in widget’s family. If no
widget has the Pt GETS FOCUS flag set, the container’s focus is
nullified (that is, none of its children will have focus).
The event argument contains the event that’s passed to the lost-focus
callback of the widget losing focus and to the got-focus callback of
the widget getting focus.
If event isn’t provided, a NULL event is generated for you.
Returns:
A pointer to the newly focused widget.
Examples:
See PtContainerGiveFocus().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerFocusNext(), PtContainerGiveFocus(),
PtContainerNullFocus(), PtWidgetExtent()
Synopsis:
PtWidget t *PtContainerGiveFocus(
PtWidget t *widget,
PhEvent t *event );
Description:
This function gives focus to the specified widget, even if the widget’s
Pt GETS FOCUS flag isn’t set.
The event argument contains the event that will be passed to the
lost-focus callback of the widget losing focus and to the got-focus
callback of the widget getting focus.
If event isn’t provided, a NULL event is generated for you.
Returns:
A pointer to the newly focused widget. This is usually the same as the
widget argument, but it could be NULL if one of the following is true:
¯ The widget has been destroyed before the attempt to give it focus.
¯ The event passed (if not NULL) has already caused focus to
change, as indicated by:
event->processing flags & Ph DIRECTED FOCUS
Examples:
first( PtWidget t *widget, void *data,
PtCallbackInfo t *cbinfo )
{
//like selecting texta
PtWidget t *text = (PtWidget t *)data;
PtContainerGiveFocus( text, cbinfo->event );
}
main()
{
PtWidget t *window, *texta, *textb, *textc,
*button;
PhPoint t pos ={ 0, 0 };
PhRect t rect;
int n;
PtArg t argt[5];
PtCallback t focus cbs[] = {
{ first, NULL },
{ next, NULL },
{ prev, NULL },
{ none, NULL }
};
n = 0;
PtSetArg( &argt[n], Pt ARG POS, &pos, 0 ); n++;
PtSetArg( &argt[n], Pt ARG TEXT STRING,
"First Field", 0 ); n++;
texta = PtCreateWidget( PtText, NULL, n, argt );
PtExtentWidget( texta );
PtWidgetExtent( texta, &rect );
pos.y += rect.lr.y + 10;
n = 0;
PtSetArg( &argt[n], Pt ARG POS, &pos, 0 ); n++;
PtSetArg( &argt[n], Pt ARG TEXT STRING,
"First Field", 0 ); n++;
textb = PtCreateWidget( PtText, NULL, n, argt );
PtExtentWidget( textb );
PtWidgetExtent( textb, &rect );
pos.y += rect.lr.y + 10;
n = 0;
PtSetArg( &argt[n], Pt ARG POS, &pos, 0 ); n++;
PtSetArg( &argt[n], Pt ARG TEXT STRING,
"First Field", 0 ); n++;
textc = PtCreateWidget( PtText, NULL, n, argt );
PtExtentWidget( textc );
PtWidgetExtent( textc, &rect );
pos.y += rect.lr.y + 15;
n = 0;
PtSetArg( &argt[n], Pt ARG POS, &pos, 0 ); n++;
PtSetArg( &argt[n], Pt CB ACTIVATE,
focus cbs[0], 1 ); n++;
PtSetArg( &argt[n], Pt ARG TEXT STRING,
"First", 0 ); n++;
button = PtCreateWidget( PtButton, NULL, n, argt );
PtExtentWidget( button );
n = 0;
PtSetArg( &argt[n], Pt ARG POS, &pos, 0 ); n++;
PtSetArg( &argt[n], Pt CB ACTIVATE,
focus cbs[1], 1 ); n++;
PtSetArg( &argt[n], Pt ARG TEXT STRING,
"Next", 0 ); n++;
button = PtCreateWidget( PtButton, NULL, n, argt );
PtExtentWidget( button );
PtWidgetExtent( button, &rect );
pos.x += rect.lr.x + 10;
n = 0;
PtSetArg( &argt[n], Pt ARG POS, &pos, 0 ); n++;
PtSetArg( &argt[n], Pt CB ACTIVATE,
focus cbs[2], 1 ); n++;
PtSetArg( &argt[n], Pt ARG TEXT STRING,
"Prev", 0 ); n++;
button = PtCreateWidget( PtButton, NULL, n, argt );
PtExtentWidget( button );
PtWidgetExtent( button, &rect );
pos.x += rect.lr.x + 10;
n = 0;
PtSetArg( &argt[n], Pt ARG POS, &pos, 0 ); n++;
PtSetArg( &argt[n], Pt CB ACTIVATE,
focus cbs[2], 1 ); n++;
PtSetArg( &argt[n], Pt ARG TEXT STRING,
"None", 0 ); n++;
button = PtCreateWidget( PtButton, NULL, n, argt );
PtExtentWidget( button );
PtWidgetExtent( button, &rect );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerFocusNext(), PtContainerFocusPrev(),
PtContainerNullFocus()
PtWindowFocus() in the Photon Widget Reference
Synopsis:
PtWidget t *PtContainerHit( PtWidget t *container,
unsigned n,
PhRect t const *rect );
Description:
This function returns a pointer to the nth widget within the specified
container that intersects with the provided rectangle. The coordinates
of the rectangle are relative to the given container’s canvas. If no
widget intersects with rect, or if there are fewer than n intersections,
the function returns NULL.
Examples:
PtWidget t *target widget, *my pane;
// ...
rect = PhGetRects( cbinfo->event );
container = PtFindContainer( widget );
target widget = PtContainerHit( container, 1, rect );
if (target widget)
PtDestroyWidget( target widget );
// ...
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetRects(), PtContainerBox()
Synopsis:
int PtContainerHold( PtWidget t *container widget );
Description:
This function prevents repairs to the specified container widget and to
all its children. Repairs aren’t made until the application makes a
corresponding call to PtContainerRelease().
When the widgets are eventually released, they aren’t repaired
separately. Instead, only the container parent widget is repaired. As a
result, the children are all repaired simultaneously.
Returns:
The container widget’s current hold count.
Examples:
See PtClearWidget().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerRelease(), PtFlush(), PtHold(), PtRelease()
Synopsis:
PtWidget t *PtContainerNullFocus(
PtWidget t *widget,
PhEvent t *event );
Description:
This function nullifies the focus of the specified widget’s parent. As a
result, none of parent’s children has focus.
The event argument contains the event to be passed to the lost-focus
callback of the parent widget and any of its children that were part of
the focus chain at the time of this function call.
If event isn’t provided, a NULL event is generated for you.
Returns:
A pointer to the widget where the focus chain stops. On successful
completion, this is widget’s parent.
Examples:
See PtContainerGiveFocus().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerFocusNext(), PtContainerFocusPrev(),
PtContainerGiveFocus()
Synopsis:
int PtContainerRelease( PtWidget t *container widget );
Description:
This function decrements the hold count for the specified container
widget. The count was incremented by a previous call to
PtContainerHold(). When the count reaches 0, the widgets are
repaired.
When the widgets are eventually released, they aren’t repaired
separately. Instead, only the container parent widget is repaired. As a
result, the children are all repaired simultaneously.
Returns:
The container widget’s current hold count.
Examples:
See PtClearWidget().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerHold(), PtHold(), PtFlush(), PtRelease()
Synopsis:
PtWidget t *PtCreateWidget(
PtWidgetClassRef t *class,
PtWidget t *parent,
unsigned n args,
PtArg t const *args );
Description:
This function creates a widget in the current widget hierarchy. The
class argument points to the desired widget class and the parent
argument points to the desired parent widget. If you set parent to
NULL, the default parent, which is the most recently created
container, will be used.
The n args argument contains the number of arguments being passed
to the widget library and the args argument points to an array
containing n args arguments.
Since this function modifies and allocates only local data structures, it
doesn’t result in any interaction with the Photon Manager. The user
doesn’t see the widget until it’s realized.
Returns:
A pointer to the newly created widget, or NULL if an error occurs.
Examples:
See PtClearWidget() and PtSetArg().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDestroyWidget(), PtGetParentWidget(), PtReParentWidget(),
PtSetArg(), PtSetParentWidget(), PtWidgetParent()
“Creating widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
int PtDamageExtent( PtWidget t *widget,
PhRect t const *extent );
Description:
This function marks the specified widget as damaged and adds extent
to the clipping list that will be used the next time the widget engine
redraws this widget.
All widgets in front of the damaged widget that intersect with extent
will be redrawn. If the damaged widget’s fill color is transparent, all
widgets behind it that intersect extent will be redrawn. In all cases, the
clipping will be set to extent.
The widget library takes care of updating widgets whenever resources
are modified. So you don’t normally use this function unless you’re
mixing Pg calls with widget calls, and want a widget to redraw and
repair itself directly.
Returns:
0 Success.
Examples:
See PhBlit().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDamageWidget()
Synopsis:
int PtDamageWidget( PtWidget t *widget );
Description:
This function adds the specified widget’s extent to the damage list of
the widget’s first window parent. This effectively marks the widget as
being damaged so that it will be redrawn.
The widget library takes care of updating widgets whenever resources
are modified. So you don’t normally use this function unless you’re
mixing Pg*() calls with widget calls, and want a widget to redraw and
repair itself directly.
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
int mycallback( PtWidget t *widget, void *data,
PtCallbackInfo t *cbinfo )
{
PgGC t *wgtlib gc;
/* my context is global */
wgtlib gc = PgSetGC( &my context );
return( Pt CONTINUE );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDamageExtent()
Synopsis:
int PtDestroyWidget( PtWidget t *widget );
Description:
This function performs the following on the specified widget:
☞ You might get callbacks from the widget after PtDestroyWidget() has
returned. To determine if this is happening, check the widget’s
Pt DESTROYED flag. For example:
Returns:
0 Success.
-1 An error occurred.
Examples:
See PtWidgetChildBack().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtEventHandler(), PtCreateWidget(), PtRealizeWidget(),
PtUnrealizeWidget(), PtWidgetFlags()
Pt ARG FLAGS, Pt CB DESTROYED, resources of PtWidget in the
Widget Reference
“Widget life cycle” in the Introduction to the Photon Programmer’s
Guide
Synopsis:
PhRect t *PtDeTranslateRect(
PhRect t *rect,
PhPoint t const *delta );
Description:
This convenience function subtracts delta->x from rect->ul.x and
rect->lr.x, and subtracts delta->y from rect->ul.y and rect->lr.y.
You’ll find this function handy for translating events, extents, or
canvases so they become relative to various points.
Returns:
A pointer to the rect argument.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTranslateRect()
Synopsis:
int PtEndFlux( PtWidget t *container );
Description:
This function decrements the global flux count as well as the
container’s flux count. If the container’s flux count is 0 or becomes 0
due to the decrement, the container’s extent is added to the container’s
damaged visibility list. All widgets under this rectangle will
recalculate their visibility flags, widget->flags (Pt CLEAR and/or
Pt OBSCURED). This doesn’t cause the widgets within the container
to redraw.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtStartFlux(), PtHold(), PtRelease(), PtContainerHold(),
PtContainerRelease(), PtDamageExtent(), PtDamageWidget()
Synopsis:
int PtEventHandler( PhEvent t *event );
Description:
This function determines which widgets were involved in an event
and invokes the appropriate callback functions. By doing this, the
function enables widgets to interact with the user and to repair
themselves when they’ve been exposed.
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
See PhEventNext().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEventNext(), PhEventPeek(), PhEventRead()
Synopsis:
PtWidget t *PtExtentWidget( PtWidget t *widget );
Description:
This function forces the specified widget to calculate its extent. You
can use this function to force PtGroup to redo the layout of its
children.
Returns:
A pointer to the widget.
Examples:
See PtContainerGiveFocus().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtExtentWidgetFamily(), PtReRealizeWidget(), PtWidgetExtent()
Synopsis:
int PtExtentWidgetFamily( PtWidget t *widget );
Description:
This function forces the specified widget and all its descendants to
calculate their extents.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtExtentWidget(), PtReRealizeWidget(), PtWidgetExtent()
Synopsis:
typedef int PtFdProcF t( int fd, void *data, unsigned mode );
typedef PtFdProcF t *PtFdProc t;
Description:
These data types define pointers to file-descriptor functions. The
PtFdProcF t type is the function type that the PtFdProc t type
points to. This allows you to do something like this:
PtFdProcF t my fd proc;
Classification:
Photon
See also:
PtAppAddFd()
Synopsis:
int PtFileSelection( PtWidget t *parent,
PhPoint t const *pos,
char const *title,
char const *root dir,
char const *file spec,
char const *btn1,
char const *btn2,
char const *format,
PtFileSelectionInfo t *info,
int flags );
Description:
This function creates a file selector dialog that lets the user browse
files and directories. The dialog allows the selection of a file and/or
directory and fills a PtFileSelectionInfo t structure with
information about the selected item and the dialog.
This function has its own event-processing loop.
The arguments are as follows:
root dir The current directory for the file selector widget. The
default is / if this parameter is NULL. You can pass a
directory or a full path for a file.
file spec The file specification to look for. The default is * if this
parameter is NULL.
btn1 The string for button 1. The default is Open. This is the
button that returns the selected-file information. When
activated, it sets info->ret to Pt FSDIALOG BTN1.
File Selector
Path: /usr/photon
Filename:
Pattern:
Select Done
Path text field You can type a directory name to open or a full
path to a file. It behaves in the following manner:
¯ If you enter a directory that exists, that
directory is displayed.
Pattern text field Only the files whose names match this pattern are
displayed. This pattern doesn’t apply to
directories.
Returns:
0 Success.
-1 An error occurred.
Examples:
#include <Pt.h>
#include <photon/PtFileSel.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
int
make fs( PtWidget t *widget,
struct fs dialog modal *user,
PtCallbackInfo t *info)
{
PtArg t args[1];
int err;
return(Pt CONTINUE);
}
void
quit( PtWidget t *widget,
struct fs dialog modal *user,
PtCallbackInfo t *info)
{
exit (EXIT SUCCESS);
}
main()
{
PtArg t args[10];
PhArea t area;
PhDim t dim = { 300, 200 };
in.dim.w = 0;
in.dim.h = 0;
// make a label
area.pos.x = 20;
area.pos.y = 30;
PtSetArg( &args[0], Pt ARG POS, &area.pos, 0 );
PtSetArg( &args[1], Pt ARG TEXT FONT, "helv12b", 0 );
PtSetArg( &args[2], Pt ARG TEXT STRING,
"There is no selected file", 0);
label = PtCreateWidget( PtLabel, window, 3, args );
PtRealizeWidget( window );
PtMainLoop();
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtWidget t *PtFindChildClass(
PtWidgetClassRef t *class,
PtWidget t *widget );
Description:
This function finds the first child widget of the specified container,
widget, that matches the specified class.
Returns:
A pointer to a PtWidget t structure, or NULL if an error occurs.
Examples:
main()
{
PtArg t argt;
PtWidget t *window, *pane, *button;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFindChildClassMember(), PtValidParent(),
PtWidgetBrotherBehind(), PtWidgetBrotherInFront(),
PtWidgetChildBack(), PtWidgetFamily(), PtWidgetParent()
Synopsis:
PtWidget t *PtFindChildClassMember(
PtWidgetClassRef t *class,
PtWidget t *widget );
Description:
This function finds the first child widget of the specified container
that’s a subclass of the specified class. For example, PtMultiText,
PtText, PtButton, and PtLabel are all subclasses of PtLabel.
Returns:
A pointer to a PtWidget t structure, or NULL if an error occurs.
Examples:
See PtFindChildClass().
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PtWidgetBrotherBehind(), PtWidgetBrotherInFront(),
PtWidgetChildBack(), PtWidgetFamily(), PtWidgetParent()
Synopsis:
PtWidget t *PtFindContainer( PtWidget t *widget );
Description:
This function returns the nearest container parent (which could be
widget itself).
Returns:
A pointer to the nearest container parent of widget, or NULL if no
container parent was found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void * PtFindData( PtDataHdr **ptr,
long type,
long subtype,
long *len,
PtDataHdr t ** node );
Description:
This function finds the first data block that matches the type and
subtype provided. If type is 0, any type will match. If subtype is -1,
any subtype will match.
If node is provided, it’s set to point to the data node that contained
the returned data in order to be able to continue the search from that
node. If len is provided, it’s set the the length of the data item as set
when the data was originally added to the chain.
Returns:
A pointer to the data, or NULL if no matching data was found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddData(), PtFindNextData(), PtRemoveData(), PtUnlinkData()
Synopsis:
PtWidget t *PtFindDisjoint( PtWidget t *widget );
Description:
This function returns the nearest disjoint parent widget (which could
be widget itself). 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. A disjoint widget’s
class rec has the Pt DISJOINT flag set.
Examples of widgets that are disjoint include:
¯ PtWindow
¯ PtMenu
¯ PtRegion
¯ PtButton
¯ PtPane
¯ PtRect
Returns:
A widget pointer to the nearest disjoint parent of widget, or NULL if
no disjoint container parent was found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtWidget t *PtFindFocusChild( PtWidget t *widget );
Description:
This function finds the closest focusable child widget of widget. If no
focusable children are found, widget is returned.
Returns:
The pointer passed in widget if no focusable children are found, or a
pointer to the first focusable child of widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerFindFocus()
Synopsis:
PtWidget t *PtFindGuardian( PtWidget t *child,
int superior only );
Description:
This function returns the widget that’s responsible for the child’s
actions. This is either the child’s natural parent or, if the child is
Pt PROCREATED, the widget that the child is a subordinate of (its
superior widget).
If the superior only value is nonzero, this function returns only a
pointer to a superior widget as a guardian. If the child hasn’t been
procreated, the function returns NULL. (Only procreated widgets have
superiors.)
Returns:
A pointer to the child widget’s legal guardian, or NULL if the child
widget has no guardian.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtGetParent(), PtValidParent(), PtWidgetParent()
Synopsis:
void * PtFindNextData( PtDataHdr t **ptr,
PtDataHdr t *data,
long type,
long subtype,
long *len,
PtDataHdr t ** node );
Description:
This function finds the next data block, from data node, that matches
the type and subtype provided. If data node is NULL, the first instance
of data that matches the type and subtype provided is found. If type is
0, any type will match. If subtype is -1, any subtype will match.
If node is provided, it’s set to point to the data node that contained
the returned data in order to be able to continue the search from that
node. If len is provided, it’s set the the length of the data item as set
when the data was originally added to the chain.
Returns:
A pointer to the data, or NULL if no matching data was found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddData(), PtFindData(), PtRemoveData(), PtUnlinkData()
Synopsis:
int PtFlush( void );
Description:
This function ensures that any widget damage is repaired (ignoring
container holding), and then calls PgFlush() to flush buffered draw
commands from your application to the graphics driver.
You’ll need to call this function explicitly if you’re drawing
somewhere “outside” the standard Photon event loop (for example, in
an input procedure) or if you want changes to the widgets to be made
immediately.
Returns:
The new value of the global hold count.
Examples:
See PtClearWidget().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerHold(), PtContainerRelease(), PtHold(), PtRelease()
Synopsis:
const char *PtFontSelection( PtWidget t *parent,
const PhPoint t *pos,
const char *title,
const char *font,
long symbol,
unsigned flags,
const char *sample);
Description:
This function displays a modal dialog allowing the user to select a
text font. The dialog is parented off the parent widget, which may be
NULL; if non-NULL, that parent widget is blocked and its cursor is
changed to reflect this.
The dialog is positioned according to the pos parameter: if NULL, the
dialog is centered on the screen; if parent is NULL, the dialog is
placed at the absolute coordinates of pos; otherwise it’s placed at the
relative offset of pos within parent.
The title of the dialog is given by title; if this is NULL a default title of
“Select Text Font” is used.
The initial font selected in the dialog is given by font.
The symbol parameter specifies which character will be used to
construct the list of available font families (refer to PfQueryFonts() in
the Library Reference); if -1L is specified a default symbol ’A’
(standard Latin fonts) is used.
The flags parameter is used to limit the inclusion of fonts based on
certain characteristics:
continued. . .
You can OR the flags together to obtain a suitable mask. The default
is PHFONT ALL FONTS (which is every option set).
The sample parameter sets the text string used to display a sample of
the selected font; if NULL the default of AaBbCcXxYyZz is used.
The modal dialog is constructed and the user may select a text font
using comboboxes for the family and size, and buttons for the style. A
sample of text using the font is dynamically updated.
The user may click a Cancel button or close the window to cancel the
selection, or click an OK button to accept it.
Returns:
A pointer to the new font string if one selected, NULL otherwise. This
string is obtained using the strdup() function, so the application
should free() it once finished with the font name.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFontSel in the Photon Widget Reference
Synopsis:
int PtForwardWindowEvent(
PhWindowEvent t const *window event );
Description:
This function forwards the provided window event to the window
manager.
Returns:
0 Success.
Examples:
int give a window focus( PtWidget t *widget )
{
PhWindowEvent t WE;
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PhWindowEvent t, PtForwardWindowTaskEvent()
PtWindowFocus(), PtWindowToBack(), PtWindowToFront() in the
Photon Widget Reference
Window Management chapter of the Photon Programmer’s Guide.
Synopsis:
int PtForwardWindowTaskEvent(
PhConnectId t task,
PhWindowEvent t const *evt);
Description:
This function is similar to PtForwardWindowEvent() — instead of
specifying the destination region ID in the message, the connection
ID of the task is specified. This ID is translated to the main window
for this task.
In addition, a special pseudo-event (Ph WM SUPERSELECT) is
recognized. This causes the window (and any child windows) to be
moved to the current console and brought in front of any other
windows. Also, the first nonblocked window is given focus.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetConnectId(), PhGetConnectInfo(), PhWindowEvent t,
PtForwardWindowEvent()
PtWindowFocus(), PtWindowToBack(), PtWindowToFront() in the
Photon Widget Reference
Window Management chapter of the Photon Programmer’s Guide.
Synopsis:
void PtFrameSize( ulong t render,
int border size,
int *left border,
int *top border,
int *right border,
int *bottom border );
Description:
This function returns the size of the frame borders, based on the
rendering flags you pass in the render argument. You should pass the
same flags that were used to define the window.
For most windows, you can set border size to 0. But if your window
sets a border width (Pt ARG BORDER WIDTH), you should pass
that value instead.
The function sets the remaining arguments to the frame’s left, top,
right, and bottom borders. These values are in pixels.
Examples:
int
my setup( PtWidget t *widget, void *data,
PtCallbackInfo t *cbinfo )
{
int xoff, yoff, woff, hoff;
short x, y;
PtArg t args[3];
PhArea t *area, tarea;
PhRect t rect;
PhWindowQueryVisible( 0, 0, 0, &rect );
if ( ( tarea.x + tarea.w + xoff + woff ) > rect.xLR )
tarea.x = rect.xLR - tarea.w - xoff - woff;
if ( ( tarea.y + tarea.h + yoff + hoff ) > rect.yLR )
tarea.y = rect.yLR - tarea.h - yoff - hoff;
if ( tarea.x < rect.xUL )
tarea.x = rect.xUL;
if ( tarea.y < rect.yUL )
tarea.y = rect.yUL;
if ( area->x != tarea.x || area->y != tarea.y ) {
PtSetArg( &args[0], Pt ARG AREA, &tarea, 0 );
PtSetResources( widget, 1, &args );
}
return( Pt CONTINUE );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhWindowQueryVisible()
Synopsis:
void PtGetAbsPosition( PtWidget t *widget,
short *x,
short *y );
Description:
This function gets the absolute position of a widget (i.e. the
coordinates of the upper left corner of the widget’s border). The
coordinates are returned in x and y.
☞ For a window, the x and y coordinates don’t include the frame that’s
added by the window manager. Windows don’t usually have borders.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetOffset()
Synopsis:
int PtGetControlFlags( void );
Description:
This function returns the flags of the Pt control structure. The valid
Pt flag bits are:
Pt FEP PRESENT
An FEP is present.
Pt FEP QUERIED
A search for any existing FEPs has been done.
Pt IN EXPOSE
The widget library is currently processing an expose event.
Returns:
The control flags.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtWidget t *PtGetParent(
PtWidget t *widget,
PtWidgetClassRef t *parent class );
Description:
This function examines the specified widget’s hierarchy, and tries to
find the nearest widget in the hierarchy (including the specified
widget itself) that matches the specified parent class.
Returns:
A pointer to the matching widget, or NULL if an error occurs.
Examples:
PtWidget t *window;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSetParentWidget(), PtWidgetParent()
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
PtWidget t *PtGetParentWidget( void );
Description:
The PtGetParentWidget() function returns the current default widget
parent.
Returns:
A pointer to the current default parent.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCreateWidget(), PtGetParent(), PtReParentWidget(),
PtSetParentWidget(), PtWidgetParent(),
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
pid t PtGetRcvidPid( int rcvid );
Description:
This function should be used to obtain the process ID (PID) from the
receive ID (RCVID). It might be needed if a nonspecific input
procedure attaches a specific input procedure.
Returns:
The PID, or -1 on error.
Examples:
int general input proc( void *data, pid t rcvid,
void *msg, size t size)
{
PtAppAddInput( NULL, PtGetRcvidPid(rcvid),
function, data );
#if defined( QNXNTO )
MsgReplyv( rcvid, ... );
#else
Reply( rcvid, ... );
#endif
return Pt END;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddInput()
Synopsis:
int PtGetResources( PtWidget t *widget,
int n args,
PtArg t *args );
Description:
This function sets pointers to resource values within the specified
widget. The args array indicates which resources are desired, and
n args indicates the number of items in the args array.
You must initialize the args array with PtSetArg() or Pt ARG() before
calling PtGetResources(). The Pt type of a resource determines how
that resource should be set or queried. You use the Pt type when
setting a resource entry with PtSetArg().
For more information, see the Manipulating Resources in Application
Code chapter of the Photon Programmer’s Guide.
!
CAUTION: Because PtGetResources() returns pointers directly into
the internals of the widget, don’t modify those values directly. If you
wish to retrieve the value of a given resource and then modify that
value:
Returns:
0 Success.
-1 An error occurred.
Examples:
Determine a widget’s color, and determine whether or not the widget
is highlighted:
PtArg t args[2];
PgColor t *color;
unsigned long *flags;
PtWidget t *widget;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtArg t, Pt ARG(), PtSetArg(), PtSetResources()
Manipulating Resources in Application Code chapter of the Photon
Programmer’s Guide.
Synopsis:
PtWidget t *PtGlobalFocusNext( PtWidget t *widget,
PhEvent t *event );
Description:
This function finds the currently focused widget in the same disjoint
widget (window, region, menu) as widget and moves the focus to the
next focusable widget.
The widget that’s given focus receives event as the reason. If event
isn’t provided, a NULL event is generated for you.
Returns:
The widget that was given focus, or NULL if no focusable widgets are
found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerGiveFocus(), PtContainerNullFocus(),
PtContainerFocusNext(), PtContainerFocusPrev(),
PtGlobalFocusNextContainer(), PtGlobalFocusNextFrom(),
PtGlobalFocusPrev(), PtGlobalFocusPrevFrom(),
PtGlobalFocusPrevContainer(), PtIsFocused()
Synopsis:
PtWidget t *PtGlobalFocusNextContainer(
PtWidget t *widget,
PhEvent t *event );
Description:
This function finds the currently focused widget in the same disjoint
widget (window, region, menu) as widget and moves the focus to the
next focusable widget in a different container. The widget that’s given
focus will receive event as the reason.
If event isn’t provided, a NULL event will be generated for you.
Returns:
The widget that was given focus, or NULL if no focusable widgets are
found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerGiveFocus(), PtContainerNullFocus(),
PtContainerFocusNext(), PtContainerFocusPrev(),
PtGlobalFocusNext(), PtGlobalFocusNextFrom(),
PtGlobalFocusPrev(), PtGlobalFocusPrevFrom(),
PtGlobalFocusPrevContainer(), PtIsFocused()
Synopsis:
PtWidget t *PtGlobalFocusNextFrom(
PtWidget t *widget,
PhEvent t *event );
Description:
Unlike PtGlobalFocusNext(), this function doesn’t find the currently
focused widget first. PtGlobalFocusNextFrom() moves the focus to
the next focusable widget after widget in the same disjoint widget
(window, region, menu) as widget.
The widget that’s given focus receives event as the reason. If event
isn’t provided, a NULL event is generated for you.
Returns:
The widget that was given focus, or NULL if no focusable widgets are
found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerGiveFocus(), PtContainerNullFocus(),
PtContainerFocusNext(), PtContainerFocusPrev(),
PtGlobalFocusNext(), PtGlobalFocusNextContainer(),
PtGlobalFocusPrev(), PtGlobalFocusPrevFrom(),
PtGlobalFocusPrevContainer(), PtIsFocused()
Synopsis:
PtWidget t *PtGlobalFocusPrev( PtWidget t *widget,
PhEvent t *event );
Description:
This function finds the currently focused widget in the same disjoint
widget (window, region, menu) as widget and moves the focus to the
previous focusable widget.
The widget that’s given focus receives event as the reason. If event
isn’t provided, a NULL event is generated for you.
Returns:
The widget that was given focus, or NULL if no focusable widgets are
found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerGiveFocus(), PtContainerNullFocus(),
PtContainerFocusNext(), PtContainerFocusPrev(),
PtGlobalFocusNext(), PtGlobalFocusNextContainer(),
PtGlobalFocusNextFrom(), PtGlobalFocusPrevFrom(),
PtGlobalFocusPrevContainer(), PtIsFocused()
Synopsis:
PtWidget t *PtGlobalFocusPrevContainer(
PtWidget t *widget,
PhEvent t *event );
Description:
This function finds the currently focused widget in the same disjoint
widget (window, region, menu) as widget and moves the focus to the
previous focusable widget in another container. The widget that’s
given focus will receive event as the reason.
If event isn’t provided, a NULL event will be generated for you.
Returns:
The widget that was given focus, or NULL if no focusable widgets are
found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerGiveFocus(), PtContainerNullFocus(),
PtContainerFocusNext(), PtContainerFocusPrev(),
PtGlobalFocusNext(), PtGlobalFocusNextContainer(),
PtGlobalFocusNextFrom(), PtGlobalFocusPrev(),
PtGlobalFocusPrevFrom(), PtIsFocused()
Synopsis:
PtWidget t *PtGlobalFocusPrevFrom(
PtWidget t *widget,
PhEvent t *event );
Description:
Unlike PtGlobalFocusPrev(), this function doesn’t find the currently
focused widget first. PtGlobalFocusNextFrom() will move the focus
to the first focusable widget previous to widget in the same disjoint
widget (window, region, menu) as widget.
The widget that’s given focus receives event as the reason. If event
isn’t provided, a NULL event is generated for you.
Returns:
The widget that was given focus, or NULL if no focusable widgets are
found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerGiveFocus(), PtContainerNullFocus(),
PtContainerFocusNext(), PtContainerFocusPrev(),
PtGlobalFocusNext(), PtGlobalFocusNextContainer(),
PtGlobalFocusNextFrom(), PtGlobalFocusPrev(),
PtGlobalFocusPrevContainer(), PtIsFocused()
Synopsis:
PtWidget t *PtHit( PtWidget t *container,
unsigned n,
PhRect t const *rect );
Description:
This function returns container’s nth child widget whose extent
intersects with rect. The rect argument should be relative to
container’s basic widget canvas. PtHit() ignores unrealized or
procreated widgets.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtHold( void );
Description:
This function prevents visible repair of all widgets until the
application makes a corresponding call to PtRelease().
A global hold count is incremented when PtHold() is called, and
decremented when PtRelease() is called. When the hold count
reaches 0, the widgets are repaired.
A global hold count of 0 simply means that the application doesn’t
want to prevent widgets from repairing themselves. The widgets
manage their own damage repair and may not take immediate action
even if the count is 0.
☞ Each damaged widget that has been held by PtHold() and then
released by PtRelease() is repaired separately.
Returns:
The new value of the global hold count.
Examples:
See PtClearWidget().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerHold(), PtContainerRelease(), PtFlush(), PtRelease()
Synopsis:
PtWidget t *PtInflateBalloon( PtWidget t *win,
PtWidget t *me,
int position,
char const *string,
char const *font,
PgColor t fill,
PgColor t text color );
Description:
This function creates a label widget as a child of win. The widget is
placed according to position, relative to me. The string sting is
rendered inside the label widget using a text color of text color, and
the font specified in font. The widget itself is filled with the color
specified in fill.
Valid values for position include:
¯ Pt BALLOON RIGHT
¯ Pt BALLOON LEFT
¯ Pt BALLOON TOP
¯ Pt BALLOON BOTTOM
¯ Pt BALLOON INPLACE
Returns:
A pointer to the newly created balloon widget, or NULL if win isn’t a
disjoint widget (e.g. PtWindow, PtRegion, etc.) or me is NULL.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtInit( char const *name );
Description:
This function initializes the widget library. If no Photon channel is
currently attached, this function calls PhAttach() with the given
Photon server name (//2/dev/photon, for example). If there is a
current channel, PhAttach() isn’t called.
Once a channel is attached, PtInit() installs all the widgets supplied
by QNX Software Systems.
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
See PtClearWidget().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAttach()
Synopsis:
typedef int PtInputCallbackProcF t( void *, pid t,
void *, size t);
typedef PtInputCallbackProcF t *PtInputCallbackProc t;
Description:
These data types define pointers to input callback functions. The
PtInputCallbackProcF t type is the function type that the
PtInputCallbackProc t type points to. This allows you to do
something like this:
Classification:
Photon
See also:
PtAppAddInput()
Synopsis:
int PtIsFluxing( PtWidget t *container );
Description:
This function determines whether container or any parent widget of
container is currently in flux.
Returns:
1 container’s family is in flux.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtStartFlux(), PtEndFlux()
Synopsis:
int PtIsFocused( PtWidget t *widget );
Description:
This function returns a value indicating to what degree a widget is
focused.
Returns:
0 The widget isn’t focused.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerFindFocus(), PtContainerFocusNext(),
PtContainerFocusPrev(), PtGlobalFocusNext(),
PtGlobalFocusNextFrom(), PtGlobalFocusPrev(),
PtGlobalFocusPrevFrom()
Synopsis:
PhRect t *PtLabelWidgetCanvas(
PtWidget t *widget,
PhRect t *canvas rect );
Description:
This function determines the canvas rectangle for the specified
widget’s PtLabel-class level. This canvas rectangle describes the
area inside PtWidget’s border, PtBasic’s margins, and PtLabel’s
margins.
The canvas rect argument should point to an instance of a PhRect t
structure; if you pass canvas rect as NULL, the function returns NULL.
Returns:
A pointer to the canvas of the PtBasic widget, or NULL if an error
occurred.
Examples:
Return the area inside PtWidget’s border:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtLabelWidgetCanvas(), PtWidgetCanvas(), PtWidgetExtent()
Synopsis:
void PtMainLoop( void );
Description:
This is a convenience function that implements an application main
loop using PhEventNext() and PtEventHandler(). Background
processing (WorkProcs) and handling of non-Photon messages
(inputs) are also supported by this function.
PtMainLoop() allocates an event buffer and resizes it as necessary.
You can set the size yourself by calling PtResizeEventMsg().
To terminate normally, your applications should call exit() (see the C
Library Reference) within a callback function.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEventNext(), PtAppAddInput(), PtAppAddWorkProc(),
PtEventHandler(), PtResizeEventMsg()
“Receiving QNX messages” in the Interprocess Communications and
Lengthy Procedures chapter of the Photon Programmer’s Guide
Synopsis:
int PtMessageBox( PtWidget t *parent,
char const *title,
char const *question,
char const *font,
char const *btn );
Description:
This function displays a message that blocks input to the specified
parent widget until the message has been acknowledged. If no parent
is specified, blocking won’t occur, but the message will persist until
it’s acknowledged. If specified, the parent must be a window.
This function returns immediately.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtModalEnd( int hold count );
Description:
This function terminates a modal-processing loop that was initiated
by PtModalStart(). The hold count argument must be the count value
that was returned by PtModalStart().
Examples:
See PtModalStart().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtModalStart()
“Modal dialogs” in the “Lengthy operations” section of the
Interprocess Communication and Lengthy Operations chapter of the
Programmer’s Guide.
Synopsis:
int PtModalStart ( void );
Description:
This function initiates modal processing. To do so, it holds the current
process loop so that another subloop can be started.
Once the subloop is complete, you must call PtModalEnd() to resume
processing of the initial process loop.
Returns:
The hold count needed for PtModalEnd().
Examples:
/* Module to handle immediate responses */
#include "imports.h"
#include <Ph.h>
#include <Pt.h>
#include <photon/PtMessage.h>
void
askresponse( PtWidget t *, int *, PtCallbackInfo t *);
callback.event f = askresponse;
callback.data = &answer;
/* initialize answer */
answer = 0;
if ( title ) {
PtSetArg( &args[n], Pt ARG MSG TITLE,
title, 0 ); n++;
}
if ( question ) {
PtSetArg( &args[n], Pt ARG MSG TEXT,
question, 0 ); n++;
}
if ( font ) {
PtSetArg( &args[n], Pt ARG MSG FONT,
font, 0 ); n++;
}
if ( btn1 ) {
PtSetArg( &args[n], Pt ARG MSG BUTTON1,
btn1, 0 ); n++;
}
if ( btn2 ) {
PtSetArg( &args[n], Pt ARG MSG BUTTON2,
btn2, 0 ); n++;
}
if ( btn3 ) {
PtSetArg( &args[n], Pt ARG MSG BUTTON3,
btn3, 0 ); n++;
}
PtSetArg( &args[n], Pt ARG MSG DEFAULT,
def btn, 0 ); n++;
PtSetArg( &args[n], Pt CB MSG BUTTON1,
&callback, 0 ); n++;
PtSetArg( &args[n], Pt CB MSG BUTTON2,
&callback, 0 ); n++;
PtSetArg( &args[n], Pt CB MSG BUTTON3,
&callback, 0 ); n++;
PtRealizeWidget( PtCreateWidget( PtMessage, NULL,
n, args ) );
return( answer );
}
PtCallbackInfo t *cbinfo )
{
switch( cbinfo->reason ) {
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtModalEnd(), PtProcessEvent()
“Modal dialogs” in the “Lengthy operations” section of the
Interprocess Communication and Lengthy Operations chapter of the
Programmer’s Guide.
Synopsis:
PtWidget t * PtNextTopLevelWidget( PtWidget t *widget );
Description:
This function gets a pointer to the next top-level widget after the
given widget.
Returns:
A pointer to the next top-level widget, or NULL if there isn’t one.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFindFocusChild(), PtGetParent(), PtValidParent(),
PtWidgetParent(), PtWidgetSkip()
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
void PtPositionMenu( PtWidget t *menu,
PhEvent t *event );
Description:
This function sets the Pt ARG POS resource of the provided menu
widget. How the function sets this resource is determined by the type
of its parent and the specified event.
If the provided menu is a child of a PtMenuButton widget, the menu
is positioned relative to that menu button (to the right or below,
depending on the menu button’s flags).
If the provided menu isn’t a child of a PtMenuButton widget and the
specified event is a pointer event, the menu is positioned at the event’s
position. If the event isn’t a pointer event and the menu has a parent,
the menu is positioned at the upper-left corner of that parent.
If the provided menu isn’t a child of a PtMenuButton widget and the
specified event isn’t a pointer event, the menu is positioned at 0,0.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtPrintSelection( PtWidget t *parent,
PhPoint t const *pos,
const char *title,
PpPrintContext t *context,
unsigned flags);
Description:
This function displays a modal dialog allowing the user to select print
options and initiate printing. The dialog is parented off the parent
widget, which may be NULL; if non-NULL, that parent widget is
blocked and its cursor is changed to reflect this.
The dialog is positioned according to the pos parameter: if NULL, the
dialog is centered on the screen; if parent is NULL, the dialog is
placed at the absolute coordinates of pos; otherwise it’s placed at the
relative offset of pos within parent.
The title of the dialog is given by title; if this is NULL a default title of
“Select Printer” is used.
The context parameter is a Print Context that was created by the
PpPrintCreatePC() function. This context must be supplied and is
filled in with details of the selected printer:
¯ At the start of this function, the print context is examined and any
fields modified at or below the INITIAL PC level are propagated
into the PtPrintSel.
Pt PRINTSEL NO COLLATE
If this is set, the Collate Method buttons are disabled.
Pt PRINTSEL DFLT LOOK
Use the default look (equivalent to Pt PRINTSEL ALL PANES |
Pt PRINTSEL PROP APP | Pt PRINTSEL NO SELECT RANGE)
Returns:
An integer that indicates which button was pressed:
¯ Pt PRINTSEL PRINT
¯ Pt PRINTSEL PREVIEW
¯ Pt PRINTSEL CANCEL
Examples:
See PpPrintStart().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpPrintClose(), PpPrintCreatePC(), PpPrintGetPC(),
PpPrintNewPage(), PpPrintOpen(), PpPrintReleasePC(),
PpPrintSetPC(), PpPrintStart(), PpPrintStop(), PpPrintWidget()
Synopsis:
void PtProcessEvent( void );
Description:
This function is used primarily for modal-dialog-event handling.
If a Photon event is pending, this function processes the event and
returns. If no event is pending, or if no work procedure has been
defined, the function puts the application into REPLY-blocked mode.
Examples:
See PtModalStart().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PtPulseMsgId t *PtPulseArmFd( PtAppContext t app,
pid t pulse,
int fd,
PtPulseMsg t *msg );
Description:
This function arms a pulse and creates a “pulse message” to be sent to
another process. The other process can use the pulse message and
PtPulseDeliver() to send the pulse.
The app argument is the address of the application context, a structure
that manages all the data associated with this application. For Photon
1.1x, this must be specified as NULL, so that the default context is
used.
The pulse argument is a pulse ID returned by PtAppCreatePulse().
The fd argument is a file descriptor associated with the process that’s
going to deliver the pulse back to this process.
The msg argument points a pulse message that’s created by the
function. You’ll need to send it to the process that’s going to deliver
the pulse.
When the pulse is no longer needed, you should call PtPulseDisarm()
to release any resources that PtPulseArmFd() allocated (e.g. a virtual
proxy in QNX 4).
Returns:
A pointer to the pulse message ID, or NULL if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppCreatePulse(), PtAppDeletePulse(), PtAppPulseTrigger(),
PtChannelCreate(), PtPulseArmPid(), PtPulseDeliver(),
PtPulseDisarm()
Interprocess Communication and Lengthy Operations in the
Programmer’s Guide
Synopsis:
PtPulseMsgId t *PtPulseArmPid( PtAppContext t app,
pid t pulse,
pid t pid,
PtPulseMsg t *msg);
Description:
This function arms a pulse and creates a “pulse message” to be sent to
another process. The other process can use the pulse message and
PtPulseDeliver() to send the pulse back to this process.
The app argument is the address of the application context, a structure
that manages all the data associated with this application. For Photon
1.1x, this must be specified as NULL, so that the default context is
used.
The pulse argument is a pulse ID returned by PtAppCreatePulse().
The pid is a process ID of a process on the same node as this process,
or a virtual circuit ID for a process on a different node. In either case,
this argument identifies the process that will deliver the pulse to the
process calling this function.
☞ If you also have a file descriptor associated with the process that’s
going to deliver the pulse, you should use PtPulseArmFd(), to arm the
pulse.
Returns:
A pointer to the pulse message ID, or NULL if an error occurs.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppCreatePulse(), PtAppDeletePulse(), PtAppPulseTrigger(),
PtChannelCreate(), PtPulseArmFd(), PtPulseDeliver(),
PtPulseDisarm()
Interprocess Communication and Lengthy Operations in the Photon
Programmer’s Guide
Synopsis:
int PtPulseDeliver( pid t rcvid,
PtPulseMsg t const *pulse );
Description:
This function sends a Photon pulse to a process. Before this function
can be called by the process that’s delivering the pulse, the process
that’s going to receive it must:
¯ Send it (by some method) to the process that’s going to deliver the
pulse.
Returns:
A nonnegative number, or -1 if an error occurs — errno indicates the
type of error detected.
Classification:
Photon
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
Caveats:
The version of this function defined in
<photon/PtPulseDeliver.h> is a macro.
See also:
PtAppCreatePulse(), PtAppDeletePulse(), PtAppPulseTrigger(),
PtChannelCreate(), PtPulseArmFd(), PtPulseArmPid(),
PtPulseDisarm()
Interprocess Communication and Lengthy Operations in the Photon
Programmer’s Guide
Synopsis:
void PtPulseDisarm( PtPulseMsgId t *mid );
Description:
This function releases any resources that PtPulseArmFd() or
PtPulseArmPid() allocated (e.g. a virtual proxy in QNX 4). You
should call PtPulseDisarm() when the pulse is no longer needed. The
mid argument points to a pulse message ID returned by
PtPulseArmFd() or PtPulseArmPid().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppCreatePulse(), PtAppDeletePulse(), PtAppPulseTrigger(),
PtChannelCreate(), PtPulseArmFd(), PtPulseArmPid(),
PtPulseDeliver()
Interprocess Communication and Lengthy Operations in the Photon
Programmer’s Guide
Synopsis:
PhSysInfo t * PtQuerySystemInfo(
PtWidget t *widget,
PhSysInfo t *sys ptr );
Description:
This function queries the system for information on the given widget:
¯ system bandwidth
¯ pointing devices
¯ keyboard devices.
¯ ...
Returns:
A pointer to the PhSysInfo t structure passed to the function, or
NULL if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhQuerySystemInfo()
For a description of PhSysInfo t and the information it provides,
see PhT.h and “System information” in the Regions chapter of the
Programmer’s Guide.
Synopsis:
int PtRealizeWidget( PtWidget t *widget );
Description:
This function initializes a widget and its children, making them
visible to the user and possibly making them interactive. To create a
hierarchy of widgets, you typically make successive calls to
PtCreateWidget(), and then call PtRealizeWidget(), passing it the root
of the hierarchy.
Returns:
0 Success.
Examples:
See PtContainerGiveFocus() and PtClearWidget().
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PtCreateWidget(), PtDestroyWidget(), PtUnrealizeWidget()
Synopsis:
int PtReattach( char *device );
Description:
This function provides Photon’s “jump gate” mechanism — it
unrealizes all top-level widgets in an application, disconnects them
from the current Photon server, connects to the Photon server
indicated by device (e.g. //88/dev/photon), and realizes the
top-level widgets at the new location.
As a result, the PHOTON environment variable is set and the user
interface is rehosted to the new Photon server.
Returns:
0 Success.
Examples:
int transport edit activate( PtWidget t *widget,
void *data, PtCallbackInfo t cbinfo );
{
PtTextCallback t *tcb=cbinfo->cbdata;
PtReattach( tcb->text );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtRectIntersect( PhRect t *rect1,
PhRect t const *rect2 );
Description:
This function finds the intersection of two rectangles. If rectangles
rect1 and rect2 intersect, this function sets rect1 to that intersection.
Returns:
≠0 There was an intersection.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtRectUnion( PhRect t *rect1,
PhRect t const *rect2 );
Description:
This function changes the rectangle pointed to by rect1 to a rectangle
that encompasses rect2 using rect1 as a starting point. The result is a
bounding box for the two original rectangles.
Returns:
0 The resulting rectangle is inverted (only possible if inverted
rectangles are provided as parameters i.e. ul > lr ).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtRelease( void );
Description:
This function decrements the global widget hold count, which was
previously incremented by a call to PtHold(). When the count reaches
0, the widgets are repaired.
Returns:
The new value of the global hold count.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerHold(), PtContainerRelease(), PtFlush(), PtHold()
Synopsis:
void PtRemoveCallback( PtWidget t *widget,
unsigned long callback type,
PtCallbackF t *callback,
void *data );
Description:
This function removes the first callback entry that matches callback
and data. It removes the entry from the callback type callback list that
belongs to widget.
Pt CB HOTKEY
PtRemoveHotkeyHandler()
Pt CB RAW PtRemoveEventHandler() or
PtRemoveEventHandlers()
Examples:
See PtAddCallback().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddCallback(), PtAddCallbacks(), PtRemoveCallbacks(),
PtRemoveEventHandler(), PtRemoveEventHandlers(),
PtRemoveHotkeyHandler()
Creating Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
void PtRemoveCallbacks(
PtWidget t *widget,
unsigned long callback type,
PtCallback t const *callback defs,
unsigned int num callbacks );
Description:
This function removes the first callback entries that exactly match an
entry in the callback defs array. It removes these entries from the
callback type callback list that belongs to widget. The num callbacks
argument specifies the length of the array.
Pt CB HOTKEY
PtRemoveHotkeyHandler()
Pt CB RAW PtRemoveEventHandler() or
PtRemoveEventHandlers()
Examples:
See PtAddCallback().
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PtAddCallback(), PtAddCallbacks(), PtRemoveCallback(),
PtRemoveEventHandler(), PtRemoveEventHandlers(),
PtRemoveHotkeyHandler()
Creating Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
int PtRemoveData( PtDataHdr t **ptr,
long type,
long subtype );
Description:
This function removes a link from the ptr data chain. If a remove
function is provided, it’s called prior to the release of the node and
data:
Returns:
-1 The data wasn’t found.
Pt CONTINUE
The data was found and released.
Pt HALT The data was found, the node was released, and the data
was taken care of by the remove function.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddData(), PtFindData(), PtFindNextData(), PtUnlinkData()
Synopsis:
void PtRemoveEventHandler(
PtWidget t *widget,
unsigned long event mask,
PtCallbackF t *callback,
void *data );
Description:
This function removes the first callback entry that matches
event mask, callback, and data. It removes the entry from the
Pt CB RAW callback list that belongs to widget
The callback argument points to a function that takes this form:
Examples:
See PtAddEventHandler().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddEventHandler(), PtRemoveCallback(), PtRemoveCallbacks(),
PtRemoveEventHandlers(), PtRemoveHotkeyHandler()
Synopsis:
void PtRemoveEventHandlers(
PtWidget t *widget,
PtRawCallback t const *callback defs,
int num handlers );
Description:
This function removes the first handler entries that exactly match an
entry in the callback defs array. It removes the entries from the
Pt CB RAW callback list that belongs widget. The num handlers
argument specifies the length of the array.
The PtRawCallback t structure is defined in PtT.h.
Examples:
See PtAddEventHandler().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddEventHandlers(), PtRemoveCallback(), PtRemoveCallbacks(),
PtRemoveEventHandler(), PtRemoveHotkeyHandler()
Synopsis:
void PtRemoveHotkeyHandler(
PtWidget t *widget,
unsigned key sym cap,
unsigned key mods,
short flags,
void *data,
PtCallbackF t *callback );
Description:
This function removes the specified callback if the callback matches
key sym cap, key mods, flags, data, and callback. The function
removes the callback from the Pt CB HOTKEY callback list that
belongs to widget.
The callback argument points to a function that takes this form:
Examples:
See PtAddHotkeyHandler().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddHotkeyHandler(), PtRemoveCallback(), PtRemoveCallbacks(),
PtRemoveEventHandler(), PtRemoveEventHandlers(),
PtRemoveHotkeyHandler()
“Hotkey callbacks” in the Editing Resources and Callbacks in PhAB
chapter of the Photon Programmer’s Guide.
Synopsis:
int PtReParentWidget( PtWidget t *widget,
PtWidget t *parent );
Description:
This function takes the specified widget from its current parent and
gives it to the specified parent. The parent must be a container widget.
Returns:
0 Successful completion.
Examples:
PtWidget t *label, *window1, *window2;
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PtCreateWidget(), PtFindGuardian(), PtGetParent(), PtValidParent(),
PtWidgetParent()
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
int PtReRealizeWidget( PtWidget t *widget );
Description:
This function forces the specified widget and all its descendants to
unrealize and rerealize themselves.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtRealizeWidget(), PtUnrealizeWidget()
Synopsis:
int PtResizeEventMsg( PtAppContext t app,
int msg size );
Description:
This function resizes the Photon event buffer, which receives all
events on behalf of a Photon application. Using this function to
increase the acceptable message size allows larger non-Photon
messages to be received by the Photon application without requiring
Readmsgmx() (see the C Library Reference).
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
“Receiving QNX messages” in the Interprocess Communications and
Lengthy Procedures chapter of the Photon Programmer’s Guide
Synopsis:
int PtSendEventToWidget( PtWidget t *widget,
PhEvent t *event );
Description:
This function allows an event to be given directly to any widget for
processing.
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
// Send a Phantom release event to a widget.
if( event ) {
new event.event = *event;
}
PtSendEventToWidget( widget,
(PhEvent t *) &new event);
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEventEmit()
Synopsis:
PhArea t * PtSetAreaFromExtent(
PtWidget t *widget,
PhRect t const *extent rect,
PhArea t *area);
Description:
This function sets area to an area that would produce the extent
extent rect, given the attributes, borders, etc. of widget.
☞ The area argument must be provided and have its own storage. This
function doesn’t allocate any memory.
Returns:
A pointer to the area argument, or NULL if an error occurred.
Examples:
// Change widget so its extent will be {5,5,25,15}.
PhRect t extent = { 5,5,25,15 };
PhArea t area;
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PtSetAreaFromWidgetCanvas()
Synopsis:
PhArea t * PtSetAreaFromWidgetCanvas(
PtWidget t *widget,
PhRect t const *canvas rect,
PhArea t *area)
Description:
This function sets area to an area that produces a widget canvas of
canvas rect, given the attributes, borders, etc. of widget.
☞ The area argument must be provided and have its own storage. This
function doesn’t allocate any memory.
Returns:
A pointer to the area argument, or NULL if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSetAreaFromExtent()
Synopsis:
PtSetArg( PtArg t *arg,
long type,
long value,
long len );
Description:
This macro builds argument lists to be used with PtCreateWidget(),
PtSetResources(), and PtGetResources().
Examples:
PtArg t args[4];
PhPoint t pos = { 100, 100 };
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtArg t, Pt ARG(), PtGetResources(), PtSetResources(),
PtCreateWidget()
Manipulating Resources in Application Code chapter of the Photon
Programmer’s Guide.
Synopsis:
PtWidget t *PtSetParentWidget( PtWidget t *widget );
Description:
This function sets the current parent widget. Some widget classes (for
example, windows, lists and menus) call this function when they’re
created.
Returns:
A pointer to the previous parent widget, or NULL if there is none.
Examples:
See PtWidgetChildBack().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCreateWidget(), PtFindGuardian(), PtGetParent(),
PtGetParentWidget(), PtReParentWidget(), PtValidParent(),
PtWidgetParent()
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
int PtSetResources( PtWidget t *widget,
int n args,
PtArg t const *args );
Description:
This function sets resources for the specified widget. The args array
indicates which resources to set, and n args indicates the number of
items in the args array. Before calling this function, you must
initialize the args array with PtSetArg() or Pt ARG().
For more information, see the Manipulating Resources in Application
Code chapter of the Photon Programmer’s Guide.
If the widget has been realized, changing its resources may change
how it appears on the screen.
Returns:
0 At least one of the given resources was applied to the widget.
Examples:
Turn the widget blue and highlight it:
PtArg t args[2];
PtWidget t *widget;
Pt HIGHLIGHTED, Pt HIGHLIGHTED );
PtSetResources( widget, 2, args );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtArg t, Pt ARG(), PtGetResources(), PtSetArg()
Manipulating Resources in Application Code chapter of the Photon
Programmer’s Guide.
Synopsis:
typedef int PtSignalProcF t( int, void *);
typedef PtSignalProcF t *PtSignalProc t;
Description:
These data types define pointers to signal-handling functions. The
PtSignalProcF t type is the function type that the
PtSignalProc t type points to. This allows you to do something
like this:
Classification:
Photon
See also:
PtAppAddSignalProc(), PtAppRemoveSignal(),
PtAppRemoveSignalProc()
Interprocess Communication in the Photon Programmer’s Guide
Synopsis:
pid t PtSpawn( const char *cmd,
const char * const *argv,
const char * const *env,
const PtSpawnOptions t *opt,
PtSpawnCbF t *cb,
void *data,
PtSpawnCbId t **csp );
Description:
This function spawns a new process and optionally installs a callback
that’s called when the child process terminates. The arguments are as
follows:
PtSpawnOptions t my opts;
my opts = PtSpawnDefaults;
my opts.iov[1] = fd; // Redirect stdout
Returns:
The process ID of the spawned process, or -1 on error.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSpawnSetCallback(), PtSpawnDeleteCallback(), PtSpawnWait()
Synopsis:
void PtSpawnDeleteCallback( PtSpawnCbId t *cs );
Description:
This function can be used to remove a callback function for a child
process created by a previous call to PtSpawn(). The cs argument is
the control structure created by that call to PtSpawn() and returned via
the csp argument.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSpawn(), PtSpawnSetCallback(), PtSpawnWait()
Synopsis:
void PtSpawnSetCallback( PtSpawnCbId t *cs,
PtSpawnCbF t *cb,
void *data );
Description:
This function can be used to specify a new callback function to be
called when a child process created by a previous call to PtSpawn()
terminates. The cs argument is the control structure created by that
call to PtSpawn() and returned via the csp argument.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSpawn(), PtSpawnDeleteCallback(), PtSpawnWait()
Synopsis:
int PtSpawnWait( const char *cmd,
const char **argv,
const char **env,
const PtSpawnOptions t *opt,
pid t *pidp );
Description:
This function spawns a new process and waits for its termination.
While the child process is running, Photon events are processed.
If pidp isn’t NULL, the process ID of the spawned command is stored
in *pidp. This can be used if callback functions need to communicate
with the running child process.
The meaning of all the other arguments is the same as for the
PtSpawn() function.
Returns:
The termination status of the child (see waitpid()), or -1 if the child
process couldn’t be started.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSpawn(), PtSpawnSetCallback(), PtSpawnDeleteCallback()
Synopsis:
int PtStartFlux( PtWidget t *container );
Description:
This function increments the global flux count as well as the
container’s flux count. If either flux count is > 0, no internal damage
is recorded for any widgets under any circumstances.
This function is especially useful for reducing flicker when many
changes are being made to overlapping widgets.
Returns:
The container’s new flux count, or -1 if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtEndFlux(), PtHold(), PtRelease(), PtContainerHold(),
PtContainerRelease()
Synopsis:
void PtSyncPhoton();
Description:
This function forces a flush of the current draw buffer and then
disposes of the memory used by any destroyed widgets. This ensures
that:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddWorkProc(), PtAppAddInput()
Synopsis:
int PtSyncWidget( PtWidget t *widget );
Description:
This function ensures that all flagged actions (such as a complete
rebuild, a resize including extenting, and any required region changes)
are performed on the specified widget.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddInput(), PtAppAddWorkProc(), PtFlush(), PtUpdate()
Synopsis:
int PtTimerArm( PtWidget t *widget,
unsigned msec );
Description:
This function arms a timer event to be trigger after msec milliseconds.
When the timer event is triggered, it’s sent to the widget specified by
widget. For this widget to receive the event, it must provide a raw
callback of type Ph EV TIMER.
☞ Any pending timers for a widget are removed automatically when the
widget is unrealized.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhTimerArm()
Synopsis:
PhRect t *PtTranslateRect( PhRect t *rect,
PhPoint t const *delta );
Description:
This convenience function adds delta->x to rect->ul.x and rect->lr.x,
and adds delta->y to rect->ul.y and rect->lr.y.
You’ll find this function handy for translating events, extents, or
canvases so that they become relative to various points.
Returns:
The pointer passed in rect.
Examples:
See PhInitDrag().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDeTranslateRect()
Synopsis:
int PtUnlinkData( PtDataHdr t **ptr,
PtDataHdr t *node );
Description:
This function removes the provided data link from the data chain. The
link is freed, but its data isn’t.
Returns:
0 on success, or -1 if node couldn’t be found in the data list.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddData(), PtFindData(), PtFindNextData(), PtRemoveData()
Synopsis:
int PtUnrealizeWidget( PtWidget t *widget );
Description:
This function unrealizes the specified widget and all its children: the
widgets are removed from the display, and the widget engine will no
longer invoke their callbacks.
Unrealized widgets still exist in the widget hierarchy and can be
realized again.
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
See PtWidgetChildBack().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDestroyWidget(), PtRealizeWidget()
Synopsis:
int PtUpdate( void );
Description:
This function decrements the global widget hold count, which was
previously incremented by a call to PtHold(). When the count reaches
0, the widgets are repaired.
Returns:
The current hold count, or -1 if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerHold(), PtContainerRelease(), PtFlush(), PtHold(),
PtModalStart(), PtRelease()
Synopsis:
PtWidget t * PtValidParent(
PtWidget t *widget parent,
PtWidgetClassRef t *class ref );
Description:
This function determines the real parent widget for widgets of type
class ref , given that its parent is specified as widget parent when
created or reparented. Examples of a class ref include PtWidget,
PtBasic, PtLabel, RtMeter, and so on.
The real parent of a widget might not be the specified widget parent
in special circumstances where the specified parent widget redirects
the child to an alternate parent. Some examples:
Returns:
A pointer to the widget that will be the real parent of any widgets of
type class ref created in or reparented to widget parent.
Examples:
PtWidget t *
MyRedirector( PtWidget t *widget )
{
MyWidget t *my = (MyWidget t * ) widget;
PtWidget t *parent;
if( ( parent =
PtValidParent( my->scroll area,
widget->class ref ) ) == widget )
return PtWidgetParent( widget );
return( parent );
/*
* Returning my->scroll area would allow the child
* to be created as a direct child of my->scroll area.
* This would be undesirable because scroll area is a
* compound widget, which also needs to redirect its
* children to work correctly.
*/
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFindGuardian(), PtGetParent(), PtGetParentWidget(),
PtReParentWidget(), PtSetParentWidget(), PtWidgetParent()
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
PhArea t * PtWidgetArea( PtWidget t *widget,
PhArea t *area );
Description:
This function retrieves a copy of widget’s area and stores it in the
PhArea t structure pointed to by area.
Returns:
The same pointer as area, or NULL if widget or area is NULL.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhArea t, PtWidgetDim()
Synopsis:
PtWidget t *PtWidgetBrotherBehind(
PtWidget t *widget);
Description:
This function returns a pointer to the brother behind widget. If there’s
no brother behind widget, the function returns NULL.
Examples:
See PtWidgetChildBack().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetBrotherInFront(), PtWidgetChildBack(),
PtWidgetChildFront(), PtWidgetParent()
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
PtWidget t *PtWidgetBrotherInFront(
PtWidget t *widget );
Description:
This function returns a pointer to the brother in front of widget. If
there’s no brother in front of widget, the function returns NULL.
Examples:
See PtWidgetChildBack().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetBrotherBehind(), PtWidgetChildBack(),
PtWidgetChildFront(), PtWidgetParent()
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
PhRect t *PtWidgetCanvas( PtWidget t *widget,
PhRect t *canvas rect );
Description:
This function determines the canvas rectangle for the specified
widget’s PtWidget-class level. This canvas rectangle describes the
area inside the widget’s border. The canvas rect argument should
point to an instance of a PhRect t structure; if you pass canvas rect
as NULL, the function returns NULL.
Returns:
A pointer to the widget’s canvas, or NULL if an error occurs.
Examples:
Return the area inside the widget’s border:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtBasicWidgetCanvas(), PtLabelWidgetCanvas(), PtWidgetExtent()
Synopsis:
PtWidget t *PtWidgetChildBack( PtWidget t *widget );
Description:
This function returns a pointer to the child that’s farthest back in the
specified container widget. If widget doesn’t have any children, the
function returns NULL.
Examples:
#include <Pt.h>
int main ()
{
PtWidget t *window, *group, *child;
PhPoint t pos;
PtArg t argt[5];
if (PtInit(NULL) == -1)
exit(EXIT FAILURE);
pos.x = pos.y = 0;
PtSetArg( &argt[0], Pt ARG POS, &pos, 0 );
PtSetArg( &argt[1], Pt ARG RESIZE FLAGS,
Pt TRUE, Pt RESIZE XY ALWAYS );
PtSetArg( &argt[2], Pt ARG GROUP ORIENTATION,
Pt GROUP HORIZONTAL, 0 );
group = PtCreateWidget( PtGroup, NULL,
3, argt );
// Make the front child red, and the backmost one blue.
PtRealizeWidget (window);
PtMainLoop();
return EXIT SUCCESS;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetBrotherBehind(), PtWidgetBrotherInFront(),
PtWidgetChildFront(), PtWidgetInsert(), PtWidgetParent(),
PtWidgetToBack(), PtWidgetToFront()
PtWindowToBack() PtWindowToFront() in the Photon Widget
Reference.
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
PtWidget t *PtWidgetChildFront(
PtWidget t *widget );
Description:
This function returns a pointer to the child at the very front of the
specified container widget. If widget doesn’t have any children, the
function returns NULL.
Examples:
See PtWidgetChildBack().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetBrotherBehind(), PtWidgetBrotherInFront(),
PtWidgetChildBack(), PtWidgetInsert(), PtWidgetParent(),
PtWidgetToBack(), PtWidgetToFront()
PtWindowToBack() PtWindowToFront() in the Photon Widget
Reference.
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
PtWidgetClassRef t *PtWidgetClass(
PtWidget t *widget );
Description:
This function lets you determine a widget’s class. Using the
PtWidgetClassRef t pointer, you can create new widgets of the
same class or check for specific widget classes.
Returns:
A pointer to a PtWidgetClassRef t, or NULL if the widget is
NULL.
Examples:
/* check the class type of a widget */
if ( PtWidgetClass( widget ) == PtWindow ) {
/* window processing */
}
else {
/* nonwindow processing */
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetIsClass(), PtWidgetIsClassMember()
Synopsis:
unsigned long PtWidgetClassFlags(
PtWidget t *widget );
Description:
This function retrieves widget’s class structure flags:
Pt UNCLEAN RESOURCES
Prevents the resources of a widget class from being indexed.
This is necessary if the widget class only defines resources to
override a superclass (i.e. the widget class doesn’t define any
new resources).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetClass(), PtWidgetFlags()
Synopsis:
PhDim t * PtWidgetDim( PtWidget t *widget,
PhDim t *dim );
Description:
This function retrieves a copy of widget’s dimension and stores it in
the PhDim t structure pointed to by dim.
Returns:
The same pointer as dim, or NULL if widget or dim is NULL.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhDim t, PtWidgetArea()
Synopsis:
PhRect t *PtWidgetExtent( PtWidget t *widget,
PhRect t *extent );
Description:
This function sets the specified PhRect t structure to the extent of
the specified widget and returns a pointer to that structure.
Returns:
The same pointer as extent, or NULL if no PhRect t structure is
provided or if the widget pointer is invalid.
Examples:
PhRect t extent;
PtWidget t *labelwidget;
PtRealizeWidget( labelwidget );
PtWidgetExtent( labelwidget, &extent);
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRect t, PtExtentWidget(), PtRealizeWidget()
Synopsis:
PtWidget t *PtWidgetFamily( PtWidget t *root,
PtWidget t *current );
Description:
This function walks the depth of the widget hierarchy, starting from
the top widget.
Returns:
A pointer to the next widget below root in the widget hierarchy. When
the hierarchy has been fully traversed, the function returns NULL.
Examples:
PtWidget t *mycontainer;
PtWidget t *root;
PtWidget t *current;
int n;
.
.
.
mycontainer = PtCreateWidget( PtContainer, NULL, n, args );
.
.
.
/*
* Set and highlight all PtLabel widgets
* within "mycontainer"
*/
root = current = mycontainer;
PtSetArg( &arg, Pt ARG FLAGS, Pt TRUE,
Pt HIGHLIGHTED|Pt SET);
while( current = PtWidgetFamily( root, current ) )
if( PtWidgetIsClass( current, PtLabel) )
PtSetResources( current, 1, &arg );
PtRealizeWidget( mycontainer );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetBrotherBehind(), PtWidgetBrotherInFront(),
PtWidgetChildBack(), PtWidgetChildFront(), PtWidgetParent(),
PtWidgetSkip(), PtWidgetToBack(), PtWidgetToFront(),
PtWidgetTree(), PtWidgetTreeTraverse()
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
long PtWidgetFlags( PtWidget t *widget );
Description:
This function retrieves a widget’s flags. For the meanings of the bits
in this flag variable, see:
¯ PtWidget.h
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetClassFlags()
Synopsis:
PtWidget t * PtWidgetHelpHit(
PtWidget t *container,
PhPoint t const *pos );
Description:
This function finds the first widget inside the given container at the
given position that contains a help topic (i.e. Pt ARG HELP TOPIC
contains a non-NULL string). The arguments are:
Returns:
A pointer to the widget found; NULL if none was found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerHit()
Synopsis:
int PtWidgetInsert ( PtWidget t *widget,
PtWidget t *new sibling,
int behind );
Description:
This function inserts widget into the widget family hierarchy as a
brother of the widget new sibling, based on the value of behind:
Use this function to insert a widget into the focus order of a group.
For example, if you have widget A and widget C with a focus order of
A→C, you could insert widget B into the focus order after widget A
by making the following call:
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtGetParentWidget(), PtWidgetBrotherBehind(),
PtWidgetBrotherInFront(), PtWidgetChildBack(),
PtWidgetChildFront(), PtWidgetInsert(), PtWidgetParent(),
PtWidgetToBack(), PtWidgetToFront()
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
int PtWidgetIsClass( PtWidget t *widget,
PtWidgetClassRef t *class );
Description:
This function determines whether the specified widget is of the
specified widget class.
Returns:
0 The widget isn’t of the given class type.
Examples:
Test to see if widget is a PtLabel-class widget:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetIsClassMember()
Synopsis:
int PtWidgetIsClassMember(
PtWidget t *widget,
PtWidgetClassRef t *class );
Description:
This function determines whether or not the specified widget is a
member of the specified widget class. You can use this function to
determine whether the widget is of the specified class or a subclass of
the specified class.
Returns:
0 widget isn’t a member of the given class.
Examples:
Test to see if widget belongs to the PtGraphic class (i.e. is it a line,
rectangle, polygon, etc.):
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetIsClass()
Synopsis:
int PtWidgetIsRealized ( PtWidget t *widget );
Description:
This function checks to see if the given widget is realized.
Returns:
A nonzero value if the widget is realized, otherwise 0.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
PhPoint t *PtWidgetOffset( PtWidget t *widget,
PhPoint t *offset );
Description:
This function determines the offset of widget’s origin from its disjoint
parent widget.
Returns:
A pointer to a PhPoint t structure that’s the offset of the widget’s
origin from its parent window (the widget’s position is relative to this
point), or NULL if an error occurs.
Examples:
PtArg t arg;
PhPoint t *widget pos;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
continued. . .
Safety
Thread No
See also:
PtGetAbsPosition(), PtTranslateRect()
Synopsis:
PtWidget t *PtWidgetParent( PtWidget t *widget );
Description:
This function returns a pointer to the parent of the specified widget. If
no parent exists, the function returns NULL.
Examples:
See PtWidgetChildBack().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCreateWidget(), PtFindGuardian(), PtGetParent(),
PtGetParentWidget(), PtReParentWidget(), PtSetParentWidget(),
PtValidParent(), PtWidgetBrotherBehind(),
PtWidgetBrotherInFront(), PtWidgetChildBack(),
PtWidgetChildFront()
Synopsis:
PhRid t PtWidgetRid( PtWidget t *widget );
Description:
This function returns the region ID of the specified widget. If widget
doesn’t have a region, the function returns 0.
Examples:
See PtGetParent().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetBrotherBehind(), PtWidgetBrotherInFront(),
PtWidgetChildFront(), PtWidgetChildBack(), PtWidgetFamily(),
PtWidgetParent(), PtWidgetToBack(), PtWidgetToFront()
Synopsis:
PtWidget t * PtWidgetSkip( PtWidget t *root,
PtWidget t *widget );
Description:
This function skips the hierarchy rooted at widget but does not return
widgets any higher than root.
Returns:
A pointer to a widget in the next hierarchy, or NULL if there isn’t
another hierarchy to skip to.
Examples:
// Set the fill color of all REALIZED widgets to white.
PtArg t argt;
int flags, skip = 0;
PtSetArg( &argt, Pt ARG FILL COLOR, Pt WHITE, 0 );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtNextTopLevelWidget(), PtWidgetBrotherBehind(),
PtWidgetBrotherInFront(), PtWidgetChildBack(),
PtWidgetChildFront(), PtWidgetFamily(), PtWidgetTree(),
PtWidgetTreeTraverse()
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
int PtWidgetToBack( PtWidget t *widget );
Description:
This function moves the specified widget behind all its brothers (i.e.
away from the user). All of widget’s children are moved too. Any
widgets damaged as a result of this operation are automatically
repaired.
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
See PtWidgetChildBack().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetBrotherBehind(), PtWidgetBrotherInFront(),
PtWidgetChildBack(), PtWidgetChildFront(), PtWidgetInsert(),
PtWidgetParent(), PtWidgetToFront()
PtWindowToBack() PtWindowToFront() in the Photon Widget
Reference.
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
int PtWidgetToFront( PtWidget t *widget );
Description:
This function moves the specified widget in front of all its brothers
(i.e. toward the user). All of widget’s children are moved too. Any
widgets damaged as a result of this operation are automatically
repaired.
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
See PtWidgetChildBack().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetBrotherBehind(), PtWidgetBrotherInFront(),
PtWidgetChildBack(), PtWidgetChildFront(), PtWidgetInsert(),
PtWidgetParent(), PtWidgetToBack()
PtWindowToBack() PtWindowToFront() in the Photon Widget
Reference.
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
int PtWidgetTree( PtWidget t *root,
PtWidget t **cur,
int D );
Description:
This function walks the widget tree pointed to by root from front to
back. The cur argument is the address of a pointer to the current
widget in the tree. The D argument is the direction control.
To start the traversal, set cur to be the address of a pointer to the root
widget, and set D to Pt TRAVERSE START. Use the result returned by
PtWidgetTree() as the value of D for the next call.
The traversal is done when PtWidgetTree() returns
Pt TRAVERSE DONE.
Returns:
Pt TRAVERSE DONE
All the widgets in the tree have been traversed.
Any other value
Pass this value as D in the next call.
Examples:
PtWidget t *cur, *window;
int d;
.
.
.
cur=window
d=Pt TRAVERSE START;
while( ( d=PtWidgetTree( window, &cur, d ) ) != Pt TRAVERSE DONE)
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtNextTopLevelWidget(), PtValidParent(), PtWidgetBrotherBehind(),
PtWidgetBrotherInFront(), PtWidgetChildBack(),
PtWidgetChildFront(), PtWidgetFamily(), PtWidgetParent(),
PtWidgetSkip(), PtWidgetTreeTraverse()
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
int PtWidgetTreeTraverse(
PtWidget t *root,
PtWidget t **current,
int direction,
int (*skip f )( PtWidget t *widget,
void *data ),
void *data );
Description:
This function walks the widget family hierarchy from the frontmost
widget of the current branch to root.
If a skip f() function is provided, it’s called prior to the traversal into
each branch of the family hierarchy. If the skip f() function returns a
value other than Pt CONTINUE, that branch may be skipped. The
skip f() function is passed the current widget (root of the branch to be
traversed next) and data, as provided in the last parameter to
PtWidgetTreeTraverse().
The direction parameter controls the direction of the traversal to the
next current widget. To begin a traversal, a direction of
Pt TRAVERSE START should be passed. New direction values are
returned by the function and should be used in subsequent calls
during the traversal.
The direction value returned is treated primarily as a bit field in which
the bottom four bits (0xF) are reserved for direction and general state
control. These bits are:
Pt TRAVERSE ROOT
current is root.
Pt TRAVERSE LAST
current is last widget in hierarchy to be processed.
Pt TRAVERSE BACK
Walk towards root.
Pt TRAVERSE FORCE
Return the return value from skip f unaltered (the return value
is usually ORed with direction prior to return).
Returns:
0 Successful completion of traversal.
-1 An error occurred.
Examples:
Example 1 — Implementation of PtWidgetTree():
static int
skip delay realize( PtWidget t *widget, void *data )
{
data;
return (
(
(
( widget->flags & ( Pt DELAY REALIZE |
Pt REALIZED ) )
== Pt DELAY REALIZED
)
) ? Pt TRAVERSE BACK : Pt CONTINUE );
}
int
PtWidgetTree( PtWidget t *root, PtWidget t **cur, int D )
{
return PtWidgetTreeTraverse( root, cur, D,
skip delay realize, NULL );
}
.
.
.
dir = Pt TRAVERSE START;
while( dir = PtWidgetTreeTraverse( NULL, ¤t,
dir, skip disjoint, NULL ) )
if( !( dir & FOUND DISJOINT ) )
break;
.
.
.
.
.
.
current = ABW pane1;
dir = Pt TRAVERSE START;
while( dir = PtWidgetTreeTraverse( ABW base, ¤t, dir,
skip disjoint, NULL ) )
{
if ( dir & FOUND DISJOINT )
// current is the disjoint widget
continue;
//do stuff with current...
}
.
.
.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtNextTopLevelWidget(), PtWidgetBrotherBehind(),
PtWidgetBrotherInFront(), PtWidgetChildBack(),
PtWidgetChildFront(), PtWidgetFamily(), PtWidgetParent(),
PtWidgetSkip(), PtWidgetTree()
“Ordering widgets” in the Creating Widgets in Application Code
chapter of the Photon Programmer’s Guide
Synopsis:
int PtWidgetVisibleExtent ( PtWidget t *widget,
PhRect t *rect );
Description:
This function determines the portion of a rectangle, rect, that isn’t
clipped by any parent of widget.
Returns:
0 No portion of rect is visible
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtWindowConsoleSwitch( PhRid t rid );
Description:
This function causes PWM to switch the current display to the
console where the window specified by rid is located. The rid is the
region of a task window, and may be obtained with PtWidgetRid().
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConsoleSwitch(), PtWidgetRid()
Synopsis:
typedef int PtWorkProcF t( void *);
typedef PtWorkProcF t *PtWorkProc t;
Description:
These data types define pointers to work procedures. The
PtWorkProcF t type is the function type that the PtWorkProc t
type points to. This allows you to do something like this:
Classification:
Photon
See also:
PtAppAddWorkProc()
¯ Create CRCs.
☞ These functions are supplied only in static form in the Photon library
phexlib3r.lib. You’ll need to link with this library explicitly.
Synopsis:
#include <photon/PxProto.h>
Description:
This function closes the currently opened configuration file (opened
using PxConfigOpen()). It doesn’t do anything if there’s no currently
opened configuration file.
Returns:
Pt TRUE The file was opened and is now closed.
Pt FALSE Otherwise.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen()
Synopsis:
#include <photon/PxProto.h>
Description:
Use this function to delete the entry entry from the section section in
the configuration file.
☞ The configuration file must have been opened for PXCONFIG WRITE
— see PxConfigOpen().
Returns:
Pt TRUE The entry is deleted.
Pt FALSE Otherwise.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigDeleteSection(), PxConfigOpen()
Synopsis:
#include <photon/PxProto.h>
Description:
This function deletes the section section from the configuration file.
☞ The file must have been opened for PXCONFIG WRITE — see
PxConfigOpen().
All entries within the section (up to either the beginning of the next
[] section or end-of-file) are deleted. The internal current section is
cleared.
Returns:
Pt TRUE The section is deleted.
Pt FALSE Otherwise.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigDeleteEntry(), PxConfigForceEmptySection(),
PxConfigOpen()
Synopsis:
#include <photon/PxProto.h>
Description:
This function creates an empty section section if one doesn’t exist.
☞ The file must have been opened for PXCONFIG WRITE — see
PxConfigOpen().
Returns:
Pt TRUE The section is created or exists.
Pt FALSE Otherwise.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigDeleteSection(), PxConfigOpen()
Synopsis:
#include <photon/PxProto.h>
Description:
Seek the start of the next section, and return the name of this section;
this section is made the internal current section. This may be used to
process a configuration file consisting of unknown sections, but where
each section has known entries.
Returns:
A string containing the next section name if one exists, NULL
otherwise
Examples:
char *section;
while ((section = PxConfigNextSection()) != NULL) {
PxConfigReadShort(NULL, "Size", 0, &recsize);
PxConfigReadShort(NULL, "Max", 0, &maxrecs);
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
continued. . .
Safety
Thread No
See also:
PxConfigNextString(), PxConfigOpen(), PxConfigSection()
Synopsis:
#include <photon/PxProto.h>
Description:
This function returns the next entry in the current section as a string.
A pointer to the entry name is returned, and its configuration value
(up to a maximum of maxlen-1 characters) is copied as a string into
the buffer at address value. This may be used to process a
configuration section consisting of unknown entries, but where each
entry is to be processed in a similar fashion.
Returns:
A string containing the next entry name within the current section if
one exists, NULL otherwise.
Examples:
char *env, val[128];
if (PxConfigSection("Environment") != NULL)
while ((env = PxConfigNextString(val, sizeof(val))) != NULL)
setenv(env, val, ˜0);
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigNextSection(), PxConfigOpen(), PxConfigSection()
Synopsis:
#include <photon/PxProto.h>
Description:
PxConfigOpen() opens the configuration file specified by cfgfile for
reading. The file should be closed using PxConfigClose() when the
configuration procedure is complete. Only one configuration file may
be opened at any one time.
The mode parameter is a bitfield specifying what operations may be
performed on the configuration file; it consists of any number of the
following values:
PXCONFIG READ
Allow reading of the config file. This access is always
permitted.
PXCONFIG WRITE
Allow writing (modification) of the config file, using
PxConfigWrite*() and PxConfigDelete*().
PXCONFIG CREATE
Create a new config file, erasing the file if it exists (be sure to
specify PXCONFIG WRITE as well).
[WWW Section]
Heading Font = swiss
Body Font = dutch
Link Color = 0000FF
Visited Color = 008080
Cache Size = 10240
[File Section]
File Font = swiss12
Print Command = lp @
Display Mode = 1
Returns:
Pt TRUE The given configuration file exists and has been
opened.
Pt FALSE Otherwise.
Examples:
if (PxConfigOpen(fname, PXCONFIG READ)) {
// read parameters from the file
PxConfigClose();
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigClose(), PxConfigDeleteEntry(), PxConfigDeleteSection(),
PxConfigForceEmptySection(), PxConfigNextSection(),
PxConfigNextString(), PxConfigReadBool(), PxConfigReadChar(),
PxConfigReadInt(), PxConfigReadLong(), PxConfigReadShort(),
PxConfigReadString(), PxConfigSection(), PxConfigWriteBool(),
PxConfigWriteChar(), PxConfigWriteInt(), PxConfigWriteLong(),
PxConfigWriteShort(), PxConfigWriteString()
Synopsis:
#include <photon/PxProto.h>
Description:
PxConfigReadBool() reads a Boolean parameter from the specified
section and entry of the configuration file. If section is NULL, the
function reads the value from entry in the current section.
PxConfigReadBool() accepts the (case-insensitive) values ON or OFF,
YES or NO, TRUE or FALSE, and stores the integer equivalent (zero or
nonzero) in *value. If any other value is given (or if none is given),
the default value dflt is put into *value instead. If the required section
or entry doesn’t exist, the default value is stored in *value.
Returns:
Pt TRUE if the required section/entry exists and the given value is
valid, otherwise Pt FALSE.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen(), PxConfigReadChar(), PxConfigReadInt(),
PxConfigReadLong(), PxConfigReadShort(), PxConfigReadString(),
PxConfigWriteBool(), PxConfigWriteChar(), PxConfigWriteInt(),
PxConfigWriteLong(), PxConfigWriteShort(), PxConfigWriteString()
Synopsis:
#include <photon/PxProto.h>
Description:
PxConfigReadChar() reads a character parameter from the specified
section and entry of the configuration file. If section is NULL, the
function reads the value from entry in the current section.
PxConfigReadChar() accepts digits (signed and unsigned) within the
char range, or a single letter, and stores the value in *value. For all
other (invalid or nonexistent) values, the default value dflt is stored
instead. If the required section or entry doesn’t exist, the default value
is stored in *value.
Returns:
Pt TRUE if the required section/entry exists and the given value is
valid, otherwise Pt FALSE.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen(), PxConfigReadBool(), PxConfigReadInt(),
PxConfigReadLong(), PxConfigReadShort(), PxConfigReadString(),
PxConfigWriteBool(), PxConfigWriteChar(), PxConfigWriteInt(),
PxConfigWriteLong(), PxConfigWriteShort(), PxConfigWriteString()
Synopsis:
#include <photon/PxProto.h>
Description:
PxConfigReadInt() reads an integer parameter from the specified
section and entry of the configuration file and stores it in *value.
If section is NULL, the function reads the value from entry in the
current section. If the required section or entry doesn’t exist, the
default value is stored in *value.
The value can be signed. The characters after the sign determine the
base:
Character(s): Base:
0x or 0X Hexadecimal
0 Octal
Other digits Decimal
If the entry doesn’t contain a valid int, the default value dflt is stored
in *value.
Returns:
Pt TRUE if the required section/entry exists and the given value is
valid, otherwise Pt FALSE.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen(), PxConfigReadBool(), PxConfigReadChar(),
PxConfigReadLong(), PxConfigReadShort(), PxConfigReadString(),
PxConfigWriteBool(), PxConfigWriteChar(), PxConfigWriteInt(),
PxConfigWriteLong(), PxConfigWriteShort(), PxConfigWriteString()
Synopsis:
#include <photon/PxProto.h>
Description:
PxConfigReadLong() reads a long parameter from the specified
section and entry of the configuration file and stores it in *value.
If section is NULL, the function reads the value from entry in the
current section. If the required section or entry doesn’t exist, the
default value is stored in *value.
The value can be signed. The characters after the sign determine the
base:
Character(s): Base:
0x or 0X Hexadecimal
0 Octal
Other digits Decimal
If the entry doesn’t contain a valid long, the default value dflt is
stored in *value.
Returns:
Pt TRUE if the required section/entry exists and the given value is
valid, otherwise Pt FALSE.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen(), PxConfigReadBool(), PxConfigReadChar(),
PxConfigReadInt(), PxConfigReadShort(), PxConfigReadString(),
PxConfigWriteBool(), PxConfigWriteChar(), PxConfigWriteInt(),
PxConfigWriteLong(), PxConfigWriteShort(), PxConfigWriteString()
Synopsis:
#include <photon/PxProto.h>
Description:
PxConfigReadShort() reads a short parameter from the specified
section and entry of the configuration file and stores it in *value.
If section is NULL, the function reads the value from entry in the
current section. If the required section or entry doesn’t exist, the
default value is stored in *value.
The value can be signed. The characters after the sign determine the
base:
Character(s): Base:
0x or 0X Hexadecimal
0 Octal
Other digits Decimal
If the entry doesn’t contain a valid short, the default value dflt is
stored in *value.
Returns:
Pt TRUE if the required section/entry exists and the given value is
valid, otherwise Pt FALSE.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen(), PxConfigReadBool(), PxConfigReadChar(),
PxConfigReadInt(), PxConfigReadLong(), PxConfigReadString(),
PxConfigWriteBool(), PxConfigWriteChar(), PxConfigWriteInt(),
PxConfigWriteLong(), PxConfigWriteShort(), PxConfigWriteString()
Synopsis:
#include <photon/PxProto.h>
Description:
PxConfigReadString() reads a string parameter from the specified
section and entry of the configuration file. If section is NULL, the
function reads the value from entry in the current section.
PxConfigReadString() copies a maximum of (maxlen-1) characters
(with a ’\0’ terminator appended) in the string into the buffer at
address value. If the required section or entry doesn’t exist, the first
(maxlen-1) characters of the default string dflt are copied into the
buffer at address value (with a ’\0’ terminator appended).
Returns:
Pt TRUE if the required section/entry exists, otherwise Pt FALSE.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen(), PxConfigReadBool(), PxConfigReadChar(),
PxConfigReadInt(), PxConfigReadLong(), PxConfigReadShort(),
PxConfigWriteBool(), PxConfigWriteChar(), PxConfigWriteInt(),
PxConfigWriteLong(), PxConfigWriteShort(), PxConfigWriteString()
Synopsis:
#include <photon/PxProto.h>
Description:
PxConfigSection() seeks to the start of the requested section, and
returns an indication of whether the section exists within the
configuration file. This function may be used to conditionally process
an optional section block. Photon also uses it internally to locate a
configuration entry; the section is made the internal current section.
Returns:
Pt TRUE if the requested section exists, Pt FALSE otherwise
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigDeleteSection(), PxConfigForceEmptySection(),
PxConfigNextSection(), PxConfigNextString(), PxConfigOpen()
Synopsis:
#include <photon/PxProto.h>
Description:
PxConfigWriteBool() writes a Boolean parameter in the specified
section and entry of the configuration file. If section is NULL, the
parameter is written in the specified entry in the current section. If the
parameter value was present in the file, it’s overwritten with its new
value; otherwise, it’s added to the end of the section.
Format Output
PXCONFIG FMT BOOL ON OFF or ON
PXCONFIG FMT BOOL YES NO or YES
PXCONFIG FMT BOOL TRUE FALSE or TRUE
Returns:
Pt TRUE if the entry is written, otherwise Pt FALSE
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen(), PxConfigReadBool(), PxConfigReadChar(),
PxConfigReadInt(), PxConfigReadLong(), PxConfigReadShort(),
PxConfigReadString(), PxConfigWriteChar(), PxConfigWriteInt(),
PxConfigWriteLong(), PxConfigWriteShort(), PxConfigWriteString()
Synopsis:
#include <photon/PxProto.h>
Description:
PxConfigWriteChar() writes a character parameter in the specified
section and entry of the configuration file. If section is NULL, the
parameter is written in the specified entry in the current section. If the
parameter value was present in the file, it’s overwritten with its new
value; otherwise, it’s added to the end of the section.
Returns:
Pt TRUE if the entry is written, otherwise Pt FALSE
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen(), PxConfigReadBool(), PxConfigReadChar(),
PxConfigReadInt(), PxConfigReadLong(), PxConfigReadShort(),
PxConfigReadString(), PxConfigWriteBool(), PxConfigWriteInt(),
PxConfigWriteLong(), PxConfigWriteShort(), PxConfigWriteString()
Synopsis:
#include <photon/PxProto.h>
Description:
PxConfigWriteInt() writes an integer parameter in the specified
section and entry of the configuration file. If section is NULL, the
parameter is written in the specified entry in the current section. If the
parameter value was present in the file, it’s overwritten with its new
value; otherwise, it’s added to the end of the section.
Returns:
Pt TRUE if the entry is written, otherwise Pt FALSE
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen(), PxConfigReadBool(), PxConfigReadChar(),
PxConfigReadInt(), PxConfigReadLong(), PxConfigReadShort(),
PxConfigReadString(), PxConfigWriteBool(), PxConfigWriteChar(),
PxConfigWriteLong(), PxConfigWriteShort(), PxConfigWriteString()
Synopsis:
#include <photon/PxProto.h>
Description:
PxConfigWriteLong() writes a long integer parameter in the specified
section and entry of the configuration file. If section is NULL, the
parameter is written in the specified entry in the current section. If the
parameter value was present in the file, it’s overwritten with its new
value; otherwise, it’s added to the end of the section.
Returns:
Pt TRUE if the entry is written, otherwise Pt FALSE
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen(), PxConfigReadBool(), PxConfigReadChar(),
PxConfigReadInt(), PxConfigReadLong(), PxConfigReadShort(),
PxConfigReadString(), PxConfigWriteBool(), PxConfigWriteChar(),
PxConfigWriteInt(), PxConfigWriteShort(), PxConfigWriteString()
Synopsis:
#include <photon/PxProto.h>
Description:
PxConfigWriteShort() writes a short integer parameter in the specified
section and entry of the configuration file. If section is NULL, the
parameter is written in the specified entry in the current section. If the
parameter value was present in the file, it’s overwritten with its new
value; otherwise, it’s added to the end of the section.
Returns:
Pt TRUE if the entry is written, otherwise Pt FALSE
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen(), PxConfigReadBool(), PxConfigReadChar(),
PxConfigReadInt(), PxConfigReadLong(), PxConfigReadShort(),
PxConfigReadString(), PxConfigWriteBool(), PxConfigWriteChar(),
PxConfigWriteInt(), PxConfigWriteLong(), PxConfigWriteString()
Synopsis:
#include <photon/PxProto.h>
Description:
PxConfigWriteString() writes a string parameter in the specified
section and entry of the configuration file. If section is NULL, the
parameter is written in the specified entry in the current section. If the
parameter value was present in the file, it’s overwritten with its new
value; otherwise, it’s added to the end of the section.
Returns:
Pt TRUE if the entry is written, otherwise Pt FALSE
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen(), PxConfigReadBool(), PxConfigReadChar(),
PxConfigReadInt(), PxConfigReadLong(), PxConfigReadShort(),
PxConfigReadString(), PxConfigWriteBool(), PxConfigWriteChar(),
PxConfigWriteInt(), PxConfigWriteLong(), PxConfigWriteShort()
Synopsis:
#include <photon/PxProto.h>
Description:
This function generates a cyclic redundancy check or CRC on the
nbytes of data pointed to by buffer.
Returns:
The cyclic redundancy check.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxLoadImage()
Synopsis:
#include <photon/PxHelp.h>
Description:
PxHelpQuit() tells the Helpviewer to exit.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxHelpTopic(), PxHelpTopicRoot(), PxHelpTopicTree(),
PxHelpSearch(), PxHelpUrl(), PxHelpUrlRoot()
Context-Sensitive Help chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/PxHelp.h>
Description:
Use PxHelpSearch() to search for a string in the online help
information. The arguments are similar to the fields in the
Helpviewer’s Search pane, and are as follows:
Returns:
0 on success, or -1 if the Helpviewer couldn’t be found or spawned.
Examples:
PxHelpSearch( "console", HELP SEARCH MODE TITLE,
HELP SEARCH SCOPE ALL,
HELP SEARCH METHOD SUBSTRING );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxHelpQuit(), PxHelpTopic(), PxHelpTopicRoot(),
PxHelpTopicTree(), PxHelpUrl(), PxHelpUrlRoot()
Context-Sensitive Help chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/PxHelp.h>
Description:
PxHelpTopic() tells the Helpviewer to display the help text located by
the given topic path.
PxHelpTopic() spawns the Helpviewer if it isn’t running, or sends a
message to the Helpviewer if it is. Using this function, a Photon
application can respond to a help request from the user by telling the
Helpviewer to display the relevant help information.
If the topic path is relative (i.e. it doesn’t start with a /), it’s appended
to the root topic path specified in an earlier call to PxHelpTopicRoot().
Returns:
0 on success, or -1 if the Helpviewer couldn’t be found or spawned.
Examples:
The following example shows a fragment from a hypothetical
application built using PhAB. This application first sets up a topic
root for all help requests; it then displays help for a particular part of
the application in response to a callback (which could be attached to a
hotkey, for example).
#include <Pt.h>
#include <photon/PxHelp.h>
PxHelpTopicRoot(
"/Photon microGUI/Installation & Configuration/pdm" );
.
.
.
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxHelpQuit(), PxHelpSearch(), PxHelpTopicRoot(),
PxHelpTopicTree(), PxHelpUrl(), PxHelpUrlRoot()
Context-Sensitive Help chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/PxHelp.h>
Description:
PxHelpTopicRoot() lets you specify a partial root topic path that’s
prefixed to any relative topic paths in subsequent PxHelpTopic() calls.
(Any path that doesn’t start with a / is considered relative.)
☞ PxHelpTopicRoot() doesn’t copy the topic root. Don’t free the string
until you’ve finished using the root topic path.
Examples:
See PxHelpTopic().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxHelpQuit(), PxHelpSearch(), PxHelpTopic(), PxHelpTopicTree(),
PxHelpUrl(), PxHelpUrlRoot()
Context-Sensitive Help chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/PxHelp.h>
Description:
PxHelpTopicTree() tells the Helpviewer to load a new topic tree. The
argument must be a top-level topic file with the .toc extension. The
format of the topic file is defined in the “Creating topic files” section
of the Helpviewer documentation in the Photon Installation &
Configuration guide.
PxHelpTopicTree() spawns the Helpviewer if it isn’t running, or sends
a message to the Helpviewer if it is.
Returns:
0 on success, or -1 if the Helpviewer couldn’t be found or spawned.
Examples:
PxHelpTopicTree( "/usr/help/product/photon.toc" );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxHelpQuit(), PxHelpSearch(), PxHelpTopic(), PxHelpTopicRoot(),
PxHelpUrl(), PxHelpUrlRoot()
Context-Sensitive Help chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/PxHelp.h>
Description:
PxHelpUrl() tells the Helpviewer to display the help text located by
the given Universal Resource Locator. If the URL is relative (i.e. it
doesn’t start with a /), it’s appended to any partial URL root specified
in a previous call to PxHelpUrlRoot().
PxHelpUrl() spawns the Helpviewer if it isn’t running, or sends a
message to the Helpviewer if it is. Using this function, a Photon
application can respond to a help request from the user by telling the
Helpviewer to display the relevant help information.
Returns:
0 on success, or -1 if the Helpviewer couldn’t be found or spawned.
Examples:
The following example shows a fragment from a hypothetical
application built using PhAB. This application first sets up a URL
root for all help requests; it then displays help for a particular part of
the application in response to a callback (which could be attached to a
hotkey, for example).
#include <Pt.h>
#include <photon/PxHelp.h>
PxHelpUrlRoot(
"/usr/help/product/photon/user guide/desktop man.html" );
.
.
.
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxHelpQuit(), PxHelpSearch(), PxHelpTopic(), PxHelpTopicRoot(),
PxHelpTopicTree(), PxHelpUrlRoot()
Context-Sensitive Help chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/PxHelp.h>
Description:
PxHelpUrlRoot() lets you specify a partial root URL that’s prefixed to
any relative URLs in subsequent PxHelpUrl() calls. (A relative URL is
one that doesn’t start with a /.)
☞ PxHelpUrlRoot() doesn’t copy the given URL. Don’t free the string
until you’ve finished using the root URL.
Examples:
See PxHelpUrl().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxHelpQuit(), PxHelpSearch(), PxHelpTopic(), PxHelpTopicRoot(),
PxHelpTopicTree(), PxHelpUrl()
Context-Sensitive Help chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/PxImage.h>
Description:
This function reads a graphic file into memory. Photon supports the
BMP, GIF, JPG, PCX, and JPEG file formats, among others. For a
complete list of the currently supported formats, see
<photon/PxImage.h>.
The filename argument specifies the name of the graphic file to load
or query.
The methods argument points to a structure that lets you modify the
behavior of the function. If this argument is NULL, the function loads
the graphic file specified by filename. PxMethods t is defined as:
typedef struct pxmethods
{
int flags;
void *(*px alloc)( long nbytes, int type );
void *(*px free)( void *memory, int type );
void *(*px error)( char *msg );
void *(*px warning)( char *msg );
void *(*px progress)( int percent );
PhDim t scale;
PgColor t transparent;
void *colors;
int ncolors;
} PxMethods t;
Returns:
A pointer to a PhImage t structure, or NULL if an error occurs.
Examples:
This example can use either shared or normal memory. The advantage
of using shared memory is that it takes less time to draw the image. If
you’re not using shared memory, increasing the draw buffer size
causes more drawing to be buffered before being sent to the graphics
driver; this isn’t as important if you’re using shared memory.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <malloc.h>
#include <assert.h>
#include <ctype.h>
#include <signal.h>
#include <Ph.h>
#include <Pt.h>
#include <photon/PxImage.h>
int UseShmem = 1;
case ’S’:
UseShmemˆ=1;
break;
}
}
if( Query )
methods.flags |= PX QUERY;
else
methods.flags |= PX LOAD;
if( Query ) {
printf( "Image width: %d\n", img->size.w );
printf( "Image height: %d\n", img->size.h );
printf( "Image BPL: %d\n", img->bpl );
printf( "Image colors: %d\n", img->colors );
printf( "Image type: %d\n", img->type );
exit( EXIT SUCCESS );
}
/* create a window */
PtSetArg( &arg[0], Pt ARG DIM, &img->size, 0 );
PtSetArg( &arg[1], Pt ARG WINDOW TITLE,
"Photon Image Viewer", 0 );
window = PtCreateWidget( PtWindow, NULL, 2, arg );
free( img );
PtRealizeWidget( window );
PtMainLoop();
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawPhImagemx(), PgSetPalette(), PgSetFillColor(),
PgSetTextColor(), PgShmemCleanup(), PhImage t,
PhMakeGhostBitmap(), PhMakeTransBitmap(), PhReleaseImage()
Synopsis:
#include <photon/PxTerminal.h>
PtTerminalCharsets t *PxTerminalBuildCharsets(
PxTerminalCsNames t const *names );
Description:
This function is an alternative to creating charset tables by hand. It
creates a PtTerminalCharsets t structure (see the Photon Widget
Reference) based on Photon character translation files (see
PxTranslateSet()).
The PxTerminalCsNames t structure is defined as follows:
typedef struct {
char const *AnsiCharsetName;
char const *InternalCharsetName;
char const *FontCharsetName;
...
}
PxTerminalCsNames t;
This function puts the resulting structure and all the tables in a single
allocated block of memory. After it’s no longer needed, you can
simply free() it.
Returns:
A pointer to the resulting PtTerminalCharsets t structure.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxTerminalLoadCharsets(), PxTerminalSaveCharsets()
PtTerminal, PtTerminalCharsets t in the Photon Widget
Reference
Synopsis:
#include <photon/PxTerminal.h>
PtTerminalCharsets t *PxTerminalLoadCharsets(
const char *filename,
PxTerminalCsNames t *names );
Description:
PxTerminalLoadCharsets() loads character-set information from the
given file. The names argument, if not NULL, points to a structure that
the names of the character sets will be stored in.
This function puts the resulting structure and all the tables and strings
in a single allocated block of memory. After it’s no longer needed,
you can simply free() it. Note that this invalidates the strings stored in
*names.
Returns:
A pointer to a PtTerminalCharsets t structure ready for use with
a PtTerminal, widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxTerminalBuildCharsets(), PxTerminalSaveCharsets()
PtTerminal, PtTerminalCharsets t in the Photon Widget
Reference
Synopsis:
#include <photon/PxTerminal.h>
int PxTerminalSaveCharsets(
PtTerminalCharsets t *charsets,
PxTerminalCsNames t *names,
const char *filename );
Description:
This function saves the character-set information in the given file. It’s
your responsibility to make sure that the information in *charsets is
consistent with the information in *names — generating both with the
same call to PxTerminalBuildCharsets() is a good way to ensure
consistency.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxTerminalBuildCharsets(), PxTerminalLoadCharsets()
PtTerminal, PtTerminalCharsets t in the Photon Widget
Reference
Synopsis:
#include <photon/PxProto.h>
Description:
PxTranslateFromUTF() is used to translate a block of characters from
UTF-8 (the internal Photon character set). The ctrl parameter
specifies the encoding of the destination characters and must be the
pointer returned by a previous call to PxTranslateSet() to install this
encoding.
The parameters are as follows:
maxsrc the length of the contents in the source buffer (in bytes).
No more than this number of bytes are read.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxTranslateList(), PxTranslateSet(), PxTranslateStateFromUTF(),
PxTranslateStateToUTF(), PxTranslateToUTF(),
PxTranslateUnknown()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
#include <photon/PxProto.h>
Description:
This function may be used to create a list or combobox of all
supported character translations. It takes as a parameter a pointer to a
list-type widget and sets its Pt ARG ITEMS resource to be the list of
translations. These translations are read from the file
/usr/photon/translations/charsets, using the
Description entry as the item text.
If non-NULL, the none parameter points to a string to be added to the
top of the list. This allows you to specify an entry such as None or
Default. Your application will need to know how to handle this entry
when it’s chosen.
This list may then be used at run time to alter the current translation
dynamically. The program should call PxTranslateSet() with the
selected description text to install the new encoding.
Returns:
The number of items placed in the list, or -1 on error.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxTranslateFromUTF(), PxTranslateSet(),
PxTranslateStateFromUTF(), PxTranslateStateToUTF(),
PxTranslateToUTF(), PxTranslateUnknown()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
#include <photon/PxProto.h>
Description:
PxTranslateSet() installs a new character set translation. The ctrl
argument, if non-NULL, is a pointer to the control structure for a
character set translation returned from a previous call to
PxTranslateSet(). The translation it specifies is disabled, and any
resources it uses are released.
PxTranslateSet() searches the
/usr/photon/translations/charsets configuration file for the
translation specified by charset; it may be an entry section name, one
of the Alias entries or the Description entry. The charset name is
usually selected by the user (see PxTranslateList()) or from an
external specification (for example, the charset= field of the
Content-type MIME / HTTP header).
If the specified charset is found, resources are allocated as required,
and any necessary data files are loaded into memory. The following
special values of charset are recognized:
Returns:
A pointer to a translation control structure, which should be passed to
subsequent translation routines and to future calls to PxTranslateSet()
Examples:
This sample program converts characters from stdin (encoded in a
character set specified to the program as its only argument) to
stdout (in UTF-8). Note that a 256-byte buffer is allocated for input
and a MB LEN MAX * 256 bytes (the worst-case UTF-8 encoding for
that number of input bytes) created for output. Alternatively, a call to
PxTranslateToUTF() with a NULL source buffer could be used to
work out the bytes-per-character requirements (we exploit the fact
that we already know this number for UTF-8 encoding).
#include <mbstring.h>
#include <stdio.h>
#include <stdlib.h>
#include <photon/PxProto.h>
if (argc < 2) {
fprintf(stderr, "specify translation charset\n");
return(1);
}
if ((trans = PxTranslateSet(NULL, argv[1])) == NULL) {
fprintf(stderr, "unknown translation charset ’%s’\n",
argv[1]);
return(1);
}
if ((code = malloc(BUFFER)) == NULL ||
(utf = malloc(BUFFER * MB LEN MAX)) == NULL) {
fprintf(stderr,
"unable to allocate %d-byte translation buffers\n",
BUFFER);
return(1);
}
stdin))) {
if ((dstlen = PxTranslateStateToUTF(trans, code,,
srclen NULL, utf,
BUFFER * MB LEN MAX)) == -1) {
fprintf(stderr, "invalid encoding sequence\n");
return(1);
}
fwrite(utf, dstlen, sizeof(char), stdout);
}
return(0);
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxTranslateList(), PxTranslateFromUTF(),
PxTranslateStateFromUTF(), PxTranslateStateToUTF(),
PxTranslateToUTF(), PxTranslateUnknown()
Unicode Multilingual Support in the Photon Programmer’s Guide
Unicode Multilingual Support in the Installation & Configuration
guide.
Synopsis:
#include <photon/PxProto.h>
int PxTranslateStateFromUTF(
struct PxTransCtrl *ctrl,
const char *src,
int maxsrc,
int *consumed,
char *dst,
int maxdst );
Description:
This function is similar to PxTranslateFromUTF() except that it uses
an internal state buffer.
Since many encodings are multibyte, it’s possible (in cases where
input data is being provided from a file or socket) for a conversion to
end in the middle of a multibyte sequence or for the output buffer to
be too small to hold the complete encoding of the final character. This
routine buffers any partial encoding, using those bytes as the start of a
character sequence for the next PxTranslateStateFromUTF() call.
This routine uses an appropriately sized temporary overflow buffer,
allocated by the PxTranslateSet() routine.
The parameters src and maxsrc specify the input UTF-8 buffer; dst
and maxdst specify the output buffer. These have the same meaning
as in the PxTranslateFromUTF() function. The consumed parameter
is updated with the number of bytes converted from the source buffer;
this may be NULL if this information isn’t required ( i.e. if the source
is always correctly encoded and the destination buffer is always
sufficiently large).
Returns:
The number of bytes produced in the destination buffer, or -1 on error.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxTranslateList(), PxTranslateFromUTF(), PxTranslateSet(),
PxTranslateStateToUTF(), PxTranslateToUTF(),
PxTranslateUnknown()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
#include <photon/PxProto.h>
Description:
This function is similar to PxTranslateToUTF() except that it uses an
internal state buffer.
Since many encodings are multibyte, it’s possible (in cases where
input data is being provided from a file or socket) for a conversion to
end in the middle of a multibyte sequence or for the output buffer to
be too small to hold the complete encoding of the final character. This
routine buffers any partial encoding, using those bytes as the start of a
character sequence for the next PxTranslateStateToUTF() call.
This routine uses an appropriately sized temporary overflow buffer,
allocated by the PxTranslateSet() routine.
The parameters src and maxsrc specify the input buffer; the
parameters dst and maxdst specify the output UTF-8 buffer. These
have the same meaning as in the PxTranslateToUTF() function. The
consumed parameter will be updated with the number of bytes
converted from the source buffer; this may be NULL if this
information isn’t required (i.e. if the source is always correctly
encoded and the destination buffer is always sufficiently large).
Returns:
The number of bytes produced in the destination buffer, or -1 on error.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxTranslateList(), PxTranslateFromUTF(), PxTranslateSet(),
PxTranslateStateFromUTF(), PxTranslateToUTF(),
PxTranslateUnknown()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
#include <photon/PxProto.h>
Description:
This function translates a block of characters to Unicode UTF-8 (the
internal Photon character set). The ctrl parameter specifies the
encoding of the source characters and must be the pointer returned by
a previous call to PxTranslateSet() to install this encoding.
The parameters are as follows:
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxTranslateList(), PxTranslateFromUTF(), PxTranslateSet(),
PxTranslateStateFromUTF(), PxTranslateStateToUTF(),
PxTranslateUnknown()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
#include <photon/PxProto.h>
Library:
phexlib
Description:
This function controls the behavior of the encoding routines when
they encounter an invalid byte sequence or a character that can’t be
represented in the current encoding scheme.
The ctrl argument is a pointer to the control structure for a character
set translation returned from a previous call to PxTranslateSet().
The to argument is used when converting to UTF-8 by calling
PxTranslateToUTF() or PxTranslateStateToUTF(). If to is 0 (the
default) and an invalid encoding is encountered, the translation is
halted an returns an error. If to is nonzero, it’s the Unicode character
to insert into the translation instead of the invalid one.
The from argument is similar, but id used when converting from
UTF-8 by calling PxTranslateFromUTF() or
PxTranslateStateFromUTF().
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxTranslateFromUTF(), PxTranslateSet(),
PxTranslateStateFromUTF(), PxTranslateStateToUTF(),
PxTranslateToUTF()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
wchar t wctolower( wchar t wc );
Description:
The wctolower() function returns the lowercase equivalent of wc, or
wc itself if there’s no lowercase equivalent. It’s similar to tolower(),
except that it knows about Unicode characters.
This function is optimized for size rather than speed. If speed is
important, use wctolower() to create a full Unicode conversion table
and then index into it directly.
Returns:
The equivalent lowercase character, or the given character itself if
there’s no lowercase equivalent.
Classification:
UNIX
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
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.
! dithering 289
summary of functions 14
<photon/PkKeyDef.h> 436 transparency 293
XOR color 295
stroke
caps 308
A color 310
dash 311
ABLPATH 68, 127
dithering 314
applications, initializing 584
joins 316
arcs, drawing 196
summary of functions 14
area
transparency 319
based on widget extent,
width 320
setting 759
XOR color 322
data structure 348
text
widget canvas, setting based
color 323
on 761
dithering 324
widget, getting 787
font 297
argument lists 598, 599, 762
transparency 326
arrows, beveled, drawing 203
underline 330
attributes
XOR color 327
drawing
plane mask, setting 305
summary of functions 14
fill
color 287
G H
geometry help
area 348 quitting 875
dimensions 381 searching 876
point 451 summary of functions 24
rectangle 463 topic path 879
summary of functions 18 topic path root 881
widgets topic tree 882
area, based on canvas 761 URL 884
area, based on extent 759 URL root 886
area, getting 787 widget with help topic, finding
dimensions, getting 799 first 805
extent, recalculating 649, HELP SEARCH METHOD EXACT 876
650 HELP SEARCH METHOD SUBSTRING
extent, visible 830 877
offset, getting 813 HELP SEARCH METHOD WORD 877
positions, absolute 608 HELP SEARCH MODE DISPLAYED 876
summary of functions 43 HELP SEARCH MODE TEXT 876
graphical contexts HELP SEARCH MODE TITLE 876
attributes, resetting 191 HELP SEARCH SCOPE ALL 876
creating 189 HELP SEARCH SCOPE SELECTED 876
K deactivating 518
draw buffer
key events incremental size 513
translating maximum size 514
summary of functions 21 flushing 510
UTF-8 value 438 releasing 512
keys, modifier 434 summary of functions 21
type, setting 515
memory, shared
attaching 334
L cleaning up 336
creating 338
libraries
destroying 340
version number 439
detaching 341
widget, initialization 706
summary of functions 29
line attributes
menus
caps 308
items
color 310
getting text 100
dash 311
setting state 110
dithering 314
setting text 112
joins 316
position, setting 720
resetting 193
summary of functions 44
summary of functions 14
messages
transparency 319
displaying 714
width 320
errors, displaying 88
XOR color 322
summary of functions 22
lines, drawing 221
modal processing
link callbacks
ending 715
determining the initiator 129
events 724
starting 716
summary of functions 22
M modifier keys 434
modules
main loop 713 creating 76
memory contexts location, specifying 116
activating 516 parent, specifying 118
creating 506 setup function, specifying 114
creating 580 Q
deleting 582
delivering to a process 729 question dialog 601
delivering to yourself 586
disarming 731
PX XXX SUPPORT 890
PXCONFIG CREATE 846
R
PXCONFIG FMT BOOL ON 862
receive ID (RCVID), getting process
PXCONFIG FMT BOOL TRUE 862
ID (PID) from 689
PXCONFIG FMT BOOL YES 862
rectangles
PXCONFIG FMT CHAR CHAR 864
data structure 463
PXCONFIG FMT CHAR HEX 864
drawing
PXCONFIG FMT INT DECIMAL 866,
beveled 203
868, 870 rounded 242
PXCONFIG FMT INT HEX 866,
intersection of 738
868, 870 union of 739
PXCONFIG FMT STRING 872
rectangles, drawing 232
PXCONFIG READ 846
regions
PXCONFIG WRITE 846
blitting 353
PX DIRECT COLOR 888
closing 472
PX DODITHER 888
console, switching to 831
PX IMAGE 888
data
PxImage.h 890
header 474
PX IMAGE MODULES 890
searching by type 473
PX LOAD 888
data structure 465
PxMethods t 887
disjoint 667, 797
PX NORMAL 888
events 382
PX PALETTE 888
data structure 414
PX QUERY 887
graphical contexts 189
PX SUPPRESS TAG 888
querying 455, 481
PX TRANSPARENT 888, 889
summary of functions 28
PX USECOLORS 888, 889
system information 459
widgets 817
windows
actions, data structure 495
REMOTE FLAG FIXED 396
REMOTE FLAG INITIAL 396