mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-24 22:34:54 +02:00
Initial new dpi management support for Shortcut Mapper
ref #14959 Close #15089
This commit is contained in:
parent
8329a9fec9
commit
3b515f1242
@ -46,7 +46,7 @@ void ShortcutMapper::initTabs()
|
|||||||
::GetWindowPlacement(hTab, &wp);
|
::GetWindowPlacement(hTab, &wp);
|
||||||
::SendMessage(hTab, TCM_GETITEMRECT, 0, reinterpret_cast<LPARAM>(&rcTab));
|
::SendMessage(hTab, TCM_GETITEMRECT, 0, reinterpret_cast<LPARAM>(&rcTab));
|
||||||
|
|
||||||
wp.rcNormalPosition.bottom = NppParameters::getInstance()._dpiManager.scaleY(30);
|
wp.rcNormalPosition.bottom = _dpiManager.scale(30);
|
||||||
wp.rcNormalPosition.top = wp.rcNormalPosition.bottom - rcTab.bottom;
|
wp.rcNormalPosition.top = wp.rcNormalPosition.bottom - rcTab.bottom;
|
||||||
|
|
||||||
::SetWindowPlacement(hTab, &wp);
|
::SetWindowPlacement(hTab, &wp);
|
||||||
@ -54,6 +54,7 @@ void ShortcutMapper::initTabs()
|
|||||||
|
|
||||||
void ShortcutMapper::getClientRect(RECT & rc) const
|
void ShortcutMapper::getClientRect(RECT & rc) const
|
||||||
{
|
{
|
||||||
|
const UINT dpi = _dpiManager.getDpi();
|
||||||
Window::getClientRect(rc);
|
Window::getClientRect(rc);
|
||||||
|
|
||||||
RECT tabRect{}, btnRect{};
|
RECT tabRect{}, btnRect{};
|
||||||
@ -69,11 +70,11 @@ void ShortcutMapper::getClientRect(RECT & rc) const
|
|||||||
int infoH = infoRect.bottom - infoRect.top;
|
int infoH = infoRect.bottom - infoRect.top;
|
||||||
int filterH = filterRect.bottom - filterRect.top;
|
int filterH = filterRect.bottom - filterRect.top;
|
||||||
int btnH = btnRect.bottom - btnRect.top;
|
int btnH = btnRect.bottom - btnRect.top;
|
||||||
int paddingBottom = btnH + NppParameters::getInstance()._dpiManager.scaleY(16);
|
int paddingBottom = btnH + _dpiManager.scale(16, dpi);
|
||||||
rc.bottom -= btnH + filterH + infoH + paddingBottom;
|
rc.bottom -= btnH + filterH + infoH + paddingBottom;
|
||||||
|
|
||||||
rc.left += NppParameters::getInstance()._dpiManager.scaleX(5);
|
rc.left += _dpiManager.scale(5, dpi);
|
||||||
rc.right -= NppParameters::getInstance()._dpiManager.scaleX(5);
|
rc.right -= _dpiManager.scale(5, dpi);
|
||||||
}
|
}
|
||||||
|
|
||||||
generic_string ShortcutMapper::getTabString(size_t i) const
|
generic_string ShortcutMapper::getTabString(size_t i) const
|
||||||
@ -111,14 +112,12 @@ void ShortcutMapper::initBabyGrid()
|
|||||||
_lastCursorRow.resize(5, 1);
|
_lastCursorRow.resize(5, 1);
|
||||||
|
|
||||||
_hGridFonts.resize(MAX_GRID_FONTS);
|
_hGridFonts.resize(MAX_GRID_FONTS);
|
||||||
_hGridFonts.at(GFONT_HEADER) = ::CreateFont(
|
LOGFONT lf{ _dpiManager.getDefaultGUIFontForDpi() };
|
||||||
NppParameters::getInstance()._dpiManager.scaleY(18), 0, 0, 0, FW_BOLD,
|
lf.lfHeight = _dpiManager.scaleFont(10);
|
||||||
FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH,
|
_hGridFonts.at(GFONT_ROWS) = ::CreateFontIndirect(&lf);
|
||||||
TEXT("MS Shell Dlg"));
|
lf.lfHeight = _dpiManager.scaleFont(12);
|
||||||
_hGridFonts.at(GFONT_ROWS) = ::CreateFont(
|
lf.lfWeight = FW_BOLD;
|
||||||
NppParameters::getInstance()._dpiManager.scaleY(16), 0, 0, 0, FW_NORMAL,
|
_hGridFonts.at(GFONT_HEADER) = ::CreateFontIndirect(&lf);
|
||||||
FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH,
|
|
||||||
TEXT("MS Shell Dlg"));
|
|
||||||
|
|
||||||
_babygrid.init(_hInst, _hSelf, IDD_BABYGRID_ID1);
|
_babygrid.init(_hInst, _hSelf, IDD_BABYGRID_ID1);
|
||||||
|
|
||||||
@ -132,9 +131,9 @@ void ShortcutMapper::initBabyGrid()
|
|||||||
_babygrid.makeColAutoWidth(true);
|
_babygrid.makeColAutoWidth(true);
|
||||||
_babygrid.setAutoRow(true);
|
_babygrid.setAutoRow(true);
|
||||||
_babygrid.setColsNumbered(false);
|
_babygrid.setColsNumbered(false);
|
||||||
_babygrid.setColWidth(0, NppParameters::getInstance()._dpiManager.scaleX(30)); // Force the first col to be small, others col will be automatically sized
|
_babygrid.setColWidth(0, _dpiManager.scale(30)); // Force the first col to be small, others col will be automatically sized
|
||||||
_babygrid.setHeaderHeight(NppParameters::getInstance()._dpiManager.scaleY(21));
|
_babygrid.setHeaderHeight(_dpiManager.scale(21));
|
||||||
_babygrid.setRowHeight(NppParameters::getInstance()._dpiManager.scaleY(21));
|
_babygrid.setRowHeight(_dpiManager.scale(21));
|
||||||
|
|
||||||
if (NppDarkMode::isEnabled())
|
if (NppDarkMode::isEnabled())
|
||||||
{
|
{
|
||||||
@ -512,8 +511,9 @@ intptr_t CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG :
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
|
setDpi();
|
||||||
initBabyGrid();
|
initBabyGrid();
|
||||||
initTabs();
|
initTabs();
|
||||||
fillOutBabyGrid();
|
fillOutBabyGrid();
|
||||||
@ -527,10 +527,9 @@ intptr_t CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||||||
_clientWidth = rect.right - rect.left;
|
_clientWidth = rect.right - rect.left;
|
||||||
_clientHeight = rect.bottom - rect.top;
|
_clientHeight = rect.bottom - rect.top;
|
||||||
|
|
||||||
int cy_border = GetSystemMetrics(SM_CYFRAME);
|
Window::getWindowRect(rect);
|
||||||
int cy_caption = GetSystemMetrics(SM_CYCAPTION);
|
_initClientWidth = rect.right - rect.left;
|
||||||
_initClientWidth = _clientWidth;
|
_initClientHeight = rect.bottom - rect.top;
|
||||||
_initClientHeight = _clientHeight + cy_caption + cy_border;
|
|
||||||
_dialogInitDone = true;
|
_dialogInitDone = true;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
_currentState = initState;
|
_currentState = initState;
|
||||||
};
|
};
|
||||||
|
|
||||||
void destroy() {};
|
void destroy() override {};
|
||||||
void doDialog(bool isRTL = false) {
|
void doDialog(bool isRTL = false) {
|
||||||
if (isRTL)
|
if (isRTL)
|
||||||
{
|
{
|
||||||
@ -49,7 +49,7 @@ public:
|
|||||||
else
|
else
|
||||||
::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_SHORTCUTMAPPER_DLG), _hParent, dlgProc, reinterpret_cast<LPARAM>(this));
|
::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_SHORTCUTMAPPER_DLG), _hParent, dlgProc, reinterpret_cast<LPARAM>(this));
|
||||||
};
|
};
|
||||||
void getClientRect(RECT & rc) const;
|
void getClientRect(RECT & rc) const override;
|
||||||
|
|
||||||
bool findKeyConflicts(__inout_opt generic_string * const keyConflictLocation,
|
bool findKeyConflicts(__inout_opt generic_string * const keyConflictLocation,
|
||||||
const KeyCombo & itemKeyCombo, const size_t & itemIndex) const;
|
const KeyCombo & itemKeyCombo, const size_t & itemIndex) const;
|
||||||
@ -60,7 +60,7 @@ public:
|
|||||||
bool isFilterValid(ScintillaKeyMap sc);
|
bool isFilterValid(ScintillaKeyMap sc);
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BabyGridWrapper _babygrid;
|
BabyGridWrapper _babygrid;
|
||||||
|
@ -29,11 +29,11 @@ CAPTION "Shortcut mapper"
|
|||||||
FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1
|
FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
CONTROL "",IDC_BABYGRID_TABBAR,"SysTabControl32",WS_TABSTOP,4,6,384,12
|
CONTROL "",IDC_BABYGRID_TABBAR,"SysTabControl32",WS_TABSTOP,4,6,384,12
|
||||||
EDITTEXT IDC_BABYGRID_INFO,3,281,443,29,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP
|
EDITTEXT IDC_BABYGRID_INFO,3,283,443,29,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP
|
||||||
RTEXT "Filter :", IDC_BABYGRID_STATIC,4,313,25,12
|
RTEXT "Filter:",IDC_BABYGRID_STATIC,4,318,25,8
|
||||||
EDITTEXT IDC_BABYGRID_FILTER,31,312,415,12,ES_AUTOHSCROLL | ES_WANTRETURN
|
EDITTEXT IDC_BABYGRID_FILTER,31,317,415,12,ES_AUTOHSCROLL | ES_WANTRETURN
|
||||||
PUSHBUTTON "Modify",IDM_BABYGRID_MODIFY,118,330,47,14
|
PUSHBUTTON "Modify",IDM_BABYGRID_MODIFY,126,335,47,14
|
||||||
PUSHBUTTON "Clear",IDM_BABYGRID_CLEAR,172,330,47,14
|
PUSHBUTTON "Clear",IDM_BABYGRID_CLEAR,180,335,47,14
|
||||||
PUSHBUTTON "Delete",IDM_BABYGRID_DELETE,226,330,47,14
|
PUSHBUTTON "Delete",IDM_BABYGRID_DELETE,234,335,47,14
|
||||||
DEFPUSHBUTTON "Close",IDOK,280,330,47,14
|
DEFPUSHBUTTON "Close",IDOK,288,335,47,14
|
||||||
END
|
END
|
||||||
|
@ -47,6 +47,9 @@ public:
|
|||||||
static void initDpiAPI();
|
static void initDpiAPI();
|
||||||
|
|
||||||
static int getSystemMetricsForDpi(int nIndex, UINT dpi);
|
static int getSystemMetricsForDpi(int nIndex, UINT dpi);
|
||||||
|
int getSystemMetricsForDpi(int nIndex) {
|
||||||
|
return getSystemMetricsForDpi(nIndex, _dpi);
|
||||||
|
}
|
||||||
static DPI_AWARENESS_CONTEXT setThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT dpiContext);
|
static DPI_AWARENESS_CONTEXT setThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT dpiContext);
|
||||||
|
|
||||||
static UINT getDpiForSystem();
|
static UINT getDpiForSystem();
|
||||||
@ -126,6 +129,9 @@ public:
|
|||||||
static LOGFONT getDefaultGUIFontForDpi(HWND hWnd, FontType type = FontType::message) {
|
static LOGFONT getDefaultGUIFontForDpi(HWND hWnd, FontType type = FontType::message) {
|
||||||
return getDefaultGUIFontForDpi(getDpiForWindow(hWnd), type);
|
return getDefaultGUIFontForDpi(getDpiForWindow(hWnd), type);
|
||||||
}
|
}
|
||||||
|
LOGFONT getDefaultGUIFontForDpi(FontType type = FontType::message) {
|
||||||
|
return getDefaultGUIFontForDpi(_dpi, type);
|
||||||
|
}
|
||||||
|
|
||||||
static void sendMessageToChildControls(HWND hwndParent, UINT msg, WPARAM wParam, LPARAM lParam);
|
static void sendMessageToChildControls(HWND hwndParent, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
static void loadIcon(HINSTANCE hinst, const wchar_t* pszName, int cx, int cy, HICON* phico, UINT fuLoad = LR_DEFAULTCOLOR);
|
static void loadIcon(HINSTANCE hinst, const wchar_t* pszName, int cx, int cy, HICON* phico, UINT fuLoad = LR_DEFAULTCOLOR);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user