62 GfuiGrButtonCreate(
void *scr,
const char *disabled,
const char *enabled,
const char *focused,
const char *pushed,
63 int x,
int y,
int align,
int mouse,
75 object->id = screen->
curId++;
78 button = &(
object->u.grbutton);
94 object->xmin = x - width;
97 object->ymax =
y + height;
100 object->xmin = x - width;
102 object->ymin =
y - height / 2;
103 object->ymax =
y + height / 2;
106 object->xmin = x - width;
108 object->ymin =
y - height;
112 object->xmin = x - width / 2;
113 object->xmax = x + width / 2;
115 object->ymax =
y + height;
118 object->xmin = x - width / 2;
119 object->xmax = x + width / 2;
120 object->ymin =
y - height / 2;
121 object->ymax =
y + height / 2;
124 object->xmin = x - width / 2;
125 object->xmax = x + width / 2;
126 object->ymin =
y - height;
131 object->xmax = x + width;
133 object->ymax =
y + height;
137 object->xmax = x + width;
138 object->ymin =
y - height / 2;
139 object->ymax =
y + height / 2;
143 object->xmax = x + width;
144 object->ymin =
y - height;
151 button->
width = width;
197 id =
GfuiButtonCreate(scr, text, font, x,
y, width, align, mouse, userDataOnPush,
onPush, userDataOnFocus,
201 if (curObject != NULL) {
203 curObject = curObject->
next;
204 if (curObject->
id ==
id) {
206 button = &(curObject->
u.
button);
211 }
while (curObject != screen->
objects);
248 GfuiButtonCreate(
void *scr,
const char *text,
int font,
int x,
int y,
int width,
int align,
int mouse,
261 object->id = screen->
curId++;
264 button = &(
object->u.button);
287 label = &(button->
label);
288 label->
text = (
char*)calloc(1, 100);
289 strncpy(label->
text, text, 100);
290 label->
text[99] =
'\0';
297 label->
align = align;
301 label->
x =
object->xmin = x;
304 object->xmax = x + width;
308 object->xmin = x - width / 2;
312 object->xmax = x + width / 2;
316 label->
x =
object->xmin = x - width;
323 #define HORIZ_MARGIN 10 364 if (curObject != NULL) {
366 curObject = curObject->
next;
367 if (curObject->
id ==
id) {
369 oldmax = curObject->
xmax;
370 oldmin = curObject->
xmin;
372 curObject->
xmax = oldmax;
373 curObject->
xmin = oldmin;
377 }
while (curObject != screen->
objects);
393 if (curObject != NULL) {
395 curObject = curObject->
next;
396 if (curObject->
focus) {
398 return curObject->
id;
430 if (bgColor[3] != 0.0) {
439 glBegin(GL_LINE_STRIP);
447 label = &(button->
label);
464 }
else if (obj->
focus) {
470 glRasterPos2i(obj->
xmin, obj->
ymin);
472 glDrawPixels(button->
width, button->
height, GL_RGBA, GL_UNSIGNED_BYTE, img);
489 if (button->
onPush != NULL) {
492 }
else if (action == 1) {
496 if (button->
onPush != NULL) {
505 if (button->
onPush != NULL) {
517 if (button->
onPush != NULL) {
523 }
else if (action == 1) {
527 if (button->
onPush != NULL) {
538 if (button->
onPush != NULL) {
564 if (button->
onPush != NULL) {
567 }
else if (action == 1) {
570 if (button->
onPush != NULL) {
577 if (button->
onPush != NULL) {
588 if (button->
onPush != NULL) {
594 }
else if (action == 1) {
598 if (button->
onPush != NULL) {
609 if (button->
onPush != NULL) {
628 label = &(button->
label);
#define GFUI_BGBTNENABLED
void gfuiSetLabelText(tGfuiObject *object, tGfuiLabel *label, const char *text)
int GfuiButtonStateCreate(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, void *userDataOnPush, tfuiCallback onPush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
Add a state button to a screen.
int GfuiButtonCreate(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, void *userDataOnPush, tfuiCallback onPush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
Add a button to a screen.
int GfuiButtonGetFocused(void)
Get the Id of the button focused in the current screen.
static void onPush(void *vi)
The Gaming Framework API (client part).
void GfuiButtonSetText(void *scr, int id, const char *text)
Change the label of a button.
GfuiFontClass * gfuiFont[FONT_NB]
#define GFUI_FOCUS_MOUSE_MOVE
static void onFocusLost(void *)
#define GFUI_BTN_RELEASED
unsigned char * GfImgReadPng(const char *filename, int *widthp, int *heightp, float screen_gamma)
Load an image from disk to a buffer in RGBA mode.
void(* tfuiCallback)(void *)
tGfuiObject * gfuiGetObject(void *scr, int id)
void gfuiAddObject(tGfuiScreen *screen, tGfuiObject *object)
void GfScrGetSize(int *scrw, int *scrh, int *vieww, int *viewh)
Get the screen and viewport sizes.
#define GFUI_BGBTNDISABLED
float GfuiColor[GFUI_COLORNB][4]
int GfuiGrButtonCreate(void *scr, const char *disabled, const char *enabled, const char *focused, const char *pushed, int x, int y, int align, int mouse, void *userDataOnPush, tfuiCallback onPush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
Add a graphical button to a screen.
void gfuiPrintString(int x, int y, GfuiFontClass *font, const char *string)
int getWidth(const char *text)