From 0c41ef8fb6be2b574384ebcdbc61be22a412c8d1 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Fri, 21 Jul 2017 14:32:15 +0000 Subject: [PATCH] [BROWSEUI] -CBandSite: Remove CCS_NORESIZE style. This is a hack probably needed because our rebar control is buggy. [EXPLORER] -CTaskBand::GetBandInfo: Use the toolbar button size as the minimum and integral size for the band. -CTaskSwitchWnd: Use the system small icon size for the size of the icon. Recreate the image list if this size changes. This together with the size of the font are the only factors for the size of the toolbar and consequently for the size of the band and if it is the only band, the size of the taskbar. Don't use TB_SETBUTTONSIZE. Now the size of the image list and the font dictate the size. -CTrayWindow: In the classic theme make the start button have the same height with the tasks toolbar button height. Improve the calculation of the size of the taskbar in FitToRebar. These changes should make the taskbar and the toolbar have a proper size. On top of that the taskbar is finally resizable (however our rebar is too buggy and still fills only the first line in the taskbar). While testing this I noticed that moving the taskbar in the sides of the screen is buggy now. I'm not sure if this was uncovered by these changes, if this was broken before or this was caused by these changes (looks unlikely to me) but will be fixed in subsequent commits). svn path=/trunk/; revision=75385 --- reactos/base/shell/explorer/taskband.cpp | 14 ++-- reactos/base/shell/explorer/taskswnd.cpp | 65 +++++++++---------- reactos/base/shell/explorer/traywnd.cpp | 24 ++++++- .../win32/browseui/shellbars/CBandSite.cpp | 2 +- 4 files changed, 61 insertions(+), 44 deletions(-) diff --git a/reactos/base/shell/explorer/taskband.cpp b/reactos/base/shell/explorer/taskband.cpp index 1186367e279..b079478ced7 100644 --- a/reactos/base/shell/explorer/taskband.cpp +++ b/reactos/base/shell/explorer/taskband.cpp @@ -104,6 +104,8 @@ public: if (m_hWnd != NULL) { + HWND hwndToolbar = ::GetWindow(m_hWnd, GW_CHILD); + /* The task band never has a title */ pdbi->dwMask &= ~DBIM_TITLE; @@ -125,13 +127,11 @@ public: } else { - /* When the band is horizontal its minimum height is the height of the start button */ - RECT rcButton; - GetWindowRect(m_hWndStartButton, &rcButton); - pdbi->ptMinSize.y = rcButton.bottom - rcButton.top; - pdbi->ptIntegral.y = pdbi->ptMinSize.y + (3 * GetSystemMetrics(SM_CYEDGE) / 2); /* FIXME: Query metrics */ - /* We're not going to allow task bands where not even the minimum button size fits into the band */ - pdbi->ptMinSize.x = pdbi->ptIntegral.y; + /* Obtain the button size, to be used as the integral size */ + DWORD size = SendMessageW(hwndToolbar, TB_GETBUTTONSIZE, 0, 0); + pdbi->ptIntegral.x = 0; + pdbi->ptIntegral.y = GET_Y_LPARAM(size); + pdbi->ptMinSize = pdbi->ptIntegral; } /* Ignored: pdbi->ptMaxSize.x */ diff --git a/reactos/base/shell/explorer/taskswnd.cpp b/reactos/base/shell/explorer/taskswnd.cpp index b673482443c..94ee9260386 100644 --- a/reactos/base/shell/explorer/taskswnd.cpp +++ b/reactos/base/shell/explorer/taskswnd.cpp @@ -1142,9 +1142,25 @@ public: LONG NewBtnSize; BOOL Horizontal; - int cx = GetSystemMetrics(SM_CXMINIMIZED); - int cy = m_ButtonSize.cy = GetSystemMetrics(SM_CYSIZE); - m_TaskBar.SetButtonSize(cx, cy); + /* Update the size of the image list if needed */ + int cx, cy; + ImageList_GetIconSize(m_ImageList, &cx, &cy); + if (cx != GetSystemMetrics(SM_CXSMICON) || cy != GetSystemMetrics(SM_CYSMICON)) + { + ImageList_SetIconSize(m_ImageList, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)); + + /* SetIconSize removes all icons so we have to reinsert them */ + PTASK_ITEM TaskItem = m_TaskItems; + PTASK_ITEM LastTaskItem = m_TaskItems + m_TaskItemCount; + while (TaskItem != LastTaskItem) + { + TaskItem->IconIndex = -1; + UpdateTaskItemButton(TaskItem); + + TaskItem++; + } + m_TaskBar.SetImageList(m_ImageList); + } if (GetClientRect(&rcClient) && !IsRectEmpty(&rcClient)) { @@ -1286,7 +1302,7 @@ public: return EnumWindows(s_EnumWindowsProc, (LPARAM)this); } - LRESULT OnThemeChanged() + LRESULT OnThemeChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { TRACE("OmThemeChanged\n"); @@ -1301,20 +1317,14 @@ public: return TRUE; } - LRESULT OnThemeChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - return OnThemeChanged(); - } - LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { if (!m_TaskBar.Initialize(m_hWnd)) return FALSE; SetWindowTheme(m_TaskBar.m_hWnd, L"TaskBand", NULL); - OnThemeChanged(); - m_ImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 1000); + m_ImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 0, 1000); m_TaskBar.SetImageList(m_ImageList); /* Set proper spacing between buttons */ @@ -1371,7 +1381,7 @@ public: return Ret; } - LRESULT HandleShellHookMsg(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + LRESULT OnShellHook(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { BOOL Ret = FALSE; @@ -1449,14 +1459,6 @@ public: return Ret; } - VOID EnableGrouping(IN BOOL bEnable) - { - m_IsGroupingEnabled = bEnable; - - /* Collapse or expand groups if necessary */ - UpdateButtonsSize(FALSE); - } - VOID HandleTaskItemClick(IN OUT PTASK_ITEM TaskItem) { BOOL bIsMinimized; @@ -1648,16 +1650,6 @@ public: return Ret; } - LRESULT DrawBackground(HDC hdc) - { - RECT rect; - - GetClientRect(&rect); - DrawThemeParentBackground(m_hWnd, hdc, &rect); - - return TRUE; - } - LRESULT OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { HDC hdc = (HDC) wParam; @@ -1668,7 +1660,11 @@ public: return 0; } - return DrawBackground(hdc); + RECT rect; + GetClientRect(&rect); + DrawThemeParentBackground(m_hWnd, hdc, &rect); + + return TRUE; } LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) @@ -1724,7 +1720,10 @@ public: LRESULT Ret = m_IsGroupingEnabled; if ((BOOL)wParam != m_IsGroupingEnabled) { - EnableGrouping((BOOL) wParam); + m_IsGroupingEnabled = (BOOL)wParam; + + /* Collapse or expand groups if necessary */ + UpdateButtonsSize(FALSE); } return Ret; } @@ -1833,7 +1832,7 @@ public: MESSAGE_HANDLER(WM_TIMER, OnTimer) MESSAGE_HANDLER(WM_SETFONT, OnSetFont) MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChanged) - MESSAGE_HANDLER(m_ShellHookMsg, HandleShellHookMsg) + MESSAGE_HANDLER(m_ShellHookMsg, OnShellHook) MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate) MESSAGE_HANDLER(WM_KLUDGEMINRECT, OnKludgeItemRect) END_MSG_MAP() diff --git a/reactos/base/shell/explorer/traywnd.cpp b/reactos/base/shell/explorer/traywnd.cpp index d22369d68d6..36a09e5f2cb 100644 --- a/reactos/base/shell/explorer/traywnd.cpp +++ b/reactos/base/shell/explorer/traywnd.cpp @@ -1532,6 +1532,13 @@ ChangePos: Horizontal = IsPosHorizontal(); + IUnknown_Exec(m_TrayBandSite, + IID_IDeskBand, + DBID_BANDINFOCHANGED, + 0, + NULL, + NULL); + /* We're about to resize/move the start button, the rebar control and the tray notification control */ dwp = BeginDeferWindowPos(3); @@ -1546,6 +1553,16 @@ ChangePos: if (StartSize.cx > rcClient.right) StartSize.cx = rcClient.right; + if (!m_Theme) + { + HWND hwndTaskToolbar = ::GetWindow(m_TaskSwitch, GW_CHILD); + if (hwndTaskToolbar) + { + DWORD size = SendMessageW(hwndTaskToolbar, TB_GETBUTTONSIZE, 0, 0); + StartSize.cy = HIWORD(size); + } + } + if (m_StartButton.m_hWnd != NULL) { /* Resize and reposition the button */ @@ -1646,15 +1663,16 @@ ChangePos: void FitToRebar(PRECT pRect) { /* Get the rect of the rebar */ - RECT rebarRect, taskbarRect; + RECT rebarRect, taskbarRect, clientRect; ::GetWindowRect(m_Rebar, &rebarRect); ::GetWindowRect(m_hWnd, &taskbarRect); + ::GetClientRect(m_hWnd, &clientRect); OffsetRect(&rebarRect, -taskbarRect.left, -taskbarRect.top); /* Calculate the difference of size of the taskbar and the rebar */ SIZE margins; - margins.cx = taskbarRect.right - taskbarRect.left - rebarRect.right + rebarRect.left; - margins.cy = taskbarRect.bottom - taskbarRect.top - rebarRect.bottom + rebarRect.top; + margins.cx = taskbarRect.right - taskbarRect.left - clientRect.right + clientRect.left; + margins.cy = taskbarRect.bottom - taskbarRect.top - clientRect.bottom + clientRect.top; /* Calculate the new size of the rebar and make it resize, then change the new taskbar size */ switch (m_Position) diff --git a/reactos/dll/win32/browseui/shellbars/CBandSite.cpp b/reactos/dll/win32/browseui/shellbars/CBandSite.cpp index 04611510114..aaac501a29b 100644 --- a/reactos/dll/win32/browseui/shellbars/CBandSite.cpp +++ b/reactos/dll/win32/browseui/shellbars/CBandSite.cpp @@ -763,7 +763,7 @@ HRESULT STDMETHODCALLTYPE CBandSiteBase::SetDeskBarSite(IUnknown *pUnk) return E_FAIL; style = WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | RBS_VARHEIGHT | RBS_AUTOSIZE | - RBS_BANDBORDERS | CCS_NODIVIDER | CCS_NORESIZE | CCS_NOPARENTALIGN; + RBS_BANDBORDERS | CCS_NODIVIDER | /*CCS_NORESIZE |*/ CCS_NOPARENTALIGN; fRebarWindow = CreateWindowExW(WS_EX_TOOLWINDOW, REBARCLASSNAMEW, -- 2.17.1