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)), \
123#define MAX_BTN_TYPE 16
279 style &= ~BS_TYPEMASK;
331 if (infoPtr->
u.
image != 0)
373 paint(theme, infoPtr,
hdc, drawState, dtFlags, infoPtr->
state &
BST_FOCUS, prfFlag);
382 ERR(
"Failed to create DC and bitmap for double buffering\n");
390 paint(theme, infoPtr, hParamDC, drawState, dtFlags, infoPtr->
state &
BST_FOCUS, prfFlag);
403 if (theme && BUTTON_PaintWithTheme(theme, infoPtr,
hdc, 0))
420 SIZE TextSize, ImageSize, ButtonSize;
457 TextSize.
cy += infoPtr->rcTextMargin.top + infoPtr->rcTextMargin.bottom;
458 TextSize.
cx += infoPtr->rcTextMargin.left + infoPtr->rcTextMargin.right;
462 ImageSize.
cx += infoPtr->imlData.margin.left + infoPtr->imlData.margin.right;
463 ImageSize.
cy += infoPtr->imlData.margin.top + infoPtr->imlData.margin.bottom;
467 ImageSize.
cx = ImageSize.
cy = 0;
472 RECT rcContents = {0};
473 RECT rcButtonExtent = {0};
474 rcContents.
right = ImageSize.
cx + TextSize.
cx;
477 ButtonSize.
cx = rcButtonExtent.
right - rcButtonExtent.
left;
478 ButtonSize.
cy = rcButtonExtent.
bottom - rcButtonExtent.
top;
482 ButtonSize.
cx = ImageSize.
cx + TextSize.
cx + 5;
483 ButtonSize.
cy =
max(ImageSize.
cy, TextSize.
cy + 7);
577 if (!(infoPtr->ui_state & UISF_HIDEACCEL))
588 if (infoPtr->ui_state !=
flags)
590 infoPtr->ui_state =
flags;
646 infoPtr = heap_alloc_zero(
sizeof(*infoPtr) );
648 infoPtr->hwnd =
hWnd;
650 SetRect(&infoPtr->rcTextMargin, 1,1,1,1);
679 case WM_THEMECHANGED:
782 state = infoPtr->state;
808 ((infoPtr->state & 3) + 1), 0 );
845 if ((infoPtr->state &
BST_HOT) == 0)
904 infoPtr->state &= ~BST_HOT;
918 infoPtr->state &= ~BST_HOT;
930 *
prc = infoPtr->rcTextMargin;
938 infoPtr->rcTextMargin = *
prc;
944 if (!pimldata || !pimldata->
himl)
946 infoPtr->imlData = *pimldata;
954 *pimldata = infoPtr->imlData;
972 ret = BUTTON_GetIdealSize(infoPtr, theme, pSize);
1055 if (!
note || !infoPtr->note)
1057 infoPtr->note_length = 0;
1058 infoPtr->note = heap_alloc_zero(
sizeof(
WCHAR));
1090 if (*size < infoPtr->note_length + 1)
1092 *
size = infoPtr->note_length + 1;
1111 return infoPtr->note_length;
1120 return (
LRESULT)infoPtr->font;
1144 infoPtr->state &= ~BST_FOCUS;
1175 if (infoPtr->state & BUTTON_BMCLICK)
1177 infoPtr->state |= BUTTON_BMCLICK;
1182 infoPtr->state &= ~BUTTON_BMCLICK;
1199 oldHbitmap = infoPtr->u.image;
1205 return (
LRESULT)infoPtr->u.image;
1208 return infoPtr->state & 3;
1217 if ((infoPtr->state & 3) !=
wParam)
1219 infoPtr->state = (infoPtr->state & ~3) |
wParam;
1229 return infoPtr->state;
1232 state = infoPtr->state;
1240 state &= ~BST_PUSHED;
1244 infoPtr->state =
state;
1251 case WM_UPDATEUISTATE:
1254 if (button_update_uistate(infoPtr))
1289 BOOL bHasIml = BUTTON_DrawIml(
hdc, &infoPtr->imlData, &
r,
TRUE, 0);
1315 if (infoPtr->ui_state & UISF_HIDEACCEL)
1327 r.right =
r.left + bm.bmWidth;
1328 r.bottom =
r.top + bm.bmHeight;
1338 r.right =
r.left + bm.bmWidth;
1339 r.bottom =
r.top + bm.bmHeight;
1357 r.left = infoPtr->imlData.margin.left;
1359 r.right = infoPtr->imlData.margin.right;
1361 r.top = infoPtr->imlData.margin.top;
1363 r.bottom = infoPtr->imlData.margin.bottom;
1374 case DT_LEFT:
r.left++;
r.right++;
break;
1377 r.right =
r.left +
n;
break;
1380 r.left =
r.right -
n;
1386 case DT_TOP:
r.top++;
r.bottom++;
break;
1393 r.bottom =
r.top +
n;
break;
1396 r.top =
r.bottom -
n;
1443 BUTTON_DrawIml(
hdc, &infoPtr->imlData, &rcText,
FALSE, 0);
1496 UINT dtFlags, uState;
1546 else if (pushedState)
1572 if (dtFlags == (
UINT)-1L)
1593 if (!(infoPtr->ui_state & UISF_HIDEFOCUS))
1620 int delta, text_offset, checkBoxWidth, checkBoxHeight;
1654 rtext.
right -= checkBoxWidth + text_offset;
1659 rtext.
left += checkBoxWidth + text_offset;
1660 rbox.
right = checkBoxWidth;
1672 if (dtFlags != (
UINT)-1L)
1694 delta = rbox.
bottom - rbox.
top - checkBoxHeight;
1698 rbox.
bottom = rbox.
top + checkBoxHeight;
1700 rbox.
top -= -delta/2 + 1;
1701 rbox.
bottom = rbox.
top + checkBoxHeight;
1705 rbox.
top = rbox.
bottom - checkBoxHeight;
1707 rbox.
bottom += -delta/2 + 1;
1708 rbox.
top = rbox.
bottom - checkBoxHeight;
1712 int ofs = (delta / 2);
1714 rbox.
top = rbox.
bottom - checkBoxHeight;
1715 }
else if (delta < 0) {
1716 int ofs = (-delta / 2);
1717 rbox.
top -= ofs + 1;
1718 rbox.
bottom = rbox.
top + checkBoxHeight;
1725 if (dtFlags == (
UINT)-1L)
1762 if (!sibling)
break;
1767 if ((
hwnd != sibling) &&
1772 }
while (sibling !=
start);
1803 rcFrame.
top += (
tm.tmHeight / 2) - 1;
1809 if (dtFlags != (
UINT)-1)
1918 int state = states[ drawState ];
1973 RECT focusRect = bgRect;
2000 static const int cb_states[3][5] =
2007 static const int rb_states[2][5] =
2016 int checkState = infoPtr->
state & 3;
2021 ? cb_states[ checkState ][ drawState ]
2022 : rb_states[ checkState ][ drawState ];
2036 TRACE(
"Failed to create font\n");
2040 created_font =
TRUE;
2143 int state = states[ drawState ];
2158 TRACE(
"Failed to create font\n");
2161 created_font =
TRUE;
2179 bgRect.
top += (textExtent.
cy / 2);
2227 memset(&wndClass, 0,
sizeof(wndClass));
2240void BUTTON_Unregister(
void)
static void * heap_alloc(size_t len)
static BOOL heap_free(void *mem)
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
int note(char *format,...)
#define ERROR_INSUFFICIENT_BUFFER
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 ERROR_INVALID_PARAMETER
#define ERROR_NOT_SUPPORTED
#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 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
GLuint GLsizei GLsizei * length
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define memcpy(s1, s2, n)
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
#define BCM_GETNOTELENGTH
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)