static void ButtonElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { ThemeButtonParams *params = clientData; const HIThemeButtonDrawInfo info = computeButtonDrawInfo(params, 0); static const CGRect scratchBounds = {{0, 0}, {100, 100}}; CGRect contentBounds; ButtonElementSizeNoPadding( clientData, elementRecord, tkwin, widthPtr, heightPtr, paddingPtr); /* * To compute internal padding, query the appearance manager * for the content bounds of a dummy rectangle, then use * the difference as the padding. */ ChkErr(HIThemeGetButtonContentBounds, &scratchBounds, &info, &contentBounds); paddingPtr->left = CGRectGetMinX(contentBounds); paddingPtr->top = CGRectGetMinY(contentBounds); paddingPtr->right = CGRectGetMaxX(scratchBounds) - CGRectGetMaxX(contentBounds) + 1; paddingPtr->bottom = CGRectGetMaxY(scratchBounds) - CGRectGetMaxY(contentBounds); /* * Now add a little extra padding to account for drop shadows. * @@@ SHOULD: call GetThemeButtonBackgroundBounds() instead. */ *paddingPtr = Ttk_AddPadding(*paddingPtr, ButtonMargins); *widthPtr += Ttk_PaddingWidth(ButtonMargins); *heightPtr += Ttk_PaddingHeight(ButtonMargins); }
static void ButtonElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { ThemeButtonParams *params = clientData; CGRect bounds = BoxToRect(d, Ttk_PadBox(b, ButtonMargins)); const HIThemeButtonDrawInfo info = computeButtonDrawInfo(params, state); BEGIN_DRAWING(d) ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL); END_DRAWING }
static void ButtonElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { ThemeButtonParms *parms = clientData; ThemeButtonDrawInfo info = computeButtonDrawInfo(parms, state); Rect bounds = BoxToRect(d, Ttk_PadBox(b, ButtonMargins)); BEGIN_DRAWING(d) ChkErr(DrawThemeButton, &bounds, parms->kind, &info, NULL, NULL, NULL, 0); END_DRAWING }