📄 guiparser.cpp.svn-base
字号:
////////////////////////////////////////////////////////////////////////////////// PAGES////////////////////////////////////////////////////////////////////////////////RMstatus RMcuracaoGuiParser::ParseMediaControls(TiXmlElement *pnode){ TiXmlElement *ptempNode; const RMascii *str; RMuint8 panels = 0; m_mediaControls =(guiMediaControls*)CALLOC(1, sizeof(guiMediaControls)); RMMemset(m_mediaControls, 0, sizeof(guiMediaControls)); for(ptempNode = pnode->FirstChildElement(); ptempNode != NULL; ptempNode = ptempNode->NextSiblingElement()) { str = ptempNode->Value(); if (str == (RMascii *)NULL) continue; if (RMCompareAsciiCaseInsensitively (str, XMLPANEL_NODE)) { m_mediaControls->panels[panels] = ParsePanels(ptempNode); if(m_mediaControls->panels[panels]) { panels++; } } else { RMDBGLOG((GUIPARSERDBG, "unknown node [%s] in osdPagesList\n", str)); } } return RM_OK;}RMstatus RMcuracaoGuiParser::ParsePageList(TiXmlElement *pnode){ TiXmlElement *ptempNode; const RMascii *str; for(ptempNode = pnode->FirstChildElement(); ptempNode != NULL; ptempNode = ptempNode->NextSiblingElement()) { str = ptempNode->Value(); if (str == (RMascii *)NULL) continue; if (RMCompareAsciiCaseInsensitively (str, XMLOSDPAGE_NODE)) { if(m_nbOsdPages < MAX_GUI_PAGES) { m_osdPages[m_nbOsdPages] = ParseOsdPage(ptempNode); if(m_osdPages[m_nbOsdPages] != (guiOsdPageType*)NULL){ m_nbOsdPages++; } } else{ RMDBGLOG((GUIPARSERDBG, "Exceed number of max osd pages (=%d)\n", MAX_GUI_PAGES)); } } else { RMDBGLOG((GUIPARSERDBG, "unknown node [%s] in osdPagesList\n", str)); } } return RM_OK;}guiPanelType* RMcuracaoGuiParser::ParsePanels(TiXmlElement *pnode){ const RMascii *str; guiPanelType* page; TiXmlElement *ptempNode; page =(guiPanelType*)CALLOC(1, sizeof(guiPanelType)); RMMemset(&page->object, 0, sizeof(RMPanelObject)); str = pnode->Attribute(XMLNAME_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read name (ParsePanel) ... error\n")); goto invalidPage; } else { page->name = STRDUP(str); } str = pnode->Attribute(XMLFILE_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read file (ParsePanel) ... error\n"));#ifdef GUI_REFID_2 page->object.file = RMCatAscii(m_bitmapsPath, "/", "background.jpg", NULL);#else // goto invalidPage;#endif } else { page->object.file = RMCatAscii(m_bitmapsPath, "/", str, NULL); } str = pnode->Attribute(XMLX_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read x (ParsePanel) ... error\n")); goto invalidPage; } else { RMasciiToUInt16 (str, &(page->object.x)); } str = pnode->Attribute(XMLORIENTATION_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read x (ParsePanel) ... error\n")); goto invalidPage; } else { RMasciiToUInt8 (str, &(page->object.orientation)); } str = pnode->Attribute(XMLY_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read y (ParsePanel) ... error\n")); goto invalidPage; } else { RMasciiToUInt16 (str, &(page->object.y)); } str = pnode->Attribute(XMLWIDTH_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read width (ParsePanel) ... error\n")); goto invalidPage; } else { RMasciiToUInt16 (str, &(page->object.width)); } str = pnode->Attribute(XMLHEIGHT_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read height (ParsePanel) ... error\n")); goto invalidPage; } else { RMasciiToUInt16 (str, &(page->object.height)); } str = pnode->Attribute(XMLVISIBLE_NODE, true); if (str != (RMascii *)NULL) { if (RMCompareAsciiCaseInsensitively (str, "TRUE")) { page->object.visible = TRUE; } else if (RMCompareAsciiCaseInsensitively (str, "FALSE")) { page->object.visible = FALSE; } else { RMDBGLOG((GUIPARSERDBG, "Invalid visible value (ParseScreenFormat) ... error\n")); goto invalidPage; } } else page->object.visible = FALSE; for(ptempNode = pnode->FirstChildElement(); ptempNode != NULL; ptempNode = ptempNode->NextSiblingElement()) { str = ptempNode->Value(); if (str == (RMascii *)NULL) continue; if (RMCompareAsciiCaseInsensitively (str, XMLSLIDER_NODE)) { page->slider = ParseSlider(ptempNode); } else if (RMCompareAsciiCaseInsensitively (str, XMLBUTTONLIST_NODE)) { ParseButtonList(ptempNode, (page->buttons), &(page->nbButtons), NULL); } else { RMDBGLOG((GUIPARSERDBG, "unknown node [%s] in osdPages\n", str)); } } RMDBGLOG((GUIPARSERDBG, "end page\n")); return page; invalidPage: FreePanel(page); return NULL;}guiOsdPageType* RMcuracaoGuiParser::ParseOsdPage(TiXmlElement *pnode){ const RMascii *str; guiOsdPageType* page; TiXmlElement *ptempNode; page =(guiOsdPageType*)CALLOC(1, sizeof(guiOsdPageType)); RMMemset(&page->object, 0, sizeof(RMPageObject)); str = pnode->Attribute(XMLNAME_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read name (ParseOsdPage) ... error\n")); goto invalidPage; } else { page->name = STRDUP(str); } str = pnode->Attribute(XMLFILE_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read file (ParseOsdPage) ... error\n"));#ifdef GUI_REFID_2 page->object.file = RMCatAscii(m_bitmapsPath, "/", "background.jpg", NULL);#else goto invalidPage;#endif } else { page->object.file = RMCatAscii(m_bitmapsPath, "/", str, NULL); } str = pnode->Attribute(XMLX_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read x (ParseOsdPage) ... error\n")); page->object.x = 0; } else { RMasciiToUInt16 (str, &(page->object.x)); } str = pnode->Attribute(XMLY_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read y (ParseOsdPage) ... error\n")); page->object.y = 0; } else { RMasciiToUInt16 (str, &(page->object.y)); } str = pnode->Attribute(XMLVISIBLE_NODE, true); if (str != (RMascii *)NULL) { if (RMCompareAsciiCaseInsensitively (str, "TRUE")) { page->object.visible = TRUE; } else if (RMCompareAsciiCaseInsensitively (str, "FALSE")) { page->object.visible = FALSE; } else { RMDBGLOG((GUIPARSERDBG, "Invalid visible value (ParseScreenFormat) ... error\n")); goto invalidPage; } } else page->object.visible = TRUE; str = pnode->Attribute(XMLDYNPAGE_NODE, true); if (str != (RMascii *)NULL) { if (RMCompareAsciiCaseInsensitively (str, "TRUE")) { page->object.dynamic = TRUE; } else if (RMCompareAsciiCaseInsensitively (str, "FALSE")) { page->object.dynamic = FALSE; } else { RMDBGLOG((GUIPARSERDBG, "Invalid visible value (ParseScreenFormat) ... error\n")); page->object.dynamic = FALSE; } } else page->object.dynamic = FALSE; if(page->object.dynamic) { str = pnode->Attribute(XMLURL_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read url (ParseOsdPage) ... error\n")); goto invalidPage; } else { page->object.url = STRDUP(str); } } str = pnode->Attribute(XMLSELECTEDOBJECT_NODE, true); if (str == (RMascii *)NULL) { RMDBGLOG((GUIPARSERDBG, "Could not read selectedObject ... ignoring\n")); } else { page->selectedObject = STRDUP(str); } RMDBGLOG((GUIPARSERDBG, "osd page : name : %s, file : %s, x=%d, y=%d, visible : %s\n", page->name, page->object.file, page->object.x, page->object.y, page->object.visible?"TRUE":"FALSE")); for(ptempNode = pnode->FirstChildElement(); ptempNode != NULL; ptempNode = ptempNode->NextSiblingElement()) { str = ptempNode->Value(); if (str == (RMascii *)NULL) continue; if (RMCompareAsciiCaseInsensitively (str, XMLEVENTLIST_NODE)) { ParseEventList(ptempNode, (page->events), &(page->nbEvents)); } else if (RMCompareAsciiCaseInsensitively (str, XMLBUTTONLIST_NODE)) { ParseButtonList(ptempNode, (page->buttons), &(page->nbButtons), NULL); } else if (RMCompareAsciiCaseInsensitively (str, XMLSTRINGLIST_NODE)) { ParseStringList(ptempNode, (page->strings), &(page->nbStrings)); } else if (RMCompareAsciiCaseInsensitively (str, XMLBITMAPLIST_NODE)) { ParseBitmapList(ptempNode, (page->bitmaps), &(page->nbBitmaps)); } else if (RMCompareAsciiCaseInsensitively (str, XMLMENULIST_NODE)) { ParseMenuList(ptempNode, (page->menus), &(page->nbMenus)); } else if (RMCompareAsciiCaseInsensitively (str, XMLLISTS_NODE)) { ParseLists(ptempNode, (page->lists), &(page->nbLists)); } else if (RMCompareAsciiCaseInsensitively (str, XMLSLIDER_NODE)) { page->temp = ParseSlider(ptempNode); } else { RMDBGLOG((GUIPARSERDBG, "unknown node [%s] in osdPages\n", str)); } } // set ids page->id = m_nbOsdPages; // page auto key navigation DoPageAutoKeyNavigation(page); RMDBGLOG((GUIPARSERDBG, "end page\n")); return page; invalidPage: FreeOsdPage(page); return (guiOsdPageType*)NULL;}void RMcuracaoGuiParser::FreePanel(guiPanelType *page){ RMuint16 i; if(page == NULL) return; if(page->name != (RMascii *)NULL){ RFREE(page->name); page->name = NULL; } if(page->object.file != (RMascii *)NULL){ RFREE(page->object.file); page->object.file = NULL; } for(i = 0; i < page->nbButtons; i++){ FreeButton(page->buttons[i]); page->buttons[i] = NULL; } if(page->slider) { FreeSlider(page->slider); page->slider = NULL; } RFREE(page);}void RMcuracaoGuiParser::FreeMediaControls(guiMediaControls *page){ RMuint16 i; if(page == NULL) return; for(i = 0; i < 3; i++){ if(page->panels[i]) FreePanel(page->panels[i]); page->panels[i] = NULL; } RFREE(page);}void RMcuracaoGuiParser::FreeOsdPage(guiOsdPageType *page){ RMuint16 i; if(page == NULL) return; if(page->name != (RMascii *)NULL){ RFREE(page->name); page->name = NULL; } if(page->selectedObject != (RMascii *)NULL){ RFREE(page->selectedObject); page->selectedObject = NULL; } if(page->object.file != (RMascii *)NULL){ RFREE(page->object.file); page->object.file = NULL; } if(page->object.url != (RMascii*) NULL) { RFREE(page->object.url); page->object.url = NULL; } if(page->temp != NULL) { FreeSlider(page->temp); //RFREE(page->temp); page->temp = NULL; } for(i = 0; i < page->nbEvents; i++){ FreeEvent(page->events[i]); page->events[i] = NULL; } for(i = 0; i < page->nbButtons; i++){ FreeButton(page->buttons[i]); page->buttons[i] = NULL; } for(i = 0; i < page->nbBitmaps; i++){ FreeBitmap(page->bitmaps[i]); page->bitmaps[i] = NULL; } for(i = 0; i < page->nbMenus; i++){ FreeMenu(page->menus[i]); page->menus[i] = NULL; } for(i = 0; i < page->nbLists; i++){ FreeList(page->lists[i]); page->lists[i] = NULL; } for(i = 0; i < page->nbStrings; i++){ FreeString(page->strings[i]); page->strings[i] = NULL; } RFREE(page);}RMstatus RMcuracaoGuiParser::GetPages( guiOsdPageType *pages[MAX_GUI_PAGES], RMuint16 *nPages){ if(m_nbOsdPages){ RMMemcpy(pages, m_osdPages, sizeof(m_osdPages)); *nPages = m_nbOsdPages; return RM_OK; } return RM_ERROR;}RMstatus RMcuracaoGuiParser::GetMediaControls( guiMediaControls **controls){ //RMMemcpy(controls, m_mediaControls, sizeof(m_mediaControls)); (*controls) = m_mediaControls; return RM_OK;}// contributed by KARL@KISS//This function will autogenerate navigation routes for buttons and special string types in pages, popups and menus.RMstatus RMcuracaoGuiParser::DoPageAutoKeyNavigation(guiOsdPageType *page){ //Special navigation commands can still be added in the XML file RMuint16 highX = 1000; RMuint16 highY = 1000; RMuint16 lowX = 0; RMuint16 lowY = 0; RMuint8 right = 0; RMuint8 down = 0; RMuint8 left = 0; RMuint8 up = 0; RMuint16 currentX = 0; RMuint16 currentY = 0; RMuint16 targetX = 0; RMuint16 targetY = 0; // buttons within page for(RMuint8 b = 0; b < page->nbButtons; b++){ //Analyse all buttons if more than one currentX = page->buttons[b]->object.x; currentY = page->buttons[b]->object.y; RMDBGLOG((GUIPARSERDBG, "Page button found with coordinates: x %d, y %d\n", currentX, currentY));// printf("Page button found with coordinates: x %d, y %d\n", currentX, currentY);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -