Commit 8d004d51 authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

shell32: Scale explorer browser sizes by DPI.

parent 94a85758
......@@ -38,6 +38,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
#define SPLITTER_WIDTH 2
#define NP_MIN_WIDTH 60
#define NP_DEFAULT_WIDTH 150
#define SV_MIN_WIDTH 150
typedef struct _event_client {
......@@ -83,6 +84,8 @@ typedef struct _ExplorerBrowserImpl {
travellog_entry *travellog_cursor;
int travellog_count;
int dpix;
IShellView *psv;
RECT sv_rc;
LPITEMIDLIST current_pidl;
......@@ -274,6 +277,8 @@ static void update_layout(ExplorerBrowserImpl *This)
RECT rc;
INT navpane_width_actual;
INT shellview_width_actual;
int np_min_width = MulDiv(NP_MIN_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
int sv_min_width = MulDiv(SV_MIN_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
TRACE("%p (navpane: %d, EBO_SHOWFRAMES: %d)\n",
This, This->navpane.show, This->eb_options & EBO_SHOWFRAMES);
......@@ -285,10 +290,10 @@ static void update_layout(ExplorerBrowserImpl *This)
navpane_width_actual = 0;
shellview_width_actual = rc.right - navpane_width_actual;
if(shellview_width_actual < SV_MIN_WIDTH && navpane_width_actual)
if(shellview_width_actual < sv_min_width && navpane_width_actual)
{
INT missing_width = SV_MIN_WIDTH - shellview_width_actual;
if(missing_width < (navpane_width_actual - NP_MIN_WIDTH))
INT missing_width = sv_min_width - shellview_width_actual;
if(missing_width < (navpane_width_actual - np_min_width))
{
/* Shrink the navpane */
navpane_width_actual -= missing_width;
......@@ -327,9 +332,10 @@ static void update_layout(ExplorerBrowserImpl *This)
static void size_panes(ExplorerBrowserImpl *This)
{
int splitter_width = MulDiv(SPLITTER_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
MoveWindow(This->navpane.hwnd_splitter,
This->navpane.rc.right - SPLITTER_WIDTH, This->navpane.rc.top,
SPLITTER_WIDTH, This->navpane.rc.bottom - This->navpane.rc.top,
This->navpane.rc.right - splitter_width, This->navpane.rc.top,
splitter_width, This->navpane.rc.bottom - This->navpane.rc.top,
TRUE);
MoveWindow(This->hwnd_sv,
......@@ -494,12 +500,14 @@ static void splitter_draw(HWND hwnd, RECT *rc)
*/
static LRESULT navpane_splitter_beginresize(ExplorerBrowserImpl *This, HWND hwnd, LPARAM lParam)
{
int splitter_width = MulDiv(SPLITTER_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
TRACE("\n");
SetCapture(hwnd);
This->splitter_rc = This->navpane.rc;
This->splitter_rc.left = This->splitter_rc.right - SPLITTER_WIDTH;
This->splitter_rc.left = This->splitter_rc.right - splitter_width;
splitter_draw(GetParent(hwnd), &This->splitter_rc);
......@@ -510,6 +518,9 @@ static LRESULT navpane_splitter_resizing(ExplorerBrowserImpl *This, HWND hwnd, L
{
int new_width, dx;
RECT rc;
int splitter_width = MulDiv(SPLITTER_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
int np_min_width = MulDiv(NP_MIN_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
int sv_min_width = MulDiv(SV_MIN_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
if(GetCapture() != hwnd) return FALSE;
......@@ -518,10 +529,10 @@ static LRESULT navpane_splitter_resizing(ExplorerBrowserImpl *This, HWND hwnd, L
rc = This->navpane.rc;
new_width = This->navpane.width + dx;
if(new_width > NP_MIN_WIDTH && This->sv_rc.right - new_width > SV_MIN_WIDTH)
if(new_width > np_min_width && This->sv_rc.right - new_width > sv_min_width)
{
rc.right = new_width;
rc.left = rc.right - SPLITTER_WIDTH;
rc.left = rc.right - splitter_width;
splitter_draw(GetParent(hwnd), &This->splitter_rc);
splitter_draw(GetParent(hwnd), &rc);
This->splitter_rc = rc;
......@@ -533,6 +544,8 @@ static LRESULT navpane_splitter_resizing(ExplorerBrowserImpl *This, HWND hwnd, L
static LRESULT navpane_splitter_endresize(ExplorerBrowserImpl *This, HWND hwnd, LPARAM lParam)
{
int new_width, dx;
int np_min_width = MulDiv(NP_MIN_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
int sv_min_width = MulDiv(SV_MIN_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
if(GetCapture() != hwnd) return FALSE;
......@@ -542,10 +555,10 @@ static LRESULT navpane_splitter_endresize(ExplorerBrowserImpl *This, HWND hwnd,
splitter_draw(GetParent(hwnd), &This->splitter_rc);
new_width = This->navpane.width + dx;
if(new_width < NP_MIN_WIDTH)
new_width = NP_MIN_WIDTH;
else if(This->sv_rc.right - new_width < SV_MIN_WIDTH)
new_width = This->sv_rc.right - SV_MIN_WIDTH;
if(new_width < np_min_width)
new_width = np_min_width;
else if(This->sv_rc.right - new_width < sv_min_width)
new_width = This->sv_rc.right - sv_min_width;
This->navpane.width = new_width;
......@@ -649,9 +662,11 @@ static LRESULT navpane_on_wm_create(HWND hwnd, CREATESTRUCTW *crs)
static LRESULT navpane_on_wm_size_move(ExplorerBrowserImpl *This)
{
UINT height, width;
int splitter_width = MulDiv(SPLITTER_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
TRACE("%p\n", This);
width = This->navpane.rc.right - This->navpane.rc.left - SPLITTER_WIDTH;
width = This->navpane.rc.right - This->navpane.rc.left - splitter_width;
height = This->navpane.rc.bottom - This->navpane.rc.top;
MoveWindow(This->navpane.hwnd_nstc,
......@@ -692,6 +707,7 @@ static void initialize_navpane(ExplorerBrowserImpl *This, HWND hwnd_parent, RECT
{
WNDCLASSW wc;
HWND splitter;
int splitter_width = MulDiv(SPLITTER_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
static const WCHAR navpane_classname[] = {'e','b','_','n','a','v','p','a','n','e',0};
if( !GetClassInfoW(shell32_hInstance, navpane_classname, &wc) )
......@@ -712,8 +728,8 @@ static void initialize_navpane(ExplorerBrowserImpl *This, HWND hwnd_parent, RECT
splitter = CreateWindowExW(0, navpane_classname, NULL,
WS_CHILD | WS_TABSTOP | WS_VISIBLE,
rc->right - SPLITTER_WIDTH, rc->top,
SPLITTER_WIDTH, rc->bottom - rc->top,
rc->right - splitter_width, rc->top,
splitter_width, rc->bottom - rc->top,
hwnd_parent, 0, shell32_hInstance, This);
if(!splitter)
ERR("Failed to create navpane : %d.\n", GetLastError());
......@@ -849,6 +865,7 @@ static HRESULT WINAPI IExplorerBrowser_fnInitialize(IExplorerBrowser *iface,
ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
WNDCLASSW wc;
LONG style;
HDC parent_dc;
static const WCHAR EB_CLASS_NAME[] =
{'E','x','p','l','o','r','e','r','B','r','o','w','s','e','r','C','o','n','t','r','o','l',0};
......@@ -876,6 +893,12 @@ static HRESULT WINAPI IExplorerBrowser_fnInitialize(IExplorerBrowser *iface,
if (!RegisterClassW(&wc)) return E_FAIL;
}
parent_dc = GetDC(hwndParent);
This->dpix = GetDeviceCaps(parent_dc, LOGPIXELSX);
ReleaseDC(hwndParent, parent_dc);
This->navpane.width = MulDiv(NP_DEFAULT_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS;
if (!(This->eb_options & EBO_NOBORDER))
style |= WS_BORDER;
......@@ -2066,7 +2089,6 @@ HRESULT WINAPI ExplorerBrowser_Constructor(IUnknown *pUnkOuter, REFIID riid, voi
eb->IInputObject_iface.lpVtbl = &vt_IInputObject;
/* Default settings */
eb->navpane.width = 150;
eb->navpane.show = TRUE;
list_init(&eb->event_clients);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment