📄 guiparser.cpp.svn-base
字号:
RMstatus RMcuracaoGuiParser::ParseBitmapList( TiXmlElement *pnode, guiBitmapType *bitmaps[MAX_GUI_BITMAPS], RMuint16 *nbBitmaps){ TiXmlElement *ptempNode; const RMascii *str; *nbBitmaps = 0; for(ptempNode = pnode->FirstChildElement(); ptempNode != NULL; ptempNode = ptempNode->NextSiblingElement()) { str = ptempNode->Value(); if (str == (RMascii *)NULL) continue; if (RMCompareAsciiCaseInsensitively (str, XMLBITMAP_NODE)) { if((*nbBitmaps) < MAX_GUI_BITMAPS){ (bitmaps[*nbBitmaps]) = ParseBitmap(ptempNode); if((bitmaps[*nbBitmaps]) != (guiBitmapType*)NULL){ (*nbBitmaps)++; } } else{ RMDBGLOG((GUIPARSERDBG, "Exceed max number of bitmaps (=%d)\n", MAX_GUI_BITMAPS)); } } else { RMDBGLOG((GUIPARSERDBG, "unknown node [%s] in bitmapList\n", str)); } } return RM_OK;}void RMcuracaoGuiParser::FreeBitmap(guiBitmapType *bitmap){ if(bitmap == NULL) return; if(bitmap->name != (RMascii *)NULL){ RFREE(bitmap->name); bitmap->name = NULL; } if(bitmap->object.file != (RMascii *)NULL){ RFREE(bitmap->object.file); bitmap->object.file = NULL; } if(bitmap->event != (RMascii *)NULL){ RFREE(bitmap->event); bitmap->event = NULL; }#ifdef GUI_REFID_2 if(bitmap->szGroupName != (RMascii *)NULL){ RFREE(bitmap->szGroupName); bitmap->szGroupName = NULL; }#endif RFREE(bitmap);}////////////////////////////////////////////////////////////////////////////////// STRINGS////////////////////////////////////////////////////////////////////////////////RMstatus RMcuracaoGuiParser::ParseStringList( TiXmlElement *pnode, guiStringType *strings[MAX_GUI_STRINGS], RMuint16 *nbStrings){ TiXmlElement *ptempNode; const RMascii *str; *nbStrings = 0; for(ptempNode = pnode->FirstChildElement(); ptempNode != NULL; ptempNode = ptempNode->NextSiblingElement()) { str = ptempNode->Value(); if (str == (RMascii *)NULL) continue; if (RMCompareAsciiCaseInsensitively (str, XMLSTRING_NODE)) { if((*nbStrings) < MAX_GUI_STRINGS){ (strings[*nbStrings]) = ParseString(ptempNode); if((strings[*nbStrings]) != (guiStringType*)NULL){ (*nbStrings)++; } } else{ RMDBGLOG((GUIPARSERDBG, "Exceed max number of strings (=%d)\n", MAX_GUI_STRINGS)); } } else { RMDBGLOG((GUIPARSERDBG, "unknown node [%s] in stringList\n", str)); } } return RM_OK;}guiStringType *RMcuracaoGuiParser::ParseString(TiXmlElement *pnode){ TiXmlElement *ptempNode; const RMascii *str; guiStringType *txt; RMuint64 color; txt = (guiStringType*) CALLOC(1, sizeof(guiStringType)); RMMemset(&txt->object, 0, sizeof(RMStringObject)); str = pnode->Attribute(XMLNAME_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read name of string ... error\n")); goto invalidString; } else { txt->name = STRDUP(str); } str = pnode->Attribute(XMLTYPE_NODE, true); if (str != (RMascii *)NULL) { if (RMCompareAsciiCaseInsensitively (str, "STRING_PASSWORD")) { txt->object.type = STRING_PASSWORD; } else if (RMCompareAsciiCaseInsensitively (str, "STRING_TIME_HMS")) { txt->object.type = STRING_TIME_HMS; } else if (RMCompareAsciiCaseInsensitively (str, "STRING_TRACK")) { txt->object.type = STRING_TRACK; } else if (RMCompareAsciiCaseInsensitively (str, "STRING_FIELD")) { txt->object.type = STRING_FIELD; } else if (RMCompareAsciiCaseInsensitively (str, "STRING_PID")) { txt->object.type = STRING_PID; } else if (RMCompareAsciiCaseInsensitively (str, "STRING_SELECTION")) { txt->object.type = STRING_SELECTION; } else { txt->object.type = STRING_UNKNOWN; } } else txt->object.type = STRING_UNKNOWN; // default to only supported type // minimum length, to be used as a reference inside gui.cpp str = pnode->Attribute(XMLMINLENGTH_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read min length of string ... set to 0\n")); } else { RMasciiToUInt8 (str, &(txt->minLength)); } // minimum length, to be used as a reference inside gui.cpp str = pnode->Attribute(XMLID_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read id of string ... set to 0\n")); } else { RMasciiToUInt8 (str, &(txt->object.id)); } str = pnode->Attribute(XMLMAXLENGTH_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not get max string length... will be set to default\n")); } else { RMasciiToUInt8 (str, &(txt->maxLength)); } str = pnode->Attribute(XMLTEXT_NODE, true); if (str == (RMascii *)NULL) { if(txt->object.type == STRING_PASSWORD){ if(txt->maxLength > 0){ txt->object.text = (RMascii*)MALLOC(txt->maxLength+1); RMMemset(txt->object.text, 0, txt->maxLength+1); } else goto invalidString; } else if(txt->object.type == STRING_TIME_HMS){ txt->object.text = STRDUP(GUI_TIMEHMS_DISPLAY_STR); } else if(txt->object.type == STRING_TRACK){ txt->object.text = STRDUP(GUI_TRACK_DISPLAY_STR); } else if(txt->object.type == STRING_FIELD){ if(txt->maxLength > 0){ txt->object.text = (RMascii*)MALLOC(txt->maxLength+1); RMMemset(txt->object.text, 0, txt->maxLength+1); } else goto invalidString; } else{ if(txt->maxLength > 0){ txt->object.text = (RMascii*)MALLOC(txt->maxLength+1); RMMemset(txt->object.text, 0, txt->maxLength+1); } else goto invalidString; } } else { if(txt->maxLength > 0){ txt->object.text = (RMascii*)MALLOC(txt->maxLength+1); RMMemset(txt->object.text, 0, txt->maxLength+1); RMNCopyAscii(txt->object.text, str, txt->maxLength); } else txt->object.text = STRDUP(str); } str = pnode->Attribute(XMLX_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read x of string ... error\n")); goto invalidString; } else { RMasciiToUInt16 (str, &(txt->object.x)); } str = pnode->Attribute(XMLY_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read y of string ... error\n")); goto invalidString; } else { RMasciiToUInt16 (str, &(txt->object.y)); } str = pnode->Attribute(XMLWIDTH_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read width of string ... error\n"));#ifdef GUI_REFID_2 RMasciiToUInt16 (DEFAULT_STRING_WIDTH, &(txt->object.width));#else goto invalidString;#endif } else { RMasciiToUInt16 (str, &(txt->object.width)); } str = pnode->Attribute(XMLHEIGHT_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read height of string ... error\n"));#ifdef GUI_REFID_2 RMasciiToUInt16 (DEFAULT_STRING_HEIGHT, &(txt->object.height));#else goto invalidString;#endif } else { RMasciiToUInt16 (str, &(txt->object.height)); } str = pnode->Attribute(XMLBACKGROUNDCOLOR_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read backgroundcolor of string ... ignoring\n")); } else { if((str[0] == '0') && (str[1] == 'x')) { // hexa RMasciiHexToUint64(str+2, &color); txt->object.backgroundcolor = (RMuint32)color; } else { RMasciiToUInt32 (str, &(txt->object.backgroundcolor)); } } str = pnode->Attribute(XMLFOREGROUNDCOLOR_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read foregroundcolor of string ... ignoring\n"));#ifdef GUI_REFID_2 RMasciiHexToUint64(DEFAULT_FOREGROUNDCOLOR+2, &color); txt->object.foregroundcolor = (RMuint32)color;#endif } else { if((str[0] == '0') && (str[1] == 'x')) { // hexa RMasciiHexToUint64(str+2, &color); txt->object.foregroundcolor = (RMuint32)color; } else { RMasciiToUInt32 (str, &(txt->object.foregroundcolor)); } } str = pnode->Attribute(XMLTRANSPARENTBACKGROUND_NODE, true); if (str != (RMascii *)NULL) { if (RMCompareAsciiCaseInsensitively (str, "TRUE")) { txt->object.transparentbackground = TRUE; } else if (RMCompareAsciiCaseInsensitively (str, "FALSE")) { txt->object.transparentbackground = FALSE; } else { RMDBGLOG((GUIPARSERDBG, "Invalid visible value of string ... error\n")); goto invalidString; } } else txt->object.transparentbackground = FALSE; str = pnode->Attribute(XMLFONTFILE_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read fontfile of text ... error\n")); txt->object.fontfile = STRDUP(DEFAULT_FONT); //goto invalidString; } else { txt->object.fontfile = STRDUP(str); } str = pnode->Attribute(XMLCHARWIDTH_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read charwidth of string ... optional\n")); //no fail here sice we could be using pre-defined fonts } else { RMasciiToUInt8 (str, &(txt->object.charwidth)); } str = pnode->Attribute(XMLTEXTALIGN_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read text alignment for string... default to ALIGN_LEFT\n")); txt->object.textalign = ALIGN_LEFT; } else { if(RMCompareAsciiCaseInsensitively(str, "ALIGN_CENTER")){ txt->object.textalign = ALIGN_CENTER; } else if(RMCompareAsciiCaseInsensitively(str, "ALIGN_RIGHT")){ txt->object.textalign = ALIGN_RIGHT; } else txt->object.textalign = ALIGN_LEFT; } str = pnode->Attribute(XMLVISIBLE_NODE, true); if (str != (RMascii *)NULL) { if (RMCompareAsciiCaseInsensitively (str, "TRUE")) { txt->object.visible = TRUE; } else if (RMCompareAsciiCaseInsensitively (str, "FALSE")) { txt->object.visible = FALSE; } else { RMDBGLOG((GUIPARSERDBG, "Invalid visible value of string ... error\n")); goto invalidString; } } else txt->object.visible = TRUE; str = pnode->Attribute(XMLKEYDOWN_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read keydown of string ... optional\n")); } else { txt->keydown = STRDUP(str); } str = pnode->Attribute(XMLKEYUP_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read keyup of string ... optional\n")); } else { txt->keyup = STRDUP(str); } str = pnode->Attribute(XMLKEYLEFT_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read keyleft of string ... optional\n")); } else { txt->keyleft = STRDUP(str); } str = pnode->Attribute(XMLKEYRIGHT_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read keyright of string ... optional\n")); } else { txt->keyright = STRDUP(str); } str = pnode->Attribute(XMLOUTLINECOLOR_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read string outline color ... optional\n")); } else { if((str[0] == '0') && (str[1] == 'x')) { // hexa RMasciiHexToUint64(str+2, &color); txt->object.outlinecolor = (RMuint32)color; } else { RMasciiToUInt32 (str, &(txt->object.outlinecolor)); } // initialize selection color as outline color just in case is no stated txt->object.selectioncolor = (RMuint32)txt->object.outlinecolor; } str = pnode->Attribute(XMLSELECTIONCOLOR_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read string selection color ... optional\n")); } else { if((str[0] == '0') && (str[1] == 'x')) { // hexa RMasciiHexToUint64(str+2, &color); txt->object.selectioncolor = (RMuint32)color; } else { RMasciiToUInt32 (str, &(txt->object.selectioncolor)); } } for(ptempNode = pnode->FirstChildElement(); ptempNode != NULL; ptempNode = ptempNode->NextSiblingElement()) { str = ptempNode->Value(); if (str == (RMascii *)NULL) continue; if (RMCompareAsciiCaseInsensitively (str, XMLEVENTLIST_NODE)) { ParseEventList(ptempNode, (txt->events), &(txt->nbEvents)); } else { RMDBGLOG((GUIPARSERDBG, "unknown node [%s] in string\n", str)); } } // set id txt->id = STRING_IDMASK | m_nextStringId++; txt->object.hasfocus = FALSE; txt->object.inputchar = 0; RMDBGLOG((GUIPARSERDBG, "String : name : %s, x=%d, y=%d, visible : %s\n", txt->name, txt->object.x, txt->object.y, txt->object.visible ? "TRUE":"FALSE")); return txt; invalidString: FreeString(txt); return (guiStringType*)NULL;}void RMcuracaoGuiParser::FreeString(guiStringType *txt){ if(txt == NULL) return; if(txt->name != (RMascii *)NULL){ RFREE(txt->name); txt->name = NULL; } if(txt->object.fontfile != (RMascii *)NULL){ RFREE(txt->object.fontfile); txt->object.fontfile = NULL; } if(txt->object.text != (RMascii *)NULL){ RFREE(txt->object.text); txt->object.text = NULL; } if(txt->keydown != (RMascii *)NULL){ RFREE(txt->keydown); txt->keydown = NULL; } if(txt->ke
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -