Photon Library Reference
Photon Library Reference
1 Summary of Entries 1
Alpha blending 3
Background processing 4
Bitmaps and Images 4
Blitting 5
Characters, translating 6
Chroma key operations 6
Clipboard operations 7
Clipping 7
Colors, converting and parsing 7
Configuration files 8
Connections to other applications 10
Coordinates, translating 11
Cursors/pointers 11
Data chains 11
Direct mode 12
Drag and drop 12
Dragging 14
Draw contexts 14
Drawing attributes 14
General attributes 14
Fill attributes 15
Line (stroke) attributes 15
Text attributes 15
Events 16
Font handling 18
Geometry 20
Gradients 20
Driver-level 20
Application-level 20
Graphical contexts 20
Input/Output events 21
Interprocess Communication (IPC) 21
Layers 22
Key events, translating 22
Memory contexts 22
Messages and questions 23
Modal dialogs 23
Modules 24
Online help 24
Photon Application Builder functions 24
Photon services, connecting and disconnecting 25
Power-saving modes 25
Primitive drawing routines 25
Printing 26
Processes 27
Realtime timers 28
Regions 28
Shared memory 28
Signals 29
Strings, translating 29
Synchronization 30
System information 30
Text 30
Threads 30
Tiles 31
UTF-8 character strings 31
Video modes 32
Video offscreen memory 32
Video overlay 33
Wide characters 34
Widgets 34
Callbacks and hotkey handlers 34
Class hierarchy 35
Control surfaces 35
Creating and destroying widgets 38
Custom widgets 38
Damaging widgets 41
Databases 41
Family hierarchy 42
Finding widgets in an area 43
Focus 43
Geometry 44
Library initialization 45
Menus 45
PtComboBox 45
PtFileSel 46
PtGenList 47
PtGenTree 49
PtList 50
PtMTrend 51
PtMultiText 51
PtPanelGroup 52
PtProgress 53
PtTerminal 53
PtText 54
PtTree 54
PtTrend 55
PtTty 55
PtWindow 56
Realizing and unrealizing widgets 56
Resources 56
Styles 57
Updates, forcing and holding off 57
Window Manager 58
2 Ab—PhAB-Generated Code 59
AbGetABW() 62
3 Al—PhAB Translation 63
AlClearTranslation() 66
AlCloseDBase() 67
AlGetEntry() 68
AlGetSize() 70
AlOpenDBase() 71
AlReadTranslation() 72
AlSaveTranslation() 74
AlSetEntry() 76
4 Ap—PhAB 79
ApAddClass() 82
ApAddContext() 84
ApAppendTranslation() 85
ApCloseDBase() 87
ApCloseMessageDB() 89
ApCopyDBWidget() 90
ApCreateDBWidget() 92
ApCreateDBWidgetFamily() 95
ApCreateModule() 97
ApCreateWidget() 101
ApCreateWidgetFamily() 104
ApDeleteDBWidget() 106
ApError() 108
ApGetDBWidgetInfo() 110
ApGetImageRes() 112
ApGetInstance() 114
ApGetItemText() 116
ApGetMessage() 118
ApGetTextRes() 119
ApGetWidgetPtr() 121
ApInfo_t 123
ApInitialize() 124
ApInstanceName() 125
ApLoadMessageDB() 127
ApLinkWindow() 129
ApModalWait() 130
ApModifyItemAccel() 132
ApModifyItemState() 134
ApModifyItemText() 136
ApModuleFunction() 138
ApModuleLocation() 140
ApModuleParent() 142
ApName() 144
ApOpenDBase() 146
ApOpenDBaseFile() 148
ApRemoveClass() 150
ApRemoveContext() 152
ApResClose() 153
ApSaveDBaseFile() 154
ApSetContext() 156
ApSetTranslation() 158
ApWidget() 160
5 mbstr—Multibyte-Character 163
PfWideTextWidthChars() 359
8 Pg—Graphics 361
PgAlphaOff(), PgAlphaOffCx() 364
PgAlphaOn(), PgAlphaOnCx() 365
PgAlphaValue() 366
PgARGB() 367
PgBackgroundShadings() 369
PgBevelBox(), PgBevelBoxCx() 370
PgBlit(), PgBlitCx() 373
PgBlueValue() 375
PgCalcColorContrast() 376
PgChromaOff(), PgChromaOffCx() 377
PgChromaOn(), PgChromaOnCx() 378
PgClearDrawBuffer(), PgClearDrawBufferCx() 379
PgClearTranslation(), PgClearTranslationCx() 381
PgCMY() 382
PgColor_t 384
PgColorHSV_t 387
PgColorMatch() 388
PgConfigScalerChannel() 390
PgContextBlit(), PgContextBlitCx() 392
PgContextBlitArea(), PgContextBlitAreaCx() 394
PgContrastBevelBox(), PgContrastBevelBoxCx() 396
PgCreateDriverRegion() 399
PgCreateGC() 401
PgCreateLayerSurface() 402
PgCreateVideoChannel() 405
PgDefaultAlpha() 407
PgDefaultChroma() 408
PgDefaultFill() 409
PgDefaultGC() 410
PgDefaultMode() 411
PgDefaultStroke() 412
PgDefaultText() 413
PgDestroyGC() 414
PgDestroyVideoChannel() 415
PgDrawArc(), PgDrawArcCx() 416
PgDrawArrow(), PgDrawArrowCx() 420
PgDrawBevelBox(), PgDrawIBevelBox(), PgDrawBevelBoxCx(),
PgDrawIBevelBoxCx() 422
PgGetPalette() 516
PgGetRegion(), PgGetRegionCx() 517
PgGetScalerCapabilities() 518
PgGetSurfaceGFSid() 519
PgGetVideoMode() 520
PgGetVideoModeInfo() 522
PgGetVideoModeList() 526
PgGray() 528
PgGrayValue() 530
PgGreenValue() 531
PgHSV() 532
PgHSV2RGB() 534
PgLayerCaps_t 535
PgLockLayer() 540
PgMap_t 542
PgMultiBlit(), PgMultiBlitCx() 543
PgNextVideoFrame() 545
PgPHookRegister() 546
PgReadScreen() 548
PgReadScreenSize() 550
PgRedValue() 551
PgRGB() 552
PgRGB2HSV() 554
PgScalerCaps_t 555
PgScalerProps_t 557
PgSetAlpha(), PgSetAlphaCx() 559
PgSetAlphaBlend(), PgSetAlphaBlendCx() 566
PgSetChroma(), PgSetChromaCx() 568
PgSetClipping(), PgSetClippingCx() 570
PgSetColorModel(), PgSetColorModelCx() 572
PgSetControlFlagGCCx() 573
PgSetDPMSMode() 574
PgSetDrawBufferSize(), PgSetDrawBufferSizeCx() 575
PgSetDrawMode(), PgSetDrawModeCx() 577
PgSetFillColor(), PgSetFillColorCx() 580
PgSetFillDither(), PgSetFillDitherCx() 582
PgSetFillTransPat(), PgSetFillTransPatCx() 586
PgSetFillXORColor(), PgSetFillXORColorCx() 588
PgSetFont(), PgSetFontCx() 590
PgSetGC(), PgSetGCCx() 592
PgSetLayerArg() 594
PgSetLayerSurface() 599
PgSetMultiClip(), PgSetMultiClipCx() 601
PgSetPalette(), PgSetPaletteCx() 603
PgSetPlaneMask(), PgSetPlaneMaskCx() 606
PgSetRegion(), PgSetRegionCx() 607
PgSetStrokeCap(), PgSetStrokeCapCx() 609
PgSetStrokeColor(), PgSetStrokeColorCx() 611
PgSetStrokeDash(), PgSetStrokeDashCx() 613
PgSetStrokeDither(), PgSetStrokeDitherCx() 616
PgSetStrokeJoin(), PgSetStrokeJoinCx() 618
PgSetStrokeTransPat(), PgSetStrokeTransPatCx() 621
PgSetStrokeWidth(), PgSetStrokeFWidth(), PgSetStrokeWidthCx(),
PgSetStrokeFWidthCx() 622
PgSetStrokeXORColor(), PgSetStrokeXORColorCx() 624
PgSetTextColor(), PgSetTextColorCx() 625
PgSetTextDither(), PgSetTextDitherCx() 626
PgSetTextTransPat(), PgSetTextTransPatCx() 628
PgSetTextXORColor(), PgSetTextXORColorCx() 629
PgSetTranslation(), PgSetTranslationCx() 630
PgSetUnderline(), PgSetUnderlineCx() 632
PgSetUserClip(), PgSetUserClipAbsolute(), PgSetUserClipCx(),
PgSetUserClipAbsoluteCx() 634
PgSetVideoMode() 636
PgShmemAttach() 638
PgShmemCleanup() 639
PgShmemCreate() 641
PgShmemDestroy() 642
PgShmemDetach() 643
PgSyncFlush(), PgSyncFlushCx() 644
PgSwapDisplay(), PgSwapDisplayCx() 645
PgUnlockLayer() 647
PgVideoChannel_t 649
PgWaitDrawComplete() 651
PgWaitHWIdle() 652
PgWaitVSync(), PgWaitVSyncCx() 653
9 Ph—Photon 655
PhAddMergeTiles() 658
PhAllocPackType() 660
PhArea_t 662
PhAreaToRect() 663
PhAttach() 664
PhBlit() 667
PhBitmapCursorDescription_t 669
PhCancelDrag() 671
PhChannelAttach() 673
PhCharacterCursorDescription_t 676
PhClipboardCopyString() 678
PhClipboardHdr 679
PhClipboardPasteString() 680
PhClipboardRead() 681
PhClipboardWrite() 683
PhClipTilings() 685
PhCoalesceTiles() 686
PhCopyTiles() 687
PhCreateImage() 688
PhCreateTransportCtrl() 690
PhCursorDef_t 691
PhCursorDescription_t 693
PhDCCreate() 694
PhDCGetCurrent() 697
PhDCRelease() 698
PhDCSetCurrent() 699
PhDetach() 701
PhDeTranslateRect() 702
PhDeTranslateTiles() 703
PhDim_t 704
PhDragEvent_t 705
PhEmit() 708
PhEmitmx() 710
PhEvent_t 712
PhEventArm() 726
PhEventEmit() 727
PhEventEmitmx() 729
PhEventNext() 731
PhEventPeek() 733
PhEventRead() 735
PhEventRegion_t 738
PhFindTransportType() 739
PhFreeTiles() 740
PhFreeTransportType() 741
PhGetAllTransportHdrs() 742
PhGetConnectId() 743
PhGetConnectInfo() 744
PhGetData() 746
PhGetMsgSize() 747
PhGetNextInlineData() 748
PhGetNextTransportHdr() 749
PhGetRects() 750
PhGetTile() 751
PhGetTransportHdr() 752
PhGetTransportVectors() 753
PhImage_t 754
PhInitDrag() 759
PhInputGroup() 763
PhIntersectTilings() 764
PhKeyEvent_t 765
PhKeyToMb() 768
PhLibVersion() 769
PhLinkTransportData() 770
PhLocateTransHdr() 771
PhMakeGhostBitmap() 772
PhMakeTransBitmap() 773
PhMakeTransparent() 777
PhMallocUnpack() 780
PhMergeTiles() 782
PhMoveCursorAbs() 783
PhMoveCursorRel() 784
PhMultiBlit() 785
PhPackEntry() 787
PhPackType() 790
PhPoint_t 793
PhPoint16dot16_t 794
PhPointerEvent_t 795
PhQueryCursor() 798
PhQueryRids() 800
PhQuerySystemInfo() 803
PhReattach() 804
PhRect_t 805
PhRect16dot16_t 806
PhRectIntersect() 807
PhRectsToTiles() 808
PhRectToArea() 809
PhRectUnion() 810
PhRegion_t 811
PhRegionChange() 814
PhRegionClose() 817
PhRegionDataFindType() 818
PhRegionDataHdr_t 819
PhRegionInfo() 820
PhRegionOpen() 822
PhRegionQuery() 826
PhRegisterTransportType() 828
PhReleaseImage() 829
PhReleaseTransportCtrl() 830
PhReleaseTransportHdrs() 831
PhSortTiles() 832
PhSysInfo_t 833
PhTile_t 837
PhTilesBoundingRect() 838
PhTilesToRects() 839
PhTimerArm() 840
PhTo8859_1() 841
PhTranslateRect() 842
PhTranslateTiles() 843
PhTransportCtrl_t 844
PhTransportFindLink() 845
PhTransportLink_t 846
PhTransportRegEntry_t 847
PhTransportType() 849
PhUnlinkTransportHdr() 852
PhUnpack() 853
PhWindowChange() 854
PhWindowClose() 856
PhWindowEvent_t 857
PhWindowOpen() 860
PhWindowQueryVisible() 862
10 Pi—Images 865
PiConvertImage() 868
PiCropImage() 871
PiDuplicateImage() 873
PiFlipImage() 875
PiGetPixel() 877
PiGetPixelFromData() 879
PiGetPixelRGB() 880
PiInitImage() 881
PiResizeImage() 883
PiSetPixel() 885
PiSetPixelInData() 886
11 Pm—Memory 887
PmMemCreateMC() 890
PmMemFlush() 894
PmMemReleaseMC() 895
PmMemSetChunkSize() 896
PmMemSetMaxBufSize() 897
PmMemSetType() 898
PmMemStart() 899
PmMemStop() 901
12 Pp—Printing 903
PpContinueJob() 906
PpCreatePC() 909
PpEndJob() 910
PpFreePrinterList() 912
PpGetCanvas() 913
PpGetPC() 914
PpLoadDefaultPrinter() 918
PpLoadPrinter() 920
PpLoadPrinterList() 922
PpPrintContext_t 923
PpPrintNewPage() 931
PpPrintWidget() 932
PpReleasePC() 935
PpSetCanvas() 936
PpSetPC() 937
PpStartJob() 941
PpSuspendJob() 943
PtAddEventHandler() 956
PtAddEventHandlers() 958
PtAddFilterCallback() 959
PtAddFilterCallbacks() 961
PtAddHotkeyHandler() 962
PtAddResponseType() 965
PtAlert() 968
PtAllowExit() 972
PtAppAddCallback() 973
PtAppAddEventHandler() 975
PtAppAddFd(), PtAppAddFdPri() 976
PtAddFilterCallback() 978
PtAppAddHotkeyHandler() 979
PtAppAddInput() 981
PtAppAddInputRemote() 985
PtAppAddSignalProc() 988
PtAppAddWorkProc() 990
PtAppCreatePulse() 993
PtAppDeletePulse() 994
PtAppGetResource() 995
PtAppGetResources() 997
PtAppInit() 999
PtAppPulseTrigger() 1000
PtAppRemoveCallback() 1001
PtAppRemoveEventHandler() 1002
PtAppRemoveFd() 1003
PtAppRemoveFilterCallback() 1004
PtAppRemoveHotkeyHandler() 1005
PtAppRemoveInput() 1007
PtAppRemoveSignal() 1008
PtAppRemoveWorkProc() 1009
PtAppSetFdMode() 1010
PtAppSetResource() 1012
PtAppSetResources() 1014
PtArg_t 1020
Pt_ARG() 1021
PtBkgdHandlerProcess() 1023
PtBlit() 1024
PtBlockAllWindows() 1025
PtBlockWindow() 1026
PtCalcAbsPosition() 1027
PtCalcCanvas() 1029
PtCalcSurface() 1030
PtCalcSurfaceByAction() 1031
PtCalcSurfaceById() 1032
PtCancelDnd() 1034
PtChannelCreate() 1036
PtCheckSurfaces() 1037
PtChildType() 1038
PtClearWidget() 1039
PtClipAdd() 1041
PtClippedBlit() 1042
PtClipRemove() 1043
PtCondTimedWait() 1044
PtCondWait() 1046
PtConnectionAddEventHandlers() 1048
PtConnectionAddMsgHandlers() 1050
PtConnectionClientDestroy() 1052
PtConnectionClientGetUserData() 1053
PtConnectionClientSetError() 1054
PtConnectionClientSetUserData() 1056
PtConnectionFindId() 1057
PtConnectionFindName() 1058
PtConnectionFlush() 1059
PtConnectionNotify() 1060
PtConnectionReply(), PtConnectionReplymx() 1062
PtConnectionResizeEventBuffer() 1063
PtConnectionSend(), PtConnectionSendmx() 1064
PtConnectionServerDestroy() 1066
PtConnectionServerGetUserData() 1067
PtConnectionServerSetError() 1068
PtConnectionServerSetUserData() 1070
PtConnectionTmpName() 1071
PtConnectionWaitForName() 1072
PtConnectorCreate() 1074
PtConnectorDestroy() 1076
PtConnectorGetId() 1077
PtConsoleSwitch() 1078
PtContainerBox() 1080
PtContainerFindFocus() 1082
PtContainerFocusNext() 1083
PtContainerFocusPrev() 1084
PtContainerGiveFocus() 1085
PtContainerHit() 1089
PtContainerHold() 1091
PtContainerNullFocus() 1092
PtContainerRelease() 1093
PtCRC() 1094
PtCRCValue() 1095
PtCreateActionSurface() 1097
PtCreateClassStyle() 1100
PtCreateSurface() 1101
PtCreateTransportCtrl() 1104
PtCreateWidget() 1105
PtDamageExtent() 1108
PtDamageSurface(), PtDamageSurfaceById() 1110
PtDamageSurfaceByAction() 1111
PtDamageWidget() 1112
PtDestroyAllSurfaces() 1114
PtDestroySurface() 1115
PtDestroySurfaceById() 1116
PtDestroyWidget() 1117
PtDisableSurface(), PtDisableSurfaceById() 1119
PtDisableSurfaceByAction() 1121
PtDndFetch_t 1122
PtDndSelect() 1124
PtDupClassStyle() 1126
PtEnableSurface(), PtEnableSurfaceById() 1127
PtEnableSurfaceByAction() 1129
PtEndFlux() 1130
PtEnter() 1131
PtEventHandler() 1134
PtExit() 1135
PtExtentWidget() 1137
PtExtentWidgetFamily() 1138
PtFdProcF_t, PtFdProc_t 1139
PtFepCmd() 1140
PtFileSelection() 1142
PtFindChildClass() 1152
PtFindChildClassMember() 1154
PtFindClassStyle() 1155
PtFindContainer() 1157
PtFindData() 1158
PtFindDisjoint() 1159
PtFindFocusChild() 1160
PtFindFocusNextFrom() 1161
PtFindFocusPrevFrom() 1162
PtFindGuardian() 1163
PtFindNextData() 1164
PtFindSurface() 1165
PtFindSurfaceByAction() 1166
PtFlush() 1168
PtFontSelection() 1169
PtForwardWindowEvent() 1172
PtForwardWindowTaskEvent() 1174
PtGetAbsPosition() 1176
PtGetControlFlags() 1177
PtGetDndFetchIndex() 1178
PtGetParent() 1180
PtGetParentWidget() 1181
PtGetRcvidPid() 1182
PtGetRcvidPidNd() 1183
PtGetResource() 1184
PtGetResources() 1186
PtGetStyleMember() 1188
PtGetWidgetStyle() 1190
PtGiveFocus() 1191
PtGlobalFocusNext() 1193
PtGlobalFocusNextContainer() 1194
PtGlobalFocusNextFrom() 1195
PtGlobalFocusPrev() 1196
PtGlobalFocusPrevContainer() 1197
PtGlobalFocusPrevFrom() 1198
PtHelpQuit() 1199
PtHelpSearch() 1200
PtHelpTopic() 1202
PtHelpTopicRoot() 1204
PtHelpTopicTree() 1205
PtHelpUrl() 1206
PtHelpUrlRoot() 1208
PtHideSurface(), PtHideSurfaceById() 1209
PtHideSurfaceByAction() 1211
PtHit() 1212
PtHold() 1213
PtInflateBalloon() 1214
PtInit() 1216
PtInitDnd() 1217
PtInputCallbackProcF_t, PtInputCallbackProc_t 1220
PtInsertSurface(), PtInsertSurfaceById() 1221
PtIsFluxing() 1223
PtIsFocused() 1224
PtLeave() 1225
PtMainLoop() 1228
PtMakeModal() 1229
PtMessageBox() 1230
PtModalBlock() 1232
PtModalEnd() 1237
PtModalStart() 1238
PtModalUnblock() 1239
PtNextTopLevelWidget() 1240
PtNotice() 1241
PtPassword() 1244
PtPositionMenu() 1247
PtPreventExit() 1248
PtPrintPropSelect() 1249
PtPrintSelect() 1257
PtPrintSelection() 1259
PtProcessEvent() 1263
PtPrompt() 1264
PtPulseArm() 1268
PtQuerySystemInfo() 1269
PtQuitMainLoop() 1271
PtRealizeWidget() 1273
PtReattach() 1274
PtRelease() 1275
PtReleaseTransportCtrl() 1276
PtRemoveCallback() 1277
PtRemoveCallbacks() 1279
PtRemoveData() 1280
PtRemoveEventHandler() 1281
PtRemoveEventHandlers() 1282
PtRemoveFilterCallback() 1283
PtRemoveFilterCallbacks() 1284
PtRemoveHotkeyHandler() 1285
PtReparentWidget() 1286
PtReRealizeWidget() 1288
PtResizeEventMsg() 1289
PtSendEventToWidget() 1290
PtSetAreaFromCanvas() 1292
PtSetArg() 1293
PtSetClassStyleMethods() 1295
PtSetParentWidget() 1297
PtSetResource() 1299
PtSetResources() 1301
PtSetStyleMember() 1303
PtSetStyleMembers() 1306
PtSetWidgetStyle() 1308
PtShowSurface(), PtShowSurfaceById() 1310
PtShowSurfaceByAction() 1311
PtSignalProcF_t, PtSignalProc_t 1312
PtSpawn() 1313
PtSpawnDeleteCallback() 1316
PtSpawnSetCallback() 1317
PtSpawnWait() 1318
PtStartFlux() 1319
PtSurfaceActionId() 1320
PtSurfaceAddData(), PtSurfaceAddDataById() 1321
PtSurfaceBrotherBehind() 1323
PtSurfaceBrotherInFront() 1324
PtSurfaceCalcBoundingBox(), PtSurfaceCalcBoundingBoxById() 1325
PtSurfaceExtent(), PtSurfaceExtentById() 1327
PtSurfaceGetData() 1329
PtSurfaceHit() 1330
PtSurfaceId() 1331
PtSurfaceInBack() 1332
PtSurfaceInFront() 1333
PtSurfaceIsDisabled() 1334
PtSurfaceIsEnabled() 1335
PtSurfaceIsHidden() 1336
PtSurfaceIsShown() 1337
PtSurfaceRect(), PtSurfaceRectById() 1338
PtSurfaceRemoveData(), PtSurfaceRemoveDataById() 1340
PtSurfaceTestPoint() 1342
PtSurfaceToBack(), PtSurfaceToBackById() 1343
PtSurfaceToFront(), PtSurfaceToFrontById() 1344
PtSyncWidget() 1346
PtTimerArm() 1347
PtTransportCtrl_t 1348
PtTransportRequestable() 1350
PtTransportType() 1354
PtUnblockWindows() 1357
PtUnlinkData() 1358
PtUnrealizeWidget() 1359
PtUpdate() 1360
PtValidParent() 1361
PtWidgetActiveSurface() 1363
PtWidgetArea() 1364
PtWidgetBrotherBehind() 1365
PtWidgetBrotherInFront() 1367
PtWidgetChildBack() 1368
PtWidgetChildFront() 1370
PtWidgetClass() 1371
PtWidgetClassFlags() 1372
PtWidgetDim() 1374
PtWidgetExtent() 1375
PtWidgetFamily() 1376
PtWidgetFlags() 1378
PtWidgetHelpHit() 1379
PtWidgetInsert() 1380
PtWidgetIsClass() 1382
PtWidgetIsClassMember() 1383
PtWidgetIsRealized() 1384
PtWidgetMinimumSize() 1385
PtWidgetOffset() 1386
PtWidgetParent() 1387
PtWidgetPreferredSize() 1388
PtWidgetRid() 1389
PtWidgetSkip() 1390
PtWidgetToBack() 1392
PtWidgetToFront() 1395
PtWidgetTree() 1396
PtWidgetTreeTraverse() 1398
PtWidgetVisibleExtent() 1401
PtWindowConsoleSwitch() 1402
PtWindowGetFrameSize() 1403
PtWorkProcF_t, PtWorkProc_t 1405
14 Px—Extended 1407
PxConfigClose(), PxConfigCloseCx() 1410
PxConfigDeleteEntry(), PxConfigDeleteEntryCx() 1412
PxConfigDeleteSection(), PxConfigDeleteSectionCx() 1414
PxConfigFirstSection(), PxConfigFirstSectionCx() 1416
PxConfigForceEmptySection(), PxConfigForceEmptySectionCx() 1417
PxConfigNextEntry(), PxConfigNextEntryCx() 1419
PxConfigNextSection(), PxConfigNextSectionCx() 1421
PxConfigNextString(), PxConfigNextStringCx() 1423
PxConfigOpen(), PxConfigOpenCx() 1425
PxConfigReadBool(), PxConfigReadBoolCx() 1429
PxConfigReadChar(), PxConfigReadCharCx() 1431
PxConfigReadDouble(), PxConfigReadDoubleCx() 1433
PxConfigReadInt(), PxConfigReadIntCx() 1435
PxConfigReadLLong(), PxConfigReadLLongCx() 1437
PxConfigReadLong(), PxConfigReadLongCx() 1439
PxConfigReadShort(), PxConfigReadShortCx() 1441
PxConfigReadString(), PxConfigReadStringCx() 1443
PxConfigSection(), PxConfigSectionCx() 1445
PxConfigWriteBool(), PxConfigWriteBoolCx() 1447
PxConfigWriteChar() 1449
PxConfigWriteDouble(), PxConfigWriteDoubleCx() 1451
PxConfigWriteInt(), PxConfigWriteIntCx() 1453
PxConfigWriteLLong(), PxConfigWriteLLongCx() 1455
PxConfigWriteLong(), PxConfigWriteLongCx() 1457
PxConfigWriteShort(), PxConfigWriteShortCx() 1459
PxConfigWriteString(), PxConfigWriteStringCx() 1461
PxGetImageExtensions() 1463
PxLoadImage() 1465
PxRotateImage() 1472
PxTerminalBuildCharsets() 1475
PxTerminalLoadCharsets() 1477
PxTerminalSaveCharsets() 1478
PxTerminate() 1479
PxTranslateFromUTF() 1480
PxTranslateList() 1482
PxTranslateSet() 1483
PxTranslateStateFromUTF() 1486
PxTranslateStateToUTF() 1488
PxTranslateToUTF() 1490
PxTranslateUnknown() 1492
15 Rt—Realtime 1495
RtTimerCreate() 1498
RtTimerDelete() 1500
RtTimerGetTime() 1501
RtTimerSetTime() 1502
17 wc—Wide-Character 1527
wctolower() 1530
wctoutf8() 1531
Glossary 1567
Index 1583
• Summary of Entries
• Ab—PhAB-Generated Code
• Al—PhAB Translation
• Ap—PhAB
• utf8—UTF-8 Character
• Pd—Draw Context
• Pf—Font Server
• Pg—Graphics
• Ph—Photon
• Pi—Images
• Pm—Memory
• Pp—Printing
• Pt—Widget Toolkit
• Px—Extended
• Rt—Realtime
• 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.
• In general, the Photon libraries aren’t thread-safe. For information on using Photon
and threads, see “Threads” in the Parallel Operations chapter of the Photon
Programmer’s Guide.
• If you’re using the Photon Application Builder (PhAB), the appropriate header files
are automatically included in your application.
• If you aren’t using PhAB but your application uses widgets, include <Pt.h>.
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.
Technical support
To obtain technical support for any QNX product, visit the Support area on our
website (www.qnx.com). You’ll find a wide range of support options, including
community forums.
In this chapter. . .
Alpha blending 3
Background processing 4
Bitmaps and Images 4
Blitting 5
Characters, translating 6
Chroma key operations 6
Clipboard operations 7
Clipping 7
Colors, converting and parsing 7
Configuration files 8
Connections to other applications 10
Coordinates, translating 11
Cursors/pointers 11
Data chains 11
Direct mode 12
Drag and drop 12
Dragging 14
Draw contexts 14
Drawing attributes 14
Events 16
Font handling 18
Geometry 20
Gradients 20
Graphical contexts 20
Input/Output events 21
Interprocess Communication (IPC) 21
Layers 22
Key events, translating 22
Memory contexts 22
Messages and questions 23
Modal dialogs 23
Modules 24
Online help 24
Photon Application Builder functions 24
Photon services, connecting and disconnecting 25
Power-saving modes 25
Primitive drawing routines 25
Printing 26
Processes 27
Realtime timers 28
Regions 28
Shared memory 28
Signals 29
Strings, translating 29
Synchronization 30
System information 30
Text 30
Threads 30
Tiles 31
UTF-8 character strings 31
Video modes 32
Video offscreen memory 32
Video overlay 33
Wide characters 34
Widgets 34
Window Manager 58
This chapter groups the datatypes and functions according to their purpose. You can
use this chapter to determine what you need to perform a task.
The first two letters of a datatype’s or function’s name identify the chapter in which
it’s described, as follows:
• 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.
Alpha blending
PgAlphaOff*() Turn alpha blending operations off
PgSetAlphaBlend*()
Set the parameters for alpha blending simply
Background processing
PtAppAddWorkProc()
Add a WorkProc (background) function
PtAppRemoveWorkProc()
Remove a WorkProc processing function
PtWorkProcF_t, PtWorkProc_t
Type for defining a work procedure function
PgDrawPhImageRect*()
Draw part of an image that’s contained in a PhImage_t
structure
PgDrawRepBitmap*()
Draw a bitmap several times
PgDrawRepImage*()
Draw an image several times
PgDrawRepPhImage*()
Repeatedly draw an image stored in a PhImage_t structure
PhMakeGhostBitmap()
Create a ghost bitmap for an image
PhMakeTransBitmap()
Create a transparency mask for an image
PhMakeTransparent()
Make a given color transparent in an image, using chroma if
possible
PiGetPixelFromData()
Retrieve a value from a run of pixels
PxGetImageExtensions()
Get a list of supported image file extensions
Blitting
PhBlit() Blit an area within a region
PgBlit() Blit an area within the region set for the current draw context
PgBlitCx() Blit an area within the region set for a specified draw context
PgMultiBlit() Blit a multi-rectangular area within the region set for the current
draw context
PgMultiBlitCx() Blit a multi-rectangular area within the region set for a specified
draw context
Characters, translating
PtFepCmd() Control a Front-End Processor (FEP) from an application
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
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
PhClipboardRead()
Read data from the clipboard
PhClipboardWrite()
Copy data to the clipboard
PhClipboardCopyString()
Copy string-only data to the clipboard
PhClipboardPasteString()
Paste string-only data from the clipboard
PhClipboardHdr
Clipboard header structure
Clipping
PgSetClipping*() Limit the extent of drawing
PgSetUserClipAbsolute*()
Restrict subsequent draws
PtWidgetVisibleExtent()
Calculate the visible portion of a widget
PgARGB() Convert alpha, red, green, and blue values to composite color
format
PgBackgroundShadings()
Calculate top and bottom shading colors
PgGetColorModel*()
Get the current color model
PgRGB() Convert red, green, and blue values to composite color format
PgSetColorModel*()
Set the current color model
Configuration files
PxConfigClose*() Close a configuration file
PxConfigDeleteEntry*()
Delete an entry from a configuration file
PxConfigDeleteSection*()
Delete a section from a configuration file
PxConfigFirstSection*()
Seek the beginning of the first section of a configuration file
PxConfigForceEmptySection*()
Create an empty section in a configuration file
PxConfigNextEntry*()
Get the next entry in the current section
PxConfigNextSection*()
Seek the beginning of the next section of a configuration file
PxConfigNextString*()
Get the next entry in the current section
PxConfigReadLLong*()
Read a long long 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
PxConfigWriteDouble*()
Write a double-precision float parameter in a configuration file
PxConfigWriteInt*() Write an integer parameter in a configuration file
PxConfigWriteLLong*()
Write a long long 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
PtConnectionServerSetUserData()
Set the server’s user data pointer in a connection object
PtConnectionTmpName()
Create a temporary name for a server
PtConnectionWaitForName()
Try to connect to the server with a given name
PtConnectorCreate()
Create a connector
PtConnectorDestroy()
Destroy a connector
PtConnectorGetId()
Get the ID of a connector
Coordinates, translating
PgClearTranslation*()
Restore the current translation to the default
PhDeTranslateRect()
Detranslate a rectangle (subtract offset)
Cursors/pointers
PhCursorDef_t Bitmap for the cursor
PhMoveCursorAbs()
Move the cursor to an absolute position
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
PtUnlinkData() Remove the provided data link from the data chain
Direct mode
PdCreateDirectContext()
Create a direct-mode context
PdReleaseDirectContext()
Leave direct mode and release the direct-mode context
PhCreateTransportCtrl()
Allocate a PhTransportCtrl_t structure
PhFindTransportType()
Find a transport type in the transport registry
PhFreeTransportType()
Free data associated with a transport registry entry
PhGetAllTransportHdrs()
Extract all the headers from a buffer of packed transport data
PhGetNextInlineData()
Get the data for the next entry in a linked list of transport data
PhGetNextTransportHdr()
Get the next header from a buffer of packed transport data
PhGetTransportHdr()
Extract the header from a buffer of packed transport data
PhGetTransportVectors()
Build an I/O vector of data to be transported
PhLinkTransportData()
Add transport data to a linked list
PhRegisterTransportType()
Add a new transport type to the transport registry
PhReleaseTransportCtrl()
Free a PhTransportCtrl_t structure
PhReleaseTransportHdrs()
Free a linked list of headers for packed transport data
PhTransportCtrl_t
Control structure for the Photon transport mechanism
PhTransportFindLink()
Search a linked list of transport data for some specific data
PhTransportLink_t
Entry in a linked list of transport data
PhTransportRegEntry_t
Data structure that describes data to be transported
PhUnlinkTransportHdr()
Remove an entry from a linked list of transport headers
PtAddResponseType()
Add data to the response chain
PtCreateTransportCtrl()
Create a transport control structure for use with drag and drop
PtGetDndFetchIndex()
Select drag-and-drop data
PtInitDnd() Search for an entry in the data_array for an incoming drag and
drop event
PtReleaseTransportCtrl()
Release a transport control structure used with drag and drop
PtTransportCtrl_t
Transport-control structure used in a drag-and-drop operation
PtTransportRequestable()
Add an entry for requestable data to the drag-and-drop data
PtTransportType() Pack transport data
Dragging
PhCancelDrag() Cancel a drag operation
PhDragEvent_t Data associated with a drag event
PhInitDrag() Initiate a drag operation
Draw contexts
PdGetDevices() Get region IDs for the currently available draw devices
PdSetTargetDevice() Set the target device
PhDCCreate() Create and initialize a new draw context
PhDCGetCurrent() Get the currently active draw context
PhDCRelease() Release a 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
PgDefaultAlpha() Reset alpha attributes to their default system values
PgSetFillXORColor*()
Set a color for XOR drawing
PgSetStrokeDither*()
Apply a color pattern to outlines
PgSetStrokeFWidth*()
Set line thickness
PgSetStrokeTransPat*()
Use a masking pattern to set draw transparency on outlines
PgSetStrokeXORColor*()
Set the stroke color for XOR drawing
Text attributes
PgDefaultText() Reset the text attribute to its system default
PgSetTextTransPat*()
Set draw transparency
PgSetTextXORColor*()
Set a color for XOR drawing
Events
PhEmit() Emit an event
PhPointerEvent_t
Data associated with a pointer event
PtAddEventHandler()
Add a single Pt_CB_RAW entry to a widget
PtAddEventHandlers()
Add several Pt_CB_RAW entries to a widget
PtAddFilterCallback()
Add a single Pt_CB_FILTER callback to a widget
PtAddFilterCallbacks()
Add several Pt_CB_FILTER entries to a widget
PtAppAddEventHandler()
Set an event handler resource for an application.
PtAppAddFilterCallback()
Set a filter callback resource for an application.
PtAppAddHotkeyHandler()
Set a hotkey handler resource for an application.
PtAppRemoveEventHandler()
Remove an event hanlder from an application’s callback list.
PtAppRemoveFilterCallback()
Remove a filter callback from an application’s callback list.
PtAppRemoveHotkeyHandler()
Remove a hotkey handler from an application’s callback list.
PtBkgdHandlerProcess()
Process all outstanding Photon events
PtForwardWindowEvent()
Forward a window event to the window with a given region ID
PtRemoveEventHandler()
Remove a single Pt_CB_RAW entry from a widget
PtRemoveEventHandlers()
Remove several Pt_CB_RAW entries from a widget
PtRemoveFilterCallback()
Remove a single Pt_CB_FILTER entry from a widget
PtRemoveFilterCallbacks()
Remove several Pt_CB_FILTER entries from a widget
PtSendEventToWidget()
Give an event to a widget
Font handling
PfAttach() Attach to a font server
PfDecomposeStemToID()
Convert a stem name into a font ID
PfExtent(), PfExtentCx()
Calculate the extent rectangle of a text string
PfExtentComponents()
Calculate the extent of a text string and invoke a callback
PfExtentFractTextCharPositions()
Calculate individual character positions, using fractional
scaling
PfExtentTextCharPositions()
Calculate individual character positions
PfExtentTextCharPositionsCx()
Calculate individual character positions, specifying a font
context
PfFractionalExtentText()
Calculate the extent rectangle of a text string, using fractional
scaling
PfGenerateFontName(), PfGenerateFontNameCx()
Generate a font name
PfGetOutline(), PfGetOutlineCx()
Get individual point information for a glyph outline
PfGlyph() Obtain the metrics and/or bitmap for the specified character
PfRender(), PfRender()
Render a string via a user callback function
PfWideTextWidthBytes()
Calculate the width of a wchar_t string of Unicode characters
PfWideTextWidthChars()
Calculate the width of a wchar_t string of Unicode characters
Geometry
PhArea_t Position and dimensions of a rectangular area
Gradients
Driver-level
PgDrawGradient*()
Ask the graphics driver to render a gradient
Application-level
PgBevelBox*() Draw a beveled box with gradients
PgCalcColorContrast()
Compute light and dark colors to use for a gradient
PgContrastBevelBox*()
Draw a beveled box with gradients and a given level of contrast
PgDrawGradientBevelBox*()
Draw a beveled box with gradients and two flat colors
Graphical contexts
PgClearDrawBuffer*()
Reset the current draw buffer
PgDefaultMode() Reset draw mode and plane mask to their default values
PgFlush*(), PgFFlush*()
Explicitly flush the current draw buffer
PgSetDrawBufferSize*()
Resize a draw buffer
Input/Output events
PtAppAddFd() Add a file-descriptor function
PtFdProcF_t, PtFdProc_t
Type for defining a file-descriptor function
PtAppAddInputRemote()
Add an input processing function for a process on a remote node
PtAppCreatePulse()
Create a Photon pulse
PtAppDeletePulse()
Delete a Photon pulse
PtAppPulseTrigger()
Deliver a Photon pulse to yourself
PtAppRemoveInput()
Remove an input processing entry
PtGetRcvidPidNd() Get the process ID (PID) and node descriptor (ND) from the
receive ID (RCVID)
PtInputCallbackProcF_t, PtInputCallbackProc_t
Type for defining a input callback function
Layers
PgCreateDriverRegion()
Create a region that’s owned by the graphics driver
PgCreateLayerSurface()
Create an offscreen context for a layer
PgSetLayerSurface()
Display the offscreen context on the specified layer surface
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
PtPrompt() Display a message and get textual input from the user
Modal dialogs
ApModalWait() Process Photon events until a given widget is destroyed
PtBlockAllWindows() Block all windows except the one with a given widget
Modules
The following can be used only by applications made with the Photon Application
Builder:
ApModuleFunction() Specify the setup function for a PhAB internal link callback
Online help
PtWidgetHelpHit() Find the first widget at a given position that has a help topic
PtHelpTopic() Display the help text identified by the given topic path
Power-saving modes
PgSetDPMSMode()
Set the display power-saving mode
PgContrastBevelBox*()
Draw a beveled box with gradients and a given level of contrast
PgDrawBevelBox*(), PgDrawIBevelBox*()
Draw a beveled box
PgDrawGradientBevelBox*()
Draw a beveled box with gradients and two flat colors
PgDrawLine*(), PgDrawILine()
Draw a single line
PgDrawMultiTextArea*()
Draw multiline text in an area
PgDrawPixel*(), PgDrawIPixel*()
Draw a single point
PgDrawPixelArray*()
Draw multiple points
PgDrawRect*(), PgDrawIRect*()
Draw a rectangle
PgDrawRepBitmap*()
Draw a bitmap several times
PgDrawRepImage*()
Draw an image several times
PgDrawRoundRect*()
Draw a rounded rectangle
PgDrawTextChars*()
Draw the specified number of text characters
Printing
PpContinueJob() Continue a suspended print job
PpLoadDefaultPrinter()
Initialize a print context with information for the default printer
PpLoadPrinter() Initialize a print context with information for a given printer
PpLoadPrinterList() Load a list of available printers
PpPrintContext_t
Data structure describing a print context
PpPrintNewPage() Place a page break in the draw stream for a print context
PpPrintWidget() Print a widget
PpReleasePC() Release a print context
PpSetCanvas() Set the size of the current drawing area of a print context
PpSetPC() Set data in a print context
PpStartJob() Start a print job
PpSuspendJob() Suspend a print job
PtPrintPropSelect() Change the printing options for a selected printer via a modal
dialog
PtPrintSelect() Display a custom modal dialog for selecting print options
PtPrintSelection() Display a modal dialog for selecting print options
Processes
PtAllowExit() Allow a Photon application to exit
PtExit() Exit a Photon program
PtPreventExit() Prevent a Photon application from exiting
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
Realtime timers
RtTimerCreate() Create a realtime timer
Regions
PhQueryRids() Get a list of regions
PhRegionDataFindType()
Find a data type within a region’s data
PhRegionDataHdr_t
Data that’s attached to a region
PhQuerySystemInfo()
Query the system for information about a given region
Shared memory
PgShmemAttach() Record a shared memory reference
Signals
PtAppAddSignalProc()
Add Photon signalling to a context
PtAppRemoveSignal()
Remove specific signal handling from a context
PtSignalProcF_t, PtSignalProc_t
Type for defining a signal-handling function
Strings, translating
AlClearTranslation()
Clear all the translations in a language or message database
ApCloseMessageDB()
Close a message database
AlReadTranslation()
Read a translation file into a database
AlSaveTranslation()
Save translations from a language or message database
ApAppendTranslation()
Append external translation files to an application’s translation
list
ApCloseMessageDB()
Close a message database
ApLoadMessageDB()
Load a message database
Synchronization
PgWaitDrawComplete()
Wait until all emitted draw streams have been processed
System information
PhGetConnectId() Get the connection ID of the calling process
PhQuerySystemInfo()
Query the system for information about a given region
Text
PgExtentMultiText()
Calculate the extent of a multiline text string
Threads
PtCondTimedWait()
Block a thread on a conditional variable, with a time limit
Tiles
PhAddMergeTiles() Merge two list tiles, eliminating overlap
PhDeTranslateTiles()
Subtract x and y offsets from the vertices of a list of tiles
PhTilesBoundingRect()
Calculate the bounding box for a list of tiles
Video modes
PgGetGraphicsHWCaps()
Determine the hardware capabilities
PgGetVideoModeInfo()
Get information about a video mode
PgGetVideoModeList()
Query a graphics driver for a list of its supported video modes
PdOffscreenContext_t
Data structure that describes an offscreen context
PdSetOffscreenTranslation()
Set the translation for an offscreen context
PdUnlockOffscreen()
Unlock an offscreen context
PgContextBlitArea*()
Copy data from an area in one context to another context
Video overlay
PgConfigScalerChannel()
Configure a video overlay scaler channel
PgCreateVideoChannel()
Create a channel for video streaming
PgDestroyVideoChannel()
Destroy resources associated with a video channel
PgGetOverlayChromaColor()
Return the color used for video overlay chroma-key operations
PgGetScalerCapabilities()
Get the capabilities of a video overlay scaler
PgNextVideoFrame()
Get the index of the next video buffer to fill
PgScalerCaps_t
Data structure that describes video overlay scaler capabilities
PgScalerProps_t
Data structure that describes video overlay scaler properties
PgVideoChannel_t
Data structure that describes a video overlay channel
Wide characters
utf8towc() Convert a UTF-8 character to a wide-character code
Widgets
Callbacks and hotkey handlers
PtAddCallback() Add a single callback entry 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
PtAddFilterCallback()
Add a single Pt_CB_FILTER callback to a widget
PtAddFilterCallbacks()
Add several Pt_CB_FILTER entries to a widget
PtAddHotkeyHandler()
Add a single hotkey handler entry to a widget
PtBalloonCallback_t
Balloon 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
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
PtRemoveFilterCallback()
Remove a single Pt_CB_FILTER entry from a widget
PtRemoveFilterCallbacks()
Remove several Pt_CB_FILTER entries from a widget
PtRemoveHotkeyHandler()
Remove a single hotkey handler entry from a widget
Class hierarchy
PtWidgetClass() Return the class of a widget
PtWidgetIsClassMember()
Determine whether a widget belongs to a specified class
Control surfaces
PtCalcSurface() Force a surface to calculate its geometry
PtCalcSurfaceByAction()
Force all surfaces associated with an action to calculate their
geometry
PtCreateActionSurface()
Create a control surface within a widget, bound to a widget
action
PtDamageSurface(), PtDamageSurfaceById()
Mark a control surface as damaged so that it will be redrawn
PtDamageSurfaceByAction()
Damage all surfaces that are associated with an action
PtDestroyAllSurfaces()
Destroy all of a widget’s control surfaces
PtDestroySurfaceById()
Destroy the control surface with a given ID
PtDisableSurface(), PtDisableSurfaceById()
Disable a control surface
PtDisableSurfaceByAction()
Disable all control surfaces associated with an action
PtEnableSurface(), PtEnableSurfaceById()
Enable a control surface
PtEnableSurfaceByAction()
Enable all control surfaces associated with an action
PtFindSurfaceByAction()
Find the control surface associated with a given action
PtHideSurface(), PtHideSurfaceById()
Hide a control surface
PtHideSurfaceByAction()
Hide all control surfaces associated with an action
PtInsertSurface(), PtInsertSurfaceById()
Insert a control surface in front of or behind another
PtShowSurface(), PtShowSurfaceById()
Show a hidden control surface
PtShowSurfaceByAction()
Show all hidden control surfaces associated with an action
PtSurfaceAddData(), PtSurfaceAddDataById()
Add data to a control surface
PtSurfaceBrotherBehind()
Get the control surface behind a given one
PtSurfaceBrotherInFront()
Get the control surface in front of a given one
PtSurfaceCalcBoundingBox(), PtSurfaceCalcBoundingBoxById()
Calculate the bounding box for a control surface
PtSurfaceExtent(), PtSurfaceExtentById()
Calculate the extent of a control surface
PtSurfaceGetData(), PtSurfaceGetDataById()
Get data associated with a control surface
PtSurfaceIsDisabled()
Determine if a control surface is disabled
PtSurfaceIsEnabled()
Determine if a control surface is enabled
PtSurfaceRect(), PtSurfaceRectById()
Get the bounding box of a control surface
PtSurfaceRemoveData(), PtSurfaceRemoveDataById()
Remove data from a control surface
PtSurfaceToBack(), PtSurfaceToBackById()
Move a control surface behind all other control surfaces
belonging to a widget
PtSurfaceToFront(), PtSurfaceToFrontById()
Move a control surface in front of all other control surfaces
belonging to a widget
PtWidgetActiveSurface()
Get a widget’s currently active control surface
Custom widgets
The following are described in Building Custom Widgets:
PtAnchorDeregister()
Deregister a widget from its parent for anchoring
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
PtCoreChangeRegion()
Determine if a region is required
PtCreateWidgetClass()
Create a widget class
PtDestroyCallbackList()
Free the specified callbacks
PtDestroyHotkeyCallbacks()
Free the specified hotkey callbacks
PtDestroyRawCallbacks()
Free the specified raw callbacks
PtFindNextWidgetData()
Find the next appropriate data block
PtFindWidgetData() Find the first data block of a given type and subtype
PtInvokeCallbackList()
Invoke a callback list
PtInvokeCallbackType()
Invoke a callback list of a specific type
PtInvokeResizeCallbacks()
Invoke the resize callbacks of the specified container
PtMoveResizeWidget()
Synchronize a widget’s extent
PtRemoveWidgetData()
Remove data from the widget data chain
PtSetExtentFromArea()
Calculate the extent of a widget
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() Get the widget that’s above a given widget in a family hierarchy
Damaging widgets
PtDamageExtent() Mark an area of a widget as damaged so that it will be redrawn
Databases
The following can be used only by applications made with the Photon Application
Builder:
ApCreateDBWidget()
Create a widget by copying it from a PhAB widget database,
specifying a parent
ApCreateDBWidgetFamily()
Create a widget family by copying it from a PhAB widget
database, specifying a parent
ApCreateWidgetFamily()
Create a widget family by copying it from a PhAB widget
database
ApDeleteDBWidget()
Remove widgets from a widget database
ApGetDBWidgetInfo()
Get information about a widget in a widget database
Family hierarchy
PtChildType() Determine the relationship between two widgets
PtFindChildClass() Find the first descendant that matches the specified class
PtFindChildClassMember()
Find the first descendant that’s a subclass of the specified class
PtGetParent() Find the nearest parent widget that matches the specified class
PtNextTopLevelWidget()
Get a pointer to the next top-level widget
PtWidgetBrotherBehind()
Get the brother behind a widget
PtWidgetBrotherInFront()
Get the brother in front of a widget
PtWidgetChildFront()
Get the child at the very front of a container
PtWidgetTreeTraverse()
Walk the widget family hierarchy from front to back
Focus
PtContainerFindFocus()
Find the currently focused widget in the same family hierarchy as a
widget
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
PtFindFocusNextFrom()
Find the next widget that can get focus
PtFindFocusPrevFrom()
Find the previous widget that can get focus
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
PtCalcAbsPosition()
Calculate the position of a widget based on a position and
another widget
PtExtentWidgetFamily()
Force a widget and its children to calculate their extents
PtSetAreaFromCanvas()
Calculate an area based on the canvas and borders of a widget
PtWidgetMinimumSize()
Determine the minimum permissible size of a widget
PtWidgetOffset() Find the offset of a widget’s origin from its disjoint parent
PtWidgetPreferredSize()
Retrieve the preferred size of a widget
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
The following can be used only with menu modules created in PhAB:
ApModifyItemAccel()
Modify the keyboard shortcut for a menu item
ApModifyItemState()
Modify the state of menu items
ApModifyItemText()
Modify the text for a menu item
PtComboBox
The following are described in the Photon Widget Reference:
PtComboBoxListOpen()
Open a combobox list
PtComboBoxListClose()
Close an open combobox list
PtFileSel
The following are described in the Photon Widget Reference:
PtFSClearSelection()
Clear the selection
PtFSExpandParents()
If any ancestors of the given item are collapsed, this function
tries to expand them.
PtFSFolderCollapse()
Collapse an expandable item (directory)
PtFSRemoveChildren()
Unlink all the children of a given item
PtFSUnselectNonBrothers()
Unselect all items that aren’t siblings of the specified item
PtGenList
The following are described in the Photon Widget Reference:
PtGenListAddItems()
Add items to a list
PtGenListClearSelection()
Clear the selection
PtGenListCreateTextBalloon()
Create a popup balloon for an item in the list
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
PtGenListSetColumnBalloon()
Adjust the balloon text to correspond to a given column
PtGenListItemIndex()
Find the index of an item
PtGenListItemRealloc()
Reallocate memory for an item
PtGenListLockItem()
Lock an item so it can be resized
PtGenListRemoveItems()
Remove items from a list
PtGenListSelectedItems()
Get pointers to the selected items
PtGenListSetGflags()
Modify the gflags field of the widget
PtGenListSetSelIndexes()
Set the selection indexes
PtGenListUnlockItem()
Unlock an item so it can be updated
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
The following are described in the Photon Widget Reference:
PtGenTreeClearSelection()
Clear the selection
PtGenTreeDamageItem()
Redraw an item when its data has changed
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
PtGenTreeRootItem()
Get a pointer to the first root item
PtGenTreeSelectedItems()
Get pointers to the selected items
PtGenTreeSetSelIndexes()
Set the selection indexes
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
PtList
The following are described in the Photon Widget Reference:
PtListDeleteAllItems()
Remove all the items from the list
PtListDeleteItemPos()
Delete a range of items by position
PtListGotoPos() Make the item at the specified position the current item and
display it.
PtListRemovePositions()
Remove the items at the specified positions
PtListReplaceItemPos()
Replace items by position number
PtListReplaceItems()
Replace items by item text
PtMTrend
The following are described in the Photon Widget Reference:
PtMTrendChangeData()
Replace some samples in a trend
PtMultiText
The following are described in the Photon Widget Reference:
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_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
PtPanelGroup
The following are described in the Photon Widget Reference:
PtPGCreatePopup()
Create an empty copy of a panel group as a popup window
PtPGFindIndexByPanel()
Get the index for a panel, given a pointer to the panel
PtPGFindIndexByTitle()
Get the index of a panel, given its title
PtPGFindPanelByIndex()
Get a pointer to the panel widget with a given index
PtPGFindPanelByTitle()
Get a pointer to the panel widget with a given title
PtPGFindTitleByIndex()
Get the title of the panel with a given index
PtProgress
The following are described in the Photon Widget Reference:
PtProgressEntireSegment()
Get the entire segment of a progress bar
PtProgressFirstSegment()
Get the first segment of a progress bar
PtProgressNextSegment()
Get the next segment of a progress bar
PtProgressTextRect()
Get the text area of a progress bar
PtTerminal
The following 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
PtTerminalFontInfo() 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
The following are described in the Photon Widget Reference:
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
The following are described in the Photon Widget Reference:
PtTreeAddFirst() Add a root item to the widget, or add an item as the first child
of a specified item
PtTreeClearSelection()
Clear the selection
PtTreeFreeAllItems()
Unlink and free all items
PtTreeGetSelIndexes()
Fill a buffer with indexes of selected items
PtTreeModifyItemString()
Change the string for a PtTree item
PtTreeRemoveChildren()
Unlink the children of the specified item
PtTreeRemoveList() Unlink the given item and any siblings that follow
PtTreeSelectedItems()
Fill a buffer with pointers to the selected items
PtTreeSetSelIndexes()
Set the selection indexes
PtTreeUnselectNonBrothers()
Unselect all items that aren’t siblings of the specified item
PtTrend
The following are described in the Photon Widget Reference:
PtTrendChangeData()
Replace some samples for all trends
PtTrendChangeTrendData()
Replace some samples for one trend
PtTty
This function is described in the Photon Widget Reference:
PtWindow
The following are described in the Photon Widget Reference:
PtWindowGetState()
Return the current state of a window
PtRealizeWidget() Make a widget and its children visible and possibly interactive
Resources
PtAppAddCallback()
Set a callback resource for an application.
PtAppGetResource()
Retrieve one resource value for an application.
PtAppGetResources()
Retrieve one or more resource values for an application.
PtAppRemoveCallback()
Remove a callback resource from an application.
PtAppSetResources()
Set one or more resources for an application.
PtGetControlFlags()
Get the flags from the _Pt_ control structure
PtWidgetClassFlags()
Retrieve a widget’s class structure flags
Styles
PtAddClassStyle() Add a style to a widget class
PtSetClassStyleMethods()
Set multiple members of a style from an array
PtContainerRelease()
Decrement the flux count for a container, potentially damaging the
container
PtHold() Increment the hold count to prevent the visible repair of all
widgets
Window Manager
PhWindowChange()
Modify the attributes of a window’s region
PhWindowClose()
Close a window
PhWindowQueryVisible()
Query a visible extent
PtForwardWindowEvent()
Forward a window event
PtForwardWindowTaskEvent()
Forward a window event to the task with a given Photon
connection ID
PtWindowConsoleSwitch()
Switch to the console a given window’s displayed on
PtWindowGetFrameSize()
Determine the size of a window’s frame
This chapter describes the functions and data structures that are generated by the
Photon Application Builder (PhAB).
These functions and data structures can be used only by applications built with PhAB.
Synopsis:
PtWidget_t *AbGetABW( int wgt_name );
Arguments:
wgt_name The ABN_ name of the widget that you want to find. PhAB
automatically generates these name values for you when you generate
your code.
Description:
This macro returns the widget’s instance pointer based on its ABN_ name. It is similar
to ApGetWidgetPtr(), but it doesn’t require a link instance (pointer to the widget’s
parent module). Instead of searching the widget hierarchy, AbGetABW() looks up the
widget’s ABW_ pointer, which means it’s much more efficient than ApGetWidgetPtr().
All the limitations that apply to the ABW_ manifests also apply to AbGetABW(). This
means that if you create multiple instances of a module, the ABWs either point to the
last instance you created, or are invalid pointers if that instance has already been
destroyed. If you create multiple instances of your widgets, you should use
ApGetWidgetPtr() rather than AbGetABW().
Returns:
A pointer to the widget wgt_name, or NULL if it wasn’t found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetInstance(), ApGetWidgetPtr()
“Handling multiple instances of a window” in the Working with Code chapter of the
Photon Programmer’s Guide
This chapter describes the functions and data structures that let you manipulate
translation files (for PhAB apps or message databases) without using the translation
editor.
You can use these functions to create your own language editor, or to convert a
language database to a different file format (for example, so you can send the file to a
non-Photon or non-QNX system for translation).
Synopsis:
#include <photon/Al.h>
Arguments:
db A pointer to a AlDataBase_t structure for the database, returned by
AlOpenDBase().
Library:
phexlib
Description:
This function clears all the translations in the given language or message database. It
frees the translated strings and sets all the str_translated fields to NULL.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
AlCloseDBase(), AlGetEntry(), AlGetSize(), AlOpenDBase(), AlReadTranslation(),
AlSaveTranslation(), AlSetEntry(), ApCloseMessageDB(), ApGetMessage(),
ApLoadMessageDB()
International Language Support chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Al.h>
Arguments:
db A pointer to a AlDataBase_t structure for the database, returned by
AlOpenDBase().
Library:
phexlib
Description:
AlCloseDBase() closes the language or message database specified by db, releasing all
the associated resources.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
AlClearTranslation(), AlGetEntry(), AlGetSize(), AlOpenDBase(),
AlReadTranslation(), AlSaveTranslation(), AlSetEntry(), ApCloseMessageDB(),
ApGetMessage(), ApLoadMessageDB()
International Language Support chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Al.h>
Arguments:
db A pointer to a AlDataBase_t structure for the database, returned by
AlOpenDBase().
n The number of the record to return.
Library:
phexlib
Description:
AlGetEntry() returns the nth record from the language or message database specified
by db.
The AlTextEntry_t structure contains at least the following members:
Returns:
A pointer to the record retrieved, or NULL if there isn’t a record corresponding to n.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
AlClearTranslation(), AlCloseDBase(), AlGetSize(), AlOpenDBase(),
AlReadTranslation(), AlSaveTranslation(), AlSetEntry(), ApCloseMessageDB(),
ApGetMessage(), ApLoadMessageDB()
International Language Support chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Al.h>
Arguments:
db A pointer to a AlDataBase_t structure for the database, returned by
AlOpenDBase().
Library:
phexlib
Description:
This function returns the number of records in the database identified by db.
Returns:
The number of records.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
AlClearTranslation(), AlCloseDBase(), AlGetEntry(), AlOpenDBase(),
AlReadTranslation(), AlSaveTranslation(), AlSetEntry(), ApCloseMessageDB(),
ApGetMessage(), ApLoadMessageDB()
International Language Support chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Al.h>
Arguments:
path The pathname of the database that you want to open.
Library:
phexlib
Description:
AlOpenDBase() loads into memory the PhAB language database or message database
stored in the file named by path.
This function doesn’t search for the file in any special directories or use any
environment variables — the path is given directly to open().
Returns:
A pointer to a AlDataBase_t structure that describes the database, which you’ll need
to pass to functions that work with the database, or NULL if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
AlClearTranslation(), AlCloseDBase(), AlGetEntry(), AlGetSize(),
AlReadTranslation(), AlSaveTranslation(), AlSetEntry(), ApCloseMessageDB(),
ApGetMessage(), ApLoadMessageDB()
International Language Support chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Al.h>
Arguments:
db A pointer to a AlDataBase_t structure for the database, returned by
AlOpenDBase().
path The pathname of the translation file to load into the database.
Library:
phexlib
Description:
This function reads the translation file with the given path into the str_translated
fields of the database, db.
This function doesn’t search for the file in any special directories or use any
environment variables — the path is given directly to open().
Returns:
0 Success.
A positive number The file contained entries that had to be ignored because they
didn’t match anything in the database.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
AlClearTranslation(), AlCloseDBase(), AlGetEntry(), AlGetSize(), AlOpenDBase(),
AlSaveTranslation(), AlSetEntry(), ApCloseMessageDB(), ApGetMessage(),
ApLoadMessageDB()
International Language Support chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Al.h>
Arguments:
db A pointer to a AlDataBase_t structure for the database, returned by
AlOpenDBase().
Library:
phexlib
Description:
AlSaveTranslation() saves the current translations in the database specified by db into
a translation file named by path.
This function doesn’t locate the file in any special directories or use any environment
variables — the path is given directly to open().
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
AlClearTranslation(), AlCloseDBase(), AlGetEntry(), AlGetSize(), AlOpenDBase(),
AlReadTranslation(), AlSetEntry(), ApCloseMessageDB(), ApGetMessage(),
ApLoadMessageDB()
Synopsis:
#include <photon/Al.h>
Arguments:
db A pointer to a AlDataBase_t structure for the database, returned by
AlOpenDBase().
Library:
phexlib
Description:
This function sets the str_translated field in the nth entry of the language or message
database specified by db. For information about the members of the entry, see
AlGetEntry().
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
AlClearTranslation(), AlCloseDBase(), AlGetEntry(), AlGetSize(), AlOpenDBase(),
AlReadTranslation(), AlSaveTranslation(), ApCloseMessageDB(), ApGetMessage(),
ApLoadMessageDB()
This chapter describes the functions and data structures that are associated with the
Photon Application Builder (PhAB).
These functions and data structures can be used only by applications built with PhAB.
Synopsis:
#include <Ap.h>
int ApAddClass(
char const * class_name_string,
PtWidgetClassRef_t * const *wgt_class);
Arguments:
class_name_string
The name of the class (for example, "PtButton").
wgt_class A predefined widget class; specify the name of the class preceded by an
ampersand (for example, &PtButton).
Library:
Ap
Description:
This function lets you indicate which widget classes you’re likely to encounter when
you call ApOpenDBaseFile().
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.
If you’re loading a DLL that adds classes, you should call ApRemoveClass() to remove
the classes before you unload the DLL.
Returns:
0 Success.
-1 There isn’t enough memory to add the widget class, or you’ve already added a
different widget class with the same name.
Examples:
base_setup ( ... )
{
return (Pt_CONTINUE);
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApOpenDBaseFile(), ApRemoveClass()
Accessing PhAB Modules from Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
context A pointer to the context to add. This argument should be the address of
AbContext, a global data structure that PhAB puts in abmain.c.
exe_path The full path of the DLL, suitable for passing to open().
Library:
Ap
Description:
This function adds a PhAB context so you can use a PhAB application as a DLL.
Returns:
0 on success, or -1 if there wasn’t enough memory or ApAddClass() failed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApAddClass(), ApRemoveContext()
“Making a DLL out of a PhAB application” in the Generating, Compiling, and
Running Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
filename The name of the translation file that you want to append.
Library:
Ap
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.
Keep in mind when calling this function from a DLL that this function performs the
language extension search based on the location of the executable or DLL associated
with the current context, and appends the language translation to the current context.
You must make sure that there is a current context. You most likely want your DLL to
append a language translation to its own context, rather than the main program’s
context:
For more information about creating DLLs from PhAB applications, see “Making a
DLL out of a PhAB application” in the Generating, Compiling, and Running Code
chapter of the Photon Programmer’s Guide.
Returns:
0 Success.
Examples:
Assuming ABLPATH has been set to /usr/photon/translations:
ApDBase_t *mytext_db;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApOpenDBase(), ApOpenDBaseFile(), ApSetTranslation(), ApGetTextRes()
International Language Support chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
db A pointer to a PhAB picture database structure, returned by ApOpenDBase() or
ApOpenDBaseFile().
Library:
Ap
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.
If you use a widget database to create widgets that have PhImage_t data attached to
them, don’t close the database until those widgets are destroyed. Closing the database
frees the memory used by the image. If you must close the database, make sure to
copy the image data within your application code and to reset the image data resource
to point to your new copy.
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(), PhImage_t
Accessing PhAB Modules from Code chapter of the Photon Programmer’s Guide
Synopsis:
void ApCloseMessageDB( ApMsgDBase_t *db );
Arguments:
db A pointer to a message database, returned by ApLoadMessageDB().
Library:
Ap
Description:
This function closes the message database specified by db.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetMessage(), ApLoadMessageDB()
International Language Support chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
from_dbase A pointer to a PhAB widget database structure, returned by
ApOpenDBase() or ApOpenDBaseFile(), for the database that you
want to copy a widget from.
to_dbase A pointer to a PhAB widget database structure for the database that
you want to copy the widget to.
Library:
Ap
Description:
ApCopyDBWidget() 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.
This function was previously called ApCopyWidget(). You should use the new name,
although applications that use the old name will still work.
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:
ApDeleteDBWidget(), ApOpenDBase(), ApOpenDBaseFile(), ApSaveDBaseFile()
Accessing PhAB Modules from Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
PtWidget_t *ApCreateDBWidget(
ApDBase_t const *db,
char const *wgt_name,
PtWidget_t *parent,
PhPoint_t const *pos,
int nargs,
PtArg_t const *args );
Arguments:
db A pointer to a widget database that you opened with either
ApOpenDBase() or ApOpenDBaseFile().
wgt_name The instance name of one of the widgets inside the database.
parent The parent for the widget. If parent is NULL, the widget has no
parent. (Contrast this with ApCreateWidget(), which makes the
widget a child of the current default parent.)
nargs and args The standard resource argument counter and argument list (of type
PtArg_t) used by PtCreateWidget().
Library:
Ap
Description:
This function creates a widget 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 that it
displays.
Before loading widgets from an external database, you should call ApAddClass() for
each widget class that you’ll likely encounter in it. This will add the widget classes to
the internal widget class table.
If the widget returned by this function contains images, the images reference data in
the widget database. Therefore, don’t close the widget database while you’re using the
widget. If you need to close the database, you must remove all references to image
data. You can do this by destroying the widgets, unsetting images in the widgets, or
changing them into images that don’t reference the database by using
PiDuplicateImage() to copy the images from the database.
Returns:
A pointer to the widget created for wgt_name, or NULL on failure.
Examples:
ApDBase_t *mydbase;
PtArg_t args[2];
PhPoint_t pos;
PtWidget_t *my_label;
ApCloseDBase( mydbase );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApCloseDBase(), ApCreateDBWidgetFamily(), ApCreateWidget(),
ApCreateWidgetFamily(), ApGetDBWidgetInfo(), ApOpenDBase(),
ApOpenDBaseFile(), ApSaveDBaseFile(), PhPoint_t, PtArg_t, PtCreateWidget()
Accessing PhAB Modules from Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
PtWidget_t *ApCreateDBWidgetFamily(
ApDBase_t const *db,
char const *wgt_name,
PtWidget_t *parent,
PhPoint_t const *pos,
int nargs,
PtArg_t const *args );
Arguments:
db A pointer to a widget database that you opened with either
ApOpenDBase() or ApOpenDBaseFile().
wgt_name The instance name of one of the widgets inside the database.
parent The parent for the widget. If parent is NULL, the widget has no
parent. (Contrast this with ApCreateWidgetFamily(), which makes
the widget a child of the current default parent.)
nargs and args The standard resource argument counter and argument list (of type
PtArg_t) used by PtCreateWidget().
Library:
Ap
Description:
This function creates 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 family.
Before loading widgets from an external database, you should call ApAddClass() for
each widget class that you’ll likely encounter in it. This will add the widget classes to
the internal widget class table.
The pointers of the widget’s children aren’t directly available using this function. If
you need access to the container’s children, you’ll need to call ApCreateDBWidget()
for the container and each widget inside it. If you create them in the same hierarchical
order as defined in the database, the parent-child relationship will be maintained.
If any of the widgets returned by this function contain images, the images reference
data in the widget database. Therefore, don’t close the widget database while you’re
using these widgets. If you need to close the database, you must remove all references
to image data. You can do this by destroying the widgets, unsetting images in the
widgets, or changing them into images that don’t reference the database by using
PiDuplicateImage() to copy the images from 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(), ApCreateDBWidget(), ApCreateWidget(), ApCreateWidgetFamily(),
ApGetDBWidgetInfo(), ApOpenDBase(), ApOpenDBaseFile(), ApSaveDBaseFile(),
PhPoint_t, PtArg_t, PtCreateWidget()
Accessing PhAB Modules from Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
PtWidget_t * ApCreateModule(
ApEventLink_t const *link_callback,
PtWidget_t *widget,
PtCallbackInfo_t *cbinfo );
Arguments:
link_callback The manifest that PhAB created for the module.
widget A pointer to a widget. The way that the function uses this argument
depends on whether or not the module is a picture; for more
information, see “Usage with window, dialog, menu, and other
modules” and “Usage with picture modules,” below.
Library:
Ap
Description:
You can use ApCreateModule() to manually create instances of modules built with
PhAB. Its behavior depends on the type of module that you’re creating, as described
below.
ApCreateModule() is also useful when you need to display modules without direct
user interaction.
This function uses the widget argument only if you’re creating a module with a
location relative to another widget. Otherwise, you can set it to NULL. It’s passed to
the module’s setup function as apinfo->widget.
The cbinfo argument is a pointer to the PtCallbackInfo_t structure (see the Photon
Widget Reference) that was passed to the callback. It’s used only if you’re creating a
module relative to the pointer position. Otherwise, you can set it to NULL.
This code creates one of two dialogs:
return (Pt_CONTINUE);
}
return (Pt_CONTINUE);
}
• If widget is NULL, the picture module becomes a child of the current parent widget,
and the picture module’s children become grandchildren of the current parent
widget. You can call PtSetParentWidget() to change the current parent. For
example:
int mycallback( PtWidget_t *widget,
ApInfo_t *apinfo,
PtCallbackInfo_t *cbinfo )
{
/* Clear the container widget. */
PtClearWidget( ABW_mycontainer );
return (Pt_CONTINUE);
}
Returns:
A pointer to the instance of the created module, or NULL if an error occurred or a
setup function aborted the creation. There are some special cases:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApModuleLocation(), ApModuleFunction(), ApModuleParent(), PtDestroyWidget(),
PtSetParentWidget()
PtCallbackInfo_t in the Photon Widget Reference
“Module setup functions” in the Working with Code chapter, “Picture modules” in the
Working with Modules chapter, and the Accessing PhAB Modules from Code chapter
of the Photon Programmer’s Guide.
Synopsis:
#include <Ap.h>
Arguments:
db A pointer to a widget database that you opened with either
ApOpenDBase() or ApOpenDBaseFile().
wgt_name The instance name of one of the widgets inside the database.
nargs and args The standard resource argument counter and argument list (of type
PtArg_t) used by PtCreateWidget().
Library:
Ap
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.
You can use ApCreateDBWidget() instead of this function. ApCreateDBWidget() lets
you specify the position without having to worry about the case when y happens to be
-1.
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().
Before loading widgets from an external database, you should call ApAddClass() for
each widget class that you’ll likely encounter in it. This will add the widget classes to
the internal widget class table.
ApCreateWidget() creates only the widget named by wgt_name regardless of its class.
ApCreateWidgetFamily() creates the named widget and, for container class widgets,
any children of the widget.
If the widget returned by this function contains images, the images reference data in
the widget database. Therefore, don’t close the widget database while you’re using the
widget. If you need to close the database, you must remove all references to image
data. You can do this by destroying the widgets, unsetting images in the widgets, or
changing them into images that don’t reference the database by using
PiDuplicateImage() to copy the images from the database.
Returns:
A pointer to the widget created for wgt_name, or NULL on failure.
Examples:
ApDBase_t *mydbase;
PtArg_t args[2];
PtWidget_t *my_label;
ApCloseDBase( mydbase );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApCloseDBase(), ApCreateDBWidget(), ApCreateDBWidgetFamily(),
ApCreateWidgetFamily(), ApGetDBWidgetInfo(), ApOpenDBase(),
ApOpenDBaseFile(), ApSaveDBaseFile(), PtArg_t, 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 );
Arguments:
db A pointer to a widget database that you opened with either
ApOpenDBase() or ApOpenDBaseFile().
wgt_name The instance name of one of the widgets inside the database.
nargs and args The standard resource argument counter and argument list (of type
PtArg_t) used by PtCreateWidget().
Library:
Ap
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.
You can use ApCreateDBWidgetFamily() instead of this function.
ApCreateDBWidgetFamily() lets you specify the position without having to worry
about the case when y happens to be -1.
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().
Before loading widgets from an external database, you should call ApAddClass() for
each widget class that you’ll likely encounter in it. This will add the widget classes to
the internal widget class table.
ApCreateWidgetFamily() creates the named widget and, for container class widgets,
any children of the widget.
The pointers of the widget’s children aren’t directly available using this function. If
you need access to the container’s children, you’ll need to call ApCreateWidget() for
the container and each widget inside it. If you create them in the same hierarchical
order as defined in the database, the parent-child relationship will be maintained.
If any of the widgets returned by this function contain images, the images reference
data in the widget database. Therefore, don’t close the widget database while you’re
using these widgets. If you need to close the database, you must remove all references
to image data. You can do this by destroying the widgets, unsetting images in the
widgets, or changing them into images that don’t reference the database by using
PiDuplicateImage() to copy the images from 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(), ApCreateDBWidget(), ApCreateDBWidgetFamily(),
ApCreateWidget(), ApGetDBWidgetInfo(), ApOpenDBase(), ApOpenDBaseFile(),
ApSaveDBaseFile(), PtArg_t, PtCreateWidget(), PtSetParentWidget().
Accessing PhAB Modules from Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
db A pointer to a widget database that you opened with either
ApOpenDBase() or ApOpenDBaseFile().
wgt_name The instance name of the widget that you want to delete.
Library:
Ap
Description:
ApDeleteDBWidget() removes the widget named wgt_name from the widget database
indicated by db. If the widget is a container, its children are also removed.
Returns:
0 Success.
-1 Failure.
Examples:
ApDBase_t *my_dbase;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApCopyDBWidget(), ApOpenDBase(), ApOpenDBaseFile(), ApSaveDBaseFile()
Accessing PhAB Modules from Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
widget A pointer to the parent widget for the error message dialog.
errnum The standard errno value set by the operation that failed. The
errno variable and its values are defined in <errno.h>, and are
described in the QNX Neutrino Library Reference.
location The location in the code where the error occurred. If you don’t
want the location displayed, specify NULL.
Library:
Ap
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.
• app_prefix
• error_message
Examples:
If you call ApError() as follows, specifying the location:
In the example above, __FILE__ is a compiler directive to insert the name of the
source file, and (Permission denied) is the string associated with the current
value of errno.
If you make the same call, but omit the location:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAlert(), PtNotice(), PtPrompt()
“Dialog modules” in the Working with Modules chapter of the Photon Programmer’s
Guide
Synopsis:
ApDBWidgetInfo_t *ApGetDBWidgetInfo(
ApDBase_t const *dbase,
unsigned index,
ApDBWidgetInfo_t *info );
Arguments:
dbase A pointer to a widget database that you opened with either ApOpenDBase()
or ApOpenDBaseFile().
index The index of the widget that you want to get information about. The index
of the first widget is 0.
Library:
Ap
Description:
This function extracts information about the widget with a given index in the database
specified by dbase.
If index is greater than or equal to the number of widgets in the database, the function
returns NULL. Otherwise, it puts information about a widget in the buffer pointed to
by info, and returns info.
The ApDBWidgetInfo_t structure contains at least the following members:
int parent_index The index of the widget’s parent in the database, or -1 if it has
no parent.
int level How deep in the hierarchy the widget is. The top level in the
hierarchy is 1.
Returns:
The same pointer as info, or NULL if there isn’t a widget with the given index.
Examples:
ApDBase_t *dbase = ApOpenDBase( ABM_db );
int i;
ApDBWidgetInfo_t wi;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApCloseDBase(), ApCreateDBWidget(), ApCreateDBWidgetFamily(),
ApCreateWidget(), ApCreateWidgetFamily(), ApOpenDBase(), ApOpenDBaseFile(),
ApSaveDBaseFile(),
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 );
Arguments:
dbase The widget database pointer returned from ApOpenDBase() or
ApOpenDBaseFile().
wgt_name The name of widget within the database that has the image that you
want to extract.
Library:
Ap
Description:
ApGetImageRes() lets you extract images from a widget in a PhAB widget database.
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, you should first use
PiDuplicateImage() to make a copy of the image and associated structures.
1 Make a copy of the image data, such as image pixel data, alpha channel, palette,
etc, using PiDuplicateImage().
2 Update the PhImage_t structure to point to the new copies of the data.
Examples:
PhImage_t *image;
if ( image ) {
PtSetResource( ABW_label_wgt, Pt_ARG_LABEL_IMAGE,
image, 0 );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApOpenDBase(), ApOpenDBaseFile(), PgDrawPhImage*(), PhCreateImage(),
PhImage_t, PhMakeGhostBitmap(), PhMakeTransBitmap(), PhMakeTransparent(),
PhReleaseImage(), PmMemCreateMC(), PmMemFlush(), PxLoadImage()
“Images” and “Animation” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
widget A pointer to the widget that you want to get the module link instance
pointer for.
Library:
Ap
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 can’t be determined.
Examples:
PtArg_t args[1];
return( Pt_CONTINUE );
}
An interesting observation about this callback example is that it doesn’t know which
window is being modified or which widget gets changed. It acts on whatever widget
the user selects.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetWidgetPtr()
“Handling multiple instances of a window” in the Working with Code chapter of the
Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
menu A pointer to a PhAB menu link structure.
Library:
Ap
Description:
ApGetItemText() is used to extract the text of a menu item in a PhAB menu module. 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.
If you call ApModifyItemText() after calling ApGetItemText() for the same menu item,
the string returned by ApGetItemText() becomes invalid.
Examples:
text = ApGetItemText( &mymenu, ABN_item1 );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApModifyItemAccel(), ApModifyItemState(), ApModifyItemText()
“Changing menu-item text” in the Working with Code chapter of the Photon
Programmer’s Guide
Synopsis:
char *ApGetMessage( ApMsgDBase_t *db,
const char *tag );
Arguments:
db A pointer to a message database, returned by ApLoadMessageDB().
tag The tag for the message that you want to get.
Library:
Ap
Description:
A message database is a file containing textual messages. ApGetMessage() can be
used to retrieve the message with the given tag from the database specified by db.
Returns:
The message corresponding to the tag, or NULL if the tag wasn’t found in the database.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApCloseMessageDB(), ApLoadMessageDB()
International Language Support chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
dbase A pointer to a widget database that you opened with either ApOpenDBase()
or ApOpenDBaseFile().
name The instance name of the text string that you want to translate.
Library:
Ap
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:
ApGetImageRes(), ApOpenDBase(), ApOpenDBaseFile()
Accessing PhAB Modules from Code and International Language Support chapters of
the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
link_instance The link instance of the module that you want to search for the
widget.
wgt_name The ABN_ name of the widget that you want to find. PhAB
automatically generates these name values for you when you
generate your code.
Library:
Ap
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.
You can also use AbGetABW() to get the widget instance pointer more efficiently,
though AbGetABW() does not work when there are multiple instances of the widget’s
window module.
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.
Returns:
A pointer to the widget within the module link_instance, or NULL if it wasn’t 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:
AbGetABW(), ApGetInstance()
“Handling multiple instances of a window” in the Working with Code chapter of the
Photon Programmer’s Guide
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:
ABR_PRE_REALIZE
Pre-realize setup function
ABR_POST_REALIZE
Post-realize setup function
The widget argument is a pointer to the widget that invoked the callback function. This
is very useful in setup functions to determine which widget initiated the link 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>
Arguments:
argc The number of entries in the argv array.
argv[] An array of pointers to strings that contain the arguments to the program.
Library:
Ap
Description:
This function is used to initialize an application. Usually argc and argv are passed
directly from the main as they come. The list of actually recognized options is
specified in the PhAB under Project→Project Properties→Generate Options.
Returns:
0 on success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApCreateModule(), ApCreateWidget()
Synopsis:
#include <Ap.h>
Arguments:
widget A pointer to the widget whose instance name you want to get.
Library:
Ap
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:
1 In PhAB, select the Startup Info/Modules command from the Application menu.
2 In the Application Startup Information dialog, click the Store Names for
ApInstanceName() button.
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
continued. . .
Safety
Signal handler No
Thread No
See also:
“Including instance names” in the Working with Applications chapter of the Photon
Programmer’s Guide
Synopsis:
ApMsgDBase_t *ApLoadMessageDB( ApMsgDBase_t *db,
const char *name );
Arguments:
db NULL, or a pointer to a message database that’s already open to which you
want to add the loaded messages.
name The name of the message database that you want to load.
Library:
Ap
Description:
This function loads the message database with the given name. It searches for the file
based on the value of the ABLPATH and the current language:
• If a language isn’t defined, the message database is loaded. It must have a name of
name.mdb.
Note that in an application that uses PhAB DLLs, this function performs the language
search based on the location of the executable or DLL associated with the current
context. If there’s no current context, a lookup that would search the directory of an
executable or DLL is skipped.
Returns:
A pointer to the new database, or NULL if it couldn’t be opened.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetMessage()
International Language Support chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
widget A pointer to the parent widget that is associated with this window. This
pointer will be passed as info.widget into the setup function(s).
cbinfo A pointer to the callback structure that contains the callback information
that prompted this call (the reason).
Library:
Ap
Description:
This function is used to open a window.
Returns:
A pointer to a PtWidget_t structure for the newly created window.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCallbackInfo_t(), ApCreateWidget()
Synopsis:
int ApModalWait( PtWidget_t *widget,
unsigned flags );
Arguments:
widget A pointer to the widget whose destruction you want to wait for.
Library:
Ap
Description:
ApModalWait() processes Photon events until the given widget is destroyed.
Returns:
0 on success, or -1 if PtModalBlock() fails.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtBlockAllWindows(), PtBlockWindow(), PtMakeModal(), PtModalBlock(),
PtUnblockWindows()
Synopsis:
int ApModifyItemAccel( ApMenuLink_t *menu,
int item_no,
const char *new_text,
int new_flags );
Arguments:
menu A pointer to a PhAB menu link structure.
Library:
Ap
Description:
ApModifyItemAccel() modifies the keyboard shortcut for a menu item in a PhAB menu
module.
You can call ApModifyItemAccel() at any time to set the menu item’s shortcut, and the
effect will be seen when the menu is next displayed.
Returns:
0 The item number isn’t valid.
1 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetItemText(), ApModifyItemState(), ApModifyItemText()
“Changing menu-item text” in the Working with Code chapter of the Photon
Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
menu A pointer to a PhAB menu link structure.
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).
Library:
Ap
Description:
ApModifyItemState() modifies the state of menu items in a PhAB menu module.
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.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetItemText(), ApModifyItemAccel(), ApModifyItemText()
“Enabling, disabling, or toggling menu items” in the Working with Code chapter of
the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
int ApModifyItemText( ApMenuLink_t *menu,
int item_num,
char const *new_text );
Arguments:
menu A pointer to a PhAB menu link structure.
Library:
Ap
Description:
ApModifyItemText() modifies the text for a menu item in a PhAB menu module.
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(), ApModifyItemAccel(), ApModifyItemState()
“Changing menu-item text” in the Working with Code chapter of the Photon
Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
link_callback The ABM_ link callback that you want to specify a setup function.
function The setup function that you want to register for the link callback.
realize_flags A flag that indicates when the setup function should be called; one
of:
• AB_FUNC_PRE_REALIZE
• AB_FUNC_POST_REALIZE
• AB_FUNC_BOTH
Library:
Ap
Description:
ApModuleFunction() is used to specify the setup function for a PhAB internal link
callback.
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
continued. . .
Safety
Signal handler No
Thread No
See also:
ApCreateModule(), ApModuleLocation()
Accessing PhAB Modules from Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
link_callback The ABM_ link callback for the module whose location you want
to specify.
loc_type Where to place the module; one of the following:
• AB_LOC_BELOW_WGT
• AB_LOC_ABOVE_WGT
• AB_LOC_RIGHT_WGT
• AB_LOC_LEFT_WGT
• AB_LOC_TOP_LEFT
• AB_LOC_TOP_RIGHT
• AB_LOC_BOT_LEFT
• AB_LOC_BOT_RIGHT
• AB_LOC_CENTER
• AB_LOC_REL_CURSOR
• AB_LOC_REL_MODULE
• AB_LOC_DEFAULT — let the window manager determine
the position. The offsets are ignored.
• AB_LOC_ABSOLUTE — x_offset and y_offset are the
absolute coordinates for the module.
x_offset, y_offset The horizontal and vertical offsets for the module, relative to the
given location.
Library:
Ap
Description:
ApModuleLocation() is used to specify the module location for a PhAB internal link.
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
See also:
ApModuleFunction()
Accessing PhAB Modules from Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
link_callback The ABM_ link callback for the module whose parent you want to
specify.
widget A pointer to the widget that you want to be the parent of the module.
Library:
Ap
Description:
ApModuleParent() lets you specify the parent module for a window or dialog module.
Examples:
Change my_window to have no parent at all:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
Accessing PhAB Modules from Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
widget A pointer to the widget whose PhAB name you want to get.
Library:
Ap
Description:
ApName() returns a PhAB name value for the specified widget. You can compare this
name value with the global name values that 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
continued. . .
Safety
Thread No
See also:
“Variables and manifests” in the Working With Code chapter of the Photon
Programmer’s Guide
Synopsis:
#include <Ap.h>
ApDBase_t *ApOpenDBase(
ApEventLink_t const *link_callback );
Arguments:
link_callback The ABM_ internal link manifest, generated by PhAB, of the module
that you want to open.
Library:
Ap
Description:
ApOpenDBase() opens the given module as a widget database. Typically, the module
is a picture, but it can also be a window or dialog.
ApOpenDBaseFile() lets you open an external module file 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(), ApCreateDBWidget(), ApCreateDBWidgetFamily(), ApCreateWidget(),
ApCreateWidgetFamily(), ApGetDBWidgetInfo(), ApCloseDBase(),
ApOpenDBaseFile()
Accessing PhAB Modules from Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
path The path of the external module file that you want to open.
Library:
Ap
Description:
ApOpenDBaseFile() opens an external module file as a widget database. Typically, the
module is a picture, but it can also be a window or dialog. External module files
supported have a .wgtp, .wgti, .wgtd, or .wgtw extension.
ApOpenDBase() opens the module specified by a ABM_ internal link manifest that’s
generated by PhAB.
Before calling ApOpenDBaseFile(), you should call ApAddClass() for each widget
class that you’ll likely encounter in the database. This function adds the widget classes
to the internal widget class table.
Note that this function associates the widget database with the current PhAB context.
Only language translations from that context are applied when you create widgets
using the database. If you don’t want any language translations to be applied to an
external database, set the current context to NULL when you open the database:
ApSetContext( NULL );
ApDBase_t *db = ApOpenDBaseFile( fname );
ApSetContext( & AbContext ); // Restore the program’s
// context
A typical PhAB application has only one PhAB context; only applications that load
PhAB-created DLLs have to deal with multiple contexts. For more information about
creating DLLs from PhAB applications, see “Making a DLL out of a PhAB
application” in the Generating, Compiling, and Running Code chapter of the Photon
Programmer’s Guide.
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(), ApCreateDBWidget(), ApCreateDBWidgetFamily(), ApCreateWidget(),
ApCreateWidgetFamily(), ApGetDBWidgetInfo(), ApCloseDBase(), ApOpenDBase()
Accessing PhAB Modules from Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
int ApRemoveClass(
char const * class_name_string,
PtWidgetClassRef_t * const *wgt_class);
Arguments:
class_name_string
The name of the class that you want to remove (for example,
"PtButton").
wgt_class A predefined widget class; specify the name of the class preceded by an
ampersand (for example, &PtButton).
Library:
Ap
Description:
This function lets you remove widget classes that you previous added by calling
ApAddClass().
If you’ve loaded a DLL that adds classes, you should remove the classes before you
unload the DLL.
Returns:
0 Success.
-1 The widget wasn’t registered with ApAddClass(), or the wgt_class pointer isn’t
the same as when you registered the class.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApAddClass(), ApRemoveContext()
“Making a DLL out of a PhAB application” in the Generating, Compiling, and
Running Code chapter, Accessing PhAB Modules from Code chapter of the Photon
Programmer’s Guide
Synopsis:
int ApRemoveContext( ApContext_t *context );
Arguments:
context A pointer to the context to remove. This argument should be the address of
AbContext, a global data structure that PhAB puts in abmain.c.
Library:
Ap
Description:
This function removes a PhAB context from a PhAB application that you’re using as a
DLL. Call this function from the DLL’s cleanup function.
Returns:
0 on success, or -1 on failure.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApAddContext(), ApRemoveClass()
“Making a DLL out of a PhAB application” in the Generating, Compiling, and
Running Code chapter of the Photon Programmer’s Guide
Synopsis:
void ApResClose ( void );
Library:
Ap
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:
if (apinfo->reason == ABR_POST_REALIZE) {
ApResClose ();
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
#include <Ap.h>
Arguments:
dbase A pointer to a widget database that you opened with either ApOpenDBase()
or ApOpenDBaseFile().
path The name of the file in which you want to save the database.
Library:
Ap
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 Success.
-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(), ApCopyDBWidget(), ApDeleteDBWidget(), ApOpenDBase(),
ApOpenDBaseFile()
Accessing PhAB Modules from Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
context A pointer to the context you want to set the current PhAB context to. This
argument should be the address of AbContext, a global data strcuture that
PhAB puts into abmain.c, or NULL for no context.
Library:
Ap
Description:
ApSetContext() makes the given context current, and returns the previous current
context. Both can be NULL; but if you pass a non-NULL pointer, it must point to a
registered context.
At program startup, the program’s PhAB context AbContext is made current. You can
unset it or change it to a different context by calling ApSetContext(). You may want to
do this in a DLL which calls Ap*() functions that use the current context.
In an application that doesn’t involve DLLs, you can use this function to set the
context to NULL when you’re calling ApOpenDBaseFile(), to prevent the database
from using your application’s language translations if the file happens to contain
widgets with the same name as one of your widgets.
Returns:
A pointer to the previous current context.
Examples:
This example sets the program’s current context to NULL so that the widget database
opened by ApOpenDBaseFile() doesn’t use the current language translation:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
“Making a DLL out of a PhAB application” in the Generating, Compiling, and
Running Code chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
lang_ext NULL, or the extension for the language that you want to switch to (e.g.
ja_JP for Japanese).
Library:
Ap
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:
Unlike the PATH environment variable, the current directory must be indicated
by a period, not an empty string. An empty string in ABLPATH indicates the
directory where the executable is.
In an application that loads PhAB DLLs, this function changes the current language
for all registered contexts (i.e. the program and all DLLs). It first unloads any existing
language translations for all the contexts, and then attempts to find a translation file for
each context, using the name and location of the executable or DLL to perform the
ABLPATH search described above.
Returns:
0 Successful completion.
Examples:
/* Set the current translation to German: */
ApSetTranslation( "de_DE");
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApAppendTranslation(), ApOpenDBase(), ApOpenDBaseFile(), ApGetTextRes()
International Language Support chapter of the Photon Programmer’s Guide
Synopsis:
#include <Ap.h>
Arguments:
cbinfo A pointer to the PtCallbackInfo_t structure (see the Photon Widget
Reference) that was passed to the callback.
Library:
Ap
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.
PtCallbackInfo_t in the Photon Widget Reference
“Module setup functions” in the Working With Code chapter of the Photon
Programmer’s Guide
Synopsis:
PdDirectContext_t *PdCreateDirectContext( void );
Library:
ph
Description:
This function creates a direct-mode context. The context isn’t activated at this point,
and the graphics driver is still operating normally (i.e it’s still Reply Blocked on
Photon).
When an application enters direct mode, it’s requesting that the graphics driver receive
draw streams and service messages directly from the application, instead of from
Photon. The driver blocks on the application, which is now responsible for telling the
graphics driver what to do.
Returns:
A pointer to a PdDirectContext_t structure if successful, or NULL on failure.
Examples:
PdDirectContext_t *DirectMode=NULL;
PhDrawContext_t *Olddc=NULL;
PhRid_t rid_array[10];
DirectMode=PdCreateDirectContext();
if (DirectMode == NULL)
{
// error code
}
PdReleaseDirectContext(DirectMode);
PhDCSetCurrent(Olddc);
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdDirectStart(), PdDirectStop(), PdReleaseDirectContext(), PdSetTargetDevice()
“Direct mode” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PdOffscreenContext_t *PdCreateOffscreenContext(
unsigned long ImageType,
unsigned short width,
unsigned short height,
unsigned long flags );
Arguments:
ImageType The type of image. Can be one of:
• Pg_IMAGE_DIRECT_1555
• Pg_IMAGE_DIRECT_565
• Pg_IMAGE_DIRECT_888
• Pg_IMAGE_DIRECT_8888
• Pg_IMAGE_PALETTE_BYTE
• 0 (the image type is defined by the current video mode)
For more information about these image types, see PhImage_t.
flags Flags that indicate how you want to create the offscreen context. Set
to 0 if there are no restrictions on where the context can be allocated.
Can be a combination of:
• Pg_OSC_CRTC_SAFE — tell the driver that you want to be able
to point the CRT at this context at a later date (using
PgSwapDisplay()).
The driver may change the dimensions and/or image type of the
context in order to comply with this flag.
• Pg_OSC_MAIN_DISPLAY — create an offscreen context from
the currently displayed screen. It doesn’t make a new offscreen
context in video ram, but just wraps the displayed screen with a
PdOffscreenContext_t structure.
• Pg_OSC_MEM_LINEAR_ACCESSIBLE — Request surface
memory that is linearly accessible.
Library:
ph
Description:
This function creates an offscreen context.
If there isn’t enough space in video RAM to create the offscreen context, the behavior
of this function depends on the driver; most drivers allocate space in system memory
instead (if none of SYS_ONLY, 2D_WRITABLE, or 2D_READABLE are set in flags).
Returns:
A pointer to a PdOffscreenContext_t, or NULL if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdDupOffscreenContext(), PdGetOffscreenContextPtr(), PdOffscreenContext_t,
PdSetOffscreenTranslation(), PdSetTargetDevice(), PgContextBlit(),
PgSwapDisplay(), PhDCCreate(), PhDCRelease()
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PdOffscreenContext_t *PdCreateOffscreenContextGF(
gf_surface_t surface);
Arguments:
surface A handle to a GF surface.
Library:
ph
Description:
The function binds a GF surface to a Photon PdOffscreenContext_t.
If there isn’t enough space in video RAM to create the offscreen context, the behavior
of this function depends on the driver; most drivers allocate space in system memory
instead (if none of SYS_ONLY, 2D_WRITABLE, or 2D_READABLE are set in flags).
Returns:
A pointer to a PdOffscreenContext_t, or NULL if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateOffscreenContext(), PdDupOffscreenContext(), PdGetOffscreenContextPtr(),
PdOffscreenContext_t, PdSetOffscreenTranslation(), PdSetTargetDevice(),
PgContextBlit(), PgSwapDisplay(), PhDCCreate(), PhDCRelease()
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PdCreateOffscreenLock(
PdOffscreenContext_t *osc,
PdOSCCreateLockParams_t *params );
Arguments:
osc A pointer to the PdOffscreenContext_t structure for the offscreen
context.
params A pointer to a PdOSCCreateLockParams_t structure that defines the
parameters for the lock; see below.
Library:
ph
Description:
This function creates an offscreen lock in an offscreen context.
This function doesn’t lock the offscreen context; to do that, call PdLockOffscreen().
You can’t lock the primary display unless the application is in direct mode.
Returns:
EOK The lock was successfully created.
Pg_OSC_LOCK_ALREADY_CREATED
The lock has already been created for this offscreen context.
Pg_OSC_CREATE_LOCK_FAILED
The lock couldn’t be created. The most likely reason is that io-graphics is
running remotely.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdDestroyOffscreenLock(), PdGetOffscreenContextPtr(), PdIsOffscreenLocked(),
PdLockOffscreen(), PdUnlockOffscreen()
“Offscreen locks” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PdDestroyOffscreenLock(
PdOffscreenContext_t *osc );
Arguments:
osc A pointer to the PdOffscreenContext_t structure for an offscreen context,
as returned by PdCreateOffscreenContext().
Library:
ph
Description:
This function removes an offscreen lock from the offscreen context, osc.
Returns:
EOK The lock was successfully destroyed.
Pg_OSC_LOCK_INVALID
The lock didn’t exist.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateOffscreenContext(), PdCreateOffscreenLock(), PdGetOffscreenContextPtr(),
PdIsOffscreenLocked(), PdLockOffscreen(), PdUnlockOffscreen()
“Offscreen locks” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PhDrawContext_t *PdDirectStart(
PdDirectContext_t *DirectContext );
Arguments:
DirectContext A pointer to the PdDirectContext_t structure for a direct
context, as returned by PdCreateDirectContext().
Library:
ph
Description:
This function puts the application into direct mode. On successful completion of this
call, the graphics driver is blocked on the application that’s awaiting rendering
services. The DirectContext is now the default context for the application.
Returns:
A pointer to the previous draw context on success, or NULL on failure.
Examples:
See PdCreateDirectContext().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateDirectContext(), PdDirectStop(), PdReleaseDirectContext()
“Direct mode” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PhDrawContext_t *PdDirectStop(
PdDirectContext_t *DirectContext );
Arguments:
DirectContext A pointer to the PdDirectContext_t structure for a direct
context, as returned by PdCreateDirectContext().
Library:
ph
Description:
This function takes the application out of direct mode, but doesn’t destroy the
direct-mode context.
Returns:
The default draw context (draw through Photon).
Examples:
See PdCreateDirectContext().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateDirectContext(), PdDirectStart(), PdReleaseDirectContext()
“Direct mode” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PdOffscreenContext_t *
PdDupOffscreenContext(
PdOffscreenContext_t *context,
unsigned long flags );
Arguments:
context A pointer to the context that you want to duplicate, as returned by
PdCreateOffscreenContext(), or NULL if you want to duplicate the screen
buffer.
flags Flags that indicate how you want to create the offscreen context:
• Pg_OSC_CRTC_SAFE — tell the driver that you want to be able to
point the CRT at this context at a later date (using PgSwapDisplay()).
The driver may change the dimensions and/or image type of the context
in order to comply with this flag.
• Pg_OSC_MEM_PAGE_ALIGN — ensure that the offscreen context
that’s created is aligned to __PAGESIZE (4K on an x86). You need to
specify this flag in order to use PdGetOffscreenContextPtr() with this
context.
• Pg_OSC_MEM_SYS_ONLY — create an offscreen context in system
RAM only. If there is not enough system RAM to create the context,
the function fails.
• Pg_OSC_MEM_2D_WRITABLE — create an offscreen context that the
graphic card’s 2D engine can write to. The offscreen context is created
in video RAM only to support hardware acceleration. If there is not
enough video RAM to create the context, the function fails.
• Pg_OSC_MEM_2D_READABLE — create an offscreen context that is
readable by the graphic card’s 2D engine. The offscreen context is
created in video RAM only to support hardware acceleration. If there is
not enough video RAM to create the context, the function fails.
• Pg_OSC_MEM_HINT_CPU_READ — create an offscreen context that
is optimized by the driver for fast reading by the CPU. Use this flag if
you are doing unaccelerated rendering or using
PdGetOffscreenContextPtr(). This flag has a lower priority than other
flags. For example, if conditions conflict for satisfying the requirements
of this flag and Pg_OSC_MEM_2D_READABLE, this flag is ignored.
• Pg_OSC_MEM_HINT_CPU_WRITE — create an offscreen context that
is optimized by the driver for fast writing by the CPU. Use this flag if
you are doing unaccelerated rendering or using
PdGetOffscreenContextPtr(). This flag has a lower priority than other
flags. For example, if conditions conflict for satisfying the requirements
of this flag and Pg_OSC_MEM_2D_WRITABLE, this flag is ignored.
Library:
ph
Description:
PdDupOffscreenContext() makes a copy of the given context. This not only creates a
context that has the same dimensions and image type, but also copies the image data.
Returns:
A pointer to a PdOffscreenContext_t structure, or NULL on failure.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateOffscreenContext(), PdGetOffscreenContextPtr(),
PdOffscreenContext_t, PdSetOffscreenTranslation(), PdSetTargetDevice(),
PgContextBlit(), PgSwapDisplay()
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PdGetDevices( PhRid_t *rid_array,
uint32_t max_rids );
Arguments:
rid_array An array that the function can fill with the region IDs of the currently
available draw contexts.
Library:
ph
Description:
PdGetDevices() fills the provided rid_array with up to max_rids region IDs of draw
devices that are currently available.
Returns:
The number of draw devices currently available on the system. This value may be
larger than max_rids, which indicates that the provided array isn’t big enough to hold
the region IDs for all the draw devices on the system.
Examples:
See PdCreateDirectContext().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdSetTargetDevice()
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void *PdGetOffscreenContextPtr(
PdOffscreenContext_t *osc );
Arguments:
osc A pointer to a PdOffscreenContext_t, structure that describes an
offscreen context. You must have created the context with the
Pg_OSC_MEM_PAGE_ALIGN flag in order for this function to work.
Library:
ph
Description:
This function creates a shared memory reference to an offscreen context and return a
pointer to the object.
!
CAUTION: PdGetOffscreenContextPtr() can fail on certain hardware. You can use
this function on closed systems where you know that the graphics frame buffer is
linear; don’t use it in applications that target generic hardware configurations.
If osc is NULL, this function returns a pointer to the currently displayed screen:
Returns:
A pointer to the shared memory object, or NULL on failure.
Examples:
Draw a white vertical line in an offscreen context using software (not PgDrawRect()):
PdOffscreenContext_t *buff;
VidPtr_t main_ptr,work_ptr;
uint32_t color,bytespp;
PhRect_t rect;
int i;
rect.ul.x=rect.ul.y=0;
rect.lr.x=rect.lr.y=99;
main_ptr.ptr8=(unsigned char *)
PdGetOffscreenContextPtr(buff);
if (main_ptr.ptr8 == NULL)
{
// Error code
}
break;
}
}
PgContextBlit(buff,&rect,NULL,&rect);
PgFlush();
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateOffscreenContext(), PdDupOffscreenContext(), PdOffscreenContext_t,
PgContextBlit(), PgContextBlitArea(), PgSwapDisplay()
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PgSurface_t *PtGetOffscreenSurface(
PdOffscreenContext_t *osc );
Arguments:
osc A pointer to an offscreen context structure, as returned by
PdCreateOffscreenContext().
Library:
ph
Description:
This function gets a handle for an offscreen context surface.
Returns:
A pointer to an opaque PgSurface_t, or NULL if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateOffscreenContext(), PdOffscreenContext_t
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PdIsOffscreenLocked(
PdOffscreenContext_t *osc );
Arguments:
osc A pointer to the offscreen context, as returned by PdCreateOffscreenContext(),
that you want to check.
Library:
ph
Description:
This function tests to see if the given offscreen context is currently locked.
This is really only useful for debugging purposes, because the state of the lock could
potentially change between the time that PdIsOffscreenLocked() queries the status and
reports it back to the application.
Returns:
One of:
• Pg_OSC_LOCKED
• Pg_OSC_LOCK_INVALID
• Pg_OSC_NOT_LOCKED
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateOffscreenLock(), PdDestroyOffscreenLock(), PdGetOffscreenContextPtr(),
PdLockOffscreen(), PdUnlockOffscreen()
“Offscreen locks” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PdLockOffscreen( PdOffscreenContext_t *osc,
PdOSCLockParams_t *params );
Arguments:
osc A pointer to the PdOffscreenContext_t structure for the offscreen
context. You must call PdCreateOffscreenLock() to create an offscreen
lock for this context before you call PdLockOffscreen().
Library:
ph
Description:
This function locks an offscreen context.
The PdOSCLockParams_t structure includes these members:
Returns:
EOK The context was succesfully locked.
Pg_OSC_LOCK_TIMED_OUT
Time out for lock occurred; the context wasn’t locked.
Pg_OSC_LOCK_INVALID
The context lock is no longer valid (or never was in the first place i.e. it
wasn’t created with PdCreateOffscreenLock()).
Pg_OSC_LOCK_DEADLOCK
A deadlock condition was detected.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateOffscreenLock(), PdDestroyOffscreenLock(), PdGetOffscreenContextPtr(),
PdIsOffscreenLocked(), PdUnlockOffscreen()
“Offscreen locks” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
See below.
Description:
This data structure describes an offscreen context.
PdOffscreenContext_t includes:
dim A PhDim_t structure that defines the dimensions of the offscreen context.
Classification:
Photon
See also:
PdCreateOffscreenContext(), PdDupOffscreenContext(), PdGetOffscreenContextPtr(),
PdSetOffscreenTranslation(), PgContextBlit(), PgContextBlitArea(),
PgSwapDisplay(), PhDim_t
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PdReleaseDirectContext(
PdDirectContext_t *DirectContext );
Arguments:
DirectContext The pointer to a PdDirectContext_t structure returned by
PdCreateDirectContext(). This argument must not be NULL.
Library:
ph
Description:
This function leaves direct mode (if the application is currently in it), destroys the
direct-mode context, and restores the original default context.
Examples:
See PdCreateDirectContext().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateDirectContext(), PdDirectStart(), PdDirectStop(), PdSetTargetDevice()
“Direct mode” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PdSetOffscreenTranslation(
PdOffscreenContext_t *osc,
PhPoint_t *trans );
Arguments:
osc A pointer to the offscreen context, as returned by
PdCreateOffscreenContext(), whose translation you want to set.
Library:
ph
Description:
This function sets the translation for the offscreen context pointed to by osc to the
value specified by the structure pointed to by trans. This translation is applied to the
points used in graphical operations in the offscreen context.
The translation stays with the offscreen context, not the application. If another
application accesses the offscreen context, the same translation applies.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateOffscreenContext(), PdDupOffscreenContext(), PdGetOffscreenContextPtr(),
PdOffscreenContext_t, PdSetTargetDevice(), PgContextBlit(), PgSwapDisplay(),
PhDCCreate(), PhDCRelease()
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PhRid_t PdSetTargetDevice ( const void *dc,
PhRid_t device_rid );
Arguments:
dc A void pointer to any type of draw context, or NULL for the current
draw context. Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by
PdCreateOffscreenContext()
device_rid The region ID of the device that you want to be the target. To get the
region IDs for the currently available draw devices, call
PdGetDevices().
Library:
ph
Description:
This function sets the device with the given region ID to be the target for
device-specific queries and control operations in the given draw context. By default,
the target is the screen.
You can target the following functions at specific cards:
• PdCreateDirectContext()
• PdCreateOffscreenContext()
• PdDupOffscreenContext()
• PdReleaseDirectContext()
• PgGetGraphicsHWCaps()
• PgGetPalette()
• PgGetVideoMode()
• PgGetVideoModeInfo()
• PgGetVideoModeList()
• PgReadScreen()
• PgReadScreenSize()
• PgSetVideoMode()
• PgWaitDrawComplete()
• PgWaitHWIdle()
Returns:
The region ID of the previously set device, or 0 if no device was set
Success.
-1 An error occurred.
Examples:
See PdCreateDirectContext().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdGetDevices()
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PdUnlockOffscreen( PdOffscreenContext_t *osc );
Arguments:
osc A pointer to the offscreen context, as returned by PdCreateOffscreenContext(),
that you want to unlock.
Library:
ph
Description:
This function unlocks the offscreen context, osc. You can lock the offscreen context
by calling PdLockOffscreen() after calling PdCreateOffscreenLock() to create the lock.
Returns:
EOK The offscreen context was successfully unlocked.
Pg_OSC_ALREADY_UNLOCKED
The context wasn’t locked to begin with (i.e. the semaphore count wasn’t
increased).
Pg_OSC_LOCK_INVALID
The lock is invalid.
Pg_OSC_NOT_LOCKED
The context wasn’t locked.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateOffscreenLock(), PdDestroyOffscreenLock(), PdGetOffscreenContextPtr(),
PdIsOffscreenLocked(), PdLockOffscreen()
“Offscreen locks” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
These functions provide font services to Photon applications and drivers. Using them,
you can:
There are two separate libraries of font functions, the Photon library and the font
library font_api. Functions that have the suffix Cx or Dll are the font library
versions. The font library functions use the font server plugin phfont.so, and let you
choose how your application attaches to the font server. See the Fonts chapter of the
Photon Programmer’s Guide for more information.
Synopsis:
#include <font_api.h>
Arguments:
context A pointer to the font context to use, returned by PfAttachCx() or
PfAttachDllCx().
name A pointer to a location where the function stores the path and name of the
shared memory, if context is not NULL.
size A pointer to a long where the function stores the size, in bytes, of the
render buffer.
Library:
font
Description:
This function retrieves the shared memory path and size of the render buffer associated
with a font context. If the render buffer was allocated from the heap, the function sets
name to NULL.
Returns:
0 Success
Errors:
EFAULT Font context is NULL.
Examples:
See the example for PfAttachDllCx().
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachCx(), PfAttachDllCx()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <font_api.h>
Arguments:
context A pointer to the font context to use, returned by PfAttachCx() or
PfAttachDllCx().
size The size, in bytes, of the render buffer you want to allocate. A value
greater than 0 allocates a shared memory buffer; less than 0 allocates a
heap buffer; -1 allocates a heap buffer using the value from the
PHFONTMEM environment variable.
Library:
font
Description:
This function allocates a render buffer for the provided font context, of the requested
size. If the context already has an allocated render buffer, this function releases it
before it allocates a new one. You must link the font context to a fontdll_t context
using PfAssignDllCx(). Otherwise, an error is returned.
Returns:
0 Success
Errors:
ENOMEM Insufficient resources
ENAMETOOLONG
shm_open() error.
Examples:
#include <font_api.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
static void func(void * ctx, const pf_point_t * pos, const FontRender * render)
{
printf("NOTE : render callback.\n");
if(check_32)
{ int times = render->bpl / 4;
int total = times * 4;
if(total != render->bpl)
bad_32 = 1;
}
if(check_64)
{ int times = render->bpl / 8;
int total = times * 8;
if(total != render->bpl)
bad_64 = 1;
}
}
if(PfAllocRenderCx(pf, -1) == 0)
{ if(PfRenderCx(pf, pf, PfConvertFontIDCx(pf, id, tag), 0L, 0L,
"TEST.", 0, 0, &pos, NULL, func) == 0)
{
if(!skip)
PfDetachCx(pf);
}
else
{ fprintf(stderr, "UNRES : Unable to attach to fontserver, errno %d.\n",
errno);
fprintf(stderr, "FAIL : PfRenderCx(dll) and bitmap alignment.\n");
}
if(PfDetachLocalDll(dll) == -1)
fprintf(stderr, "NOTE : PfDetachLocalDll failed, errno %d.\n", errno);
}
else
{ fprintf(stderr, "UNRES : Unable to load local dll, errno %d.\n", errno);
fprintf(stderr, "FAIL : PfRenderCx(dll) and bitmap alignment.\n");
}
return(0);
}
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachCx(), PfAttachDllCx(), PfAssignDllCx()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <font_api.h>
Arguments:
dll A font server context, returned by PfAttachLocalDll().
Library:
font
Description:
This function assigns the dll to the font context, context.
Returns:
0 Success
Errors:
EFAULT The font context is NULL
Examples:
/* A PtHook example. Initializes a client level font server
* instance for any application that invokes PtInit(), and has
* knowledge of this hook.
*/
#include <font_api.h>
#include <photon/PhProto.h>
#include <stdlib.h>
#include <unistd.h>
{ PfDetachLocalDll(dll);
return(0);
}
else
{ if(access("/dev/fontsleuthctrl", F_OK) == 0)
if(PfAttachSleuthMonitorDll(dll, -1) == -1)
{ PfAssignDllCx(_Ph_->font, NULL);
PfDetachLocalDll(dll);
return(0);
}
if(atexit(cleanup_hook) != 0)
{ PfAssignDllCx(_Ph_->font, NULL);
PfDetachLocalDll(dll);
return(0);
}
}
}
}
else
return(0);
return(1);
}
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachCx(), PfAttachDllCx(), PfAttachLocalDll()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
struct _Pf_ctrl *PfAttach( const char *device,
long size );
#include <font_api.h>
struct _Pf_ctrl* PfAttachCx( const char *device,
long size );
Arguments:
device The prefix name of the server; if this argument is NULL, the prefix is the
value in the PHFONT environment variable, or /dev/phfont if this isn’t
set.
size The size of an area in shared memory to set up between the task and the
server for returning text bitmaps (normally required only by graphics
drivers). The value determines the type of buffer the function creates:
0 no buffer
<0 allocate a heap buffer
-1 allocate a heap buffer using the value from the environment variable
PHFONTMEM
>0 allocate a shared memory buffer
Library:
PfAttach() ph
PfAttachCx() font
Description:
These functions attach to the font server.
PhAttach() calls PfAttach() as part of the standard Photon initialization sequence. The
font library automatically invokes PfAttach() when the library detects that the font
server has been restarted. The font control structure pointer is stored in the global
Photon control structure.
If you simply want to override the default font context, you can set the two
environment variables (PHFONT and PHFONTMEM) to new values before
performing standard Photon initialization, instead of calling this function directly.
If you want to use multiple font contexts, open them with PfAttachCx(), and then use
the Cx versions of the font functions. PfAttachCx() allocates and returns a font
context, and requests a font server connection. You need the font context returned by
PfAttachCx() or PfAttachDllCx() to pass as the first argument to other font library Cx
functions.
To detach from the font server, call the corresponding function PfDetach() or
PfDetachCx().
Returns:
A pointer to an internal control structure if successful; NULL otherwise.
Examples:
PfAttachCx(): See the examples for PfConvertFontIDCx() and PfRenderCx().
Classification:
Photon
PfAttach()
Safety
Interrupt handler No
Signal handler No
Thread No
PfAttachCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachDllCx(), PfAttachLocalDll(), PfDetach(), PfDetachCx(), PfExtentCx(),
PfExtentTextCharPositionsCx(), PfGenerateFontNameCx(), PfGetOutlineCx(),
PfRenderCx()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <font_api.h>
Arguments:
dll An opaque structure that describes a local font server DLL, returned by
PfAttachLocalDll().
size The size of render buffer allocated (the area in memory used by the font server
to return rendered bitmaps). The value determines the type of buffer allocated:
• 0 — no buffer allocated
• >0 — allocate a shared memory buffer
• <0 — allocate a heap buffer
• -1 — allocate a heap buffer using the value from the environment variable
PHFONTMEM
Library:
font
Description:
This routine allocates a font context structure, and connects to the local font server
referred to by dll.
Returns:
Font context Success
NULL Failure
Errors:
ENOMEM Insufficient resources
ENAMETOOLONG
shm_open() error.
Examples:
#include <font_api.h>
#include <stdio.h>
#include <stdlib.h>
PfDetachCx(pf);
}
PfDetachCx(pf);
}
PfDetachLocalDll(dll);
}
return(0);
}
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachLocalDll()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <font_api.h>
Arguments:
options Command-line options for the local font DLL. These commands should
be comma-separated. For example:
-A,-d=/usr/photon/font_repository. This argument may be
NULL if there are no options.
schema The name of a schema, a configuration file used to override the default
settings for a local font server.
Use the DLL_FONT_SERVER schema for processes that need to allocate
sufficient resources to act as a default font server. This schema loads a
local server instance that can be used as an external server by other
applications (that is, it appears in /def/phfont). Use NULL to load a
local server instance that cannot be used by other applications.
The string referenced by schema may not exceed
DLL_MAX_OPTION_NAME bytes, including the terminating NULL.
Library:
font
Description:
This function loads a local font DLL, which eliminates message passing to an external
font server. Options are processed and applied before the server instance is activated.
The options are the same as those supported by the font server, though some options
may not be relevant to a DLL instance of the font server.
Returns:
A fontdll_t context
Success
Errors:
ENOENT Unable to locate font server plugin.
Examples:
/* An example of how to run a root level font server device. */
#include <signal.h>
#include <font_api.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <sys/siginfo.h>
#include <atomic.h>
#include <sys/procmgr.h>
#include <unistd.h>
/*
* Install useful signal handlers.
*/
static int TrapSignals(void)
{ int sig;
}
else
{ int exit = 0;
return(EXIT_SUCCESS);
}
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachServerDll()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <font_api.h>
Arguments:
dll A font server context, returned by PfAttachLocalDll().
prio The suggested priority at which to run the font processing thread. If this
value is set to -1, the function uses the current process priority.
device The /dev device path of the font server to attach to (e.g. /dev/bob).
Library:
font
Description:
This function loads a local font server thread for the provided dll context. The function
attempts to attach a resource manager server thread, which attaches all relevant device
names. This is useful only if no external server is running, and you want this
application to function as the default font server. The application must have an
effective user ID of root in order for this approach to succeed.
Since this behaviour encorporates handling of dynamic font loading, this routine will
return an error if a sleuth thread is already in service. That is, if the application has
already successfully called PfAttachSleuthMonitorDll(), PfAttachServerDll() will fail,
and vice versa.
This routine overwrites the local PHFONT environment variable if the device
parameter is not NULL.
If the resource manager registers the default font server device (which is the same as
the global PHFONT environment variable) successfully, the application should
register a SIGUSR2 signal handler. In some instances of dynamic font loading, the
application is signalled by SIGUSR2 to request a restart of the server thread. The
application should handle the request, then at the next available time, invoke the
function PfRestartServerDll(). Otherwise, the application should block the SIGUSR2
signal if you do not wish it to honor such requests.
If the server thread attaches a device name other than the default specified by the
global PHFONT environment variable, then it is not notified of dynamic font changes
unless directly messaged.
Returns:
0 Success
-1 An error occurred (errno is set).
Examples:
See the example in PfAttachLocalDll().
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachLocalDll(), PfAttachSleuthMonitorDll(), PfRestartServerDll().
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <font_api.h>
Arguments:
dll A font server context, returned by PfAttachLocalDll().
prio The suggested priority at which to run the fontsleuth monitor thread. If
this value is set to -1, the function uses the current process priority. This value
cannot exceed a maximum value — if it does, it is set to an internally defined
maximum.
Library:
font
Description:
The fontsleuth utility is deprecated, so this function always returns -1 and errno is
set to ENOSYS.
Returns:
-1 An error occurred (errno is set).
Examples:
See the example for PfAssignDllCx().
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachLocalDll().
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
char *PfConvertFontID( FontID *ptsID );
#include <font_api.h>
char* PfConvertFontIDCx( struct _Pf_ctrl * context,
FontID * ptsID,
char * szTag );
Arguments:
context (PfConvertFontIDCx() only) A pointer to the font context to use, returned
by PfAttachCx() or PfAttachDllCx().
Library:
PfConvertFontID()
ph
PfConvertFontIDCx()
font
Description:
These functions convert the font ID pointed to by ptsID into a font name. This
function can be used for backwards compatibility with the older font API.
These functions don’t check to see if ptsID is NULL, due to the way this routine is
used.
Returns:
A version of the font identifier that the older font API can understand.
Examples:
PfConvertFontID(): See PfFindFont().
PfConvertFontIDCx():
else
{ fprintf(stderr, "NOTE : PfFindFontCx failed to create font id, errno %d.\n",
errno);
fprintf(stderr, "FAIL : FontID.\n");
}
PfDetachCx(pf);
}
else
{ fprintf(stderr, "UNRES : Unable to attach to fontserver, errno %d.\n", errno);
fprintf(stderr, "FAIL : FontID.\n");
}
return(0);
}
Classification:
Photon
PfConvertFontID()
Safety
Interrupt handler No
Signal handler No
Thread No
PfConvertFontIDCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttach(), PfAttachCx(), PfAttachDllCx(), PfDecomposeStemToID(),
PfDecomposeStemToIDCx(), PfFindFont(), PfFindFontCx(), PfFontDescription(),
PfFontDescriptionCx(), PfFontFlags(), PfFontFlagsCx(), PfFontSize(),
PfFontSizeCx(), PfFreeFont(), PfFreeFontCx(), PfGenerateFontName(),
PfGenerateFontNameCx()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <font_api.h>
FontID*
PfConvertPixelsToPointSizeCx( struct _Pf_ctrl * context,
char const * description,
int flags,
uint32_t pixel_height );
Arguments:
context A pointer to the font context to use, returned by PfAttachCx() or
PfAttachDllCx().
flags Flags that identify the requested font type. The following can be
ORed together:
• PF_STYLE_BOLD
• PF_STYLE_ITALIC
• PF_STYLE_ANTIALIAS
• PF_STYLE_ULINE
• PF_STYLE_DULINE
pixel_height The height in pixels that the ascender and descender of the resultant
font must fit within.
Library:
font
Description:
This function locates a point size for the provided foundry face (description) that has
an ascender and descender that fit within the provided pixel height. If the provided
foundry face represents a bitmap font, then the ID for the closest point size available
that fits within the pixel height is returned. You must release the returned FontID.
Returns:
A FontID Success
Errors:
ESRCH Unable to match a point size to the provided pixel height.
Examples:
#include <font_api.h>
#include <stdio.h>
#define PIXEL_HEIGHT 33
PfUnloadMetricsCx(pf, font);
}
}
PfDetachCx(pf);
}
return(0);
}
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachCx(), PfAttachDllCx().
Fonts chapter of the Photon Programmer’s Guide
#include <font_api.h>
FontID* PfDecomposeStemToIDCx(
struct _Pf_ctrl * context,
char const * pkszStem );
Arguments:
context (PfDecomposeStemToIDCx() only) A pointer to the font context to use,
returned by PfAttachCx() or PfAttachDllCx().
Library:
PfDecomposeStemToID()
ph
PfDecomposeStemToIDCx()
font
Description:
These functions convert a complete font stem, such as helv12b, to a FontID
representation. They parse pkszStem and query the font manager or server for the
information pertinent to the font.
You’re responsible for releasing the resources associated with the returned FontID
structure. To do this, call the corresponding free font function, either PfFreeFont() or
PfFreeFontCx().
Returns:
A pointer to a FontID, or NULL on failure.
Examples:
PfDecomposeStemToIDCx(): See the example for PfGetGlyphIndexCx().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
PfDecomposeStemToIDCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfConvertFontID(), PfConvertFontIDCx(), PfFindFont(), PfFindFontCx(),
PfFontDescription(), PfFontDescriptionCx(), PfFontFlags(), PfFontFlagsCx(),
PfFontSize(), PfFontSizeCx(), PfFreeFont(), PfFreeFontCx()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
_Pf_ctrl PfDefaultContext ( void );
Library:
ph
Description:
This function returns the default font context.
Returns:
A _Pf_ctrl structure.
Examples:
See the example for PfGetGlyphIndexCx().
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachDllCx(), PfAttachLocalDll(), PfDetachCx()
Synopsis:
#include <photon/Pf.h>
void PfDetach( struct _Pf_ctrl *pf );
#include <font_api.h>
void PfDetachCx( struct _Pf_ctrl * pf );
Arguments:
pf A control structure. For PfDetach(), this structure was returned by a previous
call to PfAttach(). For PfDetachCx(), this structure was returned by a previous
call to PfAttachCx() or PfAttachDllCx().
Library:
PfDetach() ph
PfDetachCx() font
Description:
These functions detach the task from the font server and release all the memory that
the font context uses, including any shared memory and local metrics code. If your
application has attached to a local font DLL (using PfAttachLocalDll()), it must also
call PfDetachLocalDll().
Examples:
PfDetachCx(): See the examples for PfConvertFontIDCx() and PfRenderCx().
Classification:
Photon
PfDetach()
Safety
Interrupt handler No
Signal handler No
Thread No
PfDetachCx()
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread Yes
See also:
PfAttach(), PfAttachCx(), PfAttachDllCx(), PfExtentCx(),
PfExtentTextCharPositionsCx(), PfGetOutlineCx(), PfRenderCx()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <font_api.h>
int PfDetachLocalDll( fontdll_t dll );
Arguments:
dll The local server context, returned by PfAttachLocalDll()
Library:
font
Description:
This function unloads a local font server dll. All resources associated with the
provided fontdll_t context are deallocated. If a server thread is active, it will also
terminate. If a fontsleuth thread is active, it will also terminate.
Returns:
0 Success
Errors:
EFAULT Font dll context is NULL.
Examples:
See the examples for PfAttachLocalDll() and PfAssignDllCx().
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachLocalDll().
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <font_api.h>
long PfDynamicFontIDCx( struct _Pf_ctrl * context,
char const * path );
Arguments:
context A pointer to the font context to use, returned by PfAttachCx() or
PfAttachDllCx().
path The full path and font name for the font file from which to locate the
dynamic ID.
Library:
font
Description:
This function retrieves the assigned dynamic load ID for the given font file, if it has
been loaded by PfDynamicLoadCx().
Returns:
A dynamic font ID
Success
-1 Failure
Errors:
EFAULT Font context or path is NULL.
Examples:
See the example for PfDynamicLoadCx().
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachCx(), PfAttachDllCx(), PfDynamicLoadCx().
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
long PfDynamicLoad( char const *pkcFontFile,
char *pszDescription );
#include <photon/Pf.h>
long PfDynamicLoadCx( struct _Pf_ctrl * context,
char const * pkcFontFile,
FontDescription pszDescription );
Arguments:
context (PfDynamicLoadCx() only) A pointer to the font context to use,
returned by PfAttachCx() or PfAttachDllCx().
pkcFontFile The full pathname of the font file that you want to load.
Library:
PfDynamicLoad() ph
PfDynamicLoadCx()
font
Description:
These functions request that the font manager dynamically install a font file. The font
can be stored in any location. For example, a web server might need to dynamically
load fonts embedded in HTML stored in its own temporary font directory.
If pkcFontFile is NULL, these functions set errno to EFAULT and return -1L.
If these functions successfully load the font, they fill the pszDescription array with the
descriptive name of the loaded font, e.g. Comic Sans MS. If a scalable “collection”
is encountered, only the first description found is returned. You can use this
description to verify that the font contains what you think it does. If pszDescription is
NULL, the parameter is ignored.
Returns:
A nonnegative dynamic font ID that can be used to refer to the file when calling
PfDynamicUnload(), or -1L if an error occurred (errno is set).
Errors:
EBUSY There are too many dynamic fonts already loaded.
EEXIST The file that was attempted to be loaded was either already dynamically
loaded, or statically installed.
Examples:
PfDynamicLoadCx():
#include <font_api.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
if(id != id2)
{ fprintf(stderr,
"NOTE : Retrieved id is not the same as loaded id, \
file : %s.\n", fullpath);
fprintf(stderr, "FAIL : PfDynamicLoadCx.\n");
exit(EXIT_FAILURE);
}
}
PfDetachCx(pf);
fprintf(stderr, "PASS : PfDynamicLoadCx.\n");
}
else
{ fprintf(stderr, "UNRES : Unable to attach to fontserver, errno %d.\n",
errno);
fprintf(stderr, "FAIL : PfDynamicLoadCx.\n");
}
}
else
{ fprintf(stderr, "UNRES : Unable to load dll font instance, errno %d.\n",
errno);
fprintf(stderr, "FAIL : PfDynamicLoadCx.\n");
}
return(0);
}
PfDynamicLoad():
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
#include <Ph.h>
#include <Pt.h>
#define FALSE 0
#define TRUE !FALSE
PtInit (NULL);
nArgs = 0;
pntDIM.x = 100;
pntDIM.y = 20;
PtSetArg(&args[0], Pt_ARG_DIM, &pntDIM, 0L);
nArgs++;
pntPOS.x = 100;
pntPOS.y = 10;
PtSetArg(&args[1], Pt_ARG_POS, &pntPOS, 0L);
nArgs++;
PtSetArg(&args[2], Pt_ARG_TEXT_STRING, (long)"LOAD", 0L);
nArgs++;
PtSetArg(&args[3], Pt_ARG_TEXT_FONT,
(long)PfGenerateFontName("TextFont", 0, 9,
szTextFont),
0L);
nArgs++;
pbtnLoad = PtCreateWidget(PtButton, pwndMain, nArgs, args);
PtAddCallback(pbtnLoad, Pt_CB_ACTIVATE, fnLoad, argv[1]);
PtRealizeWidget(pbtnLoad);
nArgs = 0;
pntDIM.x = 100;
pntDIM.y = 20;
PtSetArg(&args[0], Pt_ARG_DIM, &pntDIM, 0L);
nArgs++;
pntPOS.x = 100;
pntPOS.y = 50;
PtSetArg(&args[1], Pt_ARG_POS, &pntPOS, 0L);
nArgs++;
PtSetArg(&args[2], Pt_ARG_TEXT_STRING, (long)"UNLOAD", 0L);
nArgs++;
PtSetArg(&args[3], Pt_ARG_TEXT_FONT, (long)szTextFont,
0L);
nArgs++;
pbtnUnload = PtCreateWidget(PtButton, pwndMain, nArgs,
args);
PtAddCallback(pbtnUnload, Pt_CB_ACTIVATE, fnUnload, NULL);
PtRealizeWidget(pbtnUnload);
nArgs = 0;
pntDIM.x = 100;
pntDIM.y = 20;
PtSetArg(&args[0], Pt_ARG_DIM, &pntDIM, 0L);
nArgs++;
pntPOS.x = 100;
pntPOS.y = 90;
PtSetArg(&args[1], Pt_ARG_POS, &pntPOS, 0L);
nArgs++;
PtSetArg(&args[2], Pt_ARG_TEXT_STRING, (long)"Hello", 0L);
nArgs++;
PtSetArg(&args[3], Pt_ARG_TEXT_FONT, (long)szTextFont,
0L);
nArgs++;
ptxtDisplay = PtCreateWidget(PtText, pwndMain, nArgs, args);
(void) PtRealizeWidget(pwndMain);
pcFace = argv[2];
PtMainLoop ();
return(EXIT_SUCCESS);
}
return(Pt_CONTINUE);
}
return(Pt_CONTINUE);
}
int fnChangeDisplay(void)
{ PtArg_t tsArg;
char szTextFont12[MAX_FONT_TAG];
return(Pt_CONTINUE);
}
Classification:
Photon
PfDynamicLoad()
Safety
Interrupt handler No
Signal handler No
Thread No
PfDynamicLoadCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfDynamicUnload(), PfDynamicUnloadCx()
Fonts chapter of the Photon Programmer’s Guide
#include <font_api.h>
long PfDynamicUnloadCx( struct _Pf_ctrl * context,
long lDynamicFontID );
Arguments:
context (PfDynamicUnloadCx() only) A pointer to the font context to
use, returned by PfAttachCx() or PfAttachDllCx().
lDynamicFontID The font ID, returned by PfDynamicLoad(), of the font that you
want to unload.
Library:
PfDynamicUnload()
ph
PfDynamicUnloadCx()
font
Description:
This function unloads a dynamically loaded font.
Returns:
0L on success, or -1L if an error occurred (errno is set).
Errors:
PfDynamicUnload():
ESRCH The function couldn’t locate the given dynamic font ID or font file
entry.
EBADF An error occurred when attempting to close and remove the font file
from the affected library.
ENOMEM Not enough memory was available to proceed with the unload.
PfDynamicUnloadCx():
Examples:
PfDynamicUnload(): See PfDynamicLoad().
PfDynamicUnloadCx(): See the example for PfDynamicLoadCx().
Classification:
Photon
PfDynamicUnload()
Safety
Interrupt handler No
Signal handler No
Thread No
PfDynamicUnloadCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfDynamicLoad(), PfDynamicLoadCx()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
int PfExtent( PhRect_t *extent,
PhPoint_t const *pos,
const char *font,
long adata,
long bdata,
const char *str,
int len,
int flags,
PhRect_t const *clip );
Arguments:
extent A pointer to a PhRect_t structure where the function stores the calculated
extent. The members are:
The baseline of the font is at position y=0; the width of the string is:
lr.x - min(ul.x, 0) + 1
font The base font, which you should create by calling PfGenerateFontName().
adata The horizontal fractional point size, if you set PF_FRACTIONAL in the flags
argument.
bdata The vertical fractional point size, if you set PF_FRACTIONAL in the flags
argument.
str The string whose extent you want to calculate. The string is a UTF-8
multibyte one by default.
len The length of the string, str, in bytes. If len is 0, the function uses
strlen(str).
flags Flags that affect the behavior of the function. You can set up to one of the
following to indicate the format of the string:
Although this flag allows for 32-bit wide characters, the underlying font system
currently supports only characters up to Unicode U+FFFE.
If you don’t set either of the above, the function assumes that the string is
composed of UTF-8 multibyte characters.
You can OR in any of these flags:
• PF_FRACTIONAL — use a fractional 16.16 point size. If you set this
flag, use the adata argument to specify the horizontal fractional point
size, and bdata to specify the vertical fractional point size.
• PF_RECT — make the function behave like PfExtentTextToRect(). If you
set this flag, use the clip argument to specify the rectangle to extent
within. If successful, the function returns the number of characters that
fit within the rectangle.
Library:
PfExtent() ph
Description:
This function calculates the extent rectangle of a text string. The base font determines
the ascender and descender values of the extent. The width depends on the string; the
actual font used by characters within the string may differ from this base font (as
specified in the fontext and fontmap files).
The difference between PfExtent() and PfExtentCx() is that PfExtentCx() lets you
specify the font context to use.
If metrics for the base font have been loaded locally (see PfLoadMetrics()), the extent
is calculated internally; otherwise, a request is sent to the font server.
The generic design of these routines allows for future expansion.
Returns:
If you set PF_RECT in the flags argument, PfExtent() and PfExtentCx() return the
number of characters that fit within the rectangle specified by clip, or -1 if an error
occurred.
If you don’t set PF_RECT in the flags argument, these functions return 0 on success, or
-1 if an error occurred.
Examples:
PfExtentCx():
/* This example demonstrates a straight forward method of
* using fractional processing to fit text within a given
* canvas size, without using floating point. Fractional
* processing is performed using a 16.16 integer format, for
* example, 1 point size is represented as 1 << 16. Therefore,
* 0.1 of a point size would be (1 << 16) / 10. This example
* could be further enhanced by using 0.1 of a point size to
* further fine tune the fitting of text within the canvas size.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <Ph.h>
#include <Pt.h>
#include <errno.h>
#include <photon/PxImage.h>
#define NUM_LINES 4
win_size.w = 450;
win_size.h = 450;
nArgs = 0;
PtSetArg(&tsArg[nArgs++],Pt_ARG_DIM, &win_size, 0L);
PtSetArg(&tsArg[nArgs++],Pt_ARG_WINDOW_TITLE, "fractional", 0L);
PtWidget_t * raw;
PtExtentWidget(wnd);
PtCalcCanvas(wnd, &canvas);
nArgs = 0;
dim.w = canvas.lr.x - canvas.ul.x;
dim.h = canvas.lr.y - canvas.ul.y;
PtSetArg(&tsArg[nArgs++], Pt_ARG_DIM, &dim, 0L);
PtSetArg(&tsArg[nArgs++], Pt_ARG_RAW_DRAW_F, raw_draw, 0L);
PtSetArg(&tsArg[nArgs++], Pt_ARG_FILL_COLOR, Pg_WHITE, 0L);
flags = Pt_RIGHT_ANCHORED_RIGHT | Pt_LEFT_ANCHORED_LEFT
| Pt_TOP_ANCHORED_TOP | Pt_BOTTOM_ANCHORED_BOTTOM;
PtSetArg(&tsArg[nArgs++], Pt_ARG_ANCHOR_FLAGS, flags, flags);
PtSetArg(&tsArg[nArgs++], Pt_ARG_POINTER, pf, 0L);
PtSetArg(&tsArg[nArgs++], Pt_ARG_USER_DATA, &font, sizeof(font));
return(0);
}
PgSetFont(font);
old1 = PgSetTextColor(Pg_BLACK);
old2 = PgSetFillColor(Pg_WHITE);
do
{ pf_rect_t extent;
int xsize;
int ysize;
int xtoggle;
int ytoggle;
do
{
if(PfExtentCx(pf, &extent, NULL, font, xsize, ysize, text[i],
strlen(text[i]), PF_FRACTIONAL, NULL) == 0)
{ int ok_w = 0, ok_h = 0, diff;
xtoggle++;
ytoggle++;
i++;
}
while(i < NUM_LINES);
PgSetTextColor(old1);
PgSetFillColor(old2);
PtClipRemove();
return;
}
tsImage.image = render->bmptr;
tsImage.palette = palette;
tsImage.colors = 2;
if(render->bpp == 1)
{ tsImage.palette = NULL;
tsImage.type = Pg_BITMAP_BACKFILL;
}
else if(render->bpp == 4)
{ palette[0] = Pg_WHITE;
palette[1] = Pg_BLACK;
tsImage.type = Pg_IMAGE_GRADIENT_NIBBLE;
}
else if(render->bpp == 8)
{ if(render->flags & FONTRENDER_RGB_PIXMAP)
{ tsImage.palette = NULL;
tsImage.type = Pg_IMAGE_DIRECT_888;
}
else
{ palette[0] = Pg_WHITE;
palette[1] = Pg_BLACK;
tsImage.type = Pg_IMAGE_GRADIENT_BYTE;
}
}
PgFFlush(1);
return;
}
Classification:
Photon
PfExtent()
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfAttach(), PfAttachCx(), PfDetach(), PfDetachCx(), PfExtentComponents(),
PfExtentComponentsCx(), PfExtentFractTextCharPositions(), PfExtentText(),
PfExtentTextCharPositions(), PfExtentTextCharPositionsCx(), PfExtentTextToRect(),
PfExtentWideText(), PfFractionalExtentText(), PfGenerateFontName(),
PfGenerateFontNameCx(), PfLoadMetrics(), PfLoadMetricsCx(), PhPoint_t,
PhRect_t
Synopsis:
#include <font_api.h>
Arguments:
context A pointer to the font context to use, returned by PfAttachCx() or
PfAttachDllCx().
The baseline of the font is at position y=0; the width of the string is:
lr.x - min(ul.x, 0) + 1
lr.y - ul.y + 1
font The base font, which you should create by calling PfGenerateFontName().
adata The horizontal fractional point size, if you set PF_FRACTIONAL in the
flags argument.
bdata The vertical fractional point size, if you set PF_FRACTIONAL in the flags
argument.
str The string whose extent you want to calculate. The string is a UTF-8
multibyte one by default.
len The length of the string, str, in bytes. If len is 0, the function uses
strlen(str).
flags Flags that affect the behavior of the function. You can set up to one of the
following to indicate the format of the string:
• PF_WIDE_CHARS — the string is composed of 16-bit wide characters.
If you set this flag, the function assumes that each character is
represented by 2 bytes that conform to the ISO/IEC 10646-1 UCS-2
double-byte format.
• PF_WIDE_CHAR32 — the string is composed of 32-bit wide
characters. If you set this flag, the function assumes that each character
is represented by 4 bytes that conform to the ISO/IEC 10646-1 UCS-4
four-byte format.
Although this flag allows for 32-bit wide characters, the underlying font system
currently supports only characters up to Unicode U+FFFE.
If you don’t set either of the above, the function assumes that the string is
composed of UTF-8 multibyte characters.
You can OR in any of these flags:
• PF_FRACTIONAL — use a fractional 16.16 point size. If you set this
flag, use the adata argument to specify the horizontal fractional point
size, and bdata to specify the vertical fractional point size.
• PF_RECT — make the function behave like PfExtentTextToRect(). If
you set this flag, use the clip argument to specify the rectangle to extent
within. If successful, the function returns the number of characters that
fit within the rectangle.
Library:
PfExtentCx() font
Description:
This function calculates the extent rectangle of a text string given a font context. The
base font determines the ascender and descender values of the extent. The width
depends on the string; the actual font used by characters within the string may differ
from this base font (as specified in the fontext and fontmap files).
If metrics for the base font have been loaded locally (see PfLoadMetrics()), the extent
is calculated internally; otherwise, a request is sent to the font server.
The generic design of this routine allows for future expansion.
Returns:
If you set PF_RECT in the flags argument, PfExtent() and PfExtentCx() return the
number of characters that fit within the rectangle specified by clip, or -1 if an error
occurred.
If you don’t set PF_RECT in the flags argument, these functions return 0 on success, or
-1 if an error occurred.
Examples:
PfExtentCx():
/* This example demonstrates a straight forward method of
* using fractional processing to fit text within a given
* canvas size, without using floating point. Fractional
* processing is performed using a 16.16 integer format, for
* example, 1 point size is represented as 1 << 16. Therefore,
* 0.1 of a point size would be (1 << 16) / 10. This example
* could be further enhanced by using 0.1 of a point size to
* further fine tune the fitting of text within the canvas size.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <Ph.h>
#include <Pt.h>
#include <errno.h>
#include <photon/PxImage.h>
#define NUM_LINES 4
win_size.w = 450;
win_size.h = 450;
nArgs = 0;
PtSetArg(&tsArg[nArgs++],Pt_ARG_DIM, &win_size, 0L);
PtSetArg(&tsArg[nArgs++],Pt_ARG_WINDOW_TITLE, "fractional", 0L);
PtWidget_t * raw;
PtExtentWidget(wnd);
PtCalcCanvas(wnd, &canvas);
nArgs = 0;
dim.w = canvas.lr.x - canvas.ul.x;
dim.h = canvas.lr.y - canvas.ul.y;
PtSetArg(&tsArg[nArgs++], Pt_ARG_DIM, &dim, 0L);
PtSetArg(&tsArg[nArgs++], Pt_ARG_RAW_DRAW_F, raw_draw, 0L);
PtSetArg(&tsArg[nArgs++], Pt_ARG_FILL_COLOR, Pg_WHITE, 0L);
flags = Pt_RIGHT_ANCHORED_RIGHT | Pt_LEFT_ANCHORED_LEFT
| Pt_TOP_ANCHORED_TOP | Pt_BOTTOM_ANCHORED_BOTTOM;
PtSetArg(&tsArg[nArgs++], Pt_ARG_ANCHOR_FLAGS, flags, flags);
PtSetArg(&tsArg[nArgs++], Pt_ARG_POINTER, pf, 0L);
PtSetArg(&tsArg[nArgs++], Pt_ARG_USER_DATA, &font, sizeof(font));
return(0);
}
PgSetFont(font);
old1 = PgSetTextColor(Pg_BLACK);
old2 = PgSetFillColor(Pg_WHITE);
do
{ pf_rect_t extent;
int xsize;
int ysize;
int xtoggle;
int ytoggle;
do
{
if(PfExtentCx(pf, &extent, NULL, font, xsize, ysize, text[i],
strlen(text[i]), PF_FRACTIONAL, NULL) == 0)
{ int ok_w = 0, ok_h = 0, diff;
xtoggle++;
ytoggle++;
i++;
}
while(i < NUM_LINES);
PgSetTextColor(old1);
PgSetFillColor(old2);
PtClipRemove();
return;
}
tsImage.image = render->bmptr;
tsImage.palette = palette;
tsImage.colors = 2;
if(render->bpp == 1)
{ tsImage.palette = NULL;
tsImage.type = Pg_BITMAP_BACKFILL;
}
else if(render->bpp == 4)
{ palette[0] = Pg_WHITE;
palette[1] = Pg_BLACK;
tsImage.type = Pg_IMAGE_GRADIENT_NIBBLE;
}
else if(render->bpp == 8)
{ if(render->flags & FONTRENDER_RGB_PIXMAP)
{ tsImage.palette = NULL;
tsImage.type = Pg_IMAGE_DIRECT_888;
}
else
{ palette[0] = Pg_WHITE;
palette[1] = Pg_BLACK;
tsImage.type = Pg_IMAGE_GRADIENT_BYTE;
}
}
PgFFlush(1);
return;
}
Classification:
Photon
PfExtentCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttach(), PfAttachCx(), PfDetach(), PfDetachCx(), PfExtentComponents(),
PfExtentComponentsCx(), PfExtentFractTextCharPositions(), PfExtentText(),
PfExtentTextCharPositions(), PfExtentTextCharPositionsCx(), PfExtentTextToRect(),
PfExtentWideText(), PfFractionalExtentText(), PfGenerateFontName(),
PfGenerateFontNameCx(), PfLoadMetrics(), PfLoadMetricsCx(), PhPoint_t,
PhRect_t
Synopsis:
#include <photon/Pf.h>
Arguments:
extent A pointer to a PhRect16dot16_t structure where the function stores the
calculated 16.16 fixed point extent. The members are:
font The base font, which you should create by calling PfGenerateFontName().
adata The horizontal fractional point size, if you set PF_FRACTIONAL in the flags
argument.
bdata The vertical fractional point size, if you set PF_FRACTIONAL in the flags
argument.
str The string whose extent you want to calculate. The string is UTF-8
multibyte by default.
len The length of the string, str, in bytes. If len is 0, the function uses
strlen(str).
flags Flags that affect the behavior of the function. You can set up to one of the
following to indicate the format of the string:
• PF_WIDE_CHARS — the string is composed of 16-bit wide characters.
If you set this flag, the function assumes that each character is
represented by 2 bytes that conform to the ISO/IEC 10646-1 UCS-2
double-byte format.
Although this flag allows for 32-bit wide characters, the underlying font system
currently supports only characters up to Unicode U+FFFE.
If you don’t set either of the above, the function assumes that the string is
composed of UTF-8 multibyte characters.
You can OR in any of these flags:
• PF_FRACTIONAL — use a fractional 16.16 point size. If you set this
flag, use the adata argument to specify the horizontal fractional point
size, and bdata to specify the vertical fractional point size.
• PF_RECT — make the function behave like PfExtentTextToRect(). If you
set this flag, use the clip argument to specify the rectangle to extent
within. If successful, the function returns the number of characters that
fit within the rectangle.
clip A pointer to a PhRect_t structure that’s a suggested clipping rectangle for
the font manager to abide by.
Library:
PfExtent16dot16()
ph
Description:
This function calculates the 16.16 fixed point extent rectangle of a text string. The
16.16 fixed point return value describes the extent with much greater accuracy than the
extent pixel values. The base font determines the ascender and descender values of the
extent. The width depends on the string; the actual font used by characters within the
string may differ from this base font (as specified in the fontext and fontmap files).
The difference between PfExtent16dot16() and PfExtent16dot16Cx() is that
PfExtent16dot16Cx() lets you specify the font context to use.
The PfExtent16dot16() and PfExtent16dot16Cx() functions never load metrics locally.
A message is always sent to the server.
The generic design of this routine allows for future expansion.
Returns:
If you set PF_RECT in the flags argument, PfExtent16dot16() and
PfExtent16dot16Cx() return the number of characters that fit within the rectangle
specified by clip, or -1 if an error occurred.
If you don’t set PF_RECT in the flags argument, these functions return 0 on success, or
-1 if an error occurred.
Classification:
Photon
PfExtent16dot16()
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfAttach(), PfAttachCx(), PfDetach(), PfDetachCx(), PfExtentComponents(),
PfExtentComponentsCx(), PfExtentFractTextCharPositions(), PfExtentText(),
PfExtentTextCharPositions(), PfExtentTextCharPositionsCx(), PfExtentTextToRect(),
PfExtentWideText(), PfFractionalExtentText(), PfGenerateFontName(),
PfGenerateFontNameCx(), PfLoadMetrics(), PfLoadMetricsCx(), PhPoint_t,
PhRect_t
Synopsis:
#include <font_api.h>
int PfExtent16dot16Cx( struct _Pf_ctrl *context,
pf_rect_16dot16_t *extent,
pf_point_16dot16_t const *pos,
const char *font,
long adata,
long bdata,
const char *str,
int len,
int flags,
pf_rect_t const *clip );
Arguments:
context A pointer to the font context to use, returned by PfAttachCx() or
PfAttachDllCx().
font The base font, which you should create by calling PfGenerateFontName().
adata The horizontal fractional point size, if you set PF_FRACTIONAL in the
flags argument.
bdata The vertical fractional point size, if you set PF_FRACTIONAL in the flags
argument.
str The string whose extent you want to calculate. The string is a UTF-8
multibyte one by default.
len The length of the string, str, in bytes. If len is 0, the function uses
strlen(str).
flags Flags that affect the behavior of the function. You can set up to one of the
following to indicate the format of the string:
• PF_WIDE_CHARS — the string is composed of 16-bit wide characters.
If you set this flag, the function assumes that each character is
represented by 2 bytes that conform to the ISO/IEC 10646-1 UCS-2
double-byte format.
Although this flag allows for 32-bit wide characters, the underlying font system
currently supports only characters up to Unicode U+FFFE.
If you don’t set either of the above, the function assumes that the string is
composed of UTF-8 multibyte characters.
You can OR in any of these flags:
• PF_FRACTIONAL — use a fractional 16.16 point size. If you set this
flag, use the adata argument to specify the horizontal fractional point
size, and bdata to specify the vertical fractional point size.
• PF_RECT — make the function behave like PfExtentTextToRect(). If
you set this flag, use the clip argument to specify the rectangle to extent
within. If successful, the function returns the number of characters that
fit within the rectangle.
clip A pointer to a pf_rect_t structure that’s a suggested clipping rectangle
for the font manager to abide by.
Library:
PfExtentCx() font
Description:
This function calculates the 16.16 fixed point extent rectangle of a text string. The
16.16 fixed point return value describes the extent with much greater accuracy than the
extent pixel values. The base font determines the ascender and descender values of the
extent. The width depends on the string; the actual font used by characters within the
string may differ from this base font (as specified in the fontext and fontmap files).
The difference between PfExtent16dot16() and PfExtent16dot16Cx() is that
PfExtent16dot16Cx() lets you specify the font context to use.
The PfExtent16dot16() and PfExtent16dot16Cx() functions never load metrics locally.
A message is always sent to the server.
The generic design of this routine allows for future expansion.
Returns:
If you set PF_RECT in the flags argument, PfExtent16dot16() and
PfExtent16dot16Cx() return the number of characters that fit within the rectangle
specified by clip, or -1 if an error occurred.
If you don’t set PF_RECT in the flags argument, these functions return 0 on success, or
-1 if an error occurred.
Classification:
Photon
PfExtent16dot16Cx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttach(), PfAttachCx(), PfDetach(), PfDetachCx(), PfExtentComponents(),
PfExtentComponentsCx(), PfExtentFractTextCharPositions(), PfExtentText(),
PfExtentTextCharPositions(), PfExtentTextCharPositionsCx(), PfExtentTextToRect(),
PfExtentWideText(), PfFractionalExtentText(), PfGenerateFontName(),
PfGenerateFontNameCx(), PfLoadMetrics(), PfLoadMetricsCx(), PhPoint_t,
PhRect_t
#include <font_api.h>
pf_rect_t* PfExtentComponentsCx(
struct _Pf_ctrl *context,
pf_rect_t *extent,
pf_point_t const *pos,
const char *font,
const char *string,
int len,
void(*func)
(pf_rect_t const *,
const char *,
const char *,
int) );
Arguments:
context (PfExtentComponentsCx() only) A pointer to the font context to use,
returned by PfAttachCx() or PfAttachDllCx().
extent A pointer to a PhRect_t structure where the function stores the string’s
extent. For the interpretation of the members of this structure, see
PfExtentText().
font The base font to use when calculating the extent. You should create this
argument by calling PfGenerateFontName() or PfGenerateFontNameCx().
str The UTF-8 multibyte string whose extent you want to determine.
len The number of bytes in the string. If len is 0, the function assumes that it’s
strlen(str).
func A function that you want to call for each component of the string.
The callback function is passed an extent rectangle, the filename of the
font required, and the string and length of the character run.
Library:
PfExtentComponents()
ph
PfExtentComponentsCx()
font
Description:
These functions calculate the extent of a text string as per PfExtentText(), and also
invoke 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 phrelay (see the QNX Neutrino Utilities Reference) to
determine which font files have to be downloaded to the remote system in order to
correctly render a string.
Classification:
Photon
PfExtentComponents()
Safety
Interrupt handler No
Signal handler No
Thread No
PfExtentComponentsCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfExtent(), PfExtentCx(), PfExtentText(), PfExtentTextToRect(),
PfGenerateFontName(), PfGenerateFontNameCx(), PhPoint_t, PhRect_t
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
int PfExtentFractTextCharPositions(
PhRect_t * ptsExtent,
PhPoint_t * ptsPos,
char * psz,
const char * pckFont,
int32_t * piIndices,
int32_t * piPenPositions,
int32_t iArrayLen,
uint32_t ulFlags,
int32_t iBytes,
uint32_t uiExtentLen,
PhRect_t const * pktsClip,
uint32_t uiXscale,
uint32_t uiYscale );
Arguments:
ptsExtent A pointer to a PhRect_t structure that’s used to store the
extent of the string.
ulFlags A 32-bit value used for flags. Values that can be ORed in are:
This function assumes each character is represented by 2 bytes that conform to the
ISO/IEC 10646-1 UCS-2 double-byte format.
If this bit isn’t set, the bearing x value of the next symbols
are applied to the pen x positions. This is useful when
drawing symbols individually, where you need to know
where to place the x origin of each symbol:
Library:
ph
Description:
PfExtentFractTextCharPositions() lets you obtain the pen’s x position after every index
specified in the function call. It’s similar to PfExtentTextCharPositions(), except that
fractional scaling is applied.
Returns:
0 Success.
-1 An error occurred; errno is set.
Errors:
ERANGE The font manager couldn’t fulfill the request; one of the following is
true:
• The iArrayLen argument is larger than strlen(psz).
• If index 0 is requested, then iArrayLen is larger than strlen(psz) + 1.
• The iArrayLen argument is less than or equal to 0.
• An index in piIndices references a character greater than strlen(psz).
EINVAL The font is fixed-width, and an error occurred when trying to retrieve the
common width of all characters in that particular font.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfExtent(), PfExtentCx(), PfExtentText(), PfExtentTextCharPositions(),
PfExtentTextCharPositionsCx(), PfExtentTextToRect(), PfFractionalExtentText(),
PfGenerateFontName(), PhPoint_t, PhRect_t
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
Arguments:
extent A pointer to a PhRect_t structure where the function stores the string’s
extent. For the interpretation of the members of this structure, see below.
pos NULL, or a pointer to a PhPoint_t structure that defines an offset that you
want to apply to the extent.
font The base font to use when calculating the extent. You should create this
argument by calling PfGenerateFontName().
str The UTF-8 multibyte string whose extent you want to determine.
len The number of bytes in the string. If len is 0, PfExtentText() assumes that
it’s strlen(str).
Library:
ph
Description:
This function calculates the extent rectangle of a text string. The base font determines
the ascender and 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).
PfExtentText() stores the text extent in the PhRect_t that extent points to. The
members are used as follows:
The baseline of the font is at position y=0; the width of the string is lr.x - min(ul.x, 0) +
1. The height of the string is lr.y - ul.y + 1.
The resulting extent is offset by the point passed in the PhPoint_t structure pointed
to by pos. If pos 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:
PfExtent(), PfExtentCx(), PfExtentTextToRect(), PfExtentWideText(),
PfFractionalExtentText(), PfGenerateFontName(), PfLoadMetrics(), PgExtentText(),
PhPoint_t, PhRect_t
Fonts chapter of the Photon Programmer’s Guide
#include <photon/Pf.h>
int PfExtentTextCharPositionsCx(
struct _Pf_ctrl *context,
PhRect_t *ptsExtent,
PhPoint_t *ptsPos,
char *psz,
const char *pckFont,
long adata,
long bdata,
int32_t *piIndices,
int32_t *piPenPositions,
int32_t iArrayLen,
uint32_t ulFlags,
int32_t iBytes,
uint32_t uiExtentLen,
PhRect_t const *pktsClip );
Arguments:
context (PfExtentTextCharPositionsCx() only) A pointer to the font context to
use, returned by PfAttachCx() or PfAttachDllCx().
ptsExtent A pointer to a PhRect_t structure that’s used to store the extent of
the string.
ptsPos A pointer to a PhPoint_t structure that’s used as an offset to apply
against the extent. If NULL, no offset is added to the extent values.
psz A pointer to a NUL-terminated character string.
pckFont The font name, as created by PfGenerateFontName().
adata (PfExtentTextCharPositionsCx() only) The horizontal fractional point
size, if you set PF_FRACTIONAL in the flags argument.
bdata (PfExtentTextCharPositionsCx() only) The vertical fractional point
size, if you set PF_FRACTIONAL in the flags argument.
This function assumes each character is represented by 2 bytes that conform to the
ISO/IEC 10646-1 UCS-2 double-byte format.
If this bit isn’t set, the bearing x value of the next symbols are
applied to the pen x positions. This is useful when drawing
symbols individually, when you need to know where to place the x
origin of each symbol:
iBytes The number of bytes in the string. If this is 0, the function assumes
that the number of bytes is:
strlen( psz ) / wstrlen( psz )
uiExtentLen The number of characters from the beginning of the string to include
in the extent. If 0, the entire string is extented, as permitted by the
clipping rectangle.
Library:
PfExtentTextCharPositions()
ph
PfExtentTextCharPositionsCx()
font
Description:
These functions calculate the extent up to uiExtentLen code points. They record
horizontal pen positions for each code point referenced in piIndices, and continue
processing until pktsClip, if defined, or to the end of the input string psz.
Returns:
0 Success.
Errors:
PfExtentTextCharPositions():
ERANGE The font manager couldn’t fulfill the request; one of the following is
true:
• The iArrayLen argument is larger than strlen(psz).
• If index 0 is requested, then iArrayLen is larger than strlen(psz) + 1.
• The iArrayLen argument is less than or equal to 0.
• An index in piIndices references a character greater than strlen(psz).
EINVAL The font is fixed-width, and an error occurred when trying to retrieve the
common width of all characters in that particular font.
PfExtentTextCharPositionsCx():
Examples:
PfExtentTextCharPositionsCx():
/* Typographic positioning example. Demonstrates how to manipulate
* characters, and sub-strings properly at a typographic pen level.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <Ph.h>
#include <Pt.h>
#include <errno.h>
#include <font_api.h>
#define FALSE 0
#define __WIN_SIZE_X_ 1000
i = 0;
pntPOS.y = 100;
pntPOS.x = 75;
pntDIM.x = __WIN_SIZE_X_ - 75 - 10;
pntDIM.y = 300;
PtRealizeWidget(win);
PtMainLoop ();
return(0);
}
PtCalcCanvas(ptsWidget, &tsClip);
PtClipAdd(ptsWidget, &tsClip);
PtSuperClassDraw( PtBasic, ptsWidget, ptsDamage );
tsClip.ul.x += 2;
tsClip.ul.y += 10;
PgSetTranslation (&tsClip.ul, Pg_RELATIVE);
while(len > 0)
{ wchar_t wc;
int cl;
if (cl) continue;
wc = 0;
}
else
{ len -= cl, str += cl;
max_chars++;
}
}
len = strlen(text);
printf("\n");
printf("EXTENT_POS: ul.x: %d ul.y: %d lr.x: %d lr.y: %d\n",
tsExtent.ul.x, tsExtent.ul.y, tsExtent.lr.x, tsExtent.lr.y);
}
else
{ fprintf(stderr, "NOTE : PfExtentTextCharPositions failed, errno %d.\n",
errno);
fprintf(stderr, "FAIL : Pen.\n");
exit(EXIT_FAILURE);
}
//__SINGLE_CHAR_DRAW_
for(n = 0; n < max_chars; n++)
piIndx[n] = n + 1;
fprintf(stderr,
"NOTE : start Draw the string, one character at a time.\n");
pnt.x = 10 + tsClip.ul.x;
pnt.y = 50 + tsClip.ul.y;
fprintf(stderr,
"NOTE : end Draw the string, one character at a time.\n");
//__TWO_CHUNK_DRAW_
fprintf(stderr, "NOTE : start Draw the string in two chunks.\n");
pnt.x = 10 + tsClip.ul.x;
//__PRINT_POSITIONS_
fprintf(stderr, "NOTE : start print positions.\n");
//__DRAW_OVERLAY_
fprintf(stderr,
"NOTE : start Draw string, then overlay individual characters on \
top from right to left.\n");
default: piIndx[0] = n;
if(PfExtentTextCharPositionsCx(
ctx, &tsExtent, &tsPos, text,
pucFont, 0L, 0L, piIndx, piPos,
1, 0L, 0, 0, NULL) == -1)
{ fprintf(stderr,
"NOTE : PfExtentTextCharPositions failed, \
errno %d.\n", errno);
fprintf(stderr, "FAIL : Pen.\n");
exit(EXIT_FAILURE);
}
else
{ fprintf(stderr, "NOTE : Position: %d\n", piPos[0]);
pnt.x = 10 + tsClip.ul.x + piPos[0];
PgDrawText(text + n, len - n, &pnt, 0);
PgFlush();
}
break;
}
//__TEST_OUTORDER_
fprintf(stderr, "NOTE : start Test indices which are non-sequential.\n");
for(n = 0; n < 4; n++)
{ struct element
{ int first;
int second;
};
PgSetStrokeColor(old);
free(piPos);
free(piIndx);
tsClip.ul.x *= -1;
tsClip.ul.y *= -1;
PgSetTranslation (&tsClip.ul, Pg_RELATIVE);
PtClipRemove();
}
else
{ fprintf(stderr, "NOTE : Unable to create raw canvas, errno %d.\n", errno);
fprintf(stderr, "FAIL : Pen.\n");
exit(EXIT_FAILURE);
}
}
else
{ fprintf(stderr, "NOTE : Unable to create raw canvas, errno %d.\n", errno);
fprintf(stderr, "FAIL : Pen.\n");
exit(EXIT_FAILURE);
}
PfExtentTextCharPositions():
#define MAX_INDICES 5
#define FALSE 0
The pixel pen x positions for each character in the string Lucy are placed in the integer
array iaPos, according to the indexes specified in iaIndex. Index 0 corresponds to the
position before symbol L, index 1 corresponds to the position after L, index 2
corresponds to the position after u, and so on.
Classification:
Photon
PfExtentTextCharPositions()
Safety
Interrupt handler No
Signal handler No
Thread No
PfExtentTextCharPositionsCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfExtent(), PfExtentCx(), PfExtentText(), PfExtentTextCharPositionsCx(),
PfExtentTextToRect(), PfExtentFractTextCharPositions(), PfFractionalExtentText(),
PfGenerateFontName(), PfGenerateFontNameCx(), PhPoint_t, PhRect_t
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
int PfExtentTextToRect(PhRect_t *ptsExtent,
char *pkszFont,
PhRect_t *ptsRect,
char const *pkszString,
int iLen );
Arguments:
ptsExtent A pointer to a PhRect_t structure that’s used to store the resultant
extent.
ptsRect A pointer to a PhRect_t structure that defines the rectangle that limits
the extent.
pkszString The actual string to extent. The string must be a multibyte string;
wchar_t strings are not supported.
Library:
ph
Description:
PfExtentTextToRect() extents a string, pkszString, of length iLen, and font pkszFont, up
to the bounds specified by ptsRect. The resultant extent, which fits within the bounds
of ptsRect, is placed in ptsExtent.
Returns:
The number of characters that will fit within ptsRect, or -1 if an error occurred (errno
is set).
Examples:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <Ap.h>
#include <Ph.h>
#include <Pt.h>
#include <errno.h>
PtInit (NULL);
if(argc > 1)
{ if(PfGenerateFontName(argv[1], 0, 9, szFont) == NULL)
PfGenerateFontName("TextFont", 0, 9, szFont);
}
else
PfGenerateFontName("TextFont", 0, 9, szFont);
if(argc > 2)
strcpy (pcText, pmbGB);
nArgs = 0;
pntPOS.x = 100;
pntPOS.y = 10;
PtSetArg(&args[nArgs], Pt_ARG_POS, &pntPOS, 0);
nArgs++;
PtSetArg(&args[nArgs], Pt_ARG_TEXT_STRING, pcText, NULL);
nArgs++;
PtSetArg(&args[nArgs], Pt_ARG_TEXT_FONT, szFont, NULL);
nArgs++;
pbtn = PtCreateWidget(PtButton, pwndMain, nArgs, args);
PtRealizeWidget(pbtn);
pntPOS.y = 100;
pntPOS.x = 75;
pntDIM.x = 300;
pntDIM.y = 300;
PtRealizeWidget(pwndMain);
PtMainLoop ();
free(pmbGB);
return(0);
}
old = PgSetStrokeColor(Pg_BLACK);
// draw text
pnt.x = 10 + rect.ul.x;
pnt.y = 100 + rect.ul.y;
PgSetFont(szFont);
PgSetTextColor(Pg_BLACK);
PgDrawText(pcText, strlen(pcText), &pnt, 0);
pnt.x -= 10;
pnt2.x = pnt.x + tsExtent.lr.x + 20;
pnt2.y = pnt.y;
PgSetStrokeColor(Pg_BLUE);
PgDrawLine(&pnt, &pnt2);
pnt.x = 10 + rect.ul.x;
pnt.y = 100 + rect.ul.y;
PgSetStrokeColor(Pg_RED);
strlen(pcText))) == -1)
printf("PfExtentTextToRect failed 1.\n");
else
{ printf("lrx == %d, %d characters in string.\n",
tsExtent.lr.x, utf8strlen(pcText, &iBytes));
printf("PfExtentTextToRect lrx == %d, %d characters will fit\
in clip of %d.\n", tsExtentClip.lr.x, iRet, tsExtent.lr.x);
}
tsExtent.lr.x /= 2;
pnt.x = 10 + rect.ul.x;
pnt.y = 150 + rect.ul.y;
tsExtent.lr.x /= 2;
pnt.x = 10 + rect.ul.x;
pnt.y = 200 + rect.ul.y;
PgSetStrokeColor(old);
return( Pt_CONTINUE );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfExtentComponents(), PfExtentFractTextCharPositions(), PfExtent(), PfExtentCx(),
PfExtentText(), PfExtentTextCharPositions(), PfExtentWideText(),
PfFractionalExtentText(), PfGenerateFontName(), PhRect_t
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
PhRect_t *PfExtentWideText( PhRect_t *extent,
PhPoint_t const *pos,
const char *font,
const uint16_t *str,
int len);
Arguments:
extent A pointer to a PhRect_t structure where the function can store the text
extent. The members are:
• ul.x — the left bearing.
• lr.x — the maximum x distance.
• ul.y — the ascender.
• lr.y — the descender.
pos A pointer to a PhPoint_t structure that specifies an offset that you want
the function to apply to the resulting extent. If pos is NULL, no offset is
applied.
font The name of the base font. Create this name by calling
PfGenerateFontName().
len The length of the string, in bytes. If len is 0, the function assumes the string
is null-terminated.
Library:
ph
Description:
This function calculates the extent rectangle of a text string of wide characters.
This function assumes each character is represented by 2 bytes that conform to the
ISO/IEC 10646-1 UCS-2 double-byte format.
The font determines the ascender and 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).
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 (i.e the same pointer as extent), or NULL if an error
occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfExtent(), PfExtentCx(), PfExtentText(), PfExtentTextToRect(),
PfFractionalExtentText(), PfGenerateFontName(), PfLoadMetrics(),
PfWideTextWidthBytes(), PfWideTextWidthChars(), PgExtentText(), PhPoint_t,
PhRect_t
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
FontID * PfFindFont( char const * pkcDescription,
uint32_t kulFlags,
uint32_t kulSize );
#include <font_api.h>
FontID* PfFindFontCx (
struct _Pf_ctrl * context,
char const * pkcDescription,
uint32_t const kulFlags,
uint32_t const kulSize );
Arguments:
context (PfFindFontCx() only) A pointer to the font context to use,
returned by PfAttachCx() or PfAttachDllCx().
kulFlags Flags that identify the requested font type; any combination of:
• PF_STYLE_BOLD
• PF_STYLE_ITALIC
• PF_STYLE_ANTIALIAS
• PF_STYLE_ULINE
• PF_STYLE_DULINE
Library:
PfFindFont() ph
PfFindFontCx() font
Description:
Thess functions compose a FontID from the provided foundry descriptive name,
flags, and point size.
Returns:
A pointer to a font ID that you can use with other font functions, or NULL if an error
occurred.
Errors:
ESRCH Unable to locate font.
This function can also set errno to one of the values generated by PfQueryFonts().
Examples:
PfFindFontCx(): See the examples for PfConvertFontIDCx(), PfGetGlyphIndexCx(),
and PfRenderCx().
PfFindFont():
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <Ap.h>
#include <Ph.h>
#include <Pt.h>
#include <errno.h>
#define FALSE 0
PtInit (NULL);
ppcData = argv;
if(argc < 2)
{ printf(
"Usage: pf2id descriptive_name, e.g. pf2id Helvetica\n");
exit(EXIT_FAILURE);
}
if(argc > 2)
nArgs = 0;
pntDIM.x = 80;
pntDIM.y = 20;
PtSetArg(&args[0], Pt_ARG_DIM, &pntDIM, 0);
nArgs++;
pntPOS.x = 100;
pntPOS.y = 10;
PtSetArg(&args[1], Pt_ARG_POS, &pntPOS, 0);
nArgs++;
PtSetArg(&args[2], Pt_ARG_TEXT_STRING, pcText, NULL);
nArgs++;
PtSetArg(&args[3], Pt_ARG_TEXT_FONT,
PfConvertFontID(gs_ptsID), NULL);
nArgs++;
pbtn = PtCreateWidget(PtButton, pwndMain, nArgs, args);
PtRealizeWidget(pbtn);
pntPOS.y = 100;
pntPOS.x = 75;
pntDIM.x = 300;
pntDIM.y = 300;
PtSetArg(&args[0], Pt_ARG_POS, &pntPOS, 0);
PtSetArg(&args[1], Pt_ARG_DIM, &pntDIM, 0);
PtSetArg(&args[2], Pt_ARG_RAW_DRAW_F, fnDrawCanvas, 0L);
pobjRaw = PtCreateWidget(PtRaw, pwndMain, 3, args);
(void) PtRealizeWidget(pwndMain);
PtMainLoop ();
old = PgSetStrokeColor(Pg_BLACK);
PfExtentText(&tsExtent, &tsPos,
PfConvertFontID(gs_ptsID), pcText,
strlen(pcText));
// draw text
pnt.x = 10 + rect.ul.x;
pnt.y = 100 + rect.ul.y;
PgSetFont(PfConvertFontID(gs_ptsID));
PgSetTextColor(Pg_BLACK);
PgDrawText(pcText, strlen(pcText), &pnt, 0);
pnt.x -= 10;
pnt2.x = pnt.x + tsExtent.lr.x + 20;
pnt2.y = pnt.y;
PgSetStrokeColor(Pg_RED);
PgDrawLine(&pnt, &pnt2);
PgSetStrokeColor(old);
return( Pt_CONTINUE );
}
Classification:
Photon
PfFindFont()
Safety
Interrupt handler No
Signal handler No
Thread No
PfFindFontCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfConvertFontID(), PfConvertFontIDCx(), PfDecomposeStemToID(),
PfDecomposeStemToIDCx(), PfFontDescription(), PfFontDescriptionCx(),
PfFontFlags(), PfFontFlagsCx(), PfFontSize(), PfFontSizeCx(), PfFreeFont(),
PfFreeFontCx(), PfGenerateFontName(), PfGenerateFontNameCx(),
Synopsis:
#include <photon/Pf.h>
char const * PfFontBaseStem( FontID *ptsID );
#include <font_api.h>
char const* PfFontBaseStemCx( struct _Pf_ctrl * context,
FontID * ptsID );
Arguments:
context (PfFontBaseStemCx() only) A pointer to the font context to use, returned
by PfAttachCx() or PfAttachDllCx().
Library:
PfFontBaseStem() ph
PfFontBaseStemCx()
font
Description:
These functions get the base stem that’s associated with the font ID pointed to by
ptsID. Examples of a base stem are helv and swiss. This routine is useful when
differentiating between two or more installed fonts with identical descriptive names
(see PfFontDescription()).
Returns:
A pointer to the base stem, or NULL if ptsID is NULL.
Classification:
Photon
PfFontBaseStem()
Safety
Interrupt handler No
Signal handler No
Thread No
PfFontBaseStemCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfFontDescription(), PfFontDescriptionCx()
Fonts chapter of the Photon Programmer’s Guide
#include <font_api.h>
char const* PfFontDescriptionCx(
struct _Pf_ctrl * context,
FontID * ptsID );
Arguments:
context (PfFontDescriptionCx() only) A pointer to the font context to use, returned
by PfAttachCx() or PfAttachDllCx().
Library:
PfFontDescription()
ph
PfFontDescriptionCx()
fontlib
Description:
These functions get the foundry name specific to the font ID pointed to by ptsID.
These routines don’t check to see if ptsID is non-NULL.
Returns:
The foundry name specific to the FontID, e.g. Comic Sans MS.
Examples:
PfFontDescriptionCx(): See the example for PfConvertFontIDCx().
PfFontDescription(): See PfFindFont().
Classification:
Photon
PfFontDescription()
Safety
Interrupt handler No
continued. . .
KG.
Safety
Signal handler No
Thread No
PfFontDescriptionCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfConvertFontID(), PfConvertFontIDCx(), PfDecomposeStemToID(),
PfDecomposeStemToIDCx(), PfFindFont() PfFindFontCx(), PfFontBaseStem(),
PfFontBaseStemCx(), PfFontFlags(), PfFontFlagsCx(), PfFontSize(), PfFontSizeCx(),
PfFreeFont(), PfFreeFontCx(), PfGenerateFontName(), PfGenerateFontNameCx()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
uint32_t PfFontFlags( FontID *ptsID );
#include <font_api.h>
uint32_t PfFontFlagsCx( struct _Pf_ctrl * context,
FontID * ptsID );
Arguments:
context (PfFontFlagsCx() only) A pointer to the font context to use, returned by
PfAttachCx() or PfAttachDllCx().
Library:
PfFontFlags() ph
PfFontFlagsCx() font
Description:
These functions get the flags associated with the font ID pointed to by ptsID. The flags
can be any of the following:
• PF_STYLE_BOLD
• PF_STYLE_ITALIC
• PF_STYLE_ANTIALIAS
• PF_SCALABLE
• PF_BITMAP
Returns:
A 32-bit value containing the flags for this FontID.
Examples:
PfFontFlagsCx(): See the example for PfConvertFontIDCx().
PfFontFlags(): See PfFindFont().
Classification:
Photon
PfFontFlags()
Safety
Interrupt handler No
Signal handler No
Thread No
PfFontFlagsCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfConvertFontID(), PfConvertFontIDCx(), PfDecomposeStemToID(),
PfDecomposeStemToIDCx(), PfFindFont(), PfFindFontCx(), PfFontDescription(),
PfFontDescriptionCx(), PfFontSize(), PfFontSizeCx(), PfFreeFont(), PfFreeFontCx(),
PfGenerateFontName(), PfGenerateFontNameCx()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
uint32_t PfFontSize( FontID * ptsID );
#include <font_api.h>
uint32_t PfFontSizeCx( struct _Pf_ctrl * context,
FontID * ptsID );
Arguments:
context (PfFontSizeCx() only) A pointer to the font context to use, returned by
PfAttachCx() or PfAttachDllCx().
Library:
PfFontSize() ph
PfFontSizeCx() font
Description:
These functions get the point size associated with the font ID pointed to by ptsID.
These routines don’t verify that ptsID is non-NULL.
Returns:
The point size of the font.
Examples:
PfFontSizeCx(): See the example for PfConvertFontIDCx().
PfFontSize(): See PfFindFont().
Classification:
Photon
PfFontSize()
Safety
Interrupt handler No
Signal handler No
Thread No
PfFontSizeCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfConvertFontID(), PfConvertFontIDCx(), PfDecomposeStemToID(),
PfDecomposeStemToIDCx(), PfFindFont(), PfFindFontCx(), PfFontDescription(),
PfFontDescriptionCx(), PfFontFlags(), PfFontFlagsCx(), PfFreeFont(),
PfFreeFontCx(), PfGenerateFontName(), PfGenerateFontNameCx()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <font_api.h>
int PfFontTypeCx( struct _Pf_ctrl * context,
char const * font,
char * pcBuffer,
int iBufferLen );
Arguments:
context A pointer to the font context to use, returned by PfAttachCx() or
PfAttachDllCx().
font A string that contains the base font stem. You should create this
argument by calling PfGenerateFontNameCx().
pcBuffer A pointer to a buffer in which the function can store the font type.
Library:
font
Description:
This function retrieves a string from the font server describing what type of font
technology is used to process the provided font. For example, Adobe Type 1,
TrueType/T2K, and Bitstream(FFS).
Returns:
0 Success
Errors:
ESRCH Unable to locate device.
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachCx(), PfAttachDllCx(), PfGenerateFontNameCx().
Fonts chapter of the Photon Programmer’s Guide
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 );
Arguments:
extent A pointer to a PhRect_t structure where the function stores the
string’s extent. For the interpretation of the members of this structure,
see below.
font The base font to use when calculating the extent. You should create
this argument by calling PfGenerateFontName().
str The UTF-8 multibyte string whose extent you want to determine.
Library:
ph
Description:
This function calculates the extent rectangle of a text string. The base font determines
the ascender and 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 intended to be used with scalable fonts. If a bitmap font is provided,
an attempt is made to map the font to a scalable equivalent, though success isn’t
guaranteed.
The baseline of the font is at position y=0; the width of the string is lr.x - min(ul.x, 0) +
1. The height of the string is lr.y - ul.y + 1.
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:
PfExtent(), PfExtentCx(), PfExtentText(), PfExtentTextToRect(),
PfGenerateFontName(), PfLoadMetrics(), PgExtentText(), PhPoint_t, PhRect_t
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
long PfFreeFont( FontID *ptsID );
#include <font_api.h>
long PfFreeFontCx( struct _Pf_ctrl * context,
FontID * ptsID );
Arguments:
context (PfFreeFontCx() only) A pointer to the font context to use, returned by
PfAttachCx() or PfAttachDllCx().
Library:
PfFreeFont() ph
PfFreeFontCx() font
Description:
These functions release all resources bound to the font ID pointed to by ptsID.
Returns:
0L Success.
Errors:
EFAULT The ptsID argument is NULL.
Examples:
PfFreeFontCx(): See the examples for PfConvertFontIDCx(), PfGetGlyphIndexCx(),
and PfRenderCx().
PfFreeFont(): See PfFindFont().
Classification:
Photon
PfFreeFont()
Safety
Interrupt handler No
Signal handler No
Thread No
PfFreeFontCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfConvertFontID(), PfConvertFontIDCx(), PfDecomposeStemToID(),
PfDecomposeStemToIDCx(), PfFindFont(), PfFindFontCx(), PfFontDescription(),
PfFontDescriptionCx(), PfFontFlags(), PfFontFlagsCx(), PfFontSize(),
PfFontSizeCx(), PfGenerateFontName(), PfGenerateFontNameCx(),
Fonts chapter of the Photon Programmer’s Guide
#include <font_api.h>
char * PfGenerateFontNameCx(
struct _Pf_ctrl *context,
char const * pkcDescription,
uint32_t kuiFlags,
uint32_t kuiSize,
char * pcBuff );
Arguments:
context A pointer to the font context to use, returned by PfAttachCx() or
PfAttachDllCx().
pkcDescription The descriptive name of the font, usually the name provided by the
font foundry, e.g. Helvetica.
kuiFlags The attributes to apply to the font. The following bits can be ORed
together:
• PF_STYLE_BOLD
• PF_STYLE_ITALIC
• PF_STYLE_ANTIALIAS
• PF_STYLE_ULINE
• PF_STYLE_DULINE
pcBuff A buffer in which to store the resulting font identifier. This must
be of size MAX_FONT_TAG.
Library:
PfGenerateFontName()
ph
PfGenerateFontNameCx()
font
Description:
PfGenerateFontName() is a convenience function that generates proper font names
from the given arguments. PfGenerateFontNameCx() is similar to
PfGenerateFontName(), but lets you specify the font context.
Returns:
NULL on failure, pcBuff on success.
Errors:
ENOMEM Not enough memory to proceed with the request.
Examples:
PfGenerateFontNameCx(): See the examples for PfConvertFontIDCx() and
PfExtentCx().
PfGenerateFontName():
char szHelvetica12[MAX_FONT_TAG];
if(PfGenerateFontName("Helvetica", PF_STYLE_BOLD,
12, szHelvetica12) == NULL) {
perror("Unable to find font");
} else {
PfExtentText(&tsExtent, NULL, szHelvetica12,
"Hello", 0);
}
The szHelvetica12 variable can now be used with any function that takes a “font”
pointer, such as PfExtentText(), PfExtentTextCx(), PfGlyph(), PfRenderCx() or
PfRender().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
PfGenerateFontNameCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttach(), PfAttachCx(), PfDecomposeStemToID(), PfDecomposeStemToIDCx(),
PfQueryFontInfo(), PfQueryFontInfoCx(), PfQueryFonts(), PfQueryFontsCx()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <font_api.h>
int PfGetGlyphIndexCx( struct _Pf_ctrl * context,
wchar_tglyph,
FontID * font,
uint32_t * pIndex );
Arguments:
context A pointer to the font context to use, returned by PfAttachCx() or
PfAttachDllCx().
pIndex A pointer to a uint32_t where the function can store the glyph index.
Library:
font
Description:
This function retrieves the glyph index for the provided font and glyph combination.
Returns:
0 Success
Errors:
ESRCH Unable to locate device.
ERANGE Unable to locate suitable base font for provided code point.
Examples:
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <dirent.h>
#include <photon/PhT.h>
#include <photon/PhProto.h>
#include <Pt.h>
#include <Ph.h>
#include <font_api.h>
FontName name;
uint16_t wc = 0x65;
pos.y += -info.ascender;
w = wc;
free(bitmap);
PfFreeFontCx(PfDefaultContext(), id);
}
else
{ fprintf(stderr, "NOTE : PfDecomposeStemToIDCx failed, errno %d.\n", errno);
fprintf(stderr, "FAIL : Glyph capture.\n");
exit(EXIT_FAILURE);
}
tsClip.ul.x *= -1;
tsClip.ul.y *= -1;
PgSetTranslation (&tsClip.ul, Pg_RELATIVE);
PtClipRemove();
}
if(PtInit(NULL) == -1)
{ fprintf(stderr, "NOTE : PtInit failed, no photon.\n");
fprintf(stderr, "FAIL : Glyph Capture.\n");
return(EXIT_FAILURE);
}
PgSetDrawBufferSize(0xFFFF);
i = 0;
PtSetArg(&tsArg[i++], Pt_ARG_DIM, &dim, 0L);
PtSetArg(&tsArg[i++], Pt_ARG_WINDOW_TITLE, "Glyph Capture", 0L);
PtSetArg(&tsArg[i++], Pt_ARG_FLAGS, Pt_GETS_FOCUS, Pt_GETS_FOCUS);
PtCalcCanvas(win, &canvas);
i = 0;
dim.w = canvas.lr.x - canvas.ul.x;
dim.h = (canvas.lr.y / 2) - canvas.ul.y;
PtSetArg(&tsArg[i++], Pt_ARG_DIM, &dim, 0L);
PtSetArg(&tsArg[i++], Pt_ARG_RAW_DRAW_F, raw_draw, 0L);
pos.x = 0;
pos.y = dim.h;
PtSetArg(&tsArg[i++], Pt_ARG_POS, &pos, 0L);
PtSetArg(&tsArg[i++], Pt_ARG_FILL_COLOR, Pg_YELLOW, 0L);
flags = Pt_RIGHT_ANCHORED_RIGHT | Pt_LEFT_ANCHORED_LEFT | Pt_TOP_ANCHORED_TOP
| Pt_BOTTOM_ANCHORED_BOTTOM;
PtSetArg(&tsArg[i++], Pt_ARG_ANCHOR_FLAGS, flags, flags);
i = 0;
dim.w = canvas.lr.x - canvas.ul.x;
dim.h = (canvas.lr.y / 2) - canvas.ul.y;
PtSetArg(&tsArg[i++], Pt_ARG_DIM, &dim, 0L);
pos.x = 0;
pos.y = 0;
PtSetArg(&tsArg[i++], Pt_ARG_POS, &pos, 0L);
flags = Pt_RIGHT_ANCHORED_RIGHT | Pt_LEFT_ANCHORED_LEFT | Pt_TOP_ANCHORED_TOP
| Pt_BOTTOM_ANCHORED_BOTTOM;
PtSetArg(&tsArg[i++], Pt_ARG_ANCHOR_FLAGS, flags, flags);
PtSetArg(&tsArg[i++], Pt_ARG_FONT_FLAGS, 0L, Pt_FONTSEL_SAMPLE);
PtRealizeWidget(win);
PtMainLoop();
return(EXIT_SUCCESS);
}
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachCx(), PfAttachDllCx(), PfFindFontCx().
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
long PfGetOutline( char const *pkucFont,
unsigned long ulSymbol,
PHFONT_METRICS *ptsMetrics,
PhPoint_t **pptsPoints,
int **ppiLoops );
#include <font_api.h>
long PfGetOutlineCx( struct _Pf_ctrl *context,
char const *pkucFont,
unsigned long ulSymbol,
PHFONT_METRICS *ptsMetrics,
PhPoint_t **pptsPoints,
int **ppiLoops );
Arguments:
context (PfGetOutlineCx() only) A pointer to the font context to use, returned
by PfAttachCx() or PfAttachDllCx().
ppiLoops A pointer to a pointer of type int. The function allocates memory and
stores the number of loop iterations per contour within this memory.
Library:
PfGetOutline() ph
PfGetOutlineCx() font
Description:
These functions provide individual point information, in pixel coordinates, for a glyph
outline. These points can be transformed in any way desired. In order to fill the
resultant outlines, there are several possible routes:
Your application must free the memory pointed to by pptsPoints and ppiLoops.
PfGetOutlineCx() is similar to PfGetOutline(), but lets you specify the font context.
Returns:
The number of contours that make up the outline, or -1 if an error occurred (errno is
set).
Examples:
PfGetOutlineCx():
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include <Ph.h>
#include <Pt.h>
PtInit (NULL);
return(Pt_CONTINUE);
lAscender = 200;
pos.y = 0;
pos.x = 0;
dim.x = 400;
dim.y = (lAscender + (-extent.ul.y));
PtSetArg(&args[0], Pt_ARG_POS, &pos, 0);
PtSetArg(&args[1], Pt_ARG_DIM, &dim, 0);
PtSetArg(&args[2], Pt_ARG_RAW_DRAW_F, draw_canvas, 0L);
PtSetArg(&args[3], Pt_ARG_POINTER, font, 0L);
int * loops;
s_lAdvanceY = 0L;
old = PgSetStrokeColor(Pg_BLACK);
free(pnt);
free(loops);
}
PfDetachCx(pf);
}
PgSetStrokeColor(old);
return( Pt_CONTINUE );
}
PfGetOutline():
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include <Ph.h>
#include <Pt.h>
PhRect_t rect;
PhRect_t tsExtent;
FontName szFont;
long lAscender = 0;
int bDrawLine = 0;
PtInit (NULL);
if(argc > 1)
bDrawLine = 1;
if(PfGenerateFontName(DESC_FONT, 0, 36,
szFont) == NULL)
return(Pt_CONTINUE);
lAscender = 200;
pntPOS.y = 0;
pntPOS.x = 0;
pntDIM.x = 400;
pntDIM.y = (lAscender + (-tsExtent.ul.y));
PtSetArg(&args[0], Pt_ARG_POS, &pntPOS, 0);
PtRealizeWidget(pwndMain);
PtMainLoop ();
return(EXIT_SUCCESS);
}
int * loops;
s_lAdvanceY = 0L;
s_lAdvanceX = 0L;
old = PgSetStrokeColor(Pg_BLACK);
if((lNumContours =
PfGetOutline(szFont, ’i’, &tsMetrics,
&pnt, &loops)) == -1L)
return(Pt_CONTINUE);
if(tsMetrics.BearingX < 0)
s_lAdvanceX += (-tsMetrics.BearingX +
0xFFFFL) >> 16;
free(pnt);
free(loops);
s_lAdvanceX += (tsMetrics.Advance +
0xFFFFL) >> 16;
if((lNumContours =
PfGetOutline(szFont, ’o’, &tsMetrics,
&pnt, &loops)) == -1L)
return(Pt_CONTINUE);
free(pnt);
free(loops);
s_lAdvanceX += (tsMetrics.Advance +
0xFFFFL) >> 16;
if((lNumContours =
PfGetOutline(szFont, ’u’, &tsMetrics,
&pnt, &loops)) == -1L)
return(Pt_CONTINUE);
free(pnt);
free(loops);
s_lAdvanceX += (tsMetrics.Advance +
0xFFFFL) >> 16;
if((lNumContours =
PfGetOutline(szFont, 0x5EB3, &tsMetrics,
&pnt, &loops)) == -1L)
{ printf("return failed\n");
return(Pt_CONTINUE);
}
free(pnt);
free(loops);
s_lAdvanceX += (tsMetrics.Advance +
0xFFFFL) >> 16;
if((lNumContours =
PfGetOutline(szFont, ’A’, &tsMetrics,
&pnt, &loops)) == -1L)
{ printf("return failed\n");
return(Pt_CONTINUE);
}
free(pnt);
free(loops);
PgSetStrokeColor(old);
return( Pt_CONTINUE );
}
if(!bDrawLine)
{ printf("PgDrawPolygon()\n");
offset += loops[ii];
}
else if(bDrawLine)
{ printf("PgDrawLine()\n");
ul1++, ul2++;
}
}
PgSetFillColor(old);
return(0);
}
Classification:
Photon
PfGetOutline()
Safety
Interrupt handler No
Signal handler No
Thread No
PfGetOutlineCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachCx(), PfDetach(), PfDetachCx(), PfGlyph(), PfGlyphCx(),
PfGenerateFontName(), PfGenerateFontNameCx(), PhPoint_t
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
#include <font_api.h>
int PfGlyphCx( struct _Pf_ctrl *context,
const char *font,
long symbol,
FontRender *metrics,
unsigned char *bitmap,
int size,
FontName fontused);
Arguments:
context (PfGlyphCx() only) A pointer to the font context to use, returned by
PfAttachCx() or PfAttachDllCx().
font The base font to use, which you should create by calling
PfGenerateFontName() or PfGenerateFontNameCx().
bitmap NULL, or a pointer to a block of memory where the function can store the
character bitmap.
size The number of bytes in the block that bitmap points to.
fontused NULL, or a buffer where the function can store the name of the font that
supplies the character.
Library:
PfGlyph() ph
PfGlyphCx() font
Description:
These routines are useful for obtaining arbitrary character glyphs, such as cursors. The
functions obtain from the base font the metrics and/or bitmap for the character
specified by symbol.
When bitmap is non-NULL, it must point to an area of size bytes that the character
bitmap can 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 is placed in the string
pointed to by fontused if non-NULL.
Returns:
0 Success.
Examples:
PfGlyphCx(): See the example for PfGetGlyphIndexCx().
Classification:
Photon
PfGlyph()
Safety
Interrupt handler No
Signal handler No
Thread No
PfGlyphCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfGenerateFontName(), PfGenerateFontNameCx(), PfGetOutline(),
PfGetOutlineCx(), PfRender(), PfRenderCx()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
int PfLoadFont( const char *font,
unsigned flags,
FontName fontused );
#include <font_api.h>
int PfLoadFontCx( struct _Pf_ctrl * context,
const char * font,
unsigned flags,
FontName fontused );
Arguments:
context (PfLoadFontCx() only) A pointer to the font context to use, returned by
PfAttachCx() or PfAttachDllCx().
fontused NULL, or a buffer where the function can store the real name of the font,
which may be different from the input if the font is unknown or is
mapped as an alias to another font (via the fontmap file).
Library:
PfLoadFont() ph
PfLoadFontCx() font
Description:
This function preloads a font (from disk into memory) within the font server to speed
up subsequent use of the font. By default, a font is loaded only when required by
PgExtentText() or PgDrawText().
Returns:
0 Success.
Classification:
Photon
PfLoadFont()
Safety
Interrupt handler No
Signal handler No
Thread No
PfLoadFontCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfGenerateFontName(), PfGenerateFontNameCx(), PgDrawText(), PgExtentText()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
int PfLoadMetrics( const char *font );
#include <font_api.h>
int PfLoadMetricsCx( struct _Pf_ctrl * context,
const char * font );
Arguments:
context (PfLoadMetricsCx() only) A pointer to the font context to use, returned by
PfAttachCx() or PfAttachDllCx().
Library:
PfLoadMetrics() ph
PfLoadMetricsCx()
font
Description:
These functions load metric information for the given font from the font server into
memory and link this font into a list of available local metrics.
Subsequent text extents of this base font, involving characters solely within this font,
are 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).
In instances where the font metrics do not contain the glyph, messaging will be used
as a fallback method.
Returns:
0 Success.
Examples:
PfLoadMetricsCx(): See the example for PfConvertPixelsToPointSizeCx().
Classification:
Photon
PfLoadMetrics()
Safety
Interrupt handler No
Signal handler No
Thread No
PfLoadMetricsCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfGenerateFontName(), PfGenerateFontNameCx(), PfUnloadMetrics(),
PfUnloadMetricsCx()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
typedef struct pfPoint{
short x,y;
} pf_point_t;
Description:
The pf_point_t structure describes the coordinates of a single point. It contains at
least the following members:
Classification:
Photon
See also:
PhArea_t, PhAreaToRect(), PhDeTranslateRect(), PhDim_t, PhPoint_t
PhRectIntersect(), PhRectToArea(), PhRectUnion(), PhTranslateRect()
“Geometry data types” in the Working with Code chapter of the Photon Programmer’s
Guide
Synopsis:
typedef struct pfPoint16dot16{
int32_t x_16dot16,y_16dot16;
} pf_point_16dot16_t;
Description:
The pf_point_16dot16_t structure describes the 16.16 fixed point coordinates of a
single point. It contains at least the following members:
Classification:
Photon
See also:
PhArea_t, PhAreaToRect(), PhDeTranslateRect(), PhDim_t, PhPoint_t
PhRectIntersect(), PhRectToArea(), PhRectUnion(), PhTranslateRect()
“Geometry data types” in the Working with Code chapter of the Photon Programmer’s
Guide
Synopsis:
#include <photon/Pf.h>
int PfQueryFontInfo( const char *font,
FontQueryInfo *info );
#include <font_api.h>
int PfQueryFontInfoCx( struct _Pf_ctrl *context,
const char *font,
FontQueryInfo *info );
Arguments:
context (PfQueryFontInfoCx() only) A pointer to the font context to use, returned
by PfAttachCx() or PfAttachDllCx().
Library:
PfQueryFontInfo()
ph
PfQueryFontInfoCx()
font
Description:
These functions get 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).
Returns:
0 Successful completion.
Examples:
PfQueryFontInfoCx(): See the example for PfGetGlyphIndexCx().
Classification:
Photon
PfQueryFontInfo()
Safety
Interrupt handler No
Signal handler No
Thread No
PfQueryFontInfoCx()
Safety
Interrupt handler No
Signal handler No
continued. . .
Safety
Thread Yes
See also:
PfGenerateFontName(), PfGenerateFontNameCx(), PfQueryFonts(),
PfQueryFontsCx()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
int PfQueryFonts( long symbol,
unsigned flags,
FontDetails list[],
int n );
#include <font_api.h>
int PfQueryFontsCx( struct _Pf_ctrl *context,
long symbol,
unsigned flags,
FontDetails list[],
int n );
Arguments:
context (PfQueryFontsCx only) A pointer to the font context to use, returned by
PfAttachCx() or PfAttachDllCx().
flags Flags that you can use to filter the list of fonts; any combination of the
following:
• PHFONT_SCALABLE — select scalable fonts.
• PHFONT_BITMAP — select bitmapped fonts.
• PHFONT_PROP — select proportional fonts.
• PHFONT_FIXED — select fixed-width fonts.
• PHFONT_ALL_FONTS — select all fonts.
• PHFONT_DONT_SHOW_LEGACY — exclude legacy fonts. This flag
overrides PHFONT_ALL_FONTS.
Library:
PfQueryFonts() ph
PfQueryFontsCx()
font
Description:
These functions construct 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.)
Up to n matching font family entries are placed in the user-provided list.
If n is 0 and list is NULL, these functions return the number of matching fonts but
don’t try to fill in the list. You can use this feature to determine the number of items to
allocate for the list.
FontDetails structure
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_ALIAS — the entry is a mapping or virtual
font, like TextFont.
• PHFONT_INFO_BLDITC — bold italic style.
• PHFONT_INFO_BOLD — bold style.
• PHFONT_INFO_DECORATIVE — decorative style.
• PHFONT_INFO_FIXED — fixed-width font.
• PHFONT_INFO_ITALIC — italic style.
• PHFONT_INFO_PLAIN — plain/regular style.
• PHFONT_INFO_PROP — proportional-width font.
• PHFONT_INFO_SANSERIF — sans-serif font.
• PHFONT_INFO_SERIF — serif font.
Returns:
The number of matching fonts found, or -1 on error.
Classification:
Photon
PfQueryFonts()
Safety
Interrupt handler No
Signal handler No
Thread No
PfQueryFontsCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfGenerateFontName(), PfGenerateFontNameCx(), PfQueryFontInfo(),
PfQueryFontInfoCx(), PgSetFont()
PtFontSel (in the Photon Widget Reference)
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
typedef struct pfRect {
pf_point_t ul;
pf_point_t lr;
} pf_rect_t;
Description:
The pf_rect_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:
PhArea_t, PhAreaToRect(), PhDeTranslateRect(), PhDim_t, PhPoint_t
PhRectIntersect(), PhRectToArea(), PhRectUnion(), PhTranslateRect()
“Geometry data types” in the Working with Code chapter of the Photon Programmer’s
Guide
Synopsis:
typedef struct pfRect16dot16{
pf_point_16dot16_t ul;
pf_point_16dot16_t lr;
} pf_rect_16dot16_t;
Description:
The pf_rect_16dot16_t structure describes the coordinates of a rectangle using
16.16 fixed point. It contains at least the following members:
ul Upper-left corner.
lr Lower-right corner.
Classification:
Photon
See also:
PhArea_t, PhAreaToRect(), PhDeTranslateRect(), PhDim_t, PhPoint_t
PhRectIntersect(), PhRectToArea(), PhRectUnion(), PhTranslateRect()
“Geometry data types” in the Working with Code chapter of the Photon Programmer’s
Guide
Synopsis:
#include <photon/Pf.h>
int PfRender( void *ctx,
const char *font,
long adata,
long bdata,
const char *str,
int len,
int flags,
PhPoint_t const *pos,
PhRect_t const *clip,
void (*func) (
void *, const PhPoint_t *pos,
const FontRender *));
#include <font_api.h>
int PfRenderCx( struct _Pf_ctrl *context,
void *ctx,
const char *font,
long adata,
long bdata,
const char *str,
int len,
int flags,
PhPoint_t const *pos,
PhRect_t const *clip,
void (*func) (
void *, const PhPoint_t *pos,
const FontRender *));
Arguments:
context (PfRenderCx() only)
A pointer to the font context to use, returned by PfAttachCx() or
PfAttachDllCx().
ctx A context/data pointer that’s passed to the user callback, func. This value
must be nonzero; if you don’t want to pass a context, set this argument to 1.
font The base font, which you should create by calling PfGenerateFontName()
or PfGenerateFontNameCx().
adata The horizontal fractional point size, if you set PF_FRACTIONAL in the flags
argument.
bdata The vertical fractional point size, if you set PF_FRACTIONAL in the flags
argument.
str The string whose extent you want to calculate. The string is a UTF-8
multibyte one by default.
len The length of the string, str, in bytes. If len is 0, the function uses
strlen(str).
Although this flag allows for 32-bit wide characters, the underlying font system
currently supports only characters up to Unicode U+FFFE.
If you don’t set either of the above, the function assumes that the string is
composed of UTF-8 multibyte characters.
You can OR in:
• PF_FRACTIONAL — use a fractional 16.16 point size. If you set this
flag, use the adata argument to specify the horizontal fractional point
size, and bdata to specify the vertical fractional point size.
clip A pointer to a PhRect_t that specifies the clipping rectangle for the text. If
clip is NULL, it’s ignored. The font server performs coarse character
clipping only.
func A user callback function that’s called to render the text. It’s 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.
Library:
PfRender() ph
PfRenderCx() font
Description:
These functions render the given string via a user callback function. The difference
between PfRender() and PfRenderCx() is that PfRenderCx() lets you specify the font
context to use.
When a request to construct the bitmap is sent to the font server, the string bitmap is
returned, for efficiency, in the shared-memory area created through the initial call to
PfAttach(), PfAttachCx() or PfAttachDllCx().
Normally, only the graphics drivers use these functions, but they may be useful for
application programs that have to obtain text bitmap data directly.
The generic design of these routines allows future expansion.
The FontRender metrics structure contains at least the following members:
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.
Examples:
PfRenderCx():
/* Render alignment example. Demonstrates how to achieve 8-bit,
* 32-bit, and 64-bit aligned render maps if supported by the
* particular font server.
*/
#include <font_api.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
static void func(void * ctx, const pf_point_t * pos, const FontRender * render)
{
printf("NOTE: render callback.\n");
if(check_32)
{ int times = render->bpl / 4;
int total = times * 4;
if(total != render->bpl)
bad_32 = 1;
}
if(check_64)
{ int times = render->bpl / 8;
int total = times * 8;
if(total != render->bpl)
bad_64 = 1;
}
}
PfDetachCx(pf);
PfDetachCx(pf);
fprintf(stderr,
"PASS: PfRenderCx and bitmap alignment.\n");
}
else
{ fprintf(stderr,
"NOTE: PfRenderCx failed, errno %d.\n",
errno);
fprintf(stderr,
"FAIL: PfRenderCx and bitmap alignment.\n");
}
}
else
{ fprintf(stderr,
"UNRES: Unable to attach to fontserver, \
errno %d.\n", errno);
fprintf(stderr,
"FAIL: PfRenderCx and bitmap alignment.\n");
skip = 1;
}
}
}
else
{ fprintf(stderr, "NOTE: PfRenderCx failed, errno %d.\n",
errno);
fprintf(stderr,
"FAIL: PfRenderCx and bitmap alignment.\n");
}
}
else
{ fprintf(stderr,
"UNRES: Unable to attach to fontserver, errno %d.\n",
errno);
fprintf(stderr, "FAIL: PfRenderCx and bitmap alignment.\n");
skip = 1;
}
}
else
{ fprintf(stderr, "NOTE: PfRenderCx failed, errno %d.\n", errno);
fprintf(stderr, "FAIL: PfRenderCx and bitmap alignment.\n");
}
}
else
{ fprintf(stderr, "UNRES: PfAttachCx failed, errno %d.\n", errno);
fprintf(stderr, "FAIL: PfRenderCx and bitmap alignment.\n");
}
}
}
else
{ fprintf(stderr,
"NOTE: PfRenderCx returned success with invalid render buffer.\n");
fprintf(stderr, "FAIL: PfRenderCx and bitmap alignment.\n");
}
if(!skip)
PfDetachCx(pf);
}
else
{ fprintf(stderr, "UNRES: Unable to attach to fontserver, errno %d.\n", errno);
fprintf(stderr, "FAIL: PfRenderCx and bitmap alignment.\n");
}
return(0);
}
Classification:
Photon
PfRender()
Safety
Interrupt handler No
Signal handler No
Thread No
PfRenderCx()
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttach(), PfAttachCx(), PfDetach(), PfDetachCx(), PfGenerateFontName(),
PfGenerateFontNameCx(), PhPoint_t, PhRect_t
Synopsis:
#include <font_api.h>
int PfRestartServerDll( fontdll_t dll );
Arguments:
dll A font server context, returned by PfAttachLocalDll().
Library:
font
Description:
This function restarts the local server associated with the provided dll context. All font
DLL settings are retained during the restart.
Returns:
0 Success
Examples:
See the example for PfAttachLocalDll().
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachLocalDll().
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <font_api.h>
int PfSetOptionsDll( fontdll_t dll,
char const * options,
char const * schema );
Arguments:
dll A font DLL context, returned by PfAttachLocalDll().
options A pointer to a string that contains the options you want to set for the font
DLL. The options must be separated by commas, for example,
-A,-d=/usr/photon/font_repository. This string may be NULL.
schema The name of a schema, a configuration file used to override the default
settings for a local font server.
Use the DLL_FONT_SERVER schema for processes that need to allocate
sufficient resources to act as a default font server. This schema loads a
local server instance that can be used as an external server by other
applications (that is, it appears in /def/phfont). Use NULL to load a
local server instance that cannot be used by other applications.
The string referenced by schema may not exceed
DLL_MAX_OPTION_NAME bytes, including the terminating NULL.
Library:
font
Description:
This function applies options to an instantiated DLL context. Since this font instance
is active, all options changes may not be permitted. Legal options are identical to those
support by the font server. Some options may not be relevant to a DLL instance of the
font server. If this function is invoked on a DLL context, with an active font instance,
it is up to the font instance as to whether or not an option should be applied.
Returns:
0 Success
Errors:
EINVAL Invalid options.
Examples:
See the example for PfAllocRenderCx().
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachLocalDll()
The Fonts chapter of the Photon Programmer’s Guide
Synopsis:
int PfSetRenderingDPICx( struct _Pf_ctrl * context,
uint32_t res_x,
uint32_t res_y );
Arguments:
context A pointer to the font context to use, returned by PfAttachCx() or
PfAttachDllCx().
res_x The horizontal DPI value you want to set the context rendering to.
res_y The vertical DPI value you want to set the context rendering to.
Library:
font
Description:
This function requests that the font server set the rendering and extenting DPI for the
provided context. The font server may ignore the request completely, or a particular
font technology may not be able to accomodate the request.
Returns:
0 Success
Errors:
EFAULT Font context is NULL.
Examples:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <font_api.h>
if(e->ul.y != e2->ul.y)
return(0);
if(e->lr.x != e2->lr.x)
return(0);
if(e->lr.y != e2->lr.y)
return(0);
return(1);
}
if(r->size.y != r2->size.y)
return(0);
if(r->offset.x != r2->offset.x)
return(0);
if(r->offset.y != r2->offset.y)
return(0);
if(r->width != r2->width)
return(0);
if(r->bpl != r2->bpl)
return(0);
if(r->bpp != r2->bpp)
return(0);
if(r->flags != r2->flags)
return(0);
return(1);
}
static void func(void * ctx, const pf_point_t * pos, const FontRender * render)
{ FontRender * r = (FontRender *)ctx;
(*r) = *render;
}
if(PfSetRenderingDPICx(pf, 0, 0) == 0)
{ FontRender render;
PfDetachCx(pf);
fprintf(stderr, "PASS: DPI.\n");
}
return(0);
}
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachCx(), PfAttachDllCx().
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
int PfTextWidthBytes( const char *font,
const char *str,
int len );
Arguments:
font The name of the desired font. You should use PfGenerateFontName() to
create this name.
Library:
ph
Description:
PfTextWidthBytes() is a convenience function that calculates the width of the given
string in the given font, using the formula:
extent.lr.x - min(extent.ul.x, 0) + 1
PfTextWidthChars() is similar, but you give it the number of characters in the string
rather than the number of bytes.
Returns:
The width of the string, or 0 if an error occurred.
Examples:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <Ap.h>
#include <Ph.h>
#include <Pt.h>
#include <errno.h>
PtInit (NULL);
win_size.y = 600;
pntPOS.y = 100;
pntPOS.x = 75;
pntDIM.x = 300;
pntDIM.y = 300;
PtSetArg(&args[0], Pt_ARG_POS, &pntPOS, 0);
PtSetArg(&args[1], Pt_ARG_DIM, &pntDIM, 0);
PtSetArg(&args[2], Pt_ARG_RAW_DRAW_F, fnDrawCanvas, 0L);
pobjRaw = PtCreateWidget(PtRaw, pwndMain, 3, args);
(void) PtRealizeWidget(pwndMain);
PtMainLoop ();
return(0);
}
old = PgSetStrokeColor(Pg_BLACK);
// draw text
tsPos.x = 10 + rect.ul.x;
tsPos.y = 10 + rect.ul.y;
PgSetFont(PfGenerateFontName("Helvetica", 0, 12,
szHelvetica12));
PgSetTextColor(Pg_BLACK);
PgDrawText("Hello", 5, &tsPos, 0);
if((iLen = PfTextWidthBytes(szHelvetica12,
"Hello", 0)) == 0)
return(Pt_CONTINUE);
PgSetStrokeColor(old);
return( Pt_CONTINUE );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfGenerateFontName(), PfTextWidthChars()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
int PfTextWidthChars( const char *font,
const char *str,
int len );
Arguments:
font The name of the desired font. You should use PfGenerateFontName() to
create this name.
Library:
ph
Description:
PfTextWidthChars() is a convenience function that calculates the width of the given
string in the given font, using the formula:
extent.lr.x - min(extent.ul.x, 0) + 1
PfTextWidthBytes() is similar, but you pass it the number of bytes in the string, not the
number of characters.
Returns:
The width of the string, or 0 if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfGenerateFontName(), PfTextWidthBytes()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
int PfUnloadMetrics( const char *font );
Arguments:
font The name of the font whose metrics you want to unload. You should create
this name by calling PfGenerateFontName().
Library:
ph
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
See also:
PfLoadMetrics(), PfGenerateFontName()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <font_api.h>
int PfWaitOnServerDll( fontdll_t dll );
Arguments:
dll A font DLL context, returned by PfAttachLocalDll().
Library:
font
Description:
This function waits until the font server dll thread exits.
Returns:
0 Success
Examples:
See the example for PfAttachLocalDll().
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes
See also:
PfAttachLocalDll()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
int PfWideTextWidthBytes( const char *font,
const uint16_t *str,
int len );
Arguments:
font The name of the desired font. Use PfGenerateFontName() to create the name.
Library:
ph
Description:
PfWideTextWidthBytes() is a convenience function that calculates the width of the
given string in the given font, using the formula:
extent.lr.x - min(extent.ul.x, 0) + 1
This function assumes each character is represented by 2 bytes that conform to the
ISO/IEC 10646-1 UCS-2 double-byte format.
Returns:
The width of the string, or 0 if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfGenerateFontName(), PfTextWidthBytes(), PfTextWidthChars(),
PfWideTextWidthChars()
Fonts chapter of the Photon Programmer’s Guide
Synopsis:
#include <photon/Pf.h>
int PfWideTextWidthChars( const char *font,
const uint16_t *str,
int len );
Arguments:
font The name of the desired font. Use PfGenerateFontName() to create the name.
Library:
ph
Description:
PfWideTextWidthChars() is a convenience function that calculates the width of the
given string in the given font, using the formula:
extent.lr.x - min(extent.ul.x, 0) + 1
This function assumes each character is represented by 2 bytes that conform to the
ISO/IEC 10646-1 UCS-2 double-byte format.
PfWideTextWidthBytes() is similar, but you pass it the number of bytes in the string,
rather than the number of characters.
Returns:
The width of the string, or 0 if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfTextWidthBytes(), PfTextWidthChars(), PfWideTextWidthBytes()
Fonts chapter of the Photon Programmer’s Guide
Most Photon graphics functions append draw commands to a buffer. The application
sends these commands to the Photon Manager, which in turn sends them to the
graphics driver. The graphics driver then renders the commands on the screen.
Photon supports a set of simple, dual-purpose draw primitives that you can stroke (that
is, draw as an outline) or fill, or both. These primitives include arcs, ellipses,
polygons, rectangles, and rounded rectangles.
For fast animation, you can use the Pg... and Pd... functions.
If you’re building a GUI, you should use widgets whenever possible instead of calling
the Pg* functions directly. Widgets handle interaction with the user and look after
redrawing themselves when damaged.
If you need to do raw drawing in an application that uses widgets, 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.
Many of the Pg...() functions have multiple versions, distinguished by their suffix:
• Pg*() — standard function, which operates on the current draw or graphics context.
It is implemented as a macro for its corresponding Pg*Cx() version, if there is one.
• Pg*Cx() — you can specify the draw or graphics context. If the first argument is a
void *, it takes a draw context. If the first argument is a PhGC_t *, it takes a
graphics context.
• Pg*v() and Pg*Cxv() — 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 contents. The Pg*Cxv() are the
same as versions Pg*Cx() in that they take a draw or graphics context as the first
argument.
The Pg*mx() functions in the library are deprecated, and have been replaced with
Pg*v() versions.
Synopsis:
void PgAlphaOff( void );
Arguments:
gc PgAlphaOffCx() only. A pointer to a graphics context, as returned by
PgCreateGC() or PgGetGC().
Library:
ph
Description:
These functions turn alpha blending operations off. PgAlphaOff() works on the current
graphics context, while you can specify the graphics context for PgAlphaOffCx().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgAlphaOn*(), PgSetAlpha*()
“Alpha Blending Support” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgAlphaOn( void );
Arguments:
gc PgAlphaOnCx() only. A pointer to a graphics context, as returned by
PgCreateGC() or PgGetGC().
Library:
ph
Description:
These functions turn alpha blending operations on. PgAlphaOn() works on the current
graphics context, while you can specify the graphics context for PgAlphaOnCx().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgAlphaOff*(), PgSetAlpha*(),
“Alpha Blending Support” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PgAlphaValue( PgColor_t color );
Arguments:
color The composite color, of type PgColor_t, that you want to get the alpha
component of.
Library:
ph
Description:
This macro extracts the alpha color component from a composite color value. The
result is between 0 and 255.
This macro doesn’t check the color model currently in use, and gives undefined results
if you’re not using the Pg_CM_ARGB model.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgARGB(), PgBlueValue(), PgCMY(), PgColor_t, PgGreenValue(), PgHSV(),
PgRedValue(), PgRGB(), PgSetFillColor(), PgSetFillDither()
“Color” and “Alpha Blending Support” in the Raw Drawing and Animation chapter of
the Photon Programmer’s Guide
Synopsis:
PgColor_t PgARGB( int A,
int R,
int G,
int B );
Arguments:
A The alpha value.
Library:
ph
Description:
This macro converts alpha, red, green, and blue values into a composite color value (of
type PgColor_t). The values for alpha, red, green, and blue range from 0 to 255. If
you set the red, green, and blue values to 0, the color is black; if you set them to 255,
the color is white. The meaning of the alpha value depends on the alpha model that
you’re using.
This macro doesn’t check the color model currently in use, and gives undefined results
if you’re not using the Pg_CM_ARGB model.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgAlphaValue(), PgBlueValue(), PgColor_t, PgGreenValue(), PgRedValue(),
PgRGB(), PgSetFillColor(), PgSetStrokeColor(), PgSetTextColor()
“Color” and “Alpha Blending Support” in the Raw Drawing and Animation chapter of
the Photon Programmer’s Guide
Synopsis:
void PgBackgroundShadings( PgColor_t bg,
PgColor_t *ts,
PgColor_t *bs);
Arguments:
bg A PgColor_t object that specifies the background color that you want to base
the shading colors on.
Library:
ph
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 is lighter than the background and the
bottom border color is 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
See also:
PgCalcColorContrast(), PgColor_t
“Color” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PgBevelBox( PhPoint_t *ul,
PhPoint_t *lr,
PgColor_t light_color,
PgColor_t flat_color,
PgColor_t dark_color,
short depth,
short width,
PgColor_t outline_color,
PgColor_t inline_color,
int flags );
Arguments:
dc PgBevelBoxCx() only. A void pointer to any type of draw context.
Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by
PdCreateOffscreenContext()
ul, lr Pointers to PhPoint_t structures that define the upper left and
lower right corners of the beveled box.
light_color A PgColor_t that defines the lightest color in the bevel gradient.
flat_color The middle/neutral color in the bevel gradient, and the box’s fill
color.
width The total width of the beveled border, including outlines and inlines.
If you specify any of the above arguments as Pg_TRANSPARENT, the value of the
argument will be converted to Pg_WHITE.
Library:
ph
Description:
These functions draw a beveled box with gradients. PgBevelBox() works on the
current draw context, while you can specify the draw context for PgBevelBoxCx().
The only difference between these functions and PgDrawGradientBevelBox() or
PgDrawGradientBevelBoxCx() is that the latter allow separate specifications for the
upper-left and the lower-right flat colors. The two flat colors are the same in these
function.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor_t, PgContrastBevelBox*(), PgDrawGradientBevelBox*(), PhPoint_t
“Gradients” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PgBlit( const PhRect_t *rect,
const PhPoint_t *offset );
Arguments:
dc PgBlitCx() only. A void pointer to any type of draw context. Examples of
draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by PdCreateOffscreenContext()
rect A pointer to a PhRect_t structure that defines the area the function blits.
offset A pointer to a PhPoint_t that defines an offset for the blitted area rect.
Library:
ph
Description:
These functions “blit” the area that is defined by rect. The area is blitted by the given
offset. Other windows aren’t affected by the blit.
PgBlit() blits the region defined by the region set for the current draw context, while
PgBlitCx() lets you define the draw context dc.
Returns:
A nonnegative value
Success.
-1 The blit failed, possibly because the Photon Manager wasn’t running.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgMultiBlit*() PhBlit(), PhPoint_t, PhRect_t, PtClippedBlit(), PtWidgetRid()
Synopsis:
int PgBlueValue( PgColor_t color );
Arguments:
color A composite color value, of type PgColor_t.
Library:
ph
Description:
This macro extracts the blue color component from a composite color value. 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:
PgAlphaValue(), PgARGB(), PgCMY(), PgColor_t, PgGreenValue(), PgHSV(),
PgRedValue() PgRGB(), PgSetFillColor(), PgSetFillDither()
“Color” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
void PgCalcColorContrast( PgColor_t flat_color,
int contrast,
PgColor_t *light,
PgColor_t *dark );
Arguments:
flat_color The base color towards which the computed colors are intended to
converge. It’s the color in the middle of the gradient.
contrast The amount of contrast that you want in the gradient, ranging from 0
(low contrast) through 255 (high contrast). The contrast is biased
towards the light color.
light A pointer to the PgColor_t in which to store the lightest color for the
gradient.
dark A pointer to the PgColor_t in which to store the darkest color for the
gradient.
Library:
ph
Description:
This function computes light and dark colors that can be used to construct gradients.
It’s used by Photon to compute bevel gradients.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgBackgroundShadings(), PgColor_t
“Gradients” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
void PgChromaOff( void );
Arguments:
gc PgChromaOffCx() only. A pointer to a graphics context, as returned by
PgCreateGC() or PgGetGC().
Library:
ph
Description:
These functions turn chroma key operations off. PgChromaOff() works on the current
graphics context, while you can specify the graphics context for PgChromaOffCx().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgChromaOn*(), PgSetChroma*()
“Chroma key support” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgChromaOn( void );
Arguments:
gc PgChromaOnCx() only. A pointer to a graphics context, as returned by
PgCreateGC() or PgGetGC().
Library:
ph
Description:
These functions turn chroma key operations on. PgChromaOn() works on the current
graphics context, while you can specify the graphics context for PgChromaOnCx().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgChromaOff*(), PgSetChroma*()
“Chroma key support” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Arguments:
dc PgClearDrawBufferCx() only. A void pointer to any type of draw context.
Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by PdCreateOffscreenContext()
Library:
ph
Description:
These functions reset the current draw buffer without flushing. PgClearDrawBuffer()
works on the current draw context, while you can specify the draw context for
PgClearDrawBufferCx().
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
Co. KG.
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgFlush*(), PgSetDrawBufferSize*()
Arguments:
gc PgClearTranslationCx() only. A pointer to a graphics context, as returned by
PgCreateGC() or PgGetGC().
Library:
ph
Description:
These functions restore the current translation to the default (0,0).
PgClearTranslation() works on the current graphics context, while you can specify the
graphics context for PgClearTranslationCx().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgSetTranslation*()
Synopsis:
PgColor_t PgCMY( int C, int M, int Y );
Arguments:
C The cyan component.
Library:
ph
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()
“Color” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
unsigned long PgColor_t;
Description:
The PgColor_t type definition describes a composite color value. The interpretation
of the color depends on the current color model, which you can set by calling
PgSetColorModel().
The color models are:
Standard colors
At least the following colors are defined in <photon/Pg.h>:
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
We’ve defined the following colors for compatibility with standard VGA colors:
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
Pg_DEVICE_COLOR
Interpret up to the least significant 24 bits as the value to put into video memory.
This facility depends on the video hardware, and behaves differently depending on the
graphics driver.
Pg_INDEX_COLOR
Interpret the color as an index into the current palette.
Pg_INVERT_COLOR
Use with PgSetDrawMode(Pg_DRAWMODE_XOR) for high-visibility XOR
drawing.
Pg_TRANSPARENT
Subsequent draw events won’t be rendered.
Classification:
Photon
See also:
PgAlphaValue(), PgARGB(), PgBlueValue(), PgCMY(), PgColorHSV_t,
PgGetColorModel(), PgGreenValue(), PgHSV2RGB(), PgRedValue(), PgRGB(),
PgRGB2HSV(), PgSetColorModel(), PgSetFillColor(), PgSetFillDither(),
PgSetStrokeColor(), PgSetStrokeDither(), PgSetTextColor(), PgSetTextDither()
“Color” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
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()
“Color” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PgColorMatch(int n,
PgColor_t const *in,
PgColor_t *out);
Arguments:
n The number of colors in the array to find a match for.
in An array of PgColor_t objects that specifies the colors that you want to
match.
out An array of PgColor_t objects that the function fills with the best color
matches for the corresponding entry in the in array.
Library:
ph
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
See also:
PgColor_t
“Color” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PgConfigScalerChannel(
PgVideoChannel_t *channel,
PgScalerProps_t *props );
Arguments:
channel A pointer to a PgVideoChannel_t structure that specifies the channel
you want to configure.
Library:
ph
Description:
This function configures the video overlay scaler channel specified by channel. It uses
the configuration information specified by props to set the state of the overlay
hardware.
Once the scaler is properly configured, the structure pointed to by channel contains
pointers to offscreen context structures that describe the video data buffers. You can
use PdGetOffscreenContextPtr() to retrieve pointers to the video data buffers.
Returns:
0 The state of the scaler hardware was successfully changed, and the video data
frame buffers haven’t changed since the last call to PgConfigScalerChannel().
1 The state of the scaler hardware was successfully changed, and the offscreen
buffer contexts in the channel structure have changed. In this case, information
about the video data buffers that was returned by previous calls is no longer
valid.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdGetOffscreenContextPtr(), PgCreateVideoChannel(), PgDestroyVideoChannel(),
PgGetOverlayChromaColor(), PgGetScalerCapabilities(), PgNextVideoFrame(),
PgScalerCaps_t, PgScalerProps_t, PgVideoChannel_t
“Video overlay” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgContextBlit( PdOffscreenContext_t *src,
PhRect_t *src_rect,
PdOffscreenContext_t *dst,
PhRect_t *dst_rect );
Arguments:
dc PgContextBlitCx() only. A void pointer to any type of draw context.
Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by PdCreateOffscreenContext()
src_rect A pointer to a PhRect_t structure that defines the rectangle in the source
to copy. If src is NULL, src_rect is relative to the emitting region (see
PgSetRegion()) but isn’t clipped by overlapping windows.
dst_rect The rectangle in the destination to which to copy. The source data is
scaled to fit this rectangle.
Library:
ph
Description:
These functions copy data from a rectangle in one context to a rectangle in another
context. PgContextBlit() works on the current draw context, while you can specify the
draw context for PgContextBlitCx().
These functions obey many of the parameters in the draw state: Chroma, Alpha,
Raster Operation (DrawMode), Fill Pattern (FillDither), and Fill Transparency pattern
(FillTransp).
Fill Patterns are used only if the Raster Operation requested includes a pattern
operation (e.g. Pg_DrawModePSo). Fill Transparency patterns are obeyed whether or
not the Raster operation includes a pattern. If the current Raster Operation is a Photon
1.xx raster operation (e.g. Pg_DRAWMODE_OPAQUE), then all patterns are ignored.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateOffscreenContext(), PdDupOffscreenContext(), PdGetOffscreenContextPtr(),
PdOffscreenContext_t, PgContextBlitArea*(), PgSetRegion*(),
PgSwapDisplay*(), PhRect_t
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Arguments:
dc PgContextBlitAreaCx() only. A void pointer to any type of draw context.
Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by
PdCreateOffscreenContext()
src_area A pointer to a PhArea_t structure that defines the area in the source to
copy. If src is NULL, src_rect is relative to the emitting region (see
PgSetRegion()) but isn’t clipped by overlapping windows.
dst_area A pointer to a PhArea_t structure that defines the area in the destination
to copy the data to. The source data is scaled to fit this rectangle.
Library:
ph
Description:
These functions copy data from an area in one offscreen context to an area in another
offscreen context. PgContextBlitArea() works on the current draw context, while you
can specify the draw context for PgContextBlitAreaCx().
These functions obey many of the parameters in the draw state: Chroma, Alpha,
Raster Operation (DrawMode), Fill Pattern (FillDither), and Fill Transparency pattern
(FillTransp).
Fill Patterns are used only if the Raster Operation requested includes a pattern
operation (e.g. Pg_DrawModePSo). Fill Transparency patterns are obeyed whether or
not the Raster operation includes a pattern. If the current Raster Operation is a Photon
1.xx raster operation (e.g. Pg_DRAWMODE_OPAQUE), then all patterns are ignored.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateOffscreenContext(), PdDupOffscreenContext(), PdGetOffscreenContextPtr(),
PdOffscreenContext_t, PgContextBlit*(), PgSetRegion*(), PgSwapDisplay*(),
PhArea_t
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Arguments:
dc PgContrastBevelBoxCx() only. A void pointer to any type of draw
context. Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by
PdCreateOffscreenContext()
ul, lr Pointers to PhPoint_t that define the upper left and lower right
corners of the beveled box.
width The total width of the beveled border, including outlines and inlines.
If you specify any of the above arguments as Pg_TRANSPARENT, the value of the
argument will be converted to Pg_WHITE.
Library:
ph
Description:
These functions draw a beveled box with gradients and a given level of contrast.
PgContrastBevelBox() works on the current draw context, while you can specify the
draw context for PgContrastBevelBoxCx().
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor_t, PgBevelBox*(), PgDrawGradientBevelBox*(), PhPoint_t
“Gradients” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
PhRid_t PgCreateDriverRegion(
PdOffscreenContext_t *osc,
PhPoint_t *origin,
PhRect_t *rect,
PhRid_t parent );
Arguments:
osc A pointer to the PdOffscreenContext_t structure for the offscreen
context. This argument must not be NULL.
origin NULL, or a pointer to a PhPoint_t structure that specifies the origin of the
region, relative to its parent. The default is (0,0) if this argument is NULL.
parent The ID of the parent region, or -1 if you don’t want to specify it.
Library:
ph
Description:
PgCreateDriverRegion() creates a region that’s owned by the graphics driver and is
sensitive to draw events.
The region parent defaults to the driver’s input group’s parent region. PhRegionOpen()
defines all of the other default settings for the region. All draw events collected by the
driver region are targeted at the specified offscreen context.
The driver region persists until you explicitly close it (which we don’t recommend) or
until the corresponding offscreen context is destroyed.
A few notes:
• A single offscreen context is not usually associated with more than one driver
region.
• The draw event translation isn’t cleared when the drawstream is directed to the
offscreen context.
• The driver region can be offset from its offscreen context using
PdSetOffscreenTranslation().
• Client applications can manipulate a driver region by using its region ID. We don’t
generally recommend this.
• The driver region’s handle (Ph_REGION_HANDLE) is reserved for use by the
graphics driver. Don’t change it.
• Since the region is owned by the graphics driver, all events collected by the region
— including input events — are delivered to the graphics driver and not to the
application that called this function.
Returns:
A nonnegative region id, or -1 if an error occurred.
Errors:
EFAULT The function couldn’t access the offscreen context.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdOffscreenContext_t, PdSetOffscreenTranslation(), PdSetTargetDevice(),
PhPoint_t, PhRect_t, PhRegionOpen()
Synopsis:
PhGC_t *PgCreateGC( int unused );
Arguments:
unused PgCreateGC() doesn’t use this argument; set it to 0.
Library:
ph
Description:
This function allocates a graphics context. A graphics context contains the entire draw
state, including color, clipping, and current region.
If your application calls both Pg and Pt functions, you must provide one graphics
context for the Pg functions and a separate context for the Pt functions. To do this, call
PgSetGC() every time you switch from one API to the other.
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:
PdOffscreenContext_t *PgCreateLayerSurface(
int layer,
int surface_index,
int format_index,
unsigned short width,
unsigned short height,
unsigned long flags);
Arguments:
layer The layer index, which must be 0 or greater.
format_index The image format index, which corresponds to the index used in
PgGetLayerCaps().
Library:
ph
Description:
PgCreateLayerSurface() creates an offscreen context that can be nearby the given
layer in the given format.
For layer formats that require data from more than one surface, surface_index is used
to distinguish each surface.
For these layer formats:
• Pg_LAYER_FORMAT_YVU9
• Pg_LAYER_FORMAT_YV12
• Pg_LAYER_FORMAT_YUV420
• Pg_LAYER_FORMAT_YUV_AYUV
• Pg_LAYER_FORMAT_YUV_NV12
0 Y plane
1 U plane
2 V plane
WARNING: You can’t use Photon drawing functions on a surface with a format
that doesn’t match the current video mode.
Returns:
A pointer to a PdOffscreenContext_t structure, or NULL if an error occurred.
Errors:
EINVAL The format, dimensions, or flags are incompatible with the given
layer capabilities, or the layer or layer surface doesn’t exist.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdGetOffscreenContextPtr(), PdOffscreenContext_t, PdSetTargetDevice(),
PgGetLayerCaps(), PgSetLayerSurface()
“Layers” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
PgVideoChannel_t * PgCreateVideoChannel(
unsigned type,
unsigned flags );
Arguments:
type The type of channel to create. Currently, the only defined type is
Pg_VIDEO_CHANNEL_SCALER. This specifies that the video channel is for
outputting video frames using scaler hardware.
Library:
ph
Description:
This function creates a channel to be used for video streaming, and reserves the video
hardware for exclusive use by the application.
Returns:
A pointer to a PgVideoChannel_t structure that describes a channel for subsequent
video operations, or NULL if a video channel couldn’t be created (errno is set).
Errors:
EBUSY Scaler hardware is present, but is in use by another application.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgConfigScalerChannel(), PgDestroyVideoChannel(), PgGetOverlayChromaColor(),
PgGetScalerCapabilities(), PgNextVideoFrame(), PgScalerCaps_t,
PgScalerProps_t, PgVideoChannel_t
“Video overlay” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgDefaultAlpha(PhGC_t * GC);
Arguments:
GC A pointer to a graphics context, as returned by PgCreateGC().
Library:
ph
Description:
This function resets the alpha attribute portion of the provided graphics context to its
system default.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultChroma(), PgDefaultGC(), PgDefaultText(), PgDefaultMode(),
PgDefaultStroke(), PgSetFillColor*(), PgSetFillDither*(), PgSetFillTransPat*(),
PgSetFillXORColor*()
“Drawing attributes” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgDefaultChroma( PhGC_t *GC );
Arguments:
GC A pointer to a graphics context, as returned by PgCreateGC().
Library:
ph
Description:
This function resets the chroma attribute portion of the provided graphics context to its
system default.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultAlpha(), PgDefaultGC(), PgDefaultText(), PgDefaultMode(),
PgDefaultStroke(), PgSetFillColor(), PgSetFillDither(), PgSetFillTransPat(),
PgSetFillXORColor()
“Drawing attributes” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgDefaultFill( PhGC_t *GC );
Arguments:
GC A pointer to a graphics context, as returned by PgCreateGC().
Library:
ph
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(),
PgSetFillColor(), PgSetFillDither(), PgSetFillTransPat(), PgSetFillXORColor()
“Drawing attributes” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgDefaultGC( PhGC_t *GC );
Arguments:
GC A pointer to a graphics context, as returned by PgCreateGC().
Library:
ph
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 );
Arguments:
GC A pointer to a graphics context, as returned by PgCreateGC().
Library:
ph
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 );
Arguments:
GC A pointer to a graphics context, as returned by PgCreateGC().
Library:
ph
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(),
PgSetStrokeCap(), PgSetStrokeColor(), PgSetStrokeDash(), PgSetStrokeDither(),
PgSetStrokeFWidth(), PgSetStrokeJoin(), PgSetStrokeTransPat(), PgSetStrokeWidth(),
PgSetStrokeXORColor()
“Drawing attributes” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgDefaultText( PhGC_t *GC );
Arguments:
GC A pointer to a graphics context, as returned by PgCreateGC().
Library:
ph
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(),
PgSetTextColor(), PgSetTextDither(), PgSetTextTransPat(), PgSetTextXORColor()
“Drawing attributes” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgDestroyGC( PhGC_t *GC );
Arguments:
GC A pointer to a graphics context, as returned by PgCreateGC().
Library:
ph
Description:
This function releases any resources consumed by the specified graphics context.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgCreateGC(), PgGetGC(), PgSetGC()
Synopsis:
void PgDestroyVideoChannel(
PgVideoChannel_t *channel );
Arguments:
channel A pointer to a PgVideoChannel_t structure for the video channel that
you want to destroy.
Library:
ph
Description:
PgDestroyVideoChannel() releases any resources associated with the video channel
that was created by PgCreateVideoChannel().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgConfigScalerChannel(), PgCreateVideoChannel(), PgGetOverlayChromaColor(),
PgGetScalerCapabilities(), PgNextVideoFrame(), PgScalerCaps_t,
PgScalerProps_t, PgVideoChannel_t
“Video overlay” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PgDrawArc( PhPoint_t const *center,
PhPoint_t const *radii,
unsigned int start,
unsigned int end,
int flags );
Arguments:
dc PgDrawArcCx() only. A void pointer to any type of draw context.
Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by
PdCreateOffscreenContext()
center A pointer to a PhPoint_t structure that specifies the center of the arc.
start, end The start and end angles, in bi-grads (see below).
flags Flags that control what type of arc is drawn; see below.
Library:
ph
Description:
These functions build a command in the draw buffer to draw an arc. PgDrawArc()
works on the current draw context, while you can specify the draw context for
PgDrawArcCx().
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.
A circle is divided into 65536 gradations called binary gradations or bi-grads. Thus,
0x2000 is 45 degrees, 0x4000 is 90 degrees, 0x8000 is 180 degrees, and 0xC000 is
270 degrees.
Pg_ARC_PIE A curve with the end points connected to the arc’s 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:
PhPoint_t
To draw stroked arcs, see also:
PgSetStrokeCap*(), PgSetStrokeColor*(), PgSetStrokeDash*(), PgSetStrokeDither*(),
PgSetStrokeJoin*(), PgSetStrokeWidth*()
To draw filled arcs, see also:
PgSetFillColor*(), PgSetFillDither*(), PgSetFillTransPat*()
“Arcs, ellipses, polygons, and rectangles” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Synopsis:
void PgDrawArrow( PhRect_t const *rect,
short margin,
PgColor_t color,
int direction );
Arguments:
dc PgDrawArrowCx() only. A void pointer to any type of draw context.
Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by
PdCreateOffscreenContext()
rect A pointer to a PhRect_t structure that defines the area in which the
arrow must fit. If this area is too small to accomodate a tail, the function
draws only a triangular arrowhead, it doesn’t draw the rectangle itself.
margin The size of the margin, in pixels, to leave inside the rectangle.
color The fill and stroke color to use for the arrow, expressed as a PgColor_t.
direction The direction you want the arrow to point. One of:
• Pg_BOTTOM
• Pg_LEFT
• Pg_RIGHT
• Pg_TOP
Library:
ph
Description:
These functions call PgDrawPolygon() to draw an arrow that fits inside a given
rectangle. PgDrawArrow() works on the current draw context, while you can specify
the draw context for PgDrawArrowCx().
These functions use the current dithering and transparency settings for the fill and
stroke, and a stroke width of 1. After drawing the arrow, they reset the fill and stroke
colors and the stroke width to the values they had when you called the function.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor_t, PgDrawBeveled*(), PgDrawPolygon*(), PhRect_t
“Arcs, ellipses, polygons, and rectangles” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Arguments:
dc PgDrawBevelBoxCx() and PgDrawIBevelBoxCx() only. A void pointer
to any type of draw context. Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by
PdCreateOffscreenContext()
rect (PgDrawBevelBox() and PgDrawBevelBoxCx() only)
A rectangle that describes the size of the bevel box.
secondary The color of the lower and right edges of the bevel box. The top and
left edges are drawn with the current stroke color.
Library:
ph
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. PgDrawBevelBox() and
PgDrawIBevelBox() work on the current draw context, while you can specify the draw
context for PgDrawBevelBoxCx() and PgDrawIBevelBoxCx().
When you increase the thickness, the lines grow toward the middle of the beveled box.
The maximum width is given by Pg_BEVEL_MAX.
Returns:
0 Success.
-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
See also:
PgColor_t, PgDrawBeveled*(), PgDrawRect*(), PgSetFillColor*(),
PgSetFillDither*(), PgSetFillTransPat*(), PgSetStrokeColor*(), PgSetStrokeDither*(),
PgSetStrokeTransPat*(), PhRect_t
“Arcs, ellipses, polygons, and rectangles” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Synopsis:
int PgDrawBeveled( PhRect_t const *rect,
PhPoint_t const *radii,
PgColor_t secondary,
short width,
int flags );
Arguments:
dc PgDrawBeveledCx() and PgDrawIBevelBoxCx() only. A void pointer
to any type of draw context. Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by
PdCreateOffscreenContext()
rect A pointer to a PhRect_t that defines the area that the object fills.
secondary A PgColor_t object that specifies the colors that you want to use for
the lower and right edges of the object.
width The thickness of the lines. When you increase the thickness, the lines
grow toward the middle of the beveled object.
flags Flags that control how the object is drawn; see below.
Library:
ph
Description:
These functions build a command in the draw buffer to draw a beveled rectangle or
arrow. The flags parameter defines how the object is drawn, and includes options for
defining the types of corners that it has. PgDrawBeveled() works on the current draw
context, while you can specify the draw context for PgDrawBeveledCx().
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.
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.
• Pg_BEVEL_SET — swap the upper-left and lower-right colors; this makes the
beveled object appear to be set.
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:
DrawBevelArrow() {
PhRect_t rup = { 20, 4, 44, 16 };
PhRect_t rdown = { 20, 48, 44, 60 };
PhRect_t rleft = { 4, 20, 16, 44 };
PhRect_t rright = { 48, 20, 60, 44 };
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:
PgColor_t, PgDrawArrow*(), PgDrawBevelBox*(), PgDrawRect*(),
PgDrawIRect*(), PgDrawRoundRect*(), PgSetFillColor*(), PgSetFillDither*(),
PgSetFillTransPat*(), PgSetStrokeColor*(), PgSetStrokeDither*(),
PgSetStrokeTransPat*(), PhPoint_t, PhRect_t
“Arcs, ellipses, polygons, and rectangles” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Arguments:
dc PgDrawBezierCx() and PgDrawBezierCxv() only. A void pointer to any type
of draw context. Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by PdCreateOffscreenContext()
ptr An array of four PhPoint_t structures that define the Bézier curve.
flags Flags that control how the curve is drawn; see below.
Library:
ph
Description:
These functions build a command in the draw buffer to draw a multisegment Bézier
curve from an array of points. PgDrawBezier() and PgDrawBezierv() work on the
current draw context, while you can specify the draw context for PgDrawBezierCx()
and PgDrawBezierCxv().
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:
• Pg_RELATIVE — use relative coordinates to draw the curve. Each point is relative
to the previous point.
For absolute coordinates, pos is added to each point pointed to by ptr. For relative
coordinates, the first coordinate is the sum of pos and the first point of the array; any
subsequent coordinate is the sum of the previous point and the next point of the array.
If you call the “v” or “Cxv” 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(), PhPoint_t
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*()
“Drawing attributes” and “Lines, pixels, and pixel arrays” in the Raw Drawing and
Animation chapter of the Photon Programmer’s Guide
Arguments:
dc PgDrawBitmapCx() and PgDrawBitmapCxv() only. A void pointer to any
type of draw context. Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by PdCreateOffscreenContext()
bpl The number of bytes per line of image data (that is, the offset from one line
of data to the next).
Library:
ph
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.
PgDrawBitmap() and PgDrawBitmapv() work on the current draw context, while you
can specify the draw context for PgDrawBitmapCx() and PgDrawBitmapCxv().
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.
If you call the “v” or “Cxv”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:
DrawSimpleBitmap() {
PhPoint_t p = { 8, 8 };
PgSetTextColor( Pg_WHITE );
PgDrawBitmap( TestBitmap, 0, &p,
&TestBitmapSize, TestBitmapBPL, 0 );
}
will draw:
DrawBackFillBitmap() {
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(), PhPoint_t, PtCRC(),
PxLoadImage()
“Drawing attributes” and “Bitmaps” in the Raw Drawing and Animation chapter of the
Photon Programmer’s Guide
Synopsis:
int PgDrawEllipse( PhPoint_t const *center,
PhPoint_t const *radii,
unsigned int flags );
Arguments:
dc PgDrawEllipseCx() only. A void pointer to any type of draw context.
Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by PdCreateOffscreenContext()
center Defines the ellipse’s center.
radii Defines the ellipse’s x and y radii.
flags Must be one of the following:
• Pg_DRAW_STROKE — draw as a line.
• Pg_DRAW_FILL — fill the ellipse.
• Pg_DRAW_FILL_STROKE — fill the ellipse, then stroke it.
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.
Library:
ph
Description:
These functions build a command in the draw buffer to draw an ellipse.
PgDrawEllipse() works on the current draw context, while you can specify the draw
context for PgDrawEllipseCx().
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:
DrawFillElli() {
PhPoint_t c = { 80, 60 };
PhPoint_t r = { 72, 52 };
PgSetFillColor( Pg_PURPLE );
PgDrawEllipse( &c, &r, Pg_DRAW_FILL );
}
will draw:
DrawFillStrokeElli() {
PhPoint_t c = { 80, 60 };
PhPoint_t r = { 72, 52 };
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*(), PhPoint_t
“Arcs, ellipses, polygons, and rectangles” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Synopsis:
int PgDrawGradient( PhPoint_t *ul,
PhPoint_t *lr,
unsigned long gradient_type,
unsigned long transition_type,
unsigned long num_color_pts,
PgColor_t color1,
PgColor_t color2,
PgColor_t color3,
PgColor_t color4,
unsigned long table_size,
unsigned char *transition_table );
Arguments:
dc PgDrawGradientCx() only. A void pointer to any type of draw
context. Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by
PdCreateOffscreenContext()
ul, lr Pointers to PhPoint_t structures that define the upper left and
lower right corners of the rendering rectangle.
num_color_pts The resolution of the gradient. Basically it’s the number of colors
you want to have the driver calculate between the endpoint colors.
table_size The size of the user-defined transition table. This needs to be set
only if the transition type is Pg_GRAD_TABLE.
Library:
ph
Description:
These functions request the graphics driver to render a gradient. PgDrawGradient()
works on the current draw context, while you can specify the draw context for
PgDrawGradientCx().
Returns:
0 Success.
-1 An error occurred.
Examples:
// Draw a basic horizontal gradient from blue to red,
// with 20 colors in a rectangle of size 100 x 200
PhRect_t GradRect={{0,0},{100,200}};
PgDrawGradient(&GradRect.ul,&GradRect.lr,Pg_GRAD_HORIZONTAL,
Pg_GRAD_LINEAR,20,Pg_RED,Pg_BLUE,0,0,0,NULL);
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgCalcColorContrast(), PgColor_t, PhPoint_t
“Gradients” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Arguments:
dc PgDrawGradientCx() only. A void pointer to any type of draw
context. Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by
PdCreateOffscreenContext()
ul, lr Pointers to PhPoint_t structures that define the upper left and
lower right corners of the beveled box.
light_color A PgColor_t that defines the lightest color in the bevel gradient.
ul_flat_color The middle/neutral color in the bevel gradient of the top and left
edges. This is also the fill color of the box if Pg_BVB_FILL is set in
the flags.
lr_flat_color The middle/neutral color in the bevel gradient of the bottom and
right edges.
width The total width of the beveled border, including outlines and inlines.
If you specify any of the above arguments as Pg_TRANSPARENT, the value of the
argument will be converted to Pg_WHITE.
Library:
ph
Description:
These functions draw a beveled box with gradients. PgDrawGradientBevelBox()
works on the current draw context, while you can specify the draw context for
PgDrawGradientBevelBoxCx().
The only difference between these functions and PgBevelBox() and PgBevelBoxCx() is
that in the latter, the upper-left and the lower-right flat colors are identical.
The bits in the flags argument affect the appearance of the beveled box:
Pg_BVB_FULL_GRADIENTS
Each bevel has two gradients: light-to-flat and flat-to-dark. If this
isn’t set, the bevels have only one gradient; see the illustration
above.
Pg_BVB_DRAW_ALL_BV
Pg_BVB_DRAW_BOTTOM Pg_BVB_DRAW_LEFT
Pg_BVB_DRAW_RIGHT
Pg_BVB_DRAW_TOP
Draw the indicated edge or edges of the beveled box.
Pg_BVB_DRAW_ALL
Draw all bevels, inlines, and outlines of the beveled box.
Pg_BVB_DRAW_BITS
Turn on all of the above flag bits.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgBevelBox*(), PgColor_t, PgContrastBevelBox*(), PhPoint_t
“Gradients” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PgDrawGrid( PhRect_t const *r,
PhPoint_t const *g );
Arguments:
dc PgDrawGridCx() only. A void pointer to any type of draw context. Examples
of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by PdCreateOffscreenContext()
r A pointer to a PhRect_t structure that defines the upper left and lower right
corners of the grid box.
Library:
ph
Description:
These functions draw a rectangular grid. PgDrawGrid() works on the current draw
context, while you can specify the draw context for PgDrawGridCx().
These functions build 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 );
}
The following example uses PgDrawGrid() to generate 20 ticks. Every 5th tick is
made larger by calling PgDrawGrid() again with different parameters:
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:
PgSetStrokeCap*(), PgSetStrokeColor*(), PgSetStrokeDash*(), PgSetStrokeDither*(),
PgSetStrokeJoin*(), PgSetStrokeTransPat*(), PgSetStrokeWidth*(),
PgSetStrokeXORColor*(), PhPoint_t, PhRect_t
“Drawing attributes” and “Lines, pixels, and pixel arrays” in the Raw Drawing and
Animation chapter of the Photon Programmer’s Guide
Library:
ph
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 the dimensions
specified by the PhDim_t structure pointed to by 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 (see the
QNX Neutrino Utilities Reference). To calculate the tag, use PtCRC(). 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 possible types, see PhImage_t.
If you call the “v” forms 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:
PgDrawPhImage*(), PgDrawRepPhImagev(), PgDrawTImage*(), PgFlush*(),
PgSetFillColor*(), PgSetPalette*(), PgShmemCreate(), PhDim_t, PhImage_t,
PhMakeTransBitmap(), PhMakeTransparent(), PhPoint_t, PtCRC(), PxLoadImage()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Library:
ph
Description:
These functions build a command in the draw buffer to draw a line. Note that
PgDrawLine() and PgDrawLineCx() require two pointers to PhPoint_t structures,
whereas PgDrawILine() and PgDrawILineCx() take individual arguments.
PgDrawLine() and PgDrawILine() work on the current draw context, while you can
specify the draw context dc for PgDrawLineCx() and PgDrawILineCx().
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*(), PhPoint_t
“Drawing attributes” and “Lines, pixels, and pixel arrays” in the Raw Drawing and
Animation chapter of the Photon Programmer’s Guide
Arguments:
dc PgDrawMultiTextAreaCx() only. A void pointer to any type of draw
context. Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by
PdCreateOffscreenContext()
canvas A pointer to a PhRect_t structure that defines the area into which
the text is to be drawn.
text_flags Flags that affect how the text is drawn within the text-extent
rectangle:
• Pg_TEXT_LEFT — left align the text.
• Pg_TEXT_RIGHT — right align the text.
• Pg_TEXT_CENTER — horizontally center the text.
• Pg_BACK_FILL — backfill the text_extent rect with the currently
set fill color.
canvas_flags Flags that affect how the text-extent rectangle is aligned within the
canvas:
• Pg_TEXT_LEFT
• Pg_TEXT_RIGHT
Library:
ph
Description:
These functions draw multiline text within an area called a canvas, using the font
specified by a previous call to PgSetFont().
These functions call PgExtentMultiText() to compute the extent of the text. Text can be
aligned within the text-extent rectangle, and the text-extent rectangle itself can be
aligned within the canvas.
Returns:
0 Success.
-1 An error occurred.
Examples:
#include <stdio.h>
#include <stdlib.h>
#include <Pt.h>
PtCalcCanvas(widget, &canvas);
PgSetFillColor( Pg_RED );
PgDrawRect( &canvas, Pg_DRAW_FILL );
PgSetFillColor( Pg_BLUE );
PgSetTextColor( Pg_WHITE );
r = PgDrawMultiTextArea( s, 0, &canvas,
Pg_TEXT_RIGHT|Pg_BACK_FILL,
Pg_TEXT_CENTER|Pg_TEXT_MIDDLE, 10 );
if ( r == -1 )
fprintf( stderr, "\n Error." );
}
if (PtInit(NULL) == -1)
exit(EXIT_FAILURE);
PtRealizeWidget(base);
PtMainLoop();
return EXIT_SUCCESS;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawString*(), PgDrawText*(), PgDrawTextArea*(), PgExtentMultiText*(),
PgSetFillColor*(), PgSetFont*(), PgSetTextColor*(), PgSetTextDither*(),
PgSetTextTransPat*(), PgSetTextXORColor*(), PgSetUnderline*(), PhRect_t
“Text” in the Raw Drawing and Animation chapter of the Photon Programmer’s Guide
Library:
ph
Description:
These functions draw the provided image at the position specified in the PhPoint_t
structure pointed to by 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. These functions set the palettes for
palette-based images, and apply alpha blending if the alpha member of the
PhImage_t structure isn’t NULL.
You can pass the following bit in the flags argument:
Pg_GHOST or Pt_GHOST
Render the image using the ghost bitmap as a transparency mask.
If you call the “v” forms 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 “v” forms of this function automatically pass a
shared memory reference instead of the image.
Returns:
0 Success.
-1 The draw buffer couldn’t be resized enough to fit a single scan line of the
image (insufficient memory).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetImageRes(), PgDrawPhImageRect*v(), PgDrawRepPhImage*(), PgFlush*(),
PhCreateImage(), PhImage_t, PhMakeGhostBitmap(), PhMakeTransBitmap(),
PhMakeTransparent(), PhPoint_t, PhReleaseImage(), PmMemCreateMC(),
PmMemFlush(), PxRotateImage(), PxLoadImage()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Library:
ph
Description:
These functions draw a rectangular piece (specified by the PhRect_t structure
pointed to by rect) of 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.
PgDrawPhImageRectv() works on the current draw context, while you can specify the
draw context dc for PgDrawPhImageRectCxv().
If the image has a transparency mask, it’s used. These functions set the palettes for
palette-based images, and apply alpha blending if the alpha member of the
PhImage_t structure isn’t NULL.
The currently defined bits for the flags parameter are:
Pg_GHOST or Pt_GHOST
Render the image using the ghost bitmap as a transparency mask.
The rectangle is clipped to the image boundaries (i.e. the area bounded by (0,0) to
(image->size.w - 1, image->size.h - 1). If rect is NULL, the entire image is drawn.
The drawing of the piece of the image begins at pos (i.e. the rect argument doesn’t
introduce an additional offset.
For image formats where the number of pixels per byte is greater than 1 (e.g.
Pg_IMAGE_GRADIENT_NIBBLE, Pg_IMAGE_PALETTE_NIBBLE,
Pg_BITMAP_BACKFILL, and Pg_BITMAP_TRANSPARENT), the portion specified by
rect might be grown horizontally so that it falls on even byte boundaries.
Returns:
0 Success.
-1 The draw buffer couldn’t be resized enough to fit a single scan line of the image
(insufficient memory).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetImageRes(), PgDrawPhImage*(), PgDrawRepPhImage*(), PhCreateImage(),
PhImage_t, PhMakeGhostBitmap(), PhMakeTransBitmap(), PhMakeTransparent(),
PhPoint_t, PhRect_t, PhReleaseImage(), PmMemCreateMC(), PmMemFlush(),
PxRotateImage(), PxLoadImage()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Library:
ph
Description:
These functions build a command in the draw buffer to draw a pixel. For
PgDrawPixel*(), the pt argument points to a PhPoint_t structure that defines the
pixel location; for PgDrawIPixel*(), x and y specify the location.
PgDrawPixel() and PgDrawIPixel() work on the current draw context, while you can
specify the draw context dc for PgDrawPixelCx() and PgDrawIPixelCx().
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*(), PgFlush*(), PgSetStrokeColor*(), PgSetStrokeDither*(),
PhPoint_t
“Drawing attributes” and “Lines, pixels, and pixel arrays” in the Raw Drawing and
Animation chapter of the Photon Programmer’s Guide
PgDrawPixelArrayCx(), PgDrawPixelArrayCxv()
Draw multiple points
Synopsis:
int PgDrawPixelArray( PhPoint_t const *ptr,
int num,
PhPoint_t const *pos );
Library:
ph
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.
PgDrawPixelArray() and PgDrawPixelArrayv() work on the current draw context,
while you can specify the draw context dc for PgDrawPixelArrayCx() and
PgDrawPixelArrayCxv().
If you call the “v” forms 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() or PgFlushCx() 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
Signal handler No
Thread No
See also:
PgDrawPixel*(), PgDrawIPixel*(), PgFlush*(), PgSetStrokeColor*(),
PgSetStrokeDither*(), PhPoint_t
“Drawing attributes” and “Lines, pixels, and pixel arrays” in the Raw Drawing and
Animation chapter of the Photon Programmer’s Guide
Library:
ph
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 for all these functions.
Pg_DRAW_STROKE
Draw a stroked polygon.
Pg_DRAW_FILL_STROKE
Draw a filled polygon, then stroke it.
Pg_RELATIVE Use relative coordinates to draw the polygon. Each point is relative
to the previous point.
For absolute coordinates, pos is added to each point pointed to by ptr. For relative
coordinates, the first coordinate is the sum of pos and the first point of the array; any
subsequent coordinate is the sum of the previous point and the next point of the array.
If you call the “v” forms 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() or PgFlushCx() 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:
DrawRelPoly() {
PhPoint_t o = { 0, 0 };
PhPoint_t p[] = { 80, 8, 40, 112, -104, -88,
PgSetStrokeColor( Pg_WHITE );
PgSetFillColor( Pg_PURPLE );
PgDrawPolygon( &p, 5, &o, Pg_DRAW_FILL_STROKE |
Pg_CLOSED |
Pg_RELATIVE );
}
will draw:
DrawUnclosedPoly() {
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 );
}
will draw:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgFlush(), PhPoint_t
To draw stroked polygons, see also:
PgSetStrokeColor*(), PgSetStrokeCap*(), PgSetStrokeDash*(), PgSetStrokeDither*(),
PgSetStrokeJoin*(), PgSetStrokeWidth*()
To draw filled polygons, see also:
PgSetFillColor*(), PgSetFillDither*(), PgSetFillTransPat*()
“Arcs, ellipses, polygons, and rectangles” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Library:
ph
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.
PgDrawRect() and PgDrawIRect() work on the current draw context, while you can
specify the draw context dc for PgDrawRectCx() and PgDrawIRectCx().
The flags argument must be one of the following:
Pg_DRAW_STROKE
Draw as a line.
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:
DrawStrokeRect() {
PgSetStrokeColor( Pg_WHITE );
PgDrawIRect( 8, 8, 152, 112, Pg_DRAW_STROKE );
}
will draw:
DrawFillStrokeRect() {
PgSetFillColor( Pg_PURPLE );
PgSetStrokeColor( Pg_WHITE );
PgDrawIRect( 8, 8, 152, 112, Pg_DRAW_FILL_STROKE );
}
will draw:
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawBeveled*(), PgDrawRoundRect*(), PgSetFillColor*(), PgSetFillDither*(),
PgSetFillTransPat*(), PhRect_t
“Arcs, ellipses, polygons, and rectangles” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Library:
ph
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().
PgDrawRepBitmap() and PgDrawRepBitmapv() work on the current draw context,
while you can specify the draw context dc for PgDrawRepBitmapCx() and
PgDrawRepBitmapCxv().
• 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 OR flags with Pg_REPBM_ALTERNATE, all the bitmaps are drawn twice; the
second time the position is offset by half of space.x and space.y.
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 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 (see the
QNX Neutrino Utilities Reference). To calculate the tag, use PtCRC(). This argument
is ignored if you set it to 0.
If you call the “v” forms 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,
draws:
DrawAltRepBitmap() {
PhPoint_t p = { 0, 0 };
PhPoint_t rep = { 3, 2 };
PhPoint_t space;
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
Library:
ph
Description:
These 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.
PgDrawRepImageCx(), PgDrawRepImageCxv()
• Draw each row of images space.y pixels below the previous row.
PgDrawRepImage() and PgDrawRepImagev() work on the current draw context,
while you can specify the draw context dc for PgDrawRepImageCx() and
PgDrawRepImageCxv().
If you OR flags with Pg_REPBM_ALTERNATE, all the images are drawn twice; the
second time the position is offset by half of space.x and space.y.
The image formats are as described for PhImage_t. Specify the image format by
ORing it into the flags argument.
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 (see the
QNX Neutrino Utilities Reference). To calculate the tag, use PtCRC(). This argument
is ignored if you set it to 0.
If you call the “v” forms 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() or PgFlushCx() before you modify the image.
If the data is in shared memory, the “v” forms 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 PgDrawRepPhImage( PhImage_t const *image,
int flags,
PhPoint_t const *pos,
PhPoint_t const *rep,
PhPoint_t const *space );
Library:
ph
Description:
These functions unite the convenience of PgDrawPhImage*() and the ability to tile
images of PgDrawRepImage*() or PgDrawRepBitmap*().
These functions draw:
• the first image at pos and the next image space.x pixels to the right
• the image rep.x times in the x direction and rep.y times in the y direction
The pos, rep, and space arguments all point to structures of type PhPoint_t.
You can pass any combination of the following bits in the flags argument:
Pg_GHOST or Pt_GHOST
Render the image using the ghost bitmap as a transparency mask.
Pg_REPBM_ALTERNATE
Draw all the images twice; the second time the position is offset by half of
space.x and space.y.
If you call the “v” forms 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() or PgFlushCx() before you modify the image.
If the data is in shared memory, the “v” 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
See also:
ApGetImageRes(), PgDrawPhImage*(), PgDrawPhImageRect*(),
PgDrawRepImage*(), PgDrawRepBitmap*(), PgFlush*(), PhCreateImage(),
PhImage_t, PhMakeGhostBitmap(), PhMakeTransBitmap(), PhMakeTransparent(),
PhPoint_t, PhReleaseImage(), PmMemCreateMC(), PmMemFlush(),
PxRotateImage(), PxLoadImage()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Library:
ph
Description:
These functions build a command in the draw buffer to draw a rounded rectangle. The
rect argument is a pointer to a PhRect_t structure that defines the extent of the
rectangle. The radii is a pointer to a PhPoint_t structure that 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).
PgDrawRoundRect() works on the current draw context, while you can specify the
draw context dc for PgDrawRoundRectCx().
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 );
}
Co. KG.
will draw:
DrawFillRRect() {
PhRect_t rect = { 8, 8, 152, 112 };
PhPoint_t radii = { 32, 32 };
PgSetFillColor( Pg_PURPLE );
PgDrawRoundRect( &rect, &radii, Pg_DRAW_FILL );
}
will draw:
DrawFillStrokeRRect() {
PhRect_t rect = { 8, 8, 152, 112 };
PhPoint_t radii = { 1000, 1000 };
PgSetFillColor( Pg_PURPLE );
PgSetStrokeColor( Pg_WHITE );
PgDrawRoundRect( &rect, &radii, Pg_DRAW_FILL_STROKE );
}
will draw:
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawBeveled*(), PgDrawIRect*(), PgDrawRect*(), PgSetFillColor*(),
PgSetFillDither*(), PgSetFillTransPat*(), PhPoint_t, PhRect_t
“Arcs, ellipses, polygons, and rectangles” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Library:
ph
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
The number of spans is defined by the num parameter. The location of the spans is
offset by the pos parameter.
You can set flags to one of the following:
If you call the “v” forms 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() or PgFlushCx() before you modify the list.
PgDrawSpan() and PgDrawSpanv() work on the current draw context, while you can
specify the draw context dc for PgDrawSpanCx() and PgDrawSpanCxv().
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*(), PhPoint_t
“Arcs, ellipses, polygons, and rectangles” in the Raw Drawing and Animation chapter
of the Photon Programmer’s Guide
Library:
ph
Description:
These convenience functions for PgDrawText*() 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 “v” forms 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.
PgDrawString() and PgDrawStringv() work on the current draw context, while you
can specify the draw context dc for PgDrawStringCx() and PgDrawStringCxv().
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
continued. . .
Safety
Signal handler No
Thread No
See also:
PgDrawMultiTextArea*(), PgDrawText*(), PgDrawTextArea*(), PgFlush*(),
PgSetFillColor*(), PgSetFillDither*(), PgSetFillTransPat*(), PgSetFont*(),
PgSetTextColor*(), PgSetTextDither*(), PgSetTextTransPat*(),
PgSetTextXORColor*(), PgSetUnderline*(), PhPoint_t
“Text” in the Raw Drawing and Animation chapter of the Photon Programmer’s Guide
strlen() in the QNX Neutrino Library Reference
Synopsis:
int PgDrawText( char const *ptr,
int len,
PhPoint_t const *pos,
int flags );
Library:
ph
Description:
Each of these functions builds a command in the draw buffer to draw the text indicated
by ptr at location pos, using the font specified in a previous call to PgSetFont().
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.
PgDrawTextChars() assumes that len is the number of characters to draw. Using this
number, PgDrawTextChars() determines the number of bytes required to store the
string.
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.
If you call the “v” 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() or PgFlushCx() 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:
DrawSimpleText() {
char *s = "Hello World!";
PhPoint_t p = { 8, 30 };
char Helvetica18[MAX_FONT_TAG];
if(PfGenerateFontName("Helvetica", 0, 18,
Helvetica18) == NULL) {
perror("Unable to find font");
} else {
PgSetFont( Helvetica18 );
}
PgSetTextColor( Pg_WHITE );
PgDrawText( s, strlen( s ), &p, 0 );
}
Hello W orld!
DrawBackFillText() {
char *s = "Hello World!";
PhPoint_t p = { 8, 30 };
char Helvetica18[MAX_FONT_TAG];
if(PfGenerateFontName("Helvetica", 0, 18,
Helvetica18) == NULL) {
perror("Unable to find font");
} else {
PgSetFont( Helvetica18 );
}
PgSetTextColor( Pg_WHITE );
PgSetFillColor( Pg_PURPLE );
PgDrawText( s, strlen( s ), &p, Pg_BACK_FILL );
}
Hello W orld!
DrawUnderlineText() {
char *s = "Hello World!";
PhPoint_t p = { 8, 30 };
char Helvetica18[MAX_FONT_TAG];
if(PfGenerateFontName("Helvetica", 0, 18,
Helvetica18) == NULL) {
perror("Unable to find font");
} else {
PgSetFont( Helvetica18 );
}
PgSetTextColor( Pg_WHITE );
PgSetUnderline( Pg_RED, Pg_TRANSPARENT, 0 );
PgDrawText( s, strlen( s ), &p, 0 );
PgSetUnderline( Pg_TRANSPARENT, Pg_TRANSPARENT, 0 );
}
Hello W orld!
DrawBackFillUnderlineText() {
char *s = "Hello World!";
PhPoint_t p = { 8, 30 };
char Helvetica18[MAX_FONT_TAG];
if(PfGenerateFontName("Helvetica", 0, 18,
Helvetica18) == NULL) {
perror("Unable to find font");
} else {
PgSetFont( Helvetica18 );
}
PgSetTextColor( Pg_WHITE );
PgSetFillColor( Pg_PURPLE );
PgSetUnderline( Pg_RED, Pg_TRANSPARENT, 0 );
Hello W orld!
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawMultiTextArea*(), PgDrawString*(), PgFlush*(), PgSetFillColor*(),
PgSetFillDither*(), PgSetFillTransPat*(), PgSetFont*(), PgSetTextColor*(),
PgSetTextDither*(), PgSetTextTransPat*(), PgSetTextXORColor*(),
PgSetUnderline*(), PhPoint_t
“Text” in the Raw Drawing and Animation chapter of the Photon Programmer’s Guide
Synopsis:
int PgDrawTextArea( char const *ptr,
int len,
PhRect_t const *rect,
int flags );
Library:
ph
Description:
These functions draw text within an area, using the font specified by a previous call to
PgSetFont*(). This area is clipped to the dimensions of the rectangle specified by the
PhRect_t structure pointed to by rect.
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 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_ELLIPSIS If the text doesn’t fit into the specified rectangle, draw an
ellipsis (...) instead of part of the text, in accordance with the
text’s alignment. For example, if the text is left-aligned, draw
the ellipsis instead of the end of the text; if the text is
right-aligned, draw the ellipsis instead of the beginning.
Pg_TEXT_ELLIPSIS_MIDDLE
Draw the ellipsis in the middle of the string. You must also set
Pg_TEXT_ELLIPSIS.
Pg_TEXT_ELLIPSIS_INVERT
Invert the ellipsis location. You must also set
Pg_TEXT_ELLIPSIS.
PgDrawTextArea() works on the current draw context, while you can specify the draw
context dc for PgDrawTextAreaCx().
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:
1 Calculate the position at which to print the text, based on the extent of the text
and the desired alignment inside the drawing area.
See also:
PgDrawMultiTextArea*(), PgDrawString*(), PgDrawText*(), PgFlush*(),
PgSetFillColor*(), PgSetFillDither*(), PgSetFillTransPat*(), PgSetFont*(),
PgSetTextColor*(), PgSetTextDither*(), PgSetTextTransPat*(),
PgSetTextXORColor*(), PgSetUnderline(), PhRect_t
“Text” in the Raw Drawing and Animation chapter of the Photon Programmer’s Guide
Library:
ph
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*()
with two additions, TransPtr and TransBPL.
The TransPtr argument points to a bitmap that’s TransBPL bytes wide. This defines a
bitmap that only allows the image to draw where there’s a value of 1 in the bitmap.
Any value of 0 in the bitmap prevents the image from drawing. The leftmost pixel
corresponds to the top bit of the first byte in the mask.
PgDrawTImage() and PgDrawTImagev() work on the current draw context, while you
can specify the draw context dc for PgDrawTImageCx() and PgDrawTImageCxv().
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*(), PgDrawPhImage*(), PgDrawRepPhImage*(), PhDim_t,
PhImage_t, PhMakeTransBitmap(), PhMakeTransparent(), PhPoint_t
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Library:
ph
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:
pos.x + *(ptr+0), pos.y + (delta * 0)
pos.x + *(ptr+1), pos.y + (delta * 1)
pos.x + *(ptr+2), pos.y + (delta * 2)
...
pos.x + *(ptr+num-1), pos.y + (delta * (num-1))
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 “v” forms 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.
PgDrawTrend() and PgDrawTrendv() work on the current draw context, while you can
specify the draw context dc for PgDrawTrendCx() and PgDrawTrendCxv().
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;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawPolygon*(), PgSetStrokeColor*(), PgSetStrokeWidth*(), PgFlush*(),
PhPoint_t
“Drawing attributes” and “Lines, pixels, and pixel arrays” in the Raw Drawing and
Animation chapter of the Photon Programmer’s Guide
Synopsis:
PhRect_t *PgExtentMultiText( PhRect_t *extent,
PhPoint_t *pos,
char *font,
char *str,
unsigned n,
int linespacing );
Library:
ph
Description:
This function determines the extent that would be occupied if str were rendered at pos,
using font (which you should create by calling PfGenerateFontName()). The extent
information is stored in the PhRect_t structure pointed to by extent.
The function calculates the extent of the first n characters of the string. To calculate
the extent of the entire string, set n to zero. If you pass pos as NULL, it’s assumed to
be (0,0).
The linespacing is in pixels. A positive linespacing has the obvious effect: increased
spacing between lines, and a taller extent. A negative linespacing causes the function
to compute an extent for overlapping lines. Larger negative linespacing make the
extent decrease in height. The minimum height of the extent is the height of font.
Returns:
The same pointer as extent, or NULL if an error occurred.
Examples:
The following fragment determines the extent of a multiline string drawn in 14-point
Helvetica. The characters in neighboring lines overlap by 4 pixels.
PhRect_t extent;
char Helvetica14[MAX_FONT_TAG];
if(PfGenerateFontName("Helvetica", 0, 14,
Helvetica14) == NULL) {
perror("Unable to find font");
} else {
if (PgExtentMultiText( &extent, NULL, Helvetica14,
"First line\nSecond line\nThird line", 0, -4))
printf( "Width: %d Height: %d\n",
extent.lr.x - extent.ul.x + 1,
extent.lr.y - extent.ul.y + 1);
else
printf( "Error.\n" );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfGenerateFontName(), PgDrawMultiTextArea(), PgDrawTextArea(), PgExtentText(),
PhPoint_t, PhRect_t
“Text” in the Raw Drawing and Animation chapter of the Photon Programmer’s Guide
Synopsis:
PhRect_t *PgExtentText( PhRect_t *extent,
PhPoint_t const *pos,
char const *font,
char const *str,
unsigned n );
Library:
ph
Description:
This function determines the extent that would be occupied if str were rendered at pos,
using font (which you should create by calling PfGenerateFontName()). The extent
information is stored in the PhRect_t structure pointed to by extent. 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:
The same as pointer extent, or NULL if an error occurred.
Examples:
The following fragment determines the extent of a string drawn in 18-point, bold,
italic Helvetica:
PhRect_t extent;
char Helvetica18bi[MAX_FONT_TAG];
if(PfGenerateFontName("Helvetica",
PF_STYLE_BOLD | PF_STYLE_ITALIC, 18,
Helvetica18bi) == NULL) {
perror("Unable to find font");
} else {
if( PgExtentText( &extent, NULL, Helvetica18bi,
"Hello World!", 0 ) ) {
printf( "Ascent: %d Descent: %d Width: %d\n",
-extent.ul.y, extent.lr.y,
extent.lr.x - extent.ul.x + 1 );
} else {
printf( "Error.\n" );
}
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfGenerateFontName(), PgDrawMultiTextArea(), PgDrawText(), PgExtentMultiText(),
PgSetFont(), PhPoint_t, PhRect_t
“Text” in the Raw Drawing and Animation chapter of the Photon Programmer’s Guide
Library:
ph
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.
PgFlush() and PgFFlush() work on the current draw context, while you can specify
the draw context dc for PgFlushCx() and PgFFlushCx().
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 );
PgDrawILine( 700, 700, 0, 0 );
/*
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgClearDrawBuffer*(), PgSetDrawBufferSize*(), PhEvent_t
Synopsis:
PgColorModel_t * PgGetColorModel( void );
Arguments:
gc PgGetColorModelCx() only. A pointer to a graphics context, as returned by
PgCreateGC() or PgGetGC().
Library:
ph
Description:
These functions get the current color model. For descriptions of the currently
supported color models, see PgColor_t. For a list of available color models, see
Pt_ARG_CS_COLOR_MODELS.
PgGetColorModel() works on the current graphics context, while you can specify the
graphics context for PgGetColorModelCx().
Returns:
The current color model.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor_t, PgSetColorModel*()
Synopsis:
PhGC_t *PgGetGC( void );
Arguments:
dc PgGetGCCx() only. A pointer to a draw context.
Library:
ph
Description:
These functions get the current graphics context. PgGetGC() works on the current
draw context, while you can specify the draw context for PgGetGCCx().
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 PgGetGraphicsHWCaps (PgHWCaps_t *caps );
Arguments:
caps A pointer to a PgHWCaps_t structure that the function can fill with the
hardware capabilities; see below.
Library:
ph
Description:
This function determines the hardware capabilities and fills out the structure pointed to
by caps.
• If you have more than one card in your system, you must target this function at a
specific card by calling PdSetTargetDevice().
PgHWCaps_t
The PgHWCaps_t structure includes at least the following members:
current_video_mode The number of the mode the video card is currently in.
current_rrate Current refresh rate, in Hz. A value of 0 means the refresh rate
is the default or not supported.
current_mode_flags Current flags for the mode. The only value currently is
Pg_CM_DOUBLE_BUFFERED, meaning that double buffering
is being used.
currently_available_video_ram
The total currently available video memory.
currently_available_crtc_ram
The currently available CRTC-safe video memory.
currently_available_non_crtc_ram
The currently available non-CRTC-safe video memory.
min_pitch The minimum number of bytes per scan line for any offscreen
context. The driver already makes sure that any request for
offscreen memory is at least this big; this member is here just
to help with debugging and to help applications make efficient
use of the video memory (for example, some chips have a
minimum pitch of 1024)
max_pitch The largest number of bytes per scan line that the driver
accepts.
mult_pitch The number of bytes per scan line must be a multiple of this
value (the driver ensures this, too).
The pitch values can change for each mode; you should use them only after changing
to the desired mode.
Pg_2D_ACCELERATOR
This video card has a 2D accelerator.
Pg_VIDEO_OVERLAY
This video card has video-overlay support.
Pg_OFFSCREEN This video card can use offscreen video memory.
Pg_LINEAR_FRAME_BUFFER_CAPABLE
This video card can use a linear frame buffer.
These fields only say that it is possible to get these features on this video card. You
still need to check the mode capabilities to see if they’re available in any given mode.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdSetTargetDevice(), PgGetVideoMode(), PgGetVideoModeInfo(),
PgGetVideoModeList(), PgSetVideoMode()
“Video modes” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PgGetLayerCaps( int layer,
int format_index,
PgLayerCaps_t *const caps );
Arguments:
layer The layer index, which must be 0 or greater.
Library:
ph
Description:
PgGetLayerCaps() queries the capabilities of the given layer, in the given format. You
can use the format_index to iterate through all of the available layer formats. An error
is returned when format_index exceeds the number of supported formats.
Returns:
0 Success.
Errors:
EFAULT The caps argument is NULL.
EINVAL The layer index is invalid, or the format_index if greater than the
number of formats.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdSetTargetDevice(), PgLayerCaps_t
“Layers” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
PgColor_t PgGetOverlayChromaColor( void );
Library:
ph
Description:
This function returns the standard color that’s used for Video Overlay chroma-keying
operations.
Returns:
A composite color.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgConfigScalerChannel(), PgColor_t, PgCreateVideoChannel(),
PgDestroyVideoChannel(), PgGetScalerCapabilities(), PgNextVideoFrame(),
PgScalerCaps_t, PgScalerProps_t, PgVideoChannel_t
“Video overlay” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PgGetPalette( PgColor_t *palette );
Library:
ph
Description:
This function queries the graphics driver for the current palette. A palette is an array of
_Pg_MAX_PALETTE RGB (PgColor_t) 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
See also:
PdSetTargetDevice(), PgColor_t
“Color” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
PhRid_t PgGetRegion( void );
Arguments:
dc PgGetRegionCx() only. A void pointer to any type of draw context. Examples
of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by PdCreateOffscreenContext()
Library:
ph
Description:
These functions get the ID of the region that currently emits draw events.
PgGetRegion() works on the current draw context, while you can specify the draw
context for PgGetRegionCx().
Returns:
The ID of the region.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgSetRegion*()
Synopsis:
int PgGetScalerCapabilities(
PgVideoChannel_t *channel,
int format_index,
PgScalerCaps_t *vcaps );
Library:
ph
Description:
This function gets the capabilities of the Video Overlay scaler specified by channel for
the video data format specified by format_index. The capabilities are stored in the
PgScalerCaps_t structure pointed to by vcaps.
To find out about all available video data formats, call with increasing values for
format_index, starting at zero, until -1 is returned.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgConfigScalerChannel(), PgCreateVideoChannel(), PgDestroyVideoChannel(),
PgGetOverlayChromaColor(), PgNextVideoFrame(), PgScalerCaps_t,
PgScalerProps_t, PgVideoChannel_t
“Video overlay” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PgGetSurfaceGFSid (
PgSurface_t * surf ,
uint32_t * sid );
Arguments:
surf A handle to a surface.
Library:
ph
Description:
This function returns the GF surface id (sid) of a given PgSurface_t.
Returns:
An integer representing the surface ID.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateOffscreenContextGF(), PdDupOffscreenContext(),
PdGetOffscreenContextPtr(), PdOffscreenContext_t,
PdSetOffscreenTranslation(), PdSetTargetDevice(), PgContextBlit(),
PgSwapDisplay(), PhDCCreate(), PhDCRelease()
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PgGetVideoMode( PgDisplaySettings_t *settings );
Library:
ph
Description:
This function gets the current video mode, storing information about it in the
PgDisplaySettings_t structure pointed to by settings, which includes at least the
following:
unsigned mode The number of the current mode for the video card.
int refresh The refresh rate, in Hz. A value of 0 indicates that the default
refresh rate for this mode (usually 60Hz) is being used.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdSetTargetDevice(), PgGetGraphicsHWCaps(), PgGetVideoModeInfo(),
PgGetVideoModeList(), PgSetVideoMode()
“Video modes” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PgGetVideoModeInfo(
unsigned short mode_number,
PgVideoModeInfo_t *mode_info );
Library:
ph
Description:
This function requests detailed information on the video mode specified by the
mode_number (taken from a PgVideoModes_t structure — see
PgGetVideoModeList()).
PgVM_MODE_CAP1_OFFSCREEN
This driver supports offscreen mode.
PgVM_MODE_CAP1_2D_ACCEL
The 2D accelerator works in this mode.
PgVM_MODE_CAP1_VIDEO_OVERLAY
Video overlay works in this mode.
PgVM_MODE_CAP1_LINEAR
This mode’s memory is linear (not banked switched).
PgVM_MODE_CAP1_DOUBLE_BUFFER
This mode can be double buffered.
PgVM_MODE_CAP1_TRIPLE_BUFFER
This mode can be triple buffered.
PgVM_MODE_CAP1_REFRESH_RATE
This mode supports multiple refresh rates.
PgVM_MODE_CAP2_BITBLT
Hardware bit-blits.
PgVM_MODE_CAP2_RECTANGLE
Hardware rectangles.
PgVM_MODE_CAP2_LINES
Hardware lines.
PgVM_MODE_CAP2_POLYGONS
Hardware polygons.
PgVM_MODE_CAP2_FULL_ROPS
All 256 raster operations in hardware.
PgVM_MODE_CAP2_PATTERN
Hardware patterns (transparent or not).
PgVM_MODE_CAP2_CHROMA
Hardware chroma key capabilities.
PgVM_MODE_CAP2_ALPHA_BLEND
Hardware alpha blending capabilities.
PgVM_MODE_CAP2_PLANE_MASK
Hardware plane masking.
PgVM_MODE_CAP2_SCALED_BLIT
Hardware accelerated scaled blit
PgVM_MODE_CAP2_DWORD
Accelerated DWORD-aligned data.
PgVM_MODE_CAP2_WORD
Accelerated WORD-aligned data.
PgVM_MODE_CAP2_BYTE
Accelerated BYTE-aligned data.
PgVM_MODE_CAP2_SYSTEM_RAM
Transfers to and from system RAM using the hardware.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdSetTargetDevice(), PgGetGraphicsHWCaps(), PgGetVideoMode(),
PgGetVideoModeList(), PgSetVideoMode()
“Video modes” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PgGetVideoModeList( PgVideoModes_t *mode_list );
Library:
ph
Description:
This function queries the graphics driver for a list of video modes that it supports. The
list is an array of short entries that represent mode numbers that the drivers use to
identify a video mode.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdSetTargetDevice(), PgGetGraphicsHWCaps(), PgGetVideoMode(),
PgGetVideoModeInfo(), PgSetVideoMode()
“Video modes” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PgColor_t PgGray( int level );
Arguments:
level The gray level, which ranges from 0 (black) to 255 (white). Intermediate
values produce various shades of gray.
Library:
ph
Description:
This macro converts a gray value into a PgColor_t structure. 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(), PgColor_t, PgCMY(), PgGreenValue(), PgHSV(), PgRedValue(),
PgRGB(), PgSetFillColor(), PgSetFillDither()
“Color” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PgGrayValue( PgColor_t color );
Arguments:
color A composite color value, of type PgColor_t.
Library:
ph
Description:
This macro converts a composite 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(), PgColor_t, PgGreenValue(), PgHSV(), PgRedValue(),
PgRGB(), PgSetFillColor(), PgSetFillDither()
“Color” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PgGreenValue( PgColor_t color );
Arguments:
color A composite color value, of type PgColor_t.
Library:
ph
Description:
This macro extracts the green color component from a composite color value. 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:
PgAlphaValue(), PgARGB(), PgBlueValue(), PgCMY(), PgColor_t, PgHSV(),
PgRedValue() PgRGB(), PgSetFillColor(), PgSetFillDither()
“Color” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
PgColor_t PgHSV( unsigned H, int S, int V );
Library:
ph
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(), PgColor_t, PgGreenValue(), PgHSV2RGB(),
PgRedValue(), PgRGB(), PgRGB2HSV(), PgSetFillColor(), PgSetFillDither()
“Color” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
PgColor_t PgHSV2RGB( PgColorHSV_t hsv_color );
Library:
ph
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()
“Color” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
typedef struct {
unsigned int format;
long owner;
int max_data_width;
int max_data_height;
int max_src_width;
int max_src_height;
int max_dst_width;
int max_dst_height;
int min_dst_width;
int min_dst_height;
int max_x_scale;
int max_y_scale;
int min_x_scale;
int min_y_scale;
int format_flags;
Description:
The PgLayerCaps_t structure describes the capabilities of a layer. To fill in this
structure for a layer, call PgGetLayerCaps(). To set the capabilities, call
PgSetLayerArg().
The members of the PgLayerCaps_t structure include:
format The layer format that corresponds to the format index that you pass
to PgGetLayerCaps(); one of:
• Pg_LAYER_FORMAT_PAL8
• Pg_LAYER_FORMAT_ARGB1555
• Pg_LAYER_FORMAT_RGB565
• Pg_LAYER_FORMAT_RGB888
• Pg_LAYER_FORMAT_ARGB8888
• Pg_LAYER_FORMAT_YUY2
• Pg_LAYER_FORMAT_UYVY
• Pg_LAYER_FORMAT_YVYU
• Pg_LAYER_FORMAT_V422
• Pg_LAYER_FORMAT_YVU9
• Pg_LAYER_FORMAT_YV12
• Pg_LAYER_FORMAT_YUV420
• Pg_LAYER_FORMAT_YUV_AYUV
• Pg_LAYER_FORMAT_YUV_NV12
alpha_caps Alpha capabilities. Only global and per-pixel alpha blending are
currently supported. Alpha maps aren’t supported for blending
between layers.
alpha_combine_caps
Alpha combine capabilities.
• Pg_LAYER_ALPHA_COMBINE_CAP_SPP_WITH_DG — source per-pixel
alpha blending with destination global alpha multiplier
supported.
• Pg_LAYER_ALPHA_COMBINE_CAP_SG_WITH_DPP — destination
per-pixel alpha blending with source global alpha multiplier
supported.
• Pg_LAYER_ALPHA_COMBINE_CAP_SPP_WITH_DPP — source per-pixel
with alpha blending with destination per-pixel alpha blending
supported.
max_y_scale The maximum scaling factor for scaling up in the vertical direction:
• 1 — you can’t scale up.
• > 1 — the height of the destination viewport can be up to
max_y_scale times the height of the source viewport.
Values less than 1 are invalid.
min_x_scale The maximum scaling factor for scaling down in the horizontal
direction:
• 1 — you can’t scale down.
• > 1 — the width of the source viewport can be up to
min_x_scale times the width of the destination viewport.
Values less than 1 are invalid.
min_y_scale The maximum scaling factor for scaling down in the vertical
direction:
• 1 — you can’t scale down.
• > 1 — the height of the source viewport can be up to
min_y_scale times the height of the destination viewport.
Values less than 1 are invalid.
format_flags Flags that specify the packing or byte order of the format member;
this can be 0, or one of the following:
• Pg_LAYER_FORMAT_PKLE — 16-bit little endian packed
• Pg_LAYER_FORMAT_PKBE — 16-bit big endian packed
• Pg_LAYER_FORMAT_PACK — 16-bit, packing is indeterminate
• Pg_LAYER_FORMAT_BO_BGRA — 32-bit, BGRA byte-order
• Pg_LAYER_FORMAT_BO_ARGB — 32-bit, ARGB byte-order
Classification:
Photon
See also:
PgGetLayerCaps(), PgSetLayerArg(), PhImage_t
“Layers” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PgLockLayer( int layer );
Arguments:
layer The layer index, which must be 0 or greater.
Library:
ph
Description:
PgLockLayer() acquires exclusive use of a layer by an application. To unlock a layer,
call PgUnlockLayer().
Other applications may not use PgSetLayerSurface() or PgSetLayerArg() on a locked
surface.
Your application should unlock its layers before it exits. You can lock a layer multiple
times, but need to unlock it only once.
Returns:
0 Success.
Errors:
EBUSY The specified layer is locked by another application.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdSetTargetDevice(), PgSetLayerArg(), PgSetLayerSurface(), PgUnlockLayer()
“Layers” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
typedef struct _Pg_map {
PhDim_t dim;
short unsigned bpl;
short unsigned bpp;
char *map;
} PgMap_t;
Description:
The PgMap_t structure defines an alpha blend map. Its members include:
dim A PhDim_t structure that defines the size of area covered by the map, in
pixels.
Classification:
Photon
See also:
PgAlphaOff(), PgAlphaOn(), PgColor_t, PgSetAlpha(), PgSetAlphaBlend(),
PhDim_t
“Alpha Blending Support” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PgMultiBlit( unsigned short nrects,
const PhRect_t rects[],
const PhPoint_t *offset );
Arguments:
dc PgMultiBlitCx() only. A void pointer to any type of draw context.
Examples of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by PdCreateOffscreenContext()
rects[] A pointer to an array of PhRect_t structures that define the areas the
function blits. The areas can overlap; Photon detects the overlaps and the
contents are blitted only once.
offset A pointer to a PhPoint_t that defines an offset for the blitted area rect.
Library:
ph
Description:
These functions “blit” the multi-rectangular area that is defined by rects[]. The area is
blitted by the given offset. When the draw context is the default context, other
windows aren’t affected by the blit.
PgMultiBlit() blits the region defined by the region set for the current draw context,
while PgMultiBlitCx() lets you define the draw context dc.
Returns:
A nonnegative value
Success.
-1 The blit failed, possibly because the Photon Manager wasn’t running.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgBlit*(), PhBlit(), PhMultiBlit(), PhMultiBlit(), PhPoint_t, PhRect_t,
PtClippedBlit(), PtWidgetRid()
Synopsis:
int PgNextVideoFrame( PgVideoChannel_t *channel );
Library:
ph
Description:
PgNextVideoFrame() returns the index of the video buffers into which your application
should copy the video frame data. Call this function before transferring a frame of
video data to the video overlay scaler.
Returns:
The index of the video buffer, or -1 if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgConfigScalerChannel(), PgCreateVideoChannel(), PgDestroyVideoChannel(),
PgGetOverlayChromaColor(), PgGetScalerCapabilities(), PgScalerCaps_t,
PgScalerProps_t, PgVideoChannel_t
“Video overlay” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PgPHookRegister( char const *phook );
Arguments:
phook The name of the hook module that you want to load; one of:
• PHOOK_DFLT — the default module.
• PHOOK_ROTATE90 — rotate the display 90 degrees.
• PHOOK_ROTATE180 — rotate the display 180 degrees.
• PHOOK_ROTATE270 — rotate the display 270 degrees.
Library:
ph
Description:
This function loads a Photon hook module, such as those that rotate the display, “on
the fly.” No surface or layer is lost during the installation of the module.
You can also use the phook option in the configuration file for io-display; for more
information, see the Utilities Reference.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
io-display; in the Utilities Reference
Synopsis:
PhImage_t *PgReadScreen( PhRect_t *rect,
void *buffer );
Library:
ph
Description:
This function retrieves an image from the screen by querying the local graphics
driver(s), using the highest bit depth possible.
The PhRect_t structure pointed to by rect specifies the area to capture and is in
absolute Photon coordinates.
The buffer argument points to a buffer in which to store the image structure and its
associated data, palette, and so on. This must be shared memory, since the graphics
driver needs to be able to access it. Use PgReadScreenSize() to determine an adequate
size for the buffer. If buffer is NULL, a shared memory object is created for you.
Note the following restrictions:
• There must be a graphics driver present that completely encompasses the rectangle
being captured.
• The graphics driver must be running on the same node as the calling process, since
shared memory is used to pass data.
• All data associated with the image (structure, palette, data) is stored in one
contiguous shared memory object. Release this memory by calling
PgShmemDestroy(); don’t call PhReleaseImage() for an image acquired using
PgReadScreen(). If you plan to use the acquired image in an environment where
this restriction proves inconvenient, then you should make a copy of the image
using PiDuplicateImage(), after which you may free the original as outlined above.
Returns:
A pointer to the PhImage_t structure that defines the image, or NULL if the operation
failed (errno is set).
Errors:
ENOMEM Insufficient memory to perform the operation.
ENXIO There was no graphics driver present to capture the specified rectangle.
See the description of shm_open() in the QNX Neutrino Library Reference for further
errors that may occur.
Examples:
PhImage_t *image;
PhRect_t rect = { { 0,0 }, {100,100 } };
if(image = PgReadScreen(&rect,buffer))
{
/* Manipulate the image */
...
PhImage_t *image;
PhRect_t rect = { { 0,0 } }, { 31,31 } };
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdSetTargetDevice(), PgReadScreenSize(), PgShmemDestroy(), PhImage_t,
PhRect_t, PiDuplicateImage()
shm_open() in the QNX Neutrino Library Reference
Synopsis:
unsigned long PgReadScreenSize( PhRect_t *rect );
Library:
ph
Description:
This function determines how much memory is required to store an image that would
be generated by a corresponding call to PgReadScreen(). This function is useful only
if you plan to allocate an image storage buffer yourself.
The PhRect_t structure pointed to by rect specifies the target area (in absolute
Photon coordinates).
Returns:
The number of bytes required to store the image, including palette data (if applicable),
or 0 if an error occurred.
Errors:
See PgReadScreen().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgReadScreen(), PhRect_t
Synopsis:
int PgRedValue( PgColor_t color );
Arguments:
color A composite color value, of type PgColor_t.
Library:
ph
Description:
This macro extracts the red color component from a composite color value. 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:
PgAlphaValue(), PgARGB(), PgBlueValue(), PgCMY(), PgColor_t, PgGreenValue(),
PgHSV(), PgRGB(), PgSetFillColor(), PgSetFillDither()
“Color” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
PgColor_t PgRGB( int R, int G, int B );
Library:
ph
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.
This macro doesn’t support alpha; for colors involving alpha, use PgARGB().
Examples:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgARGB(), PgBlueValue(), PgColor_t, PgCMY(), PgGreenValue(), PgHSV(),
PgRedValue(), PgSetFillColor(), PgSetStrokeColor(), PgSetTextColor()
“Color” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
PgColorHSV_t PgRGB2HSV( PgColor_t rgb_color );
Library:
ph
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.
This function doesn’t copy any alpha value from the RGB color to the HSV color.
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()
“Color” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
typedef struct scaler_caps {
unsigned size;
unsigned format;
unsigned flags:
short src_max_x;
short src_max_y;
short max_mag_factor_x;
short max_mag_factor_y;
short max_shrink_factor_x;
short max_shrink_factor_y;
unsigned reserved[10];
} PgScalerCaps_t;
Description:
The PgScalerCaps_t structure describes video overlay scaler capabilities. It
includes at least:
size The size of this structure. The application should set this to sizeof
(PgScalerCaps_t).
format The video data format to which the capabilities in this structure pertain. It
can be one of the following formats, which are defined in <Pg.h>:
• Pg_VIDEO_FORMAT_RGB555
• Pg_VIDEO_FORMAT_RGB565
• Pg_VIDEO_FORMAT_RGB8888
• Pg_VIDEO_FORMAT_IYU1
• Pg_VIDEO_FORMAT_IYU2
• Pg_VIDEO_FORMAT_UYVY
• Pg_VIDEO_FORMAT_YUY2
• Pg_VIDEO_FORMAT_YVYU
• Pg_VIDEO_FORMAT_V422
• Pg_VIDEO_FORMAT_CLJR
• Pg_VIDEO_FORMAT_YVU9
• Pg_VIDEO_FORMAT_YV12
• Pg_VIDEO_PLANAR_YUV_FORMAT_CLPL
• Pg_VIDEO_PLANAR_YUV_FORMAT_VBPL
src_max_x, src_max_y
The maximum width and height of a video data frame before scaling.
max_mag_factor_x, max_mag_factor_y
The maximum upward scaling factor in the horizontal and vertical
directions.
max_shrink_factor_x, max_shrink_factor_y
The maximum downward scaling factor in the horizontal and vertical
directions. Some scalers can’t perform downward scaling, in which case
these fields are set to 1.
Classification:
Photon
See also:
PgConfigScalerChannel(), PgCreateVideoChannel(), PgDestroyVideoChannel(),
PgGetOverlayChromaColor(), PgGetScalerCapabilities(), PgNextVideoFrame(),
PgScalerProps_t, PgVideoChannel_t
“Video overlay” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
typedef struct {
unsigned size;
unsigned flags;
PgColor_t color_key;
unsigned reserved0;
PgColor_t color_key_mask;
PhRect_t viewport;
PhDim_t src_dim;
unsigned format;
int brightness;
int contrast;
PgVideoAlpha_t alpha[4];
unsigned reserved[10];
} PgScalerProps_t;
Description:
The PgScalerProps_t structure describes video overlay scaler properties. It
includes:
src_dim A PhDim_t structure that defines the width and height of the
video data frames before scaling.
format The format of the video frame data. This is analogous to the
format member of the PgScalerCaps_t structure.
brightness The brightness of the video output viewport. The range is 127 to
-127, where 0 specifies normal brightness.
contrast The contrast of the video output viewport. The range is 127 to
-127, where 0 specifies normal contrast.
Classification:
Photon
See also:
PgColor_t, PgConfigScalerChannel(), PgCreateVideoChannel(),
PgDestroyVideoChannel(), PgGetOverlayChromaColor(), PgGetScalerCapabilities(),
PgNextVideoFrame(), PgScalerCaps_t, PgVideoChannel_t, PhDim_t,
PhRect_t
“Video overlay” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgSetAlpha(
unsigned long const alpha_op,
PgMap_t const * const src_alpha_map,
PgGradient_t const * const src_alpha_gradient,
char unsigned const src_global_alpha,
char unsigned const dst_global_alpha );
void PgSetAlphaCx(
PhGC_t *gc,
unsigned long const alpha_op,
PgMap_t const * const src_alpha_map,
PgGradient_t const * const src_alpha_gradient,
char unsigned const src_global_alpha,
char unsigned const dst_global_alpha );
Arguments:
gc PgSetAlphaCx() only. A pointer to a graphics context, as
returned by PgCreateGC() or PgGetGC().
src_alpha_map A pointer to the alpha map to use as the source; NULL means
no map. This argument is used if alpha_op has
Pg_ALPHA_OP_SRC_MAP set.
This map, of type PgMap_t, indicates the alpha blending to be
applied to each individual pixel. The map is “pinned” to the
origin of your draw command and is tiled if the dimensions of
the map are smaller than the dimension of the drawing
operation.
src_global_alpha The constant source alpha value, which is used if you set
Pg_ALPHA_OP_SRC_GLOBAL.
dst_global_alpha The constant destination alpha value, which is used if you set
Pg_ALPHA_OP_DST_GLOBAL.
Library:
ph
Description:
These functions set the parameters for an alpha-blending or alpha-test operation.
PgSetAlpha() works on the current graphics context, while you can specify the
graphics context for PgSetAlphaCx().
The basic formula for alpha blending is:
You can OR only one source and only one destination multiplier flag into alpha_op.
You can’t combine source or destination flags.
Operation flags
The following operation flags are defined:
Pg_ALPHA_OP_SRC_GLOBAL
The source alpha value (As) is src_global_alpha.
Pg_ALPHA_OP_SRC_MAP
The source alpha is src_alpha_map. This bit can’t be used in conjunction with
Pg_ALPHA_OP_SRC_GLOBAL.
Pg_ALPHA_OP_DST_GLOBAL
The destination alpha (Ad) value is dst_global_alpha.
Pg_ALPHA_OP_TEST
Perform an alpha test rather than an alpha blend. See the test flags below.
Multiplier flags
Flags are defined for source and destination multipliers. In the descriptions below, all
channels are represented in a range from 0 to 1; that is, they have been normalized
from their actual range of 0-255. As RGB colors, (1,1,1) is white, (0,0,0) is black,
(0.5,0.5,0.5) is grey, (1, 0, 0) is full red, and so on.
The following descriptions assume an RGB or ARGB color model for the formulas, so
As is the source pixel’s alpha channel, Rs is the source pixel’s red channel, Ad is the
destination pixel’s alpha channel, Rd is the destination pixel’s red channel, and so on.
For more information about color models, see PgColor_t.
Pg_BLEND_SRC_0
Multiply the source pixel by 0: Sm = (As,Rs,Gs,Bs) * (0,0,0,0).
Pg_BLEND_SRC_1
Multiply the source pixel by 1 (no change): Sm = (As,Rs,Gs,Bs) * (1,1,1,1).
Pg_BLEND_SRC_D
Multiply the source pixel by D: Sm = (As,Rs,Gs,Bs) * (Ad,Rd,Gd,Bd).
Pg_BLEND_SRC_1mD
Multiply the source pixel by 1-D: Sm = (As,Rs,Gs,Bs) * (1-Ad,1-Rd,1-Gd,1-Bd).
Pg_BLEND_SRC_As
The source pixel is multiplied by As: Sm = (As,Rs,Gs,Bs) * (As,As,As,As).
Pg_BLEND_SRC_1mAs
Multiply the source pixel by 1-As: Sm = (As,Rs,Gs,Bs) * (1-As,1-As,1-As,1-As).
Pg_BLEND_SRC_Ad
Multiply the source pixel by Ad: Sm = (As,Rs,Gs,Bs) * (Ad,Ad,Ad,Ad).
Pg_BLEND_SRC_1mAd
Multiply the source pixel by 1-Ad: Sm = (As,Rs,Gs,Bs) *
(1-Ad,1-Ad,1-Ad,1-Ad).
Pg_BLEND_SRC_A1As
Multiply the source pixel’s alpha channel by 1, and the rest of the pixel by As:
Sm = (As,Rs,Gs,Bs) * (1,As,As,As).
Pg_BLEND_SRC_1mA1As
Multiply the source pixel’s alpha channel by 0, and the rest of the pixel by 1-As:
Sm = (As,Rs,Gs,Bs) * (1-1,1-As,1-As,1-As).
Pg_BLEND_SRC_A1Ad
Multiply the source pixel’s alpha channel by 1, and the rest of the pixel by Ad:
Sm = (As,Rs,Gs,Bs) * (1,Ad,Ad,Ad).
Pg_BLEND_SRC_1mA1Ad
Multiply the source pixel’s alpha channel by 0, and the rest of the pixel by 1-Ad:
Sm = (As,Rs,Gs,Bs) * (1-1,1-Ad,1-Ad,1-Ad).
Pg_BLEND_SRC_A0As
Multiply the source pixel’s alpha channel by 0, and the rest of the pixel by As:
Sm = (As,Rs,Gs,Bs) * (0,As,As,As).
Pg_BLEND_SRC_1mA0As
Multiply the source pixel’s alpha channel by 1, and the rest of the pixel by 1-As:
Sm = (As,Rs,Gs,Bs) * (1-0,1-As,1-As,1-As).
Pg_BLEND_SRC_A0Ad
Multiply the source pixel’s alpha channel by 0, and the rest of the pixel by Ad:
Sm = (As,Rs,Gs,Bs) * (0,Ad,Ad,Ad).
Pg_BLEND_SRC_1mA0Ad
Multiply the source pixel’s alpha channel by 1, and the rest of the pixel by 1-Ad:
Sm = (As,Rs,Gs,Bs) * (1-0,1-Ad,1-Ad,1-Ad).
Pg_BLEND_SRC_SRC_ALPHA
Deprecated; use Pg_BLEND_SRC_As.
Pg_BLEND_DST_ONE_MINUS_SRC_ALPHA
Deprecated; use Pg_BLEND_DST_1mAs.
Pg_BLEND_DST_0
Multiply the destination pixel by 0: Dm = (Ad,Rd,Gd,Bd) * (0,0,0,0).
Pg_BLEND_DST_1
Multiply the destination pixel by 1 (no change): Dm = (Ad,Rd,Gd,Bd) *
(1,1,1,1).
Pg_BLEND_DST_S
Multiply the destination pixel by S: Dm = (Ad,Rd,Gd,Bd) * (As,Rs,Gs,Bs).
Pg_BLEND_DST_1mS
Multiply the destination pixel by 1-S: Dm = (Ad,Rd,Gd,Bd) *
(1-As,1-Rs,1-Gs,1-Bs).
Pg_BLEND_DST_As
Multiply the destination pixel by As: Dm = (Ad,Rd,Gd,Bd) * (As,As,As,As).
Pg_BLEND_DST_1mAs
Multiply the destination pixel by 1-As: Dm = (Ad,Rd,Gd,Bd) *
(1-As,1-As,1-As,1-As).
Pg_BLEND_DST_Ad
Multiply the destination pixel by Ad: Dm = (Ad,Rd,Gd,Bd) * (Ad,Ad,Ad,Ad).
Pg_BLEND_DST_1mAd
Multiply the destination pixel by 1-Ad: Dm = (Ad,Rd,Gd,Bd) *
(1-Ad,1-Ad,1-Ad,1-Ad).
Pg_BLEND_DST_A1As
Multiply the destination pixel’s alpha channel by 1, and the rest of the pixel by
As: Dm = (Ad,Rd,Gd,Bd) * (1,As,As,As).
Pg_BLEND_DST_1mA1As
Multiply the destination pixel’s alpha channel by 0, and the rest of the pixel by
1-As: Dm = (Ad,Rd,Gd,Bd) * (1-1,1-As,1-As,1-As).
Pg_BLEND_DST_A1Ad
Multiply the destination pixel’s alpha channel by 1, and the rest of the pixel by
Ad: Dm = (Ad,Rd,Gd,Bd) * (1,Ad,Ad,Ad).
Pg_BLEND_DST_1mA1Ad
Multiply the destination pixel’s alpha channel by 0, and the rest of the pixel by
1-Ad: Dm = (Ad,Rd,Gd,Bd) * (1-1,1-Ad,1-Ad,1-Ad).
Pg_BLEND_DST_A0As
Multiply the destination pixel’s alpha channel by 0, and the rest of the pixel by
As: Dm = (Ad,Rd,Gd,Bd) * (0,As,As,As).
Pg_BLEND_DST_1mA0As
Multiply the destination pixel’s alpha channel by 1, and the rest of the pixel by
1-As: Dm = (Ad,Rd,Gd,Bd) * (1-0,1-As,1-As,1-As).
Pg_BLEND_DST_A0Ad
Multiply the destination pixel’s alpha channel by 0, and the rest of the pixel by
Ad: Dm = (Ad,Rd,Gd,Bd) * (0,Ad,Ad,Ad).
Pg_BLEND_DST_1mA0Ad
Multiply the destination pixel’s alpha channel by 1, and the rest of the pixel by
1-Ad: Dm = (Ad,Rd,Gd,Bd) * (1-0,1-Ad,1-Ad,1-Ad).
Pg_TEST_ALWAYS
Always write source pixels to the destination.
Pg_TEST_LESS_THAN
If As is less than Ad, write the source pixel to the destination.
Pg_TEST_LESS_THAN_OR_EQUAL
If As is less than or equal to Ad, write the source pixel to the destination.
Pg_TEST_EQUAL
If As is equal to Ad, write the source pixel to the destination.
Pg_TEST_GREATER_THAN_OR_EQUAL
If As is greater than or equal to Ad, write the source pixel to the destination.
Pg_TEST_GREATER_THAN
If As is greater than Ad, write the source pixel to the destination.
Pg_TEST_NOT_EQUAL
If As is not equal to Ad, write the source pixel to the destination.
Examples:
To use the alpha test option:
PgSetAlpha(Pg_ALPHA_OP_SRC_MAP | Pg_ALPHA_OP_DST_GLOBAL |
Pg_ALPHA_OP_TEST | Pg_TEST_LESS_THAN, &alpha_map,
NULL, 0, 0x80);
PgAlphaOn();
PgSetFillColor(Pg_WHITE);
PgDrawRect(&canvas_size, Pg_DRAW_FILL);
PgAlphaOff();
In this example, when the graphics driver is rendering the white rectangle:
• anywhere in the alphamap that is less than 128 (0x80) a white pixel is drawn
• anywhere that is equal to or greater than 128 in the alphamap the destination pixel
is unmodified.
PgMap_t alphamap;
alphamap.dim.w=8;
alphamap.dim.h=8;
alphamap.bpl=8;
alphamap.bpp=8;
alphamap.map=alphamapdata;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgAlphaOff*(), PgAlphaOn*(), PgMap_t, PgColor_t, PgSetAlphaBlend*(),
PhDim_t
“Alpha Blending Support” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgSetAlphaBlend(
PgMap_t const * const src_alpha_map,
unsigned char const src_alpha_value );
void PgSetAlphaBlendCx(
PhGC_t *gc,
PgMap_t const * const src_alpha_map,
unsigned char const src_alpha_value );
Library:
ph
Description:
These functions set the parameters for an alpha-blending operation.
Calling PgSetAlphaBlend*() is equivalent to calling PgSetAlpha*() with
Pg_BLEND_SRC_As and Pg_BLEND_DST_1mAs as the source and destination
multipliers.
The src_alpha_map argument is a pointer to the alpha map to be used in the blending
operation. If this is NULL, the global blending factor, src_alpha_value, is used. For
more information about the PgMap_t structure, see PgMap_t.
PgSetAlphaBlend() works on the current graphics context, while you can specify the
graphics context gc for PgSetAlphaBlendCx().
Examples:
// Draw a purple rectangle blended (at 25%) over top of
// whatever is under it.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgAlphaOff(), PgAlphaOn(), PgMap_t, PgSetAlpha()
“Alpha Blending Support” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgSetChroma( PgColor_t ChromaColor,
unsigned long ChromaOp );
Library:
ph
Description:
These functions set the current chroma color and defines the chroma operation.
PgSetChroma() works on the current graphics context, while you can specify the
graphics context gc for PgSetChromaCx().
ChromaColor is the color to test against for chroma operations. ChromaOp is made up
of the following bits:
Pg_CHROMA_SRC_MATCH
Test against the source data.
Pg_CHROMA_DEST_MATCH
Test against the destination data.
Pg_CHROMA_DRAW
If the test pixel matches the chroma color, draw it in the destination.
Pg_CHROMA_NODRAW
If the test pixel matches the chroma color, don’t draw it in the destination.
Examples:
// Draw an image using a chroma color of full green
PhImage_t *image;
PhPoint_t p={0,0};
PgChromaOn();
// Set the chroma operation to copy every pixel in the source to
// the destination, except the color 0x0000FF00 (bright green)
PgSetChroma(0x0000FF00, Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW);
PgDrawPhImagemx(&p,image,0);
PgChromaOff();
PgFlush();
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgChromaOff*(), PgChromaOn*(), PgColor_t,
“Chroma key support” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgSetClipping( unsigned short n,
PhRect_t const *rects );
Library:
ph
Description:
These functions let you limit the extent of drawing by specifying which rectangles to
draw in. Note that you can never draw outside of the current region.
PgSetClipping() works on the current graphics context, while you can specify the
graphics context gc for PgSetClippingCx().
The n argument contains the number of clip rectangles; rects is 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*().
PhAttach(), PhReattach(), and PgSetRegion*() reset the clipping rectangle to the full
size of the region.
Don’t call PgSetClipping*() in a widget’s draw function; use PgSetMultiClip*(),
PtClipAdd(), and PtClipRemove() instead.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgFlush*(), PgSetMultiClip*(), PgSetRegion*(), PgSetUserClip*(), PhAttach(),
PhReattach() PhRect_t, PtClipAdd(), PtClipRemove()
Synopsis:
const PgColorModel_t * PgSetColorModel(
PgColorModel_t const * model );
Library:
ph
Description:
These functions change the interpretation of colors represented by PgColor_t by the
Photon graphics library and io-graphics (see the Utilities Reference). For a list of
available color models, see Pt_ARG_CS_COLOR_MODELS.
PgSetColorModel() works on the current graphics context, while you can specify the
graphics context gc for PgSetColorModelCx().
For descriptions of the currently supported color models, see PgColor_t.
Returns:
The previous color model.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor_t, PgGetColorModel*()
io-graphics in the Utilities Reference
Synopsis:
unsigned long PgSetControlFlagGCCx( PhGC_t * GC,
unsigned long flags);
Library:
ph
Description:
These flag(s) are used to control specific behavior that is associated with the provided
PhGC_t.
You can set the following flags:
PhGC_DONT_RESET_PLANE_MASK
The photon library is prevented from resetting plane mask. This can be used to
prevent modification of destination pixel bit(s), i.e. alpha bit(s).
Returns:
All old flags.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Caveats:
Ensure the flags are set to zero after you are finished, as these control flags alter
rendering at the fundamental level.
See also:
PgDefaultMode(), PgDefaultGC(),
Synopsis:
int PgSetDPMSMode (int mode );
Library:
ph
Description:
This function sets the display power-saving mode based on VESA Display Power
Management System standards.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
int PgSetDrawBufferSizeCx(
void *dc,
unsigned short cmd_buf_len );
Library:
ph
Description:
These functions resize the current draw buffer. The default size, allocated with every
PhAttach(), is at least 4K. If cmd_buf_len is less than 1K, then 4K is allocated. The
draw buffer stores all drawing data except for data stored in shared memory.
If the draw buffer contains unflushed data when these functions are called, the function
will flush the data before reallocating the buffer.
PgSetDrawBufferSize() works on the current draw context, while you can specify the
draw context dc for PgSetDrawBufferSizeCx().
Returns:
0 Success.
-1 An error occurred.
Examples:
// Allocate a 16K draw buffer
PgSetDrawBufferSize( 16 * 1024 );
To reduce the memory requirements of the graphics driver, you should limit draw
buffers to 16K.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgClearDrawBuffer*(), PgFlush*(), PhAttach(), PhGetMsgSize()
Synopsis:
int PgSetDrawMode( int mode );
Library:
ph
Description:
These functions control how pixels are combined with video memory.
PgSetDrawMode() works on the current graphics context, while you can specify the
graphics context gc for PgSetDrawModeCx().
Pg_DRAWMODE_OPAQUE
Use default draw mode (the draw overwrites the screen).
Pg_DRAWMODE_XOR
XOR drawn pixels with the screen.
Pg_DRAWMODE_AND
AND drawn pixels with the screen.
Pg_DRAWMODE_OR
OR drawn pixels with the screen.
The effect of these functions 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.
pixel data. Extended raster operations are set the same way the normal raster
operations were set, using PgSetDrawMode().
The extended raster operations are pervasive, meaning that they affect all subsequent
drawing operations, including bit-blit operations and images. The old style raster
operations still exist and behave as described above.
The extended raster operations are defined as Pg_DrawModecharacters, in reverse
notation, where the characters are chosen from the following:
Character Meaning
P Pattern
S Source
D Destination
o OR
a AND
n NOT
x XOR
For example:
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*()
“Drawing attributes” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PgColor_t PgSetFillColor( PgColor_t color );
Library:
ph
Description:
These functions set 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.
PgSetFillColor() works on the current graphics context, while you can specify the
graphics context gc for PgSetFillColorCx().
These functions override the color defined by PgSetFillDither*().
You don’t need to set the fill color if you’re using widgets; the drawing attributes are
set based on the widgets’ definitions and resources.
However, in all other cases you should set the fill color before you begin drawing. The
defaults are undefined and drawing before setting the relevant attributes may produce
unexpected results.
Returns:
The previous color.
Examples:
/* Set the draw color to white. */
PgSetFillColor( Pg_WHITE );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgARGB(), PgCMY(), PgColor_t, PgDefaultFill*(), PgGray(), PgHSV(), PgRGB(),
PgSetDrawMode*(), PgSetFillDither*(), PgSetFillTransPat*(),
PgSetFillXORColor*(), PgSetStrokeColor*(), PgSetTextColor*()
“Drawing attributes” and “Arcs, ellipses, polygons, and rectangles” in the Raw
Drawing and Animation chapter of the Photon Programmer’s Guide
Synopsis:
void PgSetFillDither( PgColor_t c1,
PgColor_t c0,
PgPattern_t pat );
Library:
ph
Description:
These functions combine 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.
These functions override 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>:
PgSetFillDither() works on the current graphics context, while you can specify the
graphics context gc for PgSetFillDitherCx().
Examples:
// Set the fill to be black with every 8th
// vertical line being white
PgSetFillDither( Pg_WHITE, Pg_BLACK, Pg_PAT_VERT8 );
Here’s the code that produced the sample of predefined dither patterns:
typedef struct {
char *name;
PgPattern_t p;
} DithersListStruct;
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;
char Helvetica14b[MAX_FONT_TAG];
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgARGB(), PgCMY(), PgColor_t, PgDefaultFill*(), PgGray(), PgHSV(), PgRGB(),
PgSetFillColor*(), PgSetFillTransPat*(), PgSetFillXORColor*(),
PgSetStrokeDither*(), PgSetTextDither*()
“Drawing attributes” and “Arcs, ellipses, polygons, and rectangles” in the Raw
Drawing and Animation chapter of the Photon Programmer’s Guide
Synopsis:
void PgSetFillTransPat( PgPattern_t pat );
Library:
ph
Description:
These functions set a masking pattern and applies it to fills. You should use them in
combination with PgSetFillColor*() or PgSetFillDither*().
PgSetFillTransPat() works on the current graphics context, while you can specify the
graphics context gc for PgSetFillTransPatCx().
These functions use the same patterns as PgSetFillDither*(), To disable transparency
and draw normally, specify the Pg_PAT_DEFAULT pattern.
Because of speed considerations, some graphics drivers don’t draw strokes with a
transparency mask and, as a result, ignore the stroke transparency 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*()
“Drawing attributes” and “Arcs, ellipses, polygons, and rectangles” in the Raw
Drawing and Animation chapter of the Photon Programmer’s Guide
Library:
ph
Description:
These functions set 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.
PgSetFillXORColor() works on the current graphics context, while you can specify the
graphics context gc for PgSetFillXORColorCx().
Examples:
DrawXOR() {
char *s = "Hello World!";
PhPoint_t p = { 8, 30 };
PhRect_t r;
char Helvetica18[MAX_FONT_TAG];
if(PfGenerateFontName("Helvetica", 0, 18,
Helvetica18) == NULL) {
perror ("Unable to find font");
} else {
PgSetFont( Helvetica18 );
PgSetTextColor( Pg_YELLOW );
PgSetFillColor( Pg_PURPLE );
PgDrawText( s, strlen( s ), &p, Pg_BACK_FILL );
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor_t, PgDefaultFill*(), PgSetDrawMode*(), PgSetFillColor*(),
PgSetFillDither*(), PgSetFillTransPat*(), PgSetStrokeXORColor*(),
PgSetTextXORColor*()
“Drawing attributes” and “Arcs, ellipses, polygons, and rectangles” in the Raw
Drawing and Animation chapter of the Photon Programmer’s Guide
Synopsis:
void PgSetFont( char const *ff );
Library:
ph
Description:
These functions set the font for text subsequently drawn with PgDrawText*() or
PgDrawString*(). The ff argument is a pointer to a font identifier, which you should
create by calling PfGenerateFontName().
If the M1 or M2 global alpha values are set, and an anti-aliased font type is supplied to
the function, the resulting text will be blended according to the global alpha values.
See the PgSetAlphaBlend() or PgSetAlpha() functions for more information about
setting global alpha values.
PgSetFont() works on the current graphics context, while you can specify the graphics
context gc for PgSetFontCx().
Examples:
char font_name[MAX_FONT_TAG];
if (PfGenerateFontName( "Helvetica",
PF_STYLE_BOLD | PF_STYLE_ITALIC,
14, font_name ) != NULL ) {
PgSetFont( font_name );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
continued. . .
Safety
Thread No
See also:
PfGenerateFontName(), PgDrawString*(), PgDrawText*(), PgSetFillColor*(),
PgSetFillDither*(), PgSetFillTransPat*(), PgSetUnderline*()
“Drawing attributes” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PhGC_t *PgSetGC( PhGC_t *GC );
Arguments:
dc PgSetGCCx() only. A void pointer to any type of draw context. Examples of
draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by PdCreateOffscreenContext()
Library:
ph
Description:
These functions set the current graphics context to GC.
PgSetGC() works on the current draw context, while you can specify the draw context
for PgSetGCCx().
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 PgSetLayerArg( int layer,
int arg,
void *data,
int data_len );
Arguments:
layer The layer index, which must be 0 or greater.
Library:
ph
Description:
PgSetLayerArg() configures the specified layer argument. This function replaces the
existing value of the argument with the new value. It doesn’t free dynamically
allocated data. If this function fails, then the value of the argument is undefined.
You can change layer arguments only after a call to PgSetLayerArg() with an argument
of Pg_LAYER_ARG_LIST_BEGIN, and before another call with an argument of
Pg_LAYER_ARG_LIST_END. For example:
int fmt_idx = 5;
PgSetLayerArg( layer, Pg_LAYER_ARG_LIST_BEGIN, NULL, 0 );
PgSetLayerArg( layer, Pg_LAYER_ARG_FORMAT_INDEX,
&fmt_idx, sizeof(int) );
PgSetLayerSurface( layer, 0, osc0 );
PgSetLayerSurface( layer, 1, osc1 );
PgSetLayerSurface( layer, 2, osc2 );
PgSetLayerArg( layer, Pg_LAYER_ARG_BRIGHTNESS, ... );
PgSetLayerArg( layer, ... );
...
PgSetLayerArg( layer, Pg_LAYER_ARG_LIST_END, NULL, 0 );
Layer arguments
The arguments for a layer are as follows:
Pg_LAYER_ARG_ACTIVE
Whether the layer is active (shown) or hidden.
Pg_LAYER_ARG_FORMAT_INDEX
The layer format, by index. The index corresponds to the format_index passed
to PgGetLayerCaps().
Pg_LAYER_ARG_DST_VIEWPORT
The rectangle on the screen where the source data is displayed.
Pg_LAYER_ARG_SRC_VIEWPORT
The rectangle within the source data that’s displayed by the layer.
Type Default
PhArea_t The same as the destination viewport, or the maximum area allowed
by the driver, if smaller
Pg_LAYER_ARG_BRIGHTNESS
The brightness level.
Pg_LAYER_ARG_SATURATION
The saturation level.
Pg_LAYER_ARG_CONTRAST
The contrast level.
Pg_LAYER_ARG_CHROMA
Chroma information, stored in a PgChroma_t structure:
typedef struct _Pg_chroma {
unsigned int color;
unsigned long op;
} PgChroma_t;
Pg_LAYER_ARG_ALPHA
Alpha blending for the layer, stored in a PgLayerAlpha_t structure:
typedef struct {
unsigned int op;
unsigned int salpha;
unsigned int dalpha;
} PgLayerAlpha_t;
Type Default
PgLayerAlpha_t op = 0
Pg_LAYER_ARG_EDGE_MODE
How to behave if the source viewport is larger than the extent of the source data.
Pg_LAYER_ARG_FILTER_MODE
Enable or disable viewport filtering.
Pg_LAYER_ARG_LIST_BEGIN, Pg_LAYER_ARG_LIST_END
Bracket a set of calls to PgSetLayerArg() or PgSetLayerSurface() with these to
queue up register updates.
Returns:
0 Success.
Errors:
EBUSY The layer is locked by another application.
EINVAL The specified layer doesn’t exist, the layer doesn’t support the
given argument, or the data specified for the argument is invalid.
Examples:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdSetTargetDevice(), PgGetLayerCaps(), PgSetChroma(), PgSetLayerSurface(),
PhArea_t
“Layers” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PgSetLayerSurface( int layer,
int surface_index,
PdOffscreenContext_t *surface );
Arguments:
layer The layer index, which must be 0 or greater.
Library:
ph
Description:
PgSetLayerSurface() tells a layer to fetch image data from the specified surface. If
another surface was previously assigned to the layer for the same surface_index, it’s
replaced but not destroyed.
You must configure the layer’s format before calling PgSetLayerSurface(). If a layer
reads data from more than one surface, every surface read must have the same width
and height.
You must use this function after a call to PgSetLayerArg() with an argument of
Pg_LAYER_ARG_LIST_BEGIN, and before another call with an argument of
Pg_LAYER_ARG_LIST_END. For example:
int fmt_idx = 5;
PgSetLayerArg( layer, Pg_LAYER_ARG_LIST_BEGIN, NULL, 0 );
PgSetLayerArg( layer, Pg_LAYER_ARG_FORMAT_INDEX,
&fmt_idx, sizeof(int) );
PgSetLayerSurface( layer, 0, osc0 );
PgSetLayerSurface( layer, 1, osc1 );
PgSetLayerSurface( layer, 2, osc2 );
PgSetLayerArg( layer, Pg_LAYER_ARG_BRIGHTNESS, ... );
PgSetLayerArg( layer, ... );
...
PgSetLayerArg( layer, Pg_LAYER_ARG_LIST_END, NULL, 0 );
Returns:
0 Success.
-1 An error occurred (errno is set).
Errors:
EBUSY The layer is locked by another application.
EINVAL The specified layer or surface doesn’t exist, the osc argument is
NULL, or the specified offscreen context is incompatible with the
layer and/or surface.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdOffscreenContext_t, PdSetTargetDevice(), PgCreateLayerSurface(),
PgSetLayerArg()
“Layers” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PgSetMultiClip( int num,
PhRect_t const *clip_list );
Library:
ph
Description:
These functions set a list of rectangles (stored in PhRect_t structures) 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*().
PhAttach(), PhReattach(), and PgSetRegion*() reset the clipping rectangle to the full
size of the region.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgSetClipping*(), PgSetUserClip*(), PhRect_t
Synopsis:
int PgSetPalette( PgColor_t const *palette,
long palette_id,
short first_color,
short num_colors,
int flags,
long tag );
Library:
ph
Description:
These functions set 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:
Direct-color and fixed-color graphics drivers will change this palette type to
Pg_PALSET_SOFT.
Pg_PALSET_HARDINACTIVE
Same as Pg_PALSET_HARD, but doesn’t change the physical
palette. You can use this to restore the global palette.
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:
PgColor_t PgDrawImage*(), PgSetFillColor*(), PgSetStrokeColor*(),
PgSetTextColor*(), PhImage_t, PtCRC()
“Drawing attributes” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
unsigned long PgSetPlaneMask( unsigned long mask);
Library:
ph
Description:
These functions protect 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 these functions 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.
These functions work only on some 8-bit drivers.
PgSetPlaneMask() works on the current graphics context, while you can specify the
graphics context gc for PgSetPlaneMaskCx().
Returns:
The previous mask.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultMode(), PgSetFillColor*(), PgSetStrokeColor*(), PgSetTextColor*()
“Drawing attributes” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgSetRegion( PhRid_t rid );
Arguments:
dc PgSetGCCx() only. A void pointer to any type of draw context. Examples of
draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by PdCreateOffscreenContext()
Library:
ph
Description:
These functions specify which region will emit subsequent draw events.
If rid is the current region, this function does nothing.
If rid isn’t the current region, this function:
• Resets the clipping rectangle to the full size of the region. Note that all draws are
clipped to the region that emits them.
• Flushes the data before changing the current region, if the draw buffer contains
unflushed data.
PgSetRegion() works on the current draw context, while you can specify the draw
context for PgSetRegionCx().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgFlush*(), PgGetRegion*(), PgSetClipping*()
Synopsis:
int PgSetStrokeCap( int cap );
Library:
ph
Description:
These functions determine how the ends of thick lines are drawn. You can set cap to
one of the following:
• Pg_POINT_CAP
• Pg_ROUND_CAP
• Pg_SQUARE_CAP
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.
PgSetStrokeCap() works on the current graphics context, while you can specify the
graphics context gc for PgSetStrokeCapCx().
Returns:
The previous cap value.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultStroke*(), PgDrawEllipse*(), PgDrawLine*(), PgDrawPolygon*(),
PgDrawRect*(), PgDrawRoundRect*(), PgSetDrawMode*(), PgSetStrokeDash*(),
PgSetStrokeDither*(), PgSetStrokeJoin*(), PgSetStrokeTransPat*(),
PgSetStrokeWidth*(), PgSetStrokeXORColor*(),
“Drawing attributes” and “Lines, pixels, and pixel arrays” in the Raw Drawing and
Animation chapter of the Photon Programmer’s Guide
Synopsis:
PgColor_t PgSetStrokeColor( PgColor_t color );
Library:
ph
Description:
These functions set 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.
These functions override the color defined by PgSetStrokeDither*().
PgSetStrokeColor() works on the current graphics context, while you can specify the
graphics context gc for PgSetStrokeColorCx().
You don’t need to set stroke color if you’re using widgets; the drawing attributes are
set based on the widgets’ definitions and resources.
However, in all other cases you should set the stroke color before you begin drawing.
The defaults are undefined and drawing before setting the relevant attributes may
produce unexpected results.
Returns:
The previous color.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgARGB(), PgCMY(), PgColor_t, PgDefaultStroke*(), PgGray(), PgHSV(),
PgRGB(), PgSetDrawMode*(), PgSetFillColor*(), PgSetStrokeCap*(),
PgSetStrokeDash*(), PgSetStrokeDither*(), PgSetStrokeJoin*(),
Synopsis:
void PgSetStrokeDash( unsigned char const *DashList,
int ListLen,
long DashScale );
Library:
ph
Description:
These functions define 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:
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;
char Helvetica14b[MAX_FONT_TAG];
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+(DashListCHeight/2),
320, y+(DashListCHeight/2) );
}
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultStroke*(), PgDrawLine*(), PgDrawPolygon*(), PgDrawRect*(),
PgSetDrawMode*(), PgSetStrokeCap*(), PgSetStrokeDither*(), PgSetStrokeJoin*(),
PgSetStrokeTransPat*(), PgSetStrokeWidth*(), PgSetStrokeXORColor*()
“Drawing attributes” and “Lines, pixels, and pixel arrays” in the Raw Drawing and
Animation chapter of the Photon Programmer’s Guide
Library:
ph
Description:
These functions combine 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*().
Because of speed considerations, some graphics drivers don’t dither strokes. If a driver
doesn’t support dithering, it uses c1 to draw strokes.
These functions override the color defined by PgSetStrokeColor*(). For basic colors,
see PgColor_t.
PgSetStrokeDither() works on the current graphics context, while you can specify the
graphics context gc for PgSetStrokeDitherCx().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PgSetStrokeJoin( int join );
Library:
ph
Description:
These functions determine how thick lines are connected. You can set join to one of
the following:
• Pg_BEVEL_JOIN
• Pg_BUTT_JOIN
• Pg_ROUND_JOIN
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 don’t normally appear.
PgSetStrokeJoin() works on the current graphics context, while you can specify the
graphics context gc for PgSetStrokeJoinCx().
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*(),
“Drawing attributes” and “Lines, pixels, and pixel arrays” in the Raw Drawing and
Animation chapter of the Photon Programmer’s Guide
Library:
ph
Description:
These functions set a masking pattern and applies it to outlines. You should use it in
combination with PgSetStrokeColor*() or PgSetStrokeDither*().
These functions use the same patterns as PgSetFillDither*(). To disable transparency
and draw normally, specify the Pg_PAT_DEFAULT pattern.
Because of speed considerations, some graphics drivers don’t draw strokes with a
transparency mask and, as a result, ignore the stroke transparency pattern.
PgSetStrokeTransPat() works on the current graphics context, while you can specify
the graphics context gc for PgSetStrokeTransPatCx().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultStroke*(), PgSetDrawMode*(), PgSetFillTransPat*(), PgSetStrokeCap*(),
PgSetStrokeColor*(), PgSetStrokeDash*(), PgSetStrokeDither*(), PgSetStrokeJoin*(),
PgSetStrokeWidth*(), PgSetStrokeXORColor*(), PgSetTextTransPat*()
“Drawing attributes” and “Lines, pixels, and pixel arrays” in the Raw Drawing and
Animation chapter of the Photon Programmer’s Guide
Library:
ph
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
PgSetStrokeWidthCx(), PgSetStrokeFWidthCx()
Caveats:
We don’t recommend using a line width greater than one pixel. Some graphics drivers
might give unexpected results.
See also:
PgDefaultStroke*(), PgDrawEllipse*(), PgDrawLine*(), PgDrawPolygon*(),
PgDrawRect*(), PgDrawRoundRect*(), PgSetDrawMode*(), PgSetStrokeCap*(),
PgSetStrokeColor*(), PgSetStrokeDash*(), PgSetStrokeDither*(), PgSetStrokeJoin*(),
PgSetStrokeTransPat*(), PgSetStrokeXORColor*()
“Drawing attributes” and “Lines, pixels, and pixel arrays” in the Raw Drawing and
Animation chapter of the Photon Programmer’s Guide
Library:
ph
Description:
These functions set 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.
PgSetStrokeXORColor() works on the current graphics context, while you can specify
the graphics context gc for PgSetStrokeXORColorCx().
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*()
“Drawing attributes” and “Lines, pixels, and pixel arrays” in the Raw Drawing and
Animation chapter of the Photon Programmer’s Guide
Synopsis:
PgColor_t PgSetTextColor( PgColor_t color );
Library:
ph
Description:
These functions set 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.
This function overrides the color defined by PgSetTextDither*().
PgSetTextColor() works on the current graphics context, while you can specify the
graphics context gc for PgSetTextColorCx().
Returns:
The previous color.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgARGB(), PgCMY(), PgColor_t, PgDefaultText*(), PgDrawString*(),
PgDrawText*(), PgDrawTextArea*(), PgExtentMultiText*(), PgExtentText*(),
PgGray(), PgHSV(), PgRGB(), PgSetDrawMode*(), PgSetFillColor*(), PgSetFont*(),
PgSetStrokeColor*(), PgSetTextDither*(), PgSetTextTransPat*(),
PgSetTextXORColor*(), PgSetUnderline*()
“Drawing attributes” and “Text” in the Raw Drawing and Animation chapter of the
Photon Programmer’s Guide
Synopsis:
void PgSetTextDither( PgColor_t c1,
PgColor_t c0,
PgPattern_t pat );
Library:
ph
Description:
These functions combine 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*().
These functions override the color defined by PgSetTextColor*(). For basic colors, see
PgColor_t.
PgSetTextDither() works on the current graphics context, while you can specify the
graphics context gc for PgSetTextDitherCx().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgARGB(), PgColor_t, PgDefaultText*(), PgDrawString*(), PgDrawText*(),
PgDrawTextArea*(), PgExtentMultiText*(), PgExtentText*(), PgGray(), PgHSV(),
PgRGB(), PgSetDrawMode*(), PgSetFillDither*(), PgSetFont*(),
Library:
ph
Description:
These functions set a masking pattern and applies it to text and bitmaps. You should
use it in combination with PgSetTextColor*() or PgSetTextDither*().
These functions use the same patterns as PgSetFillDither*(). To disable transparency
and draw normally, specify the Pg_PAT_DEFAULT pattern.
Because of speed considerations, some graphics drivers don’t draw strokes with a
transparency mask and, as a result, ignore the stroke transparency pattern.
PgSetTextTransPat() works on the current graphics context, while you can specify the
graphics context gc for PgSetTextTransPatCx().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDefaultText*(), PgDrawString*(), PgDrawText*(), PgDrawTextArea*(),
PgExtentMultiText*(), PgExtentText*(), PgGray(), PgHSV(), PgRGB(),
PgSetDrawMode*(), PgSetFillTransPat*(), PgSetFont*(), PgSetStrokeTransPat*(),
PgSetTextColor*(), PgSetTextDither*(), PgSetTextXORColor*(), PgSetUnderline*()
“Drawing attributes” and “Text” in the Raw Drawing and Animation chapter of the
Photon Programmer’s Guide
Library:
ph
Description:
These functions set 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.
PgSetTextXORColor() works on the current graphics context, while you can specify
the graphics context gc for PgSetTextXORColorCx().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor_t, PgDefaultText*(), PgDrawString*(), PgDrawText*(),
PgDrawTextArea*(), PgExtentMultiText(), PgExtentText(), PgSetDrawMode*(),
PgSetFillXORColor*(), PgSetFont*(), PgSetStrokeXORColor*(), PgSetTextColor*(),
PgSetTextDither*(), PgSetTextTransPat*(), PgSetUnderline*()
“Drawing attributes” and “Text” in the Raw Drawing and Animation chapter of the
Photon Programmer’s Guide
Synopsis:
void PgSetTranslation ( PhPoint_t const *translation,
int flags );
Library:
ph
Description:
These functions cause 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:
PgSetTranslation() works on the current graphics context, while you can specify the
graphics context gc for PgSetTranslationCx().
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*(), PhPoint_t
“PtRaw widget” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgSetUnderline( PgColor_t c1,
PgColor_t c2,
int flags );
Library:
ph
Description:
These functions set 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
You should find double underlining useful for scored underlining (where c2 is a
shadow color) or for thick underlining (where both c1 and c2 are the same color).
No flags are currently defined.
These functions affect only the drawing operations that involve text:
• PgDrawMultiTextArea*()
• PgDrawString*()
• PgDrawText*()
• PgDrawTextArea*()
PgSetUnderline() works on the current graphics context, while you can specify the
graphics context gc for PgSetUnderlineCx().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor_t, PgDefaultText(), PgDrawMultiTextArea*(), PgDrawString*(),
PgDrawText*(), PgDrawTextArea*(), PgExtentMultiText*(), PgExtentText(),
PgSetDrawMode*(), PgSetFont*(), PgSetTextColor*(), PgSetTextDither*(),
PgSetTextTransPat*(), PgSetTextXORColor*()
“Drawing attributes” and “Text” in the Raw Drawing and Animation chapter of the
Photon Programmer’s Guide
void PgSetUserClipAbsolute(
PhRect_t const *ClipRect );
void PgSetUserClipAbsoluteCx(
PhGC_t *gc,
PhRect_t const *ClipRect );
Library:
ph
Description:
These functions restrict all subsequent draws to the area defined by the PhRect_t
pointed to 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.
PhAttach(), PhReattach(), and PgSetRegion() reset the clipping rectangle to the full
size of the region.
Classification:
Photon
Safety
Interrupt handler No
continued. . .
See also:
PgClearTranslation(), PgSetClipping(), PgSetMultiClip(), PgSetRegion(),
PgSetTranslation(), PhAttach(), PhReattach(), PhRect_t
Synopsis:
int PgSetVideoMode( PgDisplaySettings_t *settings );
Library:
ph
Description:
This function sets the current video mode to the settings given in the the
PgDisplaySettings_t structure pointed to by settings, which includes at least the
following:
unsigned mode The number of the current mode for the video card.
int refresh The refresh rate, in Hz. A refresh rate of 0 requests the default
rate for this mode (usually 60Hz).
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgGetGraphicsHWCaps(), PgGetVideoMode(), PgGetVideoModeInfo(),
PgGetVideoModeList()
“Video modes” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PgShmemAttach( char const *name,
unsigned long size,
void *addr );
Library:
ph
Description:
This function records a reference to an existing block of shared memory (that is, a
block created with shm_open(), sized with ftruncate(), and mapped into the process’s
address space with mmap() — see the QNX Neutrino Library Reference).
The Photon library uses atexit() to arrange for PgShmemCleanup() to be called 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 QNX Neutrino Library Reference.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawBitmapmx(), PgDrawImagemx(), PgShmemCleanup(), PgShmemCreate(),
PgShmemDestroy(), PgShmemDetach()
atexit(), errno, ftruncate(), mmap(), shm_open() in the QNX Neutrino Library
Reference
Synopsis:
void PgShmemCleanup();
Library:
ph
Description:
This function removes all shared memory references that you defined with
PgShmemCreate() and PgShmemAttach(). If you created the block with
PgShmemCreate(), the block is unlinked.
The Photon library uses atexit() to arrange for PgShmemCleanup() to be called when
your program terminates normally. If your program terminates abnormally, it should
call PgShmemCleanup() explicitly.
You can’t call Photon routines from a signal handler; use PtAppAddSignalProc() to
register a Photon handler for the signals.
Examples:
This code fragment shows how you can use PgShmemCleanup() in a signal handler:
#include <signal.h>
PtSignalProcF_t ExitCleanup;
main( ... ) {
sigset_t my_signals;
...
/* main loop */
...
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgShmemAttach(), PgShmemCreate(), PtAppAddSignalProc()
Interprocess Communication in the Photon Programmer’s Guide
atexit(), sigaddset(), sigemptyset() in the QNX Neutrino Library Reference
Synopsis:
void *PgShmemCreate( unsigned long size,
char const *name );
Library:
ph
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 generates 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.
The Photon library uses atexit() to arrange for PgShmemCleanup() to be called when
your program terminates normally. If your program terminates abnormally, it should
call PgShmemCleanup() explicitly.
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 QNX Neutrino Library Reference.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawBitmapmx(), PgDrawImagemx(), PgShmemAttach(), PgShmemCleanup(),
PgShmemDestroy(), PgShmemDetach()
shm_open() in the QNX Neutrino Library Reference
Synopsis:
int PgShmemDestroy( void *addr );
Library:
ph
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 QNX Neutrino Library Reference.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgShmemCreate()
Synopsis:
int PgShmemDetach( void *addr );
Library:
ph
Description:
This function removes a shared memory reference previously attached with
PgShmemAttach().
The shared memory object persists until no other applications refer to it. Don’t use the
same name for another shared memory object, especially right after detaching the first
one.
Returns:
0 Success.
Errors:
See the errors for shm_unlink() in the QNX Neutrino Library Reference.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgShmemAttach()
Synopsis:
int PgSyncFlush( void );
Library:
ph
Description:
This function ensures that the draw stream has been flushed, and processed, before
unblocking the calling client.
PgSyncFlush() works on the current draw context, while you can specify the drawing
context dc for PgSyncFlushCx(). The variable dc represents a pointer to the draw
context.
Returns:
0 Success.
-1 Error.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawString*(), PgFlush*() PgSetFillColor*(), PgSetFillDither*(),
PgSetFillTransPat*(), PgSetUnderline*()
“Drawing attributes” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PgSwapDisplay( PdOffscreenContext_t *osc,
unsigned long flags );
Library:
ph
Description:
These functions point the CRT of the video display at the context indicated by osc.
These functions can be used for double and triple buffering. They’re available only in
direct mode.
The flags argument is a combination of the following bits:
Pg_SWAP_BLIT Blit the contents of the new target to the old one.
Pg_SWAP_VSYNC Wait for a Vsync to occur before continuing to parse the draw
stream.
To guarantee that you can point the CRT at this target, you should create it with the
flag Pg_OSC_CRTC_SAFE.
PgSwapDisplay() works on the current graphics context, while you can specify the
graphics context gc for PgSwapDisplayCx().
Returns:
0 Success.
-1 An error occurred.
Examples:
This example of double buffering assumes we’re in direct mode already:
PdOffscreenContext_t *buf[2];
int cur_buf=1;
while (not_done)
{
PhDCSetCurrent(buf[cur_buf]);
RenderMyFrame();
PgSwapDisplay(buf[cur_buf],0);
PgFlush();
cur_buf = cur_buf ? 0 : 1;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateOffscreenContext(), PdDupOffscreenContext(), PdGetOffscreenContextPtr(),
PdOffscreenContext_t, PgContextBlit*()
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PgUnlockLayer( int layer );
Arguments:
layer The layer index, which must be 0 or greater.
Library:
ph
Description:
PgUnlockLayer() releases a layer from exclusive use by an application. To lock a
layer, call PgLockLayer().
Other applications may not use PgSetLayerSurface() or PgSetLayerArg() on a locked
surface.
Your application should unlock its layers before it exits. You can lock a layer multiple
times, but need to unlock it only once.
Returns:
0 Success.
Errors:
EBUSY The specified layer is locked by another application.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdSetTargetDevice(), PgLockLayer(), PgSetLayerArg(), PgSetLayerSurface()
“Layers” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
typedef struct pg_scaler_channel {
PdOffscreenContext_t *yplane1;
PdOffscreenContext_t *uplane1;
PdOffscreenContext_t *vplane1;
PdOffscreenContext_t *yplane2;
PdOffscreenContext_t *uplane2;
PdOffscreenContext_t *vplane2;
unsigned flags;
int chid;
} PgVideoChannel_t;
Description:
This data structure describes a video overlay channel. It includes at least:
uplane1 A pointer to an offscreen context describing the primary U data buffer for
a Planar YUV format. It’s used only for Planar YUV formats.
vplane1 A pointer to an offscreen context describing the primary V data buffer for
a Planar YUV format. It’s used only for Planar YUV formats.
Classification:
Photon
See also:
PdOffscreenContext_t, PgConfigScalerChannel(), PgCreateVideoChannel(),
PgDestroyVideoChannel(), PgGetOverlayChromaColor(), PgGetScalerCapabilities(),
PgNextVideoFrame(), PgScalerCaps_t, PgScalerProps_t
“Video overlay” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgWaitDrawComplete( void );
Library:
ph
Description:
This functions waits until all previously emitted draw streams have been processed by
the primary graphics driver.
This function is useful for throttling applications that continually draw. This call
prevents the applications from getting ahead of the hardware. To wait until it’s safe to
reuse a shared memory image, call PgWaitHWIdle().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdSetTargetDevice(), PgWaitHWIdle(), PgWaitVSync()
Synopsis:
int PgWaitHWIdle( void );
Library:
ph
Description:
This function waits until the video card’s FIFOs are empty and the engine is idle.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdSetTargetDevice(), PgWaitDrawComplete(), PgWaitVSync()
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PgWaitVSync( void );
Arguments:
dc PgWaitVSyncCx() only. A void pointer to any type of draw context. Examples
of draw contexts are:
• a PhDrawContext_t returned by PhDCCreate()
• a PmMemoryContext_t returned by PmMemCreateMC()
• a PpPrintContext_t returned by PpCreatePC()
• a PdOffscreenContext_t returned by PdCreateOffscreenContext()
Library:
ph
Description:
These functions insert a “wait for vertical sync” tag into the drawstream. The driver
waits until a vertical refresh has started before continuing to render the draw stream.
PgWaitVSync() works on the current draw context, while you can specify the draw
context for PgWaitVSyncCx().
Examples:
PgSetFillColor(Pg_RED);
PgWaitVSync();
PgDrawIRect(0,0,99,99,Pg_DRAW_FILL);
PgSetFillColor(Pg_BLACK);
PgDrawIRect(9,9,89,89,Pg_DRAW_FILL);
PgFlush(); // Wait for Vsync, then draw 2 rects
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgWaitDrawComplete(), PgWaitHWIdle()
“Direct mode” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
These functions handle operations that directly involve the Photon Manager. Using
these functions, you can:
• Create, destroy, or modify regions that are independent of the widget hierarchy.
Synopsis:
PhTile_t * PhAddMergeTiles( PhTile_t *tiles,
PhTile_t *add_tiles,
int *added );
Arguments:
tiles A pointer to a list of tiles.
add_tiles A pointer to a list of tiles that you want to merge into the tiles list.
Library:
ph
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 in the merged list 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(), PhIntersectTilings(), PhMergeTiles(), PhRectsToTiles(),
PhSortTiles(), PhTile_t, PhTilesToRects(), PhTranslateTiles()
“Using damage tiles” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
char * PhAllocPackType( char unsigned *type,
char unsigned *desc,
int unsigned grouping_num,
int unsigned handle,
int unsigned transport,
char *packing_type,
char unsigned *data,
int unsigned len,
int *size );
Arguments:
type A descriptive type name, such as image, text, filename, or
files. This is simply added to the header for the packed data.
grouping_num When used with Photon’s drag and drop mechanism, the
grouping_num is used to indicate which stream is just a different
representation of other data also packed into the same
PhTransportCtrl_t structure. Only one of each grouping_num
should be unpacked by the reader/destination.
This value is simply added to the header for the packed data.
handle A number that you can use to identify a transaction. This is simply
added to the header for the packed data.
transport The transport type used for the inlined data. This can be one of:
• Ph_TRANSPORT_INLINE — the data being transported is in
memory and can be unpacked immediately.
• Ph_TRANSPORT_FILEREF — the data being transported is in
the temporary file(s) named in the inlined data.
• Ph_TRANSPORT_SHMEM — the data being transported is in
the temporary shared object(s) named in the inlined data.
packing_type The name of the entry in the transport registry to be used to pack
the data. For more information, see PhTransportRegEntry_t.
If you already have a pointer to the registry entry, you can call
PhPackEntry() instead of PhPackType().
len The size, in bytes, of the data to be packed. This size is used only
for raw data.
size If this argument isn’t NULL, the size of the allocated buffer is
stored in the memory it points to.
Library:
ph
Description:
This function allocates a buffer big enough to hold the packed version of the given
data, and then packs the data into the buffer.
Returns:
A pointer to the buffer, or NULL if no data was packed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhMallocUnpack(), PhPackEntry(), PhPackType(), PhTransportCtrl_t,
PhTransportRegEntry_t, PhTransportType(), PhUnpack()
Drag and Drop chapter of the Photon Programmer’s Guide
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, PhRect_t
“Geometry data types” in the Working with Code chapter of the Photon Programmer’s
Guide
Synopsis:
void PhAreaToRect( PhArea_t const *area,
PhRect_t *rect );
Library:
ph
Description:
This function converts an area (i.e. a position and dimensions) into a rectangle (i.e.
upper-left and lower-right points).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhArea_t, PhRect_t, PhRectToArea()
Synopsis:
struct _Ph_ctrl *
PhAttach(
char const *name,
PhChannelParms_t const *parms );
Library:
ph
Description:
This function opens a communications channel to a Photon Manager. The channel
becomes the current channel.
• This is a low-level routine that you aren’t likely to call directly. Both PtInit() and
PtAppInit() invoke this function. Your application must call one of these functions
or PhAttach() before it calls any other Photon functions.
• The application that calls PhAttach() must have the appropriate permissions to read
from and write to the attached Photon server, or the call will fail.
• an optional channel that the Photon Manager can send Neutrino pulses to
PhAttach() doesn’t create a channel; if you need to create one, call PhChannelAttach().
The name argument contains the name registered by a Photon Manager. If you pass
NULL, the function uses the PHOTON environment variable. If PHOTON isn’t set,
the function uses /dev/photon instead.
The parms argument lets you fine-tune the resources of the channel. Passing NULL to
this argument gets the channel defaults:
If you don’t pass NULL for parms, you should pass a pointer to a
PhChannelParms_t structure, which contains at least:
where:
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(), PhChannelAttach(), PhDetach(), PhEventNext(),
PhEventArm(), PhEventRead(), PhGetMsgSize(), PhReattach(), PtInit(), PtAppInit()
Synopsis:
int PhBlit( PhRid_t rid,
const PhRect_t *rect,
const PhPoint_t *offset );
Arguments:
rid A pointer to a region ID within which the function will blit.
rect A pointer to a PhRect_t structure that defines the area the function blits.
offset A pointer to a PhPoint_t that defines an offset for the blitted area rect.
Library:
ph
Description:
This function “blits” the area that is defined by the PhRect_t structure pointed to by
rect and whose origin is defined by the origin of the region specified by the
PhPoint_t structure pointed to by rid. The area is blitted by the given offset. Other
windows aren’t affected by the blit.
Returns:
A nonnegative value
Success.
-1 The blit failed, possibly because rid was incorrect or the Photon Manager
wasn’t running.
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:
PhMultiBlit() PhPoint_t, PhRect_t, PgBlit*(), PtClippedBlit(), PtWidgetRid()
Synopsis:
typedef struct Ph_bitmap_cursor_descr {
PhCursorDescription_t hdr;
PhBitmapCursorData_t bmp;
} PhBitmapCursorDescription_t;
Description:
The PhBitmapCursorDescription_t structure defines a bitmap cursor. The
members include at least:
The PhBitmapCursorDescription_t contains these members:
offset1 The position of the upper-left corner of the first plane of the bitmap,
relative to the hot spot.
bytesperline1 The number of bytes per line for the first bitmap plane.
size2 The dimensions of the second bitmap plane, in pixels. If there’s only
one bitplane, set this to 0.
offset2 The position of the upper-left corner of the second plane of the
bitmap, relative to the hot spot.
bytesperline2 The number of bytes per line for the second bitmap plane. If there’s
only one bitplane, set this to 0.
Classification:
Photon
See also:
PhCursorDescription_t
Synopsis:
int PhCancelDrag(
PhRid_t rid,
unsigned input_group,
unsigned flags );
Arguments:
rid A PhRid_t that must match the rid passed to the PhInitDrag() that
initiated the drag operation you want to cancel.
flags Must be 0.
input_group An input-group value that must match the input_group passed to the
PhInitDrag() that initiated the drag operation you want to cancel.
Library:
ph
Description:
This function cancels a drag. The application still collects a Ph_EV_DRAG event with
a subtype of PhEV_DRAG_COMPLETE that describes the results of the operation. You
can inspect the button_state member of the event PhDragEvent_t data structure to
determine whether the PhCancelDrag() call or a button release caused the operation to
complete.
Returns:
A non-negative number.
Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhBitmapCursorDescription_t, PhCharacterCursorDescription_t,
PhDragEvent_t, PhEvent_t, PhGetData(), PhDim_t, PhInitDrag() PhPoint_t,
PhRect_t, PhTranslateRect()
“Dragging” in the Events chapter of the Photon Programmer’s Guide
Synopsis:
int PhChannelAttach( int channel,
int connection,
struct sigevent const *event );
Arguments:
channel A channel ID, or 0 to create a new channel.
Library:
ph
Description:
Use this function if you want the library to create a Neutrino channel or use one that
you’ve already created.
• name_attach()
• PhChannelAttach()
• PtAppAddInput()
See the Examples section for a sample of code that illustrates the correct order.
If you want to create a separate channel for Photon, it doesn’t matter whether you
create it and give it to PhChannelAttach() before or after calling name_attach(). But
keep in mind that since certain mechanisms in Photon library expect the Photon
channel to have the two DISCONNECT flags, they might not work properly if it
doesn’t. One such mechanism is the detection of broken connections (see
PtConnectionClientSetError() and PtConnectionServerSetError()) and anything that
relies on it.
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.
Examples:
To create a channel and a connection:
PhChannelAttach( 0, -1, NULL )
Here’s a fully working code sample that illustrates the order of PhChannelAttach(),
name_attach(), and PtAppAddInput():
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/neutrino.h>
#include <sys/iomsg.h>
#include <sys/iofunc.h>
#include <sys/dispatch.h>
#include <Pt.h>
struct my_msg
{
short type;
char reply[50];
};
int non_photon_msg_func (void *data, int rcvid, void *message, size_t size);
if (PtInit(NULL) == -1)
exit(EXIT_FAILURE);
/* attach the name the client will use to find us */
/* our channel will be in the attach structure */
if ( (attach = name_attach( NULL, MY_SERV, 0 )) == NULL)
{
printf("server:failed to attach name, errno %d\n", errno );
PtExit(EXIT_FAILURE);
}
PhChannelAttach (attach->chid, -1, NULL );
PtAppAddInput( NULL, 0, &non_photon_msg_func, NULL );
if ((window = PtCreateWidget(PtWindow, Pt_NO_PARENT, 0, NULL)) == NULL)
PtExit(EXIT_FAILURE);
PtRealizeWidget ( window);
PtMainLoop ();
return 0;
}
int non_photon_msg_func (void *data, int rcvid, void *message, size_t size)
{
struct my_msg *msg = ( struct my_msg * ) message;
printf ( "Recieved a non photon message\n");
if ( msg->type == NON_PHOTON_PULSE )
{
printf("server: This message is to be handled by this input handler\n");
/* deliver message to client that client requested */
strcpy ( msg->reply, "I got your message" );
MsgReply ( rcvid,EOK, (char *) msg->reply, sizeof ( msg->reply ));
return ( Pt_HALT );
}
else
{
printf("server: This message isn’t for this input handler\n");
return ( Pt_CONTINUE );
}
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddInput()
Interprocess Communication chapter of the Photon Programmer’s Guide
ionotify(), name_attach(), sigevent in the QNX Neutrino Library Reference
Synopsis:
typedef struct Ph_character_cursor_data {
PhCursorDescription_t hdr;
PgColor_t color;
} PhCharacterCursorDescription_t;
Description:
The PhCharacterCursorDescription_t structure is used to define a character
cursor. It contains these members:
Cursor types:
• Ph_CURSOR_POINTER —
• Ph_CURSOR_BIG_POINTER —
• Ph_CURSOR_MOVE —
• Ph_CURSOR_CROSSHAIR —
• Ph_CURSOR_CLOCK, Ph_CURSOR_WAIT —
• Ph_CURSOR_NOINPUT, Ph_CURSOR_DONT —
• Ph_CURSOR_FINGER —
• Ph_CURSOR_INSERT —
• Ph_CURSOR_DRAG_VERTICAL, Ph_CURSOR_DRAG_TOP,
Ph_CURSOR_DRAG_BOTTOM —
• Ph_CURSOR_DRAG_HORIZONTAL, Ph_CURSOR_DRAG_LEFT,
Ph_CURSOR_DRAG_RIGHT —
• Ph_CURSOR_DRAG_BACKDIAG, Ph_CURSOR_DRAG_TL,
Ph_CURSOR_DRAG_BR —
• Ph_CURSOR_DRAG_FOREDIAG, Ph_CURSOR_DRAG_TR,
Ph_CURSOR_DRAG_BL —
• Ph_CURSOR_LONG_WAIT —
• Ph_CURSOR_QUESTION_POINT —
• Ph_CURSOR_PASTE —
Classification:
Photon
See also:
PhCursorDescription_t, PgColor_t
Synopsis:
int PhClipboardCopyString( unsigned short ig,
const char *string );
Library:
ph
Description:
This function is a simple cover function for copying string-only data to the clipboard.
It builds a PhClipboardHdr entry:
and then calls PhClipboardWrite() to perform the operation. The string must be NULL
terminated.
Each input group has its own private clipboard, which can be selected through the ig
parameter. To determine the current input group, call PhInputGroup(), passing to it the
event that triggered the clipboard operation (e.g. cbinfo->event).
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhClipboardHdr, PhClipboardPasteString(), PhClipboardRead(),
PhClipboardWrite()
Synopsis:
typedef char PhClipType[8];
typedef struct {
PhClipType type;
uint32_t length;
void *data;
} PhClipboardHdr;
Description:
This data structure describes clipboard data. Its members include:
type The type of data — an arbitrary 8-character string (e.g. TEXT or BMAP) that
you can define for your application.
Classification:
Photon
See also:
PhClipboardCopyString(), PhClipboardPasteString(), PhClipboardRead(),
PhClipboardWrite()
Synopsis:
char *PhClipboardPasteString( unsigned short ig );
Library:
ph
Description:
This function is a simple cover function for pasting string-only data from the
clipboard. The function calls PhClipboardRead(), and requests data of type TEXT.
Each input group has its own private clipboard, which can be selected through the ig
parameter. To determine the current input group, call PhInputGroup(), passing to it the
event that triggered the clipboard operation (e.g. cbinfo->event).
This function allocates the resultant string with strdup(). Your application must free()
this memory after use.
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
Thread No
See also:
PhClipboardCopyString(), PhClipboardHdr, PhClipboardPasteString(),
PhClipboardRead, PhClipboardWrite
strdup(), free() in the QNX Neutrino Library Reference
Synopsis:
typedef char PhClipType[8];
Arguments:
ig The input group. Each input group has its own private clipboard. To
determine the current input group, call PhInputGroup(), passing to it the
event that triggered the clipboard operation (e.g. cbinfo->event).
type The data type to read from the clipboard.
Library:
ph
Description:
This function copies the clipboard data in that matches type from the Photon clipboard,
and returns a pointer to the data populated in a PhClipboardWrite structure.
Returns:
A pointer to a populated PhClipboardWrite
Successful completion.
NULL An error occurred.
Examples:
This callback reads data from the clipboard, and pastes it in a PtText widget named
text:
int
paste_from_clip( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
int *cursor, ig, insertion_pt;
PhClipboardHdr *ptr;
ig=PhInputGroup(cbinfo->event);
if (ptr=PhClipboardRead(ig,Ph_CLIPBOARD_TYPE_TEXT))
{
PtTextModifyText(ABW_text, insertion_pt, insertion_pt,
insertion_pt, ptr->data, utf8strblen( ptr->data, ptr->length, NULL ) );
free(ptr->data);
free(ptr);
}
PtContainerGiveFocus(ABW_text,NULL);
return(Pt_CONTINUE);
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhClipboardCopyString(), PhClipboardHdr, PhClipboardPasteString(),
PhClipboardWrite
Synopsis:
int32_t PhClipboardWrite(unsigned short ig,
uint32_t n,
PhClipboardHdr const clip[]);
Arguments:
ig The input group. Each input group has its own private clipboard. To
determine the current input group, call PhInputGroup(), passing to it the
event that triggered the clipboard operation (e.g. cbinfo->event).
Library:
ph
Description:
This function copies the clipboard data in clip to the Photon clipboard. Each clip is
saved based on the input group ig, data type clip.type, and ID of the user. This ensures
that one user can’t access clipboard data saved by another user. Clipboard data is also
encrypted, and can only be accessed through the clipboard API function
PhClipboardRead().
Multiple representations of the data may be placed on the clipboard. For example, you
may want to save text and format data for the text. The number of different types is
specified with the n parameter. Each type has a header structure in the clip array. For
more information, see PhClipboardHdr.
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
This callback copies selected text from a PtText widget named text, and saves it on
the clipboard:
int
copy_to_clip( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
char *selstring;
int start, end, len, ig;
PhClipboardHdr clip[1];
ig=PhInputGroup(cbinfo->event);
len = PtTextGetSelection(ABW_text, &start, &end);
if(start!=-1 && len > 1) {
char *text = NULL;
PtGetResource( ABW_text, Pt_ARG_TEXT_STRING, &text, 0 );
if( text ) {
int s = utf8strnlen( text, start, NULL ),
l = utf8strnlen( text + s, end - start, NULL );
if( NULL != (selstring = malloc( l + 1 )) ) {
// Copy text to clipboard
memcpy( selstring, text + s, l );
selstring[l] = 0;
strcpy(clip[0].type,Ph_CLIPBOARD_TYPE_TEXT);
clip[0].length=strlen(selstring);
clip[0].data = selstring;
PhClipboardWrite(ig, 1, clip);
free(selstring); selstring=NULL;
}
}
}
PtContainerGiveFocus(ABW_text, NULL);
return(Pt_CONTINUE);
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhClipboardCopyString(), PhClipboardHdr, PhClipboardPasteString(),
PhClipboardRead(), PhClipboardHdr
Synopsis:
PhTile_t *PhClipTilings(
PhTile_t *tiles,
PhTile_t const * const clip_tiles,
PhTile_t **intersection );
Library:
ph
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()
“Using damage tiles” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PhTile_t * PhCoalesceTiles( PhTile_t *tiles );
Library:
ph
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()
“Using damage tiles” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PhTile_t * PhCopyTiles(
PhTile_t const * const tile );
Library:
ph
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()
“Using damage tiles” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PhImage_t *PhCreateImage( PhImage_t *buffer,
short width,
short height,
int type,
PgColor_t const *palette,
int ncolors,
int shmem );
Library:
ph
Description:
This function creates a new Photon image and allocates space for the image data and
palette (if present).
The buffer argument lets you pass in a pointer to a PhImage_t structure to fill in. If
this value is NULL, the function allocates a structure for you.
The width and height specify the size of the new image, in pixels. The type specifies
the type of the image. Supported types are outlined in the documentation for
PhImage_t.
The palette and ncolors arguments let you have this function automatically allocate
and fill in space to store the image’s palette, if needed. The ncolors argument specifies
the size of the palette in terms of the number of colors, while palette points to the list
of colors specifying the palette itself:
• If ncolors is nonzero, but palette is NULL, space is allocated for the palette, but
nothing is copied.
• If ncolors is nonzero and palette is non-NULL, then space is allocated and the
palette is copied automatically.
The shmem argument specifies whether or not shared memory should be allocated for
the image’s data. For large images, shared memory facilitates faster data transfer to
local graphics drivers, and hence quicker rendering of the image. If you wish to use
shared memory to store the image data, set this value to 1. Otherwise, set it to 0.
Returns:
A pointer to the new image on success, or NULL if an error occurred due to lack of
memory, or if the specified type isn’t a recognized Photon image type.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetImageRes(), PgColor_t, PgDrawPhImage*(), PgDrawPhImageRect*(),
PgDrawRepPhImage*(), PhImage_t, PhMakeGhostBitmap(),
PhMakeTransBitmap(), PhMakeTransparent(), PhReleaseImage(),
PmMemCreateMC(), PmMemFlush(), PxRotateImage(), PxLoadImage()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
PhTransportCtrl_t *PhCreateTransportCtrl( );
Library:
ph
Description:
This function creates and initializes a control structure to be used when packing data
to send using Photon’s transport mechanism.
Returns:
A pointer to the PhTransportCtrl_t structure created.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetNextInlineData(), PhGetTransportVectors(), PhPackEntry(), PhPackType(),
PhReleaseTransportCtrl(), PhTransportCtrl_t, PhTransportLink_t,
PhTransportType(), PtCreateTransportCtrl()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
typedef struct Ph_cursor_def {
PhRegionDataHdr_t hdr;
PhPoint_t size1;
PhPoint_t offset1;
PgColor_t color1;
char bytesperline1;
PhPoint_t size2;
PhPoint_t offset2;
PgColor_t color2;
char bytesperline2;
char Spare[14];
char images[1];
} PhCursorDef_t;
Description:
The PhCursorDef_t structure is used to define bitmaps to be used as the cursor. The
members include at least:
offset1 The position of the upper-left corner of the first plane of the bitmap,
relative to the hot spot.
bytesperline1 The number of bytes per line for the first bitmap plane.
offset2 The position of the upper-left corner of the second plane of the
bitmap, relative to the hot spot.
color2 The color of the second bitplane. You can’t have more than two
bitplanes.
bytesperline2 The number of bytes per line for the second bitmap plane.
Classification:
Photon
See also:
PgColor_t, PhPoint_t, PhRegionDataHdr_t
Pt_ARG_BITMAP_CURSOR (PtWidget) in the Widget Reference
Synopsis:
typedef struct Ph_ev_cursor_descr {
unsigned short type;
unsigned short length;
} PhCursorDescription_t;
Description:
The PhCursorDescription_t structure is used as a header for these cursor
description structures:
In functions that call for a PhCursorDescription_t, you should pass in the address
for the hdr structure of a populated PhCharacterCursorDescription_t or
PhBitmapCursorDescription_t.
The members of PhCursorDescription_t are:
type Defines a cursor type. See the parent structure for a description.
Classification:
Photon
See also:
PhCharacterCursorDescription_t, PhBitmapCursorDescription_t,
PhInitDrag(), PtDndSelect(), PtInitDnd()
Synopsis:
PhDrawContext_t *PhDCCreate(
int type,
long flags,
int (*flush)(int Subtype),
int (*modify)(PhDrawContext_t *dc,
int acquire,
void *data ) );
Arguments:
type The type of draw context:
• Ph_DRAW_TO_MEMORY_CONTEXT — the context being created will
draw to memory.
• Ph_DRAW_TO_OFFSCREEN_MEMORY — emit the draw stream to
offscreen memory.
• Ph_DRAW_TO_PHOTON — normal draw mode.
• Ph_DRAW_TO_PRINT_CONTEXT — create a context that’s compatible
with the Pp* api and will embed the required printer control codes in
the draw stream and allow you to direct the draw stream to an external
source (spooler/file)
• Ph_DRAW_TO_SERVICE — emit the draw stream directly to a service
provider.
flush The function to be called whenever the current draw buffer needs to be
flushed. If not provided, the standard Photon graphic flush function is used.
The Subtype argument is what’s passed by PgFFlush().
modify A function that’s called whenever this draw control is to be modified. The
modification is restricted by the type of the draw control (e.g. if the type is
Ph_DRAW_TO_PRINTER, you can target a different printer but can’t target
memory with subsequent calls to the modify function).
The arguments are:
• dc — a pointer to the draw context structure.
• action — what’s being done to the draw context; one of:
- Ph_CREATED_DC
- Ph_ACTIVATE_DC
- Ph_DEACTIVATE_DC
- Ph_DESTROYING_DC
• data — a pointer to arbitrary data you want to pass to the function.
Library:
ph
Description:
This function creates a draw context structure and initializes its flush and attach
functions. The type argument is recorded in the new draw control and prevents the DC
from being used as anything but its current type.
You aren’t likely to call this function directly unless you’re creating your own type of
draw context. The functions that create specific types of contexts (e.g. direct-mode,
printer, and memory) call PhDCCreate().
Returns:
A pointer to the newly allocated draw context, or NULL if there isn’t enough memory.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdCreateDirectContext(), PdCreateOffscreenContext(), PhDCSetCurrent(),
PhDCGetCurrent(), PhDCRelease(), PmMemCreateMC(), PpCreatePC()
Synopsis:
PhDrawContext_t *PhDCGetCurrent( void );
Library:
ph
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:
PhDCCreate(), PhDCSetCurrent(), PhDCRelease()
Synopsis:
int PhDCRelease( PhDrawContext_t *dc );
Library:
ph
Description:
This function releases the provided DC (the default Photon draw context can not be
released). The context is notified of its pending demise before it’s destroyed, so that it
can do any necessary cleanup.
You aren’t likely to call this function directly unless you’re releasing:
The functions that release specific types of contexts (e.g. direct-mode, printer, and
memory) call PhDCRelease().
Returns:
0 Success.
-1 An error occurred (most likely you’re trying to release the Photon default DC).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PdReleaseDirectContext(), PdCreateOffscreenContext(), PhDCCreate(),
PhDCGetCurrent(), PhDCSetCurrent(), PmMemReleaseMC(), PpReleasePC()
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PhDrawContext_t *PhDCSetCurrent(
void *draw_context );
Arguments:
draw_context A pointer to the draw context to be made the default one.
Library:
ph
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.
Print contexts Created via PpCreatePC(). Print contexts are used to produce
printed output from Photon applications.
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
PpContinueJob(). PpContinueJob() 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 = PpContinueJob( 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:
PhDCCreate(), PhDCGetCurrent(), PhDCRelease(), PmMemCreateMC(),
PpContinueJob(), PpCreatePC(), PpPrintContext_t
Synopsis:
int PhDetach( struct _Ph_ctrl *Ph );
Library:
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:
PhRect_t *PhDeTranslateRect(
PhRect_t *rect,
PhPoint_t const *delta );
Library:
ph
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:
PhPoint_t, PhRect_t, PhTranslateRect()
“Geometry data types” in the Working with Code chapter of the Photon Programmer’s
Guide
Synopsis:
PhTile_t * PhDeTranslateTiles(
PhTile_t *tile,
PhPoint_t const *point_subtract );
Library:
ph
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(), PhPoint_t,
PhRectsToTiles(), PhSortTiles(), PhTile_t, PhTilesToRects(), PhTranslateTiles()
“Using damage tiles” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
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, PhRect_t
“Geometry data types” in the Working with Code chapter of the Photon Programmer’s
Guide
Synopsis:
typedef struct Ph_ev_drag_data {
PhRect_t rect;
PhRid_t rid;
PhRect_t boundary;
PhDim_t min;
PhDim_t max;
PhDim_t step;
PhPoint_t pos;
unsigned long key_mods;
unsigned short flags;
unsigned short button_state;
} PhDragEvent_t;
Description:
The PhDragEvent_t structure defines the data associated with Ph_EV_DRAG events
(see PhEvent_t). It contains at least the following members:
rid The ID of the region that initiated the drag operation. Your application
needs to specify the region ID when it calls PhInitDrag() to initiate the
dragging operation.
min, max PhDim_t structures that define the minimum and maximum sizes of the
drag rectangle, as specified in the call to PhInitDrag().
pos A PhPoint_t structure that indicates the current cursor position. This
position isn’t necessarily within the boundary rectangle.
key_mods Your application can use the modifier keys (e.g. Shift or Num Lock) to
change the meaning of a drag event. 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 drag event is
sent.
The key_mods member is a combination of the following bits:
• Pk_KM_Shift
• Pk_KM_Ctrl
• Pk_KM_Alt
• Pk_KM_AltGr
• Pk_KM_Shl3
• Pk_KM_Mod6
• Pk_KM_Mod7
• Pk_KM_Mod8
• Pk_KM_Shift_Lock
• Pk_KM_Ctrl_Lock
• Pk_KM_Alt_Lock
• Pk_KM_AltGr_Lock
• Pk_KM_Shl3_Lock
• Pk_KM_Mod6_Lock
• Pk_KM_Mod7_Lock
• Pk_KM_Mod8_Lock
• 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.
Classification:
Photon
See also:
PhDim_t, PhEvent_t, PhInitDrag(), PhPoint_t, PhRect_t
“Dragging” in the Events chapter of the Photon Programmer’s Guide
Synopsis:
int PhEmit( PhEvent_t const *event,
PhRect_t const *rects,
void const *data );
Library:
ph
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. If event->num_rects isn’t 0, then rects must point
to an array of event->num_rects valid rectangles.
The data argument points to variable-length event-specific data. If event->data_len
isn’t 0, then data must point to a buffer of at least event->data_len bytes.
If you set the collector ID (event->collector.rid) to zero, the event is enqueued to every
appropriately sensitive region that intersects with the event. If you set collector.rid to a
region ID, only that region notices the event.
The Photon library fills in the collector and translation fields in the PhEvent_t
structure after a copy of the event is enqueued to an application.
Returns:
A nonnegative value
Successful completion.
Examples:
The following example emits an expose event from the device region. Because the
event covers the entire event space, any visible part of the event space is refreshed:
#include <stdio.h>
#include <time.h>
#include <Ph.h>
event.subtype = 0;
event.flags = 0;
event.num_rects = 1;
event.data_len = 0;
event.emitter.rid = Ph_DEV_RID;
rect.ul.x = rect.ul.y = SHRT_MIN;
rect.lr.x = rect.lr.y = SHRT_MAX;
PhEmit( &event, &rect, NULL );
return EXIT_SUCCESS;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEvent_t, PhEmitmx(), PhEventNext(), PhEventPeek(), PhEventRead(),
PhRect_t, PtSendEventToWidget()
“Emitting events” in the Events chapter of the Photon Programmer’s Guide.
Synopsis:
int PhEmitmx( PhEvent_t const *event,
PhRect_t const *rects,
int mxparts,
iov_t *mx );
Library:
ph
Description:
This function provides an alternative to PhEmit(). You’ll find it useful when the
event-specific data isn’t contiguous in memory.
The mx argument points to an array of iov_t entries, and mxparts contains the
number of mx entries pointed to by mx. You should leave the first three entries of mx
blank; these are filled in by PhEmitmx(). You can use the remaining entries to build a
description of the data to be attached to the event. If event->data_len isn’t 0, then the
event data must be at least event->data_len bytes long.
The event argument points to a PhEvent_t structure.
The rects argument points to an array of PhRect_t structures that define the
rectangles associated with the event. If event->num_rects isn’t 0, then rects must point
to an array of event->num_rects valid rectangles.
Returns:
A nonnegative value
Successful completion.
Examples:
The following example emits a pointer press event. (A call to PhEmit() is 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.emitter.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;
SETIOV( &mx[3], &ptr_event, sizeof( ptr_event ) );
PhEmitmx( &event, &rect, 4, mx );
return EXIT_SUCCESS;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgFlush(), PhEvent_t, PhEmit(), PhPointerEvent_t, PhRect_t
“Emitting events” in the Events chapter of the Photon Programmer’s Guide.
MsgSendv(), SETIOV() in the QNX Neutrino Library Reference
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:
subtype Further information about the event. For the possible values of
subtype, see the description of each event type.
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
Emitted when the pointer crosses region boundaries. The subtype member of the
PhEvent_t structure indicates one of the following boundary conditions:
Ph_EV_PTR_ENTER*
Ph_EV_PTR_LEAVE*
Emitted when the region the cursor points at changes. Both the previous and
current regions must have the Ph_FORCE_BOUNDARY flag set, since Photon
only considers regions with this bit set to be pointed at by the cursor. The cursor
will always point at something, since the root region has this bit set. When the
region pointed to changes, any regions between the previous and new regions
(that is, regions in the common ancestor tree) regardless of whether they have
the Ph_FORCE_BOUNDARY flag set also receive boundary events. Since these
events are emitted directly to the region, they are not affected by opacity to
boundary events. The event subtypes are:
• Ph_EV_PTR_ENTER_FROM_PARENT — emitted to a child region when the
pointer enters it from a parent region. Formerly Ph_EV_PTR_ENTER, which
is deprecated.
• Ph_EV_PTR_ENTER_FROM_CHILD — emitted to a parent region when the
pointer enters it from a child region.
Ph_EV_BUT_PRESS
Emitted when the user presses a button on a pointing device. This event’s rectangle set
consists of a point source that indicates the current pointer focus. The event data is a
PhPointerEvent_t structure.
Ph_EV_BUT_RELEASE
Emitted when the user releases a pointing-device 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. However, in this case, the buttons member indicates
the buttons that were released.
This event type has the following subtypes:
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_RELEASE_OUTBOUND
Emitted when the user starts dragging, i.e. when the mouse is moved a few
pixels but the button hasn’t been released.
Ph_EV_BUT_REPEAT
Emitted when the user presses an auto-repeating button on a pointing device. This
event is emitted each time the button repeats. Its rectangle set consists of a point
source that indicates where the button was pressed. The event data is a
PhPointerEvent_t structure.
Ph_EV_DNDROP
Ph_EV_DND_INIT
The operation has started successfully.
Ph_EV_DND_CANCEL
The operation was canceled (for example, if the drop occurred when not over a
drop zone, or the destination terminated the operation before receiving the drop
or before it finished fetching requestable data).
If the operation is canceled in this way, the library cleans up the data structures
automatically.
Ph_EV_DND_COMPLETE
The drag-and-drop event is enqueued at the destination (the destination hasn’t
seen it yet).
Ph_EV_DND_DELIVERED
The destination has dequeued the drag-and-drop event.
Ph_EV_DND_ENTER
The pointer has moved into the widget’s region but no drop has occurred. This is
the reason_subtype the first time that the drag-and-drop callback is called.
Ph_EV_DND_MOTION
The pointer is moving inside the widget’s region. This type of event is emitted
only if the Pt_DND_SELECT_MOTION bit is set in the select_flags member of
the PtDndFetch_t structure for a piece of selected data.
Ph_EV_DND_REPEAT
This type of event is emitted periodically when Ph_EV_DND_MOTION events
have been requested. The destination might want to track Ph_EV_DND_REPEAT
events in, for example, a list widget, to select more than one item to be replaced
by dropped data.
Ph_EV_DND_DROP
The user has dropped the data.
Ph_EV_DND_LEAVE
The pointer has moved out of the widget’s region, but the user didn’t drop the
data.
Events with these subtypes are emitted internally to the Photon server to accept or
deny a drop:
• Ph_EV_DND_ACK
• Ph_EV_DND_NAK
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. You can cancel drag operations with
PhCancelDrag()
Ph_EV_DRAG_KEY_EVENT
Emit the event with a PhKeyEvent_t structure.
Ph_EV_DRAG_MOTION_EVENT
Emit the event with a PhPointerEvent_t structure.
Ph_EV_DRAG_MOVE
Indicates intermediate drag motion. The Photon Manager emits this drag-event
subtype if the Ph_DRAG_TRACK flag is set in the flags member of the
PhDragEvent_t structure when the drag operation is initiated.
Ph_EV_DRAG_START
Emitted when the server begins the drag operation.
Ph_EV_DRAW
Emitted by the Pg functions when applications perform draw operations. The event
travels toward the user and is collected by the graphics driver.
The event data is a PhDrawEvent_t structure that contains at least the following
members:
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:
PgFFlush (Ph_START_DRAW);
when the applications that received the expose have completed their updates.
This type of event indicates that the expose wasn’t caused by a region change.
You can use this event type to collect data for the purpose of producing some
form of hardcopy.
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
All regions must always be transparent to Ph_EV_INFO events. They are emitted by
applications or service providers to disseminate information or respond to requests.
The currently defined subtypes are:
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_OFFSCREEN_INVALID
Emitted when when an offscreen context is invalidated by the
graphics driver for any reason. Applications planning on using
offscreen contexts should be sensitive to this event and reinitialize
their off screen contexts accordingly. The data portion of this event is
a single long describing why the offscreen areas have been
invalidated. The defined types are:
Pg_VIDEO_MODE_SWITCHED
The graphics driver has changed video modes.
Pg_ENTERED_DIRECT
An application has entered direct mode.
Pg_EXITED_DIRECT
An application has left direct mode.
Pg_DRIVER_STARTED
The video driver has just started execution.
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.
Ph_EV_PTR_MOTION_BUTTON
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. The buttons member indicates which
buttons the user is pressing.
Ph_EV_PTR_MOTION_NOBUTTON
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.
Ph_EV_RAW
These are raw, unfocused events that the Photon server handles.
Ph_EV_SERVICE
Ph_EV_REMOTE_WM
Handled by relay-type services such as phrelay (see the QNX
Neutrino Utilities Reference). 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:
Ph_EV_SYSTEM
PhPoint_t origin
A PhPoint_t structure that specifies the origin of the region,
relative to its parent’s region.
PhRect_t rect Its rectangle, relative to its origin.
Ph_EV_TIMER
Ph_EV_USER
A custom event type that your application can use to interact with other applications.
If you can’t rule out the possibility that your code might need to co-exist with code
written independently by other vendors, you need to make sure that you never send a
Ph_EV_USER event to any region that you don’t own.
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:
PhCancelDrag(), PhDragEvent_t, PhEventRegion_t, PhGetData(),
PhGetRects(), PhInitDrag(), PhKeyEvent_t, PhPoint_t, PhPointerEvent_t,
PhRect_t, PhWindowEvent_t, PtDndFetch_t
Events chapter of the Photon Programmer’s Guide
Synopsis:
int PhEventArm( void );
Library:
ph
Description:
This function arms the current Photon channel so that the channel will send a Neutrino
pulse to the application when an event becomes available. If an event is already
available, the pulse is sent immediately.
You must call this function before calling PhEventRead() for the first time.
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(), PhEventRead()
“Collecting events” in the Events chapter of the Photon Programmer’s Guide
Synopsis:
int PhEventEmit( PhEvent_t const *event,
PhRect_t const *rects,
void const *data );
Library:
ph
Description:
This function emits the event described by the given PhEvent_t structure. PhEmit()
does the same things as PhEventEmit(), but provides a cleaner API.
The rects argument points to an array of PhRect_t structures that define the
rectangles associated with the event. If event->num_rects isn’t 0, then rects must point
to an array of event->num_rects valid rectangles.
The data argument points to variable-length event-specific data. If event->data_len
isn’t 0, then data must point to a buffer of at least event->data_len bytes.
If you set the collector ID (event->collector.rid) to zero, the event is enqueued to every
appropriately sensitive region that intersects with the event. If you set collector.rid to a
region ID, only that region notices the event.
The Photon library fills in the collector and translation fields in the PhEvent_t
structure after a copy of the event is enqueued to an application.
Returns:
0 Success
-1 An error occurred, or no further events are pending. Check the value of errno:
• If errno is ENOMSG, Photon had no messages enqueued to your application
at the time you emitted the event.
• If errno isn’t ENOMSG, an error occurred.
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 covers the entire event space, any visible part of the event space is refreshed:
#include <stdio.h>
#include <time.h>
#include <Ph.h>
PhEvent_t event = { 0 };
PhRect_t rect;
return EXIT_SUCCESS;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEmit(), PhEmitmx(), PhEvent_t, PhEventEmitmx(), PhEventNext(),
PhEventPeek(), PhEventRead(), PhRect_t, 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 );
Library:
ph
Description:
This function provides an alternative to PhEventEmit(). You’ll find it useful when the
event-specific data isn’t contiguous in memory.
PhEmitmx() does the same things as PhEventEmitmx() and provides a cleaner API.
The mx argument points to an array of iov_t entries, and mxparts contains the
number of mx entries pointed to by mx. You should leave the first three entries of mx
blank; these are 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. If event->data_len
isn’t 0, then the event data must be at least event->data_len bytes long.
The rects argument points to an array of PhRect_t structures that define the
rectangles associated with the event. If event->num_rects isn’t 0, then rects must point
to an array of event->num_rects valid rectangles.
Returns:
0 Successful completion.
-1 An error occurred, or no further events are pending. Check the value of errno:
• If errno is ENOMSG, Photon had no messages enqueued to your application
at the time you emitted the event.
• If errno isn’t ENOMSG, an error occurred.
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 call to PhEventEmit() is just as
efficient and slightly more convenient.)
#include <stdio.h>
#include <time.h>
#include <Ph.h>
PhRect_t rect;
PhPointerEvent_t ptr_event;
iov_t mx[4];
fprintf( stderr,
"Could not attach a Photon channel.\n");
exit( EXIT_FAILURE );
}
event.type = Ph_EV_BUT_PRESS;
event.subtype = 0;
event.emitter.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;
SETIOV( &mx[3], &ptr_event, sizeof( ptr_event ) );
PhEventEmitmx( &event, &rect, 4, mx );
return EXIT_SUCCESS;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgFlush(), PhEmit(), PhEmitmx(), PhEvent_t, PhEventEmit(),
PhPointerEvent_t, PhRect_t
“Emitting events” in the Events chapter of the Photon Programmer’s Guide.
MsgSendv(), SETIOV() in the QNX Neutrino Library Reference
Synopsis:
int PhEventNext( void *buffer,
unsigned size );
Library:
ph
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.
For asynchronous event notification, see PhEventRead() and PhEventArm().
If the application’s event queue contains an event when this call is made, Photon
replies immediately with that event.
If your application uses widgets, don’t try to write your own event-handling loop; use
PtMainLoop() or PtProcessEvent() instead.
Returns:
Ph_EVENT_MSG Successful completion.
-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 ) ) {
case Ph_EVENT_MSG:
PtEventHandler( event );
break;
case -1:
perror( "PhEventNext failed" );
break;
}
}
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAttach(), PhEvent_t, PhEventPeek(), PhEventRead(), PhGetMsgSize(),
PtEventHandler()
“Collecting events” in the Events chapter of the Photon Programmer’s Guide
Synopsis:
int PhEventPeek( void *buffer,
unsigned size );
Library:
ph
Description:
This function lets you check if an event is pending on the current Photon channel:
• When there’s an event pending, Photon replies immediately with that event, and
this function returns Ph_EVENT_MSG.
Since this function is nonblocking, you should find it useful for applications that need
to run continuously and still interact with Photon.
For asynchronous event notification, see PhEventRead() and PhEventArm().
If your application uses widgets, don’t try to write your own event-handling loop; use
PtMainLoop() or PtProcessEvent() instead.
Returns:
Ph_EVENT_MSG Successful completion.
-1 An error occurred.
Examples:
#define EVENT_SIZE sizeof( PhEvent_t ) + 1000
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(), PhEvent_t, PhEventNext(), PhEventRead(), PtEventHandler()
“Collecting events” in the Events chapter of the Photon Programmer’s Guide
Synopsis:
int PhEventRead( int rcvid,
void *buffer,
unsigned size );
Arguments:
rcvid The receive ID returned by MsgReceive() (see the QNX Neutrino Library
Reference).
buffer A pointer to the message received. If the message is a pulse telling you that
there’s a Photon event waiting, PhEventRead() stores the event in this
buffer. This buffer must be large enough to hold a Photon event and its
associated rectangles and data.
Library:
ph
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
Neutrino pulses or messages from other processes.
For synchronous event notification, see PhEventNext() and PhEventPeek().
Typically, you call this function with the rcvid returned by MsgReceive() to see if the
message received was a pulse sent by Photon.
If the message received is the application’s event pulse, then:
• If the buffer is large enough for the event, PhEventRead() retrieves the event, stores
it in the location pointed to by buffer, and rearms Photon. PhEventRead() returns
Ph_EVENT_MSG.
• If the buffer is too small for the event, but you set Ph_DYNAMIC_BUFFER when
you called PhAttach(), PhEventRead() stores a resize event in the buffer and returns
Ph_RESIZE_MSG; see PhGetMsgSize().
• If the buffer is too small for the event, and you didn’t set Ph_DYNAMIC_BUFFER
when you called PhAttach(), PhEventRead() sets errno to EMSGSIZE and returns
-1.
You must call PhAttach() and arm the event pulse by calling PhEventArm() before you
call PhEventRead() for the first time.
Returns:
Ph_EVENT_MSG Successful completion.
-1 An error occurred.
Examples:
This code fragment shows how you can use PhEventRead() with PhGetMsgSize() to
maintain a dynamic event buffer. You need to define my_msg_struct, initialize(),
and process_app_msg():
#include <stdlib.h>
#include <errno.h>
#include <sys/neutrino.h>
#include <Pt.h>
if( initialize() == -1 )
exit( EXIT_FAILURE );
PhEventArm();
chid = PhChannelAttach( 0, -1, NULL );
while( 1 ) {
rcvid = MsgReceive( chid, msg, msg_size, NULL );
case Ph_RESIZE_MSG:
msg_size = PhGetMsgSize( (PhEvent_t *)msg );
if( !( msg = realloc( msg, msg_size )))
{
errno = ENOMEM;
return( EXIT_FAILURE );
}
break;
case 0:
process_app_msg( msg );
break;
case -1:
perror( "PhEventRead failed" );
break;
}
}
return( EXIT_SUCCESS );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAttach(), PhEvent_t, PhEventArm(), PhEventNext(), PhEventPeek(),
PhGetMsgSize(), PtEventHandler()
“Collecting events” in the Events chapter of the Photon Programmer’s Guide
MsgReceive() in the QNX Neutrino 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:
long handle The user-definable handle that the application specifies when it
opens the region. Applications can use handle to quickly pass a
small amount of information along with events. For example, the
widget (Pt*()) functions use handle internally.
If the region described by a PhEventRegion_t structure isn’t
owned by the application that collected the event, then the Photon
Manager sets handle to 0.
Classification:
Photon
See also:
PhEvent_t, PhRegion_t
Events chapter of the Photon Programmer’s Guide.
Synopsis:
PhTransportRegEntry_t *
PhFindTransportType( char *packing_type );
Library:
ph
Description:
PhFindTransportType() finds the transport type matching packing_type within the
transport registry.
Returns:
A pointer to a PhTransportRegEntry_t structure that describes the requested
packing_type, which can be used in functions (such as PhPackEntry()) that require a
PhTransportRegEntry_t as a parameter, or NULL if no entry for packing_type was
found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhFreeTransportType(), PhMallocUnpack(), PhPackEntry(),
PhRegisterTransportType(), PhTransportRegEntry_t, PhTransportType(),
PhUnpack()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
void PhFreeTiles( PhTile_t * tile);
Library:
ph
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()
“Using damage tiles” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PhFreeTransportType( void *data,
char *packing_type );
Library:
ph
Description:
This function assumes that the data pointed to by data is an allocated structure that’s
described by a transport registry entry for packing_type — for more information, see
PhTransportRegEntry_t.
All data associated with data is freed using the transport registry entry for
packing_type.
Returns:
0 Success.
Examples:
PhFreeTransportType( ptr, "PhImage" );
PhFreeTransportType( ptr, "files" );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhFindTransportType(), PhMallocUnpack(), PhPackEntry(),
PhRegisterTransportType(), PhTransportRegEntry_t, PhTransportType(),
PhUnpack()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
PhTransportHdr_t * PhGetAllTransportHdrs(
char *buffer,
int unsigned buffer_size );
Library:
ph
Description:
PhGetAllTransportHdrs() extracts all the headers from the given buffer of packed
transport data and puts them into a linked list. The buffer_size argument specifies the
size of the buffer, in bytes.
Returns:
A pointer to the first entry in the linked list of transport headers.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetNextTransportHdr(), PhGetTransportHdr(), PhLocateTransHdr(),
PhReleaseTransportHdrs(), PhUnlinkTransportHdr()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
PhConnectId_t PhGetConnectId( void );
Library:
ph
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 );
Library:
ph
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 members:
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 );
Library:
ph
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()
Events chapter of the Photon Programmer’s Guide
Synopsis:
unsigned PhGetMsgSize( PhEvent_t const *event_buf );
Library:
ph
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:
See PhEventRead().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAttach(), PhEvent_t, PhEventNext(), PhEventPeek(), PhEventRead()
Synopsis:
void * PhGetNextInlineData(
PhTransportCtrl_t *ctrl,
PhTransportLink_t *current,
PhTransportLink_t **new_link );
Library:
ph
Description:
PhGetNextInlineData() gets the inline data for the next entry in the linked list
belonging to the control structure pointed to by ctrl. The current argument is a pointer
to the PhTransportLink_t structure for the current entry in the list, or NULL to start
at the beginning of the list. The memory pointed to by new_link is set to the address of
the next entry, or NULL if the end of the list has been reached.
Returns:
A pointer to the data stored in the next entry of the list, or NULL if the end of the list
has been reached.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhCreateTransportCtrl(), PhReleaseTransportCtrl(), PhTransportCtrl_t,
PhTransportLink_t
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
PhTransportHdr_t * PhGetNextTransportHdr(
PhTransportHdr_t *last_hdr,
PhTransportHdr_t *trans_hdr );
Library:
ph
Description:
This function gets the next header out of a buffer of packed transport data. This header
contains information needed to unpack the data that follows the header.
The last_hdr argument points to the last transport header that was unpacked, or to the
beginning of the buffer. The information for the next header found is stored in the
structure pointed to by trans_hdr.
Returns:
The same pointer as trans_hdr, or NULL if there isn’t another header in the buffer.
Errors:
EINVAL The structure pointed to by last_hdr has a NULL buffer pointer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetAllTransportHdrs(), PhGetTransportHdr(), PhLocateTransHdr(),
PhReleaseTransportHdrs(), PhUnlinkTransportHdr()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
PhRect_t *PhGetRects( PhEvent_t const *event );
Library:
ph
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(), PhRect_t
Events chapter of the Photon Programmer’s Guide
Synopsis:
PhTile_t *PhGetTile( void );
Library:
ph
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()
“Using damage tiles” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PhTransportHdr_t *PhGetTransportHdr(
PhTransportHdr_t *hdr,
char *buffer );
Library:
ph
Description:
This function extracts the header from the given buffer of packed transport data,
storing the header in the structure pointed to by hdr. PhGetTransportHdr() is used by
the recipient of the transport operation to get instructions for unpacking the data that
follows the header in the buffer.
Returns:
The same pointer as hdr.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetAllTransportHdrs(), PhGetNextTransportHdr(), PhLocateTransHdr(),
PhReleaseTransportHdrs(), PhUnlinkTransportHdr()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
iov_t * PhGetTransportVectors(
PhTransportCtrl_t *trans_ctrl,
int num_hdr_vectors,
int unsigned *num_vectors,
int unsigned *size );
Library:
ph
Description:
This function builds an array of I/O vectors from the linked list of packed data
belonging to the transport-control structure pointed to by trans_ctrl.
The num_hdr_vectors argument specifies the number of vectors to reserve at the
beginning of the array. These entries can be used for headers suitable for sending to
the destination of the transport operation.
The variable pointed to by num_vectors is set to the number of entries in the array,
including the reserved ones. The variable pointed to by size is set to the size of the
array, excluding the size of the reserved entries.
Returns:
A pointer to the array of I/O vectors, or NULL if there wasn’t enough memory to
allocate it.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhCreateTransportCtrl(), PhGetNextInlineData(), PhPackEntry(), PhPackType(),
PhTransportCtrl_t, PhTransportLink_t, PhTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
typedef struct PhImage
{
int type;
unsigned long image_tag;
int bpl;
PhDim_t size;
unsigned long palette_tag;
int colors;
PgAlpha_t *alpha;
PgColor_t transparent;
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 PhCreateImage() or PxLoadImage(). To
free the allocated members of this structure, call PhReleaseImage().
The structure contains at least the following members:
PhDim_t size A PhDim_t structure that defines the size of the image.
PgAlpha_t *alpha The image alpha map that’s used if the source alpha map
option is enabled.
PgColor_t transparent
The color to mask out when drawing.
char ghost_bpl The number of bytes per line for the ghosting bitmap.
char *ghost_bitmap
A pointer to the transparency mask for ghosting an image. The
leftmost pixel corresponds to the top bit of the first byte in the
mask.
int mask_bpl The number of bytes per line for the transparency mask.
Image types
The types of image are:
Pg_BITMAP_BACKFILL
A bitonal image; the two colors are specified in the color palette.
Pg_BITMAP_TRANSPARENT
A monochrome image with transparent regions. The bits in the image data that
are set to 1 are drawn using color palette entry 1; zeros are treated as transparent,
so they’re not drawn.
Pg_IMAGE_DIRECT_1555
This format has, for each pixel, one bit of alpha, and 5 bits each of red, green,
and blue.
Pg_IMAGE_DIRECT_4444
This format has 4 bits of alpha, and 4 bits each of red, green, and blue.
Pg_IMAGE_DIRECT_444
This format requires 2 bytes per pixel. It matches the high-speed color lookup
tables used by palette-based graphics drivers and provides the fastest method of
drawing direct-color images with palette-based graphics drivers. Here’s the bit
order:
xxxx.RRRR.GGGG.BBBB
Pg_IMAGE_DIRECT_565
This format packs each pixel into 2 bytes and matches the display format of
most 16-bit, direct-color, graphics drivers. Here’s the bit order:
RRRR.RGGG.GGGB.BBBB
Pg_IMAGE_DIRECT_8888
This format is an array of 4-byte color entries. The least significant byte is the
blue component, after that there is the green component, following that there is
the red component and the most significant byte is reserved.
Pg_IMAGE_DIRECT_888
This format packs each pixel into 3 bytes. Using this format, you can represent a
full 24 bit color image. Here’s the bit order:
RRRR.RRRR.GGGG.GGGG.BBBB.BBBB
Pg_IMAGE_GRADIENT_BYTE
This format uses 1 byte per pixel. The colors are algorithmically generated as a
gradient between the color set by PgSetFillColor() and the color set by
PgSetTextColor(). A pixel value of 0 produces the fill color, a pixel value of 255
produces the text color, and a pixel value of 128 produces an even blend of the
two.
Pg_IMAGE_GRADIENT_NIBBLE
This format packs 2 pixels per byte, allowing up to 16 levels. The first pixel is in
the upper half of the byte and the second pixel is in the lower half. The colors
are algorithmically generated as a gradient between the color set by
PgSetFillColor() and the color set by PgSetTextColor(). A pixel value of 0
produces the fill color, a pixel value of 15 produces the text color, and a pixel
value of 8 produces an even blend of the two.
Pg_IMAGE_PALETTE_BYTE
This format packs 1 pixel per byte, allowing up to 256 colors. This format
indexes directly into the current palette; see PgSetPalette(). If no palette is set,
the function chooses colors from the global palette; this may cause colors to
look different on each system.
Pg_IMAGE_PALETTE_NIBBLE
This format packs 2 pixels per byte, allowing up to 16 colors. The first pixel is
in the upper half of the byte, the second is in 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.
For convenience, you can AND Pg_IMAGE_CLASS_MASK with the image type to
determine the image’s class:
Pg_IMAGE_CLASS_PALETTE
The image requires a palette defined by PgSetPalette().
Pg_IMAGE_CLASS_GRADIENT
The image requires first and last colors defined by PgSetFillColor() and
PgSetTextColor().
Pg_IMAGE_CLASS_DIRECT
Each pixel defines its red, blue, and green components.
Classification:
Photon
See also:
ApGetImageRes(), PgColor_t, PgDrawPhImage*(), PgDrawPhImageRect*(),
PgDrawRepPhImage*(), PhCreateImage(), PhDim_t, PhMakeGhostBitmap(),
PhMakeTransBitmap(), PhMakeTransparent(), PhReleaseImage(),
PmMemCreateMC(), PmMemFlush(), PxRotateImage(), PxLoadImage()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
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,
const PhPoint_t *ptrpos,
const PhCursorDescription_t *cursor );
Arguments:
rid A PhRid_t that specifies the region that initiates the drag.
input_group You should set the input_group argument to the the input-group
value supplied with the event in cbinfo (see example).
min A pointer to a PhDim_t structure that defines the minimum size for
the drag rectangle returned in the drag events. (The application
receives the events in absolute coordinates.)
max A pointer to a PhDim_t structure that defines the maximum size for
the drag rectangle returned in the drag events. (The application
receives the events in absolute coordinates.)
Library:
ph
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.
Any attempt to initiate a drag operation while another is in progress in the same input
group fails.
You can cancel a drag operation with PhCancelDrag().
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
drag_lower_left( PhRect_t *rect, PhRect_t *boundary,
PtCallbackInfo_t *cbinfo )
{
PhEvent_t *event = cbinfo->event;
PhPointerEvent_t *ptrev = PhGetData( event );
static const PhCharacterCursorDescription_t
cursor = { { Ph_CURSOR_DRAG_BL, sizeof(cursor) }, Pg_RED };
switch( cbinfo->event->type )
{
case Ph_EV_DRAG:
drag = (PhDragEvent_t *)PhGetData( cbinfo->event );
rect = &drag->rect;
// drag rectangle in ABSOLUTE coordinates.
PhTranslateRect( rect,
&cbinfo->event->translation );
// rect is now relative to the region the drag
// was initiated on.
...
}
...
}
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PhBitmapCursorDescription_t, PhCharacterCursorDescription_t,
PhCancelDrag(), PhDragEvent_t, PhEvent_t, PhGetData(), PhDim_t,
PhPoint_t, PhRect_t, PhTranslateRect()
“Dragging” in the Events chapter of the Photon Programmer’s Guide
Synopsis:
int PhInputGroup( PhEvent_t *event );
Library:
ph
Description:
This function determines the input group associated with the given event. If event is
NULL or its input group is 0, PhInputGroup() returns the default input group.
Returns:
The input group.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEvent_t
Synopsis:
PhTile_t *PhIntersectTilings(
PhTile_t const * const tile1,
PhTile_t const * const tile2,
unsigned short *num_intersect_tiles );
Library:
ph
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()
“Using damage tiles” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
See below.
Description:
This structure describes a key event. It includes at least these members:
Classification:
Photon
See also:
PhEvent_t, PhPoint_t, PhPointerEvent_t
Events chapter of the Photon Programmer’s Guide
Synopsis:
int PhKeyToMb( char *buffer,
PhKeyEvent_t const *keyevent );
Library:
ph
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(), PhKeyEvent_t, PhTo8859_1()
<photon/PkKeyDef.h>
Synopsis:
unsigned PhLibVersion( void );
Library:
ph
Description:
This function returns the version of the Photon library that the calling application is
using.
You can use Ph_LIB_VERSION (defined in <PhT.h>) to determine the Photon library
version when you’re compiling.
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:
PhTransportLink_t *
PhLinkTransportData(
PhTransportLink_t **first_link,
PhTransportLink_t **last_link,
char const * const data,
int unsigned const size,
iov_t *iovs,
int unsigned const niovs );
Library:
ph
Description:
This function allocates a PhTransportLink_t structure and fills it in using the data,
size, iovs, and niovs arguments. It then adds the new structure to the end of the linked
list whose head is pointed to by first_link and whose tail is pointed to by last_link.
This function is used to build the linked list of data in a PhTransportCtrl_t
structure.
Returns:
A pointer to the PhTransportLink_t structure, or NULL if there wasn’t enough
memory.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhCreateTransportCtrl(), PhTransportCtrl_t, PhTransportFindLink(),
PhTransportLink_t, PhTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
int PhLocateTransHdr( PhTransportHdr_t **hdr_list,
PhTransLoc_t *desired_data,
PhTransportHdr_t *found );
Library:
ph
Description:
PhLocateTransHdr() searches the list of transport headers pointed to by *hdr_list for
the specific data of the type and description specified by desired_data.
If the function finds the data, it sets found to point to the header. It also removes any
headers for data in the same group as the data found (i.e. the other forms or choices of
the data).
Returns:
0 The data wasn’t found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetAllTransportHdrs(), PhGetNextTransportHdr(), PhGetTransportHdr(),
PhReleaseTransportHdrs(), PhUnlinkTransportHdr()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
int PhMakeGhostBitmap( PhImage_t *image );
Library:
ph
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
PgDrawPhImage() or PgDrawPhImagemx().
Returns:
0 The image was successfully created.
-1 The image wasn’t created. The image parameter may have been NULL, or the
allocation of the bitmap may have failed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawPhImage*(), PgDrawPhImageRect*(), PgDrawRepPhImage*(),
PhCreateImage(), PhImage_t
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PhMakeTransBitmap( PhImage_t *image,
PgColor_t trans_color );
Library:
ph
Description:
This function creates a transparent bitmap or transparency mask for the given image,
provided there isn’t one already.
The meaning of the trans_color argument depends on the type of the image:
Pg_IMAGE_PALETTE_NIBBLE
Pg_IMAGE_PALETTE_BYTE
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 )
{
.
.
.
}
Pg_IMAGE_GRADIENT_BYTE
Pg_IMAGE_GRADIENT_NIBBLE
The trans_color argument is the grey index (0-255 for BYTE, 0-15 for
NIBBLE) to be made transparent.
Pg_IMAGE_DIRECT_1555
Pg_IMAGE_DIRECT_4444
Pg_IMAGE_DIRECT_8888
Pg_IMAGE_DIRECT_888
The trans_color argument is the color to be made transparent, expressed as a
PgColor_t.
Pg_IMAGE_DIRECT_565
Pg_IMAGE_DIRECT_444
The trans_color argument is interpreted as a short packed with the color
information in the appropriate format (see PhImage_t).
The resulting bitmap is stored in the mask_bm member of the PhImage_t structure.
This function sets the image’s Ph_RELEASE_TRANSPARENCY_MASK flag.
To draw the image using the transparency mask, use PgDrawPhImage() or
PgDrawPhImagemx().
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;
PtSetResource( ABW_destination_label,
Pt_ARG_LABEL_IMAGE, &trans_image, 0 );
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:
PgColor_t, PgDrawPhImage*(), PgDrawPhImageRect*(), PgDrawRepPhImage*(),
PhCreateImage(), PhImage_t, PhMakeTransparent()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PhMakeTransparent( PhImage_t *image,
PgColor_t trans_color );
Library:
ph
Description:
PhMakeTransparent() makes the given trans_color transparent in the given image.
This function is similar to PhMakeTransBitmap(), but PhMakeTransparent() uses
chroma when possible; chroma is accelerated by most hardware, whereas transparency
bitmaps are always implemented in software.
If the image is palette-based, and the specified color appears more than once in the
palette, both become transparent if chroma is used. In this case, PhMakeTransparent()
calls PhMakeTransBitmap() to create a transparency mask.
The trans_color argument is the RGB color in the image’s palette to be made
transparent. You can pass an index into the palette as trans_color by ORing it with
Pg_INDEX_COLOR. For example:
if ( PhMakeTransparent( 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 an image transparent. It also shows how
* to take that image, put it into a label widget, and
* draw it on 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;
PtSetResource( ABW_destination_label,
Pt_ARG_LABEL_IMAGE, &trans_image, 0 );
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:
PgColor_t, PgDrawPhImage*(), PgDrawPhImageRect*(), PgDrawRepPhImage*(),
PhCreateImage(), PhImage_t, PhMakeTransBitmap()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
char * PhMallocUnpack( PhTransportHdr_t *hdr,
void **ret_struct,
TransportMalloc_t *ymalloc,
void *ymalloc_cb_data );
Library:
ph
Description:
This function unpacks data packed using one of the PhTransport* or PtTransport*
functions. Any memory required for the extraction is allocated via calls to the
provided ymalloc function. If ymalloc is NULL, a default allocator is used.
The hdr parameter describes the data to be unpacked and is itself extracted from the
packed data stream. See PhGetTransportHdr().
The pointer referenced by ret_struct is set to point to the newly unpacked data. The
actual data representation of the data extracted is described in the hdr that’s passed as
the first parameter to this function.
The TransportMalloc_t type (used for the prototype of the ymalloc function) is:
For each piece of memory that must be allocated while unpacking, the provided
ymalloc function is called with the following arguments:
• the transport registry entry for the data being extracted — see
PhTransportRegEntry_t
• the index for the data into the fixup array in the transport registry entry
This makes it very easy to unpack specific pieces of data into shared memory blocks,
etc.
As the data is unpacked, it’s automatically endian-corrected.
To free data unpacked using this function, call PhFreeTransportType().
Returns:
A pointer to the byte in the data stream following the data just extracted.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAllocPackType(), PhFindTransportType(), PhFreeTransportType(), PhPackEntry(),
PhRegisterTransportType(), PhTransportRegEntry_t, PhTransportType(),
PhUnpack()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
PhTile_t * PhMergeTiles( PhTile_t *tiles );
Library:
ph
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()
“Using damage tiles” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PhMoveCursorAbs( int input_group,
int x,
int y );
Library:
ph
Description:
This function moves the cursor for input_group to the absolute coordinates specified
by x and y.
To determine the current input group, call PhInputGroup(), passing to it the current
event, if any.
This function contravenes the standards put forth by the OSF/Motif Style Guide. Most
users will be disconcerted if your program changes the pointer position. See section
2.2.3.2 of the OSF/Motif Style Guide (ISBN 0-13-640491-X).
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 );
Library:
ph
Description:
This function moves the cursor for input_group to the coordinates specified by x and y
relative to the current cursor position.
To determine the current input group, call PhInputGroup(), passing to it the current
event, if any.
This function contravenes the standards put forth by the OSF/Motif Style Guide. Most
users will be disconcerted if your program changes the pointer position. See section
2.2.3.2 of the OSF/Motif Style Guide (ISBN 0-13-640491-X).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhMoveCursorAbs(), PhQueryCursor()
Synopsis:
int PhMultiBlit( PhRid_t rid,
unsigned short nrects,
const PhRect_t rects[],
const PhPoint_t *offset );
Arguments:
rid A pointer to a region ID from which the function will blit an area defined
by rects.
rects[] A pointer to an array of PhRect_t structures that define the areas the
function blits. The areas can overlap; Photon detects the overlaps and the
contents are blitted only once.
offset A pointer to a PhPoint_t that defines an offset for the blitted area defined
by rects.
Library:
ph
Description:
This function “blits” the multi-rectangular area that is defined by the PhRect_t
structures pointed to by rects and whose origin is defined by the origin of the region
specified by the PhPoint_t structure pointed to by rid. The area is blitted by the
given offset. Other windows aren’t affected by the blit.
Returns:
A nonnegative value
Success.
-1 The blit failed, possibly because rid was incorrect or the Photon Manager
wasn’t running.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgBlit*(), PhPoint_t, PhRect_t, PtClippedBlit(), PtWidgetRid()
Synopsis:
char * PhPackEntry(
char *buffer,
PhTransportRegEntry_t *regent,
char const * const type,
char const * const desc,
int unsigned const grouping_num,
int unsigned const handle,
int unsigned const request_transport,
int unsigned const inlined_transport,
char const * const data,
int unsigned const size,
int unsigned *tot_size,
iov_t *iovs,
int unsigned *niovs,
int unsigned *iovsize );
Library:
ph
Description:
This function takes the data referenced by data and packs it into a stream buffer
pointed to by buffer.
You’re not likely to call this function directly; call PhTransportType() instead.
regent A pointer to the transport registry entry for the type of data to
be packed. For more information, see
PhTransportRegEntry_t.
If you don’t have a pointer to the registry entry for the data to
be packed, call PhPackType() instead of PhPackEntry().
grouping_num When used with Photon’s drag and drop mechanism, the
grouping_num is used to indicate which stream is just a
different representation of other data also packed into the same
PhTransportCtrl_t structure. Only one of each
grouping_num should be unpacked by the reader/destination.
This value is simply added to the header for the packed data.
inlined_transport The transport type used for the inlined data. This can be one of:
• Ph_TRANSPORT_INLINE — the data being transported is in
memory and can be unpacked immediately.
• Ph_TRANSPORT_FILEREF — the data being transported is
in the temporary file(s) named in the inlined data.
• Ph_TRANSPORT_SHMEM — the data being transported is
in the temporary shared object(s) named in the inlined data.
Returns:
The current position in the buffer after packing the data, or NULL if no data was
packed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAllocPackType(), PhFindTransportType(), PhMallocUnpack(), PhPackType(),
PhRegisterTransportType(), PhTransportCtrl_t, PhTransportRegEntry_t,
PhTransportType(), PhUnpack()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
char * PhPackType( char *buffer,
char const * const type,
char const * const desc,
int unsigned const grouping_num,
int unsigned const handle,
int unsigned const request_transport,
int unsigned const inlined_transport,
char const * const packing_type,
void const * const data,
int unsigned const size,
int unsigned *tot_size,
iov_t *iovs,
int unsigned *niovs,
int unsigned *iovsize );
Library:
ph
Description:
This function takes the data referenced by data and packs it into a stream buffer
pointed to by buffer.
You’re not likely to call this function directly; call PhTransportType() instead.
grouping_num When used with Photon’s drag and drop mechanism, the
grouping_num is used to indicate which stream is just a
different representation of other data also packed into the same
inlined_transport The transport type used for the inlined data. This can be one of:
• Ph_TRANSPORT_INLINE — the data being transported is in
memory and can be unpacked immediately.
• Ph_TRANSPORT_FILEREF — the data being transported is
in the temporary file(s) named in the inlined data.
• Ph_TRANSPORT_SHMEM — the data being transported is
in the temporary shared object(s) named in the inlined data.
Returns:
A pointer to the buffer, or NULL if no data was packed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAllocPackType(), PhFindTransportType(), PhMallocUnpack(), PhPackEntry(),
PhRegisterTransportType(), PhTransportCtrl_t, PhTransportRegEntry_t,
PhTransportType(), PhUnpack()
Drag and Drop chapter of the Photon Programmer’s Guide
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, PhRect_t
“Geometry data types” in the Working with Code chapter of the Photon Programmer’s
Guide
Synopsis:
typedef struct Ph_point_16dot16 {
int32_t x_16dot16, y_16dot16;
} PhPoint16dot16_t;
Description:
The PhPoint16dot16_t structure describes the coordinates of a single point. It
contains at least the following members:
Classification:
Photon
See also:
PhArea_t, PhDim_t, PhRect16dot16_t
“Geometry data types” in the Working with Code chapter of the Photon Programmer’s
Guide
Synopsis:
typedef struct Ph_ev_ptr_data {
PhPoint_t pos;
unsigned short buttons;
unsigned short button_state;
unsigned char click_count;
unsigned char flags;
short z;
unsigned long key_mods;
unsigned long zero;
} PhPointerEvent_t;
Description:
The PhPointerEvent_t structure holds the data associated with all pointer events:
• Ph_EV_BUT_PRESS
• Ph_EV_BUT_RELEASE
• Ph_EV_BUT_REPEAT
• Ph_EV_PTR_MOTION_BUTTON
• Ph_EV_PTR_MOTION_NOBUTTON
button_state The current state of all the buttons (i.e. which buttons are pressed).
This is a combination of the same bits as buttons.
key_mods The modifier keys that are currently pressed. This is a combination
of:
• Pk_KM_Shift
• Pk_KM_Ctrl
• Pk_KM_Alt
• Pk_KM_AltGr
• Pk_KM_Shl3
• Pk_KM_Mod6
• Pk_KM_Mod7
• Pk_KM_Mod8
• Pk_KM_Shift_Lock
• Pk_KM_Ctrl_Lock
• Pk_KM_Alt_Lock
• Pk_KM_AltGr_Lock
• Pk_KM_Shl3_Lock
• Pk_KM_Mod6_Lock
• Pk_KM_Mod7_Lock
• Pk_KM_Mod8_Lock
• 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.
Classification:
Photon
See also:
PhEvent_t, PhKeyEvent_t
Events chapter of the Photon Programmer’s Guide
Synopsis:
int PhQueryCursor( unsigned short ig,
PhCursorInfo_t *buf );
Arguments:
ig The input group which contains the cursor you want to query. Set to 0 to
query any input group.
Library:
ph
Description:
This function collects information about the cursor for input group ig and places this
information in the provided structure buf .
To determine the current input group, call PhInputGroup(), passing to it the current
event, if any.
The PhCursorInfo_t structure is defined in <photon/PhT.h> and contains at least:
PhPoint_t last_press
Location of last Ph_EV_BUT_PRESS event.
unsigned long msec
msec of last press.
PhRect_t drag_boundary
A PhRect_t structure that defines the area to which to restrict
dragging.
PhRid_t phantom_rid
Region ID to deliver phantom to.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor_t, PhMoveCursorAbs(), PhMoveCursorRel(), PhPoint_t, PhRect_t
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 );
Library:
ph
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:
rid Consider regions that intersect with the region with this ID. Set rid
to 0 to consider all regions.
input_group Consider regions that belong to this input group (0 means any).
To determine the current input group, call PhInputGroup(), passing
to it the current event, if any.
Set type to 0 (i.e. all bits off) to consider all types of regions.
sense Consider regions that are sensitive or opaque to these event types.
The possible bits are:
• Ph_EV_BOUNDARY
• Ph_EV_BUT_PRESS
• Ph_EV_BUT_RELEASE
• Ph_EV_BUT_REPEAT
• Ph_EV_DNDROP
• Ph_EV_DRAG
• Ph_EV_DRAW
• Ph_EV_EXPOSE
• Ph_EV_INFO
• Ph_EV_KEY
• Ph_EV_PTR_MOTION_BUTTON
• Ph_EV_PTR_MOTION_NOBUTTON
• Ph_EV_RAW
• Ph_EV_SERVICE
• Ph_EV_SYSTEM
• Ph_EV_TIMER
• Ph_EV_WM
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
See also:
PhEvent_t, PhRect_t
Synopsis:
PhSysInfo_t * PhQuerySystemInfo(
PhRid_t rid,
PhRect_t const *rect,
PhSysInfo_t *sysinfo );
Library:
ph
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:
PhRect_t, PhSysInfo_t, PtQuerySystemInfo()
“System information” in the Regions chapter of the Photon Programmer’s Guide.
Synopsis:
struct _Ph_ctrl *PhReattach( struct _Ph_ctrl *Ph );
Library:
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:
PhArea_t, PhAreaToRect(), PhDeTranslateRect(), PhDim_t, PhPoint_t
PhRectIntersect(), PhRectToArea(), PhRectUnion(), PhTranslateRect()
“Geometry data types” in the Working with Code chapter of the Photon Programmer’s
Guide
Synopsis:
typedef struct Ph_rect_16dot16 {
PhPoint16dot16_t ul, lr;
} PhRect16dot16_t;
Description:
The PhRect16dot16_t structure describes the fixed point 16.16 coordinates of a
rectangle. It contains at least the following members:
ul Upper-left corner.
lr Lower-right corner.
Classification:
Photon
See also:
PhArea_t, PhAreaToRect(), PhDeTranslateRect(), PhDim_t, PhPoint16dot16_t
PhRectIntersect(), PhRectToArea(), PhRectUnion(), PhTranslateRect()
“Geometry data types” in the Working with Code chapter of the Photon Programmer’s
Guide
Synopsis:
int PhRectIntersect( PhRect_t *rect1,
PhRect_t const *rect2 );
Library:
ph
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
See also:
PhRect_t, PhRectUnion()
Synopsis:
PhTile_t * PhRectsToTiles( PhRect_t *rects,
int num_rects );
Library:
ph
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(), PhRect_t, PhSortTiles(), PhTile_t, PhTilesToRects(),
PhTranslateTiles()
“Using damage tiles” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
void PhRectToArea( PhRect_t const *rect,
PhArea_t *area);
Library:
ph
Description:
This function converts a rectangle (i.e. upper-left and lower-right points) into an area
(i.e. a position and dimensions).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhArea_t, PhAreaToRect(), PhRect_t
Synopsis:
int PhRectUnion( PhRect_t *rect1,
PhRect_t const *rect2 );
Library:
ph
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
See also:
PhRect_t, PhRectIntersect()
Synopsis:
See below.
Description:
The PhRegion_t structure describes a region. It contains at least the following
members:
PgColor_t cursor_color
The cursor color for this region.
unsigned short cursor_type
Sets the cursor type for this region. See <PhCursor.h>. A
cursor_type of Ph_CURSOR_INHERIT indicates this region
inherits the cursor from the parent region.
If you OR cursor_type with Ph_CURSOR_NO_INHERIT, then
children of this region won’t inherit its cursor type. The children
inherit the cursor from their first ancestor that doesn’t have the
Ph_CURSOR_NO_INHERIT flag set.
PhRid_t rid This region’s ID. The Photon Manager assigns this when the
region is opened.
Ph_FORCE_BOUNDARY
Determines whether the cursor points at
this region. Photon considers the cursor to
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.
PhRid_t bro_in_front
Indicates the brother region that’s located immediately in front.
If there’s no brother in front, the Photon Manager sets
bro_in_front to -1.
PhRid_t bro_behind
Indicates the brother region that’s located immediately behind. If
there’s no brother behind, the Photon Manager sets bro_behind
to -1.
unsigned short data_len
The length of the data portion of this region. The data is stored in
a single block of memory; to get a copy of it, call
PhRegionQuery().
The region data may consist of blocks of data of different types,
each preceded by a PhRegionDataHdr_t structure. There’s at
most one block of a given type. To find a specific type of data in
the region’s data, call PhRegionDataFindType().
If you need to change the region data, modify your copy or create
a new block (starting with a PhRegionDataHdr_t structure)
and pass it to PhRegionChange().
Classification:
Photon
See also:
PgColor_t, PgGetRegion(), PgSetRegion(), PhPoint_t, PhRegionChange(),
PhRegionClose(), PhRegionDataFindType(), PhRegionDataHdr_t, PhRegionInfo()
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 );
Library:
ph
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 a PhRect_t structure that defines 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:
A nonnegative value
Successful completion.
-1 An error occurred.
Examples:
#include <Pt.h>
}MyData_t;
int main() {
PtWidget_t *win;
PhRegion_t region;
char data[1000];
MyData_t region_data;
PhRid_t rid;
region.data_len = region_data.hdr.len;
region.rid = rid;
PhRegionQuery (rid, ®ion, NULL,
(PhRegionDataHdr_t *)&data,
sizeof(data));
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRect_t, PhRegion_t, PhRegionClose(), PhRegionDataHdr_t,
PhRegionOpen(), PhRegionQuery()
Regions chapter of the Photon Programmer’s Guide
Synopsis:
int PhRegionClose( PhRid_t rid );
Library:
ph
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:
A nonnegative value
Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRegion_t, PhRegionChange(), PhRegionOpen()
Regions chapter of the Photon Programmer’s Guide
Synopsis:
PhRegionDataHdr_t *
PhRegionDataFindType(
PhRegion_t const *region,
PhRegionDataHdr_t const *data,
short type);
Library:
ph
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.
Examples:
See PhRegionChange().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRegion_t, PhRegionDataHdr_t, PhRegionChange(), PhRegionQuery()
Regions chapter of the Photon Programmer’s Guide
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:
len The length of the data, in bytes. The data immediately follows the
PhRegionDataHdr_t structure in the region’s block of data.
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 PhClipboardHdr
Ph_RDATA_USER User-defined
Classification:
Photon
See also:
PhRegion_t, PhRegionDataFindType()
Regions chapter of the Photon Programmer’s Guide
Synopsis:
int PhRegionInfo( PhRid_t rid,
PhRegion_t *region,
PhRect_t rects[],
unsigned nrect,
void *data,
unsigned data_len );
Arguments:
rid The region to query.
rects An array of PhRect_t structures that the function fills in with region
rectangle information.
nrect The length of the array pointed to by rects. See the note below.
data If the queried region has data attached to it, up to data_len bytes is
copied into this member. 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().
data_len The maximum number of region data bytes to copy into data.
Library:
ph
Description:
This function returns information about the region identified by rid. On completion,
the PhRegion_t structure pointed to by region and the PhRect_t structures pointed
to by rects contain a description of the region.
Returns:
0 Success.
-1 An error occurred.
Examples:
The following example gets information about the device region:
#define NRECTS 10
PhRegion_t region; PhRect_t rects[ NRECTS ];
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRect_t, PhRegion_t, PhRegionChange(), PhRegionOpen()
Regions chapter of the Photon Programmer’s Guide
Synopsis:
PhRid_t PhRegionOpen( unsigned fields,
PhRegion_t const *info,
PhRect_t const *rect,
void const *data );
Library:
ph
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 points to a PhRegion_t structure that defines 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 a PhRect_t structure that defined the rectangle
associated with the region, and data points to the data associated with the region.
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;
if( -1 == open_region() ) {
fprintf( stderr, "Couldn’t open region.\n" );
exit( EXIT_FAILURE );
}
event = (PhEvent_t *)malloc( sizeof( PhEvent_t )
+ 1000 );
if( event == NULL ) {
fprintf( stderr,
"Couldn’t allocate event buffer.\n" );
exit( EXIT_FAILURE );
}
while( go ) {
if( PhEventNext( event, sizeof( PhEvent_t )
+ 1000 ) == Ph_EVENT_MSG ) {
if( (event->type & Ph_EV_PTR_MOTION) != 0 )
draw_at_cursor(
(PhPoint_t *)PhGetRects( event ) );
else
go = 0;
} else
fprintf( stderr, "Error.\n" );
}
return 0;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgGetRegion(), PgSetRegion(), PhAttach(), PhRect_t, PhRegion_t,
PhRegionChange(), PhRegionClose()
Regions chapter of the Photon Programmer’s Guide
Synopsis:
int PhRegionQuery( PhRid_t rid,
PhRegion_t *region,
PhRect_t *rect,
void *data,
unsigned data_len );
Library:
ph
Description:
This function returns information about the region identified by rid. On completion,
the PhRegion_t structure pointed to by region and the PhRect_t structure pointed
to by 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:
PhRect_t, PhRegion_t, PhRegionChange(), PhRegionInfo() PhRegionOpen()
Regions chapter of the Photon Programmer’s Guide
Synopsis:
int PhRegisterTransportType(
PhTransportRegEntry_t *ref );
Library:
ph
Description:
This function adds a the transport type definition pointed to by ref to the transport
registry. For details on defining your own transport types, see “Registering new
transport types” in the Drag and Drop chapter of the Photon Programmer’s Guide.
Returns:
0 The new type was added successfully.
-1 The new type couldn’t be added because there wasn’t enough memory, the type
was already defined, or ref was NULL.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhFindTransportType(), PhFreeTransportType(), PhMallocUnpack(), PhPackEntry(),
PhTransportRegEntry_t, PhTransportType(), PhUnpack()
“Registering new transport types” in the Drag and Drop chapter of the Photon
Programmer’s Guide
Synopsis:
void PhReleaseImage( PhImage_t *image );
Library:
ph
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
• Ph_RELEASE_TRANSPARENCY_MASK
• Ph_RELEASE_GHOST_BITMAP
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApGetImageRes(), PgDrawPhImage*(), PgDrawPhImageRect*(),
PgDrawRepPhImage*(), PhCreateImage(), PhImage_t, PhMakeGhostBitmap(),
PhMakeTransBitmap(), PmMemCreateMC(), PmMemFlush(), PxRotateImage(),
PxLoadImage()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
void PhReleaseTransportCtrl(
PhTransportCtrl_t *ctrl );
Library:
ph
Description:
this function releases the transport control structure pointed to by ctrl, as well as any
inline data pointed to by the structure.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhCreateTransportCtrl() PhTransportCtrl_t, PtCreateTransportCtrl(),
PtReleaseTransportCtrl()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
void PhReleaseTransportHdrs(
PhTransportHdr_t *hdrs );
Library:
ph
Description:
This function frees the linked list of transport headers pointed to by hdrs.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetAllTransportHdrs(), PhGetNextTransportHdr(), PhGetTransportHdr(),
PhLocateTransHdr(), PhUnlinkTransportHdr()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
PhTile_t * PhSortTiles( PhTile_t *tiles );
Library:
ph
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()
“Using damage tiles” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
typedef struct Ph_sys_info {
PhGeneralSysInfo_t gen;
PhGrafxInfo_t gfx;
PhKbdInfo_t kbd;
PhPtrInfo_t ptr;
PhIgInfo_t ig;
} PhSysInfo_t;
Description:
The PhSysInfo_t structure contains system information, and is filled in by
PhQuerySystemInfo() and PtQuerySystemInfo(). This structure includes at least:
PhGeneralSysInfo_t gen
General information. Always examine this.
PhGrafxInfo_t gfx
Information for graphics regions.
Always examine the general information gen first, to see which of the other structures
contain data.
The fields in the PhSysInfo_t structure each have a valid_fields field that you should
check before using the data.
For example, before referring to gfx in the PhSysInfo_t structure, you should check
that it’s valid:
gen
The gen member is a PhGeneralSysInfo_t structure that contains at least:
• Ph_GEN_INFO_BANDWIDTH
• Ph_GEN_INFO_CAPABILITIES
• Ph_GEN_INFO_NUM_GFX
• Ph_GEN_INFO_NUM_KBD
• Ph_GEN_INFO_NUM_PTR
• Ph_GEN_INFO_NUM_IG
unsigned short version
The version of the Photon server.
unsigned long bandwidth
The estimated bandwidth between your process and the Photon server. It can be
one of:
• Ph_BAUD_MIN — the minimum possible badnwidth
• Ph_BAUD_SLOW — a slow connection
• Ph_BAUD_NETWORK — a network speed connection
• Ph_BAUD_CONSOLE — a fast connection
• Ph_BAUD_MAX — the fastest possible connection
gfx
The gfx member is a PhGrafxInfo_t structure that contains at least:
The other fields in the PhSysInfo_t structure are similar. For details on these
structures, see the <photon/PhT.h> header file.
Classification:
Photon
See also:
PhQuerySystemInfo(), PtQuerySystemInfo()
“System information” in the Regions chapter of the Programmer’s Guide.
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:
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 PhFreeTiles() to return a list of tiles to the pool.
Classification:
Photon
See also:
PhAddMergeTiles(), PhClipTilings(), PhCoalesceTiles(), PhCopyTiles(),
PhDeTranslateTiles(), PhFreeTiles(), PhGetTile(), PhIntersectTilings(),
PhMergeTiles(), PhRectsToTiles(), PhSortTiles(), PhTilesToRects(),
PhTranslateTiles(), PhRect_t
“Geometry data types” in the Working with Code chapter, and “Using damage tiles” in
the Raw Drawing and Animation chapter of the Photon Programmer’s Guide
Synopsis:
void PhTilesBoundingRect( const PhTile_t *tiles,
PhRect_t *r );
Arguments:
tiles A list of PhTile_t structures you want to calculate a bounding box for. This
list can’t be empty.
Library:
ph
Description:
This function takes an array of PhTile_t structures and calculates the bounding box
for all the tiles in the list. The bounding box is put in the r argument.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAddMergeTiles(), PhClipTilings(), PhCoalesceTiles(), PhCopyTiles(),
PhDeTranslateTiles(), PhFreeTiles(), PhGetTile(), PhIntersectTilings(),
PhMergeTiles(), PhRect_t, PhRectsToTiles(), PhSortTiles(), PhTile_t,
PhTilesToRects(), PhTranslateTiles()
“Using damage tiles” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
PhRect_t * PhTilesToRects( PhTile_t *tiles,
int *num_rects );
Library:
ph
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(), PhRect_t, PhRectsToTiles(), PhSortTiles(), PhTile_t,
PhTranslateTiles()
“Using damage tiles” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
int PhTimerArm ( PhRid_t rid,
long handle,
unsigned msec );
Library:
ph
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:
A nonnegative value
Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtTimerArm(), RtTimerCreate(), RtTimerDelete(), RtTimerGetTime(),
RtTimerSetTime()
“Timers” in the Working with Code chapter of the Photon Programmer’s Guide
Synopsis:
int PhTo8859_1( PhKeyEvent_t const *keyevent );
Library:
ph
Description:
This function returns a valid ISO8859-1 code, if one exists, for the key event.
described by the PhKeyEvent_t structure pointed to by keyevent.
Returns:
The ISO8859-1 code, or -1 if there’s no valid code for the given event.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetData(), PhKeyEvent_t, PhKeyToMb()
<photon/PkKeyDef.h>
Synopsis:
PhRect_t *PhTranslateRect( PhRect_t *rect,
PhPoint_t const *delta );
Library:
ph
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:
PhDeTranslateRect(), PhPoint_t, PhRect_t
“Geometry data types” in the Working with Code chapter of the Photon Programmer’s
Guide
Synopsis:
PhTile_t * PhTranslateTiles(
PhTile_t *tile,
PhPoint_t const *point_add );
Library:
ph
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(), PhPoint_t, PhRectsToTiles(), PhSortTiles(), PhTile_t,
PhTilesToRects()
“Using damage tiles” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
typedef struct phdattransp {
PhTransportLink_t *first_inline;
PhTransportLink_t *last_inline;
int unsigned n_inline;
int unsigned rqdata_cnt;
} PhTransportCtrl_t ;
Description:
This structure is used when packing data for use with Photon’s transport mechanism.
It includes these members:
Classification:
Photon
See also:
PhCreateTransportCtrl(), PhGetNextInlineData(), PhGetTransportVectors(),
PhPackEntry(), PhPackType(), PhReleaseTransportCtrl(), PhTransportLink_t,
PhTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
PhTransportLink_t *PhTransportFindLink(
PhTransportLink_t *link_list,
void *data );
Library:
ph
Description:
This function searches the list of transport data pointed to by link_list for the entry
containing the given data.
Returns:
A pointer to the entry containing the data, or NULL if it couldn’t be found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhCreateTransportCtrl(), PhLinkTransportData(), PhTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
typedef struct __phlink PhTransportLink_t;
struct __phlink {
void *data;
int unsigned size;
int niovs;
iov_t *iovs;
PhTransportLink_t *next;
};
Description:
This structure is used to build linked lists of transport data, such as the one found in
PhTransportCtrl_t (see PhCreateTransportCtrl()). The members include:
If the data is copied into the structure, the data points to the copy. If the data isn’t
copied, the iovs vectors point to the original data.
Classification:
Photon
See also:
PhCreateTransportCtrl(), PhGetNextInlineData(), PhLinkTransportData(),
PhReleaseTransportCtrl(), PhTransportCtrl_t, PhTransportFindLink(),
PhTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
typedef struct ph_transport_reg_entry {
char *type;
int unsigned packing;
int unsigned size;
int unsigned num_fixups;
PhTransportFixupRec_t const *fixups;
int unsigned const *endians;
} PhTransportRegEntry_t;
Description:
The PhTransportRegEntry_t structure describes how data is to be packed for the
Photon transport mechanism, taking into account endian-ness and references to
memory outside of the data type.
This structure includes the following:
fixups A list of instructions for dealing with references to data outside the
type being defined. For more information, see “Fixup manifests,”
below.
Fixup manifests
The fixup manifests are:
continued. . .
Endian information
The classifications of endian-sensitive members are:
Classification:
Photon
See also:
PhFindTransportType(), PhFreeTransportType(), PhMallocUnpack(), PhPackEntry(),
PhRegisterTransportType(), PhTransportType(), PhUnpack()
“Registering new transport types” in the Drag and Drop chapter of the Photon
Programmer’s Guide
Synopsis:
PhTransportLink_t *
PhTransportType(
PhTransportCtrl_t *ctrl,
char const * const type,
char const * const desc,
int unsigned const grouping_num,
int unsigned const handle,
int unsigned inlined_transport,
char *packing_type,
void *vdata,
int unsigned len,
int unsigned const flags );
Library:
ph
Description:
This function takes the data referenced by vdata and packs it into a stream buffer
within the provided PhTransportCtrl_t structure pointed to by ctrl.
The data is packed using the transport registry entry that matches packing_type. For
more information, see PhTransportRegEntry_t.
The provided type, desc, grouping_num, and handle are added to the packed data’s
header information.
The PhTransportCtrl_t structure pointed to by ctrl was created via a call to
PhCreateTransportCtrl(). The len parameter is used only for packing raw data.
The inlined_transport argument indicates the transport type used for the inlined data,
and can be one of:
Ph_TRANSPORT_INLINE
The data being transported is in memory and can be unpacked immediately.
Ph_TRANSPORT_FILEREF
The data being transported is in the temporary file(s) named in the inlined data.
Ph_TRANSPORT_SHMEM
The data being transported is in the temporary shared object(s) named in the
inlined data.
When used with Photon’s drag and drop mechanism, the grouping_num is used to
indicate which data is just a different representation of other data also packed into the
same PhTransportCtrl_t. Only one of each grouping_num should be unpacked by
the reader/destination.
The type should be a descriptive type name, such as image, text, filename, or
files.
Each type has its most common and expected packing_type associated with it. For
example:
Other packing types can be used, but there’s no guarantee that the reader/recipient of
the data will be expecting the type of data packed. In this case, the data is ignored.
The desc should detail the specifics of what is in the data. The extractor uses a regular
expression match against the description to determine if the data should be unpacked
or discarded.
The flags parameter has the following valid bits:
If this flag is used, any modifications to the data that occur between packing and actual
transport of the data will be reflected in the data transported.
Returns:
A pointer to a PhTransportLink_t structure (within the transport control’s stream
buffer list) that contains the packed data, or NULL if the call has failed (errno is set).
Errors:
EINVAL One of the following occurred:
• One of the parameters was passed incorrectly.
• No transport control was provided.
• No data was provided via vdata.
• No inlined_transport was specified.
ENOENT No transport registry entry was found for the provided packing_type.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAllocPackType(), PhFindTransportType(), PhFreeTransportType(),
PhMallocUnpack(), PhPackEntry(), PhRegisterTransportType(),
PhTransportCtrl_t, PhTransportLink_t, PhTransportRegEntry_t,
PhUnpack(), PtCreateTransportCtrl(), PtDndFetch_t, PtDndSelect(),
PtTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
PhTransportHdr_t * PhUnlinkTransportHdr(
PhTransportHdr_t *hdr_list,
PhTransportHdr_t *victim );
Library:
ph
Description:
PhUnlinkTransportHdr() unlinks the transport header pointed to by victim from the
list pointed to by hdr_list.
Returns:
A pointer to the beginning of the list after removing the victim.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhGetAllTransportHdrs(), PhGetNextTransportHdr(), PhGetTransportHdr(),
PhLocateTransHdr(), PhReleaseTransportHdrs()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
char * PhUnpack( PhTransportHdr_t *hdr,
void **ret_struct );
Library:
ph
Description:
This function unpacks data packed using one of the PhTransport* or PtTransport*
functions. Any memory required for the extraction is allocated via malloc().
The hdr parameter describes the data to be unpacked and is itself extracted from the
packed data stream. See PhGetTransportHdr().
The pointer referenced by ret_struct is set to point to the newly unpacked data. The
actual data representation of the data extracted is described in the hdr that’s passed as
the first parameter to this function.
As the data is unpacked, it’s automatically endian-corrected.
Use PhFreeTransportType() to free data unpacked using this function.
Returns:
A pointer to the byte in the data stream following the data just extracted.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAllocPackType(), PhFindTransportType(), PhFreeTransportType(),
PhMallocUnpack(), PhPackEntry(), PhRegisterTransportType(),
PhTransportRegEntry_t, PhTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
int PhWindowChange(
unsigned fields,
unsigned flags,
const PhRegion_t *region,
const PhRect_t *rect,
const PhWindowInfo_t *win_info );
Arguments:
fields A bitmap that indicates which members of the PhRegion_t to use to
update the window’s region. For more information, see PhRegionOpen()
in the Photon Library Reference.
flags Flags that control whether or not an expose event is emitted to the
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.
region A pointer to a PhRegion_t structure that stores the data to be used to
update the window’s region.
rect A pointer to a PhRect_t structure (see the Photon Library Reference)
that defines the rectangle associated with the region.
win_info A pointer to the window information that replaces the current win_info
on the window region.
Library:
ph
Description:
This function lets you modify the attributes and window information of a window’s
region. The Window Manager is notified of this change and responds accordingly.
This function changes the definition of the window region specified by region->rid.
Returns:
A nonnegative value
Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhWindowOpen()
PhRect_t, PhRegion_t, PhRegionClose(), PhRegionOpen() in the Photon Library
Reference
See PhWm.h for a description of PhWindowInfo_t.
Synopsis:
int PhWindowClose( PhRid_t window_rid );
Arguments:
window_rid The region ID of the window to close.
Library:
ph
Description:
This function closes a window with the given region ID, that was previously opened
by a call to PhWindowOpen().
Returns:
A nonnegative value
Successful completion.
-1 An error occurred. Either a nonwindow RID was given, or the function can’t
communicate with Photon or the window manager.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhWindowOpen()
Synopsis:
typedef struct _Ph_window_event {
unsigned long event_f ;
unsigned long state_f ;
PhRid_t rid;
PhPoint_t pos;
PhDim_t size;
unsigned short event_state;
unsigned short input_group;
unsigned long rsvd[4];
} PhWindowEvent_t;
Description:
This structure defines the data that’s associated with a Ph_EV_WM event of subtype
Ph_EV_WM_EVENT. For more information, see PhEvent_t.
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:
short event_state
Indicates that the Window Manager has completed or been asked
to complete the requested action. If the event is emitted to the
Window Manager, the event is performed by the Window
Manager. If an application collects the event, the Window
Manager has completed the event.
The following operations have two event states; you can OR one
of these states into event_state:
• Ph_WM_FFRONT—either Ph_WM_EVSTATE_FFRONT or
Ph_WM_EVSTATE_FFRONT_DISABLE.
• Ph_WM_FOCUS—either Ph_WM_EVSTATE_FOCUS or
Ph_WM_EVSTATE_FOCUSLOST.
• Ph_WM_HIDE—either Ph_WM_EVSTATE_HIDE or
Ph_WM_EVSTATE_UNHIDE.
• Ph_WM_MENU—either Ph_WM_EVSTATE_MENU or
Ph_WM_EVSTATE_MENU_FINISH.
• Ph_WM_EVSTATE_FORCE—forces execution of the
requested operation irrelevant of the managed_f value. For
example, if the managed_f of a window doesn’t have
Ph_WM_FOCUS set, but you need to give focus to the
window, you must set the Ph_WM_STATE_FORCE bit in the
event_state.
• All other toggle events—either Ph_WM_EVSTATE_PERFORM
or Ph_WM_EVSTATE_INVERSE.
PhPoint_t pos A PhPoint_t structure that defines the position of the window.
This member is valid only for Ph_WM_BACKDROP,
Ph_WM_MAX, Ph_WM_MOVE, Ph_WM_RESIZE, and
Ph_WM_RESTORE events.
PhDim_t size A PhDim_t structure that 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:
PhDim_t, PhEvent_t, PhPoint_t, 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 );
Arguments:
fields A bitmap that indicates which members of the PhRegion_t structure
specified by region to use. For more information, see PhRegionOpen() in
the Photon Library Reference.
If you don’t specify a field, PhWindowOpen() sets the corresponding
member of the new region to its default value.
Library:
ph
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.
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(), PhWindowClose(), PhRect_t, PhRegion_t,
PhRegionChange(), PhRegionOpen() in the Photon Library Reference
See PhWm.h for a description of PhWindowInfo_t.
Synopsis:
int PhWindowQueryVisible( unsigned flag,
PhRid_t rid,
unsigned input_group,
PhRect_t *rect );
Library:
ph
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 with which input group the visible extent must
intersect. To determine the current input group, call PhInputGroup(), passing to it the
current event, if any.
You must set at most one of the following bits in flags:
Ph_QUERY_GRAPHICS
Return a graphics driver rectangle.
Ph_QUERY_INPUT_GROUP
Return input_group’s rectangle.
Ph_QUERY_CONSOLE
Return a console’s rectangle. A console is defined as either an input group or a
graphics driver, depending on the window manager’s Multi-monitor placement
option. In other words, this option is equivalent to either Ph_QUERY_GRAPHICS
or Ph_QUERY_INPUT_GROUP, depending on your configuration.
Ph_QUERY_WORKSPACE
Return a console’s rectangle minus any reserved space around the edges.
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.
PhWindowQueryVisible() places the visible extent in the PhRect_t structure pointed
to by rect.
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
See also:
PhRect_t
Window Management chapter of the Photon Programmer’s Guide
Synopsis:
PhImage_t *PiConvertImage( PhImage_t *image,
PhRect_t const *bounds,
int type,
int flags )
Arguments:
image A pointer to a PhImage_t structure that defines the image to be
converted.
type The type of image to convert to. This must be one of the Pg_IMAGE_*
types defined for PhImage_t. See Image types for a list of defined types.
You can pass 0 for no type conversion.
flags Flags that dictate special behavior of the conversion process and can take
on the following values:
Library:
ph
Description:
This function converts a Photon image from one type to another. It allocates space for
the resulting image, leaving the original image untouched. If you set the Pi_FREE flag
bit, the function frees the old image by setting all its release flags and calling
PhReleaseImage() on it.
Returns:
A pointer to the new, converted image on success, or NULL if an error occurred.
Examples:
This example loads a file, resizes it to 200 x 200 thumbnail, and then converts it to a
palette-based image before displaying it in a PtLabel:
#include <stdlib.h>
#include <stdio.h>
/* Toolkit headers */
#include <Pt.h>
#include <photon/PxImage.h>
PtWidget_t *window;
PtArg_t args[2];
PhImage_t *img, *resized_img, *new_img;
short width = 200;
short height = 200;
if (PtInit(NULL) == -1)
PtExit(EXIT_FAILURE);
PtMainLoop();
return (EXIT_SUCCESS);
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhCreateImage(), PhImage_t, PhRect_t, PiDuplicateImage(), PiFlipImage(),
PiResizeImage()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
PhImage_t *PiCropImage( PhImage_t *image,
PhRect_t const *bounds,
int flags );
Library:
ph
Description:
This function crops a Photon image. It allocates space for the resulting image, leaving
the original image untouched.
The image argument is a pointer to a PhImage_t structure that defines the image to be
cropped, while the bounds argument points to a PhRect_t structure specifying the
rectangle within the image to keep.
The flags argument dictates special behavior of the cropping process and can take on
the following values:
Pi_SHMEM Store the newly created image data in shared memory. This is useful if
fast rendering of the image is required.
If you set the Pi_FREE flag, the function will free the old image by setting all its
release flags and calling PhReleaseImage() on it.
Returns:
A pointer to the new image on success, or NULL if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhCreateImage(), PhImage_t, PhRect_t, PiConvertImage(), PiDuplicateImage(),
PiFlipImage(), PiResizeImage
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
PhImage_t *PiDuplicateImage( PhImage_t *image,
int flags );
Arguments:
image A pointer to the image you want to duplicate.
flags Flags that indicate how the function should behave. They can be one or
more of the following values:
Library:
ph
Description:
This function creates a duplicate of the Photon image defined in the PhImage_t
structure pointed to by image. PiDuplicateImage() does a “deep copy” of the
PhImage_t, meaning it copies not only the structure itself but also any data
associated with it such as the palette and image pixel data.
If you set the Pi_FREE flag, the function will free the old image by setting all its
release flags and calling PhReleaseImage() on it.
Returns:
A pointer to the new image on success, or NULL if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhCreateImage(), PhImage_t, PiConvertImage(), PiCropImage(), PiFlipImage(),
PiResizeImage
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
PhImage_t *PiFlipImage( PhImage_t *image,
PhRect_t const *bounds,
int flags );
Library:
ph
Description:
This function flips a Photon image. It allocates space for the resulting image, leaving
the original image untouched.
The image argument is a pointer to a PhImage_t structure that defines the image to be
flipped, while the bounds argument points to a PhRect_t structure specifying the
rectangle within the image to flip. Specifying NULL for bounds causes the entire
image to be flipped.
The flags argument dictates special behavior of the flipping process, and can take on
the following values:
Pi_SHMEM Store the newly created image data in shared memory. This is
useful if fast rendering of the image is required.
If you set the Pi_FREE flag, the function will free the old image by setting all its
release flags and calling PhReleaseImage() on it.
Returns:
A pointer to the new image on success, or NULL if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PhCreateImage(), PhImage_t, PhRect_t, PiConvertImage(), PiCropImage(),
PiDuplicateImage(), PiResizeImage
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PiGetPixel( PhImage_t const *image,
unsigned short x,
unsigned short y,
unsigned long *value );
Library:
ph
Description:
This function retrieves the value of a pixel within an image.
The image argument is a pointer to a PhImage_t structure that defines the image to be
queried, while the x and y arguments specify the coordinates of the pixel to be
examined.
The value argument points to an area of memory where the result of the query is
stored. The meaning of this value depends on the type of the image, as follows:
Pg_IMAGE_DIRECT_1555
Pg_IMAGE_DIRECT_444
Pg_IMAGE_DIRECT_4444
Pg_IMAGE_DIRECT_565
Pg_IMAGE_DIRECT_888
Pg_IMAGE_DIRECT_8888
A PgColor_t representing the pixel’s color.
Pg_IMAGE_PALETTE_BYTE
Pg_IMAGE_PALETTE_NIBBLE
An index into the image’s palette (0 - 255 for BYTE palettes, 0 - 15 for NIBBLE
palettes).
Pg_IMAGE_GRADIENT_BYTE
Pg_IMAGE_GRADIENT_NIBBLE
A number representing the pixel’s intensity (0 - 255 for BYTE gradients, 0 - 15
for NIBBLE gradients).
Pg_BITMAP_BACKFILL
Pg_BITMAP_TRANSPARENT
0 or 1 representing the pixel’s state.
Returns:
0 Success.
-1 An error occurred because the pixel was out of bounds or the image type wasn’t
recognized.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor_t, PhImage_t, PiGetPixelFromData(), PiGetPixelRGB(), PiSetPixel(),
PiSetPixelInData()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PiGetPixelFromData( char const *data,
int type,
unsigned short pixel,
unsigned long *value );
Library:
ph
Description:
This function is similar to PiGetPixel(), except that PiGetPixelFromData() retrieves
the value from a run of pixels pointed to by data, instead of from an image. The type
argument indicates the format of the data and must correspond to one of the supported
image types, as listed for PhImage_t. The pixel argument is the index of the pixel
into the run of data, and value points to an area where you want the result to be stored.
Returns:
0 Success.
-1 An error occurred because the pixel was out of bounds or the image type wasn’t
recognized.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhImage_t, PiGetPixel(), PiGetPixelRGB(), PiSetPixel(), PiSetPixelInData()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PiGetPixelRGB( PhImage_t const *image,
unsigned short x,
unsigned short y,
PgColor_t *value );
Library:
ph
Description:
This function retrieves the RGB value of a pixel within an image.
The image argument is a pointer to a PhImage_t structure that defines the image to be
queried, while the x and y arguments specify the coordinates of the pixel to be
examined. The value argument points to a PgColor_t where the result of the query is
stored.
Returns:
0 Success.
-1 An error occurred because the pixel was out of bounds or the image type wasn’t
recognized.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgColor_t, PhImage_t, PiGetPixel(), PiGetPixelFromData(), PiSetPixel(),
PiSetPixelInData()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
PhImage_t *PiInitImage( PhImage_t *oldImage,
PhRect_t const *oldRect,
PhRect_t *newRect,
int newType,
int flags,
int colors )
Arguments:
oldImage A pointer to a PhImage_t structure that defines the image parameters
to use to initialize the new image.
oldRect A rectangle that defines an area within oldImage to use to initialize the
new image. If passed as NULL, the entire rectangle representing
oldImage is used.
newRect A location where the function can fill in a rectangle that describes the
area of the new image.
newType The type of the new image. This must be one of the Pg_IMAGE_* types
defined for PhImage_t. See Image types for a list of defined types. If
this argument is 0, the type from oldImage is used.
flags Dictates special behavior of the initialization process and can take the
following values:
Pi_CHECK_BOUNDS)
Checks that the coordinates in oldRect make sense.
If you set this flag bit, the function uses (0,0) for
the upper-left corner if the coordinates in oldRect
are negative. It also uses the image’s lower-left
corner coordinates, if the lower-left corner
coordinates in oldRect are too large.
Pi_SHMEM Store the newly created image data in shared
memory. This is useful if you require fast
rendering of the image.
Pi_USE_COLORS Copy the palette of the old image. If not specified,
the new image palette is NULL.
colors
Library:
ph
Description:
This function initializes a new, empty Photon image based on the parameters of an
existing image, copying all the PhImage_t structure members, and allocating a new
image data buffer the same size as the old image’s data buffer. If you specify the
Pi_USE_COLORS flag bit, this function also copies the old image palette. You can
optionally initialize a smaller image by passing in oldRect.
To duplicate an existing image, use PiDuplicateImage().
Returns:
A pointer to the new, empty image on success, or NULL if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhCreateImage(), PhImage_t, PhRect_t, PiConvertImage() PiDuplicateImage(),
PiFlipImage(), PiResizeImage()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
PhImage_t *PiResizeImage( PhImage_t *image,
PhRect_t const *bounds,
short w,
short h,
int flags )
Arguments:
image A pointer to a PhImage_t structure that defines the image to be resized.
flags Flags that dictate special behavior of the resizing process and can take on
the following values:
Library:
ph
Description:
This function resizes a Photon image, making it larger or smaller. It allocates space for
the resulting image, leaving the original image untouched. If you set the Pi_FREE flag
bit, the function frees the old image by setting all its release flags and calling
PhReleaseImage() on it.
Returns:
A pointer to the new, resized image on success, or NULL if an error occurred.
Examples:
For an example that uses this function, see PiConvertImage().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhCreateImage(), PhImage_t, PhRect_t, PiConvertImage(), PiCropImage(),
PiDuplicateImage(), PiFlipImage()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PiSetPixel( PhImage_t *image,
unsigned short x,
unsigned short y,
unsigned long value );
Library:
ph
Description:
This function alters the value of a pixel within an image.
The image argument is a pointer to a PhImage_t structure that defines the image to be
modified, while the x and y arguments specify the coordinates of the pixel to change.
The value argument specifies the new value of the pixel, and its meaning depends on
the image’s type. See the documentation for PiGetPixel() to see how this argument is
interpreted.
Returns:
0 Success.
-1 An error occurred because the pixel was out of bounds or the image type wasn’t
recognized.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhImage_t, PiGetPixel(), PiGetPixelFromData(), PiGetPixelRGB(),
PiSetPixelInData()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
int PiSetPixelInData( char *data,
int type,
unsigned short pixel,
unsigned long value );
Library:
ph
Description:
This function is similar to PiSetPixel(), except that PiSetPixelInData() sets the value
of a pixel in a run of pixels pointed to by data, instead of in an image. The type
argument indicates the format of the data and must correspond to one of the supported
image types, as listed for PhImage_t. The pixel argument is the index of the pixel
into the run of data, and value is the new value for the pixel.
Returns:
0 Success.
-1 An error occurred because the pixel was out of bounds or the image type wasn’t
recognized.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PiGetPixel(), PiGetPixelFromData(), PiGetPixelRGB(), PiSetPixel()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
#include <photon/PhRender.h>
PmMemoryContext_t * PmMemCreateMC(
PhImage_t *mc_image,
PhDim_t *dim,
PhPoint_t *translation );
Library:
ph
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:
mc_image The resulting image’s type and dimensions. For more information, see
below.
dim A PhDim_t structure that defines the source size of the draw stream. If
the image dimension is different from the source dimension, any
drawing done to the memory context will be scaled as necessary to fit
the source dimension exactly into the image dimension.
translation A PhPoint_t structure that defines the amount by which the draw
stream is translated when being rendered into the memory image
buffer.
If you want the image to be in shared memory, allocate the shared space for the image
data, instead of letting PmMemCreateMC() do it.
The mc_image->type member indicates the type of image that’s generated. The type
must be one of:
• Pg_IMAGE_DIRECT_888
• Pg_IMAGE_DIRECT_1555
• Pg_IMAGE_DIRECT_565
• Pg_IMAGE_DIRECT_8888
• Pg_IMAGE_PALETTE_BYTE
Returns:
A pointer to the new memory context, or NULL if there isn’t enough memory to
allocate one.
Examples:
/* pmmemtobutton.c
*/
#include <stdlib.h>
#include <mem.h>
#include <photon/PhRender.h>
#include <Pt.h>
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
PgSetStrokeColor( Pg_GREEN );
PgDrawILine( 0, 0, dim->w-1, dim->h-1 );
PmMemReleaseMC( mc );
}
if (PtInit(NULL) == -1)
exit(EXIT_FAILURE);
image.size = dim;
image.image = PgShmemCreate(
dim.w * dim.h * bytes_per_pixel,
NULL );
PtRealizeWidget( window );
PtMainLoop();
return (EXIT_SUCCESS);
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgShmemCreate(), PgShmemDestroy(), PhDim_t, PhImage_t, PhPoint_t,
PmMemFlush(), PmMemReleaseMC()
“Flickerless animation” in the Raw Drawing and Animation chapter of the Photon
Programmer’s Guide
Synopsis:
#include <photon/PhRender.h>
Library:
ph
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
PgDrawPhImage*() 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:
#include <photon/PhRender.h>
Library:
ph
Description:
This function releases the draw context, and shuts down and frees any resources
created by the provided memory context.
This function doesn’t release the image buffer if PmMemCreateMC() didn’t create it.
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:
#include <photon/PhRender.h>
Library:
ph
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:
#include <photon/PhRender.h>
Library:
ph
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:
#include <photon/PhRender.h>
Library:
ph
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:
#include <photon/PhRender.h>
PhDrawContext_t * PmMemStart(
PmMemoryContext_t *mc );
Library:
ph
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:
• a different memory, print, or draw context is made active. In this case, the memory
context is automatically deactivated as if PmMemStop() had been called
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:
#include <photon/PhRender.h>
PhDrawContext_t * PmMemStop(
PmMemoryContext_t *mc );
Library:
ph
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
This chapter describes the functions that Photon provides to support a wide range of
printing needs.
Synopsis:
PhDrawContext_t *PpContinueJob(
PpPrintContext_t *pc );
Arguments:
pc The pointer to a PpPrintContext_t structure that was returned by
PpCreatePC().
Library:
ph
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 PpStartJob().
All subsequent Photon draw commands are routed through this print context until:
• a different memory or print context is made active. In this case, the print context is
automatically deactivated as if PpSuspendJob() had been called.
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 = PpCreatePC();
case Pt_PRINTSEL_PRINT:
case Pt_PRINTSEL_PREVIEW:
PtFlush(); // Ensure no draws are pending.
case Pt_PRINTSEL_CANCEL:
break;
}
return Pt_CONTINUE;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpCreatePC(), PpEndJob(), PpGetPC(), PpPrintContext_t, PpPrintNewPage(),
PpReleasePC(), PpPrintWidget(), PpSetPC(), PpStartJob(), PpSuspendJob()
Printing in the Photon Programmer’s Guide
Synopsis:
PpPrintContext_t *PpCreatePC( void );
Library:
ph
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 thePpPrintContext_t structure that describes the new print context, or
NULL if there isn’t enough memory to allocate one.
Examples:
See PpContinueJob().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpContinueJob(), PpEndJob(), PpGetCanvas(), PpGetPC(), PpPrintContext_t,
PpPrintNewPage(), PpPrintWidget(), PpReleasePC(), PpSetCanvas(), PpSetPC(),
PpStartJob(), PpSuspendJob(), PtPrintSelection()
Printing chapter of the Programmer’s Guide
Synopsis:
int PpEndJob( PpPrintContext_t *pc );
Arguments:
pc The pointer to a PpPrintContext_t structure that was returned by
PpCreatePC().
Library:
ph
Description:
This function completes the current print job for the provided print context. If the print
context is active, it’s deactivated as if PpSuspendJob() had been called.
The print context is deactivated, but isn’t destroyed, so it can be used for future print
jobs with little or no reconfiguration. To release the print context, call PpReleasePC().
When this function returns, the printed output has been generated and sent to the
destination specified in the print context.
Returns:
0 Success.
-1 The print context couldn’t be made active, probably because the required print
driver couldn’t be launched. See errno for the specific error.
Examples:
See PpContinueJob().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpContinueJob(), PpCreatePC(), PpGetPC(), PpPrintContext_t,
PpPrintNewPage(), PpReleasePC(), PpPrintWidget(), PpSetPC(), PpStartJob(),
PpSuspendJob()
Printing in the Photon Programmer’s Guide
Synopsis:
void PpFreePrinterList( char **list );
Arguments:
list A list of available printers that PpLoadPrinterList() previously created.
Library:
ph
Description:
This function frees all allocated memory in the given list of printers.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpLoadDefaultPrinter(), PpLoadPrinter(), PpLoadPrinterList()
Printing chapter of the Programmer’s Guide
Synopsis:
PhDim_t PpGetCanvas( PpPrintContext_t *pc );
Arguments:
pc The pointer to a PpPrintContext_t structure that was returned by
PpCreatePC().
Library:
ph
Description:
This function gets the size of the current drawing area associated with the given print
context, taking into account the nonprintable area, margins, scale, and either the
current source resolution or size.
If neither a source resolution nor source size has been set, 100 dpi is used, and
PpGetCanvas() fills in the Pp_PC_SOURCE_RESOLUTION member of the print
context.
Returns:
A PhDim_t structure that defines the dimensions of the rectangle, or (0, 0) if pc is
invalid.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhDim_t, PpCreatePC(), PpGetPC(), PpPrintContext_t, PpReleasePC(),
PpSetCanvas(), PpSetPC()
Printing chapter of the Programmer’s Guide
Synopsis:
void * PpGetPC( PpPrintContext_t *pc,
int member,
const void ** const data);
Arguments:
pc The pointer to a PpPrintContext_t structure that was returned by
PpCreatePC().
data the address of a pointer to the data type of the member being queried.
This pointer will be set to point to the member within the print context
structure. Don’t use it to modify the print context; use only PpSetPC().
member The member of the print context to query, as given in the table below.
For a description of the members, see PpPrintContext_t.
Library:
ph
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.
Use the following data types when getting the value of the members of the print
context:
Member Data
Pp_PC_COLLATING_MODE Address of a char * ( value )
Pp_PC_COLOR_MODE Address of a char * ( value )
Pp_PC_CONTROL Address of a PpPCControl_t *
Pp_PC_COPIES Address of a char * ( value )
Pp_PC_DATE Address of a char * (string)
Pp_PC_DEVICE Address of a char * (string)
Pp_PC_DITHERING Address of a char * ( value )
Pp_PC_DO_PREVIEW Address of a char * ( value )
continued. . .
Member Data
Pp_PC_DRIVER Address of a char * (string)
Pp_PC_DUPLEX Address of a char * ( value )
Pp_PC_FILENAME Address of a char * (string)
Pp_PC_INKTYPE Address of a char * ( value )
Pp_PC_INTENSITY Address of a unsigned long *
Pp_PC_JOB_NAME Address of a char * (string)
Pp_PC_MARGINS Address of a PhRect_t *
Pp_PC_MAX_DEST_SIZE Address of a unsigned long
Pp_PC_NAME Address of a char * (string)
Pp_PC_NONPRINT_MARGINS Address of a PhRect_t *
Pp_PC_ORIENTATION Address of a char * ( value )
Pp_PC_PAGE_NUM Address of a unsigned long
Pp_PC_PAGE_RANGE Address of a PpPageRange_t *
Pp_PC_PAPER_SIZE Address of a PhDim_t *
Pp_PC_PAPER_SOURCE Address of a char * ( value )
Pp_PC_PAPER_TYPE Address of a char * ( value )
Pp_PC_PREVIEW_APP Address of a char * (string)
Pp_PC_PRINTER_RESOLUTION Address of a PhDim_t *
Pp_PC_PROP_APP Address of a char * (string)
Pp_PC_REVERSED Address of a char ( value )
Pp_PC_SCALE Address of a PhPoint_t *
Pp_PC_SOURCE_COLORS Address of a unsigned long *
Pp_PC_SOURCE_OFFSET Address of a PhPoint_t *
Pp_PC_SOURCE_RESOLUTION Address of a PhDim_t *
Pp_PC_SOURCE_SIZE Address of a PhDim_t *
Pp_PC_USER_ID Address of a char * (string)
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 = PpCreatePC();
// A string:
PpGetPC( pc, Pp_PC_NAME, &pc_data );
printf( "printer: %s\n", (char *)pc_data );
// A structure ( PhDim_t ):
PpGetPC( 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:
PpGetPC( pc, Pp_PC_INTENSITY, &pc_data );
printf( "intensity: %ld\n", *(long *)pc_data );
PpReleasePC( pc );
return Pt_CONTINUE;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
continued. . .
Safety
Thread No
See also:
PhDim_t, PhPoint_t, PhRect_t, PpContinueJob(), PpCreatePC(), PpEndJob(),
PpGetCanvas(), PpLoadDefaultPrinter(), PpLoadPrinter(), PpPrintContext_t,
PpPrintNewPage(), PpReleasePC(), PpPrintWidget(), PpSetCanvas(), PpSetPC(),
PpSuspendJob()
Printing in the Photon Programmer’s Guide
Synopsis:
int PpLoadDefaultPrinter( PpPrintContext_t *pc );
Arguments:
pc The pointer to a PpPrintContext_t structure that was returned by
PpCreatePC().
Library:
ph
Description:
This function initializes the provided print context with the information found in
$HOME/.ph/printers/default for the default printer.
Returns:
0 Success.
-1 No default printer could be found, or the printer definition that was loaded
didn’t define a destination device or filename, so no output can be generated.
Examples:
PpPrintContext_t *pc = PpCreatePC();
PpLoadDefaultPrinter( pc );
PpStartJob( pc );
PpContinueJob( pc );
// Draw stuff
PpSuspendJob( pc );
PpEndJob( pc );
PpReleasePC( pc );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpContinueJob(), PpCreatePC(), PpEndJob(), PpFreePrinterList(), PpGetPC(),
PpLoadPrinter(), PpLoadPrinterList(), PpPrintContext_t, PpPrintNewPage(),
PpPrintWidget(), PpReleasePC(), PpSetPC(), PpStartJob(), PpSuspendJob(),
PtPrintSelection()
Printing chapter of the Programmer’s Guide
Synopsis:
int PpLoadPrinter( PpPrintContext_t *pc,
char const *name );
Arguments:
pc The pointer to a PpPrintContext_t structure that was returned by
PpCreatePC().
name The name of the printer whose attributes you want to use to initialize the
print context. If name is NULL, this function loads the attributes of the
default printer as specified in $HOME/.ph/printers/default.
Library:
ph
Description:
This function initializes the provided print context with information for the printer
section named name.
Returns:
0 Success.
-1 No name was specified and no default printer could be found, or the printer
definition loaded didn’t define a destination device or filename, so no output
can be generated.
Examples:
PpPrintContext_t *pc = PpCreatePC();
PpLoadPrinter( pc, "GenericPostScriptPrinter@localhost");
PpStartJob( pc );
PpContinueJob( pc );
// Draw stuff
PpSuspendJob( pc );
PpEndJob( pc );
PpReleasePC( pc );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpContinueJob(), PpCreatePC(), PpEndJob(), PpGetPC(), PpLoadDefaultPrinter(),
PpPrintContext_t, PpPrintNewPage(), PpPrintWidget(), PpReleasePC(),
PpSetPC(), PpStartJob(), PpSuspendJob(), PtPrintSelection()
Printing chapter of the Programmer’s Guide
Synopsis:
char **PpLoadPrinterList( void );
Library:
ph
Description:
This function loads a null-terminated list of the names of printers that are available for
printing.
Use PpFreePrinterList() to free the list.
Returns:
A pointer to the list.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpFreePrinterList(), PpLoadDefaultPrinter(), PpLoadPrinter()
Printing chapter of the Programmer’s Guide
Synopsis:
See below.
Description:
The PpPrintContext_t structure describes a print context. Its members control
how printing is to be done.
The possible values and meanings for the members of a print context are defined in
/usr/photon/print/printers.
A print context includes the data described in the sections that follow. Each section
indicates the type of data, but see PpGetPC() and PpSetPC() for details.
Pp_PC_COLLATING_MODE
Pp_PC_COLOR_MODE
• color
Pp_PC_CONTROL (read-only)
char changed_prop[Pp_PC_FLAGSIZE]
This array is treated as a large bit field that indicates which
portions of the context have been modified. There’s a bit for
each of the modifiable attributes of a print context.
This bit field can be manipulated with the following macros,
which are defined in <photon/PpT.h>:
• Pp_clearbit()
• Pp_resetbits()
• Pp_setbit()
• Pp_testbit()
For example:
char emitted_prop[Pp_PC_FLAGSIZE]
A large bit field that indicates which of the changed print
context attributes have already been written to the destination or
temporary file. For example:
int fd The file descriptor for the current print job’s working file. The
working file isn’t opened until PpStartJob() opens the print job.
This member is -1 if no files are currently open.
char *tmp_target The temporary working file that’s used if do_preview is set.
char do_preview If this is nonzero, the application specified in the print context’s
Pp_PC_PREVIEW_APP member is launched when the print job
is finished (that is, when PpEndJob() is called).
Pp_PC_COPIES
Pp_PC_DATE
Pp_PC_DEVICE
If both the device and filename members are set, the output goes to the destination
identified by the filename.
Pp_PC_DITHERING
• error diffusion
• half toning.
Pp_PC_DO_PREVIEW
Pp_PC_DRIVER
Pp_PC_DUPLEX
Pp_PC_FILENAME
Pp_PC_INKTYPE
• color cartridge
• six-color printing.
Pp_PC_INTENSITY
Pp_PC_JOB_NAME
Pp_PC_MARGINS
Pp_PC_MAX_DEST_SIZE
Pp_PC_NAME
Pp_PC_NONPRINT_MARGINS
Pp_PC_ORIENTATION
Pp_PC_PAGE_NUM
Pp_PC_PAGE_RANGE
from to Print:
0 0 All
-1 -1 Selected region
n 0 From page n to the end of the document
The library assumes that the first page printed is the first requested page. If this isn’t
the case, use Pp_PC_PAGE_NUM to set the page number manually.
Pp_PC_PAPER_SIZE
Pp_PC_PAPER_SOURCE
• don’t care
• automatic
• upper tray
• lower tray
• manual feed
Pp_PC_PAPER_TYPE
• unknown
• normal quality
• high quality
• draft quality
• transparency
Pp_PC_PREVIEW_APP
Pp_PC_PRINTER_RESOLUTION
Pp_PC_PROP_APP
Pp_PC_REVERSED
Pp_PC_SCALE
If the x and y scales are both 0, the source is scaled to be as large as possible to fit on
the page and still maintain its x and y aspect ratio.
Pp_PC_SOURCE_COLORS
Pp_PC_SOURCE_OFFSET
Pp_PC_SOURCE_RESOLUTION
Pp_PC_SOURCE_SIZE
Pp_PC_USER_ID (read-only)
Classification:
Photon
See also:
PpContinueJob(), PpGetPC(), PpPrintWidget(), PpSetPC(), PpStartJob()
For information about the available print drivers, see the entries for the phs-to-*
Photon print drivers in the Utilities Reference.
Synopsis:
int PpPrintNewPage( PpPrintContext_t *pc );
Arguments:
pc The pointer to a PpPrintContext_t structure that was returned by
PpCreatePC().
Library:
ph
Description:
This function places a New Page command in the draw stream for the specified print
context, 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, PpContinueJob() 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.
-1 The print context couldn’t be made active, probably because the required
working files couldn’t be created. See errno for the specific error.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpContinueJob(), PpCreatePC(), PpEndJob(), PpGetPC(), PpPrintContext_t,
PpReleasePC(), PpPrintWidget(), PpSetPC(), PpStartJob(), PpSuspendJob()
Printing in the Photon Programmer’s Guide
Synopsis:
void PpPrintWidget( PpPrintContext_t *pc,
PtWidget_t *widget,
PhPoint_t const *trans,
PhRect_t const *clip_rect,
unsigned long resize );
Arguments:
pc A print context obtained via PpCreatePC() and initialized via
PpSetPC() and PpStartJob().
Library:
ph
Description:
This function prints the specified widget using the provided print context. The widget
doesn’t need to be realized in order to be printed.
Examples:
#include <Ph.h>
#include <Pt.h>
int
main()
{
int n;
int do_preview_only = 1;
PhArea_t area, sev_area = {{ 0,0 },{400,400}};
PpPrintContext_t *pc;
PtArg_t args[10];
PtWidget_t *window, *button;
PhDim_t dim = { 750, 1000 };
PtInit( NULL );
pc = PpCreatePC();
PpStartJob( pc );
n = 0;
PtSetArg( &args[n++], Pt_ARG_AREA, &sev_area, 0 );
PtSetArg( &args[n++], Pt_ARG_FILL_COLOR, Pg_BLUE, 0);
PtSetArg( &args[n++], Pt_ARG_TEXT_STRING, "Test Button", 0 );
button = PtCreateWidget( PtButton, Pt_DEFAULT_PARENT, n, args );
PtRealizeWidget( window );
PpContinueJob( pc );
PpEndJob( pc );
PtMainLoop();
return EXIT_SUCCESS;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhPoint_t, PhRect_t, PpContinueJob(), PpCreatePC(), PpEndJob(), PpGetPC(),
PpPrintContext_t, PpPrintNewPage(), PpReleasePC(), PpSetPC(), PpStartJob(),
PpSuspendJob()
Printing in the Photon Programmer’s Guide
Synopsis:
void PpReleasePC( PpPrintContext_t *pc );
Arguments:
pc The pointer to a PpPrintContext_t structure that was returned by
PpCreatePC().
Library:
ph
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 PpContinueJob().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpContinueJob(), PpCreatePC(), PpEndJob(), PpGetCanvas(), PpGetPC(),
PpPrintContext_t, PpPrintNewPage(), PpPrintWidget(), PpSetCanvas(),
PpSetPC(), PpStartJob(), PpSuspendJob()
Printing in the Photon Programmer’s Guide
Synopsis:
PhDim_t PpSetCanvas( PpPrintContext_t *pc,
PhDim_t size );
Arguments:
pc The pointer to a PpPrintContext_t structure that was returned by
PpCreatePC().
size A PhDim_t structure that specifies the size of the drawing area.
Library:
ph
Description:
This function sets the size of the current drawing area associated with the given print
context.
Returns:
The dimensions of the rectangle, or (0, 0) if pc is invalid.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhDim_t, PpCreatePC(), PpGetCanvas(), PpGetPC(), PpPrintContext_t,
PpReleasePC(), PpSetPC()
Printing chapter of the Programmer’s Guide
Synopsis:
int PpSetPC( PpPrintContext_t *pc,
int member,
void const * const data,
int lock );
Arguments:
pc The pointer to a PpPrintContext_t structure that was returned by
PpCreatePC().
member The member of the print context to modify, as given in the table below.
For a description of the members, see PpPrintContext_t.
data A pointer to the data to be assigned to the specified print context member.
Library:
ph
Description:
This function provides a mechanism to modify the attributes of a print context.
Don’t modify the print context directly, as the appropriate changed bits won’t be set
and the application may stop working if the print context structure is redefined in the
future.
Use the data types given below when setting the value of the members of the print
context.
Member Data
Pp_PC_COLLATING_MODE char *
continued. . .
Member Data
Pp_PC_COLOR_MODE char *
Pp_PC_CONTROL Read only: see PpGetPC()
Pp_PC_COPIES char *
Pp_PC_DATE String
Pp_PC_DEVICE String
Pp_PC_DITHERING char *
Pp_PC_DO_PREVIEW char *
Pp_PC_DRIVER String
Pp_PC_DUPLEX char *
Pp_PC_FILENAME String
Pp_PC_INKTYPE char *
Pp_PC_INTENSITY unsigned long *
Pp_PC_JOB_NAME String
Pp_PC_MARGINS PhRect_t *
Pp_PC_MAX_DEST_SIZE unsigned long
Pp_PC_NAME String
Pp_PC_NONPRINT_MARGINS PhRect_t *
Pp_PC_ORIENTATION char *
Pp_PC_PAGE_NUM unsigned long
Pp_PC_PAGE_RANGE PpPageRange_t *
Pp_PC_PAPER_SIZE PhDim_t *
Pp_PC_PAPER_SOURCE char *
Pp_PC_PAPER_TYPE char *
Pp_PC_PREVIEW_APP String
Pp_PC_PRINTER_RESOLUTION PhDim_t *
Pp_PC_PROP_APP String
Pp_PC_REVERSED char
Pp_PC_SCALE PhPoint_t *
Pp_PC_SOURCE_COLORS unsigned long *
continued. . .
Member Data
Pp_PC_SOURCE_OFFSET PhPoint_t *
Pp_PC_SOURCE_RESOLUTION PhDim_t *
Pp_PC_SOURCE_SIZE PhDim_t *
Pp_PC_USER_ID String
Returns:
0 Success.
Errors:
EACCES The specified member couldn’t be changed because it’s locked.
Examples:
set_my_apps_Pp_prefs( PpPrintContext_t *pc )
{
char do_preview = 1, duplex = some_value;
PpSetPC( pc, Pp_PC_DO_PREVIEW, &do_preview, 0 );
PpSetPC( pc, Pp_PC_DUPLEX, &duplex, 0 );
// etc...
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhDim_t, PhPoint_t, PhRect_t, PpContinueJob(), PpCreatePC(), PpEndJob(),
PpGetCanvas(), PpGetPC(), PpLoadDefaultPrinter(), PpLoadPrinter(),
Synopsis:
int PpStartJob( PpPrintContext_t *pc );
Arguments:
pc The pointer to a PpPrintContext_t structure that was returned by
PpCreatePC().
Library:
ph
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 PpCreatePC(), and may have been configured by calls to PpSetPC(), or by
the PtPrintSel widget.
You normally call this function after setting up the print context with PpSetPC()
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, PpStartJob() fails and errno is set to
ESRCH.
Photon draw operations won’t be routed through the print context until you call
PpContinueJob().
Returns:
0 Success.
-1 The print context couldn’t be made active, probably because the required
working files couldn’t be created. 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:
See PpContinueJob().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpContinueJob(), PpCreatePC(), PpEndJob(), PpGetPC(), PpPrintContext_t,
PpPrintNewPage(), PpPrintWidget(), PpReleasePC(), PpSetPC(), PpSuspendJob()
Printing in the Photon Programmer’s Guide
Synopsis:
void PpSuspendJob( PpPrintContext_t *pc );
Arguments:
pc The pointer to a PpPrintContext_t structure that was returned by
PpCreatePC().
Library:
ph
Description:
This function deactivates the given print context, 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:
PpContinueJob(), PpCreatePC(), PpEndJob(), PpGetPC(), PpPrintContext_t,
PpPrintNewPage(), PpPrintWidget(), PpReleasePC(), PpSetPC(), PpStartJob()
Printing in the Photon Programmer’s Guide
The widget toolkit functions let you create or destroy widgets, or manipulate widgets
and the relationships between them. These functions gather detailed information about
widgets and their environment.
For widget extension functions (which extend the attributes of a widget beyond its
resources) and convenience functions (which simplify control over certain widget
resources), see the Widget Reference.
Synopsis:
void PtAddCallback( PtWidget_t *widget,
unsigned long callback_type,
PtCallbackF_t *callback,
void *data );
Arguments:
widget A pointer to the widget that you want to add the callback to.
callback_type The name of the callback list you want to add the function to. For
example, Pt_CB_ACTIVATE.
callback A pointer to the function you want to add. The function takes this
form:
int (*callback)(PtWidget_t *, void *,
PtCallbackInfo_t *)
data A pointer to data that you want to pass as the second argument to
the function.
Library:
ph
Description:
This function adds a callback to the callback list indicated by callback_type.
Some types of callback resources have special routines that you should use instead of
this one:
Pt_CB_HOTKEY PtAddHotkeyHandler()
Examples:
#include <stdlib.h>
#include <Pt.h>
PtExit( 0 );
return Pt_CONTINUE;
}
int main()
{
PtArg_t args;
PtWidget_t *window, *button;
if (PtInit(NULL) == -1)
exit(EXIT_FAILURE);
PtRealizeWidget( window );
PtMainLoop();
//unnecessary
PtRemoveCallback( button, Pt_CB_ACTIVATE, activated, NULL );
return EXIT_SUCCESS;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddCallbacks(), PtAddEventHandler(), PtAddEventHandlers(),
PtAddFilterCallback(), PtAddFilterCallbacks(), PtAddHotkeyHandler(),
PtRemoveCallback(), PtRemoveCallbacks()
PtCallbackInfo_t in the Photon Widget Reference
Managing 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 );
Library:
ph
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).
Some types of callback resources have special routines that you should use instead of
this one:
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
continued. . .
Safety
Thread No
See also:
PtAddCallback(), PtAddEventHandler(), PtAddEventHandlers(),
PtAddFilterCallback(), PtAddFilterCallbacks(), PtAddHotkeyHandler(),
PtRemoveCallback(), PtRemoveCallbacks(),
PtCallback_t in the Photon Widget Reference
Managing Widgets in Application Code chapter of the Photon Programmer’s Guide
Synopsis:
int PtAddClassStyle(
PtWidgetClassRef_t * const ref ,
PtWidgetClassStyle_t *style );
Library:
ph
Description:
This function adds the given style to the specified widget class, ref . If a style of the
same name already exists in the widget class, the contents of the new style replace the
old style, and the new style is freed.
To further manipulate the given style, you must get a new pointer to it by calling
PtFindClassStyle() or PtGetWidgetStyle().
A style is a collection of override methods that can change how a widget looks and
behaves. Styles can also add widget resources.
Returns:
The index of the style, or -1 if it couldn’t be added.
Examples:
See “Widget Styles” in the Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCreateClassStyle(), PtDupClassStyle(), PtFindClassStyle(), PtGetStyleMember(),
PtGetWidgetStyle(), PtSetClassStyleMethods(), PtSetStyleMember(),
PtSetStyleMembers(), PtSetWidgetStyle(),
Pt_ARG_STYLE resource of PtBasic in the Photon Widget Reference
“Widget Styles” in the Managing 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 );
Arguments:
ptr The address of the pointer to the chain the data should be added to.
subtype A subtype that’s used to distinguish multiple blocks of data added as the
same type. This argument shouldn’t be -1, because -1 has special meaning
when searching for a specific block within the provided data chain.
Library:
ph
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(). You can retrieve this data by calling
PtFindData(), or PtFindNextData().
Returns:
0 on success, or -1 if an error occurred (e.g. out of memory).
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 );
Library:
ph
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.
int (*callback) (
PtWidget_t *widget,
void *data,
PtCallbackInfo_t *info)
The data argument that you pass to PtAddEventHandler() is passed as the data
argument to the callback function.
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 )
...
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddCallback(), PtAddCallbacks(), PtAddEventHandlers(), PtAddFilterCallback(),
PtAddFilterCallbacks(), PtAddHotkeyHandler(), PtRemoveEventHandler(),
PtRemoveEventHandlers()
PtCallbackInfo_t, PtRawCallback_t, Pt_CB_RAW (PtWidget) in the Photon
Widget Reference
“Event handlers” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
void PtAddEventHandlers(
PtWidget_t *widget,
PtRawCallback_t const *callback_defs,
unsigned int num_handlers );
Library:
ph
Description:
This function adds the number of event handlers specified by num_handlers to the
Pt_CB_RAW callback list that belongs to widget.
Examples:
See PtAddEventHandler().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddCallback(), PtAddCallbacks(), PtAddEventHandler(), PtAddFilterCallback(),
PtAddFilterCallbacks(), PtAddHotkeyHandler(), PtRemoveEventHandler(),
PtRemoveEventHandlers()
PtRawCallback_t, Pt_CB_RAW in the Photon Widget Reference
“Event handlers” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
void PtAddFilterCallback( PtWidget_t *widget,
unsigned long event_mask,
PtCallbackF_t *callback,
void *data );
Library:
ph
Description:
This function adds the specified callback to the Pt_CB_FILTER 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.
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
PtAddFilterCallbacks( widget, callbacks, 2 );
...
//remove both event handlers
PtRemoveFilterCallbacks( widget, callbacks, 2 );
...
//add the motion button event handler
PtAddFilterCallback( widget, Ph_EV_PTR_MOTION_BUTTON,
motion_button_callback, NULL );
...
//remove the motion button event handler
PtRemoveFilterCallback( widget, Ph_EV_PTR_MOTION_BUTTON,
motion_button_callbacks, NULL );
...
//add both event handlers
PtAddFilterCallbacks( widget, callbacks, 2 );
...
//remove the motion button event handler
PtRemoveFilterCallback( widget, Ph_EV_PTR_MOTION_BUTTON,
motion_button_callbacks, NULL );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddCallback(), PtAddCallbacks(), PtAddEventHandler(), PtAddEventHandlers(),
PtAddFilterCallbacks(), PtAddHotkeyHandler(), PtRemoveFilterCallback(),
PtRemoveFilterCallbacks()
PtRawCallback_t, Pt_CB_FILTER in the Photon Widget Reference
PtCallbackInfo_t in the Photon Widget Reference
“Event handlers” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
void PtAddFilterCallbacks(
PtWidget_t *widget,
PtRawCallback_t const *callback_defs,
unsigned int num_handlers );
Library:
ph
Description:
This function adds the number of event handlers specified by num_handlers to the
Pt_CB_FILTER callback list that belongs to widget.
Examples:
See PtAddFilterCallback().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddCallback(), PtAddCallbacks(), PtAddEventHandler(), PtAddEventHandlers(),
PtAddFilterCallback(), PtAddHotkeyHandler(), PtRemoveFilterCallback(),
PtRemoveFilterCallbacks()
PtRawCallback_t, Pt_CB_FILTER in the Photon Widget Reference
“Event handlers” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
void PtAddHotkeyHandler( PtWidget_t *widget,
unsigned key_sym_cap,
unsigned key_mods,
short flags,
void *data,
PtCallbackF_t *callback );
Library:
ph
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:
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 are invoked. If callback is NULL, the widget’s Pt_CB_ACTIVATE callback
list is invoked when the hotkey is pressed.
Note the following:
• Key caps, key mods, and key syms are defined in <photon/PkKeydef.h>.
• Key caps and key syms are prefixed with only Pk_.
Hotkeys are handled at the window level. So if two widgets within the same window
happen to register the same hotkey definition without specifying the
Pt_HOTKEY_CHAINED flag, 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.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddCallback(), PtAddCallbacks(), PtAddEventHandler(), PtAddEventHandlers(),
PtAddFilterCallback(), PtAddFilterCallbacks(), PtRemoveHotkeyHandler()
PtCallbackInfo_t in the Photon Widget Reference
“Hotkey callbacks” in the Editing Resources and Callbacks in PhAB chapter of the
Photon Programmer’s Guide.
Synopsis:
PhTransportLink_t *
PtAddResponseType(
PtTransportCtrl_t *ctrl,
PtRequestables_t *requestable,
char *type,
char *desc,
int unsigned transport,
char *packing_type,
void *vdata,
int unsigned vdata_size,
int unsigned const flags );
Library:
ph
Description:
PtAddResponseType() adds data to the response chain of the transport-control
structure pointed to by ctrl. This chain is a queue of data that can be or has been
requested by the destination of a drag-and-drop operation.
The source of a drag-and-drop operation can call PtAddResponseType() when it’s
packing the data to be dragged or when a destination actually requests the data. If a
destination has already requested the data, the library automatically sends the data to
the destination immediately.
This function searches a list of the data that has already been requested and, if the
request for this data has been made, provides the data to the requester.
transport The available transport types that can be specified when requesting
data from the source:
Ph_TRANSPORT_INLINE
The data being transported is in memory and can be unpacked
immediately.
Ph_TRANSPORT_FILEREF
The data being transported is in the temporary file(s) named in
the inlined data.
Ph_TRANSPORT_SHMEM
The data being transported is in the temporary shared
object(s) named in the inlined data.
Ph_TRANSPORT_STREAM
The data being transported will be inlined a small piece at a
time.
Ph_TRANSPORT_NAMED_STREAM
The data being transported will be inlined a small piece at a
time. The streamed data is named so multiple streams of data
can be transferred serially.
Ph_TRANSPORT_FILE_STREAM
The contents of files streamed using extended named streams.
This is like the named stream but with extra information with
each data block, including file information and so on. The
requester of data must choose one of the available request
transport types when requesting delivery of additional data.
If this bit is set, any modifications to the data that occur between packing and actual
transport of the data will be reflected in the data transported.
Returns:
A pointer to the PhTransportLink_t structure containing the data just added, or
NULL if there isn’t enough memory.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhTransportLink_t, PtTransportCtrl_t, PtTransportRequestable(),
PtTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
int PtAlert( PtWidget_t *parent,
PhPoint_t const *location,
char const *title,
PhImage_t const *image,
char const *message,
char const *msgFont,
int btnCount,
char const **buttons,
char const **btnFonts,
int defBtn,
int escBtn,
int flags );
Arguments:
parent A pointer to the parent widget of the dialog (usually a window). By
setting the flags, you can block the parent and/or position the dialog
relative to it.
title The title for the dialog. If you don’t want a title bar, set this argument to
NULL.
msgFont The font for the message text; the default is TextFont09. You should
create the font name by calling PfGenerateFontName().
defBtn The number of the button that initially has focus when the dialog is
realized. The left button’s index is 1.
escBtn The number of the button that’s bound to the Esc key. If you wish to
disable the Esc key, set this argument to 0. If Esc is enabled, the close
button is included in the dialog’s titlebar (if there is one). Closing the
dialog in this manner is the same as pressing the Esc key; the dialog
closes and the escBtn button is selected.
flags Flags that specify the behavior for the dialog. This can be up to one of
the following:
• Pt_CENTER — center the dialog.
• Pt_LEFT — left-align the dialog (the default).
• Pt_RIGHT — right-align the dialog.
with any combination of the following:
• Pt_BLOCK_ALL — block all of the application’s windows while the
dialog is displayed.
• Pt_BLOCK_PARENT — block the widget specified by the parent
argument (if non-NULL).
• Pt_ESC_DISABLE — disable the ESC key as a means of dismissing
the dialog.
• Pt_MODAL — the same as Pt_BLOCK_ALL.
• Pt_RELATIVE — position the dialog relative to the given parent
widget. If this bit isn’t set or parent is NULL, the dialog is positioned
relative to the current console.
Pt_BLOCK_ALL overrides Pt_BLOCK_PARENT.
Library:
ph
Description:
This function displays a dialog that displays a message and contains any number of
buttons so that you can respond.
Returns:
The number of the button that you selected.
Examples:
char const *btns[] = { "&Save it", "&Discard changes",
"&Cancel" };
char Helvetica14[MAX_FONT_TAG];
case 1:
/* save */
break;
case 2:
/* discard changes */
break;
case 3:
/* cancel */
return;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
continued. . .
Safety
Thread No
See also:
ApError(), PfGenerateFontName(), PhImage_t, PhPoint_t, PtNotice(),
PtPassword(), PtPrompt()
“Dialog modules” in the Working with Modules chapter of the Photon Programmer’s
Guide
Synopsis:
void PtAllowExit( void );
Library:
ph
Description:
PtAllowExit() lets Photon know that it’s safe to exit your application.
In a multithreaded application, any thread can call PtExit(), but another thread might
be in the middle of an important operation, such as writing a file. To prevent this
situation from arising, call PtPreventExit() before starting the operation, and call
PtAllowExit() when it’s done.
Instead of calling PtPreventExit() and PtAllowExit() directly, you’re better off calling
PtEnter() and PtLeave() with Pt_DELAY_EXIT set in the flags. For a discussion of the
difference between these functions and using Pt_DELAY_EXIT, see “Exiting a
multithreaded program” in the Parallel Operations chapter of the Photon
Programmer’s Guide.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PtEnter(), PtExit(), PtLeave(), PtPreventExit()
Parallel Operations chapter of the Photon Programmer’s Guide
Synopsis:
void PtAppAddCallback(
unsigned long cb_type,
int (*func)(void*,PtCallbackInfo_t*),
void *data );
Arguments:
cb_type The name of the callback list you want to add the function to. For
example, Pt_CB_APP_EXIT.
func A pointer to the function you want to add. The function takes this form:
int (*func)(PtCallbackInfo_t *, void *).
data A pointer to data that you want to pass as the second argument to the
function.
Library:
ph
Description:
This function adds a callback to the application’s callback list. For a list of application
callbacks, see PtAppSetResources().
For more information, see the Manipulating Resources in Application Code chapter of
the Photon Programmer’s Guide.
Returns:
0 Success.
-1 An error occurred.
Examples:
int exit_cb(void *data,
PtCallbackInfo_t *cbinfo)
{
printf( "I\’m exiting\n" );
return( Pt_CONTINUE );
};
...
PtAppAddCallback(Pt_CB_APP_EXIT, exit_cb, NULL);
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppGetResources(), PtAppGetResource(), PtAppRemoveCallback(),
PtAppSetResource(), PtAppSetResources(), PtSetArg().
Synopsis:
void PtAppAddEventHandler( unsigned long event_mask,
int (*func)(void *,PtCallbackInfo_t *),
void *data);
Arguments:
event_mask The event type that causes the application to invoke the event handler
func.
func A pointer to the event handler function you want to add. The function
takes this form: int (*func)(void *,PtCallbackInfo_t *).
data A pointer to data that you want to pass as the second argument to the
function.
Library:
ph
Description:
This function adds an event handler to the application’s Pt_CB_RAW callback list.
The application invokes this handler whenever an event type that matches one of the
bits in event_mask intersects with the application .
For more information, see the Manipulating Resources in Application Code chapter of
the Photon Programmer’s Guide.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppGetResources(), PtAppGetResource(), PtAppRemoveCallback(),
PtAppRemoveEventHandler(), PtAppSetResource(), PtAppSetResources(), PtSetArg().
“Event handlers” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
int PtAppAddFd( PtAppContext_t app,
int fd,
unsigned mode,
PtFdProc_t fun,
void *data);
Arguments:
app The address of the application context, a structure that manages all the
data associated with this application. This must be specified as NULL , so
that the default context is used.
fd The file descriptor to attach an FD handler to.
mode Defines what kind of conditions the application is interested in:
The fd and data arguments have the same value as the fd and data
arguments to PtAppAddFd(). The mode argument indicates which
conditions were actually met.
The fun function should return Pt_CONTINUE to remain on the list of fd
functions, or Pt_END to be removed automatically from it.
data A pointer to data that you want to pass as the second argument to the FD
handler function.
priority PtAppAddFdPri() only.
Specifies the priority of the Photon pulse that’s created (see
PtAppCreatePulse()).
Library:
ph
Description:
These functions install an “FD function” that informs the application about device
events.
If your application needs to perform I/O such as reading from or writing to a pipe, you
should add an FD handler. An FD handler is a function that’s called by the main event
loop when a given file descriptor (FD) is ready for input or output.
Multiple FD functions attached to the same file descriptor aren’t supported.
PtAppAddFd() fails with errno set to EBUSY if you try to attach another function to
the same FD.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppCreatePulse(), PtAppRemoveFd(), PtAppSetFdMode(), PtFdProc_t
“Other I/O mechanisms” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
void PtAddFilterCallback(
unsigned long event_mask,
int (*func)(void *,PtCallbackInfo_t *),
void *data);
Arguments:
event_mask The event type that causes the application to invoke the filter callback
func.
func A pointer to the event handler function you want to add. The function
takes this form: int (*func)(void *,PtCallbackInfo_t *).
data A pointer to data that you want to pass as the first argument to the
function.
Library:
ph
Description:
This function adds an event handler to the application’s Pt_CB_FILTER callback list.
The application invokes this handler whenever an event type that matches one of the
bits in event_mask intersects with the application .
For more information, see the Manipulating Resources in Application Code chapter of
the Photon Programmer’s Guide.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppGetResources(), PtAppGetResource(), PtAppRemoveCallback(),
PtAppRemoveFilterCallback(), PtAppSetResource(), PtAppSetResources(), PtSetArg().
“Event handlers” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
void PtAppAddHotkeyHandler(
unsigned key_sym_cap,
unsigned key_mods,
short flags,
void *data,
int (*event_f )(void *,PtCallbackInfo_t *));
Arguments:
key_sym_cap The key cap or key sym (depending on flags) to match.
data A pointer to data you want passed as the first argument to the hotkey
handler event_f .
Library:
ph
Description:
This function adds a key event handler to the application’s Pt_CB_HOTKEY callback
list. The application invokes the last-added handler on this list whenever a key event
type that matches key_sym_cap and key_mods intersects with the application .
Note the following:
• Key caps, key mods, and key syms are defined in <photon/PkKeydef.h>.
• Key caps and key syms are prefixed with only Pk_.
For more information, see the Manipulating Resources in Application Code chapter of
the Photon Programmer’s Guide.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppGetResources(), PtAppGetResource(), PtAppRemoveCallback(),
PtAppRemoveHotkeyHandler() PtAppSetResource(), PtAppSetResources(),
PtSetArg().
“Event handlers” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
PtInputId_t *PtAppAddInput(
PtAppContext_t app_context,
pid_t pid,
PtInputCallbackProc_t input_func,
void *data );
Arguments:
app_context The address of the application context, a structure that manages all
the data associated with this application. Specify NULL for
app_context, so that the default context is used.
data A pointer to any extra data you want to pass to the input handler.
This gets passed as the data argument to input_func.
Library:
ph
Description:
This routine adds a function to a PtMainLoop() input-event processing chain.
data A pointer to any extra data you want to pass to the input handler. This is
the same as the data argument passed to PtAppAddInput() when the
input handler was registered.
size The size of the message buffer. If the actual message is longer than the
buffer, load the rest of the message by calling MsgRead().
If you application knows the maximum size of a message that can be
possibly sent to it, you can use PtResizeEventMsg() to ensure that the
buffer is large enough.
Receiving a large Photon event may make the buffer bigger than was established by
PtResizeEventMsg().
If the input function changes the display, it should call PtFlush() to make sure the
display is updated.
The rcvid argument that the input function gets may have a different value:
• In case of real processes under QNX Neutrino, the input function gets the
rcvid—which is the value that you’ll need for replying, just like the PID under
QNX 4. To retrieve the ID of the process, use PtGetRcvidPid().
• In the case of Photon pulses, the rcvid argument won’t necessarily have the same
value as the pulse PID, either. The rcvid matches the pulse PID on bits defined by
_NOTIFY_DATA_MASK (see ionotify() in the QNX Neutrino Library Reference),
but the other bits will be taken from the Neutrino pulse or signal that was received.
You can define more than one input handler in your application for a pid. When a
message is received from that process, the widget library starts calling the handlers in
the list, starting with the last one registered, and continuing up the list in reverse order
until a handler recognizes the message (that is, it doesn’t return Pt_CONTINUE). See
the description of Pt_CONTINUE below.
The input function must return one of the following:
Pt_CONTINUE The input handler doesn’t recognize the message. If there are other
input handlers attached to the same process ID, they’re called. If
there are no input handlers attached specifically to this process ID,
or if all input handlers attached specifically to this process ID
return Pt_CONTINUE, the library looks for input handlers attached
to pid 0. If all the input handlers return Pt_CONTINUE, the library
replies to the message with an ENOSYS.
Pt_END The message has been recognized and processed and the input
handler needs to be removed from the list. No other input handlers
are called for this message.
Pt_HALT The message has been recognized and processed but the input
handler needs to stay on the list. No other input handlers are called
for this message.
name_attach() and PtAppAddInput()
PtAppAddInput() and name_attach() both try to create a channel with
_NTO_CHF_COID_DISCONNECT and _NTO_CHF_DISCONNECT set (see the QNX
Neutrino Library Reference). If your application calls both functions, you need to let
Photon use the same channel as name_attach(). To do this, call these functions in this
order:
• name_attach()
• PhChannelAttach()
• PtAppAddInput()
See the Examples section of PhChannelAttach() for a sample of code that illustrates
the correct order.
If you want to create a separate channel for Photon, it doesn’t matter whether you
create it and give it to PhChannelAttach() before or after calling name_attach(). But
keep in mind that since certain mechanisms in Photon library expect the Photon
channel to have the two DISCONNECT flags, they might not work properly if it
doesn’t. One such mechanism is the detection of broken connections (see
PtConnectionClientSetError() and PtConnectionServerSetError()) and anything that
relies on it.
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:
See the example given in “Photon pulses” in the Interprocess Communication chapter
of the Photon Programmer’s Guide
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhChannelAttach(), PtAppAddInputRemote(), PtMainLoop(), PtAppCreatePulse(),
PtAppRemoveInput(), PtResizeEventMsg()
Interprocess Communication chapter of the Photon Programmer’s Guide
name_attach() in the QNX Neutrino Library Reference
Synopsis:
int PtAppAddInputRemote( PtAppContext_t app_context,
int nd,
pid_t pid,
PtInputCallbackProc_t input_func,
void *data );
Arguments:
app_context The address of the application context, a structure that manages all
the data associated with this application. Specify NULL for
app_context, so that the default context is used.
nd The node descriptor for the remote node running the process you
want to attach an input processing function to. For more information
see “Node descriptors” in ConnectAttach() in the Neutrino Library
Reference.
pid The process ID you want to attach the input handler to. The input
function is executed whenever the application receives a message
from process pid on node nd. If pid is negative, it’s the ID of a
Photon pulse, and nd must be 0.
If you specify a pid of 0, the input function is 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. If pid is 0, you must specify a nd of 0 as well. Your
input handler will get all messages from processes on any node, and
all pulses (except those that were already handled and returned
Pt_END or Pt_HALT).
data A pointer to any extra data you want to pass to the input handler.
Library:
ph
Description:
This routine adds a function to a PtMainLoop() input-event processing chain for a
process running on a remote node.
The input_func argument points to the input function to be invoked. The function
takes this form:
Receiving a large Photon event may make the buffer bigger than was established by
PtResizeEventMsg().
If the input function changes the display, it should call PtFlush() to make sure the
display is updated.
Pt_CONTINUE The input handler doesn’t recognize the message. If there are other
input handlers attached to the same process ID, they’re called. If
there are no input handlers attached specifically to this process ID,
or if all input handlers attached specifically to this process ID
return Pt_CONTINUE, the library looks for input handlers attached
to pid 0. If all the input handlers return Pt_CONTINUE, the library
replies to the message with an ENOSYS.
Pt_END The message has been recognized and processed and the input
handler needs to be removed from the list. No other input handlers
are called for this message.
Pt_HALT The message has been recognized and processed but the input
handler needs to stay on the list. No other input handlers are called
for this message.
• name_attach()
• PhChannelAttach()
• PtAppAddInputRemote()
If you want to create a separate channel for Photon, it doesn’t matter whether you
create it and give it to PhChannelAttach() before or after calling name_attach(). But
keep in mind that since certain mechanisms in Photon library expect the Photon
channel to have the two DISCONNECT flags, they might not work properly if it
doesn’t. One such mechanism is the detection of broken connections (see
PtConnectionClientSetError() and PtConnectionServerSetError()) and anything that
relies on it.
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.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhChannelAttach(), PtAppAddInput(), PtAppCreatePulse(), PtAppRemoveInput(),
PtGetRcvidPidNd(), PtMainLoop(), PtResizeEventMsg()
Interprocess Communication chapter of the Photon Programmer’s Guide
_pulse, MsgReceive(), and name_attach() in the QNX Neutrino Library Reference
Synopsis:
int PtAppAddSignalProc( PtAppContext_t app,
sigset_t const *set,
PtSignalProc_t func,
void *data);
Library:
ph
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. 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()
Interprocess Communication in the Photon Programmer’s Guide
Synopsis:
PtWorkProcId_t *PtAppAddWorkProc(
PtAppContext_t app_context,
PtWorkProc_t work_func,
void *data );
Library:
ph
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.
There is one exception to this rule. If the work procedure that’s at the top of the stack
is running already, the next one is called. This is only possible if the already running
procedure allows the Photon library to start another one, perhaps by calling a modal
function like PtModalBlock(), PtFileSelection() or PtAlert(), or calling PtLeave()
while you have other threads ready to process events.
When there are no events pending from Photon, the current WorkProc entry’s function
is invoked by PtMainLoop().
The app_context argument is the address of the application context, a structure that
manages all the data associated with this application. 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.
• If the WorkProc function changes the display, it should call PtFlush() to make sure
the display is updated.
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. These are the callbacks that start and
stop the rebounding work procedure, rebound_process().
// From src/start_rebound.c
int
start_rebound( PtWidget_t *widget, void *data,
PtCallbackInfo_t *cbinfo )
{
PtArg_t args[2];
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 );
}
// From src/stop_rebound.c
int
stop_rebound( PtWidget_t *widget, void *data,
PtCallbackInfo_t *cbinfo )
{
PtArg_t args[1];
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(), PtWorkProcF_t
Parallel Operations in the Photon Programmer’s Guide
Synopsis:
pid_t PtAppCreatePulse( PtAppContext_t app,
int priority );
Arguments:
app The address of the application context, a structure that manages all the
data associated with this application. Specify this as NULL, so as to use
the default context.
priority The priority of the pulse. If priority is -1, the pulse’s priority is the same
as that of the calling process.
Library:
ph
Description:
This function creates a Photon pulse. Under QNX Neutrino, PtAppCreatePulse()
creates a Neutrino pulse.
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(), PtPulseArm()
MsgDeliverEvent() in the QNX Neutrino Library Reference
Interprocess Communication in the Photon Programmer’s Guide
Synopsis:
int PtAppDeletePulse( PtAppContext_t app,
pid_t pulse_pid );
Library:
ph
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. This must be specified as NULL, so that
the default context is used.
If the application creates and destroys pulses frequently, the pulse ID will be reused
eventually. At least several hundred pulses can be safely created and destroyed before
that happens. If a pulse ID is reused but notifications are still generated with the old
pulse, they may or may not be delivered to the new pulse handler.
Returns:
0 Success
-1 An error occurred
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppCreatePulse(), PtAppPulseTrigger(), PtChannelCreate(), PtPulseArm()
MsgDeliverEvent() in the QNX Neutrino Library Reference
Interprocess Communication in the Photon Programmer’s Guide
Synopsis:
#define PtAppGetResources(type, value, len)
Arguments:
type The resource manifest (E.G Pt_CB_APP_EXIT).
value The address of a pointer to the appropriate data type (see the “New
resources” tables in the Photon Widget Reference).
Library:
ph
Description:
This macro sets a pointer to a resource value within the application.
PtAppGetResource() doesn’t support the nonpointer method of getting resources. For
more information, see the Manipulating Resources in Application Code chapter of the
Photon Programmer’s Guide. For a list of application callbacks, see
PtAppSetResources().
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddCallback(), PtAppGetResources(), PtAppRemoveCallback(),
PtAppSetResources(), PtAppSetResource(), PtSetArg().
Synopsis:
int PtAppGetResources(int n_args,
PtArg_t *args)
Arguments:
n_args The number of items in the args array.
Library:
ph
Description:
This function sets pointers to resource values within the application.
You must initialize the args array with PtSetArg() or Pt_ARG() before calling
PtAppGetResources(). 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 a list of application callbacks, see PtAppSetResources().
For more information, see the Manipulating Resources in Application Code chapter of
the Photon Programmer’s Guide.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddCallback(), PtAppGetResource(), PtAppRemoveCallback(),
PtAppSetResources(), PtAppSetResource(), PtSetArg().
Synopsis:
PtWidget_t *PtAppInit( PtAppContext_t *app_context,
int *argc,
char **argv,
int num_args,
PtArg_t const *args );
Library:
ph
Description:
This function:
• Creates a main window using the num_args and args arguments—these are the
same arguments passed to PtCreateWidget().
The application that calls PtAppInit() must have the appropriate permissions to read
from and write to the attached Photon server, or the call will fail.
Returns:
A pointer to the main window, or NULL if an error occurs.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhAttach(), PtArg_t. PtCreateWidget(), PtInit(), PtMainLoop()
“Basic steps” in the Programming Photon without PhAB chapter of the Photon
Programmer’s Guide
Synopsis:
int PtAppPulseTrigger( PtAppContext_t app,
pid_t pulse );
Library:
ph
Description:
This function allows an application to deliver a Photon pulse to itself:
• In QNX 4, the value of pulse must match the pulse PID exactly.
The app argument is the address of the application context, a structure that manages
all the data associated with this application. This must be specified as NULL, so that
the default context is used. The pulse argument is a pulse ID returned by
PtAppCreatePulse().
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppCreatePulse(), PtAppDeletePulse(), PtChannelCreate(), PtPulseArm()
MsgDeliverEvent() in the QNX Neutrino Library Reference
Interprocess Communication in the Photon Programmer’s Guide
Synopsis:
void PtAppRemoveCallback(unsigned long cb_type,
int (*func)(void*,PtCallbackInfo_t*),
void *data)
Arguments:
cb_type The type of the callback you want to remove. For example,
Pt_CB_APP_EXIT.
Library:
ph
Description:
This function removes the first callback entry that matches func and data. It removes
the entry from the cb_type callback list that belongs to the application. For a list of
application callbacks, see PtAppSetResources().
For more information, see the Manipulating Resources in Application Code chapter of
the Photon Programmer’s Guide.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddCallback(), PtAppGetResources(), PtAppGetResource(),
PtAppRemoveHotkeyHandler(), PtAppRemoveFilterCallback(),
PtAppRemoveEventHandler(), PtAppSetResource(), PtAppSetResources(), PtSetArg().
Synopsis:
void PtAppRemoveEventHandler(
unsigned long event_mask,
int (*func)(void *,PtCallbackInfo_t *),
void *data);
Arguments:
event_mask The event type for the handler you want to remove.
Library:
ph
Description:
This function removes the first event handler that matches event_mask, func, and data
from the application’s Pt_CB_RAW callback list.
For more information, see the Manipulating Resources in Application Code chapter of
the Photon Programmer’s Guide.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddEventHandler(), PtAppGetResources(), PtAppGetResource(),
PtAppRemoveCallback(), PtAppRemoveFilterCallback(),
PtAppRemoveHotkeyHandler(), PtAppSetResource(), PtAppSetResources(),
PtSetArg().
“Event handlers” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
int PtAppRemoveFd( PtAppContext_t app, int fd );
Library:
ph
Description:
This function removes an FD function, fd, from the list of input handlers for the
application. You’ll use an FD function when using pipes in a Photon application.
The app argument is the address of the application context, a structure that manages
all the data associated with this application. 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 chapter of the Photon
Programmer’s Guide
Synopsis:
void PtAppRemoveFilterCallback(
unsigned long event_mask,
int (*func)(void *,PtCallbackInfo_t *),
void *data);
Arguments:
event_mask The event mask for the callback you want to remove.
Library:
ph
Description:
This function removes the first event handler that matches event_mask, func, and data
from the application’s Pt_CB_FILTER callback list.
For more information, see the Manipulating Resources in Application Code chapter of
the Photon Programmer’s Guide.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddFilterCallback(), PtAppGetResources(), PtAppGetResource(),
PtAppRemoveCallback(), PtAppRemoveEventHandler(),
PtAppRemoveHotkeyHandler(), PtAppSetResource(), PtAppSetResources(),
PtSetArg().
“Event handlers” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
void PtAppRemoveHotkeyHandler(
unsigned key_sym_cap,
unsigned key_mods,
short flags,
void *data,
int (*event_f )(void *,PtCallbackInfo_t *));
Arguments:
key_sym_cap The key_sym_cap for the handler you want to remove.
Library:
ph
Description:
This function removes the first hotkey handler that matches key_sym_cap, key_mods,
flags, data, and event_f from the application’s Pt_CB_HOTKEY callback list.
Note the following:
• Key caps, key mods, and key syms are defined in <photon/PkKeydef.h>.
• Key caps and key syms are prefixed with only Pk_.
For more information, see the Manipulating Resources in Application Code chapter of
the Photon Programmer’s Guide.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddHotkeyHandler(), PtAppGetResources(), PtAppGetResource(),
PtAppRemoveCallback(), PtAppRemoveEventHandler(),
PtAppRemoveFilterCallback(), PtAppSetResource(), PtAppSetResources(), PtSetArg().
“Event handlers” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
void PtAppRemoveInput( PtAppContext_t app_context,
PtInputId_t *input_id );
Library:
ph
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 tries 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().)
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddInput(), PtMainLoop()
“Receiving QNX messages” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
int PtAppRemoveSignal( PtAppContext_t app,
sigset_t const *set,
PtSignalProc_t proc,
void *data );
Library:
ph
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.
• If set isn’t NULL, this function removes one instance of each specified signal from
a list item that matches proc and data. In other words, if you attach it twice, you
have to remove it twice.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddSignalProc(), PtSignalProc_t
Interprocess Communication in the Photon Programmer’s Guide
Synopsis:
void PtAppRemoveWorkProc(
PtAppContext_t app_context,
PtWorkProcId_t *WorkProc_id );
Library:
ph
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. Currently, only the default context (app_context == NULL) is
supported.
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()
Parallel Operations in the Photon Programmer’s Guide
Synopsis:
int PtAppSetFdMode( PtAppContext_t app,
int fd,
unsigned mode );
Library:
ph
Description:
This function changes the mode that’s of interest to the handler for the given file
descriptor, fd. You’ll use an FD function when using pipes in a Photon application.
The app argument is the address of the application context, a structure that manages
all the data associated with this application. 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:
These values correspond to conditions defined for the ionotify() or select() functions.
You can OR the values together.
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:
#define PtAppSetResource( type, value, len ) ...
Arguments:
type The resource manifest.
Library:
ph
Description:
This function sets a resource for the application. The type argument contains the
resource manifest and value contains the value of the argument being passed. The way
the len argument is used depends on the resource type. For a list of application
callbacks, see PtAppSetResources().
For more information, see the Manipulating Resources in Application Code chapter of
the Photon Programmer’s Guide.
Returns:
0 Success.
-1 An error occurred.
Examples:
int exit_cb(void *data,
PtCallbackInfo_t *cbinfo)
{
printf( "I\’m exiting\n" );
return( Pt_CONTINUE );
};
...
PtAppCallback_t exit_callback = {exit_cb, NULL}};
PtAppSetResource(Pt_CB_APP_EXIT, &exit_callback, 0);
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddCallback(), PtAppGetResources(), PtAppGetResource(),
PtAppRemoveCallback(), PtAppSetResources(), PtSetArg().
Synopsis:
int PtAppSetResources(int n_args,
PtArg_t const *args);
Arguments:
n_args The number of items in the args array.
Library:
ph
Description:
This function sets the resources specified in the args array for the application. This
function operates identically to its widget counterpart, PtSetResources(), except it
doesn’t have a widget argument.
Pt_CB_APP_EXIT
C type Pt type Default
PtAppCallback_t* Link NULL
A list of PtAppCallback_t structures that define the callbacks invoked when the
application is exiting via a call to PtExit(). All exit points from the library call
PtExit(), but it is up to the application designer to exit via this method also. Callbacks
should unconditionally return Pt_CONTINUE — other return values may be interpreted
differently in future versions.
Although an application might call PtExit() more than once (for example, from
different threads in a multi-threaded application), the callbacks in this list are invoked
only once.
reason Pt_CB_APP_EXIT
event NULL
cbdata NULL
Pt_CB_APP_WCLASS_CREATED
C type Pt type Default
PtAppCallback_t* Link NULL
reason Pt_CB_APP_WCLASS_CREATED
event NULL
Pt_CB_FILTER
C type Pt type Default
PtAppRawCallback_t* Link NULL
Application-level event filters are invoked prior to any widget processing (including
the widget event filters), and can preempt events in a similar fashion
Your application must have at least one region open for this resource to work.
Pt_CB_RAW
C type Pt type Default
PtAppRawCallback_t* Link NULL
Your application must have at least one region open for this resource to work.
Pt_CB_HOTKEY
C type Pt type Default
PtAppHotkeyCallback_t* Link NULL
Your application must have at least one window for this resource to work. Also, you
cannot bind application-level hotkey handlers to widgets. Therefore you must supply a
callback function (this is different from the widget-level hotkey handlers).
PtAppCallback_t
An application callback structure.
typedef struct Pt_app_callback {
int (*event_f )( void *, PtCallbackInfo_t * ),
void *data;
} PtAppCallback_t;
The PtAppCallback_t structure lets you specify an application’s callbacks. This
structure contains at least:
PtCallbackInfo_t *cbinfo
A pointer to a common Photon callback structure. The structure
provides information related to the widget callback being
invoked, the Photon event, and some widget-specific callback
data. The format of the data varies with the widget class and
callback type. For more information, see PtCallbackInfo_t.
Callback functions should return Pt_CONTINUE unless the description of the widget’s
callback resource tells you to return something else.
PtAppRawCallback_t
The PtAppRawCallback_t structure lets you specify event handlers (raw and filter
callbacks) for your application. You use this structure when setting the Pt_CB_RAW
or Pt_CB_FILTER resource of your application.
typedef struct Pt_app_raw_callback {
unsigned long event_mask;
int (*event_f )( void *, PtCallbackInfo_t * );
void *data;
} PtAppRawCallback_t;
event_mask A bitmap that specifies which events trigger the function specified in
event_f . See PhEvent_t in the Photon Library Reference.
PtAppHotkeyCallback_t
An application hotkey callback structure.
typedef struct Pt_app_hotkey_callback {
unsigned short key_sym_cap;
short flags;
unsigned long key_mods;
void *data;
int (*event_f )( void *, PtCallbackInfo_t * );
} PtAppHotkeyCallback_t;
key_sym_cap Depending on the specified flags, this member contains either the
symbol or cap of the key to be interpreted as a hotkey. For valid
key_sym_cap values, see <photon/PkKeyDef.h>.
key_mods Key modifiers that must be active for the key to be considered a
hotkey. If the Pt_HOTKEY_IGNORE_MODS flag is set, this member
is ignored.
For valid key modifiers, see <photon/PkKeyDef.h>. All
key-modifier manifests begin with Pk_KM_.
data A pointer to any data that you want to pass as the second argument
to the callback function.
Returns:
0 At least one of the resources was applied to the application.
-1 The application wasn’t modified because it doesn’t contain the given resources
or the values of the resources were the same as those already stored in the
application.
Examples:
Set the Pt_CB_APP_EXIT callback resource for an application:
int exit_cb(void *data,
PtCallbackInfo_t *cbinfo)
{
printf( "I\’m exiting\n" );
return( Pt_CONTINUE );
};
...
PtAppCallback_t exit_callbacks[] = {{exit_cb, NULL}};
PtArg_t args[1];
PtSetArg( &args[0], Pt_CB_APP_EXIT, exit_callbacks,
sizeof(exit_callbacks)/sizeof(exit_callbacks[0]));
PtAppSetResources( 1, args );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddCallback(), PtAppGetResources(), PtAppGetResource(),
PtAppRemoveCallback(), PtAppSetResource(), PtSetArg().
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.
len The purpose of this member is determined by the Pt type of the resource.
For more information, see the Manipulating Resources in Application Code chapter of
the Photon Programmer’s Guide.
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 ) { ... }
Library:
ph
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.
If you have to calculate some of the values at runtime, you’ll need to use PtSetArg() to
initialize the argument list.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Caveats:
Pt_ARG() is a macro.
See also:
PtArg_t, PtGetResource(), PtGetResources(), PtSetArg(), PtSetResource(),
PtSetResources()
Manipulating Resources in Application Code chapter of the Photon Programmer’s
Guide.
Synopsis:
void PtBkgdHandlerProcess( void );
Library:
ph
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
Signal handler No
Thread No
See also:
Parallel Operations chapter of the Photon Programmer’s Guide
Synopsis:
int PtBlit( PtWidget_t *widget,
PhRect_t const *source,
PhPoint_t const *delta );
Library:
ph
Description:
This function blits the area that’s defined by the PhRect_t structure pointed to by
source (relative to the widget’s origin) by an offset specified by the PhPoint_t
structure pointed to by delta. Effects of the blit are limited to only the visible portions
of the widget’s canvas.
Returns:
0 Success.
-1 The blit failed, possibly because the widget wasn’t realized or the Photon
Manager wasn’t running.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhBlit(), PhPoint_t, PhRect_t, PtClippedBlit()
Synopsis:
PtBlockedList_t *PtBlockAllWindows(
PtWidget_t *skip,
unsigned short cursor,
PgColor_t cursor_color );
Library:
ph
Description:
PtBlockAllWindows() blocks all windows belonging to the calling application, except
the window that contains the widget pointed to by skip (if not NULL).
If cursor isn’t zero, this function sets the windows’ cursors to that value and their
cursor color to cursor_color (if different from Pg_TRANSPARENT).
Ph_CURSOR_NOINPUT is a typical choice for the cursor; for a list of the other
cursors, see <photon/PhCursor.h>.
Returns:
A pointer to a control structure that can be passed to PtUnblockWindows() to undo the
changes, or NULL if an error occurred or there was nothing to do.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApModalWait(), PgColor_t, PtBlockWindow(), PtMakeModal(),
PtUnblockWindows()
“Modal dialogs” in the Window Management chapter of the Photon Programmer’s
Guide
Synopsis:
PtBlockedList_t *PtBlockWindow(
PtWidget_t *window,
unsigned short cursor,
PgColor_t cursor_color );
Library:
ph
Description:
PtBlockWindow() blocks the given window (if not NULL).
If cursor isn’t zero, this function sets the window’s cursor to that value and its cursor
color to cursor_color (if different from Pg_TRANSPARENT). Ph_CURSOR_NOINPUT
is a typical choice for the cursor; for a list of the other cursors, see
<photon/PhCursor.h>.
Returns:
A pointer to a control structure that can be passed to PtUnblockWindows() to undo the
changes, or NULL if an error occurred or there was nothing to do.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApModalWait(), PgColor_t, PtBlockAllWindows(), PtMakeModal(),
PtUnblockWindows()
“Modal dialogs” in the Window Management chapter of the Photon Programmer’s
Guide
Synopsis:
int PtCalcAbsPosition( PtWidget_t *reference,
PhPoint_t const *pos,
PhDim_t const *dim,
PhPoint_t *new_pos );
Library:
ph
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
-1 An error occurred. The dim or new_pos values might have been NULL.
Examples:
If you have a main application window and want to center a dialog on it, you could do
the following:
...
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhDim_t, PhPoint_t
Synopsis:
PhRect_t *PtCalcCanvas( PtWidget_t *widget,
PhRect_t *canvas_rect);
Library:
ph
Description:
This function determines the canvas rectangle for the specified widget and caches it in
the widget’s internal memory. This canvas rectangle describes the area inside the
widget’s border and any margins.
If canvas_rect isn’t NULL, PtCalcCanvas() copies the canvas rectangle into the
PhRect_t structure it points to.
Returns:
A pointer to the PhRect_t structure that defines the canvas. If canvas_rect is
non-NULL, this is the same pointer as canvas_rect.
!
CAUTION: If you pass NULL for canvas_rect, PtCalcCanvas() returns a pointer into
the widget’s internal memory. Don’t modify the contents of the structure or free the
memory.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRect_t, PtWidgetExtent()
Synopsis:
void PtCalcSurface( PtWidget_t *widget,
PtSurface_t *surface );
Library:
ph
Description:
PtCalcSurface() forces a control surface to calculate its geometry.
The widget argument specifies the widget owning the surface, while surface points to
the data structure that describes the control surface. Both pointers must not be NULL.
This function is useful if the geometry of one surface depends on that of another.
This function call amounts to a no-op if the geometry for the specified surface has
already been calculated for this pre/post-extent cycle.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCalcSurfaceByAction(), PtCalcSurfaceById(), PtSurfaceCalcBoundingBox(),
PtSurfaceCalcBoundingBoxById(), PtSurfaceExtent(), PtSurfaceExtentById(),
PtSurfaceRect(), PtSurfaceRectById()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
void PtCalcSurfaceByAction(
PtWidget_t *widget,
PtWidgetClassRef_t const *cref ,
unsigned short action_id );
Library:
ph
Description:
PtCalcSurfaceByAction() forces all surfaces belong to the given widget that are
associated with an action to calculate their geometry.
The cref and action_id specify the class and manifest of the action associated with
surfaces to be calculated.
The geometry is calculated only for surfaces that haven’t already calculated it for this
pre/post-extent cycle.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCalcSurface(), PtCalcSurfaceById(), PtSurfaceCalcBoundingBox(),
PtSurfaceCalcBoundingBoxById(), PtSurfaceExtent(), PtSurfaceExtentById(),
PtSurfaceRect(), PtSurfaceRectById()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
PtSurface_t *PtCalcSurfaceById(
PtWidget_t *widget,
unsigned char surface_id );
Library:
ph
Description:
PtCalcSurfaceById() forces a control surface to calculate its geometry.
The widget argument specifies the widget owning the surface, while surface_id
specifies the numeric ID of the surface to calculate. This function is useful if the
geometry of one surface depends on that of another.
This function call amounts to a no-op if the geometry for the specified surface has
already been calculated for this pre/post-extent cycle.
Returns:
A pointer to the specified surface on success, or NULL if the surface couldn’t be found.
Since control surfaces are maintained internally as an array, it’s not uncommon for
them to shift around in memory as surfaces are added and removed, thereby possibly
invalidating a pointer returned by this function. As such, all surface pointers should be
regarded as transient, and you should retrieve an updated copy whenever there is a
chance that the widget’s surface configuration might have changed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCalcSurface(), PtCalcSurfaceByAction(), PtSurfaceCalcBoundingBox(),
PtSurfaceCalcBoundingBoxById(), PtSurfaceExtent(), PtSurfaceExtentById(),
PtSurfaceRect(), PtSurfaceRectById()
Synopsis:
int PtCancelDnd( PhRid_t rid,
unsigned flags,
PhPoint_t const *pos,
unsigned ig,
unsigned long handle );
Arguments:
rid The region ID.
Library:
ph
Description:
PtCancelDnd() cancels a drag-and-drop operation.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhPoint_t, PtCreateTransportCtrl(), PtDndFetch_t, PtDndSelect(),
PtTransportCtrl_t, PtTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
int PtChannelCreate( void );
Library:
ph
Description:
In QNX 4, this function simply returns 1.
In QNX 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 QNX Neutrino, this function returns the channel number, or -1 on failure.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtCheckSurfaces( PtWidget_t *widget,
PhPoint_t *point,
PhEvent_t *event );
Library:
ph
Description:
This function matches the given event with the control surfaces belonging to widget. If
the event corresponds to a control surface, the surface’s action is invoked.
PtCheckSurfaces() is usually called only from PtEventHandler(), although you can
call it with a fake event if you need to.
Returns:
Pt_CONTINUE The event wasn’t processed by a control surface.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEvent_t, PtEventHandler(), PhPoint_t
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
int PtChildType( PtWidget_t *parent,
PtWidget_t *child );
Library:
ph
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()
“Ordering widgets” in the Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
int PtClearWidget(PtWidget_t *widget);
Arguments:
widget A pointer to the container widget that you want to clear.
Library:
ph
Description:
This function destroys all the nonprocreated widgets within the specified
container-class widget.
Procreated widgets are widgets that are created as part of a compound widget, as
opposed to those that your application creates. For example, a PtScrollContainer
can have:
• nonprocreated children — the widgets that your application adds inside the
PtScrollContainer. These are the only children that PtClearWidget() destroys.
Returns:
0 Successful completion.
Examples:
#include <stdlib.h>
#include <Pt.h>
int main()
{
PtWidget_t *group, *window;
PtArg_t argt;
PtArg_t argts[3];
PhPoint_t pos ={ 10,10 };
if (PtInit(NULL) == -1)
exit(EXIT_FAILURE);
PtRealizeWidget( window );
PtContainerHold( group );
PtClearWidget( group );
//destroys all widgets within the group,
//clearing it...
PtContainerRelease( group );
PtMainLoop();
return EXIT_SUCCESS;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerHold(), PtContainerRelease(), PtDestroyWidget(), PtExtentWidget(),
PtWidgetChildBack()
Synopsis:
int PtClipAdd( PtWidget_t *widget,
PhRect_t *rect );
Description:
This function adds a clipping rectangle to the clipping stack. The rectangle added to
the clipping stack is the intersection of the last rectangle on the stack and the rectangle
defined in the PhRect_t pointed to by rect.
Prior to entering a widget’s Draw method, the canvas rectangle derived from the
PtBasic-class level is pushed onto the clipping stack. This prevents any children
from drawing beyond the canvas of the parent container.
A widget can, however, draw beyond its own canvas or extent unless additional
clipping is performed. PtAttemptResize() and PtResizeCanvas() set the Pt_UCLIP bit
of a widget’s resize flags if the widget requires additional clipping (to prevent it from
drawing beyond its own canvas).
Returns:
The current level of stack clipping.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRect_t, PtCalcCanvas(), PtClipRemove()
PtAttemptResize(), PtResizeCanvas() in Building Custom Widgets
Synopsis:
int PtClippedBlit( PtWidget_t *widget,
PhTile_t const *src,
PhPoint_t const *delta,
PhTile_t const *clip );
Library:
ph
Description:
This function blits the areas inside widget specified by the PhTile_t tile list src
(areas are relative to the widget’s origin) by an offset specified by delta. Effects of the
blit are limited by the tiles specified by clip.
Returns:
0 Success.
-1 The blit failed, possibly because the widget wasn’t realized or the Photon
Manager wasn’t running.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhBlit(), PhPoint_t, PhTile_t, PtBlit()
Synopsis:
int PtClipRemove();
Description:
This function pops the last clipping rectangle off the clipping stack.
Returns:
The current level of stack clipping.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCalcCanvas(), PtClipAdd()
PtAttemptResize(), PtResizeCanvas() in Building Custom Widgets
Synopsis:
int PtCondTimedWait(
pthread_cond_t *cond,
const struct timespec *abstime );
Arguments:
cond The condition variable to wait on.
Library:
ph
Description:
PtCondTimedWait() is an equivalent of pthread_cond_timedwait() that uses the
Photon library lock instead of a mutex, which has the effect of an implicit PtLeave()
when you block, and PtEnter() when you unblock.
The calling thread is blocked until:
In all cases, the thread reacquires the Photon library lock before being unblocked.
Returns:
EOK Success, or the call was interrupted by a signal.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PtCondWait(), PtEnter(), PtLeave()
pthread_cond_timedwait() in the QNX Neutrino Library Reference
“Threads” in the Parallel Operations chapter of the Photon Programmer’s Guide
Synopsis:
int PtCondWait( pthread_cond_t *cond );
Arguments:
cond The condition variable to wait on.
Library:
ph
Description:
PtCondWait() is an equivalent of pthread_cond_wait() that uses the Photon library
lock instead of a mutex, which has the effect of an implicit PtLeave() when you block,
and PtEnter() when you unblock.
The calling thread is blocked until:
In all cases, the thread reacquires the Photon library lock before being unblocked.
The implicit PtLeave() call that PtCondWait() makes before blocking turns the calling
thread into an event non-reader. If you passed the Pt_DELAY_EXIT flag to PtEnter()
before calling PtCondWait(), it also disables the effect of that flag. Before returning,
PtCondWait() turns the thread back into an event reader if it was an event reader
before, but will not turn the Pt_DELAY_EXIT flag back on. In particular, this means
that if another thread has called PtExit(), this function does not return, even if a third
thread signals the condvar.
Returns:
EOK Success, or the call was interrupted by a signal.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PtCondTimedWait(), PtEnter(), PtLeave()
pthread_cond_wait() in the QNX Neutrino Library Reference
“Threads” in the Parallel Operations chapter of the Photon Programmer’s Guide
Synopsis:
int PtConnectionAddEventHandlers(
PtConnectionClient_t *connection,
PtConnectionEventHandler_t const *handlers,
unsigned nhandlers );
Library:
ph
Description:
This function adds a set of server event handlers to a client connection object. The
handlers[] argument points to an array of PtConnectionEventHandler_t
structures:
The array must be sorted with respect to the type field; it also must not be destroyed or
modified as long as the connection object using it exists.
If you add multiple tables to a connection object, they’re searched in the reverse order:
a call to PtConnectionAddEventHandlers() can override handlers that were attached
by a previous call. An event handler should return Pt_END to “consume” the event, or
Pt_CONTINUE to continue the search.
A special value of zero in the type field means “any type.” When a notification from
the server arrives, all the tables are searched for an exact match on the type, and if the
event isn’t consumed, the tables are searched again for a handler with type 0.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PtConnectionAddMsgHandlers(), PtConnectionNotify(), PtConnectionReply(),
PtConnectionReplymx(), PtConnectionResizeEventBuffer()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
int PtConnectionAddMsgHandlers(
PtConnectionServer_t *connection,
PtConnectionMsgHandler_t const handlers[],
unsigned nhandlers );
Library:
ph
Description:
This function adds a set of message handlers to a server connection object. The
handlers[] argument points to an array of PtConnectionMsgHandler_t structures:
These structures describe your message handler functions. Your message handler
should have these arguments:
user_data a pointer to the connection object’s user data. This data is set with
PtConnectionServerSetUserData().
The array must be sorted with respect to the type field; it also must not be destroyed or
modified as long as the connection object using it exists.
If you add multiple tables to a connection object, they’re searched in the reverse order:
a call to PtConnectionAddMsgHandlers() can override handlers that were attached by
a previous call.
A special value of zero in the type field means “any type.” When a message from a
client arrives, all the tables are searched for an exact match on the type, and if this
search fails, the tables is searched again for a handler with type 0.
A message handler can do one of three things:
• Just return NULL. This means that the handler hasn’t handled the message and
another handler should be looked for in the tables.
• Set up a reply message, set *reply_len to the length of it, and return the pointer to
the reply.
• Reply to the client by calling PtConnectionReply(), and then return any non-NULL
value.
A message handler shouldn’t perform any blocking operations and isn’t allowed to
process Photon events (e.g. don’t call PtBkgdHandlerProcess() from an event
handler). There’s no way to delay the reply to the client — if none of the handlers
returns a non-NULL value, the library sends a zero-length reply.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionAddEventHandlers(), PtConnectionReply(), PtConnectionReplymx(),
PtConnectionSend(), PtConnectionSendmx()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
void PtConnectionClientDestroy(
PtConnectionClient_t *connection );
Library:
ph
Description:
This function destroys the client connection object. Attempting to send any messages
or notifications to a partner whose connection object has been destroyed isn’t safe;
preventing such attempts is the responsibility of a higher level protocol.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionClientGetUserData(), PtConnectionClientSetError(),
PtConnectionClientSetUserData(), PtConnectionServerDestroy()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
void *PtConnectionClientGetUserData(
PtConnectionClient_t *connection );
Library:
ph
Description:
A connection object contains a user data pointer that’s passed to its message handlers.
This function lets you retrieve that pointer.
Returns:
A void * pointer to the data.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionClientDestroy(), PtConnectionClientSetError(),
PtConnectionClientSetUserData(), PtConnectionServerGetUserData(),
PtConnectionServerSetUserData()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
PtConnectionClientErrorFunc_t *
PtConnectionClientSetError(
PtConnectionClient_t *connection,
PtConnectionClientErrorFunc_t *func );
Library:
ph
Description:
This function sets up an error handling function for the client-side of a connection.
The prototype of the handler is:
Pt_CONNECTION_SEND_FAILED
The MsgSend() to the server failed.
Pt_CONNECTION_REALLOC_REPLY
The realloc() failed to expand the reply buffer.
Pt_CONNECTION_CLIENT_BROKEN
The server has died or closed its part of the connection.
The error handler is called when certain errors occur; the handler can return
Pt_CONTINUE to retry, or Pt_END to fail. The default error handler returns Pt_END.
Returns:
A pointer to the previous error-handler function.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionClientDestroy(), PtConnectionClientGetUserData(),
PtConnectionClientSetUserData(), PtConnectionServerSetError()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
void PtConnectionClientSetUserData(
PtConnectionClient_t *connection,
void *data );
Library:
ph
Description:
A connection object contains a user data pointer that’s passed to its message handlers.
This function lets you set that pointer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionClientDestroy(), PtConnectionClientGetUserData(),
PtConnectionClientSetError(), PtConnectionServerGetUserData(),
PtConnectionServerSetUserData()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
PtConnectionClient_t *PtConnectionFindId(
PhConnectorId_t id,
int subtype,
unsigned flags );
Library:
ph
Description:
This function connects to the connector with the given ID, and creates a
client-connection object.
The subtype and flags arguments should be set to zero for now.
Returns:
A pointer to the client-connection object.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionFindName(), PtConnectionTmpName(), PtConnectionWaitForName()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
PtConnectionClient_t *PtConnectionFindName(
const char *name,
int subtype,
unsigned flags );
Library:
ph
Description:
This function connects to the connector with the given name, and creates a
client-connection object.
The subtype and flags arguments should be set to zero for now.
Returns:
A pointer to the client-connection object.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionFindId(), PtConnectionTmpName(), PtConnectionWaitForName()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
int PtConnectionFlush(
PtConnectionServer_t *connection );
Library:
ph
Description:
This function waits for a message from the client and sends all the pending
notifications in the reply. If there are no notifications to be sent, the function doesn’t
wait.
This function may process Photon events or other messages while waiting for the
message from the client. If a received Photon event invokes a callback that calls
PtConnectionFlush() on the same connection again, the second call fails with errno
set to EBUSY.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionNotify(), PtConnectionReply(), PtConnectionReplymx(),
PtConnectionSend(), PtConnectionSendmx()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
int PtConnectionNotify(
PtConnectionServer_t *connection,
unsigned long type,
void const *message,
unsigned length,
unsigned flags );
Library:
ph
Description:
This function sends an event notification to the client. The possible values of flags
include:
Pt_CONNECTION_NOTIFY_NOFLUSH
Unless you set this flag, PtConnectionNotify() calls PtConnectionFlush() if there
isn’t enough room for the notification in the buffer.
Pt_CONNECTION_NOTIFY_RESIZE
Resize the buffer if necessary.
Pt_CONNECTION_NOTIFY_FLUSH
If you set this flag, PtConnectionNotify() calls PtConnectionFlush() after
appending the notification to the buffer.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionAddEventHandlers(), PtConnectionAddMsgHandlers(),
PtConnectionFlush(), PtConnectionReply(), PtConnectionReplymx(),
PtConnectionResizeEventBuffer(), PtConnectionSend(), PtConnectionSendmx()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Library:
ph
Description:
The server in a connection uses these functions to reply to a message sent by a client
with a call to PtConnectionSend() or PtConnectionSendmx().
Under QNX 4, the iov_t type is a synonym for struct _mxfer_entry. The
riov[0] entry is reserved for headers used internally by the library; the “real” reply
buffer are defined by the contents of riov[1] through riov[rparts-1].
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionFlush(), PtConnectionNotify(), PtConnectionSend(),
PtConnectionSendmx()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
int PtConnectionResizeEventBuffer(
PtConnectionServer_t *connection,
unsigned length );
Library:
ph
Description:
This function allocates or reallocates a buffer that notifications are stored in until the
client responds to a pulse.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionAddEventHandlers(), PtConnectionNotify()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
int PtConnectionSendmx(
PtConnectionClient_t *connection,
unsigned long type,
int sparts,
iov_t *siov,
int rparts,
iov_t *riov );
Library:
ph
Description:
The client of a connection uses these functions to send a message to the server. The
server uses PtConnectionReply() and PtConnectionReplymx() to reply.
The arguments are similar to kernel functions, except that the message type isn’t
considered to be part of the message.
Under QNX 4, the iov_t type is a synonym for struct _mxfer_entry. The
siov[0] and riov[0] entries are reserved for headers used internally by the library; the
“real” message and reply buffer are defined by the contents of siov[1] through
siov[sparts-1] and riov[1] through riov[rparts-1].
Returns:
The number of bytes in the reply, or -1 if the send failed (errno is set).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
void PtConnectionServerDestroy(
PtConnectionServer_t *connection );
Library:
ph
Description:
This function destroys the server connection object. Attempting to send any messages
or notifications to a partner whose connection object has been destroyed isn’t safe;
preventing such attempts is the responsibility of a higher level protocol.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionClientDestroy(), PtConnectionServerGetUserData(),
PtConnectionServerSetError(), PtConnectionServerSetUserData()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
void *PtConnectionServerGetUserData(
PtConnectionServer_t *connection );
Library:
ph
Description:
A connection object contains a user data pointer that is passed to its message handlers.
This function lets you retrieve that pointer.
Returns:
A void * pointer to the data.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionClientGetUserData(), PtConnectionClientSetUserData(),
PtConnectionServerDestroy(), PtConnectionServerSetError(),
PtConnectionServerSetUserData()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
PtConnectionServerErrorFunc_t *
PtConnectionServerSetError(
PtConnectionServer_t *connection,
PtConnectionServerErrorFunc_t *func );
Library:
ph
Description:
This function sets up an error handling function for the server-side of a connection.
The prototype of the handler is:
Pt_CONNECTION_REPLY_FAILED
The MsgReply() to the client failed.
Pt_CONNECTION_REALLOC_RECEIVE
The realloc() failed to expand the receive buffer.
Pt_CONNECTION_SERVER_BROKEN
The client has died or closed its part of the connection.
Pt_CONNECTION_MSGREAD_FAILED
The MsgRead() from the client failed.
The error handler is called when certain errors occur; the handler can return
Pt_CONTINUE to retry, or Pt_END to fail. The default error handler returns Pt_END.
Returns:
A pointer to the previous error-handler function.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionClientSetError(), PtConnectionServerDestroy(),
PtConnectionServerGetUserData(), PtConnectionServerSetUserData()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
void PtConnectionServerSetUserData(
PtConnectionServer_t *connection,
void *data );
Library:
ph
Description:
A connection object contains a user data pointer that is passed to its message handlers.
This function lets you set that pointer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionClientGetUserData(), PtConnectionClientSetUserData(),
PtConnectionServerDestroy(), PtConnectionServerGetUserData(),
PtConnectionServerSetError()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
char *PtConnectionTmpName( char name[32] );
Library:
ph
Description:
This function creates a temporary name that can be given to a new server. The name
argument is the buffer in which to build the name.
If the same client may generate more temporary names in the future, the server should
destroy its connector as soon as the client has connected — currently, there’s only
room for a few unique temporary names per client.
Returns:
A pointer to name, or NULL if a name couldn’t be generated.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionFindId(), PtConnectionFindName(), PtConnectionWaitForName()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
typedef int PtConnectionWaitFunc_t(
PtConnectionClient_t *connection,
void *user_data,
unsigned n );
int PtConnectionWaitForName(
const char *name,
int subtype,
unsigned flags,
PtConnectionWaitFunc_t *cb,
void *usrdata );
Library:
ph
Description:
This function lets you set up a timer that periodically tries to connect to a server. This
mechanism is meant to be used when you might need to spawn the server and then
wait until it’s ready to accept a connection.
Each attempt consists of a call to PtConnectionFindName(), followed by a call to your
callback. The callback should check its connection argument: if it’s non-NULL, it
means that this attempt was successful. The callback should then set up the connection
object and return zero.
If the connection argument to your callback is NULL, the connection couldn’t been
established this time. The callback should return the number of milliseconds to wait
before making another attempt. Returning zero means “don’t retry.”
The n argument to the callback is just a serial number that gets incremented after each
failed attempt. It can be useful if you want to spawn the server after the first attempt
fails:
int connection_callback(
PtConnectionClient_t *connection,
void *user_data, unsigned n ) {
if ( connection )
PtConnectionAddEventHandlers( connection, tab, N );
else
switch ( n ) {
default :
return 200; /* retry after 1/5 of a second */
case 0 :
/* First attempt failed -- spawn the server */
if ( PtSpawn( ... ) > 0 )
return 1000; /* Retry after one second */
else
warn( "Couldn’t spawn the server" );
case 9 :
/* ten attempts failed -- give up */
;
}
return 0;
}
(A better way would be to let it keep trying until the spawned server terminates rather
than just have a fixed number of retries — but we’ll leave that as an exercise for the
reader.)
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectionFindId(), PtConnectionFindName(), PtConnectionTmpName(),
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
PtConnector_t *PtConnectorCreate(
const char *name,
PtConnectorCallbackFunc_t *cb,
void *data );
Arguments:
name The name to register, or NULL for a nameless connector. If name isn’t
NULL, it must be unique; an attempt to create a connector with a name
that’s already registered will fail.
The callback is called each time a new server connection object is created as
a response to a connection request from a client.
Library:
ph
Description:
This function creates a connector.
Returns:
A pointer to a PtConnector_t structure that describes the connector.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectorDestroy(), PtConnectorGetId()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
int PtConnectorDestroy( PtConnector_t *connector );
Library:
ph
Description:
This function destroys the given connector.
Destroying a connector doesn’t affect existing connections. If a server is only capable
of talking to one client, it’s a good idea to destroy the connector as soon as the client
has connected.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectorCreate(), PtConnectorGetId()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
PhConnectorId_t PtConnectorGetId(
PtConnector_t const *connector );
Library:
ph
Description:
This function obtains the connector ID that a client can pass to PtConnectionFindId()
in order to connect.
Returns:
The connector ID.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtConnectorCreate(), PtConnectorDestroy()
“Connections” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
int PtConsoleSwitch( int console );
Library:
ph
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()
Window Management chapter of the Photon Programmer’s Guide
Synopsis:
PtWidget_t * PtContainerBox( PtWidget_t *container,
PtWidget_t *start,
PhRect_t const *rect );
Library:
ph
Description:
This function returns a pointer to the first widget within the specified container that
intersects with the rectangle defined in the PhRect_t structure pointed to by rect.
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(), PhRect_t, PtContainerHit(), PtWidgetChildFront()
Synopsis:
PtWidget_t *PtContainerFindFocus(
PtWidget_t *family_member );
Library:
ph
Description:
This function finds the focused widget for the disjoint widget that contains
family_member, or the focused widget in family_member if family_member is a
disjoint widget. In other words, in a multi-window application, the function will find
the focused widget in the same window as 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 );
Library:
ph
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 is a pointer to a PhEvent_t structure that describes 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 is NULL, this function generates a PhEvent_t structure filled with zeros 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:
PhEvent_t, PtContainerFocusPrev(), PtContainerGiveFocus(),
PtContainerNullFocus()
Synopsis:
PtWidget_t *PtContainerFocusPrev(
PtWidget_t *widget,
PhEvent_t *event );
Library:
ph
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 is a pointer to a PhEvent_t structure that describes 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 is NULL, this function generates a PhEvent_t structure filled with zeros 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:
PhEvent_t, PtContainerFocusNext(), PtContainerGiveFocus(),
PtContainerNullFocus(), PtWidgetExtent()
Synopsis:
PtWidget_t *PtContainerGiveFocus(
PtWidget_t *widget,
PhEvent_t *event );
Library:
ph
Description:
This function gives focus to the specified widget, even if the widget’s
Pt_GETS_FOCUS flag isn’t set. PtContainerGiveFocus() is the same as PtGiveFocus().
If the widget is a PtWindow, use PtWindowFocus() instead of this function — see the
Photon Widget Reference.
The event argument is a pointer to a PhEvent_t structure that describes 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 is NULL, this function generates a
PhEvent_t structure filled with zeros 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 is blocked; that is, it has Pt_BLOCKED set in its Pt_ARG_FLAGS
resource (see PtWidget in the Photon Widget Reference).
• 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
This function could also return a pointer to a different widget if that widget for some
reason refused to relinquish focus (i.e. its Pt_CB_LOST_FOCUS callback returned
Pt_END — see PtBasic in the Photon Widget Reference). This usually happens if the
requirements of an entry field haven’t been met and must be met before any other
action can be taken.
The widget library never refuses to relinquish focus. If a widget does this, it’s because
of a Pt_CB_LOST_FOCUS callback in your application.
Examples:
#include <stdlib.h>
#include <Pt.h>
int main()
{
PtWidget_t *window, *texta, *textb, *textc,
*button;
PhPoint_t pos ={ 0, 0 };
PhArea_t area ={ {0, 0}, {100, 20} };
PhRect_t rect;
int n;
PtArg_t argt[5];
if (PtInit(NULL) == -1)
exit(EXIT_FAILURE);
n = 0;
PtSetArg( &argt[n], Pt_ARG_AREA, &area, 0 ); n++;
n = 0;
PtSetArg( &argt[n], Pt_ARG_AREA, &area, 0 ); n++;
PtSetArg( &argt[n], Pt_ARG_TEXT_STRING,
"Second Field", 0 ); n++;
textb = PtCreateWidget( PtText, Pt_DEFAULT_PARENT,
n, argt );
PtExtentWidget( textb );
PtWidgetExtent( textb, &rect );
area.pos.y = rect.lr.y + 10;
n = 0;
PtSetArg( &argt[n], Pt_ARG_AREA, &area, 0 ); n++;
PtSetArg( &argt[n], Pt_ARG_TEXT_STRING,
"Third Field", 0 ); n++;
textc = PtCreateWidget( PtText, Pt_DEFAULT_PARENT,
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_ARG_FLAGS, Pt_FALSE, Pt_GETS_FOCUS);
n++;
PtSetArg( &argt[n], Pt_ARG_TEXT_STRING,
"First", 0 ); n++;
button = PtCreateWidget( PtButton, Pt_DEFAULT_PARENT,
n, argt );
PtAddCallback (button, Pt_CB_ACTIVATE, first, (void *)texta);
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_ARG_FLAGS, Pt_FALSE, Pt_GETS_FOCUS);
n++;
PtSetArg( &argt[n], Pt_ARG_TEXT_STRING,
"Next", 0 ); n++;
button = PtCreateWidget( PtButton, Pt_DEFAULT_PARENT,
n, argt );
PtAddCallback (button, Pt_CB_ACTIVATE, next, NULL);
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_ARG_FLAGS, Pt_FALSE, Pt_GETS_FOCUS);
n++;
PtSetArg( &argt[n], Pt_ARG_TEXT_STRING,
"Prev", 0 ); n++;
button = PtCreateWidget( PtButton, Pt_DEFAULT_PARENT,
n, argt );
PtAddCallback (button, Pt_CB_ACTIVATE, prev, NULL);
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_ARG_FLAGS, Pt_FALSE, Pt_GETS_FOCUS);
n++;
PtSetArg( &argt[n], Pt_ARG_TEXT_STRING,
"None", 0 ); n++;
button = PtCreateWidget( PtButton, Pt_DEFAULT_PARENT,
n, argt );
PtAddCallback (button, Pt_CB_ACTIVATE, none, NULL);
PtRealizeWidget( window );
PtMainLoop();
return EXIT_SUCCESS;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEvent_t, PtContainerFocusNext(), PtContainerFocusPrev(),
PtContainerNullFocus(), PtGiveFocus()
PtWindowFocus() in the Photon Widget Reference
Synopsis:
PtWidget_t *PtContainerHit( PtWidget_t *container,
unsigned n,
PhRect_t const *rect );
Library:
ph
Description:
This function returns a pointer to the nth widget within the specified container that
intersects with the rectangle provided in the PhRect_t structure pointed to by rect.
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(), PhRect_t, PtContainerBox()
Synopsis:
int PtContainerHold( PtWidget_t *container_widget );
Library:
ph
Description:
This function increments the flux count for the given container, to prevent repairs to
the specified container and to all its children. You can still modify the widgets, but the
damage to them isn’t recorded.
You typically use this function when you’re about to make a lot of changes to the
container and its children, and you don’t want to update the display until you’re done.
When you want the container to be repaired, call PtContainerRelease().
Returns:
The container widget’s current flux count, or -1 if an error occurred.
Examples:
See PtClearWidget().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerRelease(), PtFlush(), PtIsFluxing()
“Delaying and forcing updates to the display” in the Working with Code chapter of the
Photon Programmer’s Guide
Synopsis:
PtWidget_t *PtContainerNullFocus(
PtWidget_t *widget,
PhEvent_t *event );
Library:
ph
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 is a pointer to a PhEvent_t, structure that describes 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 is NULL, this function generates a PhEvent_t structure filled with zeros 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:
PhEvent_t, PtContainerFocusNext(), PtContainerFocusPrev(),
PtContainerGiveFocus()
Synopsis:
int PtContainerRelease( PtWidget_t *container_widget );
Library:
ph
Description:
This function decrements the flux count for the specified container widget. To
increment the flux count (to delay updates to the display), call PtContainerHold().
When the count reaches 0, PtContainerRelease() repairs the widgets by damaging the
entire container.
Returns:
The container widget’s current flux count, or -1 if an error occurred.
Examples:
See PtClearWidget().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerHold(), PtFlush(), PtIsFluxing()
“Delaying and forcing updates to the display” in the Working with Code chapter of the
Photon Programmer’s Guide
Synopsis:
long PtCRC( const char *buffer,
int nbytes );
Library:
ph
Description:
This function generates a 32-bit cyclic redundancy check or CRC on the nbytes of data
pointed to by buffer.
We recommend that bitmaps and images have a CRC on the image data and the
palette. This CRC is used extensively by phrelay (see the QNX Neutrino Utilities
Reference) to cache images.
Returns:
The cyclic redundancy check.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCRCValue(), PxLoadImage()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
long PtCRCValue( long crc32val,
unsigned char next_val );
Library:
ph
Description:
This function lets you maintain your own 32-bit cyclic redundancy check or CRC
checksum. The crc32val is 0 or the value calculated by a previous call to
PtCRCValue(), while next_val is the next byte of data for which to calculate the CRC.
We recommend that bitmaps and images have a CRC on the image data and the
palette. This CRC is used extensively by phrelay (see the QNX Neutrino Utilities
Reference) to cache images.
Returns:
The cyclic redundancy check.
Examples:
This is a slower implementation of PtCRC() for a 512-byte data segment:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCRC(), PxLoadImage()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
PtSurface_t *PtCreateActionSurface(
PtWidget_t *widget,
unsigned char surface_id,
PtWidgetClassRef_t const *cref ,
unsigned short compound_action_id,
unsigned short flags,
unsigned short npoints,
PhPoint_t *points,
PtSurfaceDraw_f draw_f ,
PtSurfaceCalc_f calc_points_f );
Library:
ph
Description:
The function creates an action control surface within the given widget. The control
surface is bound to a widget action.
The surface_id argument lets you specify the ID assigned to the surface. If you
specify 0 for this argument, the next available surface ID for that widget is assigned to
the surface. If you specify a surface ID that already exists within the widget, the
function fails and returns 0.
The cref argument specifies the widget class that owns the action to which you’re
binding the surface. If you specify NULL for this argument, PtCreateActionSurface()
assumes that the action belongs to the same class as widget.
The compound_action_id argument specifies the action to bind to the surface. Refer
to the widget documentation for a list of actions that each widget supports.
The flags argument gives you additional control over how the surface behaves. The
valid bits are:
Pt_SURFACE_RELEASE_POINTS
The array of points specifying the widget’s geometry will be freed when the
surface is destroyed.
Pt_SURFACE_HIDDEN
Make the surface initially “hidden.” When surfaces are hidden, they don’t draw
or respond to events. You should manipulate this flag only when creating the
surface. To hide the surface after it’s created, use PtHideSurface() or
PtHideSurfaceByAction().
Pt_SURFACE_CONSUME_EVENTS
The surface always consumes the events it receives. Setting this bit makes a
surface opaque to events that it’s accepting, regardless of whether or not the
surface actually uses the event. This functionality may prove useful if you wish
to disable a portion of a widget.
Pt_SURFACE_DISABLED
Prevent a surface from taking any action as a result of an event. If this flag is set,
no events are consumed by the surface, unless the
Pt_SURFACE_CONSUME_EVENTS flag is set.
Pt_SURFACE_USE_ORIGIN
The surface should use an adjustable origin that allows you to change the
position of the surface without having to move the points that define the surface.
This feature is useful if the surface is defined by a large number of points.
Pt_SURFACE_PARENT_RELATIVE
By default, all events and drawing of a surface are relative to the upper-left
corner of the widget’s canvas. Setting this flag adjusts this origin so that the
surface uses the same coordinate system as its associated widget.
The npoints argument specifies the number of points that define the surface. Special
values for this argument include:
The damage argument points to a list of PhTile_t structures that specifies the areas
of the control surface that were damaged.
If you don’t want the surface to draw anything, specify NULL for draw_f .
Similarly, the calc_points_f argument lets you specify a geometry-calculation
function for the surface, which must be of the following prototype:
void calc_points_f ( PtWidget_t *widget,
PtSurface_t *surface,
unsigned char post );
If the widget’s extent depends on the geometry of a surface, you will want to perform
the work if post is 0. If the surface’s geometry depends on the widget’s extent, you
will want to perform the work if post is nonzero.
Returns:
A pointer to a PtSurface_t structure that describes the control surface, or NULL if
the operation failed due to lack of memory, or incorrect parameters.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhPoint_t, PhTile_t, PtCreateSurface(), PtDestroyAllSurfaces(),
PtDestroySurface()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
PtWidgetClassStyle_t *PtCreateClassStyle(
char *name );
Library:
ph
Description:
This function creates a new class style and calls the style name.
Returns:
A pointer to a new class style, or NULL if the wasn’t enough memory to create it.
Examples:
This example is based on the one in “Widget Styles” in the Managing Widgets in
Application Code chapter of the Photon Programmer’s Guide:
PtWidgetClassStyle_t *new_style =
PtCreateClassStyle("blue");
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddClassStyle(), PtDupClassStyle(), PtFindClassStyle(), PtGetStyleMember(),
PtGetWidgetStyle(), PtSetClassStyleMethods(), PtSetStyleMember(),
PtSetStyleMembers(), PtSetWidgetStyle()
Pt_ARG_STYLE resource of PtBasic in the Photon Widget Reference
“Widget Styles” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
PtSurface_t PtCreateSurface(
PtWidget_t *widget,
unsigned char surface_id,
unsigned short flags,
unsigned short npoints,
PhPoint_t *points,
long event_mask,
PtSurfaceCallback_f event_f ,
PtSurfaceDraw_f draw_f ,
PtSurfaceCalc_f calc_points_f );
Library:
ph
Description:
This function creates a regular control surface within the given widget.
The surface_id argument lets you specify the ID assigned to the surface. If you
specify 0 for this argument, the next available surface ID for that widget is assigned to
the surface. If you specify a surface ID that already exists within the widget, the
function fails and returns 0.
The flags argument gives you additional control over how the surface behaves. The
valid bits are:
Pt_SURFACE_RELEASE_POINTS
The array of points specifying the widget’s geometry will be freed when the
surface is destroyed.
Pt_SURFACE_HIDDEN
Make the surface initially “hidden.” When surfaces are hidden, they don’t draw
or respond to events. You should manipulate this flag only when creating the
surface. To hide the surface after it’s created, use PtHideSurface() or
PtHideSurfaceByAction().
Pt_SURFACE_CONSUME_EVENTS
The surface always consumes the events it receives. Setting this bit makes a
surface opaque to events that it’s accepting, regardless of whether or not the
surface actually uses the event. This functionality may prove useful if you wish
to disable a portion of a widget.
Pt_SURFACE_DISABLED
Prevent a surface from taking any action as a result of an event. If this flag is set,
no events are consumed by the surface, unless the
Pt_SURFACE_CONSUME_EVENTS flag is set.
Pt_SURFACE_USE_ORIGIN
The surface should use an adjustable origin that allows you to change the
position of the surface without having to move the points that define the surface.
This feature is useful if the surface is defined by a large number of points.
Pt_SURFACE_PARENT_RELATIVE
By default, all events and drawing of a surface are relative to the upper-left
corner of the widget’s canvas. Setting this flag adjusts this origin so that the
surface uses the same coordinate system as its associated widget.
The npoints argument specifies the number of points that define the surface. Special
values for this argument include:
The expected return values for event_f are consistent with those of raw callbacks:
The draw_f argument specifies a draw function for the surface, which must be of the
following prototype:
The damage argument points to a list of PhTile_t structures that specifies the areas
of the control surface that were damaged.
If you don’t want the surface to draw anything, specify NULL for draw_f .
Similarly, the calc_points_f argument lets you specify a geometry-calculation
function for the surface, which must be of the following prototype:
This function’s post argument indicates when the function is being called:
If the widget’s extent depends on the geometry of a surface, you will want to perform
the work if post is 0. If the surface’s geometry depends on the widget’s extent, you
will want to perform the work if post is nonzero.
Returns:
A pointer to a PtSurface_t structure that describes the control surface, or NULL if
the operation failed due to lack of memory, or incorrect parameters.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEvent_t, PhPoint_t, PhTile_t, PtCreateActionSurface(),
PtDestroyAllSurfaces(), PtDestroySurface()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
PtTransportCtrl_t *PtCreateTransportCtrl();
Library:
ph
Description:
This function creates and initializes a control structure for the request and inline
transport mechanism used for Drag and Drop. A widget that wants to act as the source
in a drag-and-drop operation typically calls PtCreateTransportCtrl() in its
Pt_CB_ARM callback.
Returns:
A pointer to the PtTransportCtrl_t structure, or NULL if it couldn’t be created.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDndFetch_t, PtDndSelect(), PtInitDnd(), PtReleaseTransportCtrl(),
PtTransportCtrl_t, PtTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
PtWidget_t *PtCreateWidget(
PtWidgetClassRef_t *class,
PtWidget_t *parent,
unsigned n_args,
PtArg_t const *args );
Library:
ph
Description:
This function creates a widget in the current widget hierarchy. The class argument
points to the desired widget class.
The parent argument specifies the parent widget. It can be a pointer to the parent
widget or one of:
• Pt_DEFAULT_PARENT — use the default parent, which is the most recently created
container.
• Pt_NO_PARENT
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 PtArg_t entries.
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.
Widgets that belong to the PtContainer class become the current parent widget
when created. If you’re creating multiple PtContainer-class widgets, make sure
each one is placed in the correct container. To do this, either specify the desired parent
in parent or call PtSetParentWidget().
Returns:
A pointer to the newly created widget, or NULL if an error occurs.
Examples:
#include <stdlib.h>
#include <Pt.h>
int main ()
{
PtWidget_t *window, *group1, *group2;
PhPoint_t pos;
PtArg_t argt[5];
if (PtInit(NULL) == -1)
exit(EXIT_FAILURE);
PtRealizeWidget (window);
PtMainLoop();
return EXIT_SUCCESS;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtArg_t, PtDestroyWidget(), PtGetParentWidget(), PtReparentWidget(), PtSetArg(),
PtSetParentWidget(), PtWidgetParent()
“Creating widgets” in the Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
int PtDamageExtent( PtWidget_t *widget,
PhRect_t const *extent );
Library:
ph
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. The
rectangle specified by the PhRect_t structure pointed to by extent is relative to the
widget’s origin.
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;
you don’t normally need to use this function unless you’re using a PtRaw widget and
want it to redraw and repair part or all of itself.
If you want the widget to be redrawn immediately, call PtFlush() after calling
PtDamageExtent().
Returns:
0 Success.
-1 An error occurred. This function fails if the widget isn’t a container and doesn’t
reside in a container, or if there isn’t enough memory to expand the damage list.
Examples:
See PhBlit().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRect_t, PtDamageWidget(), PtFlush()
Library:
ph
Description:
These functions flag a control surface to be redrawn. The widget argument specifies
the widget owning the surface. The functions differ in how they identify the control
surface:
PtDamageSurface()
Uses the surface argument, which points to a PtSurface_t structure that
describes the control surface. This pointer must not be NULL.
PtDamageSurfaceById()
Searches the control surfaces belonging to the widget for the one with an ID of
surface_id.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDamageSurfaceByAction()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
void PtDamageSurfaceByAction(
PtWidget_t *widget,
PtWidgetClassRef_t const *cref ,
unsigned short action_id );
Library:
ph
Description:
PtDamageSurfaceByAction() flags to be redrawn all surfaces belonging to the given
widget that are associated with an action. The cref and action_id specify the class and
manifest of the action associated with the surfaces to be damaged.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDamageSurface(), PtDamageSurfaceById()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
int PtDamageWidget( PtWidget_t *widget );
Library:
ph
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;
you don’t normally need to use this function unless you’re using a PtRaw widget and
want it to redraw and repair itself.
If you want the widget to be redrawn immediately, call PtFlush() after calling
PtDamageWidget().
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
Set some global variables used in a PtRaw widget’s draw function and then damage
the widget:
grid_color = Pg_BLACK;
line_color1 = Pg_BLUE;
line_color2 = Pg_RED;
PtDamageWidget( my_raw_widget );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDamageExtent(), PtFlush()
Synopsis:
void PtDestroyAllSurfaces( PtWidget_t *widget );
Library:
ph
Description:
This function destroys all control surfaces of the given widget.
Generally this function is used only internally by the widget library, however you may
call it if you wish.
All surfaces of a widget are automatically destroyed when the widget is destroyed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCreateActionSurface(), PtCreateSurface(), PtDestroySurface()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
void PtDestroySurface( PtWidget_t *widget,
PtSurface_t *surface );
Library:
ph
Description:
This function destroys the control surface specified by surface belonging to the given
widget.
All surfaces of a widget are automatically destroyed when the widget is destroyed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCreateActionSurface(), PtCreateSurface(), PtDestroyAllSurfaces(),
PtDestroySurfaceById()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
int PtDestroySurfaceById( PtWidget_t *widget,
unsigned char surface_id );
Library:
ph
Description:
This function destroys the control surface with ID surface_id belonging to the given
widget.
All surfaces of a widget are automatically destroyed when the widget is destroyed.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCreateActionSurface(), PtCreateSurface(), PtDestroyAllSurfaces(),
PtDestroySurface()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
int PtDestroyWidget( PtWidget_t *widget );
Library:
ph
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 PtContainerBox().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtEventHandler(), PtCreateWidget(), PtRealizeWidget(), PtUnrealizeWidget(),
PtWidgetFlags()
Pt_ARG_FLAGS, Pt_CB_DESTROYED, Pt_CB_IS_DESTROYED resources of
PtWidget in the Widget Reference
“Widget life cycle” in the Introduction to the Photon Programmer’s Guide
Library:
ph
Description:
These functions disable a control surface belonging to the given widget.
PtDisableSurface()
Uses the surface argument, which points to a PtSurface_t structure that
describes the control surface. This pointer must not be NULL.
PtDisableSurfaceById()
Searches the control surfaces belonging to the widget for the one with an ID of
surface_id.
Disabled surfaces are drawn, but they don’t respond to events. They do or don’t
consume events to which they’re sensitive, depending on the setting of their
Pt_SURFACE_CONSUME_EVENTS flag. If this bit is set, the surface effectively blocks
events to which it’s sensitive.
The flags argument specifies additional action to take, and may include the following
values:
Pt_DAMAGE_SURFACE
Damage the surface if its state changes. This is useful if a surface draws
differently depending on its enabled/disabled state.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
KG.
See also:
PtDisableSurfaceByAction(), PtEnableSurface(), PtEnableSurfaceByAction(),
PtEnableSurfaceById(), PtSurfaceIsDisabled(), PtSurfaceIsEnabled()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
void PtDisableSurfaceByAction(
PtWidget_t *widget,
PtWidgetClassRef_t const *cref ,
unsigned short action_id,
unsigned long flags );
Library:
ph
Description:
This function disables all surfaces belonging to the given widget that are associated
with an action. The cref and action_id specify the class and manifest of the action
associated with surfaces to be disabled.
Disabled surfaces are drawn, but they don’t respond to events. They do or don’t
consume events to which they’re sensitive, depending on the setting of their
Pt_SURFACE_CONSUME_EVENTS flag. If this bit is set, the surface effectively blocks
events to which it’s sensitive.
The flags argument specifies additional action to take, and may include the following
values:
Pt_DAMAGE_SURFACE
Damage the surface if its state changes. This is useful if a surface draws
differently depending on its enabled/disabled state.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDisableSurface(), PtDisableSurfaceById(), PtEnableSurface(),
PtEnableSurfaceByAction(), PtEnableSurfaceById(), PtSurfaceIsDisabled(),
PtSurfaceIsEnabled()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
typedef struct ptdndfetch PtDndFetch_t;
struct ptdndfetch {
char *type_name;
char *description;
int unsigned transport;
int unsigned select_flags;
void *user_data;
PtSelectFunc_t *select_cb;
PtRequestFunc_t *request_cb;
TransportMalloc_t *transport_malloc;
void *transport_malloc_cb_data;
};
Description:
The PtDndFetch_t structure is used to define the data types a widget accepts from a
drag-and-drop event. It contains at least the following members:
type_name A string that must match the type string in the data being
dropped.
select_cb If provided, this callback is invoked and its return value is used
to determine if a piece of the data being dragged should be
selected for drop acceptance or not. The return value of the
function must be a transport type to select the data, or 0 to
prevent that data from being unpacked on a drop event. See
<PhTransport.h> for the defined transport types.
request_cb An optional callback that’s called before asking the source for
data. The parameters of the data request can be modified in the
callback, or the request can be canceled altogether.
transport_malloc_cb_data
Data that’s passed to the transport_malloc function.
Classification:
Photon
See also:
PtCreateTransportCtrl(), PtDndSelect(), PtInitDnd(), PtTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
int PtDndSelect(
PtWidget_t *widget,
PtDndFetch_t *data_array,
int unsigned array_size,
PhCursorDescription_t *accept_cursor,
PhCursorDescription_t *reject_cursor,
PtCallbackInfo_t *cbinfo );
Arguments:
widget A pointer to the widget involved in the drag-and-drop event.
accept_cursor The cursor that’s displayed if some data from the drag-and-drop
event is selected. If this argument is NULL, the default accept
cursor is used.
reject_cursor The cursor that’s displayed if no data from the drag-and-drop event
is selected. If this argument is NULL, the default reject cursor is
used.
Library:
ph
Description:
This function selects the drag-and-drop data from the event found in the cbinfo that
matches the selection criteria in data_array.
Returns:
The number of elements selected from the drag-and-drop event.
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PtCreateTransportCtrl(), PtDndFetch_t, PtInitDnd(), PtTransportType()
PtCallbackInfo_t in the Photon Widget Reference
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
PtWidgetClassStyle_t * PtDupClassStyle(
PtWidgetClassRef_t * const ref ,
char const * const name,
char const * const new_name );
Library:
ph
Description:
This function obtains a copy of the style called name in the widget class ref , and sets
the copy’s name to new_name. You can modify this new style and/or add it as a new
style to the widget class from which the style was duplicated.
Returns:
A pointer to the copy of the specified class style, or NULL if the specified style didn’t
exist or there wasn’t enough memory to create the duplicate.
Examples:
See “Widget Styles” in the Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddClassStyle(), PtCreateClassStyle(), PtFindClassStyle(), PtGetStyleMember(),
PtGetWidgetStyle(), PtSetClassStyleMethods(), PtSetStyleMember(),
PtSetStyleMembers(), PtSetWidgetStyle(),
Pt_ARG_STYLE resource of PtBasic in the Photon Widget Reference
“Widget Styles” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
void PtEnableSurface( PtWidget_t *widget,
PtSurface_t *surface,
unsigned long flags );
Library:
ph
Description:
These functions enable a control surface, restoring it from a disabled state. The widget
argument specifies the widget owning the surface. The functions differ in the way they
identify the control surface:
The flags argument specifies additional action to take, and may include the following
values:
Pt_DAMAGE_SURFACE
Damage the surface if its state changes. This is useful if a surface draws
differently depending on its enabled/disabled state.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDisableSurface(), PtDisableSurfaceByAction(), PtDisableSurfaceById(),
PtEnableSurfaceByAction(), PtSurfaceIsDisabled(), PtSurfaceIsEnabled()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
void PtEnableSurfaceByAction(
PtWidget_t *widget,
PtWidgetClassRef_t const *cref ,
unsigned short action_id,
unsigned long flags );
Library:
ph
Description:
This function enables all surfaces associated with an action, restoring them from a
disabled state.
The widget argument specifies the widget owning the surfaces, while cref and
action_id specify the class and manifest of the action associated with surfaces to be
enabled.
The flags argument specifies additional action to take, and may include the following
values:
Pt_DAMAGE_SURFACE
Damage the surface if its state changes. This is useful if a surface draws
differently depending on its enabled/disabled state.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDisableSurface(), PtDisableSurfaceByAction(), PtDisableSurfaceById(),
PtEnableSurface(), PtEnableSurfaceById(), PtSurfaceIsDisabled(),
PtSurfaceIsEnabled()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
int PtEndFlux( PtWidget_t *container );
Library:
ph
Description:
This function decrements the given container’s flux count. If the container’s flux count
is 0 or becomes 0 due to the decrement, the container and its children can be repaired.
Returns:
The container widget’s current flux count, or -1 if an error occurred.
When the flux count goes to 0, you must manually call PtDamageExtent() and/or
PtDamageWidget() to damage any widgets or areas that you want to be repaired.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDamageExtent(), PtDamageWidget(), PtIsFluxing(), PtStartFlux()
“Delaying and forcing updates to the display” in the Working with Code chapter of the
Photon Programmer’s Guide
Synopsis:
int PtEnter( int flags );
Arguments:
The value of flags can be 0 or one of:
Pt_EVENT_PROCESS_ALLOW
Consider the calling thread an event reader.
Pt_EVENT_PROCESS_PREVENT
Consider the calling thread a nonreader.
In most cases, it’s better to set neither of these bits in flags, in which case the thread’s
status as event reader or nonreader doesn’t change. For more information about
changing a thread’s event reader status, see “Threads” in the Parallel Operations
chapter of the Photon Programmer’s Guide.
You can OR the following into the flags:
Library:
ph
Description:
This function gives the calling thread access to the Photon library by “locking the
library.” If another thread has already locked the library, PtEnter() blocks until the
library is unlocked.
Since Photon functions aren’t thread-safe, any thread other than the one that called
PtInit() must call PtEnter() before trying to call any other Photon functions. After
you’re done, call PtLeave() to give other threads access to the library.
PtProcessEvent() unlocks the library before waiting for an event, and locks it back
after. If you’re calling PtProcessEvent() or any other function that processes Photon
events (like PtBkgdHandlerProcess() or PtModalBlock()), other threads may enter and
leave the library while you’re waiting for an event. The same applies to PtCondWait()
and PtCondTimedWait(), even though these functions don’t process Photon events.
Mixing threads and work procedures might cause a minor problem; if one of the other
threads adds a workproc while another thread is already waiting for an event, the
workproc might not be invoked until you receive an event.
As with other Pt functions, you have to make sure that PtInit() has been called (and
succeeded) before you can call PtEnter().
The lock implemented by PtEnter() and PtLeave() isn’t recursive (in the way that
mutexes can be recursive). If you call PtEnter() twice without calling PtLeave() in
between, the second call to PtEnter() fails and returns the negative of EDEADLK.
If another thread has called PtExit() before you call PtEnter(), or calls PtExit() while
PtEnter() is waiting for the lock to become available, the Pt_DELAY_EXIT flag
ensures that PtExit() will return and allow the calling thread to keep running. Without
this flag, PtEnter() does not return if another thread has called PtExit().
Returns:
0 Success. and the state of the thread didn’t change.
>0 Success, and the state of the thread changed. The return value can be a
combination of:
• Pt_EVENT_PROCESS_ALLOW—The thread was a reader, and PtEnter()
was called with flags set to Pt_EVENT_PROCESS_PREVENT.
• Pt_EVENT_PROCESS_PREVENT—The thread was a nonreader, and
PtEnter() was called with flags set to Pt_EVENT_PROCESS_ALLOW .
• Pt_DELAY_EXIT—For both the current call to PtEnter() and the previous
call to PtLeave(), flags was set to Pt_DELAY_EXIT.
Some functions will reset the Pt_DELAY_EXIT flag bit for the thread to 0, which will
affect the return value. These functions are PtCondWait(), PtCondTimedWait(), and
any function that reads and processes an event (such as PtProcessEvent() or
PtModalBlock()).
<0 An error occurred; the value is a negative error code.
Errors:
If an error occurs, PtEnter() returns the negative of:
Examples:
You can test whether you have the Photon Library locked by evaluating PtEnter(). If
the Photon Library is already locked, PtEnter() will fail with an error of -EDEADLK.
When PtLeave() is called with a negative value, it is guaranteed to fail, so in this
example the Photon Library has the same lock state as it had before the call to
PtEnter():
int eval;
if ((eval = PtEnter(0)) < 0 && eval != -EDEADLK)
fprintf( stderr, ‘‘Couldn’t enter: %s\n‘‘,
strerror( -eval ) );
else
{
PtSetResource(w, Pt_ARG_WINDOW_TITLE, text, 0);
PtLeave(eval); // does nothing if eval == -EDEADLK
}
In this example, the Photon Library is locked elsewhere, and you want to unlock it to
perform some lengthy operation, such as in a widget callback where not unlocking the
library would “freeze” the GUI for the duration of the operation:
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PtCondTimedWait(), PtCondWait(), PtExit(), PtInit(), PtLeave(), PtProcessEvent()
pthread_mutex_lock() in the QNX Neutrino Library Reference
“Threads” in the Parallel Operations chapter of the Photon Programmer’s Guide
Synopsis:
int PtEventHandler( PhEvent_t *event );
Library:
ph
Description:
This function determines which widgets were involved in the given 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:
The value returned by the last callback function invoked by the event, or -1 if an error
occurred.
Examples:
See PhEventNext().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEvent_t, PhEventNext(), PhEventPeek(), PhEventRead(), PtSendEventToWidget()
Synopsis:
void PtExit( int return_code );
Library:
ph
Description:
This function is similar to exit(), except that PtExit() properly destroys all your
application’s widgets before exiting.
In a multithreaded application, a callback can call PtExit() in one thread while a
second thread might be in the middle of an important operation, such as writing a file.
To prevent the second thread from terminating early, call PtPreventExit() before
starting the operation, and call PtAllowExit() when it’s done.
Instead of calling PtPreventExit() and PtAllowExit() directly, you’re better off calling
PtEnter() and PtLeave() with Pt_DELAY_EXIT set in the flags, because the
Pt_DELAY_EXIT flag may not cause your application to lock up in some situations
where PtPreventExit() would. For a discussion of the difference between these
functions and using Pt_DELAY_EXIT, see “Exiting a multithreaded program” in the
Parallel Operations chapter of the Photon Programmer’s Guide.
However, if you create a widget or add a Pt_CB_APP_EXIT callback inside a
PtEnter(Pt_DELAY_EXIT) section, and another thread has already called PtExit(),
there’s no guarantee that the new widget will be destroyed, or the new callback called.
The callbacks in Pt_CB_APP_EXIT are called only once, even if PtExit() is called
multiple times (for example by multiple threads, or recursively from a
Pt_CB_APP_EXIT callback).
3 Enters the delayed exit state. In this state, the function waits for the counter
associated with the PtPreventExit() function and the Pt_DELAY_EXIT flag to
reach zero, if it’s not zero. If its value is nonzero, PtExit() unlocks the library
using an equivalent of PtLeave(0) (notice that this will decrement the counter
if the Pt_DELAY_EXIT flag is in effect for the calling thread) and waits until the
counter reaches zero. If PtExit() is called again by another thread, that second
call also unlocks the library and blocks until the first call terminates the process.
Returns:
This function doesn’t return.
Classification:
Photon
Safety
Cancellation point No
Interrupt handler No
Signal handler Not applicable
Thread Yes
See also:
PtAllowExit(), PtEnter(), PtLeave(), PtPreventExit()
exit() in the QNX Neutrino Library Reference
Synopsis:
PtWidget_t *PtExtentWidget( PtWidget_t *widget );
Library:
ph
Description:
This function forces the specified widget to calculate its preferred size and apply its
resize policy.
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()
“Widget geometry” in the Introduction to the Photon Programmer’s Guide
Synopsis:
int PtExtentWidgetFamily( PtWidget_t *widget );
Library:
ph
Description:
This function forces the specified widget and all its descendants to calculate their
preferred sizes and apply their resize policies.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtExtentWidget(), PtReRealizeWidget(), PtWidgetExtent()
“Widget geometry” in the Introduction to the Photon Programmer’s Guide
Synopsis:
typedef int PtFdProcF_t( int fd,
void *data,
unsigned mode );
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;
The compiler should detect any inconsistencies between the two declarations of
my_fd_proc() and give you an error (which is better than a “pointer mismatch”
warning on the call to PtAppAddFd()).
Classification:
Photon
See also:
PtAppAddFd()
“Other I/O mechanisms” in the Interprocess Communication chapter of the Photon
Programmer’s Guide
Synopsis:
int PtFepCmd( PtWidget_t *widget,
long cmd,
long sub_cmd,
char const *data );
Arguments:
widget A pointer to the widget on which you want any text-input boxes to
appear.
cmd The command that you want to send to the FEP; one of:
• Ph_FEP_CHANGE_MODE — change to the mode specified by the
string pointed to by data.
The data string must be a null-terminated UTF-8 string that’s
identical to the string that the FEP’s GUI displays in the
mode-selection buttons.
• Ph_FEP_HELP — invoke the FEP’s help routine. This command
doesn’t require any extra data, so you should pass NULL for the data
argument.
• Ph_FEP_TOGGLE_1 — toggle the FEP’s mode. This is usually the
same as pressing Alt-˜ in the FEP. This command doesn’t require any
extra data, so you should pass NULL for the data argument.
data A pointer to any extra data that the specific command needs.
Library:
ph
Description:
PtFepCmd() lets you control a Photon front-end processor (FEP) from an application.
This function lets you create your own front-end processor that includes all of the
functionality of the GUI versions of the FEPs.
To use this function, start the FEP with the -h option to suppress the GUI interface.
For more information, see the documentation for cpim and vpim.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
cpim, vpim
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 );
Arguments:
parent The dialog’s parent, which can be NULL. It’s used with the pos argument
to position the dialog.
title The dialog’s title. If NULL, the function uses the string File
Selector.
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. PtFileSelection() parses
the string and uses the longest existing path as the root directory. The
function uses rest of the string as a suggested path to be displayed in the
Name field.
file_spec The file specification to look for. The default is * if this argument 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.
If you want to have a hotkey for this button, place an ampersand (&) in
front of the appropriate character in the string. For example, to have the
string Select with s as a hotkey, pass &Select as btn1.
btn2 The string for button 2 (the default is Cancel). When activated, it sets
info->ret to Pt_FSDIALOG_BTN2. If you want to have a hotkey for this
button, place an ampersand (&) in front of the appropriate character in
the string.
info This is a mandatory parameter. The function returns the selected file in
the path portion of this structure. For more information, see
“PtFileSelectionInfo_t structure,” below.
flags Flags that affect the appearance and behavior of the dialog. The default
is 0; you can OR together any of the following bits:
Pt_FSR_MULTIPLE Let the user select more than one file or directory
at a time.
Pt_FSR_NO_FCHECK
Permit nonexistent files/directories to be selected.
(The path must exist.)
Pt_FSR_NO_FSPEC Don’t display the file specification.
Pt_FSR_NO_UP_BUTTON
Don’t display the up-directory button.
Pt_FSR_NO_NEW Disable new directory creation via the Insert key.
Pt_FSR_NO_NEW_BUTTON
Don’t display the new-directory button.
Pt_FSR_NO_SELECT_FILES
Files aren’t selectable.
Pt_FSR_SELECT_DIRS
Directories are selectable.
Pt_FSR_CREATE_PATH
Create directories as needed when typed in
manually.
Pt_FSR_NO_CONFIRM_CREATE_PATH
Don’t confirm directory creation.
Pt_FSR_NO_DELETE
Disable deletions via the Delete key.
Pt_FSR_NO_CONFIRM_DELETE
Don’t confirm deletions.
Pt_FSR_RECURSIVE_DELETE
Enable the recursive deletion of directories.
Pt_FSR_CONFIRM_EXISTING
Confirm the selection of an existing file with an
message.
You can also OR in the following bits, which affect the appearance and
behavior of the PtFileSel widget in the dialog. Each of these bits
corresponds to a flag in the Pt_ARG_FS_FLAGS resource of the
PtFileSel widget:
Pt_FSR_DONT_SHOW_DIRS
Don’t display directories.
Pt_FSR_DONT_SHOW_FILES
Don’t display files.
Pt_FSR_SHOW_HIDDEN
Show hidden directory entries (i.e. those whose names
begin with a period).
Pt_FSR_SHOW_ERRORS
Display (with a special icon) directory entries that had a
read error.
Pt_FSR_FREE_ON_COLLAPSE
Free items on every collapse. This means that every
time a directory expands, its content is reread from the
disk.
Pt_FSR_TREE Display the directory entries in a tree. By default,
entries are displayed in a single level.
Pt_FSR_NO_SEEK_KEY
Disable keyboard-seek in single-level mode. The
default is to allow key-seeks by typing a single
character.
Pt_FSR_NO_ROOT_DISPLAY
Don’t display a root directory item in tree display
mode. By default, when Pt_FSR_TREE is set, a root
directory item is shown.
Pt_FSR_CASE_INSENSITIVE
Make the file-specification pattern-matching insensitive
to case.
Pt_FSR_NO_ERROR_POPUP
Don’t pop up an error dialog when unable to open a
directory.
Library:
ph
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.
You can specify the dimensions of the dialog by setting the info->dim field before
calling this function.
This function can select directories as well as files. Enable directory selection with the
Pt_FSR_SELECT_DIRS flag. Existing directories can be selected with btn1 (the Open
button).
PtFileSelection() can create and delete directories and delete files. You can create new
directories at any time by pressing the New button. When the PtFileSel widget has
focus, these hotkeys are activated:
• The Insert key creates a new directory, just like the New Directory button.
• The Delete key removes the currently selected item. If you’ve set
Pt_FSR_MULTIPLE in the flags argument, the Delete key tries to delete all the
selected items. A separate delete-confirmation/delete-error dialog is presented for
each selected item, and the dialog has four buttons: Cancel, Delete, Skip, and
Delete All.
PtFileSelectionInfo_t structure
The PtFileSelectionInfo_t structure includes at least the following members:
PhDim_t dim A PhDim_t structure that defines the dimensions of the dialog
when the selection was completed. You can specify the size of
the dialog by setting this field before calling PtFileSelection().
PhPoint_t pos The position of the dialog when the selection was completed.
char format[80] The format string of the dialog when the selection was
completed.
char fspec[80] The file specification of the dialog when the selection was
completed.
void *user_data User data to pass as the data argument to the confirm_display,
confirm_selection, and new_directory functions.
int (*confirm_display) ( PtWidget_t *widget, void *data, PtCallbackInfo_t
*cbinfo)
A function to be called before an item is added to the file
selector. If this member isn’t NULL, it must point to a function.
The members of the PtCallbackInfo_t structure are used as
follows:
• reason — Pt_CB_FSR_DISPLAY
• cbdata— a pointer to a PtFileSelectorInfo_t structure
(see below).
This function should return Pt_CONTINUE or Pt_END to
indicate whether or not the item should be displayed in the file
selector.
int (*confirm_selection) ( PtWidget_t *widget, void *data,
PtCallbackInfo_t *cbinfo)
A function that’s called when the user has made a final
selection of a directory item by double-clicking on an item in
the file selector, pressing Enter in the Name box, or clicking on
the Open button. If this member isn’t NULL, it must point to a
function.
The members of the PtCallbackInfo_t structure are used as
follows:
• reason — Pt_CB_FSR_SELECTION
• reason_subtype — Pt_FSR_MULTIPLE if you’ve permitted
multiple selections, 0 otherwise.
• cbdata— a pointer to a PtFileSelectorInfo_t structure
(see below).
If reason_subtype is Pt_FSR_MULTIPLE, the following
members of the PtFileSelectorInfo_t structure are valid:
• nitems — the number of items
• items — the array items; items[n]->fullpath is the file
specification of the nth selected item.
If confirm_selection returns Pt_CONTINUE, PtFileSelection()
exits. If confirm_selection returns Pt_END, PtFileSelection()
doesn’t exit, the selector stays on the screen, and the user must
choose another file or directory.
Applications can use this function to screen selections and
avoid having to call PtFileSelection() repeatedly.
PtFileSelectorInfo_t structure
PtFileSelection() passes the PtFileSelectorInfo_t structure as a parameter to the
confirm_display, confirm_selection and new_directory functions.
char *path The full path of the directory item. This member is valid only if you
haven’t set Pt_FSR_MULTIPLE in the flags argument to
PtFileSelection().
struct stat *statbuf
A pointer to the same buffer as lstatbuf if lstat() succeeded and the
file isn’t a symbolic link. If the file is a symbolic link according to
lstat() (or, perhaps, if lstat() failed), stat() is called, and statbuf
points to its results — or is NULL if stat() fails.
int nitems The number of selected items if you’ve set Pt_FSR_MULTIPLE in the
flags argument to PtFileSelection().
char **multipath
The full path of each selected item if you’ve set Pt_FSR_MULTIPLE.
FileSelItem_t **items
An array of the selected items if you’ve set Pt_FSR_MULTIPLE.
Returns:
0 Success.
-1 An error occurred.
Examples:
/*************************************
* fsel.c
*
* Sample program that illustrates usage of
* the PtFileSelection() convenience function.
*
* Compile as follows:
#include <stdio.h>
#include <stdlib.h>
#include <Ph.h>
#include <Pt.h>
if ( info.ret == Pt_FSDIALOG_BTN1 )
fprintf( stderr,
"\nOpen button was pressed. The selected file is:\n\t%s\n",
info.path );
else
fprintf( stderr, "\nCancel button was pressed.\n" );
PtExit( 0 );
return EXIT_SUCCESS;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhDim_t, PtArg_t
PtFileSel in the Photon Widget Reference
“Dialog modules” in the Working with Modules chapter of the Photon Programmer’s
Guide
Synopsis:
PtWidget_t *PtFindChildClass(
PtWidgetClassRef_t *class,
PtWidget_t *widget );
Library:
ph
Description:
This function searches the widget family hierarchy of the given container, widget, for a
descendant widget that matches the specified class.
Returns:
A pointer to a PtWidget_t structure, or NULL if an error occurs.
Examples:
#include <stdlib.h>
#include <Pt.h>
int main()
{
PtArg_t argt;
PtWidget_t *window, *pane, *button;
if (PtInit(NULL) == -1)
exit(EXIT_FAILURE);
return EXIT_SUCCESS;
}
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 );
Library:
ph
Description:
This function searches the widget family hierarchy of the given container, widget, for a
descendant widget 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
Signal handler No
Thread No
See also:
PtWidgetBrotherBehind(), PtWidgetBrotherInFront(), PtWidgetChildBack(),
PtWidgetFamily(), PtWidgetParent()
Synopsis:
PtWidgetClassStyle_t *PtFindClassStyle(
PtWidgetClassRef_t *ref ,
char *name );
Library:
ph
Description:
This function returns a pointer to the style called name from the widget class ref . If
the name is NULL, PtFindClassStyle() returns a pointer to the default style for the
provided class.
Returns:
A pointer to the style, or NULL if it wasn’t found.
Examples:
Return a pointer to the default style for PtButton:
PtWidgetClassStyle_t *stylep;
PtWidgetClassStyle_t *stylep;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddClassStyle(), PtCreateClassStyle(), PtDupClassStyle(), PtGetStyleMember(),
PtGetWidgetStyle(), PtSetClassStyleMethods(), PtSetStyleMember(),
PtSetStyleMembers(), PtSetWidgetStyle()
Synopsis:
PtWidget_t *PtFindContainer( PtWidget_t *widget );
Library:
ph
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 );
Library:
ph
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 to
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 );
Library:
ph
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
• PtBkgd
• 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 );
Library:
ph
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(), PtFindFocusNextFrom(), PtFindFocusPrevFrom()
Synopsis:
PtWidget_t *PtFindFocusNextFrom(
PtWidget_t *widget );
Library:
ph
Description:
This function returns a pointer to the next widget that can get focus above the provided
widget. If there are no such widgets above the provided widget, the search wraps
around to the backmost widget that can get focus.
Returns:
A pointer to the next widget that can get focus.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFindFocusChild(), PtFindFocusPrevFrom()
Synopsis:
PtWidget_t *PtFindFocusPrevFrom(
PtWidget_t *widget );
Library:
ph
Description:
This function returns a pointer to the previous widget that can get focus behind the
provided widget. If there are no such widgets below the provided widget, the search
wraps around to the frontmost widget that can get focus.
Returns:
A pointer to the previous widget that can get focus.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFindFocusChild(), PtFindFocusNextFrom()
Synopsis:
PtWidget_t *PtFindGuardian( PtWidget_t *child,
int superior_only );
Library:
ph
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()
“Ordering widgets” in the Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
void * PtFindNextData( PtDataHdr_t **ptr,
PtDataHdr_t *data,
long type,
long subtype,
long *len,
PtDataHdr_t **_node );
Library:
ph
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 to
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:
PtSurface_t *PtFindSurface( PtWidget_t *widget,
unsigned char surface_id );
Library:
ph
Description:
This function locates a control surface belonging to a given widget, using the surface’s
numerical ID, surface_id, as a search key.
Returns:
A pointer to the structure representing the control surface, or NULL if the specified
surface couldn’t be found.
Since control surfaces are maintained internally as an array, it’s not uncommon for
them to shift around in memory as surfaces are added and removed, thereby possibly
invalidating a pointer returned by this function. As such, all surface pointers should be
regarded as transient, and you should retrieve an updated copy whenever there’s a
chance that the widget’s surface configuration might have changed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFindSurfaceByAction(), PtWidgetActiveSurface()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
PtSurface_t *PtFindSurfaceByAction(
PtWidget_t *widget,
PtWidgetClassRef_t const *cref ,
unsigned short action_id,
PtSurface_t const *surface );
Library:
ph
Description:
This function locates a control surface using its associated action as a search key.
The widget argument specifies the widget to search, while cref and action_id specify
the class and manifest of the action to seek. The surface argument specifies the surface
at which to start the search, letting you find all the surfaces in a widget associated with
a particular action. If this argument is NULL, the search begins at the first surface
within the widget.
This function ignores regular surfaces (i.e. those created using PtCreateSurface() as
opposed to PtCreateActionSurface()).
Returns:
A pointer to the structure representing the control surface, or NULL if no more
surfaces associated with the specified action could be found.
Since control surfaces are maintained internally as an array, it’s not uncommon for
them to shift around in memory as surfaces are added and removed, thereby possibly
invalidating a pointer returned by this function. As such, all surface pointers should be
regarded as transient, and you should retrieve an updated copy whenever there’s a
chance that the widget’s surface configuration might have changed.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFindSurface(), PtWidgetActiveSurface()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
int PtFlush( void );
Library:
ph
Description:
This function ensures that any widget damage is repaired, 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.
PtFlush() ignores and doesn’t affect the application’s hold count. For more
information, see “Delaying and forcing updates to the display” in the Working with
Code chapter of the Photon Programmer’s Guide.
Returns:
The new value of the global hold count.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgFlush(), PtHold(), PtRelease()
“Delaying and forcing updates to the display” in the Working with Code chapter of the
Photon Programmer’s Guide
Synopsis:
char *PtFontSelection( PtWidget_t *parent,
const PhPoint_t *pos,
const char *title,
const char *font,
long symbol,
unsigned flags,
const char *sample);
Library:
ph
Description:
This function displays a modal dialog that lets you select a text font.
A font-selection dialog.
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. If this argument is NULL, the
initial font is TextFont09. Otherwise, it should point to a font name created by
PfGenerateFontName().
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:
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.
Examples:
const char *fontname;
PhPoint_t pos= {10, 23};
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfGenerateFontName(), PhPoint_t
PtFontSel in the Photon Widget Reference
“Dialog modules” in the Working with Modules chapter, and the Fonts chapter of the
Photon Programmer’s Guide
Synopsis:
int PtForwardWindowEvent(
PhWindowEvent_t const *window_event );
Library:
ph
Description:
This function forwards the provided window event to the window manager, which
forwards it to the window whose region ID is specified in the event.
Returns:
0 Success.
Examples:
int give_a_window_focus( PtWidget_t *widget )
{
PhWindowEvent_t WE;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhWindowEvent_t, PtForwardWindowTaskEvent()
Synopsis:
int PtForwardWindowTaskEvent(
PhConnectId_t task,
PhWindowEvent_t const *evt);
Library:
ph
Description:
This function forwards a window event to the task with a given Photon connection ID.
It’s similar to PtForwardWindowEvent().
You can get the Photon connection ID from the information that you get from
PhGetConnectInfo(). PtForwardWindowTaskEvent() forwards the event to the main
window for the task.
In addition to the window-event types described for the PhWindowEvent_t structure,
you can specify a special pseudo-event, Ph_WM_SUPERSELECT. If you forward this
type of event to a task, the window manager moves the window and any child
windows to the current console, puts them in front of any other windows, and gives
focus to the first nonblocked window.
Returns:
0 Success.
-1 An error occurred.
Examples:
See “Getting and setting the window state” in the Window Management chapter of the
Photon Programmer’s Guide.
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
“Getting and setting the window state” in the Window Management chapter of the
Photon Programmer’s Guide.
Synopsis:
void PtGetAbsPosition( PtWidget_t *widget,
short *x,
short *y );
Library:
ph
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 );
Library:
ph
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.
Returns:
The control flags.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Synopsis:
int PtGetDndFetchIndex(
const PtDndCallbackInfo_t * cbinfo,
const PtDndFetch_t * data_array,
unsigned array_size);
Arguments:
dndcb A pointer to the drag-and-drop callback data.
Library:
ph
Description:
This function determines if the drag-and-drop data from the event found in the
PtDndCallbackInfo_t matches any of the transport types in the data_array.
Returns:
The index in the data_array for drag-and-drop event
A match was found.
-1 No entry is found.
Examples:
In this example, we determine the index in the data_array for the incoming
drag-and-drop event:
PtDndCallbackInfo_t *dndcb = cbinfo->cbdata;
static PtDndFetch_t FetchTypes[] = {
{"PhTransfiles", NULL, Ph_TRANSPORT_INLINE, },
};
/*
* ARRAY_SIZE is defined as follows.
*/
#define ARRAY_SIZE ( m_array ) ( sizeof( m_array ) / sizeof( m_array[0] ) )
int
dnd_callback( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
switch( cbinfo->reason_subtype )
{
case Ph_EV_DND_ENTER:
num_matches = PtDndSelect( widget, FetchTypes, ARRAY_SIZE( FetchTypes ) )
break;
case Ph_EV_DND_DROP:
switch( PtGetDndFetchIndex( dndcb, FetchTypes, ARRAY_SIZE( FetchTypes ) ) )
{
case 0: //file
.
.
.
break;
}
.
.
.
break;
}
return( Pt_CONTINUE );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDndFetch_t, PtDndSelect(), PtInitDnd(), PtReleaseTransportCtrl()
PtTransportCtrl_t, PtTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
PtWidget_t *PtGetParent(
PtWidget_t *widget,
PtWidgetClassRef_t *parent_class );
Library:
ph
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 no parent was found.
Examples:
PtWidget_t *window;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSetParentWidget(), PtWidgetParent()
“Ordering widgets” in the Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
PtWidget_t *PtGetParentWidget( void );
Library:
ph
Description:
PtGetParentWidget() 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 Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
pid_t PtGetRcvidPid( int rcvid );
Library:
ph
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(), PtAppAddInputRemote(), PtGetRcvidPidNd()
Synopsis:
pid_t PtGetRcvidPid( int rcvid,
int *nd );
Arguments:
rcvid The receive ID you want to get the PID and node descriptor from
nd The address where the function stores the node descriptor associated with
the rcvid. You can pass NULL, in which case the function will fail with
EREMOTE if the rcvid is from a remote process.
Library:
ph
Description:
This function should be used to obtain the process ID (PID) and node descriptor (ND)
from the receive ID (RCVID). It might be needed if a nonspecific input procedure
attaches a specific input procedure.
Returns:
The PID on success or:
EREMOTE The rcvid is from a remote process, but you passed NULL for nd.
-1 an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppAddInput()
Synopsis:
#define PtGetResource( widget, type, value, len ) ...
Arguments:
widget A pointer to the widget whose resource you want to set.
value The address of a pointer to the appropriate data type (see the “New
resources” tables in the Photon Widget Reference).
Library:
ph
Description:
This macro sets a pointer to a resource value within the specified widget.
PtGetResource() doesn’t support the nonpointer method of getting resources. For
information on getting and setting resources, see the Manipulating Resources in
Application Code chapter of the Photon Programmer’s Guide.
!
CAUTION: Because PtGetResource() returns a pointer directly into the internals of
the widget, don’t modify the resource value 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 whether or not a widget is highlighted:
unsigned long *flags;
PtWidget_t *widget;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtArg_t, Pt_ARG(), PtGetResources(), PtSetArg(), PtSetResource(),
PtSetResources()
Manipulating Resources in Application Code chapter of the Photon Programmer’s
Guide.
Synopsis:
int PtGetResources( PtWidget_t *widget,
int n_args,
PtArg_t *args );
Library:
ph
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(), PtGetResource(), PtSetArg(), PtSetResource(), PtSetResources()
Manipulating Resources in Application Code chapter of the Photon Programmer’s
Guide.
Synopsis:
void *PtGetStyleMember(
PtWidgetClassStyle_t *style,
int manifest );
Library:
ph
Description:
This function retrieves the value of the given style associated with the given manifest.
For a description of the possible manifests, see PtSetStyleMember().
Returns:
The provided manifest determines the type of the pointer returned:
Pt_STYLE_EXTENT or Pt_STYLE_SIZING
A pointer to the style’s extent function:
void (*sizing_f)( PtWidget_t *widget );
Pt_STYLE_ACTIVATE
A pointer to the style’s activate function:
void (*activate_f)( PtWidget_t *widget,
PtWidgetClassStyle_t *old_style );
Pt_STYLE_CALC_BORDER
A pointer to the function that calculates the style’s borders:
void (*calc_border_f)( PtWidget_t const *widget,
PhRect_t *border );
The style’s borders are the distances from the widget’s extent
(i.e. the widget’s outermost borders) to the widget’s canvas (i.e.
the content area of the widget). For example, if the style’s
border.ul.x is 5, there are five pixels between the widget’s left
extent and the left side of the widget’s canvas. This space is
typically used to render outlines, bevels, and so on.
Pt_STYLE_CALC_OPAQUE
A pointer to the function that calculates the style’s opacity:
void (*calc_opaque_f)( PtWidget_t *widget );
Pt_STYLE_DEACTIVATE
A pointer to the style’s deactivation function:
PtGetStyleMember() returns NULL if the member specified isn’t set or the manifest is
invalid.
Examples:
void display_style_name( PtWidgetClassStyle_t *style )
{
char *name = PtGetStyleMember( style, Pt_STYLE_NAME );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddClassStyle(), PtCreateClassStyle(), PtDupClassStyle(), PtFindClassStyle(),
PtGetWidgetStyle(), PtSetClassStyleMethods(), PtSetStyleMember(),
PtSetStyleMembers(), PtSetWidgetStyle()
Pt_ARG_STYLE resource of PtBasic in the Photon Widget Reference
“Widget Styles” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
PtWidgetClassStyle_t *PtGetWidgetStyle(
PtWidget_t *widget );
Library:
ph
Description:
This function returns a pointer to the style that the provided widget is currently using.
Returns:
A pointer to the style.
Examples:
void display_style( PtWidget_t *widget )
{
PtWidgetClassStyle_t *style =
PtGetWidgetStyle( widget );
display_style_name ( style );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddClassStyle(), PtCreateClassStyle(), PtDupClassStyle(), PtFindClassStyle(),
PtGetStyleMember(), PtSetClassStyleMethods(), PtSetStyleMember(),
PtSetStyleMembers(), PtSetWidgetStyle()
Pt_ARG_STYLE resource of PtBasic in the Photon Widget Reference
“Widget Styles” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
PtWidget_t *PtGiveFocus( PtWidget_t *widget,
PhEvent_t *event );
Library:
ph
Description:
This function gives focus to the specified widget, even if the widget’s
Pt_GETS_FOCUS flag isn’t set. PtGiveFocus() is the same as PtContainerGiveFocus().
If the widget is a PtWindow, use PtWindowFocus() instead of this function — see the
Photon Widget Reference.
The event argument is a pointer to a PhEvent_t structure that describes 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 is NULL, this function generates a
PhEvent_t structure filled with zeros 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 is blocked; that is, it has Pt_BLOCKED set in its Pt_ARG_FLAGS
resource (see PtWidget in the Photon Widget Reference).
• 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
This function could also return a pointer to a different widget if that widget for some
reason refused to relinquish focus (i.e. its Pt_CB_LOST_FOCUS callback returned
Pt_END — see PtBasic in the Photon Widget Reference). This usually happens if the
requirements of an entry field haven’t been met and must be met before any other
action can be taken.
The widget library never refuses to relinquish focus. If a widget does this, it’s because
of a Pt_CB_LOST_FOCUS callback in your application.
Examples:
See PtContainerGiveFocus().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEvent_t, PtContainerFocusNext(), PtContainerFocusPrev(),
PtContainerGiveFocus(), PtContainerNullFocus()
PtWindowFocus() in the Photon Widget Reference
Synopsis:
PtWidget_t *PtGlobalFocusNext( PtWidget_t *widget,
PhEvent_t *event );
Library:
ph
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 the event described in the given PhEvent_t
structure as the reason. If event is NULL, this function generates a PhEvent_t
structure filled with zeros 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:
PhEvent_t, PtContainerGiveFocus(), PtContainerNullFocus(),
PtContainerFocusNext(), PtContainerFocusPrev(), PtGlobalFocusNextContainer(),
PtGlobalFocusNextFrom(), PtGlobalFocusPrev(), PtGlobalFocusPrevFrom(),
PtGlobalFocusPrevContainer(), PtIsFocused()
Synopsis:
PtWidget_t *PtGlobalFocusNextContainer(
PtWidget_t *widget,
PhEvent_t *event );
Library:
ph
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 receives the given event as the reason. If event is NULL,
this function generates a PhEvent_t structure filled with zeros 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:
PhEvent_t, PtContainerGiveFocus(), PtContainerNullFocus(),
PtContainerFocusNext(), PtContainerFocusPrev(), PtGlobalFocusNext(),
PtGlobalFocusNextFrom(), PtGlobalFocusPrev(), PtGlobalFocusPrevFrom(),
PtGlobalFocusPrevContainer(), PtIsFocused()
Synopsis:
PtWidget_t *PtGlobalFocusNextFrom(
PtWidget_t *widget,
PhEvent_t *event );
Library:
ph
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 is NULL, this
function generates a PhEvent_t structure filled with zeros 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:
PhEvent_t, PtContainerGiveFocus(), PtContainerNullFocus(),
PtContainerFocusNext(), PtContainerFocusPrev(), PtGlobalFocusNext(),
PtGlobalFocusNextContainer(), PtGlobalFocusPrev(), PtGlobalFocusPrevFrom(),
PtGlobalFocusPrevContainer(), PtIsFocused()
Synopsis:
PtWidget_t *PtGlobalFocusPrev( PtWidget_t *widget,
PhEvent_t *event );
Library:
ph
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 is NULL, this
function generates a PhEvent_t structure filled with zeros 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:
PhEvent_t, PtContainerGiveFocus(), PtContainerNullFocus(),
PtContainerFocusNext(), PtContainerFocusPrev(), PtGlobalFocusNext(),
PtGlobalFocusNextContainer(), PtGlobalFocusNextFrom(),
PtGlobalFocusPrevFrom(), PtGlobalFocusPrevContainer(), PtIsFocused()
Synopsis:
PtWidget_t *PtGlobalFocusPrevContainer(
PtWidget_t *widget,
PhEvent_t *event );
Library:
ph
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 receives the given event as the reason. If event is NULL,
this function generates a PhEvent_t structure filled with zeros 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:
PhEvent_t, PtContainerGiveFocus(), PtContainerNullFocus(),
PtContainerFocusNext(), PtContainerFocusPrev(), PtGlobalFocusNext(),
PtGlobalFocusNextContainer(), PtGlobalFocusNextFrom(), PtGlobalFocusPrev(),
PtGlobalFocusPrevFrom(), PtIsFocused()
Synopsis:
PtWidget_t *PtGlobalFocusPrevFrom(
PtWidget_t *widget,
PhEvent_t *event );
Library:
ph
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 the event described in the given PhEvent_t
structure as the reason. If event is NULL, this function generates a PhEvent_t
structure filled with zeros 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:
PhEvent_t, PtContainerGiveFocus(), PtContainerNullFocus(),
PtContainerFocusNext(), PtContainerFocusPrev(), PtGlobalFocusNext(),
PtGlobalFocusNextContainer(), PtGlobalFocusNextFrom(), PtGlobalFocusPrev(),
PtGlobalFocusPrevContainer(), PtIsFocused()
Synopsis:
void PtHelpQuit( void );
Library:
ph
Description:
PtHelpQuit() tells the Helpviewer to exit.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtHelpTopic(), PtHelpTopicRoot(), PtHelpTopicTree(), PtHelpSearch(), PtHelpUrl(),
PtHelpUrlRoot()
Context-Sensitive Help chapter of the Photon Programmer’s Guide
helpviewer in the QNX Neutrino Utilities Reference.
Synopsis:
int PtHelpSearch( char *string,
int mode,
int scope,
int method );
Arguments:
string The string you’re looking for.
Library:
ph
Description:
Use PtHelpSearch() to search for a string in the online help information.
PtHelpSearch() 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:
PtHelpSearch( "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:
PtHelpQuit(), PtHelpTopic(), PtHelpTopicRoot(), PtHelpTopicTree(), PtHelpUrl(),
PtHelpUrlRoot()
Context-Sensitive Help chapter of the Photon Programmer’s Guide
helpviewer in the QNX Neutrino Utilities Reference.
Synopsis:
int PtHelpTopic( char *topic );
Library:
ph
Description:
PtHelpTopic() tells the Helpviewer to display the help text located by the given topic
path.
PtHelpTopic() 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 PtHelpTopicRoot().
Returns:
0 on success, or -1 if the Helpviewer couldn’t be found or spawned.
PtHelpTopic() returns immediately, before the help topic has been displayed.
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>
return( Pt_CONTINUE );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtHelpQuit(), PtHelpSearch(), PtHelpTopicRoot(), PtHelpTopicTree(), PtHelpUrl(),
PtHelpUrlRoot()
Context-Sensitive Help chapter of the Photon Programmer’s Guide
helpviewer in the QNX Neutrino Utilities Reference.
Synopsis:
void PtHelpTopicRoot( char *topic );
Library:
ph
Description:
PtHelpTopicRoot() lets you specify a partial root topic path that’s prefixed to any
relative topic paths in subsequent PtHelpTopic() calls. (Any path that doesn’t start
with a / is considered relative.)
PtHelpTopicRoot() doesn’t copy the topic root. Don’t free the string until you’ve
finished using the root topic path.
Examples:
See PtHelpTopic().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtHelpQuit(), PtHelpSearch(), PtHelpTopic(), PtHelpTopicTree(), PtHelpUrl(),
PtHelpUrlRoot()
Context-Sensitive Help chapter of the Photon Programmer’s Guide
helpviewer in the QNX Neutrino Utilities Reference.
Synopsis:
int PtHelpTopicTree( char *file );
Library:
ph
Description:
PtHelpTopicTree() 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 “Creating topic files” in the Helpviewer documentation in the QNX Neutrino
Utilities Reference.
PtHelpTopicTree() 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.
PtHelpTopicTree() returns immediately, before the topic tree has been displayed.
Examples:
PtHelpTopicTree( "$YOUR_QNX_TARGET_NAME/usr/help/product/photon.toc" );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtHelpQuit(), PtHelpSearch(), PtHelpTopic(), PtHelpTopicRoot(), PtHelpUrl(),
PtHelpUrlRoot()
Context-Sensitive Help chapter of the Photon Programmer’s Guide
helpviewer in the QNX Neutrino Utilities Reference.
Synopsis:
int PtHelpUrl( char *url );
Library:
ph
Description:
PtHelpUrl() 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 PtHelpUrlRoot().
PtHelpUrl() 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.
PtHelpUrl() returns immediately, before the help topic has been displayed.
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>
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtHelpQuit(), PtHelpSearch(), PtHelpTopic(), PtHelpTopicRoot(), PtHelpTopicTree(),
PtHelpUrlRoot()
Context-Sensitive Help chapter of the Photon Programmer’s Guide
helpviewer in the QNX Neutrino Utilities Reference.
Synopsis:
void PtHelpUrlRoot( char *url );
Library:
ph
Description:
PtHelpUrlRoot() lets you specify a partial root URL that’s prefixed to any relative
URLs in subsequent PtHelpUrl() calls. (A relative URL is one that doesn’t start with a
/.)
PtHelpUrlRoot() doesn’t copy the given URL. Don’t free the string until you’ve
finished using the root URL.
Examples:
See PtHelpUrl().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtHelpQuit(), PtHelpSearch(), PtHelpTopic(), PtHelpTopicRoot(), PtHelpTopicTree(),
PtHelpUrl()
Context-Sensitive Help chapter of the Photon Programmer’s Guide
helpviewer in the QNX Neutrino Utilities Reference.
Synopsis:
int PtHideSurface( PtWidget_t *widget,
PtSurface_t *surface );
Library:
ph
Description:
These functions hide a control surface belonging to the given widget. They differ in
how they identify the control surface:
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtHideSurfaceByAction(), PtShowSurface(), PtShowSurfaceByAction(),
PtShowSurfaceById(), PtSurfaceIsHidden(), PtSurfaceIsShown()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
int PtHideSurfaceByAction(
PtWidget_t *widget,
PtWidgetClassRef_t const *cref ,
unsigned short action_id );
Library:
ph
Description:
This function hides all control surfaces associated with an action. The widget
argument specifies the widget owning the surfaces, while cref and action_id specify
the class and manifest of the action associated with surfaces to be hidden.
Returns:
0 if any surfaces were hidden, or -1 if no surfaces were affected.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtHideSurface(), PtHideSurfaceById(), PtShowSurface(), PtShowSurfaceByAction(),
PtShowSurfaceById(), PtSurfaceIsHidden(), PtSurfaceIsShown()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
PtWidget_t *PtHit( PtWidget_t *container,
unsigned n,
PhRect_t const *rect );
Library:
ph
Description:
This function returns container’s nth child widget whose extent intersects with the
rectangle defined in the PhRect_t pointed to by rect. The rectangle’s coordinates
must be relative to container’s canvas. PtHit() ignores unrealized or procreated
widgets.
Returns:
A pointer to the container’s nth widget who’s extent intersects with rect, or NULL if
there’s no such child widget.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRect_t
Synopsis:
int PtHold( void );
Library:
ph
Description:
This function prevents visible repair of all widgets until your application makes a
corresponding call to PtRelease().
The application’s hold count is incremented when you call PtHold(), and decremented
when you call PtRelease(). When the hold count reaches 0, the widgets are repaired.
A 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.
Returns:
The new value of the hold count.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFlush(), PtRelease()
“Delaying and forcing updates to the display” in the Working with Code chapter of the
Photon Programmer’s Guide
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 );
Library:
ph
Description:
This function creates a label widget as a child of win. The widget is placed according
to position, relative to me. The string is rendered inside the label widget using a text
color of text_color, and the font specified in font (which you should create by calling
PfGenerateFontName()). 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
See also:
PfGenerateFontName(), PgColor_t
Synopsis:
int PtInit( char const *name );
Library:
ph
Description:
This function initializes the widget library. If no Photon channel is currently attached,
this function calls PhAttach() with the given Photon server name
(/net/darrin/dev/photon, for example). If there is a current channel, PhAttach()
isn’t called.
Once a channel is attached, PtInit() initializes all the widgets supplied by QNX
Software Systems.
The application that calls PtInit() must have the appropriate permissions to read from
and write to the attached Photon server, or the call will fail.
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:
int PtInitDnd( PtTransportCtrl_t *ctrl,
PtWidget_t *widget,
PhEvent_t *event,
PhDndCursors_t *cursors,
int unsigned flags );
Arguments:
ctrl A pointer to a PtTransportCtrl_t structure which contains the data
that the function uses to initiate a drag-and-drop operation.
event A pointer to a PhEvent_t structure that describes the event that was used
to precipitate the operation. This may be a pointer event
(Ph_EV_PTR_MOTION_*) or drag event (Ph_EV_DRAG). If the event
isn’t of one of these types, the function will fail.
If the drag event’s subtype isn’t Ph_EV_DRAG_COMPLETE, you’ll have to cancel the
drag first, using PhCancelDrag().
Pt_DND_LOCAL Restrict the drop so that it can occur only within the
context of the application that initiated the
drag-and-drop. That is to say that the user can’t drop
the data on any other application. This is very useful
for allowing the dragging and dropping of private data
or pointer references that are meaningful only within a
single application’s context.
Library:
ph
Description:
This function initiates a drag-and-drop operation with the data previously added to the
PtTransportCtrl_t structure pointed to by ctrl. Before calling PtInitDnd(), your
application must create this structure by calling PtCreateTransportCtrl() and populate
it via calls to PtTransportType() and PtTransportRequestable().
The structure pointed to by ctrl is automatically released at the end of the
drag-and-drop operation.
Returns:
0 Success.
-1 An error occurred.
Examples:
int cb_outbound (PtWidget_t *widget, void *data,
PtCallbackInfo_t *cbinfo);
{
PtTransportCtrl_t *tctrl = PtCreateTransportCtrl();
PtTransportType( tctrl, "text", "simple sentence",
0, Ph_TRANSPORT_INLINE, "string",
"This is my inlined data.", 0, 0 );
PtInitDnd( tctrl, widget, cbinfo->event, NULL,
Pt_DND_LOCAL | Pt_DND_SILENT );
return Pt_CONTINUE;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
continued. . .
Safety
Thread No
See also:
PhCursorDescription_t, PhCancelDrag(), PhEvent_t, PtCancelDnd(),
PtCreateTransportCtrl(), PtDndFetch_t, PtDndSelect(), PtTransportCtrl_t,
PtTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
typedef int PtInputCallbackProcF_t( void *, int,
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:
PtInputCallbackProcF_t my_input_callback;
The compiler should detect any inconsistencies between the two declarations of
my_input_callback() and give you an error (which is better than a “pointer mismatch”
warning on the call to PtAppAddInput()).
Classification:
Photon
See also:
PtAppAddInput()
Interprocess Communication chapter of the Photon Programmer’s Guide
Synopsis:
int PtInsertSurface( PtWidget_t *widget,
PtSurface_t *surface,
unsigned char brother_id,
int behind );
Library:
ph
Description:
These functions change a surface’s z coordinate by inserting the surface in front of or
behind another surface. They differ in how they identify the control surface:
The widget argument specifies the widget owning the specified surfaces. The
brother_id argument specifies the numerical ID of the surface to position relative to,
and the behind argument specifies how to position the surface:
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSurfaceBrotherBehind(), PtSurfaceBrotherInFront(), PtSurfaceInBack(),
PtSurfaceInFront(), PtSurfaceToBack(), PtSurfaceToBackById(), PtSurfaceToFront(),
PtSurfaceToFrontById()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
int PtIsFluxing( PtWidget_t *container );
Library:
ph
Description:
This function determines whether container or any parent widget of container is
currently in flux (i.e. your application is delaying any updates to the display for the
container).
Returns:
1 The container’s family is in flux.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtContainerHold(), PtContainerRelease(), PtEndFlux(), PtStartFlux()
“Delaying updates to the display” in the Working with Code chapter of the Photon
Programmer’s Guide
Synopsis:
int PtIsFocused( PtWidget_t *widget );
Arguments:
widget A pointer to the widget whose focus you want to determine.
Library:
ph
Description:
This function returns a value indicating to what degree a widget is focused.
The widget family hierarchy is a set of trees. The widget that you would normally say
has focus is called the focus leaf . Its parent, grandparent, and so on, up to the root of
the tree (typically a window), form the focus branch. In other words, a widget is on the
focus branch if the focus leaf is somewhere inside it.
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:
int PtLeave( int flags );
Arguments:
The value of flags can be one of:
Pt_EVENT_PROCESS_ALLOW
Turn the calling thread into an event reader.
Pt_EVENT_PROCESS_PREVENT
Turn the calling thread into a nonreader.
In most cases, it’s better to set neither of these bits in flags, in which case the thread’s
status as event reader or nonreader doesn’t change. For more information about
changing a thread’s event reader status, see “Threads” in the Parallel Operations
chapter of the Photon Programmer’s Guide.
You can OR the following into the flags:
Library:
ph
Description:
This function is the opposite to PtEnter(); it “unlocks” the library and lets other
threads use Photon functions.
Don’t call PtLeave() if your thread hasn’t locked the library by successfully calling
PtEnter(). If you do, your application will crash if you’re lucky, or just randomly
corrupt some data if you’re less lucky.
PtLeave() doesn’t atomically give the library lock to another thread blocked inside
PtEnter(); the other thread gets unblocked, but then it must compete with any other
threads as if it just called PtEnter().
Returns:
0 Success. and the state of the thread didn’t change.
>0 Success, and the state of the thread changed. The return value can be a
combination of:
• Pt_EVENT_PROCESS_ALLOW—The thread was a reader, and PtLeave()
was called with flags set to Pt_EVENT_PROCESS_PREVENT.
• Pt_EVENT_PROCESS_PREVENT—The thread was a nonreader, and
PtLeave() was called with flags set to Pt_EVENT_PROCESS_ALLOW .
• Pt_DELAY_EXIT—For both the current call to PtLeave() and the previous
call to PtEnter(), flags was set to Pt_DELAY_EXIT.
Some functions will reset the Pt_DELAY_EXIT flag bit for the thread to 0, which will
affect the return value. These functions are PtCondWait(), PtCondTimedWait(), and
any function that reads and processes an event (such as PtProcessEvent() or
PtModalBlock()).
<0 An error occurred; the value is a negative error code.
Errors:
EINVAL The parameter flags is an incorrect value.
Examples:
You can test whether you have the Photon Library locked by evaluating PtEnter(). If
the Photon Library is already locked, PtEnter() will fail with an error of -EDEADLK.
When PtLeave() is called with a negative value, it is guaranteed to fail, so in this
example the Photon Library has the same lock state as it had before the call to
PtEnter():
int eval;
if ((eval = PtEnter(0)) < 0 && eval != -EDEADLK)
fprintf( stderr, ‘‘Couldn’t enter: %s\n‘‘,
strerror( -eval ) );
else
{
PtSetResource(w, Pt_ARG_WINDOW_TITLE, text, 0);
PtLeave(eval); // does nothing if eval == -EDEADLK
}
In this example, the Photon Library is locked elsewhere, and you want to unlock it to
perform some lengthy operation, such as in a widget callback where not unlocking the
library would “freeze” the GUI for the duration of the operation:
strerror( -flags ) );
else {
do_some_lengthy_stuff();
/* This will turn your thread back into a reader if it
was a reader before: */
if ( ( flags = PtEnter( flags ) ) < 0 )
fprintf( stderr, ‘‘Couldn’t enter: %s\n‘‘,
strerror( -flags ) );
}
...
return( Pt_CONTINUE );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PtEnter(), PtExit()
pthread_mutex_unlock() in the QNX Neutrino Library Reference
“Threads” in the Parallel Operations chapter of the Photon Programmer’s Guide
Synopsis:
void PtMainLoop( void );
Library:
ph
Description:
This is a convenience function that implements an application main loop using
PhEventNext() and PtEventHandler(). PtMainLoop() also supports background
processing (WorkProcs), signals, threads, and the handling of non-Photon messages
(inputs).
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 PtExit() within a callback
function. To terminate a thread that’s running PtMainLoop() without terminating the
entire application, call PtQuitMainLoop().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEventNext(), PtAppAddInput(), PtAppAddWorkProc(), PtEventHandler(), PtExit(),
PtQuitMainLoop(), PtResizeEventMsg()
“Receiving QNX messages” in the Interprocess Communications chapter of the
Photon Programmer’s Guide
Synopsis:
void PtMakeModal( PtWidget_t *widget,
unsigned short cursor,
PgColor_t cursor_color );
Library:
ph
Description:
PtMakeModal() blocks all windows except the one that contains widget (using
PtBlockAllWindows()), and attaches a destroyed callback that will unblock them
(using PtUnblockWindows()).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApModalWait(), PgColor_t, PtBlockAllWindows(), PtBlockWindow(),
PtUnblockWindows()
“Modal dialogs” in the Window Management 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 );
Library:
ph
Description:
This function displays the message specified by question, blocking 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 widget must be a window.
The other arguments are:
title The title of the dialog. If this argument is NULL, the dialog has no title bar.
font The name of the font to use for the message, as created by
PfGenerateFontName(). The default is TextFont09.
btn The label to display in the dialog’s button. The default is Ok.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApError(), PfGenerateFontName(), PtAlert(), PtNotice(), PtPrompt()
“Dialog modules” in the Working with Modules chapter of the Photon Programmer’s
Guide
Synopsis:
void *PtModalBlock( PtModalCtrl_t *ctrl,
unsigned flags );
Library:
ph
Description:
PtModalBlock() implements a modal loop.
The PtModalCtrl_t structure is a replacement for the “done” flag typically used by
the modal loop. PtModalUnblock() is a replacement for setting that flag.
PtModalBlock() doesn’t return until PtModalUnblock() is called with the same value
of its ctrl argument. The structure pointed to by ctrl doesn’t need to be initialized in
any special way.
While PtModalBlock() is running, Photon events are processed by either the same
thread, other threads, or both. PtModalUnblock() causes the corresponding
PtModalBlock() call to return the value passed to the result argument.
The flags argument can be one of:
Pt_EVENT_PROCESS_PREVENT
Temporarily turn your thread into a nonreader: PtModalBlock() blocks on a
condvar rather than processing events.
Pt_EVENT_PROCESS_ALLOW
Make sure that PtModalBlock() processes events rather than blocking on a
condvar.
If you pass 0 for flags, PtModalBlock() tries to guess the best possible behavior:
Either way, the previous status of the thread as a reader or nonreader is restored before
PtModalBlock() returns, even if the status was changed by a callback invoked from
within PtModalBlock() rather than by PtModalBlock() itself.
If another thread calls PtExit() while this function is blocked, the function does not
return, even if a third thread calls PtModalUnblock().
Returns:
NULL on error, or the value passed as the second argument to PtModalUnblock()
(don’t use NULL or you won’t be able to recognize a failure).
Examples:
/* callbacks.c */
/* */
/* This application demonstrates how to optain set */
/* up a modal dialog in an application in order to */
/* obtain information from the user before continuing. */
/* */
/* This file contains: */
/* */
/* modal_btn_done_activateCB */
/* Callback type: Pt_CB_ACTIVATE */
/* Widget: modal_btn_done */
/* */
/* This function displays how to obtain and pass back */
/* some data input by the user, and then unblock from */
/* a modal situation */
/* */
/*-------------------------------------------------------*/
/* */
/* nonmodal_btn_launchmodaldlg_activateCB */
/* */
/* Callback type: Pt_CB_ACTIVATE */
/* Widget: modal_btn_done */
/* */
/* This function launchs our modal dialog, blocks */
/* other windows in the application, changes their */
/* cursors (and overrides those of their children) to */
/* be the noninput cursor, and then calls */
/* PtModalBlock() to wait for the user to return from */
/* the dialog (via modal_btn_done_activateCB()). */
/* */
/* Information obtained from the user in the modal */
/* dialog is used, and then the other windows are */
/* restored to normal. */
/* */
/*-------------------------------------------------------*/
/* */
/* AppBuilder Photon Code Lib */
/* Version 2.01A */
/* 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 "globals.h"
#include "abimport.h"
#include "proto.h"
/*
* global variables
*/
PtModalCtrl_t modalctrl;
int *choice;
/***************************************************************
*
* modal_btn_done_activateCB
*
***************************************************************/
int
modal_btn_done_activateCB( PtWidget_t *widget, ApInfo_t *apinfo,
PtCallbackInfo_t *cbinfo )
{
PtArg_t arg[1];
int *users_choice;
return( Pt_CONTINUE );
}
/***************************************************************
*
* nonmodal_btn_launchmodaldlg_activateCB
*
***************************************************************/
int
nonmodal_btn_launchmodaldlg_activateCB(
PtWidget_t *widget,
ApInfo_t *apinfo,
PtCallbackInfo_t *cbinfo )
{
/*
* Create and realize a dialog to get a user respons; in
* it we’ll ask the user to choose a value with a
* PtNumericInteger. (We created the dialog in PhAB, along
* with an internal link to it. Note that the internal
* link needs a pointer to a widget in order to place
* the dialog)
*/
ApCreateModule( ABM_modal, widget, NULL );
/*
* save away cursor data from other windows
*/
PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE, &ptr2oldcursor, 0 );
PtSetArg( &args[1], Pt_ARG_CURSOR_OVERRIDE,
&cursor_override_state, 0 );
PtGetResources( ABW_base, 2, args );
base_oldcursor = *ptr2oldcursor;
base_oldcursoroverride = cursor_override_state;
PtGetResources( ABW_nonmodal, 2, args );
nonmodal_oldcursor = *ptr2oldcursor;
nonmodal_oldcursoroverride = cursor_override_state;
/*
* block user interaction to windows - note that instead of
* blocking each window individually, we’d normally use
* PtBlockAllWindows(); we’ll also alter the windows’
* cursors to reflect their blocked state
*/
PtSetArg( &args[0], Pt_ARG_FLAGS, Pt_BLOCKED, Pt_BLOCKED );
PtSetArg( &args[1], Pt_ARG_CURSOR_TYPE,
Ph_CURSOR_NOINPUT, 0 );
PtSetArg( &args[2], Pt_ARG_CURSOR_OVERRIDE, Pt_TRUE, 0 );
PtSetResources( ABW_base, 3, args );
PtSetResources( ABW_nonmodal, 3, args );
/*
* block; this will return when PtModalUnblock() is called
*/
PtModalBlock( &modalctrl, 0 );
/*
* the global variable "choice" has now been filled in;
* we’ll display that value now
*/
itoa( *choice, choice_as_string, 10 );
PtSetArg( &args[0], Pt_ARG_TEXT_STRING,
choice_as_string, 0 );
PtSetResources( ABW_nonmodal_lbl_choice, 1, args );
/*
* unblock user interaction to windows and restore cursors to
* original states
*/
PtSetArg( &args[0], Pt_ARG_FLAGS, 0, Pt_BLOCKED );
PtSetArg( &args[1], Pt_ARG_CURSOR_TYPE,
base_oldcursor, 0 );
if( base_oldcursoroverride )
return( Pt_CONTINUE );
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtModalEnd(), PtModalStart(), PtModalUnblock(), PtProcessEvent()
“Threads” in the Parallel Operations chapter, and “Modal dialogs” in the Window
Management chapter of the Photon Programmer’s Guide
Synopsis:
void PtModalEnd( void );
Library:
ph
Description:
This function terminates a modal-processing loop that was initiated by PtModalStart().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtModalBlock(), PtModalStart(), PtModalUnblock(), PtProcessEvent()
“Modal dialogs” in the Window Management chapter of the Photon Programmer’s
Guide
Synopsis:
void PtModalStart ( void );
Library:
ph
Description:
This function initiates modal processing. To do so, it holds the current process loop so
that another subloop can be started. This is needed so that the “current event” before
the loop is the same as after.
Once the subloop is complete, you must call PtModalEnd() to resume processing of
the initial process loop.
If you want the parent or any windows in the application to refuse input while the
modal dialog is displayed, you need to block them programmatically by setting the
Pt_BLOCKED flag.
We recommend using PtModalBlock() and PtModalUnblock() instead of a
PtModalStart() / PtProcessEvent() / PtModalEnd() loop. PtModalBlock() makes it
easier for you to write modal code that’s compatible with multithreaded applications.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtModalBlock(), PtModalEnd(), PtModalUnblock(), PtProcessEvent()
“Modal dialogs” in the Window Management chapter of the Photon Programmer’s
Guide
Synopsis:
int PtModalUnblock( PtModalCtrl_t *ctrl,
void *result );
Library:
ph
Description:
PtModalUnblock() causes the corresponding PtModalBlock() call to return the value
passed to the result argument. If you call PtModalUnblock() more than once before
PtModalBlock() returns, only the first call matters; don’t call PtModalUnblock() after
PtModalBlock() has returned.
Returns:
0 Success.
-1 An error occurred.
Examples:
See PtModalBlock().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtModalBlock(), PtModalEnd(), PtModalStart(), PtProcessEvent()
“Modal dialogs” in the Window Management chapter of the Photon Programmer’s
Guide
Synopsis:
PtWidget_t * PtNextTopLevelWidget(
PtWidget_t *widget );
Library:
ph
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 Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
void PtNotice( PtWidget_t *parent,
PhPoint_t const *location,
char const *title,
PhImage_t const *image,
char const *message,
char const *msgFont,
char const *btnText,
char const *btnFont,
int flags );
Arguments:
parent A pointer to the parent widget of the dialog (usually a window). By
setting the flags, you can block the parent and/or position the dialog
relative to it.
title The title for the dialog. If you don’t want a title bar, set this argument to
NULL.
msgFont The font for the message text; the default is TextFont09. You should
create the font name by calling PfGenerateFontName().
btnText The text to be displayed in the button. If this is set to NULL, a default of
&OK is used. The btnText argument lets you define a shortcut key — place
an ampersand (&) in front of the character to be used as the shortcut.
btnFont The font to use in the button. If this is NULL, a default font of
TextFont09 is used. You should create the font names by calling
PfGenerateFontName().
flags Flags that specify the behavior for the dialog. This can be up to one of
the following:
• Pt_CENTER — center the dialog.
• Pt_LEFT — left-align the dialog (the default).
• Pt_RIGHT — right-align the dialog.
with any combination of the following:
• Pt_BLOCK_ALL — block all of the application’s windows while the
dialog is displayed.
Library:
ph
Description:
This function displays a message and waits for you to acknowledge it. By setting the
flags, you can make PtNotice() work modally, meaning that it doesn’t return until you
respond.
Examples:
char Helvetica12[MAX_FONT_TAG];
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApError(), PfGenerateFontName(), PhImage_t, PhPoint_t, PtAlert(),
PtPassword(), PtPrompt()
“Dialog modules” in the Working with Modules chapter of the Photon Programmer’s
Guide
Synopsis:
int PtPassword( PtWidget_t *parent,
PhPoint_t const *location,
char const *title,
PhImage_t const *image,
char const *message,
char const *msg_font,
char const **buttons,
char const **btn_fonts,
char const *text_font,
int (*validate_f )(void *,char const *),
void *validate_data,
char const *echo,
int flags );
Arguments:
parent A pointer to the parent widget of the dialog (usually a window). By
setting the flags, you can block the parent and/or position the dialog
relative to it.
title The title for the dialog. If you don’t want a title bar, set this
argument to NULL.
msg_font The font for the message text; the default is TextFont09. You
should create the font name by calling PfGenerateFontName().
text_font The name of the font to use for the text. You should create the font
name by calling PfGenerateFontName().
echo A multibyte character to replace the characters that the user types.
If NULL, * is used. Specify "" if you don’t want any echoing to
take place (i.e. the text field appears non-interactive but there’s no
indication of how many characters the user types, which might be
appealing for higher security restrictions).
flags Flags that define the behavior for the dialog. This can be up to one
of the following:
• Pt_CENTER — center the dialog.
• Pt_LEFT — left-align the dialog (the default).
• Pt_RIGHT — right-align the dialog.
with any combination of the following:
• Pt_BLOCK_ALL — block all of the application’s windows while
the dialog is displayed.
• Pt_BLOCK_PARENT — block the widget specified by the parent
argument (if non-NULL).
• Pt_ESC_DISABLE — disable the ESC key as a means of
dismissing the dialog.
• Pt_MODAL — the same as Pt_BLOCK_ALL.
Library:
ph
Description:
This function displays a dialog that prompts the user for a password.
Returns:
Pt_PWD_ACCEPT The user typed an acceptable password.
Otherwise, the function returns -1 to indicate some lower-level error (e.g. the dialog
couldn’t be created).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PfGenerateFontName(), PhImage_t, PhPoint_t, PtAlert(), PtNotice(), PtPrompt()
“Dialog modules” in the Working with Modules chapter of the Photon Programmer’s
Guide
Synopsis:
void PtPositionMenu( PtWidget_t *menu,
PhEvent_t *event );
Library:
ph
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
See also:
PhEvent_t
Synopsis:
void PtPreventExit( void );
Library:
ph
Description:
PtPreventExit() lets Photon know that it isn’t safe to exit your application.
In a multithreaded application, any thread can call PtExit(), but another thread might
be in the middle of an important operation, such as writing a file. To prevent this
situation from arising, call PtPreventExit() before starting the operation, and call
PtAllowExit() when it’s done.
Instead of calling PtPreventExit() and PtAllowExit() directly, you’re better off calling
PtEnter() and PtLeave() with Pt_DELAY_EXIT set in the flags. For a discussion of the
difference between these functions and using Pt_DELAY_EXIT, see “Exiting a
multithreaded program” in the Parallel Operations chapter of the Photon
Programmer’s Guide.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread Yes
See also:
PtAllowExit(), PtEnter(), PtExit(), PtLeave()
Parallel Operations chapter of the Photon Programmer’s Guide
Synopsis:
int PtPrintPropSelect(
PtWidget_t *parent,
char const *title,
PtPrintPropSelectionInfo_t *info );
Arguments:
parent A pointer to the parent widget. If this argument isn’t NULL, the parent
widget is blocked while the dialog is displayed.
title The title of the print-properties dialog.
info A pointer to a PtPrintPropSelectionInfo_t structure (see below).
Library:
ph
Description:
This function displays a dialog for modifying most of the print parameters for a
particular printer:
The display is limited to parameters and values that are valid for the selected printer.
A print context is passed to the function in the info argument. This print context is
modified according to the state of the dialog when you press the Apply or Done button.
PtPrintPropSelect() also lets you load and save your own preferences, which are
stored in personal print configuration files.
The PtPrintSel widget calls PtPrintPropSelect() when you press the Preferences
button.
PtPrintPropSelectionInfo_t structure
The PtPrintPropSelectionInfo_t structure includes at least:
PpPrintContext_t *pcontext
A pointer to a PpPrintContext_t structure that describes the
print context. You must create this structure by calling
PpCreatePC(). Optionally, you can initialize the print context by
calling PpLoadPrinter().
PhPoint_t pos The position of the print-properties dialog; the meaning of this
position depends on the parent argument, and on whether the
Pt_PSP_CENTER bit is set or cleared in the flags member:
• Pt_PSP_NO_LOAD_GLOBAL_DFLT_BUTTON — don’t
display the Load Global Defaults button.
int num_args The number of resources specified in the args array.
PtArg_t *args A pointer to an array of resources for the dialog; see below.
Dialog “resources”
You can customize the print-properties dialog as if it were a widget with resources.
You can set or get the values of these pseudo-resources for a PtPrintSel widget (see
the Widget Reference).
All the resources are of this type:
Resource Default
Pt_ARG_PSP_LBL_CANCEL Cancel
Pt_ARG_PSP_LBL_APPLY Apply
Pt_ARG_PSP_LBL_DONE Done
Resource Default
Pt_ARG_PSP_LBL_TITLE Printer Properties
Pt_ARG_PSP_LBL_TITLE_PAPER Paper
Pt_ARG_PSP_LBL_TITLE_GRAPHICS Graphics
Pt_ARG_PSP_LBL_TITLE_MARGINS Margins
Pt_ARG_PSP_LBL_TITLE_PRINT_ORDER Print Order
Pt_ARG_PSP_LBL_TITLE_PRINTERS Printers
Pt_ARG_PSP_LBL_TITLE_DFLT Defaults
Paper pane
Resource Default
Pt_ARG_PSP_LBL_PAPERSIZE Paper Size
Pt_ARG_PSP_LBL_PAPERSOURCE Paper Source
Pt_ARG_PSP_LBL_PAPERTYPE Paper Type
Pt_ARG_PSP_LBL_ORIENTATION Orientation
Pt_ARG_PSP_LBL_PORTRAIT Portrait
Pt_ARG_PSP_LBL_LANDSCAPE Landscape
Graphics pane
Resource Default
Pt_ARG_PSP_LBL_COLORMODE Color Mode
Pt_ARG_PSP_LBL_DITHERING Dithering
Pt_ARG_PSP_LBL_RESOLUTION Resolution
Pt_ARG_PSP_LBL_INTENSITY Intensity
Pt_ARG_PSP_LBL_DARKEST Darkest
Pt_ARG_PSP_LBL_LIGHTEST Lightest
Margins pane
Resource Default
Pt_ARG_PSP_LBL_TOP Top
Pt_ARG_PSP_LBL_BOTTOM Bottom
Pt_ARG_PSP_LBL_LEFT Left
Pt_ARG_PSP_LBL_RIGHT Right
Pt_ARG_PSP_LBL_UNITS Units
Pt_ARG_PSP_LBL_INCHES 1000th inch
Pt_ARG_PSP_LBL_MILLIMETERS 100th mm
Defaults pane
Resource Default
Pt_ARG_PSP_LBL_SAVE_DFLT Save Personal Defaults
Pt_ARG_PSP_LBL_LOAD_DFLT Load Personal Defaults
Pt_ARG_PSP_LBL_LOAD_GLOBAL_DFLT Load Factory Settings
Printers pane
Resource Default
Pt_ARG_PSP_LBL_DEFAULT_PRINTER Default Printer
Pt_ARG_PSP_LBL_CURRENT_PRINTER Current Printer
Pt_ARG_PSP_LBL_FONTMAP Font Map
Resource Default
Pt_ARG_PSP_LBL_REVERSED Print Reversed Order
Pt_ARG_PSP_LBL_DOUBLE_SIDED Print Double Sided
Pt_ARG_PSP_LBL_COLLATED Print Collated
Returns:
Pt_PSP_ERROR An error occurred:
• The info argument is NULL or points to an invalid structure.
• The printcontext is NULL.
• No printers have been installed.
If you press the Apply button, the contents of the print context might change, no
matter which button you ultimately use to close the dialog. If PtPrintPropSelect()
returns Pt_PSP_CANCEL, your application shouldn’t assume that nothing changed.
Examples:
/*************************************
*
* psp.c
*
* Sample program illustrates usage of
* PtPrintPropSelect() convenience function.
*
* Compile as follows:
* $ qcc -lph -o psp psp.c
*
* Run as follows:
* $ ./psp
*
*************************************/
#include <stdio.h>
#include <stdlib.h>
#include <Ph.h>
#include <Pt.h>
info.num_args = 3;
info.args = args;
// Create a print-context.
if ( NULL == (info.pcontext = PpCreatePC()) ) {
fprintf( stderr, "\nUnable to create print context.\n" );
PtExit( -1 );
}
if ( Pt_PSP_ERROR == r )
fprintf( stderr,
"\nPtPrintPropSelect() failed. The print context was not \
modified.\n" );
else if ( Pt_PSP_DONE == r )
fprintf( stderr,
"\n’MyDone’ button pressed. The print context may have \
been modified.\n" );
else // Pt_PSP_CANCEL == r
fprintf( stderr,
"\n’Esc’ key pressed or dialog closed. The print \
context may have been modified.\n" );
PtMainLoop();
return EXIT_SUCCESS;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpCreatePC(), PpPrintContext_t, PpSetPC(), PtPrintSelect(), PtPrintSelection()
PtPrintSel in the Widget Reference
“Dialog modules” in the Working with Modules chapter, and the Printing chapter of
the Photon Programmer’s Guide
Synopsis:
int PtPrintSelect(
PtWidget_t *parent,
const char *title,
PtPrintSelectionInfo_t *info );
Library:
ph
Description:
This function displays a modal dialog that lets you select print options and initiate
printing. This function is similar to PtPrintSelection(), but PtPrintSelect() lets you
customize the appearance and function of the dialog and the underlying PtPrintSel
widget.
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 title of the dialog is given by title; if this is NULL a default title of “Select Printer”
is used.
The user may click one of these buttons:
• Print—initiate printing
Returns:
An integer that indicates which button was pressed:
• Pt_PRINTSEL_PRINT
• Pt_PRINTSEL_PREVIEW
• Pt_PRINTSEL_CANCEL
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PpContinueJob(), PpCreatePC(), PpEndJob(), PpGetPC(), PpPrintNewPage(),
PpReleasePC(), PpPrintWidget(), PpSetPC(), PpStartJob(), PpSuspendJob(),
PtPrintSelection(), PtSetResources()
Printing chapter, and “Setting resources” in the Manipulating Resources in
Application Code chapter of the Photon Programmer’s Guide
Synopsis:
int PtPrintSelection( PtWidget_t *parent,
PhPoint_t const *pos,
const char *title,
PpPrintContext_t *context,
unsigned flags);
Arguments:
parent A pointer to the parent widget for the dialog. If the parent widget isn’t
NULL, it’s blocked and its cursor is changed to reflect this.
The parent argument is also used to position the dialog, as described
below.
title The title of the dialog; if this is NULL, a default title of “Select Printer” is
used.
flags Flags that enable or disable parts of the user interface (see below). This
argument should normally be set to Pt_PRINTSEL_DFLT_LOOK.
Library:
ph
Description:
This convenience function displays a PtPrintSel widget and a button-pane in a
modal dialog. It lets you select print options and initiate printing:
The parent and pos arguments determine where the dialog is to appear:
Your application can call PpSetPC() to modify the print context before calling
PtPrintSelection(). These modifications are propagated to the PtPrintSel widget.
Note that some modified context settings may not be displayed or may be reset (e.g. if
the selected printer doesn’t support double-sided printing and the Pp_PC_DUPLEX
member was set in the context before calling PtPrintSelection()).
The valid flags are those defined for Pt_ARG_PRINT_FLAGS:
Pt_PRINTSEL_FILE_PANE
Enable the Send to file pane.
Pt_PRINTSEL_NO_COPIES
Disable the Copies widget.
Pt_PRINTSEL_NO_PAGE_RANGE
Disable the Print Range toggle button and the From and To fields.
Pt_PRINTSEL_NO_PRINTSELECT
Disable the printer-name combobox. Physical output goes to the default physical
printer whose name is shown.
Pt_PRINTSEL_NO_SELECT_RANGE
Disable the Print Selection toggle button.
Pt_PRINTSEL_PREFERENCES
Enable the Preferences button.
Pt_PRINTSEL_SETTINGS_PANE
Enable the Print Pages, Print Order and Copies panes.
Pt_PRINTSEL_ALL_PANES
Pt_PRINTSEL_FILE_PANE | Pt_PRINTSEL_SETTINGS_PANE
Pt_PRINTSEL_DFLT_LOOK
Pt_PRINTSEL_FILE_PANE | Pt_PRINTSEL_SETTINGS_PANE |
Pt_PRINTSEL_PREFERENCES
Returns:
An integer that indicates which button was pressed:
• Pt_PRINTSEL_PRINT
• Pt_PRINTSEL_PREVIEW
• Pt_PRINTSEL_CANCEL
The Pp_PC_DO_PREVIEW member of the print context is set when the user presses
the Preview button. This means that the context can be passed to the printing function,
which spawn the print-preview application if necessary.
Examples:
See PpContinueJob().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhPoint_t, PpPrintContext_t, PpPrintWidget(), PpSetPC(), PtPrintSelect(),
PtPrintPropSelect()
PtPrintSel in the Photon Widget Reference
“Dialog modules” in the Working with Modules chapter, and the Printing chapter of
the Photon Programmer’s Guide
Synopsis:
void PtProcessEvent( void );
Library:
ph
Description:
This function is used primarily for modal-dialog-event handling. If this case, be sure
to call PtModalStart() before the event-handling loop, and PtModalEnd() after it.
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 blocks until an
event is received.
Before waiting for an event, this function performs an equivalent of
PtLeave(Pt_EVENT_PROCESS_ALLOW). This turns the calling thread into an event
reader if it wasn’t one already. If you passed the Pt_DELAY_EXIT flag to PtEnter()
before calling this function, it will also disable the effect of that flag.
After getting an event, PtProcessEvent() performs an equivalent of PtEnter(0). This
means that if another thread called PtExit() while the function was waiting for an
event, PtProcessEvent() doesn’t invoke any callbacks and will not return.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtModalBlock(), PtModalEnd(), PtModalStart(), PtModalUnblock(),
“Modal dialogs” in the Window Management chapter of the Photon Programmer’s
Guide
Synopsis:
int PtPrompt( PtWidget_t *parent,
PhPoint_t const *location,
char const *title,
PhImage_t const *image,
char const *message,
char const *msgFont,
int btnCount,
char const **buttons,
char const **btnFonts,
int defBtn,
int escBtn,
short textLength,
char *text,
char const *textFont,
PhDim_t const *text_dim,
int flags );
Arguments:
parent A pointer to the parent widget of the dialog (usually a window). By
setting the flags, you can block the parent and/or position the dialog
relative to it.
title The title for the dialog. If you don’t want a title bar, set this argument
to NULL.
msgFont The font for the message text; the default is TextFont09. You should
create the font name by calling PfGenerateFontName().
You need to initialize this buffer, or unwanted characters may appear in the text box.
Library:
ph
Description:
PtPrompt() displays a dialog that prompts you for input, and can contain any number
of buttons so that you can respond. This function is similar to PtAlert(), but lets you
type a line of text. PtPrompt() works modally, which means that it doesn’t return until
you choose a button.
Returns:
The number of the button pressed, or -1 if an error occurred.
Examples:
int answer;
char const *btns[] = { "&OK", "&Cancel" };
char text[31]="Default text";
switch( answer ) {
case 1:
/* ok */
printf("You pressed OK and typed: %s\n", text);
break;
case 2:
/* cancel */
break;
case -1:
printf("An error occurred.\n");
break;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApError(), PfGenerateFontName(), PhDim_t, PhImage_t, PhPoint_t, PtAlert(),
PtNotice(), PtPassword()
“Dialog modules” in the Working with Modules chapter of the Photon Programmer’s
Guide
Synopsis:
int PtPulseArm( PtAppContext_t app,
pid_t pulse,
struct sigevent *msg );
Library:
ph
Description:
This function arms a Photon pulse and creates a “pulse message” to be sent to another
process. The other process can use the pulse message and MsgDeliverEvent() 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. This must be specified as NULL, so that
the default context is used.
The pulse argument is a pulse ID returned by PtAppCreatePulse().
The msg argument points a sigevent that’s filled in by the function. You’ll need to
send it to the process that’s going to deliver the pulse.
Returns:
0 Success.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAppCreatePulse(), PtAppDeletePulse(), PtAppPulseTrigger(), PtChannelCreate()
MsgDeliverEvent() in the QNX Neutrino Library Reference
Interprocess Communication in the Photon Programmer’s Guide
Synopsis:
PhSysInfo_t * PtQuerySystemInfo(
PtWidget_t *widget,
PhSysInfo_t *sys_ptr );
Library:
ph
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(), PhSysInfo_t
“System information” in the Regions chapter of the Photon Programmer’s Guide.
Synopsis:
int PtQuitMainLoop( void );
Library:
ph
Description:
This function causes PtMainLoop() in the calling thread to return right after it finishes
processing the current event.
PtQuitMainLoop() doesn’t affect any modal operations that the thread is currently
doing; if you call PtQuitMainLoop() from within a modal loop, there’s no way for
PtMainLoop() to return until after the modal loop has completed.
Keep in mind that if you let your main() function return, exit() is called and your
application is terminated without letting any widgets or threads do any cleaning up.
It’s better to call PtExit() instead – the main purpose of PtQuitMainLoop()is to let you
terminate threads running PtMainLoop() without terminating the application.
To ensure your application doesn’t terminate, put a pthread_exit() call after the
PtMainLoop() call in main(). In PhAB, changes to main() get overwritten by PhAB, so
you should declare a global header for your application and map PtMainLoop() to
your own function using a macro. For example:
#undef PtMainLoop
void MyMainLoop( void ) {
PtMainLoop();
pthread_exit(NULL);
}
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtExit(), PtMainLoop()
“Threads” in the Parallel Operations chapter of the Photon Programmer’s Guide
Synopsis:
int PtRealizeWidget( PtWidget_t *widget );
Library:
ph
Description:
This function makes a widget and its children visible to the user and possibly
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
Signal handler No
Thread No
See also:
PtCreateWidget(), PtDestroyWidget(), PtUnrealizeWidget()
“Widget life cycle” in the Introduction to the Photon Programmer’s Guide
Synopsis:
int PtReattach( char *device );
Library:
ph
Description:
This function 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.
/net/sam/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 PtRelease( void );
Library:
ph
Description:
This function decrements the hold count, which was previously incremented by a call
to PtHold(). When the count reaches 0, the Photon libraries repair any damaged
widgets.
Returns:
The current hold count, or -1 if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFlush(), PtHold(), PtUpdate()
“Delaying and forcing updates to the display” in the Working with Code chapter of the
Photon Programmer’s Guide
Synopsis:
void PtReleaseTransportCtrl(
PtTransportCtrl_t *ctrl );
Library:
ph
Description:
This function releases the PtTransportCtrl_t structure pointed to by ctrl, as well
as its members.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCreateTransportCtrl(), PtInitDnd(), PtTransportCtrl_t, PtTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
void PtRemoveCallback( PtWidget_t *widget,
unsigned long callback_type,
PtCallbackF_t *callback,
void *data );
Library:
ph
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.
Some types of callback resources have special routines that you should use instead of
this one:
Pt_CB_HOTKEY PtRemoveHotkeyHandler()
Examples:
See PtAddCallback().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddCallback(), PtAddCallbacks(), PtRemoveCallbacks(), PtRemoveEventHandler(),
PtRemoveEventHandlers(), PtRemoveFilterCallback(), PtRemoveFilterCallbacks(),
PtRemoveHotkeyHandler()
PtCallbackInfo_t in the Photon Widget Reference
“Callbacks” in the Managing 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 );
Library:
ph
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.
Some types of callback resources have special routines that you should use instead of
this one:
Pt_CB_HOTKEY PtRemoveHotkeyHandler()
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddCallback(), PtAddCallbacks(), PtRemoveCallback(), PtRemoveEventHandler(),
PtRemoveEventHandlers(), PtRemoveFilterCallback(), PtRemoveFilterCallbacks(),
PtRemoveHotkeyHandler()
PtCallback_t in the Photon Widget Reference
“Callbacks” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
int PtRemoveData( PtDataHdr_t **ptr,
long type,
long subtype );
Library:
ph
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:
• If the remove function returns Pt_END, the node shouldn’t be removed, no action is
taken, and PtRemoveData() returns EOK.
• It the remove function returns Pt_END or Pt_HALT, the data isn’t be freed here as it
may have been freed by the remove function.
Returns:
-1 The data wasn’t found.
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 );
Library:
ph
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(), PtAddEventHandlers(), PtRemoveCallback(),
PtRemoveCallbacks(), PtRemoveEventHandlers() PtRemoveFilterCallback(),
PtRemoveFilterCallbacks(), PtRemoveHotkeyHandler(),
PtCallbackInfo_t in the Photon Widget Reference
“Event handlers” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
void PtRemoveEventHandlers(
PtWidget_t *widget,
PtRawCallback_t const *callback_defs,
int num_handlers );
Library:
ph
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.
For information about the PtRawCallback_t structure, see the Photon Widget
Reference.
Examples:
See PtAddEventHandler().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddEventHandler(), PtAddEventHandlers(), PtRemoveCallback(),
PtRemoveCallbacks(), PtRemoveEventHandler() PtRemoveFilterCallback(),
PtRemoveFilterCallbacks(), PtRemoveHotkeyHandler(),
PtRawCallback_t, Pt_CB_RAW in the Photon Widget Reference
“Event handlers” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
void PtRemoveFilterCallback(
PtWidget_t *widget,
unsigned long event_mask,
PtCallbackF_t *callback,
void *data );
Library:
ph
Description:
This function removes the first callback entry that matches event_mask, callback, and
data. It removes the entry from the Pt_CB_FILTER callback list that belongs to
widget
The callback argument points to a function that takes this form:
Examples:
See PtAddFilterCallback().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddCallback(), PtAddCallbacks(), PtAddEventHandler(), PtAddEventHandlers(),
PtAddFilterCallback(), PtAddFilterCallbacks(), PtAddHotkeyHandler(),
PtRemoveFilterCallbacks()
PtCallbackInfo_t in the Photon Widget Reference
“Event handlers” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
void PtRemoveFilterCallbacks(
PtWidget_t *widget,
PtRawCallback_t const *callback_defs,
int num_handlers );
Library:
ph
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_FILTER callback list that
belongs widget. The num_handlers argument specifies the length of the array.
For information about the PtRawCallback_t structure, see the Photon Widget
Reference.
Examples:
See PtAddFilterCallback().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddCallback(), PtAddCallbacks(), PtAddEventHandler(), PtAddEventHandlers(),
PtAddFilterCallback(), PtAddFilterCallbacks(), PtAddHotkeyHandler(),
PtRemoveFilterCallback()
PtRawCallback_t, Pt_CB_FILTER in the Photon Widget Reference
“Event handlers” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
void PtRemoveHotkeyHandler(
PtWidget_t *widget,
unsigned key_sym_cap,
unsigned key_mods,
short flags,
void *data,
PtCallbackF_t *callback );
Library:
ph
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(), PtRemoveFilterCallback(),
PtRemoveFilterCallbacks()
PtCallbackInfo_t in the Photon Widget Reference
“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 );
Library:
ph
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 Success.
Examples:
PtWidget_t *label, *window1, *window2;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCreateWidget(), PtFindGuardian(), PtGetParent(), PtValidParent(),
PtWidgetParent()
“Ordering widgets” in the Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
int PtReRealizeWidget( PtWidget_t *widget );
Library:
ph
Description:
This function forces the specified widget and all its descendants to unrealize and
rerealize themselves.
!
CAUTION: This function is heavy handed, so use it sparingly. As we add more
advanced geometry negotiation to the widget engine, this function will become
obsolete.
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 );
Library:
ph
Description:
This function sets the size 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 MsgReadv() (see the QNX Neutrino Library Reference).
PtResizeEventMsg() won’t reduce the message buffer beyond a certain minimum size.
This is so that the widget library will continue to function.
PtResizeEventMsg() doesn’t actually reallocate any message buffers. It just sets the
size to be used for them.
The app argument is the address of the application context, a structure that manages
all the data associated with this application. This must be specified as NULL, so that
the default context is used.
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 chapter of the
Photon Programmer’s Guide
Synopsis:
int PtSendEventToWidget( PtWidget_t *widget,
PhEvent_t *event );
Library:
ph
Description:
This function passes the event in the given PhEvent_t structure directly to the given
widget for processing.
The widget expects the event to be followed immediately by the associated set of
rectangles and event data. See the example below.
Returns:
The value returned by the last callback function invoked by the event, or -1 if an error
occurred.
Examples:
// Send a Phantom release event to a widget.
memset( &new_event.rect, -1 ,
sizeof( new_event.rect ) );
if( event ) {
new_event.event = *event;
}
new_event.event.processing_flags = Ph_FAKE_EVENT;
new_event.event.type = Ph_EV_BUT_RELEASE;
new_event.event.subtype = Ph_EV_RELEASE_PHANTOM;;
new_event.pevent.click_count = 1;
new_event.pevent.buttons = Ph_BUTTON_SELECT;
new_event.event.num_rects = 1;
PtSendEventToWidget( widget,
(PhEvent_t *) &new_event);
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhEvent_t, PhEmit(), PhEmitmx(), PhPointerEvent_t
Events chapter of the Photon Programmer’s Guide
Synopsis:
PhArea_t * PtSetAreaFromCanvas(
PtWidget_t *widget,
PhRect_t const *canvas_rect,
PhArea_t *area);
Library:
ph
Description:
This function sets the PhArea_t structure pointed to by 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:
The same pointer as the area argument, or NULL if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhArea_t, PhAreaToRect(), PhRect_t, PhRectToArea()
Synopsis:
PtSetArg( PtArg_t *arg,
long type,
long value,
long len );
Library:
ph
Description:
This macro builds argument lists to be used with PtCreateWidget(), PtSetResources(),
and PtGetResources().
• If the values don’t need to be calculated at runtime, you might be able to use
Pt_ARG() instead to initialize the argument list.
• A common mistake is to think that this macro actually sets the resources. It
doesn’t; be sure to call PtCreateWidget(), PtSetResources(), or PtGetResources().
The arg argument is normally part of an array of PtArg_t data structures. The type
argument contains the resource manifest and value contains the value of the argument
being passed. The way the len argument is used depends on the resource type.
For information on getting and setting resources, see the Manipulating Resources in
Application Code chapter of the Photon Programmer’s Guide.
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(), PtCreateWidget(), PtGetResources(), PtSetResources()
Manipulating Resources in Application Code chapter of the Photon Programmer’s
Guide.
Synopsis:
int PtSetClassStyleMethods(
PtWidgetClassStyle_t *style,
int num_methods,
PtStyleMethods_t *meth_array );
Library:
ph
Description:
This function is similar to PtSetStyleMember(), but lets you specify an array of
(manifest, value) pairs to set multiple members in a single call.
Returns:
0 on success, or the number of the first manifest that wasn’t successfully set.
If the return is greater than 0, subtract 1 from it to determine the index into the array of
manifests. For example, if PtSetClassStyleMethods() returns 1, meth_array[0]
contains the first manifest that couldn’t be set.
Examples:
...
PtStyleMethods_t neon_methods[2] = {
{Pt_STYLE_DRAW, neon_draw},
{Pt_STYLE_SIZING, neon_sizing}
};
...
PtSetClassStyleMethods (neon_style, 2, neon_methods);
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddClassStyle(), PtCreateClassStyle(), PtDupClassStyle(), PtFindClassStyle(),
PtGetStyleMember(), PtGetWidgetStyle(), PtSetStyleMember(), PtSetStyleMembers(),
PtSetWidgetStyle()
Pt_ARG_STYLE resource of PtBasic in the Photon Widget Reference
“Widget Styles” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
PtWidget_t *PtSetParentWidget( PtWidget_t *widget );
Library:
ph
Description:
This function sets the current parent widget. Some widget classes (for example,
windows, lists and menus) call this function when they’re created.
Widgets that belong to the PtContainer class become the current parent widget
when created. If you’re creating multiple PtContainer-class widgets, you must
ensure that each one is placed in the correct container.
To do this, either call PtSetParentWidget() or specify the appropriate widget in the
parent argument to PtCreateWidget().
If the widget argument to PtSetParentWidget() is NULL and you then call
PtCreateWidget() with a Pt_DEFAULT_PARENT parent argument, the new widget has
no parent. It’s easier to create a widget with no parent by calling PtCreateWidget()
with a parent argument of Pt_NO_PARENT.
Returns:
A pointer to the previous parent widget, or NULL if there is none.
Examples:
See PtCreateWidget().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCreateWidget(), PtFindGuardian(), PtGetParent(), PtGetParentWidget(),
PtReparentWidget(), PtValidParent(), PtWidgetParent()
Synopsis:
#define PtSetResource( widget, type, value, len ) ...
Library:
ph
Description:
This function sets a resource for the specified widget. The type argument contains the
resource manifest and value contains the value of the argument being passed. The way
the len argument is used depends on the resource type.
For information on getting and setting resources, 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 The given resources was applied to the widget.
-1 The widget wasn’t modified because it doesn’t contain the given resource or the
value of the resource was the same as that already stored in the widget.
Examples:
Turn the widget blue:
PtWidget_t *widget;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtArg_t, Pt_ARG(), PtGetResource(), PtGetResources(), PtSetArg(),
PtSetResources()
Manipulating Resources in Application Code chapter of the Photon Programmer’s
Guide.
Synopsis:
int PtSetResources( PtWidget_t *widget,
int n_args,
PtArg_t const *args );
Library:
ph
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.
-1 The widget wasn’t modified because it doesn’t contain the given resources or
the values of the resources were the same as those already stored in the widget.
A return code of 0 doesn’t necessarily mean that all the resources were successfully
set. The only way to be sure that a resource was set is to set it, then get it and compare
the values.
Examples:
Turn the widget blue and highlight it:
PtArg_t args[2];
PtWidget_t *widget;
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtArg_t, Pt_ARG(), PtGetResource(), PtGetResources(), PtSetArg(),
PtSetResource()
Manipulating Resources in Application Code chapter of the Photon Programmer’s
Guide.
Synopsis:
int PtSetStyleMember( PtWidgetClassStyle_t *style,
int manifest,
void *value );
Library:
ph
Description:
This function sets the member of the given style associated with the given manifest to
the provided value.
The type of value is dictated by the manifest as follows:
Pt_STYLE_CALC_BORDER
The address of a function of the following form:
Pt_STYLE_CALC_OPAQUE
The address of a function of the following form:
Returns:
0 Success.
Examples:
PtSetStyleMember (neon_style, Pt_STYLE_DRAW, neon_draw);
PtSetStyleMember (neon_style, Pt_STYLE_SIZING, neon_sizing);
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddClassStyle(), PtCreateClassStyle(), PtDupClassStyle(), PtFindClassStyle(),
PtGetStyleMember(), PtGetWidgetStyle(), PtSetClassStyleMethods(),
PtSetStyleMembers(), PtSetWidgetStyle()
Pt_ARG_STYLE resource of PtBasic in the Photon Widget Reference
“Widget Styles” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
int PtSetStyleMembers (
PtWidgetClassStyle_t *style, ... );
Library:
ph
Description:
This function is similar to PtSetStyleMember(), but lets you specify multiple
(manifest, value) pairs at once.
Returns:
0 on success, or the number of manifests that were successfully set.
If the return is greater than 0, it will be less than the number of manifests provided,
because at least one of the manifests couldn’t be set.
Examples:
PtSetStyleMembers( neon_style,
Pt_STYLE_DRAW, neon_draw,
Pt_STYLE_SIZING, neon_sizing,
-1, -1 );
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddClassStyle(), PtCreateClassStyle(), PtDupClassStyle(), PtFindClassStyle(),
PtGetStyleMember(), PtGetWidgetStyle(), PtSetClassStyleMethods(),
PtSetStyleMember(), PtSetWidgetStyle()
Pt_ARG_STYLE resource of PtBasic in the Photon Widget Reference
“Widget Styles” in the Managing Widgets in Application Code chapter of the Photon
Programmer’s Guide
Synopsis:
int PtSetWidgetStyle( PtWidget_t *widget,
char *name );
Library:
ph
Description:
This function causes the provided widget to use the style called name from its widget
class’s style set.
If there isn’t a style called name, this function creates a duplicate of the default style
and calls the copy name. The widget then references this new style. If at a later time
you modify the style, all widgets referencing it reextent (resize) and redraw
themselves.
You can also set the style for a widget instance by setting its Pt_ARG_STYLE resource
(defined by PtBasic). Setting this resource has the same effect as calling
PtSetWidgetStyle().
Returns:
The index of the style selected.
Examples:
See “Widget Styles” in the Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddClassStyle(), PtCreateClassStyle(), PtDupClassStyle(), PtFindClassStyle(),
PtGetStyleMember(), PtGetWidgetStyle(), PtSetClassStyleMethods(),
PtSetStyleMember(), PtSetStyleMembers()
Synopsis:
int PtShowSurface( PtWidget_t *widget,
PtSurface_t *surface );
Library:
ph
Description:
These functions show a control surface, restoring it from a hidden state. The widget
argument specifies the widget owning the surface. The functions differ in how they
identify the control surface:
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtHideSurface(), PtHideSurfaceByAction(), PtHideSurfaceById(),
PtShowSurfaceByAction(), PtSurfaceIsHidden(), PtSurfaceIsShown()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
int PtShowSurfaceByAction(
PtWidget_t *widget,
PtWidgetClassRef_t const *cref ,
unsigned short action_id);
Library:
ph
Description:
This function shows all hidden control surfaces associated with an action. The widget
argument specifies the widget owning the surfaces, while cref and action_id specify
the class and manifest of the action associated with surfaces to be shown.
Returns:
0 if any surfaces were shown by this function, or -1 if no surfaces were affected.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtHideSurface(), PtHideSurfaceByAction(), PtHideSurfaceById(), PtShowSurface(),
PtShowSurfaceById(), PtSurfaceIsHidden(), PtSurfaceIsShown()
Control Surfaces 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:
PtSignalProcF_t my_signal_proc;
The compiler should detect any inconsistencies between the two declarations of
my_signal_proc() and give you an error (which is better than a “pointer mismatch”
warning on the call to PtAppAddSignalProc()).
Classification:
Photon
See also:
PtAppAddSignalProc(), PtAppRemoveSignal()
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 );
Arguments:
cmd The program to be started. If it doesn’t contain a slash, directories listed
in the PATH environment variable are searched.
env Environment variables for the new process. If it’s NULL, the value of the
global variable extern char **environ is used.
cb, data A callback to be called after the child process terminates, and data to pass
to the callback. See “Callback function,” below.
This control structure exists only until the termination callback is called; don’t call
PtSpawnSetCallback() or PtSpawnDeleteCallback() after the callback has been called.
Library:
ph
Description:
This function spawns a new process and optionally installs a callback that’s called
when the child process terminates.
Options
Under QNX Neutrino, PtSpawnOptions_t consists of:
By default, the new process inherits all of the parent’s valid file descriptors whose
values are less than or equal to 9.
If you want to specify a non-NULL value for opt, it’s a good idea to modify a copy of
the default structure. For example:
PtSpawnOptions_t my_opts;
my_opts = PtSpawnDefaults;
my_opts.iov[1] = fd; // Redirect stdout
Callback function
PtSpawnCbF_t is a function type:
If cb isn’t NULL, PtSpawn() attaches a signal handler for SIGCHLD that calls waitpid()
to determine whether the child process has terminated. If waitpid() succeeds, the
function specified by cb is called, and the signal handler is removed.
If cb is NULL, PtSpawn() doesn’t attach any signal handlers or call waitpid().
If you don’t need a callback but you also don’t want to have to worry about zombie
processes, specify cb as PtSpawnNoCb — it’s an empty callback function defined in
the library.
If cb is NULL but csp isn’t, no callback is attached, and *csp is set to NULL.
Returns:
The process ID of the spawned process, or -1 on error.
Errors:
See spawn() in the QNX Neutrino Library Reference.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSpawnSetCallback(), PtSpawnDeleteCallback(), PtSpawnWait()
Synopsis:
void PtSpawnDeleteCallback( PtSpawnCbId_t *cs );
Library:
ph
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 );
Library:
ph
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 );
Library:
ph
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 );
Library:
ph
Description:
This function increments the flux count for the given container, to prevent repairs to
the specified container and to all its children. You can still modify the widgets, but the
damage to them isn’t recorded.
You typically use this function when you’re about to make a lot of changes to the
container and its children, and you don’t want to update the display until you’re done.
When you want repairs to be made, call PtEndFlux().
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(), PtIsFluxing()
“Delaying and forcing updates to the display” in the Working with Code chapter of the
Photon Programmer’s Guide
Synopsis:
int PtSurfaceActionId( PtSurface_t *surface);
Library:
ph
Description:
This macro retrieves the numeric action ID associated with the provided surface.
Returns:
The action ID, or -1 if the provided surface isn’t an action surface.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSurfaceId()
Control Surfaces chapter of the Photon Programmer’s Guide
Library:
ph
Description:
These functions attach data to a control surface belonging to the given widget. They
differ in how they identify the control surface:
PtSurfaceAddData()
Uses the surface argument, which points to a PtSurface_t structure that
describes the control surface. This pointer must not be NULL.
PtSurfaceAddDataById()
Searches the control surfaces belonging to the widget for the one with an ID of
surface_id.
The data arguments points to the data to attach. This data can be anything you need to
store with the surface. Any data previously added to this surface is removed and
overwritten.
The len argument specifies the length (in bytes) of the data. If len is nonzero, then len
bytes of data are copied from the data pointer, and that copy is attached to the surface.
This copy is freed when the data is removed. If len is 0, no copying is performed, and
no deallocation takes place when the data is removed.
Returns:
0 Success.
-1 The operation failed due to a lack of memory, or the specified surface couldn’t
be found.
Classification:
Photon
Co. KG.
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSurfaceGetData(), PtSurfaceGetDataById(), PtSurfaceRemoveData(),
PtSurfaceRemoveDataById()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
PtSurface_t *PtSurfaceBrotherBehind(
PtWidget_t *widget,
PtSurface_t *surface );
Library:
ph
Description:
This function gets the control surface behind the surface described by surface.
Returns:
A pointer to the PtSurface_t structure describing the control surface behind, or
NULL if there isn’t one.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtInsertSurface(), PtInsertSurfaceById(), PtSurfaceInBack(), PtSurfaceInFront(),
PtSurfaceBrotherInFront(), PtSurfaceToBack(), PtSurfaceToBackById(),
PtSurfaceToFront(), PtSurfaceToFrontById()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
PtSurface_t *PtSurfaceBrotherInFront(
PtWidget_t *widget,
PtSurface_t *surface );
Library:
ph
Description:
This function gets the control surface in front of the surface described by surface.
Returns:
A pointer to the PtSurface_t structure describing the control surface in front, or
NULL if there isn’t one.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtInsertSurface(), PtInsertSurfaceById(), PtSurfaceBrotherBehind(),
PtSurfaceInBack(), PtSurfaceInFront(), PtSurfaceToBack(), PtSurfaceToBackById(),
PtSurfaceToFront(), PtSurfaceToFrontById()
Control Surfaces chapter of the Photon Programmer’s Guide
PhRect_t *PtSurfaceCalcBoundingBoxById(
PtWidget_t *widget,
unsigned char surface_id );
Library:
ph
Description:
These functions calculate the bounding box for a control surface. They differ in the
way they identify the control surface:
PtSurfaceCalcBoundingBox()
Uses the surface argument, which points to a PtSurface_t structure that
describes the control surface. This pointer must not be NULL.
PtSurfaceCalcBoundingBoxById()
Searches the control surfaces belonging to the given widget for the one with an
ID of surface_id.
You should call one of these functions whenever you modify the points defining a
surface. Although these functions are mainly targeted as a convenience function for
polygonal surfaces, they also ensure that the upper-left/lower-right corners of a
rectangular or elliptical surface never get inverted.
Returns:
A pointer to a PhRect_t structure that defines the bounding rectangle of the surface.
PtSurfaceCalcBoundingBoxById() returns NULL if it couldn’t find the control surface
with the given ID.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRect_t, PtCalcSurface(), PtCalcSurfaceByAction(), PtCalcSurfaceById(),
PtSurfaceExtent(), PtSurfaceExtentById(), PtSurfaceRect(), PtSurfaceRectById()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
PhRect_t *PtSurfaceExtent(
PtWidget_t *widget,
PtSurface_t const *surface,
PhRect_t *extent );
PhRect_t *PtSurfaceExtentById(
PtWidget_t *widget,
unsigned char surface_id,
PhRect_t *extent );
Library:
ph
Description:
These functions calculate the extent of a control surface belonging to a given widget.
They differ in how they identify the control surface:
The extent argument points to a PhRect_t structure in which the result is stored.
Returns:
The same pointer as extent. PtSurfaceExtentById() returns NULL if it can’t find the
control surface with the given ID.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRect_t, PtCalcSurface(), PtCalcSurfaceByAction(), PtCalcSurfaceById(),
PtSurfaceCalcBoundingBox(), PtSurfaceCalcBoundingBoxById(), PtSurfaceRect(),
PtSurfaceRectById()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
void *PtSurfaceGetData( PtWidget_t *widget,
PtSurface_t *surface );
Library:
ph
Description:
These functions retrieve the user data stored with a control surface belonging to the
given widget. They differ in the way they identify the control surface:
PtSurfaceGetData()
Uses the surface argument, which points to a PtSurface_t structure that
describes the control surface. This pointer must not be NULL.
PtSurfaceGetDataById()
Searches the control surfaces belonging to the widget for the one with an ID of
surface_id.
Returns:
A pointer to the data, or NULL if either the specified surface couldn’t be found, or it
doesn’t have any data attached to it.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSurfaceAddData(), PtSurfaceAddDataById(), PtSurfaceRemoveData(),
PtSurfaceRemoveDataById()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
PtSurface_t *PtSurfaceHit(
PtWidget_t *widget,
PhPoint_t const *point,
unsigned long event_mask,
PtSurface_t const *surface );
Library:
ph
Description:
PtSurfaceHit() finds the control surface, belonging to the given widget, at the
coordinates pointed to by point.
The event_mask specifies the event types to which the control surface must be
sensitive. A value of 0 means any event types.
The surface argument, if not NULL is the control surface to test first.
Returns:
A pointer to the control surface hit by the given point, or NULL if there isn’t one or an
error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhPoint_t, PtSurfaceCalcBoundingBox(), PtSurfaceRect(), PtSurfaceTestPoint()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
unsigned char PtSurfaceId( PtSurface_t *surface);
Library:
ph
Description:
This macro retrieves the numeric ID from a control surface structure.
Returns:
The surface ID.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtSurfaceActionId()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
PtSurface_t *PtSurfaceInBack( PtWidget_t *widget );
Library:
ph
Description:
This function gets the backmost control surface belonging to the given widget.
Returns:
A pointer to the PtSurface_t structure describing the control surface, or NULL if the
widget doesn’t have any control surfaces.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtInsertSurface(), PtInsertSurfaceById(), PtSurfaceBrotherBehind(),
PtSurfaceBrotherInFront(), PtSurfaceInFront(), PtSurfaceToBack(),
PtSurfaceToBackById(), PtSurfaceToFront(), PtSurfaceToFrontById()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
PtSurface_t *PtSurfaceInFront( PtWidget_t *widget );
Library:
ph
Description:
This function gets the frontmost control surface belonging to the given widget.
Returns:
A pointer to the PtSurface_t structure describing the control surface, or NULL if the
widget doesn’t have any control surfaces.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtInsertSurface(), PtInsertSurfaceById(), PtSurfaceBrotherBehind(),
PtSurfaceBrotherInFront(), PtSurfaceInBack(), PtSurfaceToBack(),
PtSurfaceToBackById(), PtSurfaceToFront(), PtSurfaceToFrontById()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
int PtSurfaceIsDisabled( PtSurface_t *surface);
Library:
ph
Description:
This macro evaluates to nonzero if the provided surface is currently disabled.
Otherwise, it evaluates to 0.
Returns:
Nonzero if the surface is disabled, 0 if it’s enabled.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDisableSurface(), PtDisableSurfaceByAction(), PtEnableSurface(),
PtEnableSurfaceByAction(), PtSurfaceIsEnabled()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
int PtSurfaceIsEnabled( PtSurface_t *surface);
Library:
ph
Description:
This macro evaluates to nonzero if the provided surface is currently enabled.
Otherwise, it evaluates to 0.
Returns:
Nonzero if the surface is enabled, 0 if it’s disabled.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDisableSurface(), PtDisableSurfaceByAction(), PtEnableSurface(),
PtEnableSurfaceByAction(), PtSurfaceIsDisabled()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
int PtSurfaceIsHidden( PtSurface_t *surface);
Library:
ph
Description:
This macro evaluates to nonzero if the provided surface is hidden. Otherwise, it
evaluates to 0.
Returns:
Nonzero if the surface is hidden, 0 if it’s shown.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtHideSurface(), PtHideSurfaceByAction(), PtShowSurface(),
PtShowSurfaceByAction(), PtSurfaceIsShown(),
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
int PtSurfaceIsShown( PtSurface_t *surface);
Arguments:
surface A pointer to a PtSurface_t structure that describes the control surface.
Library:
ph
Description:
This macro evaluates to nonzero if the provided surface is being shown. Otherwise, it
evaluates to 0.
Returns:
Nonzero if the surface is shown, 0 if it’s hidden.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtHideSurface(), PtHideSurfaceByAction(), PtShowSurface(),
PtShowSurfaceByAction(), PtSurfaceIsHidden()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
PhRect_t *PtSurfaceRect( PtSurface_t *surface,
PhRect_t *rect );
Library:
ph
Description:
These functions retrieve the bounding box of a control surface. They differ in the way
they identify the control surface:
Returns:
If rect is non-NULL, the result is copied there and the functions return rect. Otherwise,
a pointer to the surface’s internal data is returned.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
Caveats:
PtSurfaceRect() is a macro.
See also:
PhRect_t, PtCalcSurface(), PtCalcSurfaceByAction(), PtCalcSurfaceById(),
PtSurfaceCalcBoundingBox(), PtSurfaceCalcBoundingBoxById(), PtSurfaceExtent(),
PtSurfaceExtentById()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
int PtSurfaceRemoveData( PtWidget_t *widget,
PtSurface_t *surface );
Library:
ph
Description:
These functions remove user data from a control surface belonging to the given
widget. They differ in the way they identify the control surface:
PtSurfaceRemoveData()
Uses the surface argument, which points to a PtSurface_t structure that
describes the control surface. This pointer must not be NULL.
PtSurfaceRemoveDataById()
Searches the control surfaces belonging to the widget for the one with an ID of
surface_id.
If, when the data was added, the len argument was nonzero, the copy of the data that
was made is automatically freed, otherwise no deallocation takes place.
Returns:
-1 The control surface or data wasn’t found.
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:
PtSurfaceAddData(), PtSurfaceAddDataById(), PtSurfaceGetData(),
PtSurfaceGetDataById()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
int PtSurfaceTestPoint( PtSurface_t const *surface,
PhPoint_t const *point );
Library:
ph
Description:
This function determines whether or not the given point is inside the control surface
described by the structure pointed to by surface.
Returns:
A nonzero value if the point is inside the control surface, or zero if it isn’t.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhPoint_t, PtSurfaceCalcBoundingBox(), PtSurfaceHit(), PtSurfaceRect()
Control Surfaces chapter of the Photon Programmer’s Guide
Library:
ph
Description:
These functions move a control surface behind all other control surfaces belonging to
the given widget. They differ in how they identify the control surface:
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtInsertSurface(), PtInsertSurfaceById(), PtSurfaceBrotherBehind(),
PtSurfaceBrotherInFront(), PtSurfaceInBack(), PtSurfaceInFront(),
PtSurfaceToFront(), PtSurfaceToFrontById()
Control Surfaces chapter of the Photon Programmer’s Guide
Library:
ph
Description:
These functions move a surface in front of all other surfaces belonging to the given
widget. They differ in how they identify the control surface:
PtSurfaceToFront()
Uses the surface argument, which points to a PtSurface_t structure that
describes the control surface. This pointer must not be NULL.
PtSurfaceToFrontById()
Searches the control surfaces belonging to the widget for the one with an ID of
surface_id.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtInsertSurface(), PtInsertSurfaceById(), PtSurfaceBrotherBehind(),
PtSurfaceBrotherInFront(), PtSurfaceInBack(), PtSurfaceInFront(),
PtSurfaceToBack(), PtSurfaceToBackById()
Synopsis:
int PtSyncWidget( PtWidget_t *widget );
Library:
ph
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 );
Library:
ph
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.
You typically use this routine when you’re building custom widgets. Some widgets
(such as PtTerminal) already use this type of timer, so calling PtTimerArm() may
have unexpected results.
To disarm any timers that might be pending for the widget, call PtTimerArm() with
msec set to 0.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhTimerArm(), RtTimerCreate(), RtTimerDelete(), RtTimerGetTime(),
RtTimerSetTime()
“Timers” in the Working with Code chapter of the Photon Programmer’s Guide
Synopsis:
typedef struct ptdatatransctrl PtTransportCtrl_t;
struct ptdatatransctrl {
PtTransportHdr_t hdr;
PhTransportCtrl_t *ctrl;
PtWidget_t *widget;
PtRequestables_t *requestables;
PtRequestedLink_t *requested;
PhTransportLink_t *response;
PhTransportLink_t *last_response;
PtConnector_t *connector;
PtConnectionServer_t *connection;
int (*complete)(
PtTransportCtrl_t *tctrl,
short unsigned event_subtype );
void *data;
};
Description:
The PtTransportCtrl_t structure is used with the Photon transport mechanism in a
drag-and-drop operation. Your application can pack multiple pieces of data into a
single control structure and transport them simultaneously. Data can be packed inline
or can be requestable.
The PtTransportCtrl_t structure includes:
hdr Information about the connection and the size of the structure.
requested A list of data that the destination of the operation has requested.
Classification:
Photon
See also:
PhTransportCtrl_t, PhTransportLink_t, PtAddResponseType(),
PtCreateTransportCtrl(), PtInitDnd(), PtReleaseTransportCtrl(), PtTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
PtRequestables_t *
PtTransportRequestable(
PtTransportCtrl_t *ctrl,
char const * const type,
char const * const desc,
int unsigned const flags,
int unsigned transport,
PtTransportReqDataCB_t *rq_callback,
void *rq_callback_data );
Arguments:
ctrl A pointer to the PtTransportCtrl_t control structure for the
drag-and-drop operation.
If this bit is set, any modifications to the data that occur between packing and actual
transport of the data will be reflected in the data transported.
transport The available transport types that can be specified when
requesting data from the source:
Ph_TRANSPORT_INLINE
The data being transported is in memory and can be
unpacked immediately.
Ph_TRANSPORT_FILEREF
The data being transported is in the temporary file(s)
named in the inlined data.
Ph_TRANSPORT_SHMEM
The data being transported is in the temporary shared
object(s) named in the inlined data.
Ph_TRANSPORT_STREAM
The data being transported will be inlined a small piece at
a time.
Ph_TRANSPORT_NAMED_STREAM
The data being transported will be inlined a small piece at
a time. The streamed data is named so multiple streams
of data can be transferred serially.
Ph_TRANSPORT_FILE_STREAM
The contents of files streamed using extended named
streams. This is like the named stream but with extra
information with each data block, including file
information and so on. The requester of data must choose
one of the available request transport types when
requesting delivery of additional data.
Library:
ph
Description:
This function adds an entry for requestable data to the data being packed up for a
drag-and-drop operation. It’s called by the source widget when it’s starting the
operation.
PtReqResponseHdr_t structure
The PtReqResponseHdr_t data structure determines how a data request is
responded to. It’s defined as:
typedef struct req_resp_msg_hdr PtReqResponseHdr_t;
struct req_resp_msg_hdr {
int unsigned transport;
int unsigned cmd;
int unsigned chunk_size;
int total_size;
int unsigned byte_offset;
void * source_handle;
void * dest_handle;
int unsigned data_size;
};
This structure’s members can be used in the callback function as described below:
chunk_size The size of the data that the client will accept. If this is too small,
return Pt_END from the callback to make the request fail.
total_size The size of data to be sent to the destination. This is equal to
chunk_size if you’re not streaming.
byte_offset The offset into the data from which to start sending data. This is
useful for streams of data.
source_handle An identifier for the source that’s passed back in this member if
more than one transmission is required to provide the requested
data. The destination shouldn’t modify this member.
dest_handle An identifier for the destination that’s passed back in this member
if more than one transmission is required to provide the requested
data. The source shouldn’t modify this member.
data_size If you’re responding with packed data, this is the packed size, not
the unpacked size.
Returns:
0 Success.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtAddResponseType(), PtCreateTransportCtrl(), PtInitDnd(), PtTransportCtrl_t,
PtTransportType()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
int PtTransportType(
PtTransportCtrl_t *ctrl,
char const * const type,
char const * const desc,
int unsigned const grouping_num,
int unsigned inlined_transport,
char *packing_type,
void *vdata,
int unsigned len,
int unsigned const flags );
Arguments:
ctrl A pointer to the PtTransportCtrl_t control structure for the
drag-and-drop operation. Multiple data blocks can be packed
into the same PtTransportCtrl_t.
This structure must have been created via a call to
PtCreateTransportCtrl().
grouping_num When used with Photon’s drag and drop mechanism, the
grouping_num is used to indicate which stream is just a
different representation of other data also packed into the same
PhTransportCtrl_t structure. Only one of each
grouping_num should be unpacked by the reader/destination.
This value is simply added to the header for the packed data.
inlined_transport The transport type to be used for the inlined data. This may be
one of:
• Ph_TRANSPORT_INLINE — the data being transported is in
memory and can be unpacked immediately.
• Ph_TRANSPORT_FILEREF — the data being transported is
in the temporary file(s) named in the inlined data.
• Ph_TRANSPORT_SHMEM — the data being transported is in
the temporary shared object(s) named in the inlined data.
• Ph_TRANSPORT_STREAM — the data being transported
will be inlined a small piece at a time.
• Ph_TRANSPORT_NAMED_STREAM — the data being
transported will be inlined a small piece at a time. The
streamed data is named so multiple streams of data can be
transferred serially.
• Ph_TRANSPORT_FILE_STREAM — the contents of files
streamed using extended named streams. This is like the
named stream but with extra information with each data
block, including file information and so on.
If this bit is set, any modifications to the data that occur between packing and actual
transport of the data will be reflected in the data transported.
Library:
ph
Description:
This function is used to pack inline data for a drag-and-drop operation. It’s called by
the source widget.
Returns:
0 Success.
-1 The call has failed; errno is set.
Errors:
EINVAL One of the following occurred:
• One of the parameters was passed incorrectly.
• No transport control was provided.
• No data was provided via vdata.
• No inlined_transport was specified.
ENOENT No transport registry entry was found for the provided packing_type.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhTransportCtrl_t, PtCreateTransportCtrl(), PtInitDnd(),
PtTransportCtrl_t, PtTransportRequestable()
Drag and Drop chapter of the Photon Programmer’s Guide
Synopsis:
void PtUnblockWindows( PtBlockedList_t *bl );
Library:
ph
Description:
This function unblocks windows that were blocked by PtBlockAllWindows() or
PtBlockWindow() and restores their cursors.
The bl argument must either be NULL or the pointer to a control structure returned by
PtBlockAllWindows() or PtBlockWindow().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
ApModalWait(), PtBlockAllWindows(), PtBlockWindow(), PtMakeModal()
“Modal dialogs” in the Window Management chapter of the Photon Programmer’s
Guide
Synopsis:
int PtUnlinkData( PtDataHdr_t **ptr,
PtDataHdr_t *node );
Library:
ph
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 );
Library:
ph
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.
Unrealizing and realizing a widget can take some time. If you want to hide a widget
quickly, you can set its Pt_ARG_POS to a very negative value. You should also set
Pt_BLOCKED in its Pt_ARG_FLAGS so the widget won’t get focus.
Returns:
0 Successful completion.
-1 An error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtDestroyWidget(), PtRealizeWidget()
“Widget life cycle” in the Introduction to the Photon Programmer’s Guide
Synopsis:
int PtUpdate( void );
Library:
ph
Description:
This function decrements the hold count, which was previously incremented by a call
to PtHold(). When the count reaches 0, the Photon libraries repair any damaged
widgets.
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()
“Delaying and forcing updates to the display” in the Working with Code chapter of the
Photon Programmer’s Guide
Synopsis:
PtWidget_t * PtValidParent(
PtWidget_t *widget_parent,
PtWidgetClassRef_t *class_ref );
Library:
ph
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, PtMeter, 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 Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
unsigned char PtWidgetActiveSurface( PtWidget_t *widget );
Library:
ph
Description:
This macro retrieves the provided widget’s currently “active” surface. The active
surface is the last surface that consumed an event of type Ph_EV_BUT_PRESS.
Returns:
The ID of the currently active control surface, or 0 if there isn’t one.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtFindSurface(), PtFindSurfaceByAction()
Control Surfaces chapter of the Photon Programmer’s Guide
Synopsis:
PhArea_t * PtWidgetArea( PtWidget_t *widget,
PhArea_t *area );
Library:
ph
Description:
This macro 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);
Arguments:
widget A pointer to the widget whose brother you want to find.
Library:
ph
Description:
This macro returns a pointer to the brother behind widget. If there’s no brother behind
widget, the macro returns NULL.
Examples:
#include <stdlib.h>
#include <Pt.h>
int main ()
{
PtWidget_t *window, *group, *child;
PtArg_t argt[5];
char *name;
if (PtInit(NULL) == -1)
exit(EXIT_FAILURE);
PtRealizeWidget (window);
PtMainLoop();
return EXIT_SUCCESS;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetBrotherInFront(), PtWidgetChildBack(), PtWidgetChildFront(),
PtWidgetParent()
“Ordering widgets” in the Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
PtWidget_t *PtWidgetBrotherInFront(
PtWidget_t *widget );
Arguments:
widget A pointer to the widget whose brother you want to find.
Library:
ph
Description:
This macro returns a pointer to the brother in front of widget. If there’s no brother in
front of widget, the macro returns NULL.
Examples:
See PtWidgetBrotherBehind().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtWidgetBrotherBehind(), PtWidgetChildBack(), PtWidgetChildFront(),
PtWidgetParent()
“Ordering widgets” in the Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
PtWidget_t *PtWidgetChildBack( PtWidget_t *widget );
Library:
ph
Description:
This macro returns a pointer to the child that’s farthest back in the specified container
widget. If widget doesn’t have any children, the macro returns NULL.
Examples:
#include <stdlib.h>
#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, Pt_DEFAULT_PARENT,
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 Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
PtWidget_t *PtWidgetChildFront(
PtWidget_t *widget );
Library:
ph
Description:
This macro returns a pointer to the child at the very front of the specified container
widget. If widget doesn’t have any children, the macro 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 Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
PtWidgetClassRef_t *PtWidgetClass(
PtWidget_t *widget );
Library:
ph
Description:
This macro 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 );
Library:
ph
Description:
This macro retrieves widget’s class structure flags:
Pt_NO_INHERITED_RESOURCES
Prevents the search for a resource from walking up through
superclasses. Only the resources for this class are handled; all
others are ignored. This doesn’t prevent resources from being
propagated to procreated widgets.
This is handy for allowing common resources such as
Pt_ARG_COLOR to pass to procreated children without having
to write a resource-redirection function.
Pt_RECTANGULAR
Rectangular widgets are opaque when filled. Opaque widgets
don’t damage widgets below them when they are modified
(unless their size or position is modified).
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 );
Library:
ph
Description:
This macro 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 );
Library:
ph
Description:
This macro 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.
A widget’s extent isn’t calculated until the widget is either realized or forced to
calculate the extent by a call to PtExtentWidget(). If the widget hasn’t been realized,
be sure to call PtExtentWidget() first.
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()
“Widget geometry” in the Introduction to the Photon Programmer’s Guide
Synopsis:
PtWidget_t *PtWidgetFamily( PtWidget_t *root,
PtWidget_t *current );
Library:
ph
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, Pt_DEFAULT_PARENT,
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 Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
long PtWidgetFlags( PtWidget_t *widget );
Library:
ph
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 );
Arguments:
container A pointer to the container to be searched for widgets.
Library:
ph
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).
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:
PhPoint_t, PtContainerHit()
Synopsis:
int PtWidgetInsert ( PtWidget_t *widget,
PtWidget_t *new_sibling,
int behind );
Library:
ph
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.
Remember that the focus order goes from the back of the widget family hierarchy to
the front.
For example, if you have widget A and widget C with a focus order of A→C, you can
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(), PtWidgetParent(), PtWidgetToBack(),
PtWidgetToFront()
“Ordering widgets” in the Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
int PtWidgetIsClass( PtWidget_t *widget,
PtWidgetClassRef_t *class );
Library:
ph
Description:
This macro 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 );
Library:
ph
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 );
Library:
ph
Description:
This macro 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:
PhDim_t *PtWidgetMinimumSize(
PtWidget_t const *widget,
PhDim_t *dim );
Library:
ph
Description:
This function calculates the minimum size a widget can be, taking into account its
current border sizes, resize policy, and value for its Pt_ARG_MINIMUM_DIM
resource.
The resulting dimension is stored in the PhDim_t structure pointed to by dim.
Returns:
A pointer to the PhDim_t structure that was passed in.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhDim_t, PtWidgetPreferredSize()
Synopsis:
PhPoint_t *PtWidgetOffset( PtWidget_t *widget,
PhPoint_t *offset );
Library:
ph
Description:
This function determines the offset of widget’s origin from its disjoint parent widget
and stores it in the PhPoint_t structure pointed to by offset.
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
Thread No
See also:
PhPoint_t, PhTranslateRect(), PtGetAbsPosition()
Synopsis:
PtWidget_t *PtWidgetParent( PtWidget_t *widget );
Library:
ph
Description:
This macro returns a pointer to the parent of the specified widget. If no parent exists,
the macro returns NULL.
Examples:
See PtValidParent().
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PtCreateWidget(), PtFindGuardian(), PtGetParent(), PtGetParentWidget(),
PtReparentWidget(), PtSetParentWidget(), PtValidParent(), PtWidgetBrotherBehind(),
PtWidgetBrotherInFront(), PtWidgetChildBack(), PtWidgetChildFront()
“Ordering widgets” in the Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
PhDim_t *PtWidgetPreferredSize(
PtWidget_t const *widget,
PhDim_t *dim );
Library:
ph
Description:
This function retrieves the optimal size of a widget, which is recorded whenever the
widget calls PtResizeCanvas() or PtAttemptResize() while calculating its extent (see
Building Custom Widgets).
The preferred size is the size the widget would be if Pt_RESIZE_XY_ALWAYS were
set in its Pt_ARG_RESIZE_FLAGS. The preferred size is never any smaller than the
widget’s minimum size. The resulting dimension is stored in the PhDim_t structure
pointed to by dim.
Returns:
A pointer to the PhDim_t structure that was passed in.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhDim_t, PtWidgetMinimumSize()
PtAttemptResize(), PtResizeCanvas() in Building Custom Widgets
Synopsis:
PhRid_t PtWidgetRid( PtWidget_t *widget );
Library:
ph
Description:
This macro returns the region ID of the specified widget. If widget doesn’t have a
region, the macro 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 );
Library:
ph
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 Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
int PtWidgetToBack( PtWidget_t *widget );
Library:
ph
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.
This function doesn’t work for PtWindow widgets — their positions are controlled by
the Window Manager. To move a window to the back of the workspace, use
PtWindowToBack(), which is described in the Photon Widget Reference.
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
#include <stdlib.h>
#include <Pt.h>
int main ()
{
PtWidget_t *window, *group, *child, *child2, *child3;
PtArg_t argt[5];
char *name;
if (PtInit(NULL) == -1)
exit(EXIT_FAILURE);
PtWidgetToFront (child2);
PtWidgetToBack (child3);
PtRealizeWidget (window);
PtMainLoop();
return EXIT_SUCCESS;
}
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 Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
int PtWidgetToFront( PtWidget_t *widget );
Library:
ph
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.
This function doesn’t work for PtWindow widgets — their positions are controlled by
the Window Manager. To move a window to the front of the workspace, use
PtWindowToFront(), which is described in the Photon Widget Reference.
Returns:
0 Successful completion.
-1 An error occurred.
Examples:
See PtWidgetToBack().
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 Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
int PtWidgetTree( PtWidget_t *root,
PtWidget_t **cur,
int D );
Library:
ph
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.
This function performs a simple traversal of the widget tree. If you need more control
over how the tree is traversed (for example, specifying the direction, or skipping
certain branches), use PtWidgetTreeTraverse().
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.
Examples:
PtWidget_t *cur, *window;
int d;
.
.
.
cur=window
d=Pt_TRAVERSE_START;
while( ( d=PtWidgetTree( window, &cur, d ) ) !=
Pt_TRAVERSE_DONE)
PtSetResources( cur, 1, argt );
.
.
.
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 Managing 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 );
Library:
ph
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 );
}
Example 3 — Find the frontmost widget in ABW_pane1 that isn’t within a disjoint
child:
#define FOUND_DISJOINT 0x10
.
.
.
dir = Pt_TRAVERSE_START;
Example 4 — Walk the widget family hierarchy from the frontmost descendant within
ABW_pane1 back to ABW_base (skipping disjoint subhierarchies):
.
.
.
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 Managing Widgets in Application Code chapter of the
Photon Programmer’s Guide
Synopsis:
int PtWidgetVisibleExtent ( PtWidget_t *widget,
PhRect_t *rect );
Library:
ph
Description:
This function determines the portion of a rectangle, defined in the PhRect_t pointed
to by rect, that isn’t clipped by any parent of widget.
Returns:
0 No portion of rect is visible
1 Success — rect contains the portion of the original rectangle that isn’t clipped
by any of widget’s parents
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRect_t
Synopsis:
int PtWindowConsoleSwitch( PhRid_t rid );
Library:
ph
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()
Window Management chapter of the Photon Programmer’s Guide
Synopsis:
int PtWindowGetFrameSize( PtWidget_t *window,
PhRect_t *rect );
Arguments:
window The window you want to query the size of.
rect A pointer to a PhRect_t in which the function stores the size of the
window.
Library:
ph
Description:
This function determines the size of the frame for the window pointed to by window.
The results are stored in the PhRect_t structure pointed to by rect; each member
gives the size of a different part of the frame:
Returns:
0 Success.
Errors:
EINVAL The widget given isn’t a window.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PhRect_t, PtCalcCanvas(), PtWidgetArea(), PtWidgetDim(), PtWidgetExtent()
Window Management chapter of the Photon Programmer’s Guide
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:
PtWorkProcF_t my_work_proc;
The compiler should detect any inconsistencies between the two declarations of
my_work_proc() and give you an error (which is better than a “pointer mismatch”
warning on the call to PtAppAddWorkProc()).
Classification:
Photon
See also:
PtAppAddWorkProc()
Parallel Operations in the Photon Programmer’s Guide
These functions extend Photon’s basic functionality. Using them, you can:
PxConfig*() functions are provided in two versions. The standard versions work on a
single configuration file at a time. The PxConfig*Cx() versions can work on multiple
configuration files concurrently.
These functions are supplied only in static form in the Photon library phexlib. You’ll
need to link with this library explicitly.
Synopsis:
#include <photon/PxProto.h>
Arguments:
cx PxConfigCloseCx() only. The configuration file handle for the file you want to
close. This handle is returned by PxConfigOpenCx().
Library:
phexlib
Description:
These functions close a configuration file, and release all the resources associated with
that file.
PxConfigClose() closes the currently opened configuration file (opened using
PxConfigOpen()). It doesn’t do anything and returns Pt_FALSE if there’s no currently
opened configuration file.
PxConfigCloseCx() closes the configuration file indicated by cx (opened using
PxConfigOpenCx()). It doesn’t do anything and returns Pt_FALSE if cx is NULL.
Returns:
Pt_TRUE The file was opened and is now closed.
Pt_FALSE No file was open, cx was NULL, or there was an error updating the file
to reflect the new configuration.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen*()
Synopsis:
#include <photon/PxProto.h>
Arguments:
cx PxConfigDeleteEntryCx() only. The configuration file handle for the file
you want to delete an entry from. This handle is returned by
PxConfigOpenCx().
Library:
phexlib
Description:
These functions delete the entry entry from the section section in a 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>
Arguments:
cx PxConfigDeleteSectionCx() only. The configuration file handle for the file
you want to delete a section from. This handle is returned by
PxConfigOpenCx().
Library:
phexlib
Description:
These functions delete the section section from the configuration file.
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*()
Arguments:
cx PxConfigFirstSectionCx() only. The configuration file handle for the file you
want to seek in. This handle is returned by PxConfigOpenCx().
Library:
phexlib
Description:
These functions seek the start of the first section, and return the name of this section;
this section is made the internal current section. These functions may be used to
process a configuration file consisting of unknown sections, but where each section
has known entries. If there are no sections, the function returns NULL.
PxConfigFirstSection() works on the currently open configuration file opened by
PxConfigOpen(), while PxConfigFirstSectionCx() works on the configuration file
indicated by cx.
Returns:
A string containing the first section name if one exists, NULL otherwise
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigNextEntry*(), PxConfigNextSection*(), PxConfigNextString*(),
PxConfigOpen*(), PxConfigSection*()
Arguments:
cx PxConfigForceEmptySectionCx() only. The configuration file handle for
the file you want to write to. This handle is returned by
PxConfigOpenCx().
Library:
phexlib
Description:
These functions create an empty section section if one doesn’t exist.
The configuration file must have been opened by PxConfigOpen*() with a mode of
PXCONFIG_WRITE.
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*()
Arguments:
cx PxConfigNextEntryCx() only. The configuration file handle for the file you
want to get the next string in. This handle is returned by PxConfigOpenCx().
value If passed in as a non-NULL pointer, the function fills this in with pointer to
a string containing the value of the next entry.
Library:
phexlib
Description:
These functions return the next entry in the current section as a pointer to a string. A
pointer to the entry name is returned, and value is filled in with a pointer to the string
containing its configuration 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.
These functions are similar to PxConfigNextString*(), but because they don’t copy the
string, they are faster.
If there is no current section (for example, if the file has just been opened),
PxConfigNextEntry*() seeks to the beginning of the first section, and returns the first
entry.
Returns:
A string containing the next entry name within the current section if one exists, NULL
otherwise.
If PxConfigNextEntry*() detects the end of the section, it returns NULL. If you call
PxConfigNextEntry() again, it gets the next entry in the next section.
Classification:
Photon
Co. KG.
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigFirstSection*(), PxConfigNextEntry*(), PxConfigNextSection*(),
PxConfigOpen*(), PxConfigSection*()
Arguments:
cx PxConfigNextSectionCx() only. The configuration file handle for the file you
want to seek in. This handle is returned by PxConfigOpenCx().
Library:
phexlib
Description:
These functions seek the start of the next section, and return the name of this section;
this section is made the internal current section. These functions may be used to
process a configuration file consisting of unknown sections, but where each section
has known entries. If there aren’t any more sections (that is, the current section is the
last section) the function returns NULL, but the current section and file pointer are left
untouched.
PxConfigNextSection() works on the currently open configuration file opened by
PxConfigOpen(), while PxConfigNextSectionCx() works on the configuration file
indicated by cx.
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:
PxConfigFirstSection*(), PxConfigNextEntry*(), PxConfigNextString*(),
PxConfigOpen*(), PxConfigSection*()
Arguments:
cx PxConfigNextStringCx() only. The configuration file handle for the file
you want to get the next string in. This handle is returned by
PxConfigOpenCx().
Library:
phexlib
Description:
These functions return 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
characters including trailing NULL) 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.
If there is no current section (for example, if the file has just been opened),
PxConfigNextString*() seeks to the beginning of the first section, and returns the first
entry.
Returns:
A string containing the next entry name within the current section if one exists, NULL
otherwise.
If PxConfigNextString*() detects the end of the section, it returns NULL. If you call
PxConfigNextString() again, it gets the next entry in the next section.
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:
PxConfigFirstSection*(), PxConfigNextEntry*(), PxConfigNextSection*(),
PxConfigOpen*(), PxConfigSection*()
Synopsis:
#include <photon/PxProto.h>
Arguments:
cfgfile The configuration file to open
mode A bitfield specifying what operations may be performed on the
configuration file; it consists of a combination of the following values:
PXCONFIG_READ Open the file for reading only. The file must exist.
PXCONFIG_WRITE Allow reading and modification of an existing config
file (using PxConfigWrite*() and
PxConfigDelete*()), or create a new config file if
one doesn’t exist.
PXCONFIG_CLEAR (formerly PXCONFIG_CREATE)
Clear the file by removing all entries and sections.
This flag only applies when PXCONFIG_WRITE is
set. PXCONFIG_CREATE is deprecated.
Depending on which of the above flags are set for mode, it can take a
combination of these additional flags:
PXCONFIG_UNLINK
Remove the file after it’s been read by calling
unlink() on it. If it is a symbolic link, just the link is
removed. This setting is useful for “read-once”
scenarios, or if your application wishes to migrate
the config file from one location to another. This flag
only applies if PXCONFIG_READ is set.
PXCONFIG_HOME Interpret cfgfile as a path relative to the user’s Photon
configuration path, which is always >$HOME/.ph/.
If this flag is set, the real file PxConfigOpen()
attempts to open is a concatenation of this path and
cfgfile.
PXCONFIG_GLOBAL
Interpret cfgfile as a path relative to the system-wide
Photon configuration area, which is currently is
always $PHOTON_PATH/config/. If this flag is set,
the real file PxConfigOpen() attempts to open is a
concatenation of this path and cfgfile.
Library:
phexlib
Description:
These functions open the configuration file specified by cfgfile for reading and/or
writing. The file should be closed using the corresponding PxConfigClose*() when the
configuration procedure is complete.
With PxConfigOpen(), you may have only one configuration file open any one time. If
there is a file already open, it is first closed and PxConfigOpen() attempts to open the
new file regardless of whether or not the close of the old file succeeded. The return
code from PxConfigOpen() in this case reflects the status of the open of the new file,
and does not indicate whether or not the old file was successfully closed. To avoid this
ambiguity, you should always call PxConfigClose() on an open file prior to opening a
new one.
You can use PxConfigOpenCx() to open more than one configuration file. The
PxCfgContext_t * returned from this function is the configuration file handle you
use to manage multiple files, and you pass it as the cx argument to other
PxConfig*Cx() functions.
The configuration file consists of simple text and is divided into sections, introduced
by [section_name]. Each section is made up of entries (one per line) of the form:
entry_name = value
Lines (entry name and value) are currently limited to 1024 characters; lines longer
than that are truncated. Comments follow #, anywhere on a line. Here’s an example:
[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
You can use duplicate section names in configuration files, although it is not
recommended. Functions such as PxConfigSection*() that directly reference a section
by name, will return or operate on the first matched section in a file. To advance to the
next section with the same name, you have to use PxConfigNextSection*() until you
reach the desired section.
Returns:
PxConfigOpen():
Pt_TRUE The given configuration file has been opened for the specified mode.
Pt_FALSE Otherwise.
PxConfigOpenCx():
NULL Otherwise.
Examples:
if (PxConfigOpen(fname, PXCONFIG_READ)) {
// read parameters from the file
PxConfigClose();
}
For user “joe” with home directory /home/joe, first attempt to open
/home/joe/.ph/foo/bar.cfg for read. Failing that, try
/usr/photon/config/foo/bar.cfg (assuming the default setting for
PHOTON_PATH):
PxConfigOpen("foo/bar.cfg",PXCONFIG_READ
| PXCONFIG_HOME | PXCONFIG_GLOBAL);
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigClose*(), PxConfigDeleteEntry*(), PxConfigDeleteSection*(),
PxConfigFirstSection*(), PxConfigForceEmptySection*(), PxConfigNextSection*(),
PxConfigNextString*(), PxConfigReadBool*(), PxConfigReadChar*(),
PxConfigReadDouble*(), PxConfigReadInt*(), PxConfigReadLLong*(),
PxConfigReadLong*(), PxConfigReadShort*(), PxConfigReadString*(),
PxConfigSection*(), PxConfigWriteBool*(), PxConfigWriteChar*(),
PxConfigWriteDouble*(), PxConfigWriteInt*(), PxConfigWriteLLong*(),
PxConfigWriteLong*(), PxConfigWriteShort*(), PxConfigWriteString*()
Arguments:
cx PxConfigReadBoolCx() only. The configuration file handle for the file you
want to read from. This handle is returned by PxConfigOpenCx().
dflt The default to store in value if the specified section or entry don’t exist,
or if the entry value is not ON or OFF, YES or NO, TRUE or FALSE
(case-insensitive).
value A pointer to an int where the function stores the value it reads.
Library:
phexlib
Description:
These functions read a Boolean parameter from a configuration file.
PxConfigReadBool() reads from the currently open configuration file opened by
PxConfigOpen(), while PxConfigReadBoolCx() reads from the configuration file
indicated by cx.
Returns:
Pt_TRUE if the required section/entry exists and the given value is valid, otherwise
Pt_FALSE.
Co. KG.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen*(), PxConfigReadChar*(), PxConfigReadDouble*(),
PxConfigReadInt*(), PxConfigReadLLong*(), PxConfigReadLong*(),
PxConfigReadShort*(), PxConfigReadString*(), PxConfigWriteBool*(),
PxConfigWriteChar*(), PxConfigWriteDouble*(), PxConfigWriteInt*(),
PxConfigWriteLLong*(), PxConfigWriteLong*(), PxConfigWriteShort*(),
PxConfigWriteString*()
Arguments:
cx PxConfigReadCharCx() only. The configuration file handle for the file
you want to read from. This handle is returned by PxConfigOpenCx().
dflt The default to store in value if the specified section or entry don’t exist,
or if the value is not a digit (signed and unsigned) within the char range,
or a single letter,
value A pointer to an char where the function stores the value it reads.
Library:
phexlib
Description:
These functions read a character parameter from a configuration file.
PxConfigReadChar() reads from the currently open configuration file opened by
PxConfigOpen(), while PxConfigReadCharCx() reads from the configuration file
indicated by cx.
Returns:
Pt_TRUE if the required section/entry exists and the given value is valid, otherwise
Pt_FALSE.
Co. KG.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen*(), PxConfigReadBool*(), PxConfigReadDouble*(),
PxConfigReadInt*(), PxConfigReadLLong*(), PxConfigReadLong*(),
PxConfigReadShort*(), PxConfigReadString*(), PxConfigWriteBool*(),
PxConfigWriteChar*(), PxConfigWriteDouble*(), PxConfigWriteInt*(),
PxConfigWriteLLong*(), PxConfigWriteLong*(), PxConfigWriteShort*(),
PxConfigWriteString*()
Arguments:
cx PxConfigReadDoubleCx() only. The configuration file handle for the file
you want to read from. This handle is returned by PxConfigOpenCx().
dflt The default to store in value if the specified section or entry don’t exist.
value A pointer to a double where the function stores the value it reads.
Library:
phexlib
Description:
These functions read a double-precision float parameter from a configuration file.
PxConfigReadDouble() reads from the currently open configuration file opened by
PxConfigOpen(), while PxConfigReadDoubleCx() reads from the configuration file
indicated by cx.
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*(),
PxConfigReadLLong*(), PxConfigReadLong*(), PxConfigReadShort*(),
PxConfigReadString*(), PxConfigWriteBool*(), PxConfigWriteChar*(),
PxConfigWriteDouble*(), PxConfigWriteInt*(), PxConfigWriteLLong*(),
PxConfigWriteLong*(), PxConfigWriteShort*(), PxConfigWriteString*()
Synopsis:
#include <photon/PxProto.h>
Arguments:
cx PxConfigReadIntCx() only. The configuration file handle for the file you
want to read from. This handle is returned by PxConfigOpenCx().
dflt The default to store in value if the specified section or entry don’t exist,
or if the entry value is not a valid integer (see below).
value A pointer to an int where the function stores the value it reads.
Library:
phexlib
Description:
These functions read an integer parameter from a configuration file.
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
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen*(), PxConfigReadBool*(), PxConfigReadChar*(),
PxConfigReadDouble*(), PxConfigReadLLong*(), PxConfigReadLong*(),
PxConfigReadShort*(), PxConfigReadString*(), PxConfigWriteBool*(),
PxConfigWriteChar*(), PxConfigWriteDouble*(), PxConfigWriteInt*(),
PxConfigWriteLLong*(), PxConfigWriteLong*(), PxConfigWriteShort*(),
PxConfigWriteString*()
Arguments:
cx PxConfigReadLLongCx() only. The configuration file handle for the file
you want to read from. This handle is returned by PxConfigOpenCx().
dflt The default to store in value if the specified section or entry don’t exist,
or if the entry value is not a valid long long (see below).
value A pointer to a long long where the function stores the value it reads.
Library:
phexlib
Description:
These functions read a long long parameter from the specified section and entry of a
configuration file and stores it 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
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen*(), PxConfigReadBool*(), PxConfigReadChar*(),
PxConfigReadDouble*(), PxConfigReadInt*(), PxConfigReadLong*(),
PxConfigReadShort*(), PxConfigReadString*(), PxConfigWriteBool*(),
PxConfigWriteChar*(), PxConfigWriteDouble*(), PxConfigWriteInt*(),
PxConfigWriteLLong*(), PxConfigWriteLong*(), PxConfigWriteShort*(),
PxConfigWriteString*()
Arguments:
cx PxConfigReadLongCx() only. The configuration file handle for the file
you want to read from. This handle is returned by PxConfigOpenCx().
dflt The default to store in value if the specified section or entry don’t exist,
or if the entry value is not a valid long (see below).
value A pointer to a long where the function stores the value it reads.
Library:
phexlib
Description:
These functions read a long parameter from the specified section and entry of a
configuration file and stores it 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
Co. KG.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen*(), PxConfigReadBool*(), PxConfigReadChar*(),
PxConfigReadDouble*(), PxConfigReadInt*(), PxConfigReadLLong*(),
PxConfigReadShort*(), PxConfigReadString*(), PxConfigWriteBool*(),
PxConfigWriteChar*(), PxConfigWriteDouble*(), PxConfigWriteInt*(),
PxConfigWriteLLong*(), PxConfigWriteLong*(), PxConfigWriteShort*(),
PxConfigWriteString*()
Arguments:
cx PxConfigReadShortCx() only. The configuration file handle for the file
you want to read from. This handle is returned by PxConfigOpenCx().
dflt The default to store in value if the specified section or entry don’t exist,
or if the entry value is not a valid short.
value A pointer to an short where the function stores the value it reads.
Library:
phexlib
Description:
These functions read a short parameter from the specified section and entry of the
configuration file and stores it 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
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxConfigOpen*(), PxConfigReadBool*(), PxConfigReadChar*(),
PxConfigReadDouble*(), PxConfigReadInt*(), PxConfigReadLLong*(),
PxConfigReadLong*(), PxConfigReadString*(), PxConfigWriteBool*(),
PxConfigWriteChar*(), PxConfigWriteDouble*(), PxConfigWriteInt*(),
PxConfigWriteLLong*(), PxConfigWriteLong*(), PxConfigWriteShort*(),
PxConfigWriteString*()
Arguments:
cx PxConfigReadStringCx() only. The configuration file handle for the file
you want to read from. This handle is returned by PxConfigOpenCx().
dflt The default to store in value if the specified section or entry don’t exist.
The first (maxlen-1) characters of the default string are copied (with a
’\0’ terminator appended).
Library:
phexlib
Description:
These functions read a string parameter from the specified section and entry of a
configuration file.
PxConfigReadString() reads from the currently open configuration file opened by
PxConfigOpen(), while PxConfigReadStringCx() reads from the configuration file
indicated by cx.
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*(),
PxConfigReadDouble*(), PxConfigReadInt*(), PxConfigReadLLong*(),
PxConfigReadLong*(), PxConfigReadShort*(), PxConfigWriteBool*(),
PxConfigWriteChar*(), PxConfigWriteDouble*(), PxConfigWriteInt*(),
PxConfigWriteLLong*(), PxConfigWriteLong*(), PxConfigWriteShort*(),
PxConfigWriteString*()
Synopsis:
#include <photon/PxProto.h>
Arguments:
cx PxConfigSectionCx() only. The configuration file handle for the file you
want to seek for a section in. This handle is returned by
PxConfigOpenCx().
Section names must be an exact match—they must not be abbreviated and the match is
case-sensitive. If there is more than one section with the same name, these functions
seek to the first matched section in the file. Use PxConfigNextSection*() to find
subsequent sections with the same name.
Library:
phexlib
Description:
These functions seek to the start of the requested section, and return an indication of
whether the section exists within the configuration file. These functions 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.
If the requested section can’t be found, the file pointer and current section remain
untouched, and the function returns Pt_FALSE.
Returns:
Pt_TRUE if the requested section exists, Pt_FALSE otherwise
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
PxConfigDeleteSection*(), PxConfigFirstSection*(), PxConfigForceEmptySection*(),
PxConfigNextEntry*(), PxConfigNextSection*(), PxConfigNextString*(),
PxConfigOpen*()
Arguments:
cx PxConfigWriteBoolCx() only. The configuration file handle for the file
you want to write to. This handle is returned by PxConfigOpenCx().
entry The entry to write value to. If the entry already exists in the current
section, it’s overwritten; 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
Library:
phexlib
Description:
These functions write a Boolean parameter in the specified section and entry of a
configuration file.
Co. KG.
• The configuration file must have been opened by PxConfigOpen*() with a mode of
PXCONFIG_WRITE.
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*(),
PxConfigReadDouble*(), PxConfigReadInt*(), PxConfigReadLLong*(),
PxConfigReadLong*(), PxConfigReadShort*(), PxConfigReadString*(),
PxConfigWriteChar*(), PxConfigWriteDouble*(), PxConfigWriteInt*(),
PxConfigWriteLLong*(), PxConfigWriteLong*(), PxConfigWriteShort*(),
PxConfigWriteString*()
Synopsis:
#include <photon/PxProto.h>
Arguments:
cx PxConfigWriteCharCx() only. The configuration file handle for the file
you want to write to. This handle is returned by PxConfigOpenCx().
entry The entry to write value to. If the entry already exists in the current
section, it’s overwritten; otherwise, it’s added to the end of the section.
PXCONFIG_FMT_CHAR_CHAR
As a single character (letter/digit).
PXCONFIG_FMT_CHAR_HEX
As a 2-digit hex number with leading 0x.
Library:
phexlib
Description:
These functions write a character parameter in the specified section and entry of a
configuration file.
• The configuration file must have been opened by PxConfigOpen*() with a mode of
PXCONFIG_WRITE.
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*(),
PxConfigReadDouble*(), PxConfigReadInt*(), PxConfigReadLLong*(),
PxConfigReadLong*(), PxConfigReadShort*(), PxConfigReadString*(),
PxConfigWriteBool*(), PxConfigWriteDouble*(), PxConfigWriteInt*(),
PxConfigWriteLong*(), PxConfigWriteLLong*(), PxConfigWriteShort*(),
PxConfigWriteString*()
Arguments:
cx PxConfigWriteDoubleCx() only. The configuration file handle for the file
you want to write to. This handle is returned by PxConfigOpenCx().
section The section to write value to.
If section matches a valid section name, it becomes the current section. If
section is NULL, the function writes to the current section. If section
doesn’t exist, the function creates it and makes it the current section.
entry The entry to write value to. If the entry already exists in the current
section, it’s overwritten; otherwise, it’s added to the end of the section.
format Must be PXCONFIG_FMT_DOUBLE.
value The value the function writes to the file.
Library:
phexlib
Description:
These functions write a double-precision float parameter in the specified section and
entry of the configuration file.
• The configuration file must have been opened by PxConfigOpen*() with a mode of
PXCONFIG_WRITE.
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*(),
PxConfigReadDouble*(), PxConfigReadInt*(), PxConfigReadLLong*(),
PxConfigReadLong*(), PxConfigReadShort*(), PxConfigReadString*(),
PxConfigWriteBool*(), PxConfigWriteChar*(), PxConfigWriteInt*(),
PxConfigWriteLLong*(), PxConfigWriteLong*(), PxConfigWriteShort*(),
PxConfigWriteString*()
Synopsis:
#include <photon/PxProto.h>
Arguments:
cx PxConfigWriteIntCx() only. The configuration file handle for the file you
want to write to. This handle is returned by PxConfigOpenCx().
entry The entry to write value to. If the entry already exists in the current
section, it’s overwritten; otherwise, it’s added to the end of the section.
PXCONFIG_FMT_INT_DECIMAL
As a decimal number.
PXCONFIG_FMT_INT_HEX
As a hex number with leading 0x.
Library:
phexlib
Description:
These functions write an integer parameter in the specified section and entry of the
configuration file.
• The configuration file must have been opened by PxConfigOpen*() with a mode of
PXCONFIG_WRITE.
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*(),
PxConfigReadDouble*(), PxConfigReadInt*(), PxConfigReadLLong*(),
PxConfigReadLong*(), PxConfigReadShort*(), PxConfigReadString*(),
PxConfigWriteBool*(), PxConfigWriteChar*(), PxConfigWriteDouble*(),
PxConfigWriteLLong*(), PxConfigWriteLong*(), PxConfigWriteShort*(),
PxConfigWriteString*()
Arguments:
cx PxConfigWriteLLongCx() only. The configuration file handle for the file
you want to write to. This handle is returned by PxConfigOpenCx().
entry The entry to write value to. If the entry already exists in the current
section, it’s overwritten; otherwise, it’s added to the end of the section.
PXCONFIG_FMT_INT_DECIMAL
As a decimal number.
PXCONFIG_FMT_INT_HEX
As a hex number with leading 0x.
Library:
phexlib
Description:
These functions write a long long integer parameter in the specified section and entry
of the configuration file.
• The configuration file must have been opened by PxConfigOpen*() with a mode of
PXCONFIG_WRITE.
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*(),
PxConfigReadDouble*(), PxConfigReadInt*(), PxConfigReadLLong*(),
PxConfigReadLong*(), PxConfigReadShort*(), PxConfigReadString*(),
PxConfigWriteBool*(), PxConfigWriteChar*(), PxConfigWriteDouble*(),
PxConfigWriteInt*(), PxConfigWriteLong*(), PxConfigWriteShort*(),
PxConfigWriteString*()
Arguments:
cx PxConfigWriteLongCx() only. The configuration file handle for the file
you want to write to. This handle is returned by PxConfigOpenCx().
entry The entry to write value to. If the entry already exists in the current
section, it’s overwritten; otherwise, it’s added to the end of the section.
PXCONFIG_FMT_INT_DECIMAL
As a decimal number.
PXCONFIG_FMT_INT_HEX
As a hex number with leading 0x.
Library:
phexlib
Description:
These functions write a long integer parameter in the specified section and entry of the
configuration file.
• The configuration file must have been opened by PxConfigOpen*() with a mode of
PXCONFIG_WRITE.
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*(),
PxConfigReadDouble*(), PxConfigReadInt*(), PxConfigReadLLong*(),
PxConfigReadLong*(), PxConfigReadShort*(), PxConfigReadString*(),
PxConfigWriteBool*(), PxConfigWriteChar*(), PxConfigWriteDouble*(),
PxConfigWriteInt*(), PxConfigWriteLLong*(), PxConfigWriteShort*(),
PxConfigWriteString*()
Arguments:
cx PxConfigWriteShortCx() only. The configuration file handle for the file
you want to write to. This handle is returned by PxConfigOpenCx().
entry The entry to write value to. If the entry already exists in the current
section, it’s overwritten; otherwise, it’s added to the end of the section.
PXCONFIG_FMT_INT_DECIMAL
As a decimal number.
PXCONFIG_FMT_INT_HEX
As a hex number with leading 0x.
Library:
phexlib
Description:
These functions write a short integer parameter in the specified section and entry of
the configuration file.
• The configuration file must have been opened by PxConfigOpen*() with a mode of
PXCONFIG_WRITE.
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*(),
PxConfigReadDouble*(), PxConfigReadInt*(), PxConfigReadLLong*(),
PxConfigReadLong*(), PxConfigReadShort*(), PxConfigReadString*(),
PxConfigWriteBool*(), PxConfigWriteChar*(), PxConfigWriteDouble*(),
PxConfigWriteInt*(), PxConfigWriteLLong*(), PxConfigWriteLong*(),
PxConfigWriteString*()
Arguments:
cx PxConfigWriteStringCx() only. The configuration file handle for the file
you want to write to. This handle is returned by PxConfigOpenCx().
entry The entry to write value to. If the entry already exists in the current
section, it’s overwritten; otherwise, it’s added to the end of the section.
value The value the function writes to the file. The string must not contain a \n
Library:
phexlib
Description:
These functions write a string parameter in the specified section and entry of the
configuration file.
• The configuration file must have been opened by PxConfigOpen*() with a mode of
PXCONFIG_WRITE.
You can write a single comment line in the section by specifying "#" for entry and the
comment for value. For example:
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*(),
PxConfigReadDouble*(), PxConfigReadInt*(), PxConfigReadLLong*(),
PxConfigReadLong*(), PxConfigReadShort*(), PxConfigReadString*(),
PxConfigWriteBool*(), PxConfigWriteChar*(), PxConfigWriteDouble*(),
PxConfigWriteInt*(), PxConfigWriteLLong*(), PxConfigWriteLong*(),
PxConfigWriteShort*()
Synopsis:
#include <photon/PxImage.h>
Arguments:
extlist A buffer the function fills with a space-separated list of image filename
extensions supported by the currently loaded image handler plugins.
prefix An optional prefix string the function can append to each extension to make
it easy to create filter lists.
Library:
phexlib
Description:
This function creates a space-separated list of image filename extensions supported by
the currently loaded image handler plugins, and puts the list into extlist. You can easily
create a filter list by passing a string containing an asterisk and period characters
("*.") as the prefix. This will create, for example, a list such as: *.jpg *.gif
*.bmp.
Returns:
0 Success
1 Failure
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxLoadImage().
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
#include <photon/PxImage.h>
Arguments:
filename The name of the graphic file that you want to load or query.
methods A pointer to a PxMethods_t structure that lets you modify the behavior
of the function; see below.
If this argument is NULL, the function loads the graphic file specified by
filename.
Library:
phexlib
Description:
This function reads a graphic file into memory. Photon supports at least the BMP, GIF,
JPEG, PCX, PNG, and SGI file formats.
To draw an image, call PgDrawPhImage() or PgDrawPhImagemx().
When you’re finished with the image, you can free the allocated members of the image
structure by calling PhReleaseImage() after setting the image’s flag member to
indicate which parts of the image should be freed. You can then free the PhImage_t
structure. For more information, see PhImage_t.
PxMethods_t
The PxMethods_t structure alters how PxLoadImage() behaves. This structure 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;
void *colors;
int ncolors;
} PxMethods_t;
The members are as follows:
The loader frees all of the memory that it allocated before calling this function.
You can call PxTerminate() in this function to abort the call to PxLoadImage() if
something has gone wrong.
colors, ncolors Used in conjunction with the PX_USECOLORS flag. The colors
argument points to a palette, and ncolors indicates the number of
valid entries in the palette.
PxLoadImage() doesn’t use the value that px_free, px_error, px_warning, and
px_progress return. These functions can return NULL to avoid compiler warnings.
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;
}
}
methods.px_alloc = memory_allocate;
methods.px_free = memory_free;
methods.px_warning = warning;
methods.px_error = error;
methods.px_progress = progress;
if( Query )
methods.flags |= PX_QUERY;
else
methods.flags |= PX_LOAD;
img->flags |= Ph_RELEASE_IMAGE_ALL;
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 );
PtExit( 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, Pt_NO_PARENT, 2, arg );
free( img );
PtRealizeWidget( window );
PtMainLoop();
return EXIT_SUCCESS;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawPhImage*(), PgDrawPhImageRect*(), PgDrawRepPhImage*(),
PgSetPalette(), PgSetFillColor(), PgSetTextColor(), PgShmemCleanup(),
PhCreateImage(), PhImage_t, PhMakeGhostBitmap(), PhMakeTransBitmap(),
Synopsis:
#include <photon/PxImage.h>
Arguments:
src A pointer to the image that you want to rotate.
dst A pointer to a PhImage_t structure where the function can store the
rotated image.
angle The angle to rotate the image by; one of the following:
• 0
• PXIMG_ANGLE_90CW — 90 degrees clockwise.
• PXIMG_ANGLE_90CCW — 90 degrees counterclockwise.
• PXIMG_ANGLE_180 — 180 degrees.
methods A pointer to a PxMethods_t structure that lets you modify the behavior
of the function. For full details about the structure, see the entry for
PxLoadImage(); for information about the methods that PxRotateImage()
uses, see below.
Library:
phexlib
Description:
This function reads a graphic file into memory. Photon supports at least the BMP, GIF,
JPEG, PCX, PNG, and SGI file formats.
To load an image, call PxLoadImage(); to draw an image, call PgDrawPhImage() or
PgDrawPhImagemx().
When you’re finished with the image, you can free the allocated members of the image
structure by calling PhReleaseImage() after setting the image’s flag member to
indicate which parts of the image should be freed. You can then free the PhImage_t
structure. For more information, see PhImage_t.
Methods
The PxMethods_t structure alters how PxRotateImage() behaves. The only methods
that PxRotateImage() uses (if specified) are px_alloc, px_free, and px_error: void
*(*px_error)( char *msg ); An error routine that you supply. The loader calls this
function if it encounters a fatal error while loading the graphic file. The msg argument
is a pointer to an error string.
Before calling this function, PxRotateImage() frees all of the memory that it allocated
PxRotateImage() doesn’t use the value that px_free, px_error, px_warning, and
px_progress return. These functions can return NULL to avoid compiler warnings.
Returns:
0 on success, or 1 if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PgDrawPhImage*(), PgDrawPhImageRect*(), PgDrawRepPhImage*(),
PgSetPalette(), PgSetFillColor(), PgSetTextColor(), PgShmemCleanup(),
PhCreateImage(), PhImage_t, PhMakeGhostBitmap(), PhMakeTransBitmap(),
PhMakeTransparent(), PhReleaseImage(), PtCRC(), PtCRCValue(), PxLoadImage(),
PxTerminate()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
#include <photon/PxTerminal.h>
PtTerminalCharsets_t *PxTerminalBuildCharsets(
PxTerminalCsNames_t const *names );
Library:
phexlib
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
continued. . .
Safety
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 );
Library:
phexlib
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 );
Library:
phexlib
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/PxImage.h>
Arguments:
image The image that PxLoadImage() is trying to load or query.
Library:
phexlib
Description:
This function terminates a call to PxLoadImage(). You can call PxTerminate() in the
progress callback for PxLoadImage() to abort if something goes wrong with the image
load or query.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
PxLoadImage()
“Images” in the Raw Drawing and Animation chapter of the Photon Programmer’s
Guide
Synopsis:
#include <photon/PxProto.h>
Library:
phexlib
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:
src a pointer to the buffer containing the source UTF-8 characters. If this is
NULL, no translation is performed, and the function returns the
worst-case number of bytes required to hold a character in the current
encoding.
maxsrc the length of the contents in the source buffer (in bytes). No more than
this number of bytes are read.
dst a pointer to the buffer where the encoded characters should be placed. If
this is NULL, no data is copied but the translation is still performed to
calculate the length required to store the converted data.
maxdst the length of the destination buffer (in bytes). No more than this number
of bytes will be written; if this is 0, the buffer is assumed to be large
enough to hold the entire encoding.
srctaken this must point to an integer, which will be updated to reflect the number
of bytes consumed from the source buffer src. This value may be smaller
than maxsrc (if the given destination buffer would overflow or if the final
input character of a multibyte UTF-8 sequence is incomplete).
dstmade this must point to an integer, which will be updated to reflect the number
of bytes produced (or would be produced) into the destination buffer dst.
This value may be smaller than maxdst (if the given source buffer is
exhausted or if the final output character of a multibyte sequence would
be incomplete).
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
mbtowc(), wctomb() in the QNX Neutrino Library Reference
Synopsis:
#include <photon/PxProto.h>
Library:
phexlib
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>
Library:
phexlib
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:
• NULL — release any resources used by the existing encoding scheme without
installing a new translation
The translation routines are provided in the Photon library phexlib, with prototypes
in <photon/PxProto.h>.
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 <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);
}
return EXIT_SUCCESS;
}
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
Synopsis:
#include <photon/PxProto.h>
int PxTranslateStateFromUTF(
struct PxTransCtrl *ctrl,
const char *src,
int maxsrc,
int *consumed,
char *dst,
int maxdst );
Library:
phexlib
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
continued. . .
Safety
Thread No
See also:
PxTranslateList(), PxTranslateFromUTF(), PxTranslateSet(),
PxTranslateStateToUTF(), PxTranslateToUTF(), PxTranslateUnknown()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
#include <photon/PxProto.h>
Library:
phexlib
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>
Library:
phexlib
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:
src A pointer to the buffer containing the source characters. If this is NULL,
no translation is performed and the function returns the worst-case
number of bytes required to hold a character in UTF-8 (MB_LEN_MAX
== 3).
maxsrc The length of the contents in the source buffer (in bytes). No more than
this number of bytes are read.
dst A pointer to the buffer where the UTF-8 characters should be placed. If
this is NULL, no data is copied but the translation is still performed to
calculate the length required to store the converted data
maxdst The length of the destination buffer (in bytes). No more than this number
of bytes will be written; if this is 0, the buffer is assumed to be large
enough to hold the entire encoding
srctaken This must point to an integer, which will be updated to reflect the
number of bytes consumed from the source buffer src. This value may
be smaller than maxsrc (if the given destination buffer would overflow or
if the final input character of a multibyte sequence is incomplete)
dstmade This must point to an integer, which will be updated to reflect the
number of bytes produced (or would be produced) in the destination
buffer dst. This value may be smaller than maxdst (if the given source
buffer is exhausted or if the final output character of a multibyte UTF-8
sequence would be incomplete).
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
mbtowc(), wctomb() in the QNX Neutrino Library Reference
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 and 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 is 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:
#include <photon/realtime/RtTimer.h>
Arguments:
clock_id The clock source; see the documentation for timer_create() in the QNX
Neutrino Library Reference for the possible values.
prio The priority of the Photon pulse that will be used when the timer expires.
If priority is -1, the pulse’s priority is the same as that of the calling
process.
cb A pointer to the function that you want called when the timer expires.
The RtTimerCbF_t type is:
data A pointer to a block of data that’s passed to the cb function as the data
argument.
Library:
ph
Description:
This function creates a realtime timer. The timer is disabled when created; it isn’t
enabled until you call RtTimerSetTime().
Returns:
A pointer to a RtTimer_t structure to be passed to the other routines dealing with
realtime timers, or NULL if an error occurred.
Classification:
Photon
Safety
Interrupt handler No
continued. . .
Safety
Signal handler No
Thread No
See also:
RtTimerDelete(), RtTimerGetTime(), RtTimerSetTime()
“Timers” in the Working with Code chapter of the Photon Programmer’s Guide
timer_create() in the QNX Neutrino Library Reference
Synopsis:
#include <photon/realtime/RtTimer.h>
Arguments:
timer A pointer to a RtTimer_t that was created by a call to RtTimerCreate().
Library:
ph
Description:
This function deletes the realtime timer identified by the structure pointed to by timer.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
RtTimerCreate(), RtTimerGetTime(), RtTimerSetTime()
“Timers” in the Working with Code chapter of the Photon Programmer’s Guide
timer_delete() in the QNX Neutrino Library Reference
Synopsis:
#include <photon/realtime/RtTimer.h>
Arguments:
timer A pointer to a RtTimer_t that was created by a call to RtTimerCreate().
Library:
ph
Description:
This function gets the time remaining on the realtime timer identified by the structure
pointed to by timer. The time remaining is put into the structure pointed to by value.
Returns:
0 Success.
Errors:
EINVAL The given timer isn’t attached to the calling process.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
RtTimerCreate(), RtTimerDelete(), RtTimerSetTime()
“Timers” in the Working with Code chapter of the Photon Programmer’s Guide
timer_gettime() in the QNX Neutrino Library Reference
Synopsis:
#include <photon/realtime/RtTimer.h>
Arguments:
timer A pointer to a RtTimer_t that was created by a call to RtTimerCreate().
value A pointer to a itimerspec structure that defines the new expiration time.
Library:
ph
Description:
This function sets the expiration time for the timer identified by the structure pointed
to by timer to the time specified by value.
Returns:
0 Success.
Errors:
See timer_settime() in the QNX Neutrino Library Reference.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
RtTimerCreate(), RtTimerDelete(), RtTimerGetTime()
timer_settime() in the QNX Neutrino Library Reference
“Timers” in the Working with Code chapter of the Photon Programmer’s Guide
The Photon libraries provide multibyte string functions that are useful if you’re using
UTF-8 character strings. Use the functions described in this chapter instead of the
usual 8-bit-character functions such as strlen() that are described in the QNX Neutrino
Library Reference.
Synopsis:
#include <utf8.h>
Arguments:
s A pointer to a UTF-8 character.
Library:
ph
Description:
The utf8str() function counts the number of bytes in the UTF-8 character pointed to by
s, to a maximum of n bytes, if n is nonzero.
This function is similar to mblen(), except that:
• You can pass 0 for n if you know that s points to a null-terminated string (i.e. 0 is
equivalent to, but more efficient than, strlen(s)).
Returns:
0 s points to the null character.
>0 The number of bytes that comprise the multibyte character (if the next n or
fewer bytes form a valid multibyte character).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
utf8strblen(), utf8strlen(), utf8strnlen()
Unicode Multilingual Support in the Photon Programmer’s Guide
mblen() in the QNX Neutrino Library Reference
Synopsis:
#include <utf8.h>
Arguments:
text A UTF-8 string.
Library:
ph
Description:
The utf8strblen() function returns the number of UTF-8 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 UTF-8 characters returned.
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 UTF-8 character.
Returns:
The number of UTF-8 characters made up of max_bytes bytes in the string text.
Classification:
Photon
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
See also:
utf8len(), utf8strlen(), utf8strnlen()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
#include <utf8.h>
Arguments:
string A pointer to the string to search.
count A pointer to the location where utf8strchr() stores the number of UTF-8
characters the matching character is from the start of the string.
Library:
ph
Description:
The utf8strchr() 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 UTF-8
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>
int 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:
utf8strichr(), utf8strnchr(), utf8strnichr(), utf8strrchr(), utf8strirchr()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
char *utf8strichr( char const *string,
char const *mbchar,
int *count );
Arguments:
string A pointer to the string to search.
count A pointer to the location where utf8strrchr() stores the number of UTF-8
characters the matching character is from the start of the search.
Library:
ph
Description:
The utf8strichr() searches for a character in string that matches mbchar disregarding
the case. If such a match occurs in string, then count (if provided) is set to the number
of characters spanned to find the match.
Returns:
A pointer to the beginning of the matching character within string, or NULL if no
match is found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
See also:
utf8strchr(), utf8strnchr(), utf8strnichr(), utf8strrchr(), utf8strirchr()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
char *utf8strirchr( char const *string_base,
char const *start_char,
char const *mbchar,
int *count );
Arguments:
string_base A pointer to the beginning of the string to search.
Library:
ph
Description:
The utf8strirchr() function searches backwards from start_char to string_base,
inclusive, for a character that matches mbchar, regardless of case. If such a match
occurs, count (if provided) is set to the number of characters spanned to find the
match.
Returns:
A pointer to the beginning of the matching character within string_base, or NULL if
no match is found.
Classification:
Photon
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
See also:
utf8strchr(), utf8strichr(), utf8strnchr(), utf8strnichr(), utf8strrchr()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
#include <utf8.h>
Arguments:
text A UTF-8 string.
bytes A pointer to a location where utf8strlen() stores the number of bytes in the
string.
Library:
ph
Description:
The utf8strlen() function returns the number of UTF-8 characters in the string text, and
sets bytes to the number of bytes in text.
Returns:
The number of UTF-8 characters in the string.
Classification:
Photon
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
See also:
utf8len(), utf8strblen(), utf8strnlen()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
#include <utf8.h>
Arguments:
string A pointer to the string to search.
count A pointer to the location where utf8strnchr() stores the number of UTF-8
characters the matching character is from the start of the string.
Library:
ph
Description:
This function searches for a UTF-8 character in string that matches mbchar. The
match must occur in the first num UTF-8 characters. If such a match is found, count (if
provided) is set to the number of UTF-8 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 UTF-8 characters for a match to the provided UTF-8 character:
#include <Pt.h>
int main()
{
char string[] = "Hello there: äı̂òéü found";
char mbchar[] = "é";
int count;
char *p;
else
printf( "Not found.\n" );
return EXIT_SUCCESS;
}
Classification:
Photon
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
See also:
utf8strchr(), utf8strichr(), utf8strnichr(), utf8strrchr(), utf8strirchr()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
#include <utf8.h>
Arguments:
str1, str2 The UTF-8 strings to compare.
Library:
ph
Description:
Compare len UTF-8 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
See also:
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
char *utf8strndup( char const *text,
int count,
int *bytes );
Arguments:
text The UTF-8 character string to be copied.
bytes A pointer to a location where utf8strndup() stores the number of bytes in the
copy of the string.
Library:
ph
Description:
The utf8strndup() function creates a copy of the first count characters of the given
UTF-8 character string, text. It sets bytes to the number of bytes in the resulting string,
not including the terminating \0.
Returns:
A pointer to the new string.
Classification:
Photon
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
See also:
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
char *utf8strnichr( char const *string,
char const *mbchar,
int num,
int *count );
Arguments:
string A pointer to the string to search.
count A pointer to the location where utf8strnichr() stores the number of UTF-8
characters the matching character is from the start of the search.
Library:
ph
Description:
The utf8strnichr() function searches for a character in string that matches mbchar,
regardless of case. If such a match occurs within num characters in string, count (if
provided) is set to the number of characters spanned to find the match.
Returns:
A pointer to the beginning of the matching character within string, or NULL if no
match is found within num characters.
Classification:
Photon
Safety
Interrupt handler No
Signal handler Yes
Thread Yes
See also:
utf8strchr(), utf8strichr(), utf8strnchr(), utf8strrchr(), utf8strirchr()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
#include <utf8.h>
Arguments:
text A UTF-8 string.
Library:
ph
Description:
The utf8strnlen() function returns the number of bytes occupied by max_len
characters in the string 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:
utf8len(), utf8strblen(), utf8strlen()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
#include <utf8.h>
Arguments:
string_base A pointer to the beginning of the string to search.
Library:
ph
Description:
This function searches backwards from start_char to string_base (inclusive) for a
UTF-8 character that matches mbchar. If such a match is found, count (if provided) is
set to the number of UTF-8 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>
int 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:
utf8strchr(), utf8strichr(), utf8strnchr(), utf8strnichr(), utf8strirchr()
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
int utf8towc( wchar_t *pwc,
const char *s,
size_t n );
Arguments:
pwc A pointer to a location where utf8towc() stores the wide-character
representation of s.
Library:
ph
Description:
The utf8towc() function converts a single UTF-8 character pointed to by s into a
wide-character code pointed to by pwc, to a maximum of n bytes.
This function is similar to mbtowc(), except:
• You can pass 0 for n if you know that s points to a null-terminated string (i.e. 0 is
equivalent to, but more efficient than, strlen(s)).
Returns:
0 The s argument points to the null character.
>0 The number of bytes that comprise the multibyte character, to a maximum of
UTF8_LEN_MAX (if the next n or fewer bytes form a valid multibyte
character).
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
wctoutf8()
Unicode Multilingual Support in the Photon Programmer’s Guide
mbtowc() in the QNX Neutrino Library Reference
The Photon libraries provide wide-character functions that are useful if you’re
working with Unicode characters.
Synopsis:
wchar_t wctolower( wchar_t wc );
Arguments:
wc The wide character that you want to get the lowercase equivalent of.
Library:
ph
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
See also:
tolower() in the QNX Neutrino Library Reference
Unicode Multilingual Support in the Photon Programmer’s Guide
Synopsis:
int wctoutf8( char *s,
wchar_t wc );
Arguments:
s A pointer to a location where wctoutf8() stores the UTF-8 character
corresponding to wc.
Library:
ph
Description:
The wctoutf8() function stores the multibyte representation corresponding to the code
contained in wc in the array pointed to by s. This function stores at most
MB_CUR_MAX characters.
The wctoutf8() function is similar to wctomb(), except:
Returns:
-1 The value of wc doesn’t correspond to a valid multibyte character.
>0 The number of bytes that comprise the multibyte character corresponding to
the value of wc.
Classification:
Photon
Safety
Interrupt handler No
Signal handler No
Thread No
See also:
utf8towc()
Unicode Multilingual Support in the Photon Programmer’s Guide
wctomb() in the QNX Neutrino Library Reference
In this appendix. . .
What’s new in Photon for QNX Neutrino 6.5.0 1535
What’s new in Photon for QNX Neutrino 6.4.1 1536
What’s new in Photon for QNX Neutrino 6.4.0 1536
What’s new in Photon for QNX Neutrino 6.3 Service Pack 1 1537
What’s new in Photon for QNX Neutrino 6.3 1538
What’s new in Photon for QNX Neutrino 6.2.1 1545
What’s new in Photon for QNX Neutrino 6.2.0 1546
What’s new in Photon for QNX Neutrino 6.1.0 1550
What’s new in Photon for QNX Neutrino 6.0 1551
This appendix describes what’s new in Photon for the following releases:
Changed entries
PgLayerCaps_t • The following format types are new:
- Pg_LAYER_FORMAT_YUV_AYUV
- Pg_LAYER_FORMAT_YUV_NV12
• The new format_flags member specifies the packing or byte
order of the format member; it can be 0, or one of the
following:
- Pg_LAYER_FORMAT_PKLE — 16-bit little endian
packed
- Pg_LAYER_FORMAT_PKBE — 16-bit big endian packed
- Pg_LAYER_FORMAT_PACK — 16-bit, packing is
indeterminate
- Pg_LAYER_FORMAT_BO_BGRA — 32-bit, BGRA
byte-order
- Pg_LAYER_FORMAT_BO_ARGB — 32-bit, ARGB
byte-order
(Ref# 69322, 69235)
Errata
PgShmemCleanup()
You can’t call Photon functions from signal handlers; we’ve
corrected the example.
• ApInitialize()
• PfExtent16dot16Cx()
• pf_point_t()
• pf_point16dot16_t()
• pf_rect_t()
• pf_rect_16dot16_t()
• PgMultiBlit*()
• PgGetSurfaceGFSid()
• PgSetControlFlagGCCx()
• PdCreateOffscreenContextGF()
• PgSyncFlush()
• PhCancelDrag()
• PhMultiBlit()
• PhPoint16dot16_t()
• PhRect16dot16_t()
• PiConvertImage()
• PiInitImage()
• PiResizeImage()
PhCharacterCursorDescription_t
Ph_CURSOR_NONE - Hides the cursor.
PgDrawTextArea*()
The len parameter specifies the number of bytes required to store the
string.
PgGetScalerCapabilities()
You must set vcaps->size to sizeof(PgScalerCaps_t) before
calling this function.
PgSetFont() If the M1 or M2 global alpha values are set, and an anti-aliased font
type is supplied to the function, the resulting text will be blended
according to the global alpha values.
PgSetVideoMode()
PgSetVideoMode() returns an error if more than one layer is currently
active via the Pg layer family of calls. By default, io-graphics
utilizes one layer.
PgVideoChannel_t()
Documented as an internal-only type.
• ApSetContext()
• PdGetOffscreenSurface()
• PfAllocDetailsCx()
• PfAllocRenderCx()
• PfAssignDllCx()
• PfAttachCx()
• PfAttachDllCx()
• PfAttachLocalDll()
• PfAttachServerDll()
• PfAttachSleuthMonitorDll()
• PfConvertFontIDCx()
• PfConvertPixelsToPointSizeCx()
• PfDecomposeStemToIDCx ()
• PfDefaultContext()
• PfDetachCx()
• PfDetachLocalDll()
• PfDynamicFontIDCx()
• PfDynamicLoadCx()
• PfDynamicUnloadCx()
• PfExtentComponentsCx()
• PfExtentCx()
• PfExtentTextCharPositionsCx()
• PfFindFontCx()
• PfFontBaseStemCx()
• PfFontDescriptionCx()
• PfFontFlagsCx()
• PfFontSizeCx()
• PfFontTypeCx()
• PfFreeFontCx()
• PfGenerateFontNameCx()
• PfGetGlyphIndexCx()
• PfGetOutlineCx()
• PfGlyphCx()
• PfLoadFontCx()
• PfLoadMetricsCx()
• PfQueryFontInfoCx()
• PfQueryFontsCx()
• PfRenderCx()
• PfRestartServerDll()
• PfSetOptionsDll()
• PfSetRenderingDPICx()
• PfWaitOnServerDll()
• PgAlphaOffCx()
• PgAlphaOnCx()
• PgBevelBoxCx()
• PgBlit()
• PgBlitCx()
• PgChromaOffCx()
• PgChromaOnCx()
• PgClearDrawBufferCx()
• PgClearTranslationCx()
• PgContextBlitCx()
• PgContextBlitAreaCx()
• PgContrastBevelBoxCx()
• PgDefaultAlpha()
• PgDefaultChroma()
• PgDrawArcCx()
• PgDrawArrowCx()
• PgDrawBevelBoxCx(), PgDrawIBevelBoxCx()
• PgDrawBeveledCx()
• PgDrawEllipseCx()
• PgDrawGradientCx()
• PgDrawGradientBevelBoxCx()
• PgDrawGridCx()
• PgDrawGridCx()
• PgDrawLineCx(), PgDrawILineCx()
• PgDrawMultiTextAreaCx ()
• PgDrawPhImageRectv(), PgDrawPhImageRectCxv()
• PgDrawPixelCx(), PgDrawIPixelCx()
• PgDrawRectCx(), PgDrawIRectCx()
• PgDrawRoundRectCx()
• PgDrawTextAreaCx()
• PgFlushCx(), PgFFlushCx()
• PgGetColorModelCx()
• PgGetGCCx()
• PgGetRegionCx()
• PgSetAlphaCx()
• PgSetAlphaBlendCx()
• PgSetChromaCx()
• PgSetClippingCx()
• PgSetColorModelCx()
• PgSetDrawBufferSizeCx ()
• PgSetDrawModeCx()
• PgSetFillColorCx()
• PgSetFillDitherCx()
• PgSetFillTransPatCx()
• PgSetFillXORColorCx()
• PgSetFontCx()
• PgSetGCCx()
• PgSetMultiClipCx()
• PgSetPaletteCx()
• PgSetPlaneMaskCx()
• PgSetRegionCx()
• PgSetStrokeCapCx()
• PgSetStrokeColorCx()
• PgSetStrokeDashCx()
• PgSetStrokeDitherCx()
• PgSetStrokeJoinCx()
• PgSetStrokeTransPatCx ()
• PgSetStrokeWidthCx(), PgSetStrokeFWidthCx()
• PgSetStrokeXORColorCx ()
• PgSetTextColorCx()
• PgSetTextDitherCx()
• PgSetTextTransPatCx()
• PgSetTextXORColorCx()
• PgSetTranslationCx()
• PgSetUnderlineCx()
• PgSetUserClipCx(), PgSetUserClipAbsoluteCx()
• PgSwapDisplayCx()
• PgWaitVSyncCx()
• PgMap_t
• PhClipboardHdr
• PhClipboardRead()
• PhClipboardWrite()
• PhRegionInfo()
• PtAppAddCallback()
• PtAppAddEventHandler()
• PtAppAddFilterCallback()
• PtAppAddHotkeyHandler()
• PtAppGetResource()
• PtAppGetResources()
• PtAppRemoveCallback()
• PtAppRemoveEventHandler()
• PtAppRemoveFilterCallback()
• PtAppRemoveHotkeyHandler()
• PtAppSetResource()
• PtAppSetResources()
• PtGetDndFetchIndex()
• PtWindowGetFrameSize ()
• PxConfigCloseCx()
• PxConfigDeleteEntryCx()
• PxConfigDeleteSectionCx ()
• PxConfigFirstSection(), PxConfigFirstSectionCx()
• PxConfigForceEmptySectionCx()
• PxConfigNextEntry(), PxConfigNextEntryCx()
• PxConfigNextSectionCx()
• PxConfigNextStringCx()
• PxConfigOpenCx()
• PxConfigReadBoolCx()
• PxConfigReadCharCx()
• PxConfigReadDoubleCx()
• PxConfigReadIntCx()
• PxConfigReadLLong(), PxConfigReadLLongCx()
• PxConfigReadLongCx()
• PxConfigReadShortCx()
• PxConfigReadStringCx()
• PxConfigSectionCx()
• PxConfigWriteBoolCx()
• PxConfigWriteCharCx()
• PxConfigWriteDoubleCx()
• PxConfigWriteIntCx()
• PxConfigWriteLLong(), PxConfigWriteLLongCx()
• PxConfigWriteLongCx()
• PxConfigWriteShortCx()
• PxConfigWriteStringCx()
• PxGetImageExtensions()
• PxTerminate()
PgGetVideoModeInfo()
Returns a new flag in
PgVideoModeInfo_t.mode_capabilities2:
PgVM_MODE_CAP2_SCALED_BLIT
PgCreateDriverRegion()
Create a region that’s owned by the graphics driver
PgCreateLayerSurface()
Create an offscreen context for a layer
PgSetLayerSurface()
Display the offscreen context on the specified layer surface
Corrections
ApCreateModule() Corrected the description of creating a picture module.
ApRemoveContext() Remove the PhAB context from a PhAB application that you’re
using as a DLL
Pd
PdCreateOffscreenLock()
Create an offscreen lock
PdDestroyOffscreenLock()
Destroy an offscreen lock
PdIsOffscreenLocked()
Determine whether or not an offscreen context is locked
PdLockOffscreen() Lock an offscreen context
PdUnlockOffscreen() Unlock an offscreen context
Pf
PfExtent(), PfExtentCx()
Calculate the extent rectangle of a text string
PfExtentTextCharPositionsCx()
Calculate individual character positions, specifying a font
context
PfExtentWideText()
The prototype has changed; the string is now of type uint16_t
*.
PfFindFont(), PfGenerateFontName()
The prototypes have changed; they now use char instead of
unsigned char.
PfGenerateFontNameCx()
Generate a font name.
PfGetOutlineCx() Get individual point information for a glyph outline, specifying
the font context.
PfRenderCtx(), PfRenderCx()
Render a string via a user callback function
PfRenderWideText(), PfWideTextWidthBytes() , PfWideTextWidthChars()
The prototype has changed; the string is now of type uint16_t
*.
Pg
PgAlphaValue() Extract the alpha component from a color value
PgARGB() Convert alpha, red, green, and blue values to composite color
format
PgContextBlit(), PgContextBlitArea()
The source data is now scaled to fit the destination rectangle.
PgGetColorModel()
Get the current color model
PgSetColorModel()
Set the current color model
Ph
PhImage_t New image types:
• Pg_IMAGE_DIRECT_1555
• Pg_IMAGE_DIRECT_4444
Pp
PpPrintContext_t
Data structure describing a print context
Pt
PtCreateClassStyle() Create a class style
PtSetClassStyleMethods()
Set multiple members of a style from an array
utf8
utf8len() Count the bytes in a UTF-8 character
wc
wctoutf8() Convert a wide-character code into a UTF-8 character
PdGetOffscreenContextPtr()
This function can fail on certain hardware. You can use
PdGetOffscreenContextPtr() on closed systems where you
know that the graphics frame buffer is linear; don’t use it in
applications that target generic hardware configurations.
PfQueryFonts() If you don’t want to limit the search to fonts that support a
specific character, pass PHFONT_ALL_SYMBOLS as the
symbol argument.
PtQuitMainLoop() This function now returns an int that indicates whether or not
the thread has already called PtQuitMainLoop().
PtSpawn() By default, the new process inherits all of the parent’s valid file
descriptors whose values are less than or equal to 9.
PxLoadImage() You don’t have to define the file formats that you want to
support any more (e.g. PX_GIF_SUPPORT).
• PgDrawArrow()
• PfFontBaseStem()
• PgDrawPhImage()
• PgDrawRepPhImage()
• PgGetRegion()
• PhMakeTransparent()
• PtAllowExit()
• PtPassword()
• PtPreventExit()
• PtPrintPropSelect()
• PdOpenGLContextSwapBuffers()
• PgCreateGradient()
• PgGetGradientColor()
• PgGradientControl_t
• PgGradientLinear()
• PgGradientMakeImage()
• PgGradientPercent()
• PgGradientRotatePalette()
Other changes
PhWindowQueryVisible()
Ph_QUERY_CONSOLE and Ph_QUERY_WORKSPACE are new bits for the flags
argument. Ph_QUERY_CONSOLE is the default value.
New functionality
Font names
An API for handling font names in an organized, portable way has been added.
Previously, we recommended you address a font by the “stem name” supplied by the
font manager (e.g. helv12). This approach is no longer recommended, since stem
names aren’t guaranteed to be static. This is especially true when new font technology
is added to the Photon font subsystem. The new API provides an interface that
eliminates the need to recode in the future. It includes:
• PfConvertFontID()
• PfFindFont()
• PfFontDescription()
• PfFontFlags()
• PfFontSize()
• PfFreeFont()
• AlClearTranslation()
• AlCloseDBase()
• AlGetEntry()
• AlGetSize()
• AlOpenDBase()
• AlReadTranslation()
• AlSaveTranslation()
• AlSetEntry()
Ap—PhAB
New:
• ApCloseMessageDB()
• ApCreateDBWidget()
• ApCreateDBWidgetFamily()
• ApDeleteDBWidget()
• ApGetDBWidgetInfo()
• ApGetMessage()
• ApLoadMessageDB()
• ApModalWait()
These functions have been renamed; you should use the new name, although
applications that use the old name will still work:
Deprecated:
• ApBitmap_t
• ApFreeBitmapRes()
• ApGetBitmapRes()
• ApCreateModule()
mbstr—Multibyte-Character
New:
Pd—Draw Context
New:
• PdCreateDirectContext()
• PdCreateOffscreenContext()
• PdDirectStart()
• PdDirectStop()
• PdDupOffscreenContext()
• PdGetDevices()
• PdGetOffscreenContextPtr()
• PdOffscreenContext_t
• PdReleaseDirectContext()
• PdSetTargetDevice()
Pf—Font Server
New:
• PfConvertFontID()
• PfDecomposeStemToID()
• PfDynamicLoad()
• PfDynamicUnload()
• PfExtentFractTextCharPositions()
• PfExtentTextCharPositions()
• PfExtentTextToRect()
• PfExtentWideText()
• PfFindFont()
• PfFontDescription()
• PfFontFlags()
• PfFontSize()
• PfFreeFont()
• PfGenerateFontName()
• PfGetCacheStats()
• PfGetOutline()
• PfRenderWideText()
• PfTextWidthBytes()
• PfTextWidthChars()
• PfWideTextWidthBytes()
• PfWideTextWidthChars()
Deprecated:
Pg—Graphics
New:
• PgAlphaOff()
• PgAlphaOn()
• PgBevelBox()
• PgCalcColorContrast()
• PgChromaOff()
• PgChromaOn()
• PgConfigScalerChannel()
• PgContextBlit()
• PgContextBlitArea()
• PgContrastBevelBox()
• PgCreateVideoChannel()
• PgDestroyVideoChannel()
• PgDrawGradient()
• PgDrawGradientBevelBox()
• PgDrawMultiTextArea()
• PgDrawPhImageRectmx()
• PgDrawRepPhImagemx()
• PgExtentMultiText()
• PgGetGraphicsHWCaps()
• PgGetOverlayChromaColor()
• PgGetScalerCapabilities()
• PgGetVideoMode()
• PgGetVideoModeInfo()
• PgGetVideoModeList()
• PgNextVideoFrame()
• PgScalerCaps_t
• PgScalerProps_t
• PgReadScreen()
• PgReadScreenSize()
• PgSetAlpha()
• PgSetAlphaBlend()
• PgSetChroma()
• PgSetDPMSMode()
• PgSetVideoMode()
• PgSwapDisplay()
• PgVideoChannel_t
• PgWaitDrawComplete()
• PgWaitHWIdle()
• PgWaitVSync()
Ph—Photon
New:
• PhAllocPackType()
• PhAreaToRect()
• PhCreateImage()
• PhCreateTransportCtrl()
• PhDCCreate()
• PhDCRelease()
• PhDeTranslateRect()
• PhFindTransportType()
• PhFreeTransportType()
• PhGetAllTransportHdrs()
• PhGetNextInlineData()
• PhGetNextTransportHdr()
• PhGetTransportHdr()
• PhGetTransportVectors()
• PhInputGroup()
• PhLinkTransportData()
• PhLocateTransHdr()
• PhMallocUnpack()
• PhPackEntry()
• PhPackType()
• PhRectToArea()
• PhRegionGetData()
• PhRegisterTransportType()
• PhReleaseTransportCtrl()
• PhReleaseTransportHdrs()
• PhTransportFindLink()
• PhTransportCtrl_t
• PhTransportLink_t
• PhTransportRegEntry_t
• PhTransportType()
• PhUnlinkTransportHdr()
• PhUnpack()
Other changes:
PhInitDrag() The prototype has changed; the ptrpos and cursor arguments have
been added.
PhMakeTransBitmap()
This function now supports all image types currently supported by
Photon. The meaning of the trans_color argument depends on the
image type.
Pi—Images
These new functions support image operations:
• PiCropImage()
• PiDuplicateImage()
• PiFlipImage()
• PiGetPixel()
• PiGetPixelFromData()
• PiGetPixelRGB()
• PiSetPixel()
• PiSetPixelInData()
Pp—Printing
New functions:
• PpFreePrinterList()
• PpGetCanvas()
• PpLoadDefaultPrinter()
• PpLoadPrinterList()
• PpSetCanvas()
Other changes:
PpPrintWidget() You no longer need to call PtFlush() after calling this function.
Pt—Widget toolkit
New:
• PtAddClassStyle()
• PtAddFilterCallback()
• PtAddFilterCallbacks()
• PtAddResponseType()
• PtAlert()
• PtAppSetFdMode()
• PtBlit()
• PtBlockAllWindows()
• PtBlockWindow()
• PtCalcCanvas()
• PtCalcSurface()
• PtCalcSurfaceByAction()
• PtCalcSurfaceById()
• PtCancelDnd()
• PtCheckSurfaces()
• PtClippedBlit()
• PtCondTimedWait()
• PtCondWait()
• PtConnectionAddEventHandlers()
• PtConnectionAddMsgHandlers()
• PtConnectionClientGetUserData()
• PtConnectionClientSetError()
• PtConnectionClientSetUserData()
• PtConnectionFindId()
• PtConnectionFlush()
• PtConnectionFindName()
• PtConnectionNotify()
• PtConnectionReply(), PtConnectionReplymx()
• PtConnectionResizeEventBuffer()
• PtConnectionSend(), PtConnectionSendmx()
• PtConnectionServerDestroy()
• PtConnectionServerGetUserData()
• PtConnectionServerSetError()
• PtConnectionServerSetUserData()
• PtConnectionTmpName()
• PtConnectionWaitForName()
• PtConnectorCreate()
• PtConnectorDestroy()
• PtConnectorGetId()
• PtCRCValue()
• PtCreateActionSurface()
• PtCreateSurface()
• PtCreateTransportCtrl()
• PtDamageSurface(), PtDamageSurfaceById()
• PtDamageSurfaceByAction()
• PtDestroyAllSurfaces()
• PtDestroySurface()
• PtDestroySurfaceById()
• PtDisableSurface(), PtDisableSurfaceById()
• PtDisableSurfaceByAction()
• PtDndFetch_t
• PtDndSelect()
• PtEnableSurface(), PtEnableSurfaceById()
• PtEnableSurfaceByAction()
• PtEnter()
• PtExit()
• PtFindFocusNextFrom()
• PtFindFocusPrevFrom()
• PtFindSurface()
• PtFindSurfaceByAction()
• PtGetResource()
• PtGiveFocus()
• PtHideSurface(), PtHideSurfaceById()
• PtHideSurfaceByAction()
• PtInitDnd()
• PtInsertSurface(), PtInsertSurfaceById()
• PtLeave()
• PtMakeModal()
• PtModalBlock()
• PtModalUnblock()
• PtNotice()
• PtPrintSelect()
• PtPrompt()
• PtPulseArm()
• PtQuitMainLoop()
• PtReleaseTransportCtrl()
• PtRemoveFilterCallback()
• PtRemoveFilterCallbacks()
• PtSetAreaFromCanvas()
• PtSetResource()
• PtShowSurface(), PtShowSurfaceById()
• PtShowSurfaceByAction()
• PtSurfaceActionId()
• PtSurfaceAddData(), PtSurfaceAddDataById()
• PtSurfaceBrotherBehind()
• PtSurfaceBrotherInFront()
• PtSurfaceCalcBoundingBox(), PtSurfaceCalcBoundingBoxById()
• PtSurfaceExtent(), PtSurfaceExtentById()
• PtSurfaceGetData(), PtSurfaceGetDataById()
• PtSurfaceHit()
• PtSurfaceId()
• PtSurfaceInBack()
• PtSurfaceInFront()
• PtSurfaceIsDisabled()
• PtSurfaceIsEnabled()
• PtSurfaceIsHidden()
• PtSurfaceIsShown()
• PtSurfaceRect(), PtSurfaceRectById()
• PtSurfaceRemoveData(), PtSurfaceRemoveDataById()
• PtSurfaceTestPoint()
• PtSurfaceToBack(), PtSurfaceToBackById()
• PtSurfaceToFront(), PtSurfaceToFrontById()
• PtTransportCtrl_t
• PtTransportRequestable()
• PtTransportType()
• PtUnblockWindows()
• PtWidgetActiveSurface()
• PtWidgetMinimumSize()
• PtWidgetPreferredSize()
• PtWindowFrameSize()
Deprecated:
• PtAskQuestion()
These functions have been renamed; you should use the new name, although
applications that use the old name will still work:
Other changes:
PtCreateWidget() The parent argument has changed. It can now be a pointer to the
parent widget or one of:
• Pt_DEFAULT_PARENT — use the default parent, which is
the most recently created container.
• Pt_NO_PARENT
• Pt_FSR_RECURSIVE_DELETE
• Pt_FSR_CONFIRM_EXISTING
Px—Extended
PxCRC() Replaced by PtCRC().
You no longer need to include <photon/PxHelp.h> when using the help functions.
Rt—Realtime
New:
• RtTimerCreate()
• RtTimerDelete()
• RtTimerGetTime()
• RtTimerSetTime()
Corrections
Pg—Graphics
PgDrawImage(), PgDrawImagemx()
Instead of using this function, we recommend using a PhImage_t structure and
calling PgDrawPhImagemx().
PgDrawTImage(), PgDrawTImagemx()
Instead of using this function, we recommend using a PhImage_t structure and
calling PgDrawPhImagemx().
Ph—Photon
PhMakeTransBitmap()
Use PgDrawPhImagemx() to draw a transparent image.
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 distance between the edges of a widget and the parent widget it’s anchored to.
anchor
A constraint mechanism used to manage what happens to a 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 a graphics context (e.g. the screen) to another area
on the same or a different context.
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 margins. Other widgets, such as PtLabel, may define additional
margins.
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 PtOSContainer.
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 focus by using
the keyboard.
current item
The item in a list or tree widget that will be selected (or perhaps unselected) when you
press Enter or Space. It’s typically drawn with a blue dotted line around it when its
widget has 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.
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, consisting of nine consoles or workspaces.
device region
The region located in the middle of the event space, with application regions behind
it and driver regions in front of it (from the user’s point of view).
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.
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 tokens that are dispatched via draw events and can be collected by a
rendering engine such as a graphics driver.
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 of 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
Typically 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 associates icons with an application.
image
A rectangular array of color values, where each element 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/or pointer events.
input group
A set of input and output devices. There’s typically one input group per user.
instance
A concrete example of an abstract class; for example, “Lassie” is an instance of the
class “dog.” In Photon, an instance is usually a widget instance; for example, a
pushbutton is an instance of the PtButton widget class. When an instance of a
widget 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 you can access
the instance in your 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.
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.
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. The region prevents the event from passing through.
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.
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 a Photon session from a Microsoft
Windows environment.
Photon Terminal
An application (pterm) that emulates a character-mode terminal in a Photon window.
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 a
printer, 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 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.
shelf
An application that attaches areas to the outside edge of the screen. You can add
plugins to customize these areas, such as a taskbar, launcher, clock, and magnifier.
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
A shelf plugin that 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.
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 desktop.
J width 622
XOR color 624
Japanese characters, entering 1140 lines, drawing 451
joints, stroke (line) 618 link callbacks
determining the initiator 160
K
M
key events
UTF-8 value 768 main loop 1228
keys, modifier 705, 765 exiting 1271
MAX_FONT_TAG 307
MB_CUR_MAX 1531
mbstr* See utf*
L memory contexts
activating 899
language databases
creating 890
closing 67
deactivating 901
getting entries 68
draw buffer
number of records 70
incremental size 896
opening 71
maximum size 897
setting translation 76
flushing 894
translations
releasing 895
clearing 66
type, setting 898
reading 72
memory, shared
saving 74
attaching 638
layers
cleaning up 639
arguments
creating 641
setting 594
destroying 642
capabilities 535
detaching 643
capabilities, querying 513
menus
locking 540, 647
items
offscreen contexts
state, setting 134
creating 402
text, getting 116
displaying 599
text, setting 132, 136
libraries
position, setting 1247
version number 769
message databases
widget, initialization 1216
closing 67, 89
line attributes
getting entries 68
caps 609
loading 127
color 611
number of records 70
dash 613
opening 71
dithering 616
retrieving messages 118
joints 618
setting translation 76
resetting 412
translations
transparency 621
clearing 66
reading 72 P
saving 74
messages palette
displaying 1230 current, getting 516
errors, displaying 108 current, setting 603
modal dialogs 130, 1229, 1263 passwords, prompting for 1246
modal loop PATH 1313
starting 1232 pathname delimiter in QNX
stopping 1239 documentation xxxiii
modal processing PdCreateDirectContext() 170
ending 1237 PdCreateOffscreenContext() 173
starting 1238 PdCreateOffscreenContextGF() 175
modifier keys 705, 765 PdCreateOffscreenLock() 176
modules PdDestroyOffscreenLock() 178
creating 97 PdDirectStart() 179
location, specifying 140 PdDirectStop() 180
parent, specifying 142 PdDupOffscreenContext() 182
setup function, specifying 138 PdGetDevices() 183
setup functions PdGetOffscreenContextPtr() 184
information structure 123 PdGetOffscreenSurfacet() 187
widget instance pointer, getting 114 PdIsOffscreenLocked() 188
widget instance pointer, getting within 121 PdLockOffscreen() 190
widgets, determining which initiated a link PdOffscreenContext_t 192
callback 160 PdOSCCreateLockParams_t 176
MsgReceive() 735 PdReleaseDirectContext() 193
multibyte characters See UTF-8 PdSetOffscreenTranslation() 194
PdSetTargetDevice() 196
PdUnlockOffscreen() 198
PF_BITMAP 297
N PF_CHAR_DRAW_POSITIONS 268, 273
PF_FRACTIONAL 247, 248, 253, 254, 259,
name_attach() 983, 987 260, 262, 263, 272, 339
nodes pf_point_t 328
descriptor, getting from receive ID pf_point16dot16_t 329
(RCVID) 1183 PF_RECT 248, 254, 260, 263
notice dialog 1242 pf_rect_16dot16_t 337
pf_rect_t 336
PF_SCALABLE 297
PF_STYLE_ANTIALIAS 288, 297, 307
O PF_STYLE_BI 297
PF_STYLE_BOLD 288, 297, 307
offscreen contexts
PF_STYLE_DULINE 288, 307
layers
PF_STYLE_ITALIC 288, 297, 307
creating for 402
PF_STYLE_ULINE 288, 307
displaying 599
PF_WIDE_CHAR32 248, 254, 260, 263, 339
translation, setting 194
removing 1009
X
XOR color
bitmaps 629
fill 588
stroke 624
text 629