Replace GRAPH_ functions with Win SDK equivalents.
[wine/multimedia.git] / controls / button.c
blob7ab8c3377593037b2aea10602e525593129a2aa4
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 "win.h"
9 #include "button.h"
10 #include "windows.h"
11 #include "tweak.h"
13 static void PB_Paint( WND *wndPtr, HDC32 hDC, WORD action );
14 static void PB_PaintGrayOnGray(HDC32 hDC,HFONT32 hFont,RECT32 *rc,char *text);
15 static void CB_Paint( WND *wndPtr, HDC32 hDC, WORD action );
16 static void GB_Paint( WND *wndPtr, HDC32 hDC, WORD action );
17 static void UB_Paint( WND *wndPtr, HDC32 hDC, WORD action );
18 static void OB_Paint( WND *wndPtr, HDC32 hDC, WORD action );
19 static void BUTTON_CheckAutoRadioButton( WND *wndPtr );
21 #define MAX_BTN_TYPE 12
23 static const WORD maxCheckState[MAX_BTN_TYPE] =
25 BUTTON_UNCHECKED, /* BS_PUSHBUTTON */
26 BUTTON_UNCHECKED, /* BS_DEFPUSHBUTTON */
27 BUTTON_CHECKED, /* BS_CHECKBOX */
28 BUTTON_CHECKED, /* BS_AUTOCHECKBOX */
29 BUTTON_CHECKED, /* BS_RADIOBUTTON */
30 BUTTON_3STATE, /* BS_3STATE */
31 BUTTON_3STATE, /* BS_AUTO3STATE */
32 BUTTON_UNCHECKED, /* BS_GROUPBOX */
33 BUTTON_UNCHECKED, /* BS_USERBUTTON */
34 BUTTON_CHECKED, /* BS_AUTORADIOBUTTON */
35 BUTTON_UNCHECKED, /* Not defined */
36 BUTTON_UNCHECKED /* BS_OWNERDRAW */
39 typedef void (*pfPaint)( WND *wndPtr, HDC32 hdc, WORD action );
41 static const pfPaint btnPaintFunc[MAX_BTN_TYPE] =
43 PB_Paint, /* BS_PUSHBUTTON */
44 PB_Paint, /* BS_DEFPUSHBUTTON */
45 CB_Paint, /* BS_CHECKBOX */
46 CB_Paint, /* BS_AUTOCHECKBOX */
47 CB_Paint, /* BS_RADIOBUTTON */
48 CB_Paint, /* BS_3STATE */
49 CB_Paint, /* BS_AUTO3STATE */
50 GB_Paint, /* BS_GROUPBOX */
51 UB_Paint, /* BS_USERBUTTON */
52 CB_Paint, /* BS_AUTORADIOBUTTON */
53 NULL, /* Not defined */
54 OB_Paint /* BS_OWNERDRAW */
57 #define PAINT_BUTTON(wndPtr,style,action) \
58 if (btnPaintFunc[style]) { \
59 HDC32 hdc = GetDC32( (wndPtr)->hwndSelf ); \
60 (btnPaintFunc[style])(wndPtr,hdc,action); \
61 ReleaseDC32( (wndPtr)->hwndSelf, hdc ); }
63 #define BUTTON_SEND_CTLCOLOR(wndPtr,hdc) \
64 SendMessage32A( GetParent32((wndPtr)->hwndSelf), WM_CTLCOLORBTN, \
65 (hdc), (wndPtr)->hwndSelf )
67 static HBITMAP32 hbitmapCheckBoxes = 0;
68 static WORD checkBoxWidth = 0, checkBoxHeight = 0;
71 /***********************************************************************
72 * ButtonWndProc
74 LRESULT WINAPI ButtonWndProc( HWND32 hWnd, UINT32 uMsg,
75 WPARAM32 wParam, LPARAM lParam )
77 RECT32 rect;
78 POINT32 pt = { LOWORD(lParam), HIWORD(lParam) };
79 WND *wndPtr = WIN_FindWndPtr(hWnd);
80 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
81 LONG style = wndPtr->dwStyle & 0x0f;
83 switch (uMsg)
85 case WM_GETDLGCODE:
86 switch(style)
88 case BS_PUSHBUTTON: return DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON;
89 case BS_DEFPUSHBUTTON: return DLGC_BUTTON | DLGC_DEFPUSHBUTTON;
90 case BS_RADIOBUTTON:
91 case BS_AUTORADIOBUTTON: return DLGC_BUTTON | DLGC_RADIOBUTTON;
92 default: return DLGC_BUTTON;
95 case WM_ENABLE:
96 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
97 break;
99 case WM_CREATE:
100 if (!hbitmapCheckBoxes)
102 BITMAP32 bmp;
103 hbitmapCheckBoxes = LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_CHECKBOXES));
104 GetObject32A( hbitmapCheckBoxes, sizeof(bmp), &bmp );
105 checkBoxWidth = bmp.bmWidth / 4;
106 checkBoxHeight = bmp.bmHeight / 3;
108 if (style < 0L || style >= MAX_BTN_TYPE) return -1; /* abort */
109 infoPtr->state = BUTTON_UNCHECKED;
110 infoPtr->hFont = 0;
111 return 0;
113 case WM_ERASEBKGND:
114 return 1;
116 case WM_PAINT:
117 if (btnPaintFunc[style])
119 PAINTSTRUCT32 ps;
120 HDC32 hdc = wParam ? (HDC32)wParam : BeginPaint32( hWnd, &ps );
121 SetBkMode32( hdc, OPAQUE );
122 (btnPaintFunc[style])( wndPtr, hdc, ODA_DRAWENTIRE );
123 if( !wParam ) EndPaint32( hWnd, &ps );
125 break;
127 case WM_LBUTTONDOWN:
128 case WM_LBUTTONDBLCLK:
129 SendMessage32A( hWnd, BM_SETSTATE32, TRUE, 0 );
130 SetFocus32( hWnd );
131 SetCapture32( hWnd );
132 break;
134 case WM_LBUTTONUP:
135 ReleaseCapture();
136 if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break;
137 SendMessage32A( hWnd, BM_SETSTATE32, FALSE, 0 );
138 GetClientRect32( hWnd, &rect );
139 if (PtInRect32( &rect, pt ))
141 switch(style)
143 case BS_AUTOCHECKBOX:
144 SendMessage32A( hWnd, BM_SETCHECK32,
145 !(infoPtr->state & BUTTON_CHECKED), 0 );
146 break;
147 case BS_AUTORADIOBUTTON:
148 SendMessage32A( hWnd, BM_SETCHECK32, TRUE, 0 );
149 break;
150 case BS_AUTO3STATE:
151 SendMessage32A( hWnd, BM_SETCHECK32,
152 (infoPtr->state & BUTTON_3STATE) ? 0 :
153 ((infoPtr->state & 3) + 1), 0 );
154 break;
156 SendMessage32A( GetParent32(hWnd), WM_COMMAND,
157 MAKEWPARAM( wndPtr->wIDmenu, BN_CLICKED ), hWnd);
159 break;
161 case WM_MOUSEMOVE:
162 if (GetCapture32() == hWnd)
164 GetClientRect32( hWnd, &rect );
165 SendMessage32A( hWnd, BM_SETSTATE32, PtInRect32(&rect, pt), 0 );
167 break;
169 case WM_NCHITTEST:
170 if(style == BS_GROUPBOX) return HTTRANSPARENT;
171 return DefWindowProc32A( hWnd, uMsg, wParam, lParam );
173 case WM_SETTEXT:
174 DEFWND_SetText( wndPtr, (LPCSTR)lParam );
175 if( wndPtr->dwStyle & WS_VISIBLE )
176 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
177 return 0;
179 case WM_SETFONT:
180 infoPtr->hFont = (HFONT16)wParam;
181 if (lParam && (wndPtr->dwStyle & WS_VISIBLE))
182 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
183 break;
185 case WM_GETFONT:
186 return infoPtr->hFont;
188 case WM_SETFOCUS:
189 infoPtr->state |= BUTTON_HASFOCUS;
190 if (style == BS_AUTORADIOBUTTON)
192 SendMessage32A( hWnd, BM_SETCHECK32, 1, 0 );
194 PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
195 break;
197 case WM_KILLFOCUS:
198 infoPtr->state &= ~BUTTON_HASFOCUS;
199 PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
200 InvalidateRect32( hWnd, NULL, TRUE );
201 break;
203 case WM_SYSCOLORCHANGE:
204 InvalidateRect32( hWnd, NULL, FALSE );
205 break;
207 case BM_SETSTYLE16:
208 case BM_SETSTYLE32:
209 if ((wParam & 0x0f) >= MAX_BTN_TYPE) break;
210 wndPtr->dwStyle = (wndPtr->dwStyle & 0xfffffff0)
211 | (wParam & 0x0000000f);
212 style = wndPtr->dwStyle & 0x0000000f;
213 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
214 break;
216 case BM_GETCHECK16:
217 case BM_GETCHECK32:
218 return infoPtr->state & 3;
220 case BM_SETCHECK16:
221 case BM_SETCHECK32:
222 if (wParam > maxCheckState[style]) wParam = maxCheckState[style];
223 if ((infoPtr->state & 3) != wParam)
225 if ((style == BS_RADIOBUTTON) || (style == BS_AUTORADIOBUTTON))
227 if (wParam)
228 wndPtr->dwStyle |= WS_TABSTOP;
229 else
230 wndPtr->dwStyle &= ~WS_TABSTOP;
232 infoPtr->state = (infoPtr->state & ~3) | wParam;
233 PAINT_BUTTON( wndPtr, style, ODA_SELECT );
235 if ((style == BS_AUTORADIOBUTTON) && (wParam == BUTTON_CHECKED))
236 BUTTON_CheckAutoRadioButton( wndPtr );
237 break;
239 case BM_GETSTATE16:
240 case BM_GETSTATE32:
241 return infoPtr->state;
243 case BM_SETSTATE16:
244 case BM_SETSTATE32:
245 if (wParam)
247 if (infoPtr->state & BUTTON_HIGHLIGHTED) break;
248 infoPtr->state |= BUTTON_HIGHLIGHTED;
250 else
252 if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break;
253 infoPtr->state &= ~BUTTON_HIGHLIGHTED;
255 PAINT_BUTTON( wndPtr, style, ODA_SELECT );
256 break;
258 default:
259 return DefWindowProc32A(hWnd, uMsg, wParam, lParam);
261 return 0;
265 /**********************************************************************
266 * Push Button Functions
269 static void PB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
271 RECT32 rc;
272 HPEN32 hOldPen;
273 HBRUSH32 hOldBrush;
274 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
276 GetClientRect32( wndPtr->hwndSelf, &rc );
278 /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
279 if (infoPtr->hFont) SelectObject32( hDC, infoPtr->hFont );
280 BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
281 hOldPen = (HPEN32)SelectObject32(hDC, GetSysColorPen32(COLOR_WINDOWFRAME));
282 hOldBrush =(HBRUSH32)SelectObject32(hDC,GetSysColorBrush32(COLOR_BTNFACE));
283 SetBkMode32(hDC, TRANSPARENT);
284 Rectangle32(hDC, rc.left, rc.top, rc.right, rc.bottom);
285 if (action == ODA_DRAWENTIRE)
287 SetPixel32( hDC, rc.left, rc.top, GetSysColor32(COLOR_WINDOW) );
288 SetPixel32( hDC, rc.left, rc.bottom-1, GetSysColor32(COLOR_WINDOW) );
289 SetPixel32( hDC, rc.right-1, rc.top, GetSysColor32(COLOR_WINDOW) );
290 SetPixel32( hDC, rc.right-1, rc.bottom-1, GetSysColor32(COLOR_WINDOW));
292 InflateRect32( &rc, -1, -1 );
294 if ((wndPtr->dwStyle & 0x000f) == BS_DEFPUSHBUTTON)
296 Rectangle32(hDC, rc.left, rc.top, rc.right, rc.bottom);
297 InflateRect32( &rc, -1, -1 );
300 if (infoPtr->state & BUTTON_HIGHLIGHTED)
302 /* draw button shadow: */
303 SelectObject32(hDC, GetSysColorBrush32(COLOR_BTNSHADOW));
304 PatBlt32(hDC, rc.left, rc.top, 1, rc.bottom-rc.top, PATCOPY );
305 PatBlt32(hDC, rc.left, rc.top, rc.right-rc.left, 1, PATCOPY );
306 rc.left += 2; /* To position the text down and right */
307 rc.top += 2;
308 } else {
309 rc.right++, rc.bottom++;
310 DrawEdge32( hDC, &rc, EDGE_RAISED, BF_RECT );
311 rc.right--, rc.bottom--;
314 /* draw button label, if any: */
315 if (wndPtr->text && wndPtr->text[0])
317 LOGBRUSH32 lb;
318 GetObject32A( GetSysColorBrush32(COLOR_BTNFACE), sizeof(lb), &lb );
319 if (wndPtr->dwStyle & WS_DISABLED &&
320 GetSysColor32(COLOR_GRAYTEXT)==lb.lbColor)
321 /* don't write gray text on gray bkg */
322 PB_PaintGrayOnGray(hDC,infoPtr->hFont,&rc,wndPtr->text);
323 else
325 SetTextColor32( hDC, (wndPtr->dwStyle & WS_DISABLED) ?
326 GetSysColor32(COLOR_GRAYTEXT) :
327 GetSysColor32(COLOR_BTNTEXT) );
328 DrawText32A( hDC, wndPtr->text, -1, &rc,
329 DT_SINGLELINE | DT_CENTER | DT_VCENTER );
330 /* do we have the focus? */
331 if (infoPtr->state & BUTTON_HASFOCUS)
333 RECT32 r = { 0, 0, 0, 0 };
334 INT32 xdelta, ydelta;
336 DrawText32A( hDC, wndPtr->text, -1, &r,
337 DT_SINGLELINE | DT_CALCRECT );
338 xdelta = ((rc.right - rc.left) - (r.right - r.left) - 1) / 2;
339 ydelta = ((rc.bottom - rc.top) - (r.bottom - r.top) - 1) / 2;
340 if (xdelta < 0) xdelta = 0;
341 if (ydelta < 0) ydelta = 0;
342 InflateRect32( &rc, -xdelta, -ydelta );
343 DrawFocusRect32( hDC, &rc );
348 SelectObject32( hDC, hOldPen );
349 SelectObject32( hDC, hOldBrush );
353 /**********************************************************************
354 * Push Button sub function [internal]
355 * using a raster brush to avoid gray text on gray background
358 void PB_PaintGrayOnGray(HDC32 hDC,HFONT32 hFont,RECT32 *rc,char *text)
360 static const int Pattern[] = {0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55};
361 HBITMAP32 hbm = CreateBitmap32( 8, 8, 1, 1, Pattern );
362 HDC32 hdcMem = CreateCompatibleDC32(hDC);
363 HBITMAP32 hbmMem;
364 HBRUSH32 hBr;
365 RECT32 rect,rc2;
367 rect=*rc;
368 DrawText32A( hDC, text, -1, &rect, DT_SINGLELINE | DT_CALCRECT);
369 rc2=rect;
370 rect.left=(rc->right-rect.right)/2; /* for centering text bitmap */
371 rect.top=(rc->bottom-rect.bottom)/2;
372 hbmMem = CreateCompatibleBitmap32( hDC,rect.right,rect.bottom );
373 SelectObject32( hdcMem, hbmMem);
374 hBr = SelectObject32( hdcMem, CreatePatternBrush32(hbm) );
375 DeleteObject32( hbm );
376 PatBlt32( hdcMem,0,0,rect.right,rect.bottom,WHITENESS);
377 if (hFont) SelectObject32( hdcMem, hFont);
378 DrawText32A( hdcMem, text, -1, &rc2, DT_SINGLELINE);
379 PatBlt32( hdcMem,0,0,rect.right,rect.bottom,0xFA0089);
380 DeleteObject32( SelectObject32( hdcMem,hBr) );
381 BitBlt32(hDC,rect.left,rect.top,rect.right,rect.bottom,hdcMem,0,0,0x990000);
382 DeleteDC32( hdcMem);
383 DeleteObject32( hbmMem );
387 /**********************************************************************
388 * Check Box & Radio Button Functions
391 static void CB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
393 RECT32 rbox, rtext, client;
394 HBRUSH32 hBrush;
395 int textlen, delta;
396 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
398 textlen = 0;
399 GetClientRect32(wndPtr->hwndSelf, &client);
400 rbox = rtext = client;
402 if (infoPtr->hFont) SelectObject32( hDC, infoPtr->hFont );
404 /* Something is still not right, checkboxes (and edit controls)
405 * in wsping32 have white backgrounds instead of dark grey.
406 * BUTTON_SEND_CTLCOLOR() is even worse since it returns 0 in this
407 * particular case and the background is not painted at all.
410 hBrush = GetControlBrush( wndPtr->hwndSelf, hDC, CTLCOLOR_BTN );
412 if (wndPtr->dwStyle & BS_LEFTTEXT)
414 /* magic +4 is what CTL3D expects */
416 rtext.right -= checkBoxWidth + 4;
417 rbox.left = rbox.right - checkBoxWidth;
419 else
421 rtext.left += checkBoxWidth + 4;
422 rbox.right = checkBoxWidth;
425 /* Draw the check-box bitmap */
427 if (wndPtr->text) textlen = strlen( wndPtr->text );
428 if (action == ODA_DRAWENTIRE || action == ODA_SELECT)
430 HDC32 hMemDC = CreateCompatibleDC32( hDC );
431 int x = 0, y = 0;
432 delta = (rbox.bottom - rbox.top - checkBoxHeight) >> 1;
434 if (action == ODA_SELECT) FillRect32( hDC, &rbox, hBrush );
435 else FillRect32( hDC, &client, hBrush );
437 if (infoPtr->state & BUTTON_HIGHLIGHTED) x += 2 * checkBoxWidth;
438 if (infoPtr->state & (BUTTON_CHECKED | BUTTON_3STATE)) x += checkBoxWidth;
439 if (((wndPtr->dwStyle & 0x0f) == BS_RADIOBUTTON) ||
440 ((wndPtr->dwStyle & 0x0f) == BS_AUTORADIOBUTTON)) y += checkBoxHeight;
441 else if (infoPtr->state & BUTTON_3STATE) y += 2 * checkBoxHeight;
443 SelectObject32( hMemDC, hbitmapCheckBoxes );
444 BitBlt32( hDC, rbox.left, rbox.top + delta, checkBoxWidth,
445 checkBoxHeight, hMemDC, x, y, SRCCOPY );
446 DeleteDC32( hMemDC );
448 if( textlen && action != ODA_SELECT )
450 if (wndPtr->dwStyle & WS_DISABLED)
451 SetTextColor32( hDC, GetSysColor32(COLOR_GRAYTEXT) );
452 DrawText32A( hDC, wndPtr->text, textlen, &rtext,
453 DT_SINGLELINE | DT_VCENTER );
454 textlen = 0; /* skip DrawText() below */
458 if ((action == ODA_FOCUS) ||
459 ((action == ODA_DRAWENTIRE) && (infoPtr->state & BUTTON_HASFOCUS)))
461 /* again, this is what CTL3D expects */
463 SetRectEmpty32(&rbox);
464 if( textlen )
465 DrawText32A( hDC, wndPtr->text, textlen, &rbox,
466 DT_SINGLELINE | DT_CALCRECT );
467 textlen = rbox.bottom - rbox.top;
468 delta = ((rtext.bottom - rtext.top) - textlen)/2;
469 rbox.bottom = (rbox.top = rtext.top + delta - 1) + textlen + 2;
470 textlen = rbox.right - rbox.left;
471 rbox.right = (rbox.left += --rtext.left) + textlen + 2;
472 IntersectRect32(&rbox, &rbox, &rtext);
473 DrawFocusRect32( hDC, &rbox );
478 /**********************************************************************
479 * BUTTON_CheckAutoRadioButton
481 * wndPtr is checked, uncheck every other auto radio button in group
483 static void BUTTON_CheckAutoRadioButton( WND *wndPtr )
485 HWND32 parent, sibling, start;
486 if (!(wndPtr->dwStyle & WS_CHILD)) return;
487 parent = wndPtr->parent->hwndSelf;
488 /* assure that starting control is not disabled or invisible */
489 start = sibling = GetNextDlgGroupItem32( parent, wndPtr->hwndSelf, TRUE );
492 if (!sibling) break;
493 if ((wndPtr->hwndSelf != sibling) &&
494 ((WIN_FindWndPtr(sibling)->dwStyle & 0x0f) == BS_AUTORADIOBUTTON))
495 SendMessage32A( sibling, BM_SETCHECK32, BUTTON_UNCHECKED, 0 );
496 sibling = GetNextDlgGroupItem32( parent, sibling, FALSE );
497 } while (sibling != start);
501 /**********************************************************************
502 * Group Box Functions
505 static void GB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
507 RECT32 rc, rcFrame;
508 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
510 if (action != ODA_DRAWENTIRE) return;
512 BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
514 GetClientRect32( wndPtr->hwndSelf, &rc);
515 if (TWEAK_WineLook == WIN31_LOOK) {
516 HPEN32 hPrevPen = SelectObject32( hDC,
517 GetSysColorPen32(COLOR_WINDOWFRAME));
518 HBRUSH32 hPrevBrush = SelectObject32( hDC,
519 GetStockObject32(NULL_BRUSH) );
521 Rectangle32( hDC, rc.left, rc.top + 2, rc.right - 1, rc.bottom - 1 );
522 SelectObject32( hDC, hPrevBrush );
523 SelectObject32( hDC, hPrevPen );
524 } else {
525 TEXTMETRIC32A tm;
526 rcFrame = rc;
528 if (infoPtr->hFont)
529 SelectObject32 (hDC, infoPtr->hFont);
530 GetTextMetrics32A (hDC, &tm);
531 rcFrame.top += (tm.tmHeight / 2) - 1;
532 DrawEdge32 (hDC, &rcFrame, EDGE_ETCHED, BF_RECT);
535 if (wndPtr->text)
537 if (infoPtr->hFont) SelectObject32( hDC, infoPtr->hFont );
538 if (wndPtr->dwStyle & WS_DISABLED)
539 SetTextColor32( hDC, GetSysColor32(COLOR_GRAYTEXT) );
540 rc.left += 10;
541 DrawText32A( hDC, wndPtr->text, -1, &rc, DT_SINGLELINE | DT_NOCLIP );
546 /**********************************************************************
547 * User Button Functions
550 static void UB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
552 RECT32 rc;
553 HBRUSH32 hBrush;
554 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
556 if (action == ODA_SELECT) return;
558 GetClientRect32( wndPtr->hwndSelf, &rc);
560 if (infoPtr->hFont) SelectObject32( hDC, infoPtr->hFont );
561 hBrush = GetControlBrush( wndPtr->hwndSelf, hDC, CTLCOLOR_BTN );
563 FillRect32( hDC, &rc, hBrush );
564 if ((action == ODA_FOCUS) ||
565 ((action == ODA_DRAWENTIRE) && (infoPtr->state & BUTTON_HASFOCUS)))
566 DrawFocusRect32( hDC, &rc );
570 /**********************************************************************
571 * Ownerdrawn Button Functions
574 static void OB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
576 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
577 DRAWITEMSTRUCT32 dis;
579 dis.CtlType = ODT_BUTTON;
580 dis.CtlID = wndPtr->wIDmenu;
581 dis.itemID = 0;
582 dis.itemAction = action;
583 dis.itemState = ((infoPtr->state & BUTTON_HASFOCUS) ? ODS_FOCUS : 0) |
584 ((infoPtr->state & BUTTON_HIGHLIGHTED) ? ODS_SELECTED : 0) |
585 ((wndPtr->dwStyle & WS_DISABLED) ? ODS_DISABLED : 0);
586 dis.hwndItem = wndPtr->hwndSelf;
587 dis.hDC = hDC;
588 dis.itemData = 0;
589 GetClientRect32( wndPtr->hwndSelf, &dis.rcItem );
590 SendMessage32A( GetParent32(wndPtr->hwndSelf), WM_DRAWITEM,
591 wndPtr->wIDmenu, (LPARAM)&dis );