//----------------------------------------------------------------------------- bool TemplateDescriptor::operator<(const TemplateDescriptor& right) const { int p = getMenuPosition(); int rp = right.getMenuPosition(); if (p == rp) return (getMenuCaption().compare(right.getMenuCaption()) < 0); else return (p < rp); }
void NativeLangSpeaker::changeMenuLang(HMENU menuHandle, generic_string & pluginsTrans, generic_string & windowTrans) { if (!_nativeLangA) return; TiXmlNodeA *mainMenu = _nativeLangA->FirstChild("Menu"); if (!mainMenu) return; mainMenu = mainMenu->FirstChild("Main"); if (!mainMenu) return; TiXmlNodeA *entriesRoot = mainMenu->FirstChild("Entries"); if (!entriesRoot) return; const char *idName = NULL; #ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); #endif for (TiXmlNodeA *childNode = entriesRoot->FirstChildElement("Item"); childNode ; childNode = childNode->NextSibling("Item") ) { TiXmlElementA *element = childNode->ToElement(); //int id; const char *menuIdStr = element->Attribute("menuId"); //if (element->Attribute("id", &id)) if (menuIdStr) { MenuPosition & menuPos = getMenuPosition(menuIdStr); if (menuPos._x != -1) { const char *name = element->Attribute("name"); #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); ::ModifyMenu(menuHandle, menuPos._x, MF_BYPOSITION, 0, nameW); #else ::ModifyMenu(menuHandle, menuPos._x, MF_BYPOSITION, 0, name); #endif } } else { idName = element->Attribute("idName"); if (idName) { const char *name = element->Attribute("name"); if (!strcmp(idName, "Plugins")) { #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); pluginsTrans = nameW; #else pluginsTrans = name; #endif } else if (!strcmp(idName, "Window")) { #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); windowTrans = nameW; #else windowTrans = name; #endif } } } } TiXmlNodeA *menuCommandsRoot = mainMenu->FirstChild("Commands"); for (TiXmlNodeA *childNode = menuCommandsRoot->FirstChildElement("Item"); childNode ; childNode = childNode->NextSibling("Item") ) { TiXmlElementA *element = childNode->ToElement(); int id; element->Attribute("id", &id); const char *name = element->Attribute("name"); #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); ::ModifyMenu(menuHandle, id, MF_BYCOMMAND, id, nameW); #else ::ModifyMenu(menuHandle, id, MF_BYCOMMAND, id, name); #endif } TiXmlNodeA *subEntriesRoot = mainMenu->FirstChild("SubEntries"); for (TiXmlNodeA *childNode = subEntriesRoot->FirstChildElement("Item"); childNode ; childNode = childNode->NextSibling("Item") ) { TiXmlElementA *element = childNode->ToElement(); int x, y, z; //const char *xStr = element->Attribute("posX", &x); //const char *yStr = element->Attribute("posY", &y); const char *subMenuIdStr = element->Attribute("subMenuId"); const char *name = element->Attribute("name"); if (!subMenuIdStr || !name) continue; MenuPosition & menuPos = getMenuPosition(subMenuIdStr); x = menuPos._x; y = menuPos._y; z = menuPos._z; HMENU hSubMenu = ::GetSubMenu(menuHandle, x); if (!hSubMenu) continue; HMENU hSubMenu2 = ::GetSubMenu(hSubMenu, y); if (!hSubMenu2) continue; HMENU hMenu = hSubMenu; int pos = y; //const char *zStr = element->Attribute("posZ", &z); if (z != -1) { HMENU hSubMenu3 = ::GetSubMenu(hSubMenu2, z); if (!hSubMenu3) continue; hMenu = hSubMenu2; pos = z; } #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); ::ModifyMenu(hMenu, pos, MF_BYPOSITION, 0, nameW); #else ::ModifyMenu(hMenu, pos, MF_BYPOSITION, 0, name); #endif } }