1
(******************************************************************************
3
* Copyright (c) 1994-2000 Palm, Inc. or its subsidiaries.
8
* Release: Palm OS SDK 4.0 (63220)
11
* This file defines form structures and routines.
14
* 09/06/94 art Created by Art Lamb.
15
* 08/28/00 kwk Added FrmGetActiveField (4.0)
17
*****************************************************************************)
23
uses palmos, coretraps, rect, font, window, control, field, list, scrollbar, table, event_;
28
frmInvalidObjectId = $ffff;
29
frmNoSelectedControl = $ff;
31
// Update code send as part of a frmUpdate event.
32
frmRedrawUpdateCode = $8000;
34
// Magic button IDs used by FrmCustomResponseAlert callbacks
35
frmResponseCreate = 1974;
36
frmResponseQuit = $BEEF;
38
// Alert constants and structures
44
confirmationAlert = Succ(informationAlert);
45
warningAlert = Succ(confirmationAlert);
46
errorAlert = Succ(warningAlert);
49
AlertType = alertTypes;
51
AlertTemplateType = record
52
{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FORMS} // These fields will not be available in the next OS release!
56
defaultButton: UInt16;
59
AlertTemplateTag = AlertTemplateType;
60
// Types of object in a dialog box
65
frmControlObj = Succ(frmFieldObj);
66
frmListObj = Succ(frmControlObj);
67
frmTableObj = Succ(frmListObj);
68
frmBitmapObj = Succ(frmTableObj);
69
frmLineObj = Succ(frmBitmapObj);
70
frmFrameObj = Succ(frmLineObj);
71
frmRectangleObj = Succ(frmFrameObj);
72
frmLabelObj = Succ(frmRectangleObj);
73
frmTitleObj = Succ(frmLabelObj);
74
frmPopupObj = Succ(frmTitleObj);
75
frmGraffitiStateObj = Succ(frmPopupObj);
76
frmGadgetObj = Succ(frmGraffitiStateObj);
77
frmScrollBarObj = Succ(frmGadgetObj);
80
FormObjectKind = formObjects;
82
FormObjAttrType = record
83
{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FORMS} // These fields will not be available in the next OS release!
86
UInt16 usable :1; // Set if part of ui
87
UInt16 reserved :15; // pad it out
92
FormObjAttrTag = FormObjAttrType;
96
formGadgetDrawCmd = 0; // paramP is unspecified
97
formGadgetEraseCmd = 1; // paramP is unspecified
98
formGadgetHandleEventCmd = 2; // paramP is an EventType *for the relevant event.
99
formGadgetDeleteCmd = 3; // paramP is unspecified.
102
FormGadgetAttrType = record
103
{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FORMS} // These fields will not be available in the next OS release!
106
UInt16 usable :1; // Set if part of ui - "should be drawn"
107
UInt16 extended :1; // Set if the structure is an "Extended" gadget (i.e., the 'handler' field is present)
108
UInt16 visible :1; // Set if drawn - "has been drawn" or "must do work to erase"
109
UInt16 reserved :13; // pad it out
113
FormGadgetAttrTag = FormGadgetAttrType;
115
FormGadgetPtr = ^FormGadgetType;
117
FormGadgetHandlerType = function(gadgetP: FormGadgetPtr; cmd: UInt16; paramP: Pointer): Boolean;
119
FormGadgetType = record
120
{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FORMS} // These fields will not be available in the next OS release!
122
attr: FormGadgetAttrType;
125
handler: FormGadgetHandlerType;
129
// All of the smaller form objects:
131
FormBitmapType = record
132
{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FORMS} // These fields will not be available in the next OS release!
133
attr: FormObjAttrType;
138
FormBitmapTag = FormBitmapType;
139
FormBitmapPtr = ^FormBitmapType;
141
FormLineType = record
142
{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FORMS} // These fields will not be available in the next OS release!
143
attr: FormObjAttrType;
148
FormLineTag = FormLineType;
150
FormFrameType = record
151
{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FORMS} // These fields will not be available in the next OS release!
153
attr: FormObjAttrType;
158
FormFrameTag = FormFrameType;
160
FormRectangleType = record
161
{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FORMS} // These fields will not be available in the next OS release!
162
attr: FormObjAttrType;
166
FormRectangleTag = FormRectangleType;
168
FormLabelType = record
169
{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FORMS} // These fields will not be available in the next OS release!
172
attr: FormObjAttrType;
178
FormLabelTag = FormLabelType;
179
FormLabelPtr = ^FormLabelType;
181
FormTitleType = record
182
{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FORMS} // These fields will not be available in the next OS release!
187
FormTitleTag = FormTitleType;
189
FormPopupType = record
190
{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FORMS} // These fields will not be available in the next OS release!
195
FormPopupTag = FormPopupType;
197
FrmGraffitiStateType = record
198
{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FORMS} // These fields will not be available in the next OS release!
202
FormGraffitiStateTag = FrmGraffitiStateType;
203
FrmGraffitiStatePtr = ^FrmGraffitiStateType;
205
FormObjectType = record
208
2: (field: ^FieldType);
209
3: (control: ^ControlType);
210
4: (graphicControl: ^GraphicControlType);
211
5: (sliderControl: ^SliderControlType);
212
6: (list: ^ListType);
213
7: (table: ^TableType);
214
8: (bitmap: ^FormBitmapType);
215
// FormLineType * line;
216
// FormFrameType * frame;
217
// FormRectangleType * rectangle;
218
9: (label_: ^FormLabelType);
219
10: (title: ^FormTitleType);
220
11: (popup: ^FormPopupType);
221
12: (grfState: ^FrmGraffitiStateType);
222
13: (gadget: ^FormGadgetType);
223
14: (scrollBar: ^ScrollBarType);
225
FormObjectTag = FormObjectType;
227
// typedef FormObjectType *FormObjectPtr;
229
FormObjListType = record
230
{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FORMS} // These fields will not be available in the next OS release!
231
objectType: FormObjectKind;
233
object_: FormObjectType;
236
FormObjListTag = FormObjListType;
238
FormAttrType = record
239
{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FORMS} // These fields will not be available in the next OS release!
242
UInt16 usable :1; // Set if part of ui
243
UInt16 enabled :1; // Set if interactable (not grayed out)
244
UInt16 visible :1; // Set if drawn, used internally
245
UInt16 dirty :1; // Set if dialog has been modified
246
UInt16 saveBehind :1; // Set if bits behind form are save when form ids drawn
247
UInt16 graffitiShift :1; // Set if graffiti shift indicator is supported
248
UInt16 globalsAvailable:1; // Set by Palm OS if globals are available for the
249
// form event handler
250
UInt16 doingDialog :1; // FrmDoDialog is using for nested event loop
251
UInt16 exitDialog :1; // tells FrmDoDialog to bail out and stop using this form
252
UInt16 attnIndicator :1; // Set if attention indicator is supported
253
UInt16 reserved :6; // pad to 16
255
reserved2: UInt16; // FormAttrType now explicitly 32-bits wide.
258
FormAttrTag = FormAttrType;
260
FormEventHandlerType = function(var eventP: EventType): Boolean;
261
FormEventHandlerPtr = FormEventHandlerType;
264
{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FORMS} // These fields will not be available in the next OS release!
268
bitsBehindForm: WinHandle;
269
handler: FormEventHandlerType;
271
defaultButton: UInt16;
275
objects: ^FormObjListType;
280
FieldPtr = ^FieldType;
281
// FormActiveStateType: this structure is passed to FrmActiveState for
282
// saving and restoring active form/window state; this structure's
283
// contents are abstracted because the contents will differ significantly
285
// Added for PalmOS 3.0
286
FormActiveStateType = record
287
data: array [0..10] of UInt16;
290
// FrmCustomResponseAlert callback routine prototype
291
FormCheckResponseFuncType = function(button: Int16; attempt: PChar): Boolean;
292
FormCheckResponseFuncPtr = FormCheckResponseFuncType;
294
//--------------------------------------------------------------------
298
//--------------------------------------------------------------------
300
function FrmInitForm(rscID: UInt16): FormPtr; syscall sysTrapFrmInitForm;
302
procedure FrmDeleteForm(formP: FormPtr); syscall sysTrapFrmDeleteForm;
304
procedure FrmDrawForm(formP: FormPtr); syscall sysTrapFrmDrawForm;
306
procedure FrmEraseForm(formP: FormPtr); syscall sysTrapFrmEraseForm;
308
function FrmGetActiveForm: FormPtr; syscall sysTrapFrmGetActiveForm;
310
procedure FrmSetActiveForm(formP: FormPtr); syscall sysTrapFrmSetActiveForm;
312
function FrmGetActiveFormID: UInt16; syscall sysTrapFrmGetActiveFormID;
314
function FrmGetActiveField(const formP: FormPtr): FieldPtr; syscall sysTrapFrmGetActiveField;
316
function FrmGetUserModifiedState(const formP: FormPtr): Boolean; syscall sysTrapFrmGetUserModifiedState;
318
procedure FrmSetNotUserModified(formP: FormPtr); syscall sysTrapFrmSetNotUserModified;
320
function FrmGetFocus(const formP: FormPtr): UInt16; syscall sysTrapFrmGetFocus;
322
procedure FrmSetFocus(formP: FormPtr; fieldIndex: UInt16); syscall sysTrapFrmSetFocus;
324
function FrmHandleEvent(formP: FormPtr; eventP: EventPtr): Boolean; syscall sysTrapFrmHandleEvent;
326
procedure FrmGetFormBounds(const formP: FormPtr; var rP: RectangleType); syscall sysTrapFrmGetFormBounds;
328
function FrmGetWindowHandle(const formP: FormPtr): WinHandle; syscall sysTrapFrmGetWindowHandle;
330
function FrmGetFormId(const formP: FormPtr): UInt16; syscall sysTrapFrmGetFormId;
332
function FrmGetFormPtr(formId: UInt16): FormPtr; syscall sysTrapFrmGetFormPtr;
334
function FrmGetFirstForm: FormPtr; syscall sysTrapFrmGetFirstForm;
336
function FrmGetNumberOfObjects(const formP: FormPtr): UInt16; syscall sysTrapFrmGetNumberOfObjects;
338
function FrmGetObjectIndex(const formP: FormPtr; objID: UInt16): UInt16; syscall sysTrapFrmGetObjectIndex;
340
function FrmGetObjectIndexFromPtr(const formP: FormPtr; objP: Pointer): UInt16; syscall sysTrapFrmGetObjectIndexFromPtr;
342
function FrmGetObjectId(const formP: FormPtr; objIndex: UInt16): UInt16; syscall sysTrapFrmGetObjectId;
344
function FrmGetObjectType(const formP: FormPtr; objIndex: UInt16): FormObjectKind; syscall sysTrapFrmGetObjectType;
346
function FrmGetObjectPtr(const formP: FormPtr; objIndex: UInt16): Pointer; syscall sysTrapFrmGetObjectPtr;
348
procedure FrmGetObjectBounds(const formP: FormPtr; objIndex: UInt16; var rP: RectangleType); syscall sysTrapFrmGetObjectBounds;
350
procedure FrmHideObject(formP: FormPtr; objIndex: UInt16); syscall sysTrapFrmHideObject;
352
procedure FrmShowObject(formP: FormPtr; objIndex: UInt16); syscall sysTrapFrmShowObject;
354
procedure FrmGetObjectPosition(const formP: FormPtr; objIndex: UInt16; var x, y: Coord); syscall sysTrapFrmGetObjectPosition;
356
procedure FrmSetObjectPosition(formP: FormPtr; objIndex: UInt16; x, y: Coord); syscall sysTrapFrmSetObjectPosition;
358
procedure FrmSetObjectBounds(formP: FormPtr; objIndex: UInt16; {const} var bounds: RectangleType); syscall sysTrapFrmSetObjectBounds;
360
function FrmGetControlValue(const formP: FormPtr; objIndex: UInt16): Int16; syscall sysTrapFrmGetControlValue;
362
procedure FrmSetControlValue(const formP: FormPtr; objIndex, newValue: Int16); syscall sysTrapFrmSetControlValue;
364
function FrmGetControlGroupSelection(const formP: FormPtr; groupNum: UInt8): UInt16; syscall sysTrapFrmGetControlGroupSelection;
366
procedure FrmSetControlGroupSelection(const formP: FormPtr; groupNum: UInt8; controlID: UInt16); syscall sysTrapFrmSetControlGroupSelection;
368
procedure FrmCopyLabel(formP: FormPtr; labelID: UInt16; const newLabel: PChar); syscall sysTrapFrmCopyLabel;
370
function FrmGetLabel(const formP: FormPtr; labelID: UInt16): {const} PChar; syscall sysTrapFrmGetLabel;
372
procedure FrmSetCategoryLabel(const formP: FormPtr; objIndex: UInt16; newLabel: PChar); syscall sysTrapFrmSetCategoryLabel;
374
function FrmGetTitle(const formP: FormPtr): {const} PChar; syscall sysTrapFrmGetTitle;
376
procedure FrmSetTitle(formP: FormPtr; newTitle: PChar); syscall sysTrapFrmSetTitle;
378
procedure FrmCopyTitle(formP: FormPtr; const newTitle: PChar); syscall sysTrapFrmCopyTitle;
380
function FrmGetGadgetData(const formP: FormPtr; objIndex: UInt16): Pointer; syscall sysTrapFrmGetGadgetData;
382
procedure FrmSetGadgetData(formP: FormPtr; objIndex: UInt16; const data: Pointer); syscall sysTrapFrmSetGadgetData;
384
procedure FrmSetGadgetHandler(formP: FormPtr; objIndex: UInt16; attrP: FormGadgetHandlerType); syscall sysTrapFrmSetGadgetHandler;
386
function FrmDoDialog(formP: FormPtr): UInt16; syscall sysTrapFrmDoDialog;
388
function FrmAlert(alertId: UInt16): UInt16; syscall sysTrapFrmAlert;
390
function FrmCustomAlert(alertId: UInt16; const s1, s2, s3: PChar): UInt16; syscall sysTrapFrmCustomAlert;
392
procedure FrmHelp(helpMsgId: UInt16); syscall sysTrapFrmHelp;
394
procedure FrmUpdateScrollers(formP: FormPtr; upIndex, downIndex: UInt16; scrollableUp, scrollableDown: Boolean); syscall sysTrapFrmUpdateScrollers;
396
function FrmVisible(const formP: FormPtr): Boolean; syscall sysTrapFrmVisible;
398
procedure FrmSetEventHandler(formP: FormPtr; handler: FormEventHandlerType); syscall sysTrapFrmSetEventHandler;
400
function FrmDispatchEvent(var eventP: EventType): Boolean; syscall sysTrapFrmDispatchEvent;
402
procedure FrmPopupForm(formId: UInt16); syscall sysTrapFrmPopupForm;
404
procedure FrmGotoForm(formId: UInt16); syscall sysTrapFrmGotoForm;
406
procedure FrmUpdateForm(formId, updateCode: UInt16); syscall sysTrapFrmUpdateForm;
408
procedure FrmReturnToForm(formId: UInt16); syscall sysTrapFrmReturnToForm;
410
procedure FrmCloseAllForms; syscall sysTrapFrmCloseAllForms;
412
procedure FrmSaveAllForms; syscall sysTrapFrmSaveAllForms;
414
function FrmPointInTitle(const formP: FormPtr; x, y: Coord): Boolean; syscall sysTrapFrmPointInTitle;
416
procedure FrmSetMenu(formP: FormPtr; menuRscID: UInt16); syscall sysTrapFrmSetMenu;
418
function FrmValidatePtr(const formP: FormPtr): Boolean; syscall sysTrapFrmValidatePtr;
420
function FrmAddSpaceForObject(var formPP: FormPtr; var objectPP: MemPtr; objectKind: FormObjectKind; objectSize: UInt16): Err; syscall sysTrapFrmAddSpaceForObject;
422
function FrmRemoveObject(var formPP: FormPtr; objIndex: UInt16): Err; syscall sysTrapFrmRemoveObject;
424
function FrmNewForm(formID: UInt16; const titleStrP: PChar; x, y, width, height: Coord; modal: Boolean;
425
defaultButton, helpRscID, menuRscID: UInt16): FormPtr; syscall sysTrapFrmNewForm;
427
function FrmNewLabel(var formPP: FormPtr; ID: UInt16; const textP: PChar; x, y: Coord; font: FontID): FormLabelPtr; syscall sysTrapFrmNewLabel;
429
function FrmNewBitmap(var formPP: FormPtr; ID, rscID: UInt16; x, y: Coord): FormBitmapPtr; syscall sysTrapFrmNewBitmap;
431
function FrmNewGadget(var formPP: FormPtr; id: UInt16; x, y, width, height: Coord): FormGadgetPtr; syscall sysTrapFrmNewGadget;
433
function FrmActiveState(var stateP: FormActiveStateType; save: Boolean): Err; syscall sysTrapFrmActiveState;
435
function FrmCustomResponseAlert(alertId: UInt16; const s1, s2, s3: PChar; entryStringBuf: PChar;
436
entryStringBufLength: Int16; callback: FormCheckResponseFuncType): UInt16; syscall sysTrapFrmCustomResponseAlert;
438
function FrmNewGsi(var formPP: FormPtr; x, y: Coord): FrmGraffitiStatePtr; syscall sysTrapFrmNewGsi;
440
function FrmSaveActiveState(var stateP: FormActiveStateType): Err;
441
function FrmRestoreActiveState(var stateP: FormActiveStateType): Err;
445
function FrmSaveActiveState(var stateP: FormActiveStateType): Err;
447
FrmSaveActiveState := FrmActiveState(stateP, True);
450
function FrmRestoreActiveState(var stateP: FormActiveStateType): Err;
452
FrmRestoreActiveState := FrmActiveState(stateP, False);