Paint gray text on gray background in checkboxes/radiobuttons by
[wine/wine-kai.git] / controls / button.c
blobfe2f98f09dc967cb5b908d0764ed5d2dcd0d7063
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
6 */
8 #include <string.h>
9 #include "win.h"
10 #include "button.h"
11 #include "winuser.h"
12 #include "wine/winuser16.h"
13 #include "tweak.h"
15 static void PaintGrayOnGray( HDC hDC,HFONT hFont,RECT *rc,
16 char *text, UINT format );
18 static void PB_Paint( WND *wndPtr, HDC hDC, WORD action );
19 static void CB_Paint( WND *wndPtr, HDC hDC, WORD action );
20 static void GB_Paint( WND *wndPtr, HDC hDC, WORD action );
21 static void UB_Paint( WND *wndPtr, HDC hDC, WORD action );
22 static void OB_Paint( WND *wndPtr, HDC hDC, WORD action );
23 static void BUTTON_CheckAutoRadioButton( WND *wndPtr );
25 #define MAX_BTN_TYPE 12
27 static const WORD maxCheckState[MAX_BTN_TYPE] =
29 BUTTON_UNCHECKED, /* BS_PUSHBUTTON */
30 BUTTON_UNCHECKED, /* BS_DEFPUSHBUTTON */
31 BUTTON_CHECKED, /* BS_CHECKBOX */
32 BUTTON_CHECKED, /* BS_AUTOCHECKBOX */
33 BUTTON_CHECKED, /* BS_RADIOBUTTON */
34 BUTTON_3STATE, /* BS_3STATE */
35 BUTTON_3STATE, /* BS_AUTO3STATE */
36 BUTTON_UNCHECKED, /* BS_GROUPBOX */
37 BUTTON_UNCHECKED, /* BS_USERBUTTON */
38 BUTTON_CHECKED, /* BS_AUTORADIOBUTTON */
39 BUTTON_UNCHECKED, /* Not defined */
40 BUTTON_UNCHECKED /* BS_OWNERDRAW */
43 typedef void (*pfPaint)( WND *wndPtr, HDC hdc, WORD action );
45 static const pfPaint btnPaintFunc[MAX_BTN_TYPE] =
47 PB_Paint, /* BS_PUSHBUTTON */
48 PB_Paint, /* BS_DEFPUSHBUTTON */
49 CB_Paint, /* BS_CHECKBOX */
50 CB_Paint, /* BS_AUTOCHECKBOX */
51 CB_Paint, /* BS_RADIOBUTTON */
52 CB_Paint, /* BS_3STATE */
53 CB_Paint, /* BS_AUTO3STATE */
54 GB_Paint, /* BS_GROUPBOX */
55 UB_Paint, /* BS_USERBUTTON */
56 CB_Paint, /* BS_AUTORADIOBUTTON */
57 NULL, /* Not defined */
58 OB_Paint /* BS_OWNERDRAW */
61 #define PAINT_BUTTON(wndPtr,style,action) \
62 if (btnPaintFunc[style]) { \
63 HDC hdc = GetDC( (wndPtr)->hwndSelf ); \
64 (btnPaintFunc[style])(wndPtr,hdc,action); \
65 ReleaseDC( (wndPtr)->hwndSelf, hdc ); }
67 #define BUTTON_SEND_CTLCOLOR(wndPtr,hdc) \
68 SendMessageA( GetParent((wndPtr)->hwndSelf), WM_CTLCOLORBTN, \
69 (hdc), (wndPtr)->hwndSelf )
71 static HBITMAP hbitmapCheckBoxes = 0;
72 static WORD checkBoxWidth = 0, checkBoxHeight = 0;
75 /***********************************************************************
76 * ButtonWndProc
78 LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg,
79 WPARAM wParam, LPARAM lParam )
81 RECT rect;
82 POINT pt = { LOWORD(lParam), HIWORD(lParam) };
83 WND *wndPtr = WIN_FindWndPtr(hWnd);
84 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
85 LONG style = wndPtr->dwStyle & 0x0f;
87 switch (uMsg)
89 case WM_GETDLGCODE:
90 switch(style)
92 case BS_PUSHBUTTON: return DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON;
93 case BS_DEFPUSHBUTTON: return DLGC_BUTTON | DLGC_DEFPUSHBUTTON;
94 case BS_RADIOBUTTON:
95 case BS_AUTORADIOBUTTON: return DLGC_BUTTON | DLGC_RADIOBUTTON;
96 default: return DLGC_BUTTON;
99 case WM_ENABLE:
100 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
101 break;
103 case WM_CREATE:
104 if (!hbitmapCheckBoxes)
106 BITMAP bmp;
107 hbitmapCheckBoxes = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_CHECKBOXES));
108 GetObjectA( hbitmapCheckBoxes, sizeof(bmp), &bmp );
109 checkBoxWidth = bmp.bmWidth / 4;
110 checkBoxHeight = bmp.bmHeight / 3;
112 if (style < 0L || style >= MAX_BTN_TYPE) return -1; /* abort */
113 infoPtr->state = BUTTON_UNCHECKED;
114 infoPtr->hFont = 0;
115 return 0;
117 case WM_ERASEBKGND:
118 return 1;
120 case WM_PAINT:
121 if (btnPaintFunc[style])
123 PAINTSTRUCT ps;
124 HDC hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps );
125 SetBkMode( hdc, OPAQUE );
126 (btnPaintFunc[style])( wndPtr, hdc, ODA_DRAWENTIRE );
127 if( !wParam ) EndPaint( hWnd, &ps );
129 break;
131 case WM_LBUTTONDOWN:
132 case WM_LBUTTONDBLCLK:
133 SendMessageA( hWnd, BM_SETSTATE, TRUE, 0 );
134 SetFocus( hWnd );
135 SetCapture( hWnd );
136 break;
138 case WM_LBUTTONUP:
139 ReleaseCapture();
140 if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break;
141 SendMessageA( hWnd, BM_SETSTATE, FALSE, 0 );
142 GetClientRect( hWnd, &rect );
143 if (PtInRect( &rect, pt ))
145 switch(style)
147 case BS_AUTOCHECKBOX:
148 SendMessageA( hWnd, BM_SETCHECK,
149 !(infoPtr->state & BUTTON_CHECKED), 0 );
150 break;
151 case BS_AUTORADIOBUTTON:
152 SendMessageA( hWnd, BM_SETCHECK, TRUE, 0 );
153 break;
154 case BS_AUTO3STATE:
155 SendMessageA( hWnd, BM_SETCHECK,
156 (infoPtr->state & BUTTON_3STATE) ? 0 :
157 ((infoPtr->state & 3) + 1), 0 );
158 break;
160 SendMessageA( GetParent(hWnd), WM_COMMAND,
161 MAKEWPARAM( wndPtr->wIDmenu, BN_CLICKED ), hWnd);
163 break;
165 case WM_MOUSEMOVE:
166 if (GetCapture() == hWnd)
168 GetClientRect( hWnd, &rect );
169 SendMessageA( hWnd, BM_SETSTATE, PtInRect(&rect, pt), 0 );
171 break;
173 case WM_NCHITTEST:
174 if(style == BS_GROUPBOX) return HTTRANSPARENT;
175 return DefWindowProcA( hWnd, uMsg, wParam, lParam );
177 case WM_SETTEXT:
178 DEFWND_SetText( wndPtr, (LPCSTR)lParam );
179 if( wndPtr->dwStyle & WS_VISIBLE )
180 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
181 return 0;
183 case WM_SETFONT:
184 infoPtr->hFont = (HFONT16)wParam;
185 if (lParam && (wndPtr->dwStyle & WS_VISIBLE))
186 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
187 break;
189 case WM_GETFONT:
190 return infoPtr->hFont;
192 case WM_SETFOCUS:
193 infoPtr->state |= BUTTON_HASFOCUS;
194 if (style == BS_AUTORADIOBUTTON)
196 SendMessageA( hWnd, BM_SETCHECK, 1, 0 );
198 PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
199 break;
201 case WM_KILLFOCUS:
202 infoPtr->state &= ~BUTTON_HASFOCUS;
203 PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
204 InvalidateRect( hWnd, NULL, TRUE );
205 break;
207 case WM_SYSCOLORCHANGE:
208 InvalidateRect( hWnd, NULL, FALSE );
209 break;
211 case BM_SETSTYLE16:
212 case BM_SETSTYLE:
213 if ((wParam & 0x0f) >= MAX_BTN_TYPE) break;
214 wndPtr->dwStyle = (wndPtr->dwStyle & 0xfffffff0)
215 | (wParam & 0x0000000f);
216 style = wndPtr->dwStyle & 0x0000000f;
217 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
218 break;
220 case BM_GETCHECK16:
221 case BM_GETCHECK:
222 return infoPtr->state & 3;
224 case BM_SETCHECK16:
225 case BM_SETCHECK:
226 if (wParam > maxCheckState[style]) wParam = maxCheckState[style];
227 if ((infoPtr->state & 3) != wParam)
229 if ((style == BS_RADIOBUTTON) || (style == BS_AUTORADIOBUTTON))
231 if (wParam)
232 wndPtr->dwStyle |= WS_TABSTOP;
233 else
234 wndPtr->dwStyle &= ~WS_TABSTOP;
236 infoPtr->state = (infoPtr->state & ~3) | wParam;
237 PAINT_BUTTON( wndPtr, style, ODA_SELECT );
239 if ((style == BS_AUTORADIOBUTTON) && (wParam == BUTTON_CHECKED))
240 BUTTON_CheckAutoRadioButton( wndPtr );
241 break;
243 case BM_GETSTATE16:
244 case BM_GETSTATE:
245 return infoPtr->state;
247 case BM_SETSTATE16:
248 case BM_SETSTATE:
249 if (wParam)
251 if (infoPtr->state & BUTTON_HIGHLIGHTED) break;
252 infoPtr->state |= BUTTON_HIGHLIGHTED;
254 else
256 if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break;
257 infoPtr->state &= ~BUTTON_HIGHLIGHTED;
259 PAINT_BUTTON( wndPtr, style, ODA_SELECT );
260 break;
262 default:
263 return DefWindowProcA(hWnd, uMsg, wParam, lParam);
265 return 0;
269 /**********************************************************************
270 * Push Button Functions
273 static void PB_Paint( WND *wndPtr, HDC hDC, WORD action )
275 RECT rc;
276 HPEN hOldPen;
277 HBRUSH hOldBrush;
278 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
280 GetClientRect( wndPtr->hwndSelf, &rc );
282 /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
283 if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
284 BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
285 hOldPen = (HPEN)SelectObject(hDC, GetSysColorPen(COLOR_WINDOWFRAME));
286 hOldBrush =(HBRUSH)SelectObject(hDC,GetSysColorBrush(COLOR_BTNFACE));
287 SetBkMode(hDC, TRANSPARENT);
288 Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
289 if (action == ODA_DRAWENTIRE)
291 SetPixel( hDC, rc.left, rc.top, GetSysColor(COLOR_WINDOW) );
292 SetPixel( hDC, rc.left, rc.bottom-1, GetSysColor(COLOR_WINDOW) );
293 SetPixel( hDC, rc.right-1, rc.top, GetSysColor(COLOR_WINDOW) );
294 SetPixel( hDC, rc.right-1, rc.bottom-1, GetSysColor(COLOR_WINDOW));
296 InflateRect( &rc, -1, -1 );
298 if ((wndPtr->dwStyle & 0x000f) == BS_DEFPUSHBUTTON)
300 Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
301 InflateRect( &rc, -1, -1 );
304 if (infoPtr->state & BUTTON_HIGHLIGHTED)
306 /* draw button shadow: */
307 SelectObject(hDC, GetSysColorBrush(COLOR_BTNSHADOW));
308 PatBlt(hDC, rc.left, rc.top, 1, rc.bottom-rc.top, PATCOPY );
309 PatBlt(hDC, rc.left, rc.top, rc.right-rc.left, 1, PATCOPY );
310 rc.left += 2; /* To position the text down and right */
311 rc.top += 2;
312 } else {
313 rc.right++, rc.bottom++;
314 DrawEdge( hDC, &rc, EDGE_RAISED, BF_RECT );
315 rc.right--, rc.bottom--;
318 /* draw button label, if any: */
319 if (wndPtr->text && wndPtr->text[0])
321 LOGBRUSH lb;
322 GetObjectA( GetSysColorBrush(COLOR_BTNFACE), sizeof(lb), &lb );
323 if (wndPtr->dwStyle & WS_DISABLED &&
324 GetSysColor(COLOR_GRAYTEXT)==lb.lbColor)
325 /* don't write gray text on gray background */
326 PaintGrayOnGray( hDC,infoPtr->hFont,&rc,wndPtr->text,
327 DT_CENTER | DT_VCENTER );
328 else
330 SetTextColor( hDC, (wndPtr->dwStyle & WS_DISABLED) ?
331 GetSysColor(COLOR_GRAYTEXT) :
332 GetSysColor(COLOR_BTNTEXT) );
333 DrawTextA( hDC, wndPtr->text, -1, &rc,
334 DT_SINGLELINE | DT_CENTER | DT_VCENTER );
335 /* do we have the focus? */
336 if (infoPtr->state & BUTTON_HASFOCUS)
338 RECT r = { 0, 0, 0, 0 };
339 INT xdelta, ydelta;
341 DrawTextA( hDC, wndPtr->text, -1, &r,
342 DT_SINGLELINE | DT_CALCRECT );
343 xdelta = ((rc.right - rc.left) - (r.right - r.left) - 1) / 2;
344 ydelta = ((rc.bottom - rc.top) - (r.bottom - r.top) - 1) / 2;
345 if (xdelta < 0) xdelta = 0;
346 if (ydelta < 0) ydelta = 0;
347 InflateRect( &rc, -xdelta, -ydelta );
348 DrawFocusRect( hDC, &rc );
353 SelectObject( hDC, hOldPen );
354 SelectObject( hDC, hOldBrush );
358 /**********************************************************************
359 * PB_Paint & CB_Paint sub function [internal]
360 * Paint text using a raster brush to avoid gray text on gray
361 * background. 'format' can be a combination of DT_CENTER and
362 * DT_VCENTER to use this function in both PB_PAINT and
363 * CB_PAINT. - Dirk Thierbach
365 * FIXME: This and TEXT_GrayString should be eventually combined,
366 * so calling one common function from PB_Paint, CB_Paint and
367 * TEXT_GrayString will be enough. Also note that this
368 * function ignores the CACHE_GetPattern funcs.
371 void PaintGrayOnGray(HDC hDC,HFONT hFont,RECT *rc,char *text,
372 UINT format)
374 /* This is the standard gray on gray pattern:
375 static const WORD Pattern[] = {0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55};
377 /* This pattern gives better readability with X Fonts.
378 FIXME: Maybe the user should be allowed to decide which he wants. */
379 static const WORD Pattern[] = {0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF};
381 HBITMAP hbm = CreateBitmap( 8, 8, 1, 1, Pattern );
382 HDC hdcMem = CreateCompatibleDC(hDC);
383 HBITMAP hbmMem;
384 HBRUSH hBr;
385 RECT rect,rc2;
387 rect=*rc;
388 DrawTextA( hDC, text, -1, &rect, DT_SINGLELINE | DT_CALCRECT);
389 /* now text width and height are in rect.right and rect.bottom */
390 rc2=rect;
391 rect.left = rect.top = 0; /* drawing pos in hdcMem */
392 if (format & DT_CENTER) rect.left=(rc->right-rect.right)/2;
393 if (format & DT_VCENTER) rect.top=(rc->bottom-rect.bottom)/2;
394 hbmMem = CreateCompatibleBitmap( hDC,rect.right,rect.bottom );
395 SelectObject( hdcMem, hbmMem);
396 PatBlt( hdcMem,0,0,rect.right,rect.bottom,WHITENESS);
397 /* will be overwritten by DrawText, but just in case */
398 if (hFont) SelectObject( hdcMem, hFont);
399 DrawTextA( hdcMem, text, -1, &rc2, DT_SINGLELINE);
400 /* After draw: foreground = 0 bits, background = 1 bits */
401 hBr = SelectObject( hdcMem, CreatePatternBrush(hbm) );
402 DeleteObject( hbm );
403 PatBlt( hdcMem,0,0,rect.right,rect.bottom,0xAF0229);
404 /* only keep the foreground bits where pattern is 1 */
405 DeleteObject( SelectObject( hdcMem,hBr) );
406 BitBlt(hDC,rect.left,rect.top,rect.right,rect.bottom,hdcMem,0,0,SRCAND);
407 /* keep the background of the dest */
408 DeleteDC( hdcMem);
409 DeleteObject( hbmMem );
413 /**********************************************************************
414 * Check Box & Radio Button Functions
417 static void CB_Paint( WND *wndPtr, HDC hDC, WORD action )
419 RECT rbox, rtext, client;
420 HBRUSH hBrush;
421 int textlen, delta;
422 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
424 textlen = 0;
425 GetClientRect(wndPtr->hwndSelf, &client);
426 rbox = rtext = client;
428 if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
430 /* Something is still not right, checkboxes (and edit controls)
431 * in wsping32 have white backgrounds instead of dark grey.
432 * BUTTON_SEND_CTLCOLOR() is even worse since it returns 0 in this
433 * particular case and the background is not painted at all.
436 hBrush = GetControlBrush16( wndPtr->hwndSelf, hDC, CTLCOLOR_BTN );
438 if (wndPtr->dwStyle & BS_LEFTTEXT)
440 /* magic +4 is what CTL3D expects */
442 rtext.right -= checkBoxWidth + 4;
443 rbox.left = rbox.right - checkBoxWidth;
445 else
447 rtext.left += checkBoxWidth + 4;
448 rbox.right = checkBoxWidth;
451 /* Draw the check-box bitmap */
453 if (wndPtr->text) textlen = strlen( wndPtr->text );
454 if (action == ODA_DRAWENTIRE || action == ODA_SELECT)
456 HDC hMemDC = CreateCompatibleDC( hDC );
457 int x = 0, y = 0;
458 delta = (rbox.bottom - rbox.top - checkBoxHeight) >> 1;
460 if (action == ODA_SELECT) FillRect( hDC, &rbox, hBrush );
461 else FillRect( hDC, &client, hBrush );
463 if (infoPtr->state & BUTTON_HIGHLIGHTED) x += 2 * checkBoxWidth;
464 if (infoPtr->state & (BUTTON_CHECKED | BUTTON_3STATE)) x += checkBoxWidth;
465 if (((wndPtr->dwStyle & 0x0f) == BS_RADIOBUTTON) ||
466 ((wndPtr->dwStyle & 0x0f) == BS_AUTORADIOBUTTON)) y += checkBoxHeight;
467 else if (infoPtr->state & BUTTON_3STATE) y += 2 * checkBoxHeight;
469 SelectObject( hMemDC, hbitmapCheckBoxes );
470 BitBlt( hDC, rbox.left, rbox.top + delta, checkBoxWidth,
471 checkBoxHeight, hMemDC, x, y, SRCCOPY );
472 DeleteDC( hMemDC );
474 if( textlen && action != ODA_SELECT )
476 if (wndPtr->dwStyle & WS_DISABLED &&
477 GetSysColor(COLOR_GRAYTEXT)==GetBkColor(hDC)) {
478 /* don't write gray text on gray background */
479 PaintGrayOnGray( hDC, infoPtr->hFont, &rtext, wndPtr->text,
480 DT_VCENTER);
481 } else {
482 if (wndPtr->dwStyle & WS_DISABLED)
483 SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) );
484 DrawTextA( hDC, wndPtr->text, textlen, &rtext,
485 DT_SINGLELINE | DT_VCENTER );
486 textlen = 0; /* skip DrawText() below */
491 if ((action == ODA_FOCUS) ||
492 ((action == ODA_DRAWENTIRE) && (infoPtr->state & BUTTON_HASFOCUS)))
494 /* again, this is what CTL3D expects */
496 SetRectEmpty(&rbox);
497 if( textlen )
498 DrawTextA( hDC, wndPtr->text, textlen, &rbox,
499 DT_SINGLELINE | DT_CALCRECT );
500 textlen = rbox.bottom - rbox.top;
501 delta = ((rtext.bottom - rtext.top) - textlen)/2;
502 rbox.bottom = (rbox.top = rtext.top + delta - 1) + textlen + 2;
503 textlen = rbox.right - rbox.left;
504 rbox.right = (rbox.left += --rtext.left) + textlen + 2;
505 IntersectRect(&rbox, &rbox, &rtext);
506 DrawFocusRect( hDC, &rbox );
511 /**********************************************************************
512 * BUTTON_CheckAutoRadioButton
514 * wndPtr is checked, uncheck every other auto radio button in group
516 static void BUTTON_CheckAutoRadioButton( WND *wndPtr )
518 HWND parent, sibling, start;
519 if (!(wndPtr->dwStyle & WS_CHILD)) return;
520 parent = wndPtr->parent->hwndSelf;
521 /* assure that starting control is not disabled or invisible */
522 start = sibling = GetNextDlgGroupItem( parent, wndPtr->hwndSelf, TRUE );
525 if (!sibling) break;
526 if ((wndPtr->hwndSelf != sibling) &&
527 ((WIN_FindWndPtr(sibling)->dwStyle & 0x0f) == BS_AUTORADIOBUTTON))
528 SendMessageA( sibling, BM_SETCHECK, BUTTON_UNCHECKED, 0 );
529 sibling = GetNextDlgGroupItem( parent, sibling, FALSE );
530 } while (sibling != start);
534 /**********************************************************************
535 * Group Box Functions
538 static void GB_Paint( WND *wndPtr, HDC hDC, WORD action )
540 RECT rc, rcFrame;
541 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
543 if (action != ODA_DRAWENTIRE) return;
545 BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
547 GetClientRect( wndPtr->hwndSelf, &rc);
548 if (TWEAK_WineLook == WIN31_LOOK) {
549 HPEN hPrevPen = SelectObject( hDC,
550 GetSysColorPen(COLOR_WINDOWFRAME));
551 HBRUSH hPrevBrush = SelectObject( hDC,
552 GetStockObject(NULL_BRUSH) );
554 Rectangle( hDC, rc.left, rc.top + 2, rc.right - 1, rc.bottom - 1 );
555 SelectObject( hDC, hPrevBrush );
556 SelectObject( hDC, hPrevPen );
557 } else {
558 TEXTMETRICA tm;
559 rcFrame = rc;
561 if (infoPtr->hFont)
562 SelectObject (hDC, infoPtr->hFont);
563 GetTextMetricsA (hDC, &tm);
564 rcFrame.top += (tm.tmHeight / 2) - 1;
565 DrawEdge (hDC, &rcFrame, EDGE_ETCHED, BF_RECT);
568 if (wndPtr->text)
570 if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
571 if (wndPtr->dwStyle & WS_DISABLED)
572 SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) );
573 rc.left += 10;
574 DrawTextA( hDC, wndPtr->text, -1, &rc, DT_SINGLELINE | DT_NOCLIP );
579 /**********************************************************************
580 * User Button Functions
583 static void UB_Paint( WND *wndPtr, HDC hDC, WORD action )
585 RECT rc;
586 HBRUSH hBrush;
587 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
589 if (action == ODA_SELECT) return;
591 GetClientRect( wndPtr->hwndSelf, &rc);
593 if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
594 hBrush = GetControlBrush16( wndPtr->hwndSelf, hDC, CTLCOLOR_BTN );
596 FillRect( hDC, &rc, hBrush );
597 if ((action == ODA_FOCUS) ||
598 ((action == ODA_DRAWENTIRE) && (infoPtr->state & BUTTON_HASFOCUS)))
599 DrawFocusRect( hDC, &rc );
603 /**********************************************************************
604 * Ownerdrawn Button Functions
607 static void OB_Paint( WND *wndPtr, HDC hDC, WORD action )
609 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
610 DRAWITEMSTRUCT dis;
612 dis.CtlType = ODT_BUTTON;
613 dis.CtlID = wndPtr->wIDmenu;
614 dis.itemID = 0;
615 dis.itemAction = action;
616 dis.itemState = ((infoPtr->state & BUTTON_HASFOCUS) ? ODS_FOCUS : 0) |
617 ((infoPtr->state & BUTTON_HIGHLIGHTED) ? ODS_SELECTED : 0) |
618 ((wndPtr->dwStyle & WS_DISABLED) ? ODS_DISABLED : 0);
619 dis.hwndItem = wndPtr->hwndSelf;
620 dis.hDC = hDC;
621 dis.itemData = 0;
622 GetClientRect( wndPtr->hwndSelf, &dis.rcItem );
623 SendMessageA( GetParent(wndPtr->hwndSelf), WM_DRAWITEM,
624 wndPtr->wIDmenu, (LPARAM)&dis );