1 /***********************************************************
2 * Artsoft Retro-Game Library *
3 *----------------------------------------------------------*
4 * (c) 1994-2001 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)
49 /* gadget button states */
50 #define GD_BUTTON_UNPRESSED 0
51 #define GD_BUTTON_PRESSED 1
53 /* gadget structure constants */
54 #define MAX_GADGET_TEXTSIZE 1024
55 #define MAX_INFO_TEXTSIZE 1024
57 /* gadget creation tags */
59 #define GDI_CUSTOM_ID 1
60 #define GDI_CUSTOM_TYPE_ID 2
68 #define GDI_RADIO_NR 10
69 #define GDI_NUMBER_VALUE 11
70 #define GDI_NUMBER_MIN 12
71 #define GDI_NUMBER_MAX 13
72 #define GDI_TEXT_VALUE 14
73 #define GDI_TEXT_SIZE 15
74 #define GDI_TEXT_FONT 16
75 #define GDI_DESIGN_UNPRESSED 17
76 #define GDI_DESIGN_PRESSED 18
77 #define GDI_ALT_DESIGN_UNPRESSED 19
78 #define GDI_ALT_DESIGN_PRESSED 20
79 #define GDI_BORDER_SIZE 21
80 #define GDI_TEXTINPUT_DESIGN_WIDTH 22
81 #define GDI_DECORATION_DESIGN 23
82 #define GDI_DECORATION_POSITION 24
83 #define GDI_DECORATION_SIZE 25
84 #define GDI_DECORATION_SHIFTING 26
85 #define GDI_EVENT_MASK 27
87 #define GDI_CALLBACK_INFO 29
88 #define GDI_CALLBACK_ACTION 30
89 #define GDI_AREA_SIZE 31
90 #define GDI_ITEM_SIZE 32
91 #define GDI_SCROLLBAR_ITEMS_MAX 33
92 #define GDI_SCROLLBAR_ITEMS_VISIBLE 34
93 #define GDI_SCROLLBAR_ITEM_POSITION 35
94 #define GDI_INFO_TEXT 36
96 typedef void (*gadget_function)(void *);
100 int size; /* size of gadget border */
101 int width; /* for text input gadgets */
106 Bitmap *bitmap; /* Bitmap with gadget surface */
107 int x, y; /* position of rectangle in Bitmap */
110 struct GadgetDecoration
112 struct GadgetDesign design; /* decoration design structure */
113 int x, y; /* position of deco on the gadget */
114 int width, height; /* width and height of decoration */
115 int xshift, yshift; /* deco shifting when gadget pressed */
120 unsigned long type; /* event type */
121 int button; /* button number for button events */
122 int x, y; /* gadget position at event time */
123 boolean off_borders; /* mouse pointer outside gadget? */
124 int item_x, item_y, item_position; /* new item position */
127 struct GadgetDrawingArea
129 int area_xsize, area_ysize; /* size of drawing area (in items) */
130 int item_xsize, item_ysize; /* size of each item in drawing area */
133 struct GadgetTextInput
135 char value[MAX_GADGET_TEXTSIZE]; /* text string in input field */
136 int number_value; /* integer value, if numeric */
137 int number_min; /* minimal allowed numeric value */
138 int number_max; /* maximal allowed numeric value */
139 int size; /* maximal size of input text */
140 int cursor_position; /* actual cursor position */
141 int font_type; /* font to use for text input */
144 struct GadgetScrollbar
146 int items_max; /* number of items to access */
147 int items_visible; /* number of visible items */
148 int item_position; /* actual item position */
149 int size_max; /* this is either width or height */
150 int size; /* scrollbar size on screen */
151 int position; /* scrollbar position on screen */
152 int position_max; /* bottom/right scrollbar position */
153 int drag_position; /* drag position on scrollbar */
154 int correction; /* scrollbar position correction */
159 int id; /* internal gadget identifier */
160 int custom_id; /* custom gadget identifier */
161 int custom_type_id; /* custom gadget type identifier */
162 char info_text[MAX_INFO_TEXTSIZE]; /* short popup info text */
163 int x, y; /* gadget position */
164 int width, height; /* gadget size */
165 unsigned long type; /* type (button, text input, ...) */
166 unsigned long state; /* state (pressed, released, ...) */
167 boolean checked; /* check/radio button state */
168 int radio_nr; /* number of radio button series */
169 boolean mapped; /* gadget is active */
170 struct GadgetBorder border; /* gadget border design */
171 struct GadgetDesign design[2]; /* 0: normal; 1: pressed */
172 struct GadgetDesign alt_design[2]; /* alternative design */
173 struct GadgetDecoration deco; /* decoration on top of gadget */
174 unsigned long event_mask; /* possible events for this gadget */
175 struct GadgetEvent event; /* actual gadget event */
176 gadget_function callback_info; /* function for pop-up info text */
177 gadget_function callback_action; /* function for gadget action */
178 struct GadgetDrawingArea drawing; /* fields for drawing area gadget */
179 struct GadgetTextInput text; /* fields for text input gadget */
180 struct GadgetScrollbar scrollbar; /* fields for scrollbar gadget */
181 struct GadgetInfo *next; /* next list entry */
184 struct GadgetInfo *CreateGadget(int, ...);
185 void FreeGadget(struct GadgetInfo *);
187 void ModifyGadget(struct GadgetInfo *, int, ...);
188 void RedrawGadget(struct GadgetInfo *);
190 void MapGadget(struct GadgetInfo *);
191 void UnmapGadget(struct GadgetInfo *);
192 void UnmapAllGadgets();
193 void RemapAllGadgets();
195 boolean anyTextGadgetActive();
196 void ClickOnGadget(struct GadgetInfo *, int);
198 void HandleGadgets(int, int, int);
199 void HandleGadgetsKeyInput(Key);
201 #endif /* GADGETS_H */