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 /***********************************************************************
76 * ButtonWndProc_locked
78 * Called with window lock held.
80 static inline LRESULT WINAPI
ButtonWndProc_locked(WND
* wndPtr
, UINT uMsg
,
81 WPARAM wParam
, LPARAM lParam
)
84 HWND hWnd
= wndPtr
->hwndSelf
;
86 BUTTONINFO
*infoPtr
= (BUTTONINFO
*)wndPtr
->wExtra
;
87 LONG style
= wndPtr
->dwStyle
& 0x0f;
90 pt
.x
= LOWORD(lParam
);
91 pt
.y
= HIWORD(lParam
);
98 case BS_PUSHBUTTON
: return DLGC_BUTTON
| DLGC_UNDEFPUSHBUTTON
;
99 case BS_DEFPUSHBUTTON
: return DLGC_BUTTON
| DLGC_DEFPUSHBUTTON
;
101 case BS_AUTORADIOBUTTON
: return DLGC_BUTTON
| DLGC_RADIOBUTTON
;
102 default: return DLGC_BUTTON
;
106 PAINT_BUTTON( wndPtr
, style
, ODA_DRAWENTIRE
);
110 if (!hbitmapCheckBoxes
)
113 hbitmapCheckBoxes
= LoadBitmapA(0, MAKEINTRESOURCEA(OBM_CHECKBOXES
));
114 GetObjectA( hbitmapCheckBoxes
, sizeof(bmp
), &bmp
);
115 checkBoxWidth
= bmp
.bmWidth
/ 4;
116 checkBoxHeight
= bmp
.bmHeight
/ 3;
118 if (style
< 0L || style
>= MAX_BTN_TYPE
)
120 WIN_ReleaseWndPtr(wndPtr
);
121 return -1; /* abort */
123 infoPtr
->state
= BUTTON_UNCHECKED
;
125 infoPtr
->hImage
= NULL
;
132 if (btnPaintFunc
[style
])
135 HDC hdc
= wParam
? (HDC
)wParam
: BeginPaint( hWnd
, &ps
);
136 SetBkMode( hdc
, OPAQUE
);
137 (btnPaintFunc
[style
])( wndPtr
, hdc
, ODA_DRAWENTIRE
);
138 if( !wParam
) EndPaint( hWnd
, &ps
);
143 case WM_LBUTTONDBLCLK
:
144 SendMessageA( hWnd
, BM_SETSTATE
, TRUE
, 0 );
151 if (!(infoPtr
->state
& BUTTON_HIGHLIGHTED
)) break;
152 SendMessageA( hWnd
, BM_SETSTATE
, FALSE
, 0 );
153 GetClientRect( hWnd
, &rect
);
154 if (PtInRect( &rect
, pt
))
158 case BS_AUTOCHECKBOX
:
159 SendMessageA( hWnd
, BM_SETCHECK
,
160 !(infoPtr
->state
& BUTTON_CHECKED
), 0 );
162 case BS_AUTORADIOBUTTON
:
163 SendMessageA( hWnd
, BM_SETCHECK
, TRUE
, 0 );
166 SendMessageA( hWnd
, BM_SETCHECK
,
167 (infoPtr
->state
& BUTTON_3STATE
) ? 0 :
168 ((infoPtr
->state
& 3) + 1), 0 );
171 SendMessageA( GetParent(hWnd
), WM_COMMAND
,
172 MAKEWPARAM( wndPtr
->wIDmenu
, BN_CLICKED
), hWnd
);
177 if (GetCapture() == hWnd
)
179 GetClientRect( hWnd
, &rect
);
180 SendMessageA( hWnd
, BM_SETSTATE
, PtInRect(&rect
, pt
), 0 );
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
);
195 infoPtr
->hFont
= (HFONT16
)wParam
;
196 if (lParam
&& (wndPtr
->dwStyle
& WS_VISIBLE
))
197 PAINT_BUTTON( wndPtr
, style
, ODA_DRAWENTIRE
);
201 return infoPtr
->hFont
;
204 infoPtr
->state
|= BUTTON_HASFOCUS
;
205 if (style
== BS_AUTORADIOBUTTON
)
206 SendMessageA( hWnd
, BM_SETCHECK
, 1, 0 );
207 PAINT_BUTTON( wndPtr
, style
, ODA_FOCUS
);
211 infoPtr
->state
&= ~BUTTON_HASFOCUS
;
212 PAINT_BUTTON( wndPtr
, style
, ODA_FOCUS
);
213 InvalidateRect( hWnd
, NULL
, TRUE
);
216 case WM_SYSCOLORCHANGE
:
217 InvalidateRect( hWnd
, NULL
, FALSE
);
222 if ((wParam
& 0x0f) >= MAX_BTN_TYPE
) break;
223 wndPtr
->dwStyle
= (wndPtr
->dwStyle
& 0xfffffff0)
224 | (wParam
& 0x0000000f);
225 style
= wndPtr
->dwStyle
& 0x0000000f;
226 PAINT_BUTTON( wndPtr
, style
, ODA_DRAWENTIRE
);
230 oldHbitmap
= infoPtr
->hImage
;
231 if(wndPtr
->dwStyle
& BS_BITMAP
)
232 infoPtr
->hImage
= (HANDLE
) lParam
;
236 return infoPtr
->hImage
;
240 return infoPtr
->state
& 3;
244 if (wParam
> maxCheckState
[style
]) wParam
= maxCheckState
[style
];
245 if ((infoPtr
->state
& 3) != wParam
)
247 if ((style
== BS_RADIOBUTTON
) || (style
== BS_AUTORADIOBUTTON
))
250 wndPtr
->dwStyle
|= WS_TABSTOP
;
252 wndPtr
->dwStyle
&= ~WS_TABSTOP
;
254 infoPtr
->state
= (infoPtr
->state
& ~3) | wParam
;
255 PAINT_BUTTON( wndPtr
, style
, ODA_SELECT
);
257 if ((style
== BS_AUTORADIOBUTTON
) && (wParam
== BUTTON_CHECKED
))
258 BUTTON_CheckAutoRadioButton( wndPtr
);
263 return infoPtr
->state
;
269 if (infoPtr
->state
& BUTTON_HIGHLIGHTED
) break;
270 infoPtr
->state
|= BUTTON_HIGHLIGHTED
;
274 if (!(infoPtr
->state
& BUTTON_HIGHLIGHTED
)) break;
275 infoPtr
->state
&= ~BUTTON_HIGHLIGHTED
;
277 PAINT_BUTTON( wndPtr
, style
, ODA_SELECT
);
281 return DefWindowProcA(hWnd
, uMsg
, wParam
, lParam
);
286 /***********************************************************************
288 * The button window procedure. This is just a wrapper which locks
289 * the passed HWND and calls the real window procedure (with a WND*
290 * pointer pointing to the locked windowstructure).
292 LRESULT WINAPI
ButtonWndProc( HWND hWnd
, UINT uMsg
,
293 WPARAM wParam
, LPARAM lParam
)
296 WND
*wndPtr
= WIN_FindWndPtr(hWnd
);
298 res
= ButtonWndProc_locked(wndPtr
,uMsg
,wParam
,lParam
);
300 WIN_ReleaseWndPtr(wndPtr
);
304 /**********************************************************************
305 * Push Button Functions
308 static void PB_Paint( WND
*wndPtr
, HDC hDC
, WORD action
)
313 BUTTONINFO
*infoPtr
= (BUTTONINFO
*)wndPtr
->wExtra
;
314 int xBorderOffset
, yBorderOffset
;
315 xBorderOffset
= yBorderOffset
= 0;
317 GetClientRect( wndPtr
->hwndSelf
, &rc
);
319 /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
320 if (infoPtr
->hFont
) SelectObject( hDC
, infoPtr
->hFont
);
321 BUTTON_SEND_CTLCOLOR( wndPtr
, hDC
);
322 hOldPen
= (HPEN
)SelectObject(hDC
, GetSysColorPen(COLOR_WINDOWFRAME
));
323 hOldBrush
=(HBRUSH
)SelectObject(hDC
,GetSysColorBrush(COLOR_BTNFACE
));
324 SetBkMode(hDC
, TRANSPARENT
);
325 Rectangle(hDC
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
326 /* if (action == ODA_DRAWENTIRE)*/
328 SetPixel( hDC
, rc
.left
, rc
.top
, GetSysColor(COLOR_WINDOW
) );
329 SetPixel( hDC
, rc
.left
, rc
.bottom
-1, GetSysColor(COLOR_WINDOW
) );
330 SetPixel( hDC
, rc
.right
-1, rc
.top
, GetSysColor(COLOR_WINDOW
) );
331 SetPixel( hDC
, rc
.right
-1, rc
.bottom
-1, GetSysColor(COLOR_WINDOW
));
333 InflateRect( &rc
, -1, -1 );
335 if ((wndPtr
->dwStyle
& 0x000f) == BS_DEFPUSHBUTTON
)
337 Rectangle(hDC
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
338 InflateRect( &rc
, -1, -1 );
341 if (infoPtr
->state
& BUTTON_HIGHLIGHTED
)
343 /* draw button shadow: */
344 SelectObject(hDC
, GetSysColorBrush(COLOR_BTNSHADOW
));
345 PatBlt(hDC
, rc
.left
, rc
.top
, 1, rc
.bottom
-rc
.top
, PATCOPY
);
346 PatBlt(hDC
, rc
.left
, rc
.top
, rc
.right
-rc
.left
, 1, PATCOPY
);
347 rc
.left
+= 2; /* To position the text down and right */
350 rc
.right
++, rc
.bottom
++;
351 DrawEdge( hDC
, &rc
, EDGE_RAISED
, BF_RECT
);
353 /* To place de bitmap correctly */
354 xBorderOffset
+= GetSystemMetrics(SM_CXEDGE
);
355 yBorderOffset
+= GetSystemMetrics(SM_CYEDGE
);
357 rc
.right
--, rc
.bottom
--;
360 /* draw button label, if any: */
361 if (wndPtr
->text
&& wndPtr
->text
[0])
364 GetObjectA( GetSysColorBrush(COLOR_BTNFACE
), sizeof(lb
), &lb
);
365 if (wndPtr
->dwStyle
& WS_DISABLED
&&
366 GetSysColor(COLOR_GRAYTEXT
)==lb
.lbColor
)
367 /* don't write gray text on gray background */
368 PaintGrayOnGray( hDC
,infoPtr
->hFont
,&rc
,wndPtr
->text
,
369 DT_CENTER
| DT_VCENTER
);
372 SetTextColor( hDC
, (wndPtr
->dwStyle
& WS_DISABLED
) ?
373 GetSysColor(COLOR_GRAYTEXT
) :
374 GetSysColor(COLOR_BTNTEXT
) );
375 DrawTextA( hDC
, wndPtr
->text
, -1, &rc
,
376 DT_SINGLELINE
| DT_CENTER
| DT_VCENTER
);
377 /* do we have the focus? */
378 if (infoPtr
->state
& BUTTON_HASFOCUS
)
380 RECT r
= { 0, 0, 0, 0 };
383 DrawTextA( hDC
, wndPtr
->text
, -1, &r
,
384 DT_SINGLELINE
| DT_CALCRECT
);
385 xdelta
= ((rc
.right
- rc
.left
) - (r
.right
- r
.left
) - 1) / 2;
386 ydelta
= ((rc
.bottom
- rc
.top
) - (r
.bottom
- r
.top
) - 1) / 2;
387 if (xdelta
< 0) xdelta
= 0;
388 if (ydelta
< 0) ydelta
= 0;
389 InflateRect( &rc
, -xdelta
, -ydelta
);
390 DrawFocusRect( hDC
, &rc
);
395 if((wndPtr
->dwStyle
& BS_BITMAP
) && (infoPtr
->hImage
!= NULL
))
399 int yOffset
, xOffset
, imageWidth
, imageHeight
;
401 GetObjectA (infoPtr
->hImage
, sizeof(BITMAP
), &bm
);
403 /* Center the bitmap */
404 xOffset
= (((rc
.right
- rc
.left
) - 2*xBorderOffset
) - bm
.bmWidth
) / 2;
405 yOffset
= (((rc
.bottom
- rc
.top
) - 2*yBorderOffset
) - bm
.bmHeight
) / 2;
407 imageWidth
= bm
.bmWidth
;
408 imageHeight
= bm
.bmHeight
;
410 /* If the image is to big for the button */
413 imageWidth
= rc
.right
- rc
.left
- 2*xBorderOffset
-1;
414 xOffset
= xBorderOffset
;
419 imageHeight
= rc
.bottom
- rc
.top
- 2*yBorderOffset
-1;
420 yOffset
= yBorderOffset
;
423 /* Let minimum 1 space from border */
424 xOffset
++, yOffset
++;
426 hdcMem
= CreateCompatibleDC (hDC
);
427 SelectObject (hdcMem
, (HBITMAP
)infoPtr
->hImage
);
428 BitBlt(hDC
, rc
.left
+ xOffset
,
430 imageWidth
, imageHeight
,
431 hdcMem
, 0, 0, SRCCOPY
);
436 SelectObject( hDC
, hOldPen
);
437 SelectObject( hDC
, hOldBrush
);
441 /**********************************************************************
442 * PB_Paint & CB_Paint sub function [internal]
443 * Paint text using a raster brush to avoid gray text on gray
444 * background. 'format' can be a combination of DT_CENTER and
445 * DT_VCENTER to use this function in both PB_PAINT and
446 * CB_PAINT. - Dirk Thierbach
448 * FIXME: This and TEXT_GrayString should be eventually combined,
449 * so calling one common function from PB_Paint, CB_Paint and
450 * TEXT_GrayString will be enough. Also note that this
451 * function ignores the CACHE_GetPattern funcs.
454 void PaintGrayOnGray(HDC hDC
,HFONT hFont
,RECT
*rc
,char *text
,
457 /* This is the standard gray on gray pattern:
458 static const WORD Pattern[] = {0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55};
460 /* This pattern gives better readability with X Fonts.
461 FIXME: Maybe the user should be allowed to decide which he wants. */
462 static const WORD Pattern
[] = {0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF};
464 HBITMAP hbm
= CreateBitmap( 8, 8, 1, 1, Pattern
);
465 HDC hdcMem
= CreateCompatibleDC(hDC
);
471 DrawTextA( hDC
, text
, -1, &rect
, DT_SINGLELINE
| DT_CALCRECT
);
472 /* now text width and height are in rect.right and rect.bottom */
474 rect
.left
= rect
.top
= 0; /* drawing pos in hdcMem */
475 if (format
& DT_CENTER
) rect
.left
=(rc
->right
-rect
.right
)/2;
476 if (format
& DT_VCENTER
) rect
.top
=(rc
->bottom
-rect
.bottom
)/2;
477 hbmMem
= CreateCompatibleBitmap( hDC
,rect
.right
,rect
.bottom
);
478 SelectObject( hdcMem
, hbmMem
);
479 PatBlt( hdcMem
,0,0,rect
.right
,rect
.bottom
,WHITENESS
);
480 /* will be overwritten by DrawText, but just in case */
481 if (hFont
) SelectObject( hdcMem
, hFont
);
482 DrawTextA( hdcMem
, text
, -1, &rc2
, DT_SINGLELINE
);
483 /* After draw: foreground = 0 bits, background = 1 bits */
484 hBr
= SelectObject( hdcMem
, CreatePatternBrush(hbm
) );
486 PatBlt( hdcMem
,0,0,rect
.right
,rect
.bottom
,0xAF0229);
487 /* only keep the foreground bits where pattern is 1 */
488 DeleteObject( SelectObject( hdcMem
,hBr
) );
489 BitBlt(hDC
,rect
.left
,rect
.top
,rect
.right
,rect
.bottom
,hdcMem
,0,0,SRCAND
);
490 /* keep the background of the dest */
492 DeleteObject( hbmMem
);
496 /**********************************************************************
497 * Check Box & Radio Button Functions
500 static void CB_Paint( WND
*wndPtr
, HDC hDC
, WORD action
)
502 RECT rbox
, rtext
, client
;
505 BUTTONINFO
*infoPtr
= (BUTTONINFO
*)wndPtr
->wExtra
;
508 GetClientRect(wndPtr
->hwndSelf
, &client
);
509 rbox
= rtext
= client
;
511 if (infoPtr
->hFont
) SelectObject( hDC
, infoPtr
->hFont
);
513 /* Something is still not right, checkboxes (and edit controls)
514 * in wsping32 have white backgrounds instead of dark grey.
515 * BUTTON_SEND_CTLCOLOR() is even worse since it returns 0 in this
516 * particular case and the background is not painted at all.
519 hBrush
= GetControlBrush16( wndPtr
->hwndSelf
, hDC
, CTLCOLOR_BTN
);
521 if (wndPtr
->dwStyle
& BS_LEFTTEXT
)
523 /* magic +4 is what CTL3D expects */
525 rtext
.right
-= checkBoxWidth
+ 4;
526 rbox
.left
= rbox
.right
- checkBoxWidth
;
530 rtext
.left
+= checkBoxWidth
+ 4;
531 rbox
.right
= checkBoxWidth
;
534 /* Draw the check-box bitmap */
536 if (wndPtr
->text
) textlen
= strlen( wndPtr
->text
);
537 if (action
== ODA_DRAWENTIRE
|| action
== ODA_SELECT
)
539 HDC hMemDC
= CreateCompatibleDC( hDC
);
541 delta
= (rbox
.bottom
- rbox
.top
- checkBoxHeight
) >> 1;
543 if (action
== ODA_SELECT
) FillRect( hDC
, &rbox
, hBrush
);
544 else FillRect( hDC
, &client
, hBrush
);
546 if (infoPtr
->state
& BUTTON_HIGHLIGHTED
) x
+= 2 * checkBoxWidth
;
547 if (infoPtr
->state
& (BUTTON_CHECKED
| BUTTON_3STATE
)) x
+= checkBoxWidth
;
548 if (((wndPtr
->dwStyle
& 0x0f) == BS_RADIOBUTTON
) ||
549 ((wndPtr
->dwStyle
& 0x0f) == BS_AUTORADIOBUTTON
)) y
+= checkBoxHeight
;
550 else if (infoPtr
->state
& BUTTON_3STATE
) y
+= 2 * checkBoxHeight
;
552 SelectObject( hMemDC
, hbitmapCheckBoxes
);
553 BitBlt( hDC
, rbox
.left
, rbox
.top
+ delta
, checkBoxWidth
,
554 checkBoxHeight
, hMemDC
, x
, y
, SRCCOPY
);
557 if( textlen
&& action
!= ODA_SELECT
)
559 if (wndPtr
->dwStyle
& WS_DISABLED
&&
560 GetSysColor(COLOR_GRAYTEXT
)==GetBkColor(hDC
)) {
561 /* don't write gray text on gray background */
562 PaintGrayOnGray( hDC
, infoPtr
->hFont
, &rtext
, wndPtr
->text
,
565 if (wndPtr
->dwStyle
& WS_DISABLED
)
566 SetTextColor( hDC
, GetSysColor(COLOR_GRAYTEXT
) );
567 DrawTextA( hDC
, wndPtr
->text
, textlen
, &rtext
,
568 DT_SINGLELINE
| DT_VCENTER
);
569 textlen
= 0; /* skip DrawText() below */
574 if ((action
== ODA_FOCUS
) ||
575 ((action
== ODA_DRAWENTIRE
) && (infoPtr
->state
& BUTTON_HASFOCUS
)))
577 /* again, this is what CTL3D expects */
581 DrawTextA( hDC
, wndPtr
->text
, textlen
, &rbox
,
582 DT_SINGLELINE
| DT_CALCRECT
);
583 textlen
= rbox
.bottom
- rbox
.top
;
584 delta
= ((rtext
.bottom
- rtext
.top
) - textlen
)/2;
585 rbox
.bottom
= (rbox
.top
= rtext
.top
+ delta
- 1) + textlen
+ 2;
586 textlen
= rbox
.right
- rbox
.left
;
587 rbox
.right
= (rbox
.left
+= --rtext
.left
) + textlen
+ 2;
588 IntersectRect(&rbox
, &rbox
, &rtext
);
589 DrawFocusRect( hDC
, &rbox
);
594 /**********************************************************************
595 * BUTTON_CheckAutoRadioButton
597 * wndPtr is checked, uncheck every other auto radio button in group
599 static void BUTTON_CheckAutoRadioButton( WND
*wndPtr
)
601 HWND parent
, sibling
, start
;
602 if (!(wndPtr
->dwStyle
& WS_CHILD
)) return;
603 parent
= wndPtr
->parent
->hwndSelf
;
604 /* assure that starting control is not disabled or invisible */
605 start
= sibling
= GetNextDlgGroupItem( parent
, wndPtr
->hwndSelf
, TRUE
);
610 tmpWnd
= WIN_FindWndPtr(sibling
);
611 if ((wndPtr
->hwndSelf
!= sibling
) &&
612 ((tmpWnd
->dwStyle
& 0x0f) == BS_AUTORADIOBUTTON
))
613 SendMessageA( sibling
, BM_SETCHECK
, BUTTON_UNCHECKED
, 0 );
614 sibling
= GetNextDlgGroupItem( parent
, sibling
, FALSE
);
615 WIN_ReleaseWndPtr(tmpWnd
);
616 } while (sibling
!= start
);
620 /**********************************************************************
621 * Group Box Functions
624 static void GB_Paint( WND
*wndPtr
, HDC hDC
, WORD action
)
627 BUTTONINFO
*infoPtr
= (BUTTONINFO
*)wndPtr
->wExtra
;
629 if (action
!= ODA_DRAWENTIRE
) return;
631 BUTTON_SEND_CTLCOLOR( wndPtr
, hDC
);
633 GetClientRect( wndPtr
->hwndSelf
, &rc
);
634 if (TWEAK_WineLook
== WIN31_LOOK
) {
635 HPEN hPrevPen
= SelectObject( hDC
,
636 GetSysColorPen(COLOR_WINDOWFRAME
));
637 HBRUSH hPrevBrush
= SelectObject( hDC
,
638 GetStockObject(NULL_BRUSH
) );
640 Rectangle( hDC
, rc
.left
, rc
.top
+ 2, rc
.right
- 1, rc
.bottom
- 1 );
641 SelectObject( hDC
, hPrevBrush
);
642 SelectObject( hDC
, hPrevPen
);
648 SelectObject (hDC
, infoPtr
->hFont
);
649 GetTextMetricsA (hDC
, &tm
);
650 rcFrame
.top
+= (tm
.tmHeight
/ 2) - 1;
651 DrawEdge (hDC
, &rcFrame
, EDGE_ETCHED
, BF_RECT
);
656 if (infoPtr
->hFont
) SelectObject( hDC
, infoPtr
->hFont
);
657 if (wndPtr
->dwStyle
& WS_DISABLED
)
658 SetTextColor( hDC
, GetSysColor(COLOR_GRAYTEXT
) );
660 DrawTextA( hDC
, wndPtr
->text
, -1, &rc
, DT_SINGLELINE
| DT_NOCLIP
);
665 /**********************************************************************
666 * User Button Functions
669 static void UB_Paint( WND
*wndPtr
, HDC hDC
, WORD action
)
673 BUTTONINFO
*infoPtr
= (BUTTONINFO
*)wndPtr
->wExtra
;
675 if (action
== ODA_SELECT
) return;
677 GetClientRect( wndPtr
->hwndSelf
, &rc
);
679 if (infoPtr
->hFont
) SelectObject( hDC
, infoPtr
->hFont
);
680 hBrush
= GetControlBrush16( wndPtr
->hwndSelf
, hDC
, CTLCOLOR_BTN
);
682 FillRect( hDC
, &rc
, hBrush
);
683 if ((action
== ODA_FOCUS
) ||
684 ((action
== ODA_DRAWENTIRE
) && (infoPtr
->state
& BUTTON_HASFOCUS
)))
685 DrawFocusRect( hDC
, &rc
);
689 /**********************************************************************
690 * Ownerdrawn Button Functions
693 static void OB_Paint( WND
*wndPtr
, HDC hDC
, WORD action
)
695 BUTTONINFO
*infoPtr
= (BUTTONINFO
*)wndPtr
->wExtra
;
698 dis
.CtlType
= ODT_BUTTON
;
699 dis
.CtlID
= wndPtr
->wIDmenu
;
701 dis
.itemAction
= action
;
702 dis
.itemState
= ((infoPtr
->state
& BUTTON_HASFOCUS
) ? ODS_FOCUS
: 0) |
703 ((infoPtr
->state
& BUTTON_HIGHLIGHTED
) ? ODS_SELECTED
: 0) |
704 ((wndPtr
->dwStyle
& WS_DISABLED
) ? ODS_DISABLED
: 0);
705 dis
.hwndItem
= wndPtr
->hwndSelf
;
708 GetClientRect( wndPtr
->hwndSelf
, &dis
.rcItem
);
709 SendMessageA( GetParent(wndPtr
->hwndSelf
), WM_DRAWITEM
,
710 wndPtr
->wIDmenu
, (LPARAM
)&dis
);