Shortcut Mapper is resizable and maximizable

This commit is contained in:
Christophe Meriaux 2017-09-30 10:17:58 +02:00
parent fb17638de7
commit b47de8048d
3 changed files with 54 additions and 10 deletions

View File

@ -92,7 +92,7 @@ generic_string ShortcutMapper::getTabString(size_t i) const
case 4:
return nativeLangSpeaker->getShortcutMapperLangStr("ScintillaCommandsTab", TEXT("Scintilla commands"));
default: //0
default: //0
return nativeLangSpeaker->getShortcutMapperLangStr("MainMenuTab", TEXT("Main menu"));
}
}
@ -121,13 +121,10 @@ void ShortcutMapper::initBabyGrid() {
_babygrid.reSizeToWH(rect);
_babygrid.hideCursor();
_babygrid.makeColAutoWidth(false);
_babygrid.setAutoRow(false);
_babygrid.makeColAutoWidth(true);
_babygrid.setAutoRow(true);
_babygrid.setColsNumbered(false);
_babygrid.setColWidth(0, NppParameters::getInstance()->_dpiManager.scaleX(30));
_babygrid.setColWidth(1, NppParameters::getInstance()->_dpiManager.scaleX(290));
_babygrid.setColWidth(2, NppParameters::getInstance()->_dpiManager.scaleX(140));
_babygrid.setColWidth(3, NppParameters::getInstance()->_dpiManager.scaleX(40));
_babygrid.setColWidth(0, NppParameters::getInstance()->_dpiManager.scaleX(30)); // Force the first col to be small, others col will be automatically sized
_babygrid.setHeaderHeight(NppParameters::getInstance()->_dpiManager.scaleY(21));
_babygrid.setRowHeight(NppParameters::getInstance()->_dpiManager.scaleY(21));
@ -338,6 +335,12 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
fillOutBabyGrid();
_babygrid.display();
goToCenter();
RECT rect;
Window::getClientRect(rect);
_clientWidth = rect.right - rect.left;
_clientHeight = rect.bottom - rect.top;
return TRUE;
}
@ -348,6 +351,45 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
_hGridFonts.clear();
_hGridFonts.shrink_to_fit();
break;
}
case WM_SIZE:
{
LONG newWidth = LOWORD(lParam);
LONG newHeight = HIWORD(lParam);
RECT rect;
LONG addWidth = newWidth - _clientWidth;
LONG addHeight = newHeight - _clientHeight;
_clientWidth = newWidth;
_clientHeight = newHeight;
getClientRect(rect);
_babygrid.reSizeToWH(rect);
//elements that need to be moved
const auto moveWindowIDs = {
IDM_BABYGRID_MODIFY, IDM_BABYGRID_CLEAR, IDM_BABYGRID_DELETE, IDOK
};
const UINT flags = SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS;
Window::getClientRect(rect);
for (int moveWndID : moveWindowIDs)
{
HWND moveHwnd = ::GetDlgItem(_hSelf, moveWndID);
::GetWindowRect(moveHwnd, &rect);
::MapWindowPoints(NULL, _hSelf, (LPPOINT)&rect, 2);
::SetWindowPos(moveHwnd, NULL, rect.left + addWidth, rect.top + addHeight, 0, 0, SWP_NOSIZE | flags);
}
// Move and resize IDC_BABYGRID_INFO
// Move the Y position, Resize the width
HWND resizeHwnd = ::GetDlgItem(_hSelf, IDC_BABYGRID_INFO);
::GetWindowRect(resizeHwnd, &rect);
::MapWindowPoints(NULL, _hSelf, (LPPOINT)&rect, 2);
::SetWindowPos(resizeHwnd, NULL, rect.left, rect.top + addHeight, rect.right - rect.left + addWidth, rect.bottom - rect.top, flags);
break;
}
break;

View File

@ -90,6 +90,8 @@ private:
GFONT_ROWS,
MAX_GRID_FONTS
};
LONG _clientWidth;
LONG _clientHeight;
void initTabs();
void initBabyGrid();

View File

@ -33,9 +33,9 @@
#define IDC_STATIC -1
#endif
IDD_SHORTCUTMAPPER_DLG DIALOGEX 0, 0, 391, 344
IDD_SHORTCUTMAPPER_DLG DIALOGEX 0, 0, 450, 344
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
WS_SYSMENU | WS_MAXIMIZEBOX | WS_THICKFRAME
//EXSTYLE WS_EX_TOOLWINDOW
CAPTION "Shortcut mapper"
FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1
@ -45,5 +45,5 @@ BEGIN
DEFPUSHBUTTON "Clear", IDM_BABYGRID_CLEAR,172,319,47,14
DEFPUSHBUTTON "Delete", IDM_BABYGRID_DELETE, 226, 319, 47, 14
DEFPUSHBUTTON "Close",IDOK,280,319,47,14
EDITTEXT IDC_BABYGRID_INFO,4,279,383,29,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP
EDITTEXT IDC_BABYGRID_INFO,4,279,440,29,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP
END