77#define BUTTON_NSTATES 0x0F
78#define BUTTON_BTNPRESSED 0x40
79#define BUTTON_UNKNOWN2 0x20
80#define BUTTON_UNKNOWN3 0x10
82#define BUTTON_BMCLICK 0x100
85#define BUTTON_NOTIFY_PARENT(hWnd, code) \
87 TRACE("notification " #code " sent to hwnd=%p\n", GetParent(hWnd)); \
88 SendMessageW(GetParent(hWnd), WM_COMMAND, \
89 MAKEWPARAM(GetWindowLongPtrW((hWnd),GWLP_ID), (code)), \
120#define MAX_BTN_TYPE 16
268 style &= ~BS_TYPEMASK;
320 if (infoPtr->
u.
image != 0)
362 paint(theme, infoPtr,
hdc, drawState, dtFlags, infoPtr->
state &
BST_FOCUS, prfFlag);
371 ERR(
"Failed to create DC and bitmap for double buffering\n");
379 paint(theme, infoPtr, hParamDC, drawState, dtFlags, infoPtr->
state &
BST_FOCUS, prfFlag);
392 if (theme && BUTTON_PaintWithTheme(theme, infoPtr,
hdc, 0))
409 SIZE TextSize, ImageSize, ButtonSize;
446 TextSize.
cy += infoPtr->rcTextMargin.top + infoPtr->rcTextMargin.bottom;
447 TextSize.
cx += infoPtr->rcTextMargin.left + infoPtr->rcTextMargin.right;
451 ImageSize.
cx += infoPtr->imlData.margin.left + infoPtr->imlData.margin.right;
452 ImageSize.
cy += infoPtr->imlData.margin.top + infoPtr->imlData.margin.bottom;
456 ImageSize.
cx = ImageSize.
cy = 0;
461 RECT rcContents = {0};
462 RECT rcButtonExtent = {0};
463 rcContents.
right = ImageSize.
cx + TextSize.
cx;
466 ButtonSize.
cx = rcButtonExtent.
right - rcButtonExtent.
left;
467 ButtonSize.
cy = rcButtonExtent.
bottom - rcButtonExtent.
top;
471 ButtonSize.
cx = ImageSize.
cx + TextSize.
cx + 5;
472 ButtonSize.
cy =
max(ImageSize.
cy, TextSize.
cy + 7);
566 if (!(infoPtr->ui_state & UISF_HIDEACCEL))
577 if (infoPtr->ui_state !=
flags)
579 infoPtr->ui_state =
flags;
635 infoPtr = heap_alloc_zero(
sizeof(*infoPtr) );
637 infoPtr->hwnd =
hWnd;
639 SetRect(&infoPtr->rcTextMargin, 1,1,1,1);
667 case WM_THEMECHANGED:
770 state = infoPtr->state;
796 ((infoPtr->state & 3) + 1), 0 );
833 if ((infoPtr->state &
BST_HOT) == 0)
892 infoPtr->state &= ~BST_HOT;
906 infoPtr->state &= ~BST_HOT;
918 *
prc = infoPtr->rcTextMargin;
926 infoPtr->rcTextMargin = *
prc;
932 if (!pimldata || !pimldata->
himl)
934 infoPtr->imlData = *pimldata;
942 *pimldata = infoPtr->imlData;
960 ret = BUTTON_GetIdealSize(infoPtr, theme, pSize);
1033 return (
LRESULT)infoPtr->font;
1050 infoPtr->state &= ~BST_FOCUS;
1081 if (infoPtr->state & BUTTON_BMCLICK)
1083 infoPtr->state |= BUTTON_BMCLICK;
1088 infoPtr->state &= ~BUTTON_BMCLICK;
1105 oldHbitmap = infoPtr->u.image;
1111 return (
LRESULT)infoPtr->u.image;
1114 return infoPtr->state & 3;
1123 if ((infoPtr->state & 3) !=
wParam)
1125 infoPtr->state = (infoPtr->state & ~3) |
wParam;
1135 return infoPtr->state;
1138 state = infoPtr->state;
1146 state &= ~BST_PUSHED;
1150 infoPtr->state =
state;
1157 case WM_UPDATEUISTATE:
1160 if (button_update_uistate(infoPtr))
1195 BOOL bHasIml = BUTTON_DrawIml(
hdc, &infoPtr->imlData, &
r,
TRUE, 0);
1221 if (infoPtr->ui_state & UISF_HIDEACCEL)
1233 r.right =
r.left + bm.bmWidth;
1234 r.bottom =
r.top + bm.bmHeight;
1244 r.right =
r.left + bm.bmWidth;
1245 r.bottom =
r.top + bm.bmHeight;
1263 r.left = infoPtr->imlData.margin.left;
1265 r.right = infoPtr->imlData.margin.right;
1267 r.top = infoPtr->imlData.margin.top;
1269 r.bottom = infoPtr->imlData.margin.bottom;
1280 case DT_LEFT:
r.left++;
r.right++;
break;
1283 r.right =
r.left +
n;
break;
1286 r.left =
r.right -
n;
1292 case DT_TOP:
r.top++;
r.bottom++;
break;
1299 r.bottom =
r.top +
n;
break;
1302 r.top =
r.bottom -
n;
1349 BUTTON_DrawIml(
hdc, &infoPtr->imlData, &rcText,
FALSE, 0);
1402 UINT dtFlags, uState;
1452 else if (pushedState)
1478 if (dtFlags == (
UINT)-1L)
1499 if (!(infoPtr->ui_state & UISF_HIDEFOCUS))
1526 int delta, text_offset, checkBoxWidth, checkBoxHeight;
1560 rtext.
right -= checkBoxWidth + text_offset;
1565 rtext.
left += checkBoxWidth + text_offset;
1566 rbox.
right = checkBoxWidth;
1578 if (dtFlags != (
UINT)-1L)
1600 delta = rbox.
bottom - rbox.
top - checkBoxHeight;
1604 rbox.
bottom = rbox.
top + checkBoxHeight;
1606 rbox.
top -= -delta/2 + 1;
1607 rbox.
bottom = rbox.
top + checkBoxHeight;
1611 rbox.
top = rbox.
bottom - checkBoxHeight;
1613 rbox.
bottom += -delta/2 + 1;
1614 rbox.
top = rbox.
bottom - checkBoxHeight;
1618 int ofs = (delta / 2);
1620 rbox.
top = rbox.
bottom - checkBoxHeight;
1621 }
else if (delta < 0) {
1622 int ofs = (-delta / 2);
1623 rbox.
top -= ofs + 1;
1624 rbox.
bottom = rbox.
top + checkBoxHeight;
1631 if (dtFlags == (
UINT)-1L)
1668 if (!sibling)
break;
1673 if ((
hwnd != sibling) &&
1678 }
while (sibling !=
start);
1709 rcFrame.
top += (
tm.tmHeight / 2) - 1;
1715 if (dtFlags != (
UINT)-1)
1824 int state = states[ drawState ];
1879 RECT focusRect = bgRect;
1906 static const int cb_states[3][5] =
1913 static const int rb_states[2][5] =
1922 int checkState = infoPtr->
state & 3;
1927 ? cb_states[ checkState ][ drawState ]
1928 : rb_states[ checkState ][ drawState ];
1942 TRACE(
"Failed to create font\n");
1946 created_font =
TRUE;
2049 int state = states[ drawState ];
2064 TRACE(
"Failed to create font\n");
2067 created_font =
TRUE;
2085 bgRect.
top += (textExtent.
cy / 2);
2133 memset(&wndClass, 0,
sizeof(wndClass));
2146void BUTTON_Unregister(
void)
static void * heap_alloc(size_t len)
static BOOL heap_free(void *mem)
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
BOOL WINAPI ImageList_Draw(HIMAGELIST himl, INT i, HDC hdc, INT x, INT y, UINT fStyle)
INT WINAPI ImageList_GetImageCount(HIMAGELIST himl)
BOOL WINAPI ImageList_GetIconSize(HIMAGELIST himl, INT *cx, INT *cy)
#define HeapFree(x, y, z)
static void cleanup(void)
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
BOOL WINAPI IsThemeBackgroundPartiallyTransparent(HTHEME hTheme, int iPartId, int iStateId)
HRESULT WINAPI GetThemePartSize(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz)
HRESULT WINAPI GetThemeBackgroundExtent(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pContentRect, RECT *pExtentRect)
HRESULT WINAPI DrawThemeText(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect)
HRESULT WINAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT *prc)
HRESULT WINAPI GetThemeBackgroundContentRect(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pBoundingRect, RECT *pContentRect)
HRESULT WINAPI GetThemeFont(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, LOGFONTW *pFont)
HRESULT WINAPI GetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, RECT *prc, MARGINS *pMargins)
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
HTHEME WINAPI GetWindowTheme(HWND hwnd)
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
static VOID NTAPI BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
DWORD WINAPI GetLayout(_In_ HDC hdc)
GLuint GLuint GLsizei GLenum type
GLuint GLuint GLsizei count
GLdouble GLdouble GLdouble r
GLdouble GLdouble GLdouble GLdouble top
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
_Must_inspect_result_ _Out_ LPSIZE psize
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
#define BS_AUTORADIOBUTTON
_Out_opt_ int _Out_opt_ int * cy
#define CDRF_NOTIFYPOSTERASE
#define CDIS_SHOWKEYBOARDCUES
#define BUTTON_IMAGELIST_ALIGN_CENTER
#define BS_DEFCOMMANDLINK
#define BUTTON_IMAGELIST_ALIGN_TOP
#define BUTTON_IMAGELIST_ALIGN_LEFT
#define CDRF_NOTIFYPOSTPAINT
#define BCN_HOTITEMCHANGE
#define BCM_SETTEXTMARGIN
#define BS_DEFSPLITBUTTON
struct tagTRACKMOUSEEVENT TRACKMOUSEEVENT
#define BUTTON_IMAGELIST_ALIGN_RIGHT
#define BUTTON_IMAGELIST_ALIGN_BOTTOM
#define BCM_GETTEXTMARGIN
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
WCHAR lfFaceName[LF_FACESIZE]
#define CBS_UNCHECKEDNORMAL
#define CBS_CHECKEDNORMAL
#define TMT_CONTENTMARGINS
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI GetCharWidthW(_In_ HDC hdc, _In_ UINT iFirst, _In_ UINT iLast, _Out_writes_(iLast+1 - iFirst) LPINT lpBuffer)
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI ExcludeClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI DPtoLP(_In_ HDC hdc, _Inout_updates_(c) LPPOINT lppt, _In_ int c)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int WINAPI GetClipRgn(_In_ HDC, _In_ HRGN)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define BST_INDETERMINATE
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
DWORD WINAPI GetSysColor(_In_ int)
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define WM_CTLCOLORSTATIC
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
void WINAPI mouse_event(_In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ ULONG_PTR)
#define GetWindowLongPtrW
BOOL WINAPI ReleaseCapture(void)
#define COLOR_WINDOWFRAME
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
#define WM_CAPTURECHANGED
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define DLGC_UNDEFPUSHBUTTON
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
HWND WINAPI GetCapture(void)
BOOL WINAPI TrackMouseEvent(_Inout_ LPTRACKMOUSEEVENT)
#define WM_SYSCOLORCHANGE
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
#define DLGC_DEFPUSHBUTTON
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
HWND WINAPI GetNextDlgGroupItem(_In_ HWND, _In_opt_ HWND, _In_ BOOL)
#define DFCS_BUTTON3STATE
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
HDC WINAPI GetDC(_In_opt_ HWND)
int WINAPI GetWindowTextLengthW(_In_ HWND)
BOOL WINAPI IsWindowEnabled(_In_ HWND)
HWND WINAPI GetParent(_In_ HWND)
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define SetWindowLongPtrW
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
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)
BOOL WINAPI IsWindowVisible(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)