automatically adjusted size of notification area and quicklaunch bar in desktop bar

svn path=/trunk/; revision=7616
This commit is contained in:
Martin Fuchs 2004-01-13 23:35:47 +00:00
parent 61b6e0fe14
commit a40cb5023f
10 changed files with 77 additions and 28 deletions

View file

@ -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

View file

@ -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

View file

@ -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) {

View file

@ -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();

View file

@ -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);
}

View file

@ -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();
};

View file

@ -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.

View file

@ -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)

View file

@ -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<x+16)
break;
x += 20;
x += NOTIFYICON_DIST;
}
return it;

View file

@ -31,7 +31,9 @@
#define CLASSNAME_CLOCKWINDOW TEXT("TrayClockWClass")
#define NOTIFYAREA_WIDTH 64
#define NOTIFYAREA_WIDTH_DEF 75
#define NOTIFYICON_DIST 20
#define NOTIFYAREA_SPACE 10
/// NotifyIconIndex is used for maintaining the order of notification icons.
@ -89,6 +91,7 @@ protected:
int _next_idx;
WindowHandle _hwndClock;
int _clock_width;
LRESULT Init(LPCREATESTRUCT pcs);
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);