From becf23850d94408876126c83defed6e127e1127d Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Sun, 24 Aug 2003 13:53:40 +0000 Subject: [PATCH] Added logo in start menu. svn path=/trunk/; revision=5826 --- .../system/explorer/desktop/desktop.cpp | 22 +++----- reactos/subsys/system/explorer/explorer.cpp | 6 ++ reactos/subsys/system/explorer/explorer.dsp | 4 ++ .../subsys/system/explorer/explorer_intres.h | 5 +- .../subsys/system/explorer/explorer_intres.rc | 1 + reactos/subsys/system/explorer/globals.h | 11 ++++ reactos/subsys/system/explorer/res/logov.bmp | Bin 0 -> 6198 bytes reactos/subsys/system/explorer/shell/pane.cpp | 3 +- .../system/explorer/taskbar/startmenu.cpp | 53 ++++++++++++++++-- .../system/explorer/taskbar/startmenu.h | 13 +++-- .../system/explorer/taskbar/taskbar.cpp | 11 ++-- .../subsys/system/explorer/utility/utility.h | 12 ++++ 12 files changed, 105 insertions(+), 36 deletions(-) create mode 100644 reactos/subsys/system/explorer/res/logov.bmp diff --git a/reactos/subsys/system/explorer/desktop/desktop.cpp b/reactos/subsys/system/explorer/desktop/desktop.cpp index 6bed9600f7c..21c24f516cf 100644 --- a/reactos/subsys/system/explorer/desktop/desktop.cpp +++ b/reactos/subsys/system/explorer/desktop/desktop.cpp @@ -44,7 +44,7 @@ static BOOL (WINAPI*SetShellWindowEx)(HWND, HWND); BOOL IsAnyDesktopRunning() { - HINSTANCE shell32 = GetModuleHandle(TEXT("user32")); + HINSTANCE shell32 = GetModuleHandle(_T("user32")); SetShellWindow = (BOOL(WINAPI*)(HWND)) GetProcAddress(shell32, "SetShellWindow"); SetShellWindowEx = (BOOL(WINAPI*)(HWND,HWND)) GetProcAddress(shell32, "SetShellWindowEx"); @@ -55,13 +55,6 @@ BOOL IsAnyDesktopRunning() static void draw_desktop_background(HWND hwnd, HDC hdc) { - // We'd want to draw the desktop wallpaper here. Need to - // maintain a copy of the wallpaper in an off-screen DC and then - // bitblt (or stretchblt?) it to the screen appropriately. For - // now, though, we'll just draw some text. - - static const TCHAR BkgndText[] = TEXT("ReactOS 0.1.2 Desktop Example\nby Silver Blade, Martin Fuchs"); - ClientRect rect(hwnd); PaintDesktop(hdc); @@ -70,14 +63,14 @@ static void draw_desktop_background(HWND hwnd, HDC hdc) FillRect(hdc, &rect, bkgndBrush); DeleteBrush(bkgndBrush); */ - // This next part could be improved by working out how much - // space the text actually needs... rect.left = rect.right - 280; rect.top = rect.bottom - 56 - DESKTOPBARBAR_HEIGHT; rect.right = rect.left + 250; rect.bottom = rect.top + 40; + static const LPCTSTR BkgndText = _T("ReactOS 0.1.2 Explorer\nby Martin Fuchs"); + BkMode bkMode(hdc, TRANSPARENT); TextColor textColor(hdc, RGB(128,128,192)); @@ -94,7 +87,7 @@ LRESULT BackgroundWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) { switch(nmsg) { case WM_ERASEBKGND: - draw_desktop_background(_hwnd, (HDC)wparam); + PaintDesktop((HDC)wparam); return TRUE; case WM_MBUTTONDBLCLK: @@ -218,10 +211,9 @@ LRESULT DesktopWindow::Init(LPCREATESTRUCT pcs) LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) { switch(nmsg) { - case WM_PAINT: { - PaintCanvas canvas(_hwnd); - draw_desktop_background(_hwnd, canvas); - break;} + case WM_PAINT: + draw_desktop_background(_hwnd, PaintCanvas(_hwnd)); + break; case WM_LBUTTONDBLCLK: case WM_RBUTTONDBLCLK: diff --git a/reactos/subsys/system/explorer/explorer.cpp b/reactos/subsys/system/explorer/explorer.cpp index 3e5f35fbe77..ed352d5e761 100644 --- a/reactos/subsys/system/explorer/explorer.cpp +++ b/reactos/subsys/system/explorer/explorer.cpp @@ -74,6 +74,12 @@ SmallIcon::SmallIcon(UINT nid) } +ResBitmap::ResBitmap(UINT nid) +{ + _hBmp = LoadBitmap(g_Globals._hInstance, MAKEINTRESOURCE(nid)); +} + + void explorer_show_frame(HWND hwndDesktop, int cmdshow) { if (g_Globals._hMainWnd) diff --git a/reactos/subsys/system/explorer/explorer.dsp b/reactos/subsys/system/explorer/explorer.dsp index 5bb75b6d217..d7e3a1552b9 100644 --- a/reactos/subsys/system/explorer/explorer.dsp +++ b/reactos/subsys/system/explorer/explorer.dsp @@ -346,6 +346,10 @@ SOURCE=.\res\logoff.ico # End Source File # Begin Source File +SOURCE=.\res\logov.bmp +# End Source File +# Begin Source File + SOURCE=.\res\reactos.ico # End Source File # Begin Source File diff --git a/reactos/subsys/system/explorer/explorer_intres.h b/reactos/subsys/system/explorer/explorer_intres.h index d05740dae38..ae8741dc767 100644 --- a/reactos/subsys/system/explorer/explorer_intres.h +++ b/reactos/subsys/system/explorer/explorer_intres.h @@ -19,7 +19,7 @@ #define IDS_ADMIN 15 #define IDS_NETWORK 16 #define IDS_CONNECTIONS 17 -#define IDS_DRIVES 18 +#define IDS_DRIVES 18 #define IDI_REACTOS 100 #define IDI_EXPLORER 101 #define IDI_STARTMENU 102 @@ -37,6 +37,7 @@ #define IDI_FOLDERARROW 125 #define IDI_ARROW 125 #define IDI_ARROW_SELECTED 126 +#define IDB_LOGOV 129 #define ID_VIEW_NAME 401 #define ID_VIEW_ALL_ATTRIBUTES 402 #define ID_VIEW_SELECTED_ATTRIBUTES 403 @@ -68,7 +69,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_RESOURCE_VALUE 130 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 101 diff --git a/reactos/subsys/system/explorer/explorer_intres.rc b/reactos/subsys/system/explorer/explorer_intres.rc index c039f74003b..f3d9663af55 100644 --- a/reactos/subsys/system/explorer/explorer_intres.rc +++ b/reactos/subsys/system/explorer/explorer_intres.rc @@ -30,6 +30,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDB_IMAGES BITMAP DISCARDABLE "res/images.bmp" IDB_TOOLBAR BITMAP DISCARDABLE "res/toolbar.bmp" IDB_DRIVEBAR BITMAP DISCARDABLE "res/drivebar.bmp" +IDB_LOGOV BITMAP DISCARDABLE "res/logov.bmp" ///////////////////////////////////////////////////////////////////////////// // diff --git a/reactos/subsys/system/explorer/globals.h b/reactos/subsys/system/explorer/globals.h index 47217f6ae1d..1d2351f7231 100644 --- a/reactos/subsys/system/explorer/globals.h +++ b/reactos/subsys/system/explorer/globals.h @@ -63,3 +63,14 @@ struct SmallIcon protected: HICON _hIcon; }; + +struct ResBitmap +{ + ResBitmap(UINT nid); + ~ResBitmap() {DeleteObject(_hBmp);} + + operator HBITMAP() const {return _hBmp;} + +protected: + HBITMAP _hBmp; +}; diff --git a/reactos/subsys/system/explorer/res/logov.bmp b/reactos/subsys/system/explorer/res/logov.bmp new file mode 100644 index 0000000000000000000000000000000000000000..534ea9ddadb81ecf4bef604bdb921bca92bbf550 GIT binary patch literal 6198 zcmeH{ze{CD6vxkkg@TO`B!$JsD%JxFw)Vm{)^_tR*ra%sbs!*2Czu3MY~x?>sub(g z+N_nuf&{X5LW;@foIAhn^*y)9n%&}EojWtk@XhyP&zm)oA6dO-oHJg@ zI&YruhUw{hCc>}GX2ZmrrOfAZnSYqer}w|h+S;0|udmDI=B8|IZOQibw(RWe$nNg0 z?CtHz(b16{9v;fU!GY}W@5}6`ByZm)`9-cJ{T1cU>%Zmt<45`Vk9Q<;49^IRIBXp@ zhs|MgYD>j(vuEzrQfIYAY*aLPZiP$6dh&^J6*c1E2K1Ivycsuet0yz#j zNn+`FIT#!a4h9E{>D`p5&fHo}eBUYXhQZ;bHNxSXU?4ODI}8bi1VaKKkv|eFaWLWJiQ(CMIFiLyA1^=1Z*qKmEGH)?a(a3y zXJ=<}b#*0|mzQ#Lb0fF6w{mxPC-?XF^6>B=kB^V?>7OLOo}cq~Jfpk%H=q;oY^QN` zn`GnpCp|B3tn}v_wCc|{(VvSaPrjHuJ&`Y_dUec;T-MZlQ4YSCK29*nZ*}y9Wj$~q zCmroh%Ca;-_q|8a&00=&4oz<{`v{A5Qeo>NzXm(gqZQGbHVTb)l&dZC_?g6FqMi_orEx->;_OsjhweYJ4HRWo?=I{GY9VU?06l=SRx0 z>GhViITk(NOPPwf_P+>aE)HeZh%G)|Sy-$$*DtBJs@kfL->hxb>(koQtLa76xmoL~ zncJ#6KRVQH%K1KK-^r|ZCzPsft6l=B+y(e%^sZ+M_}d3D#;^Tv6(_=hd3`xuQ|D-H)%cC9Ih4F*wzKtIU6k|L&}GO6YerktbJcOI z*K7L!^`Z1>9i_erSjFq~8h{w3kNx+NFILqi*YlHWuiM<8x}Ppq`m`hC{i;9XeoS|( R{!BYE-mm&I?#FbO{srG_#})tp literal 0 HcmV?d00001 diff --git a/reactos/subsys/system/explorer/shell/pane.cpp b/reactos/subsys/system/explorer/shell/pane.cpp index 71f35d161f2..c7c08734655 100644 --- a/reactos/subsys/system/explorer/shell/pane.cpp +++ b/reactos/subsys/system/explorer/shell/pane.cpp @@ -324,7 +324,6 @@ void Pane::draw_item(LPDRAWITEMSTRUCT dis, Entry* entry, int calcWidthCol) int visible_cols = _visible_cols; COLORREF bkcolor, textcolor; RECT focusRect = dis->rcItem; - HBRUSH hbrush; enum IMAGE img; int img_pos, cx; int col = 0; @@ -459,7 +458,7 @@ void Pane::draw_item(LPDRAWITEMSTRUCT dis, Entry* entry, int calcWidthCol) bkcolor = RGB(255,255,255); } - hbrush = CreateSolidBrush(bkcolor); + HBRUSH hbrush = CreateSolidBrush(bkcolor); FillRect(dis->hDC, &focusRect, hbrush); DeleteObject(hbrush); diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.cpp b/reactos/subsys/system/explorer/taskbar/startmenu.cpp index e38d56fc9bd..6a6783e007e 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.cpp +++ b/reactos/subsys/system/explorer/taskbar/startmenu.cpp @@ -46,6 +46,7 @@ StartMenu::StartMenu(HWND hwnd) { _next_id = IDC_FIRST_MENU; _submenu_id = 0; + _border_left = 0; } StartMenu::StartMenu(HWND hwnd, const StartMenuFolders& info) @@ -57,6 +58,7 @@ StartMenu::StartMenu(HWND hwnd, const StartMenuFolders& info) _next_id = IDC_FIRST_MENU; _submenu_id = 0; + _border_left = 0; } StartMenu::~StartMenu() @@ -153,7 +155,7 @@ LRESULT StartMenu::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) { switch(nmsg) { case WM_SIZE: - ResizeButtons(LOWORD(lparam)); + ResizeButtons(LOWORD(lparam)-_border_left); break; case WM_NCHITTEST: { @@ -306,15 +308,17 @@ void StartMenu::AddButton(LPCTSTR title, HICON hIcon, bool hasSubmenu, UINT id, } // widen window, if it is too small - int width = StartMenuButton::GetTextWidth(title,_hwnd) + 16/*icon*/ + 10/*placeholder*/ + 16/*arrow*/; + int text_width = StartMenuButton::GetTextWidth(title,_hwnd) + 16/*icon*/ + 10/*placeholder*/ + 16/*arrow*/; ClientRect clnt(_hwnd); - if (width > clnt.right) - rect.right += width-clnt.right; + int cx = clnt.right - _border_left; + if (text_width > cx) + rect.right += text_width-cx; MoveWindow(_hwnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE); - StartMenuCtrl(_hwnd, rect.bottom-rect.top-STARTMENU_LINE_HEIGHT-6, title, id, hIcon, hasSubmenu, style); + StartMenuCtrl(_hwnd, _border_left, rect.bottom-rect.top-STARTMENU_LINE_HEIGHT-6, rect.right-rect.left-_border_left, + title, id, hIcon, hasSubmenu, style); } void StartMenu::AddSeparator() @@ -330,7 +334,7 @@ void StartMenu::AddSeparator() MoveWindow(_hwnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE); - StartMenuSeparator(_hwnd, rect.bottom-rect.top-STARTMENU_SEP_HEIGHT-6); + StartMenuSeparator(_hwnd, _border_left, rect.bottom-rect.top-STARTMENU_SEP_HEIGHT-6, rect.right-rect.left-_border_left); } @@ -538,6 +542,14 @@ StartMenuRoot::StartMenuRoot(HWND hwnd) // insert directory "\Start Menu" ShellDirectory usr_startmenu(Desktop(), SpecialFolderPath(CSIDL_STARTMENU, _hwnd), _hwnd); _dirs.push_back(StartMenuDirectory(usr_startmenu, false)); // don't add subfolders + + // read size of logo bitmap + BITMAP bmp_hdr; + GetObject(ResBitmap(IDB_LOGOV), sizeof(BITMAP), &bmp_hdr); + _logo_size.cx = bmp_hdr.bmWidth; + _logo_size.cy = bmp_hdr.bmHeight; + + _border_left = _logo_size.cx; } @@ -583,6 +595,35 @@ LRESULT StartMenuRoot::Init(LPCREATESTRUCT pcs) } +LRESULT StartMenuRoot::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) +{ + switch(nmsg) { + case WM_PAINT: { + PaintCanvas canvas(_hwnd); + MemCanvas mem_dc; + ResBitmap bmp(IDB_LOGOV); + BitmapSelection sel(mem_dc, bmp); + + ClientRect clnt(_hwnd); + int h = min(_logo_size.cy, clnt.bottom); + + RECT rect = {0, 0, _logo_size.cx-1, clnt.bottom-h}; + HBRUSH hbr = CreateSolidBrush(RGB(166,202,240)); // same color as the background color in the logo bitmap + FillRect(canvas, &rect, hbr); + PatBlt(canvas, _logo_size.cx-1, 0, 1, clnt.bottom-h, WHITENESS); + DeleteObject(hbr); + + BitBlt(canvas, 0, clnt.bottom-h, _logo_size.cx, h, mem_dc, 0, 0, SRCCOPY); + break;} + + default: + return super::WndProc(nmsg, wparam, lparam); + } + + return 0; +} + + int StartMenuRoot::Command(int id, int code) { switch(id) { diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.h b/reactos/subsys/system/explorer/taskbar/startmenu.h index fc9b4607b37..c43bb945b06 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.h +++ b/reactos/subsys/system/explorer/taskbar/startmenu.h @@ -95,9 +95,9 @@ protected: */ struct StartMenuCtrl : public Button { - StartMenuCtrl(HWND parent, int y, LPCTSTR title, + StartMenuCtrl(HWND parent, int x, int y, int w, LPCTSTR title, UINT id, HICON hIcon=0, bool hasSubmenu=false, DWORD style=WS_VISIBLE|WS_CHILD|BS_OWNERDRAW, DWORD exStyle=0) - : Button(parent, title, 0, y, ClientRect(parent).right, STARTMENU_LINE_HEIGHT, id, style, exStyle) + : Button(parent, title, x, y, w, STARTMENU_LINE_HEIGHT, id, style, exStyle) { *new StartMenuButton(_hwnd, hIcon, hasSubmenu); @@ -108,8 +108,8 @@ struct StartMenuCtrl : public Button struct StartMenuSeparator : public Static { - StartMenuSeparator(HWND parent, int y, DWORD style=WS_VISIBLE|WS_CHILD|WS_DISABLED|SS_ETCHEDHORZ, DWORD exStyle=0) - : Static(parent, NULL, 0, y+STARTMENU_SEP_HEIGHT/2-1, ClientRect(parent).right, 2, -1, style, exStyle) + StartMenuSeparator(HWND parent, int x, int y, int w, DWORD style=WS_VISIBLE|WS_CHILD|WS_DISABLED|SS_ETCHEDHORZ, DWORD exStyle=0) + : Static(parent, NULL, x, y+STARTMENU_SEP_HEIGHT/2-1, w, 2, -1, style, exStyle) { } }; @@ -153,6 +153,8 @@ protected: UINT _submenu_id; WindowHandle _submenu; + int _border_left; // left border in pixels + // member functions void ResizeButtons(int cx); @@ -200,9 +202,12 @@ struct StartMenuRoot : public StartMenu protected: LRESULT Init(LPCREATESTRUCT pcs); + LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); int Command(int id, int code); void ShowLaunchDialog(HWND hwndDesktopBar); + + SIZE _logo_size; }; diff --git a/reactos/subsys/system/explorer/taskbar/taskbar.cpp b/reactos/subsys/system/explorer/taskbar/taskbar.cpp index 8e07fcdd9a8..c2aff097b4a 100644 --- a/reactos/subsys/system/explorer/taskbar/taskbar.cpp +++ b/reactos/subsys/system/explorer/taskbar/taskbar.cpp @@ -246,16 +246,13 @@ HBITMAP create_bitmap_from_icon(HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd) { HBITMAP hbmp = CreateCompatibleBitmap(hdc_wnd, 16, 16); - HDC hdc = CreateCompatibleDC(0); - HBITMAP hbmp_org = SelectBitmap(hdc, hbmp); + MemCanvas canvas; + BitmapSelection sel(canvas, hbmp); RECT rect = {0, 0, 16, 16}; - FillRect(hdc, &rect, hbrush_bkgnd); + FillRect(canvas, &rect, hbrush_bkgnd); - DrawIconEx(hdc, 0, 0, hIcon, 16, 16, 0, hbrush_bkgnd, DI_NORMAL); - - SelectBitmap(hdc, hbmp_org); - DeleteDC(hdc); + DrawIconEx(canvas, 0, 0, hIcon, 16, 16, 0, hbrush_bkgnd, DI_NORMAL); return hbmp; } diff --git a/reactos/subsys/system/explorer/utility/utility.h b/reactos/subsys/system/explorer/utility/utility.h index c498f69649c..f56fc81cbe6 100644 --- a/reactos/subsys/system/explorer/utility/utility.h +++ b/reactos/subsys/system/explorer/utility/utility.h @@ -322,6 +322,18 @@ protected: HFONT _old_hFont; }; +struct BitmapSelection +{ + BitmapSelection(HDC hdc, HBITMAP hBmp) + : _hdc(hdc), _old_hBmp(SelectBitmap(hdc, hBmp)) {} + + ~BitmapSelection() {SelectBitmap(_hdc, _old_hBmp);} + +protected: + HDC _hdc; + HBITMAP _old_hBmp; +}; + struct String #ifdef UNICODE