diff --git a/src/Dialogs.c b/src/Dialogs.c index c94a340dd..3c4f7bcaf 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -45,12 +45,12 @@ #include "version.h" #include "helpers.h" #include "encoding.h" +#include "SciCall.h" #include "dialogs.h" extern HWND g_hwndMain; -extern HWND g_hwndEdit; extern HINSTANCE g_hInstance; extern WCHAR g_wchWorkingDirectory[]; extern WCHAR g_wchCurFile[]; @@ -451,10 +451,10 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam LOGFONT lf; GetObject(hFontTitle, sizeof(LOGFONT), &lf); - POINT res = GetSystemDpi(); + POINT dpi = GetSystemDpi(); lf.lfWeight = FW_BOLD; - lf.lfWidth = (8 * res.x) / 96L; - lf.lfHeight = (22 * res.y) / 96L; + lf.lfWidth = MulDiv(8, dpi.x, USER_DEFAULT_SCREEN_DPI); + lf.lfHeight = MulDiv(22, dpi.y, USER_DEFAULT_SCREEN_DPI); // lf.lfQuality = ANTIALIASED_QUALITY; hFontTitle = CreateFontIndirect(&lf); @@ -2639,6 +2639,7 @@ WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO* hMonitorInfo) wi.cx = wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left; wi.cy = wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top; wi.max = IsZoomed(hwnd) || (wndpl.flags & WPF_RESTORETOMAXIMIZED); + wi.zoom = SciCall_GetZoom(); if (hMonitorInfo) { diff --git a/src/Notepad3.c b/src/Notepad3.c index 89bb9df45..f78a81d9f 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -253,10 +253,10 @@ const int FontQuality[4] = { , SC_EFF_QUALITY_LCD_OPTIMIZED }; -static WININFO g_WinInfo = { CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0 }; +static WININFO g_WinInfo = INIT_WININFO; static int g_WinCurrentWidth = 0; -bool bStickyWinPos; +bool g_bStickyWinPos; bool bIsAppThemed; int cyReBar; @@ -853,6 +853,7 @@ static void __fastcall _InitWindowPosition(HWND hwnd) { g_WinInfo.x = g_WinInfo.y = g_WinInfo.cx = g_WinInfo.cy = CW_USEDEFAULT; g_WinInfo.max = 0; + g_WinInfo.zoom = 0; } else if (g_flagDefaultPos >= 4) { @@ -883,6 +884,8 @@ static void __fastcall _InitWindowPosition(HWND hwnd) g_WinInfo.y += (g_flagDefaultPos & 32) ? 4 : 8; g_WinInfo.cy -= (g_flagDefaultPos & (16 | 32)) ? 12 : 16; g_WinInfo.max = 1; + g_WinInfo.zoom = 0; + } } else if (g_flagDefaultPos == 2 || g_flagDefaultPos == 3) // NP3 default window position @@ -960,15 +963,18 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow) hInstance, NULL); - if (g_WinInfo.max) + if (g_WinInfo.max) { nCmdShow = SW_SHOWMAXIMIZED; - + } if ((bAlwaysOnTop || g_flagAlwaysOnTop == 2) && g_flagAlwaysOnTop != 1) { SetWindowPos(g_hwndMain, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } - if (bTransparentMode) - SetWindowTransparentMode(g_hwndMain,true); - + if (bTransparentMode) { + SetWindowTransparentMode(g_hwndMain, true); + } + if (g_WinInfo.zoom) { + SciCall_SetZoom(g_WinInfo.zoom); + } // Current file information -- moved in front of ShowWindow() FileLoad(true,true,false,bSkipUnicodeDetection,bSkipANSICodePageDetection,L""); @@ -2698,8 +2704,8 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam) CheckCmd(hmenu,IDM_VIEW_REUSEWINDOW,i); i = IniGetInt(L"Settings2",L"SingleFileInstance",0); CheckCmd(hmenu,IDM_VIEW_SINGLEFILEINSTANCE,i); - bStickyWinPos = IniGetInt(L"Settings2",L"StickyWindowPosition",0); - CheckCmd(hmenu,IDM_VIEW_STICKYWINPOS,bStickyWinPos); + g_bStickyWinPos = IniGetBool(L"Settings2",L"StickyWindowPosition",false); + CheckCmd(hmenu,IDM_VIEW_STICKYWINPOS,g_bStickyWinPos); CheckCmd(hmenu,IDM_VIEW_ALWAYSONTOP,((bAlwaysOnTop || g_flagAlwaysOnTop == 2) && g_flagAlwaysOnTop != 1)); CheckCmd(hmenu,IDM_VIEW_MINTOTRAY,bMinimizeToTray); CheckCmd(hmenu,IDM_VIEW_TRANSPARENT,bTransparentMode && bTransparentModeAvailable); @@ -4605,17 +4611,17 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) break; case IDM_VIEW_ZOOMIN: - SendMessage(g_hwndEdit,SCI_ZOOMIN,0,0); + SciCall_ZoomIn(); UpdateLineNumberWidth(); break; case IDM_VIEW_ZOOMOUT: - SendMessage(g_hwndEdit,SCI_ZOOMOUT,0,0); + SciCall_ZoomOut(); UpdateLineNumberWidth(); break; case IDM_VIEW_RESETZOOM: - SendMessage(g_hwndEdit,SCI_SETZOOM,0,0); + SciCall_SetZoom(0); UpdateLineNumberWidth(); break; @@ -4694,10 +4700,10 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_VIEW_STICKYWINPOS: - bStickyWinPos = IniGetInt(L"Settings2",L"StickyWindowPosition",bStickyWinPos); - if (!bStickyWinPos) + g_bStickyWinPos = IniGetBool(L"Settings2",L"StickyWindowPosition",g_bStickyWinPos); + if (!g_bStickyWinPos) { - WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32]; + WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32], tchZoom[32]; int ResX = GetSystemMetrics(SM_CXSCREEN); int ResY = GetSystemMetrics(SM_CYSCREEN); @@ -4707,8 +4713,9 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) StringCchPrintf(tchSizeX,COUNTOF(tchSizeX),L"%ix%i SizeX",ResX,ResY); StringCchPrintf(tchSizeY,COUNTOF(tchSizeY),L"%ix%i SizeY",ResX,ResY); StringCchPrintf(tchMaximized,COUNTOF(tchMaximized),L"%ix%i Maximized",ResX,ResY); + StringCchPrintf(tchZoom, COUNTOF(tchZoom), L"%ix%i Zoom", ResX, ResY); - bStickyWinPos = 1; + g_bStickyWinPos = true; IniSetInt(L"Settings2",L"StickyWindowPosition",1); // GetWindowPlacement @@ -4718,11 +4725,12 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) IniSetInt(L"Window",tchSizeX,wi.cx); IniSetInt(L"Window",tchSizeY,wi.cy); IniSetInt(L"Window",tchMaximized,wi.max); + IniSetInt(L"Window", tchZoom, wi.zoom); InfoBox(0,L"MsgStickyWinPos",IDS_STICKYWINPOS); } else { - bStickyWinPos = 0; + g_bStickyWinPos = false; IniSetInt(L"Settings2",L"StickyWindowPosition",0); } break; @@ -6456,8 +6464,7 @@ void LoadSettings() LoadIniSection(L"Settings2",pIniSection,cchIniSection); // -------------------------------------------------------------------------- - bStickyWinPos = IniSectionGetInt(pIniSection,L"StickyWindowPosition",0); - if (bStickyWinPos) bStickyWinPos = 1; + g_bStickyWinPos = IniSectionGetBool(pIniSection,L"StickyWindowPosition",false); IniSectionGetString(pIniSection,L"DefaultExtension",L"txt", g_tchDefaultExtension,COUNTOF(g_tchDefaultExtension)); StrTrim(g_tchDefaultExtension,L" \t.\""); @@ -6553,15 +6560,16 @@ void LoadSettings() iHighDpiToolBar = 0; } - if (!g_flagPosParam /*|| bStickyWinPos*/) { // ignore window position if /p was specified + if (!g_flagPosParam /*|| g_bStickyWinPos*/) { // ignore window position if /p was specified - WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32]; + WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32], tchZoom[32]; StringCchPrintf(tchPosX,COUNTOF(tchPosX),L"%ix%i PosX",ResX,ResY); StringCchPrintf(tchPosY,COUNTOF(tchPosY),L"%ix%i PosY",ResX,ResY); StringCchPrintf(tchSizeX,COUNTOF(tchSizeX),L"%ix%i SizeX",ResX,ResY); StringCchPrintf(tchSizeY,COUNTOF(tchSizeY),L"%ix%i SizeY",ResX,ResY); StringCchPrintf(tchMaximized,COUNTOF(tchMaximized),L"%ix%i Maximized",ResX,ResY); + StringCchPrintf(tchZoom, COUNTOF(tchZoom), L"%ix%i Zoom", ResX, ResY); g_WinInfo.x = IniSectionGetInt(pIniSection,tchPosX,INT_MAX - 1); g_WinInfo.y = IniSectionGetInt(pIniSection,tchPosY, INT_MAX - 1); @@ -6569,7 +6577,8 @@ void LoadSettings() g_WinInfo.cy = IniSectionGetInt(pIniSection,tchSizeY, INT_MAX - 1); g_WinInfo.max = IniSectionGetInt(pIniSection,tchMaximized,0); if (g_WinInfo.max) g_WinInfo.max = 1; - + g_WinInfo.zoom = IniSectionGetInt(pIniSection, tchZoom, 0); + if (((g_WinInfo.x & ~CW_USEDEFAULT) == (INT_MAX - 1)) || ((g_WinInfo.y & ~CW_USEDEFAULT) == (INT_MAX - 1)) || @@ -6771,19 +6780,21 @@ void SaveSettings(bool bSaveSettingsNow) { if (!IniGetInt(L"Settings2",L"StickyWindowPosition",0)) { - WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32]; + WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32], tchZoom[32]; StringCchPrintf(tchPosX,COUNTOF(tchPosX),L"%ix%i PosX",ResX,ResY); StringCchPrintf(tchPosY,COUNTOF(tchPosY),L"%ix%i PosY",ResX,ResY); StringCchPrintf(tchSizeX,COUNTOF(tchSizeX),L"%ix%i SizeX",ResX,ResY); StringCchPrintf(tchSizeY,COUNTOF(tchSizeY),L"%ix%i SizeY",ResX,ResY); StringCchPrintf(tchMaximized,COUNTOF(tchMaximized),L"%ix%i Maximized",ResX,ResY); + StringCchPrintf(tchZoom, COUNTOF(tchMaximized), L"%ix%i Zoom", ResX, ResY); IniSetInt(L"Window",tchPosX,g_WinInfo.x); IniSetInt(L"Window",tchPosY,g_WinInfo.y); IniSetInt(L"Window",tchSizeX,g_WinInfo.cx); IniSetInt(L"Window",tchSizeY,g_WinInfo.cy); IniSetInt(L"Window",tchMaximized,g_WinInfo.max); + IniSetInt(L"Window",tchZoom, g_WinInfo.zoom); } @@ -9447,6 +9458,7 @@ void SnapToDefaultPos(HWND hwnd) //OffsetRect(&wndpl.rcNormalPosition,mi.rcMonitor.left - mi.rcWork.left,mi.rcMonitor.top - mi.rcWork.top); } SetWindowPlacement(hwnd,&wndpl); + SciCall_SetZoom(g_WinInfo.zoom); } diff --git a/src/SciCall.h b/src/SciCall.h index 470239e2d..32a97f47c 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -174,6 +174,11 @@ DeclareSciCallV2(SetSelectionNAnchor, SETSELECTIONNANCHOR, DocPosU, selnum, DocP DeclareSciCallV2(SetSelectionNCaretVirtualSpace, SETSELECTIONNCARETVIRTUALSPACE, DocPosU, selnum, DocPos, position) DeclareSciCallV2(SetSelectionNAnchorVirtualSpace, SETSELECTIONNANCHORVIRTUALSPACE, DocPosU, selnum, DocPos, position) +// Zoom +DeclareSciCallR0(GetZoom, GETZOOM, int) +DeclareSciCallV1(SetZoom, SETZOOM, int, zoom) +DeclareSciCallV0(ZoomIn, ZOOMIN) +DeclareSciCallV0(ZoomOut, ZOOMOUT) // Operations DeclareSciCallV0(Cut, CUT) diff --git a/src/Styles.c b/src/Styles.c index 4839b45da..a8bb05948 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -5576,9 +5576,11 @@ void Style_SetStyles(HWND hwnd, int iStyle, LPCWSTR lpszStyle, bool bInitDefault } // Size values are relative to BaseFontSize/CurrentFontSize + POINT dpi = GetSystemDpi(); float fBaseFontSize = _GetCurrentFontSize(); if (Style_StrGetSize(lpszStyle, &fBaseFontSize)) { fBaseFontSize = (float)max(0.0, fBaseFontSize); + fBaseFontSize = (float)MulDiv((int)fBaseFontSize, (dpi.x + dpi.y)/2, USER_DEFAULT_SCREEN_DPI); //SendMessage(hwnd, SCI_STYLESETSIZE, iStyle, (int)fBaseFontSize); SendMessage(hwnd, SCI_STYLESETSIZEFRACTIONAL, iStyle, (LPARAM)((int)(fBaseFontSize * SC_FONT_SIZE_MULTIPLIER + 0.5))); if (iStyle == STYLE_DEFAULT) { diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 9dd195e12..1180b4a86 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -52,8 +52,11 @@ typedef struct _wi int cx; int cy; int max; + int zoom; } WININFO; +#define INIT_WININFO { CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0 } + // -------------------------------------------------------------------------- typedef enum BufferSizes