ReactOS  0.4.15-dev-449-g64abd9f
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 BUTTON_HFONT_GWL_OFFSET   (sizeof(LONG))
 
#define HIMAGE_GWL_OFFSET   (BUTTON_HFONT_GWL_OFFSET+sizeof(HFONT))
 
#define BUTTON_UISTATE_GWL_OFFSET   (HIMAGE_GWL_OFFSET+sizeof(HFONT))
 
#define NB_EXTRA_BYTES   (BUTTON_UISTATE_GWL_OFFSET+sizeof(LONG))
 
#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(* pfButtonPaint) (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 void set_button_state (HWND hwnd, LONG state)
 
static HFONT get_button_font (HWND hwnd)
 
static void set_button_font (HWND hwnd, HFONT font)
 
static UINT get_button_type (LONG window_style)
 
static void paint_button (HWND hwnd, LONG style, UINT action)
 
static WCHARget_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 pfButtonPaint btnPaintFunc [MAX_BTN_TYPE]
 
static const WCHAR buttonW [] = {'B','u','t','t','o','n',0}
 
const struct builtin_class_descr BUTTON_builtin_class
 

Macro Definition Documentation

◆ BUTTON_BTNPRESSED

#define BUTTON_BTNPRESSED   0x40

Definition at line 79 of file button.c.

◆ BUTTON_HFONT_GWL_OFFSET

#define BUTTON_HFONT_GWL_OFFSET   (sizeof(LONG))

Definition at line 72 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)
#define MAKEWPARAM(l, h)
Definition: winuser.h:3984
HWND hWnd
Definition: settings.c:17
#define GetWindowLongPtrW
Definition: winuser.h:4804
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_COMMAND
Definition: winuser.h:1722
HWND WINAPI GetParent(_In_ HWND)
#define GWLP_ID
Definition: winuser.h:854

Definition at line 86 of file button.c.

◆ BUTTON_NSTATES

#define BUTTON_NSTATES   0x0F

Definition at line 78 of file button.c.

◆ BUTTON_UISTATE_GWL_OFFSET

#define BUTTON_UISTATE_GWL_OFFSET   (HIMAGE_GWL_OFFSET+sizeof(HFONT))

Definition at line 74 of file button.c.

◆ BUTTON_UNKNOWN2

#define BUTTON_UNKNOWN2   0x20

Definition at line 80 of file button.c.

◆ BUTTON_UNKNOWN3

#define BUTTON_UNKNOWN3   0x10

Definition at line 81 of file button.c.

◆ HIMAGE_GWL_OFFSET

#define HIMAGE_GWL_OFFSET   (BUTTON_HFONT_GWL_OFFSET+sizeof(HFONT))

Definition at line 73 of file button.c.

◆ MAX_BTN_TYPE

#define MAX_BTN_TYPE   16

Definition at line 102 of file button.c.

◆ NB_EXTRA_BYTES

#define NB_EXTRA_BYTES   (BUTTON_UISTATE_GWL_OFFSET+sizeof(LONG))

Definition at line 75 of file button.c.

◆ STATE_GWL_OFFSET

#define STATE_GWL_OFFSET   0

Definition at line 71 of file button.c.

Typedef Documentation

◆ pfButtonPaint

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

Definition at line 120 of file button.c.

Function Documentation

◆ BUTTON_BStoDT()

static UINT BUTTON_BStoDT ( DWORD  style,
DWORD  ex_style 
)
static

Definition at line 694 of file button.c.

695 {
696  UINT dtStyle = DT_NOCLIP; /* We use SelectClipRgn to limit output */
697 
698  /* "Convert" pushlike buttons to pushbuttons */
699  if (style & BS_PUSHLIKE)
700  style &= ~BS_TYPEMASK;
701 
702  if (!(style & BS_MULTILINE))
703  dtStyle |= DT_SINGLELINE;
704  else
705  dtStyle |= DT_WORDBREAK;
706 
707  switch (style & BS_CENTER)
708  {
709  case BS_LEFT: /* DT_LEFT is 0 */ break;
710  case BS_RIGHT: dtStyle |= DT_RIGHT; break;
711  case BS_CENTER: dtStyle |= DT_CENTER; break;
712  default:
713  /* Pushbutton's text is centered by default */
714  if (get_button_type(style) <= BS_DEFPUSHBUTTON) dtStyle |= DT_CENTER;
715  /* all other flavours have left aligned text */
716  }
717 
718  if (ex_style & WS_EX_RIGHT) dtStyle = DT_RIGHT | (dtStyle & ~(DT_LEFT | DT_CENTER));
719 
720  /* DrawText ignores vertical alignment for multiline text,
721  * but we use these flags to align label manually.
722  */
724  {
725  switch (style & BS_VCENTER)
726  {
727  case BS_TOP: /* DT_TOP is 0 */ break;
728  case BS_BOTTOM: dtStyle |= DT_BOTTOM; break;
729  case BS_VCENTER: /* fall through */
730  default: dtStyle |= DT_VCENTER; break;
731  }
732  }
733  else
734  /* GroupBox's text is always single line and is top aligned. */
735  dtStyle |= DT_SINGLELINE;
736 
737  return dtStyle;
738 }
#define BS_LEFT
Definition: winuser.h:265
#define BS_RIGHT
Definition: winuser.h:274
#define DT_WORDBREAK
Definition: winuser.h:544
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
#define DT_RIGHT
Definition: winuser.h:538
#define BS_CENTER
Definition: winuser.h:260
#define WS_EX_RIGHT
Definition: winuser.h:400
#define BS_GROUPBOX
Definition: pedump.c:658
#define DT_LEFT
Definition: winuser.h:534
#define DT_VCENTER
Definition: winuser.h:543
static UINT get_button_type(LONG window_style)
Definition: button.c:192
#define BS_MULTILINE
Definition: winuser.h:267
#define BS_TOP
Definition: winuser.h:277
#define BS_VCENTER
Definition: winuser.h:279
#define DT_NOCLIP
Definition: winuser.h:536
#define DT_SINGLELINE
Definition: winuser.h:540
#define BS_TYPEMASK
Definition: winuser.h:270
unsigned int UINT
Definition: ndis.h:50
#define BS_BOTTOM
Definition: winuser.h:259
#define BS_PUSHLIKE
Definition: winuser.h:272
#define DT_CENTER
Definition: winuser.h:527
Arabic default style
Definition: afstyles.h:93
#define DT_BOTTOM
Definition: winuser.h:525

Referenced by BUTTON_CalcLabelRect().

◆ BUTTON_CalcLabelRect()

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

Definition at line 750 of file button.c.

751 {
753  LONG ex_style = GetWindowLongPtrW( hwnd, GWL_EXSTYLE );
754  WCHAR *text;
755  ICONINFO iconInfo;
756  BITMAP bm;
757  UINT dtStyle = BUTTON_BStoDT( style, ex_style );
758  RECT r = *rc;
759  INT n;
760 
761  /* Calculate label rectangle according to label type */
762  switch (style & (BS_ICON|BS_BITMAP))
763  {
764  case BS_TEXT:
765  {
766  HFONT hFont, hPrevFont = 0;
767 
768  if (!(text = get_button_text( hwnd ))) goto empty_rect;
769  if (!text[0])
770  {
771  HeapFree( GetProcessHeap(), 0, text );
772  goto empty_rect;
773  }
774 
775  if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hdc, hFont );
776 #ifdef __REACTOS__
777  DrawTextW(hdc, text, -1, &r, ((dtStyle | DT_CALCRECT) & ~(DT_VCENTER | DT_BOTTOM)));
778 #else
779  DrawTextW(hdc, text, -1, &r, dtStyle | DT_CALCRECT);
780 #endif
781  if (hPrevFont) SelectObject( hdc, hPrevFont );
782  HeapFree( GetProcessHeap(), 0, text );
783 #ifdef __REACTOS__
784  if (get_ui_state(hwnd) & UISF_HIDEACCEL)
785  dtStyle |= DT_HIDEPREFIX;
786 #endif
787  break;
788  }
789 
790  case BS_ICON:
792  goto empty_rect;
793 
794  GetObjectW (iconInfo.hbmColor, sizeof(BITMAP), &bm);
795 
796  r.right = r.left + bm.bmWidth;
797  r.bottom = r.top + bm.bmHeight;
798 
799  DeleteObject(iconInfo.hbmColor);
800  DeleteObject(iconInfo.hbmMask);
801  break;
802 
803  case BS_BITMAP:
805  goto empty_rect;
806 
807  r.right = r.left + bm.bmWidth;
808  r.bottom = r.top + bm.bmHeight;
809  break;
810 
811  default:
812  empty_rect:
813  rc->right = r.left;
814  rc->bottom = r.top;
815  return (UINT)-1;
816  }
817 
818  /* Position label inside bounding rectangle according to
819  * alignment flags. (calculated rect is always left-top aligned).
820  * If label is aligned to any side - shift label in opposite
821  * direction to leave extra space for focus rectangle.
822  */
823  switch (dtStyle & (DT_CENTER|DT_RIGHT))
824  {
825  case DT_LEFT: r.left++; r.right++; break;
826  case DT_CENTER: n = r.right - r.left;
827  r.left = rc->left + ((rc->right - rc->left) - n) / 2;
828  r.right = r.left + n; break;
829  case DT_RIGHT: n = r.right - r.left;
830  r.right = rc->right - 1;
831  r.left = r.right - n;
832  break;
833  }
834 
835  switch (dtStyle & (DT_VCENTER|DT_BOTTOM))
836  {
837  case DT_TOP: r.top++; r.bottom++; break;
838  case DT_VCENTER: n = r.bottom - r.top;
839 #ifdef __REACTOS__
840  r.top = rc->top + ((rc->bottom - 1 - rc->top) - n) / 2;
841 #else
842  r.top = rc->top + ((rc->bottom - rc->top) - n) / 2;
843 #endif
844  r.bottom = r.top + n; break;
845  case DT_BOTTOM: n = r.bottom - r.top;
846  r.bottom = rc->bottom - 1;
847  r.top = r.bottom - n;
848  break;
849  }
850 
851  *rc = r;
852  return dtStyle;
853 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static HICON
Definition: imagelist.c:84
#define DT_HIDEPREFIX
Definition: winuser.h:547
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
const WCHAR * text
Definition: package.c:1827
#define BS_TEXT
Definition: winuser.h:276
GLdouble n
Definition: glext.h:7729
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define GWL_EXSTYLE
Definition: winuser.h:845
#define DT_RIGHT
Definition: winuser.h:538
#define GetWindowLongPtrW
Definition: winuser.h:4804
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:57
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2014
HFONT hFont
Definition: main.c:53
#define DT_LEFT
Definition: winuser.h:534
#define DT_CALCRECT
Definition: winuser.h:526
long LONG
Definition: pedump.c:60
HBITMAP hbmMask
Definition: winuser.h:3101
HBITMAP hbmColor
Definition: winuser.h:3102
#define DT_VCENTER
Definition: winuser.h:543
#define GetProcessHeap()
Definition: compat.h:404
__wchar_t WCHAR
Definition: xmlstorage.h:180
static WCHAR * get_button_text(HWND hwnd)
Definition: button.c:209
static HFONT get_button_font(HWND hwnd)
Definition: button.c:182
#define BS_ICON
Definition: winuser.h:264
HDC hdc
Definition: main.c:9
#define BS_BITMAP
Definition: winuser.h:258
#define GWL_STYLE
Definition: winuser.h:846
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
Definition: bl.h:1331
#define DT_TOP
Definition: winuser.h:542
unsigned int UINT
Definition: ndis.h:50
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
LONG bottom
Definition: windef.h:309
#define DT_CENTER
Definition: winuser.h:527
Arabic default style
Definition: afstyles.h:93
#define HIMAGE_GWL_OFFSET
Definition: button.c:73
#define DT_BOTTOM
Definition: winuser.h:525
static UINT BUTTON_BStoDT(DWORD style, DWORD ex_style)
Definition: button.c:694
#define HeapFree(x, y, z)
Definition: compat.h:403
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17

Referenced by ButtonWndProc_common(), CB_Paint(), GB_Paint(), and PB_Paint().

◆ BUTTON_CheckAutoRadioButton()

static void BUTTON_CheckAutoRadioButton ( HWND  hwnd)
static

Definition at line 1189 of file button.c.

1190 {
1191  HWND parent, sibling, start;
1192 
1193  parent = GetParent(hwnd);
1194  /* make sure that starting control is not disabled or invisible */
1195  start = sibling = hwnd;
1196  do
1197  {
1198  if (!sibling) break;
1199  if (SendMessageW( sibling, WM_GETDLGCODE, 0, 0 ) == (DLGC_BUTTON | DLGC_RADIOBUTTON))
1200  SendMessageW( sibling, BM_SETCHECK, sibling == hwnd ? BST_CHECKED : BST_UNCHECKED, 0 );
1201  sibling = GetNextDlgGroupItem( parent, sibling, FALSE );
1202  } while (sibling != start);
1203 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define WM_GETDLGCODE
Definition: winuser.h:1671
#define DLGC_RADIOBUTTON
Definition: winuser.h:2592
HWND WINAPI GetNextDlgGroupItem(_In_ HWND, _In_opt_ HWND, _In_ BOOL)
#define BM_SETCHECK
Definition: winuser.h:1903
r parent
Definition: btrfs.c:2944
#define BST_UNCHECKED
Definition: winuser.h:199
HWND WINAPI GetParent(_In_ HWND)
GLuint start
Definition: gl.h:1545
#define DLGC_BUTTON
Definition: winuser.h:2595
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_CHECKED
Definition: winuser.h:197

Referenced by ButtonWndProc_common().

◆ BUTTON_DrawLabel()

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

Definition at line 876 of file button.c.

877 {
878  DRAWSTATEPROC lpOutputProc = NULL;
879  LPARAM lp;
880  WPARAM wp = 0;
881  HBRUSH hbr = 0;
885  WCHAR *text = NULL;
886 
887  /* FIXME: To draw disabled label in Win31 look-and-feel, we probably
888  * must use DSS_MONO flag and COLOR_GRAYTEXT brush (or maybe DSS_UNION).
889  * I don't have Win31 on hand to verify that, so I leave it as is.
890  */
891 
892  if ((style & BS_PUSHLIKE) && (state & BST_INDETERMINATE))
893  {
895  flags |= DSS_MONO;
896  }
897 
898  switch (style & (BS_ICON|BS_BITMAP))
899  {
900  case BS_TEXT:
901  /* DST_COMPLEX -- is 0 */
902  lpOutputProc = BUTTON_DrawTextCallback;
903  if (!(text = get_button_text( hwnd ))) return;
904  lp = (LPARAM)text;
905  wp = (WPARAM)dtFlags;
906 
907 #ifdef __REACTOS__
908  if (dtFlags & DT_HIDEPREFIX)
910 #endif
911  break;
912 
913  case BS_ICON:
914  flags |= DST_ICON;
916  break;
917 
918  case BS_BITMAP:
919  flags |= DST_BITMAP;
921  break;
922 
923  default:
924  return;
925  }
926 
927  DrawStateW(hdc, hbr, lpOutputProc, lp, wp, rc->left, rc->top,
928  rc->right - rc->left, rc->bottom - rc->top, flags);
929  HeapFree( GetProcessHeap(), 0, text );
930 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define DT_HIDEPREFIX
Definition: winuser.h:547
UINT state
Definition: button.c:168
const WCHAR * text
Definition: package.c:1827
#define BS_TEXT
Definition: winuser.h:276
LONG top
Definition: windef.h:307
BOOL(CALLBACK * DRAWSTATEPROC)(HDC, LPARAM, WPARAM, int, int)
Definition: winuser.h:2882
UINT_PTR WPARAM
Definition: windef.h:207
#define GetWindowLongPtrW
Definition: winuser.h:4804
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define BST_INDETERMINATE
Definition: winuser.h:198
#define DSS_HIDEPREFIX
Definition: winuser.h:522
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define GetProcessHeap()
Definition: compat.h:404
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define DSS_MONO
Definition: winuser.h:521
#define DSS_DISABLED
Definition: winuser.h:519
static BOOL CALLBACK BUTTON_DrawTextCallback(HDC hdc, LPARAM lp, WPARAM wp, int cx, int cy)
Definition: button.c:861
static WCHAR * get_button_text(HWND hwnd)
Definition: button.c:209
GLbitfield flags
Definition: glext.h:7161
static LPARAM
Definition: button.c:42
#define BS_ICON
Definition: winuser.h:264
#define COLOR_GRAYTEXT
Definition: winuser.h:922
HDC hdc
Definition: main.c:9
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 BS_BITMAP
Definition: winuser.h:258
static LONG get_button_state(HWND hwnd)
Definition: button.c:158
#define GWL_STYLE
Definition: winuser.h:846
unsigned int UINT
Definition: ndis.h:50
#define BS_PUSHLIKE
Definition: winuser.h:272
#define DST_BITMAP
Definition: winuser.h:516
#define DSS_NORMAL
Definition: winuser.h:517
LONG bottom
Definition: windef.h:309
#define DST_ICON
Definition: winuser.h:515
Arabic default style
Definition: afstyles.h:93
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define HIMAGE_GWL_OFFSET
Definition: button.c:73
static WPARAM
Definition: button.c:42
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by CB_Paint(), GB_Paint(), and PB_Paint().

◆ BUTTON_DrawTextCallback()

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

Definition at line 861 of file button.c.

862 {
863  RECT rc;
864 
865  SetRect(&rc, 0, 0, cx, cy);
866  DrawTextW(hdc, (LPCWSTR)lp, -1, &rc, (UINT)wp);
867  return TRUE;
868 }
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
HDC hdc
Definition: main.c:9
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
unsigned int UINT
Definition: ndis.h:50
_Out_opt_ int * cx
Definition: commctrl.h:581
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17

Referenced by BUTTON_DrawLabel().

◆ ButtonWndProc_common()

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

Definition at line 243 of file button.c.

245 {
246  RECT rect;
247  POINT pt;
249  UINT btn_type = get_button_type( style );
250  LONG state;
251  HANDLE oldHbitmap;
252 #ifdef __REACTOS__
253  PWND pWnd;
254 
255  pWnd = ValidateHwnd(hWnd);
256  if (pWnd)
257  {
258  if (!pWnd->fnid)
259  {
261  }
262  else
263  {
264  if (pWnd->fnid != FNID_BUTTON)
265  {
266  ERR("Wrong window class for Button! fnId 0x%x\n",pWnd->fnid);
267  return 0;
268  }
269  }
270  }
271  else
272  return 0;
273 #else
274  if (!IsWindow( hWnd )) return 0;
275 #endif
276 
277  pt.x = (short)LOWORD(lParam);
278  pt.y = (short)HIWORD(lParam);
279 
280  switch (uMsg)
281  {
282  case WM_GETDLGCODE:
283  switch(btn_type)
284  {
285  case BS_USERBUTTON:
288  case BS_RADIOBUTTON:
290  case BS_GROUPBOX: return DLGC_STATIC;
291  default: return DLGC_BUTTON;
292  }
293 
294  case WM_ENABLE:
295  paint_button( hWnd, btn_type, ODA_DRAWENTIRE );
296  break;
297 
298  case WM_CREATE:
299  if (btn_type >= MAX_BTN_TYPE)
300  return -1; /* abort */
301 
302  /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
303  if (btn_type == BS_USERBUTTON )
304  {
306 #ifdef __REACTOS__
308 #else
309  WIN_SetStyle( hWnd, style, BS_TYPEMASK & ~style );
310 #endif
311  }
313 #ifdef __REACTOS__
314  button_update_uistate( hWnd, unicode );
315 #endif
316  return 0;
317 
318 #ifdef __REACTOS__
319  case WM_NCDESTROY:
321  case WM_DESTROY:
322  break;
323 #endif
324 
325  case WM_ERASEBKGND:
326  if (btn_type == BS_OWNERDRAW)
327  {
328  HDC hdc = (HDC)wParam;
329  RECT rc;
330  HBRUSH hBrush;
332  if (!parent) parent = hWnd;
333 #ifdef __REACTOS__
335 #else
336  hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hdc, (LPARAM)hWnd);
337  if (!hBrush) /* did the app forget to call defwindowproc ? */
338  hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN,
339  (WPARAM)hdc, (LPARAM)hWnd);
340 #endif
341  GetClientRect(hWnd, &rc);
342  FillRect(hdc, &rc, hBrush);
343  }
344  return 1;
345 
346  case WM_PRINTCLIENT:
347  case WM_PAINT:
348  {
349  PAINTSTRUCT ps;
350  HDC hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps );
351  if (btnPaintFunc[btn_type])
352  {
353  int nOldMode = SetBkMode( hdc, OPAQUE );
354  (btnPaintFunc[btn_type])( hWnd, hdc, ODA_DRAWENTIRE );
355  SetBkMode(hdc, nOldMode); /* reset painting mode */
356  }
357  if ( !wParam ) EndPaint( hWnd, &ps );
358  break;
359  }
360 
361  case WM_KEYDOWN:
362  if (wParam == VK_SPACE)
363  {
366  SetCapture( hWnd );
367  }
368  break;
369 
370  case WM_LBUTTONDBLCLK:
371  if(style & BS_NOTIFY ||
372  btn_type == BS_RADIOBUTTON ||
373  btn_type == BS_USERBUTTON ||
374  btn_type == BS_OWNERDRAW)
375  {
377  break;
378  }
379  /* fall through */
380  case WM_LBUTTONDOWN:
381  SetCapture( hWnd );
382  SetFocus( hWnd );
385  break;
386 
387  case WM_KEYUP:
388  if (wParam != VK_SPACE)
389  break;
390  /* fall through */
391  case WM_LBUTTONUP:
392 #ifdef __REACTOS__
393  {
394  BOOL TellParent = FALSE;
395 #endif
397  if (!(state & BUTTON_BTNPRESSED)) break;
400  if (!(state & BST_PUSHED))
401  {
402  ReleaseCapture();
403  break;
404  }
406  GetClientRect( hWnd, &rect );
407  if (uMsg == WM_KEYUP || PtInRect( &rect, pt ))
408  {
410  switch(btn_type)
411  {
412  case BS_AUTOCHECKBOX:
414  break;
415  case BS_AUTORADIOBUTTON:
417  break;
418  case BS_AUTO3STATE:
420  (state & BST_INDETERMINATE) ? 0 : ((state & 3) + 1), 0 );
421  break;
422  }
423 #ifdef __REACTOS__
424  TellParent = TRUE; // <---- Fix CORE-10194, Notify parent after capture is released.
425 #else
426  ReleaseCapture();
428 #endif
429  }
430 #ifndef __REACTOS__
431  else
432  {
433  ReleaseCapture();
434  }
435 #else
436  ReleaseCapture();
437  if (TellParent) BUTTON_NOTIFY_PARENT(hWnd, BN_CLICKED);
438  }
439 #endif
440  break;
441 
442  case WM_CAPTURECHANGED:
443  TRACE("WM_CAPTURECHANGED %p\n", hWnd);
444  if (hWnd == (HWND)lParam) break;
446  if (state & BUTTON_BTNPRESSED)
447  {
451  }
452  break;
453 
454  case WM_MOUSEMOVE:
455  if ((wParam & MK_LBUTTON) && GetCapture() == hWnd)
456  {
457  GetClientRect( hWnd, &rect );
459  }
460  break;
461 
462  case WM_SETTEXT:
463  {
464  /* Clear an old text here as Windows does */
465 //
466 // ReactOS Note :
467 // wine Bug: http://bugs.winehq.org/show_bug.cgi?id=25790
468 // Patch: http://source.winehq.org/patches/data/70889
469 // By: Alexander LAW, Replicate Windows behavior of WM_SETTEXT handler regarding WM_CTLCOLOR*
470 //
471 #ifdef __REACTOS__
472  if (style & WS_VISIBLE)
473 #else
474  if (IsWindowVisible(hWnd))
475 #endif
476  {
477  HDC hdc = GetDC(hWnd);
478  HBRUSH hbrush;
479  RECT client, rc;
481  UINT message = (btn_type == BS_PUSHBUTTON ||
482  btn_type == BS_DEFPUSHBUTTON ||
483  btn_type == BS_PUSHLIKE ||
484  btn_type == BS_USERBUTTON ||
485  btn_type == BS_OWNERDRAW) ?
487 
488  if (!parent) parent = hWnd;
489 #ifdef __REACTOS__
491 #else
492  hbrush = (HBRUSH)SendMessageW(parent, message,
493  (WPARAM)hdc, (LPARAM)hWnd);
494  if (!hbrush) /* did the app forget to call DefWindowProc ? */
495  hbrush = (HBRUSH)DefWindowProcW(parent, message,
496  (WPARAM)hdc, (LPARAM)hWnd);
497 #endif
498 
500  rc = client;
501  /* FIXME: check other BS_* handlers */
502  if (btn_type == BS_GROUPBOX)
503  InflateRect(&rc, -7, 1); /* GB_Paint does this */
505  /* Clip by client rect bounds */
506  if (rc.right > client.right) rc.right = client.right;
507  if (rc.bottom > client.bottom) rc.bottom = client.bottom;
508  FillRect(hdc, &rc, hbrush);
509  ReleaseDC(hWnd, hdc);
510  }
511 
512  if (unicode) DefWindowProcW( hWnd, WM_SETTEXT, wParam, lParam );
514  if (btn_type == BS_GROUPBOX) /* Yes, only for BS_GROUPBOX */
516  else
517  paint_button( hWnd, btn_type, ODA_DRAWENTIRE );
518  return 1; /* success. FIXME: check text length */
519  }
520 
521  case WM_SETFONT:
524  break;
525 
526  case WM_GETFONT:
527  return (LRESULT)get_button_font( hWnd );
528 
529  case WM_SETFOCUS:
530  TRACE("WM_SETFOCUS %p\n",hWnd);
532  paint_button( hWnd, btn_type, ODA_FOCUS );
533  if (style & BS_NOTIFY)
535  break;
536 
537  case WM_KILLFOCUS:
538  TRACE("WM_KILLFOCUS %p\n",hWnd);
541  paint_button( hWnd, btn_type, ODA_FOCUS );
542 
543  if ((state & BUTTON_BTNPRESSED) && GetCapture() == hWnd)
544  ReleaseCapture();
545  if (style & BS_NOTIFY)
547 
549  break;
550 
551  case WM_SYSCOLORCHANGE:
553  break;
554 
555  case BM_SETSTYLE:
556  btn_type = wParam & BS_TYPEMASK;
557  style = (style & ~BS_TYPEMASK) | btn_type;
558 #ifdef __REACTOS__
560 #else
561  WIN_SetStyle( hWnd, style, BS_TYPEMASK & ~style );
562 #endif
563 
564  /* Only redraw if lParam flag is set.*/
565  if (lParam)
567 
568  break;
569 
570  case BM_CLICK:
571 #ifdef __REACTOS__
573  if (state & BUTTON_BMCLICK)
574  break;
575  set_button_state(hWnd, state | BUTTON_BMCLICK); // Tracked in STATE_GWL_OFFSET.
576 #endif
577  SendMessageW( hWnd, WM_LBUTTONDOWN, 0, 0 );
578  SendMessageW( hWnd, WM_LBUTTONUP, 0, 0 );
579 #ifdef __REACTOS__
581  if (!(state & BUTTON_BMCLICK)) break;
582  state &= ~BUTTON_BMCLICK;
584 #endif
585  break;
586 
587  case BM_SETIMAGE:
588  /* Check that image format matches button style */
589  switch (style & (BS_BITMAP|BS_ICON))
590  {
591  case BS_BITMAP:
592  if (wParam != IMAGE_BITMAP) return 0;
593  break;
594  case BS_ICON:
595  if (wParam != IMAGE_ICON) return 0;
596  break;
597  default:
598  return 0;
599  }
602  return (LRESULT)oldHbitmap;
603 
604  case BM_GETIMAGE:
606 
607  case BM_GETCHECK:
608  return get_button_state( hWnd ) & 3;
609 
610  case BM_SETCHECK:
611  if (wParam > maxCheckState[btn_type]) wParam = maxCheckState[btn_type];
613  if ((btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON))
614  {
615 #ifdef __REACTOS__
616  if (wParam) style |= WS_TABSTOP;
617  else style &= ~WS_TABSTOP;
619 #else
620  if (wParam) WIN_SetStyle( hWnd, WS_TABSTOP, 0 );
621  else WIN_SetStyle( hWnd, 0, WS_TABSTOP );
622 #endif
623  }
624  if ((state & 3) != wParam)
625  {
626  set_button_state( hWnd, (state & ~3) | wParam );
627  paint_button( hWnd, btn_type, ODA_SELECT );
628  }
629  break;
630 
631  case BM_GETSTATE:
632  return get_button_state( hWnd );
633 
634  case BM_SETSTATE:
636  if (wParam)
638  else
640 
641  paint_button( hWnd, btn_type, ODA_SELECT );
642  break;
643 
644 #ifdef __REACTOS__
645  case WM_UPDATEUISTATE:
646  if (unicode)
648  else
650 
651  if (button_update_uistate(hWnd, unicode))
652  paint_button( hWnd, btn_type, ODA_DRAWENTIRE );
653  break;
654 #endif
655 
656  case WM_NCHITTEST:
657  if(btn_type == BS_GROUPBOX) return HTTRANSPARENT;
658  /* fall through */
659  default:
660  return unicode ? DefWindowProcW(hWnd, uMsg, wParam, lParam) :
662  }
663  return 0;
664 }
#define BS_NOTIFY
Definition: winuser.h:268
#define BM_SETSTATE
Definition: winuser.h:1905
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1608
#define BS_OWNERDRAW
Definition: pedump.c:661
#define BUTTON_NSTATES
Definition: button.c:78
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
Definition: tftpd.h:59
static const WORD maxCheckState[MAX_BTN_TYPE]
Definition: button.c:104
#define HTTRANSPARENT
Definition: winuser.h:2448
#define TRUE
Definition: types.h:120
#define DLGC_UNDEFPUSHBUTTON
Definition: winuser.h:2591
#define IMAGE_ICON
Definition: winuser.h:212
static HBRUSH hbrush
#define WM_GETDLGCODE
Definition: winuser.h:1671
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define MK_LBUTTON
Definition: winuser.h:2342
HDC WINAPI GetDC(_In_opt_ HWND)
#define BS_RADIOBUTTON
Definition: pedump.c:655
UINT state
Definition: button.c:168
#define pt(x, y)
Definition: drawing.c:79
#define BM_GETSTATE
Definition: winuser.h:1902
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1754
#define WM_CAPTURECHANGED
Definition: winuser.h:1790
static HDC
Definition: imagelist.c:92
#define DLGC_RADIOBUTTON
Definition: winuser.h:2592
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
HWND hWnd
Definition: settings.c:17
HWND WINAPI SetFocus(_In_opt_ HWND)
#define WM_NCHITTEST
Definition: winuser.h:1668
UINT_PTR WPARAM
Definition: windef.h:207
#define GetWindowLongPtrW
Definition: winuser.h:4804
#define FNID_DESTROY
Definition: ntuser.h:859
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
LONG right
Definition: windef.h:308
#define ODA_FOCUS
Definition: winuser.h:2519
#define BM_GETIMAGE
Definition: winuser.h:1901
#define BM_SETIMAGE
Definition: winuser.h:1904
#define BS_GROUPBOX
Definition: pedump.c:658
& rect
Definition: startmenu.cpp:1413
WPARAM wParam
Definition: combotst.c:138
#define BST_INDETERMINATE
Definition: winuser.h:198
#define WM_ENABLE
Definition: winuser.h:1597
#define WM_PRINTCLIENT
Definition: richedit.h:70
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BUTTON_BTNPRESSED
Definition: button.c:79
HBRUSH FASTCALL GetControlColor(PWND pwndParent, PWND pwnd, HDC hdc, UINT CtlMsg)
Definition: misc.c:145
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
#define WM_CTLCOLORBTN
Definition: winuser.h:1751
static void BUTTON_CheckAutoRadioButton(HWND hwnd)
Definition: button.c:1189
static const pfButtonPaint btnPaintFunc[MAX_BTN_TYPE]
Definition: button.c:122
DWORD fnid
Definition: ntuser.h:673
unsigned int BOOL
Definition: ntddk_ex.h:94
static void set_button_font(HWND hwnd, HFONT font)
Definition: button.c:187
long LONG
Definition: pedump.c:60
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
HWND WINAPI GetCapture(void)
Definition: message.c:2880
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
#define WM_GETFONT
Definition: winuser.h:1633
#define BS_AUTOCHECKBOX
Definition: pedump.c:654
#define BS_AUTO3STATE
Definition: pedump.c:657
#define WM_KEYDOWN
Definition: winuser.h:1697
#define BM_GETCHECK
Definition: winuser.h:1900
#define BST_FOCUS
Definition: winuser.h:200
static UINT get_button_type(LONG window_style)
Definition: button.c:192
#define WM_SETTEXT
Definition: winuser.h:1599
#define WM_DESTROY
Definition: winuser.h:1591
#define BM_CLICK
Definition: winuser.h:1899
#define ODA_DRAWENTIRE
Definition: winuser.h:2517
DWORD NTAPI NtUserAlterWindowStyle(HWND hWnd, DWORD Index, LONG NewValue)
Definition: window.c:3829
#define DLGC_DEFPUSHBUTTON
Definition: winuser.h:2590
#define BM_SETCHECK
Definition: winuser.h:1903
#define TRACE(s)
Definition: solgame.cpp:4
#define WM_KILLFOCUS
Definition: winuser.h:1596
r parent
Definition: btrfs.c:2944
#define BM_SETSTYLE
Definition: winuser.h:1906
#define BST_PUSHED
Definition: winuser.h:201
#define WM_NCDESTROY
Definition: winuser.h:1666
#define WM_KEYUP
Definition: winuser.h:1698
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
static FILE * client
Definition: client.c:41
#define BN_CLICKED
Definition: winuser.h:1907
static LPARAM
Definition: button.c:42
#define BN_KILLFOCUS
Definition: winuser.h:1912
#define WM_PAINT
Definition: winuser.h:1602
static HFONT get_button_font(HWND hwnd)
Definition: button.c:182
#define BS_ICON
Definition: winuser.h:264
#define OPAQUE
Definition: wingdi.h:948
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
HDC hdc
Definition: main.c:9
#define BS_BITMAP
Definition: winuser.h:258
static LONG get_button_state(HWND hwnd)
Definition: button.c:158
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1760
#define WS_TABSTOP
Definition: pedump.c:634
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_UNCHECKED
Definition: winuser.h:199
#define BS_PUSHBUTTON
Definition: pedump.c:651
#define MAX_BTN_TYPE
Definition: button.c:102
#define ERR(fmt,...)
Definition: debug.h:110
#define GWL_STYLE
Definition: winuser.h:846
Definition: ntuser.h:657
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define BN_SETFOCUS
Definition: winuser.h:1915
HWND WINAPI GetParent(_In_ HWND)
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define BUTTON_NOTIFY_PARENT(hWnd, code)
Definition: button.c:86
#define BS_AUTORADIOBUTTON
Definition: pedump.c:660
#define BS_TYPEMASK
Definition: winuser.h:270
#define DLGC_BUTTON
Definition: winuser.h:2595
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_LBUTTONUP
Definition: winuser.h:1759
#define FNID_BUTTON
Definition: ntuser.h:828
unsigned int UINT
Definition: ndis.h:50
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define VK_SPACE
Definition: winuser.h:2194
#define IMAGE_BITMAP
Definition: winuser.h:211
static void paint_button(HWND hwnd, LONG style, UINT action)
Definition: button.c:198
#define WM_SETFONT
Definition: winuser.h:1632
#define BST_CHECKED
Definition: winuser.h:197
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2889
static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc)
Definition: button.c:750
#define BS_PUSHLIKE
Definition: winuser.h:272
#define WM_CREATE
Definition: winuser.h:1590
static void set_button_state(HWND hwnd, LONG state)
Definition: button.c:163
#define HIWORD(l)
Definition: typedefs.h:246
BOOL WINAPI IsWindowVisible(_In_ HWND)
LONG bottom
Definition: windef.h:309
BOOL NTAPI NtUserSetWindowFNID(HWND hWnd, WORD fnID)
Definition: window.c:4054
#define BN_DOUBLECLICKED
Definition: winuser.h:1910
#define SetWindowLongPtrW
Definition: winuser.h:5321
static HBITMAP
Definition: button.c:44
#define BS_USERBUTTON
Definition: pedump.c:659
#define WM_ERASEBKGND
Definition: winuser.h:1607
#define WM_SETFOCUS
Definition: winuser.h:1595
LONG_PTR LRESULT
Definition: windef.h:209
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
Arabic default style
Definition: afstyles.h:93
#define WS_VISIBLE
Definition: pedump.c:620
#define HIMAGE_GWL_OFFSET
Definition: button.c:73
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define DLGC_STATIC
Definition: winuser.h:2594
#define ODA_SELECT
Definition: winuser.h:2518

Referenced by RegisterClientPFN().

◆ CB_Paint()

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

Definition at line 1041 of file button.c.

1042 {
1043  RECT rbox, rtext, client;
1044  HBRUSH hBrush;
1045  int delta, text_offset, checkBoxWidth, checkBoxHeight;
1046  UINT dtFlags;
1047  HFONT hFont;
1050  LONG ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
1051  HWND parent;
1052  HRGN hrgn;
1053 
1054  if (style & BS_PUSHLIKE)
1055  {
1056  PB_Paint( hwnd, hDC, action );
1057  return;
1058  }
1059 
1061  rbox = rtext = client;
1062 
1063  checkBoxWidth = 12 * GetDeviceCaps( hDC, LOGPIXELSX ) / 96 + 1;
1064  checkBoxHeight = 12 * GetDeviceCaps( hDC, LOGPIXELSY ) / 96 + 1;
1065 
1066  if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
1067  GetCharWidthW( hDC, '0', '0', &text_offset );
1068  text_offset /= 2;
1069 
1070  parent = GetParent(hwnd);
1071  if (!parent) parent = hwnd;
1072 #ifdef __REACTOS__
1074 #else
1075  hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC,
1076  (WPARAM)hDC, (LPARAM)hwnd);
1077  if (!hBrush) /* did the app forget to call defwindowproc ? */
1078  hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
1079  (WPARAM)hDC, (LPARAM)hwnd );
1080 #endif
1082 
1083  if (style & BS_LEFTTEXT || ex_style & WS_EX_RIGHT)
1084  {
1085  /* magic +4 is what CTL3D expects */
1086 
1087  rtext.right -= checkBoxWidth + text_offset;;
1088  rbox.left = rbox.right - checkBoxWidth;
1089  }
1090  else
1091  {
1092  rtext.left += checkBoxWidth + text_offset;;
1093  rbox.right = checkBoxWidth;
1094  }
1095 
1096  /* Since WM_ERASEBKGND does nothing, first prepare background */
1097  if (action == ODA_SELECT) FillRect( hDC, &rbox, hBrush );
1098  if (action == ODA_DRAWENTIRE) FillRect( hDC, &client, hBrush );
1099 
1100  /* Draw label */
1101  client = rtext;
1102  dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &rtext);
1103 
1104  /* Only adjust rbox when rtext is valid */
1105  if (dtFlags != (UINT)-1L)
1106  {
1107  rbox.top = rtext.top;
1108  rbox.bottom = rtext.bottom;
1109  }
1110 
1111  /* Draw the check-box bitmap */
1112  if (action == ODA_DRAWENTIRE || action == ODA_SELECT)
1113  {
1114  UINT flags;
1115 
1116  if ((get_button_type(style) == BS_RADIOBUTTON) ||
1119  else flags = DFCS_BUTTONCHECK;
1120 
1122  if (state & BST_PUSHED) flags |= DFCS_PUSHED;
1123 
1125 
1126  /* rbox must have the correct height */
1127  delta = rbox.bottom - rbox.top - checkBoxHeight;
1128 
1129  if (style & BS_TOP) {
1130  if (delta > 0) {
1131  rbox.bottom = rbox.top + checkBoxHeight;
1132  } else {
1133  rbox.top -= -delta/2 + 1;
1134  rbox.bottom = rbox.top + checkBoxHeight;
1135  }
1136  } else if (style & BS_BOTTOM) {
1137  if (delta > 0) {
1138  rbox.top = rbox.bottom - checkBoxHeight;
1139  } else {
1140  rbox.bottom += -delta/2 + 1;
1141  rbox.top = rbox.bottom - checkBoxHeight;
1142  }
1143  } else { /* Default */
1144  if (delta > 0) {
1145  int ofs = (delta / 2);
1146  rbox.bottom -= ofs + 1;
1147  rbox.top = rbox.bottom - checkBoxHeight;
1148  } else if (delta < 0) {
1149  int ofs = (-delta / 2);
1150  rbox.top -= ofs + 1;
1151  rbox.bottom = rbox.top + checkBoxHeight;
1152  }
1153  }
1154 
1155  DrawFrameControl( hDC, &rbox, DFC_BUTTON, flags );
1156  }
1157 
1158  if (dtFlags == (UINT)-1L) /* Noting to draw */
1159  return;
1160 
1161  if (action == ODA_DRAWENTIRE)
1162  BUTTON_DrawLabel(hwnd, hDC, dtFlags, &rtext);
1163 
1164  /* ... and focus */
1165  if (action == ODA_FOCUS || (state & BST_FOCUS))
1166  {
1167 #ifdef __REACTOS__
1168  if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS))
1169  {
1170 #endif
1171  rtext.left--;
1172  rtext.right++;
1173  IntersectRect(&rtext, &rtext, &client);
1174  DrawFocusRect( hDC, &rtext );
1175 #ifdef __REACTOS__
1176  }
1177 #endif
1178  }
1179  SelectClipRgn( hDC, hrgn );
1180  if (hrgn) DeleteObject( hrgn );
1181 }
#define WS_DISABLED
Definition: pedump.c:621
BOOL WINAPI GetCharWidthW(_In_ HDC hdc, _In_ UINT iFirst, _In_ UINT iLast, _Out_writes_(iLast+1 - iFirst) LPINT lpBuffer)
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define LOGPIXELSX
Definition: wingdi.h:717
#define DFC_BUTTON
Definition: winuser.h:476
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
#define BS_LEFTTEXT
Definition: pedump.c:662
#define DFCS_CHECKED
Definition: winuser.h:504
#define BS_RADIOBUTTON
Definition: pedump.c:655
UINT state
Definition: button.c:168
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1754
#define DFCS_BUTTON3STATE
Definition: winuser.h:500
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
#define DFCS_INACTIVE
Definition: winuser.h:502
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define GWL_EXSTYLE
Definition: winuser.h:845
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
UINT_PTR WPARAM
Definition: windef.h:207
#define GetWindowLongPtrW
Definition: winuser.h:4804
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define ODA_FOCUS
Definition: winuser.h:2519
#define WS_EX_RIGHT
Definition: winuser.h:400
HRGN set_control_clipping(HDC hdc, const RECT *rect)
Definition: button.c:239
#define BST_INDETERMINATE
Definition: winuser.h:198
HFONT hFont
Definition: main.c:53
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HBRUSH FASTCALL GetControlColor(PWND pwndParent, PWND pwnd, HDC hdc, UINT CtlMsg)
Definition: misc.c:145
#define DFCS_PUSHED
Definition: winuser.h:503
#define DFCS_BUTTONRADIO
Definition: winuser.h:499
long LONG
Definition: pedump.c:60
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define BST_FOCUS
Definition: winuser.h:200
static UINT get_button_type(LONG window_style)
Definition: button.c:192
static void BUTTON_DrawLabel(HWND hwnd, HDC hdc, UINT dtFlags, const RECT *rc)
Definition: button.c:876
#define ODA_DRAWENTIRE
Definition: winuser.h:2517
r parent
Definition: btrfs.c:2944
#define BST_PUSHED
Definition: winuser.h:201
#define BS_TOP
Definition: winuser.h:277
static FILE * client
Definition: client.c:41
GLbitfield flags
Definition: glext.h:7161
static LPARAM
Definition: button.c:42
static HFONT get_button_font(HWND hwnd)
Definition: button.c:182
static const WCHAR L[]
Definition: oid.c:1250
static HRGN hrgn
Definition: win.c:55
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
static LONG get_button_state(HWND hwnd)
Definition: button.c:158
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define GWL_STYLE
Definition: winuser.h:846
#define DFCS_BUTTONCHECK
Definition: winuser.h:496
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetParent(_In_ HWND)
#define BS_AUTORADIOBUTTON
Definition: pedump.c:660
const WCHAR * action
Definition: action.c:7783
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned int UINT
Definition: ndis.h:50
#define BS_BOTTOM
Definition: winuser.h:259
#define BST_CHECKED
Definition: winuser.h:197
static void PB_Paint(HWND hwnd, HDC hDC, UINT action)
Definition: button.c:935
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc)
Definition: button.c:750
#define BS_PUSHLIKE
Definition: winuser.h:272
LONG bottom
Definition: windef.h:309
#define LOGPIXELSY
Definition: wingdi.h:718
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
Arabic default style
Definition: afstyles.h:93
#define ODA_SELECT
Definition: winuser.h:2518

◆ GB_Paint()

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

Definition at line 1210 of file button.c.

1211 {
1212  RECT rc, rcFrame;
1213  HBRUSH hbr;
1214  HFONT hFont;
1215  UINT dtFlags;
1216  TEXTMETRICW tm;
1218  HWND parent;
1219  HRGN hrgn;
1220 
1221  if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
1222  /* GroupBox acts like static control, so it sends CTLCOLORSTATIC */
1223  parent = GetParent(hwnd);
1224  if (!parent) parent = hwnd;
1225 #ifdef __REACTOS__
1227 #else
1229  if (!hbr) /* did the app forget to call defwindowproc ? */
1230  hbr = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
1231  (WPARAM)hDC, (LPARAM)hwnd);
1232 #endif
1233  GetClientRect( hwnd, &rc);
1234  rcFrame = rc;
1235  hrgn = set_control_clipping( hDC, &rc );
1236 
1237  GetTextMetricsW (hDC, &tm);
1238  rcFrame.top += (tm.tmHeight / 2) - 1;
1239  DrawEdge (hDC, &rcFrame, EDGE_ETCHED, BF_RECT | ((style & BS_FLAT) ? BF_FLAT : 0));
1240 
1241  InflateRect(&rc, -7, 1);
1242  dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &rc);
1243 
1244  if (dtFlags != (UINT)-1L)
1245  {
1246  /* Because buttons have CS_PARENTDC class style, there is a chance
1247  * that label will be drawn out of client rect.
1248  * But Windows doesn't clip label's rect, so do I.
1249  */
1250 
1251  /* There is 1-pixel margin at the left, right, and bottom */
1252  rc.left--; rc.right++; rc.bottom++;
1253  FillRect(hDC, &rc, hbr);
1254  rc.left++; rc.right--; rc.bottom--;
1255 
1256  BUTTON_DrawLabel(hwnd, hDC, dtFlags, &rc);
1257  }
1258  SelectClipRgn( hDC, hrgn );
1259  if (hrgn) DeleteObject( hrgn );
1260 }
#define BF_FLAT
Definition: winuser.h:471
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1754
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
UINT_PTR WPARAM
Definition: windef.h:207
#define GetWindowLongPtrW
Definition: winuser.h:4804
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
HRGN set_control_clipping(HDC hdc, const RECT *rect)
Definition: button.c:239
HFONT hFont
Definition: main.c:53
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HBRUSH FASTCALL GetControlColor(PWND pwndParent, PWND pwnd, HDC hdc, UINT CtlMsg)
Definition: misc.c:145
#define BF_RECT
Definition: winuser.h:462
long LONG
Definition: pedump.c:60
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
static void BUTTON_DrawLabel(HWND hwnd, HDC hdc, UINT dtFlags, const RECT *rc)
Definition: button.c:876
r parent
Definition: btrfs.c:2944
#define EDGE_ETCHED
Definition: winuser.h:452
static LPARAM
Definition: button.c:42
static HFONT get_button_font(HWND hwnd)
Definition: button.c:182
static const WCHAR L[]
Definition: oid.c:1250
static HRGN hrgn
Definition: win.c:55
Definition: time.h:76
#define BS_FLAT
Definition: winuser.h:280
#define GWL_STYLE
Definition: winuser.h:846
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetParent(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned int UINT
Definition: ndis.h:50
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc)
Definition: button.c:750
LONG bottom
Definition: windef.h:309
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
Arabic default style
Definition: afstyles.h:93

◆ get_button_font()

static HFONT get_button_font ( HWND  hwnd)
inlinestatic

Definition at line 182 of file button.c.

183 {
185 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define BUTTON_HFONT_GWL_OFFSET
Definition: button.c:72
#define GetWindowLongPtrW
Definition: winuser.h:4804
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)

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

◆ get_button_state()

static LONG get_button_state ( HWND  hwnd)
inlinestatic

Definition at line 158 of file button.c.

159 {
161 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define GetWindowLongPtrW
Definition: winuser.h:4804
#define STATE_GWL_OFFSET
Definition: button.c:71

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 209 of file button.c.

210 {
211  INT len = 512;
212  WCHAR *buffer = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) );
214  return buffer;
215 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
GLuint buffer
Definition: glext.h:5915
int32_t INT
Definition: typedefs.h:57
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLsizei len
Definition: glext.h:6722
INT WINAPI InternalGetWindowText(_In_ HWND hWnd, _Out_writes_to_(cchMaxCount, return+1) LPWSTR pString, _In_ int cchMaxCount)

Referenced by BUTTON_CalcLabelRect(), and BUTTON_DrawLabel().

◆ get_button_type()

static UINT get_button_type ( LONG  window_style)
inlinestatic

Definition at line 192 of file button.c.

193 {
194  return (window_style & BS_TYPEMASK);
195 }
#define BS_TYPEMASK
Definition: winuser.h:270

Referenced by BUTTON_BStoDT(), ButtonWndProc_common(), CB_Paint(), and PB_Paint().

◆ OB_Paint()

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

Definition at line 1322 of file button.c.

1323 {
1325  DRAWITEMSTRUCT dis;
1327  HWND parent;
1328  HFONT hFont, hPrevFont = 0;
1329  HRGN hrgn;
1330 
1331  dis.CtlType = ODT_BUTTON;
1332  dis.CtlID = id;
1333  dis.itemID = 0;
1334  dis.itemAction = action;
1335  dis.itemState = ((state & BST_FOCUS) ? ODS_FOCUS : 0) |
1336  ((state & BST_PUSHED) ? ODS_SELECTED : 0) |
1338  dis.hwndItem = hwnd;
1339  dis.hDC = hDC;
1340  dis.itemData = 0;
1341  GetClientRect( hwnd, &dis.rcItem );
1342 
1343  if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, hFont );
1344  parent = GetParent(hwnd);
1345  if (!parent) parent = hwnd;
1346 #ifdef __REACTOS__
1348 #else
1350 #endif
1351 
1352  hrgn = set_control_clipping( hDC, &dis.rcItem );
1353 
1354  SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
1355  if (hPrevFont) SelectObject(hDC, hPrevFont);
1356  SelectClipRgn( hDC, hrgn );
1357  if (hrgn) DeleteObject( hrgn );
1358 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
UINT state
Definition: button.c:168
ULONG_PTR itemData
Definition: winuser.h:3068
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define ODS_FOCUS
Definition: winuser.h:2524
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
UINT_PTR WPARAM
Definition: windef.h:207
#define GetWindowLongPtrW
Definition: winuser.h:4804
HRGN set_control_clipping(HDC hdc, const RECT *rect)
Definition: button.c:239
HFONT hFont
Definition: main.c:53
HBRUSH FASTCALL GetControlColor(PWND pwndParent, PWND pwnd, HDC hdc, UINT CtlMsg)
Definition: misc.c:145
#define WM_CTLCOLORBTN
Definition: winuser.h:1751
long LONG
Definition: pedump.c:60
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define BST_FOCUS
Definition: winuser.h:200
r parent
Definition: btrfs.c:2944
#define ODS_DISABLED
Definition: winuser.h:2522
#define BST_PUSHED
Definition: winuser.h:201
static HFONT get_button_font(HWND hwnd)
Definition: button.c:182
static HRGN hrgn
Definition: win.c:55
static LONG get_button_state(HWND hwnd)
Definition: button.c:158
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetParent(_In_ HWND)
const WCHAR * action
Definition: action.c:7783
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WM_DRAWITEM
Definition: winuser.h:1627
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define ODS_SELECTED
Definition: winuser.h:2520
#define ODT_BUTTON
Definition: winuser.h:2515
GLenum GLuint id
Definition: glext.h:5579
#define GWLP_ID
Definition: winuser.h:854

◆ paint_button()

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

Definition at line 198 of file button.c.

199 {
201  {
202  HDC hdc = GetDC( hwnd );
204  ReleaseDC( hwnd, hdc );
205  }
206 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
static const pfButtonPaint btnPaintFunc[MAX_BTN_TYPE]
Definition: button.c:122
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC hdc
Definition: main.c:9
const WCHAR * action
Definition: action.c:7783
BOOL WINAPI IsWindowVisible(_In_ HWND)
Arabic default style
Definition: afstyles.h:93

Referenced by ButtonWndProc_common().

◆ PB_Paint()

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

Definition at line 935 of file button.c.

936 {
937  RECT rc, r;
938  UINT dtFlags, uState;
939  HPEN hOldPen;
940  HBRUSH hOldBrush;
941  INT oldBkMode;
942  COLORREF oldTxtColor;
943  HFONT hFont;
946  BOOL pushedState = (state & BST_PUSHED);
947  HWND parent;
948  HRGN hrgn;
949 
950  GetClientRect( hwnd, &rc );
951 
952  /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
954  parent = GetParent(hwnd);
955  if (!parent) parent = hwnd;
956 #ifdef __REACTOS__
958 #else
960 #endif
961 
962  hrgn = set_control_clipping( hDC, &rc );
963 #ifdef __REACTOS__
964  hOldPen = SelectObject(hDC, GetStockObject(DC_PEN));
966 #else
967  hOldPen = SelectObject(hDC, SYSCOLOR_GetPen(COLOR_WINDOWFRAME));
968 #endif
970  oldBkMode = SetBkMode(hDC, TRANSPARENT);
971 
973  {
974  if (action != ODA_FOCUS)
975  Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
976  InflateRect( &rc, -1, -1 );
977  }
978 
979  /* completely skip the drawing if only focus has changed */
980  if (action == ODA_FOCUS) goto draw_focus;
981 
982  uState = DFCS_BUTTONPUSH;
983 
984  if (style & BS_FLAT)
985  uState |= DFCS_MONO;
986  else if (pushedState)
987  {
989  uState |= DFCS_FLAT;
990  else
991  uState |= DFCS_PUSHED;
992  }
993 
995  uState |= DFCS_CHECKED;
996 
997  DrawFrameControl( hDC, &rc, DFC_BUTTON, uState );
998 
999  /* draw button label */
1000  r = rc;
1001  dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &r);
1002 
1003  if (dtFlags == (UINT)-1L)
1004  goto cleanup;
1005 
1006  if (pushedState)
1007  OffsetRect(&r, 1, 1);
1008 
1009  oldTxtColor = SetTextColor( hDC, GetSysColor(COLOR_BTNTEXT) );
1010 
1011  BUTTON_DrawLabel(hwnd, hDC, dtFlags, &r);
1012 
1013  SetTextColor( hDC, oldTxtColor );
1014 
1015 draw_focus:
1016  if (action == ODA_FOCUS || (state & BST_FOCUS))
1017  {
1018 #ifdef __REACTOS__
1019  if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS))
1020  {
1021 #endif
1022  InflateRect( &rc, -2, -2 );
1023  DrawFocusRect( hDC, &rc );
1024 #ifdef __REACTOS__
1025  }
1026 #endif
1027  }
1028 
1029  cleanup:
1030  SelectObject( hDC, hOldPen );
1031  SelectObject( hDC, hOldBrush );
1032  SetBkMode(hDC, oldBkMode);
1033  SelectClipRgn( hDC, hrgn );
1034  if (hrgn) DeleteObject( hrgn );
1035 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define DFCS_FLAT
Definition: winuser.h:510
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define DFC_BUTTON
Definition: winuser.h:476
#define COLOR_WINDOWFRAME
Definition: winuser.h:909
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define DFCS_CHECKED
Definition: winuser.h:504
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
UINT state
Definition: button.c:168
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
UINT_PTR WPARAM
Definition: windef.h:207
#define GetWindowLongPtrW
Definition: winuser.h:4804
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define ODA_FOCUS
Definition: winuser.h:2519
HRGN set_control_clipping(HDC hdc, const RECT *rect)
Definition: button.c:239
int32_t INT
Definition: typedefs.h:57
DWORD WINAPI GetSysColor(_In_ int)
#define BST_INDETERMINATE
Definition: winuser.h:198
HFONT hFont
Definition: main.c:53
HBRUSH FASTCALL GetControlColor(PWND pwndParent, PWND pwnd, HDC hdc, UINT CtlMsg)
Definition: misc.c:145
#define DFCS_PUSHED
Definition: winuser.h:503
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
#define WM_CTLCOLORBTN
Definition: winuser.h:1751
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define TRANSPARENT
Definition: wingdi.h:949
LONG_PTR LPARAM
Definition: windef.h:208
#define BST_FOCUS
Definition: winuser.h:200
static UINT get_button_type(LONG window_style)
Definition: button.c:192
static void BUTTON_DrawLabel(HWND hwnd, HDC hdc, UINT dtFlags, const RECT *rc)
Definition: button.c:876
r parent
Definition: btrfs.c:2944
#define BST_PUSHED
Definition: winuser.h:201
DWORD COLORREF
Definition: windef.h:300
#define DFCS_MONO
Definition: winuser.h:511
static HFONT get_button_font(HWND hwnd)
Definition: button.c:182
static const WCHAR L[]
Definition: oid.c:1250
#define COLOR_BTNFACE
Definition: winuser.h:918
static HRGN hrgn
Definition: win.c:55
static LONG get_button_state(HWND hwnd)
Definition: button.c:158
#define BS_FLAT
Definition: winuser.h:280
#define GWL_STYLE
Definition: winuser.h:846
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetParent(_In_ HWND)
const WCHAR * action
Definition: action.c:7783
#define DFCS_BUTTONPUSH
Definition: winuser.h:501
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned int UINT
Definition: ndis.h:50
#define BST_CHECKED
Definition: winuser.h:197
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc)
Definition: button.c:750
LONG bottom
Definition: windef.h:309
char * cleanup(char *str)
Definition: wpickclick.c:99
#define COLOR_BTNTEXT
Definition: winuser.h:923
COLORREF WINAPI SetDCPenColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:917
Arabic default style
Definition: afstyles.h:93
HBRUSH WINAPI GetSysColorBrush(_In_ int)

Referenced by CB_Paint().

◆ set_button_font()

static void set_button_font ( HWND  hwnd,
HFONT  font 
)
inlinestatic

Definition at line 187 of file button.c.

188 {
190 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define BUTTON_HFONT_GWL_OFFSET
Definition: button.c:72
Definition: mk_font.cpp:20
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define SetWindowLongPtrW
Definition: winuser.h:5321

Referenced by ButtonWndProc_common().

◆ set_button_state()

static void set_button_state ( HWND  hwnd,
LONG  state 
)
inlinestatic

Definition at line 163 of file button.c.

164 {
166 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
UINT state
Definition: button.c:168
#define STATE_GWL_OFFSET
Definition: button.c:71
#define SetWindowLongPtrW
Definition: winuser.h:5321

Referenced by ButtonWndProc_common().

◆ UB_Paint()

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

Definition at line 1267 of file button.c.

1268 {
1269  RECT rc;
1270  HBRUSH hBrush;
1271  HFONT hFont;
1273  HWND parent;
1274 
1275  GetClientRect( hwnd, &rc);
1276 
1277  if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
1278 
1279  parent = GetParent(hwnd);
1280  if (!parent) parent = hwnd;
1281 #ifdef __REACTOS__
1283 #else
1284  hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd);
1285  if (!hBrush) /* did the app forget to call defwindowproc ? */
1286  hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN,
1287  (WPARAM)hDC, (LPARAM)hwnd);
1288 #endif
1289 
1290  FillRect( hDC, &rc, hBrush );
1291  if (action == ODA_FOCUS || (state & BST_FOCUS))
1292 #ifdef __REACTOS__
1293  {
1294  if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS))
1295 #endif
1296  DrawFocusRect( hDC, &rc );
1297 #ifdef __REACTOS__
1298  }
1299 #endif
1300 
1301  switch (action)
1302  {
1303  case ODA_FOCUS:
1305  break;
1306 
1307  case ODA_SELECT:
1309  break;
1310 
1311  default:
1313  break;
1314  }
1315 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
UINT state
Definition: button.c:168
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
UINT_PTR WPARAM
Definition: windef.h:207
#define ODA_FOCUS
Definition: winuser.h:2519
#define BN_UNHILITE
Definition: winuser.h:1916
HFONT hFont
Definition: main.c:53
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HBRUSH FASTCALL GetControlColor(PWND pwndParent, PWND pwnd, HDC hdc, UINT CtlMsg)
Definition: misc.c:145
#define WM_CTLCOLORBTN
Definition: winuser.h:1751
long LONG
Definition: pedump.c:60
#define BST_FOCUS
Definition: winuser.h:200
#define BN_HILITE
Definition: winuser.h:1911
r parent
Definition: btrfs.c:2944
#define BST_PUSHED
Definition: winuser.h:201
static LPARAM
Definition: button.c:42
#define BN_KILLFOCUS
Definition: winuser.h:1912
static HFONT get_button_font(HWND hwnd)
Definition: button.c:182
static LONG get_button_state(HWND hwnd)
Definition: button.c:158
#define BN_PAINT
Definition: winuser.h:1913
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define BN_SETFOCUS
Definition: winuser.h:1915
HWND WINAPI GetParent(_In_ HWND)
#define BUTTON_NOTIFY_PARENT(hWnd, code)
Definition: button.c:86
const WCHAR * action
Definition: action.c:7783
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define ODA_SELECT
Definition: winuser.h:2518

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( button  )

Variable Documentation

◆ btnPaintFunc

const pfButtonPaint btnPaintFunc[MAX_BTN_TYPE]
static
Initial value:
=
{
NULL,
}
static void CB_Paint(HWND hwnd, HDC hDC, UINT action)
Definition: button.c:1041
static void UB_Paint(HWND hwnd, HDC hDC, UINT action)
Definition: button.c:1267
static void GB_Paint(HWND hwnd, HDC hDC, UINT action)
Definition: button.c:1210
smooth NULL
Definition: ftsmooth.c:416
static void OB_Paint(HWND hwnd, HDC hDC, UINT action)
Definition: button.c:1322
static void PB_Paint(HWND hwnd, HDC hDC, UINT action)
Definition: button.c:935

Definition at line 122 of file button.c.

Referenced by ButtonWndProc_common(), and paint_button().

◆ BUTTON_builtin_class

const struct builtin_class_descr BUTTON_builtin_class
Initial value:
=
{
WINPROC_BUTTON,
0
}
#define CS_HREDRAW
Definition: winuser.h:648
#define CS_VREDRAW
Definition: winuser.h:653
static const WCHAR buttonW[]
Definition: button.c:141
#define CS_DBLCLKS
Definition: winuser.h:646
#define NB_EXTRA_BYTES
Definition: button.c:75
#define IDC_ARROW
Definition: winuser.h:682
#define CS_PARENTDC
Definition: winuser.h:651

Definition at line 142 of file button.c.

◆ buttonW

const WCHAR buttonW[] = {'B','u','t','t','o','n',0}
static

Definition at line 141 of file button.c.

◆ maxCheckState

const WORD maxCheckState[MAX_BTN_TYPE]
static
Initial value:

Definition at line 104 of file button.c.

Referenced by ButtonWndProc_common().