1 /***********************************************************
2 * Artsoft Retro-Game Library *
3 *----------------------------------------------------------*
4 * (c) 1994-2002 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
20 #define GADGET_FRAME_DELAY 150 /* delay between gadget actions */
23 #define GD_TYPE_NORMAL_BUTTON (1 << 0)
24 #define GD_TYPE_CHECK_BUTTON (1 << 1)
25 #define GD_TYPE_RADIO_BUTTON (1 << 2)
26 #define GD_TYPE_DRAWING_AREA (1 << 3)
27 #define GD_TYPE_TEXTINPUT_ALPHANUMERIC (1 << 4)
28 #define GD_TYPE_TEXTINPUT_NUMERIC (1 << 5)
29 #define GD_TYPE_SCROLLBAR_VERTICAL (1 << 6)
30 #define GD_TYPE_SCROLLBAR_HORIZONTAL (1 << 7)
32 #define GD_TYPE_BUTTON (GD_TYPE_NORMAL_BUTTON | \
33 GD_TYPE_CHECK_BUTTON | \
35 #define GD_TYPE_SCROLLBAR (GD_TYPE_SCROLLBAR_VERTICAL | \
36 GD_TYPE_SCROLLBAR_HORIZONTAL)
37 #define GD_TYPE_TEXTINPUT (GD_TYPE_TEXTINPUT_ALPHANUMERIC | \
38 GD_TYPE_TEXTINPUT_NUMERIC)
41 #define GD_EVENT_PRESSED (1 << 0)
42 #define GD_EVENT_RELEASED (1 << 1)
43 #define GD_EVENT_MOVING (1 << 2)
44 #define GD_EVENT_REPEATED (1 << 3)
45 #define GD_EVENT_OFF_BORDERS (1 << 4)
46 #define GD_EVENT_TEXT_RETURN (1 << 5)
47 #define GD_EVENT_TEXT_LEAVING (1 << 6)
48 #define GD_EVENT_INFO_ENTERING (1 << 7)
49 #define GD_EVENT_INFO_LEAVING (1 << 8)
51 /* gadget button states */
52 #define GD_BUTTON_UNPRESSED 0
53 #define GD_BUTTON_PRESSED 1
55 /* gadget structure constants */
56 #define MAX_GADGET_TEXTSIZE 1024
57 #define MAX_INFO_TEXTSIZE 1024
59 /* gadget creation tags */
61 #define GDI_CUSTOM_ID 1
62 #define GDI_CUSTOM_TYPE_ID 2
70 #define GDI_RADIO_NR 10
71 #define GDI_NUMBER_VALUE 11
72 #define GDI_NUMBER_MIN 12
73 #define GDI_NUMBER_MAX 13
74 #define GDI_TEXT_VALUE 14
75 #define GDI_TEXT_SIZE 15
76 #define GDI_TEXT_FONT 16
77 #define GDI_DESIGN_UNPRESSED 17
78 #define GDI_DESIGN_PRESSED 18
79 #define GDI_ALT_DESIGN_UNPRESSED 19
80 #define GDI_ALT_DESIGN_PRESSED 20
81 #define GDI_BORDER_SIZE 21
82 #define GDI_TEXTINPUT_DESIGN_WIDTH 22
83 #define GDI_DECORATION_DESIGN 23
84 #define GDI_DECORATION_POSITION 24
85 #define GDI_DECORATION_SIZE 25
86 #define GDI_DECORATION_SHIFTING 26
87 #define GDI_EVENT_MASK 27
89 #define GDI_CALLBACK_INFO 29
90 #define GDI_CALLBACK_ACTION 30
91 #define GDI_AREA_SIZE 31
92 #define GDI_ITEM_SIZE 32
93 #define GDI_SCROLLBAR_ITEMS_MAX 33
94 #define GDI_SCROLLBAR_ITEMS_VISIBLE 34
95 #define GDI_SCROLLBAR_ITEM_POSITION 35
96 #define GDI_INFO_TEXT 36
98 typedef void (*gadget_function)(void *);
102 int size; /* size of gadget border */
103 int width; /* for text input gadgets */
108 Bitmap *bitmap; /* Bitmap with gadget surface */
109 int x, y; /* position of rectangle in Bitmap */
112 struct GadgetDecoration
114 struct GadgetDesign design; /* decoration design structure */
115 int x, y; /* position of deco on the gadget */
116 int width, height; /* width and height of decoration */
117 int xshift, yshift; /* deco shifting when gadget pressed */
122 unsigned long type; /* event type */
123 int button; /* button number for button events */
124 int x, y; /* gadget position at event time */
125 boolean off_borders; /* mouse pointer outside gadget? */
126 int item_x, item_y, item_position; /* new item position */
129 struct GadgetDrawingArea
131 int area_xsize, area_ysize; /* size of drawing area (in items) */
132 int item_xsize, item_ysize; /* size of each item in drawing area */
135 struct GadgetTextInput
137 char value[MAX_GADGET_TEXTSIZE]; /* text string in input field */
138 int number_value; /* integer value, if numeric */
139 int number_min; /* minimal allowed numeric value */
140 int number_max; /* maximal allowed numeric value */
141 int size; /* maximal size of input text */
142 int cursor_position; /* actual cursor position */
143 int font_type; /* font to use for text input */
146 struct GadgetScrollbar
148 int items_max; /* number of items to access */
149 int items_visible; /* number of visible items */
150 int item_position; /* actual item position */
151 int size_max; /* this is either width or height */
152 int size; /* scrollbar size on screen */
153 int position; /* scrollbar position on screen */
154 int position_max; /* bottom/right scrollbar position */
155 int drag_position; /* drag position on scrollbar */
156 int correction; /* scrollbar position correction */
161 int id; /* internal gadget identifier */
162 int custom_id; /* custom gadget identifier */
163 int custom_type_id; /* custom gadget type identifier */
164 char info_text[MAX_INFO_TEXTSIZE]; /* short popup info text */
165 int x, y; /* gadget position */
166 int width, height; /* gadget size */
167 unsigned long type; /* type (button, text input, ...) */
168 unsigned long state; /* state (pressed, released, ...) */
169 boolean checked; /* check/radio button state */
170 int radio_nr; /* number of radio button series */
171 boolean mapped; /* gadget is active */
172 struct GadgetBorder border; /* gadget border design */
173 struct GadgetDesign design[2]; /* 0: normal; 1: pressed */
174 struct GadgetDesign alt_design[2]; /* alternative design */
175 struct GadgetDecoration deco; /* decoration on top of gadget */
176 unsigned long event_mask; /* possible events for this gadget */
177 struct GadgetEvent event; /* actual gadget event */
178 gadget_function callback_info; /* function for pop-up info text */
179 gadget_function callback_action; /* function for gadget action */
180 struct GadgetDrawingArea drawing; /* fields for drawing area gadget */
181 struct GadgetTextInput text; /* fields for text input gadget */
182 struct GadgetScrollbar scrollbar; /* fields for scrollbar gadget */
183 struct GadgetInfo *next; /* next list entry */
186 struct GadgetInfo *CreateGadget(int, ...);
187 void FreeGadget(struct GadgetInfo *);
189 void ModifyGadget(struct GadgetInfo *, int, ...);
190 void RedrawGadget(struct GadgetInfo *);
192 void MapGadget(struct GadgetInfo *);
193 void UnmapGadget(struct GadgetInfo *);
194 void UnmapAllGadgets();
195 void RemapAllGadgets();
197 boolean anyTextGadgetActive();
198 void ClickOnGadget(struct GadgetInfo *, int);
200 void HandleGadgets(int, int, int);
201 void HandleGadgetsKeyInput(Key);
203 #endif /* GADGETS_H */