1 /* File: button.c -- Button type widgets
3 * Copyright (C) 1993 Johannes Ruscheinski
4 * Copyright (C) 1993 David Metcalfe
5 * Copyright (C) 1994 Alexandre Julliard
11 #include "wine/winuser16.h"
14 static void PaintGrayOnGray( HDC hDC,HFONT hFont,RECT *rc,
15 char *text, UINT format );
17 static void PB_Paint( WND *wndPtr, HDC hDC, WORD action );
18 static void CB_Paint( WND *wndPtr, HDC hDC, WORD action );
19 static void GB_Paint( WND *wndPtr, HDC hDC, WORD action );
20 static void UB_Paint( WND *wndPtr, HDC hDC, WORD action );
21 static void OB_Paint( WND *wndPtr, HDC hDC, WORD action );
22 static void BUTTON_CheckAutoRadioButton( WND *wndPtr );
24 #define MAX_BTN_TYPE 12
26 static const WORD maxCheckState[MAX_BTN_TYPE] =
28 BUTTON_UNCHECKED, /* BS_PUSHBUTTON */
29 BUTTON_UNCHECKED, /* BS_DEFPUSHBUTTON */
30 BUTTON_CHECKED, /* BS_CHECKBOX */
31 BUTTON_CHECKED, /* BS_AUTOCHECKBOX */
32 BUTTON_CHECKED, /* BS_RADIOBUTTON */
33 BUTTON_3STATE, /* BS_3STATE */
34 BUTTON_3STATE, /* BS_AUTO3STATE */
35 BUTTON_UNCHECKED, /* BS_GROUPBOX */
36 BUTTON_UNCHECKED, /* BS_USERBUTTON */
37 BUTTON_CHECKED, /* BS_AUTORADIOBUTTON */
38 BUTTON_UNCHECKED, /* Not defined */
39 BUTTON_UNCHECKED /* BS_OWNERDRAW */
42 typedef void (*pfPaint)( WND *wndPtr, HDC hdc, WORD action );
44 static const pfPaint btnPaintFunc[MAX_BTN_TYPE] =
46 PB_Paint, /* BS_PUSHBUTTON */
47 PB_Paint, /* BS_DEFPUSHBUTTON */
48 CB_Paint, /* BS_CHECKBOX */
49 CB_Paint, /* BS_AUTOCHECKBOX */
50 CB_Paint, /* BS_RADIOBUTTON */
51 CB_Paint, /* BS_3STATE */
52 CB_Paint, /* BS_AUTO3STATE */
53 GB_Paint, /* BS_GROUPBOX */
54 UB_Paint, /* BS_USERBUTTON */
55 CB_Paint, /* BS_AUTORADIOBUTTON */
56 NULL, /* Not defined */
57 OB_Paint /* BS_OWNERDRAW */
60 #define PAINT_BUTTON(wndPtr,style,action) \
61 if (btnPaintFunc[style]) { \
62 HDC hdc = GetDC( (wndPtr)->hwndSelf ); \
63 (btnPaintFunc[style])(wndPtr,hdc,action); \
64 ReleaseDC( (wndPtr)->hwndSelf, hdc ); }
66 #define BUTTON_SEND_CTLCOLOR(wndPtr,hdc) \
67 SendMessageA( GetParent((wndPtr)->hwndSelf), WM_CTLCOLORBTN, \
68 (hdc), (wndPtr)->hwndSelf )
70 static HBITMAP hbitmapCheckBoxes = 0;
71 static WORD checkBoxWidth = 0, checkBoxHeight = 0;
74 /***********************************************************************
75 * ButtonWndProc_locked
77 * Called with window lock held.
79 static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg,
80 WPARAM wParam, LPARAM lParam )
83 HWND hWnd = wndPtr->hwndSelf;
85 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
86 LONG style = wndPtr->dwStyle & 0x0f;
89 pt.x = LOWORD(lParam);
90 pt.y = HIWORD(lParam);
97 case BS_PUSHBUTTON: return DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON;
98 case BS_DEFPUSHBUTTON: return DLGC_BUTTON | DLGC_DEFPUSHBUTTON;
100 case BS_AUTORADIOBUTTON: return DLGC_BUTTON | DLGC_RADIOBUTTON;
101 default: return DLGC_BUTTON;
105 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
109 if (!hbitmapCheckBoxes)
112 hbitmapCheckBoxes = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_CHECKBOXES));
113 GetObjectA( hbitmapCheckBoxes, sizeof(bmp), &bmp );
114 checkBoxWidth = bmp.bmWidth / 4;
115 checkBoxHeight = bmp.bmHeight / 3;
117 if (style < 0L || style >= MAX_BTN_TYPE)
118 return -1; /* abort */
119 infoPtr->state = BUTTON_UNCHECKED;
121 infoPtr->hImage = NULL;
128 if (btnPaintFunc[style])
131 HDC hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps );
132 SetBkMode( hdc, OPAQUE );
133 (btnPaintFunc[style])( wndPtr, hdc, ODA_DRAWENTIRE );
134 if( !wParam ) EndPaint( hWnd, &ps );
139 case WM_LBUTTONDBLCLK:
140 SendMessageA( hWnd, BM_SETSTATE, TRUE, 0 );
147 if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break;
148 SendMessageA( hWnd, BM_SETSTATE, FALSE, 0 );
149 GetClientRect( hWnd, &rect );
150 if (PtInRect( &rect, pt ))
154 case BS_AUTOCHECKBOX:
155 SendMessageA( hWnd, BM_SETCHECK,
156 !(infoPtr->state & BUTTON_CHECKED), 0 );
158 case BS_AUTORADIOBUTTON:
159 SendMessageA( hWnd, BM_SETCHECK, TRUE, 0 );
162 SendMessageA( hWnd, BM_SETCHECK,
163 (infoPtr->state & BUTTON_3STATE) ? 0 :
164 ((infoPtr->state & 3) + 1), 0 );
167 SendMessageA( GetParent(hWnd), WM_COMMAND,
168 MAKEWPARAM( wndPtr->wIDmenu, BN_CLICKED ), hWnd);
173 if (GetCapture() == hWnd)
175 GetClientRect( hWnd, &rect );
176 SendMessageA( hWnd, BM_SETSTATE, PtInRect(&rect, pt), 0 );
181 if(style == BS_GROUPBOX) return HTTRANSPARENT;
182 return DefWindowProcA( hWnd, uMsg, wParam, lParam );
185 DEFWND_SetText( wndPtr, (LPCSTR)lParam );
186 if( wndPtr->dwStyle & WS_VISIBLE )
187 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
191 infoPtr->hFont = (HFONT16)wParam;
192 if (lParam && (wndPtr->dwStyle & WS_VISIBLE))
193 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
197 return infoPtr->hFont;
200 infoPtr->state |= BUTTON_HASFOCUS;
201 if (style == BS_AUTORADIOBUTTON)
202 SendMessageA( hWnd, BM_SETCHECK, 1, 0 );
203 PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
207 infoPtr->state &= ~BUTTON_HASFOCUS;
208 PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
209 InvalidateRect( hWnd, NULL, TRUE );
212 case WM_SYSCOLORCHANGE:
213 InvalidateRect( hWnd, NULL, FALSE );
218 if ((wParam & 0x0f) >= MAX_BTN_TYPE) break;
219 wndPtr->dwStyle = (wndPtr->dwStyle & 0xfffffff0)
220 | (wParam & 0x0000000f);
221 style = wndPtr->dwStyle & 0x0000000f;
222 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
226 oldHbitmap = infoPtr->hImage;
227 if(wndPtr->dwStyle & BS_BITMAP)
228 infoPtr->hImage = (HANDLE) lParam;
232 return infoPtr->hImage;
236 return infoPtr->state & 3;
240 if (wParam > maxCheckState[style]) wParam = maxCheckState[style];
241 if ((infoPtr->state & 3) != wParam)
243 if ((style == BS_RADIOBUTTON) || (style == BS_AUTORADIOBUTTON))
246 wndPtr->dwStyle |= WS_TABSTOP;
248 wndPtr->dwStyle &= ~WS_TABSTOP;
250 infoPtr->state = (infoPtr->state & ~3) | wParam;
251 PAINT_BUTTON( wndPtr, style, ODA_SELECT );
253 if ((style == BS_AUTORADIOBUTTON) && (wParam == BUTTON_CHECKED))
254 BUTTON_CheckAutoRadioButton( wndPtr );
259 return infoPtr->state;
265 if (infoPtr->state & BUTTON_HIGHLIGHTED) break;
266 infoPtr->state |= BUTTON_HIGHLIGHTED;
270 if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break;
271 infoPtr->state &= ~BUTTON_HIGHLIGHTED;
273 PAINT_BUTTON( wndPtr, style, ODA_SELECT );
277 return DefWindowProcA(hWnd, uMsg, wParam, lParam);
282 /***********************************************************************
284 * The button window procedure. This is just a wrapper which locks
285 * the passed HWND and calls the real window procedure (with a WND*
286 * pointer pointing to the locked windowstructure).
288 LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg,
289 WPARAM wParam, LPARAM lParam )
292 WND *wndPtr = WIN_FindWndPtr(hWnd);
294 res = ButtonWndProc_locked(wndPtr,uMsg,wParam,lParam);
296 WIN_ReleaseWndPtr(wndPtr);
300 /**********************************************************************
301 * Push Button Functions
304 static void PB_Paint( WND *wndPtr, HDC hDC, WORD action )
309 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
310 int xBorderOffset, yBorderOffset;
311 xBorderOffset = yBorderOffset = 0;
313 GetClientRect( wndPtr->hwndSelf, &rc );
315 /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
316 if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
317 BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
318 hOldPen = (HPEN)SelectObject(hDC, GetSysColorPen(COLOR_WINDOWFRAME));
319 hOldBrush =(HBRUSH)SelectObject(hDC,GetSysColorBrush(COLOR_BTNFACE));
320 SetBkMode(hDC, TRANSPARENT);
321 Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
322 if (TWEAK_WineLook == WIN31_LOOK)
324 SetPixel( hDC, rc.left, rc.top, GetSysColor(COLOR_WINDOW) );
325 SetPixel( hDC, rc.left, rc.bottom-1, GetSysColor(COLOR_WINDOW) );
326 SetPixel( hDC, rc.right-1, rc.top, GetSysColor(COLOR_WINDOW) );
327 SetPixel( hDC, rc.right-1, rc.bottom-1, GetSysColor(COLOR_WINDOW));
329 InflateRect( &rc, -1, -1 );
331 if ((wndPtr->dwStyle & 0x000f) == BS_DEFPUSHBUTTON)
333 Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
334 InflateRect( &rc, -1, -1 );
337 if (infoPtr->state & BUTTON_HIGHLIGHTED)
339 /* draw button shadow: */
340 SelectObject(hDC, GetSysColorBrush(COLOR_BTNSHADOW));
341 PatBlt(hDC, rc.left, rc.top, 1, rc.bottom-rc.top, PATCOPY );
342 PatBlt(hDC, rc.left, rc.top, rc.right-rc.left, 1, PATCOPY );
343 rc.left += 2; /* To position the text down and right */
346 rc.right++, rc.bottom++;
347 DrawEdge( hDC, &rc, EDGE_RAISED, BF_RECT );
349 /* To place de bitmap correctly */
350 xBorderOffset += GetSystemMetrics(SM_CXEDGE);
351 yBorderOffset += GetSystemMetrics(SM_CYEDGE);
353 rc.right--, rc.bottom--;
356 /* draw button label, if any: */
357 if (wndPtr->text && wndPtr->text[0])
360 GetObjectA( GetSysColorBrush(COLOR_BTNFACE), sizeof(lb), &lb );
361 if (wndPtr->dwStyle & WS_DISABLED &&
362 GetSysColor(COLOR_GRAYTEXT)==lb.lbColor)
363 /* don't write gray text on gray background */
364 PaintGrayOnGray( hDC,infoPtr->hFont,&rc,wndPtr->text,
365 DT_CENTER | DT_VCENTER );
368 SetTextColor( hDC, (wndPtr->dwStyle & WS_DISABLED) ?
369 GetSysColor(COLOR_GRAYTEXT) :
370 GetSysColor(COLOR_BTNTEXT) );
371 DrawTextA( hDC, wndPtr->text, -1, &rc,
372 DT_SINGLELINE | DT_CENTER | DT_VCENTER );
373 /* do we have the focus? */
374 if (infoPtr->state & BUTTON_HASFOCUS)
376 RECT r = { 0, 0, 0, 0 };
379 DrawTextA( hDC, wndPtr->text, -1, &r,
380 DT_SINGLELINE | DT_CALCRECT );
381 xdelta = ((rc.right - rc.left) - (r.right - r.left) - 1) / 2;
382 ydelta = ((rc.bottom - rc.top) - (r.bottom - r.top) - 1) / 2;
383 if (xdelta < 0) xdelta = 0;
384 if (ydelta < 0) ydelta = 0;
385 InflateRect( &rc, -xdelta, -ydelta );
386 DrawFocusRect( hDC, &rc );
391 if((wndPtr->dwStyle & BS_BITMAP) && (infoPtr->hImage != NULL))
395 int yOffset, xOffset, imageWidth, imageHeight;
397 GetObjectA (infoPtr->hImage, sizeof(BITMAP), &bm);
399 /* Center the bitmap */
400 xOffset = (((rc.right - rc.left) - 2*xBorderOffset) - bm.bmWidth ) / 2;
401 yOffset = (((rc.bottom - rc.top) - 2*yBorderOffset) - bm.bmHeight ) / 2;
403 imageWidth = bm.bmWidth;
404 imageHeight = bm.bmHeight;
406 /* If the image is to big for the button */
409 imageWidth = rc.right - rc.left - 2*xBorderOffset -1;
410 xOffset = xBorderOffset;
415 imageHeight = rc.bottom - rc.top - 2*yBorderOffset -1;
416 yOffset = yBorderOffset;
419 /* Let minimum 1 space from border */
420 xOffset++, yOffset++;
422 hdcMem = CreateCompatibleDC (hDC);
423 SelectObject (hdcMem, (HBITMAP)infoPtr->hImage);
424 BitBlt(hDC, rc.left + xOffset,
426 imageWidth, imageHeight,
427 hdcMem, 0, 0, SRCCOPY);
432 SelectObject( hDC, hOldPen );
433 SelectObject( hDC, hOldBrush );
437 /**********************************************************************
438 * PB_Paint & CB_Paint sub function [internal]
439 * Paint text using a raster brush to avoid gray text on gray
440 * background. 'format' can be a combination of DT_CENTER and
441 * DT_VCENTER to use this function in both PB_PAINT and
442 * CB_PAINT. - Dirk Thierbach
444 * FIXME: This and TEXT_GrayString should be eventually combined,
445 * so calling one common function from PB_Paint, CB_Paint and
446 * TEXT_GrayString will be enough. Also note that this
447 * function ignores the CACHE_GetPattern funcs.
450 void PaintGrayOnGray(HDC hDC,HFONT hFont,RECT *rc,char *text,
453 /* This is the standard gray on gray pattern:
454 static const WORD Pattern[] = {0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55};
456 /* This pattern gives better readability with X Fonts.
457 FIXME: Maybe the user should be allowed to decide which he wants. */
458 static const WORD Pattern[] = {0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF};
460 HBITMAP hbm = CreateBitmap( 8, 8, 1, 1, Pattern );
461 HDC hdcMem = CreateCompatibleDC(hDC);
467 DrawTextA( hDC, text, -1, &rect, DT_SINGLELINE | DT_CALCRECT);
468 /* now text width and height are in rect.right and rect.bottom */
470 rect.left = rect.top = 0; /* drawing pos in hdcMem */
471 if (format & DT_CENTER) rect.left=(rc->right-rect.right)/2;
472 if (format & DT_VCENTER) rect.top=(rc->bottom-rect.bottom)/2;
473 hbmMem = CreateCompatibleBitmap( hDC,rect.right,rect.bottom );
474 SelectObject( hdcMem, hbmMem);
475 PatBlt( hdcMem,0,0,rect.right,rect.bottom,WHITENESS);
476 /* will be overwritten by DrawText, but just in case */
477 if (hFont) SelectObject( hdcMem, hFont);
478 DrawTextA( hdcMem, text, -1, &rc2, DT_SINGLELINE);
479 /* After draw: foreground = 0 bits, background = 1 bits */
480 hBr = SelectObject( hdcMem, CreatePatternBrush(hbm) );
482 PatBlt( hdcMem,0,0,rect.right,rect.bottom,0xAF0229);
483 /* only keep the foreground bits where pattern is 1 */
484 DeleteObject( SelectObject( hdcMem,hBr) );
485 BitBlt(hDC,rect.left,rect.top,rect.right,rect.bottom,hdcMem,0,0,SRCAND);
486 /* keep the background of the dest */
488 DeleteObject( hbmMem );
492 /**********************************************************************
493 * Check Box & Radio Button Functions
496 static void CB_Paint( WND *wndPtr, HDC hDC, WORD action )
498 RECT rbox, rtext, client;
501 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
504 GetClientRect(wndPtr->hwndSelf, &client);
505 rbox = rtext = client;
507 if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
509 /* Something is still not right, checkboxes (and edit controls)
510 * in wsping32 have white backgrounds instead of dark grey.
511 * BUTTON_SEND_CTLCOLOR() is even worse since it returns 0 in this
512 * particular case and the background is not painted at all.
515 hBrush = GetControlBrush16( wndPtr->hwndSelf, hDC, CTLCOLOR_BTN );
517 if (wndPtr->dwStyle & BS_LEFTTEXT)
519 /* magic +4 is what CTL3D expects */
521 rtext.right -= checkBoxWidth + 4;
522 rbox.left = rbox.right - checkBoxWidth;
526 rtext.left += checkBoxWidth + 4;
527 rbox.right = checkBoxWidth;
530 /* Draw the check-box bitmap */
532 if (wndPtr->text) textlen = strlen( wndPtr->text );
533 if (action == ODA_DRAWENTIRE || action == ODA_SELECT)
535 HDC hMemDC = CreateCompatibleDC( hDC );
537 delta = (rbox.bottom - rbox.top - checkBoxHeight) >> 1;
539 if (action == ODA_SELECT) FillRect( hDC, &rbox, hBrush );
540 else FillRect( hDC, &client, hBrush );
542 if (infoPtr->state & BUTTON_HIGHLIGHTED) x += 2 * checkBoxWidth;
543 if (infoPtr->state & (BUTTON_CHECKED | BUTTON_3STATE)) x += checkBoxWidth;
544 if (((wndPtr->dwStyle & 0x0f) == BS_RADIOBUTTON) ||
545 ((wndPtr->dwStyle & 0x0f) == BS_AUTORADIOBUTTON)) y += checkBoxHeight;
546 else if (infoPtr->state & BUTTON_3STATE) y += 2 * checkBoxHeight;
548 SelectObject( hMemDC, hbitmapCheckBoxes );
549 BitBlt( hDC, rbox.left, rbox.top + delta, checkBoxWidth,
550 checkBoxHeight, hMemDC, x, y, SRCCOPY );
553 if( textlen && action != ODA_SELECT )
555 if (wndPtr->dwStyle & WS_DISABLED &&
556 GetSysColor(COLOR_GRAYTEXT)==GetBkColor(hDC)) {
557 /* don't write gray text on gray background */
558 PaintGrayOnGray( hDC, infoPtr->hFont, &rtext, wndPtr->text,
561 if (wndPtr->dwStyle & WS_DISABLED)
562 SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) );
563 DrawTextA( hDC, wndPtr->text, textlen, &rtext,
564 DT_SINGLELINE | DT_VCENTER );
565 textlen = 0; /* skip DrawText() below */
570 if ((action == ODA_FOCUS) ||
571 ((action == ODA_DRAWENTIRE) && (infoPtr->state & BUTTON_HASFOCUS)))
573 /* again, this is what CTL3D expects */
577 DrawTextA( hDC, wndPtr->text, textlen, &rbox,
578 DT_SINGLELINE | DT_CALCRECT );
579 textlen = rbox.bottom - rbox.top;
580 delta = ((rtext.bottom - rtext.top) - textlen)/2;
581 rbox.bottom = (rbox.top = rtext.top + delta - 1) + textlen + 2;
582 textlen = rbox.right - rbox.left;
583 rbox.right = (rbox.left += --rtext.left) + textlen + 2;
584 IntersectRect(&rbox, &rbox, &rtext);
585 DrawFocusRect( hDC, &rbox );
590 /**********************************************************************
591 * BUTTON_CheckAutoRadioButton
593 * wndPtr is checked, uncheck every other auto radio button in group
595 static void BUTTON_CheckAutoRadioButton( WND *wndPtr )
597 HWND parent, sibling, start;
598 if (!(wndPtr->dwStyle & WS_CHILD)) return;
599 parent = wndPtr->parent->hwndSelf;
600 /* assure that starting control is not disabled or invisible */
601 start = sibling = GetNextDlgGroupItem( parent, wndPtr->hwndSelf, TRUE );
606 tmpWnd = WIN_FindWndPtr(sibling);
607 if ((wndPtr->hwndSelf != sibling) &&
608 ((tmpWnd->dwStyle & 0x0f) == BS_AUTORADIOBUTTON))
609 SendMessageA( sibling, BM_SETCHECK, BUTTON_UNCHECKED, 0 );
610 sibling = GetNextDlgGroupItem( parent, sibling, FALSE );
611 WIN_ReleaseWndPtr(tmpWnd);
612 } while (sibling != start);
616 /**********************************************************************
617 * Group Box Functions
620 static void GB_Paint( WND *wndPtr, HDC hDC, WORD action )
623 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
625 if (action != ODA_DRAWENTIRE) return;
627 BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
629 GetClientRect( wndPtr->hwndSelf, &rc);
630 if (TWEAK_WineLook == WIN31_LOOK) {
631 HPEN hPrevPen = SelectObject( hDC,
632 GetSysColorPen(COLOR_WINDOWFRAME));
633 HBRUSH hPrevBrush = SelectObject( hDC,
634 GetStockObject(NULL_BRUSH) );
636 Rectangle( hDC, rc.left, rc.top + 2, rc.right - 1, rc.bottom - 1 );
637 SelectObject( hDC, hPrevBrush );
638 SelectObject( hDC, hPrevPen );
644 SelectObject (hDC, infoPtr->hFont);
645 GetTextMetricsA (hDC, &tm);
646 rcFrame.top += (tm.tmHeight / 2) - 1;
647 DrawEdge (hDC, &rcFrame, EDGE_ETCHED, BF_RECT);
652 if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
653 if (wndPtr->dwStyle & WS_DISABLED)
654 SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) );
656 DrawTextA( hDC, wndPtr->text, -1, &rc, DT_SINGLELINE | DT_NOCLIP );
661 /**********************************************************************
662 * User Button Functions
665 static void UB_Paint( WND *wndPtr, HDC hDC, WORD action )
669 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
671 if (action == ODA_SELECT) return;
673 GetClientRect( wndPtr->hwndSelf, &rc);
675 if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
676 hBrush = GetControlBrush16( wndPtr->hwndSelf, hDC, CTLCOLOR_BTN );
678 FillRect( hDC, &rc, hBrush );
679 if ((action == ODA_FOCUS) ||
680 ((action == ODA_DRAWENTIRE) && (infoPtr->state & BUTTON_HASFOCUS)))
681 DrawFocusRect( hDC, &rc );
685 /**********************************************************************
686 * Ownerdrawn Button Functions
689 static void OB_Paint( WND *wndPtr, HDC hDC, WORD action )
691 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
694 dis.CtlType = ODT_BUTTON;
695 dis.CtlID = wndPtr->wIDmenu;
697 dis.itemAction = action;
698 dis.itemState = ((infoPtr->state & BUTTON_HASFOCUS) ? ODS_FOCUS : 0) |
699 ((infoPtr->state & BUTTON_HIGHLIGHTED) ? ODS_SELECTED : 0) |
700 ((wndPtr->dwStyle & WS_DISABLED) ? ODS_DISABLED : 0);
701 dis.hwndItem = wndPtr->hwndSelf;
704 GetClientRect( wndPtr->hwndSelf, &dis.rcItem );
705 SendMessageA( GetParent(wndPtr->hwndSelf), WM_DRAWITEM,
706 wndPtr->wIDmenu, (LPARAM)&dis );