From a40cb5023f9d7697a9d9576df60d88add0e295a3 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Tue, 13 Jan 2004 23:35:47 +0000 Subject: [PATCH] automatically adjusted size of notification area and quicklaunch bar in desktop bar svn path=/trunk/; revision=7616 --- .../subsys/system/explorer/doc/changes.txt | 1 + reactos/subsys/system/explorer/explorer.h | 3 ++ .../system/explorer/taskbar/desktopbar.cpp | 48 ++++++++++++------- .../system/explorer/taskbar/desktopbar.h | 1 + .../system/explorer/taskbar/quicklaunch.cpp | 10 +++- .../system/explorer/taskbar/quicklaunch.h | 6 ++- .../system/explorer/taskbar/startmenu.h | 4 +- .../system/explorer/taskbar/taskbar.cpp | 4 +- .../system/explorer/taskbar/traynotify.cpp | 23 +++++++-- .../system/explorer/taskbar/traynotify.h | 5 +- 10 files changed, 77 insertions(+), 28 deletions(-) diff --git a/reactos/subsys/system/explorer/doc/changes.txt b/reactos/subsys/system/explorer/doc/changes.txt index 9f02f281577..8bc6c504930 100644 --- a/reactos/subsys/system/explorer/doc/changes.txt +++ b/reactos/subsys/system/explorer/doc/changes.txt @@ -55,3 +55,4 @@ If you search for more information, look into the CVS repository. direct file system access for start menu 04.01.2004 m. fuchs implemented icon cache 11.01.2004 m. fuchs keyboard navigation in start menu +14.01.2004 m. fuchs automatically adjusted size of notification area and quicklaunch bar in desktop bar diff --git a/reactos/subsys/system/explorer/explorer.h b/reactos/subsys/system/explorer/explorer.h index 20f71c159d9..92df868a6ae 100644 --- a/reactos/subsys/system/explorer/explorer.h +++ b/reactos/subsys/system/explorer/explorer.h @@ -46,6 +46,9 @@ #define PM_GET_FILEWND_PTR (WM_APP+0x05) #define PM_GET_CONTROLWINDOW (WM_APP+0x06) +#define PM_RESIZE_CHILDREN (WM_APP+0x17) +#define PM_GET_WIDTH (WM_APP+0x18) + #define CLASSNAME_FRAME TEXT("CabinetWClass") // same class name for frame window as in MS Explorer diff --git a/reactos/subsys/system/explorer/taskbar/desktopbar.cpp b/reactos/subsys/system/explorer/taskbar/desktopbar.cpp index 9905c37aa3f..54df2b2fae5 100644 --- a/reactos/subsys/system/explorer/taskbar/desktopbar.cpp +++ b/reactos/subsys/system/explorer/taskbar/desktopbar.cpp @@ -160,23 +160,13 @@ LRESULT DesktopBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) ShowStartMenu(); goto def; - case WM_SIZE: { - int cx = LOWORD(lparam); - int cy = HIWORD(lparam); + case WM_SIZE: + Resize(LOWORD(lparam), HIWORD(lparam)); + break; - if (_hwndTaskBar) - MoveWindow(_hwndTaskBar, TASKBAR_LEFT+QUICKLAUNCH_WIDTH, 0, cx-TASKBAR_LEFT-QUICKLAUNCH_WIDTH-(NOTIFYAREA_WIDTH+1), cy, TRUE); - - if (_hwndNotify) - MoveWindow(_hwndNotify, cx-(NOTIFYAREA_WIDTH+1), 1, NOTIFYAREA_WIDTH, cy-2, TRUE); - - if (_hwndQuickLaunch) - MoveWindow(_hwndQuickLaunch, TASKBAR_LEFT, 1, QUICKLAUNCH_WIDTH, cy-2, TRUE); - - WindowRect rect(_hwnd); - RECT work_area = {0, 0, GetSystemMetrics(SM_CXSCREEN), rect.top}; - SystemParametersInfo(SPI_SETWORKAREA, 0, &work_area, 0); // don't use SPIF_SENDCHANGE because then we have to wait for any message being delivered - PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETWORKAREA, 0); + case PM_RESIZE_CHILDREN: { + ClientRect size(_hwnd); + Resize(size.right, size.bottom); break;} case WM_CLOSE: @@ -198,6 +188,32 @@ LRESULT DesktopBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) } +void DesktopBar::Resize(int cx, int cy) +{ + ///@todo general children resizing algorithm + int quicklaunch_width = SendMessage(_hwndQuickLaunch, PM_GET_WIDTH, 0, 0); + int notifyarea_width = SendMessage(_hwndNotify, PM_GET_WIDTH, 0, 0); + + HDWP hdwp = BeginDeferWindowPos(3); + + if (_hwndTaskBar) + DeferWindowPos(hdwp, _hwndTaskBar, 0, TASKBAR_LEFT+quicklaunch_width, 0, cx-TASKBAR_LEFT-quicklaunch_width-(notifyarea_width+1), cy, SWP_NOZORDER|SWP_NOACTIVATE); + + if (_hwndNotify) + DeferWindowPos(hdwp, _hwndNotify, 0, cx-(notifyarea_width+1), 1, notifyarea_width, cy-2, SWP_NOZORDER|SWP_NOACTIVATE); + + if (_hwndQuickLaunch) + DeferWindowPos(hdwp, _hwndQuickLaunch, 0, TASKBAR_LEFT, 1, quicklaunch_width, cy-2, SWP_NOZORDER|SWP_NOACTIVATE); + + EndDeferWindowPos(hdwp); + + WindowRect rect(_hwnd); + RECT work_area = {0, 0, GetSystemMetrics(SM_CXSCREEN), rect.top}; + SystemParametersInfo(SPI_SETWORKAREA, 0, &work_area, 0); // don't use SPIF_SENDCHANGE because then we have to wait for any message being delivered + PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETWORKAREA, 0); +} + + int DesktopBar::Command(int id, int code) { switch(id) { diff --git a/reactos/subsys/system/explorer/taskbar/desktopbar.h b/reactos/subsys/system/explorer/taskbar/desktopbar.h index 34b6064e438..e1bf66781a1 100644 --- a/reactos/subsys/system/explorer/taskbar/desktopbar.h +++ b/reactos/subsys/system/explorer/taskbar/desktopbar.h @@ -83,6 +83,7 @@ protected: LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); int Command(int id, int code); + void Resize(int cx, int cy); void RegisterHotkeys(); void ProcessHotKey(int id_hotkey); void ShowStartMenu(); diff --git a/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp b/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp index 25211354550..fda858cfebb 100644 --- a/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp +++ b/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp @@ -55,14 +55,14 @@ QuickLaunchBar::QuickLaunchBar(HWND hwnd) CONTEXT("QuickLaunchBar::QuickLaunchBar()"); _dir = NULL; - _next_id = IDC_FIRST_QUICK_ID; + _btn_dist = 20; HWND hwndToolTip = (HWND) SendMessage(hwnd, TB_GETTOOLTIPS, 0, 0); SetWindowStyle(hwndToolTip, GetWindowStyle(hwndToolTip)|TTS_ALWAYSTIP); - // delay refresh to some tome later + // delay refresh to some time later PostMessage(hwnd, PM_REFRESH, 0, 0); } @@ -147,6 +147,9 @@ void QuickLaunchBar::AddShortcuts() SendMessage(_hwnd, TB_INSERTBUTTON, idx, (LPARAM)&btn); } } + + _btn_dist = LOWORD(SendMessage(_hwnd, TB_GETBUTTONSIZE, 0, 0)); + SendMessage(GetParent(_hwnd), PM_RESIZE_CHILDREN, 0, 0); } LRESULT QuickLaunchBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) @@ -156,6 +159,9 @@ LRESULT QuickLaunchBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) AddShortcuts(); break; + case PM_GET_WIDTH: + return _entries.size()*_btn_dist; + default: return super::WndProc(nmsg, wparam, lparam); } diff --git a/reactos/subsys/system/explorer/taskbar/quicklaunch.h b/reactos/subsys/system/explorer/taskbar/quicklaunch.h index 14b90c2889b..10ef42c30d2 100644 --- a/reactos/subsys/system/explorer/taskbar/quicklaunch.h +++ b/reactos/subsys/system/explorer/taskbar/quicklaunch.h @@ -26,11 +26,12 @@ // -#define QUICKLAUNCH_WIDTH 64 +#define QUICKLAUNCH_WIDTH_DEF 70 +#define QUICKLAUNCH_WIDTH_DEF 70 #define IDW_QUICKLAUNCHBAR 101 -#define PM_REFRESH (WM_APP+0x14) +#define PM_REFRESH (WM_APP+0x16) #define IDC_FIRST_QUICK_ID 0x4000 @@ -74,6 +75,7 @@ protected: int _next_id; QuickLaunchMap _entries; + int _btn_dist; void AddShortcuts(); }; diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.h b/reactos/subsys/system/explorer/taskbar/startmenu.h index 869ec426e03..c2c19be1fd4 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.h +++ b/reactos/subsys/system/explorer/taskbar/startmenu.h @@ -49,8 +49,8 @@ #define PM_STARTENTRY_FOCUSED (WM_APP+0x13) #endif -#define PM_UPDATE_ICONS (WM_APP+0x15) -#define PM_SELECT_ENTRY (WM_APP+0x16) +#define PM_UPDATE_ICONS (WM_APP+0x14) +#define PM_SELECT_ENTRY (WM_APP+0x15) /// StartMenuDirectory is used to store the base directory of start menus. diff --git a/reactos/subsys/system/explorer/taskbar/taskbar.cpp b/reactos/subsys/system/explorer/taskbar/taskbar.cpp index 88599820066..8a6f49046fd 100644 --- a/reactos/subsys/system/explorer/taskbar/taskbar.cpp +++ b/reactos/subsys/system/explorer/taskbar/taskbar.cpp @@ -32,7 +32,7 @@ #include "../globals.h" #include "taskbar.h" -#include "traynotify.h" // for NOTIFYAREA_WIDTH +#include "traynotify.h" // for NOTIFYAREA_WIDTH_DEF TaskBarEntry::TaskBarEntry() @@ -73,7 +73,7 @@ HWND TaskBar::Create(HWND hwndParent) return Window::Create(WINDOW_CREATOR(TaskBar), 0, BtnWindowClass(CLASSNAME_TASKBAR), TITLE_TASKBAR, WS_CHILD|WS_VISIBLE, - TASKBAR_LEFT, 0, clnt.right-TASKBAR_LEFT-(NOTIFYAREA_WIDTH+1), clnt.bottom, hwndParent); + TASKBAR_LEFT, 0, clnt.right-TASKBAR_LEFT-(NOTIFYAREA_WIDTH_DEF+1), clnt.bottom, hwndParent); } LRESULT TaskBar::Init(LPCREATESTRUCT pcs) diff --git a/reactos/subsys/system/explorer/taskbar/traynotify.cpp b/reactos/subsys/system/explorer/taskbar/traynotify.cpp index f48ca741904..105477849d3 100644 --- a/reactos/subsys/system/explorer/taskbar/traynotify.cpp +++ b/reactos/subsys/system/explorer/taskbar/traynotify.cpp @@ -85,6 +85,7 @@ NotifyArea::NotifyArea(HWND hwnd) : super(hwnd) { _next_idx = 0; + _clock_width = 0; } LRESULT NotifyArea::Init(LPCREATESTRUCT pcs) @@ -99,6 +100,11 @@ LRESULT NotifyArea::Init(LPCREATESTRUCT pcs) // create clock window _hwndClock = ClockWindow::Create(_hwnd); + if (_hwndClock) { + ClientRect clock_size(_hwndClock); + _clock_width = clock_size.right; + } + SetTimer(_hwnd, 0, 1000, NULL); } @@ -116,7 +122,7 @@ HWND NotifyArea::Create(HWND hwndParent) return Window::Create(WINDOW_CREATOR(NotifyArea), WS_EX_STATICEDGE, BtnWindowClass(CLASSNAME_TRAYNOTIFY,CS_DBLCLKS), TITLE_TRAYNOTIFY, WS_CHILD|WS_VISIBLE, - clnt.right-(NOTIFYAREA_WIDTH+1), 1, NOTIFYAREA_WIDTH, clnt.bottom-2, hwndParent); + clnt.right-(NOTIFYAREA_WIDTH_DEF+1), 1, NOTIFYAREA_WIDTH_DEF, clnt.bottom-2, hwndParent); } LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) @@ -135,6 +141,14 @@ LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) clock_window->TimerTick(); break;} + case WM_SIZE: { + int cx = LOWORD(lparam); + SetWindowPos(_hwndClock, 0, cx-_clock_width, 0, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE); + break;} + + case PM_GET_WIDTH: + return _sorted_icons.size()*NOTIFYICON_DIST + NOTIFYAREA_SPACE + _clock_width; + default: if (nmsg>=WM_MOUSEFIRST && nmsg<=WM_MOUSELAST) { // close startup menu and other popup menus @@ -231,6 +245,8 @@ void NotifyArea::Refresh() _sorted_icons.insert(entry); } + SendMessage(GetParent(_hwnd), PM_RESIZE_CHILDREN, 0, 0); + InvalidateRect(_hwnd, NULL, FALSE); // refresh icon display UpdateWindow(_hwnd); } @@ -248,7 +264,8 @@ void NotifyArea::Paint() for(NotifyIconSet::const_iterator it=_sorted_icons.begin(); it!=_sorted_icons.end(); ++it) { DrawIconEx(canvas, x, y, it->_hIcon, 16, 16, 0, 0, DI_NORMAL); - x += 20; + + x += NOTIFYICON_DIST; } } @@ -286,7 +303,7 @@ NotifyIconSet::iterator NotifyArea::IconHitTest(const POINT& pos) if (pos.x>=x && pos.x