1(******************************************************************************
2 *
3 * Copyright (c) 1994-2000 Palm, Inc. or its subsidiaries.
4 * All rights reserved.
5 *
6 * File: Control.h
7 *
8 * Release: Palm OS SDK 4.0 (63220)
9 *
10 * Description:
11 *   This file defines check box structures and routines.
12 *
13 * History:
14 *    August 29, 1994   Created by Art Lamb
15 *       Name  Date     Description
16 *       ----  ----     -----------
17 *       bob   2/9/99   Fix up const stuff
18 *       bob   4/16/99  add GraphicControlType
19 *
20 *****************************************************************************)
21{$MACRO ON}
22
23unit control;
24
25interface
26
27uses palmos, coretraps, rect, datamgr, font;
28
29type
30  ControlAttrType = record
31{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_CONTROLS} // These fields will not be available in the next OS release!
32    Bits: UInt16;
33{
34    UInt8 usable                :1; // set if part of ui
35    UInt8 enabled               :1; // set if interactable (not grayed out)
36    UInt8 visible               :1; // set if drawn (set internally)
37    UInt8 on                    :1; // set if on (checked)
38    UInt8 leftAnchor            :1; // set if bounds expand to the right
39                                    // clear if bounds expand to the left
40    UInt8 frame                 :3;
41    UInt8 drawnAsSelected       :1; // support for old-style graphic controls
42                                    // where control overlaps a bitmap
43    UInt8 graphical             :1; // set if images are used instead of text
44    UInt8 vertical              :1; // true for vertical sliders
45    UInt8 reserved              :5;
46}
47{$endif}
48  end;
49  ControlAttrTag = ControlAttrType;
50
51type
52  controlStyles = Enum;
53
54const
55  buttonCtl = 0;
56  pushButtonCtl = Succ(buttonCtl);
57  checkboxCtl = Succ(pushButtonCtl);
58  popupTriggerCtl = Succ(checkboxCtl);
59  selectorTriggerCtl = Succ(popupTriggerCtl);
60  repeatingButtonCtl = Succ(selectorTriggerCtl);
61  sliderCtl = Succ(repeatingButtonCtl);
62  feedbackSliderCtl = Succ(sliderCtl);
63
64type
65  ControlStyleType = controlStyles;
66
67type
68  buttonFrames = Enum;
69
70const
71  noButtonFrame = 0;
72  standardButtonFrame = Succ(noButtonFrame);
73  boldButtonFrame = Succ(standardButtonFrame);
74  rectangleButtonFrame = Succ(boldButtonFrame);
75
76type
77  ButtonFrameType = buttonFrames;
78
79type
80  ControlType = record
81{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_CONTROLS} // These fields will not be available in the next OS release!
82    id: UInt16;
83    bounds: RectangleType;
84    text: PChar;
85    attr: ControlAttrType;
86    style: ControlStyleType;
87    font: FontID;
88    group: UInt8;
89    reserved: UInt8;
90{$endif}
91  end;
92
93  ControlPtr = ^ControlType; // deprecated, use ControlType *
94
95// GraphicControlType *'s can be cast to ControlType *'s and passed to all
96// Control API functions (as long as the 'graphical' bit in the attrs is set)
97
98  GraphicControlType = record
99{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_CONTROLS} // These fields will not be available in the next OS release!
100    id: UInt16;
101    bounds: RectangleType;
102    bitmapID: DmResID;         // overlays text in ControlType
103    selectedBitmapID: DmResID; // overlays text in ControlType
104    attr: ControlAttrType;
105    style: ControlStyleType;
106    unused: FontID;
107    group: UInt8;
108    reserved: UInt8;
109{$endif}
110  end;
111  GraphicControlPtr = ^GraphicControlType;
112
113// SliderControlType *'s can be cast to ControlType *'s and passed to all
114// Control API functions (as long as the control style is a slider)
115
116  SliderControlType = record
117{$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_CONTROLS} // These fields will not be available in the next OS release!
118    id: UInt16;
119    bounds: RectangleType;
120    thumbID: DmResID;        // overlays text in ControlType
121    backgroundID: DmResID;   // overlays text in ControlType
122    attr: ControlAttrType;   // graphical *is* set
123    style: ControlStyleType; // must be sliderCtl or repeatingSliderCtl
124    reserved: UInt8;
125    minValue: Int16;
126    maxValue: Int16;
127    pageSize: Int16;
128    value: Int16;
129    activeSliderP: MemPtr;
130{$endif}
131  end;
132  SliderControlPtr = ^SliderControlType;
133
134//----------------------------------------------------------
135//  Control Functions
136//----------------------------------------------------------
137
138procedure CtlDrawControl(controlP: ControlPtr); syscall sysTrapCtlDrawControl;
139
140procedure CtlEraseControl(controlP: ControlPtr); syscall sysTrapCtlEraseControl;
141
142procedure CtlHideControl(controlP: ControlPtr); syscall sysTrapCtlHideControl;
143
144procedure CtlShowControl(controlP: ControlPtr); syscall sysTrapCtlShowControl;
145
146function CtlEnabled(const controlP: ControlPtr): Boolean; syscall sysTrapCtlEnabled;
147
148procedure CtlSetEnabled(controlP: ControlPtr; usable: Boolean); syscall sysTrapCtlSetEnabled;
149
150procedure CtlSetUsable(controlP: ControlPtr; usable: Boolean); syscall sysTrapCtlSetUsable;
151
152function CtlGetValue(const controlP: ControlPtr): Int16; syscall sysTrapCtlGetValue;
153
154procedure CtlSetValue(controlP: ControlPtr; newValue: Int16); syscall sysTrapCtlSetValue;
155
156function CtlGetLabel(const controlP: ControlPtr): PChar; syscall sysTrapCtlGetLabel;
157
158procedure CtlSetLabel(controlP: ControlPtr; const newLabel: PChar); syscall sysTrapCtlSetLabel;
159
160procedure CtlSetGraphics(ctlP: ControlPtr; newBitmapID, newSelectedBitmapID: DmResID); syscall sysTrapCtlSetGraphics;
161
162procedure CtlSetSliderValues(ctlP: ControlPtr; {const} var minValueP, maxValueP, pageSizeP, valueP: UInt16); syscall sysTrapCtlSetSliderValues;
163
164procedure CtlGetSliderValues(const ctlP: ControlPtr; var minValueP, maxValueP, pageSizeP, valueP: UInt16); syscall sysTrapCtlGetSliderValues;
165
166procedure CtlHitControl(const controlP: ControlPtr); syscall sysTrapCtlHitControl;
167
168type
169  EventPtr = Pointer;
170
171function CtlHandleEvent(controlP: ControlPtr; pEvent: EventPtr): Boolean; syscall sysTrapCtlHandleEvent;
172
173function CtlValidatePointer(const controlP: ControlPtr): Boolean; syscall sysTrapCtlValidatePointer;
174
175function CtlNewControl(formPP: PointerPtr; ID: UInt16; style: ControlStyleType; const textP: PChar;
176                       x, y, width, height: Coord; font: FontID; group: UInt8; leftAnchor: Boolean): ControlPtr; syscall sysTrapCtlNewControl;
177
178function CtlNewGraphicControl(formPP: PointerPtr; ID: UInt16; style: ControlStyleType; bitmapID, selectedBitmapID: DmResID;
179                              x, y, width, height: Coord; group: UInt8; leftAnchor: Boolean): GraphicControlPtr; syscall sysTrapCtlNewGraphicControl;
180
181function CtlNewSliderControl(formPP: PointerPtr; ID: UInt16; style: ControlStyleType; thumbID, backgroundID: DmResID;
182                             x, y, width, height: Coord; minValue, maxValue, pageSize, value: UInt16): SliderControlPtr; syscall sysTrapCtlNewSliderControl;
183
184implementation
185
186end.
187