[NEW_FEATURE] Change language on the run time for Unicode version (in progress - reloading another language is ok).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@385 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2009-01-04 22:35:51 +00:00
parent be3285aa2c
commit 43bf9f4c9e
9 changed files with 78 additions and 50 deletions

View File

@ -4588,13 +4588,11 @@ bool Notepad_plus::reloadLang()
} }
int indexWindow = ::GetMenuItemCount(_mainMenuHandle) - 2; int indexWindow = ::GetMenuItemCount(_mainMenuHandle) - 2;
::ModifyMenu(_mainMenuHandle, MENUINDEX_PLUGINS, MF_BYPOSITION, 0, windowTrans.c_str()); ::ModifyMenu(_mainMenuHandle, indexWindow, MF_BYPOSITION, 0, windowTrans.c_str());
windowTrans += TEXT("..."); windowTrans += TEXT("...");
::ModifyMenu(_mainMenuHandle, IDM_WINDOW_WINDOWS, MF_BYCOMMAND, IDM_WINDOW_WINDOWS, windowTrans.c_str()); ::ModifyMenu(_mainMenuHandle, IDM_WINDOW_WINDOWS, MF_BYCOMMAND, IDM_WINDOW_WINDOWS, windowTrans.c_str());
::DrawMenuBar(_hSelf); // Update scintilla context menu strings
/*
// Update context menu strings
vector<MenuItemUnit> & tmp = pNppParam->getContextMenuItems(); vector<MenuItemUnit> & tmp = pNppParam->getContextMenuItems();
size_t len = tmp.size(); size_t len = tmp.size();
TCHAR menuName[64]; TCHAR menuName[64];
@ -4604,10 +4602,23 @@ bool Notepad_plus::reloadLang()
{ {
::GetMenuString(_mainMenuHandle, tmp[i]._cmdID, menuName, 64, MF_BYCOMMAND); ::GetMenuString(_mainMenuHandle, tmp[i]._cmdID, menuName, 64, MF_BYCOMMAND);
tmp[i]._itemName = purgeMenuItemString(menuName); tmp[i]._itemName = purgeMenuItemString(menuName);
//printStr(tmp[i]._itemName.c_str());
} }
} }
*/
vector<CommandShortcut> & shortcuts = pNppParam->getUserShortcuts();
len = shortcuts.size();
for(size_t i = 0; i < len; i++)
{
CommandShortcut & csc = shortcuts[i];
::GetMenuString(_mainMenuHandle, csc.getID(), menuName, 64, MF_BYCOMMAND);
csc.setName(purgeMenuItemString(menuName, true).c_str());
}
_accelerator.updateFullMenu();
_scintaccelerator.updateKeys();
if (_tabPopupMenu.isCreated()) if (_tabPopupMenu.isCreated())
{ {
changeLangTabContextMenu(); changeLangTabContextMenu();
@ -4616,7 +4627,6 @@ bool Notepad_plus::reloadLang()
{ {
changeLangTabDrapContextMenu(); changeLangTabDrapContextMenu();
} }
pNppParam->reloadContextMenuFromXmlTree(_mainMenuHandle);
if (_preference.isCreated()) if (_preference.isCreated())
{ {
@ -5328,7 +5338,7 @@ void Notepad_plus::changeLangTabContextMenu()
#else #else
if (pGoToView && pGoToView[0]) if (pGoToView && pGoToView[0])
{ {
::ModifyMenu(hCM, POS_GO2VIEW, MF_BYPOSITION, 0, goToViewG); ::ModifyMenu(hCM, POS_GO2VIEW, MF_BYPOSITION, 0, pGoToView);
} }
if (pCloneToView && pCloneToView[0]) if (pCloneToView && pCloneToView[0])
{ {

View File

@ -1120,6 +1120,13 @@ public:
winVer getWinVersion() { return _winVersion;}; winVer getWinVersion() { return _winVersion;};
FindHistory & getFindHistory() {return _findHistory;}; FindHistory & getFindHistory() {return _findHistory;};
#ifdef UNICODE
const vector<wstring> & getLocalizationList() const {
return _localizationList;
};
#endif
private: private:
NppParameters(); NppParameters();
~NppParameters(); ~NppParameters();
@ -1177,8 +1184,9 @@ private:
vector<ScintillaKeyMap> _scintillaKeyCommands; //scintilla keycommands. Static size vector<ScintillaKeyMap> _scintillaKeyCommands; //scintilla keycommands. Static size
vector<int> _scintillaModifiedKeyIndices; //modified scintilla keys. Indices static, determined by searching for commandId. Needed when saving alterations vector<int> _scintillaModifiedKeyIndices; //modified scintilla keys. Indices static, determined by searching for commandId. Needed when saving alterations
#ifdef UNICODE
vector<wstring> _localizationList;
#endif
//vector<generic_string> _noMenuCmdNames; //vector<generic_string> _noMenuCmdNames;
vector<MenuItemUnit> _contextMenuItems; vector<MenuItemUnit> _contextMenuItems;
Session _session; Session _session;

View File

@ -263,8 +263,7 @@ BOOL CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
_babygrid.setText(row, 2, skm.toString().c_str()); _babygrid.setText(row, 2, skm.toString().c_str());
//Notify current Accelerator class to update key //Notify current Accelerator class to update key
//nppParam->getScintillaAccelerator()->updateKeys(); nppParam->getScintillaAccelerator()->updateKeys();
nppParam->getScintillaAccelerator()->updateKey(prevskm, skm);
//::SendMessage(_hParent, NPPM_INTERNAL_BINDSCINTILLAKEY, scintillaSc.toKeyDef(), scintillaSc.getScintillaKey()); //::SendMessage(_hParent, NPPM_INTERNAL_BINDSCINTILLAKEY, scintillaSc.toKeyDef(), scintillaSc.getScintillaKey());
//::SendMessage(_hParent, NPPM_INTERNAL_CLEARSCINTILLAKEY, scintillaShortcuts[index].toKeyDef(), 0); //::SendMessage(_hParent, NPPM_INTERNAL_CLEARSCINTILLAKEY, scintillaShortcuts[index].toKeyDef(), 0);

View File

@ -34,14 +34,14 @@ END
IDD_PREFERENCE_BAR_BOX DIALOGEX 0, 0, 370, 180 IDD_PREFERENCE_BAR_BOX DIALOGEX 0, 0, 370, 180
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
GROUPBOX "Tool bar",IDC_TOOLBAR_GB_STATIC,17,5,145,68,BS_CENTER GROUPBOX "Tool bar",IDC_TOOLBAR_GB_STATIC,17,47,147,68,BS_CENTER
CONTROL "Hide",IDC_CHECK_HIDE,"Button",BS_AUTOCHECKBOX,24,15,94,10 CONTROL "Hide",IDC_CHECK_HIDE,"Button",BS_AUTOCHECKBOX,24,57,94,10
CONTROL "Small icons",IDC_RADIO_SMALLICON,"Button",BS_AUTORADIOBUTTON,24,29,114,10 CONTROL "Small icons",IDC_RADIO_SMALLICON,"Button",BS_AUTORADIOBUTTON,24,71,114,10
CONTROL "Big icons",IDC_RADIO_BIGICON,"Button",BS_AUTORADIOBUTTON,24,43,109,10 CONTROL "Big icons",IDC_RADIO_BIGICON,"Button",BS_AUTORADIOBUTTON,24,85,109,10
CONTROL "Small standard icons",IDC_RADIO_STANDARD,"Button",BS_AUTORADIOBUTTON,24,57,119,10 CONTROL "Small standard icons",IDC_RADIO_STANDARD,"Button",BS_AUTORADIOBUTTON,24,99,119,10
GROUPBOX "Tab bar",IDC_TABBAR_GB_STATIC,183,5,176,151,BS_CENTER GROUPBOX "Tab bar",IDC_TABBAR_GB_STATIC,183,6,176,151,BS_CENTER
CONTROL "Hide",IDC_CHECK_TAB_HIDE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,16,108,10 CONTROL "Hide",IDC_CHECK_TAB_HIDE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,16,108,10
CONTROL "Multi-Line",IDC_CHECK_TAB_MULTILINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,30,134,10 CONTROL "Multi-Line",IDC_CHECK_TAB_MULTILINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,30,134,10
CONTROL "Vertical",IDC_CHECK_TAB_VERTICAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,44,134,10 CONTROL "Vertical",IDC_CHECK_TAB_VERTICAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,44,134,10
@ -49,13 +49,13 @@ BEGIN
CONTROL "Lock (No Drag N Drop)",IDC_CHECK_LOCK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,73,134,10 CONTROL "Lock (No Drag N Drop)",IDC_CHECK_LOCK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,73,134,10
CONTROL "Draw the inactive tabs",IDC_CHECK_DRAWINACTIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,88,134,10 CONTROL "Draw the inactive tabs",IDC_CHECK_DRAWINACTIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,88,134,10
CONTROL "Draw the orange top bar",IDC_CHECK_ORANGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,103,133,10 CONTROL "Draw the orange top bar",IDC_CHECK_ORANGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,103,133,10
CONTROL "Enable close button on each tab",IDC_CHECK_ENABLETABCLOSE, CONTROL "Enable close button on each tab",IDC_CHECK_ENABLETABCLOSE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,118,133,10
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,118,133,10 CONTROL "Double click to close document",IDC_CHECK_DBCLICK2CLOSE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,133,133,10
CONTROL "Double click to close document",IDC_CHECK_DBCLICK2CLOSE, CONTROL "Show Status Bar",IDC_CHECK_SHOWSTATUSBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,163,130,10
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,133,133,10 GROUPBOX "Menu bar",IDC_MENUBAR_GB_STATIC,17,120,147,35,BS_CENTER
CONTROL "Show Status Bar",IDC_CHECK_SHOWSTATUSBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,140,130,10 CONTROL "Hide (Use Alt or F10 key to toggle it)",IDC_CHECK_HIDEMENUBAR,"Button",BS_AUTOCHECKBOX | BS_MULTILINE,24,127,135,25
GROUPBOX "Menu bar",IDC_MENUBAR_GB_STATIC,16,77,147,49,BS_CENTER GROUPBOX "Localization",IDC_LOCALIZATION_GB_STATIC,17,6,147,35,BS_CENTER
CONTROL "Hide (Use Alt or F10 key to toggle it)",IDC_CHECK_HIDEMENUBAR,"Button",BS_AUTOCHECKBOX | BS_MULTILINE,24,87,135,26 COMBOBOX IDC_COMBO_LOCALIZATION,28,20,119,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
END END
IDD_PREFERENCE_MARGEIN_BOX DIALOGEX 0, 0, 392, 185 IDD_PREFERENCE_MARGEIN_BOX DIALOGEX 0, 0, 392, 185

View File

@ -170,10 +170,14 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
::SendDlgItemMessage(_hSelf, IDC_CHECK_SHOWSTATUSBAR, BM_SETCHECK, showStatus, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_SHOWSTATUSBAR, BM_SETCHECK, showStatus, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_HIDEMENUBAR, BM_SETCHECK, !showMenu, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_HIDEMENUBAR, BM_SETCHECK, !showMenu, 0);
if (!nppGUI._doTaskList) #ifndef UNICODE
{ ::EnableWindow(::GetDlgItem(_hSelf, IDC_LOCALIZATION_GB_STATIC), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_STYLEMRU), FALSE); ::EnableWindow(::GetDlgItem(_hSelf, IDC_COMBO_LOCALIZATION), FALSE);
} #else
const vector<wstring> & localList = pNppParam->getLocalizationList();
for (size_t i = 0 ; i < localList.size() ; i++)
::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_ADDSTRING, 0, (LPARAM)localList[i].c_str());
#endif
ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture(); ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture();
if (enableDlgTheme) if (enableDlgTheme)

View File

@ -45,6 +45,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define IDC_CHECK_TAB_VERTICAL (IDD_PREFERENCE_BAR_BOX + 20) #define IDC_CHECK_TAB_VERTICAL (IDD_PREFERENCE_BAR_BOX + 20)
#define IDC_MENUBAR_GB_STATIC (IDD_PREFERENCE_BAR_BOX + 21) #define IDC_MENUBAR_GB_STATIC (IDD_PREFERENCE_BAR_BOX + 21)
#define IDC_CHECK_HIDEMENUBAR (IDD_PREFERENCE_BAR_BOX + 22) #define IDC_CHECK_HIDEMENUBAR (IDD_PREFERENCE_BAR_BOX + 22)
#define IDC_LOCALIZATION_GB_STATIC (IDD_PREFERENCE_BAR_BOX + 23)
#define IDC_COMBO_LOCALIZATION (IDD_PREFERENCE_BAR_BOX + 24)
#define IDD_PREFERENCE_MARGEIN_BOX 6200 //(IDD_PREFERENCE_BOX + 200) #define IDD_PREFERENCE_MARGEIN_BOX 6200 //(IDD_PREFERENCE_BOX + 200)
#define IDC_FMS_GB_STATIC (IDD_PREFERENCE_MARGEIN_BOX + 1) #define IDC_FMS_GB_STATIC (IDD_PREFERENCE_MARGEIN_BOX + 1)

View File

@ -601,22 +601,27 @@ void ScintillaAccelerator::init(vector<HWND> * vScintillas, HMENU hMenu, HWND me
_nrScintillas = (int)nr; _nrScintillas = (int)nr;
} }
void ScintillaAccelerator::updateKeys() { void ScintillaAccelerator::updateKeys()
{
NppParameters *pNppParam = NppParameters::getInstance(); NppParameters *pNppParam = NppParameters::getInstance();
vector<ScintillaKeyMap> & map = pNppParam->getScintillaKeyList(); vector<ScintillaKeyMap> & map = pNppParam->getScintillaKeyList();
size_t mapSize = map.size(); size_t mapSize = map.size();
size_t index; size_t index;
for(int i = 0; i < _nrScintillas; i++) { for(int i = 0; i < _nrScintillas; i++)
{
::SendMessage(_vScintillas[i], SCI_CLEARALLCMDKEYS, 0, 0); ::SendMessage(_vScintillas[i], SCI_CLEARALLCMDKEYS, 0, 0);
for(size_t j = mapSize - 1; j >= 0; j--) { //reverse order, top of the list has highest priority for(size_t j = mapSize - 1; j >= 0; j--) //reverse order, top of the list has highest priority
{
ScintillaKeyMap skm = map[j]; ScintillaKeyMap skm = map[j];
if (skm.isEnabled()) { //no validating, scintilla accepts more keys if (skm.isEnabled())
{ //no validating, scintilla accepts more keys
size_t size = skm.getSize(); size_t size = skm.getSize();
for(index = 0; index < size; index++) for(index = 0; index < size; index++)
::SendMessage(_vScintillas[i], SCI_ASSIGNCMDKEY, skm.toKeyDef(index), skm.getScintillaKeyID()); ::SendMessage(_vScintillas[i], SCI_ASSIGNCMDKEY, skm.toKeyDef(index), skm.getScintillaKeyID());
} }
if (skm.getMenuCmdID() != 0) { if (skm.getMenuCmdID() != 0)
{
updateMenuItemByID(skm, skm.getMenuCmdID()); updateMenuItemByID(skm, skm.getMenuCmdID());
} }
if (j == 0) //j is unsigned, so default method doesnt work if (j == 0) //j is unsigned, so default method doesnt work
@ -625,30 +630,25 @@ void ScintillaAccelerator::updateKeys() {
} }
} }
void ScintillaAccelerator::updateKey(ScintillaKeyMap skmOld, ScintillaKeyMap skmNew) { void ScintillaAccelerator::updateMenuItemByID(ScintillaKeyMap skm, int id)
updateKeys(); //do a full update, double mappings can make this work badly {
return;
//for(int i = 0; i < _nrScintillas; i++) {
// ::SendMessage(_vScintillas[i], SCI_CLEARCMDKEY, skmOld.toKeyDef(0), 0);
// ::SendMessage(_vScintillas[i], SCI_ASSIGNCMDKEY, skmNew.toKeyDef(0), skmNew.getScintillaKeyID());
//}
}
void ScintillaAccelerator::updateMenuItemByID(ScintillaKeyMap skm, int id) {
NppParameters *pNppParam = NppParameters::getInstance(); NppParameters *pNppParam = NppParameters::getInstance();
const int commandSize = 64; const int commandSize = 64;
TCHAR cmdName[commandSize]; TCHAR cmdName[commandSize];
::GetMenuString(_hAccelMenu, id, cmdName, commandSize, MF_BYCOMMAND); ::GetMenuString(_hAccelMenu, id, cmdName, commandSize, MF_BYCOMMAND);
int i = 0; int i = 0;
while(cmdName[i] != 0) { while(cmdName[i] != 0)
if (cmdName[i] == '\t') { {
if (cmdName[i] == '\t')
{
cmdName[i] = 0; cmdName[i] = 0;
break; break;
} }
i++; i++;
} }
generic_string menuItem = cmdName; generic_string menuItem = cmdName;
if (skm.isEnabled()) { if (skm.isEnabled())
{
menuItem += TEXT("\t"); menuItem += TEXT("\t");
//menuItem += TEXT("Sc:"); //sc: scintilla shortcut //menuItem += TEXT("Sc:"); //sc: scintilla shortcut
menuItem += skm.toString(); menuItem += skm.toString();

View File

@ -346,6 +346,8 @@ public:
HACCEL getAccTable() const {return _hAccTable;}; HACCEL getAccTable() const {return _hAccTable;};
void updateShortcuts(); void updateShortcuts();
void updateFullMenu();
private: private:
HMENU _hAccelMenu; HMENU _hAccelMenu;
HWND _hMenuParent; HWND _hMenuParent;
@ -358,7 +360,6 @@ private:
::DestroyAcceleratorTable(_hAccTable); ::DestroyAcceleratorTable(_hAccTable);
_hAccTable = ::CreateAcceleratorTable(_pAccelArray, _nbAccelItems); _hAccTable = ::CreateAcceleratorTable(_pAccelArray, _nbAccelItems);
}; };
void updateFullMenu();
void updateMenuItemByCommand(CommandShortcut csc); void updateMenuItemByCommand(CommandShortcut csc);
}; };

View File

@ -627,6 +627,10 @@
RelativePath="..\src\resource.h" RelativePath="..\src\resource.h"
> >
</File> </File>
<File
RelativePath="..\src\WinControls\Preference\resource.h"
>
</File>
<File <File
RelativePath="..\src\WinControls\StaticDialog\RunDlg\RunDlg.h" RelativePath="..\src\WinControls\StaticDialog\RunDlg\RunDlg.h"
> >