2 * Copyright 2003 Martin Fuchs
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 // Martin Fuchs, 22.08.2003
29 #include "../utility/utility.h"
31 #include "../explorer.h"
32 #include "../globals.h"
33 #include "../externals.h"
34 #include "../explorer_intres.h"
36 #include "desktopbar.h"
38 #include "startmenu.h"
39 #include "traynotify.h"
40 #include "quicklaunch.h"
43 DesktopBar::DesktopBar(HWND hwnd)
45 // initialize Common Controls library
46 WM_TASKBARCREATED(RegisterWindowMessage(WINMSG_TASKBARCREATED))
48 SystemParametersInfo(SPI_GETWORKAREA, 0, &_work_area_org, 0);
51 DesktopBar::~DesktopBar()
53 // restore work area to the previous size
54 SystemParametersInfo(SPI_SETWORKAREA, 0, &_work_area_org, 0);
55 PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETWORKAREA, 0);
57 // exit application after destroying desktop window
62 HWND DesktopBar::Create()
66 rect.left = -2; // hide left border
68 rect.top = -2; // hide top border
70 rect.top = GetSystemMetrics(SM_CYSCREEN) - DESKTOPBARBAR_HEIGHT;
72 rect.right = GetSystemMetrics(SM_CXSCREEN) + 2;
73 rect.bottom = rect.top + DESKTOPBARBAR_HEIGHT + 2;
75 return Window::Create(WINDOW_CREATOR(DesktopBar), WS_EX_PALETTEWINDOW,
76 BtnWindowClass(CLASSNAME_EXPLORERBAR), TITLE_EXPLORERBAR,
77 WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE,
78 rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, 0);
82 LRESULT DesktopBar::Init(LPCREATESTRUCT pcs)
87 // create start button
88 new PictureButton(Button(_hwnd, ResString(IDS_START), 2, 2, STARTBUTTON_WIDTH, DESKTOPBARBAR_HEIGHT-8, IDC_START, WS_VISIBLE|WS_CHILD|BS_OWNERDRAW),
89 SmallIcon(IDI_STARTMENU)/*, GetStockBrush(WHITE_BRUSH)*/);
92 _hwndTaskBar = TaskBar::Create(_hwnd);
94 // create tray notification area
95 _hwndNotify = NotifyArea::Create(_hwnd);
97 _hwndQuickLaunch = QuickLaunchBar::Create(_hwnd);
101 // notify all top level windows about the successfully created desktop bar
102 PostMessage(HWND_BROADCAST, WM_TASKBARCREATED, 0, 0);
108 void DesktopBar::RegisterHotkeys()
110 // register hotkey WIN+E opening explorer
111 RegisterHotKey(_hwnd, 0, MOD_WIN, 'E');
113 //TODO: register all common hotkeys
116 void DesktopBar::ProcessHotKey(int id_hotkey)
119 case 0: explorer_show_frame(_hwnd, SW_SHOWNORMAL); break;
120 //TODO: implement all common hotkeys
125 LRESULT DesktopBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
129 LRESULT res = super::WndProc(nmsg, wparam, lparam);
131 if (res>=HTSIZEFIRST && res<=HTSIZELAST) {
132 #ifdef TASKBAR_AT_TOP
133 if (res == HTBOTTOM) // enable vertical resizing at the lower border
135 if (res == HTTOP) // enable vertical resizing at the upper border
139 return HTCLIENT; // disable any other resizing
144 if ((wparam&0xFFF0) == SC_SIZE) {
145 #ifdef TASKBAR_AT_TOP
146 if (wparam == SC_SIZE+6)// enable vertical resizing at the lower border
148 if (wparam == SC_SIZE+3)// enable vertical resizing at the upper border
152 return 0; // disable any other resizing
153 } else if (wparam == SC_TASKLIST)
158 int cx = LOWORD(lparam);
159 int cy = HIWORD(lparam);
162 MoveWindow(_hwndTaskBar, TASKBAR_LEFT+QUICKLAUNCH_WIDTH, 0, cx-TASKBAR_LEFT-QUICKLAUNCH_WIDTH-(NOTIFYAREA_WIDTH+1), cy, TRUE);
165 MoveWindow(_hwndNotify, cx-(NOTIFYAREA_WIDTH+1), 1, NOTIFYAREA_WIDTH, cy-2, TRUE);
167 if (_hwndQuickLaunch)
168 MoveWindow(_hwndQuickLaunch, TASKBAR_LEFT, 1, QUICKLAUNCH_WIDTH, cy-2, TRUE);
170 WindowRect rect(_hwnd);
171 RECT work_area = {0, 0, GetSystemMetrics(SM_CXSCREEN), rect.top};
172 SystemParametersInfo(SPI_SETWORKAREA, 0, &work_area, 0); // don't use SPIF_SENDCHANGE because then we have to wait for any message being delivered
173 PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETWORKAREA, 0);
180 ProcessHotKey(wparam);
184 return ProcessCopyData((COPYDATASTRUCT*)lparam);
187 return super::WndProc(nmsg, wparam, lparam);
194 int DesktopBar::Command(int id, int code)
197 case IDC_START: //TODO: startmenu should popup for WM_LBUTTONDOWN, not for WM_COMMAND
202 if ((id&~0xFF) == IDC_FIRST_QUICK_ID)
203 SendMessage(_hwndQuickLaunch, WM_COMMAND, MAKEWPARAM(id,code), 0);
210 void DesktopBar::ShowStartMenu()
213 StartMenuRoot* startMenuRoot = GET_WINDOW(StartMenuRoot, StartMenuRoot::Create(_hwnd));
216 startMenuRoot->TrackStartmenu();
220 /// copy data structure for tray notifications
221 struct TrayNotifyCDS {
224 NOTIFYICONDATA nicon_data;
227 LRESULT DesktopBar::ProcessCopyData(COPYDATASTRUCT* pcd)
229 // Is this a tray notification message?
230 if (pcd->dwData == 1) {
231 TrayNotifyCDS* ptr = (TrayNotifyCDS*) pcd->lpData;
233 //TODO: process the differnt versions of the NOTIFYICONDATA structure (look at cbSize to decide which one)
235 NotifyArea* notify_area = GET_WINDOW(NotifyArea, _hwndNotify);
238 return notify_area->ProcessTrayNotification(ptr->notify_code, &ptr->nicon_data);