ReactOS 0.4.17-dev-683-g0dafdc5
button.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 1993 Johannes Ruscheinski
3 * Copyright (C) 1993 David Metcalfe
4 * Copyright (C) 1994 Alexandre Julliard
5 * Copyright (C) 2008 by Reece H. Dunn
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 *
21 * TODO
22 * Styles
23 * - BS_NOTIFY: is it complete?
24 * - BS_RIGHTBUTTON: same as BS_LEFTTEXT
25 *
26 * Messages
27 * - WM_CHAR: Checks a (manual or automatic) check box on '+' or '=', clears it on '-' key.
28 * - WM_SETFOCUS: For (manual or automatic) radio buttons, send the parent window BN_CLICKED
29 * - WM_NCCREATE: Turns any BS_OWNERDRAW button into a BS_PUSHBUTTON button.
30 * - WM_SYSKEYUP
31 * - BCM_GETIDEALSIZE
32 * - BCM_GETIMAGELIST
33 * - BCM_GETTEXTMARGIN
34 * - BCM_SETIMAGELIST
35 * - BCM_SETTEXTMARGIN
36 *
37 * Notifications
38 * - BCN_HOTITEMCHANGE
39 * - BN_DISABLE
40 * - BN_PUSHED/BN_HILITE
41 * + BN_KILLFOCUS: is it OK?
42 * - BN_PAINT
43 * + BN_SETFOCUS: is it OK?
44 * - BN_UNPUSHED/BN_UNHILITE
45 * - NM_CUSTOMDRAW
46 *
47 * Structures/Macros/Definitions
48 * - BUTTON_IMAGELIST
49 * - NMBCHOTITEM
50 * - Button_GetIdealSize
51 * - Button_GetImageList
52 * - Button_GetTextMargin
53 * - Button_SetImageList
54 * - Button_SetTextMargin
55 */
56
57#include <stdarg.h>
58#include <string.h>
59#include <stdlib.h>
60
61#define OEMRESOURCE
62
63#include "windef.h"
64#include "winbase.h"
65#include "wingdi.h"
66#include "winuser.h"
67#include "uxtheme.h"
68#include "vssym32.h"
69#include "wine/debug.h"
70#include "wine/heap.h"
71
72#include "comctl32.h"
73
75
76/* undocumented flags */
77#define BUTTON_NSTATES 0x0F
78#define BUTTON_BTNPRESSED 0x40
79#define BUTTON_UNKNOWN2 0x20
80#define BUTTON_UNKNOWN3 0x10
81#ifdef __REACTOS__
82#define BUTTON_BMCLICK 0x100 // ReactOS Need to up to wine!
83#endif
84
85#define BUTTON_NOTIFY_PARENT(hWnd, code) \
86 do { /* Notify parent which has created this button control */ \
87 TRACE("notification " #code " sent to hwnd=%p\n", GetParent(hWnd)); \
88 SendMessageW(GetParent(hWnd), WM_COMMAND, \
89 MAKEWPARAM(GetWindowLongPtrW((hWnd),GWLP_ID), (code)), \
90 (LPARAM)(hWnd)); \
91 } while(0)
92
93typedef struct _BUTTON_INFO
94{
98 HFONT font;
101 union
102 {
106 } u;
107
108#ifdef __REACTOS__
109 DWORD ui_state;
110 RECT rcTextMargin;
111 BUTTON_IMAGELIST imlData;
112#endif
114
115static UINT BUTTON_CalcLabelRect( const BUTTON_INFO *infoPtr, HDC hdc, RECT *rc );
116static void PB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action );
117static void CB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action );
118static void GB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action );
119static void UB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action );
120static void OB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action );
122
123#define MAX_BTN_TYPE 16
124
126{
127 BST_UNCHECKED, /* BS_PUSHBUTTON */
128 BST_UNCHECKED, /* BS_DEFPUSHBUTTON */
129 BST_CHECKED, /* BS_CHECKBOX */
130 BST_CHECKED, /* BS_AUTOCHECKBOX */
131 BST_CHECKED, /* BS_RADIOBUTTON */
132 BST_INDETERMINATE, /* BS_3STATE */
133 BST_INDETERMINATE, /* BS_AUTO3STATE */
134 BST_UNCHECKED, /* BS_GROUPBOX */
135 BST_UNCHECKED, /* BS_USERBUTTON */
136 BST_CHECKED, /* BS_AUTORADIOBUTTON */
137 BST_UNCHECKED, /* BS_PUSHBOX */
138 BST_UNCHECKED, /* BS_OWNERDRAW */
139 BST_UNCHECKED, /* BS_SPLITBUTTON */
140 BST_UNCHECKED, /* BS_DEFSPLITBUTTON */
141 BST_UNCHECKED, /* BS_COMMANDLINK */
142 BST_UNCHECKED /* BS_DEFCOMMANDLINK */
143};
144
145/* These are indices into a states array to determine the theme state for a given theme part. */
146typedef enum
147{
154
155typedef void (*pfPaint)( const BUTTON_INFO *infoPtr, HDC hdc, UINT action );
156
158{
159 PB_Paint, /* BS_PUSHBUTTON */
160 PB_Paint, /* BS_DEFPUSHBUTTON */
161 CB_Paint, /* BS_CHECKBOX */
162 CB_Paint, /* BS_AUTOCHECKBOX */
163 CB_Paint, /* BS_RADIOBUTTON */
164 CB_Paint, /* BS_3STATE */
165 CB_Paint, /* BS_AUTO3STATE */
166 GB_Paint, /* BS_GROUPBOX */
167 UB_Paint, /* BS_USERBUTTON */
168 CB_Paint, /* BS_AUTORADIOBUTTON */
169 NULL, /* BS_PUSHBOX */
170 OB_Paint, /* BS_OWNERDRAW */
171 PB_Paint, /* BS_SPLITBUTTON */
172 PB_Paint, /* BS_DEFSPLITBUTTON */
173 PB_Paint, /* BS_COMMANDLINK */
174 PB_Paint /* BS_DEFCOMMANDLINK */
175};
176
177
178#ifdef __REACTOS__ /* r73885 */
179typedef void (*pfThemedPaint)( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused, LPARAM prfFlag);
180
181static void PB_ThemedPaint( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused, LPARAM prfFlag);
182static void CB_ThemedPaint( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused, LPARAM prfFlag);
183static void GB_ThemedPaint( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused, LPARAM prfFlag);
184
185#else
186typedef void (*pfThemedPaint)( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused);
187
188static void PB_ThemedPaint( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused);
189static void CB_ThemedPaint( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused);
190static void GB_ThemedPaint( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused);
191
192#endif
193
195{
196 PB_ThemedPaint, /* BS_PUSHBUTTON */
197 PB_ThemedPaint, /* BS_DEFPUSHBUTTON */
198 CB_ThemedPaint, /* BS_CHECKBOX */
199 CB_ThemedPaint, /* BS_AUTOCHECKBOX */
200 CB_ThemedPaint, /* BS_RADIOBUTTON */
201 CB_ThemedPaint, /* BS_3STATE */
202 CB_ThemedPaint, /* BS_AUTO3STATE */
203 GB_ThemedPaint, /* BS_GROUPBOX */
204 NULL, /* BS_USERBUTTON */
205 CB_ThemedPaint, /* BS_AUTORADIOBUTTON */
206 NULL, /* BS_PUSHBOX */
207 NULL, /* BS_OWNERDRAW */
208 NULL, /* BS_SPLITBUTTON */
209 NULL, /* BS_DEFSPLITBUTTON */
210 NULL, /* BS_COMMANDLINK */
211 NULL, /* BS_DEFCOMMANDLINK */
212};
213
214static inline UINT get_button_type( LONG window_style )
215{
216 return (window_style & BS_TYPEMASK);
217}
218
219#ifndef __REACTOS__
220/* paint a button of any type */
221static inline void paint_button( BUTTON_INFO *infoPtr, LONG style, UINT action )
222{
223 if (btnPaintFunc[style] && IsWindowVisible(infoPtr->hwnd))
224 {
225 HDC hdc = GetDC( infoPtr->hwnd );
226 btnPaintFunc[style]( infoPtr, hdc, action );
227 ReleaseDC( infoPtr->hwnd, hdc );
228 }
229}
230#endif
231
232/* retrieve the button text; returned buffer must be freed by caller */
233static inline WCHAR *get_button_text( const BUTTON_INFO *infoPtr )
234{
235 INT len = GetWindowTextLengthW( infoPtr->hwnd );
236 WCHAR *buffer = heap_alloc( (len + 1) * sizeof(WCHAR) );
237 if (buffer)
238 GetWindowTextW( infoPtr->hwnd, buffer, len + 1 );
239 return buffer;
240}
241
243{
244 RECT rc = *rect;
245 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
246
247 if (GetClipRgn( hdc, hrgn ) != 1)
248 {
250 hrgn = 0;
251 }
252 DPtoLP( hdc, (POINT *)&rc, 2 );
253 if (GetLayout( hdc ) & LAYOUT_RTL) /* compensate for the shifting done by IntersectClipRect */
254 {
255 rc.left++;
256 rc.right++;
257 }
258 IntersectClipRect( hdc, rc.left, rc.top, rc.right, rc.bottom );
259 return hrgn;
260}
261
262static WCHAR *heap_strndupW(const WCHAR *src, size_t length)
263{
264 size_t size = (length + 1) * sizeof(WCHAR);
266 if (dst) memcpy(dst, src, size);
267 return dst;
268}
269
270/**********************************************************************
271 * Convert button styles to flags used by DrawText.
272 */
273static UINT BUTTON_BStoDT( DWORD style, DWORD ex_style )
274{
275 UINT dtStyle = DT_NOCLIP; /* We use SelectClipRgn to limit output */
276
277 /* "Convert" pushlike buttons to pushbuttons */
278 if (style & BS_PUSHLIKE)
279 style &= ~BS_TYPEMASK;
280
281 if (!(style & BS_MULTILINE))
282 dtStyle |= DT_SINGLELINE;
283 else
284 dtStyle |= DT_WORDBREAK;
285
286 switch (style & BS_CENTER)
287 {
288 case BS_LEFT: /* DT_LEFT is 0 */ break;
289 case BS_RIGHT: dtStyle |= DT_RIGHT; break;
290 case BS_CENTER: dtStyle |= DT_CENTER; break;
291 default:
292 /* Pushbutton's text is centered by default */
294 /* all other flavours have left aligned text */
295 }
296
297 if (ex_style & WS_EX_RIGHT) dtStyle = DT_RIGHT | (dtStyle & ~(DT_LEFT | DT_CENTER));
298
299 /* DrawText ignores vertical alignment for multiline text,
300 * but we use these flags to align label manually.
301 */
303 {
304 switch (style & BS_VCENTER)
305 {
306 case BS_TOP: /* DT_TOP is 0 */ break;
307 case BS_BOTTOM: dtStyle |= DT_BOTTOM; break;
308 case BS_VCENTER: /* fall through */
309 default: dtStyle |= DT_VCENTER; break;
310 }
311 }
312 else
313 /* GroupBox's text is always single line and is top aligned. */
314 dtStyle |= DT_SINGLELINE;
315
316 return dtStyle;
317}
318
319
320#ifdef __REACTOS__
321BOOL BUTTON_PaintWithTheme(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hParamDC, LPARAM prfFlag)
322{
323 DWORD dwStyle;
324 DWORD dwStyleEx;
325 DWORD type;
326 UINT dtFlags;
327 ButtonState drawState;
328 pfThemedPaint paint;
329
330 /* Don't draw with themes on a button with BS_ICON or BS_BITMAP */
331 if (infoPtr->u.image != 0)
332 return FALSE;
333
334 /* If the button isn't visible, don't paint it (themed or not) */
335 if (!IsWindowVisible(infoPtr->hwnd))
336 return TRUE; /* Pretend it has been drawn successfully */
337
338 dwStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
339 type = get_button_type(dwStyle);
340
341 if (type != BS_PUSHBUTTON && type != BS_DEFPUSHBUTTON && (dwStyle & BS_PUSHLIKE))
343
344 paint = btnThemedPaintFunc[type];
345 if (!paint)
346 return FALSE;
347
348 dwStyleEx = GetWindowLongW(infoPtr->hwnd, GWL_EXSTYLE);
349 dtFlags = BUTTON_BStoDT(dwStyle, dwStyleEx);
350
351 if(dwStyle & WS_DISABLED)
352 drawState = STATE_DISABLED;
353 else if(infoPtr->state & BST_PUSHED)
354 drawState = STATE_PRESSED;
355 else if ((dwStyle & BS_PUSHLIKE) && (infoPtr->state & (BST_CHECKED|BST_INDETERMINATE)))
356 drawState = STATE_PRESSED;
357 else if(infoPtr->state & BST_HOT)
358 drawState = STATE_HOT;
359 else if((infoPtr->state & BST_FOCUS) || (dwStyle & BS_DEFPUSHBUTTON))
360 drawState = STATE_DEFAULTED;
361 else
362 drawState = STATE_NORMAL;
363
364 if (paint == PB_ThemedPaint || paint == CB_ThemedPaint)
365 {
366 HDC hdc;
368 RECT rc;
369
370 GetClientRect(infoPtr->hwnd, &rc);
371 hdc = CreateCompatibleDC(hParamDC);
372 hbmp = CreateCompatibleBitmap(hParamDC, rc.right, rc.bottom);
373 if (hdc && hbmp)
374 {
376
377 paint(theme, infoPtr, hdc, drawState, dtFlags, infoPtr->state & BST_FOCUS, prfFlag);
378
379 BitBlt(hParamDC, 0, 0, rc.right, rc.bottom, hdc, 0, 0, SRCCOPY);
381 DeleteDC(hdc);
382 return TRUE;
383 }
384 else
385 {
386 ERR("Failed to create DC and bitmap for double buffering\n");
387 if (hbmp)
389 if (hdc)
390 DeleteDC(hdc);
391 }
392 }
393
394 paint(theme, infoPtr, hParamDC, drawState, dtFlags, infoPtr->state & BST_FOCUS, prfFlag);
395 return TRUE;
396}
397
398/* paint a button of any type */
399static inline void paint_button( BUTTON_INFO *infoPtr, LONG style, UINT action )
400{
401 HTHEME theme = GetWindowTheme(infoPtr->hwnd);
402 RECT rc;
403 HDC hdc = GetDC( infoPtr->hwnd );
404 /* GetDC appears to give a dc with a clip rect that includes the whoe parent, not sure if it is correct or not. */
405 GetClientRect(infoPtr->hwnd, &rc);
406 IntersectClipRect (hdc, rc.left, rc. top, rc.right, rc.bottom);
407 if (theme && BUTTON_PaintWithTheme(theme, infoPtr, hdc, 0))
408 {
409 ReleaseDC( infoPtr->hwnd, hdc );
410 return;
411 }
412 if (btnPaintFunc[style] && IsWindowVisible(infoPtr->hwnd))
413 {
414 btnPaintFunc[style]( infoPtr, hdc, action );
415 }
416 ReleaseDC( infoPtr->hwnd, hdc );
417}
418
419BOOL BUTTON_GetIdealSize(BUTTON_INFO *infoPtr, HTHEME theme, SIZE* psize)
420{
421 HDC hdc;
422 WCHAR *text;
423 HFONT hFont = 0, hPrevFont = 0;
424 SIZE TextSize, ImageSize, ButtonSize;
425 BOOL ret = FALSE;
426 LOGFONTW logfont = {0};
427
428 text = get_button_text(infoPtr);
429 hdc = GetDC(infoPtr->hwnd);
430 if (!text || !hdc || !text[0])
431 goto cleanup;
432
433 /* FIXME : Should use GetThemeTextExtent but unfortunately uses DrawTextW which is broken */
434 if (theme)
435 {
437 if(SUCCEEDED(hr))
438 {
439 hFont = CreateFontIndirectW(&logfont);
440 if(hFont)
441 hPrevFont = SelectObject( hdc, hFont );
442 }
443 }
444 else
445 {
446 if (infoPtr->font)
447 hPrevFont = SelectObject( hdc, infoPtr->font );
448 }
449
451
452 if (logfont.lfHeight == -1 && logfont.lfWidth == 0 && wcscmp(logfont.lfFaceName, L"Arial") == 0 && wcsicmp(text, L"Start") == 0)
453 {
454 TextSize.cx = 5;
455 TextSize.cy = 4;
456 }
457
458 if (hPrevFont)
459 SelectObject( hdc, hPrevFont );
460
461 TextSize.cy += infoPtr->rcTextMargin.top + infoPtr->rcTextMargin.bottom;
462 TextSize.cx += infoPtr->rcTextMargin.left + infoPtr->rcTextMargin.right;
463
464 if (infoPtr->imlData.himl && ImageList_GetIconSize(infoPtr->imlData.himl, &ImageSize.cx, &ImageSize.cy))
465 {
466 ImageSize.cx += infoPtr->imlData.margin.left + infoPtr->imlData.margin.right;
467 ImageSize.cy += infoPtr->imlData.margin.top + infoPtr->imlData.margin.bottom;
468 }
469 else
470 {
471 ImageSize.cx = ImageSize.cy = 0;
472 }
473
474 if (theme)
475 {
476 RECT rcContents = {0};
477 RECT rcButtonExtent = {0};
478 rcContents.right = ImageSize.cx + TextSize.cx;
479 rcContents.bottom = max(ImageSize.cy, TextSize.cy);
480 GetThemeBackgroundExtent(theme, hdc, BP_PUSHBUTTON, PBS_NORMAL, &rcContents, &rcButtonExtent);
481 ButtonSize.cx = rcButtonExtent.right - rcButtonExtent.left;
482 ButtonSize.cy = rcButtonExtent.bottom - rcButtonExtent.top;
483 }
484 else
485 {
486 ButtonSize.cx = ImageSize.cx + TextSize.cx + 5;
487 ButtonSize.cy = max(ImageSize.cy, TextSize.cy + 7);
488 }
489
490 *psize = ButtonSize;
491 ret = TRUE;
492
493cleanup:
494 if (hFont)
496 if (text)
498 if (hdc)
499 ReleaseDC(infoPtr->hwnd, hdc);
500
501 return ret;
502}
503
504BOOL BUTTON_DrawIml(HDC hDC, const BUTTON_IMAGELIST *pimlData, RECT *prc, BOOL bOnlyCalc, int index)
505{
506 SIZE ImageSize;
507 int left, top, count;
508
509 if (!pimlData->himl)
510 return FALSE;
511
512 if (!ImageList_GetIconSize(pimlData->himl, &ImageSize.cx, &ImageSize.cy))
513 return FALSE;
514
515 if (pimlData->uAlign == BUTTON_IMAGELIST_ALIGN_LEFT)
516 {
517 left = prc->left + pimlData->margin.left;
518 top = prc->top + (prc->bottom - prc->top - ImageSize.cy) / 2;
519 prc->left = left + pimlData->margin.right + ImageSize.cx;
520 }
521 else if (pimlData->uAlign == BUTTON_IMAGELIST_ALIGN_RIGHT)
522 {
523 left = prc->right - pimlData->margin.right - ImageSize.cx;
524 top = prc->top + (prc->bottom - prc->top - ImageSize.cy) / 2;
525 prc->right = left - pimlData->margin.left;
526 }
527 else if (pimlData->uAlign == BUTTON_IMAGELIST_ALIGN_TOP)
528 {
529 left = prc->left + (prc->right - prc->left - ImageSize.cx) / 2;
530 top = prc->top + pimlData->margin.top;
531 prc->top = top + ImageSize.cy + pimlData->margin.bottom;
532 }
533 else if (pimlData->uAlign == BUTTON_IMAGELIST_ALIGN_BOTTOM)
534 {
535 left = prc->left + (prc->right - prc->left - ImageSize.cx) / 2;
536 top = prc->bottom - pimlData->margin.bottom - ImageSize.cy;
537 prc->bottom = top - pimlData->margin.top;
538 }
539 else if (pimlData->uAlign == BUTTON_IMAGELIST_ALIGN_CENTER)
540 {
541 left = prc->left + (prc->right - prc->left - ImageSize.cx) / 2;
542 top = prc->top + (prc->bottom - prc->top - ImageSize.cy) / 2;
543 }
544
545 if (bOnlyCalc)
546 return TRUE;
547
549
550 if (count == 1)
551 index = 0;
552 else if (index >= count)
553 return TRUE;
554
555 ImageList_Draw(pimlData->himl, index, hDC, left, top, 0);
556
557 return TRUE;
558}
559
560DWORD BUTTON_SendCustomDraw(const BUTTON_INFO *infoPtr, HDC hDC, DWORD dwDrawStage, RECT* prc)
561{
562 NMCUSTOMDRAW nmcs;
563
564 nmcs.hdr.hwndFrom = infoPtr->hwnd;
565 nmcs.hdr.idFrom = GetWindowLongPtrW (infoPtr->hwnd, GWLP_ID);
566 nmcs.hdr.code = NM_CUSTOMDRAW ;
567 nmcs.dwDrawStage = dwDrawStage;
568 nmcs.hdc = hDC;
569 nmcs.rc = *prc;
570 nmcs.dwItemSpec = 0;
571 nmcs.uItemState = 0;
572 nmcs.lItemlParam = 0;
573 if(!IsWindowEnabled(infoPtr->hwnd))
575 if (infoPtr->state & (BST_CHECKED | BST_INDETERMINATE))
576 nmcs.uItemState |= CDIS_CHECKED;
577 if (infoPtr->state & BST_FOCUS)
578 nmcs.uItemState |= CDIS_FOCUS;
579 if (infoPtr->state & BST_PUSHED)
581 if (!(infoPtr->ui_state & UISF_HIDEACCEL))
583
584 return SendMessageW(GetParent(infoPtr->hwnd), WM_NOTIFY, nmcs.hdr.idFrom, (LPARAM)&nmcs);
585}
586
587/* Retrieve the UI state for the control */
588static BOOL button_update_uistate(BUTTON_INFO *infoPtr)
589{
590 LONG flags = DefWindowProcW(infoPtr->hwnd, WM_QUERYUISTATE, 0, 0);
591
592 if (infoPtr->ui_state != flags)
593 {
594 infoPtr->ui_state = flags;
595 return TRUE;
596 }
597
598 return FALSE;
599}
600#endif
601
603{
605 RECT rect;
606 POINT pt;
608 UINT btn_type = get_button_type( style );
609 LONG state, new_state;
610 HANDLE oldHbitmap;
611 HTHEME theme;
612
613 if (!IsWindow( hWnd )) return 0;
614
615 if (!infoPtr && (uMsg != WM_NCCREATE))
616 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
617
618 pt.x = (short)LOWORD(lParam);
619 pt.y = (short)HIWORD(lParam);
620
621 switch (uMsg)
622 {
623 case WM_GETDLGCODE:
624 switch(btn_type)
625 {
626 case BS_COMMANDLINK:
627 case BS_USERBUTTON:
631 case BS_RADIOBUTTON:
633 case BS_GROUPBOX: return DLGC_STATIC;
636 default: return DLGC_BUTTON;
637 }
638
639 case WM_ENABLE:
640#ifndef __REACTOS__
641 theme = GetWindowTheme( hWnd );
642 if (theme)
644 else
645#endif
646 paint_button( infoPtr, btn_type, ODA_DRAWENTIRE );
647 break;
648
649 case WM_NCCREATE:
650 infoPtr = heap_alloc_zero( sizeof(*infoPtr) );
651 SetWindowLongPtrW( hWnd, 0, (LONG_PTR)infoPtr );
652 infoPtr->hwnd = hWnd;
653#ifdef __REACTOS__
654 SetRect(&infoPtr->rcTextMargin, 1,1,1,1);
655#endif
656 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
657
658 case WM_NCDESTROY:
659 SetWindowLongPtrW( hWnd, 0, 0 );
660 heap_free(infoPtr->note);
661 heap_free(infoPtr);
662 break;
663
664 case WM_CREATE:
665 if (btn_type >= MAX_BTN_TYPE)
666 return -1; /* abort */
667
668 /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
669 if (btn_type == BS_USERBUTTON )
670 {
671 style = (style & ~BS_TYPEMASK) | BS_PUSHBUTTON;
673 }
674 infoPtr->state = BST_UNCHECKED;
676 return 0;
677
678 case WM_DESTROY:
679 theme = GetWindowTheme( hWnd );
680 CloseThemeData( theme );
681 break;
682
683 case WM_THEMECHANGED:
684 theme = GetWindowTheme( hWnd );
685 CloseThemeData( theme );
687#ifdef __REACTOS__
689#endif
690 break;
691
692 case WM_ERASEBKGND:
693 if (btn_type == BS_OWNERDRAW)
694 {
695 HDC hdc = (HDC)wParam;
696 RECT rc;
697 HBRUSH hBrush;
699 if (!parent) parent = hWnd;
700 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hdc, (LPARAM)hWnd);
701 if (!hBrush) /* did the app forget to call defwindowproc ? */
702 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN,
703 (WPARAM)hdc, (LPARAM)hWnd);
704 GetClientRect(hWnd, &rc);
705 FillRect(hdc, &rc, hBrush);
706 }
707 return 1;
708
709 case WM_PRINTCLIENT:
710 case WM_PAINT:
711 {
712 PAINTSTRUCT ps;
713 HDC hdc;
714
715 theme = GetWindowTheme( hWnd );
716 hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps );
717
718#ifdef __REACTOS__
719 if (theme && BUTTON_PaintWithTheme(theme, infoPtr, hdc, uMsg == WM_PRINTCLIENT ? lParam : 0))
720 {
721 if ( !wParam ) EndPaint( hWnd, &ps );
722 return 0;
723 }
724#else
725 if (theme && btnThemedPaintFunc[btn_type])
726 {
727 ButtonState drawState;
728 UINT dtflags;
729
730 if (IsWindowEnabled( hWnd ))
731 {
732 if (infoPtr->state & BST_PUSHED) drawState = STATE_PRESSED;
733 else if (infoPtr->state & BST_HOT) drawState = STATE_HOT;
734 else if (infoPtr->state & BST_FOCUS) drawState = STATE_DEFAULTED;
735 else drawState = STATE_NORMAL;
736 }
737 else
738 drawState = STATE_DISABLED;
739
741 btnThemedPaintFunc[btn_type](theme, infoPtr, hdc, drawState, dtflags, infoPtr->state & BST_FOCUS);
742 }
743#endif
744 else if (btnPaintFunc[btn_type])
745 {
746 int nOldMode = SetBkMode( hdc, OPAQUE );
747 btnPaintFunc[btn_type]( infoPtr, hdc, ODA_DRAWENTIRE );
748 SetBkMode(hdc, nOldMode); /* reset painting mode */
749 }
750
751 if ( !wParam ) EndPaint( hWnd, &ps );
752 break;
753 }
754
755 case WM_KEYDOWN:
756 if (wParam == VK_SPACE)
757 {
759 infoPtr->state |= BUTTON_BTNPRESSED;
760 SetCapture( hWnd );
761 }
762 break;
763
764 case WM_LBUTTONDBLCLK:
765 if(style & BS_NOTIFY ||
766 btn_type == BS_RADIOBUTTON ||
767 btn_type == BS_USERBUTTON ||
768 btn_type == BS_OWNERDRAW)
769 {
771 break;
772 }
773 /* fall through */
774 case WM_LBUTTONDOWN:
775 SetCapture( hWnd );
776 SetFocus( hWnd );
777 infoPtr->state |= BUTTON_BTNPRESSED;
779 break;
780
781 case WM_KEYUP:
782 if (wParam != VK_SPACE)
783 break;
784 /* fall through */
785 case WM_LBUTTONUP:
786 state = infoPtr->state;
787 if (!(state & BUTTON_BTNPRESSED)) break;
788 infoPtr->state &= BUTTON_NSTATES;
789 if (!(state & BST_PUSHED))
790 {
792 break;
793 }
796 if (uMsg == WM_KEYUP || PtInRect( &rect, pt ))
797 {
798 switch(btn_type)
799 {
800 case BS_AUTOCHECKBOX:
801 SendMessageW( hWnd, BM_SETCHECK, !(infoPtr->state & BST_CHECKED), 0 );
802 break;
804#ifdef __REACTOS__
806#else
808#endif
809 break;
810 case BS_AUTO3STATE:
811 SendMessageW( hWnd, BM_SETCHECK, (infoPtr->state & BST_INDETERMINATE) ? 0 :
812 ((infoPtr->state & 3) + 1), 0 );
813 break;
814 }
815#ifdef __REACTOS__
816 // Fix CORE-10194, Notify parent after capture is released.
819#else
822#endif
823 }
824 else
825 {
827 }
828
829 break;
830
832 TRACE("WM_CAPTURECHANGED %p\n", hWnd);
833 if (hWnd == (HWND)lParam) break;
834 if (infoPtr->state & BUTTON_BTNPRESSED)
835 {
836 infoPtr->state &= BUTTON_NSTATES;
837 if (infoPtr->state & BST_PUSHED)
839 }
840 break;
841
842 case WM_MOUSEMOVE:
843 {
845 mouse_event.cbSize = sizeof(TRACKMOUSEEVENT);
846 mouse_event.dwFlags = TME_QUERY;
847
848#ifdef __REACTOS__
849 if ((infoPtr->state & BST_HOT) == 0)
850 {
851 NMBCHOTITEM nmhotitem;
852
853 infoPtr->state |= BST_HOT;
854
855 nmhotitem.hdr.hwndFrom = hWnd;
856 nmhotitem.hdr.idFrom = GetWindowLongPtrW (hWnd, GWLP_ID);
857 nmhotitem.hdr.code = BCN_HOTITEMCHANGE;
858 nmhotitem.dwFlags = HICF_ENTERING;
859 SendMessageW(GetParent(hWnd), WM_NOTIFY, nmhotitem.hdr.idFrom, (LPARAM)&nmhotitem);
860
861 theme = GetWindowTheme( hWnd );
862 if (theme)
864 }
865
867 {
868 mouse_event.dwFlags = TME_LEAVE;
869 mouse_event.hwndTrack = hWnd;
870 mouse_event.dwHoverTime = 1;
872 }
873#else
874
875 if (!TrackMouseEvent(&mouse_event) || !(mouse_event.dwFlags & (TME_HOVER | TME_LEAVE)))
876 {
877 mouse_event.dwFlags = TME_HOVER | TME_LEAVE;
878 mouse_event.hwndTrack = hWnd;
879 mouse_event.dwHoverTime = 1;
881 }
882#endif
883
884 if ((wParam & MK_LBUTTON) && GetCapture() == hWnd)
885 {
888 }
889 break;
890 }
891
892#ifndef __REACTOS__
893 case WM_MOUSEHOVER:
894 {
895 infoPtr->state |= BST_HOT;
897 break;
898 }
899#endif
900
901 case WM_MOUSELEAVE:
902 {
903#ifdef __REACTOS__
904 if (infoPtr->state & BST_HOT)
905 {
906 NMBCHOTITEM nmhotitem;
907
908 infoPtr->state &= ~BST_HOT;
909
910 nmhotitem.hdr.hwndFrom = hWnd;
911 nmhotitem.hdr.idFrom = GetWindowLongPtrW (hWnd, GWLP_ID);
912 nmhotitem.hdr.code = BCN_HOTITEMCHANGE;
913 nmhotitem.dwFlags = HICF_LEAVING;
914 SendMessageW(GetParent(hWnd), WM_NOTIFY, nmhotitem.hdr.idFrom, (LPARAM)&nmhotitem);
915
916 theme = GetWindowTheme( hWnd );
917 if (theme)
919 }
920 break;
921#else
922 infoPtr->state &= ~BST_HOT;
924 break;
925#endif
926 }
927
928#ifdef __REACTOS__
930 {
931 RECT* prc = (RECT*)lParam;
932 if (!prc)
933 return FALSE;
934 *prc = infoPtr->rcTextMargin;
935 return TRUE;
936 }
938 {
939 RECT* prc = (RECT*)lParam;
940 if (!prc)
941 return FALSE;
942 infoPtr->rcTextMargin = *prc;
943 return TRUE;
944 }
945 case BCM_SETIMAGELIST:
946 {
948 if (!pimldata || !pimldata->himl)
949 return FALSE;
950 infoPtr->imlData = *pimldata;
951 return TRUE;
952 }
953 case BCM_GETIMAGELIST:
954 {
956 if (!pimldata)
957 return FALSE;
958 *pimldata = infoPtr->imlData;
959 return TRUE;
960 }
961 case BCM_GETIDEALSIZE:
962 {
963 HTHEME theme = GetWindowTheme(hWnd);
964 BOOL ret = FALSE;
965 SIZE* pSize = (SIZE*)lParam;
966
967 if (!pSize)
968 {
969 return FALSE;
970 }
971
972 if (btn_type == BS_PUSHBUTTON ||
973 btn_type == BS_DEFPUSHBUTTON ||
974 btn_type == BS_USERBUTTON)
975 {
976 ret = BUTTON_GetIdealSize(infoPtr, theme, pSize);
977 }
978
979 if (!ret)
980 {
982 pSize->cx = rect.right;
983 pSize->cy = rect.bottom;
984 }
985
986 return TRUE;
987 }
988#endif
989
990 case WM_SETTEXT:
991 {
992 /* Clear an old text here as Windows does */
993#ifdef __REACTOS__
994//
995// ReactOS Note :
996// wine Bug: http://bugs.winehq.org/show_bug.cgi?id=25790
997// Patch: http://source.winehq.org/patches/data/70889
998// By: Alexander LAW, Replicate Windows behavior of WM_SETTEXT handler regarding WM_CTLCOLOR*
999//
1000 if (style & WS_VISIBLE)
1001#else
1002 if (IsWindowVisible(hWnd))
1003#endif
1004 {
1005 HDC hdc = GetDC(hWnd);
1006 HBRUSH hbrush;
1007 RECT client, rc;
1009 UINT message = (btn_type == BS_PUSHBUTTON ||
1010 btn_type == BS_DEFPUSHBUTTON ||
1011 btn_type == BS_USERBUTTON ||
1012 btn_type == BS_OWNERDRAW) ?
1014
1015 if (!parent) parent = hWnd;
1016 hbrush = (HBRUSH)SendMessageW(parent, message,
1017 (WPARAM)hdc, (LPARAM)hWnd);
1018 if (!hbrush) /* did the app forget to call DefWindowProc ? */
1020 (WPARAM)hdc, (LPARAM)hWnd);
1021
1023 rc = client;
1024 /* FIXME: check other BS_* handlers */
1025 if (btn_type == BS_GROUPBOX)
1026 InflateRect(&rc, -7, 1); /* GB_Paint does this */
1027 BUTTON_CalcLabelRect(infoPtr, hdc, &rc);
1028 /* Clip by client rect bounds */
1029 if (rc.right > client.right) rc.right = client.right;
1030 if (rc.bottom > client.bottom) rc.bottom = client.bottom;
1031 FillRect(hdc, &rc, hbrush);
1032 ReleaseDC(hWnd, hdc);
1033 }
1034
1036 if (btn_type == BS_GROUPBOX) /* Yes, only for BS_GROUPBOX */
1038 else
1039 paint_button( infoPtr, btn_type, ODA_DRAWENTIRE );
1040 return 1; /* success. FIXME: check text length */
1041 }
1042
1043 case BCM_SETNOTE:
1044 {
1045 WCHAR *note = (WCHAR *)lParam;
1046 if (btn_type != BS_COMMANDLINK && btn_type != BS_DEFCOMMANDLINK)
1047 {
1049 return FALSE;
1050 }
1051
1052 heap_free(infoPtr->note);
1053 if (note)
1054 {
1055 infoPtr->note_length = lstrlenW(note);
1056 infoPtr->note = heap_strndupW(note, infoPtr->note_length);
1057 }
1058
1059 if (!note || !infoPtr->note)
1060 {
1061 infoPtr->note_length = 0;
1062 infoPtr->note = heap_alloc_zero(sizeof(WCHAR));
1063 }
1064
1066 return TRUE;
1067 }
1068
1069 case BCM_GETNOTE:
1070 {
1071 DWORD *size = (DWORD *)wParam;
1072 WCHAR *buffer = (WCHAR *)lParam;
1073 INT length = 0;
1074
1075 if (btn_type != BS_COMMANDLINK && btn_type != BS_DEFCOMMANDLINK)
1076 {
1078 return FALSE;
1079 }
1080
1081 if (!buffer || !size || !infoPtr->note)
1082 {
1084 return FALSE;
1085 }
1086
1087 if (*size > 0)
1088 {
1089 length = min(*size - 1, infoPtr->note_length);
1090 memcpy(buffer, infoPtr->note, length * sizeof(WCHAR));
1091 buffer[length] = '\0';
1092 }
1093
1094 if (*size < infoPtr->note_length + 1)
1095 {
1096 *size = infoPtr->note_length + 1;
1098 return FALSE;
1099 }
1100 else
1101 {
1103 return TRUE;
1104 }
1105 }
1106
1107 case BCM_GETNOTELENGTH:
1108 {
1109 if (btn_type != BS_COMMANDLINK && btn_type != BS_DEFCOMMANDLINK)
1110 {
1112 return 0;
1113 }
1114
1115 return infoPtr->note_length;
1116 }
1117
1118 case WM_SETFONT:
1119 infoPtr->font = (HFONT)wParam;
1121 break;
1122
1123 case WM_GETFONT:
1124 return (LRESULT)infoPtr->font;
1125
1126 case WM_SETFOCUS:
1127 TRACE("WM_SETFOCUS %p\n",hWnd);
1128 infoPtr->state |= BST_FOCUS;
1129#ifdef __REACTOS__
1130 if (btn_type != BS_OWNERDRAW)
1132 else
1133#endif
1134 paint_button( infoPtr, btn_type, ODA_FOCUS );
1135 if (style & BS_NOTIFY)
1137#ifdef __REACTOS__
1138 if (((btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON)) &&
1139 !(infoPtr->state & BST_CHECKED))
1140 {
1142 }
1143#endif
1144 break;
1145
1146 case WM_KILLFOCUS:
1147 TRACE("WM_KILLFOCUS %p\n",hWnd);
1148 infoPtr->state &= ~BST_FOCUS;
1149#ifndef __REACTOS__
1150 paint_button( infoPtr, btn_type, ODA_FOCUS );
1151#endif
1152
1153 if ((infoPtr->state & BUTTON_BTNPRESSED) && GetCapture() == hWnd)
1155 if (style & BS_NOTIFY)
1157
1159 break;
1160
1161 case WM_SYSCOLORCHANGE:
1163 break;
1164
1165 case BM_SETSTYLE:
1166 btn_type = wParam & BS_TYPEMASK;
1167 style = (style & ~BS_TYPEMASK) | btn_type;
1169
1170 /* Only redraw if lParam flag is set.*/
1171 if (lParam)
1173
1174 break;
1175
1176 case BM_CLICK:
1177#ifdef __REACTOS__
1178 /* Fix for core CORE-6024 */
1179 if (infoPtr->state & BUTTON_BMCLICK)
1180 break;
1181 infoPtr->state |= BUTTON_BMCLICK;
1182#endif
1184 SendMessageW( hWnd, WM_LBUTTONUP, 0, 0 );
1185#ifdef __REACTOS__
1186 infoPtr->state &= ~BUTTON_BMCLICK;
1187#endif
1188 break;
1189
1190 case BM_SETIMAGE:
1191 /* Check that image format matches button style */
1192 switch (style & (BS_BITMAP|BS_ICON))
1193 {
1194 case BS_BITMAP:
1195 if (wParam != IMAGE_BITMAP) return 0;
1196 break;
1197 case BS_ICON:
1198 if (wParam != IMAGE_ICON) return 0;
1199 break;
1200 default:
1201 return 0;
1202 }
1203 oldHbitmap = infoPtr->u.image;
1204 infoPtr->u.image = (HANDLE)lParam;
1206 return (LRESULT)oldHbitmap;
1207
1208 case BM_GETIMAGE:
1209 return (LRESULT)infoPtr->u.image;
1210
1211 case BM_GETCHECK:
1212 return infoPtr->state & 3;
1213
1214 case BM_SETCHECK:
1215 if (wParam > maxCheckState[btn_type]) wParam = maxCheckState[btn_type];
1216 if ((btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON))
1217 {
1218 style = wParam ? style | WS_TABSTOP : style & ~WS_TABSTOP;
1220 }
1221 if ((infoPtr->state & 3) != wParam)
1222 {
1223 infoPtr->state = (infoPtr->state & ~3) | wParam;
1225 }
1226#ifndef __REACTOS__
1227 if ((btn_type == BS_AUTORADIOBUTTON) && (wParam == BST_CHECKED) && (style & WS_CHILD))
1229#endif
1230 break;
1231
1232 case BM_GETSTATE:
1233 return infoPtr->state;
1234
1235 case BM_SETSTATE:
1236 state = infoPtr->state;
1237 new_state = wParam ? BST_PUSHED : 0;
1238
1239 if ((state ^ new_state) & BST_PUSHED)
1240 {
1241 if (wParam)
1242 state |= BST_PUSHED;
1243 else
1244 state &= ~BST_PUSHED;
1245
1246 if (btn_type == BS_USERBUTTON)
1248 infoPtr->state = state;
1249
1251 }
1252 break;
1253
1254#ifdef __REACTOS__
1255 case WM_UPDATEUISTATE:
1257
1258 if (button_update_uistate(infoPtr))
1259 paint_button( infoPtr, btn_type, ODA_DRAWENTIRE );
1260 break;
1261#endif
1262
1263 case WM_NCHITTEST:
1264 if(btn_type == BS_GROUPBOX) return HTTRANSPARENT;
1265 /* fall through */
1266 default:
1267 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
1268 }
1269 return 0;
1270}
1271
1272/**********************************************************************
1273 * BUTTON_CalcLabelRect
1274 *
1275 * Calculates label's rectangle depending on button style.
1276 *
1277 * Returns flags to be passed to DrawText.
1278 * Calculated rectangle doesn't take into account button state
1279 * (pushed, etc.). If there is nothing to draw (no text/image) output
1280 * rectangle is empty, and return value is (UINT)-1.
1281 */
1282static UINT BUTTON_CalcLabelRect(const BUTTON_INFO *infoPtr, HDC hdc, RECT *rc)
1283{
1284 LONG style = GetWindowLongW( infoPtr->hwnd, GWL_STYLE );
1285 LONG ex_style = GetWindowLongW( infoPtr->hwnd, GWL_EXSTYLE );
1286 WCHAR *text;
1287 ICONINFO iconInfo;
1288 BITMAP bm;
1289 UINT dtStyle = BUTTON_BStoDT( style, ex_style );
1290 RECT r = *rc;
1291 INT n;
1292#ifdef __REACTOS__
1293 BOOL bHasIml = BUTTON_DrawIml(hdc, &infoPtr->imlData, &r, TRUE, 0);
1294#endif
1295
1296 /* Calculate label rectangle according to label type */
1297 switch (style & (BS_ICON|BS_BITMAP))
1298 {
1299 case BS_TEXT:
1300 {
1301 HFONT hFont, hPrevFont = 0;
1302
1303 if (!(text = get_button_text( infoPtr ))) goto empty_rect;
1304 if (!text[0])
1305 {
1306 heap_free( text );
1307 goto empty_rect;
1308 }
1309
1310 if ((hFont = infoPtr->font)) hPrevFont = SelectObject( hdc, hFont );
1311#ifdef __REACTOS__
1312 DrawTextW(hdc, text, -1, &r, ((dtStyle | DT_CALCRECT) & ~(DT_VCENTER | DT_BOTTOM)));
1313#else
1314 DrawTextW(hdc, text, -1, &r, dtStyle | DT_CALCRECT);
1315#endif
1316 if (hPrevFont) SelectObject( hdc, hPrevFont );
1317 heap_free( text );
1318#ifdef __REACTOS__
1319 if (infoPtr->ui_state & UISF_HIDEACCEL)
1320 dtStyle |= DT_HIDEPREFIX;
1321#endif
1322 break;
1323 }
1324
1325 case BS_ICON:
1326 if (!GetIconInfo(infoPtr->u.icon, &iconInfo))
1327 goto empty_rect;
1328
1329 GetObjectW (iconInfo.hbmColor, sizeof(BITMAP), &bm);
1330
1331 r.right = r.left + bm.bmWidth;
1332 r.bottom = r.top + bm.bmHeight;
1333
1334 DeleteObject(iconInfo.hbmColor);
1335 DeleteObject(iconInfo.hbmMask);
1336 break;
1337
1338 case BS_BITMAP:
1339 if (!GetObjectW( infoPtr->u.bitmap, sizeof(BITMAP), &bm))
1340 goto empty_rect;
1341
1342 r.right = r.left + bm.bmWidth;
1343 r.bottom = r.top + bm.bmHeight;
1344 break;
1345
1346 default:
1347 empty_rect:
1348#ifdef __REACTOS__
1349 if (bHasIml)
1350 break;
1351#endif
1352 rc->right = r.left;
1353 rc->bottom = r.top;
1354 return (UINT)-1;
1355 }
1356
1357#ifdef __REACTOS__
1358 if (bHasIml)
1359 {
1360 if (infoPtr->imlData.uAlign == BUTTON_IMAGELIST_ALIGN_LEFT)
1361 r.left = infoPtr->imlData.margin.left;
1362 else if (infoPtr->imlData.uAlign == BUTTON_IMAGELIST_ALIGN_RIGHT)
1363 r.right = infoPtr->imlData.margin.right;
1364 else if (infoPtr->imlData.uAlign == BUTTON_IMAGELIST_ALIGN_TOP)
1365 r.top = infoPtr->imlData.margin.top;
1366 else if (infoPtr->imlData.uAlign == BUTTON_IMAGELIST_ALIGN_BOTTOM)
1367 r.bottom = infoPtr->imlData.margin.bottom;
1368 }
1369#endif
1370
1371 /* Position label inside bounding rectangle according to
1372 * alignment flags. (calculated rect is always left-top aligned).
1373 * If label is aligned to any side - shift label in opposite
1374 * direction to leave extra space for focus rectangle.
1375 */
1376 switch (dtStyle & (DT_CENTER|DT_RIGHT))
1377 {
1378 case DT_LEFT: r.left++; r.right++; break;
1379 case DT_CENTER: n = r.right - r.left;
1380 r.left = rc->left + ((rc->right - rc->left) - n) / 2;
1381 r.right = r.left + n; break;
1382 case DT_RIGHT: n = r.right - r.left;
1383 r.right = rc->right - 1;
1384 r.left = r.right - n;
1385 break;
1386 }
1387
1388 switch (dtStyle & (DT_VCENTER|DT_BOTTOM))
1389 {
1390 case DT_TOP: r.top++; r.bottom++; break;
1391 case DT_VCENTER: n = r.bottom - r.top;
1392#ifdef __REACTOS__
1393 r.top = rc->top + ((rc->bottom - 1 - rc->top) - n) / 2;
1394#else
1395 r.top = rc->top + ((rc->bottom - rc->top) - n) / 2;
1396#endif
1397 r.bottom = r.top + n; break;
1398 case DT_BOTTOM: n = r.bottom - r.top;
1399 r.bottom = rc->bottom - 1;
1400 r.top = r.bottom - n;
1401 break;
1402 }
1403
1404 *rc = r;
1405 return dtStyle;
1406}
1407
1408
1409/**********************************************************************
1410 * BUTTON_DrawTextCallback
1411 *
1412 * Callback function used by DrawStateW function.
1413 */
1415{
1416 RECT rc;
1417
1418 SetRect(&rc, 0, 0, cx, cy);
1419 DrawTextW(hdc, (LPCWSTR)lp, -1, &rc, (UINT)wp);
1420 return TRUE;
1421}
1422
1423
1424/**********************************************************************
1425 * BUTTON_DrawLabel
1426 *
1427 * Common function for drawing button label.
1428 */
1429static void BUTTON_DrawLabel(const BUTTON_INFO *infoPtr, HDC hdc, UINT dtFlags, const RECT *rc)
1430{
1431 DRAWSTATEPROC lpOutputProc = NULL;
1432 LPARAM lp;
1433 WPARAM wp = 0;
1434 HBRUSH hbr = 0;
1436 LONG state = infoPtr->state;
1437 LONG style = GetWindowLongW( infoPtr->hwnd, GWL_STYLE );
1438 WCHAR *text = NULL;
1439
1440 /* FIXME: To draw disabled label in Win31 look-and-feel, we probably
1441 * must use DSS_MONO flag and COLOR_GRAYTEXT brush (or maybe DSS_UNION).
1442 * I don't have Win31 on hand to verify that, so I leave it as is.
1443 */
1444
1445#ifdef __REACTOS__
1446 RECT rcText = *rc;
1447 BUTTON_DrawIml(hdc, &infoPtr->imlData, &rcText, FALSE, 0);
1448#endif
1449
1451 {
1453 flags |= DSS_MONO;
1454 }
1455
1456 switch (style & (BS_ICON|BS_BITMAP))
1457 {
1458 case BS_TEXT:
1459 /* DST_COMPLEX -- is 0 */
1460 lpOutputProc = BUTTON_DrawTextCallback;
1461 if (!(text = get_button_text( infoPtr ))) return;
1462 lp = (LPARAM)text;
1463 wp = dtFlags;
1464#ifdef __REACTOS__
1465 if (dtFlags & DT_HIDEPREFIX)
1467#endif
1468 break;
1469
1470 case BS_ICON:
1471 flags |= DST_ICON;
1472 lp = (LPARAM)infoPtr->u.icon;
1473 break;
1474
1475 case BS_BITMAP:
1476 flags |= DST_BITMAP;
1477 lp = (LPARAM)infoPtr->u.bitmap;
1478 break;
1479
1480 default:
1481 return;
1482 }
1483
1484#ifdef __REACTOS__
1485 DrawStateW(hdc, hbr, lpOutputProc, lp, wp, rcText.left, rcText.top,
1486 rcText.right - rcText.left, rcText.bottom - rcText.top, flags);
1487#else
1488 DrawStateW(hdc, hbr, lpOutputProc, lp, wp, rc->left, rc->top,
1489 rc->right - rc->left, rc->bottom - rc->top, flags);
1490#endif
1491 heap_free( text );
1492}
1493
1494/**********************************************************************
1495 * Push Button Functions
1496 */
1497static void PB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
1498{
1499 RECT rc, r;
1500 UINT dtFlags, uState;
1501 HPEN hOldPen, hpen;
1502 HBRUSH hOldBrush;
1503 INT oldBkMode;
1504 COLORREF oldTxtColor;
1505 HFONT hFont;
1506 LONG state = infoPtr->state;
1507 LONG style = GetWindowLongW( infoPtr->hwnd, GWL_STYLE );
1508 BOOL pushedState = (state & BST_PUSHED);
1509 HWND parent;
1510 HRGN hrgn;
1511#ifdef __REACTOS__
1512 DWORD cdrf;
1513#endif
1514
1515 GetClientRect( infoPtr->hwnd, &rc );
1516
1517 /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
1518 if ((hFont = infoPtr->font)) SelectObject( hDC, hFont );
1519 parent = GetParent(infoPtr->hwnd);
1520 if (!parent) parent = infoPtr->hwnd;
1522
1523 hrgn = set_control_clipping( hDC, &rc );
1524
1526 hOldPen = SelectObject(hDC, hpen);
1528 oldBkMode = SetBkMode(hDC, TRANSPARENT);
1529
1530#ifdef __REACTOS__
1531 cdrf = BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_PREERASE, &rc);
1532 if (cdrf == CDRF_SKIPDEFAULT)
1533 goto cleanup;
1534#endif
1535
1537 {
1538 if (action != ODA_FOCUS)
1539 Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
1540 InflateRect( &rc, -1, -1 );
1541 }
1542
1543 /* completely skip the drawing if only focus has changed */
1544 if (action == ODA_FOCUS) goto draw_focus;
1545
1546 uState = DFCS_BUTTONPUSH;
1547
1548 if (style & BS_FLAT)
1549 uState |= DFCS_MONO;
1550 else if (pushedState)
1551 {
1553 uState |= DFCS_FLAT;
1554 else
1555 uState |= DFCS_PUSHED;
1556 }
1557
1559 uState |= DFCS_CHECKED;
1560
1561 DrawFrameControl( hDC, &rc, DFC_BUTTON, uState );
1562
1563#ifdef __REACTOS__
1564 if (cdrf == CDRF_NOTIFYPOSTERASE)
1565 BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_POSTERASE, &rc);
1566
1567 cdrf = BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_PREPAINT, &rc);
1568 if (cdrf == CDRF_SKIPDEFAULT)
1569 goto cleanup;
1570#endif
1571
1572 /* draw button label */
1573 r = rc;
1574 dtFlags = BUTTON_CalcLabelRect(infoPtr, hDC, &r);
1575
1576 if (dtFlags == (UINT)-1L)
1577 goto cleanup;
1578
1579 if (pushedState)
1580 OffsetRect(&r, 1, 1);
1581
1582 oldTxtColor = SetTextColor( hDC, GetSysColor(COLOR_BTNTEXT) );
1583
1584 BUTTON_DrawLabel(infoPtr, hDC, dtFlags, &r);
1585
1586 SetTextColor( hDC, oldTxtColor );
1587
1588#ifdef __REACTOS__
1589 if (cdrf == CDRF_NOTIFYPOSTPAINT)
1590 BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_POSTPAINT, &rc);
1591#endif
1592
1593draw_focus:
1594 if (action == ODA_FOCUS || (state & BST_FOCUS))
1595 {
1596#ifdef __REACTOS__
1597 if (!(infoPtr->ui_state & UISF_HIDEFOCUS))
1598 {
1599#endif
1600 InflateRect( &rc, -2, -2 );
1601 DrawFocusRect( hDC, &rc );
1602#ifdef __REACTOS__
1603 }
1604#endif
1605 }
1606
1607 cleanup:
1608 SelectObject( hDC, hOldPen );
1609 SelectObject( hDC, hOldBrush );
1610 SetBkMode(hDC, oldBkMode);
1612 if (hrgn) DeleteObject( hrgn );
1613 DeleteObject( hpen );
1614}
1615
1616/**********************************************************************
1617 * Check Box & Radio Button Functions
1618 */
1619
1620static void CB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
1621{
1622 RECT rbox, rtext, client;
1623 HBRUSH hBrush;
1624 int delta, text_offset, checkBoxWidth, checkBoxHeight;
1625 UINT dtFlags;
1626 HFONT hFont;
1627 LONG state = infoPtr->state;
1628 LONG style = GetWindowLongW( infoPtr->hwnd, GWL_STYLE );
1629 LONG ex_style = GetWindowLongW( infoPtr->hwnd, GWL_EXSTYLE );
1630 HWND parent;
1631 HRGN hrgn;
1632
1633 if (style & BS_PUSHLIKE)
1634 {
1635 PB_Paint( infoPtr, hDC, action );
1636 return;
1637 }
1638
1639 GetClientRect(infoPtr->hwnd, &client);
1640 rbox = rtext = client;
1641
1642 checkBoxWidth = 12 * GetDeviceCaps( hDC, LOGPIXELSX ) / 96 + 1;
1643 checkBoxHeight = 12 * GetDeviceCaps( hDC, LOGPIXELSY ) / 96 + 1;
1644
1645 if ((hFont = infoPtr->font)) SelectObject( hDC, hFont );
1646 GetCharWidthW( hDC, '0', '0', &text_offset );
1647 text_offset /= 2;
1648
1649 parent = GetParent(infoPtr->hwnd);
1650 if (!parent) parent = infoPtr->hwnd;
1651 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
1652 if (!hBrush) /* did the app forget to call defwindowproc ? */
1653 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
1655
1656 if (style & BS_LEFTTEXT || ex_style & WS_EX_RIGHT)
1657 {
1658 rtext.right -= checkBoxWidth + text_offset;
1659 rbox.left = rbox.right - checkBoxWidth;
1660 }
1661 else
1662 {
1663 rtext.left += checkBoxWidth + text_offset;
1664 rbox.right = checkBoxWidth;
1665 }
1666
1667 /* Since WM_ERASEBKGND does nothing, first prepare background */
1668 if (action == ODA_SELECT) FillRect( hDC, &rbox, hBrush );
1669 if (action == ODA_DRAWENTIRE) FillRect( hDC, &client, hBrush );
1670
1671 /* Draw label */
1672 client = rtext;
1673 dtFlags = BUTTON_CalcLabelRect(infoPtr, hDC, &rtext);
1674
1675 /* Only adjust rbox when rtext is valid */
1676 if (dtFlags != (UINT)-1L)
1677 {
1678 rbox.top = rtext.top;
1679 rbox.bottom = rtext.bottom;
1680 }
1681
1682 /* Draw the check-box bitmap */
1684 {
1685 UINT flags;
1686
1690 else flags = DFCS_BUTTONCHECK;
1691
1694
1696
1697 /* rbox must have the correct height */
1698 delta = rbox.bottom - rbox.top - checkBoxHeight;
1699
1700 if (style & BS_TOP) {
1701 if (delta > 0) {
1702 rbox.bottom = rbox.top + checkBoxHeight;
1703 } else {
1704 rbox.top -= -delta/2 + 1;
1705 rbox.bottom = rbox.top + checkBoxHeight;
1706 }
1707 } else if (style & BS_BOTTOM) {
1708 if (delta > 0) {
1709 rbox.top = rbox.bottom - checkBoxHeight;
1710 } else {
1711 rbox.bottom += -delta/2 + 1;
1712 rbox.top = rbox.bottom - checkBoxHeight;
1713 }
1714 } else { /* Default */
1715 if (delta > 0) {
1716 int ofs = (delta / 2);
1717 rbox.bottom -= ofs + 1;
1718 rbox.top = rbox.bottom - checkBoxHeight;
1719 } else if (delta < 0) {
1720 int ofs = (-delta / 2);
1721 rbox.top -= ofs + 1;
1722 rbox.bottom = rbox.top + checkBoxHeight;
1723 }
1724 }
1725
1727 }
1728
1729 if (dtFlags == (UINT)-1L) /* Noting to draw */
1730 return;
1731
1732 if (action == ODA_DRAWENTIRE)
1733 BUTTON_DrawLabel(infoPtr, hDC, dtFlags, &rtext);
1734
1735 /* ... and focus */
1736 if (action == ODA_FOCUS || (state & BST_FOCUS))
1737 {
1738 rtext.left--;
1739 rtext.right++;
1740 IntersectRect(&rtext, &rtext, &client);
1741 DrawFocusRect( hDC, &rtext );
1742 }
1744 if (hrgn) DeleteObject( hrgn );
1745}
1746
1747
1748/**********************************************************************
1749 * BUTTON_CheckAutoRadioButton
1750 *
1751 * hwnd is checked, uncheck every other auto radio button in group
1752 */
1754{
1755 HWND parent, sibling, start;
1756
1758 /* make sure that starting control is not disabled or invisible */
1759#ifdef __REACTOS__
1760 start = sibling = hwnd;
1761#else
1762 start = sibling = GetNextDlgGroupItem( parent, hwnd, TRUE );
1763#endif
1764 do
1765 {
1766 if (!sibling) break;
1767#ifdef __REACTOS__
1769 SendMessageW( sibling, BM_SETCHECK, sibling == hwnd ? BST_CHECKED : BST_UNCHECKED, 0 );
1770#else
1771 if ((hwnd != sibling) &&
1773 SendMessageW( sibling, BM_SETCHECK, BST_UNCHECKED, 0 );
1774#endif
1775 sibling = GetNextDlgGroupItem( parent, sibling, FALSE );
1776 } while (sibling != start);
1777}
1778
1779
1780/**********************************************************************
1781 * Group Box Functions
1782 */
1783
1784static void GB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
1785{
1786 RECT rc, rcFrame;
1787 HBRUSH hbr;
1788 HFONT hFont;
1789 UINT dtFlags;
1791 LONG style = GetWindowLongW( infoPtr->hwnd, GWL_STYLE );
1792 HWND parent;
1793 HRGN hrgn;
1794
1795 if ((hFont = infoPtr->font)) SelectObject( hDC, hFont );
1796 /* GroupBox acts like static control, so it sends CTLCOLORSTATIC */
1797 parent = GetParent(infoPtr->hwnd);
1798 if (!parent) parent = infoPtr->hwnd;
1799 hbr = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
1800 if (!hbr) /* did the app forget to call defwindowproc ? */
1801 hbr = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
1802 GetClientRect( infoPtr->hwnd, &rc);
1803 rcFrame = rc;
1804 hrgn = set_control_clipping( hDC, &rc );
1805
1807 rcFrame.top += (tm.tmHeight / 2) - 1;
1808 DrawEdge (hDC, &rcFrame, EDGE_ETCHED, BF_RECT | ((style & BS_FLAT) ? BF_FLAT : 0));
1809
1810 InflateRect(&rc, -7, 1);
1811 dtFlags = BUTTON_CalcLabelRect(infoPtr, hDC, &rc);
1812
1813 if (dtFlags != (UINT)-1)
1814 {
1815 /* Because buttons have CS_PARENTDC class style, there is a chance
1816 * that label will be drawn out of client rect.
1817 * But Windows doesn't clip label's rect, so do I.
1818 */
1819
1820 /* There is 1-pixel margin at the left, right, and bottom */
1821 rc.left--; rc.right++; rc.bottom++;
1822 FillRect(hDC, &rc, hbr);
1823 rc.left++; rc.right--; rc.bottom--;
1824
1825 BUTTON_DrawLabel(infoPtr, hDC, dtFlags, &rc);
1826 }
1828 if (hrgn) DeleteObject( hrgn );
1829}
1830
1831
1832/**********************************************************************
1833 * User Button Functions
1834 */
1835
1836static void UB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
1837{
1838 RECT rc;
1839 HBRUSH hBrush;
1840 HFONT hFont;
1841 LONG state = infoPtr->state;
1842 HWND parent;
1843
1844 GetClientRect( infoPtr->hwnd, &rc);
1845
1846 if ((hFont = infoPtr->font)) SelectObject( hDC, hFont );
1847
1848 parent = GetParent(infoPtr->hwnd);
1849 if (!parent) parent = infoPtr->hwnd;
1850 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
1851 if (!hBrush) /* did the app forget to call defwindowproc ? */
1852 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
1853
1854 FillRect( hDC, &rc, hBrush );
1855 if (action == ODA_FOCUS || (state & BST_FOCUS))
1856 DrawFocusRect( hDC, &rc );
1857
1858 switch (action)
1859 {
1860 case ODA_FOCUS:
1862 break;
1863
1864 case ODA_SELECT:
1866 break;
1867
1868 default:
1869 break;
1870 }
1871}
1872
1873
1874/**********************************************************************
1875 * Ownerdrawn Button Functions
1876 */
1877
1878static void OB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
1879{
1880 LONG state = infoPtr->state;
1881 DRAWITEMSTRUCT dis;
1882 LONG_PTR id = GetWindowLongPtrW( infoPtr->hwnd, GWLP_ID );
1883 HWND parent;
1884 HFONT hFont;
1885 HRGN hrgn;
1886
1887 dis.CtlType = ODT_BUTTON;
1888 dis.CtlID = id;
1889 dis.itemID = 0;
1890 dis.itemAction = action;
1891 dis.itemState = ((state & BST_FOCUS) ? ODS_FOCUS : 0) |
1892 ((state & BST_PUSHED) ? ODS_SELECTED : 0) |
1893 (IsWindowEnabled(infoPtr->hwnd) ? 0: ODS_DISABLED);
1894 dis.hwndItem = infoPtr->hwnd;
1895 dis.hDC = hDC;
1896 dis.itemData = 0;
1897 GetClientRect( infoPtr->hwnd, &dis.rcItem );
1898
1899 if ((hFont = infoPtr->font)) SelectObject( hDC, hFont );
1900 parent = GetParent(infoPtr->hwnd);
1901 if (!parent) parent = infoPtr->hwnd;
1903
1905
1906 SendMessageW( GetParent(infoPtr->hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
1908 if (hrgn) DeleteObject( hrgn );
1909}
1910
1911#ifdef __REACTOS__ /* r73885 */
1912static void PB_ThemedPaint( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused, LPARAM prfFlag)
1913#else
1914static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused)
1915#endif
1916{
1917 static const int states[] = { PBS_NORMAL, PBS_DISABLED, PBS_HOT, PBS_PRESSED, PBS_DEFAULTED };
1918
1919 RECT bgRect, textRect;
1920 HFONT font = infoPtr->font;
1921 HFONT hPrevFont = font ? SelectObject(hDC, font) : NULL;
1922 int state = states[ drawState ];
1923 WCHAR *text = get_button_text(infoPtr);
1924#ifdef __REACTOS__
1925 HWND parent;
1926 DWORD cdrf;
1927
1928 GetClientRect(infoPtr->hwnd, &bgRect);
1929 GetThemeBackgroundContentRect(theme, hDC, BP_PUSHBUTTON, state, &bgRect, &textRect);
1930
1931 if (prfFlag == 0)
1932 {
1935 }
1936
1937 parent = GetParent(infoPtr->hwnd);
1938 if (!parent) parent = infoPtr->hwnd;
1940
1941 cdrf = BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_PREERASE, &bgRect);
1942 if (cdrf == CDRF_SKIPDEFAULT)
1943 goto cleanup;
1944
1945 DrawThemeBackground(theme, hDC, BP_PUSHBUTTON, state, &bgRect, NULL);
1946
1947 if (cdrf == CDRF_NOTIFYPOSTERASE)
1948 BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_POSTERASE, &bgRect);
1949
1950 cdrf = BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_PREPAINT, &bgRect);
1951 if (cdrf == CDRF_SKIPDEFAULT)
1952 goto cleanup;
1953
1954 BUTTON_DrawIml(hDC, &infoPtr->imlData, &textRect, FALSE, drawState);
1955#else
1956 GetClientRect(infoPtr->hwnd, &bgRect);
1957 GetThemeBackgroundContentRect(theme, hDC, BP_PUSHBUTTON, state, &bgRect, &textRect);
1958
1961
1962 DrawThemeBackground(theme, hDC, BP_PUSHBUTTON, state, &bgRect, NULL);
1963#endif
1964
1965 if (text)
1966 {
1967 DrawThemeText(theme, hDC, BP_PUSHBUTTON, state, text, lstrlenW(text), dtFlags, 0, &textRect);
1968 heap_free(text);
1969#ifdef __REACTOS__
1970 text = NULL;
1971#endif
1972 }
1973
1974 if (focused)
1975 {
1977 RECT focusRect = bgRect;
1978
1980
1981 focusRect.left += margins.cxLeftWidth;
1982 focusRect.top += margins.cyTopHeight;
1983 focusRect.right -= margins.cxRightWidth;
1984 focusRect.bottom -= margins.cyBottomHeight;
1985
1986 DrawFocusRect( hDC, &focusRect );
1987 }
1988
1989#ifdef __REACTOS__
1990 if (cdrf == CDRF_NOTIFYPOSTPAINT)
1991 BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_POSTPAINT, &bgRect);
1992cleanup:
1993 if (text) heap_free(text);
1994#endif
1995 if (hPrevFont) SelectObject(hDC, hPrevFont);
1996}
1997
1998#ifdef __REACTOS__ /* r73885 */
1999static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused, LPARAM prfFlag)
2000#else
2001static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused)
2002#endif
2003{
2004 static const int cb_states[3][5] =
2005 {
2009 };
2010
2011 static const int rb_states[2][5] =
2012 {
2015 };
2016
2017 SIZE sz;
2018 RECT bgRect, textRect;
2019 HFONT font, hPrevFont = NULL;
2020 int checkState = infoPtr->state & 3;
2021 DWORD dwStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
2022 UINT btn_type = get_button_type( dwStyle );
2023 int part = (btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON) ? BP_RADIOBUTTON : BP_CHECKBOX;
2024 int state = (part == BP_CHECKBOX)
2025 ? cb_states[ checkState ][ drawState ]
2026 : rb_states[ checkState ][ drawState ];
2027 WCHAR *text = get_button_text(infoPtr);
2028 LOGFONTW lf;
2029 BOOL created_font = FALSE;
2030#ifdef __REACTOS__
2031 HWND parent;
2032 HBRUSH hBrush;
2033 DWORD cdrf;
2034#endif
2035
2036 HRESULT hr = GetThemeFont(theme, hDC, part, state, TMT_FONT, &lf);
2037 if (SUCCEEDED(hr)) {
2039 if (!font)
2040 TRACE("Failed to create font\n");
2041 else {
2042 TRACE("font = %s\n", debugstr_w(lf.lfFaceName));
2043 hPrevFont = SelectObject(hDC, font);
2044 created_font = TRUE;
2045 }
2046 } else {
2047#ifdef __REACTOS__ /* r73885 */
2048 font = infoPtr->font;
2049#else
2050 font = (HFONT)SendMessageW(infoPtr->hwnd, WM_GETFONT, 0, 0);
2051#endif
2052 hPrevFont = SelectObject(hDC, font);
2053 }
2054
2055 if (FAILED(GetThemePartSize(theme, hDC, part, state, NULL, TS_DRAW, &sz)))
2056 sz.cx = sz.cy = 13;
2057
2058 GetClientRect(infoPtr->hwnd, &bgRect);
2059
2060#ifdef __REACTOS__
2061 if (prfFlag == 0)
2062 {
2064 }
2065
2066 parent = GetParent(infoPtr->hwnd);
2067 if (!parent) parent = infoPtr->hwnd;
2068 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC,
2069 (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
2070 if (!hBrush) /* did the app forget to call defwindowproc ? */
2071 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
2072 (WPARAM)hDC, (LPARAM)infoPtr->hwnd );
2073 FillRect( hDC, &bgRect, hBrush );
2074
2075 cdrf = BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_PREERASE, &bgRect);
2076 if (cdrf == CDRF_SKIPDEFAULT)
2077 goto cleanup;
2078#endif
2079
2080 GetThemeBackgroundContentRect(theme, hDC, part, state, &bgRect, &textRect);
2081
2082 if (dtFlags & DT_SINGLELINE) /* Center the checkbox / radio button to the text. */
2083 bgRect.top = bgRect.top + (textRect.bottom - textRect.top - sz.cy) / 2;
2084
2085 /* adjust for the check/radio marker */
2086 bgRect.bottom = bgRect.top + sz.cy;
2087 bgRect.right = bgRect.left + sz.cx;
2088 textRect.left = bgRect.right + 6;
2089
2090#ifdef __REACTOS__
2091 DrawThemeBackground(theme, hDC, part, state, &bgRect, NULL);
2092
2093 if (cdrf == CDRF_NOTIFYPOSTERASE)
2094 BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_POSTERASE, &bgRect);
2095
2096 cdrf = BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_PREPAINT, &bgRect);
2097 if (cdrf == CDRF_SKIPDEFAULT)
2098 goto cleanup;
2099
2100#else
2102 DrawThemeBackground(theme, hDC, part, state, &bgRect, NULL);
2103#endif
2104 if (text)
2105 {
2106 DrawThemeText(theme, hDC, part, state, text, lstrlenW(text), dtFlags, 0, &textRect);
2107
2108 if (focused)
2109 {
2110 RECT focusRect;
2111
2112 focusRect = textRect;
2113
2114 DrawTextW(hDC, text, lstrlenW(text), &focusRect, dtFlags | DT_CALCRECT);
2115
2116 if (focusRect.right < textRect.right) focusRect.right++;
2117 focusRect.bottom = textRect.bottom;
2118
2119 DrawFocusRect( hDC, &focusRect );
2120 }
2121
2122 heap_free(text);
2123#ifdef __REACTOS__
2124 text = NULL;
2125#endif
2126 }
2127
2128#ifdef __REACTOS__
2129 if (cdrf == CDRF_NOTIFYPOSTPAINT)
2130 BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_POSTPAINT, &bgRect);
2131cleanup:
2132 if (text) heap_free(text);
2133#endif
2134 if (created_font) DeleteObject(font);
2135 if (hPrevFont) SelectObject(hDC, hPrevFont);
2136}
2137
2138#ifdef __REACTOS__ /* r73885 */
2139static void GB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused, LPARAM prfFlag)
2140#else
2141static void GB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused)
2142#endif
2143{
2144 static const int states[] = { GBS_NORMAL, GBS_DISABLED, GBS_NORMAL, GBS_NORMAL, GBS_NORMAL };
2145
2146 RECT bgRect, textRect, contentRect;
2147 int state = states[ drawState ];
2148 WCHAR *text = get_button_text(infoPtr);
2149 LOGFONTW lf;
2150 HFONT font, hPrevFont = NULL;
2151 BOOL created_font = FALSE;
2152#ifdef __REACTOS__ /* r74406 */
2153 HWND parent;
2154 HBRUSH hBrush;
2155 RECT clientRect;
2156#endif
2157
2159 if (SUCCEEDED(hr)) {
2161 if (!font)
2162 TRACE("Failed to create font\n");
2163 else {
2164 hPrevFont = SelectObject(hDC, font);
2165 created_font = TRUE;
2166 }
2167 } else {
2168#ifdef __REACTOS__ /* r73885 */
2169 font = infoPtr->font;
2170#else
2171 font = (HFONT)SendMessageW(infoPtr->hwnd, WM_GETFONT, 0, 0);
2172#endif
2173 hPrevFont = SelectObject(hDC, font);
2174 }
2175
2176 GetClientRect(infoPtr->hwnd, &bgRect);
2177 textRect = bgRect;
2178
2179 if (text)
2180 {
2181 SIZE textExtent;
2182 GetTextExtentPoint32W(hDC, text, lstrlenW(text), &textExtent);
2183 bgRect.top += (textExtent.cy / 2);
2184 textRect.left += 10;
2185 textRect.bottom = textRect.top + textExtent.cy;
2186 textRect.right = textRect.left + textExtent.cx + 4;
2187
2188 ExcludeClipRect(hDC, textRect.left, textRect.top, textRect.right, textRect.bottom);
2189 }
2190
2191 GetThemeBackgroundContentRect(theme, hDC, BP_GROUPBOX, state, &bgRect, &contentRect);
2192 ExcludeClipRect(hDC, contentRect.left, contentRect.top, contentRect.right, contentRect.bottom);
2193
2194#ifdef __REACTOS__ /* r73885 & r74149 */
2195 if (prfFlag == 0)
2196#endif
2199
2200#ifdef __REACTOS__ /* r74406 */
2201 parent = GetParent(infoPtr->hwnd);
2202 if (!parent) parent = infoPtr->hwnd;
2203 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC,
2204 (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
2205 if (!hBrush) /* did the app forget to call defwindowproc ? */
2206 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
2207 (WPARAM)hDC, (LPARAM)infoPtr->hwnd );
2208 GetClientRect(infoPtr->hwnd, &clientRect);
2209 FillRect( hDC, &clientRect, hBrush );
2210#endif
2211
2212 DrawThemeBackground(theme, hDC, BP_GROUPBOX, state, &bgRect, NULL);
2213
2215
2216 if (text)
2217 {
2218 InflateRect(&textRect, -2, 0);
2219 DrawThemeText(theme, hDC, BP_GROUPBOX, state, text, lstrlenW(text), 0, 0, &textRect);
2220 heap_free(text);
2221 }
2222
2223 if (created_font) DeleteObject(font);
2224 if (hPrevFont) SelectObject(hDC, hPrevFont);
2225}
2226
2228{
2229 WNDCLASSW wndClass;
2230
2231 memset(&wndClass, 0, sizeof(wndClass));
2233 wndClass.lpfnWndProc = BUTTON_WindowProc;
2234 wndClass.cbClsExtra = 0;
2235 wndClass.cbWndExtra = sizeof(BUTTON_INFO *);
2236 wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
2237 wndClass.hbrBackground = NULL;
2238 wndClass.lpszClassName = WC_BUTTONW;
2239 RegisterClassW(&wndClass);
2240}
2241
2242
2243#ifdef __REACTOS__
2244void BUTTON_Unregister(void)
2245{
2247}
2248#endif
static HDC hDC
Definition: 3dtext.c:33
static HRGN hrgn
static HBRUSH hbrush
static HPEN hpen
Arabic default style
Definition: afstyles.h:94
static int state
Definition: maze.c:121
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
HWND hWnd
Definition: settings.c:17
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
HFONT hFont
Definition: main.c:53
static RECT margins
Definition: print.c:55
int note(char *format,...)
Definition: util.c:12
#define ERR(fmt,...)
Definition: precomp.h:57
HBITMAP hbmp
RECT rect
Definition: combotst.c:67
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static WCHAR * heap_strndupW(const WCHAR *src, size_t length)
Definition: button.c:262
void BUTTON_Register(void)
Definition: button.c:2227
static const pfThemedPaint btnThemedPaintFunc[MAX_BTN_TYPE]
Definition: button.c:194
HRGN set_control_clipping(HDC hdc, const RECT *rect)
Definition: button.c:242
static void GB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused)
Definition: button.c:2141
static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: button.c:602
#define BUTTON_NSTATES
Definition: button.c:77
static void BUTTON_DrawLabel(const BUTTON_INFO *infoPtr, HDC hdc, UINT dtFlags, const RECT *rc)
Definition: button.c:1429
static BOOL CALLBACK BUTTON_DrawTextCallback(HDC hdc, LPARAM lp, WPARAM wp, int cx, int cy)
Definition: button.c:1414
static void GB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1784
#define BUTTON_NOTIFY_PARENT(hWnd, code)
Definition: button.c:85
static void CB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1620
static const pfPaint btnPaintFunc[MAX_BTN_TYPE]
Definition: button.c:157
struct _BUTTON_INFO BUTTON_INFO
static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused)
Definition: button.c:2001
static UINT BUTTON_CalcLabelRect(const BUTTON_INFO *infoPtr, HDC hdc, RECT *rc)
Definition: button.c:1282
static void paint_button(BUTTON_INFO *infoPtr, LONG style, UINT action)
Definition: button.c:221
static UINT BUTTON_BStoDT(DWORD style, DWORD ex_style)
Definition: button.c:273
ButtonState
Definition: button.c:147
@ STATE_PRESSED
Definition: button.c:151
@ STATE_DEFAULTED
Definition: button.c:152
@ STATE_DISABLED
Definition: button.c:149
@ STATE_NORMAL
Definition: button.c:148
@ STATE_HOT
Definition: button.c:150
#define BUTTON_BTNPRESSED
Definition: button.c:78
static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused)
Definition: button.c:1914
static UINT get_button_type(LONG window_style)
Definition: button.c:214
static void PB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1497
static WCHAR * get_button_text(const BUTTON_INFO *infoPtr)
Definition: button.c:233
static const WORD maxCheckState[MAX_BTN_TYPE]
Definition: button.c:125
static void UB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1836
#define MAX_BTN_TYPE
Definition: button.c:123
void(* pfThemedPaint)(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused)
Definition: button.c:186
static void OB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1878
void(* pfPaint)(const BUTTON_INFO *infoPtr, HDC hdc, UINT action)
Definition: button.c:155
static void BUTTON_CheckAutoRadioButton(HWND hwnd)
Definition: button.c:1753
BOOL WINAPI ImageList_Draw(HIMAGELIST himl, INT i, HDC hdc, INT x, INT y, UINT fStyle)
Definition: imagelist.c:1246
INT WINAPI ImageList_GetImageCount(HIMAGELIST himl)
Definition: imagelist.c:2081
BOOL WINAPI ImageList_GetIconSize(HIMAGELIST himl, INT *cx, INT *cy)
Definition: imagelist.c:2055
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
#define wcsicmp
Definition: compat.h:15
#define lstrlenW
Definition: compat.h:750
static void cleanup(void)
Definition: main.c:1335
const WCHAR * text
Definition: package.c:1794
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
BOOL WINAPI IsThemeBackgroundPartiallyTransparent(HTHEME hTheme, int iPartId, int iStateId)
Definition: draw.c:1927
HRESULT WINAPI GetThemePartSize(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz)
Definition: draw.c:1821
HRESULT WINAPI GetThemeBackgroundExtent(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pContentRect, RECT *pExtentRect)
Definition: draw.c:1572
HRESULT WINAPI DrawThemeText(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect)
Definition: draw.c:1500
HRESULT WINAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT *prc)
Definition: draw.c:72
HRESULT WINAPI GetThemeBackgroundContentRect(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pBoundingRect, RECT *pContentRect)
Definition: draw.c:1523
HRESULT WINAPI GetThemeFont(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, LOGFONTW *pFont)
Definition: property.c:108
HRESULT WINAPI GetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, RECT *prc, MARGINS *pMargins)
Definition: property.c:216
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:920
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:1036
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR pszClassList)
Definition: system.c:890
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define pt(x, y)
Definition: drawing.c:79
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Height *Stride) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Stride)
Definition: common.c:42
return ret
Definition: mutex.c:147
action
Definition: namespace.c:707
#define L(x)
Definition: resources.c:13
r parent
Definition: btrfs.c:3010
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
DWORD WINAPI GetLayout(_In_ HDC hdc)
Definition: coord.c:750
GLuint start
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
GLenum src
Definition: glext.h:6340
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLuint index
Definition: glext.h:6031
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
GLenum GLenum dst
Definition: glext.h:6340
GLbitfield flags
Definition: glext.h:7161
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLenum GLsizei len
Definition: glext.h:6722
GLuint id
Definition: glext.h:5910
unsigned int UINT
Definition: sysinfo.c:13
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_w
Definition: kernel32.h:32
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
DWORD button
Definition: button.c:166
static HDC
Definition: imagelist.c:88
static HICON
Definition: imagelist.c:80
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
#define min(a, b)
Definition: monoChain.cc:55
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
Definition: mk_font.cpp:20
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
#define LOWORD(l)
Definition: pedump.c:82
#define BS_AUTORADIOBUTTON
Definition: pedump.c:660
#define WS_CHILD
Definition: pedump.c:617
#define BS_USERBUTTON
Definition: pedump.c:659
#define BS_LEFTTEXT
Definition: pedump.c:662
#define WS_TABSTOP
Definition: pedump.c:634
short WCHAR
Definition: pedump.c:58
#define WS_VISIBLE
Definition: pedump.c:620
#define BS_AUTOCHECKBOX
Definition: pedump.c:654
long LONG
Definition: pedump.c:60
#define BS_GROUPBOX
Definition: pedump.c:658
#define BS_OWNERDRAW
Definition: pedump.c:661
#define WS_DISABLED
Definition: pedump.c:621
#define BS_AUTO3STATE
Definition: pedump.c:657
#define BS_RADIOBUTTON
Definition: pedump.c:655
#define BS_PUSHBUTTON
Definition: pedump.c:651
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
#define BST_HOT
Definition: commctrl.h:4673
#define WC_BUTTONW
Definition: commctrl.h:4628
#define CDIS_DISABLED
Definition: commctrl.h:293
#define CDRF_NOTIFYPOSTERASE
Definition: commctrl.h:277
#define CDIS_SHOWKEYBOARDCUES
Definition: commctrl.h:300
#define TME_LEAVE
Definition: commctrl.h:4998
#define BCM_SETNOTE
Definition: commctrl.h:4664
#define BS_SPLITBUTTON
Definition: commctrl.h:4675
#define BCM_GETNOTE
Definition: commctrl.h:4665
#define BUTTON_IMAGELIST_ALIGN_CENTER
Definition: commctrl.h:4636
#define BS_DEFCOMMANDLINK
Definition: commctrl.h:4678
#define BUTTON_IMAGELIST_ALIGN_TOP
Definition: commctrl.h:4634
#define BUTTON_IMAGELIST_ALIGN_LEFT
Definition: commctrl.h:4632
_Out_opt_ int * cx
Definition: commctrl.h:585
#define CDIS_SELECTED
Definition: commctrl.h:291
#define CDRF_NOTIFYPOSTPAINT
Definition: commctrl.h:274
#define BCM_GETIDEALSIZE
Definition: commctrl.h:4644
#define CDDS_POSTERASE
Definition: commctrl.h:283
#define NM_CUSTOMDRAW
Definition: commctrl.h:137
#define BCM_SETIMAGELIST
Definition: commctrl.h:4647
#define CDIS_FOCUS
Definition: commctrl.h:295
#define BCN_HOTITEMCHANGE
Definition: commctrl.h:260
#define CDIS_CHECKED
Definition: commctrl.h:294
#define BCM_SETTEXTMARGIN
Definition: commctrl.h:4653
#define WM_MOUSELEAVE
Definition: commctrl.h:4992
#define BS_DEFSPLITBUTTON
Definition: commctrl.h:4676
#define HICF_ENTERING
Definition: commctrl.h:1330
#define BCM_GETNOTELENGTH
Definition: commctrl.h:4666
#define CDDS_PREPAINT
Definition: commctrl.h:280
struct tagTRACKMOUSEEVENT TRACKMOUSEEVENT
#define HICF_LEAVING
Definition: commctrl.h:1331
#define BUTTON_IMAGELIST_ALIGN_RIGHT
Definition: commctrl.h:4633
#define WM_MOUSEHOVER
Definition: commctrl.h:4991
#define CDDS_POSTPAINT
Definition: commctrl.h:281
#define TME_QUERY
Definition: commctrl.h:5000
#define CDRF_SKIPDEFAULT
Definition: commctrl.h:270
#define BUTTON_IMAGELIST_ALIGN_BOTTOM
Definition: commctrl.h:4635
#define BS_COMMANDLINK
Definition: commctrl.h:4677
#define TME_HOVER
Definition: commctrl.h:4997
#define CDDS_PREERASE
Definition: commctrl.h:282
#define BCM_GETTEXTMARGIN
Definition: commctrl.h:4655
#define BCM_GETIMAGELIST
Definition: commctrl.h:4650
_Out_ LPRECT prc
Definition: ntgdi.h:1658
_Must_inspect_result_ _Out_ LPSIZE psize
Definition: ntgdi.h:1569
#define WM_PRINTCLIENT
Definition: richedit.h:70
#define WM_NOTIFY
Definition: richedit.h:61
#define memset(x, y, z)
Definition: compat.h:39
static FILE * client
Definition: client.c:37
#define TRACE(s)
Definition: solgame.cpp:4
HIMAGELIST himl
Definition: commctrl.h:4639
LONG lfHeight
Definition: dimm.idl:59
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
LONG lfWidth
Definition: dimm.idl:60
WCHAR * note
Definition: button.c:99
HBITMAP bitmap
Definition: button.c:104
HANDLE image
Definition: button.c:105
INT note_length
Definition: button.c:100
HWND hwnd
Definition: button.c:95
HICON icon
Definition: button.c:103
HFONT font
Definition: button.c:98
LONG state
Definition: button.c:97
HWND parent
Definition: button.c:96
union _BUTTON_INFO::@331 u
HBITMAP hbmColor
Definition: winuser.h:3235
HBITMAP hbmMask
Definition: winuser.h:3234
Definition: misc.c:279
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
LPCWSTR lpszClassName
Definition: winuser.h:3293
HBRUSH hbrBackground
Definition: winuser.h:3291
int cbClsExtra
Definition: winuser.h:3286
UINT style
Definition: winuser.h:3284
WNDPROC lpfnWndProc
Definition: winuser.h:3285
int cbWndExtra
Definition: winuser.h:3287
HCURSOR hCursor
Definition: winuser.h:3290
Definition: tftpd.h:60
LONG bmHeight
Definition: wingdi.h:1869
LONG bmWidth
Definition: wingdi.h:1868
ULONG_PTR itemData
Definition: winuser.h:3201
DWORD_PTR dwItemSpec
Definition: commctrl.h:307
UINT_PTR idFrom
Definition: winuser.h:3266
UINT code
Definition: winuser.h:3267
HWND hwndFrom
Definition: winuser.h:3265
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
#define max(a, b)
Definition: svc.c:63
#define CBS_UNCHECKEDNORMAL
Definition: treelist.c:148
#define CBS_CHECKEDNORMAL
Definition: treelist.c:151
#define BP_CHECKBOX
Definition: treelist.c:145
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint16_t * LPWSTR
Definition: typedefs.h:56
PVOID HANDLE
Definition: typedefs.h:73
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
@ CBS_CHECKEDDISABLED
Definition: vsstyle.h:113
@ CBS_UNCHECKEDDISABLED
Definition: vsstyle.h:109
@ CBS_UNCHECKEDHOT
Definition: vsstyle.h:107
@ CBS_MIXEDPRESSED
Definition: vsstyle.h:116
@ CBS_MIXEDNORMAL
Definition: vsstyle.h:114
@ CBS_UNCHECKEDPRESSED
Definition: vsstyle.h:108
@ CBS_CHECKEDPRESSED
Definition: vsstyle.h:112
@ CBS_CHECKEDHOT
Definition: vsstyle.h:111
@ CBS_MIXEDDISABLED
Definition: vsstyle.h:117
@ CBS_MIXEDHOT
Definition: vsstyle.h:115
@ PBS_DISABLED
Definition: vsstyle.h:89
@ PBS_PRESSED
Definition: vsstyle.h:88
@ PBS_NORMAL
Definition: vsstyle.h:86
@ PBS_HOT
Definition: vsstyle.h:87
@ PBS_DEFAULTED
Definition: vsstyle.h:90
@ BP_RADIOBUTTON
Definition: vsstyle.h:75
@ BP_PUSHBUTTON
Definition: vsstyle.h:74
@ BP_GROUPBOX
Definition: vsstyle.h:77
@ RBS_UNCHECKEDHOT
Definition: vsstyle.h:96
@ RBS_CHECKEDPRESSED
Definition: vsstyle.h:101
@ RBS_CHECKEDHOT
Definition: vsstyle.h:100
@ RBS_UNCHECKEDNORMAL
Definition: vsstyle.h:95
@ RBS_CHECKEDDISABLED
Definition: vsstyle.h:102
@ RBS_UNCHECKEDDISABLED
Definition: vsstyle.h:98
@ RBS_CHECKEDNORMAL
Definition: vsstyle.h:99
@ RBS_UNCHECKEDPRESSED
Definition: vsstyle.h:97
@ GBS_NORMAL
Definition: vsstyle.h:129
@ GBS_DISABLED
Definition: vsstyle.h:130
#define TMT_CONTENTMARGINS
Definition: vssym32.h:324
#define TMT_FONT
Definition: vssym32.h:144
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1382
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
DWORD COLORREF
Definition: windef.h:100
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI GetCharWidthW(_In_ HDC hdc, _In_ UINT iFirst, _In_ UINT iLast, _Out_writes_(iLast+1 - iFirst) LPINT lpBuffer)
#define LOGPIXELSY
Definition: wingdi.h:719
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI ExcludeClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI DPtoLP(_In_ HDC hdc, _Inout_updates_(c) LPPOINT lppt, _In_ int c)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int WINAPI GetClipRgn(_In_ HDC, _In_ HRGN)
#define TRANSPARENT
Definition: wingdi.h:950
#define SRCCOPY
Definition: wingdi.h:333
#define LAYOUT_RTL
Definition: wingdi.h:1371
#define OPAQUE
Definition: wingdi.h:949
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
#define LOGPIXELSX
Definition: wingdi.h:718
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917
BOOL WINAPI DeleteDC(_In_ HDC)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
#define PS_SOLID
Definition: wingdi.h:586
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
#define WM_PAINT
Definition: winuser.h:1648
#define ODS_DISABLED
Definition: winuser.h:2583
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define BST_INDETERMINATE
Definition: winuser.h:198
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define WM_ERASEBKGND
Definition: winuser.h:1653
#define CS_VREDRAW
Definition: winuser.h:666
DWORD WINAPI GetSysColor(_In_ int)
#define BS_BITMAP
Definition: winuser.h:258
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1800
#define ODS_SELECTED
Definition: winuser.h:2581
#define BM_GETSTATE
Definition: winuser.h:1949
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
void WINAPI mouse_event(_In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ ULONG_PTR)
#define COLOR_BTNTEXT
Definition: winuser.h:944
#define IMAGE_BITMAP
Definition: winuser.h:211
#define GetWindowLongPtrW
Definition: winuser.h:4983
#define WM_ENABLE
Definition: winuser.h:1643
#define WM_KEYUP
Definition: winuser.h:1744
#define COLOR_GRAYTEXT
Definition: winuser.h:943
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define COLOR_WINDOWFRAME
Definition: winuser.h:930
#define DT_CENTER
Definition: winuser.h:527
#define ODA_DRAWENTIRE
Definition: winuser.h:2578
#define BS_RIGHT
Definition: winuser.h:274
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DLGC_BUTTON
Definition: winuser.h:2662
#define BST_UNCHECKED
Definition: winuser.h:199
#define BN_DOUBLECLICKED
Definition: winuser.h:1957
#define IMAGE_ICON
Definition: winuser.h:212
#define DFCS_BUTTONPUSH
Definition: winuser.h:501
#define BN_SETFOCUS
Definition: winuser.h:1962
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2414
#define WM_CAPTURECHANGED
Definition: winuser.h:1836
#define DSS_DISABLED
Definition: winuser.h:519
#define WM_CREATE
Definition: winuser.h:1636
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define DFCS_FLAT
Definition: winuser.h:510
#define BS_ICON
Definition: winuser.h:264
#define VK_SPACE
Definition: winuser.h:2255
#define BS_PUSHLIKE
Definition: winuser.h:272
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define BM_SETSTATE
Definition: winuser.h:1952
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define DT_SINGLELINE
Definition: winuser.h:540
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1806
#define BS_TYPEMASK
Definition: winuser.h:270
#define DFCS_BUTTONCHECK
Definition: winuser.h:496
#define CS_HREDRAW
Definition: winuser.h:661
#define ODA_FOCUS
Definition: winuser.h:2580
#define DFCS_INACTIVE
Definition: winuser.h:502
#define DLGC_UNDEFPUSHBUTTON
Definition: winuser.h:2658
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:695
#define WM_NCHITTEST
Definition: winuser.h:1714
#define DFC_BUTTON
Definition: winuser.h:476
#define BS_BOTTOM
Definition: winuser.h:259
#define BN_KILLFOCUS
Definition: winuser.h:1959
#define WM_SETFOCUS
Definition: winuser.h:1641
#define EDGE_ETCHED
Definition: winuser.h:452
#define BN_HILITE
Definition: winuser.h:1958
#define WM_MOUSEMOVE
Definition: winuser.h:1803
#define DT_NOCLIP
Definition: winuser.h:536
#define RDW_UPDATENOW
Definition: winuser.h:1231
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define BS_NOTIFY
Definition: winuser.h:268
#define DST_ICON
Definition: winuser.h:515
BOOL WINAPI TrackMouseEvent(_Inout_ LPTRACKMOUSEEVENT)
#define CS_DBLCLKS
Definition: winuser.h:659
#define WM_LBUTTONDOWN
Definition: winuser.h:1804
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1654
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2474
#define DLGC_DEFPUSHBUTTON
Definition: winuser.h:2657
#define WM_GETFONT
Definition: winuser.h:1679
#define BF_FLAT
Definition: winuser.h:471
#define WM_DRAWITEM
Definition: winuser.h:1673
#define WM_NCCREATE
Definition: winuser.h:1711
#define BM_SETCHECK
Definition: winuser.h:1950
#define BS_MULTILINE
Definition: winuser.h:267
#define BM_SETIMAGE
Definition: winuser.h:1951
#define BN_UNHILITE
Definition: winuser.h:1963
#define WM_CTLCOLORBTN
Definition: winuser.h:1797
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define WM_SETTEXT
Definition: winuser.h:1645
#define DFCS_MONO
Definition: winuser.h:511
HWND WINAPI GetNextDlgGroupItem(_In_ HWND, _In_opt_ HWND, _In_ BOOL)
#define DFCS_BUTTON3STATE
Definition: winuser.h:500
#define DT_LEFT
Definition: winuser.h:534
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DT_TOP
Definition: winuser.h:542
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define DLGC_RADIOBUTTON
Definition: winuser.h:2659
#define BS_FLAT
Definition: winuser.h:280
#define BS_LEFT
Definition: winuser.h:265
#define WM_SETFONT
Definition: winuser.h:1678
#define BM_CLICK
Definition: winuser.h:1946
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define DLGC_WANTARROWS
Definition: winuser.h:2652
#define DST_BITMAP
Definition: winuser.h:516
#define DT_WORDBREAK
Definition: winuser.h:544
#define BST_PUSHED
Definition: winuser.h:201
#define BM_GETIMAGE
Definition: winuser.h:1948
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define RDW_FRAME
Definition: winuser.h:1223
#define DFCS_BUTTONRADIO
Definition: winuser.h:499
#define BM_SETSTYLE
Definition: winuser.h:1953
#define BST_FOCUS
Definition: winuser.h:200
#define BS_VCENTER
Definition: winuser.h:279
HDC WINAPI GetDC(_In_opt_ HWND)
#define BS_TOP
Definition: winuser.h:277
#define DLGC_STATIC
Definition: winuser.h:2661
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define WM_LBUTTONUP
Definition: winuser.h:1805
#define BS_TEXT
Definition: winuser.h:276
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define DT_VCENTER
Definition: winuser.h:543
HWND WINAPI GetParent(_In_ HWND)
#define DT_BOTTOM
Definition: winuser.h:525
#define CS_GLOBALCLASS
Definition: winuser.h:660
#define WM_NCDESTROY
Definition: winuser.h:1712
#define ODA_SELECT
Definition: winuser.h:2579
#define HTTRANSPARENT
Definition: winuser.h:2509
#define DSS_NORMAL
Definition: winuser.h:517
#define GWLP_ID
Definition: winuser.h:871
#define DSS_HIDEPREFIX
Definition: winuser.h:522
#define MK_LBUTTON
Definition: winuser.h:2403
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define BN_CLICKED
Definition: winuser.h:1954
#define WM_DESTROY
Definition: winuser.h:1637
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
#define DFCS_CHECKED
Definition: winuser.h:504
#define ODT_BUTTON
Definition: winuser.h:2576
#define WM_KEYDOWN
Definition: winuser.h:1743
#define DT_RIGHT
Definition: winuser.h:538
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
#define BS_CENTER
Definition: winuser.h:260
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define DT_CALCRECT
Definition: winuser.h:526
#define DT_HIDEPREFIX
Definition: winuser.h:547
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define SetWindowLongPtrW
Definition: winuser.h:5512
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define BF_RECT
Definition: winuser.h:462
BOOL WINAPI DrawStateW(_In_ HDC, _In_opt_ HBRUSH, _In_opt_ DRAWSTATEPROC, _In_ LPARAM, _In_ WPARAM, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define GWL_STYLE
Definition: winuser.h:863
#define CS_PARENTDC
Definition: winuser.h:664
BOOL(CALLBACK * DRAWSTATEPROC)(HDC, LPARAM, WPARAM, int, int)
Definition: winuser.h:3015
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define DFCS_PUSHED
Definition: winuser.h:503
#define WM_KILLFOCUS
Definition: winuser.h:1642
#define ODS_FOCUS
Definition: winuser.h:2585
#define RDW_INVALIDATE
Definition: winuser.h:1225
#define WM_GETDLGCODE
Definition: winuser.h:1717
#define DSS_MONO
Definition: winuser.h:521
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_CHECKED
Definition: winuser.h:197
#define COLOR_BTNFACE
Definition: winuser.h:939
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define BM_GETCHECK
Definition: winuser.h:1947
#define WS_EX_RIGHT
Definition: winuser.h:400
#define GWL_EXSTYLE
Definition: winuser.h:862