Commit 767b099f authored by Dennis Björklund's avatar Dennis Björklund Committed by Alexandre Julliard

Win9x look & feel on buttons and a fix for ownerdrawn buttons

(background set to COLOR_BTNFACE).
parent d65b73bb
...@@ -312,7 +312,7 @@ LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg, ...@@ -312,7 +312,7 @@ LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg,
static void PB_Paint( WND *wndPtr, HDC hDC, WORD action ) static void PB_Paint( WND *wndPtr, HDC hDC, WORD action )
{ {
RECT rc; RECT rc, focus_rect;
HPEN hOldPen; HPEN hOldPen;
HBRUSH hOldBrush; HBRUSH hOldBrush;
BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra; BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
...@@ -327,43 +327,77 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action ) ...@@ -327,43 +327,77 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action )
hOldPen = (HPEN)SelectObject(hDC, GetSysColorPen(COLOR_WINDOWFRAME)); hOldPen = (HPEN)SelectObject(hDC, GetSysColorPen(COLOR_WINDOWFRAME));
hOldBrush =(HBRUSH)SelectObject(hDC,GetSysColorBrush(COLOR_BTNFACE)); hOldBrush =(HBRUSH)SelectObject(hDC,GetSysColorBrush(COLOR_BTNFACE));
SetBkMode(hDC, TRANSPARENT); SetBkMode(hDC, TRANSPARENT);
Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
if (TWEAK_WineLook == WIN31_LOOK) if ( TWEAK_WineLook == WIN31_LOOK)
{ {
Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
SetPixel( hDC, rc.left, rc.top, GetSysColor(COLOR_WINDOW) ); SetPixel( hDC, rc.left, rc.top, GetSysColor(COLOR_WINDOW) );
SetPixel( hDC, rc.left, rc.bottom-1, GetSysColor(COLOR_WINDOW) ); SetPixel( hDC, rc.left, rc.bottom-1, GetSysColor(COLOR_WINDOW) );
SetPixel( hDC, rc.right-1, rc.top, GetSysColor(COLOR_WINDOW) ); SetPixel( hDC, rc.right-1, rc.top, GetSysColor(COLOR_WINDOW) );
SetPixel( hDC, rc.right-1, rc.bottom-1, GetSysColor(COLOR_WINDOW)); SetPixel( hDC, rc.right-1, rc.bottom-1, GetSysColor(COLOR_WINDOW));
InflateRect( &rc, -1, -1 );
} }
InflateRect( &rc, -1, -1 );
if ((wndPtr->dwStyle & 0x000f) == BS_DEFPUSHBUTTON) if ((wndPtr->dwStyle & 0x000f) == BS_DEFPUSHBUTTON)
{ {
Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
InflateRect( &rc, -1, -1 ); InflateRect( &rc, -1, -1 );
} }
if (infoPtr->state & BUTTON_HIGHLIGHTED) if (TWEAK_WineLook == WIN31_LOOK)
{ {
/* draw button shadow: */ if (infoPtr->state & BUTTON_HIGHLIGHTED)
SelectObject(hDC, GetSysColorBrush(COLOR_BTNSHADOW)); {
PatBlt(hDC, rc.left, rc.top, 1, rc.bottom-rc.top, PATCOPY ); /* draw button shadow: */
PatBlt(hDC, rc.left, rc.top, rc.right-rc.left, 1, PATCOPY ); SelectObject(hDC, GetSysColorBrush(COLOR_BTNSHADOW));
rc.left += 2; /* To position the text down and right */ PatBlt(hDC, rc.left, rc.top, 1, rc.bottom-rc.top, PATCOPY );
rc.top += 2; PatBlt(hDC, rc.left, rc.top, rc.right-rc.left, 1, PATCOPY );
} else { rc.left += 2; /* To position the text down and right */
rc.right++, rc.bottom++; rc.top += 2;
DrawEdge( hDC, &rc, EDGE_RAISED, BF_RECT ); } else {
rc.right++, rc.bottom++;
DrawEdge( hDC, &rc, EDGE_RAISED, BF_RECT );
/* To place de bitmap correctly */
xBorderOffset += GetSystemMetrics(SM_CXEDGE);
yBorderOffset += GetSystemMetrics(SM_CYEDGE);
rc.right--, rc.bottom--;
}
}
else
{
UINT uState = DFCS_BUTTONPUSH;
if (infoPtr->state & BUTTON_HIGHLIGHTED)
{
if ( (wndPtr->dwStyle & 0x000f) == BS_DEFPUSHBUTTON )
uState |= DFCS_FLAT;
else
uState |= DFCS_PUSHED;
}
/* To place de bitmap correctly */ DrawFrameControl( hDC, &rc, DFC_BUTTON, uState );
xBorderOffset += GetSystemMetrics(SM_CXEDGE); InflateRect( &rc, -2, -2 );
yBorderOffset += GetSystemMetrics(SM_CYEDGE);
rc.right--, rc.bottom--; focus_rect = rc;
if (infoPtr->state & BUTTON_HIGHLIGHTED)
{
rc.left += 2; /* To position the text down and right */
rc.top += 2;
}
} }
/* draw button label, if any: */ /* draw button label, if any:
if (wndPtr->text && wndPtr->text[0]) *
* In win9x we don't show text if there is a bitmap or icon.
* I don't know about win31 so I leave it as it was for win31.
* Dennis Bjrklund 12 Jul, 99
*/
if ( wndPtr->text && wndPtr->text[0]
&& (TWEAK_WineLook == WIN31_LOOK || !(wndPtr->dwStyle & (BS_ICON|BS_BITMAP))) )
{ {
LOGBRUSH lb; LOGBRUSH lb;
GetObjectA( GetSysColorBrush(COLOR_BTNFACE), sizeof(lb), &lb ); GetObjectA( GetSysColorBrush(COLOR_BTNFACE), sizeof(lb), &lb );
...@@ -379,8 +413,11 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action ) ...@@ -379,8 +413,11 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action )
GetSysColor(COLOR_BTNTEXT) ); GetSysColor(COLOR_BTNTEXT) );
DrawTextA( hDC, wndPtr->text, -1, &rc, DrawTextA( hDC, wndPtr->text, -1, &rc,
DT_SINGLELINE | DT_CENTER | DT_VCENTER ); DT_SINGLELINE | DT_CENTER | DT_VCENTER );
/* do we have the focus? */ /* do we have the focus?
if (infoPtr->state & BUTTON_HASFOCUS) * Win9x draws focus last with a size prop. to the button
*/
if (TWEAK_WineLook == WIN31_LOOK
&& infoPtr->state & BUTTON_HASFOCUS)
{ {
RECT r = { 0, 0, 0, 0 }; RECT r = { 0, 0, 0, 0 };
INT xdelta, ydelta; INT xdelta, ydelta;
...@@ -437,6 +474,14 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action ) ...@@ -437,6 +474,14 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action )
DeleteDC (hdcMem); DeleteDC (hdcMem);
} }
if (TWEAK_WineLook != WIN31_LOOK
&& infoPtr->state & BUTTON_HASFOCUS)
{
InflateRect( &focus_rect, -1, -1 );
DrawFocusRect( hDC, &focus_rect );
}
SelectObject( hDC, hOldPen ); SelectObject( hDC, hOldPen );
SelectObject( hDC, hOldBrush ); SelectObject( hDC, hOldBrush );
...@@ -711,6 +756,10 @@ static void OB_Paint( WND *wndPtr, HDC hDC, WORD action ) ...@@ -711,6 +756,10 @@ static void OB_Paint( WND *wndPtr, HDC hDC, WORD action )
dis.hDC = hDC; dis.hDC = hDC;
dis.itemData = 0; dis.itemData = 0;
GetClientRect( wndPtr->hwndSelf, &dis.rcItem ); GetClientRect( wndPtr->hwndSelf, &dis.rcItem );
SetBkColor( hDC, GetSysColor( COLOR_BTNFACE ) );
FillRect( hDC, &dis.rcItem, GetSysColorBrush( COLOR_BTNFACE ) );
SendMessageA( GetParent(wndPtr->hwndSelf), WM_DRAWITEM, SendMessageA( GetParent(wndPtr->hwndSelf), WM_DRAWITEM,
wndPtr->wIDmenu, (LPARAM)&dis ); wndPtr->wIDmenu, (LPARAM)&dis );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment