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)
377 paint(theme, infoPtr,
hdc, drawState, dtFlags, infoPtr->
state &
BST_FOCUS, prfFlag);
386 ERR(
"Failed to create DC and bitmap for double buffering\n");
394 paint(theme, infoPtr, hParamDC, drawState, dtFlags, infoPtr->
state &
BST_FOCUS, prfFlag);
407 if (theme && BUTTON_PaintWithTheme(theme, infoPtr,
hdc, 0))
423 HFONT
hFont = 0, hPrevFont = 0;
424 SIZE TextSize, ImageSize, ButtonSize;
461 TextSize.
cy += infoPtr->rcTextMargin.top + infoPtr->rcTextMargin.bottom;
462 TextSize.
cx += infoPtr->rcTextMargin.left + infoPtr->rcTextMargin.right;
466 ImageSize.
cx += infoPtr->imlData.margin.left + infoPtr->imlData.margin.right;
467 ImageSize.
cy += infoPtr->imlData.margin.top + infoPtr->imlData.margin.bottom;
471 ImageSize.
cx = ImageSize.
cy = 0;
476 RECT rcContents = {0};
477 RECT rcButtonExtent = {0};
478 rcContents.
right = ImageSize.
cx + TextSize.
cx;
481 ButtonSize.
cx = rcButtonExtent.
right - rcButtonExtent.
left;
482 ButtonSize.
cy = rcButtonExtent.
bottom - rcButtonExtent.
top;
486 ButtonSize.
cx = ImageSize.
cx + TextSize.
cx + 5;
487 ButtonSize.
cy =
max(ImageSize.
cy, TextSize.
cy + 7);
581 if (!(infoPtr->ui_state & UISF_HIDEACCEL))
592 if (infoPtr->ui_state !=
flags)
594 infoPtr->ui_state =
flags;
650 infoPtr = heap_alloc_zero(
sizeof(*infoPtr) );
652 infoPtr->hwnd =
hWnd;
654 SetRect(&infoPtr->rcTextMargin, 1,1,1,1);
683 case WM_THEMECHANGED:
786 state = infoPtr->state;
812 ((infoPtr->state & 3) + 1), 0 );
849 if ((infoPtr->state &
BST_HOT) == 0)
908 infoPtr->state &= ~BST_HOT;
922 infoPtr->state &= ~BST_HOT;
934 *
prc = infoPtr->rcTextMargin;
942 infoPtr->rcTextMargin = *
prc;
948 if (!pimldata || !pimldata->
himl)
950 infoPtr->imlData = *pimldata;
958 *pimldata = infoPtr->imlData;
976 ret = BUTTON_GetIdealSize(infoPtr, theme, pSize);
1059 if (!
note || !infoPtr->note)
1061 infoPtr->note_length = 0;
1062 infoPtr->note = heap_alloc_zero(
sizeof(
WCHAR));
1094 if (*size < infoPtr->note_length + 1)
1096 *
size = infoPtr->note_length + 1;
1115 return infoPtr->note_length;
1119 infoPtr->font = (HFONT)
wParam;
1124 return (
LRESULT)infoPtr->font;
1148 infoPtr->state &= ~BST_FOCUS;
1179 if (infoPtr->state & BUTTON_BMCLICK)
1181 infoPtr->state |= BUTTON_BMCLICK;
1186 infoPtr->state &= ~BUTTON_BMCLICK;
1203 oldHbitmap = infoPtr->u.image;
1209 return (
LRESULT)infoPtr->u.image;
1212 return infoPtr->state & 3;
1221 if ((infoPtr->state & 3) !=
wParam)
1223 infoPtr->state = (infoPtr->state & ~3) |
wParam;
1233 return infoPtr->state;
1236 state = infoPtr->state;
1244 state &= ~BST_PUSHED;
1248 infoPtr->state =
state;
1255 case WM_UPDATEUISTATE:
1258 if (button_update_uistate(infoPtr))
1293 BOOL bHasIml = BUTTON_DrawIml(
hdc, &infoPtr->imlData, &
r,
TRUE, 0);
1301 HFONT
hFont, hPrevFont = 0;
1319 if (infoPtr->ui_state & UISF_HIDEACCEL)
1361 r.left = infoPtr->imlData.margin.left;
1363 r.right = infoPtr->imlData.margin.right;
1365 r.top = infoPtr->imlData.margin.top;
1367 r.bottom = infoPtr->imlData.margin.bottom;
1378 case DT_LEFT:
r.left++;
r.right++;
break;
1381 r.right =
r.left +
n;
break;
1384 r.left =
r.right -
n;
1390 case DT_TOP:
r.top++;
r.bottom++;
break;
1397 r.bottom =
r.top +
n;
break;
1400 r.top =
r.bottom -
n;
1447 BUTTON_DrawIml(
hdc, &infoPtr->imlData, &rcText,
FALSE, 0);
1500 UINT dtFlags, uState;
1550 else if (pushedState)
1576 if (dtFlags == (
UINT)-1L)
1597 if (!(infoPtr->ui_state & UISF_HIDEFOCUS))
1624 int delta, text_offset, checkBoxWidth, checkBoxHeight;
1658 rtext.
right -= checkBoxWidth + text_offset;
1663 rtext.
left += checkBoxWidth + text_offset;
1664 rbox.
right = checkBoxWidth;
1676 if (dtFlags != (
UINT)-1L)
1698 delta = rbox.
bottom - rbox.
top - checkBoxHeight;
1702 rbox.
bottom = rbox.
top + checkBoxHeight;
1704 rbox.
top -= -delta/2 + 1;
1705 rbox.
bottom = rbox.
top + checkBoxHeight;
1709 rbox.
top = rbox.
bottom - checkBoxHeight;
1711 rbox.
bottom += -delta/2 + 1;
1712 rbox.
top = rbox.
bottom - checkBoxHeight;
1716 int ofs = (delta / 2);
1718 rbox.
top = rbox.
bottom - checkBoxHeight;
1719 }
else if (delta < 0) {
1720 int ofs = (-delta / 2);
1721 rbox.
top -= ofs + 1;
1722 rbox.
bottom = rbox.
top + checkBoxHeight;
1729 if (dtFlags == (
UINT)-1L)
1766 if (!sibling)
break;
1771 if ((
hwnd != sibling) &&
1776 }
while (sibling !=
start);
1807 rcFrame.
top += (
tm.tmHeight / 2) - 1;
1813 if (dtFlags != (
UINT)-1)
1919 RECT bgRect, textRect;
1922 int state = states[ drawState ];
1954 BUTTON_DrawIml(
hDC, &infoPtr->imlData, &textRect,
FALSE, drawState);
1977 RECT focusRect = bgRect;
2004 static const int cb_states[3][5] =
2011 static const int rb_states[2][5] =
2018 RECT bgRect, textRect;
2020 int checkState = infoPtr->
state & 3;
2025 ? cb_states[ checkState ][ drawState ]
2026 : rb_states[ checkState ][ drawState ];
2040 TRACE(
"Failed to create font\n");
2044 created_font =
TRUE;
2112 focusRect = textRect;
2146 RECT bgRect, textRect, contentRect;
2147 int state = states[ drawState ];
2162 TRACE(
"Failed to create font\n");
2165 created_font =
TRUE;
2183 bgRect.
top += (textExtent.
cy / 2);
2184 textRect.
left += 10;
2186 textRect.
right = textRect.
left + textExtent.
cx + 4;
2231 memset(&wndClass, 0,
sizeof(wndClass));
2244void 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)
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
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 GetWindowTheme(HWND hwnd)
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR pszClassList)
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_(Height *Stride) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Stride)
DWORD WINAPI GetLayout(_In_ HDC hdc)
GLuint GLuint GLsizei count
GLuint GLuint GLsizei GLenum type
GLdouble GLdouble GLdouble r
GLdouble GLdouble GLdouble GLdouble top
GLuint GLsizei GLsizei * length
#define memcpy(s1, s2, n)
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
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
_Must_inspect_result_ _Out_ LPSIZE psize
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)