mirror of
https://github.com/henrypp/simplewall.git
synced 2026-10-22 02:52:54 -05:00
fixed toolbar font
This commit is contained in:
5 files changed
+59
-9
No files matched your search
+45
-5
@@ -689,6 +689,7 @@ VOID _app_setinterfacestate (_In_ HWND hwnd, _In_ LONG dpi_value)
|
||||
dpi_value = _r_dc_gettaskbardpi ();
|
||||
|
||||
icon_small_x = _r_dc_getsystemmetrics (SM_CXSMICON, dpi_value);
|
||||
icon_small_y = _r_dc_getsystemmetrics (SM_CYSMICON, dpi_value);
|
||||
|
||||
hico_sm = _r_sys_loadsharedicon (_r_sys_getimagebase (), MAKEINTRESOURCE (icon_id), icon_small_x, icon_small_y);
|
||||
|
||||
@@ -975,7 +976,7 @@ VOID _app_listviewloadfont (_In_ LONG dpi_value, _In_ BOOLEAN is_forced)
|
||||
|
||||
_r_config_getfont (L"Font", &logfont, dpi_value);
|
||||
|
||||
config.hfont = CreateFontIndirect (&logfont);
|
||||
config.hfont = _app_createfont (&logfont, 0, FALSE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -985,6 +986,32 @@ VOID _app_listviewsetfont (_In_ HWND hwnd, _In_ INT listview_id)
|
||||
SendDlgItemMessage (hwnd, listview_id, WM_SETFONT, (WPARAM)config.hfont, TRUE);
|
||||
}
|
||||
|
||||
HFONT _app_createfont (_Inout_ PLOGFONT logfont, _In_ LONG size, _In_ BOOLEAN is_underline, _In_ LONG dpi_value)
|
||||
{
|
||||
if (size)
|
||||
logfont->lfHeight = _r_dc_fontsizetoheight (size, dpi_value);
|
||||
|
||||
logfont->lfUnderline = is_underline;
|
||||
logfont->lfCharSet = DEFAULT_CHARSET;
|
||||
logfont->lfQuality = DEFAULT_QUALITY;
|
||||
|
||||
return CreateFontIndirect (logfont);
|
||||
}
|
||||
|
||||
VOID _app_windowloadfont (_In_ LONG dpi_value)
|
||||
{
|
||||
NONCLIENTMETRICS ncm = {0};
|
||||
|
||||
ncm.cbSize = sizeof (ncm);
|
||||
|
||||
if (!_r_dc_getsystemparametersinfo (SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, dpi_value))
|
||||
return;
|
||||
|
||||
SAFE_DELETE_OBJECT (config.wnd_font);
|
||||
|
||||
config.wnd_font = _app_createfont (&ncm.lfMessageFont, 0, FALSE, 0);
|
||||
}
|
||||
|
||||
INT CALLBACK _app_listviewcompare_callback (_In_ LPARAM lparam1, _In_ LPARAM lparam2, _In_ LPARAM lparam)
|
||||
{
|
||||
WCHAR config_name[128];
|
||||
@@ -1167,6 +1194,8 @@ VOID _app_toolbar_init (_In_ HWND hwnd, _In_ LONG dpi_value)
|
||||
|
||||
config.hrebar = GetDlgItem (hwnd, IDC_REBAR);
|
||||
|
||||
_app_windowloadfont (dpi_value);
|
||||
|
||||
SendMessage (config.hrebar, RB_SETBARINFO, 0, (LPARAM)(&(REBARINFO)
|
||||
{
|
||||
sizeof (REBARINFO)
|
||||
@@ -1191,6 +1220,9 @@ VOID _app_toolbar_init (_In_ HWND hwnd, _In_ LONG dpi_value)
|
||||
{
|
||||
_r_toolbar_setstyle (config.hrebar, IDC_TOOLBAR, TBSTYLE_EX_DOUBLEBUFFER | TBSTYLE_EX_MIXEDBUTTONS | TBSTYLE_EX_HIDECLIPPEDBUTTONS);
|
||||
|
||||
SendMessage (config.htoolbar, WM_SETFONT, (WPARAM)config.wnd_font, TRUE); // fix font
|
||||
SendMessage (config.htoolbar, TB_SETIMAGELIST, 0, (LPARAM)config.himg_toolbar);
|
||||
|
||||
_r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_START, 0, BTNS_BUTTON | BTNS_AUTOSIZE, TBSTATE_ENABLED, I_IMAGENONE);
|
||||
_r_toolbar_addseparator (config.hrebar, IDC_TOOLBAR);
|
||||
_r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_OPENRULESEDITOR, 0, BTNS_BUTTON | BTNS_AUTOSIZE, TBSTATE_ENABLED, 8);
|
||||
@@ -1207,9 +1239,6 @@ VOID _app_toolbar_init (_In_ HWND hwnd, _In_ LONG dpi_value)
|
||||
_r_toolbar_addseparator (config.hrebar, IDC_TOOLBAR);
|
||||
_r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_DONATE, 0, BTNS_BUTTON | BTNS_AUTOSIZE, TBSTATE_ENABLED, 9);
|
||||
|
||||
SendMessage (config.htoolbar, TB_SETIMAGELIST, 0, (LPARAM)config.himg_toolbar);
|
||||
SendMessage (config.htoolbar, WM_SETFONT, SendMessage (config.hrebar, WM_GETFONT, 0, 0), TRUE); // fix font
|
||||
|
||||
_r_toolbar_resize (config.hrebar, IDC_TOOLBAR);
|
||||
|
||||
// insert toolbar
|
||||
@@ -1244,7 +1273,7 @@ VOID _app_toolbar_init (_In_ HWND hwnd, _In_ LONG dpi_value)
|
||||
|
||||
if (config.hsearchbar)
|
||||
{
|
||||
SendMessage (config.hsearchbar, WM_SETFONT, SendMessage (config.hrebar, WM_GETFONT, 0, 0), TRUE); // fix font
|
||||
SendMessage (config.hsearchbar, WM_SETFONT, (WPARAM)config.wnd_font, TRUE); // fix font
|
||||
|
||||
_app_search_initialize (config.hsearchbar);
|
||||
_app_search_setvisible (hwnd, config.hsearchbar);
|
||||
@@ -1270,6 +1299,8 @@ VOID _app_toolbar_resize (_In_ HWND hwnd, _In_ LONG dpi_value)
|
||||
ULONG button_size;
|
||||
UINT rebar_count;
|
||||
|
||||
_app_toolbar_setfont ();
|
||||
|
||||
SendMessage (config.htoolbar, TB_AUTOSIZE, 0, 0);
|
||||
|
||||
rebar_count = (UINT)SendMessage (config.hrebar, RB_GETBANDCOUNT, 0, 0);
|
||||
@@ -1310,6 +1341,15 @@ VOID _app_toolbar_resize (_In_ HWND hwnd, _In_ LONG dpi_value)
|
||||
}
|
||||
}
|
||||
|
||||
VOID _app_toolbar_setfont ()
|
||||
{
|
||||
if (config.htoolbar)
|
||||
SendMessage (config.htoolbar, WM_SETFONT, (WPARAM)config.wnd_font, TRUE); // fix font
|
||||
|
||||
if (config.hsearchbar)
|
||||
SendMessage (config.hsearchbar, WM_SETFONT, (WPARAM)config.wnd_font, TRUE); // fix font
|
||||
}
|
||||
|
||||
VOID _app_window_resize (_In_ HWND hwnd, _In_ LPCRECT rect, _In_ LONG dpi_value)
|
||||
{
|
||||
HDWP hdefer;
|
||||
|
||||
@@ -44,11 +44,15 @@ VOID _app_listviewsetview (_In_ HWND hwnd, _In_ INT listview_id);
|
||||
VOID _app_listviewloadfont (_In_ LONG dpi_value, _In_ BOOLEAN is_forced);
|
||||
VOID _app_listviewsetfont (_In_ HWND hwnd, _In_ INT listview_id);
|
||||
|
||||
HFONT _app_createfont (_Inout_ PLOGFONT logfont, _In_ LONG size, _In_ BOOLEAN is_underline, _In_ LONG dpi_value);
|
||||
VOID _app_windowloadfont (_In_ LONG dpi_value);
|
||||
|
||||
INT CALLBACK _app_listviewcompare_callback (_In_ LPARAM lparam1, _In_ LPARAM lparam2, _In_ LPARAM lparam);
|
||||
VOID _app_listviewsort (_In_ HWND hwnd, _In_ INT listview_id, _In_ LONG column_id, _In_ BOOLEAN is_notifycode);
|
||||
|
||||
VOID _app_toolbar_init (_In_ HWND hwnd, _In_ LONG dpi_value);
|
||||
VOID _app_toolbar_resize (_In_ HWND hwnd, _In_ LONG dpi_value);
|
||||
VOID _app_toolbar_setfont ();
|
||||
|
||||
VOID _app_window_resize (_In_ HWND hwnd, _In_ LPCRECT rect, _In_ LONG dpi_value);
|
||||
|
||||
|
||||
+4
-2
@@ -2104,11 +2104,13 @@ INT_PTR CALLBACK DlgProc (_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wparam, _In
|
||||
|
||||
dpi_value = _r_dc_getwindowdpi (hwnd);
|
||||
|
||||
_app_toolbar_resize (hwnd, dpi_value);
|
||||
|
||||
_app_windowloadfont (dpi_value);
|
||||
_app_listviewloadfont (dpi_value, TRUE);
|
||||
|
||||
_app_updatelistviewbylparam (hwnd, DATA_LISTVIEW_CURRENT, PR_UPDATE_TYPE | PR_UPDATE_FORCE);
|
||||
|
||||
SendMessage (hwnd, WM_SIZE, 0, 0);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -222,6 +222,8 @@ typedef struct _STATIC_DATA
|
||||
volatile HWND hnotification;
|
||||
|
||||
HFONT hfont;
|
||||
HFONT wnd_font;
|
||||
|
||||
HWND hrebar;
|
||||
HWND htoolbar;
|
||||
HWND hsearchbar;
|
||||
|
||||
+4
-2
@@ -409,6 +409,8 @@ VOID _app_message_dpichanged (_In_ HWND hwnd, _In_ LONG dpi_value)
|
||||
{
|
||||
PR_STRING localized_string = NULL;
|
||||
|
||||
_app_windowloadfont (dpi_value);
|
||||
|
||||
_app_imagelist_init (hwnd, dpi_value);
|
||||
|
||||
// reset toolbar information
|
||||
@@ -432,11 +434,11 @@ VOID _app_message_dpichanged (_In_ HWND hwnd, _In_ LONG dpi_value)
|
||||
|
||||
_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_DONATE, _r_locale_getstring (IDS_DONATE), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE);
|
||||
|
||||
_app_toolbar_resize (hwnd, dpi_value);
|
||||
|
||||
_app_listviewloadfont (dpi_value, TRUE);
|
||||
_app_updatelistviewbylparam (hwnd, DATA_LISTVIEW_CURRENT, PR_UPDATE_TYPE | PR_UPDATE_FORCE);
|
||||
|
||||
SendMessage (hwnd, WM_SIZE, 0, 0);
|
||||
|
||||
_r_obj_dereference (localized_string);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user