forked from DC-SWAT/DreamShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.pkg
More file actions
354 lines (291 loc) · 16.2 KB
/
GUI.pkg
File metadata and controls
354 lines (291 loc) · 16.2 KB
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
/*
luaGUI
by SWAT
*/
$
$#include "ds.h"
$#include "lua/tolua.h"
$
$
$
$GUI_Object *GUI_AnyToObject(void *type) { return (GUI_Object *)type; }
$GUI_Widget *GUI_AnyToWidget(void *type) { return (GUI_Widget *)type; }
$GUI_ListBox *GUI_AnyToListbox(void *type) { return (GUI_ListBox *)type; }
$GUI_Font *GUI_AnyToFont(void *type) { return (GUI_Font *)type; }
$GUI_Surface *GUI_AnyToSurface(void *type) { return (GUI_Surface *)type; }
$
$
$void GUI_Free(void *ptr) { GUI_ObjectDecRef((GUI_Object *) ptr); }
$
$
module GUI
{
/* flags */
#define WIDGET_PRESSED 0x00000001
#define WIDGET_INSIDE 0x00000002
#define WIDGET_HIDDEN 0x00000004
#define WIDGET_CHANGED 0x00000008
#define WIDGET_TRANSPARENT 0x00000010
#define WIDGET_HAS_FOCUS 0x00000020
#define WIDGET_WANTS_FOCUS 0x00000040
#define WIDGET_TURNED_ON 0x00000080
#define WIDGET_ALIGN_MASK 0x00000F00
#define WIDGET_HORIZ_MASK 0x00000300
#define WIDGET_HORIZ_RIGHT 0x00000100
#define WIDGET_HORIZ_LEFT 0x00000200
#define WIDGET_HORIZ_CENTER 0x00000300
#define WIDGET_VERT_MASK 0x00000C00
#define WIDGET_VERT_TOP 0x00000400
#define WIDGET_VERT_BOTTOM 0x00000800
#define WIDGET_VERT_CENTER 0x00000C00
#define WIDGET_DISABLED 0x00001000
#define WIDGET_TYPE_OTHER 0
#define WIDGET_TYPE_BUTTON 1
#define WIDGET_TYPE_SCROLLBAR 2
#define WIDGET_TYPE_CONTAINER 3
#define WIDGET_TYPE_CARDSTACK 4
#define WIDGET_TYPE_TEXTENTRY 5
/* GUI API */
void GUI_SetScreen(GUI_Screen *);
GUI_Screen *GUI_GetScreen(void);
int GUI_ClipRect(SDL_Rect *sr, SDL_Rect *dr, const SDL_Rect *clip);
/* Object API */
GUI_Object *GUI_ObjectCreate(const char *s);
const char *GUI_ObjectGetName(GUI_Object *object);
void GUI_ObjectSetName(GUI_Object *object, const char *s);
void GUI_ObjectIncRef(GUI_Object *object);
int GUI_ObjectDecRef(GUI_Object *object);
int GUI_ObjectGetRef(GUI_Object *object);
int GUI_ObjectKeep(GUI_Object **target, GUI_Object *source);
//int GUI_ObjectTrash(GUI_Object *object);
//void GUI_ClearTrash();
/* Surface API */
void GUI_SurfaceSaveBMP(GUI_Surface *src, const char *filename);
GUI_Surface *GUI_SurfaceLoad(const char *fn);
GUI_Surface *GUI_SurfaceLoad_Rect(const char *fn, SDL_Rect *selection);
GUI_Surface *GUI_SurfaceCreate(const char *aname, int f, int w, int h, int d, int rm, int gm, int bm, int am);
GUI_Surface *GUI_SurfaceFrom(const char *aname, SDL_Surface *src);
void GUI_SurfaceBlit(GUI_Surface *src, SDL_Rect *src_r, GUI_Surface *dst, SDL_Rect *dst_r);
void GUI_SurfaceFill(GUI_Surface *surface, SDL_Rect *r, Uint32 c);
void GUI_SurfaceUpdateRects(GUI_Surface *surface, int n, SDL_Rect *rects);
void GUI_SurfaceUpdateRect(GUI_Surface *surface, int x, int y, int w, int h);
int GUI_SurfaceGetWidth(GUI_Surface *surface);
int GUI_SurfaceGetHeight(GUI_Surface *surface);
Uint32 GUI_SurfaceMapRGB(GUI_Surface *surface, int r, int g, int b);
Uint32 GUI_SurfaceMapRGBA(GUI_Surface *surface, int r, int g, int b, int a);
//void GUI_SurfaceFlip(GUI_Surface *src);
SDL_Surface *GUI_SurfaceGet(GUI_Surface *surface);
void GUI_SurfaceSetAlpha(GUI_Surface *surface, Uint32 flag, Uint8 alpha);
/* Font API */
GUI_Surface *GUI_FontRenderFast(GUI_Font *font, const char *s, SDL_Color fg);
GUI_Surface *GUI_FontRenderQuality(GUI_Font *font, const char *s, SDL_Color fg);
void GUI_FontDrawText(GUI_Font *font, GUI_Surface *surface, const char *s, int x, int y);
SDL_Rect GUI_FontGetTextSize(GUI_Font *font, const char *s);
/* Widget API */
void GUI_WidgetUpdate(GUI_Widget *widget, int force);
void GUI_WidgetDraw(GUI_Widget *widget, GUI_Surface *image, const SDL_Rect *sr, const SDL_Rect *dr);
void GUI_WidgetErase(GUI_Widget *widget, const SDL_Rect *dr);
void GUI_WidgetFill(GUI_Widget *widget, const SDL_Rect *dr, SDL_Color c);
int GUI_WidgetEvent(GUI_Widget *widget, const SDL_Event *event, int xoffset, int yoffset);
void GUI_WidgetClicked(GUI_Widget *widget, int x, int y);
void GUI_WidgetContextClicked(GUI_Widget *widget, int x, int y);
void GUI_WidgetSetAlign(GUI_Widget *widget, int align);
void GUI_WidgetMarkChanged(GUI_Widget *widget);
void GUI_WidgetSetTransparent(GUI_Widget *widget, int trans);
void GUI_WidgetSetEnabled(GUI_Widget *widget, int flag);
void GUI_WidgetTileImage(GUI_Widget *widget, GUI_Surface *surface, const SDL_Rect *area, int x_offset, int y_offset);
void GUI_WidgetSetFlags(GUI_Widget *widget, int mask);
void GUI_WidgetClearFlags(GUI_Widget *widget, int mask);
void GUI_WidgetSetState(GUI_Widget *widget, int state);
int GUI_WidgetGetState(GUI_Widget *widget);
SDL_Rect GUI_WidgetGetArea(GUI_Widget *widget);
void GUI_WidgetSetPosition(GUI_Widget *widget, int x, int y);
void GUI_WidgetSetSize(GUI_Widget *widget, int w, int h);
int GUI_WidgetGetType(GUI_Widget *widget);
int GUI_WidgetGetFlags(GUI_Widget *widget);
GUI_Widget *GUI_WidgetGetParent(GUI_Widget *widget);
/* Container API */
int GUI_ContainerContains(GUI_Widget *container, GUI_Widget *widget);
void GUI_ContainerAdd(GUI_Widget *container, GUI_Widget *widget);
void GUI_ContainerRemove(GUI_Widget *container, GUI_Widget *widget);
void GUI_ContainerRemoveAll(GUI_Widget *container);
int GUI_ContainerGetCount(GUI_Widget *container);
void GUI_ContainerRemoveAll(GUI_Widget *container);
GUI_Widget *GUI_ContainerGetChild(GUI_Widget *container, int index);
void GUI_ContainerSetEnabled(GUI_Widget *container, int flag);
int GUI_ContainerIsVisibleWidget(GUI_Widget *container, GUI_Widget *widget);
/* Screen API */
void GUI_ScreenSetContents(GUI_Screen *screen, GUI_Widget *contents);
void GUI_ScreenSetBackground(GUI_Screen *screen, GUI_Surface *surface);
void GUI_ScreenSetFocusWidget(GUI_Screen *screen, GUI_Widget *item);
void GUI_ScreenClearFocusWidget(GUI_Screen *screen);
void GUI_ScreenSetBackgroundColor(GUI_Screen *screen, SDL_Color c);
GUI_Widget *GUI_ScreenGetFocusWidget(GUI_Screen *screen);
void GUI_ScreenSetJoySelectState(GUI_Screen *screen, int value);
void GUI_ScreenEvent(GUI_Screen *screen, const SDL_Event *event,
int xoffset, int yoffset);
void GUI_ScreenUpdate(GUI_Screen *screen, int force);
void GUI_ScreenDoUpdate(GUI_Screen *screen, int force);
void GUI_ScreenDraw(GUI_Screen *screen, GUI_Surface *image,
const SDL_Rect *src_r, const SDL_Rect *dst_r);
void GUI_ScreenFill(GUI_Screen *screen, const SDL_Rect *dst_r, SDL_Color c);
void GUI_ScreenErase(GUI_Screen *screen, const SDL_Rect *area);
GUI_Surface *GUI_ScreenGetSurface(GUI_Screen *screen);
/* Button Widget */
GUI_Widget *GUI_ButtonCreate(const char *name, int x, int y, int w, int h);
int GUI_ButtonCheck(GUI_Widget *widget);
void GUI_ButtonSetNormalImage(GUI_Widget *widget, GUI_Surface *surface);
void GUI_ButtonSetHighlightImage(GUI_Widget *widget, GUI_Surface *surface);
void GUI_ButtonSetPressedImage(GUI_Widget *widget, GUI_Surface *surface);
void GUI_ButtonSetDisabledImage(GUI_Widget *widget, GUI_Surface *surface);
void GUI_ButtonSetCaption(GUI_Widget *widget, GUI_Widget *caption);
void GUI_ButtonSetCaption2(GUI_Widget *widget, GUI_Widget *caption);
GUI_Widget *GUI_ButtonGetCaption(GUI_Widget *widget);
GUI_Widget *GUI_ButtonGetCaption2(GUI_Widget *widget);
void GUI_ButtonSetClick(GUI_Widget *widget, GUI_Callback *callback);
void GUI_ButtonSetContextClick(GUI_Widget *widget, GUI_Callback *callback);
void GUI_ButtonSetMouseover(GUI_Widget *widget, GUI_Callback *callback);
void GUI_ButtonSetMouseout(GUI_Widget *widget, GUI_Callback *callback);
/* Callback API */
/* GUI_Callback *GUI_CallbackCreate(GUI_CallbackFunction *function, GUI_CallbackFunction *freefunc, void *data); */
GUI_Callback *GUI_LuaCallbackCreate(int appId, const char *luastring);
void GUI_CallbackCall(GUI_Callback *callback);
/* FastFont object */
GUI_Font *GUI_FontLoadBitmap(char *fn);
/* TTF Font object */
GUI_Font *GUI_FontLoadTrueType(char *fn, int size);
/* Panel Widget API */
GUI_Widget *GUI_PanelCreate(const char *name, int x, int y, int w, int h);
int GUI_PanelCheck(GUI_Widget *widget);
void GUI_PanelSetBackground(GUI_Widget *widget, GUI_Surface *surface);
void GUI_PanelSetBackgroundCenter(GUI_Widget *widget, GUI_Surface *surface);
void GUI_PanelSetBackgroundColor(GUI_Widget *widget, SDL_Color c);
void GUI_PanelSetXOffset(GUI_Widget *widget, int value);
void GUI_PanelSetYOffset(GUI_Widget *widget, int value);
int GUI_PanelGetXOffset(GUI_Widget *widget);
int GUI_PanelGetYOffset(GUI_Widget *widget);
void GUI_PanelSetLayout(GUI_Widget *widget, GUI_Layout *layout);
/* VBox Layout object */
GUI_Layout *GUI_VBoxLayoutCreate(void);
/* ToggleButton Widget API */
GUI_Widget *GUI_ToggleButtonCreate(const char *name, int x, int y, int w, int h);
int GUI_ToggleButtonCheck(GUI_Widget *widget);
void GUI_ToggleButtonSetOnNormalImage(GUI_Widget *widget, GUI_Surface *surface);
void GUI_ToggleButtonSetOnHighlightImage(GUI_Widget *widget, GUI_Surface *surface);
void GUI_ToggleButtonSetOffNormalImage(GUI_Widget *widget, GUI_Surface *surface);
void GUI_ToggleButtonSetOffHighlightImage(GUI_Widget *widget, GUI_Surface *surface);
void GUI_ToggleButtonSetCaption(GUI_Widget *widget, GUI_Widget *caption);
GUI_Widget *GUI_ToggleButtonGetCaption(GUI_Widget *widget);
void GUI_ToggleButtonSetClick(GUI_Widget *widget, GUI_Callback *callback);
void GUI_ToggleButtonSetContextClick(GUI_Widget *widget, GUI_Callback *callback);
void GUI_ToggleButtonSetMouseover(GUI_Widget *widget, GUI_Callback *callback);
void GUI_ToggleButtonSetMouseout(GUI_Widget *widget, GUI_Callback *callback);
/* Label Widget API */
GUI_Widget *GUI_LabelCreate(const char *name, int x, int y, int w, int h, GUI_Font *font, const char *text);
int GUI_LabelCheck(GUI_Widget *widget);
void GUI_LabelSetFont(GUI_Widget *widget, GUI_Font *font);
void GUI_LabelSetTextColor(GUI_Widget *widget, int r, int g, int b);
void GUI_LabelSetText(GUI_Widget *widget, const char *text);
char *GUI_LabelGetText(GUI_Widget *widget);
/* Picture Widget API */
GUI_Widget *GUI_PictureCreate(const char *name, int x, int y, int w, int h, GUI_Surface *image);
int GUI_PictureCheck(GUI_Widget *widget);
void GUI_PictureSetImage(GUI_Widget *widget, GUI_Surface *image);
void GUI_PictureSetCaption(GUI_Widget *widget, GUI_Widget *caption);
/* ProgressBar widget API */
GUI_Widget *GUI_ProgressBarCreate(const char *name, int x, int y, int w, int h);
int GUI_ProgressBarCheck(GUI_Widget *widget);
void GUI_ProgressBarSetImage1(GUI_Widget *widget, GUI_Surface *image);
void GUI_ProgressBarSetImage2(GUI_Widget *widget, GUI_Surface *image);
void GUI_ProgressBarSetPosition(GUI_Widget *widget, double value);
/* ScrollBar widget API */
GUI_Widget *GUI_ScrollBarCreate(const char *name, int x, int y, int w, int h);
int GUI_ScrollBarCheck(GUI_Widget *widget);
void GUI_ScrollBarSetKnobImage(GUI_Widget *widget, GUI_Surface *image);
GUI_Surface *GUI_ScrollBarGetKnobImage(GUI_Widget *widget);
void GUI_ScrollBarSetBackgroundImage(GUI_Widget *widget, GUI_Surface *image);
void GUI_ScrollBarSetPosition(GUI_Widget *widget, int value); // Deprecated
int GUI_ScrollBarGetPosition(GUI_Widget *widget); // Deprecated
void GUI_ScrollBarSetMovedCallback(GUI_Widget *widget, GUI_Callback *callback);
int GUI_ScrollBarGetHorizontalPosition(GUI_Widget *widget);
int GUI_ScrollBarGetVerticalPosition(GUI_Widget *widget);
void GUI_ScrollBarSetHorizontalPosition(GUI_Widget *widget, int value);
void GUI_ScrollBarSetVerticalPosition(GUI_Widget *widget, int value);
/* CardStack widget API */
GUI_Widget *GUI_CardStackCreate(const char *name, int x, int y, int w, int h);
int GUI_CardStackCheck(GUI_Widget *widget);
void GUI_CardStackSetBackground(GUI_Widget *widget, GUI_Surface *surface);
void GUI_CardStackSetBackgroundColor(GUI_Widget *widget, SDL_Color c);
void GUI_CardStackNext(GUI_Widget *widget);
void GUI_CardStackPrev(GUI_Widget *widget);
void GUI_CardStackShowIndex(GUI_Widget *widget, int index);
void GUI_CardStackShow(GUI_Widget *widget, const char *name);
int GUI_CardStackGetIndex(GUI_Widget *widget);
/* TextEntry widget API */
GUI_Widget *GUI_TextEntryCreate(const char *name, int x, int y, int w, int h, GUI_Font *font, int size);
int GUI_TextEntryCheck(GUI_Widget *widget);
void GUI_TextEntrySetFont(GUI_Widget *widget, GUI_Font *font);
void GUI_TextEntrySetTextColor(GUI_Widget *widget, int r, int g, int b);
void GUI_TextEntrySetText(GUI_Widget *widget, const char *text);
const char *GUI_TextEntryGetText(GUI_Widget *widget);
void GUI_TextEntrySetNormalImage(GUI_Widget *widget, GUI_Surface *surface);
void GUI_TextEntrySetHighlightImage(GUI_Widget *widget, GUI_Surface *surface);
void GUI_TextEntrySetFocusImage(GUI_Widget *widget, GUI_Surface *surface);
void GUI_TextEntrySetFocusCallback(GUI_Widget *widget, GUI_Callback *callback);
void GUI_TextEntrySetUnfocusCallback(GUI_Widget *widget, GUI_Callback *callback);
/* ListBox Widget API */
GUI_ListBox *GUI_CreateListBox(const char *aname, int x, int y, int w, int h, GUI_Font *afont);
int GUI_ListBoxGetRowCount(GUI_ListBox *list);
int GUI_ListBoxGetRowSize(GUI_ListBox *list, int row);
int GUI_ListBoxGetColumnCount(GUI_ListBox *list);
int GUI_ListBoxGetColumnSize(GUI_ListBox *list, int column);
void GUI_ListBoxSetFont(GUI_ListBox *list, GUI_Font *afont);
void GUI_ListBoxSetTextColor(GUI_ListBox *list, int r, int g, int b);
void GUI_ListBoxDrawCell(GUI_ListBox *list, int column, int row, const SDL_Rect *r);
void GUI_ListBoxAddItem(GUI_ListBox *list, const char *s);
void GUI_ListBoxRemoveItem(GUI_ListBox *list, int n);
/* RTF Widget API */
GUI_Widget *GUI_RTF_Load(const char *name, const char *file, const char *default_font, int x, int y, int w, int h);
GUI_Widget *GUI_RTF_LoadRW(const char *name, SDL_RWops *src, int freesrc, const char *default_font, int x, int y, int w, int h);
int GUI_RTF_GetFullHeight(GUI_Widget *widget);
void GUI_RTF_SetOffset(GUI_Widget *widget, int value);
void GUI_RTF_SetBgColor(GUI_Widget *widget, int r, int g, int b);
int GUI_RTF_SetFont(GUI_Widget *widget, RTF_FontFamily family, const char *file);
const char *GUI_RTF_GetTitle(GUI_Widget *widget);
const char *GUI_RTF_GetSubject(GUI_Widget *widget);
const char *GUI_RTF_GetAuthor(GUI_Widget *widget);
/* FileManager Widget API */
GUI_Widget *GUI_FileManagerCreate(const char *name, const char *path, int x, int y, int w, int h);
void GUI_FileManagerResize(GUI_Widget *widget, int w, int h);
void GUI_FileManagerSetPath(GUI_Widget *widget, const char *path);
const char *GUI_FileManagerGetPath(GUI_Widget *widget);
void GUI_FileManagerChangeDir(GUI_Widget *widget, const char *name, int size);
void GUI_FileManagerScan(GUI_Widget *widget);
void GUI_FileManagerAddItem(GUI_Widget *widget, const char *name, int size, int time, int attr);
GUI_Widget *GUI_FileManagerGetItem(GUI_Widget *widget, int index);
GUI_Widget *GUI_FileManagerGetItemPanel(GUI_Widget *widget);
void GUI_FileManagerSetItemSurfaces(GUI_Widget *widget, GUI_Surface *normal, GUI_Surface *highlight, GUI_Surface *pressed, GUI_Surface *disabled);
void GUI_FileManagerSetItemLabel(GUI_Widget *widget, GUI_Font *font, int r, int g, int b);
void GUI_FileManagerSetItemSize(GUI_Widget *widget, const SDL_Rect *item_r);
/** Not support by lua =(
void GUI_FileManagerSetItemClick(GUI_Widget *widget, GUI_CallbackFunction *func);
void GUI_FileManagerSetItemContextClick(GUI_Widget *widget, GUI_CallbackFunction *func);
void GUI_FileManagerSetItemMouseover(GUI_Widget *widget, GUI_CallbackFunction *func);
void GUI_FileManagerSetItemMouseout(GUI_Widget *widget, GUI_CallbackFunction *func);
*/
void GUI_FileManagerSetScrollbar(GUI_Widget *widget, GUI_Surface *knob, GUI_Surface *background);
void GUI_FileManagerSetScrollbarButtonUp(GUI_Widget *widget, GUI_Surface *normal, GUI_Surface *highlight, GUI_Surface *pressed, GUI_Surface *disabled);
void GUI_FileManagerSetScrollbarButtonDown(GUI_Widget *widget, GUI_Surface *normal, GUI_Surface *highlight, GUI_Surface *pressed, GUI_Surface *disabled);
int GUI_FileManagerEvent(GUI_Widget *widget, const SDL_Event *event, int xoffset, int yoffset);
void GUI_FileManagerUpdate(GUI_Widget *widget, int force);
void GUI_FileManagerRemoveScrollbar(GUI_Widget *widget);
void GUI_FileManagerRestoreScrollbar(GUI_Widget *widget);
GUI_Object *GUI_AnyToObject(void *type);
GUI_Widget *GUI_AnyToWidget(void *type);
GUI_ListBox *GUI_AnyToListbox(void *type);
GUI_Font *GUI_AnyToFont(void *type);
GUI_Surface *GUI_AnyToSurface(void *type);
void GUI_Free(void *ptr);
/* Ends C function definitions when using C++ */
} /* end tolua module GUI */
/* Some code to be included in the generated .c file */