Commit 9b4748b6 authored by Francis Beaudet's avatar Francis Beaudet Committed by Alexandre Julliard

Implemented the BS_ICON style.

parent 483c548e
...@@ -20,6 +20,7 @@ static void GB_Paint( WND *wndPtr, HDC hDC, WORD action ); ...@@ -20,6 +20,7 @@ static void GB_Paint( WND *wndPtr, HDC hDC, WORD action );
static void UB_Paint( WND *wndPtr, HDC hDC, WORD action ); static void UB_Paint( WND *wndPtr, HDC hDC, WORD action );
static void OB_Paint( WND *wndPtr, HDC hDC, WORD action ); static void OB_Paint( WND *wndPtr, HDC hDC, WORD action );
static void BUTTON_CheckAutoRadioButton( WND *wndPtr ); static void BUTTON_CheckAutoRadioButton( WND *wndPtr );
static void BUTTON_DrawPushButton( WND *wndPtr, HDC hDC, WORD action, BOOL pushedState);
#define MAX_BTN_TYPE 12 #define MAX_BTN_TYPE 12
...@@ -233,12 +234,17 @@ static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg, ...@@ -233,12 +234,17 @@ static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg,
case BM_SETIMAGE: case BM_SETIMAGE:
oldHbitmap = infoPtr->hImage; oldHbitmap = infoPtr->hImage;
if(wndPtr->dwStyle & BS_BITMAP) if ((wndPtr->dwStyle & BS_BITMAP) || (wndPtr->dwStyle & BS_ICON))
infoPtr->hImage = (HANDLE) lParam; infoPtr->hImage = (HANDLE) lParam;
return oldHbitmap; return oldHbitmap;
case BM_GETIMAGE: case BM_GETIMAGE:
return infoPtr->hImage; if (wParam == IMAGE_BITMAP)
return (HBITMAP)infoPtr->hImage;
else if (wParam == IMAGE_ICON)
return (HICON)infoPtr->hImage;
else
return NULL;
case BM_GETCHECK16: case BM_GETCHECK16:
case BM_GETCHECK: case BM_GETCHECK:
...@@ -309,9 +315,31 @@ LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg, ...@@ -309,9 +315,31 @@ LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg,
/********************************************************************** /**********************************************************************
* Push Button Functions * Push Button Functions
*/ */
static void PB_Paint( WND *wndPtr, HDC hDC, WORD action ) static void PB_Paint( WND *wndPtr, HDC hDC, WORD action )
{ {
BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
BOOL bHighLighted = (infoPtr->state & BUTTON_HIGHLIGHTED);
/*
* Delegate this to the more generic pushbutton painting
* method.
*/
return BUTTON_DrawPushButton(wndPtr,
hDC,
action,
bHighLighted);
}
/**********************************************************************
* This method will actually do the drawing of the pushbutton
* depending on it's state and the pushedState parameter.
*/
static void BUTTON_DrawPushButton(
WND* wndPtr,
HDC hDC,
WORD action,
BOOL pushedState )
{
RECT rc, focus_rect; RECT rc, focus_rect;
HPEN hOldPen; HPEN hOldPen;
HBRUSH hOldBrush; HBRUSH hOldBrush;
...@@ -347,7 +375,7 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action ) ...@@ -347,7 +375,7 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action )
if (TWEAK_WineLook == WIN31_LOOK) if (TWEAK_WineLook == WIN31_LOOK)
{ {
if (infoPtr->state & BUTTON_HIGHLIGHTED) if (pushedState)
{ {
/* draw button shadow: */ /* draw button shadow: */
SelectObject(hDC, GetSysColorBrush(COLOR_BTNSHADOW)); SelectObject(hDC, GetSysColorBrush(COLOR_BTNSHADOW));
...@@ -370,7 +398,7 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action ) ...@@ -370,7 +398,7 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action )
{ {
UINT uState = DFCS_BUTTONPUSH; UINT uState = DFCS_BUTTONPUSH;
if (infoPtr->state & BUTTON_HIGHLIGHTED) if (pushedState)
{ {
if ( (wndPtr->dwStyle & 0x000f) == BS_DEFPUSHBUTTON ) if ( (wndPtr->dwStyle & 0x000f) == BS_DEFPUSHBUTTON )
uState |= DFCS_FLAT; uState |= DFCS_FLAT;
...@@ -383,7 +411,7 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action ) ...@@ -383,7 +411,7 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action )
focus_rect = rc; focus_rect = rc;
if (infoPtr->state & BUTTON_HIGHLIGHTED) if (pushedState)
{ {
rc.left += 2; /* To position the text down and right */ rc.left += 2; /* To position the text down and right */
rc.top += 2; rc.top += 2;
...@@ -433,21 +461,39 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action ) ...@@ -433,21 +461,39 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action )
} }
} }
} }
if ( ((wndPtr->dwStyle & BS_ICON) || (wndPtr->dwStyle & BS_BITMAP) ) &&
(infoPtr->hImage != NULL) )
{
int yOffset, xOffset;
int imageWidth, imageHeight;
if((wndPtr->dwStyle & BS_BITMAP) && (infoPtr->hImage != NULL)) /*
* We extract the size of the image from the handle.
*/
if (wndPtr->dwStyle & BS_ICON)
{ {
ICONINFO iconInfo;
BITMAP bm; BITMAP bm;
HDC hdcMem;
int yOffset, xOffset, imageWidth, imageHeight;
GetObjectA (infoPtr->hImage, sizeof(BITMAP), &bm); GetIconInfo((HICON)infoPtr->hImage, &iconInfo);
GetObjectA (iconInfo.hbmColor, sizeof(BITMAP), &bm);
/* Center the bitmap */ imageWidth = bm.bmWidth;
xOffset = (((rc.right - rc.left) - 2*xBorderOffset) - bm.bmWidth ) / 2; imageHeight = bm.bmHeight;
yOffset = (((rc.bottom - rc.top) - 2*yBorderOffset) - bm.bmHeight ) / 2; }
else
{
BITMAP bm;
GetObjectA (infoPtr->hImage, sizeof(BITMAP), &bm);
imageWidth = bm.bmWidth; imageWidth = bm.bmWidth;
imageHeight = bm.bmHeight; imageHeight = bm.bmHeight;
}
/* Center the bitmap */
xOffset = (((rc.right - rc.left) - 2*xBorderOffset) - imageWidth ) / 2;
yOffset = (((rc.bottom - rc.top) - 2*yBorderOffset) - imageHeight) / 2;
/* If the image is to big for the button */ /* If the image is to big for the button */
if (xOffset < 0) if (xOffset < 0)
...@@ -465,15 +511,31 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action ) ...@@ -465,15 +511,31 @@ static void PB_Paint( WND *wndPtr, HDC hDC, WORD action )
/* Let minimum 1 space from border */ /* Let minimum 1 space from border */
xOffset++, yOffset++; xOffset++, yOffset++;
/*
* Draw the image now.
*/
if (wndPtr->dwStyle & BS_ICON)
{
DrawIcon(hDC,
rc.left + xOffset,
rc.top + yOffset,
(HICON)infoPtr->hImage);
}
else
{
HDC hdcMem;
hdcMem = CreateCompatibleDC (hDC); hdcMem = CreateCompatibleDC (hDC);
SelectObject (hdcMem, (HBITMAP)infoPtr->hImage); SelectObject (hdcMem, (HBITMAP)infoPtr->hImage);
BitBlt(hDC, rc.left + xOffset, BitBlt(hDC,
rc.left + xOffset,
rc.top + yOffset, rc.top + yOffset,
imageWidth, imageHeight, imageWidth, imageHeight,
hdcMem, 0, 0, SRCCOPY); hdcMem, 0, 0, SRCCOPY);
DeleteDC (hdcMem); DeleteDC (hdcMem);
} }
}
if (TWEAK_WineLook != WIN31_LOOK if (TWEAK_WineLook != WIN31_LOOK
&& infoPtr->state & BUTTON_HASFOCUS) && infoPtr->state & BUTTON_HASFOCUS)
...@@ -554,6 +616,21 @@ static void CB_Paint( WND *wndPtr, HDC hDC, WORD action ) ...@@ -554,6 +616,21 @@ static void CB_Paint( WND *wndPtr, HDC hDC, WORD action )
int textlen, delta; int textlen, delta;
BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra; BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
/*
* if the button has a bitmap/icon, draw a normal pushbutton
* instead of a radion button.
*/
if (infoPtr->hImage!=NULL)
{
BOOL bHighLighted = ((infoPtr->state & BUTTON_HIGHLIGHTED) ||
(infoPtr->state & BUTTON_CHECKED));
return BUTTON_DrawPushButton(wndPtr,
hDC,
action,
bHighLighted);
}
textlen = 0; textlen = 0;
GetClientRect(wndPtr->hwndSelf, &client); GetClientRect(wndPtr->hwndSelf, &client);
rbox = rtext = client; rbox = rtext = client;
......
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