Refactoring for new DPI management: avoiod the multiple inherence
Using the composition instead of the multiple inherence 1. For preventing from the diamond problem. 2. To fix the semantic problem by using DPIManagerV2 as class ancestor of class StaticDialog. Remove also unecessary scaleX, unscaleX, scaleY & unscaleY methods.pull/15078/head
parent
e518c79a53
commit
2d076b645a
|
@ -87,7 +87,7 @@ intptr_t CALLBACK HashFromFilesDlg::run_dlgProc(UINT message, WPARAM wParam, LPA
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
|
||||
destroy();
|
||||
_hFont = createFont(L"Courier New", 9, false, _hSelf);
|
||||
|
@ -535,7 +535,7 @@ intptr_t CALLBACK HashFromTextDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
|
||||
destroy();
|
||||
_hFont = createFont(L"Courier New", 9, false, _hSelf);
|
||||
|
|
|
@ -1089,7 +1089,7 @@ intptr_t CALLBACK FindInFinderDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
setPositionDpi(lParam);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -71,7 +71,7 @@ intptr_t CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
setPositionDpi(lParam);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -1156,7 +1156,7 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
setPositionDpi(lParam);
|
||||
|
||||
return TRUE;
|
||||
|
@ -1643,7 +1643,7 @@ intptr_t CALLBACK StringDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
setPositionDpi(lParam);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -150,7 +150,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
setPositionDpi(lParam);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -95,7 +95,7 @@ intptr_t CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
destroy();
|
||||
//setPositionDpi(lParam);
|
||||
getClientRect(_rc);
|
||||
|
@ -105,7 +105,7 @@ intptr_t CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar
|
|||
|
||||
case WM_DRAWITEM:
|
||||
{
|
||||
const int iconSize = DPIManagerV2::scale(80);
|
||||
const int iconSize = _dpiManager.scale(80);
|
||||
if (_hIcon == nullptr)
|
||||
{
|
||||
DPIManagerV2::loadIcon(_hInst, MAKEINTRESOURCE(NppDarkMode::isEnabled() ? IDI_CHAMELEON_DM : IDI_CHAMELEON), iconSize, iconSize, &_hIcon);
|
||||
|
@ -380,7 +380,7 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
getClientRect(_rc);
|
||||
setPositionDpi(lParam);
|
||||
|
||||
|
@ -521,7 +521,7 @@ intptr_t CALLBACK DoSaveOrNotBox::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
setPositionDpi(lParam);
|
||||
|
||||
return TRUE;
|
||||
|
@ -639,7 +639,7 @@ intptr_t CALLBACK DoSaveAllBox::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
setPositionDpi(lParam);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -137,7 +137,7 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
|
|||
_pBgColour->init(_hInst, _hSelf);
|
||||
|
||||
setDpi();
|
||||
const int cpDynamicalSize = DPIManagerV2::scale(25);
|
||||
const int cpDynamicalSize = _dpiManager.scale(25);
|
||||
|
||||
move2CtrlRight(IDC_FG_STATIC, _pFgColour->getHSelf(), cpDynamicalSize, cpDynamicalSize);
|
||||
move2CtrlRight(IDC_BG_STATIC, _pBgColour->getHSelf(), cpDynamicalSize, cpDynamicalSize);
|
||||
|
@ -268,11 +268,11 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
|
||||
_goToSettings.destroy();
|
||||
|
||||
const int cpDynamicalSize = DPIManagerV2::scale(25);
|
||||
const int cpDynamicalSize = _dpiManager.scale(25);
|
||||
move2CtrlRight(IDC_FG_STATIC, _pFgColour->getHSelf(), cpDynamicalSize, cpDynamicalSize);
|
||||
move2CtrlRight(IDC_BG_STATIC, _pBgColour->getHSelf(), cpDynamicalSize, cpDynamicalSize);
|
||||
|
||||
|
@ -583,7 +583,7 @@ void WordStyleDlg::move2CtrlRight(int ctrlID, HWND handle2Move, int handle2MoveW
|
|||
RECT rc{};
|
||||
::GetWindowRect(::GetDlgItem(_hSelf, ctrlID), &rc);
|
||||
|
||||
p.x = rc.right + DPIManagerV2::scale(5);
|
||||
p.x = rc.right + _dpiManager.scale(5);
|
||||
p.y = rc.top + ((rc.bottom - rc.top) / 2) - handle2MoveHeight / 2;
|
||||
|
||||
::ScreenToClient(_hSelf, &p);
|
||||
|
|
|
@ -97,7 +97,7 @@ intptr_t CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam,
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
setPositionDpi(lParam);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -146,7 +146,7 @@ void PluginsAdminDlg::create(int dialogID, bool isRTL, bool msgDestParent)
|
|||
getMappedChildRect(IDC_PLUGINADM_EDIT, rcDesc);
|
||||
|
||||
const long margeX = ::GetSystemMetrics(SM_CXEDGE);
|
||||
const long margeY = DPIManagerV2::scale(13);
|
||||
const long margeY = _dpiManager.scale(13);
|
||||
|
||||
rect.bottom = rcDesc.bottom + margeY;
|
||||
_tab.reSizeTo(rect);
|
||||
|
@ -170,7 +170,7 @@ void PluginsAdminDlg::create(int dialogID, bool isRTL, bool msgDestParent)
|
|||
const COLORREF fgColor = nppParam.getCurrentDefaultFgColor();
|
||||
const COLORREF bgColor = nppParam.getCurrentDefaultBgColor();
|
||||
|
||||
const size_t szColVer = DPIManagerV2::scale(100);
|
||||
const size_t szColVer = _dpiManager.scale(100);
|
||||
const size_t szColName = szColVer * 2;
|
||||
|
||||
auto initListView = [&](PluginViewList& list) -> void {
|
||||
|
@ -1177,10 +1177,10 @@ intptr_t CALLBACK PluginsAdminDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
_repoLink.destroy();
|
||||
|
||||
const size_t szColVer = DPIManagerV2::scale(100);
|
||||
const size_t szColVer = _dpiManager.scale(100);
|
||||
const size_t szColName = szColVer * 2;
|
||||
|
||||
auto setListViewSize = [&](PluginViewList& list) -> void {
|
||||
|
|
|
@ -368,26 +368,26 @@ intptr_t CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_generalSubDlg.setDpiWP(wParam);
|
||||
_editingSubDlg.setDpiWP(wParam);
|
||||
_editing2SubDlg.setDpiWP(wParam);
|
||||
_darkModeSubDlg.setDpiWP(wParam);
|
||||
_marginsBorderEdgeSubDlg.setDpiWP(wParam);
|
||||
_miscSubDlg.setDpiWP(wParam);
|
||||
_fileAssocDlg.setDpiWP(wParam);
|
||||
_languageSubDlg.setDpiWP(wParam);
|
||||
_highlightingSubDlg.setDpiWP(wParam);
|
||||
_printSubDlg.setDpiWP(wParam);
|
||||
_searchingSubDlg.setDpiWP(wParam);
|
||||
_newDocumentSubDlg.setDpiWP(wParam);
|
||||
_defaultDirectorySubDlg.setDpiWP(wParam);
|
||||
_recentFilesHistorySubDlg.setDpiWP(wParam);
|
||||
_backupSubDlg.setDpiWP(wParam);
|
||||
_autoCompletionSubDlg.setDpiWP(wParam);
|
||||
_multiInstanceSubDlg.setDpiWP(wParam);
|
||||
_delimiterSubDlg.setDpiWP(wParam);
|
||||
_performanceSubDlg.setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
_generalSubDlg.dpiManager().setDpiWP(wParam);
|
||||
_editingSubDlg.dpiManager().setDpiWP(wParam);
|
||||
_editing2SubDlg.dpiManager().setDpiWP(wParam);
|
||||
_darkModeSubDlg.dpiManager().setDpiWP(wParam);
|
||||
_marginsBorderEdgeSubDlg.dpiManager().setDpiWP(wParam);
|
||||
_miscSubDlg.dpiManager().setDpiWP(wParam);
|
||||
_fileAssocDlg.dpiManager().setDpiWP(wParam);
|
||||
_languageSubDlg.dpiManager().setDpiWP(wParam);
|
||||
_highlightingSubDlg.dpiManager().setDpiWP(wParam);
|
||||
_printSubDlg.dpiManager().setDpiWP(wParam);
|
||||
_searchingSubDlg.dpiManager().setDpiWP(wParam);
|
||||
_newDocumentSubDlg.dpiManager().setDpiWP(wParam);
|
||||
_defaultDirectorySubDlg.dpiManager().setDpiWP(wParam);
|
||||
_recentFilesHistorySubDlg.dpiManager().setDpiWP(wParam);
|
||||
_backupSubDlg.dpiManager().setDpiWP(wParam);
|
||||
_autoCompletionSubDlg.dpiManager().setDpiWP(wParam);
|
||||
_multiInstanceSubDlg.dpiManager().setDpiWP(wParam);
|
||||
_delimiterSubDlg.dpiManager().setDpiWP(wParam);
|
||||
_performanceSubDlg.dpiManager().setDpiWP(wParam);
|
||||
|
||||
setPositionDpi(lParam);
|
||||
|
||||
|
@ -1460,9 +1460,9 @@ void DarkModeSubDlg::move2CtrlLeft(int ctrlID, HWND handle2Move, int handle2Move
|
|||
NppParameters& nppParam = NppParameters::getInstance();
|
||||
|
||||
if(nppParam.getNativeLangSpeaker()->isRTL())
|
||||
p.x = rc.right + DPIManagerV2::scale(5) + handle2MoveWidth;
|
||||
p.x = rc.right + _dpiManager.scale(5) + handle2MoveWidth;
|
||||
else
|
||||
p.x = rc.left - DPIManagerV2::scale(5) - handle2MoveWidth;
|
||||
p.x = rc.left - _dpiManager.scale(5) - handle2MoveWidth;
|
||||
|
||||
p.y = rc.top + ((rc.bottom - rc.top) / 2) - handle2MoveHeight / 2;
|
||||
|
||||
|
@ -1542,8 +1542,8 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||
_pHotEdgeColorPicker->init(_hInst, _hSelf);
|
||||
_pDisabledEdgeColorPicker->init(_hInst, _hSelf);
|
||||
|
||||
DPIManagerV2::setDpi(_hSelf);
|
||||
const int cpDynamicalSize = DPIManagerV2::scale(25);
|
||||
_dpiManager.setDpi(_hSelf);
|
||||
const int cpDynamicalSize = _dpiManager.scale(25);
|
||||
|
||||
move2CtrlLeft(IDD_CUSTOMIZED_COLOR1_STATIC, _pPureBackgroundColorPicker->getHSelf(), cpDynamicalSize, cpDynamicalSize);
|
||||
move2CtrlLeft(IDD_CUSTOMIZED_COLOR2_STATIC, _pHotBackgroundColorPicker->getHSelf(), cpDynamicalSize, cpDynamicalSize);
|
||||
|
@ -1659,7 +1659,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||
|
||||
case WM_DPICHANGED_AFTERPARENT:
|
||||
{
|
||||
const int cpDynamicalSize = DPIManagerV2::scale(25);
|
||||
const int cpDynamicalSize = _dpiManager.scale(25);
|
||||
|
||||
move2CtrlLeft(IDD_CUSTOMIZED_COLOR1_STATIC, _pPureBackgroundColorPicker->getHSelf(), cpDynamicalSize, cpDynamicalSize);
|
||||
move2CtrlLeft(IDD_CUSTOMIZED_COLOR2_STATIC, _pHotBackgroundColorPicker->getHSelf(), cpDynamicalSize, cpDynamicalSize);
|
||||
|
|
|
@ -1372,7 +1372,7 @@ intptr_t CALLBACK FileRelocalizerDlg::run_dlgProc(UINT Message, WPARAM wParam, L
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
setPositionDpi(lParam);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -313,7 +313,7 @@ intptr_t CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
setPositionDpi(lParam);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -38,7 +38,7 @@ struct DLGTEMPLATEEX
|
|||
// The structure has more fields but are variable length
|
||||
};
|
||||
|
||||
class StaticDialog : public Window, public DPIManagerV2
|
||||
class StaticDialog : public Window
|
||||
{
|
||||
public :
|
||||
virtual ~StaticDialog();
|
||||
|
@ -72,7 +72,7 @@ public :
|
|||
}
|
||||
|
||||
void setDpi() {
|
||||
DPIManagerV2::setDpi(_hSelf);
|
||||
_dpiManager.setDpi(_hSelf);
|
||||
}
|
||||
|
||||
void setPositionDpi(LPARAM lParam, UINT flags = SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE) {
|
||||
|
@ -85,8 +85,12 @@ public :
|
|||
|
||||
void destroy() override;
|
||||
|
||||
DPIManagerV2& dpiManager() { return _dpiManager; }
|
||||
|
||||
protected:
|
||||
RECT _rc{};
|
||||
DPIManagerV2 _dpiManager;
|
||||
|
||||
static intptr_t CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) = 0;
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ intptr_t CALLBACK RunMacroDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
setPositionDpi(lParam);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -447,7 +447,7 @@ intptr_t CALLBACK Shortcut::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
setPositionDpi(lParam);
|
||||
|
||||
return TRUE;
|
||||
|
@ -1129,7 +1129,7 @@ intptr_t CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPAR
|
|||
|
||||
case WM_DPICHANGED:
|
||||
{
|
||||
DPIManagerV2::setDpiWP(wParam);
|
||||
_dpiManager.setDpiWP(wParam);
|
||||
setPositionDpi(lParam);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -110,22 +110,6 @@ public:
|
|||
return unscale(x, _dpi);
|
||||
}
|
||||
|
||||
int scaleX(int x) {
|
||||
return scale(x);
|
||||
}
|
||||
|
||||
int unscaleX(int x) {
|
||||
return unscale(x);
|
||||
}
|
||||
|
||||
int scaleY(int y) {
|
||||
return scale(y);
|
||||
}
|
||||
|
||||
int unscaleY(int y) {
|
||||
return unscale(y);
|
||||
}
|
||||
|
||||
static int scaleFont(int pt, UINT dpi) {
|
||||
return -(scale(pt, dpi, 72));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue