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
)
119 return -1; /* abort */
120 infoPtr
->state
= BUTTON_UNCHECKED
;
122 infoPtr
->hImage
= NULL
;
129 if (btnPaintFunc
[style
])
132 HDC hdc
= wParam
? (HDC
)wParam
: BeginPaint( hWnd
, &ps
);
133 SetBkMode( hdc
, OPAQUE
);
134 (btnPaintFunc
[style
])( wndPtr
, hdc
, ODA_DRAWENTIRE
);
135 if( !wParam
) EndPaint( hWnd
, &ps
);
140 case WM_LBUTTONDBLCLK
:
141 SendMessageA( hWnd
, BM_SETSTATE
, TRUE
, 0 );
148 if (!(infoPtr
->state
& BUTTON_HIGHLIGHTED
)) break;
149 SendMessageA( hWnd
, BM_SETSTATE
, FALSE
, 0 );
150 GetClientRect( hWnd
, &rect
);
151 if (PtInRect( &rect
, pt
))
155 case BS_AUTOCHECKBOX
:
156 SendMessageA( hWnd
, BM_SETCHECK
,
157 !(infoPtr
->state
& BUTTON_CHECKED
), 0 );
159 case BS_AUTORADIOBUTTON
:
160 SendMessageA( hWnd
, BM_SETCHECK
, TRUE
, 0 );
163 SendMessageA( hWnd
, BM_SETCHECK
,
164 (infoPtr
->state
& BUTTON_3STATE
) ? 0 :
165 ((infoPtr
->state
& 3) + 1), 0 );
168 SendMessageA( GetParent(hWnd
), WM_COMMAND
,
169 MAKEWPARAM( wndPtr
->wIDmenu
, BN_CLICKED
), hWnd
);
174 if (GetCapture() == hWnd
)
176 GetClientRect( hWnd
, &rect
);
177 SendMessageA( hWnd
, BM_SETSTATE
, PtInRect(&rect
, pt
), 0 );
182 if(style
== BS_GROUPBOX
) return HTTRANSPARENT
;
183 return DefWindowProcA( hWnd
, uMsg
, wParam
, lParam
);
186 DEFWND_SetText( wndPtr
, (LPCSTR
)lParam
);
187 if( wndPtr
->dwStyle
& WS_VISIBLE
)
188 PAINT_BUTTON( wndPtr
, style
, ODA_DRAWENTIRE
);
192 infoPtr
->hFont
= (HFONT16
)wParam
;
193 if (lParam
&& (wndPtr
->dwStyle
& WS_VISIBLE
))
194 PAINT_BUTTON( wndPtr
, style
, ODA_DRAWENTIRE
);
198 return infoPtr
->hFont
;
201 infoPtr
->state
|= BUTTON_HASFOCUS
;
202 if (style
== BS_AUTORADIOBUTTON
)
203 SendMessageA( hWnd
, BM_SETCHECK
, 1, 0 );
204 PAINT_BUTTON( wndPtr
, style
, ODA_FOCUS
);
208 infoPtr
->state
&= ~BUTTON_HASFOCUS
;
209 PAINT_BUTTON( wndPtr
, style
, ODA_FOCUS
);
210 InvalidateRect( hWnd
, NULL
, TRUE
);
213 case WM_SYSCOLORCHANGE
:
214 InvalidateRect( hWnd
, NULL
, FALSE
);
219 if ((wParam
& 0x0f) >= MAX_BTN_TYPE
) break;
220 wndPtr
->dwStyle
= (wndPtr
->dwStyle
& 0xfffffff0)
221 | (wParam
& 0x0000000f);
222 style
= wndPtr
->dwStyle
& 0x0000000f;
223 PAINT_BUTTON( wndPtr
, style
, ODA_DRAWENTIRE
);
227 oldHbitmap
= infoPtr
->hImage
;
228 if(wndPtr
->dwStyle
& BS_BITMAP
)
229 infoPtr
->hImage
= (HANDLE
) lParam
;
233 return infoPtr
->hImage
;
237 return infoPtr
->state
& 3;
241 if (wParam
> maxCheckState
[style
]) wParam
= maxCheckState
[style
];
242 if ((infoPtr
->state
& 3) != wParam
)
244 if ((style
== BS_RADIOBUTTON
) || (style
== BS_AUTORADIOBUTTON
))
247 wndPtr
->dwStyle
|= WS_TABSTOP
;
249 wndPtr
->dwStyle
&= ~WS_TABSTOP
;
251 infoPtr
->state
= (infoPtr
->state
& ~3) | wParam
;
252 PAINT_BUTTON( wndPtr
, style
, ODA_SELECT
);
254 if ((style
== BS_AUTORADIOBUTTON
) && (wParam
== BUTTON_CHECKED
))
255 BUTTON_CheckAutoRadioButton( wndPtr
);
260 return infoPtr
->state
;
266 if (infoPtr
->state
& BUTTON_HIGHLIGHTED
) break;
267 infoPtr
->state
|= BUTTON_HIGHLIGHTED
;
271 if (!(infoPtr
->state
& BUTTON_HIGHLIGHTED
)) break;
272 infoPtr
->state
&= ~BUTTON_HIGHLIGHTED
;
274 PAINT_BUTTON( wndPtr
, style
, ODA_SELECT
);
278 return DefWindowProcA(hWnd
, uMsg
, wParam
, lParam
);
283 /***********************************************************************
285 * The button window procedure. This is just a wrapper which locks
286 * the passed HWND and calls the real window procedure (with a WND*
287 * pointer pointing to the locked windowstructure).
289 LRESULT WINAPI
ButtonWndProc( HWND hWnd
, UINT uMsg
,
290 WPARAM wParam
, LPARAM lParam
)
293 WND
*wndPtr
= WIN_FindWndPtr(hWnd
);
295 res
= ButtonWndProc_locked(wndPtr
,uMsg
,wParam
,lParam
);
297 WIN_ReleaseWndPtr(wndPtr
);
301 /**********************************************************************
302 * Push Button Functions
305 static void PB_Paint( WND
*wndPtr
, HDC hDC
, WORD action
)
310 BUTTONINFO
*infoPtr
= (BUTTONINFO
*)wndPtr
->wExtra
;
311 int xBorderOffset
, yBorderOffset
;
312 xBorderOffset
= yBorderOffset
= 0;
314 GetClientRect( wndPtr
->hwndSelf
, &rc
);
316 /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
317 if (infoPtr
->hFont
) SelectObject( hDC
, infoPtr
->hFont
);
318 BUTTON_SEND_CTLCOLOR( wndPtr
, hDC
);
319 hOldPen
= (HPEN
)SelectObject(hDC
, GetSysColorPen(COLOR_WINDOWFRAME
));
320 hOldBrush
=(HBRUSH
)SelectObject(hDC
,GetSysColorBrush(COLOR_BTNFACE
));
321 SetBkMode(hDC
, TRANSPARENT
);
322 Rectangle(hDC
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
323 if (TWEAK_WineLook
== WIN31_LOOK
)
325 SetPixel( hDC
, rc
.left
, rc
.top
, GetSysColor(COLOR_WINDOW
) );
326 SetPixel( hDC
, rc
.left
, rc
.bottom
-1, GetSysColor(COLOR_WINDOW
) );
327 SetPixel( hDC
, rc
.right
-1, rc
.top
, GetSysColor(COLOR_WINDOW
) );
328 SetPixel( hDC
, rc
.right
-1, rc
.bottom
-1, GetSysColor(COLOR_WINDOW
));
330 InflateRect( &rc
, -1, -1 );
332 if ((wndPtr
->dwStyle
& 0x000f) == BS_DEFPUSHBUTTON
)
334 Rectangle(hDC
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
335 InflateRect( &rc
, -1, -1 );
338 if (infoPtr
->state
& BUTTON_HIGHLIGHTED
)
340 /* draw button shadow: */
341 SelectObject(hDC
, GetSysColorBrush(COLOR_BTNSHADOW
));
342 PatBlt(hDC
, rc
.left
, rc
.top
, 1, rc
.bottom
-rc
.top
, PATCOPY
);
343 PatBlt(hDC
, rc
.left
, rc
.top
, rc
.right
-rc
.left
, 1, PATCOPY
);
344 rc
.left
+= 2; /* To position the text down and right */
347 rc
.right
++, rc
.bottom
++;
348 DrawEdge( hDC
, &rc
, EDGE_RAISED
, BF_RECT
);
350 /* To place de bitmap correctly */
351 xBorderOffset
+= GetSystemMetrics(SM_CXEDGE
);
352 yBorderOffset
+= GetSystemMetrics(SM_CYEDGE
);
354 rc
.right
--, rc
.bottom
--;
357 /* draw button label, if any: */
358 if (wndPtr
->text
&& wndPtr
->text
[0])
361 GetObjectA( GetSysColorBrush(COLOR_BTNFACE
), sizeof(lb
), &lb
);
362 if (wndPtr
->dwStyle
& WS_DISABLED
&&
363 GetSysColor(COLOR_GRAYTEXT
)==lb
.lbColor
)
364 /* don't write gray text on gray background */
365 PaintGrayOnGray( hDC
,infoPtr
->hFont
,&rc
,wndPtr
->text
,
366 DT_CENTER
| DT_VCENTER
);
369 SetTextColor( hDC
, (wndPtr
->dwStyle
& WS_DISABLED
) ?
370 GetSysColor(COLOR_GRAYTEXT
) :
371 GetSysColor(COLOR_BTNTEXT
) );
372 DrawTextA( hDC
, wndPtr
->text
, -1, &rc
,
373 DT_SINGLELINE
| DT_CENTER
| DT_VCENTER
);
374 /* do we have the focus? */
375 if (infoPtr
->state
& BUTTON_HASFOCUS
)
377 RECT r
= { 0, 0, 0, 0 };
380 DrawTextA( hDC
, wndPtr
->text
, -1, &r
,
381 DT_SINGLELINE
| DT_CALCRECT
);
382 xdelta
= ((rc
.right
- rc
.left
) - (r
.right
- r
.left
) - 1) / 2;
383 ydelta
= ((rc
.bottom
- rc
.top
) - (r
.bottom
- r
.top
) - 1) / 2;
384 if (xdelta
< 0) xdelta
= 0;
385 if (ydelta
< 0) ydelta
= 0;
386 InflateRect( &rc
, -xdelta
, -ydelta
);
387 DrawFocusRect( hDC
, &rc
);
392 if((wndPtr
->dwStyle
& BS_BITMAP
) && (infoPtr
->hImage
!= NULL
))
396 int yOffset
, xOffset
, imageWidth
, imageHeight
;
398 GetObjectA (infoPtr
->hImage
, sizeof(BITMAP
), &bm
);
400 /* Center the bitmap */
401 xOffset
= (((rc
.right
- rc
.left
) - 2*xBorderOffset
) - bm
.bmWidth
) / 2;
402 yOffset
= (((rc
.bottom
- rc
.top
) - 2*yBorderOffset
) - bm
.bmHeight
) / 2;
404 imageWidth
= bm
.bmWidth
;
405 imageHeight
= bm
.bmHeight
;
407 /* If the image is to big for the button */
410 imageWidth
= rc
.right
- rc
.left
- 2*xBorderOffset
-1;
411 xOffset
= xBorderOffset
;
416 imageHeight
= rc
.bottom
- rc
.top
- 2*yBorderOffset
-1;
417 yOffset
= yBorderOffset
;
420 /* Let minimum 1 space from border */
421 xOffset
++, yOffset
++;
423 hdcMem
= CreateCompatibleDC (hDC
);
424 SelectObject (hdcMem
, (HBITMAP
)infoPtr
->hImage
);
425 BitBlt(hDC
, rc
.left
+ xOffset
,
427 imageWidth
, imageHeight
,
428 hdcMem
, 0, 0, SRCCOPY
);
433 SelectObject( hDC
, hOldPen
);
434 SelectObject( hDC
, hOldBrush
);
438 /**********************************************************************
439 * PB_Paint & CB_Paint sub function [internal]
440 * Paint text using a raster brush to avoid gray text on gray
441 * background. 'format' can be a combination of DT_CENTER and
442 * DT_VCENTER to use this function in both PB_PAINT and
443 * CB_PAINT. - Dirk Thierbach
445 * FIXME: This and TEXT_GrayString should be eventually combined,
446 * so calling one common function from PB_Paint, CB_Paint and
447 * TEXT_GrayString will be enough. Also note that this
448 * function ignores the CACHE_GetPattern funcs.
451 void PaintGrayOnGray(HDC hDC
,HFONT hFont
,RECT
*rc
,char *text
,
454 /* This is the standard gray on gray pattern:
455 static const WORD Pattern[] = {0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55};
457 /* This pattern gives better readability with X Fonts.
458 FIXME: Maybe the user should be allowed to decide which he wants. */
459 static const WORD Pattern
[] = {0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF};
461 HBITMAP hbm
= CreateBitmap( 8, 8, 1, 1, Pattern
);
462 HDC hdcMem
= CreateCompatibleDC(hDC
);
468 DrawTextA( hDC
, text
, -1, &rect
, DT_SINGLELINE
| DT_CALCRECT
);
469 /* now text width and height are in rect.right and rect.bottom */
471 rect
.left
= rect
.top
= 0; /* drawing pos in hdcMem */
472 if (format
& DT_CENTER
) rect
.left
=(rc
->right
-rect
.right
)/2;
473 if (format
& DT_VCENTER
) rect
.top
=(rc
->bottom
-rect
.bottom
)/2;
474 hbmMem
= CreateCompatibleBitmap( hDC
,rect
.right
,rect
.bottom
);
475 SelectObject( hdcMem
, hbmMem
);
476 PatBlt( hdcMem
,0,0,rect
.right
,rect
.bottom
,WHITENESS
);
477 /* will be overwritten by DrawText, but just in case */
478 if (hFont
) SelectObject( hdcMem
, hFont
);
479 DrawTextA( hdcMem
, text
, -1, &rc2
, DT_SINGLELINE
);
480 /* After draw: foreground = 0 bits, background = 1 bits */
481 hBr
= SelectObject( hdcMem
, CreatePatternBrush(hbm
) );
483 PatBlt( hdcMem
,0,0,rect
.right
,rect
.bottom
,0xAF0229);
484 /* only keep the foreground bits where pattern is 1 */
485 DeleteObject( SelectObject( hdcMem
,hBr
) );
486 BitBlt(hDC
,rect
.left
,rect
.top
,rect
.right
,rect
.bottom
,hdcMem
,0,0,SRCAND
);
487 /* keep the background of the dest */
489 DeleteObject( hbmMem
);
493 /**********************************************************************
494 * Check Box & Radio Button Functions
497 static void CB_Paint( WND
*wndPtr
, HDC hDC
, WORD action
)
499 RECT rbox
, rtext
, client
;
502 BUTTONINFO
*infoPtr
= (BUTTONINFO
*)wndPtr
->wExtra
;
505 GetClientRect(wndPtr
->hwndSelf
, &client
);
506 rbox
= rtext
= client
;
508 if (infoPtr
->hFont
) SelectObject( hDC
, infoPtr
->hFont
);
510 /* Something is still not right, checkboxes (and edit controls)
511 * in wsping32 have white backgrounds instead of dark grey.
512 * BUTTON_SEND_CTLCOLOR() is even worse since it returns 0 in this
513 * particular case and the background is not painted at all.
516 hBrush
= GetControlBrush16( wndPtr
->hwndSelf
, hDC
, CTLCOLOR_BTN
);
518 if (wndPtr
->dwStyle
& BS_LEFTTEXT
)
520 /* magic +4 is what CTL3D expects */
522 rtext
.right
-= checkBoxWidth
+ 4;
523 rbox
.left
= rbox
.right
- checkBoxWidth
;
527 rtext
.left
+= checkBoxWidth
+ 4;
528 rbox
.right
= checkBoxWidth
;
531 /* Draw the check-box bitmap */
533 if (wndPtr
->text
) textlen
= strlen( wndPtr
->text
);
534 if (action
== ODA_DRAWENTIRE
|| action
== ODA_SELECT
)
536 HDC hMemDC
= CreateCompatibleDC( hDC
);
538 delta
= (rbox
.bottom
- rbox
.top
- checkBoxHeight
) >> 1;
540 if (action
== ODA_SELECT
) FillRect( hDC
, &rbox
, hBrush
);
541 else FillRect( hDC
, &client
, hBrush
);
543 if (infoPtr
->state
& BUTTON_HIGHLIGHTED
) x
+= 2 * checkBoxWidth
;
544 if (infoPtr
->state
& (BUTTON_CHECKED
| BUTTON_3STATE
)) x
+= checkBoxWidth
;
545 if (((wndPtr
->dwStyle
& 0x0f) == BS_RADIOBUTTON
) ||
546 ((wndPtr
->dwStyle
& 0x0f) == BS_AUTORADIOBUTTON
)) y
+= checkBoxHeight
;
547 else if (infoPtr
->state
& BUTTON_3STATE
) y
+= 2 * checkBoxHeight
;
549 SelectObject( hMemDC
, hbitmapCheckBoxes
);
550 BitBlt( hDC
, rbox
.left
, rbox
.top
+ delta
, checkBoxWidth
,
551 checkBoxHeight
, hMemDC
, x
, y
, SRCCOPY
);
554 if( textlen
&& action
!= ODA_SELECT
)
556 if (wndPtr
->dwStyle
& WS_DISABLED
&&
557 GetSysColor(COLOR_GRAYTEXT
)==GetBkColor(hDC
)) {
558 /* don't write gray text on gray background */
559 PaintGrayOnGray( hDC
, infoPtr
->hFont
, &rtext
, wndPtr
->text
,
562 if (wndPtr
->dwStyle
& WS_DISABLED
)
563 SetTextColor( hDC
, GetSysColor(COLOR_GRAYTEXT
) );
564 DrawTextA( hDC
, wndPtr
->text
, textlen
, &rtext
,
565 DT_SINGLELINE
| DT_VCENTER
);
566 textlen
= 0; /* skip DrawText() below */
571 if ((action
== ODA_FOCUS
) ||
572 ((action
== ODA_DRAWENTIRE
) && (infoPtr
->state
& BUTTON_HASFOCUS
)))
574 /* again, this is what CTL3D expects */
578 DrawTextA( hDC
, wndPtr
->text
, textlen
, &rbox
,
579 DT_SINGLELINE
| DT_CALCRECT
);
580 textlen
= rbox
.bottom
- rbox
.top
;
581 delta
= ((rtext
.bottom
- rtext
.top
) - textlen
)/2;
582 rbox
.bottom
= (rbox
.top
= rtext
.top
+ delta
- 1) + textlen
+ 2;
583 textlen
= rbox
.right
- rbox
.left
;
584 rbox
.right
= (rbox
.left
+= --rtext
.left
) + textlen
+ 2;
585 IntersectRect(&rbox
, &rbox
, &rtext
);
586 DrawFocusRect( hDC
, &rbox
);
591 /**********************************************************************
592 * BUTTON_CheckAutoRadioButton
594 * wndPtr is checked, uncheck every other auto radio button in group
596 static void BUTTON_CheckAutoRadioButton( WND
*wndPtr
)
598 HWND parent
, sibling
, start
;
599 if (!(wndPtr
->dwStyle
& WS_CHILD
)) return;
600 parent
= wndPtr
->parent
->hwndSelf
;
601 /* assure that starting control is not disabled or invisible */
602 start
= sibling
= GetNextDlgGroupItem( parent
, wndPtr
->hwndSelf
, TRUE
);
607 tmpWnd
= WIN_FindWndPtr(sibling
);
608 if ((wndPtr
->hwndSelf
!= sibling
) &&
609 ((tmpWnd
->dwStyle
& 0x0f) == BS_AUTORADIOBUTTON
))
610 SendMessageA( sibling
, BM_SETCHECK
, BUTTON_UNCHECKED
, 0 );
611 sibling
= GetNextDlgGroupItem( parent
, sibling
, FALSE
);
612 WIN_ReleaseWndPtr(tmpWnd
);
613 } while (sibling
!= start
);
617 /**********************************************************************
618 * Group Box Functions
621 static void GB_Paint( WND
*wndPtr
, HDC hDC
, WORD action
)
624 BUTTONINFO
*infoPtr
= (BUTTONINFO
*)wndPtr
->wExtra
;
626 if (action
!= ODA_DRAWENTIRE
) return;
628 BUTTON_SEND_CTLCOLOR( wndPtr
, hDC
);
630 GetClientRect( wndPtr
->hwndSelf
, &rc
);
631 if (TWEAK_WineLook
== WIN31_LOOK
) {
632 HPEN hPrevPen
= SelectObject( hDC
,
633 GetSysColorPen(COLOR_WINDOWFRAME
));
634 HBRUSH hPrevBrush
= SelectObject( hDC
,
635 GetStockObject(NULL_BRUSH
) );
637 Rectangle( hDC
, rc
.left
, rc
.top
+ 2, rc
.right
- 1, rc
.bottom
- 1 );
638 SelectObject( hDC
, hPrevBrush
);
639 SelectObject( hDC
, hPrevPen
);
645 SelectObject (hDC
, infoPtr
->hFont
);
646 GetTextMetricsA (hDC
, &tm
);
647 rcFrame
.top
+= (tm
.tmHeight
/ 2) - 1;
648 DrawEdge (hDC
, &rcFrame
, EDGE_ETCHED
, BF_RECT
);
653 if (infoPtr
->hFont
) SelectObject( hDC
, infoPtr
->hFont
);
654 if (wndPtr
->dwStyle
& WS_DISABLED
)
655 SetTextColor( hDC
, GetSysColor(COLOR_GRAYTEXT
) );
657 DrawTextA( hDC
, wndPtr
->text
, -1, &rc
, DT_SINGLELINE
| DT_NOCLIP
);
662 /**********************************************************************
663 * User Button Functions
666 static void UB_Paint( WND
*wndPtr
, HDC hDC
, WORD action
)
670 BUTTONINFO
*infoPtr
= (BUTTONINFO
*)wndPtr
->wExtra
;
672 if (action
== ODA_SELECT
) return;
674 GetClientRect( wndPtr
->hwndSelf
, &rc
);
676 if (infoPtr
->hFont
) SelectObject( hDC
, infoPtr
->hFont
);
677 hBrush
= GetControlBrush16( wndPtr
->hwndSelf
, hDC
, CTLCOLOR_BTN
);
679 FillRect( hDC
, &rc
, hBrush
);
680 if ((action
== ODA_FOCUS
) ||
681 ((action
== ODA_DRAWENTIRE
) && (infoPtr
->state
& BUTTON_HASFOCUS
)))
682 DrawFocusRect( hDC
, &rc
);
686 /**********************************************************************
687 * Ownerdrawn Button Functions
690 static void OB_Paint( WND
*wndPtr
, HDC hDC
, WORD action
)
692 BUTTONINFO
*infoPtr
= (BUTTONINFO
*)wndPtr
->wExtra
;
695 dis
.CtlType
= ODT_BUTTON
;
696 dis
.CtlID
= wndPtr
->wIDmenu
;
698 dis
.itemAction
= action
;
699 dis
.itemState
= ((infoPtr
->state
& BUTTON_HASFOCUS
) ? ODS_FOCUS
: 0) |
700 ((infoPtr
->state
& BUTTON_HIGHLIGHTED
) ? ODS_SELECTED
: 0) |
701 ((wndPtr
->dwStyle
& WS_DISABLED
) ? ODS_DISABLED
: 0);
702 dis
.hwndItem
= wndPtr
->hwndSelf
;
705 GetClientRect( wndPtr
->hwndSelf
, &dis
.rcItem
);
706 SendMessageA( GetParent(wndPtr
->hwndSelf
), WM_DRAWITEM
,
707 wndPtr
->wIDmenu
, (LPARAM
)&dis
);