⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guiparser.cpp.svn-base

📁 sigmadesign smp8623 gui source code ,bingo
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
	TiXmlElement *pnode,	guiEventType *events[MAX_GUI_EVENTS],	RMuint16 *nbEvents){	TiXmlElement *ptempNode;	const RMascii *str;	*nbEvents = 0;	for(ptempNode = pnode->FirstChildElement(); ptempNode != NULL; ptempNode = ptempNode->NextSiblingElement()) {       		str = ptempNode->Value();		if (str == (RMascii *)NULL)			continue;		if (RMCompareAsciiCaseInsensitively (str, XMLEVENT_NODE)) {			if((*nbEvents) < MAX_GUI_EVENTS){				(events[*nbEvents]) = ParseEvent(ptempNode);				if((events[*nbEvents]) != (guiEventType*)NULL){					(*nbEvents)++;				}			}			else{				RMDBGLOG((GUIPARSERDBG, "Exceed max number of events (=%d)\n", MAX_GUI_EVENTS));			}		}		else {			RMDBGLOG((GUIPARSERDBG, "unknown node [%s] in eventList\n", str));		}	}	return RM_OK;}guiEventType *RMcuracaoGuiParser::ParseEvent(TiXmlElement *pnode){	const RMascii *str;	guiEventType *event;	event = (guiEventType*) CALLOC(1, sizeof(guiEventType));	str = pnode->Attribute(XMLNAME_NODE, true);	if (str == (RMascii *)NULL) {		RMDBGLOG((GUIPARSERDBG, "Could not read name of event (ParseEvent) ... error\n"));		goto invalidEvent;	}	else {		event->name = STRDUP(str);	}	str = pnode->Attribute(XMLCOMMAND_NODE, true);	if (str == (RMascii *)NULL) {		RMDBGLOG((GUIPARSERDBG, "Could not read name of event (ParseEvent) ... error\n"));		goto invalidEvent;	}	else {		event->command = STRDUP(str);#ifdef GUI_REFID_2		event->pMetaData = CommandMetaData::create(str);		event->pMetaData->parseData(pnode);#endif	}	str = pnode->Attribute(XMLLINK_NODE, true);	if (str != (RMascii *)NULL) {		event->link = STRDUP(str);	}	str = pnode->Attribute(XMLVALUE_NODE, true);	if (str != (RMascii *)NULL) {		event->value = STRDUP(str);	}	RMDBGLOG((GUIPARSERDBG, "Event : name : %s, command : %s, link : %s\n",		  event->name, event->command, event->link));	return event; invalidEvent:	FreeEvent(event);	return (guiEventType*)NULL;}void RMcuracaoGuiParser::FreeEvent(guiEventType *event){	if(event == NULL)		return;	if(event->name != (RMascii *)NULL){		RFREE(event->name);		event->name = NULL;	}	if(event->command != (RMascii *)NULL){		RFREE(event->command);		event->command = NULL;	}	if(event->link != (RMascii *)NULL){		RFREE(event->link);		event->link = NULL;	}	if(event->value != (RMascii *)NULL){		RFREE(event->value);		event->value = NULL;	}	RFREE(event);}////////////////////////////////////////////////////////////////////////////////// BUTTONS////////////////////////////////////////////////////////////////////////////////RMstatus RMcuracaoGuiParser::ParseButtonList(	TiXmlElement *pnode,	guiButtonType *buttons[MAX_GUI_BUTTONS],	RMuint16 *nbButtons,	guiMenuType *pMenu){	TiXmlElement *ptempNode;	const RMascii *str;	*nbButtons = 0;	for(ptempNode = pnode->FirstChildElement(); ptempNode != NULL; ptempNode = ptempNode->NextSiblingElement()) {       		str = ptempNode->Value();		if (str == (RMascii *)NULL)			continue;		if (RMCompareAsciiCaseInsensitively (str, XMLBUTTON_NODE)) {			if((*nbButtons) < MAX_GUI_BUTTONS){				(buttons[*nbButtons]) = ParseButton(ptempNode, pMenu);				if((buttons[*nbButtons]) != (guiButtonType*)NULL){					(*nbButtons)++;				}			}			else{				RMDBGLOG((GUIPARSERDBG, "Exceed max number of buttons (=%d)\n", MAX_GUI_BUTTONS));			}		}		else {			RMDBGLOG((GUIPARSERDBG, "unknown node [%s] in buttonList\n", str));		}	}	return RM_OK;}guiButtonType *RMcuracaoGuiParser::ParseButton(	TiXmlElement *pnode,	guiMenuType *pMenu){	TiXmlElement *ptempNode;	const RMascii *str;	guiButtonType *button;	RMGuiObjectState state;	RMuint64 color;	button = (guiButtonType*) CALLOC(1, sizeof(guiButtonType));	RMMemset(&button->object, 0, sizeof(RMButtonObject));	str = pnode->Attribute(XMLNAME_NODE, true);	if (str == (RMascii *)NULL) {		RMDBGLOG((GUIPARSERDBG, "Could not read name of button (ParseButton) ... error\n"));		goto invalidButton;	}	else {		button->name = STRDUP(str);	}	str = pnode->Attribute(XMLFILE_NODE, true);	if (str == (RMascii *)NULL) {		RMDBGLOG((GUIPARSERDBG, "Could not read file (ParseButton) ... optional\n"));	}	else {		button->object.file = RMCatAscii(m_bitmapsPath, "/", str, NULL);	}	str = pnode->Attribute(XMLSELECTOVERLAY_NODE, true);	if (str == (RMascii *)NULL) {		RMDBGLOG((GUIPARSERDBG, "Could not read file (ParseButton) ... optional\n"));	}	else {		button->object.selectOverlay = RMCatAscii(m_bitmapsPath, "/", str, NULL);	}	str = pnode->Attribute(XMLSELECTEDFILE_NODE, true);	if (str == (RMascii *)NULL) {		RMDBGLOG((GUIPARSERDBG, "Could not read selected file (ParseButton) ... file will be taken as 3 state\n"));	}	else {		button->object.selectedFile = RMCatAscii(m_bitmapsPath, "/", str, NULL);	}#ifdef GUI_REFID_2	str = pnode->Attribute(XMLHEIGHT_NODE, true);	if (RMCompareAscii(str, "KBD_MATRIX")){		//do kbd calculation		RMuint16 temp = 0;		button->object.height = (RMuint16) KEYBOARD_HEIGHT;		str = pnode->Attribute(XMLWIDTH_NODE, true);		if (RMCompareAscii(str, "WIDE")){			button->object.width = (RMuint16) KEYBOARD_WIDTH_WIDE;			str = pnode->Attribute(XMLX_NODE, true);			RMasciiToUInt16 (str, &temp);			if(temp == 10) button->object.x = (RMuint16) (temp * KEYBOARD_WIDTH_REGULAR + KEYBOARD_X_OFFSET);			else button->object.x = (RMuint16) (temp * KEYBOARD_WIDTH_WIDE + KEYBOARD_X_OFFSET);		}		else{			button->object.width = (RMuint16) KEYBOARD_WIDTH_REGULAR;			str = pnode->Attribute(XMLX_NODE, true);			RMasciiToUInt16 (str, &temp);			button->object.x = (RMuint16) (temp * KEYBOARD_WIDTH_REGULAR + KEYBOARD_X_OFFSET);		}		str = pnode->Attribute(XMLY_NODE, true);		RMasciiToUInt16 (str, &temp);		button->object.y = (RMuint16) (temp * KEYBOARD_HEIGHT + KEYBOARD_Y_OFFSET);		button->object.backgroundcolor = 0x0;		//button->object.transparentcolor = 0x080ff0000;		//button->object.usetransparentcolor = TRUE;		goto skipCoordinates;	}	else	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(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(XMLX_NODE, true);	if (str == (RMascii *)NULL) {		RMDBGLOG((GUIPARSERDBG, "Could not read x of button (ParseButton) ... error\n"));		goto invalidButton;	}	else {		RMasciiToUInt16 (str, &(button->object.x));	}	str = pnode->Attribute(XMLY_NODE, true);	if (str == (RMascii *)NULL) {		RMDBGLOG((GUIPARSERDBG, "Could not read x of button (ParseButton) ... error\n"));		goto invalidButton;	}	else {		RMasciiToUInt16 (str, &(button->object.y));	}	str = pnode->Attribute(XMLBACKGROUNDCOLOR_NODE, true);	if (str == (RMascii *)NULL) {		RMasciiHexToUint64(DEFAULT_BUTTON_BACKGROUNDCOLOR+2, &color);		button->object.backgroundcolor = (RMuint32)color;	}	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(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;	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));		}	}skipCoordinates:#else	str = pnode->Attribute(XMLX_NODE, true);	if (str == (RMascii *)NULL) {		RMDBGLOG((GUIPARSERDBG, "Could not read x of button (ParseButton) ... error\n"));		goto invalidButton;	}	else {		RMasciiToUInt16 (str, &(button->object.x));	}	str = pnode->Attribute(XMLY_NODE, true);	if (str == (RMascii *)NULL) {		RMDBGLOG((GUIPARSERDBG, "Could not read x of button (ParseButton) ... error\n"));		goto invalidButton;	}	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;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -