ReactOS 0.4.17-dev-1321-g5c122a9
button.c File Reference
#include <user32.h>
Include dependency graph for button.c:

Go to the source code of this file.

Macros

#define STATE_GWL_OFFSET   0
 
#define HFONT_GWL_OFFSET   (sizeof(LONG))
 
#define HICON_GWL_OFFSET   (HFONT_GWL_OFFSET+sizeof(HFONT))
 
#define NB_EXTRA_BYTES   (HICON_GWL_OFFSET+sizeof(HICON))
 
#define BUTTON_NSTATES   0x0F
 
#define BUTTON_BTNPRESSED   0x40
 
#define BUTTON_UNKNOWN2   0x20
 
#define BUTTON_UNKNOWN3   0x10
 
#define BUTTON_NOTIFY_PARENT(hWnd, code)
 
#define MAX_BTN_TYPE   16
 

Typedefs

typedef void(* pfPaint) (HWND hwnd, HDC hdc, UINT action)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (button)
 
static UINT BUTTON_CalcLabelRect (HWND hwnd, HDC hdc, RECT *rc)
 
static void PB_Paint (HWND hwnd, HDC hDC, UINT action)
 
static void CB_Paint (HWND hwnd, HDC hDC, UINT action)
 
static void GB_Paint (HWND hwnd, HDC hDC, UINT action)
 
static void UB_Paint (HWND hwnd, HDC hDC, UINT action)
 
static void OB_Paint (HWND hwnd, HDC hDC, UINT action)
 
static void BUTTON_CheckAutoRadioButton (HWND hwnd)
 
static LONG get_button_state (HWND hwnd)
 
static LONG set_button_state (HWND hwnd, LONG state)
 
static HFONT get_button_font (HWND hwnd)
 
static HFONT set_button_font (HWND hwnd, HFONT font)
 
static HANDLE get_button_icon (HWND hwnd)
 
static HANDLE set_button_icon (HWND hwnd, HANDLE icon)
 
static UINT get_button_type (LONG window_style)
 
static void paint_button (HWND hwnd, LONG style, UINT action)
 
static WCHAR * get_button_text (HWND hwnd)
 
LRESULT WINAPI ButtonWndProc_common (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode)
 
static UINT BUTTON_BStoDT (DWORD style, DWORD ex_style)
 
static BOOL CALLBACK BUTTON_DrawTextCallback (HDC hdc, LPARAM lp, WPARAM wp, int cx, int cy)
 
static void BUTTON_DrawLabel (HWND hwnd, HDC hdc, UINT dtFlags, const RECT *rc)
 

Variables

static const WORD maxCheckState [MAX_BTN_TYPE]
 
static const pfPaint btnPaintFunc [MAX_BTN_TYPE]
 

Macro Definition Documentation

◆ BUTTON_BTNPRESSED

#define BUTTON_BTNPRESSED   0x40

Definition at line 57 of file button.c.

◆ BUTTON_NOTIFY_PARENT

#define BUTTON_NOTIFY_PARENT (   hWnd,
  code 
)
Value:
do { /* Notify parent which has created this button control */ \
TRACE("notification " #code " sent to hwnd=%p\n", GetParent(hWnd)); \
SendMessageW(GetParent(hWnd), WM_COMMAND, \
(LPARAM)(hWnd)); \
} while(0)
HWND hWnd
Definition: settings.c:17
LONG_PTR LPARAM
Definition: minwindef.h:175
#define MAKEWPARAM(l, h)
Definition: winuser.h:4117
#define GetWindowLongPtrW
Definition: winuser.h:4983
#define WM_COMMAND
Definition: winuser.h:1768
HWND WINAPI GetParent(_In_ HWND)
#define GWLP_ID
Definition: winuser.h:871
Definition: inflate.c:139

Definition at line 64 of file button.c.

◆ BUTTON_NSTATES

#define BUTTON_NSTATES   0x0F

Definition at line 56 of file button.c.

◆ BUTTON_UNKNOWN2

#define BUTTON_UNKNOWN2   0x20

Definition at line 58 of file button.c.

◆ BUTTON_UNKNOWN3

#define BUTTON_UNKNOWN3   0x10

Definition at line 59 of file button.c.

◆ HFONT_GWL_OFFSET

#define HFONT_GWL_OFFSET   (sizeof(LONG))

Definition at line 46 of file button.c.

◆ HICON_GWL_OFFSET

#define HICON_GWL_OFFSET   (HFONT_GWL_OFFSET+sizeof(HFONT))

Definition at line 47 of file button.c.

◆ MAX_BTN_TYPE

#define MAX_BTN_TYPE   16

Definition at line 80 of file button.c.

◆ NB_EXTRA_BYTES

#define NB_EXTRA_BYTES   (HICON_GWL_OFFSET+sizeof(HICON))

Definition at line 52 of file button.c.

◆ STATE_GWL_OFFSET

#define STATE_GWL_OFFSET   0

Definition at line 45 of file button.c.

Typedef Documentation

◆ pfPaint

typedef void(* pfPaint) (HWND hwnd, HDC hdc, UINT action)

Definition at line 98 of file button.c.

Function Documentation

◆ BUTTON_BStoDT()

static UINT BUTTON_BStoDT ( DWORD  style,
DWORD  ex_style 
)
static

Definition at line 656 of file button.c.

657{
658 UINT dtStyle = DT_NOCLIP; /* We use SelectClipRgn to limit output */
659
660 /* "Convert" pushlike buttons to pushbuttons */
661 if (style & BS_PUSHLIKE)
662 style &= ~BS_TYPEMASK;
663
664 if (!(style & BS_MULTILINE))
665 dtStyle |= DT_SINGLELINE;
666 else
667 dtStyle |= DT_WORDBREAK;
668
669 switch (style & BS_CENTER)
670 {
671 case BS_LEFT: /* DT_LEFT is 0 */ break;
672 case BS_RIGHT: dtStyle |= DT_RIGHT; break;
673 case BS_CENTER: dtStyle |= DT_CENTER; break;
674 default:
675 /* Pushbutton's text is centered by default */
677 /* all other flavours have left aligned text */
678 }
679
680 if (ex_style & WS_EX_RIGHT) dtStyle = DT_RIGHT | (dtStyle & ~(DT_LEFT | DT_CENTER));
681
682 /* DrawText ignores vertical alignment for multiline text,
683 * but we use these flags to align label manually.
684 */
686 {
687 switch (style & BS_VCENTER)
688 {
689 case BS_TOP: /* DT_TOP is 0 */ break;
690 case BS_BOTTOM: dtStyle |= DT_BOTTOM; break;
691 case BS_VCENTER: /* fall through */
692 default: dtStyle |= DT_VCENTER; break;
693 }
694 }
695 else
696 /* GroupBox's text is always single line and is top aligned. */
697 dtStyle |= DT_SINGLELINE;
698
699 return dtStyle;
700}
static UINT get_button_type(LONG window_style)
Definition: button.c:214
unsigned int UINT
Definition: sysinfo.c:13
#define BS_GROUPBOX
Definition: pedump.c:658
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
#define DT_CENTER
Definition: winuser.h:527
#define BS_RIGHT
Definition: winuser.h:274
#define BS_PUSHLIKE
Definition: winuser.h:272
#define DT_SINGLELINE
Definition: winuser.h:540
#define BS_BOTTOM
Definition: winuser.h:259
#define DT_NOCLIP
Definition: winuser.h:536
#define BS_MULTILINE
Definition: winuser.h:267
#define DT_LEFT
Definition: winuser.h:534
#define BS_LEFT
Definition: winuser.h:265
#define DT_WORDBREAK
Definition: winuser.h:544
#define BS_VCENTER
Definition: winuser.h:279
#define BS_TOP
Definition: winuser.h:277
#define DT_VCENTER
Definition: winuser.h:543
#define DT_BOTTOM
Definition: winuser.h:525
#define DT_RIGHT
Definition: winuser.h:538
#define BS_CENTER
Definition: winuser.h:260
#define WS_EX_RIGHT
Definition: winuser.h:400
Definition: style.c:91

◆ BUTTON_CalcLabelRect()

static UINT BUTTON_CalcLabelRect ( HWND  hwnd,
HDC  hdc,
RECT *  rc 
)
static

Definition at line 712 of file button.c.

713{
715 LONG ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
716 WCHAR *text;
717 ICONINFO iconInfo;
718 BITMAP bm;
719 UINT dtStyle = BUTTON_BStoDT( style, ex_style );
720 RECT r = *rc;
721 INT n;
722
723 /* Calculate label rectangle according to label type */
724 switch (style & (BS_ICON|BS_BITMAP))
725 {
726 case BS_TEXT:
727 {
728 HFONT hFont, hPrevFont = 0;
729
730 if (!(text = get_button_text( hwnd ))) goto empty_rect;
731 if (!text[0])
732 {
734 goto empty_rect;
735 }
736
737 if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hdc, hFont );
738#ifdef __REACTOS__
739 DrawTextW(hdc, text, -1, &r, ((dtStyle | DT_CALCRECT) & ~(DT_VCENTER | DT_BOTTOM)));
740#else
741 DrawTextW(hdc, text, -1, &r, dtStyle | DT_CALCRECT);
742#endif
743 if (hPrevFont) SelectObject( hdc, hPrevFont );
745#ifdef __REACTOS__
746 if (get_ui_state(hwnd) & UISF_HIDEACCEL)
747 dtStyle |= DT_HIDEPREFIX;
748#endif
749 break;
750 }
751
752 case BS_ICON:
753 if (!GetIconInfo( get_button_icon( hwnd ), &iconInfo ))
754 goto empty_rect;
755
756 GetObjectW (iconInfo.hbmColor, sizeof(BITMAP), &bm);
757
758 r.right = r.left + bm.bmWidth;
759 r.bottom = r.top + bm.bmHeight;
760
761 DeleteObject(iconInfo.hbmColor);
762 DeleteObject(iconInfo.hbmMask);
763 break;
764
765 case BS_BITMAP:
766 if (!GetObjectW( get_button_icon( hwnd ), sizeof(BITMAP), &bm))
767 goto empty_rect;
768
769 r.right = r.left + bm.bmWidth;
770 r.bottom = r.top + bm.bmHeight;
771 break;
772
773 default:
774 empty_rect:
775 rc->right = r.left;
776 rc->bottom = r.top;
777 return (UINT)-1;
778 }
779
780 /* Position label inside bounding rectangle according to
781 * alignment flags. (calculated rect is always left-top aligned).
782 * If label is aligned to any side - shift label in opposite
783 * direction to leave extra space for focus rectangle.
784 */
785 switch (dtStyle & (DT_CENTER|DT_RIGHT))
786 {
787 case DT_LEFT: r.left++; r.right++; break;
788 case DT_CENTER: n = r.right - r.left;
789 r.left = rc->left + ((rc->right - rc->left) - n) / 2;
790 r.right = r.left + n; break;
791 case DT_RIGHT: n = r.right - r.left;
792 r.right = rc->right - 1;
793 r.left = r.right - n;
794 break;
795 }
796
797 switch (dtStyle & (DT_VCENTER|DT_BOTTOM))
798 {
799 case DT_TOP: r.top++; r.bottom++; break;
800 case DT_VCENTER: n = r.bottom - r.top;
801#ifdef __REACTOS__
802 r.top = rc->top + ((rc->bottom - 1 - rc->top) - n) / 2;
803#else
804 r.top = rc->top + ((rc->bottom - rc->top) - n) / 2;
805#endif
806 r.bottom = r.top + n; break;
807 case DT_BOTTOM: n = r.bottom - r.top;
808 r.bottom = rc->bottom - 1;
809 r.top = r.bottom - n;
810 break;
811 }
812
813 *rc = r;
814 return dtStyle;
815}
HFONT hFont
Definition: main.c:53
static UINT BUTTON_BStoDT(DWORD style, DWORD ex_style)
Definition: button.c:273
static WCHAR * get_button_text(const BUTTON_INFO *infoPtr)
Definition: button.c:233
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
const WCHAR * text
Definition: package.c:1826
pKey DeleteObject()
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
HDC hdc
Definition: main.c:9
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
#define BS_BITMAP
Definition: winuser.h:258
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2414
#define BS_ICON
Definition: winuser.h:264
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define DT_TOP
Definition: winuser.h:542
#define BS_TEXT
Definition: winuser.h:276
#define DT_CALCRECT
Definition: winuser.h:526
#define DT_HIDEPREFIX
Definition: winuser.h:547
#define GWL_STYLE
Definition: winuser.h:863
#define GWL_EXSTYLE
Definition: winuser.h:862
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
HBITMAP hbmColor
Definition: winuser.h:3235
HBITMAP hbmMask
Definition: winuser.h:3234
LONG bmHeight
Definition: wingdi.h:1869
LONG bmWidth
Definition: wingdi.h:1868
int32_t INT
Definition: typedefs.h:58
static HANDLE get_button_icon(HWND hwnd)
Definition: button.c:153
static HFONT get_button_font(HWND hwnd)
Definition: button.c:143
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546

◆ BUTTON_CheckAutoRadioButton()

static void BUTTON_CheckAutoRadioButton ( HWND  hwnd)
static

Definition at line 1154 of file button.c.

1155{
1156 HWND parent, sibling, start;
1157
1159 /* make sure that starting control is not disabled or invisible */
1160 start = sibling = hwnd;
1161 do
1162 {
1163 if (!sibling) break;
1164#ifdef __REACTOS__
1166#else
1167 if (SendMessageW( sibling, WM_GETDLGCODE, 0, 0 ) == (DLGC_BUTTON | DLGC_RADIOBUTTON))
1168#endif
1169 SendMessageW( sibling, BM_SETCHECK, sibling == hwnd ? BST_CHECKED : BST_UNCHECKED, 0 );
1170 sibling = GetNextDlgGroupItem( parent, sibling, FALSE );
1171 } while (sibling != start);
1172}
#define FALSE
Definition: types.h:117
r parent
Definition: btrfs.c:3010
GLuint start
Definition: gl.h:1545
#define DLGC_BUTTON
Definition: winuser.h:2662
#define BST_UNCHECKED
Definition: winuser.h:199
#define BM_SETCHECK
Definition: winuser.h:1950
HWND WINAPI GetNextDlgGroupItem(_In_ HWND, _In_opt_ HWND, _In_ BOOL)
#define DLGC_RADIOBUTTON
Definition: winuser.h:2659
#define WM_GETDLGCODE
Definition: winuser.h:1717
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_CHECKED
Definition: winuser.h:197

◆ BUTTON_DrawLabel()

static void BUTTON_DrawLabel ( HWND  hwnd,
HDC  hdc,
UINT  dtFlags,
const RECT *  rc 
)
static

Definition at line 838 of file button.c.

839{
840 DRAWSTATEPROC lpOutputProc = NULL;
841 LPARAM lp;
842 WPARAM wp = 0;
843 HBRUSH hbr = 0;
847 WCHAR *text = NULL;
848
849 /* FIXME: To draw disabled label in Win31 look-and-feel, we probably
850 * must use DSS_MONO flag and COLOR_GRAYTEXT brush (or maybe DSS_UNION).
851 * I don't have Win31 on hand to verify that, so I leave it as is.
852 */
853
855 {
857 flags |= DSS_MONO;
858 }
859
860 switch (style & (BS_ICON|BS_BITMAP))
861 {
862 case BS_TEXT:
863 /* DST_COMPLEX -- is 0 */
864 lpOutputProc = BUTTON_DrawTextCallback;
865 if (!(text = get_button_text( hwnd ))) return;
866 lp = (LPARAM)text;
867 wp = dtFlags;
868
869#ifdef __REACTOS__
870 if (dtFlags & DT_HIDEPREFIX)
872#endif
873 break;
874
875 case BS_ICON:
876 flags |= DST_ICON;
877 lp = (LPARAM)get_button_icon( hwnd );
878 break;
879
880 case BS_BITMAP:
881 flags |= DST_BITMAP;
882 lp = (LPARAM)get_button_icon( hwnd );
883 break;
884
885 default:
886 return;
887 }
888
889 DrawStateW(hdc, hbr, lpOutputProc, lp, wp, rc->left, rc->top,
890 rc->right - rc->left, rc->bottom - rc->top, flags);
892}
static int state
Definition: maze.c:121
#define NULL
Definition: types.h:112
static BOOL CALLBACK BUTTON_DrawTextCallback(HDC hdc, LPARAM lp, WPARAM wp, int cx, int cy)
Definition: button.c:1414
GLbitfield flags
Definition: glext.h:7161
UINT_PTR WPARAM
Definition: minwindef.h:174
#define BST_INDETERMINATE
Definition: winuser.h:198
#define COLOR_GRAYTEXT
Definition: winuser.h:943
#define DSS_DISABLED
Definition: winuser.h:519
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define DST_ICON
Definition: winuser.h:515
#define DST_BITMAP
Definition: winuser.h:516
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define DSS_NORMAL
Definition: winuser.h:517
#define DSS_HIDEPREFIX
Definition: winuser.h:522
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)
BOOL(CALLBACK * DRAWSTATEPROC)(HDC, LPARAM, WPARAM, int, int)
Definition: winuser.h:3015
#define DSS_MONO
Definition: winuser.h:521
static LONG get_button_state(HWND hwnd)
Definition: button.c:133

◆ BUTTON_DrawTextCallback()

static BOOL CALLBACK BUTTON_DrawTextCallback ( HDC  hdc,
LPARAM  lp,
WPARAM  wp,
int  cx,
int  cy 
)
static

Definition at line 823 of file button.c.

824{
825 RECT rc;
826
827 SetRect(&rc, 0, 0, cx, cy);
828 DrawTextW(hdc, (LPCWSTR)lp, -1, &rc, (UINT)wp);
829 return TRUE;
830}
#define TRUE
Definition: types.h:120
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
const uint16_t * LPCWSTR
Definition: typedefs.h:57

◆ ButtonWndProc_common()

LRESULT WINAPI ButtonWndProc_common ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL  unicode 
)

Definition at line 224 of file button.c.

225{
226 RECT rect;
227 POINT pt;
229 UINT btn_type = get_button_type( style );
230 LONG state;
231 HANDLE oldHbitmap;
232
233 if (!IsWindow( hWnd )) return 0;
235
236 pt.x = (short)LOWORD(lParam);
237 pt.y = (short)HIWORD(lParam);
238
239 switch (uMsg)
240 {
241 case WM_GETDLGCODE:
242 switch(btn_type)
243 {
244 case BS_USERBUTTON:
247 case BS_RADIOBUTTON:
249 case BS_GROUPBOX: return DLGC_STATIC;
250 default: return DLGC_BUTTON;
251 }
252
253 case WM_ENABLE:
254 paint_button( hWnd, btn_type, ODA_DRAWENTIRE );
255 break;
256
257 case WM_CREATE:
258 if (btn_type >= MAX_BTN_TYPE)
259 return -1; /* abort */
260
261 /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
262#ifdef __REACTOS__
263 if (btn_type == BS_USERBUTTON )
264 {
265 style = (style & ~BS_TYPEMASK) | BS_PUSHBUTTON;
267 }
268#else
270#endif
272#ifdef __REACTOS__
273 button_update_uistate( hWnd, unicode );
274#endif
275 return 0;
276
277#ifdef __REACTOS__
278 case WM_NCDESTROY:
280 case WM_DESTROY:
281 break;
282#endif
283
284 case WM_ERASEBKGND:
285 if (btn_type == BS_OWNERDRAW)
286 {
287 HDC hdc = (HDC)wParam;
288 RECT rc;
289 HBRUSH hBrush;
291 if (!parent) parent = hWnd;
292#ifdef __REACTOS__
294#else
295 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hdc, (LPARAM)hWnd);
296 if (!hBrush) /* did the app forget to call defwindowproc ? */
297 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN,
298 (WPARAM)hdc, (LPARAM)hWnd);
299#endif
300 GetClientRect(hWnd, &rc);
301 FillRect(hdc, &rc, hBrush);
302 }
303 return 1;
304
305 case WM_PRINTCLIENT:
306 case WM_PAINT:
307 {
308 PAINTSTRUCT ps;
310 if (btnPaintFunc[btn_type])
311 {
312 int nOldMode = SetBkMode( hdc, OPAQUE );
313 (btnPaintFunc[btn_type])( hWnd, hdc, ODA_DRAWENTIRE );
314 SetBkMode(hdc, nOldMode); /* reset painting mode */
315 }
316 if (!wParam) NtUserEndPaint( hWnd, &ps );
317 break;
318 }
319
320 case WM_KEYDOWN:
321 if (wParam == VK_SPACE)
322 {
326 }
327 break;
328
329 case WM_LBUTTONDBLCLK:
330 if(style & BS_NOTIFY ||
331 btn_type == BS_RADIOBUTTON ||
332 btn_type == BS_USERBUTTON ||
333 btn_type == BS_OWNERDRAW)
334 {
336 break;
337 }
338 /* fall through */
339 case WM_LBUTTONDOWN:
344 break;
345
346 case WM_KEYUP:
347 if (wParam != VK_SPACE)
348 break;
349 /* fall through */
350 case WM_LBUTTONUP:
351#ifdef __REACTOS__
352 {
353 BOOL TellParent = FALSE;
354#endif
356 if (!(state & BUTTON_BTNPRESSED)) break;
359 if (!(state & BST_PUSHED))
360 {
362 break;
363 }
366 if (uMsg == WM_KEYUP || PtInRect( &rect, pt ))
367 {
369 switch(btn_type)
370 {
371 case BS_AUTOCHECKBOX:
373 break;
376 break;
377 case BS_AUTO3STATE:
379 (state & BST_INDETERMINATE) ? 0 : ((state & 3) + 1), 0 );
380 break;
381 }
382
383#ifdef __REACTOS__
384 TellParent = TRUE; // <---- Fix CORE-10194, Notify parent after capture is released.
385#else
388#endif
389 }
390#ifndef __REACTOS__
391 else
392 {
394 }
395#else
397 if (TellParent) BUTTON_NOTIFY_PARENT(hWnd, BN_CLICKED);
398 }
399#endif
400 break;
401
403 TRACE("WM_CAPTURECHANGED %p\n", hWnd);
404 if (hWnd == (HWND)lParam) break;
407 {
411 }
412 break;
413
414 case WM_MOUSEMOVE:
415 if ((wParam & MK_LBUTTON) && GetCapture() == hWnd)
416 {
419 }
420 break;
421
422 case WM_SETTEXT:
423 {
424 /* Clear an old text here as Windows does */
426 {
428 HBRUSH hbrush;
429 RECT client, rc;
431 UINT message = (btn_type == BS_PUSHBUTTON ||
432 btn_type == BS_DEFPUSHBUTTON ||
433 btn_type == BS_USERBUTTON ||
434 btn_type == BS_OWNERDRAW) ?
436
437 if (!parent) parent = hWnd;
438#ifdef __REACTOS__
440#else
442 (WPARAM)hdc, (LPARAM)hWnd);
443 if (!hbrush) /* did the app forget to call DefWindowProc ? */
445 (WPARAM)hdc, (LPARAM)hWnd);
446#endif
447
449 rc = client;
450 /* FIXME: check other BS_* handlers */
451 if (btn_type == BS_GROUPBOX)
452 InflateRect(&rc, -7, 1); /* GB_Paint does this */
454 /* Clip by client rect bounds */
455 if (rc.right > client.right) rc.right = client.right;
456 if (rc.bottom > client.bottom) rc.bottom = client.bottom;
457 FillRect(hdc, &rc, hbrush);
459 }
460
461 if (unicode) DefWindowProcW( hWnd, WM_SETTEXT, wParam, lParam );
463 if (btn_type == BS_GROUPBOX) /* Yes, only for BS_GROUPBOX */
465 else
466 paint_button( hWnd, btn_type, ODA_DRAWENTIRE );
467 return 1; /* success. FIXME: check text length */
468 }
469
470 case WM_SETFONT:
471 set_button_font( hWnd, (HFONT)wParam );
473 break;
474
475 case WM_GETFONT:
476 return (LRESULT)get_button_font( hWnd );
477
478 case WM_SETFOCUS:
479 TRACE("WM_SETFOCUS %p\n",hWnd);
481 paint_button( hWnd, btn_type, ODA_FOCUS );
482 if (style & BS_NOTIFY)
484
485 if (((btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON)) &&
487 {
489 }
490 break;
491
492 case WM_KILLFOCUS:
493 TRACE("WM_KILLFOCUS %p\n",hWnd);
496 paint_button( hWnd, btn_type, ODA_FOCUS );
497
498 if ((state & BUTTON_BTNPRESSED) && GetCapture() == hWnd)
500 if (style & BS_NOTIFY)
502
504 break;
505
508 break;
509
510 case BM_SETSTYLE:
511 btn_type = wParam & BS_TYPEMASK;
512#ifdef __REACTOS__
513 style = (style & ~BS_TYPEMASK) | btn_type;
515#else
517#endif
518
519 NtUserNotifyWinEvent( EVENT_OBJECT_STATECHANGE, hWnd, OBJID_CLIENT, 0 );
520
521 /* Only redraw if lParam flag is set.*/
522 if (lParam)
524
525 break;
526
527 case BM_CLICK:
528#ifdef __REACTOS__
530 if (state & BUTTON_BMCLICK)
531 break;
532 set_button_state(hWnd, state | BUTTON_BMCLICK); // Tracked in STATE_GWL_OFFSET.
533#endif
536#ifdef __REACTOS__
538 if (!(state & BUTTON_BMCLICK)) break;
539 state &= ~BUTTON_BMCLICK;
541#endif
542 break;
543
544 case BM_SETIMAGE:
545 /* Check that image format matches button style */
546 switch (style & (BS_BITMAP|BS_ICON))
547 {
548 case BS_BITMAP:
549 if (wParam != IMAGE_BITMAP) return 0;
550 break;
551 case BS_ICON:
552 if (wParam != IMAGE_ICON) return 0;
553 break;
554 default:
555 return 0;
556 }
557 oldHbitmap = set_button_icon( hWnd, (HANDLE)lParam );
559 return (LRESULT)oldHbitmap;
560
561 case BM_GETIMAGE:
562 return (LRESULT)get_button_icon( hWnd );
563
564 case BM_GETCHECK:
565 return get_button_state( hWnd ) & 3;
566
567 case BM_SETCHECK:
568 if (wParam > maxCheckState[btn_type]) wParam = maxCheckState[btn_type];
570 if ((btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON))
571 {
572#ifdef __REACTOS__
573 if (wParam) style |= WS_TABSTOP;
574 else style &= ~WS_TABSTOP;
576#else
579#endif
580 }
581 if ((state & 3) != wParam)
582 {
583 set_button_state( hWnd, (state & ~3) | wParam );
584 paint_button( hWnd, btn_type, ODA_SELECT );
585
586 NtUserNotifyWinEvent( EVENT_OBJECT_STATECHANGE, hWnd, OBJID_CLIENT, 0 );
587 }
588 break;
589
590 case BM_GETSTATE:
591 return get_button_state( hWnd );
592
593 case BM_SETSTATE:
595 if (wParam)
597 else
599
600 paint_button( hWnd, btn_type, ODA_SELECT );
601
602 NtUserNotifyWinEvent( EVENT_OBJECT_STATECHANGE, hWnd, OBJID_CLIENT, 0 );
603
604 break;
605
606#ifdef __REACTOS__
607 case WM_UPDATEUISTATE:
608 if (unicode)
610 else
612
613 if (button_update_uistate(hWnd, unicode))
614 paint_button( hWnd, btn_type, ODA_DRAWENTIRE );
615 break;
616#endif
617
618 case WM_NCHITTEST:
619 if(btn_type == BS_GROUPBOX) return HTTRANSPARENT;
620 /* fall through */
621 default:
622 return unicode ? DefWindowProcW(hWnd, uMsg, wParam, lParam) :
624 }
625 return 0;
626}
static HBRUSH hbrush
RECT rect
Definition: combotst.c:67
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define BUTTON_NSTATES
Definition: button.c:77
#define BUTTON_NOTIFY_PARENT(hWnd, code)
Definition: button.c:85
static const pfPaint btnPaintFunc[MAX_BTN_TYPE]
Definition: button.c:157
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
#define BUTTON_BTNPRESSED
Definition: button.c:78
static const WORD maxCheckState[MAX_BTN_TYPE]
Definition: button.c:125
#define MAX_BTN_TYPE
Definition: button.c:123
static void BUTTON_CheckAutoRadioButton(HWND hwnd)
Definition: button.c:1753
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define pt(x, y)
Definition: drawing.c:79
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID NTAPI NtUserNotifyWinEvent(DWORD Event, HWND hWnd, LONG idObject, LONG idChild)
Definition: event.c:254
#define FNID_DESTROY
Definition: ntuser.h:905
HWND NTAPI NtUserSetFocus(HWND hWnd)
Definition: focus.c:1717
BOOL NTAPI NtUserInvalidateRect(HWND hWnd, CONST RECT *lpRect, BOOL bErase)
Definition: painting.c:2541
DWORD NTAPI NtUserAlterWindowStyle(HWND hWnd, DWORD Index, LONG NewValue)
Definition: window.c:4092
BOOL NTAPI NtUserEndPaint(HWND hWnd, CONST PAINTSTRUCT *lPs)
Definition: painting.c:1660
HDC NTAPI NtUserBeginPaint(HWND hWnd, PAINTSTRUCT *lPs)
Definition: painting.c:1614
HWND NTAPI NtUserSetCapture(HWND Wnd)
Definition: focus.c:1699
BOOL NTAPI NtUserSetWindowFNID(HWND hWnd, WORD fnID)
Definition: window.c:4335
HDC NTAPI NtUserGetDC(HWND hWnd)
Definition: windc.c:1014
LONG_PTR LRESULT
Definition: minwindef.h:176
static HDC
Definition: imagelist.c:88
#define LOWORD(l)
Definition: pedump.c:82
#define BS_AUTORADIOBUTTON
Definition: pedump.c:660
#define BS_USERBUTTON
Definition: pedump.c:659
#define WS_TABSTOP
Definition: pedump.c:634
#define BS_AUTOCHECKBOX
Definition: pedump.c:654
#define BS_OWNERDRAW
Definition: pedump.c:661
#define BS_AUTO3STATE
Definition: pedump.c:657
#define BS_RADIOBUTTON
Definition: pedump.c:655
#define BS_PUSHBUTTON
Definition: pedump.c:651
#define WM_PAINT
Definition: winuser.h:1648
#define WM_ERASEBKGND
Definition: winuser.h:1653
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1800
#define BM_GETSTATE
Definition: winuser.h:1949
#define IMAGE_BITMAP
Definition: winuser.h:211
#define WM_ENABLE
Definition: winuser.h:1643
#define WM_KEYUP
Definition: winuser.h:1744
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define ODA_DRAWENTIRE
Definition: winuser.h:2578
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BN_DOUBLECLICKED
Definition: winuser.h:1957
#define IMAGE_ICON
Definition: winuser.h:212
#define BN_SETFOCUS
Definition: winuser.h:1962
#define WM_CAPTURECHANGED
Definition: winuser.h:1836
#define WM_CREATE
Definition: winuser.h:1636
#define VK_SPACE
Definition: winuser.h:2255
#define BM_SETSTATE
Definition: winuser.h:1952
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1806
#define BS_TYPEMASK
Definition: winuser.h:270
#define ODA_FOCUS
Definition: winuser.h:2580
#define DLGC_UNDEFPUSHBUTTON
Definition: winuser.h:2658
#define WM_NCHITTEST
Definition: winuser.h:1714
#define BN_KILLFOCUS
Definition: winuser.h:1959
#define WM_SETFOCUS
Definition: winuser.h:1641
#define WM_MOUSEMOVE
Definition: winuser.h:1803
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define BS_NOTIFY
Definition: winuser.h:268
#define WM_LBUTTONDOWN
Definition: winuser.h:1804
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1654
#define DLGC_DEFPUSHBUTTON
Definition: winuser.h:2657
#define WM_GETFONT
Definition: winuser.h:1679
#define WM_NCCREATE
Definition: winuser.h:1711
#define BM_SETIMAGE
Definition: winuser.h:1951
#define WM_CTLCOLORBTN
Definition: winuser.h:1797
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define WM_SETTEXT
Definition: winuser.h:1645
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define WM_SETFONT
Definition: winuser.h:1678
#define BM_CLICK
Definition: winuser.h:1946
#define BST_PUSHED
Definition: winuser.h:201
#define BM_GETIMAGE
Definition: winuser.h:1948
#define BM_SETSTYLE
Definition: winuser.h:1953
#define BST_FOCUS
Definition: winuser.h:200
#define DLGC_STATIC
Definition: winuser.h:2661
#define WM_LBUTTONUP
Definition: winuser.h:1805
#define WM_NCDESTROY
Definition: winuser.h:1712
#define ODA_SELECT
Definition: winuser.h:2579
#define HTTRANSPARENT
Definition: winuser.h:2509
#define MK_LBUTTON
Definition: winuser.h:2403
#define BN_CLICKED
Definition: winuser.h:1954
#define WM_DESTROY
Definition: winuser.h:1637
#define WM_KEYDOWN
Definition: winuser.h:1743
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define WM_KILLFOCUS
Definition: winuser.h:1642
#define BM_GETCHECK
Definition: winuser.h:1947
#define WM_PRINTCLIENT
Definition: richedit.h:70
static FILE * client
Definition: client.c:37
#define TRACE(s)
Definition: solgame.cpp:4
Definition: tftpd.h:60
#define HIWORD(l)
Definition: typedefs.h:247
#define NtUserReleaseDC(HWND, HDC)
Definition: user_x.h:120
#define NTUSER_WNDPROC_BUTTON
Definition: user_x.h:137
#define MAKE_FNID(index)
Definition: user_x.h:143
#define NtUserReleaseCapture()
Definition: user_x.h:121
HBRUSH FASTCALL GetControlColor(PWND pwndParent, PWND pwnd, HDC hdc, UINT CtlMsg)
Definition: misc.c:153
static HANDLE set_button_icon(HWND hwnd, HANDLE icon)
Definition: button.c:158
static HFONT set_button_font(HWND hwnd, HFONT font)
Definition: button.c:148
static LONG set_button_state(HWND hwnd, LONG state)
Definition: button.c:138
#define OBJID_CLIENT
Definition: winable.h:19
#define OPAQUE
Definition: wingdi.h:949
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056

Referenced by RegisterClientPFN().

◆ CB_Paint()

static void CB_Paint ( HWND  hwnd,
HDC  hDC,
UINT  action 
)
static

Definition at line 1003 of file button.c.

1004{
1005 RECT rbox, rtext, client;
1006 HBRUSH hBrush;
1007 int delta, text_offset, checkBoxWidth, checkBoxHeight;
1008 UINT dtFlags;
1009 HFONT hFont;
1012 LONG ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
1013 HWND parent;
1014 HRGN hrgn;
1015
1016 if (style & BS_PUSHLIKE)
1017 {
1018 PB_Paint( hwnd, hDC, action );
1019 return;
1020 }
1021
1023 rbox = rtext = client;
1024
1025#ifdef __REACTOS__
1026 checkBoxWidth = 12 * GetDeviceCaps( hDC, LOGPIXELSX ) / 96 + 1;
1027 checkBoxHeight = 12 * GetDeviceCaps( hDC, LOGPIXELSY ) / 96 + 1;
1028#else
1029 checkBoxWidth = 12 * GetDpiForWindow( hwnd ) / 96 + 1;
1030 checkBoxHeight = 12 * GetDpiForWindow( hwnd ) / 96 + 1;
1031#endif
1032
1034 GetCharWidthW( hDC, '0', '0', &text_offset );
1035 text_offset /= 2;
1036
1038 if (!parent) parent = hwnd;
1039#ifdef __REACTOS__
1041#else
1042 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC,
1043 (WPARAM)hDC, (LPARAM)hwnd);
1044 if (!hBrush) /* did the app forget to call defwindowproc ? */
1045 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
1046 (WPARAM)hDC, (LPARAM)hwnd );
1047#endif
1049
1050 if (style & BS_LEFTTEXT || ex_style & WS_EX_RIGHT)
1051 {
1052 rtext.right -= checkBoxWidth + text_offset;
1053 rbox.left = rbox.right - checkBoxWidth;
1054 }
1055 else
1056 {
1057 rtext.left += checkBoxWidth + text_offset;
1058 rbox.right = checkBoxWidth;
1059 }
1060
1061 /* Since WM_ERASEBKGND does nothing, first prepare background */
1062 if (action == ODA_SELECT) FillRect( hDC, &rbox, hBrush );
1063 if (action == ODA_DRAWENTIRE) FillRect( hDC, &client, hBrush );
1064
1065 /* Draw label */
1066 client = rtext;
1067 dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &rtext);
1068
1069 /* Only adjust rbox when rtext is valid */
1070 if (dtFlags != (UINT)-1L)
1071 {
1072 rbox.top = rtext.top;
1073 rbox.bottom = rtext.bottom;
1074 }
1075
1076 /* Draw the check-box bitmap */
1078 {
1079 UINT flags;
1080
1084 else flags = DFCS_BUTTONCHECK;
1085
1088
1090
1091 /* rbox must have the correct height */
1092 delta = rbox.bottom - rbox.top - checkBoxHeight;
1093
1094 if ((style & BS_VCENTER) == BS_TOP) {
1095 if (delta > 0) {
1096 rbox.bottom = rbox.top + checkBoxHeight;
1097 } else {
1098 rbox.top -= -delta/2 + 1;
1099 rbox.bottom = rbox.top + checkBoxHeight;
1100 }
1101 } else if ((style & BS_VCENTER) == BS_BOTTOM) {
1102 if (delta > 0) {
1103 rbox.top = rbox.bottom - checkBoxHeight;
1104 } else {
1105 rbox.bottom += -delta/2 + 1;
1106 rbox.top = rbox.bottom - checkBoxHeight;
1107 }
1108 } else { /* Default */
1109 if (delta > 0) {
1110 int ofs = (delta / 2);
1111 rbox.bottom -= ofs + 1;
1112 rbox.top = rbox.bottom - checkBoxHeight;
1113 } else if (delta < 0) {
1114 int ofs = (-delta / 2);
1115 rbox.top -= ofs + 1;
1116 rbox.bottom = rbox.top + checkBoxHeight;
1117 }
1118 }
1119
1121 }
1122
1123 if (dtFlags == (UINT)-1L) /* Noting to draw */
1124 return;
1125
1126 if (action == ODA_DRAWENTIRE)
1127 BUTTON_DrawLabel(hwnd, hDC, dtFlags, &rtext);
1128
1129 /* ... and focus */
1130 if (action == ODA_FOCUS || (state & BST_FOCUS))
1131 {
1132#ifdef __REACTOS__
1133 if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS))
1134 {
1135#endif
1136 rtext.left--;
1137 rtext.right++;
1138 IntersectRect(&rtext, &rtext, &client);
1139 DrawFocusRect( hDC, &rtext );
1140#ifdef __REACTOS__
1141 }
1142#endif
1143 }
1145 if (hrgn) DeleteObject( hrgn );
1146}
static HDC hDC
Definition: 3dtext.c:33
static HRGN hrgn
HRGN set_control_clipping(HDC hdc, const RECT *rect)
Definition: button.c:242
static void BUTTON_DrawLabel(const BUTTON_INFO *infoPtr, HDC hdc, UINT dtFlags, const RECT *rc)
Definition: button.c:1429
static void PB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1497
UINT WINAPI GetDpiForWindow(_In_ HWND hWnd)
Definition: dpi.c:41
action
Definition: namespace.c:714
#define BS_LEFTTEXT
Definition: pedump.c:662
#define WS_DISABLED
Definition: pedump.c:621
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define DFCS_BUTTONCHECK
Definition: winuser.h:496
#define DFCS_INACTIVE
Definition: winuser.h:502
#define DFC_BUTTON
Definition: winuser.h:476
#define DFCS_BUTTON3STATE
Definition: winuser.h:500
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define DFCS_BUTTONRADIO
Definition: winuser.h:499
#define DFCS_CHECKED
Definition: winuser.h:504
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
#define DFCS_PUSHED
Definition: winuser.h:503
int WINAPI GetDeviceCaps(_In_opt_ HDC, _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
#define LOGPIXELSX
Definition: wingdi.h:718
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)

◆ GB_Paint()

static void GB_Paint ( HWND  hwnd,
HDC  hDC,
UINT  action 
)
static

Definition at line 1179 of file button.c.

1180{
1181 RECT rc, rcFrame;
1182 HBRUSH hbr;
1183 HFONT hFont;
1184 UINT dtFlags;
1187 HWND parent;
1188 HRGN hrgn;
1189
1191 /* GroupBox acts like static control, so it sends CTLCOLORSTATIC */
1193 if (!parent) parent = hwnd;
1194#ifdef __REACTOS__
1196#else
1198 if (!hbr) /* did the app forget to call defwindowproc ? */
1200 (WPARAM)hDC, (LPARAM)hwnd);
1201#endif
1202 GetClientRect( hwnd, &rc);
1203 rcFrame = rc;
1204 hrgn = set_control_clipping( hDC, &rc );
1205
1207 rcFrame.top += (tm.tmHeight / 2) - 1;
1208 DrawEdge (hDC, &rcFrame, EDGE_ETCHED, BF_RECT | ((style & BS_FLAT) ? BF_FLAT : 0));
1209
1210 InflateRect(&rc, -7, 1);
1211 dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &rc);
1212
1213 if (dtFlags != (UINT)-1)
1214 {
1215 /* Because buttons have CS_PARENTDC class style, there is a chance
1216 * that label will be drawn out of client rect.
1217 * But Windows doesn't clip label's rect, so do I.
1218 */
1219
1220 /* There is 1-pixel margin at the left, right, and bottom */
1221 rc.left--; rc.right++; rc.bottom++;
1222 FillRect(hDC, &rc, hbr);
1223 rc.left++; rc.right--; rc.bottom--;
1224
1225 BUTTON_DrawLabel(hwnd, hDC, dtFlags, &rc);
1226 }
1228 if (hrgn) DeleteObject( hrgn );
1229}
#define EDGE_ETCHED
Definition: winuser.h:452
#define BF_FLAT
Definition: winuser.h:471
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define BS_FLAT
Definition: winuser.h:280
#define BF_RECT
Definition: winuser.h:462
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221

◆ get_button_font()

static HFONT get_button_font ( HWND  hwnd)
static

Definition at line 143 of file button.c.

144{
145 return (HFONT)NtUserGetPrivateData( hwnd, HFONT_GWL_OFFSET, sizeof(HFONT) );
146}
#define NtUserGetPrivateData(HWND, OFFSET, SIZE)
Definition: user_x.h:131
#define HFONT_GWL_OFFSET
Definition: button.c:46

Referenced by BUTTON_CalcLabelRect(), ButtonWndProc_common(), CB_Paint(), GB_Paint(), OB_Paint(), PB_Paint(), and UB_Paint().

◆ get_button_icon()

static HANDLE get_button_icon ( HWND  hwnd)
static

Definition at line 153 of file button.c.

154{
156}
static HICON
Definition: imagelist.c:80
#define HICON_GWL_OFFSET
Definition: button.c:47

Referenced by BUTTON_CalcLabelRect(), BUTTON_DrawLabel(), and ButtonWndProc_common().

◆ get_button_state()

static LONG get_button_state ( HWND  hwnd)
inlinestatic

Definition at line 133 of file button.c.

134{
136}
#define STATE_GWL_OFFSET
Definition: button.c:45

Referenced by BUTTON_DrawLabel(), ButtonWndProc_common(), CB_Paint(), OB_Paint(), PB_Paint(), and UB_Paint().

◆ get_button_text()

static WCHAR * get_button_text ( HWND  hwnd)
inlinestatic

Definition at line 180 of file button.c.

181{
182 static const INT len = 512;
183 WCHAR *buffer = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) );
185 return buffer;
186}
#define HeapAlloc
Definition: compat.h:733
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
INT NTAPI NtUserInternalGetWindowText(HWND hWnd, LPWSTR lpString, INT nMaxCount)
Definition: window.c:4592

◆ get_button_type()

static UINT get_button_type ( LONG  window_style)
inlinestatic

Definition at line 163 of file button.c.

164{
165 return (window_style & BS_TYPEMASK);
166}

◆ OB_Paint()

static void OB_Paint ( HWND  hwnd,
HDC  hDC,
UINT  action 
)
static

Definition at line 1291 of file button.c.

1292{
1294 DRAWITEMSTRUCT dis;
1296 HWND parent;
1297 HFONT hFont;
1298 HRGN hrgn;
1299
1300 dis.CtlType = ODT_BUTTON;
1301 dis.CtlID = id;
1302 dis.itemID = 0;
1303 dis.itemAction = action;
1304 dis.itemState = ((state & BST_FOCUS) ? ODS_FOCUS : 0) |
1305 ((state & BST_PUSHED) ? ODS_SELECTED : 0) |
1307 dis.hwndItem = hwnd;
1308 dis.hDC = hDC;
1309 dis.itemData = 0;
1310 GetClientRect( hwnd, &dis.rcItem );
1311
1314 if (!parent) parent = hwnd;
1315#ifdef __REACTOS__
1317#else
1319#endif
1320
1322
1325 if (hrgn) DeleteObject( hrgn );
1326}
GLuint id
Definition: glext.h:5910
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define ODS_DISABLED
Definition: winuser.h:2583
#define ODS_SELECTED
Definition: winuser.h:2581
#define WM_DRAWITEM
Definition: winuser.h:1673
#define ODT_BUTTON
Definition: winuser.h:2576
#define ODS_FOCUS
Definition: winuser.h:2585
ULONG_PTR itemData
Definition: winuser.h:3201

◆ paint_button()

static void paint_button ( HWND  hwnd,
LONG  style,
UINT  action 
)
inlinestatic

Definition at line 169 of file button.c.

170{
172 {
173 HDC hdc = NtUserGetDC( hwnd );
176 }
177}

◆ PB_Paint()

static void PB_Paint ( HWND  hwnd,
HDC  hDC,
UINT  action 
)
static

Definition at line 897 of file button.c.

898{
899 RECT rc, r;
900 UINT dtFlags, uState;
901 HPEN hOldPen;
902 HBRUSH hOldBrush;
903 INT oldBkMode;
904 COLORREF oldTxtColor;
905 HFONT hFont;
908 BOOL pushedState = (state & BST_PUSHED);
909 HWND parent;
910 HRGN hrgn;
911
912 GetClientRect( hwnd, &rc );
913
914 /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
917 if (!parent) parent = hwnd;
918#ifdef __REACTOS__
920#else
922#endif
923
924 hrgn = set_control_clipping( hDC, &rc );
925#ifdef __REACTOS__
926 hOldPen = SelectObject(hDC, GetStockObject(DC_PEN));
928#else
929 hOldPen = SelectObject(hDC, SYSCOLOR_GetPen(COLOR_WINDOWFRAME));
930#endif
932 oldBkMode = SetBkMode(hDC, TRANSPARENT);
933
935 {
936 if (action != ODA_FOCUS)
937 Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
938 InflateRect( &rc, -1, -1 );
939 }
940
941 /* completely skip the drawing if only focus has changed */
942 if (action == ODA_FOCUS) goto draw_focus;
943
944 uState = DFCS_BUTTONPUSH;
945
946 if (style & BS_FLAT)
947 uState |= DFCS_MONO;
948 else if (pushedState)
949 {
951 uState |= DFCS_FLAT;
952 else
953 uState |= DFCS_PUSHED;
954 }
955
957 uState |= DFCS_CHECKED;
958
959 DrawFrameControl( hDC, &rc, DFC_BUTTON, uState );
960
961 /* draw button label */
962 r = rc;
963 dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &r);
964
965 if (dtFlags == (UINT)-1L)
966 goto cleanup;
967
968 if (pushedState)
969 OffsetRect(&r, 1, 1);
970
971 oldTxtColor = SetTextColor( hDC, GetSysColor(COLOR_BTNTEXT) );
972
973 BUTTON_DrawLabel(hwnd, hDC, dtFlags, &r);
974
975 SetTextColor( hDC, oldTxtColor );
976
977draw_focus:
978 if (action == ODA_FOCUS || (state & BST_FOCUS))
979 {
980#ifdef __REACTOS__
981 if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS))
982 {
983#endif
984 InflateRect( &rc, -2, -2 );
985 DrawFocusRect( hDC, &rc );
986#ifdef __REACTOS__
987 }
988#endif
989 }
990
991 cleanup:
992 SelectObject( hDC, hOldPen );
993 SelectObject( hDC, hOldBrush );
994 SetBkMode(hDC, oldBkMode);
996 if (hrgn) DeleteObject( hrgn );
997}
static void cleanup(void)
Definition: main.c:1335
DWORD WINAPI GetSysColor(_In_ int)
#define COLOR_BTNTEXT
Definition: winuser.h:944
#define COLOR_WINDOWFRAME
Definition: winuser.h:930
#define DFCS_BUTTONPUSH
Definition: winuser.h:501
#define DFCS_FLAT
Definition: winuser.h:510
#define DFCS_MONO
Definition: winuser.h:511
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define COLOR_BTNFACE
Definition: winuser.h:939
COLORREF WINAPI SetDCPenColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:941
DWORD COLORREF
Definition: windef.h:100
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define TRANSPARENT
Definition: wingdi.h:950
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917

◆ set_button_font()

static HFONT set_button_font ( HWND  hwnd,
HFONT  font 
)
static

Definition at line 148 of file button.c.

149{
150 return (HFONT)NtUserSetPrivateData( hwnd, HFONT_GWL_OFFSET, sizeof(HFONT), (LONG_PTR)font );
151}
Definition: mk_font.cpp:20
#define NtUserSetPrivateData(HWND, OFFSET, SIZE, VALUE)
Definition: user_x.h:132

Referenced by ButtonWndProc_common().

◆ set_button_icon()

static HANDLE set_button_icon ( HWND  hwnd,
HANDLE  icon 
)
static

Definition at line 158 of file button.c.

159{
161}

Referenced by ButtonWndProc_common().

◆ set_button_state()

static LONG set_button_state ( HWND  hwnd,
LONG  state 
)
inlinestatic

Definition at line 138 of file button.c.

139{
141}

Referenced by ButtonWndProc_common().

◆ UB_Paint()

static void UB_Paint ( HWND  hwnd,
HDC  hDC,
UINT  action 
)
static

Definition at line 1236 of file button.c.

1237{
1238 RECT rc;
1239 HBRUSH hBrush;
1240 HFONT hFont;
1242 HWND parent;
1243
1244 GetClientRect( hwnd, &rc);
1245
1247
1249 if (!parent) parent = hwnd;
1250#ifdef __REACTOS__
1252#else
1253 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd);
1254 if (!hBrush) /* did the app forget to call defwindowproc ? */
1255 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN,
1256 (WPARAM)hDC, (LPARAM)hwnd);
1257#endif
1258
1259 FillRect( hDC, &rc, hBrush );
1260 if (action == ODA_FOCUS || (state & BST_FOCUS))
1261#ifdef __REACTOS__
1262 {
1263 if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS))
1264#endif
1265 DrawFocusRect( hDC, &rc );
1266#ifdef __REACTOS__
1267 }
1268#endif
1269
1270 switch (action)
1271 {
1272 case ODA_FOCUS:
1274 break;
1275
1276 case ODA_SELECT:
1278 break;
1279
1280 default:
1282 break;
1283 }
1284}
#define BN_HILITE
Definition: winuser.h:1958
#define BN_UNHILITE
Definition: winuser.h:1963
#define BN_PAINT
Definition: winuser.h:1960

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( button  )

Variable Documentation

◆ btnPaintFunc

const pfPaint btnPaintFunc[MAX_BTN_TYPE]
static
Initial value:
=
{
NULL,
}
static void GB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1784
static void CB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1620
static void UB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1836
static void OB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1878

Definition at line 100 of file button.c.

◆ maxCheckState