mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 01:39:30 +00:00
picture button for start menu
svn path=/trunk/; revision=5623
This commit is contained in:
parent
ff7ea1c1f5
commit
a24652a4d7
11 changed files with 304 additions and 22 deletions
|
@ -72,9 +72,9 @@ static void draw_desktop_background(HWND hwnd, HDC hdc)
|
|||
rect.right = rect.left + 250;
|
||||
rect.bottom = rect.top + 40;
|
||||
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
BkMode bkMode(hdc, TRANSPARENT);
|
||||
|
||||
SetTextColor(hdc, RGB(128,128,192));
|
||||
TextColor textColor(hdc, RGB(128,128,192));
|
||||
DrawText(hdc, BkgndText, -1, &rect, DT_RIGHT);
|
||||
|
||||
SetTextColor(hdc, RGB(255,255,255));
|
||||
|
|
|
@ -433,6 +433,10 @@ SOURCE=.\shell\shellfs.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\res\startmenu.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\shell\startup.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -35,9 +35,6 @@
|
|||
#include "utility/window.h"
|
||||
|
||||
|
||||
#define BUFFER_LEN 1024
|
||||
|
||||
|
||||
#define IDW_STATUSBAR 0x100
|
||||
#define IDW_TOOLBAR 0x101
|
||||
#define IDW_DRIVEBAR 0x102
|
||||
|
@ -61,17 +58,6 @@
|
|||
#define CLASSNAME_WINEFILETREE TEXT("WFS_Tree")
|
||||
|
||||
|
||||
struct String
|
||||
#ifdef UNICODE
|
||||
: public wstring
|
||||
#else
|
||||
: public string
|
||||
#endif
|
||||
{
|
||||
String& operator=(LPCTSTR s) {assign(s); return *this;}
|
||||
operator LPCTSTR() const {return c_str();}
|
||||
};
|
||||
|
||||
struct ResString : public String
|
||||
{
|
||||
ResString(UINT nid);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#define IDM_MAINFRAME 105
|
||||
#define ID_EXECUTE 105
|
||||
#define IDM_WINEFILE 107
|
||||
#define IDB_STARTMENU 120
|
||||
#define IDI_STARTMENU 121
|
||||
#define ID_VIEW_NAME 401
|
||||
#define ID_VIEW_ALL_ATTRIBUTES 402
|
||||
#define ID_VIEW_SELECTED_ATTRIBUTES 403
|
||||
|
@ -45,7 +47,7 @@
|
|||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 120
|
||||
#define _APS_NEXT_RESOURCE_VALUE 122
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
|
|
|
@ -91,6 +91,7 @@ END
|
|||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_EXPLORER ICON DISCARDABLE "res/explorer.ico"
|
||||
IDI_STARTMENU ICON DISCARDABLE "res/startmenu.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
|
BIN
reactos/subsys/system/explorer/res/startmenu.ico
Normal file
BIN
reactos/subsys/system/explorer/res/startmenu.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -32,6 +32,7 @@
|
|||
#include "../explorer.h"
|
||||
#include "../globals.h"
|
||||
#include "../externals.h"
|
||||
#include "../explorer_intres.h"
|
||||
|
||||
#include "taskbar.h"
|
||||
|
||||
|
@ -80,7 +81,9 @@ 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
|
||||
new PictureButton(Button(_hwnd, TEXT("Start"), 2, 2, STARTBUTTON_WIDTH, TASKBAR_HEIGHT-10, IDC_START,
|
||||
WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_OWNERDRAW),
|
||||
LoadIcon(g_Globals._hInstance, MAKEINTRESOURCE(IDI_STARTMENU)));
|
||||
|
||||
// create task bar
|
||||
WindowClass wcTaskBar(CLASSNAME_TASKBAR);
|
||||
|
|
|
@ -32,8 +32,9 @@
|
|||
#include <set>
|
||||
|
||||
|
||||
#define TASKBAR_HEIGHT 30
|
||||
#define TASKBAR_LEFT 60
|
||||
#define TASKBAR_HEIGHT 30
|
||||
#define STARTBUTTON_WIDTH 90
|
||||
#define TASKBAR_LEFT 100
|
||||
//#define TASKBAR_AT_TOP
|
||||
|
||||
#define WM_SHELLHOOK_NOTIFY (WM_APP+0x10)
|
||||
|
@ -46,9 +47,9 @@
|
|||
#define TITLE_TASKBAR _T("Running Applications")
|
||||
|
||||
|
||||
struct DesktopBar : public Window
|
||||
struct DesktopBar : public OwnerDrawParent<Window>
|
||||
{
|
||||
typedef Window super;
|
||||
typedef OwnerDrawParent<Window> super;
|
||||
|
||||
DesktopBar(HWND hwnd);
|
||||
~DesktopBar();
|
||||
|
|
|
@ -69,6 +69,9 @@ using namespace _com_util;
|
|||
#define for if (0) {} else for
|
||||
|
||||
|
||||
#define BUFFER_LEN 1024
|
||||
|
||||
|
||||
struct CommonControlInit
|
||||
{
|
||||
CommonControlInit(DWORD flags=ICC_LISTVIEW_CLASSES)
|
||||
|
@ -106,6 +109,32 @@ struct ClientRect : public RECT
|
|||
};
|
||||
|
||||
|
||||
struct TextColor
|
||||
{
|
||||
TextColor(HDC hdc, COLORREF color)
|
||||
: _hdc(hdc), _old_color(SetTextColor(hdc, color)) {}
|
||||
|
||||
~TextColor() {SetTextColor(_hdc, _old_color);}
|
||||
|
||||
protected:
|
||||
HDC _hdc;
|
||||
COLORREF _old_color;
|
||||
};
|
||||
|
||||
|
||||
struct BkMode
|
||||
{
|
||||
BkMode(HDC hdc, int bkmode)
|
||||
: _hdc(hdc), _old_bkmode(SetBkMode(hdc, bkmode)) {}
|
||||
|
||||
~BkMode() {SetBkMode(_hdc, _old_bkmode);}
|
||||
|
||||
protected:
|
||||
HDC _hdc;
|
||||
COLORREF _old_bkmode;
|
||||
};
|
||||
|
||||
|
||||
struct FullScreenParameters {
|
||||
FullScreenParameters()
|
||||
: _mode(FALSE)
|
||||
|
@ -118,6 +147,18 @@ struct FullScreenParameters {
|
|||
};
|
||||
|
||||
|
||||
struct String
|
||||
#ifdef UNICODE
|
||||
: public wstring
|
||||
#else
|
||||
: public string
|
||||
#endif
|
||||
{
|
||||
String& operator=(LPCTSTR s) {assign(s); return *this;}
|
||||
operator LPCTSTR() const {return c_str();}
|
||||
};
|
||||
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
|
|
|
@ -193,6 +193,9 @@ SubclassedWindow::SubclassedWindow(HWND hwnd)
|
|||
: Window(hwnd)
|
||||
{
|
||||
_orgWndProc = SubclassWindow(_hwnd, WindowWndProc);
|
||||
|
||||
if (!_orgWndProc)
|
||||
delete this;
|
||||
}
|
||||
|
||||
LRESULT SubclassedWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||
|
@ -359,3 +362,160 @@ Button::Button(HWND parent, LPCTSTR text, int left, int top, int width, int heig
|
|||
_hwnd = CreateWindowEx(ex_flags, TEXT("BUTTON"), text, flags, left, top, width, height,
|
||||
parent, (HMENU)id, g_Globals._hInstance, 0);
|
||||
}
|
||||
|
||||
|
||||
static RECT s_MyDrawText_Rect = {0, 0};
|
||||
|
||||
static BOOL CALLBACK MyDrawText(HDC hdc, LPARAM data, int cnt)
|
||||
{
|
||||
::DrawText(hdc, (LPCTSTR)data, cnt, &s_MyDrawText_Rect, DT_SINGLELINE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
LRESULT ColorButton::WndProc(UINT message, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
if (message == WM_DISPATCH_DRAWITEM) {
|
||||
LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lparam;
|
||||
UINT style = DFCS_BUTTONPUSH;
|
||||
|
||||
if (dis->itemState & ODS_DISABLED)
|
||||
style |= DFCS_INACTIVE;
|
||||
|
||||
RECT textRect = {dis->rcItem.left+2, dis->rcItem.top+2, dis->rcItem.right-4, dis->rcItem.bottom-4};
|
||||
|
||||
if (dis->itemState & ODS_SELECTED) {
|
||||
style |= DFCS_PUSHED;
|
||||
++textRect.left; ++textRect.top;
|
||||
++textRect.right; ++textRect.bottom;
|
||||
}
|
||||
|
||||
DrawFrameControl(dis->hDC, &dis->rcItem, DFC_BUTTON, style);
|
||||
|
||||
TCHAR text[BUFFER_LEN];
|
||||
GetWindowText(_hwnd, text, BUFFER_LEN);
|
||||
|
||||
if (dis->itemState & (ODS_DISABLED|ODS_GRAYED)) {
|
||||
COLORREF gray = GetSysColor(COLOR_GRAYTEXT);
|
||||
|
||||
if (gray) {
|
||||
{
|
||||
TextColor lcColor(dis->hDC, GetSysColor(COLOR_BTNHIGHLIGHT));
|
||||
RECT shadowRect = {textRect.left+1, textRect.top+1, textRect.right+1, textRect.bottom+1};
|
||||
DrawText(dis->hDC, text, -1, &shadowRect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
|
||||
}
|
||||
|
||||
BkMode mode(dis->hDC, TRANSPARENT);
|
||||
TextColor lcColor(dis->hDC, gray);
|
||||
DrawText(dis->hDC, text, -1, &textRect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
|
||||
} else {
|
||||
int old_r = textRect.right;
|
||||
int old_b = textRect.bottom;
|
||||
DrawText(dis->hDC, text, -1, &textRect, DT_SINGLELINE|DT_VCENTER|DT_CENTER|DT_CALCRECT);
|
||||
int x = textRect.left + (old_r-textRect.right)/2;
|
||||
int y = textRect.top + (old_b-textRect.bottom)/2;
|
||||
int w = textRect.right-textRect.left;
|
||||
int h = textRect.bottom-textRect.top;
|
||||
s_MyDrawText_Rect.right = w;
|
||||
s_MyDrawText_Rect.bottom = h;
|
||||
GrayString(dis->hDC, GetSysColorBrush(COLOR_GRAYTEXT), MyDrawText, (LPARAM)text, -1, x, y, w, h);
|
||||
}
|
||||
} else {
|
||||
TextColor lcColor(dis->hDC, _textColor);
|
||||
DrawText(dis->hDC, text, -1, &textRect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
|
||||
}
|
||||
|
||||
if (dis->itemState & ODS_FOCUS) {
|
||||
RECT rect = {
|
||||
dis->rcItem.left+3, dis->rcItem.top+3,
|
||||
dis->rcItem.right-dis->rcItem.left-4, dis->rcItem.bottom-dis->rcItem.top-4
|
||||
};
|
||||
if (dis->itemState & ODS_SELECTED) {
|
||||
++rect.left; ++rect.top;
|
||||
++rect.right; ++rect.bottom;
|
||||
}
|
||||
DrawFocusRect(dis->hDC, &rect);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
} else
|
||||
return super::WndProc(message, wparam, lparam);
|
||||
}
|
||||
|
||||
|
||||
LRESULT PictureButton::WndProc(UINT message, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
if (message == WM_DISPATCH_DRAWITEM) {
|
||||
LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lparam;
|
||||
UINT style = DFCS_BUTTONPUSH;
|
||||
|
||||
if (dis->itemState & ODS_DISABLED)
|
||||
style |= DFCS_INACTIVE;
|
||||
|
||||
POINT iconPos = {dis->rcItem.left+2, dis->rcItem.top+2};
|
||||
RECT textRect = {dis->rcItem.left+2, dis->rcItem.top+2, dis->rcItem.right-4, dis->rcItem.bottom-4};
|
||||
|
||||
if (dis->itemState & ODS_SELECTED) {
|
||||
style |= DFCS_PUSHED;
|
||||
++iconPos.x; ++iconPos.y;
|
||||
++textRect.left; ++textRect.top;
|
||||
++textRect.right; ++textRect.bottom;
|
||||
}
|
||||
|
||||
/*@@ if (_flat) {
|
||||
if (GetWindowStyle(_hwnd) & BS_FLAT) // Nur wenn zusätzlich BS_FLAT gesetzt ist, wird ohne Highlight ein Rahmen gezeichnet.
|
||||
DrawEdge(dis->hDC, &dis->rcItem, EDGE_RAISED, BF_RECT|BF_FLAT);
|
||||
} else*/
|
||||
DrawFrameControl(dis->hDC, &dis->rcItem, DFC_BUTTON, style);
|
||||
|
||||
DrawIconEx(dis->hDC, iconPos.x, iconPos.y, _hicon, 16, 16, 0, GetSysColorBrush(COLOR_BTNFACE), DI_NORMAL);
|
||||
|
||||
TCHAR text[BUFFER_LEN];
|
||||
GetWindowText(_hwnd, text, BUFFER_LEN);
|
||||
|
||||
if (dis->itemState & (ODS_DISABLED|ODS_GRAYED)) {
|
||||
COLORREF gray = GetSysColor(COLOR_GRAYTEXT);
|
||||
|
||||
if (gray) {
|
||||
{
|
||||
TextColor lcColor(dis->hDC, GetSysColor(COLOR_BTNHIGHLIGHT));
|
||||
RECT shadowRect = {textRect.left+1, textRect.top+1, textRect.right+1, textRect.bottom+1};
|
||||
DrawText(dis->hDC, text, -1, &shadowRect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
|
||||
}
|
||||
|
||||
BkMode mode(dis->hDC, TRANSPARENT);
|
||||
TextColor lcColor(dis->hDC, gray);
|
||||
DrawText(dis->hDC, text, -1, &textRect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
|
||||
} else {
|
||||
int old_r = textRect.right;
|
||||
int old_b = textRect.bottom;
|
||||
DrawText(dis->hDC, text, -1, &textRect, DT_SINGLELINE|DT_VCENTER|DT_CENTER|DT_CALCRECT);
|
||||
int x = textRect.left + (old_r-textRect.right)/2;
|
||||
int y = textRect.top + (old_b-textRect.bottom)/2;
|
||||
int w = textRect.right-textRect.left;
|
||||
int h = textRect.bottom-textRect.top;
|
||||
s_MyDrawText_Rect.right = w;
|
||||
s_MyDrawText_Rect.bottom = h;
|
||||
GrayString(dis->hDC, GetSysColorBrush(COLOR_GRAYTEXT), MyDrawText, (LPARAM)text, -1, x, y, w, h);
|
||||
}
|
||||
} else {
|
||||
//TextColor lcColor(dis->hDC, _textColor);
|
||||
DrawText(dis->hDC, text, -1, &textRect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
|
||||
}
|
||||
|
||||
if (dis->itemState & ODS_FOCUS) {
|
||||
RECT rect = {
|
||||
dis->rcItem.left+3, dis->rcItem.top+3,
|
||||
dis->rcItem.right-dis->rcItem.left-4, dis->rcItem.bottom-dis->rcItem.top-4
|
||||
};
|
||||
if (dis->itemState & ODS_SELECTED) {
|
||||
++rect.left; ++rect.top;
|
||||
++rect.right; ++rect.bottom;
|
||||
}
|
||||
DrawFocusRect(dis->hDC, &rect);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
} else
|
||||
return super::WndProc(message, wparam, lparam);
|
||||
}
|
||||
|
|
|
@ -181,3 +181,87 @@ struct Button
|
|||
protected:
|
||||
HWND _hwnd;
|
||||
};
|
||||
|
||||
|
||||
// control message routing for colloered and owner drawn controls
|
||||
#define WM_DISPATCH_CTLCOLOR (WM_APP+0x07)
|
||||
#define WM_DISPATCH_DRAWITEM (WM_APP+0x08)
|
||||
|
||||
template<typename BASE> struct CtlColorParent : public BASE
|
||||
{
|
||||
typedef BASE super;
|
||||
|
||||
CtlColorParent(HWND hwnd)
|
||||
: super(hwnd) {}
|
||||
|
||||
LRESULT WndProc(UINT message, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch(message) {
|
||||
case WM_CTLCOLOR:
|
||||
case WM_CTLCOLORBTN:
|
||||
case WM_CTLCOLORDLG:
|
||||
case WM_CTLCOLORSCROLLBAR:
|
||||
case WM_CTLCOLORSTATIC: {
|
||||
HWND hctl = (HWND) lparam;
|
||||
return SendMessage(hctl, WM_DISPATCH_CTLCOLOR, wparam, message);
|
||||
}
|
||||
|
||||
default:
|
||||
return super::WndProc(message, wparam, lparam);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// for ColorButton and PictureButton
|
||||
template<typename BASE> struct OwnerDrawParent : public BASE
|
||||
{
|
||||
typedef BASE super;
|
||||
|
||||
OwnerDrawParent(HWND hwnd)
|
||||
: super(hwnd) {}
|
||||
|
||||
LRESULT WndProc(UINT message, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch(message) {
|
||||
case WM_DRAWITEM:
|
||||
if (wparam) { // ein Control?
|
||||
HWND hctl = GetDlgItem(_hwnd, wparam);
|
||||
|
||||
if (hctl)
|
||||
return SendMessage(hctl, WM_DISPATCH_DRAWITEM, wparam, lparam);
|
||||
} /*else // oder ein Menüeintrag?
|
||||
; */
|
||||
|
||||
return 0;
|
||||
|
||||
default:
|
||||
return super::WndProc(message, wparam, lparam);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct ColorButton : public SubclassedWindow
|
||||
{
|
||||
typedef SubclassedWindow super;
|
||||
|
||||
ColorButton(HWND hwnd, COLORREF textColor)
|
||||
: super(hwnd), _textColor(textColor) {}
|
||||
|
||||
protected:
|
||||
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||
|
||||
COLORREF _textColor;
|
||||
};
|
||||
|
||||
struct PictureButton : public SubclassedWindow
|
||||
{
|
||||
typedef SubclassedWindow super;
|
||||
|
||||
PictureButton(HWND hwnd, HICON hicon)
|
||||
: super(hwnd), _hicon(hicon) {}
|
||||
|
||||
protected:
|
||||
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||
|
||||
HICON _hicon;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue