mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-11 21:03:05 +08:00
Merge branch 'RC2_DEV' into NewFeatures
# Conflicts: # scintilla/win32/PlatWin.cxx # scintilla/win32/PlatWin.h # scintilla/win32/ScintillaWin.cxx # src/Dialogs.c # src/Helpers.c # src/Helpers.h # src/Styles.c
This commit is contained in:
commit
7cdb3be668
@ -138,7 +138,7 @@
|
||||
<LinkTimeCodeGeneration>false</LinkTimeCodeGeneration>
|
||||
</Lib>
|
||||
<Link>
|
||||
<AdditionalDependencies>imm32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>imm32.lib;Shlwapi.lib;Comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@ -165,7 +165,7 @@
|
||||
<LinkLibraryDependencies>true</LinkLibraryDependencies>
|
||||
</ProjectReference>
|
||||
<Link>
|
||||
<AdditionalDependencies>imm32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>imm32.lib;Shlwapi.lib;Comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@ -192,7 +192,7 @@
|
||||
<LinkLibraryDependencies>true</LinkLibraryDependencies>
|
||||
</ProjectReference>
|
||||
<Link>
|
||||
<AdditionalDependencies>imm32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>imm32.lib;Shlwapi.lib;Comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@ -220,7 +220,7 @@
|
||||
<LinkLibraryDependencies>true</LinkLibraryDependencies>
|
||||
</ProjectReference>
|
||||
<Link>
|
||||
<AdditionalDependencies>imm32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>imm32.lib;Shlwapi.lib;Comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@ -15,14 +15,20 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _dpi_t { int x; int y; } DPI_T;
|
||||
|
||||
#if defined(_WIN32)
|
||||
/* Return false on failure: */
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
__declspec(dllexport) int Scintilla_RegisterClasses(void *hInstance);
|
||||
__declspec(dllexport) int Scintilla_ReleaseResources(void);
|
||||
__declspec(dllexport) int Scintilla_InputCodePage(void);
|
||||
|
||||
__declspec(dllexport) int Scintilla_RegisterClasses(void *hInstance);
|
||||
__declspec(dllexport) int Scintilla_ReleaseResources(void);
|
||||
__declspec(dllexport) int Scintilla_InputCodePage(void);
|
||||
__declspec(dllexport) DPI_T Scintilla_GetCurrentDPI(void* hwnd);
|
||||
__declspec(dllexport) int Scintilla_GetSystemMetricsEx(void* hwnd, int nIndex);
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
#endif
|
||||
|
||||
int Scintilla_LinkLexers(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
#include <richedit.h>
|
||||
#include <windowsx.h>
|
||||
#include <shlwapi.h>
|
||||
#include <VersionHelpers.h>
|
||||
|
||||
#include "Platform.h"
|
||||
#include "Scintilla.h"
|
||||
@ -69,13 +70,9 @@
|
||||
#endif
|
||||
|
||||
#if _WIN32_WINNT < _WIN32_WINNT_WIN8
|
||||
#if NP2_FORCE_COMPILE_C_AS_CPP
|
||||
extern DWORD kSystemLibraryLoadFlags;
|
||||
#else
|
||||
extern "C" DWORD kSystemLibraryLoadFlags;
|
||||
#endif
|
||||
#else
|
||||
#define kSystemLibraryLoadFlags LOAD_LIBRARY_SEARCH_SYSTEM32
|
||||
#define kSystemLibraryLoadFlags LOAD_LIBRARY_SEARCH_SYSTEM32
|
||||
#endif
|
||||
|
||||
namespace Scintilla {
|
||||
@ -2631,7 +2628,7 @@ PRectangle ListBoxX::GetDesiredRect() {
|
||||
|
||||
rcDesired.right = rcDesired.left + TextOffset() + width + (TextInset.x * 2);
|
||||
if (Length() > rows)
|
||||
rcDesired.right += GetSystemMetricsDPIScaledX(GetHWND(), SM_CXVSCROLL);
|
||||
rcDesired.right += GetSystemMetricsEx(GetHWND(), SM_CXVSCROLL);
|
||||
|
||||
AdjustWindowRect(&rcDesired);
|
||||
return rcDesired;
|
||||
@ -2879,7 +2876,7 @@ POINT ListBoxX::MinTrackSize() const {
|
||||
|
||||
POINT ListBoxX::MaxTrackSize() const {
|
||||
const int width = maxCharWidth * maxItemCharacters + static_cast<int>(TextInset.x) * 2 +
|
||||
TextOffset() + GetSystemMetricsDPIScaledX(GetHWND(), SM_CXVSCROLL);
|
||||
TextOffset() + GetSystemMetricsEx(GetHWND(), SM_CXVSCROLL);
|
||||
PRectangle rc = PRectangle::FromInts(0, 0,
|
||||
std::max(MinClientWidth(), width),
|
||||
ItemHeight() * lti.Count());
|
||||
@ -2990,7 +2987,7 @@ LRESULT ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const noexcept {
|
||||
// window caption height + frame, even if one is hovering over the bottom edge of
|
||||
// the frame, so workaround that here
|
||||
if (hit >= HTTOP && hit <= HTTOPRIGHT) {
|
||||
const int minHeight = GetSystemMetricsDPIScaledY(hwnd, SM_CYMINTRACK);
|
||||
const int minHeight = GetSystemMetricsEx(hwnd, SM_CYMINTRACK);
|
||||
const int yPos = GET_Y_LPARAM(lParam);
|
||||
if ((rc.Height() < minHeight) && (yPos > ((rc.top + rc.bottom)/2))) {
|
||||
hit += HTBOTTOM - HTTOP;
|
||||
@ -2998,9 +2995,9 @@ LRESULT ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const noexcept {
|
||||
}
|
||||
#if LISTBOXX_USE_BORDER || LISTBOXX_USE_FAKE_FRAME
|
||||
else if (hit < HTSIZEFIRST || hit > HTSIZELAST) {
|
||||
const int cx = GetSystemMetricsDPIScaledX(hwnd, SM_CXVSCROLL);
|
||||
const int cx = GetSystemMetricsEx(hwnd, SM_CXVSCROLL);
|
||||
#if LISTBOXX_USE_BORDER
|
||||
const PRectangle rcInner = rc.Deflate(GetSystemMetricsDPIScaledX(hwnd, SM_CXBORDER), GetSystemMetricsDPIScaledY(hwnd, SM_CYBORDER));
|
||||
const PRectangle rcInner = rc.Deflate(GetSystemMetricsEx(hwnd, SM_CXBORDER), GetSystemMetricsEx(GetHWND(), SM_CYBORDER));
|
||||
#else
|
||||
const PRectangle rcInner = rc.Deflate(ListBoxXFakeFrameSize, ListBoxXFakeFrameSize);
|
||||
#endif
|
||||
@ -3575,4 +3572,71 @@ void Platform_Finalise(bool fromDllMain) noexcept {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// GetCurrentDPI()
|
||||
//
|
||||
#ifdef _WIN64
|
||||
typedef INT_PTR(FAR WINAPI* FARPROCHWND)(HWND);
|
||||
typedef INT_PTR(FAR WINAPI* FARPROCMONI)(HMONITOR, int, UINT*, UINT*);
|
||||
#else
|
||||
typedef int (FAR WINAPI* FARPROCHWND)(HWND);
|
||||
typedef int (FAR WINAPI* FARPROCMONI)(HMONITOR, int, UINT*, UINT*);
|
||||
#endif // _WIN64
|
||||
|
||||
|
||||
DPI_T GetCurrentDPI(HWND hwnd) {
|
||||
|
||||
DPI_T curDPI = { 0, 0 };
|
||||
|
||||
if (IsWindows10OrGreater()) {
|
||||
HMODULE const hModule = GetModuleHandle(L"user32.dll");
|
||||
if (hModule) {
|
||||
FARPROCHWND const pfnGetDpiForWindow = (FARPROCHWND)GetProcAddress(hModule, "GetDpiForWindow");
|
||||
if (pfnGetDpiForWindow) {
|
||||
curDPI.x = curDPI.y = (int)pfnGetDpiForWindow(hwnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((curDPI.x == 0) && IsWindows8Point1OrGreater()) {
|
||||
HMODULE hShcore = LoadLibrary(L"shcore.dll");
|
||||
if (hShcore) {
|
||||
FARPROCMONI const pfnGetDpiForMonitor = (FARPROCMONI)GetProcAddress(hShcore, "GetDpiForMonitor");
|
||||
if (pfnGetDpiForMonitor) {
|
||||
HMONITOR const hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
|
||||
UINT dpiX = 0, dpiY = 0;
|
||||
if (pfnGetDpiForMonitor(hMonitor, 0 /* MDT_EFFECTIVE_DPI */, &dpiX, &dpiY) == S_OK) {
|
||||
curDPI.x = dpiX;
|
||||
curDPI.y = dpiY;
|
||||
}
|
||||
}
|
||||
FreeLibrary(hShcore);
|
||||
}
|
||||
}
|
||||
|
||||
if (curDPI.x == 0) {
|
||||
HDC hDC = GetDC(hwnd);
|
||||
curDPI.x = GetDeviceCaps(hDC, LOGPIXELSX);
|
||||
curDPI.y = GetDeviceCaps(hDC, LOGPIXELSY);
|
||||
ReleaseDC(hwnd, hDC);
|
||||
}
|
||||
|
||||
curDPI.x = std::max((int)curDPI.x, USER_DEFAULT_SCREEN_DPI);
|
||||
curDPI.y = std::max((int)curDPI.y, USER_DEFAULT_SCREEN_DPI);
|
||||
return curDPI;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// GetSystemMetricsEx()
|
||||
// get system metric for current DPI
|
||||
// https://docs.microsoft.com/de-de/windows/desktop/api/winuser/nf-winuser-getsystemmetricsfordpi
|
||||
//
|
||||
int GetSystemMetricsEx(HWND hwnd, int nIndex)
|
||||
{
|
||||
return ScaleIntToDPI_Y(hwnd, GetSystemMetrics(nIndex));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -43,17 +43,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
// force compile C as CPP
|
||||
#define NP2_FORCE_COMPILE_C_AS_CPP 0
|
||||
|
||||
#if NP2_FORCE_COMPILE_C_AS_CPP
|
||||
extern int GetSystemMetricsDPIScaledX(HWND hwnd, int nIndex);
|
||||
extern int GetSystemMetricsDPIScaledY(HWND hwnd, int nIndex);
|
||||
#else
|
||||
extern "C" int GetSystemMetricsDPIScaledX(HWND hwnd, int nIndex);
|
||||
extern "C" int GetSystemMetricsDPIScaledY(HWND hwnd, int nIndex);
|
||||
#endif
|
||||
|
||||
|
||||
namespace Scintilla {
|
||||
|
||||
@ -88,6 +77,12 @@ extern ID2D1Factory *pD2DFactory;
|
||||
extern IDWriteFactory *pIDWriteFactory;
|
||||
#endif
|
||||
|
||||
|
||||
DPI_T GetCurrentDPI(HWND hwnd);
|
||||
int GetSystemMetricsEx(HWND hwnd, int nIndex);
|
||||
inline int ScaleIntToDPI_X(HWND hwnd, int val) { DPI_T const dpi = GetCurrentDPI(hwnd); return MulDiv((val), dpi.x, USER_DEFAULT_SCREEN_DPI); }
|
||||
inline int ScaleIntToDPI_Y(HWND hwnd, int val) { DPI_T const dpi = GetCurrentDPI(hwnd); return MulDiv((val), dpi.y, USER_DEFAULT_SCREEN_DPI); }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -50,6 +50,7 @@
|
||||
#include <shlwapi.h>
|
||||
#include <shlobj.h>
|
||||
#include <shellapi.h>
|
||||
#include <VersionHelpers.h>
|
||||
|
||||
#define DebugDragAndDropDataFormat 0
|
||||
|
||||
@ -150,6 +151,7 @@ constexpr UINT SC_WORK_IDLE = 5002;
|
||||
#endif
|
||||
|
||||
#if _WIN32_WINNT < _WIN32_WINNT_WIN8
|
||||
DWORD kSystemLibraryLoadFlags = 0;
|
||||
using SetCoalescableTimerSig = UINT_PTR (WINAPI *)(HWND hwnd, UINT_PTR nIDEvent,
|
||||
UINT uElapse, TIMERPROC lpTimerFunc, ULONG uToleranceDelay);
|
||||
#endif
|
||||
@ -822,8 +824,8 @@ bool ScintillaWin::DragThreshold(Point ptStart, Point ptNow) noexcept {
|
||||
const Point ptDifference = ptStart - ptNow;
|
||||
const XYPOSITION xMove = std::trunc(std::abs(ptDifference.x));
|
||||
const XYPOSITION yMove = std::trunc(std::abs(ptDifference.y));
|
||||
return (xMove > GetSystemMetricsDPIScaledX(MainHWND(), SM_CXDRAG)) ||
|
||||
(yMove > GetSystemMetricsDPIScaledY(MainHWND(), SM_CYDRAG));
|
||||
return (xMove > GetSystemMetricsEx(MainHWND(), SM_CXDRAG)) ||
|
||||
(yMove > GetSystemMetricsEx(MainHWND(), SM_CYDRAG));
|
||||
}
|
||||
|
||||
void ScintillaWin::StartDrag() {
|
||||
@ -1073,8 +1075,8 @@ sptr_t ScintillaWin::WndPaint() {
|
||||
const PRectangle rcClient = GetClientRectangle();
|
||||
paintingAllText = BoundsContains(rcPaint, hRgnUpdate, rcClient);
|
||||
if (!PaintDC(ps.hdc)) {
|
||||
paintState = paintAbandoned;
|
||||
}
|
||||
paintState = paintAbandoned;
|
||||
}
|
||||
if (hRgnUpdate) {
|
||||
::DeleteRgn(hRgnUpdate);
|
||||
hRgnUpdate = {};
|
||||
@ -3784,7 +3786,14 @@ namespace Scintilla {
|
||||
// Must be called once only.
|
||||
extern "C" __declspec(dllexport)
|
||||
int Scintilla_RegisterClasses(void *hInstance) {
|
||||
|
||||
#if _WIN32_WINNT < _WIN32_WINNT_WIN8
|
||||
// see LoadD2D() in PlatWin.cxx
|
||||
kSystemLibraryLoadFlags = (IsWindows8Point1OrGreater() || GetProcAddress(GetModuleHandle(L"kernel32.dll"), "SetDefaultDllDirectories")) ? LOAD_LIBRARY_SEARCH_SYSTEM32 : 0;
|
||||
#endif
|
||||
|
||||
Platform_Initialise(hInstance);
|
||||
|
||||
const bool result = ScintillaWin::Register(static_cast<HINSTANCE>(hInstance));
|
||||
#ifdef SCI_LEXER
|
||||
Scintilla_LinkLexers();
|
||||
@ -3802,3 +3811,14 @@ extern "C" __declspec(dllexport)
|
||||
int Scintilla_InputCodePage(void) {
|
||||
return InputCodePage();
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport)
|
||||
DPI_T Scintilla_GetCurrentDPI(void* hwnd) {
|
||||
return GetCurrentDPI(static_cast<HWND>(hwnd));
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport)
|
||||
int Scintilla_GetSystemMetricsEx(void* hwnd, int nIndex) {
|
||||
return GetSystemMetricsEx(static_cast<HWND>(hwnd), nIndex);
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#include "ChooseFont.h"
|
||||
#include "FontEnumeration.h"
|
||||
#include "GdiTextRenderer.h"
|
||||
#include "Scintilla.h"
|
||||
|
||||
extern "C" {
|
||||
#include "../resource.h"
|
||||
|
||||
@ -699,7 +699,7 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam
|
||||
{
|
||||
UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0);
|
||||
|
||||
DPI_T const dpi = GetCurrentDPI(hwnd);
|
||||
DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd);
|
||||
SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETZOOM, (WPARAM)dpi.y, (LPARAM)USER_DEFAULT_SCREEN_DPI);
|
||||
|
||||
//~~// get current richedit box format
|
||||
@ -844,7 +844,7 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam
|
||||
StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Screen-Resolution = %i x %i [pix]", ResX, ResY);
|
||||
StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
|
||||
|
||||
DPI_T dpi = GetCurrentDPI(hwnd);
|
||||
DPI_T dpi = Scintilla_GetCurrentDPI(hwnd);
|
||||
StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Display-DPI = %i x %i (Scale: %i%%).", dpi.x, dpi.y, ScaleIntToDPI_X(hwnd, 100));
|
||||
StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
|
||||
|
||||
@ -3920,7 +3920,7 @@ void ResizeDlg_InitEx(HWND hwnd, int cxFrame, int cyFrame, int nIdGrip, int iDir
|
||||
HWND hwndCtl = GetDlgItem(hwnd, nIdGrip);
|
||||
SetWindowLongPtr(hwndCtl, GWL_STYLE, GetWindowLongPtr(hwndCtl, GWL_STYLE) | SBS_SIZEGRIP | WS_CLIPSIBLINGS);
|
||||
/// TODO: per-window DPI
|
||||
const int cGrip = GetSystemMetricsDPIScaledX(hwnd, SM_CXHTHUMB);
|
||||
const int cGrip = Scintilla_GetSystemMetricsEx(hwnd, SM_CXHTHUMB);
|
||||
SetWindowPos(hwndCtl, NULL, pm->cxClient - cGrip, pm->cyClient - cGrip, cGrip, cGrip, SWP_NOZORDER);
|
||||
}
|
||||
|
||||
@ -4419,52 +4419,6 @@ DPI_T GetCurrentPPI(HWND hwnd) {
|
||||
return ppi;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// GetCurrentDPI()
|
||||
//
|
||||
DPI_T GetCurrentDPI(HWND hwnd) {
|
||||
|
||||
DPI_T curDPI = { 0, 0 };
|
||||
|
||||
if (IsWin10OrHigher()) {
|
||||
HMODULE const hModule = GetModuleHandle(L"user32.dll");
|
||||
if (hModule) {
|
||||
FARPROC const pfnGetDpiForWindow = GetProcAddress(hModule, "GetDpiForWindow");
|
||||
if (pfnGetDpiForWindow) {
|
||||
curDPI.x = curDPI.y = (UINT)pfnGetDpiForWindow(hwnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((curDPI.x == 0) && IsWin81OrHigher()) {
|
||||
HMODULE hShcore = LoadLibrary(L"shcore.dll");
|
||||
if (hShcore) {
|
||||
FARPROC const pfnGetDpiForMonitor = GetProcAddress(hShcore, "GetDpiForMonitor");
|
||||
if (pfnGetDpiForMonitor) {
|
||||
HMONITOR const hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
|
||||
UINT dpiX = 0, dpiY = 0;
|
||||
if (pfnGetDpiForMonitor(hMonitor, 0 /* MDT_EFFECTIVE_DPI */, &dpiX, &dpiY) == S_OK) {
|
||||
curDPI.x = dpiX;
|
||||
curDPI.y = dpiY;
|
||||
}
|
||||
}
|
||||
FreeLibrary(hShcore);
|
||||
}
|
||||
}
|
||||
|
||||
if (curDPI.x == 0) {
|
||||
curDPI = GetCurrentPPI(hwnd); // fallback to device caps
|
||||
}
|
||||
|
||||
curDPI.x = max_u(curDPI.x, USER_DEFAULT_SCREEN_DPI);
|
||||
curDPI.y = max_u(curDPI.y, USER_DEFAULT_SCREEN_DPI);
|
||||
return curDPI;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if (!bSucceed) {
|
||||
NONCLIENTMETRICS ncm;
|
||||
@ -4478,22 +4432,6 @@ if (!bSucceed) {
|
||||
}*/
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// GetSystemMetricsDPIScaled()
|
||||
// get system metric for current DPI
|
||||
// https://docs.microsoft.com/de-de/windows/desktop/api/winuser/nf-winuser-getsystemmetricsfordpi
|
||||
|
||||
int GetSystemMetricsDPIScaledX(HWND hwnd, const int nValue)
|
||||
{
|
||||
return ScaleIntToDPI_X(hwnd, GetSystemMetrics(nValue));
|
||||
}
|
||||
|
||||
int GetSystemMetricsDPIScaledY(HWND hwnd, const int nValue)
|
||||
{
|
||||
return ScaleIntToDPI_Y(hwnd, GetSystemMetrics(nValue));
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// UpdateWindowLayoutForDPI()
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
|
||||
#include <math.h>
|
||||
#include "TypeDefs.h"
|
||||
#include "Scintilla.h"
|
||||
|
||||
INT_PTR DisplayCmdLineHelp(HWND hwnd);
|
||||
bool GetDirectory(HWND hwndParent,int uiTitle,LPWSTR pszFolder,LPCWSTR pszBase,bool);
|
||||
@ -110,38 +111,34 @@ int Toolbar_SetButtons(HANDLE, int, LPCWSTR, void*, int);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int GetSystemMetricsDPIScaledX(HWND hwnd, const int nValue);
|
||||
int GetSystemMetricsDPIScaledY(HWND hwnd, const int nValue);
|
||||
|
||||
DPI_T GetCurrentPPI(HWND hwnd);
|
||||
DPI_T GetCurrentDPI(HWND hwnd);
|
||||
|
||||
inline int ScaleIntToDPI_X(HWND hwnd, int val) { DPI_T const dpi = GetCurrentDPI(hwnd); return MulDiv((val), dpi.x, USER_DEFAULT_SCREEN_DPI); }
|
||||
inline int ScaleIntToDPI_Y(HWND hwnd, int val) { DPI_T const dpi = GetCurrentDPI(hwnd); return MulDiv((val), dpi.y, USER_DEFAULT_SCREEN_DPI); }
|
||||
inline int ScaleIntToDPI_X(HWND hwnd, int val) { DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd); return MulDiv((val), dpi.x, USER_DEFAULT_SCREEN_DPI); }
|
||||
inline int ScaleIntToDPI_Y(HWND hwnd, int val) { DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd); return MulDiv((val), dpi.y, USER_DEFAULT_SCREEN_DPI); }
|
||||
|
||||
inline int ScaleFloatToDPI_X(HWND hwnd, float fVal) { DPI_T const dpi = GetCurrentDPI(hwnd); return (int)lroundf((fVal * dpi.x) / (float)USER_DEFAULT_SCREEN_DPI); }
|
||||
inline int ScaleFloatToDPI_Y(HWND hwnd, float fVal) { DPI_T const dpi = GetCurrentDPI(hwnd); return (int)lroundf((fVal * dpi.y) / (float)USER_DEFAULT_SCREEN_DPI); }
|
||||
inline int ScaleFloatToDPI_X(HWND hwnd, float fVal) { DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd); return (int)lroundf((fVal * dpi.x) / (float)USER_DEFAULT_SCREEN_DPI); }
|
||||
inline int ScaleFloatToDPI_Y(HWND hwnd, float fVal) { DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd); return (int)lroundf((fVal * dpi.y) / (float)USER_DEFAULT_SCREEN_DPI); }
|
||||
|
||||
inline int ScaleIntFontSizeWidth(HWND hwnd, int val) {
|
||||
DPI_T const dpi = GetCurrentDPI(hwnd);
|
||||
DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd);
|
||||
DPI_T const ppi = GetCurrentPPI(hwnd);
|
||||
return MulDiv((val), dpi.x, ppi.x);
|
||||
}
|
||||
|
||||
inline int ScaleIntFontSizeHeight(HWND hwnd, int val) {
|
||||
DPI_T const dpi = GetCurrentDPI(hwnd);
|
||||
DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd);
|
||||
DPI_T const ppi = GetCurrentPPI(hwnd);
|
||||
return MulDiv((val), dpi.y, ppi.y);
|
||||
}
|
||||
|
||||
inline int ScaleFloatFontSize(HWND hwnd, float fSize) {
|
||||
DPI_T const dpi = GetCurrentDPI(hwnd);
|
||||
DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd);
|
||||
DPI_T const ppi = GetCurrentPPI(hwnd);
|
||||
return (int)lroundf((fSize * (float)dpi.y) / (float)ppi.y);
|
||||
}
|
||||
|
||||
inline int ScaleFractionalFontSize(HWND hwnd, float fSize) {
|
||||
DPI_T const dpi = GetCurrentDPI(hwnd);
|
||||
DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd);
|
||||
DPI_T const ppi = GetCurrentPPI(hwnd);
|
||||
return (int)lroundf((fSize * 10.0f * dpi.y) / (float)ppi.y) * 10;
|
||||
}
|
||||
|
||||
@ -214,26 +214,26 @@ void GetWinVersionString(LPWSTR szVersionStr, size_t cchVersionStr)
|
||||
{
|
||||
StringCchCopy(szVersionStr, cchVersionStr, L"OS Version: Windows ");
|
||||
|
||||
if (IsWin10OrHigher()) {
|
||||
StringCchCat(szVersionStr, cchVersionStr, IsWinServer() ? L"Server 2016 " : L"10 ");
|
||||
if (IsWindows10OrGreater()) {
|
||||
StringCchCat(szVersionStr, cchVersionStr, IsWindowsServer() ? L"Server 2016 " : L"10 ");
|
||||
}
|
||||
else if (IsWin81OrHigher()) {
|
||||
StringCchCat(szVersionStr, cchVersionStr, IsWinServer() ? L"Server 2012 R2 " : L"8.1");
|
||||
else if (IsWindows8Point1OrGreater()) {
|
||||
StringCchCat(szVersionStr, cchVersionStr, IsWindowsServer() ? L"Server 2012 R2 " : L"8.1");
|
||||
}
|
||||
else if (IsWin8OrHigher()) {
|
||||
StringCchCat(szVersionStr, cchVersionStr, IsWinServer() ? L"Server 2012 " : L"8");
|
||||
else if (IsWindows8OrGreater()) {
|
||||
StringCchCat(szVersionStr, cchVersionStr, IsWindowsServer() ? L"Server 2012 " : L"8");
|
||||
}
|
||||
else if (IsWin71OrHigher()) {
|
||||
StringCchCat(szVersionStr, cchVersionStr, IsWinServer() ? L"Server 2008 R2 " : L"7 (SP1)");
|
||||
else if (IsWindows7SP1OrGreater()) {
|
||||
StringCchCat(szVersionStr, cchVersionStr, IsWindowsServer() ? L"Server 2008 R2 " : L"7 (SP1)");
|
||||
}
|
||||
else if (IsWin7OrHigher()) {
|
||||
StringCchCat(szVersionStr, cchVersionStr, IsWinServer() ? L"Server 2008 " : L"7");
|
||||
else if (IsWindows7OrGreater()) {
|
||||
StringCchCat(szVersionStr, cchVersionStr, IsWindowsServer() ? L"Server 2008 " : L"7");
|
||||
}
|
||||
else {
|
||||
StringCchCat(szVersionStr, cchVersionStr, IsWinServer() ? L"Unkown Server " : L"?");
|
||||
StringCchCat(szVersionStr, cchVersionStr, IsWindowsServer() ? L"Unkown Server " : L"?");
|
||||
}
|
||||
|
||||
if (IsWin10OrHigher()) {
|
||||
if (IsWindows10OrGreater()) {
|
||||
WCHAR win10ver[80] = { L'\0' };
|
||||
if (s_OSversion.dwOSVersionInfoSize == 0) { _GetTrueWindowsVersion(); }
|
||||
DWORD const build = s_OSversion.dwBuildNumber;
|
||||
@ -312,7 +312,7 @@ bool IsProcessElevated() {
|
||||
// Vista, GetTokenInformation returns FALSE with the
|
||||
// ERROR_INVALID_PARAMETER error code because TokenElevation is
|
||||
// not supported on those operating systems.
|
||||
if (!IsVistaOrHigher()) { return false; }
|
||||
if (!IsWindowsVistaOrGreater()) { return false; }
|
||||
|
||||
bool bIsElevated = false;
|
||||
HANDLE hToken = NULL;
|
||||
|
||||
@ -24,6 +24,8 @@
|
||||
#include <heapapi.h>
|
||||
#include <versionhelpers.h>
|
||||
|
||||
#include "Scintilla.h"
|
||||
|
||||
// ============================================================================
|
||||
// --- Disable/Enable some CodeAnalysis Warnings ---
|
||||
|
||||
@ -178,30 +180,6 @@ inline COLORREF GetBackgroundColor(HWND hwnd) { return GetBkColor(GetDC(hwnd));
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
//#define Is2k() (g_uWinVer >= 0x0500)
|
||||
#define IsXPOrHigher() IsWindowsXPOrGreater() // Indicates if the current OS version matches,or is greater than,the Windows XP version.
|
||||
#define IsXP1OrHigher() IsWindowsXPSP1OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows XP with Service Pack 1 (SP1)version.
|
||||
#define IsXP2OrHigher() IsWindowsXPSP2OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows XP with Service Pack 2 (SP2)version.
|
||||
#define IsXP3OrHigher() IsWindowsXPSP3OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows XP with Service Pack 3 (SP3)version.
|
||||
|
||||
#define IsVistaOrHigher() IsWindowsVistaOrGreater() // Indicates if the current OS version matches,or is greater than,the Windows Vista version.
|
||||
#define IsVista1OrHigher() IsWindowsVistaSP1OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows Vista with Service Pack 1 (SP1)version.
|
||||
#define IsVista2OrHigher() IsWindowsVistaSP2OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows Vista with Service Pack 2 (SP2)version.
|
||||
|
||||
#define IsWin7OrHigher() IsWindows7OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows 7 version.
|
||||
#define IsWin71OrHigher() IsWindows7SP1OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows 7 with Service Pack 1 (SP1)version.
|
||||
#define IsWin8OrHigher() IsWindows8OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows 8 version.
|
||||
#define IsWin81OrHigher() IsWindows8Point1OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows 8.1 version.
|
||||
// For Windows 10,IsWindows8Point1OrGreater returns false unless the application contains a manifest that includes
|
||||
// a compatibility section that contains the GUIDs that designate Windows 8.1 and/or Windows 10.
|
||||
|
||||
#define IsWin10OrHigher() IsWindows10OrGreater() // Indicates if the current OS version matches, or is greater than, the Windows 10 version.
|
||||
// For Windows 10,IsWindows10OrGreater returns false unless the application contains a manifest that includes
|
||||
// a compatibility section that contains the GUID that designates Windows 10.
|
||||
|
||||
#define IsWinServer() IsWindowsServer() // Indicates if the current OS is a Windows Server release.
|
||||
// Applications that need to distinguish between server and client versions of Windows should call this function.
|
||||
|
||||
void GetWinVersionString(LPWSTR szVersionStr, size_t cchVersionStr);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@ -201,10 +201,6 @@ static TBBUTTON s_tbbMainWnd[] = {
|
||||
};
|
||||
static const int NUMTOOLBITMAPS = 29;
|
||||
|
||||
#if _WIN32_WINNT < _WIN32_WINNT_WIN8
|
||||
DWORD kSystemLibraryLoadFlags = 0;
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
const WCHAR* const TBBUTTON_DEFAULT_IDS_V1 = L"1 2 4 3 28 0 5 6 0 7 8 9 0 10 11 0 12 0 24 26 0 22 23 0 13 14 0 27 0 15 0 25 0 17";
|
||||
@ -667,7 +663,7 @@ static void _InitGlobals()
|
||||
Flags.RelativeFileMRU = DefaultFlags.RelativeFileMRU = true;
|
||||
Flags.PortableMyDocs = DefaultFlags.PortableMyDocs = Flags.RelativeFileMRU;
|
||||
Flags.NoFadeHidden = DefaultFlags.NoFadeHidden = false;
|
||||
Flags.ToolbarLook = DefaultFlags.ToolbarLook = IsXPOrHigher() ? 1 : 2;
|
||||
Flags.ToolbarLook = DefaultFlags.ToolbarLook = IsWindowsXPSP3OrGreater() ? 1 : 2;
|
||||
Flags.SimpleIndentGuides = DefaultFlags.SimpleIndentGuides = false;
|
||||
Flags.NoHTMLGuess =DefaultFlags.NoHTMLGuess = false;
|
||||
Flags.NoCGIGuess = DefaultFlags.NoCGIGuess = false;
|
||||
@ -820,8 +816,8 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
|
||||
|
||||
// check if running at least on Windows 7
|
||||
if (!IsWin7OrHigher()) {
|
||||
// check if running at least on Windows 7 (SP1)
|
||||
if (!IsWindows7SP1OrGreater()) {
|
||||
MsgBoxLastError(L"Application Initialization", ERROR_OLD_WIN_VERSION);
|
||||
return 1; // exit
|
||||
}
|
||||
@ -859,11 +855,6 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
icex.dwICC = ICC_WIN95_CLASSES | ICC_COOL_CLASSES | ICC_BAR_CLASSES | ICC_USEREX_CLASSES;
|
||||
InitCommonControlsEx(&icex);
|
||||
|
||||
#if _WIN32_WINNT < _WIN32_WINNT_WIN8
|
||||
// see LoadD2D() in PlatWin.cxx
|
||||
kSystemLibraryLoadFlags = (IsWin8OrHigher() || GetProcAddress(GetModuleHandle(L"kernel32.dll"), "SetDefaultDllDirectories")) ? LOAD_LIBRARY_SEARCH_SYSTEM32 : 0;
|
||||
#endif
|
||||
|
||||
Scintilla_RegisterClasses(hInstance);
|
||||
|
||||
//SetProcessDPIAware(); -> .manifest
|
||||
@ -1705,7 +1696,7 @@ static void _SetWrapVisualFlags(HWND hwndEditCtrl)
|
||||
//
|
||||
static void _InitializeSciEditCtrl(HWND hwndEditCtrl)
|
||||
{
|
||||
if (IsVistaOrHigher()) {
|
||||
if (IsWindowsVistaOrGreater()) {
|
||||
// Current platforms perform window buffering so it is almost always better for this option to be turned off.
|
||||
// There are some older platforms and unusual modes where buffering may still be useful - so keep it ON
|
||||
//~SciCall_SetBufferedDraw(true); // default is true
|
||||
@ -1943,7 +1934,7 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam,LPARAM lParam)
|
||||
SetWindowLongPtr(Globals.hwndEdit,GWL_EXSTYLE,GetWindowLongPtr(Globals.hwndEdit,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE);
|
||||
SetWindowPos(Globals.hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
|
||||
|
||||
if (IsVistaOrHigher()) {
|
||||
if (IsWindowsVistaOrGreater()) {
|
||||
s_cxEditFrame = 0;
|
||||
s_cyEditFrame = 0;
|
||||
}
|
||||
@ -2138,7 +2129,7 @@ static HIMAGELIST CreateScaledImageListFromBitmap(HWND hWnd, HBITMAP hBmp)
|
||||
HIMAGELIST himl = ImageList_Create(cx, cy, ILC_COLOR32 | ILC_MASK, NUMTOOLBITMAPS, NUMTOOLBITMAPS);
|
||||
ImageList_AddMasked(himl, hBmp, CLR_DEFAULT);
|
||||
|
||||
DPI_T dpi = GetCurrentDPI(hWnd);
|
||||
DPI_T dpi = Scintilla_GetCurrentDPI(hWnd);
|
||||
if (!Settings.DpiScaleToolBar ||
|
||||
((dpi.x == USER_DEFAULT_SCREEN_DPI) && (dpi.y == USER_DEFAULT_SCREEN_DPI)))
|
||||
{
|
||||
@ -2289,10 +2280,10 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance)
|
||||
if (Flags.ToolbarLook == 1) {
|
||||
bProcessed = BitmapAlphaBlend(hbmpCopy, GetSysColor(COLOR_3DFACE), 0x60);
|
||||
}
|
||||
else if (Flags.ToolbarLook == 2 || (!IsXPOrHigher() && Flags.ToolbarLook == 0)) {
|
||||
else if (Flags.ToolbarLook == 2 || (!IsWindowsXPSP3OrGreater() && Flags.ToolbarLook == 0)) {
|
||||
bProcessed = BitmapGrayScale(hbmpCopy);
|
||||
}
|
||||
if (bProcessed && !IsXPOrHigher()) {
|
||||
if (bProcessed && !IsWindowsXPSP3OrGreater()) {
|
||||
BitmapMergeAlpha(hbmpCopy, GetSysColor(COLOR_3DFACE));
|
||||
}
|
||||
if (bProcessed)
|
||||
@ -2509,7 +2500,7 @@ LRESULT MsgThemeChanged(HWND hwnd, WPARAM wParam ,LPARAM lParam)
|
||||
SetWindowLongPtr(Globals.hwndEdit,GWL_EXSTYLE,GetWindowLongPtr(Globals.hwndEdit,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE);
|
||||
SetWindowPos(Globals.hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE);
|
||||
|
||||
if (IsVistaOrHigher()) {
|
||||
if (IsWindowsVistaOrGreater()) {
|
||||
s_cxEditFrame = 0;
|
||||
s_cyEditFrame = 0;
|
||||
}
|
||||
@ -10332,7 +10323,7 @@ bool RelaunchMultiInst() {
|
||||
//
|
||||
bool RelaunchElevated(LPWSTR lpNewCmdLnArgs)
|
||||
{
|
||||
if (!IsVistaOrHigher() || !Flags.bDoRelaunchElevated ||
|
||||
if (!IsWindowsVistaOrGreater() || !Flags.bDoRelaunchElevated ||
|
||||
s_bIsProcessElevated || s_IsThisAnElevatedRelaunch || s_bIsRunAsAdmin ||
|
||||
s_flagDisplayHelp)
|
||||
{
|
||||
|
||||
@ -3092,7 +3092,7 @@ bool Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, LPCWSTR sLexerNam
|
||||
|
||||
// --- open systems Font Selection dialog ---
|
||||
if (Settings.RenderingTechnology > 0) {
|
||||
DPI_T const dpi = GetCurrentDPI(hwnd);
|
||||
DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd);
|
||||
if (!ChooseFontDirectWrite(Globals.hwndMain, Settings2.PreferredLanguageLocaleName, dpi, &cf) ||
|
||||
(lf.lfFaceName[0] == L'\0')) {
|
||||
return false;
|
||||
@ -4451,7 +4451,7 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR
|
||||
SetWindowLongPtr(GetDlgItem(hwnd,IDC_RESIZEGRIP),GWL_STYLE,
|
||||
GetWindowLongPtr(GetDlgItem(hwnd,IDC_RESIZEGRIP),GWL_STYLE)|SBS_SIZEGRIP|WS_CLIPSIBLINGS);
|
||||
|
||||
int const cGrip = GetSystemMetricsDPIScaledX(hwnd, SM_CXHTHUMB);
|
||||
int cGrip = Scintilla_GetSystemMetricsEx(hwnd, SM_CXHTHUMB);
|
||||
SetWindowPos(GetDlgItem(hwnd,IDC_RESIZEGRIP),NULL,cxClient-cGrip,
|
||||
cyClient-cGrip,cGrip,cGrip,SWP_NOZORDER);
|
||||
|
||||
|
||||
@ -72,12 +72,6 @@ typedef DocPos DocLn; // Sci::Line
|
||||
//typedef intptr_t cpi_enc_t;
|
||||
typedef int cpi_enc_t;
|
||||
|
||||
typedef struct _dpi_t
|
||||
{
|
||||
UINT x;
|
||||
UINT y;
|
||||
} DPI_T;
|
||||
|
||||
typedef struct _wi
|
||||
{
|
||||
int x;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user