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
12 #include "wine/winuser16.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 /***********************************************************************
78 LRESULT WINAPI
ButtonWndProc( HWND hWnd
, UINT uMsg
,
79 WPARAM wParam
, LPARAM lParam
)
83 POINT pt
= { LOWORD(lParam
), HIWORD(lParam
) };
84 WND
*wndPtr
= WIN_FindWndPtr(hWnd
);
85 BUTTONINFO
*infoPtr
= (BUTTONINFO
*)wndPtr
->wExtra
;
86 LONG style
= wndPtr
->dwStyle
& 0x0f;
92 WIN_ReleaseWndPtr(wndPtr
);
95 case BS_PUSHBUTTON
: return DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
;
96 case BS_DEFPUSHBUTTON
: return DLGC_BUTTON
| DLGC_DEFPUSHBUTTON
;
98 case BS_AUTORADIOBUTTON
: return DLGC_BUTTON
| DLGC_RADIOBUTTON
;
99 default: return DLGC_BUTTON
;
103 PAINT_BUTTON( wndPtr
, style
, ODA_DRAWENTIRE
);
107 if (!hbitmapCheckBoxes
)
110 hbitmapCheckBoxes
= LoadBitmapA(0, MAKEINTRESOURCEA(OBM_CHECKBOXES
));
111 GetObjectA( hbitmapCheckBoxes
, sizeof(bmp
), &bmp
);
112 checkBoxWidth
= bmp
.bmWidth
/ 4;
113 checkBoxHeight
= bmp
.bmHeight
/ 3;
115 if (style
< 0L || style
>= MAX_BTN_TYPE
)
117 WIN_ReleaseWndPtr(wndPtr
);
118 return -1; /* abort */
120 infoPtr
->state
= BUTTON_UNCHECKED
;
122 infoPtr
->hImage
= NULL
;
123 WIN_ReleaseWndPtr(wndPtr
);
127 WIN_ReleaseWndPtr(wndPtr
);
131 if (btnPaintFunc
[style
])
134 HDC hdc
= wParam
? (HDC
)wParam
: BeginPaint( hWnd
, &ps
);
135 SetBkMode( hdc
, OPAQUE
);
136 (btnPaintFunc
[style
])( wndPtr
, hdc
, ODA_DRAWENTIRE
);
137 if( !wParam
) EndPaint( hWnd
, &ps
);
142 case WM_LBUTTONDBLCLK
:
143 SendMessageA( hWnd
, BM_SETSTATE
, TRUE
, 0 );
150 if (!(infoPtr
->state
& BUTTON_HIGHLIGHTED
)) break;
151 SendMessageA( hWnd
, BM_SETSTATE
, FALSE
, 0 );
152 GetClientRect( hWnd
, &rect
);
153 if (PtInRect( &rect
, pt
))
157 case BS_AUTOCHECKBOX
:
158 SendMessageA( hWnd
, BM_SETCHECK
,
159 !(infoPtr
->state
& BUTTON_CHECKED
), 0 );
161 case BS_AUTORADIOBUTTON
:
162 SendMessageA( hWnd
, BM_SETCHECK
, TRUE
, 0 );
165 SendMessageA( hWnd
, BM_SETCHECK
,
166 (infoPtr
->state
& BUTTON_3STATE
) ? 0 :
167 ((infoPtr
->state
& 3) + 1), 0 );
170 SendMessageA( GetParent(hWnd
), WM_COMMAND
,
171 MAKEWPARAM( wndPtr
->wIDmenu
, BN_CLICKED
), hWnd
);
176 if (GetCapture() == hWnd
)
178 GetClientRect( hWnd
, &rect
);
179 SendMessageA( hWnd
, BM_SETSTATE
, PtInRect(&rect
, pt
), 0 );
184 WIN_ReleaseWndPtr(wndPtr
);
185 if(style
== BS_GROUPBOX
) return HTTRANSPARENT
;
186 return DefWindowProcA( hWnd
, uMsg
, wParam
, lParam
);
189 DEFWND_SetText( wndPtr
, (LPCSTR
)lParam
);
190 if( wndPtr
->dwStyle
& WS_VISIBLE
)
191 PAINT_BUTTON( wndPtr
, style
, ODA_DRAWENTIRE
);
192 WIN_ReleaseWndPtr(wndPtr
);
196 infoPtr
->hFont
= (HFONT16
)wParam
;
197 if (lParam
&& (wndPtr
->dwStyle
& WS_VISIBLE
))
198 PAINT_BUTTON( wndPtr
, style
, ODA_DRAWENTIRE
);
202 retvalue
= infoPtr
->hFont
;
203 WIN_ReleaseWndPtr(wndPtr
);
207 infoPtr
->state
|= BUTTON_HASFOCUS
;
208 if (style
== BS_AUTORADIOBUTTON
)
210 SendMessageA( hWnd
, BM_SETCHECK
, 1, 0 );
212 PAINT_BUTTON( wndPtr
, style
, ODA_FOCUS
);
216 infoPtr
->state
&= ~BUTTON_HASFOCUS
;
217 PAINT_BUTTON( wndPtr
, style
, ODA_FOCUS
);
218 InvalidateRect( hWnd
, NULL
, TRUE
);
221 case WM_SYSCOLORCHANGE
:
222 InvalidateRect( hWnd
, NULL
, FALSE
);
227 if ((wParam
& 0x0f) >= MAX_BTN_TYPE
) break;
228 wndPtr
->dwStyle
= (wndPtr
->dwStyle
& 0xfffffff0)
229 | (wParam
& 0x0000000f);
230 style
= wndPtr
->dwStyle
& 0x0000000f;
231 PAINT_BUTTON( wndPtr
, style
, ODA_DRAWENTIRE
);
235 oldHbitmap
= infoPtr
->hImage
;
236 if(wndPtr
->dwStyle
& BS_BITMAP
)
237 infoPtr
->hImage
= (HANDLE
) lParam
;
238 WIN_ReleaseWndPtr(wndPtr
);
242 WIN_ReleaseWndPtr(wndPtr
);
243 return infoPtr
->hImage
;
247 retvalue
= infoPtr
->state
& 3;
248 WIN_ReleaseWndPtr(wndPtr
);
253 if (wParam
> maxCheckState
[style
]) wParam
= maxCheckState
[style
];
254 if ((infoPtr
->state
& 3) != wParam
)
256 if ((style
== BS_RADIOBUTTON
) || (style
== BS_AUTORADIOBUTTON
))
259 wndPtr
->dwStyle
|= WS_TABSTOP
;
261 wndPtr
->dwStyle
&= ~WS_TABSTOP
;
263 infoPtr
->state
= (infoPtr
->state
& ~3) | wParam
;
264 PAINT_BUTTON( wndPtr
, style
, ODA_SELECT
);
266 if ((style
== BS_AUTORADIOBUTTON
) && (wParam
== BUTTON_CHECKED
))
267 BUTTON_CheckAutoRadioButton( wndPtr
);
272 retvalue
= infoPtr
->state
;
273 WIN_ReleaseWndPtr(wndPtr
);
280 if (infoPtr
->state
& BUTTON_HIGHLIGHTED
) break;
281 infoPtr
->state
|= BUTTON_HIGHLIGHTED
;
285 if (!(infoPtr
->state
& BUTTON_HIGHLIGHTED
)) break;
286 infoPtr
->state
&= ~BUTTON_HIGHLIGHTED
;
288 PAINT_BUTTON( wndPtr
, style
, ODA_SELECT
);
292 WIN_ReleaseWndPtr(wndPtr
);
293 return DefWindowProcA(hWnd
, uMsg
, wParam
, lParam
);
295 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 (action == ODA_DRAWENTIRE)*/
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
);