ported xml menu changes from sdl-port

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@1679 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 1527d942ec8165fdfc601297f44a57c502d5cebf
Former-commit-id: 7a1b92d51c2730655217bde6cee15a7079865b2b
This commit is contained in:
briangr 2009-10-27 10:22:56 +00:00
parent 30864e139f
commit 2f9458c404
4 changed files with 77 additions and 165 deletions

View file

@ -35,6 +35,7 @@
#include "gui.h"
#include "guimenu.h"
#include <string>
#include "gui.h"
void
gfMenuInit(void)
@ -469,7 +470,7 @@ CreateLabelControl(void *menuHandle,void *param,const char *pControlName)
}
int
CreateTextButtonControl(void *menuHandle,void *param,const char *pControlName,void *userdata, tfuiCallback onpush)
CreateTextButtonControl(void *menuHandle,void *param,const char *pControlName,void *userdata, tfuiCallback onpush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
{
std::string strText,strTip;
int textsize;
@ -540,8 +541,8 @@ CreateTextButtonControl(void *menuHandle,void *param,const char *pControlName,vo
textsize,
x, y, width, alignH, GFUI_MOUSE_UP,
userdata, onpush,
NULL, NULL,
NULL);
userDataOnFocus, onFocus,
onFocusLost);
GfuiButtonShowBox(menuHandle,id,bShowbox);
GfuiButtonSetImage(menuHandle,id,imgX,imgY,imgWidth,imgHeight,
strDisabledImage.c_str(),strEnabledImage.c_str(),strFocusedImage.c_str(),strPushedImage.c_str());
@ -562,7 +563,7 @@ CreateTextButtonControl(void *menuHandle,void *param,const char *pControlName,vo
}
int
CreateImageButtonControl(void *menuHandle,void *param,const char *pControlName,void *userdata, tfuiCallback onpush)
CreateImageButtonControl(void *menuHandle,void *param,const char *pControlName,void *userdata, tfuiCallback onpush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
{
std::string strTip,strText;
//int textsize;
@ -592,24 +593,30 @@ CreateImageButtonControl(void *menuHandle,void *param,const char *pControlName,v
x,y,alignment,GFUI_MOUSE_UP
,userdata,
onpush,
NULL,
(tfuiCallback)NULL,
(tfuiCallback)NULL);
userDataOnFocus,
onFocus,
onFocusLost);
return id;
return id;
}
int
CreateButtonControl(void *menuHandle,void *param,const char *pControlName,void *userdata, tfuiCallback onpush)
{
return CreateButtonControlEx(menuHandle,param,pControlName,userdata,onpush,NULL,NULL,NULL);
}
int
CreateButtonControlEx(void *menuHandle,void *param,const char *pControlName,void *userdata, tfuiCallback onpush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
{
std::string strControlName = pControlName;
strControlName = "dynamiccontrols/"+strControlName;
std::string strType = GfParmGetStr(param, strControlName.c_str(), "type", "");
if (strType == "textbutton")
return CreateTextButtonControl(menuHandle,param,strControlName.c_str(),userdata,onpush);
return CreateTextButtonControl(menuHandle,param,strControlName.c_str(),userdata,onpush,NULL,NULL,NULL);
else if(strType == "imagebutton")
return CreateImageButtonControl(menuHandle,param,strControlName.c_str(),userdata,onpush);
return CreateImageButtonControl(menuHandle,param,strControlName.c_str(),userdata,onpush,NULL,NULL,NULL);
else
printf("ERROR: unknown button type\n");

View file

@ -242,6 +242,41 @@ gfuiScrollListRemElt(tGfuiScrollList *scrollist, int index)
return cur;
}
/** Set the selected element from the scroll list.
@ingroup gui
@param scr Current screen
@param Id Scroll list Id
@param userData address of the userData of the element to retrieve
@return Name of the retrieved element
<br>NULL if Error
*/
bool
GfuiScrollListSetSelectedElement(void *scr, int Id, unsigned int selectElement)
{
tGfuiObject *object;
tGfuiScrollList *scrollist;
tGfuiListElement *elt;
const char *name;
int i;
object = gfuiGetObject(scr, Id);
if (object == NULL) {
return (const char*)NULL;
}
if (object->widget != GFUI_SCROLLIST) {
return (const char*)NULL;
}
scrollist = &(object->u.scrollist);
if (selectElement >= scrollist->nbElts)
return false;
scrollist->selectedElt == selectElement;
return true;
}
/** Get the selected element from the scroll list.
@ingroup gui
@param scr Current screen

View file

@ -793,177 +793,45 @@ onActivate(void * /* dummy */)
void *
GfScrMenuInit(void *precMenu)
{
int y, x1, x2;
#ifndef WIN32
const int yoffset1 = 30, yoffset2 = 60;
#else // WIN32
const int yoffset1 = 30, yoffset2 = 40;
#endif // WIN32
sprintf(buf, "%s%s", GetLocalDir(), GFSCR_CONF_FILE);
paramHdle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
if (scrHandle) return scrHandle;
scrHandle = GfuiScreenCreateEx((float*)NULL, NULL, onActivate, NULL, (tfuiCallback)NULL, 1);
GfuiTitleCreate(scrHandle, "Screen configuration", 0);
GfuiScreenAddBgImg(scrHandle, "data/img/splash-graphic.png");
void *param = LoadMenuXML("screenconfigmenu.xml");
CreateStaticControls(param,scrHandle);
x1 = 200;
x2 = 440;
y = 400;
GfuiLabelCreate(scrHandle,
"Screen Resolution",
GFUI_FONT_LARGE,
320, y, GFUI_ALIGN_HC_VB,
0);
CreateButtonControl(scrHandle,param,"resleftarrow",(void*)-1,ResPrevNext);
CreateButtonControl(scrHandle,param,"resrightarrow",(void*)1,ResPrevNext);
ResLabelId = CreateLabelControl(scrHandle,param,"reslabel");
y -= yoffset1; //30;
GfuiGrButtonCreate(scrHandle,
"data/img/arrow-left.png",
"data/img/arrow-left.png",
"data/img/arrow-left.png",
"data/img/arrow-left-pushed.png",
x1, y, GFUI_ALIGN_HC_VB, 0,
(void*)-1, ResPrevNext,
NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
GfuiAddSKey(scrHandle, GLUT_KEY_LEFT, "Previous Resolution", (void*)-1, ResPrevNext, NULL);
ResLabelId = GfuiLabelCreate(scrHandle,
"",
GFUI_FONT_LARGE_C,
320, y, GFUI_ALIGN_HC_VB,
30);
GfuiLabelSetColor(scrHandle, ResLabelId, LabelColor);
GfuiGrButtonCreate(scrHandle,
"data/img/arrow-right.png",
"data/img/arrow-right.png",
"data/img/arrow-right.png",
"data/img/arrow-right-pushed.png",
x2, y, GFUI_ALIGN_HC_VB, 0,
(void*)1, ResPrevNext,
NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
GfuiAddSKey(scrHandle, GLUT_KEY_LEFT, "Previous Resolution", (void*)-1, ResPrevNext, NULL);
GfuiAddSKey(scrHandle, GLUT_KEY_RIGHT, "Next Resolution", (void*)1, ResPrevNext, NULL);
y -= yoffset2; //60;
GfuiLabelCreate(scrHandle,
"Color Depth",
GFUI_FONT_LARGE,
320, y, GFUI_ALIGN_HC_VB,
0);
y -= yoffset1; //30;
GfuiGrButtonCreate(scrHandle,
"data/img/arrow-left.png",
"data/img/arrow-left.png",
"data/img/arrow-left.png",
"data/img/arrow-left-pushed.png",
x1, y, GFUI_ALIGN_HC_VB, 0,
(void*)-1, DepthPrevNext,
NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
DepthLabelId = GfuiLabelCreate(scrHandle,
"",
GFUI_FONT_LARGE_C,
320, y, GFUI_ALIGN_HC_VB,
30);
GfuiLabelSetColor(scrHandle, DepthLabelId, LabelColor);
GfuiGrButtonCreate(scrHandle,
"data/img/arrow-right.png",
"data/img/arrow-right.png",
"data/img/arrow-right.png",
"data/img/arrow-right-pushed.png",
x2, y, GFUI_ALIGN_HC_VB, 0,
(void*)1, DepthPrevNext,
NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
y -= yoffset2; //60;
GfuiLabelCreate(scrHandle,
"Display Mode",
GFUI_FONT_LARGE,
320, y, GFUI_ALIGN_HC_VB,
0);
y -= yoffset1; //30;
GfuiGrButtonCreate(scrHandle,
"data/img/arrow-left.png",
"data/img/arrow-left.png",
"data/img/arrow-left.png",
"data/img/arrow-left-pushed.png",
x1, y, GFUI_ALIGN_HC_VB, 0,
(void*)-1, ModePrevNext,
NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
ModeLabelId = GfuiLabelCreate(scrHandle,
"",
GFUI_FONT_LARGE_C,
320, y, GFUI_ALIGN_HC_VB,
30);
GfuiLabelSetColor(scrHandle, ModeLabelId, LabelColor);
GfuiGrButtonCreate(scrHandle,
"data/img/arrow-right.png",
"data/img/arrow-right.png",
"data/img/arrow-right.png",
"data/img/arrow-right-pushed.png",
x2, y, GFUI_ALIGN_HC_VB, 0,
(void*)1, ModePrevNext,
NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
GfuiAddKey(scrHandle, 'f', "Display Mode", (void*)1, ModePrevNext, NULL);
#ifdef WIN32
y -= yoffset2; //60;
GfuiLabelCreate(scrHandle,
"Max Frequency",
GFUI_FONT_LARGE,
320, y, GFUI_ALIGN_HC_VB,
0);
y -= yoffset1; //30;
MaxFreqId = GfuiEditboxCreate(scrHandle, "", GFUI_FONT_MEDIUM_C,
275, y, 0, 8, NULL, (tfuiCallback)NULL, ChangeMaxFreq);
#endif
y -= yoffset2; //60;
GfuiLabelCreate(scrHandle,
"Video Mode Initialization",
GFUI_FONT_LARGE,
320, y, GFUI_ALIGN_HC_VB,
0);
y -= yoffset1; //30;
GfuiGrButtonCreate(scrHandle,
"data/img/arrow-left.png",
"data/img/arrow-left.png",
"data/img/arrow-left.png",
"data/img/arrow-left-pushed.png",
x1, y, GFUI_ALIGN_HC_VB, 0,
(void*)-1, VInitPrevNext,
NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
VInitLabelId = GfuiLabelCreate(scrHandle,
"",
GFUI_FONT_LARGE_C,
320, y, GFUI_ALIGN_HC_VB,
30);
GfuiLabelSetColor(scrHandle, VInitLabelId, LabelColor);
GfuiGrButtonCreate(scrHandle,
"data/img/arrow-right.png",
"data/img/arrow-right.png",
"data/img/arrow-right.png",
"data/img/arrow-right-pushed.png",
x2, y, GFUI_ALIGN_HC_VB, 0,
(void*)1, VInitPrevNext,
NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
GfuiAddKey(scrHandle, 13, "Apply Mode", NULL, GfScrReinit, NULL);
GfuiButtonCreate(scrHandle, "Apply", GFUI_FONT_LARGE, 210, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP,
NULL, GfScrReinit, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
GfuiAddKey(scrHandle, 27, "Cancel", precMenu, GfuiScreenActivate, NULL);
GfuiButtonCreate(scrHandle, "Back", GFUI_FONT_LARGE, 430, 40, 150, GFUI_ALIGN_HC_VB, GFUI_MOUSE_UP,
precMenu, GfuiScreenActivate, NULL, (tfuiCallback)NULL, (tfuiCallback)NULL);
CreateButtonControl(scrHandle,param,"depthleftarrow",(void*)-1,DepthPrevNext);
CreateButtonControl(scrHandle,param,"depthrightarrow",(void*)1,DepthPrevNext);
DepthLabelId = CreateLabelControl(scrHandle,param,"depthlabel");
CreateButtonControl(scrHandle,param,"displeftarrow",(void*)-1,ModePrevNext);
CreateButtonControl(scrHandle,param,"disprightarrow",(void*)1,ModePrevNext);
ModeLabelId = CreateLabelControl(scrHandle,param,"displabel");
#ifdef WIN32
CreateLabelControl(scrHandle,param,"maxfreqlabel");
MaxFreqId = CreateEditControl(scrHandle,param,"freqedit",NULL,ChangeMaxFreq,NULL);
#endif
CreateButtonControl(scrHandle,param,"vmleftarrow",(void*)-1, VInitPrevNext);
CreateButtonControl(scrHandle,param,"vmrightarrow",(void*)1, VInitPrevNext);
VInitLabelId = CreateLabelControl(scrHandle,param,"vmlabel");
return scrHandle;
}

View file

@ -229,6 +229,7 @@ extern int GfuiScrollListMoveSelectedElement(void *scr, int Id, int delta);
extern const char *GfuiScrollListExtractSelectedElement(void *scr, int Id, void **userData);
extern const char *GfuiScrollListExtractElement(void *scr, int Id, int index, void **userData);
extern const char *GfuiScrollListGetSelectedElement(void *scr, int Id, void **userData);
extern bool GfuiScrollListSetSelectedElement(void *scr, int Id, unsigned int selectElement);
extern const char *GfuiScrollListGetElement(void *scr, int Id, int index, void **userData);
extern void GfuiScrollListShowElement(void *scr, int Id, int index);
extern void GfuiScrollListSetColor(void *scr, int id,Color color);
@ -327,6 +328,7 @@ extern void *LoadMenuXML(const char *pFilePath);
extern bool CreateStaticControls(void *param,void *menuHandle);
extern int CreateButtonControl(void *menuHandle,void *param,const char *pControlName,void *userdata, tfuiCallback onpush);
extern int CreateButtonControlEx(void *menuHandle,void *param,const char *pControlName,void *userdata, tfuiCallback onpush, void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost);
extern int CreateStaticImageControl(void *menuHandle,void *param,const char *pControlName);
extern int CreateLabelControl(void *menuHandle,void *param,const char *pControlName);
extern int CreateEditControl(void *menuHandle,void *param,const char *pControlName,void *userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost);