first draft of working task bar

svn path=/trunk/; revision=5608
This commit is contained in:
Martin Fuchs 2003-08-16 23:27:18 +00:00
parent 8d77a084ae
commit e0aedc01c3
21 changed files with 692 additions and 155 deletions

View file

@ -1,3 +1,8 @@
2003-08-16 Martin Fuchs <martin-fuchs@gmx.net>
* subsys/system/explorer/taskbar/taskbar.coo:
first draft of working task bar
2003-08-13 Casper S. Hornstrup <chorns@users.sourceforge.net>
* include/win32k/ntuser.h (NtUserGetClassName): Make nMaxCount an ULONG.

View file

@ -67,8 +67,9 @@ static void draw_desktop_background(HWND hwnd, HDC hdc)
// This next part could be improved by working out how much
// space the text actually needs...
#define TASKBAR_HEIGHT 30
rect.left = rect.right - 280;
rect.top = rect.bottom - 56 - 30;
rect.top = rect.bottom - 56 - TASKBAR_HEIGHT;
rect.right = rect.left + 250;
rect.bottom = rect.top + 40;
@ -116,6 +117,82 @@ DesktopWindow::~DesktopWindow()
}
LRESULT DesktopWindow::Init(LPCREATESTRUCT pcs)
{
super::Init(pcs);
HRESULT hr = Desktop()->CreateViewObject(_hwnd, IID_IShellView, (void**)&_pShellView);
/* also possible:
SFV_CREATE sfv_create;
sfv_create.cbSize = sizeof(SFV_CREATE);
sfv_create.pshf = Desktop();
sfv_create.psvOuter = NULL;
sfv_create.psfvcb = NULL;
HRESULT hr = SHCreateShellFolderView(&sfv_create, &_pShellView);
*/
HWND hWndView = 0;
if (SUCCEEDED(hr)) {
FOLDERSETTINGS fs;
fs.ViewMode = FVM_ICON;
fs.fFlags = FWF_DESKTOP|FWF_NOCLIENTEDGE|FWF_NOSCROLL|FWF_BESTFITWINDOW|FWF_SNAPTOGRID;
RECT rect;
GetClientRect(_hwnd, &rect);
hr = _pShellView->CreateViewWindow(NULL, &fs, this, &rect, &hWndView);
//TODO: use IShellBrowser::GetViewStateStream() to restore previous view state -> see SHOpenRegStream()
if (SUCCEEDED(hr)) {
_pShellView->UIActivate(SVUIA_ACTIVATE_FOCUS);
/*
IShellView2* pShellView2;
hr = _pShellView->QueryInterface(IID_IShellView2, (void**)&pShellView2);
SV2CVW2_PARAMS params;
params.cbSize = sizeof(SV2CVW2_PARAMS);
params.psvPrev = _pShellView;
params.pfs = &fs;
params.psbOwner = this;
params.prcView = &rect;
params.pvid = params.pvid;//@@
hr = pShellView2->CreateViewWindow2(&params);
params.pvid;
*/
/*
IFolderView* pFolderView;
hr = _pShellView->QueryInterface(IID_IFolderView, (void**)&pFolderView);
if (SUCCEEDED(hr)) {
hr = pFolderView->GetAutoArrange();
hr = pFolderView->SetCurrentViewMode(FVM_DETAILS);
}
*/
HWND hwndFolderView = ::GetNextWindow(hWndView, GW_CHILD);
new BackgroundWindow(hwndFolderView);
}
}
if (hWndView && SetShellWindowEx)
SetShellWindowEx(_hwnd, hWndView);
else if (SetShellWindow)
SetShellWindow(_hwnd);
return 0;
}
LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
{
switch(nmsg) {
@ -134,76 +211,6 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
case WM_GETISHELLBROWSER:
return (LRESULT)static_cast<IShellBrowser*>(this);
case WM_CREATE: {
HRESULT hr = Desktop()->CreateViewObject(_hwnd, IID_IShellView, (void**)&_pShellView);
/* also possible:
SFV_CREATE sfv_create;
sfv_create.cbSize = sizeof(SFV_CREATE);
sfv_create.pshf = Desktop();
sfv_create.psvOuter = NULL;
sfv_create.psfvcb = NULL;
HRESULT hr = SHCreateShellFolderView(&sfv_create, &_pShellView);
*/
HWND hWndView = 0;
if (SUCCEEDED(hr)) {
FOLDERSETTINGS fs;
fs.ViewMode = FVM_ICON;
fs.fFlags = FWF_DESKTOP|FWF_NOCLIENTEDGE|FWF_NOSCROLL|FWF_BESTFITWINDOW|FWF_SNAPTOGRID;
RECT rect;
GetClientRect(_hwnd, &rect);
hr = _pShellView->CreateViewWindow(NULL, &fs, this, &rect, &hWndView);
//TODO: use IShellBrowser::GetViewStateStream() to restore previous view state -> see SHOpenRegStream()
if (SUCCEEDED(hr)) {
_pShellView->UIActivate(SVUIA_ACTIVATE_FOCUS);
/*
IShellView2* pShellView2;
hr = _pShellView->QueryInterface(IID_IShellView2, (void**)&pShellView2);
SV2CVW2_PARAMS params;
params.cbSize = sizeof(SV2CVW2_PARAMS);
params.psvPrev = _pShellView;
params.pfs = &fs;
params.psbOwner = this;
params.prcView = &rect;
params.pvid = params.pvid;//@@
hr = pShellView2->CreateViewWindow2(&params);
params.pvid;
*/
/*
IFolderView* pFolderView;
hr = _pShellView->QueryInterface(IID_IFolderView, (void**)&pFolderView);
if (SUCCEEDED(hr)) {
hr = pFolderView->GetAutoArrange();
hr = pFolderView->SetCurrentViewMode(FVM_DETAILS);
}
*/
HWND hwndFolderView = ::GetNextWindow(hWndView, GW_CHILD);
new BackgroundWindow(hwndFolderView);
}
}
if (hWndView && SetShellWindowEx)
SetShellWindowEx(_hwnd, hWndView);
else if (SetShellWindow)
SetShellWindow(_hwnd);
break;}
case WM_DESTROY:
//TODO: use IShellBrowser::GetViewStateStream() and _pShellView->SaveViewState() to store view state
@ -225,12 +232,12 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
HWND create_desktop_window(HINSTANCE hInstance)
{
WindowClass wcDesktop(_T("Program Manager"));
WindowClass wcDesktop(_T("Progman"));
wcDesktop.style = CS_DBLCLKS;
wcDesktop.hbrBackground = (HBRUSH)(COLOR_BACKGROUND+1);
wcDesktop.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcDesktop.hCursor = LoadCursor(NULL, IDC_ARROW);
wcDesktop.hIcon = LoadIcon(0, IDI_APPLICATION);
wcDesktop.hCursor = LoadCursor(0, IDC_ARROW);
ATOM desktopClass = wcDesktop.Register();
@ -239,6 +246,6 @@ HWND create_desktop_window(HINSTANCE hInstance)
int height = GetSystemMetrics(SM_CYSCREEN);
return Window::Create(WINDOW_CREATOR(DesktopWindow),
0, (LPCTSTR)(int)desktopClass, _T("Progman"), WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN,
WS_EX_TOOLWINDOW, (LPCTSTR)(int)desktopClass, _T("Program Manager"), WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN,
0, 0, width, height, 0);
}

View file

@ -76,6 +76,7 @@ struct DesktopWindow : public Window, public IShellBrowserImpl
}
protected:
LRESULT Init(LPCREATESTRUCT pcs);
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
IShellView* _pShellView;

View file

@ -1,12 +1,14 @@
- extend shell view code in Wine
- implement start menu
- iplement taskbar and additional deskbands
- tray area
- taskbar notification area (aka "tray")
- Fix the Explorer Bar/Start Menu. Currently it is almost nothing like Windows.
- paint desktop background: configurable colors, background image, ...
- Drag Drop on desktop does not work.
- implement Drag Drop from the tree view.
- activate accelerator keys like <DEL> in shell view folders
- progman DDE server
- command line parameters like "/e,/root,c:\"
- Windows-key combos
- Application Desktop Toolbars
- desktop switching

View file

@ -15,3 +15,4 @@
11.08.2003 m. fuchs class BackgroundWindow for painting of desktop background
open child folders by double click in ShellBrowserChild
13.08.2003 m. fuchs make explorer bar look more like windows taskbar bar
16.08.2003 m. fuchs first draft of working task bar

View file

@ -62,7 +62,7 @@ ResString::ResString(UINT nid)
}
void explorer_show_frame(HWND hwndParent, int cmdshow)
void explorer_show_frame(HWND hwndDesktop, int cmdshow)
{
if (g_Globals._hMainWnd)
return;
@ -75,7 +75,7 @@ void explorer_show_frame(HWND hwndParent, int cmdshow)
g_Globals._hMainWnd = Window::Create(WINDOW_CREATOR(MainFrame), 0,
(LPCTSTR)(int)g_Globals._hframeClass, ResString(IDS_TITLE), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hwndParent, hMenuFrame);
0/*hwndDesktop*/, hMenuFrame);
ShowWindow(g_Globals._hMainWnd, cmdshow);
@ -133,7 +133,7 @@ static void InitInstance(HINSTANCE hinstance)
}
int explorer_main(HINSTANCE hinstance, HWND hwndParent, int cmdshow)
int explorer_main(HINSTANCE hinstance, HWND hwndDesktop, int cmdshow)
{
// initialize COM and OLE
OleInit usingCOM;
@ -146,7 +146,7 @@ int explorer_main(HINSTANCE hinstance, HWND hwndParent, int cmdshow)
InitInstance(hinstance);
if (hwndParent)
if (hwndDesktop)
g_Globals._desktop_mode = true;
if (cmdshow != SW_HIDE) {
@ -156,7 +156,7 @@ int explorer_main(HINSTANCE hinstance, HWND hwndParent, int cmdshow)
cmdshow = SW_MAXIMIZE;
#endif
explorer_show_frame(hwndParent, cmdshow);
explorer_show_frame(hwndDesktop, cmdshow);
}
while(GetMessage(&msg, 0, 0, 0)) {
@ -207,7 +207,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
HWND hwndExplorerBar = InitializeExplorerBar(hInstance);
// Load plugins
LoadAvailablePlugIns(hwndExplorerBar);
// LoadAvailablePlugIns(hwndExplorerBar);
#ifndef _DEBUG //MF: disabled for debugging
{
@ -219,7 +219,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
int ret = explorer_main(hInstance, hwndDesktop, nShowCmd);
ReleaseAvailablePlugIns();
// ReleaseAvailablePlugIns();
return ret;
}

View file

@ -45,7 +45,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_ROS_" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_ROS_" /D _WIN32_IE=0x0501 /D _WIN32_WINNT=0x0501 /YX /FD /c
# ADD BASE RSC /l 0x407 /d "NDEBUG"
# ADD RSC /l 0x407 /d "NDEBUG"
BSC32=bscmake.exe
@ -70,7 +70,7 @@ LINK32=link.cmd
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_ROS_" /FR /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_ROS_" /D _WIN32_IE=0x0501 /D _WIN32_WINNT=0x0501 /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x407 /d "_DEBUG"
# ADD RSC /l 0x407 /d "_DEBUG"
BSC32=bscmake.exe
@ -96,7 +96,7 @@ LINK32=link.cmd
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_ROS_" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /D "NDEBUG" /D "WIN32" /D "_ROS_" /FR /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /D "NDEBUG" /D "WIN32" /D "_ROS_" /D _WIN32_IE=0x0501 /D _WIN32_WINNT=0x0501 /FR /YX /FD /c
# ADD BASE RSC /l 0x407 /d "NDEBUG"
# ADD RSC /l 0x407 /d "NDEBUG"
BSC32=bscmake.exe
@ -122,7 +122,7 @@ LINK32=link.cmd
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "UNICODE" /D "_ROS_" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "UNICODE" /D "_ROS_" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "UNICODE" /D "WIN32" /D "_ROS_" /D _WIN32_IE=0x0501 /D _WIN32_WINNT=0x0501 /YX /FD /c
# ADD BASE RSC /l 0x407 /d "NDEBUG"
# ADD RSC /l 0x407 /d "NDEBUG"
BSC32=bscmake.exe
@ -148,7 +148,7 @@ LINK32=link.cmd
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "UNICODE" /D "_ROS_" /FR /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "UNICODE" /D "_ROS_" /FR /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "UNICODE" /D "WIN32" /D "_ROS_" /D _WIN32_IE=0x0501 /D _WIN32_WINNT=0x0501 /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x407 /d "_DEBUG"
# ADD RSC /l 0x407 /d "_DEBUG"
BSC32=bscmake.exe
@ -332,23 +332,11 @@ SOURCE=.\res\toolbar.bmp
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\taskbar\ex_bar.c
SOURCE=.\taskbar\taskbar.cpp
# End Source File
# Begin Source File
SOURCE=.\taskbar\ex_bar.h
# End Source File
# Begin Source File
SOURCE=.\taskbar\ex_clock.c
# End Source File
# Begin Source File
SOURCE=.\taskbar\ex_menu.c
# End Source File
# Begin Source File
SOURCE=.\taskbar\ex_shutdwn.c
SOURCE=.\taskbar\taskbar.h
# End Source File
# End Group
# Begin Group "desktop"

View file

@ -35,10 +35,10 @@ extern "C" {
extern int startup(int argc, char *argv[]);
// explorer main routine
extern int explorer_main(HINSTANCE hinstance, HWND hwndParent, int cmdshow);
extern int explorer_main(HINSTANCE hinstance, HWND hwndDesktop, int cmdshow);
// display explorer/file manager window
extern void explorer_show_frame(HWND hWndParent, int cmdshow);
extern void explorer_show_frame(HWND hwndDesktop, int cmdshow);
// create desktop window
extern HWND create_desktop_window(HINSTANCE hInstance);

View file

@ -12,9 +12,9 @@ TARGET_APPTYPE = windows
TARGET_NAME = explorer
TARGET_CFLAGS = -fexceptions -Os -DNDEBUG -DWIN32 -D_ROS_ -W -D_WIN32_IE=0x0500
TARGET_CFLAGS = -fexceptions -Os -DNDEBUG -DWIN32 -D_ROS_ -W -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501
TARGET_CPPFLAGS = -fexceptions -Os -DNDEBUG -DWIN32 -D_ROS_ -W -D_WIN32_IE=0x0500
TARGET_CPPFLAGS = -fexceptions -Os -DNDEBUG -DWIN32 -D_ROS_ -W -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501
TARGET_RCFLAGS = -DNDEBUG -DWIN32 -D_ROS_
@ -50,10 +50,6 @@ TARGET_SDKLIBS = \
TARGET_OBJECTS = \
startup.o \
ex_bar.o \
ex_menu.o \
ex_clock.o \
ex_shutdwn.o \
shellclasses.o \
utility.o \
window.o \
@ -67,7 +63,8 @@ TARGET_OBJECTS = \
filechild.o \
pane.o \
shellbrowser.o \
desktop.o
desktop.o \
taskbar.o
include $(PATH_TO_TOP)/rules.mak

View file

@ -61,13 +61,13 @@ MainFrame::MainFrame(HWND hwnd)
TBBUTTON toolbarBtns[] = {
{0, 0, 0, TBSTYLE_SEP, {0, 0}, 0, 0},
{0, ID_WINDOW_NEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0},
{1, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0},
{2, ID_WINDOW_TILE_HORZ, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0},
{3, ID_WINDOW_TILE_VERT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0},
{0, ID_WINDOW_NEW, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
{1, ID_WINDOW_CASCADE, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
{2, ID_WINDOW_TILE_HORZ, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
{3, ID_WINDOW_TILE_VERT, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
/*TODO
{4, ID_... , TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0},
{5, ID_... , TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0},
{4, ID_... , TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
{5, ID_... , TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
*/ };
_htoolbar = CreateToolbarEx(hwnd, WS_CHILD|WS_VISIBLE,
@ -88,7 +88,7 @@ MainFrame::MainFrame(HWND hwnd)
GetLogicalDriveStrings(BUFFER_LEN, _drives);
drivebarBtn.fsStyle = TBSTYLE_BUTTON;
drivebarBtn.fsStyle = BTNS_BUTTON;
#ifdef _linux_
// insert unix file system button

View file

@ -165,7 +165,7 @@ bool Pane::create_header(HWND hparent, int id)
if (!hwnd)
return false;
SendMessage(hwnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), FALSE);
SetWindowFont(hwnd, GetStockFont(DEFAULT_GUI_FONT), FALSE);
HD_ITEM hdi;
@ -188,7 +188,7 @@ void Pane::init()
{
_himl = ImageList_LoadBitmap(g_Globals._hInstance, MAKEINTRESOURCE(IDB_IMAGES), 16, 0, RGB(0,255,0));
SendMessage(_hwnd, WM_SETFONT, (WPARAM)_out_wrkr._hfont, FALSE);
SetWindowFont(_hwnd, _out_wrkr._hfont, FALSE);
// calculate column widths
_out_wrkr.init_output(_hwnd);

View file

@ -71,8 +71,10 @@ ShellBrowserChild::~ShellBrowserChild()
}
void ShellBrowserChild::OnCreate(LPCREATESTRUCT pcs)
LRESULT ShellBrowserChild::Init(LPCREATESTRUCT pcs)
{
super::Init(pcs);
_hWndFrame = GetParent(pcs->hwndParent);
RECT rect;
@ -95,6 +97,8 @@ void ShellBrowserChild::OnCreate(LPCREATESTRUCT pcs)
InitDragDrop();
}
return 0;
}
@ -211,9 +215,8 @@ void ShellBrowserChild::Tree_DoItemMenu(HWND hwndTreeView, HTREEITEM hItem, LPPO
IContextMenu* pcm;
HRESULT hr = CDefFolderMenu_Create2(dir?dir->_pidl:DesktopFolder(), hwndParent, 1, &pidl, shell_folder, NULL, 0, NULL, &pcm);
// HRESULT hr = shell_folder->GetUIObjectOf(hwndParent, 1, &pidl, IID_IContextMenu, NULL, (LPVOID*)&pcm);
HRESULT hr = shell_folder->GetUIObjectOf(hwndParent, 1, &pidl, IID_IContextMenu, NULL, (LPVOID*)&pcm);
// HRESULT hr = CDefFolderMenu_Create2(dir?dir->_pidl:DesktopFolder(), hwndParent, 1, &pidl, shell_folder, NULL, 0, NULL, &pcm);
if (SUCCEEDED(hr)) {
HMENU hPopup = CreatePopupMenu();
@ -405,11 +408,7 @@ LRESULT ShellBrowserChild::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
case WM_GETISHELLBROWSER: // for Registry Explorer Plugin
return (LRESULT)static_cast<IShellBrowser*>(this);
case WM_CREATE:
OnCreate((LPCREATESTRUCT)lparam);
goto def;
default: def:
default:
return super::WndProc(nmsg, wparam, lparam);
}

View file

@ -116,7 +116,7 @@ protected:
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
int Notify(int id, NMHDR* pnmh);
void OnCreate(LPCREATESTRUCT);
LRESULT Init(LPCREATESTRUCT);
void InitializeTree(/*const FileChildWndInfo& info*/);
void InsertSubitems(HTREEITEM hParentItem, Entry* entry, IShellFolder* pParentFolder);
bool InitDragDrop();

View file

@ -26,7 +26,7 @@ LRESULT WINAPI ExplorerBarProc(HWND, UINT, WPARAM, LPARAM);
//#define TASKBAR_AT_TOP
#define TASKBAR_WIDTH 30
#define TASKBAR_HEIGHT 30
// Loads a configuration style given by PInt
@ -37,10 +37,10 @@ DWORD LoadProperty(int PInt)
switch(PInt)
{
case 1: // WS_EX_Style for creating the bar
return WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_PALETTEWINDOW;
return WS_EX_PALETTEWINDOW;
break;
case 2: // WS_Style for creating the bar
return WS_POPUP | WS_THICKFRAME | WS_CLIPCHILDREN | WS_VISIBLE ;
return WS_POPUP | WS_THICKFRAME | WS_CLIPCHILDREN | WS_VISIBLE;
break;
case 3: // Start X for the panel
return -2; // hide border
@ -49,14 +49,14 @@ DWORD LoadProperty(int PInt)
#ifdef TASKBAR_AT_TOP
return -2;
#else
return GetSystemMetrics(SM_CYSCREEN)-TASKBAR_WIDTH;
return GetSystemMetrics(SM_CYSCREEN)-TASKBAR_HEIGHT;
#endif
break;
case 5:
return GetSystemMetrics(SM_CXSCREEN)+4; // XLen for the panel
break;
case 6:
return TASKBAR_WIDTH+2; // YLen for the panel
return TASKBAR_HEIGHT+2; // YLen for the panel
break;
}

View file

@ -0,0 +1,403 @@
/*
* Copyright 2003 Martin Fuchs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//
// Explorer clone
//
// taskbar.cpp
//
// Martin Fuchs, 16.08.2003
//
#include "../utility/utility.h"
#include "../utility/shellclasses.h"
#include "../explorer.h"
#include "../globals.h"
#include "../externals.h"
#include "taskbar.h"
#define IDC_START 0x1000
#define IDC_FIRST_APP 0x2000
HWND InitializeExplorerBar(HINSTANCE hInstance)
{
WindowClass wcExplorerBar(_T("Shell_TrayWnd"));
wcExplorerBar.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
wcExplorerBar.hCursor = LoadCursor(0, IDC_ARROW);
ATOM explorerBarClass = wcExplorerBar.Register();
RECT rect;
rect.left = -2; // hide left border
#ifdef TASKBAR_AT_TOP
rect.top = -2; // hide top border
#else
rect.top = GetSystemMetrics(SM_CYSCREEN) - TASKBAR_HEIGHT;
#endif
rect.right = GetSystemMetrics(SM_CXSCREEN) + 2;
rect.bottom = rect.top + TASKBAR_HEIGHT + 2;
return Window::Create(WINDOW_CREATOR(DesktopBar), WS_EX_PALETTEWINDOW,
(LPCTSTR)(int)explorerBarClass, _T("DesktopBar"), WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE,
rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, 0);
}
DesktopBar::DesktopBar(HWND hwnd)
: super(hwnd)
{
_hwndTaskBar = 0;
}
DesktopBar::~DesktopBar()
{
PostQuitMessage(0);
}
LRESULT DesktopBar::Init(LPCREATESTRUCT pcs)
{
super::Init(pcs);
// create start button
Button(_hwnd, TEXT("Start"), 2, 2, 50, TASKBAR_HEIGHT-10, IDC_START);//BS_OWNERDRAW
// create task bar
WindowClass wcTaskBar(_T("MSTaskSwWClass"));
wcTaskBar.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
wcTaskBar.hCursor = LoadCursor(0, IDC_ARROW);
ATOM taskbarClass = wcTaskBar.Register();
RECT clnt;
GetClientRect(_hwnd, &clnt);
_hwndTaskBar = Window::Create(WINDOW_CREATOR(TaskBar), 0,
(LPCTSTR)(int)taskbarClass, _T("Running Applications"), WS_CHILD|WS_VISIBLE,
TASKBAR_LEFT, 0, clnt.right-TASKBAR_LEFT, TASKBAR_HEIGHT, _hwnd);
TaskBar* taskbar = static_cast<TaskBar*>(Window::get_window(_hwndTaskBar));
taskbar->_desktop_bar = this;
return 0;
}
LRESULT DesktopBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
{
switch(nmsg) {
case WM_NCHITTEST: {
LRESULT res = super::WndProc(nmsg, wparam, lparam);
if (res>=HTSIZEFIRST && res<=HTSIZELAST) {
#ifdef TASKBAR_AT_TOP
if (res == HTBOTTOM) // enable vertical resizing at the lower border
#else
if (res == HTTOP) // enable vertical resizing at the upper border
#endif
return res;
else
return HTCLIENT; // disable any other resizing
}
return res;}
case WM_SYSCOMMAND:
if ((wparam&0xFFF0) == SC_SIZE) {
#ifdef TASKBAR_AT_TOP
if (wparam == SC_SIZE+6)// enable vertical resizing at the lower border
#else
if (wparam == SC_SIZE+3)// enable vertical resizing at the upper border
#endif
goto def;
else
return 0; // disable any other resizing
}
goto def;
case WM_SIZE: {
if (_hwndTaskBar) {
RECT clnt;
GetClientRect(_hwnd, &clnt);
MoveWindow(_hwndTaskBar, TASKBAR_LEFT, 0, clnt.right-TASKBAR_LEFT, HIWORD(lparam), TRUE);
}
break;}
case WM_CLOSE:
break;
default: def:
return super::WndProc(nmsg, wparam, lparam);
}
return 0;
}
int DesktopBar::Command(int id, int code)
{
if (id == IDC_START)
DestroyWindow(_hwnd);
return 0;
}
static HICON get_window_icon(HWND hwnd)
{
HICON hicon = 0;
SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hicon);
if (!hicon)
SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hicon);
if (!hicon)
SendMessageTimeout(hwnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hicon);
if (!hicon)
hicon = (HICON)GetClassLong(hwnd, GCL_HICONSM);
if (!hicon)
hicon = (HICON)GetClassLong(hwnd, GCL_HICON);
if (!hicon)
SendMessageTimeout(hwnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, (LPDWORD)&hicon);
if (!hicon)
hicon = LoadIcon(0, IDI_APPLICATION);
return hicon;
}
static HBITMAP create_bitmap_from_icon(HICON hicon, HWND hwnd, HBRUSH hbrush_bkgnd)
{
HDC hdc_wnd = GetDC(hwnd);
HBITMAP hbmp = CreateCompatibleBitmap(hdc_wnd, 16, 16);
ReleaseDC(hwnd, hdc_wnd);
HDC hdc = CreateCompatibleDC(0);
HBITMAP hbmp_org = SelectBitmap(hdc, hbmp);
DrawIconEx(hdc, 0, 0, hicon, 16, 16, 0, hbrush_bkgnd, DI_IMAGE);
SelectBitmap(hdc, hbmp_org);
DeleteDC(hdc);
return hbmp;
}
TaskBarMap::~TaskBarMap()
{
while(!empty()) {
iterator it = begin();
DeleteBitmap(it->second._hbmp);
erase(it);
}
}
TaskBar::TaskBar(HWND hwnd)
: super(hwnd)
{
_desktop_bar = NULL;
_last_foreground_wnd = 0;
}
// fill task bar with buttons for enumerated top level windows
BOOL CALLBACK TaskBar::EnumWndProc(HWND hwnd, LPARAM lparam)
{
TaskBar* pThis = (TaskBar*)lparam;
DWORD style = GetWindowStyle(hwnd);
DWORD ex_style = GetWindowExStyle(hwnd);
if ((style&WS_VISIBLE) && !(ex_style&WS_EX_TOOLWINDOW) &&
!GetParent(hwnd) && !GetWindow(hwnd,GW_OWNER)) {
TBBUTTON btn = {-2/*I_IMAGENONE*/, 0, TBSTATE_ENABLED/*|TBSTATE_ELLIPSES*/, BTNS_BUTTON, {0, 0}, 0, 0};
TaskBarMap::iterator found = pThis->_map.find(hwnd);
int last_id = 0;
if (found != pThis->_map.end()) {
last_id = found->second._id;
if (!last_id)
found->second._id = pThis->_next_id++;
} else {
HICON hicon = get_window_icon(hwnd);
HBITMAP hbmp = create_bitmap_from_icon(hicon, pThis->_htoolbar, GetSysColorBrush(COLOR_BTNFACE));
TBADDBITMAP ab = {0, (UINT_PTR)hbmp};
int bmp_idx = SendMessage(pThis->_htoolbar, TB_ADDBITMAP, 1, (LPARAM)&ab);
TaskBarEntry bmp = {pThis->_next_id++, hbmp, bmp_idx, 0, 0};
pThis->_map[hwnd] = bmp;
found = pThis->_map.find(hwnd);
}
TaskBarEntry& entry = found->second;
++entry._used;
btn.idCommand = entry._id;
// create new toolbar buttons for new windows
if (!last_id) {
if (hwnd == GetForegroundWindow())
btn.fsState |= TBSTATE_PRESSED/*|TBSTATE_MARKED*/;
TCHAR title[BUFFER_LEN];
if (!GetWindowText(hwnd, title, BUFFER_LEN))
title[0] = '\0';
if (title[0])
btn.iString = (INT_PTR)title;
btn.iBitmap = entry._bmp_idx;
entry._btn_idx = SendMessage(pThis->_htoolbar, TB_BUTTONCOUNT, 0, 0);
SendMessage(pThis->_htoolbar, TB_INSERTBUTTON, entry._btn_idx, (LPARAM)&btn);
}
}
return TRUE;
}
LRESULT TaskBar::Init(LPCREATESTRUCT pcs)
{
super::Init(pcs);
_htoolbar = CreateToolbarEx(_hwnd,
WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|CCS_TOP|//CCS_NORESIZE|
TBSTYLE_LIST|TBSTYLE_TOOLTIPS|TBSTYLE_WRAPABLE|TBSTYLE_TRANSPARENT,
IDW_TASKTOOLBAR, 0, 0, 0, NULL, 0, 0, 0, 16, 16, sizeof(TBBUTTON));
SendMessage(_htoolbar, TB_SETBUTTONWIDTH, 0, MAKELONG(16,160));
//SendMessage(_htoolbar, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS);
//SendMessage(_htoolbar, TB_SETDRAWTEXTFLAGS, DT_CENTER|DT_VCENTER, DT_CENTER|DT_VCENTER);
//SetWindowFont(_htoolbar, GetStockFont(ANSI_VAR_FONT), FALSE);
_next_id = IDC_FIRST_APP;
Refresh();
SetTimer(_hwnd, 0, 1000, NULL);
return 0;
}
LRESULT TaskBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
{
switch(nmsg) {
case WM_CLOSE:
break;
case WM_SIZE:
SendMessage(_htoolbar, WM_SIZE, 0, 0);
break;
case WM_TIMER: // could be optimized by using WH_CBT hooks instead of timer
Refresh();
return 0;
default:
return super::WndProc(nmsg, wparam, lparam);
}
return super::WndProc(nmsg, wparam, lparam);
}
int TaskBar::Command(int id, int code)
{
TaskBarMap::iterator found = _map.find_id(id);
if (found != _map.end()) {
HWND hwnd = found->first;
if (hwnd==GetForegroundWindow() || hwnd==_last_foreground_wnd) {
ShowWindow(hwnd, SW_MINIMIZE);
_last_foreground_wnd = 0;
} else {
// switch to selected application window
SetForegroundWindow(hwnd);
if (IsIconic(hwnd))
ShowWindow(hwnd, SW_RESTORE);
_last_foreground_wnd = hwnd;
}
return 0;
}
return super::Command(id, code);
}
void TaskBar::Refresh()
{
for(TaskBarMap::iterator it=_map.begin(); it!=_map.end(); ++it)
it->second._used = 0;
EnumWindows(EnumWndProc, (LPARAM)this);
//EnumDesktopWindows(GetThreadDesktop(GetCurrentThreadId()), EnumWndProc, (LPARAM)_htoolbar);
set<int> btn_idx_to_delete;
for(TaskBarMap::iterator it=_map.begin(); it!=_map.end(); ++it) {
TaskBarEntry& entry = it->second;
if (!entry._used && entry._id) {
// store button indexes to remove
btn_idx_to_delete.insert(entry._btn_idx);
entry._id = 0;
}
}
// remove buttons from right to left
for(set<int>::reverse_iterator it=btn_idx_to_delete.rbegin(); it!=btn_idx_to_delete.rend(); ++it) {
int idx = *it;
SendMessage(_htoolbar, TB_DELETEBUTTON, idx, 0);
for(TaskBarMap::iterator it=_map.begin(); it!=_map.end(); ++it) {
TaskBarEntry& entry = it->second;
// adjust button indexes
if (entry._btn_idx > idx)
--entry._btn_idx;
}
}
}
TaskBarMap::iterator TaskBarMap::find_id(int id)
{
for(iterator it=begin(); it!=end(); ++it)
if (it->second._id == id)
return it;
return end();
}

View file

@ -0,0 +1,93 @@
/*
* Copyright 2003 Martin Fuchs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//
// Explorer and Desktop clone
//
// taskbar.h
//
// Martin Fuchs, 16.08.2003
//
#include <map>
#include <set>
#define TASKBAR_HEIGHT 30
#define TASKBAR_LEFT 60
//#define TASKBAR_AT_TOP
struct DesktopBar : public Window
{
typedef Window super;
DesktopBar(HWND hwnd);
~DesktopBar();
protected:
LRESULT Init(LPCREATESTRUCT pcs);
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
int Command(int id, int code);
HWND _hwndTaskBar;
};
#define IDW_TASKTOOLBAR 100
struct TaskBarEntry
{
int _id; // ID for WM_COMMAND
HBITMAP _hbmp;
int _bmp_idx;
int _used;
int _btn_idx;
};
struct TaskBarMap : public map<HWND, TaskBarEntry>
{
~TaskBarMap();
iterator find_id(int id);
};
struct TaskBar : public Window
{
typedef Window super;
TaskBar(HWND hwnd);
DesktopBar* _desktop_bar;
protected:
HWND _htoolbar;
TaskBarMap _map;
int _next_id;
HWND _last_foreground_wnd;
LRESULT Init(LPCREATESTRUCT pcs);
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
int Command(int id, int code);
static BOOL CALLBACK EnumWndProc(HWND, LPARAM);
void Refresh();
};

View file

@ -45,6 +45,11 @@
#include <time.h>
#ifndef BTNS_BUTTON
#define BTNS_BUTTON TBSTYLE_BUTTON //@@ -> wingw headers
#endif
#ifdef __cplusplus
// STL headers for strings and streams
@ -61,6 +66,9 @@ using namespace _com_util;
#endif // _MSC_VER
#define for if (0) {} else for
struct CommonControlInit
{
CommonControlInit(DWORD flags=ICC_LISTVIEW_CLASSES)
@ -133,6 +141,9 @@ extern "C" {
#endif
#define SetDlgCtrlID(hwnd, id) SetWindowLong(hwnd, GWL_ID, id)
// display
extern void display_error(HWND hwnd, DWORD error);

View file

@ -138,25 +138,34 @@ Window* Window::get_window(HWND hwnd)
}
LRESULT Window::Init(LPCREATESTRUCT pcs)
{
return 0;
}
LRESULT CALLBACK Window::WindowWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam)
{
Window* pThis = get_window(hwnd);
if (pThis) {
switch(nmsg) {
case WM_COMMAND:
return pThis->Command(LOWORD(wparam), HIWORD(wparam));
case WM_NOTIFY:
return pThis->Notify(wparam, (NMHDR*)lparam);
case WM_CREATE:
return pThis->Init((LPCREATESTRUCT)lparam);
case WM_NCDESTROY:
delete pThis;
return 0;
case WM_COMMAND:
pThis->Command(LOWORD(wparam), HIWORD(wparam));
return 0;
case WM_NOTIFY:
return pThis->Notify(wparam, (NMHDR*)lparam);
default:
return pThis->WndProc(nmsg, wparam, lparam);
}
return pThis->WndProc(nmsg, wparam, lparam);
}
else
return DefWindowProc(hwnd, nmsg, wparam, lparam);
@ -343,3 +352,11 @@ void ChildWindow::resize_children(int cx, int cy)
EndDeferWindowPos(hdwp);
}
Button::Button(HWND parent, LPCTSTR text, int left, int top, int width, int height,
UINT id, DWORD flags, DWORD ex_flags)
{
_hwnd = CreateWindowEx(ex_flags, TEXT("BUTTON"), text, flags, left, top, width, height,
parent, (HMENU)id, g_Globals._hInstance, 0);
}

View file

@ -65,6 +65,7 @@ protected:
HWND _hwnd;
virtual LRESULT Init(LPCREATESTRUCT pcs);
virtual LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
virtual int Command(int id, int code);
virtual int Notify(int id, NMHDR* pnmh);
@ -168,3 +169,15 @@ protected:
int _split_pos;
int _last_split;
};
struct Button
{
Button(HWND parent, LPCTSTR text, int left, int top, int width, int height,
UINT id, DWORD flags=WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, DWORD ex_flags=0);
operator HWND() const {return _hwnd;}
protected:
HWND _hwnd;
};

View file

@ -117,8 +117,8 @@ HWND create_desktop_window(HINSTANCE hInstance)
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hbrBackground= (HBRUSH) GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName= DesktopClassName;

View file

@ -1944,7 +1944,7 @@ static HWND create_header(HWND parent, Pane* pane, int id)
if (!hwnd)
return 0;
SendMessage(hwnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), FALSE);
SetWindowFont(hwnd, GetStockObject(DEFAULT_GUI_FONT), FALSE);
hdi.mask = HDI_TEXT|HDI_WIDTH|HDI_FORMAT;
@ -2182,7 +2182,7 @@ static void create_tree_window(HWND parent, Pane* pane, int id, int id_header)
SetWindowLong(pane->hwnd, GWL_USERDATA, (LPARAM)pane);
g_orgTreeWndProc = SubclassWindow(pane->hwnd, TreeWndProc);
SendMessage(pane->hwnd, WM_SETFONT, (WPARAM)Globals.hfont, FALSE);
SetWindowFont(pane->hwnd, Globals.hfont, FALSE);
/* insert entries into listbox */
if (entry)
@ -3549,7 +3549,7 @@ void explorer_show_frame(HWND hwndParent, int cmdshow)
GetLogicalDriveStrings(BUFFER_LEN, Globals.drives);
drivebarBtn.fsStyle = TBSTYLE_BUTTON;
drivebarBtn.fsStyle = BTNS_BUTTON;
#ifndef _NO_EXTENSIONS
#ifdef __linux__
@ -3600,13 +3600,13 @@ void explorer_show_frame(HWND hwndParent, int cmdshow)
{
TBBUTTON toolbarBtns[] = {
{0, 0, 0, TBSTYLE_SEP, {0, 0}, 0, 0},
{0, ID_WINDOW_NEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0},
{1, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0},
{2, ID_WINDOW_TILE_HORZ, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0},
{3, ID_WINDOW_TILE_VERT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0},
{0, ID_WINDOW_NEW, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
{1, ID_WINDOW_CASCADE, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
{2, ID_WINDOW_TILE_HORZ, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
{3, ID_WINDOW_TILE_VERT, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
/*TODO
{4, ID_... , TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0},
{5, ID_... , TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0},
{4, ID_... , TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
{5, ID_... , TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
*/ };
Globals.htoolbar = CreateToolbarEx(Globals.hMainWnd, WS_CHILD|WS_VISIBLE,