📄 guiparser.cpp.svn-base
字号:
else { RMasciiToUInt16 (str, &(button->object.y)); } str = pnode->Attribute(XMLWIDTH_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read width of button (ParseButton) ... error\n")); goto invalidButton; } else { RMasciiToUInt16 (str, &(button->object.width)); } str = pnode->Attribute(XMLHEIGHT_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read height of button (ParseButton) ... error\n")); goto invalidButton; } else { RMasciiToUInt16 (str, &(button->object.height)); } str = pnode->Attribute(XMLBACKGROUNDCOLOR_NODE, true); if (str == (RMascii *)NULL) { if(pMenu){ RMDBGLOG((GUIPARSERDBG, "Setting button backgroundcolor frommparent menu (ParseButton)\n")); button->object.backgroundcolor = pMenu->object.backgroundcolor; } } else { if((str[0] == '0') && (str[1] == 'x')) { // hexa RMasciiHexToUint64(str+2, &color); button->object.backgroundcolor = (RMuint32)color; } else { RMasciiToUInt32 (str, &(button->object.backgroundcolor)); } } str = pnode->Attribute(XMLOUTLINECOLOR_NODE, true); if (str == (RMascii *)NULL) { if(pMenu){ RMDBGLOG((GUIPARSERDBG, "Reading outline color from parent menu (ParseButton)\n")); button->object.outlinecolor = pMenu->object.outlinecolor; } } else { if((str[0] == '0') && (str[1] == 'x')) { // hexa RMasciiHexToUint64(str+2, &color); button->object.outlinecolor = (RMuint32)color; } else { RMasciiToUInt32 (str, &(button->object.outlinecolor)); } } str = pnode->Attribute(XMLTRANSPARENTCOLOR_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read button transparent color... error\n")); } else { if((str[0] == '0') && (str[1] == 'x')) { // hexa RMasciiHexToUint64(str+2, &color); button->object.transparentcolor = (RMuint32)color; } else { RMasciiToUInt32 (str, &(button->object.transparentcolor)); } } str = pnode->Attribute(XMLUSETRANSPARENTCOLOR_NODE, true); if (str != (RMascii *)NULL) { if (RMCompareAsciiCaseInsensitively (str, "TRUE")) { button->object.usetransparentcolor = TRUE; } else if (RMCompareAsciiCaseInsensitively (str, "FALSE")) { button->object.usetransparentcolor = FALSE; } else { RMDBGLOG((GUIPARSERDBG, "Invalid usetransparentcolor value of button ... error\n")); goto invalidButton; } } else button->object.usetransparentcolor = FALSE;#endif str = pnode->Attribute(XMLFOREGROUNDCOLOR_NODE, true); if (str == (RMascii *)NULL) {#ifdef GUI_REFID_2 RMasciiHexToUint64(DEFAULT_FOREGROUNDCOLOR+2, &color); button->object.foregroundcolor = (RMuint32)color;#else if(pMenu){ RMDBGLOG((GUIPARSERDBG, "Reading foreground color from parent menu (ParseButton)\n")); button->object.foregroundcolor = pMenu->object.foregroundcolor; }#endif } else { if((str[0] == '0') && (str[1] == 'x')) { // hexa RMasciiHexToUint64(str+2, &color); button->object.foregroundcolor = (RMuint32)color; } else { RMasciiToUInt32 (str, &(button->object.foregroundcolor)); } } str = pnode->Attribute(XMLFONTFILE_NODE, true); if (str == (RMascii *)NULL) { if(pMenu){ RMDBGLOG((GUIPARSERDBG, "Setting fontfile from parent menu (ParseButton)\n")); button->object.fontfile = STRDUP(pMenu->object.fontfile); } else button->object.fontfile = STRDUP(DEFAULT_FONT); // could be a bitmapped button } else { button->object.fontfile = STRDUP(str); } str = pnode->Attribute(XMLCHARWIDTH_NODE, true); if (str == (RMascii *)NULL) { if(pMenu){ RMDBGLOG((GUIPARSERDBG, "Reading charwidth from parent menu (ParseButton)\n")); button->object.charwidth = pMenu->object.charwidth; } //no fail here sice we could be using pre-defined fonts } else { RMasciiToUInt8 (str, &(button->object.charwidth)); } str = pnode->Attribute(XMLTEXTALIGN_NODE, true); if (str == (RMascii *)NULL) { if(pMenu != NULL){ RMDBGLOG((GUIPARSERDBG, "Could not read button text alignment... (Parse Button) default to ALIGN_LEFT\n")); button->object.textalign = ALIGN_LEFT; } else{ RMDBGLOG((GUIPARSERDBG, "Could not read button text alignment... (Parse Button) default to ALIGN_CENTER\n")); button->object.textalign = ALIGN_CENTER; } } else { if(RMCompareAsciiCaseInsensitively(str, "ALIGN_LEFT")){ button->object.textalign = ALIGN_LEFT; } else if(RMCompareAsciiCaseInsensitively(str, "ALIGN_RIGHT")){ button->object.textalign = ALIGN_RIGHT; } else button->object.textalign = ALIGN_CENTER; } str = pnode->Attribute(XMLROUNDED_NODE, true); if (str != (RMascii *)NULL) { if (RMCompareAsciiCaseInsensitively (str, "TRUE")) { button->object.rounded = TRUE; } else if (RMCompareAsciiCaseInsensitively (str, "FALSE")) { button->object.rounded = FALSE; } else { RMDBGLOG((GUIPARSERDBG, "Invalid rounded value of button ... (Parse Button) optional\n")); } } else button->object.rounded = FALSE; str = pnode->Attribute(XMLTEXT_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read text of button (ParseButton) ... optional\n")); // could be a bitmapped button } else { button->object.text = STRDUP(str); } str = pnode->Attribute(XMLSTATE_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read state of button (Parse Button)... default to enabled\n")); button->object.state = STATE_ENABLED; } else { if(RMCompareAsciiCaseInsensitively(str, "STATE_DISABLED")){ state = STATE_DISABLED; } else state = STATE_ENABLED; // cannot have focus from xml button->object.state = state; } str = pnode->Attribute(XMLVISIBLE_NODE, true); if (str != (RMascii *)NULL) { if (RMCompareAsciiCaseInsensitively (str, "TRUE")) { button->object.visible = TRUE; } else if (RMCompareAsciiCaseInsensitively (str, "FALSE")) { button->object.visible = FALSE; } else { RMDBGLOG((GUIPARSERDBG, "Invalid visible value of button ... error\n")); goto invalidButton; } } else button->object.visible = TRUE; str = pnode->Attribute(XMLKEYDOWN_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read keydown of button (ParseButton) ... optional\n")); } else { button->keydown = STRDUP(str); } str = pnode->Attribute(XMLKEYUP_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read keyup of button (ParseButton) ... optional\n")); } else { button->keyup = STRDUP(str); } str = pnode->Attribute(XMLKEYLEFT_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read keyleft of button (ParseButton) ... optional\n")); } else { button->keyleft = STRDUP(str); } str = pnode->Attribute(XMLKEYRIGHT_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read keyright of button (ParseButton) ... optional\n")); } else { button->keyright = STRDUP(str); } str = pnode->Attribute(XMLZINDEX_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read zIndex of button (ParseButton) ... default to 0\n")); button->object.zIndex = 0; } else { RMasciiToUInt8 (str, &(button->object.zIndex)); } RMDBGLOG((GUIPARSERDBG, "Button : name : %s, x=%d, y=%d, width=%d, height=%d, text : %s, keydown : %s\n", button->name, button->object.x, button->object.y, button->object.width, button->object.height, button->object.text, button->keydown)); for(ptempNode = pnode->FirstChildElement(); ptempNode != NULL; ptempNode = ptempNode->NextSiblingElement()) { str = ptempNode->Value(); if (str == (RMascii *)NULL) continue; if (RMCompareAsciiCaseInsensitively (str, XMLEVENTLIST_NODE)) { ParseEventList(ptempNode, (button->events), &(button->nbEvents)); } else { RMDBGLOG((GUIPARSERDBG, "unknown node [%s] in button\n", str)); } } // set id if(pMenu != NULL) button->id = SUBMENUBUTTON_IDMASK | m_nextSubMenuButtonId++; else button->id = BUTTON_IDMASK | m_nextButtonId++; return button;invalidButton: FreeButton(button); return (guiButtonType*)NULL;}void RMcuracaoGuiParser::FreeButton(guiButtonType *button){ if(button == NULL) return; if(button->name != (RMascii *)NULL){ RFREE(button->name); button->name = NULL; } if(button->object.file != (RMascii *)NULL){ RFREE(button->object.file); button->object.file = NULL; } if(button->object.selectedFile != (RMascii *)NULL){ RFREE(button->object.selectedFile); button->object.selectedFile = NULL; } if(button->object.selectOverlay != (RMascii *)NULL){ RFREE(button->object.selectOverlay); button->object.selectOverlay = NULL; } if(button->object.fontfile != (RMascii *)NULL){ RFREE(button->object.fontfile); button->object.fontfile = NULL; } if(button->object.text != (RMascii *)NULL){ RFREE(button->object.text); button->object.text = NULL; } if(button->keydown != (RMascii *)NULL){ RFREE(button->keydown); button->keydown = NULL; } if(button->keyup != (RMascii *)NULL){ RFREE(button->keyup); button->keyup = NULL; } if(button->keyleft != (RMascii *)NULL){ RFREE(button->keyleft); button->keyleft = NULL; } if(button->keyright != (RMascii *)NULL){ RFREE(button->keyright); button->keyright = NULL; } for(RMuint16 i = 0; i < button->nbEvents; i++){ FreeEvent(button->events[i]); button->events[i] = NULL; } RFREE(button);}////////////////////////////////////////////////////////////////////////////////// BITMAPS////////////////////////////////////////////////////////////////////////////////guiBitmapType *RMcuracaoGuiParser::ParseBitmap(TiXmlElement *pnode){ const RMascii *str; guiBitmapType *bitmap; RMuint64 color; bitmap = (guiBitmapType*) CALLOC(1, sizeof(guiBitmapType)); RMMemset(&bitmap->object, 0, sizeof(RMBitmapObject)); str = pnode->Attribute(XMLNAME_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read name of bitmap (ParseBitmap) ... error\n")); goto invalidBitmap; } else { bitmap->name = STRDUP(str); } str = pnode->Attribute(XMLFILE_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read file of bitmap (ParseBitmap) ... error\n")); goto invalidBitmap; } else { bitmap->object.file = RMCatAscii(m_bitmapsPath, "/", str, NULL); } str = pnode->Attribute(XMLX_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read x of bitmap (ParseBitmap) ... error\n")); goto invalidBitmap; } else { RMasciiToUInt16 (str, &(bitmap->object.x)); } str = pnode->Attribute(XMLY_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read y of bitmap (ParseBitmap) ... error\n")); goto invalidBitmap; } else { RMasciiToUInt16 (str, &(bitmap->object.y)); } str = pnode->Attribute(XMLVISIBLE_NODE, true); if (str != (RMascii *)NULL) { if (RMCompareAsciiCaseInsensitively (str, "TRUE")) { bitmap->object.visible = TRUE; } else if (RMCompareAsciiCaseInsensitively (str, "FALSE")) { bitmap->object.visible = FALSE; } else { RMDBGLOG((GUIPARSERDBG, "Invalid visible value of bitmap ... error\n")); goto invalidBitmap; } } else bitmap->object.visible = TRUE; str = pnode->Attribute(XMLTRANSPARENTCOLOR_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read bitmap transparent color... ignoring\n")); } else { if((str[0] == '0') && (str[1] == 'x')) { // hexa RMasciiHexToUint64(str+2, &color); bitmap->object.transparentcolor = (RMuint32)color; } else { RMasciiToUInt32 (str, &(bitmap->object.transparentcolor)); } } str = pnode->Attribute(XMLUSETRANSPARENTCOLOR_NODE, true); if (str != (RMascii *)NULL) { if (RMCompareAsciiCaseInsensitively (str, "TRUE")) { bitmap->object.usetransparentcolor = TRUE; } else if (RMCompareAsciiCaseInsensitively (str, "FALSE")) { bitmap->object.usetransparentcolor = FALSE; } else { RMDBGLOG((GUIPARSERDBG, "Invalid usetransparentcolor value of bitmap ... error\n")); goto invalidBitmap; } } else bitmap->object.usetransparentcolor = FALSE; str = pnode->Attribute(XMLEVENT_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read bitmap event (ParseEventBitmap) ... ignoring\n")); } else { bitmap->event = STRDUP(str); } str = pnode->Attribute(XMLZINDEX_NODE, true); // drawOrder if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read zIndex of image (ParseImage) ... default to 0\n")); bitmap->object.zIndex = 0; } else { RMasciiToUInt8 (str, &(bitmap->object.zIndex)); } RMDBGLOG((GUIPARSERDBG, "Bitmap : name : %s, x=%d, y=%d, visible : %s\n", bitmap->name, bitmap->object.x, bitmap->object.y, bitmap->object.visible ? "TRUE":"FALSE")); // set id bitmap->id = BITMAP_IDMASK | m_nextBitmapId++;#ifdef GUI_REFID_2 str = pnode->Attribute("group", true); if ( str != (RMascii *)NULL) { bitmap->szGroupName = STRDUP(str);// printf("Bitmap: %s, group: %s\n", bitmap->name, bitmap->szGroupName); }#endif return bitmap; invalidBitmap: FreeBitmap(bitmap); return (guiBitmapType*)NULL;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -