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

📄 guiparser.cpp.svn-base

📁 sigmadesign smp8623 gui source code ,bingo
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
		}		//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;}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->obje

⌨️ 快捷键说明

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