Enhance Shortcut Mapper and make it translatable
This commit is contained in:
parent
70f7287e58
commit
fb17638de7
@ -447,6 +447,31 @@
|
||||
<Item id="2232" name="啟用共用底線字"/>
|
||||
</SubDialog>
|
||||
</StyleConfig>
|
||||
<ShortcutMapper title="快速鍵管理">
|
||||
<Item id="2602" name="修改"/>
|
||||
<Item id="2603" name="刪除"/>
|
||||
<Item id="2606" name="清除"/>
|
||||
<Item id="1" name="關閉"/>
|
||||
<ColumnName name="名稱"/>
|
||||
<ColumnShortcut name="快速鍵"/>
|
||||
<ColumnCategory name="類別"/>
|
||||
<ColumnPlugin name="外掛"/>
|
||||
<MainMenuTab name="主選單"/>
|
||||
<MacrosTab name="巨集"/>
|
||||
<RunCommandsTab name="自訂指令"/>
|
||||
<PluginCommandsTab name="外掛指令"/>
|
||||
<ScintillaCommandsTab name="Scintilla 指令"/>
|
||||
</ShortcutMapper>
|
||||
<ShortcutMapperSubDialg title="快速鍵設定">
|
||||
<Item id="1" name="確認"/>
|
||||
<Item id="2" name="取消"/>
|
||||
<Item id="5006" name="名稱"/>
|
||||
<Item id="5008" name="增加"/>
|
||||
<Item id="5009" name="移除"/>
|
||||
<Item id="5010" name="套用"/>
|
||||
<Item id="5007" name="這將會移除快速鍵"/>
|
||||
<Item id="5012" name="快速鍵重複定義"/>
|
||||
</ShortcutMapperSubDialg>
|
||||
<UserDefine title="自訂程式語言">
|
||||
<Item id="20001" name="停靠面板"/>
|
||||
<Item id="20002" name="重新命名"/>
|
||||
|
@ -446,9 +446,33 @@
|
||||
<Item id="2231" name="Enable global italic font style"/>
|
||||
<Item id="2232" name="Enable global underline font style"/>
|
||||
</SubDialog>
|
||||
|
||||
</StyleConfig>
|
||||
|
||||
<ShortcutMapper title="Shortcut Mapper">
|
||||
<Item id="2602" name="Modify"/>
|
||||
<Item id="2603" name="Delete"/>
|
||||
<Item id="2606" name="Clear"/>
|
||||
<Item id="1" name="Close"/>
|
||||
<ColumnName name="Name"/>
|
||||
<ColumnShortcut name="Shortcut"/>
|
||||
<ColumnCategory name="Category"/>
|
||||
<ColumnPlugin name="Plugin"/>
|
||||
<MainMenuTab name="Main menu"/>
|
||||
<MacrosTab name="Macros"/>
|
||||
<RunCommandsTab name="Run commands"/>
|
||||
<PluginCommandsTab name="Plugin commands"/>
|
||||
<ScintillaCommandsTab name="Scintilla commands"/>
|
||||
</ShortcutMapper>
|
||||
<ShortcutMapperSubDialg title="Shortcut">
|
||||
<Item id="1" name="OK"/>
|
||||
<Item id="2" name="Cancel"/>
|
||||
<Item id="5006" name="Name"/>
|
||||
<Item id="5008" name="Add"/>
|
||||
<Item id="5009" name="Remove"/>
|
||||
<Item id="5010" name="Apply"/>
|
||||
<Item id="5007" name="This will remove the accelerator"/>
|
||||
<Item id="5012" name="CONFLICT FOUND!"/>
|
||||
</ShortcutMapperSubDialg>
|
||||
<UserDefine title="User-Defined">
|
||||
<Item id="20001" name="Dock"/>
|
||||
<Item id="20002" name="Rename"/>
|
||||
@ -987,6 +1011,7 @@ Do you want to continue?"/>
|
||||
<UDLNewNameError title="UDL Error" message="This name is used by another language,
|
||||
please give another one."/>
|
||||
<UDLRemoveCurrentLang title="Remove the current language" message="Are you sure?"/>
|
||||
<SCMapperDoDeleteOrNot title="Are you sure?" message="Are you sure you want to delete this shortcut?"/>
|
||||
<FindCharRangeValueError title="Range Value problem" message="You should type between from 0 to 255."/>
|
||||
</MessageBox>
|
||||
<ClipboardHistory>
|
||||
|
@ -2458,7 +2458,6 @@ void Notepad_plus::command(int id)
|
||||
GridState st = id==IDM_SETTING_SHORTCUT_MAPPER_MACRO?STATE_MACRO:id==IDM_SETTING_SHORTCUT_MAPPER_RUN?STATE_USER:STATE_MENU;
|
||||
ShortcutMapper shortcutMapper;
|
||||
shortcutMapper.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), st);
|
||||
_nativeLangSpeaker.changeShortcutmapperLang(&shortcutMapper);
|
||||
shortcutMapper.doDialog(_nativeLangSpeaker.isRTL());
|
||||
shortcutMapper.destroy();
|
||||
break;
|
||||
|
@ -29,28 +29,22 @@
|
||||
#include "ShortcutMapper.h"
|
||||
#include "Notepad_plus.h"
|
||||
|
||||
#ifdef UNICODE
|
||||
#define numToStr std::to_wstring
|
||||
#else
|
||||
#define numToStr std::to_string
|
||||
#endif //UNICODE
|
||||
|
||||
using namespace std;
|
||||
|
||||
void ShortcutMapper::initTabs() {
|
||||
void ShortcutMapper::initTabs()
|
||||
{
|
||||
HWND hTab = _hTabCtrl = ::GetDlgItem(_hSelf, IDC_BABYGRID_TABBAR);
|
||||
TCITEM tie;
|
||||
tie.mask = TCIF_TEXT;
|
||||
tie.pszText = tabNames[0];
|
||||
::SendMessage(hTab, TCM_INSERTITEM, 0, reinterpret_cast<LPARAM>(&tie));
|
||||
tie.pszText = tabNames[1];
|
||||
::SendMessage(hTab, TCM_INSERTITEM, 1, reinterpret_cast<LPARAM>(&tie));
|
||||
tie.pszText = tabNames[2];
|
||||
::SendMessage(hTab, TCM_INSERTITEM, 2, reinterpret_cast<LPARAM>(&tie));
|
||||
tie.pszText = tabNames[3];
|
||||
::SendMessage(hTab, TCM_INSERTITEM, 3, reinterpret_cast<LPARAM>(&tie));
|
||||
tie.pszText = tabNames[4];
|
||||
::SendMessage(hTab, TCM_INSERTITEM, 4, reinterpret_cast<LPARAM>(&tie));
|
||||
|
||||
for (size_t i = 0; i < _nbTab; ++i)
|
||||
{
|
||||
_tabNames[i] = getTabString(i);
|
||||
|
||||
tie.pszText = const_cast<LPWSTR>(_tabNames[i].c_str());
|
||||
::SendMessage(hTab, TCM_INSERTITEM, i, reinterpret_cast<LPARAM>(&tie));
|
||||
}
|
||||
|
||||
TabCtrl_SetCurSel(_hTabCtrl, int(_currentState));
|
||||
|
||||
@ -78,10 +72,29 @@ void ShortcutMapper::getClientRect(RECT & rc) const
|
||||
rc.right -= NppParameters::getInstance()->_dpiManager.scaleX(5);
|
||||
}
|
||||
|
||||
void ShortcutMapper::translateTab(int index, const TCHAR * newname) {
|
||||
if (index < 0 || index > 4)
|
||||
return;
|
||||
generic_strncpy(tabNames[index], newname, maxTabName);
|
||||
generic_string ShortcutMapper::getTabString(size_t i) const
|
||||
{
|
||||
if (i >= _nbTab)
|
||||
return TEXT("");
|
||||
|
||||
NativeLangSpeaker* nativeLangSpeaker = NppParameters::getInstance()->getNativeLangSpeaker();
|
||||
switch (i)
|
||||
{
|
||||
case 1:
|
||||
return nativeLangSpeaker->getShortcutMapperLangStr("MacrosTab", TEXT("Macros"));
|
||||
|
||||
case 2:
|
||||
return nativeLangSpeaker->getShortcutMapperLangStr("RunCommandsTab", TEXT("Run commands"));
|
||||
|
||||
case 3:
|
||||
return nativeLangSpeaker->getShortcutMapperLangStr("PluginCommandsTab", TEXT("Plugin commands"));
|
||||
|
||||
case 4:
|
||||
return nativeLangSpeaker->getShortcutMapperLangStr("ScintillaCommandsTab", TEXT("Scintilla commands"));
|
||||
|
||||
default: //0
|
||||
return nativeLangSpeaker->getShortcutMapperLangStr("MainMenuTab", TEXT("Main menu"));
|
||||
}
|
||||
}
|
||||
|
||||
void ShortcutMapper::initBabyGrid() {
|
||||
@ -122,6 +135,8 @@ void ShortcutMapper::initBabyGrid() {
|
||||
_babygrid.setProtectColor(RGB(255,130,120));
|
||||
_babygrid.setHighlightColorProtect(RGB(244,10,20));
|
||||
_babygrid.setHighlightColorProtectNoFocus(RGB(230,194,190));
|
||||
|
||||
NppParameters::getInstance()->getNativeLangSpeaker()->changeDlgLang(_hSelf, "ShortcutMapper");
|
||||
}
|
||||
|
||||
void ShortcutMapper::fillOutBabyGrid()
|
||||
@ -131,57 +146,82 @@ void ShortcutMapper::fillOutBabyGrid()
|
||||
_babygrid.setInitialContent(true);
|
||||
|
||||
size_t nbItems = 0;
|
||||
NativeLangSpeaker* nativeLangSpeaker = nppParam->getNativeLangSpeaker();
|
||||
generic_string nameStr = nativeLangSpeaker->getShortcutMapperLangStr("ColumnName", TEXT("Name"));
|
||||
generic_string shortcutStr = nativeLangSpeaker->getShortcutMapperLangStr("ColumnShortcut", TEXT("Shortcut"));
|
||||
|
||||
_babygrid.setText(0, 1, TEXT("Name"));
|
||||
_babygrid.setText(0, 2, TEXT("Shortcut"));
|
||||
_babygrid.setText(0, 1, nameStr.c_str());
|
||||
_babygrid.setText(0, 2, shortcutStr.c_str());
|
||||
|
||||
switch(_currentState) {
|
||||
case STATE_MENU: {
|
||||
switch(_currentState)
|
||||
{
|
||||
case STATE_MENU:
|
||||
{
|
||||
nbItems = nppParam->getUserShortcuts().size();
|
||||
_babygrid.setLineColNumber(nbItems, 3);
|
||||
_babygrid.setText(0, 3, TEXT("Category"));
|
||||
break; }
|
||||
case STATE_MACRO: {
|
||||
generic_string categoryStr = nativeLangSpeaker->getShortcutMapperLangStr("ColumnCategory", TEXT("Category"));
|
||||
_babygrid.setText(0, 3, categoryStr.c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_MACRO:
|
||||
{
|
||||
nbItems = nppParam->getMacroList().size();
|
||||
_babygrid.setLineColNumber(nbItems, 2);
|
||||
break; }
|
||||
case STATE_USER: {
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_USER:
|
||||
{
|
||||
nbItems = nppParam->getUserCommandList().size();
|
||||
_babygrid.setLineColNumber(nbItems, 2);
|
||||
break; }
|
||||
case STATE_PLUGIN: {
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_PLUGIN:
|
||||
{
|
||||
nbItems = nppParam->getPluginCommandList().size();
|
||||
_babygrid.setLineColNumber(nbItems, 3);
|
||||
_babygrid.setText(0, 3, TEXT("Plugin"));
|
||||
break; }
|
||||
case STATE_SCINTILLA: {
|
||||
generic_string pluginStr = nativeLangSpeaker->getShortcutMapperLangStr("ColumnPlugin", TEXT("Plugin"));
|
||||
_babygrid.setText(0, 3, pluginStr.c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_SCINTILLA:
|
||||
{
|
||||
nbItems = nppParam->getScintillaKeyList().size();
|
||||
_babygrid.setLineColNumber(nbItems, 2);
|
||||
break; }
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
bool isMarker = false;
|
||||
|
||||
switch(_currentState) {
|
||||
case STATE_MENU: {
|
||||
switch(_currentState)
|
||||
{
|
||||
case STATE_MENU:
|
||||
{
|
||||
vector<CommandShortcut> & cshortcuts = nppParam->getUserShortcuts();
|
||||
for(size_t i = 0; i < nbItems; ++i)
|
||||
for (size_t i = 0; i < nbItems; ++i)
|
||||
{
|
||||
if (findKeyConflicts(nullptr, cshortcuts[i].getKeyCombo(), i))
|
||||
isMarker = _babygrid.setMarker(true);
|
||||
|
||||
_babygrid.setText(i+1, 1, cshortcuts[i].getName());
|
||||
_babygrid.setText(i + 1, 1, cshortcuts[i].getName());
|
||||
if (cshortcuts[i].isEnabled()) //avoid empty strings for better performance
|
||||
_babygrid.setText(i+1, 2, cshortcuts[i].toString().c_str());
|
||||
_babygrid.setText(i+1, 3, cshortcuts[i].getCategory());
|
||||
_babygrid.setText(i + 1, 2, cshortcuts[i].toString().c_str());
|
||||
_babygrid.setText(i + 1, 3, cshortcuts[i].getCategory());
|
||||
if (isMarker)
|
||||
isMarker = _babygrid.setMarker(false);
|
||||
}
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), true);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), true);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
|
||||
break; }
|
||||
case STATE_MACRO: {
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_MACRO:
|
||||
{
|
||||
vector<MacroShortcut> & cshortcuts = nppParam->getMacroList();
|
||||
for(size_t i = 0; i < nbItems; ++i)
|
||||
{
|
||||
@ -199,8 +239,11 @@ void ShortcutMapper::fillOutBabyGrid()
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), shouldBeEnabled);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), shouldBeEnabled);
|
||||
break; }
|
||||
case STATE_USER: {
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_USER:
|
||||
{
|
||||
vector<UserCommand> & cshortcuts = nppParam->getUserCommandList();
|
||||
for(size_t i = 0; i < nbItems; ++i)
|
||||
{
|
||||
@ -218,8 +261,11 @@ void ShortcutMapper::fillOutBabyGrid()
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), shouldBeEnabled);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), shouldBeEnabled);
|
||||
break; }
|
||||
case STATE_PLUGIN: {
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_PLUGIN:
|
||||
{
|
||||
vector<PluginCmdShortcut> & cshortcuts = nppParam->getPluginCommandList();
|
||||
for(size_t i = 0; i < nbItems; ++i)
|
||||
{
|
||||
@ -238,8 +284,11 @@ void ShortcutMapper::fillOutBabyGrid()
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), shouldBeEnabled);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
|
||||
break; }
|
||||
case STATE_SCINTILLA: {
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_SCINTILLA:
|
||||
{
|
||||
vector<ScintillaKeyMap> & cshortcuts = nppParam->getScintillaKeyList();
|
||||
for(size_t i = 0; i < nbItems; ++i)
|
||||
{
|
||||
@ -266,14 +315,15 @@ void ShortcutMapper::fillOutBabyGrid()
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), true);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), false);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
|
||||
break; }
|
||||
}
|
||||
if (nbItems > 0)
|
||||
//restore the last view
|
||||
break;
|
||||
}
|
||||
|
||||
if (nbItems > 0) //restore the last view
|
||||
_babygrid.setLastView(_lastHomeRow[_currentState], _lastCursorRow[_currentState]);
|
||||
else
|
||||
//clear the info area
|
||||
else //clear the info area
|
||||
::SendDlgItemMessage(_hSelf, IDC_BABYGRID_INFO, WM_SETTEXT, 0, 0);
|
||||
|
||||
_babygrid.setInitialContent(false);
|
||||
}
|
||||
|
||||
@ -295,32 +345,42 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
{
|
||||
for (const HFONT & hFont : _hGridFonts)
|
||||
::DeleteObject(hFont);
|
||||
|
||||
_hGridFonts.clear();
|
||||
_hGridFonts.shrink_to_fit();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NOTIFY: {
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
NMHDR nmh = *((NMHDR*)lParam);
|
||||
if (nmh.hwndFrom == _hTabCtrl) {
|
||||
if (nmh.code == TCN_SELCHANGE) {
|
||||
if (nmh.hwndFrom == _hTabCtrl)
|
||||
{
|
||||
if (nmh.code == TCN_SELCHANGE)
|
||||
{
|
||||
//save the current view
|
||||
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||
_lastCursorRow[_currentState] = _babygrid.getSelectedRow();
|
||||
int index = TabCtrl_GetCurSel(_hTabCtrl);
|
||||
switch (index) {
|
||||
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
_currentState = STATE_MENU;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
_currentState = STATE_MACRO;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
_currentState = STATE_USER;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
_currentState = STATE_PLUGIN;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
_currentState = STATE_SCINTILLA;
|
||||
break;
|
||||
@ -328,7 +388,8 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
fillOutBabyGrid();
|
||||
}
|
||||
}
|
||||
break; }
|
||||
}
|
||||
break;
|
||||
|
||||
case NPPM_INTERNAL_FINDKEYCONFLICTS:
|
||||
{
|
||||
@ -339,6 +400,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
|
||||
const bool isConflict = findKeyConflicts(&conflictInfo, *reinterpret_cast<KeyCombo*>(wParam), _babygrid.getSelectedRow() - 1);
|
||||
*reinterpret_cast<bool*>(lParam) = isConflict;
|
||||
|
||||
if (isConflict)
|
||||
::SendDlgItemMessage(_hSelf, IDC_BABYGRID_INFO, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(conflictInfo.c_str()));
|
||||
else
|
||||
@ -381,7 +443,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
csc.clear();
|
||||
shortcuts[row - 1] = csc;
|
||||
//shortcut was altered
|
||||
nppParam->addUserModifiedIndex(row-1);
|
||||
nppParam->addUserModifiedIndex(row - 1);
|
||||
|
||||
//save the current view
|
||||
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||
@ -393,8 +455,9 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
//Notify current Accelerator class to update everything
|
||||
nppParam->getAccelerator()->updateShortcuts();
|
||||
nppParam->setShortcutDirty();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_MACRO:
|
||||
{
|
||||
//Get MacroShortcut corresponding to row
|
||||
@ -412,8 +475,9 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
//Notify current Accelerator class to update everything
|
||||
nppParam->getAccelerator()->updateShortcuts();
|
||||
nppParam->setShortcutDirty();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_USER:
|
||||
{
|
||||
//Get UserCommand corresponding to row
|
||||
@ -434,8 +498,9 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
//Notify current Accelerator class to update everything
|
||||
nppParam->getAccelerator()->updateShortcuts();
|
||||
nppParam->setShortcutDirty();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_PLUGIN:
|
||||
{
|
||||
//Get PluginCmdShortcut corresponding to row
|
||||
@ -443,7 +508,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
PluginCmdShortcut pcsc = shortcuts[row - 1];
|
||||
pcsc.clear();
|
||||
//shortcut was altered
|
||||
nppParam->addPluginModifiedIndex(row-1);
|
||||
nppParam->addPluginModifiedIndex(row - 1);
|
||||
shortcuts[row - 1] = pcsc;
|
||||
|
||||
//save the current view
|
||||
@ -464,18 +529,23 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
|
||||
::SendMessage(_hParent, NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED, cmdID, reinterpret_cast<LPARAM>(&shortcut));
|
||||
nppParam->setShortcutDirty();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_SCINTILLA:
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (not isModified)
|
||||
::SendMessage(_hSelf, WM_COMMAND, MAKEWPARAM(IDD_BABYGRID_ID1, BGN_ROWCHANGED), row);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case IDM_BABYGRID_MODIFY :
|
||||
{
|
||||
if (_babygrid.getNumberRows() < 1)
|
||||
@ -496,7 +566,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
if (csc.doDialog() != -1 && prevcsc != csc)
|
||||
{
|
||||
//shortcut was altered
|
||||
nppParam->addUserModifiedIndex(row-1);
|
||||
nppParam->addUserModifiedIndex(row - 1);
|
||||
shortcuts[row - 1] = csc;
|
||||
|
||||
//save the current view
|
||||
@ -510,8 +580,8 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
nppParam->getAccelerator()->updateShortcuts();
|
||||
nppParam->setShortcutDirty();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_MACRO:
|
||||
{
|
||||
@ -535,8 +605,8 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
nppParam->getAccelerator()->updateShortcuts();
|
||||
nppParam->setShortcutDirty();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_USER:
|
||||
{
|
||||
@ -561,8 +631,8 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
nppParam->getAccelerator()->updateShortcuts();
|
||||
nppParam->setShortcutDirty();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_PLUGIN:
|
||||
{
|
||||
@ -574,7 +644,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
if (pcsc.doDialog() != -1 && prevpcsc != pcsc)
|
||||
{
|
||||
//shortcut was altered
|
||||
nppParam->addPluginModifiedIndex(row-1);
|
||||
nppParam->addPluginModifiedIndex(row - 1);
|
||||
shortcuts[row - 1] = pcsc;
|
||||
|
||||
//save the current view
|
||||
@ -596,20 +666,20 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
::SendMessage(_hParent, NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED, cmdID, reinterpret_cast<LPARAM>(&shortcut));
|
||||
nppParam->setShortcutDirty();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_SCINTILLA:
|
||||
{
|
||||
//Get ScintillaKeyMap corresponding to row
|
||||
vector<ScintillaKeyMap> & shortcuts = nppParam->getScintillaKeyList();
|
||||
ScintillaKeyMap skm = shortcuts[row - 1], prevskm = shortcuts[row-1];
|
||||
ScintillaKeyMap skm = shortcuts[row - 1], prevskm = shortcuts[row - 1];
|
||||
skm.init(_hInst, _hSelf);
|
||||
if (skm.doDialog() != -1 && prevskm != skm)
|
||||
{
|
||||
//shortcut was altered
|
||||
nppParam->addScintillaModifiedIndex(row-1);
|
||||
shortcuts[row-1] = skm;
|
||||
nppParam->addScintillaModifiedIndex(row - 1);
|
||||
shortcuts[row - 1] = skm;
|
||||
|
||||
//save the current view
|
||||
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||
@ -623,11 +693,13 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
nppParam->getScintillaAccelerator()->updateKeys();
|
||||
nppParam->setShortcutDirty();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (not isModified)
|
||||
::SendMessage(_hSelf, WM_COMMAND, MAKEWPARAM(IDD_BABYGRID_ID1, BGN_ROWCHANGED), row);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -636,9 +708,15 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
if (_babygrid.getNumberRows() < 1)
|
||||
return TRUE;
|
||||
|
||||
if (::MessageBox(_hSelf, TEXT("Are you sure you want to delete this shortcut?"), TEXT("Are you sure?"), MB_OKCANCEL) == IDOK)
|
||||
{
|
||||
NppParameters *nppParam = NppParameters::getInstance();
|
||||
int res = nppParam->getNativeLangSpeaker()->messageBox("SCMapperDoDeleteOrNot",
|
||||
_hSelf,
|
||||
TEXT("Are you sure you want to delete this shortcut?"),
|
||||
TEXT("Are you sure?"),
|
||||
MB_OKCANCEL);
|
||||
|
||||
if (res == IDOK)
|
||||
{
|
||||
const int row = _babygrid.getSelectedRow();
|
||||
int shortcutIndex = row-1;
|
||||
DWORD cmdID = 0;
|
||||
@ -682,14 +760,14 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
HMENU m = reinterpret_cast<HMENU>(::SendMessage(_hParent, NPPM_INTERNAL_GETMENU, 0, 0));
|
||||
hMenu = ::GetSubMenu(m, MENUINDEX_MACRO);
|
||||
modifCmd = IDM_SETTING_SHORTCUT_MAPPER_MACRO;
|
||||
for (size_t i = shortcutIndex ; i < nbElem ; ++i) //lower the IDs of the remaining items so there are no gaps
|
||||
for (size_t i = shortcutIndex; i < nbElem; ++i) //lower the IDs of the remaining items so there are no gaps
|
||||
{
|
||||
MacroShortcut ms = theMacros[i];
|
||||
ms.setID(ms.getID() - 1); //shift all IDs
|
||||
theMacros[i] = ms;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_USER:
|
||||
{
|
||||
@ -716,14 +794,14 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
HMENU m = reinterpret_cast<HMENU>(::SendMessage(_hParent, NPPM_INTERNAL_GETMENU, 0, 0));
|
||||
hMenu = ::GetSubMenu(m, MENUINDEX_RUN);
|
||||
modifCmd = IDM_SETTING_SHORTCUT_MAPPER_RUN;
|
||||
for (size_t i = shortcutIndex ; i < nbElem ; ++i) //lower the IDs of the remaining items so there are no gaps
|
||||
for (size_t i = shortcutIndex; i < nbElem; ++i) //lower the IDs of the remaining items so there are no gaps
|
||||
{
|
||||
UserCommand uc = theUserCmds[i];
|
||||
uc.setID(uc.getID() - 1); //shift all IDs
|
||||
theUserCmds[i] = uc;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// updateShortcuts() will update all menu item - the menu items will be shifted
|
||||
@ -781,16 +859,23 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
_rightClickMenu.enableItem(IDM_BABYGRID_CLEAR, false);
|
||||
else
|
||||
_rightClickMenu.enableItem(IDM_BABYGRID_CLEAR, true);
|
||||
switch(_currentState) {
|
||||
|
||||
switch(_currentState)
|
||||
{
|
||||
case STATE_MACRO:
|
||||
case STATE_USER: {
|
||||
case STATE_USER:
|
||||
{
|
||||
_rightClickMenu.enableItem(IDM_BABYGRID_DELETE, true);
|
||||
break; }
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_MENU:
|
||||
case STATE_PLUGIN:
|
||||
case STATE_SCINTILLA: {
|
||||
case STATE_SCINTILLA:
|
||||
{
|
||||
_rightClickMenu.enableItem(IDM_BABYGRID_DELETE, false);
|
||||
break; }
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -824,34 +909,38 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
{
|
||||
vector<CommandShortcut> & vShortcuts = nppParam->getUserShortcuts();
|
||||
findKeyConflicts(&conflictInfo, vShortcuts[currentIndex].getKeyCombo(), currentIndex);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_MACRO:
|
||||
{
|
||||
vector<MacroShortcut> & vShortcuts = nppParam->getMacroList();
|
||||
findKeyConflicts(&conflictInfo, vShortcuts[currentIndex].getKeyCombo(), currentIndex);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_USER:
|
||||
{
|
||||
vector<UserCommand> & vShortcuts = nppParam->getUserCommandList();
|
||||
findKeyConflicts(&conflictInfo, vShortcuts[currentIndex].getKeyCombo(), currentIndex);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_PLUGIN:
|
||||
{
|
||||
vector<PluginCmdShortcut> & vShortcuts = nppParam->getPluginCommandList();
|
||||
findKeyConflicts(&conflictInfo, vShortcuts[currentIndex].getKeyCombo(), currentIndex);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_SCINTILLA:
|
||||
{
|
||||
vector<ScintillaKeyMap> & vShortcuts = nppParam->getScintillaKeyList();
|
||||
size_t sciCombos = vShortcuts[currentIndex].getSize();
|
||||
for (size_t sciIndex = 0; sciIndex < sciCombos; ++sciIndex)
|
||||
findKeyConflicts(&conflictInfo, vShortcuts[currentIndex].getKeyComboByIndex(sciIndex), currentIndex);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (conflictInfo.empty())
|
||||
@ -861,13 +950,16 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
} //switch (HIWORD(wParam))
|
||||
}
|
||||
} //switch (LOWORD(wParam))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
} //switch (message)
|
||||
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -905,9 +997,9 @@ bool ShortcutMapper::findKeyConflicts(__inout_opt generic_string * const keyConf
|
||||
{
|
||||
if (not keyConflictLocation->empty())
|
||||
*keyConflictLocation += TEXT("\r\n");
|
||||
*keyConflictLocation += tabNames[gridState];
|
||||
*keyConflictLocation += _tabNames[gridState];
|
||||
*keyConflictLocation += TEXT(" | ");
|
||||
*keyConflictLocation += numToStr(itemIndex + 1);
|
||||
*keyConflictLocation += std::to_wstring(itemIndex + 1);
|
||||
*keyConflictLocation += TEXT(" ");
|
||||
*keyConflictLocation += vShortcuts[itemIndex].getName();
|
||||
*keyConflictLocation += TEXT(" ( ");
|
||||
@ -939,9 +1031,9 @@ bool ShortcutMapper::findKeyConflicts(__inout_opt generic_string * const keyConf
|
||||
{
|
||||
if (not keyConflictLocation->empty())
|
||||
*keyConflictLocation += TEXT("\r\n");
|
||||
*keyConflictLocation += tabNames[gridState];
|
||||
*keyConflictLocation += _tabNames[gridState];
|
||||
*keyConflictLocation += TEXT(" | ");
|
||||
*keyConflictLocation += numToStr(itemIndex + 1);
|
||||
*keyConflictLocation += std::to_wstring(itemIndex + 1);
|
||||
*keyConflictLocation += TEXT(" ");
|
||||
*keyConflictLocation += vShortcuts[itemIndex].getName();
|
||||
*keyConflictLocation += TEXT(" ( ");
|
||||
@ -973,9 +1065,9 @@ bool ShortcutMapper::findKeyConflicts(__inout_opt generic_string * const keyConf
|
||||
{
|
||||
if (not keyConflictLocation->empty())
|
||||
*keyConflictLocation += TEXT("\r\n");
|
||||
*keyConflictLocation += tabNames[gridState];
|
||||
*keyConflictLocation += _tabNames[gridState];
|
||||
*keyConflictLocation += TEXT(" | ");
|
||||
*keyConflictLocation += numToStr(itemIndex + 1);
|
||||
*keyConflictLocation += std::to_wstring(itemIndex + 1);
|
||||
*keyConflictLocation += TEXT(" ");
|
||||
*keyConflictLocation += vShortcuts[itemIndex].getName();
|
||||
*keyConflictLocation += TEXT(" ( ");
|
||||
@ -1007,9 +1099,9 @@ bool ShortcutMapper::findKeyConflicts(__inout_opt generic_string * const keyConf
|
||||
{
|
||||
if (not keyConflictLocation->empty())
|
||||
*keyConflictLocation += TEXT("\r\n");
|
||||
*keyConflictLocation += tabNames[gridState];
|
||||
*keyConflictLocation += _tabNames[gridState];
|
||||
*keyConflictLocation += TEXT(" | ");
|
||||
*keyConflictLocation += numToStr(itemIndex + 1);
|
||||
*keyConflictLocation += std::to_wstring(itemIndex + 1);
|
||||
*keyConflictLocation += TEXT(" ");
|
||||
*keyConflictLocation += vShortcuts[itemIndex].getName();
|
||||
*keyConflictLocation += TEXT(" ( ");
|
||||
@ -1044,9 +1136,9 @@ bool ShortcutMapper::findKeyConflicts(__inout_opt generic_string * const keyConf
|
||||
{
|
||||
if (not keyConflictLocation->empty())
|
||||
*keyConflictLocation += TEXT("\r\n");
|
||||
*keyConflictLocation += tabNames[gridState];
|
||||
*keyConflictLocation += _tabNames[gridState];
|
||||
*keyConflictLocation += TEXT(" | ");
|
||||
*keyConflictLocation += numToStr(itemIndex + 1);
|
||||
*keyConflictLocation += std::to_wstring(itemIndex + 1);
|
||||
if (sciIndex > 0)
|
||||
*keyConflictLocation += TEXT("* ");
|
||||
else
|
||||
@ -1060,8 +1152,8 @@ bool ShortcutMapper::findKeyConflicts(__inout_opt generic_string * const keyConf
|
||||
}
|
||||
}
|
||||
break;
|
||||
} //case STATE_SCINTILLA
|
||||
} //switch (gridState)
|
||||
} //for (...)
|
||||
}
|
||||
}
|
||||
}
|
||||
return retIsConflict;
|
||||
}
|
||||
|
@ -37,13 +37,7 @@ enum GridState {STATE_MENU, STATE_MACRO, STATE_USER, STATE_PLUGIN, STATE_SCINTIL
|
||||
|
||||
class ShortcutMapper : public StaticDialog {
|
||||
public:
|
||||
ShortcutMapper() : _currentState(STATE_MENU), StaticDialog() {
|
||||
generic_strncpy(tabNames[0], TEXT("Main menu"), maxTabName);
|
||||
generic_strncpy(tabNames[1], TEXT("Macros"), maxTabName);
|
||||
generic_strncpy(tabNames[2], TEXT("Run commands"), maxTabName);
|
||||
generic_strncpy(tabNames[3], TEXT("Plugin commands"), maxTabName);
|
||||
generic_strncpy(tabNames[4], TEXT("Scintilla commands"), maxTabName);
|
||||
};
|
||||
ShortcutMapper() : _currentState(STATE_MENU), StaticDialog() {};
|
||||
~ShortcutMapper() {};
|
||||
|
||||
void init(HINSTANCE hInst, HWND parent, GridState initState = STATE_MENU) {
|
||||
@ -64,7 +58,6 @@ public:
|
||||
::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_SHORTCUTMAPPER_DLG), _hParent, dlgProc, reinterpret_cast<LPARAM>(this));
|
||||
};
|
||||
void getClientRect(RECT & rc) const;
|
||||
void translateTab(int index, const TCHAR * newname);
|
||||
|
||||
bool findKeyConflicts(__inout_opt generic_string * const keyConflictLocation,
|
||||
const KeyCombo & itemKeyCombo, const size_t & itemIndex) const;
|
||||
@ -73,14 +66,14 @@ protected :
|
||||
INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
private:
|
||||
static const int maxTabName = 64;
|
||||
BabyGridWrapper _babygrid;
|
||||
ContextMenu _rightClickMenu;
|
||||
|
||||
GridState _currentState;
|
||||
HWND _hTabCtrl = nullptr;
|
||||
|
||||
TCHAR tabNames[5][maxTabName];
|
||||
const static int _nbTab = 5;
|
||||
generic_string _tabNames[_nbTab];
|
||||
|
||||
//save/restore the last view
|
||||
std::vector<size_t> _lastHomeRow;
|
||||
@ -101,6 +94,7 @@ private:
|
||||
void initTabs();
|
||||
void initBabyGrid();
|
||||
void fillOutBabyGrid();
|
||||
generic_string getTabString(size_t i) const;
|
||||
|
||||
bool isConflict(const KeyCombo & lhs, const KeyCombo & rhs) const
|
||||
{
|
||||
|
@ -389,8 +389,13 @@ INT_PTR CALLBACK Shortcut::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
|
||||
|
||||
if (iFound != -1)
|
||||
::SendDlgItemMessage(_hSelf, IDC_KEY_COMBO, CB_SETCURSEL, iFound, 0);
|
||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_WARNING_STATIC), isEnabled()?SW_HIDE:SW_SHOW);
|
||||
|
||||
// Hide this warning on startup
|
||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_WARNING_STATIC), SW_HIDE);
|
||||
|
||||
updateConflictState();
|
||||
NativeLangSpeaker* nativeLangSpeaker = NppParameters::getInstance()->getNativeLangSpeaker();
|
||||
nativeLangSpeaker->changeDlgLang(_hSelf, "ShortcutMapperSubDialg");
|
||||
goToCenter();
|
||||
return TRUE;
|
||||
}
|
||||
@ -778,7 +783,8 @@ void ScintillaKeyMap::applyToCurrentIndex()
|
||||
|
||||
}
|
||||
|
||||
void ScintillaKeyMap::validateDialog() {
|
||||
void ScintillaKeyMap::validateDialog()
|
||||
{
|
||||
bool valid = isValid(); //current combo valid?
|
||||
bool isDisabling = _keyCombo._key == 0; //true if this keycombo were to disable the shortcut
|
||||
bool isDisabled = !isEnabled(); //true if this shortcut already is
|
||||
@ -846,6 +852,11 @@ INT_PTR CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARA
|
||||
showCurrentSettings();
|
||||
validateDialog();
|
||||
|
||||
// Hide this warning on startup
|
||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_WARNING_STATIC), SW_HIDE);
|
||||
|
||||
NativeLangSpeaker* nativeLangSpeaker = NppParameters::getInstance()->getNativeLangSpeaker();
|
||||
nativeLangSpeaker->changeDlgLang(_hSelf, "ShortcutMapperSubDialg");
|
||||
goToCenter();
|
||||
return TRUE;
|
||||
}
|
||||
@ -856,19 +867,16 @@ INT_PTR CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARA
|
||||
{
|
||||
case IDC_CTRL_CHECK :
|
||||
_keyCombo._isCtrl = BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0);
|
||||
//applyToCurrentIndex();
|
||||
validateDialog();
|
||||
return TRUE;
|
||||
|
||||
case IDC_ALT_CHECK :
|
||||
_keyCombo._isAlt = BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0);
|
||||
//applyToCurrentIndex();
|
||||
validateDialog();
|
||||
return TRUE;
|
||||
|
||||
case IDC_SHIFT_CHECK :
|
||||
_keyCombo._isShift = BST_CHECKED == ::SendDlgItemMessage(_hSelf, static_cast<int32_t>(wParam), BM_GETCHECK, 0, 0);
|
||||
//applyToCurrentIndex();
|
||||
validateDialog();
|
||||
return TRUE;
|
||||
|
||||
@ -935,7 +943,7 @@ INT_PTR CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARA
|
||||
{
|
||||
auto i = ::SendDlgItemMessage(_hSelf, IDC_KEY_COMBO, CB_GETCURSEL, 0, 0);
|
||||
_keyCombo._key = namedKeyArray[i].id;
|
||||
//applyToCurrentIndex();
|
||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_WARNING_STATIC), isEnabled() ? SW_HIDE : SW_SHOW);
|
||||
validateDialog();
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -33,29 +33,24 @@
|
||||
#define IDC_STATIC -1
|
||||
#endif
|
||||
|
||||
IDD_SHORTCUT_DLG DIALOGEX 0, 0, 180, 102
|
||||
STYLE DS_SETFONT | /*DS_MODALFRAME |*/ DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
|
||||
WS_SYSMENU
|
||||
IDD_SHORTCUT_DLG DIALOGEX 0, 0, 180, 105
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_TOOLWINDOW
|
||||
CAPTION "Shortcut"
|
||||
FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1
|
||||
BEGIN
|
||||
CONTROL "CTRL",IDC_CTRL_CHECK,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,12,30,33,10
|
||||
CONTROL "ALT",IDC_ALT_CHECK,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,12,51,28,10
|
||||
CONTROL "SHIFT",IDC_SHIFT_CHECK,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,57,42,35,10
|
||||
COMBOBOX IDC_KEY_COMBO,110,40,64,270,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
CONTROL "CTRL",IDC_CTRL_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,30,33,10
|
||||
CONTROL "ALT",IDC_ALT_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,51,28,10
|
||||
CONTROL "SHIFT",IDC_SHIFT_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,57,42,35,10
|
||||
COMBOBOX IDC_KEY_COMBO,110,40,64,270,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "OK",IDOK,32,74,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,103,73,50,14
|
||||
LTEXT "+",IDC_STATIC,45,42,8,8
|
||||
LTEXT "+",IDC_STATIC,96,42,8,8
|
||||
EDITTEXT IDC_NAME_EDIT,56,9,118,14,ES_AUTOHSCROLL
|
||||
LTEXT "Name :",IDC_NAME_STATIC,15,12,34,8,0,WS_EX_RIGHT
|
||||
LTEXT "This will disable the accelerator!",IDC_WARNING_STATIC,6,91,170,8
|
||||
LTEXT "CONFLICT FOUND!",IDC_CONFLICT_STATIC,6,91,170,8
|
||||
LTEXT "This will disable the accelerator",IDC_WARNING_STATIC,6,93,170,8
|
||||
LTEXT "CONFLICT FOUND!",IDC_CONFLICT_STATIC,6,93,170,8
|
||||
END
|
||||
|
||||
IDD_SHORTCUTSCINT_DLG DIALOGEX 0, 0, 286, 114
|
||||
@ -64,25 +59,20 @@ EXSTYLE WS_EX_TOOLWINDOW
|
||||
CAPTION "Shortcut"
|
||||
FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1
|
||||
BEGIN
|
||||
CONTROL "CTRL",IDC_CTRL_CHECK,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,114,27,33,10
|
||||
CONTROL "ALT",IDC_ALT_CHECK,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,114,48,28,10
|
||||
CONTROL "SHIFT",IDC_SHIFT_CHECK,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,159,39,35,10
|
||||
COMBOBOX IDC_KEY_COMBO,212,37,64,270,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "OK",IDOK,144,78,48,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,210,78,48,14
|
||||
CONTROL "CTRL",IDC_CTRL_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,27,33,10
|
||||
CONTROL "ALT",IDC_ALT_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,48,28,10
|
||||
CONTROL "SHIFT",IDC_SHIFT_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,39,35,10
|
||||
COMBOBOX IDC_KEY_COMBO,212,37,64,270,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "Apply", IDC_BUTTON_APPLY, 210, 66, 48, 14
|
||||
PUSHBUTTON "OK",IDOK,144,84,48,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,210,84,48,14
|
||||
LTEXT "+",IDC_STATIC,147,39,8,8
|
||||
LTEXT "+",IDC_STATIC,198,39,8,8
|
||||
EDITTEXT IDC_NAME_EDIT,158,6,118,14,ES_AUTOHSCROLL | ES_READONLY
|
||||
LTEXT "Name :",IDC_NAME_STATIC,117,9,34,8,0,WS_EX_RIGHT
|
||||
LTEXT "This will remove the accelerator!",IDC_WARNING_STATIC,114,99,162,8
|
||||
LTEXT "CONFLICT FOUND!",IDC_CONFLICT_STATIC,114,99,162,8
|
||||
LISTBOX IDC_LIST_KEYS,6,6,90,72,LBS_NOINTEGRALHEIGHT |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "This will remove the accelerator",IDC_WARNING_STATIC,6,101,162,8
|
||||
LTEXT "CONFLICT FOUND!",IDC_CONFLICT_STATIC,6,101,162,8
|
||||
LISTBOX IDC_LIST_KEYS,6,6,90,72,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "Add",IDC_BUTTON_ADD,6,84,42,14
|
||||
PUSHBUTTON "Remove",IDC_BUTTON_RMVE,56,84,40,14
|
||||
PUSHBUTTON "Apply",IDC_BUTTON_APPLY,210,60,48,14
|
||||
END
|
||||
|
@ -944,34 +944,27 @@ void NativeLangSpeaker::changeShortcutLang()
|
||||
|
||||
}
|
||||
|
||||
void NativeLangSpeaker::changeShortcutmapperLang(ShortcutMapper * sm)
|
||||
generic_string NativeLangSpeaker::getShortcutMapperLangStr(const char *nodeName, const TCHAR *defaultStr) const
|
||||
{
|
||||
if (!_nativeLangA) return;
|
||||
if (!_nativeLangA) return defaultStr;
|
||||
|
||||
TiXmlNodeA *shortcuts = _nativeLangA->FirstChild("Dialog");
|
||||
if (!shortcuts) return;
|
||||
TiXmlNodeA *targetNode = _nativeLangA->FirstChild("Dialog");
|
||||
if (!targetNode) return defaultStr;
|
||||
|
||||
shortcuts = shortcuts->FirstChild("ShortcutMapper");
|
||||
if (!shortcuts) return;
|
||||
targetNode = targetNode->FirstChild("ShortcutMapper");
|
||||
if (!targetNode) return defaultStr;
|
||||
|
||||
for (TiXmlNodeA *childNode = shortcuts->FirstChildElement("Item");
|
||||
childNode ;
|
||||
childNode = childNode->NextSibling("Item") )
|
||||
targetNode = targetNode->FirstChild(nodeName);
|
||||
if (!targetNode) return defaultStr;
|
||||
|
||||
const char *name = (targetNode->ToElement())->Attribute("name");
|
||||
if (name && name[0])
|
||||
{
|
||||
TiXmlElementA *element = childNode->ToElement();
|
||||
int index;
|
||||
if (element->Attribute("index", &index))
|
||||
{
|
||||
if (index > -1 && index < 5) //valid index only
|
||||
{
|
||||
const char *name = element->Attribute("name");
|
||||
|
||||
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
|
||||
const wchar_t * nameW = wmc->char2wchar(name, _nativeLangEncoding);
|
||||
sm->translateTab(index, nameW);
|
||||
}
|
||||
}
|
||||
return wmc->char2wchar(name, _nativeLangEncoding);
|
||||
}
|
||||
|
||||
return defaultStr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,7 +60,6 @@ public:
|
||||
generic_string getNativeLangMenuString(int itemID) const;
|
||||
void changeMenuLang(HMENU menuHandle, generic_string & pluginsTrans, generic_string & windowTrans);
|
||||
void changeShortcutLang();
|
||||
void changeShortcutmapperLang(ShortcutMapper * sm);
|
||||
void changeStyleCtrlsLang(HWND hDlg, int *idArray, const char **translatedText);
|
||||
void changeUserDefineLang(UserDefineDialog *userDefineDlg);
|
||||
void changeUserDefineLangPopupDlg(HWND hDlg);
|
||||
@ -82,6 +81,7 @@ public:
|
||||
return _nativeLangEncoding;
|
||||
};
|
||||
bool getMsgBoxLang(const char *msgBoxTagName, generic_string & title, generic_string & message);
|
||||
generic_string getShortcutMapperLangStr(const char *nodeName, const TCHAR *defaultStr) const;
|
||||
generic_string getProjectPanelLangMenuStr(const char * nodeName, int cmdID, const TCHAR *defaultStr) const;
|
||||
generic_string getFileBrowserLangMenuStr(int cmdID, const TCHAR *defaultStr) const;
|
||||
generic_string getAttrNameStr(const TCHAR *defaultStr, const char *nodeL1Name, const char *nodeL2Name = NULL) const;
|
||||
|
Loading…
Reference in New Issue
Block a user