diff --git a/src/libs/tgfclient/gui.h b/src/libs/tgfclient/gui.h index 46c33bad4..7a77de75a 100644 --- a/src/libs/tgfclient/gui.h +++ b/src/libs/tgfclient/gui.h @@ -68,6 +68,9 @@ typedef struct int x, y; /* label position */ int align; int maxlen; + void *userDataOnFocus; + tfuiCallback onFocus; + tfuiCallback onFocusLost; } tGfuiLabel; /* button state */ @@ -225,6 +228,9 @@ typedef struct float max; float value; + void *userDataOnFocus; + tfuiCallback onFocus; + tfuiCallback onFocusLost; } tGfuiProgressbar; diff --git a/src/libs/tgfclient/guibutton.cpp b/src/libs/tgfclient/guibutton.cpp index ff7d34975..43cf50ee1 100644 --- a/src/libs/tgfclient/guibutton.cpp +++ b/src/libs/tgfclient/guibutton.cpp @@ -417,6 +417,9 @@ GfuiButtonCreate(void *scr, const char *text, int font, int x, int y, int width, object->ymax = y + gfuiFont[font]->getHeight() - gfuiFont[font]->getDescender(); break; } + label->userDataOnFocus = 0; + label->onFocus = 0; + label->onFocusLost = 0; #define HORIZ_MARGIN 10 object->xmin -= HORIZ_MARGIN; object->xmax += HORIZ_MARGIN; diff --git a/src/libs/tgfclient/guicheckbox.cpp b/src/libs/tgfclient/guicheckbox.cpp index 9f6b7e2bd..970c3a1ba 100644 --- a/src/libs/tgfclient/guicheckbox.cpp +++ b/src/libs/tgfclient/guicheckbox.cpp @@ -72,8 +72,10 @@ gfuiUnchecked(void *idv) } int -GfuiCheckboxCreate(void *scr, int font, int x, int y, int imagewidth,int imageheight,int align ,int style,const char *pszText,bool bChecked, - void* userData, tfuiCheckboxCallback onChange) +GfuiCheckboxCreate(void *scr, int font, int x, int y, int imagewidth, int imageheight, + int align ,int style, const char *pszText, bool bChecked, + void* userData, tfuiCheckboxCallback onChange, + void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost) { tGfuiCheckbox *Checkbox; tGfuiObject *object; @@ -159,17 +161,19 @@ GfuiCheckboxCreate(void *scr, int font, int x, int y, int imagewidth,int imagehe break; } - Checkbox->checkId = GfuiGrButtonCreateEx(scr, "data/img/checked.png", "data/img/checked.png", - "data/img/checked.png", "data/img/checked.png", - x,y,imagewidth,imageheight, GFUI_ALIGN_HL_VC, GFUI_MOUSE_UP, - (void*)(object->id), gfuiChecked, - NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); + Checkbox->checkId = + GfuiGrButtonCreateEx(scr, "data/img/checked.png", "data/img/checked.png", + "data/img/checked.png", "data/img/checked.png", + x,y,imagewidth,imageheight, GFUI_ALIGN_HL_VC, GFUI_MOUSE_UP, + (void*)(object->id), gfuiChecked, + userDataOnFocus, onFocus, onFocusLost); - Checkbox->uncheckId = GfuiGrButtonCreateEx(scr, "data/img/unchecked.png", "data/img/unchecked.png", - "data/img/unchecked.png", "data/img/unchecked.png", - x,y, imagewidth,imageheight,GFUI_ALIGN_HL_VC, GFUI_MOUSE_UP, - (void*)(object->id), gfuiUnchecked, - NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); + Checkbox->uncheckId = + GfuiGrButtonCreateEx(scr, "data/img/unchecked.png", "data/img/unchecked.png", + "data/img/unchecked.png", "data/img/unchecked.png", + x,y, imagewidth,imageheight,GFUI_ALIGN_HL_VC, GFUI_MOUSE_UP, + (void*)(object->id), gfuiUnchecked, 0, 0, 0); + // We avoid sharing the same userDataOnFocus among multiple controls (otherwise multiple frees). gfuiAddObject(screen, object); diff --git a/src/libs/tgfclient/guicombobox.cpp b/src/libs/tgfclient/guicombobox.cpp index 499a5e6bd..c09243b49 100644 --- a/src/libs/tgfclient/guicombobox.cpp +++ b/src/libs/tgfclient/guicombobox.cpp @@ -86,7 +86,8 @@ gfuiRightArrow(void *idv) int GfuiComboboxCreate(void *scr, int font, int x, int y, int width, int align, int style, const char *pszText, - void *userData, tfuiComboboxCallback onChange) + void *userData, tfuiComboboxCallback onChange, + void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost) { tGfuiCombobox *combobox; tGfuiObject *object; @@ -94,7 +95,7 @@ GfuiComboboxCreate(void *scr, int font, int x, int y, int width, object = (tGfuiObject*)calloc(1, sizeof(tGfuiObject)); object->widget = GFUI_COMBOBOX; - object->focusMode = GFUI_FOCUS_NONE; + object->focusMode = GFUI_FOCUS_NONE; // Children controls take care of this. object->id = screen->curId++; object->visible = 1; @@ -170,23 +171,23 @@ GfuiComboboxCreate(void *scr, int font, int x, int y, int width, int xm = object->xmin + (object->xmax-object->xmin)/2; int ym = object->ymin + (object->ymax-object->ymin)/2; - combobox->labelId = GfuiLabelCreate(scr, pszText, font, xm, ym, GFUI_ALIGN_HC_VC, 99); + combobox->labelId = + GfuiLabelCreateEx(scr, pszText, 0, font, xm, ym, GFUI_ALIGN_HC_VC, 99, + userDataOnFocus, onFocus, onFocusLost); // Create the left arrow button control. combobox->leftButtonId = GfuiGrButtonCreate(scr, "data/img/arrow-left-disabled.png", "data/img/arrow-left.png", "data/img/arrow-left.png", "data/img/arrow-left-pushed.png", object->xmin, ym, GFUI_ALIGN_HL_VC, GFUI_MOUSE_UP, - (void*)(object->id), gfuiLeftArrow, - NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); + (void*)(object->id), gfuiLeftArrow, 0, 0, 0); // Create the right arrow button control. combobox->rightButtonId = GfuiGrButtonCreate(scr, "data/img/arrow-right-disabled.png", "data/img/arrow-right.png", "data/img/arrow-right.png", "data/img/arrow-right-pushed.png", object->xmax, ym, GFUI_ALIGN_HR_VC, GFUI_MOUSE_UP, - (void*)(object->id), gfuiRightArrow, - NULL, (tfuiCallback)NULL, (tfuiCallback)NULL); + (void*)(object->id), gfuiRightArrow, 0, 0, 0); gfuiAddObject(screen, object); diff --git a/src/libs/tgfclient/guiedit.cpp b/src/libs/tgfclient/guiedit.cpp index 992595de6..27ce08d98 100644 --- a/src/libs/tgfclient/guiedit.cpp +++ b/src/libs/tgfclient/guiedit.cpp @@ -100,6 +100,10 @@ GfuiEditboxCreate(void *scr, const char *text, int font, int x, int y, int width strncpy(label->text, text, maxlen+1); label->font = gfuiFont[font]; label->maxlen = maxlen; + label->userDataOnFocus = 0; + label->onFocus = 0; + label->onFocusLost = 0; + if (width == 0) { char *buf; int i; diff --git a/src/libs/tgfclient/guilabel.cpp b/src/libs/tgfclient/guilabel.cpp index 1fb2c91b6..c83fbfd13 100644 --- a/src/libs/tgfclient/guilabel.cpp +++ b/src/libs/tgfclient/guilabel.cpp @@ -64,7 +64,9 @@ gfuiLabelInit(void) @see GfuiSetLabelText */ int -GfuiLabelCreateEx(void *scr, const char *text, const float *fgColorPtr, int font, int x, int y, int align, int maxlen) +GfuiLabelCreateEx(void *scr, const char *text, const float *fgColorPtr, + int font, int x, int y, int align, int maxlen, + void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost) { tGfuiLabel *label; tGfuiObject *object; @@ -72,11 +74,12 @@ GfuiLabelCreateEx(void *scr, const char *text, const float *fgColorPtr, int font int height; tGfuiScreen *screen = (tGfuiScreen*)scr; - Color fgColor = GetColor((float*)fgColorPtr); + Color fgColor = + GetColor(fgColorPtr ? fgColorPtr : &(GfuiColor[GFUI_LABELCOLOR][0])); object = (tGfuiObject*)calloc(1, sizeof(tGfuiObject)); object->widget = GFUI_LABEL; - object->focusMode = GFUI_FOCUS_NONE; + object->focusMode = (onFocus || onFocusLost) ? GFUI_FOCUS_MOUSE_MOVE : GFUI_FOCUS_NONE; object->visible = 1; object->id = screen->curId++; @@ -94,6 +97,11 @@ GfuiLabelCreateEx(void *scr, const char *text, const float *fgColorPtr, int font height = gfuiFont[font]->getHeight() - gfuiFont[font]->getDescender(); label->align = align; + + label->userDataOnFocus = userDataOnFocus; + label->onFocus = onFocus; + label->onFocusLost = onFocusLost; + switch(align) { case GFUI_ALIGN_HL_VB: label->x = object->xmin = x; @@ -347,6 +355,7 @@ gfuiReleaseLabel(tGfuiObject *obj) label = &(obj->u.label); + freez(label->userDataOnFocus); free(label->text); free(obj); } diff --git a/src/libs/tgfclient/guimenu.cpp b/src/libs/tgfclient/guimenu.cpp index f460727b0..de43a0588 100644 --- a/src/libs/tgfclient/guimenu.cpp +++ b/src/libs/tgfclient/guimenu.cpp @@ -481,7 +481,24 @@ CreateLabel(void *menuHandle,void *param,const char *pControlName) const int alignment = GetAlignment(pszAlignH,pszAlignV); const int maxlen = (int)GfParmGetNum(param,pControlName,"maxlen",NULL,32.0); - int labelId = GfuiLabelCreate(menuHandle, pszText, textsize, x, y, alignment, maxlen); + void *userDataOnFocus = 0; + tfuiCallback onFocus = 0; + tfuiCallback onFocusLost = 0; + const char* pszTip = GfParmGetStr(param, pControlName, "tip", 0); + if (pszTip && strlen(pszTip) > 0) + { + tMnuCallbackInfo * cbinfo = (tMnuCallbackInfo*)calloc(1, sizeof(tMnuCallbackInfo)); + cbinfo->screen = menuHandle; + cbinfo->labelId = GfuiTipCreate(menuHandle, pszTip, strlen(pszTip)); + GfuiVisibilitySet(menuHandle, cbinfo->labelId, 0); + + userDataOnFocus = (void*)cbinfo; + onFocus = dispInfo; + onFocusLost = remInfo; + } + + int labelId = GfuiLabelCreateEx(menuHandle, pszText, 0, textsize, x, y, alignment, maxlen, + userDataOnFocus, onFocus, onFocusLost); Color c; const bool bColor = GetColorFromXML(param,pControlName,"color",c); @@ -505,9 +522,8 @@ CreateLabelControl(void *menuHandle,void *param,const char *pControlName) int CreateTextButtonControl(void *menuHandle,void *param,const char *pControlName,void *userData, tfuiCallback onpush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost) { - const char* pszTip = GfParmGetStr(param, pControlName, "tip", ""); - - if (strlen(pszTip) > 0) + const char* pszTip = GfParmGetStr(param, pControlName, "tip", 0); + if (pszTip && strlen(pszTip) > 0) { tMnuCallbackInfo * cbinfo = (tMnuCallbackInfo*)calloc(1, sizeof(tMnuCallbackInfo)); cbinfo->screen = menuHandle; @@ -718,28 +734,42 @@ CreateComboboxControl(void *menuHandle,void *param,const char *pControlName,void int id = -1; - std::string strText,strTip; - int textsize; - int x,y,width; - - x = (int)GfParmGetNum(param,strControlName.c_str(),"x",NULL,0.0); - y = (int)GfParmGetNum(param,strControlName.c_str(),"y",NULL,0.0); + const int x = (int)GfParmGetNum(param,strControlName.c_str(),"x",NULL,0.0); + const int y = (int)GfParmGetNum(param,strControlName.c_str(),"y",NULL,0.0); std::string strTextsize = GfParmGetStr(param, strControlName.c_str(), "textsize", ""); - textsize = GetFontSize(strTextsize.c_str()); + const int textsize = GetFontSize(strTextsize.c_str()); const char * pszAlignH = GfParmGetStr(param, strControlName.c_str(), "alignH", ""); const char * pszAlignV = GfParmGetStr(param, strControlName.c_str(), "alignV", ""); - int align = GetAlignment(pszAlignH,pszAlignV); + const int align = GetAlignment(pszAlignH,pszAlignV); - width = (int)GfParmGetNum(param,strControlName.c_str(),"width",NULL,0.0); + int width = (int)GfParmGetNum(param,strControlName.c_str(),"width",NULL,0.0); if (width == 0) width = 200; const char* pszText = GfParmGetStr(param, strControlName.c_str(), "text", ""); - id = GfuiComboboxCreate(menuHandle,textsize,x,y,width,align,0,pszText,userData,onChange); + const char* pszTip = GfParmGetStr(param, strControlName.c_str(), "tip", 0); + + void *userDataOnFocus = 0; + tfuiCallback onFocus = 0; + tfuiCallback onFocusLost = 0; + if (pszTip && strlen(pszTip) > 0) + { + tMnuCallbackInfo * cbinfo = (tMnuCallbackInfo*)calloc(1, sizeof(tMnuCallbackInfo)); + cbinfo->screen = menuHandle; + cbinfo->labelId = GfuiTipCreate(menuHandle, pszTip, strlen(pszTip)); + GfuiVisibilitySet(menuHandle, cbinfo->labelId, 0); + + userDataOnFocus = (void*)cbinfo; + onFocus = dispInfo; + onFocusLost = remInfo; + } + + id = GfuiComboboxCreate(menuHandle, textsize, x, y, width, align, 0, pszText, + userData, onChange, userDataOnFocus, onFocus, onFocusLost); Color c; bool bColor = GetColorFromXML(param,pControlName,"color",c); @@ -883,8 +913,27 @@ CreateCheckboxControl(void *menuHandle,void *param,const char *pControlName,void const bool bChecked = ReadBoolean(param,strControlName.c_str(),"checked", true); + const char* pszTip = GfParmGetStr(param, strControlName.c_str(), "tip", ""); + + void *userDataOnFocus = 0; + tfuiCallback onFocus = 0; + tfuiCallback onFocusLost = 0; + if (strlen(pszTip) > 0) + { + tMnuCallbackInfo * cbinfo = (tMnuCallbackInfo*)calloc(1, sizeof(tMnuCallbackInfo)); + cbinfo->screen = menuHandle; + cbinfo->labelId = GfuiTipCreate(menuHandle, pszTip, strlen(pszTip)); + GfuiVisibilitySet(menuHandle, cbinfo->labelId, 0); + + userDataOnFocus = (void*)cbinfo; + onFocus = dispInfo; + onFocusLost = remInfo; + } - id = GfuiCheckboxCreate(menuHandle,textsize,x,y,imagewidth,imageheight,align,0,pszText,bChecked,userData,onChange); + + id = GfuiCheckboxCreate(menuHandle, textsize, x, y, imagewidth, imageheight, align, 0, + pszText, bChecked, userData, onChange, + userDataOnFocus, onFocus, onFocusLost); Color c; bool bColor = GetColorFromXML(param,pControlName,"color",c); @@ -898,31 +947,51 @@ CreateCheckboxControl(void *menuHandle,void *param,const char *pControlName,void int CreateProgressbarControl(void *menuHandle,void *param,const char *pControlName) { - std::string strControlName("dynamiccontrols/"); - strControlName += pControlName; + std::string strControlName("dynamiccontrols/"); + strControlName += pControlName; + + const std::string strType = GfParmGetStr(param, strControlName.c_str(), "type", ""); + if (strType != "progressbar") + return -1; + + const char* pszProgressbackgroundImage = GfParmGetStr(param, strControlName.c_str(), "image", "data/img/progressbackground.png"); + const char* pszProgressbarImage = GfParmGetStr(param, pControlName, "image", "data/img/progressbar.png"); + + const int x = (int)GfParmGetNum(param,strControlName.c_str(),"x",NULL,0.0); + const int y = (int)GfParmGetNum(param,strControlName.c_str(),"y",NULL,0.0); + const int w = (int)GfParmGetNum(param,strControlName.c_str(),"width",NULL,0.0); + const int h = (int)GfParmGetNum(param,strControlName.c_str(),"height",NULL,0.0); + + const char* pszAlignH = GfParmGetStr(param, strControlName.c_str(), "alignH", ""); + const char* pszAlignV = GfParmGetStr(param, strControlName.c_str(), "alignV", ""); + const float min = GfParmGetNum(param, strControlName.c_str(), "min",NULL,0.0); + const float max = GfParmGetNum(param, strControlName.c_str(), "max",NULL,100.0); + const float value = GfParmGetNum(param, strControlName.c_str(), "value",NULL,100.0); + const int alignment = GetAlignment(pszAlignH,pszAlignV); + + const char* pszTip = GfParmGetStr(param, strControlName.c_str(), "tip", ""); + + void *userDataOnFocus = 0; + tfuiCallback onFocus = 0; + tfuiCallback onFocusLost = 0; + if (strlen(pszTip) > 0) + { + tMnuCallbackInfo * cbinfo = (tMnuCallbackInfo*)calloc(1, sizeof(tMnuCallbackInfo)); + cbinfo->screen = menuHandle; + cbinfo->labelId = GfuiTipCreate(menuHandle, pszTip, strlen(pszTip)); + GfuiVisibilitySet(menuHandle, cbinfo->labelId, 0); + + userDataOnFocus = (void*)cbinfo; + onFocus = dispInfo; + onFocusLost = remInfo; + } - const std::string strType = GfParmGetStr(param, strControlName.c_str(), "type", ""); - if (strType != "progressbar") - return -1; - - const char* pszProgressbackgroundImage = GfParmGetStr(param, strControlName.c_str(), "image", "data/img/progressbackground.png"); - const char* pszProgressbarImage = GfParmGetStr(param, pControlName, "image", "data/img/progressbar.png"); - - const int x = (int)GfParmGetNum(param,strControlName.c_str(),"x",NULL,0.0); - const int y = (int)GfParmGetNum(param,strControlName.c_str(),"y",NULL,0.0); - const int w = (int)GfParmGetNum(param,strControlName.c_str(),"width",NULL,0.0); - const int h = (int)GfParmGetNum(param,strControlName.c_str(),"height",NULL,0.0); - - const char* pszAlignH = GfParmGetStr(param, strControlName.c_str(), "alignH", ""); - const char* pszAlignV = GfParmGetStr(param, strControlName.c_str(), "alignV", ""); - const float min = GfParmGetNum(param, strControlName.c_str(), "min",NULL,0.0); - const float max = GfParmGetNum(param, strControlName.c_str(), "max",NULL,100.0); - const float value = GfParmGetNum(param, strControlName.c_str(), "value",NULL,100.0); - const int alignment = GetAlignment(pszAlignH,pszAlignV); - - int id = GfuiProgressbarCreate(menuHandle,x,y,w,h,pszProgressbackgroundImage,pszProgressbarImage,alignment,min,max,value); - - return id; + int id = GfuiProgressbarCreate(menuHandle, x, y, w, h, + pszProgressbackgroundImage, pszProgressbarImage, + alignment, min, max, value, + userDataOnFocus, onFocus, onFocusLost); + + return id; } //=================================================================================== diff --git a/src/libs/tgfclient/guiobject.cpp b/src/libs/tgfclient/guiobject.cpp index c37bd2c70..febd8d295 100644 --- a/src/libs/tgfclient/guiobject.cpp +++ b/src/libs/tgfclient/guiobject.cpp @@ -239,68 +239,106 @@ GfuiUnSelectCurrent(void) static void gfuiLoseFocus(tGfuiObject *obj) { - tGfuiButton *button; - tGfuiEditbox *editbox; - tGfuiGrButton *grbutton; - GfuiScreen->hasFocus = (tGfuiObject*)NULL; obj->focus = 0; - switch (obj->widget) { - case GFUI_BUTTON: - button = &(obj->u.button); - button->state = GFUI_BTN_RELEASED; - if (button->onFocusLost != NULL) { - button->onFocusLost(button->userDataOnFocus); - } - break; - case GFUI_GRBUTTON: - grbutton = &(obj->u.grbutton); - grbutton->state = GFUI_BTN_RELEASED; - if (grbutton->onFocusLost != NULL) { - grbutton->onFocusLost(grbutton->userDataOnFocus); - } - break; - case GFUI_EDITBOX: - editbox = &(obj->u.editbox); - editbox->state = GFUI_BTN_RELEASED; - if (editbox->onFocusLost != NULL) { - editbox->onFocusLost(editbox->userDataOnFocus); - } - break; + + switch (obj->widget) + { + case GFUI_BUTTON: + { + tGfuiButton* button = &(obj->u.button); + button->state = GFUI_BTN_RELEASED; + if (button->onFocusLost) + button->onFocusLost(button->userDataOnFocus); + } + break; + + case GFUI_GRBUTTON: + { + tGfuiGrButton* grbutton = &(obj->u.grbutton); + grbutton->state = GFUI_BTN_RELEASED; + if (grbutton->onFocusLost) + grbutton->onFocusLost(grbutton->userDataOnFocus); + } + break; + + case GFUI_EDITBOX: + { + tGfuiEditbox* editbox = &(obj->u.editbox); + editbox->state = GFUI_BTN_RELEASED; + if (editbox->onFocusLost) + editbox->onFocusLost(editbox->userDataOnFocus); + } + break; + + case GFUI_PROGRESSBAR: + { + tGfuiProgressbar* progress = &(obj->u.progressbar); + if (progress->onFocusLost) + progress->onFocusLost(progress->userDataOnFocus); + } + break; + + case GFUI_LABEL: + { + tGfuiLabel* label = &(obj->u.label); + if (label->onFocusLost) + label->onFocusLost(label->userDataOnFocus); + } + break; } } static void gfuiSetFocus(tGfuiObject *obj) { - tGfuiButton *button; - tGfuiEditbox *editbox; - tGfuiGrButton *grbutton; - - if (GfuiScreen->hasFocus != NULL) { - gfuiLoseFocus(GfuiScreen->hasFocus); - } + if (GfuiScreen->hasFocus) + gfuiLoseFocus(GfuiScreen->hasFocus); + GfuiScreen->hasFocus = obj; obj->focus = 1; - switch (obj->widget) { - case GFUI_BUTTON: - button = &(obj->u.button); - if (button->onFocus != NULL) { - button->onFocus(button->userDataOnFocus); - } - break; - case GFUI_GRBUTTON: - grbutton = &(obj->u.grbutton); - if (grbutton->onFocus != NULL) { - grbutton->onFocus(grbutton->userDataOnFocus); - } - break; - case GFUI_EDITBOX: - editbox = &(obj->u.editbox); - if (editbox->onFocus != NULL) { - editbox->onFocus(editbox->userDataOnFocus); - } - break; + + switch (obj->widget) + { + case GFUI_BUTTON: + { + tGfuiButton* button = &(obj->u.button); + if (button->onFocus) + button->onFocus(button->userDataOnFocus); + } + break; + + case GFUI_GRBUTTON: + { + tGfuiGrButton* grbutton = &(obj->u.grbutton); + if (grbutton->onFocus) + grbutton->onFocus(grbutton->userDataOnFocus); + } + break; + + case GFUI_EDITBOX: + { + tGfuiEditbox* editbox = &(obj->u.editbox); + if (editbox->onFocus) + editbox->onFocus(editbox->userDataOnFocus); + } + break; + + case GFUI_PROGRESSBAR: + { + tGfuiProgressbar* progress = &(obj->u.progressbar); + if (progress->onFocus) + progress->onFocus(progress->userDataOnFocus); + } + break; + + case GFUI_LABEL: + { + tGfuiLabel* label = &(obj->u.label); + if (label->onFocus) + label->onFocus(label->userDataOnFocus); + } + break; } } diff --git a/src/libs/tgfclient/guiprogresbar.cpp b/src/libs/tgfclient/guiprogresbar.cpp index f2becd74f..634d6554e 100644 --- a/src/libs/tgfclient/guiprogresbar.cpp +++ b/src/libs/tgfclient/guiprogresbar.cpp @@ -37,7 +37,10 @@
-1 Error @warning the image must be square and its size must be a power of 2. */ -int GfuiProgressbarCreate(void *scr, int x, int y, int w, int h, const char *pszProgressbackImg,const char *progressbarimg, int align,float min,float max,float value) +int GfuiProgressbarCreate(void *scr, int x, int y, int w, int h, + const char *pszProgressbackImg, const char *progressbarimg, + int align, float min, float max, float value, + void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost) { tGfuiProgressbar *progress; tGfuiObject *object; @@ -45,7 +48,7 @@ int GfuiProgressbarCreate(void *scr, int x, int y, int w, int h, const char *psz object = (tGfuiObject*)calloc(1, sizeof(tGfuiObject)); object->widget = GFUI_PROGRESSBAR; - object->focusMode = GFUI_FOCUS_NONE; + object->focusMode = (onFocus || onFocusLost) ? GFUI_FOCUS_MOUSE_MOVE : GFUI_FOCUS_NONE; object->visible = 1; object->id = screen->curId++; @@ -65,6 +68,10 @@ int GfuiProgressbarCreate(void *scr, int x, int y, int w, int h, const char *psz value = progress->min; progress->value = value; + progress->userDataOnFocus = userDataOnFocus; + progress->onFocus = onFocus; + progress->onFocusLost = onFocusLost; + switch (align) { case GFUI_ALIGN_HR_VB: object->xmin = x - w; @@ -159,6 +166,7 @@ gfuiReleaseProgressbar(tGfuiObject *obj) progress = &(obj->u.progressbar); GfTexFreeTexture(progress->progressbarimage); + freez(progress->userDataOnFocus); free(obj); } diff --git a/src/libs/tgfclient/guiscreen.cpp b/src/libs/tgfclient/guiscreen.cpp index 4041e5d23..ea67d3a4f 100644 --- a/src/libs/tgfclient/guiscreen.cpp +++ b/src/libs/tgfclient/guiscreen.cpp @@ -179,8 +179,8 @@ tScreenSize* GfScrGetPossibleSizes(int nColorDepth, bool bFullScreen, int* pnSiz // Get the possible sizes for this pixel format. SDL_Rect **asdlPossSizes = SDL_ListModes(&sdlPixelFormat, sdlDisplayMode); - GfLogTrace("Available %u-bit %s video sizes :", - sdlPixelFormat.BitsPerPixel, bFullScreen ? "full-screen" : "windowed"); + GfLogInfo("Available %u-bit %s video sizes :", + sdlPixelFormat.BitsPerPixel, bFullScreen ? "full-screen" : "windowed"); tScreenSize* aPossSizes; if (asdlPossSizes == (SDL_Rect**)0) @@ -216,7 +216,7 @@ tScreenSize* GfScrGetPossibleSizes(int nColorDepth, bool bFullScreen, int* pnSiz return aPossSizes; } -/** Get the possible color depths as supported bythe underlying hardware/driver. +/** Get the possible color depths as supported by the underlying hardware/driver. @ingroup screen @param pnDepths Address of number of detected color depths (output) @return Array of detected possible color depths (allocated on the heap, must use free at the end) diff --git a/src/libs/tgfclient/tgfclient.h b/src/libs/tgfclient/tgfclient.h index 302689299..b939171b3 100644 --- a/src/libs/tgfclient/tgfclient.h +++ b/src/libs/tgfclient/tgfclient.h @@ -332,8 +332,10 @@ TGFCLIENT_API void GfuiUnSelectCurrent(void); #define GFUI_FONT_SMALL_C 7 #define GFUI_FONT_DIGIT 8 TGFCLIENT_API int GfuiLabelCreate(void *scr, const char *text, - int font, int x, int y, int align, int maxlen); -TGFCLIENT_API int GfuiLabelCreateEx(void *scr, const char *text, const float *fgColorPtr, int font, int x, int y, int align, int maxlen); + int font, int x, int y, int align, int maxlen); +TGFCLIENT_API int GfuiLabelCreateEx(void *scr, const char *text, const float *fgColorPtr, + int font, int x, int y, int align, int maxlen, + void *userDataOnFocus = 0, tfuiCallback onFocus = 0, tfuiCallback onFocusLost = 0); TGFCLIENT_API void GfuiSetTipPosition(int x,int y); TGFCLIENT_API int GfuiTipCreate(void *scr, const char *text, int maxlen); @@ -342,7 +344,8 @@ TGFCLIENT_API int GfuiTitleCreate(void *scr, const char *text, int maxlen); TGFCLIENT_API void GfuiLabelSetText(void *scr, int id, const char *text); TGFCLIENT_API void GfuiLabelSetColor(void *scr, int id, const float * colorPtr); -TGFCLIENT_API void GfuiPrintString(const char *text, float *fgColor, int font, int x, int y, int align); +TGFCLIENT_API void GfuiPrintString(const char *text, float *fgColor, + int font, int x, int y, int align); TGFCLIENT_API int GfuiFontHeight(int font); TGFCLIENT_API int GfuiFontWidth(int font, const char *text); @@ -350,22 +353,33 @@ TGFCLIENT_API int GfuiFontWidth(int font, const char *text); /* Buttons */ #define GFUI_BTNSZ 300 TGFCLIENT_API 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); -TGFCLIENT_API 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); -TGFCLIENT_API 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); -TGFCLIENT_API int GfuiGrButtonCreateEx(void *scr, const char *disabled, const char *enabled, const char *focused, const char *pushed, - int x, int y, int imageWidth,int imageHeight,int align, int mouse, - void *userDataOnPush, tfuiCallback onPush, - void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost); -TGFCLIENT_API int GfuiComboboxCreate(void *scr, int font, int x, int y, int width,int align ,int style,const char *pszText,void* userData,tfuiComboboxCallback onChange); -TGFCLIENT_API int GfuiCheckboxCreate(void *scr, int font, int x, int y, int imagewidth,int imageheight,int align ,int style,const char *pszText,bool bChecked,void* userData,tfuiCheckboxCallback onChange); + int x, int y, int width, int align, int mouse, + void *userDataOnPush, tfuiCallback onPush, + void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost); +TGFCLIENT_API 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); +TGFCLIENT_API 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); +TGFCLIENT_API int GfuiGrButtonCreateEx(void *scr, const char *disabled, const char *enabled, + const char *focused, const char *pushed, + int x, int y, int imageWidth,int imageHeight, + int align, int mouse, + void *userDataOnPush, tfuiCallback onPush, + void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost); +TGFCLIENT_API int GfuiComboboxCreate(void *scr, int font, int x, int y, int width, + int align ,int style, const char *pszText, + void* userData, tfuiComboboxCallback onChange, + void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost); +TGFCLIENT_API int GfuiCheckboxCreate(void *scr, int font, int x, int y, + int imagewidth, int imageheight, int align, int style, + const char *pszText, bool bChecked, + void* userData, tfuiCheckboxCallback onChange, + void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost); class TGFCLIENT_API Color @@ -383,7 +397,10 @@ TGFCLIENT_API unsigned int GfuiComboboxGetPosition(void *scr, int id); TGFCLIENT_API const char* GfuiComboboxGetText(void *scr, int id); TGFCLIENT_API void GfuiComboboxClear(void *scr, int id); -TGFCLIENT_API int GfuiProgressbarCreate(void *scr, int x, int y, int w, int h, const char *pszProgressbackImg,const char *progressbarimg, int align,float min,float max,float value); +TGFCLIENT_API int GfuiProgressbarCreate(void *scr, int x, int y, int w, int h, + const char *pszProgressbackImg, const char *progressbarimg, + int align,float min,float max,float value, + void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost); TGFCLIENT_API void GfuiProgressbarSetValue(void *scr, int id, float value);