aboutsummaryrefslogtreecommitdiff
path: root/SrcShared/Palm/Platform/Incs/Core/UI/Control.h
blob: bd23d96a234be580a0d3af6257455f65a6a5e30a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/******************************************************************************
 *
 * Copyright (c) 1994-1999 Palm Computing, Inc. or its subsidiaries.
 * All rights reserved.
 *
 * File: Control.h
 *
 * Description:
 *	  This file defines check box structures and routines.
 *
 * History:
 *		August 29, 1994	Created by Art Lamb
 *			Name	Date		Description
 *			----	----		-----------
 *			bob	2/9/99	Fix up const stuff
 *			bob	4/16/99	add GraphicControlType
 *
 *****************************************************************************/

#ifndef __CONTROL_H__
#define __CONTROL_H__

#include <PalmTypes.h>
#include <CoreTraps.h>
#include <DataMgr.h>
#include <Event.h>

typedef struct {
	UInt8 usable				:1;	// set if part of ui 
	UInt8 enabled				:1;	// set if interactable (not grayed out)
	UInt8 visible				:1;	// set if drawn (set internally)
	UInt8 on						:1;	// set if on (checked)
	UInt8 leftAnchor			:1;	// set if bounds expand to the right
	                        		// clear if bounds expand to the left
   UInt8 frame					:3;
	UInt8 drawnAsSelected	:1;	// support for old-style graphic controls
											// where control overlaps a bitmap
	UInt8 graphical			:1;	// set if images are used instead of text
	UInt8 vertical				:1;	// true for vertical sliders
	UInt8 reserved				:5;
} ControlAttrType;


enum controlStyles {buttonCtl, pushButtonCtl, checkboxCtl, popupTriggerCtl,
						  selectorTriggerCtl, repeatingButtonCtl, sliderCtl,
						  feedbackSliderCtl };
typedef enum controlStyles ControlStyleType;

enum buttonFrames {noButtonFrame, standardButtonFrame, boldButtonFrame,
						 rectangleButtonFrame};
typedef enum buttonFrames ButtonFrameType;


typedef struct ControlType {
	UInt16					id;
	RectangleType			bounds;
	Char *				   text;	
	ControlAttrType		attr;
	ControlStyleType		style;
	FontID					font;
	UInt8						group;
	UInt8 					reserved;
} ControlType;

typedef ControlType *ControlPtr;				// deprecated, use ControlType *


// GraphicControlType *'s can be cast to ControlType *'s and passed to all
// Control API functions (as long as the 'graphical' bit in the attrs is set)

typedef struct GraphicControlType {
	UInt16					id;
	RectangleType			bounds;
	DmResID					bitmapID;			// overlays text in ControlType
	DmResID					selectedBitmapID;	// overlays text in ControlType
	ControlAttrType		attr;
	ControlStyleType		style;
	FontID					unused;
	UInt8						group;
	UInt8 					reserved;
} GraphicControlType;


// SliderControlType *'s can be cast to ControlType *'s and passed to all
// Control API functions (as long as the control style is a slider)

typedef struct SliderControlType {
	UInt16					id;
	RectangleType			bounds;
	DmResID					thumbID;			// overlays text in ControlType
	DmResID					backgroundID;	// overlays text in ControlType
	ControlAttrType		attr;				// graphical *is* set
	ControlStyleType		style;			// must be sliderCtl or repeatingSliderCtl
	UInt8						reserved;		
	Int16						minValue;
	Int16						maxValue;
	Int16						pageSize;
	Int16						value;
	MemPtr					activeSliderP;
} SliderControlType;


//----------------------------------------------------------
//	Control Functions
//----------------------------------------------------------

#ifdef __cplusplus
extern "C" {
#endif

extern void CtlDrawControl (ControlType *controlP)
							SYS_TRAP(sysTrapCtlDrawControl);

extern void CtlEraseControl (ControlType *controlP)
							SYS_TRAP(sysTrapCtlEraseControl);

extern void CtlHideControl (ControlType *controlP)
							SYS_TRAP(sysTrapCtlHideControl);

extern void CtlShowControl (ControlType *controlP)
							SYS_TRAP(sysTrapCtlShowControl);

extern Boolean CtlEnabled (const ControlType *controlP)
							SYS_TRAP(sysTrapCtlEnabled);

extern void CtlSetEnabled (ControlType *controlP, Boolean usable)
							SYS_TRAP(sysTrapCtlSetEnabled);

extern void CtlSetUsable (ControlType *controlP, Boolean usable)
							SYS_TRAP(sysTrapCtlSetUsable);

extern Int16 CtlGetValue (const ControlType *controlP)
							SYS_TRAP(sysTrapCtlGetValue);

extern void CtlSetValue (ControlType *controlP, Int16 newValue)
							SYS_TRAP(sysTrapCtlSetValue);

extern const Char *CtlGetLabel (const ControlType *controlP)
							SYS_TRAP(sysTrapCtlGetLabel);

extern void CtlSetLabel (ControlType *controlP, const Char *newLabel)
							SYS_TRAP(sysTrapCtlSetLabel);

extern void CtlSetGraphics (ControlType *ctlP,
	DmResID newBitmapID, DmResID newSelectedBitmapID)
							SYS_TRAP(sysTrapCtlSetGraphics);

extern void CtlSetSliderValues(ControlType *ctlP, const UInt16 *minValueP, const UInt16 *maxValueP,
					const UInt16 *pageSizeP, const UInt16 *valueP)
							SYS_TRAP(sysTrapCtlSetSliderValues);

extern void CtlGetSliderValues(const ControlType *ctlP, UInt16 *minValueP, UInt16 *maxValueP,
					UInt16 *pageSizeP, UInt16 *valueP)
							SYS_TRAP(sysTrapCtlGetSliderValues);

extern void CtlHitControl (const ControlType *controlP)
							SYS_TRAP(sysTrapCtlHitControl);

extern Boolean CtlHandleEvent (ControlType *controlP, EventType *pEvent)
							SYS_TRAP(sysTrapCtlHandleEvent);

extern Boolean CtlValidatePointer (const ControlType *controlP)
							SYS_TRAP(sysTrapCtlValidatePointer);

extern ControlType *CtlNewControl (void **formPP, UInt16 ID, 
 	ControlStyleType style, const Char *textP, 
	Coord x, Coord y, Coord width, Coord height, 
	FontID font, UInt8 group, Boolean leftAnchor)
							SYS_TRAP(sysTrapCtlNewControl);

extern GraphicControlType *CtlNewGraphicControl (void **formPP, UInt16 ID, 
   ControlStyleType style, DmResID bitmapID, DmResID selectedBitmapID, 
   Coord x, Coord y, Coord width, Coord height, 
   UInt8 group, Boolean leftAnchor)
							SYS_TRAP(sysTrapCtlNewGraphicControl);

extern SliderControlType *CtlNewSliderControl (void **formPP, UInt16 ID, 
   ControlStyleType style, DmResID thumbID, DmResID backgroundID, 
   Coord x, Coord y, Coord width, Coord height, UInt16 minValue, UInt16 maxValue,
   UInt16 pageSize, UInt16 value)
							SYS_TRAP(sysTrapCtlNewSliderControl);

#ifdef __cplusplus 
}
#endif


#endif //__CONTROL_H__