00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _GUI_H__
00020 #define _GUI_H__
00021
00022 #include "guifont.h"
00023
00024 #define GFUI_COLORNB 21
00025 extern float GfuiColor[GFUI_COLORNB][4];
00026
00027 #define GFUI_BGCOLOR 0
00028 #define GFUI_TITLECOLOR 1
00029 #define GFUI_BGBTNFOCUS 2
00030 #define GFUI_BGBTNCLICK 3
00031 #define GFUI_BGBTNENABLED 4
00032 #define GFUI_BGBTNDISABLED 5
00033 #define GFUI_BTNFOCUS 6
00034 #define GFUI_BTNCLICK 7
00035 #define GFUI_BTNENABLED 8
00036 #define GFUI_BTNDISABLED 9
00037 #define GFUI_LABELCOLOR 10
00038 #define GFUI_TIPCOLOR 11
00039 #define GFUI_MOUSECOLOR1 12
00040 #define GFUI_MOUSECOLOR2 13
00041 #define GFUI_HELPCOLOR1 14
00042 #define GFUI_HELPCOLOR2 15
00043 #define GFUI_BGSCROLLIST 16
00044 #define GFUI_FGSCROLLIST 17
00045 #define GFUI_BGSELSCROLLIST 18
00046 #define GFUI_FGSELSCROLLIST 19
00047 #define GFUI_EDITCURSORCLR 20
00048 #define GFUI_IMAGE 21
00049
00050 typedef struct
00051 {
00052 char *text;
00053 float *bgColor;
00054 float *fgColor;
00055 GfuiFontClass *font;
00056 int x, y;
00057 int align;
00058 int maxlen;
00059 } tGfuiLabel;
00060
00061
00062 #define GFUI_BTN_DISABLE 0
00063 #define GFUI_BTN_RELEASED 1
00064 #define GFUI_BTN_PUSHED 2
00065
00066
00067 #define GFUI_BTN_PUSH 0
00068 #define GFUI_BTN_STATE 1
00069
00070 typedef struct
00071 {
00072 tGfuiLabel label;
00073 float *bgColor[3];
00074 float *fgColor[3];
00075 float *bgFocusColor[3];
00076 float *fgFocusColor[3];
00077 unsigned int state;
00078 int buttonType;
00079 int mouseBehaviour;
00080 void *userDataOnPush;
00081 tfuiCallback onPush;
00082 void *userDataOnFocus;
00083 tfuiCallback onFocus;
00084 tfuiCallback onFocusLost;
00085 } tGfuiButton;
00086
00087 typedef struct
00088 {
00089 unsigned int state;
00090 unsigned char *disabled;
00091 unsigned char *enabled;
00092 unsigned char *focused;
00093 unsigned char *pushed;
00094 int width, height;
00095 int buttonType;
00096 int mouseBehaviour;
00097 void *userDataOnPush;
00098 tfuiCallback onPush;
00099 void *userDataOnFocus;
00100 tfuiCallback onFocus;
00101 tfuiCallback onFocusLost;
00102 } tGfuiGrButton;
00103
00104 #define GFUI_FOCUS_NONE 0
00105 #define GFUI_FOCUS_MOUSE_MOVE 1
00106 #define GFUI_FOCUS_MOUSE_CLICK 2
00107
00108 typedef struct GfuiListElement
00109 {
00110 char *name;
00111 char *label;
00112 void *userData;
00113 int selected;
00114 int index;
00115 struct GfuiListElement *next;
00116 struct GfuiListElement *prev;
00117 } tGfuiListElement;
00118
00119 typedef struct
00120 {
00121 int sbPos;
00122 float *bgColor[3];
00123 float *fgColor[3];
00124 float *bgSelectColor[3];
00125 float *fgSelectColor[3];
00126 GfuiFontClass *font;
00127 tGfuiListElement *elts;
00128 int nbElts;
00129 int firstVisible;
00130 int nbVisible;
00131 int selectedElt;
00132 int scrollBar;
00133 tfuiCallback onSelect;
00134 void *userDataOnSelect;
00135 } tGfuiScrollList;
00136
00137 typedef struct
00138 {
00139 tScrollBarInfo info;
00140 int min, max, len, pos;
00141 int orientation;
00142 void *userData;
00143 tfuiSBCallback onScroll;
00144 } tGfuiScrollBar;
00145
00146 typedef struct
00147 {
00148 tGfuiLabel label;
00149 float *cursorColor[3];
00150 float *bgColor[3];
00151 float *fgColor[3];
00152 float *bgFocusColor[3];
00153 float *fgFocusColor[3];
00154 int state;
00155 int cursorx;
00156 int cursory1;
00157 int cursory2;
00158 int cursorIdx;
00159 void *userDataOnFocus;
00160 tfuiCallback onFocus;
00161 tfuiCallback onFocusLost;
00162 } tGfuiEditbox;
00163
00164 typedef struct
00165 {
00166 GLuint texture;
00167 } tGfuiImage;
00168
00169 typedef struct GfuiObject
00170 {
00171 int widget;
00172 int id;
00173 int visible;
00174 int focusMode;
00175 int focus;
00176 int state;
00177 int xmin, ymin;
00178 int xmax, ymax;
00179 union
00180 {
00181 tGfuiLabel label;
00182 tGfuiButton button;
00183 tGfuiGrButton grbutton;
00184 tGfuiScrollList scrollist;
00185 tGfuiScrollBar scrollbar;
00186 tGfuiEditbox editbox;
00187 tGfuiImage image;
00188 } u;
00189 struct GfuiObject *next;
00190 struct GfuiObject *prev;
00191 } tGfuiObject;
00192
00193
00194 typedef struct GfuiKey
00195 {
00196 unsigned char key;
00197 char *name;
00198 char *descr;
00199 int specialkey;
00200 int modifier;
00201 void *userData;
00202 tfuiCallback onPress;
00203 tfuiCallback onRelease;
00204 struct GfuiKey *next;
00205 } tGfuiKey;
00206
00207
00208 typedef struct
00209 {
00210 float width, height;
00211 float *bgColor;
00212 GLuint bgImage;
00213
00214
00215 tGfuiObject *objects;
00216 tGfuiObject *hasFocus;
00217 int curId;
00218
00219
00220 tGfuiKey *userKeys;
00221 tGfuiKey *userSpecKeys;
00222 void *userActData;
00223 tfuiCallback onActivate;
00224 void *userDeactData;
00225 tfuiCallback onDeactivate;
00226
00227
00228 tfuiKeyCallback onKeyAction;
00229 tfuiSKeyCallback onSKeyAction;
00230
00231
00232 int mouse;
00233 int mouseAllowed;
00234 float *mouseColor[2];
00235
00236
00237 int nbItems;
00238
00239
00240 int onlyCallback;
00241 } tGfuiScreen;
00242
00243
00244 extern tGfuiScreen *GfuiScreen;
00245 extern tMouseInfo GfuiMouse;
00246 extern int GfuiMouseHW;
00247
00248 extern void gfuiReleaseObject(tGfuiObject *curObject);
00249
00250 extern void GfuiDrawCursor();
00251 extern void GfuiDraw(tGfuiObject *obj);;
00252 extern void gfuiUpdateFocus();
00253 extern void gfuiPrintString(int x, int y, GfuiFontClass *font, char *string);
00254 extern void gfuiMouseAction(void *action);
00255 extern void gfuiSelectNext(void *);
00256 extern void gfuiSelectPrev(void *);
00257 extern void gfuiSelectId(void *scr, int id);
00258 extern void gfuiAddObject(tGfuiScreen *screen, tGfuiObject *object);
00259 extern tGfuiObject *gfuiGetObject(void *scr, int id);
00260
00261 extern void gfuiSetLabelText(tGfuiObject *object, tGfuiLabel *label, char *text);
00262
00263 extern void gfuiDrawLabel(tGfuiObject *obj);
00264 extern void gfuiDrawButton(tGfuiObject *obj);
00265 extern void gfuiButtonAction(int action);
00266 extern void gfuiDrawGrButton(tGfuiObject *obj);
00267 extern void gfuiGrButtonAction(int action);
00268 extern void gfuiDrawScrollist(tGfuiObject *obj);
00269 extern void gfuiScrollListAction(int mouse);
00270 extern void gfuiDrawEditbox(tGfuiObject *obj);
00271 extern void gfuiEditboxAction(int action);
00272
00273 extern void gfuiInit(void);
00274 extern void gfuiButtonInit(void);
00275 extern void gfuiHelpInit(void);
00276 extern void gfuiLabelInit(void);
00277 extern void gfuiObjectInit(void);
00278 extern void gfuiEditboxInit(void);
00279
00280 extern void gfuiReleaseLabel(tGfuiObject *obj);
00281 extern void gfuiReleaseButton(tGfuiObject *obj);
00282 extern void gfuiReleaseGrButton(tGfuiObject *obj);
00283 extern void gfuiReleaseScrollist(tGfuiObject *curObject);
00284 extern void gfuiReleaseScrollbar(tGfuiObject *curObject);
00285 extern void gfuiReleaseEditbox(tGfuiObject *curObject);
00286
00287 extern void gfuiLoadFonts(void);
00288
00289 extern void gfuiEditboxKey(tGfuiObject *obj, int key, int modifier);
00290
00291
00292 extern void gfuiScrollListNextElt (tGfuiObject *object);
00293 extern void gfuiScrollListPrevElt (tGfuiObject *object);
00294
00295 extern void gfuiReleaseImage(tGfuiObject *obj);
00296 extern void gfuiDrawImage(tGfuiObject *obj);
00297
00298
00299 #endif
00300
00301
00302