+ chg: initial default base font size depending on screen resolution

This commit is contained in:
Rainer Kottenhoff 2018-10-09 09:52:37 +02:00
parent 1021002e5d
commit 9edf9fc3ae
5 changed files with 27 additions and 20 deletions

View File

@ -181,6 +181,13 @@ DWORD GetLastErrorToMsgBox(LPWSTR lpszFunction, DWORD dwErrID);
// ----------------------------------------------------------------------------
inline bool IsFullHDOrHigher(int resX, int resY) {
if (resX <= 0) { resX = GetSystemMetrics(SM_CXSCREEN); }
if (resY <= 0) { resY = GetSystemMetrics(SM_CYSCREEN); }
return ((resX >= 1920) && (resY >= 1080));
}
// ----------------------------------------------------------------------------
//#define Is2k() (g_uWinVer >= 0x0500)
#define IsXP() IsWindowsXPOrGreater() // Indicates if the current OS version matches,or is greater than,the Windows XP version.
@ -369,7 +376,6 @@ WCHAR* StrNextTokW(WCHAR*, const WCHAR*);
bool StrDelChrA(LPSTR pszSource, LPCSTR pCharsToRemove);
//==== StrSafe lstrlen() =======================================================
inline size_t StringCchLenA(LPCSTR s, size_t n) {
size_t len = (n ? n : STRSAFE_MAX_CCH); return (size_t)(!s ? 0 : (SUCCEEDED(StringCchLengthA(s, len, &len)) ? len : n));

View File

@ -1026,6 +1026,7 @@ HWND InitInstance(HINSTANCE hInstance,LPWSTR pszCmdLine,int nCmdShow)
if (s_WinInfo.zoom) {
SciCall_SetZoom(s_WinInfo.zoom);
}
// Current file information -- moved in front of ShowWindow()
FileLoad(true,true,false,Settings.SkipUnicodeDetection,Settings.SkipANSICodePageDetection,L"");
@ -6918,9 +6919,8 @@ void LoadSettings()
IniSectionGetString(pIniSection, L"BitmapDisabled", L"",
s_tchToolbarBitmapDisabled, COUNTOF(s_tchToolbarBitmap));
int ResX = GetSystemMetrics(SM_CXSCREEN);
int ResY = GetSystemMetrics(SM_CYSCREEN);
int const ResX = GetSystemMetrics(SM_CXSCREEN);
int const ResY = GetSystemMetrics(SM_CYSCREEN);
// --------------------------------------------------------------------------
LoadIniSection(L"Window", pIniSection, cchIniSection);
@ -6931,7 +6931,7 @@ void LoadSettings()
s_iHighDpiToolBar = IniSectionGetInt(pIniSection, tchHighDpiToolBar, -1);
s_iHighDpiToolBar = clampi(s_iHighDpiToolBar, -1, 1);
if (s_iHighDpiToolBar < 0) { // undefined: determine high DPI (higher than Full-HD)
s_iHighDpiToolBar = ((ResX >= 1920) && (ResY >= 1080)) ? 1 : 0;
s_iHighDpiToolBar = IsFullHDOrHigher(ResX, ResY) ? 1 : 0;
}
// --------------------------------------------------------------

View File

@ -11,11 +11,11 @@
// -----------------------------------------------------------------------------
#define INITIAL_BASE_FONT_SIZE (11.0f)
#define BUFZIZE_STYLE_EXTENTIONS 512
#define BUFSIZE_STYLE_VALUE 256
// -----------------------------------------------------------------------------
typedef enum

View File

@ -35,7 +35,7 @@ EDITLEXER lexStandard = {
SCLEX_NULL, IDS_LEX_DEF_TXT, L"Default Text", L"txt; text; wtx; log; asc; doc", L"",
&StdLexFunction, // static
&KeyWords_NULL, {
/* 0 */ { STYLE_DEFAULT, IDS_LEX_STD_STYLE, L"Default Style", L"font:Default; size:11", L"" },
/* 0 */ { STYLE_DEFAULT, IDS_LEX_STD_STYLE, L"Default Style", L"font:Default", L"" },
/* 1 */ { STYLE_LINENUMBER, IDS_LEX_STD_MARGIN, L"Margins and Line Numbers", L"size:-2; fore:#008080", L"" },
/* 2 */ { STYLE_BRACELIGHT, IDS_LEX_STD_BRACE, L"Matching Braces (Indicator)", L"fore:#00FF40; alpha:80; alpha2:80; indic_roundbox", L"" },
/* 3 */ { STYLE_BRACEBAD, IDS_LEX_STD_BRACE_FAIL, L"Matching Braces Error (Indicator)", L"fore:#FF0080; alpha:140; alpha2:140; indic_roundbox", L"" },
@ -58,7 +58,7 @@ EDITLEXER lexStandard2nd = {
SCLEX_NULL, IDS_LEX_STR_63266, L"2nd Default Text", L"txt; text; wtx; log; asc; doc", L"",
&Std2ndLexFunction, // static
&KeyWords_NULL,{
/* 0 */ { STYLE_DEFAULT, IDS_LEX_2ND_STYLE, L"2nd Default Style", L"font:Courier New; size:11", L"" },
/* 0 */ { STYLE_DEFAULT, IDS_LEX_2ND_STYLE, L"2nd Default Style", L"font:Courier New", L"" },
/* 1 */ { STYLE_LINENUMBER, IDS_LEX_2ND_MARGIN, L"2nd Margins and Line Numbers", L"font:Courier New; size:-2; fore:#008080", L"" },
/* 2 */ { STYLE_BRACELIGHT, IDS_LEX_2ND_BRACE, L"2nd Matching Braces (Indicator)", L"fore:#00FF40; alpha:80; alpha2:220; indic_roundbox", L"" },
/* 3 */ { STYLE_BRACEBAD, IDS_LEX_2ND_BRACE_FAIL, L"2nd Matching Braces Error (Indicator)", L"fore:#FF0080; alpha:140; alpha2:220; indic_roundbox", L"" },

View File

@ -179,7 +179,7 @@ bool Style_IsCurLexerStandard()
//
static float _SetBaseFontSize(float fSize)
{
static float fBaseFontSize = INITIAL_BASE_FONT_SIZE;
static float fBaseFontSize = 10.0f;
if (fSize >= 0.0f) {
fBaseFontSize = Round10th(fSize);
@ -212,7 +212,7 @@ int Style_RgbAlpha(int rgbFore, int rgbBack, int alpha)
//
static float _SetCurrentFontSize(float fSize)
{
static float fCurrentFontSize = INITIAL_BASE_FONT_SIZE;
static float fCurrentFontSize = 10.0f;
if (signbit(fSize) == 0) {
float const fSizeR10th = Round10th(fSize);
@ -233,13 +233,11 @@ float Style_GetCurrentFontSize()
//
void Style_Load()
{
WCHAR tch[32] = { L'\0' };
_SetBaseFontSize(IsFullHDOrHigher(-1, -1) ? 11.0f : 10.0f);
size_t const len = NUMLEXERS * AVG_NUM_OF_STYLES_PER_LEXER * 100;
WCHAR *pIniSection = AllocMem(len * sizeof(WCHAR), HEAP_ZERO_MEMORY);
if (pIniSection) {
int const cchIniSection = (int)len;
// Default colors
s_colorDefault[0] = RGB(0x00, 0x00, 0x00);
s_colorDefault[1] = RGB(0x0A, 0x24, 0x6A);
@ -258,6 +256,9 @@ void Style_Load()
s_colorDefault[14] = RGB(0xB0, 0x00, 0xB0);
s_colorDefault[15] = RGB(0xB2, 0x8B, 0x40);
WCHAR tch[32] = { L'\0' };
int const cchIniSection = (int)len;
LoadIniSection(L"Custom Colors", pIniSection, cchIniSection);
for (int i = 0; i < 16; i++) {
WCHAR wch[32] = { L'\0' };
@ -613,8 +614,9 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew)
//~Style_SetACPfromCharSet(hwnd);
// --- apply/init default style ---
_SetBaseFontSize(INITIAL_BASE_FONT_SIZE);
_SetCurrentFontSize(INITIAL_BASE_FONT_SIZE);
float const fBFS = IsFullHDOrHigher(-1, -1) ? 11.0f : 10.0f;
_SetBaseFontSize(fBFS);
_SetCurrentFontSize(fBFS);
Style_SetStyles(hwnd, STYLE_DEFAULT, wchStandardStyleStrg, true);
// --- apply current scheme specific settings to default style ---
@ -2355,14 +2357,13 @@ bool Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, LPCWSTR sLexerNam
}
// is "size:" definition relative ?
bool bRelFontSize = (!StrStrI(lpszStyle, L"size:") || StrStrI(lpszStyle, L"size:+") || StrStrI(lpszStyle, L"size:-"));
bool const bRelFontSize = (!StrStrI(lpszStyle, L"size:") || StrStrI(lpszStyle, L"size:+") || StrStrI(lpszStyle, L"size:-"));
const float fBaseFontSize = (bGlobalDefaultStyle ? INITIAL_BASE_FONT_SIZE : \
(bCurrentDefaultStyle ? _GetBaseFontSize() : Style_GetCurrentFontSize()));
float const fBFS = IsFullHDOrHigher(-1, -1) ? 11.0f : 10.0f;
float const fBaseFontSize = (bGlobalDefaultStyle ? fBFS : (bCurrentDefaultStyle ? _GetBaseFontSize() : Style_GetCurrentFontSize()));
// Font Height
int iFontHeight = 0;
int iPointSize = 0;
float fFontSize = fBaseFontSize;