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
11 #include "wine/winuser16.h"
14 static void PaintGrayOnGray( HDC hDC,HFONT hFont,RECT *rc,
15 char *text, UINT format );
17 static void PB_Paint( WND *wndPtr, HDC hDC, WORD action );
18 static void CB_Paint( WND *wndPtr, HDC hDC, WORD action );
19 static void GB_Paint( WND *wndPtr, HDC hDC, WORD action );
20 static void UB_Paint( WND *wndPtr, HDC hDC, WORD action );
21 static void OB_Paint( WND *wndPtr, HDC hDC, WORD action );
22 static void BUTTON_CheckAutoRadioButton( WND *wndPtr );
24 #define MAX_BTN_TYPE 12
26 static const WORD maxCheckState[MAX_BTN_TYPE] =
28 BUTTON_UNCHECKED, /* BS_PUSHBUTTON */
29 BUTTON_UNCHECKED, /* BS_DEFPUSHBUTTON */
30 BUTTON_CHECKED, /* BS_CHECKBOX */
31 BUTTON_CHECKED, /* BS_AUTOCHECKBOX */
32 BUTTON_CHECKED, /* BS_RADIOBUTTON */
33 BUTTON_3STATE, /* BS_3STATE */
34 BUTTON_3STATE, /* BS_AUTO3STATE */
35 BUTTON_UNCHECKED, /* BS_GROUPBOX */
36 BUTTON_UNCHECKED, /* BS_USERBUTTON */
37 BUTTON_CHECKED, /* BS_AUTORADIOBUTTON */
38 BUTTON_UNCHECKED, /* Not defined */
39 BUTTON_UNCHECKED /* BS_OWNERDRAW */
42 typedef void (*pfPaint)( WND *wndPtr, HDC hdc, WORD action );
44 static const pfPaint btnPaintFunc[MAX_BTN_TYPE] =
46 PB_Paint, /* BS_PUSHBUTTON */
47 PB_Paint, /* BS_DEFPUSHBUTTON */
48 CB_Paint, /* BS_CHECKBOX */
49 CB_Paint, /* BS_AUTOCHECKBOX */
50 CB_Paint, /* BS_RADIOBUTTON */
51 CB_Paint, /* BS_3STATE */
52 CB_Paint, /* BS_AUTO3STATE */
53 GB_Paint, /* BS_GROUPBOX */
54 UB_Paint, /* BS_USERBUTTON */
55 CB_Paint, /* BS_AUTORADIOBUTTON */
56 NULL, /* Not defined */
57 OB_Paint /* BS_OWNERDRAW */
60 #define PAINT_BUTTON(wndPtr,style,action) \
61 if (btnPaintFunc[style]) { \
62 HDC hdc = GetDC( (wndPtr)->hwndSelf ); \
63 (btnPaintFunc[style])(wndPtr,hdc,action); \
64 ReleaseDC( (wndPtr)->hwndSelf, hdc ); }
66 #define BUTTON_SEND_CTLCOLOR(wndPtr,hdc) \
67 SendMessageA( GetParent((wndPtr)->hwndSelf), WM_CTLCOLORBTN, \
68 (hdc), (wndPtr)->hwndSelf )
70 static HBITMAP hbitmapCheckBoxes = 0;
71 static WORD checkBoxWidth = 0, checkBoxHeight = 0;
74 /***********************************************************************
75 * ButtonWndProc_locked
77 * Called with window lock held.
79 static inline LRESULT WINAPI ButtonWndProc_locked(WND* wndPtr, UINT uMsg,
80 WPARAM wParam, LPARAM lParam )
83 HWND hWnd = wndPtr->hwndSelf;
85 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
86 LONG style = wndPtr->dwStyle & 0x0f;
89 pt.x = LOWORD(lParam);
90 pt.y = HIWORD(lParam);
97 case BS_PUSHBUTTON: return DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON;
98 case BS_DEFPUSHBUTTON: return DLGC_BUTTON | DLGC_DEFPUSHBUTTON;
100 case BS_AUTORADIOBUTTON: return DLGC_BUTTON | DLGC_RADIOBUTTON;
101 default: return DLGC_BUTTON;
105 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
109 if (!hbitmapCheckBoxes)
112 hbitmapCheckBoxes = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_CHECKBOXES));
113 GetObjectA( hbitmapCheckBoxes, sizeof(bmp), &bmp );
114 checkBoxWidth = bmp.bmWidth / 4;
115 checkBoxHeight = bmp.bmHeight / 3;
117 if (style < 0L || style >= MAX_BTN_TYPE)
118 return -1; /* abort */
119 infoPtr->state = BUTTON_UNCHECKED;
121 infoPtr->hImage = NULL;
128 if (btnPaintFunc[style])
131 HDC hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps );
132 SetBkMode( hdc, OPAQUE );
133 (btnPaintFunc[style])( wndPtr, hdc, ODA_DRAWENTIRE );
134 if( !wParam ) EndPaint( hWnd, &ps );
139 case WM_LBUTTONDBLCLK:
140 SendMessageA( hWnd, BM_SETSTATE, TRUE, 0 );
146 /* FIXME: real windows uses extra flags in the status for this */
147 if (GetCapture() != hWnd) break;
149 if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break;
150 SendMessageA( hWnd, BM_SETSTATE, FALSE, 0 );
151 GetClientRect( hWnd, &rect );
152 if (PtInRect( &rect, pt ))
156 case BS_AUTOCHECKBOX:
157 SendMessageA( hWnd, BM_SETCHECK,
158 !(infoPtr->state & BUTTON_CHECKED), 0 );
160 case BS_AUTORADIOBUTTON:
161 SendMessageA( hWnd, BM_SETCHECK, TRUE, 0 );
164 SendMessageA( hWnd, BM_SETCHECK,
165 (infoPtr->state & BUTTON_3STATE) ? 0 :
166 ((infoPtr->state & 3) + 1), 0 );
169 SendMessageA( GetParent(hWnd), WM_COMMAND,
170 MAKEWPARAM( wndPtr->wIDmenu, BN_CLICKED ), hWnd);
175 if (GetCapture() == hWnd)
177 GetClientRect( hWnd, &rect );
178 SendMessageA( hWnd, BM_SETSTATE, PtInRect(&rect, pt), 0 );
183 if(style == BS_GROUPBOX) return HTTRANSPARENT;
184 return DefWindowProcA( hWnd, uMsg, wParam, lParam );
187 DEFWND_SetText( wndPtr, (LPCSTR)lParam );
188 if( wndPtr->dwStyle & WS_VISIBLE )
189 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
193 infoPtr->hFont = (HFONT16)wParam;
194 if (lParam && (wndPtr->dwStyle & WS_VISIBLE))
195 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
199 return infoPtr->hFont;
202 if ((style == BS_AUTORADIOBUTTON) && (GetCapture() != hWnd) &&
203 !(SendMessageA(hWnd, BM_GETCHECK, 0, 0) & BST_CHECKED))
205 /* The notification is sent when the button (BS_AUTORADIOBUTTON)
206 is unckecked and the focus was not given by a mouse click. */
207 SendMessageA( hWnd, BM_SETCHECK, TRUE, 0 );
208 SendMessageA( GetParent(hWnd), WM_COMMAND,
209 MAKEWPARAM( wndPtr->wIDmenu, BN_CLICKED ), hWnd);
211 infoPtr->state |= BUTTON_HASFOCUS;
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;
241 return infoPtr->hImage;
245 return infoPtr->state & 3;
249 if (wParam > maxCheckState[style]) wParam = maxCheckState[style];
250 if ((infoPtr->state & 3) != wParam)
252 if ((style == BS_RADIOBUTTON) || (style == BS_AUTORADIOBUTTON))
255 wndPtr->dwStyle |= WS_TABSTOP;
257 wndPtr->dwStyle &= ~WS_TABSTOP;
259 infoPtr->state = (infoPtr->state & ~3) | wParam;
260 PAINT_BUTTON( wndPtr, style, ODA_SELECT );
262 if ((style == BS_AUTORADIOBUTTON) && (wParam == BUTTON_CHECKED))
263 BUTTON_CheckAutoRadioButton( wndPtr );
268 return infoPtr->state;
274 if (infoPtr->state & BUTTON_HIGHLIGHTED) break;
275 infoPtr->state |= BUTTON_HIGHLIGHTED;
279 if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break;
280 infoPtr->state &= ~BUTTON_HIGHLIGHTED;
282 PAINT_BUTTON( wndPtr, style, ODA_SELECT );
286 return DefWindowProcA(hWnd, uMsg, wParam, lParam);
291 /***********************************************************************
293 * The button window procedure. This is just a wrapper which locks
294 * the passed HWND and calls the real window procedure (with a WND*
295 * pointer pointing to the locked windowstructure).
297 LRESULT WINAPI ButtonWndProc( HWND hWnd, UINT uMsg,
298 WPARAM wParam, LPARAM lParam )
301 WND *wndPtr = WIN_FindWndPtr(hWnd);
303 res = ButtonWndProc_locked(wndPtr,uMsg,wParam,lParam);
305 WIN_ReleaseWndPtr(wndPtr);
309 /**********************************************************************
310 * Push Button Functions
313 static void PB_Paint( WND *wndPtr, HDC hDC, WORD action )
318 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
319 int xBorderOffset, yBorderOffset;
320 xBorderOffset = yBorderOffset = 0;
322 GetClientRect( wndPtr->hwndSelf, &rc );
324 /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
325 if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
326 BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
327 hOldPen = (HPEN)SelectObject(hDC, GetSysColorPen(COLOR_WINDOWFRAME));
328 hOldBrush =(HBRUSH)SelectObject(hDC,GetSysColorBrush(COLOR_BTNFACE));
329 SetBkMode(hDC, TRANSPARENT);
330 Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
331 if (TWEAK_WineLook == WIN31_LOOK)
333 SetPixel( hDC, rc.left, rc.top, GetSysColor(COLOR_WINDOW) );
334 SetPixel( hDC, rc.left, rc.bottom-1, GetSysColor(COLOR_WINDOW) );
335 SetPixel( hDC, rc.right-1, rc.top, GetSysColor(COLOR_WINDOW) );
336 SetPixel( hDC, rc.right-1, rc.bottom-1, GetSysColor(COLOR_WINDOW));
338 InflateRect( &rc, -1, -1 );
340 if ((wndPtr->dwStyle & 0x000f) == BS_DEFPUSHBUTTON)
342 Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
343 InflateRect( &rc, -1, -1 );
346 if (infoPtr->state & BUTTON_HIGHLIGHTED)
348 /* draw button shadow: */
349 SelectObject(hDC, GetSysColorBrush(COLOR_BTNSHADOW));
350 PatBlt(hDC, rc.left, rc.top, 1, rc.bottom-rc.top, PATCOPY );
351 PatBlt(hDC, rc.left, rc.top, rc.right-rc.left, 1, PATCOPY );
352 rc.left += 2; /* To position the text down and right */
355 rc.right++, rc.bottom++;
356 DrawEdge( hDC, &rc, EDGE_RAISED, BF_RECT );
358 /* To place de bitmap correctly */
359 xBorderOffset += GetSystemMetrics(SM_CXEDGE);
360 yBorderOffset += GetSystemMetrics(SM_CYEDGE);
362 rc.right--, rc.bottom--;
365 /* draw button label, if any: */
366 if (wndPtr->text && wndPtr->text[0])
369 GetObjectA( GetSysColorBrush(COLOR_BTNFACE), sizeof(lb), &lb );
370 if (wndPtr->dwStyle & WS_DISABLED &&
371 GetSysColor(COLOR_GRAYTEXT)==lb.lbColor)
372 /* don't write gray text on gray background */
373 PaintGrayOnGray( hDC,infoPtr->hFont,&rc,wndPtr->text,
374 DT_CENTER | DT_VCENTER );
377 SetTextColor( hDC, (wndPtr->dwStyle & WS_DISABLED) ?
378 GetSysColor(COLOR_GRAYTEXT) :
379 GetSysColor(COLOR_BTNTEXT) );
380 DrawTextA( hDC, wndPtr->text, -1, &rc,
381 DT_SINGLELINE | DT_CENTER | DT_VCENTER );
382 /* do we have the focus? */
383 if (infoPtr->state & BUTTON_HASFOCUS)
385 RECT r = { 0, 0, 0, 0 };
388 DrawTextA( hDC, wndPtr->text, -1, &r,
389 DT_SINGLELINE | DT_CALCRECT );
390 xdelta = ((rc.right - rc.left) - (r.right - r.left) - 1) / 2;
391 ydelta = ((rc.bottom - rc.top) - (r.bottom - r.top) - 1) / 2;
392 if (xdelta < 0) xdelta = 0;
393 if (ydelta < 0) ydelta = 0;
394 InflateRect( &rc, -xdelta, -ydelta );
395 DrawFocusRect( hDC, &rc );
400 if((wndPtr->dwStyle & BS_BITMAP) && (infoPtr->hImage != NULL))
404 int yOffset, xOffset, imageWidth, imageHeight;
406 GetObjectA (infoPtr->hImage, sizeof(BITMAP), &bm);
408 /* Center the bitmap */
409 xOffset = (((rc.right - rc.left) - 2*xBorderOffset) - bm.bmWidth ) / 2;
410 yOffset = (((rc.bottom - rc.top) - 2*yBorderOffset) - bm.bmHeight ) / 2;
412 imageWidth = bm.bmWidth;
413 imageHeight = bm.bmHeight;
415 /* If the image is to big for the button */
418 imageWidth = rc.right - rc.left - 2*xBorderOffset -1;
419 xOffset = xBorderOffset;
424 imageHeight = rc.bottom - rc.top - 2*yBorderOffset -1;
425 yOffset = yBorderOffset;
428 /* Let minimum 1 space from border */
429 xOffset++, yOffset++;
431 hdcMem = CreateCompatibleDC (hDC);
432 SelectObject (hdcMem, (HBITMAP)infoPtr->hImage);
433 BitBlt(hDC, rc.left + xOffset,
435 imageWidth, imageHeight,
436 hdcMem, 0, 0, SRCCOPY);
441 SelectObject( hDC, hOldPen );
442 SelectObject( hDC, hOldBrush );
446 /**********************************************************************
447 * PB_Paint & CB_Paint sub function [internal]
448 * Paint text using a raster brush to avoid gray text on gray
449 * background. 'format' can be a combination of DT_CENTER and
450 * DT_VCENTER to use this function in both PB_PAINT and
451 * CB_PAINT. - Dirk Thierbach
453 * FIXME: This and TEXT_GrayString should be eventually combined,
454 * so calling one common function from PB_Paint, CB_Paint and
455 * TEXT_GrayString will be enough. Also note that this
456 * function ignores the CACHE_GetPattern funcs.
459 void PaintGrayOnGray(HDC hDC,HFONT hFont,RECT *rc,char *text,
462 /* This is the standard gray on gray pattern:
463 static const WORD Pattern[] = {0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55};
465 /* This pattern gives better readability with X Fonts.
466 FIXME: Maybe the user should be allowed to decide which he wants. */
467 static const WORD Pattern[] = {0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF};
469 HBITMAP hbm = CreateBitmap( 8, 8, 1, 1, Pattern );
470 HDC hdcMem = CreateCompatibleDC(hDC);
476 DrawTextA( hDC, text, -1, &rect, DT_SINGLELINE | DT_CALCRECT);
477 /* now text width and height are in rect.right and rect.bottom */
479 rect.left = rect.top = 0; /* drawing pos in hdcMem */
480 if (format & DT_CENTER) rect.left=(rc->right-rect.right)/2;
481 if (format & DT_VCENTER) rect.top=(rc->bottom-rect.bottom)/2;
482 hbmMem = CreateCompatibleBitmap( hDC,rect.right,rect.bottom );
483 SelectObject( hdcMem, hbmMem);
484 PatBlt( hdcMem,0,0,rect.right,rect.bottom,WHITENESS);
485 /* will be overwritten by DrawText, but just in case */
486 if (hFont) SelectObject( hdcMem, hFont);
487 DrawTextA( hdcMem, text, -1, &rc2, DT_SINGLELINE);
488 /* After draw: foreground = 0 bits, background = 1 bits */
489 hBr = SelectObject( hdcMem, CreatePatternBrush(hbm) );
491 PatBlt( hdcMem,0,0,rect.right,rect.bottom,0xAF0229);
492 /* only keep the foreground bits where pattern is 1 */
493 DeleteObject( SelectObject( hdcMem,hBr) );
494 BitBlt(hDC,rect.left,rect.top,rect.right,rect.bottom,hdcMem,0,0,SRCAND);
495 /* keep the background of the dest */
497 DeleteObject( hbmMem );
501 /**********************************************************************
502 * Check Box & Radio Button Functions
505 static void CB_Paint( WND *wndPtr, HDC hDC, WORD action )
507 RECT rbox, rtext, client;
510 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
513 GetClientRect(wndPtr->hwndSelf, &client);
514 rbox = rtext = client;
516 if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
518 /* Something is still not right, checkboxes (and edit controls)
519 * in wsping32 have white backgrounds instead of dark grey.
520 * BUTTON_SEND_CTLCOLOR() is even worse since it returns 0 in this
521 * particular case and the background is not painted at all.
524 hBrush = GetControlBrush16( wndPtr->hwndSelf, hDC, CTLCOLOR_BTN );
526 if (wndPtr->dwStyle & BS_LEFTTEXT)
528 /* magic +4 is what CTL3D expects */
530 rtext.right -= checkBoxWidth + 4;
531 rbox.left = rbox.right - checkBoxWidth;
535 rtext.left += checkBoxWidth + 4;
536 rbox.right = checkBoxWidth;
539 /* Draw the check-box bitmap */
541 if (wndPtr->text) textlen = strlen( wndPtr->text );
542 if (action == ODA_DRAWENTIRE || action == ODA_SELECT)
544 HDC hMemDC = CreateCompatibleDC( hDC );
546 delta = (rbox.bottom - rbox.top - checkBoxHeight) >> 1;
548 if (action == ODA_SELECT) FillRect( hDC, &rbox, hBrush );
549 else FillRect( hDC, &client, hBrush );
551 if (infoPtr->state & BUTTON_HIGHLIGHTED) x += 2 * checkBoxWidth;
552 if (infoPtr->state & (BUTTON_CHECKED | BUTTON_3STATE)) x += checkBoxWidth;
553 if (((wndPtr->dwStyle & 0x0f) == BS_RADIOBUTTON) ||
554 ((wndPtr->dwStyle & 0x0f) == BS_AUTORADIOBUTTON)) y += checkBoxHeight;
555 else if (infoPtr->state & BUTTON_3STATE) y += 2 * checkBoxHeight;
557 SelectObject( hMemDC, hbitmapCheckBoxes );
558 BitBlt( hDC, rbox.left, rbox.top + delta, checkBoxWidth,
559 checkBoxHeight, hMemDC, x, y, SRCCOPY );
562 if( textlen && action != ODA_SELECT )
564 if (wndPtr->dwStyle & WS_DISABLED &&
565 GetSysColor(COLOR_GRAYTEXT)==GetBkColor(hDC)) {
566 /* don't write gray text on gray background */
567 PaintGrayOnGray( hDC, infoPtr->hFont, &rtext, wndPtr->text,
570 if (wndPtr->dwStyle & WS_DISABLED)
571 SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) );
572 DrawTextA( hDC, wndPtr->text, textlen, &rtext,
573 DT_SINGLELINE | DT_VCENTER );
574 textlen = 0; /* skip DrawText() below */
579 if ((action == ODA_FOCUS) ||
580 ((action == ODA_DRAWENTIRE) && (infoPtr->state & BUTTON_HASFOCUS)))
582 /* again, this is what CTL3D expects */
586 DrawTextA( hDC, wndPtr->text, textlen, &rbox,
587 DT_SINGLELINE | DT_CALCRECT );
588 textlen = rbox.bottom - rbox.top;
589 delta = ((rtext.bottom - rtext.top) - textlen)/2;
590 rbox.bottom = (rbox.top = rtext.top + delta - 1) + textlen + 2;
591 textlen = rbox.right - rbox.left;
592 rbox.right = (rbox.left += --rtext.left) + textlen + 2;
593 IntersectRect(&rbox, &rbox, &rtext);
594 DrawFocusRect( hDC, &rbox );
599 /**********************************************************************
600 * BUTTON_CheckAutoRadioButton
602 * wndPtr is checked, uncheck every other auto radio button in group
604 static void BUTTON_CheckAutoRadioButton( WND *wndPtr )
606 HWND parent, sibling, start;
607 if (!(wndPtr->dwStyle & WS_CHILD)) return;
608 parent = wndPtr->parent->hwndSelf;
609 /* assure that starting control is not disabled or invisible */
610 start = sibling = GetNextDlgGroupItem( parent, wndPtr->hwndSelf, TRUE );
615 tmpWnd = WIN_FindWndPtr(sibling);
616 if ((wndPtr->hwndSelf != sibling) &&
617 ((tmpWnd->dwStyle & 0x0f) == BS_AUTORADIOBUTTON))
618 SendMessageA( sibling, BM_SETCHECK, BUTTON_UNCHECKED, 0 );
619 sibling = GetNextDlgGroupItem( parent, sibling, FALSE );
620 WIN_ReleaseWndPtr(tmpWnd);
621 } while (sibling != start);
625 /**********************************************************************
626 * Group Box Functions
629 static void GB_Paint( WND *wndPtr, HDC hDC, WORD action )
632 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
634 if (action != ODA_DRAWENTIRE) return;
636 BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
638 GetClientRect( wndPtr->hwndSelf, &rc);
639 if (TWEAK_WineLook == WIN31_LOOK) {
640 HPEN hPrevPen = SelectObject( hDC,
641 GetSysColorPen(COLOR_WINDOWFRAME));
642 HBRUSH hPrevBrush = SelectObject( hDC,
643 GetStockObject(NULL_BRUSH) );
645 Rectangle( hDC, rc.left, rc.top + 2, rc.right - 1, rc.bottom - 1 );
646 SelectObject( hDC, hPrevBrush );
647 SelectObject( hDC, hPrevPen );
653 SelectObject (hDC, infoPtr->hFont);
654 GetTextMetricsA (hDC, &tm);
655 rcFrame.top += (tm.tmHeight / 2) - 1;
656 DrawEdge (hDC, &rcFrame, EDGE_ETCHED, BF_RECT);
661 if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
662 if (wndPtr->dwStyle & WS_DISABLED)
663 SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) );
665 DrawTextA( hDC, wndPtr->text, -1, &rc, DT_SINGLELINE | DT_NOCLIP );
670 /**********************************************************************
671 * User Button Functions
674 static void UB_Paint( WND *wndPtr, HDC hDC, WORD action )
678 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
680 if (action == ODA_SELECT) return;
682 GetClientRect( wndPtr->hwndSelf, &rc);
684 if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
685 hBrush = GetControlBrush16( wndPtr->hwndSelf, hDC, CTLCOLOR_BTN );
687 FillRect( hDC, &rc, hBrush );
688 if ((action == ODA_FOCUS) ||
689 ((action == ODA_DRAWENTIRE) && (infoPtr->state & BUTTON_HASFOCUS)))
690 DrawFocusRect( hDC, &rc );
694 /**********************************************************************
695 * Ownerdrawn Button Functions
698 static void OB_Paint( WND *wndPtr, HDC hDC, WORD action )
700 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
703 dis.CtlType = ODT_BUTTON;
704 dis.CtlID = wndPtr->wIDmenu;
706 dis.itemAction = action;
707 dis.itemState = ((infoPtr->state & BUTTON_HASFOCUS) ? ODS_FOCUS : 0) |
708 ((infoPtr->state & BUTTON_HIGHLIGHTED) ? ODS_SELECTED : 0) |
709 ((wndPtr->dwStyle & WS_DISABLED) ? ODS_DISABLED : 0);
710 dis.hwndItem = wndPtr->hwndSelf;
713 GetClientRect( wndPtr->hwndSelf, &dis.rcItem );
714 SendMessageA( GetParent(wndPtr->hwndSelf), WM_DRAWITEM,
715 wndPtr->wIDmenu, (LPARAM)&dis );