65 object->id = screen->
curId++;
68 editbox = &(
object->u.editbox);
90 label = &(editbox->
label);
91 if (maxlen == 0) maxlen = strlen(text);
92 label->
text = (
char*)calloc(1, maxlen+1);
93 strncpy(label->
text, text, maxlen);
94 label->
text[maxlen] =
'\0';
101 buf = (
char*)malloc(maxlen+1);
102 if (buf == NULL)
return -1;
103 for (i = 0; i < maxlen; i++) buf[i] =
'W';
105 width =
gfuiFont[font]->getWidth((
const char *)buf);
110 label->
x =
object->xmin = x;
111 label->
y =
y - 2 *
gfuiFont[font]->getDescender();
113 object->xmax = x + width;
115 editbox->
cursory1 =
object->ymin + 2;
116 editbox->
cursory2 =
object->ymax - 2;
119 object->xmin -= margin;
120 object->xmax += margin;
148 if (curObject != NULL) {
150 curObject = curObject->
next;
151 if (curObject->
focus) {
153 return curObject->
id;
195 glBegin(GL_LINE_STRIP);
203 label = &(editbox->
label);
235 }
else if (mouse == 0) {
236 editbox = &(
object->u.editbox);
237 label = &(editbox->
label);
240 for (i = 0; i < strlen(label->
text); i++){
241 buf[i] = label->
text[i];
243 if (relX < label->font->getWidth((
const char *)buf)) {
266 label = &(editbox->
label);
286 label = &(editbox->
label);
290 case GLUT_ACTIVE_SHIFT:
292 case 256 + GLUT_KEY_RIGHT:
298 case 256 + GLUT_KEY_LEFT:
304 case 256 + GLUT_KEY_HOME:
307 case 256 + GLUT_KEY_END:
314 while ( *p1 !=
'\0' ) {
323 while ( *p1 !=
'\0' ) {
330 if (key >=
' ' && key < 127) {
331 if ((
int)strlen(label->
text) < label->
maxlen) {
332 i2 = (int)strlen(label->
text) + 1;
345 case GLUT_ACTIVE_CTRL:
348 case GLUT_ACTIVE_ALT:
377 label = &(editbox->
label);
403 label = &(editbox->
label);
417 label = &(editbox->
label);
int getWidth(const char *text)
static void onFocusLost(void)
int GfuiEditboxGetFocused(void)
Get the Id of the editbox focused in the current screen.
int GfuiEditboxCreateAction(void *scr, const char *text, int font, int x, int y, int width, int maxlen, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost, int margin)
Add an edit box to a screen.
int GfuiEditboxCreate(void *scr, const char *text, int font, int x, int y, int width, int maxlen, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost, int margin)
Create an edit box using callbacks with caller-supplied data.
void GfuiEditboxSetString(void *scr, int id, const char *text)
Set a new string.
char * GfuiEditboxGetString(void *scr, int id)
Get the current text of an edit box.
void gfuiReleaseAction(tGfuiAction *action)
tGfuiAction gfuiMakeAction(void *userData, tfuiCallback callback)
float GfuiColor[GFUI_COLORNB][4]
tGfuiAction * gfuiCreateAction(const tGfuiAction &action)
#define GFUI_EDITCURSORCLR
#define GFUI_BTN_RELEASED
#define GFUI_BGBTNENABLED
#define GFUI_BGBTNDISABLED
void gfuiPrintString(int x, int y, GfuiFontClass *font, const char *string)
void gfuiSelectNext(void *)
void gfuiAddObject(tGfuiScreen *screen, tGfuiObject *object)
struct GfuiObject tGfuiObject
tGfuiObject * gfuiGetObject(void *scr, int id)
#define GFUI_FOCUS_MOUSE_CLICK
void gfuiEditboxKey(tGfuiObject *obj, int key, int modifier)
void gfuiEditboxAction(int mouse)
void gfuiDrawEditbox(tGfuiObject *obj)
void gfuiEditboxInit(void)
void gfuiReleaseEditbox(tGfuiObject *curObject)
static void gfuiEditboxRecalcCursor(tGfuiObject *obj)
GfuiFontClass * gfuiFont[FONT_NB]
union GfuiObject::@107216344126174123112226307372375007210201317144 u
tGfuiAction * onFocusLostAction
tGfuiAction * onFocusAction
The Gaming Framework API (client part).
void(* tfuiCallback)(void *)
std::function< void()> tGfuiAction