void NativeLangSpeaker::changeShortcutLang() { if (!_nativeLangA) return; NppParameters * pNppParam = NppParameters::getInstance(); vector<CommandShortcut> & mainshortcuts = pNppParam->getUserShortcuts(); vector<ScintillaKeyMap> & scinshortcuts = pNppParam->getScintillaKeyList(); int mainSize = (int)mainshortcuts.size(); int scinSize = (int)scinshortcuts.size(); TiXmlNodeA *shortcuts = _nativeLangA->FirstChild("Shortcuts"); if (!shortcuts) return; shortcuts = shortcuts->FirstChild("Main"); if (!shortcuts) return; TiXmlNodeA *entriesRoot = shortcuts->FirstChild("Entries"); if (!entriesRoot) return; for (TiXmlNodeA *childNode = entriesRoot->FirstChildElement("Item"); childNode ; childNode = childNode->NextSibling("Item") ) { TiXmlElementA *element = childNode->ToElement(); int index, id; if (element->Attribute("index", &index) && element->Attribute("id", &id)) { if (index > -1 && index < mainSize) { //valid index only const char *name = element->Attribute("name"); CommandShortcut & csc = mainshortcuts[index]; if (csc.getID() == (unsigned long)id) { #ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); const wchar_t * nameW = wmc->char2wchar(name, _nativeLangEncoding); csc.setName(nameW); #else csc.setName(name); #endif } } } } //Scintilla shortcuts = _nativeLangA->FirstChild("Shortcuts"); if (!shortcuts) return; shortcuts = shortcuts->FirstChild("Scintilla"); if (!shortcuts) return; entriesRoot = shortcuts->FirstChild("Entries"); if (!entriesRoot) return; for (TiXmlNodeA *childNode = entriesRoot->FirstChildElement("Item"); childNode ; childNode = childNode->NextSibling("Item") ) { TiXmlElementA *element = childNode->ToElement(); int index; if (element->Attribute("index", &index)) { if (index > -1 && index < scinSize) { //valid index only const char *name = element->Attribute("name"); ScintillaKeyMap & skm = scinshortcuts[index]; #ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); const wchar_t * nameW = wmc->char2wchar(name, _nativeLangEncoding); skm.setName(nameW); #else skm.setName(name); #endif } } } }
void NativeLangSpeaker::changeUserDefineLang(UserDefineDialog *userDefineDlg) { if (!_nativeLangA) return; TiXmlNodeA *userDefineDlgNode = _nativeLangA->FirstChild("Dialog"); if (!userDefineDlgNode) return; userDefineDlgNode = userDefineDlgNode->FirstChild("UserDefine"); if (!userDefineDlgNode) return; HWND hDlg = userDefineDlg->getHSelf(); #ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); #endif // Set Title const char *titre = (userDefineDlgNode->ToElement())->Attribute("title"); if (titre && titre[0]) { #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding); ::SetWindowText(hDlg, nameW); #else ::SetWindowText(hDlg, titre); #endif } // for each control const int nbControl = 9; const char *translatedText[nbControl]; for (int i = 0 ; i < nbControl ; i++) translatedText[i] = NULL; for (TiXmlNodeA *childNode = userDefineDlgNode->FirstChildElement("Item"); childNode ; childNode = childNode->NextSibling("Item") ) { TiXmlElementA *element = childNode->ToElement(); int id; const char *sentinel = element->Attribute("id", &id); const char *name = element->Attribute("name"); if (sentinel && (name && name[0])) { if (id > 30) { HWND hItem = ::GetDlgItem(hDlg, id); if (hItem) { #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); ::SetWindowText(hItem, nameW); #else ::SetWindowText(hItem, name); #endif } } else { switch(id) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: translatedText[id] = name; break; } } } } const int nbDlg = 4; HWND hDlgArrary[nbDlg]; hDlgArrary[0] = userDefineDlg->getFolderHandle(); hDlgArrary[1] = userDefineDlg->getKeywordsHandle(); hDlgArrary[2] = userDefineDlg->getCommentHandle(); hDlgArrary[3] = userDefineDlg->getSymbolHandle(); /* const int nbGrpFolder = 3; int folderID[nbGrpFolder][nbControl] = { //{IDC_DEFAULT_COLORSTYLEGROUP_STATIC, IDC_DEFAULT_FG_STATIC, IDC_DEFAULT_BG_STATIC, IDC_DEFAULT_FONTSTYLEGROUP_STATIC, IDC_DEFAULT_FONTNAME_STATIC, IDC_DEFAULT_FONTSIZE_STATIC, IDC_DEFAULT_BOLD_CHECK, IDC_DEFAULT_ITALIC_CHECK, IDC_DEFAULT_UNDERLINE_CHECK},\ //{IDC_FOLDEROPEN_COLORSTYLEGROUP_STATIC, IDC_FOLDEROPEN_FG_STATIC, IDC_FOLDEROPEN_BG_STATIC, IDC_FOLDEROPEN_FONTSTYLEGROUP_STATIC, IDC_FOLDEROPEN_FONTNAME_STATIC, IDC_FOLDEROPEN_FONTSIZE_STATIC, IDC_FOLDEROPEN_BOLD_CHECK, IDC_FOLDEROPEN_ITALIC_CHECK, IDC_FOLDEROPEN_UNDERLINE_CHECK},\ //{IDC_FOLDERCLOSE_COLORSTYLEGROUP_STATIC, IDC_FOLDERCLOSE_FG_STATIC, IDC_FOLDERCLOSE_BG_STATIC, IDC_FOLDERCLOSE_FONTSTYLEGROUP_STATIC, IDC_FOLDERCLOSE_FONTNAME_STATIC, IDC_FOLDERCLOSE_FONTSIZE_STATIC, IDC_FOLDERCLOSE_BOLD_CHECK, IDC_FOLDERCLOSE_ITALIC_CHECK, IDC_FOLDERCLOSE_UNDERLINE_CHECK} }; const int nbGrpKeywords = 4; int keywordsID[nbGrpKeywords][nbControl] = {//\ //{IDC_KEYWORD1_COLORSTYLEGROUP_STATIC, IDC_KEYWORD1_FG_STATIC, IDC_KEYWORD1_BG_STATIC, IDC_KEYWORD1_FONTSTYLEGROUP_STATIC, IDC_KEYWORD1_FONTNAME_STATIC, IDC_KEYWORD1_FONTSIZE_STATIC, IDC_KEYWORD1_BOLD_CHECK, IDC_KEYWORD1_ITALIC_CHECK, IDC_KEYWORD1_UNDERLINE_CHECK},\ //{IDC_KEYWORD2_COLORSTYLEGROUP_STATIC, IDC_KEYWORD2_FG_STATIC, IDC_KEYWORD2_BG_STATIC, IDC_KEYWORD2_FONTSTYLEGROUP_STATIC, IDC_KEYWORD2_FONTNAME_STATIC, IDC_KEYWORD2_FONTSIZE_STATIC, IDC_KEYWORD2_BOLD_CHECK, IDC_KEYWORD2_ITALIC_CHECK, IDC_KEYWORD2_UNDERLINE_CHECK},\ //{IDC_KEYWORD3_COLORSTYLEGROUP_STATIC, IDC_KEYWORD3_FG_STATIC, IDC_KEYWORD3_BG_STATIC, IDC_KEYWORD3_FONTSTYLEGROUP_STATIC, IDC_KEYWORD3_FONTNAME_STATIC, IDC_KEYWORD3_FONTSIZE_STATIC, IDC_KEYWORD3_BOLD_CHECK, IDC_KEYWORD3_ITALIC_CHECK, IDC_KEYWORD3_UNDERLINE_CHECK},\ //{IDC_KEYWORD4_COLORSTYLEGROUP_STATIC, IDC_KEYWORD4_FG_STATIC, IDC_KEYWORD4_BG_STATIC, IDC_KEYWORD4_FONTSTYLEGROUP_STATIC, IDC_KEYWORD4_FONTNAME_STATIC, IDC_KEYWORD4_FONTSIZE_STATIC, IDC_KEYWORD4_BOLD_CHECK, IDC_KEYWORD4_ITALIC_CHECK, IDC_KEYWORD4_UNDERLINE_CHECK} }; const int nbGrpComment = 3; int commentID[nbGrpComment][nbControl] = {//\ //{IDC_COMMENT_COLORSTYLEGROUP_STATIC, IDC_COMMENT_FG_STATIC, IDC_COMMENT_BG_STATIC, IDC_COMMENT_FONTSTYLEGROUP_STATIC, IDC_COMMENT_FONTNAME_STATIC, IDC_COMMENT_FONTSIZE_STATIC, IDC_COMMENT_BOLD_CHECK, IDC_COMMENT_ITALIC_CHECK, IDC_COMMENT_UNDERLINE_CHECK},\ //{IDC_NUMBER_COLORSTYLEGROUP_STATIC, IDC_NUMBER_FG_STATIC, IDC_NUMBER_BG_STATIC, IDC_NUMBER_FONTSTYLEGROUP_STATIC, IDC_NUMBER_FONTNAME_STATIC, IDC_NUMBER_FONTSIZE_STATIC, IDC_NUMBER_BOLD_CHECK, IDC_NUMBER_ITALIC_CHECK, IDC_NUMBER_UNDERLINE_CHECK},\ //{IDC_COMMENTLINE_COLORSTYLEGROUP_STATIC, IDC_COMMENTLINE_FG_STATIC, IDC_COMMENTLINE_BG_STATIC, IDC_COMMENTLINE_FONTSTYLEGROUP_STATIC, IDC_COMMENTLINE_FONTNAME_STATIC, IDC_COMMENTLINE_FONTSIZE_STATIC, IDC_COMMENTLINE_BOLD_CHECK, IDC_COMMENTLINE_ITALIC_CHECK, IDC_COMMENTLINE_UNDERLINE_CHECK} }; const int nbGrpOperator = 4; int operatorID[nbGrpOperator][nbControl] = {//\ //{IDC_OPERATOR_COLORSTYLEGROUP_STATIC, IDC_OPERATOR_FG_STATIC, IDC_OPERATOR_BG_STATIC, IDC_OPERATOR_FONTSTYLEGROUP_STATIC, IDC_OPERATOR_FONTNAME_STATIC, IDC_OPERATOR_FONTSIZE_STATIC, IDC_OPERATOR_BOLD_CHECK, IDC_OPERATOR_ITALIC_CHECK, IDC_OPERATOR_UNDERLINE_CHECK},\ //{IDC_DELIMITER1_COLORSTYLEGROUP_STATIC, IDC_DELIMITER1_FG_STATIC, IDC_DELIMITER1_BG_STATIC, IDC_DELIMITER1_FONTSTYLEGROUP_STATIC, IDC_DELIMITER1_FONTNAME_STATIC, IDC_DELIMITER1_FONTSIZE_STATIC, IDC_DELIMITER1_BOLD_CHECK, IDC_DELIMITER1_ITALIC_CHECK, IDC_DELIMITER1_UNDERLINE_CHECK},\ //{IDC_DELIMITER2_COLORSTYLEGROUP_STATIC, IDC_DELIMITER2_FG_STATIC, IDC_DELIMITER2_BG_STATIC, IDC_DELIMITER2_FONTSTYLEGROUP_STATIC, IDC_DELIMITER2_FONTNAME_STATIC, IDC_DELIMITER2_FONTSIZE_STATIC, IDC_DELIMITER2_BOLD_CHECK, IDC_DELIMITER2_ITALIC_CHECK, IDC_DELIMITER2_UNDERLINE_CHECK},\ //{IDC_DELIMITER3_COLORSTYLEGROUP_STATIC, IDC_DELIMITER3_FG_STATIC, IDC_DELIMITER3_BG_STATIC, IDC_DELIMITER3_FONTSTYLEGROUP_STATIC, IDC_DELIMITER3_FONTNAME_STATIC, IDC_DELIMITER3_FONTSIZE_STATIC, IDC_DELIMITER3_BOLD_CHECK, IDC_DELIMITER3_ITALIC_CHECK, IDC_DELIMITER3_UNDERLINE_CHECK} }; int nbGpArray[nbDlg] = {nbGrpFolder, nbGrpKeywords, nbGrpComment, nbGrpOperator}; */ const char nodeNameArray[nbDlg][16] = {"Folder", "Keywords", "Comment", "Operator"}; for (int i = 0 ; i < nbDlg ; i++) { /* for (int j = 0 ; j < nbGpArray[i] ; j++) { switch (i) { case 0 : changeStyleCtrlsLang(hDlgArrary[i], folderID[j], translatedText); break; case 1 : changeStyleCtrlsLang(hDlgArrary[i], keywordsID[j], translatedText); break; case 2 : changeStyleCtrlsLang(hDlgArrary[i], commentID[j], translatedText); break; case 3 : changeStyleCtrlsLang(hDlgArrary[i], operatorID[j], translatedText); break; } } */ TiXmlNodeA *node = userDefineDlgNode->FirstChild(nodeNameArray[i]); if (node) { // Set Title titre = (node->ToElement())->Attribute("title"); if (titre &&titre[0]) { #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding); userDefineDlg->setTabName(i, nameW); #else userDefineDlg->setTabName(i, titre); #endif } for (TiXmlNodeA *childNode = node->FirstChildElement("Item"); childNode ; childNode = childNode->NextSibling("Item") ) { TiXmlElementA *element = childNode->ToElement(); int id; const char *sentinel = element->Attribute("id", &id); const char *name = element->Attribute("name"); if (sentinel && (name && name[0])) { HWND hItem = ::GetDlgItem(hDlgArrary[i], id); if (hItem) { #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); ::SetWindowText(hItem, nameW); #else ::SetWindowText(hItem, name); #endif } } } } } }
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 } }
void NativeLangSpeaker::changeConfigLang(HWND hDlg) { if (!_nativeLangA) return; TiXmlNodeA *styleConfDlgNode = _nativeLangA->FirstChild("Dialog"); if (!styleConfDlgNode) return; styleConfDlgNode = styleConfDlgNode->FirstChild("StyleConfig"); if (!styleConfDlgNode) return; //HWND hDlg = _configStyleDlg.getHSelf(); #ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); #endif // Set Title const char *titre = (styleConfDlgNode->ToElement())->Attribute("title"); if ((titre && titre[0]) && hDlg) { #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding); ::SetWindowText(hDlg, nameW); #else ::SetWindowText(hDlg, titre); #endif } for (TiXmlNodeA *childNode = styleConfDlgNode->FirstChildElement("Item"); childNode ; childNode = childNode->NextSibling("Item") ) { TiXmlElementA *element = childNode->ToElement(); int id; const char *sentinel = element->Attribute("id", &id); const char *name = element->Attribute("name"); if (sentinel && (name && name[0])) { HWND hItem = ::GetDlgItem(hDlg, id); if (hItem) { #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); ::SetWindowText(hItem, nameW); #else ::SetWindowText(hItem, name); #endif } } } styleConfDlgNode = styleConfDlgNode->FirstChild("SubDialog"); for (TiXmlNodeA *childNode = styleConfDlgNode->FirstChildElement("Item"); childNode ; childNode = childNode->NextSibling("Item") ) { TiXmlElementA *element = childNode->ToElement(); int id; const char *sentinel = element->Attribute("id", &id); const char *name = element->Attribute("name"); if (sentinel && (name && name[0])) { HWND hItem = ::GetDlgItem(hDlg, id); if (hItem) { #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); ::SetWindowText(hItem, nameW); #else ::SetWindowText(hItem, name); #endif } } } }
void NativeLangSpeaker::changeUserDefineLang(UserDefineDialog *userDefineDlg) { if (!_nativeLangA) return; TiXmlNodeA *userDefineDlgNode = _nativeLangA->FirstChild("Dialog"); if (!userDefineDlgNode) return; userDefineDlgNode = userDefineDlgNode->FirstChild("UserDefine"); if (!userDefineDlgNode) return; HWND hDlg = userDefineDlg->getHSelf(); #ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); #endif // Set Title const char *titre = (userDefineDlgNode->ToElement())->Attribute("title"); if (titre && titre[0]) { #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding); ::SetWindowText(hDlg, nameW); #else ::SetWindowText(hDlg, titre); #endif } // for each control const int nbControl = 9; const char *translatedText[nbControl]; for (int i = 0 ; i < nbControl ; ++i) translatedText[i] = NULL; for (TiXmlNodeA *childNode = userDefineDlgNode->FirstChildElement("Item"); childNode ; childNode = childNode->NextSibling("Item") ) { TiXmlElementA *element = childNode->ToElement(); int id; const char *sentinel = element->Attribute("id", &id); const char *name = element->Attribute("name"); if (sentinel && (name && name[0])) { if (id > 30) { HWND hItem = ::GetDlgItem(hDlg, id); if (hItem) { #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); ::SetWindowText(hItem, nameW); #else ::SetWindowText(hItem, name); #endif } } else { switch(id) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: translatedText[id] = name; break; } } } } const int nbDlg = 4; HWND hDlgArrary[nbDlg]; hDlgArrary[0] = userDefineDlg->getFolderHandle(); hDlgArrary[1] = userDefineDlg->getKeywordsHandle(); hDlgArrary[2] = userDefineDlg->getCommentHandle(); hDlgArrary[3] = userDefineDlg->getSymbolHandle(); const char nodeNameArray[nbDlg][16] = {"Folder", "Keywords", "Comment", "Operator"}; for (int i = 0 ; i < nbDlg ; ++i) { /* for (int j = 0 ; j < nbGpArray[i] ; j++) { switch (i) { case 0 : changeStyleCtrlsLang(hDlgArrary[i], folderID[j], translatedText); break; case 1 : changeStyleCtrlsLang(hDlgArrary[i], keywordsID[j], translatedText); break; case 2 : changeStyleCtrlsLang(hDlgArrary[i], commentID[j], translatedText); break; case 3 : changeStyleCtrlsLang(hDlgArrary[i], operatorID[j], translatedText); break; } } */ TiXmlNodeA *node = userDefineDlgNode->FirstChild(nodeNameArray[i]); if (node) { // Set Title titre = (node->ToElement())->Attribute("title"); if (titre &&titre[0]) { #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding); userDefineDlg->setTabName(i, nameW); #else userDefineDlg->setTabName(i, titre); #endif } for (TiXmlNodeA *childNode = node->FirstChildElement("Item"); childNode ; childNode = childNode->NextSibling("Item") ) { TiXmlElementA *element = childNode->ToElement(); int id; const char *sentinel = element->Attribute("id", &id); const char *name = element->Attribute("name"); if (sentinel && (name && name[0])) { HWND hItem = ::GetDlgItem(hDlgArrary[i], id); if (hItem) { #ifdef UNICODE const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); ::SetWindowText(hItem, nameW); #else ::SetWindowText(hItem, name); #endif } } } } } }