69 object->id = screen->
curId++;
72 editbox = &(
object->u.editbox);
95 label = &(editbox->
label);
96 if (maxlen == 0) maxlen = strlen(text);
97 label->
text = (
char*)calloc(1, maxlen+1);
98 strncpy(label->
text, text, maxlen);
99 label->
text[maxlen] =
'\0';
106 buf = (
char*)malloc(maxlen+1);
107 if (buf == NULL)
return -1;
108 for (i = 0; i < maxlen; i++) buf[i] =
'W';
115 label->
x =
object->xmin = x;
118 object->xmax = x + width;
120 editbox->
cursory1 =
object->ymin + 2;
121 editbox->
cursory2 =
object->ymax - 2;
124 object->xmin -= margin;
125 object->xmax += margin;
144 if (curObject != NULL) {
146 curObject = curObject->
next;
147 if (curObject->
focus) {
149 return curObject->
id;
191 glBegin(GL_LINE_STRIP);
199 label = &(editbox->
label);
231 }
else if (mouse == 0) {
232 editbox = &(
object->u.editbox);
233 label = &(editbox->
label);
236 for (i = 0; i < strlen(label->
text); i++){
237 buf[i] = label->
text[i];
239 if (relX < label->font->getWidth((
const char *)buf)) {
262 label = &(editbox->
label);
282 label = &(editbox->
label);
286 case GLUT_ACTIVE_SHIFT:
288 case 256 + GLUT_KEY_RIGHT:
294 case 256 + GLUT_KEY_LEFT:
300 case 256 + GLUT_KEY_HOME:
303 case 256 + GLUT_KEY_END:
310 while ( *p1 !=
'\0' ) {
319 while ( *p1 !=
'\0' ) {
326 if (key >=
' ' && key < 127) {
327 if ((
int)strlen(label->
text) < label->
maxlen) {
328 i2 = (int)strlen(label->
text) + 1;
341 case GLUT_ACTIVE_CTRL:
344 case GLUT_ACTIVE_ALT:
371 label = &(editbox->
label);
396 label = &(editbox->
label);
410 label = &(editbox->
label);
#define GFUI_BGBTNENABLED
void gfuiEditboxInit(void)
char * GfuiEditboxGetString(void *scr, int id)
Get the string.
int GfuiEditboxGetFocused(void)
Get the Id of the editbox focused in the current screen.
void gfuiDrawEditbox(tGfuiObject *obj)
void gfuiReleaseEditbox(tGfuiObject *curObject)
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)
Add a editbox to a screen.
The Gaming Framework API (client part).
GfuiFontClass * gfuiFont[FONT_NB]
void GfuiEditboxSetString(void *scr, int id, const char *text)
Set a new string.
static void onFocusLost(void *)
#define GFUI_BTN_RELEASED
#define GFUI_EDITCURSORCLR
void(* tfuiCallback)(void *)
#define GFUI_FOCUS_MOUSE_CLICK
tGfuiObject * gfuiGetObject(void *scr, int id)
void gfuiEditboxAction(int mouse)
static void gfuiEditboxRecalcCursor(tGfuiObject *obj)
void gfuiAddObject(tGfuiScreen *screen, tGfuiObject *object)
#define GFUI_BGBTNDISABLED
float GfuiColor[GFUI_COLORNB][4]
void gfuiPrintString(int x, int y, GfuiFontClass *font, const char *string)
void gfuiEditboxKey(tGfuiObject *obj, int key, int modifier)
int getWidth(const char *text)
void gfuiSelectNext(void *)