本文整理汇总了C++中BoxToRect函数的典型用法代码示例。如果您正苦于以下问题:C++ BoxToRect函数的具体用法?C++ BoxToRect怎么用?C++ BoxToRect使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BoxToRect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EntryElementDraw
static void EntryElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
EntryElement *e = elementRecord;
Tk_3DBorder backgroundPtr = Tk_Get3DBorderFromObj(tkwin,e->backgroundObj);
Ttk_Box inner = Ttk_PadBox(b, Ttk_UniformPadding(3));
CGRect bounds = BoxToRect(d, inner);
const HIThemeFrameDrawInfo info = {
.version = 0,
.kind = kHIThemeFrameTextFieldSquare,
.state = Ttk_StateTableLookup(ThemeStateTable, state),
.isFocused = state & TTK_STATE_FOCUS,
};
/*
* Erase w/background color:
*/
XFillRectangle(Tk_Display(tkwin), d,
Tk_3DBorderGC(tkwin, backgroundPtr, TK_3D_FLAT_GC),
inner.x,inner.y, inner.width, inner.height);
BEGIN_DRAWING(d)
ChkErr(HIThemeDrawFrame, &bounds, &info, dc.context, HIOrientation);
/*if (state & TTK_STATE_FOCUS) {
ChkErr(DrawThemeFocusRect, &bounds, 1);
}*/
END_DRAWING
}
static Ttk_ElementSpec EntryElementSpec = {
TK_STYLE_VERSION_2,
sizeof(EntryElement),
EntryElementOptions,
EntryElementSize,
EntryElementDraw
};
/*----------------------------------------------------------------------
* +++ Combobox:
*
* NOTES:
* kThemeMetricComboBoxLargeDisclosureWidth -> 17
* Padding and margins guesstimated by trial-and-error.
*/
static Ttk_Padding ComboboxPadding = { 2, 3, 17, 1 };
static Ttk_Padding ComboboxMargins = { 3, 3, 4, 4 };
static void ComboboxElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
*widthPtr = 0;
*heightPtr = 0;
*paddingPtr = Ttk_AddPadding(ComboboxMargins, ComboboxPadding);
}
示例2: ClientElementDraw
static void ClientElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
RECT rc = BoxToRect(b);
TkWinDCState dcState;
HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT | BF_SOFT);
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
示例3: ButtonElementDraw
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
}
示例4: FocusElementDraw
static void FocusElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
if (state & TTK_STATE_FOCUS) {
RECT rc = BoxToRect(b);
TkWinDCState dcState;
HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
DrawFocusRect(hdc, &rc);
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
}
示例5: ButtonBorderElementDraw
static void ButtonBorderElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
ButtonBorderElement *bd = elementRecord;
int relief = TK_RELIEF_FLAT;
int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
TkWinDCState dcState;
HDC hdc;
RECT rc;
Tk_GetReliefFromObj(NULL, bd->reliefObj, &relief);
Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState);
if (defaultState == TTK_BUTTON_DEFAULT_ACTIVE) {
XColor *highlightColor =
Tk_GetColorFromObj(tkwin, bd->highlightColorObj);
GC gc = Tk_GCForColor(highlightColor, d);
XDrawRectangle(Tk_Display(tkwin), d, gc, b.x,b.y,b.width-1,b.height-1);
}
if (defaultState != TTK_BUTTON_DEFAULT_DISABLED) {
++b.x; ++b.y; b.width -= 2; b.height -= 2;
}
hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
rc = BoxToRect(b);
DrawFrameControl(hdc, &rc,
DFC_BUTTON, /* classId */
DFCS_BUTTONPUSH | Ttk_StateTableLookup(pushbutton_statemap, state));
/* Draw focus ring:
*/
if (state & TTK_STATE_FOCUS) {
short int borderWidth = 3; /* @@@ Use GetSystemMetrics?*/
rc = BoxToRect(Ttk_PadBox(b, Ttk_UniformPadding(borderWidth)));
DrawFocusRect(hdc, &rc);
}
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
示例6: ToolbarBackgroundElementDraw
/*----------------------------------------------------------------------
* +++ ToolbarBackground element -- toolbar style for frames.
*
* This is very similar to the normal background element, but uses a
* different ThemeBrush in order to get the lighter pinstripe effect
* used in toolbars. We use SetThemeBackground() rather than
* ApplyThemeBackground() in order to get the right style.
*
* <URL: http://developer.apple.com/documentation/Carbon/Reference/
* Appearance_Manager/appearance_manager/constant_7.html#/
* /apple_ref/doc/uid/TP30000243/C005321>
*
*/
static void ToolbarBackgroundElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
ThemeBrush brush = kThemeBrushToolbarBackground;
CGRect bounds = BoxToRect(d, Ttk_WinBox(tkwin));
BEGIN_DRAWING(d)
ChkErr(HIThemeSetFill, brush, NULL, dc.context, HIOrientation);
//QDSetPatternOrigin(PatternOrigin(tkwin, d));
CGContextFillRect(dc.context, bounds);
END_DRAWING
}
示例7: FrameControlElementDraw
static void FrameControlElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
FrameControlElementData *elementData = clientData;
RECT rc = BoxToRect(Ttk_PadBox(b, elementData->margins));
TkWinDCState dcState;
HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
DrawFrameControl(hdc, &rc,
elementData->classId,
elementData->partId|Ttk_StateTableLookup(elementData->stateMap, state));
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
示例8: TreeHeaderElementDraw
static void TreeHeaderElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
ThemeButtonParams *params = clientData;
CGRect bounds = BoxToRect(d, b);
const HIThemeButtonDrawInfo info = {
.version = 0,
.state = Ttk_StateTableLookup(ThemeStateTable, state),
.kind = params->kind,
.value = Ttk_StateTableLookup(TreeHeaderValueTable, state),
.adornment = Ttk_StateTableLookup(TreeHeaderAdornmentTable, state),
};
BEGIN_DRAWING(d)
ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL);
END_DRAWING
}
static Ttk_ElementSpec TreeHeaderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
ButtonElementSizeNoPadding,
TreeHeaderElementDraw
};
/*
* Disclosure triangle:
*/
#define TTK_TREEVIEW_STATE_OPEN TTK_STATE_USER1
#define TTK_TREEVIEW_STATE_LEAF TTK_STATE_USER2
static Ttk_StateTable DisclosureValueTable[] = {
{ kThemeDisclosureDown, TTK_TREEVIEW_STATE_OPEN, 0 },
{ kThemeDisclosureRight, 0, 0 },
};
static void DisclosureElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
SInt32 s;
ChkErr(GetThemeMetric, kThemeMetricDisclosureTriangleWidth, &s);
*widthPtr = s;
ChkErr(GetThemeMetric, kThemeMetricDisclosureTriangleHeight, &s);
*heightPtr = s;
}
示例9: ThumbElementDraw
static void ThumbElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
RECT rc = BoxToRect(b);
TkWinDCState dcState;
HDC hdc;
/* Windows doesn't show a thumb when the scrollbar is disabled */
if (state & TTK_STATE_DISABLED)
return;
hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT | BF_MIDDLE);
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
示例10: GroupElementDraw
static void GroupElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
CGRect bounds = BoxToRect(d, b);
const HIThemeGroupBoxDrawInfo info = {
.version = 0,
.state = Ttk_StateTableLookup(ThemeStateTable, state),
.kind = kHIThemeGroupBoxKindPrimaryOpaque,
};
BEGIN_DRAWING(d)
ChkErr(HIThemeDrawGroupBox, &bounds, &info, dc.context, HIOrientation);
END_DRAWING
}
static Ttk_ElementSpec GroupElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
GroupElementSize,
GroupElementDraw
};
/*----------------------------------------------------------------------
* +++ Entry element --
* 3 pixels padding for focus rectangle
* 2 pixels padding for EditTextFrame
*/
typedef struct {
Tcl_Obj *backgroundObj;
} EntryElement;
static Ttk_ElementOptionSpec EntryElementOptions[] = {
{ "-background", TK_OPTION_BORDER,
Tk_Offset(EntryElement,backgroundObj), "white"
},
{0}
};
static void EntryElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
*paddingPtr = Ttk_UniformPadding(5);
}
示例11: pixman_region32_rectangles
nsRegion& nsRegion::Transform (const gfx3DMatrix &aTransform)
{
int n;
pixman_box32_t *boxes = pixman_region32_rectangles(&mImpl, &n);
for (int i=0; i<n; i++) {
nsRect rect = BoxToRect(boxes[i]);
boxes[i] = RectToBox(nsIntRegion::ToRect(TransformRect(nsIntRegion::FromRect(rect), aTransform)));
}
pixman_region32_t region;
// This will union all of the rectangles and runs in about O(n lg(n))
pixman_region32_init_rects(®ion, boxes, n);
pixman_region32_fini(&mImpl);
mImpl = region;
return *this;
}
示例12: FieldElementDraw
static void FieldElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
FieldElement *field = elementRecord;
Tk_3DBorder bg = Tk_Get3DBorderFromObj(tkwin, field->backgroundObj);
RECT rc = BoxToRect(b);
TkWinDCState dcState;
HDC hdc;
Tk_Fill3DRectangle(
tkwin, d, bg, b.x, b.y, b.width, b.height, 0, TK_RELIEF_FLAT);
hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
DrawEdge(hdc, &rc, EDGE_SUNKEN, BF_RECT);
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
示例13: ComboboxElementDraw
static void ComboboxElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
CGRect bounds = BoxToRect(d, Ttk_PadBox(b, ComboboxMargins));
const HIThemeButtonDrawInfo info = {
.version = 0,
.state = Ttk_StateTableLookup(ThemeStateTable, state),
.kind = kThemeComboBox,
.value = Ttk_StateTableLookup(ButtonValueTable, state),
.adornment = Ttk_StateTableLookup(ButtonAdornmentTable, state),
};
BEGIN_DRAWING(d)
ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL);
END_DRAWING
}
static Ttk_ElementSpec ComboboxElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
ComboboxElementSize,
ComboboxElementDraw
};
/*----------------------------------------------------------------------
* +++ Spinbuttons.
*
* From Apple HIG, part III, section "Controls", "The Stepper Control":
* there should be 2 pixels of space between the stepper control
* (AKA IncDecButton, AKA "little arrows") and the text field it modifies.
*/
static Ttk_Padding SpinbuttonMargins = {2,0,2,0};
static void SpinButtonElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
SInt32 s;
ChkErr(GetThemeMetric, kThemeMetricLittleArrowsWidth, &s);
*widthPtr = s + Ttk_PaddingWidth(SpinbuttonMargins);
ChkErr(GetThemeMetric, kThemeMetricLittleArrowsHeight, &s);
*heightPtr = s + Ttk_PaddingHeight(SpinbuttonMargins);
}
示例14: PaneElementDraw
static void PaneElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
CGRect bounds = BoxToRect(d, b);
HIThemeTabPaneDrawInfo info = {
.version = 1,
.state = Ttk_StateTableLookup(ThemeStateTable, state),
.direction = kThemeTabNorth,
.size = kHIThemeTabSizeNormal,
.kind = kHIThemeTabKindNormal,
.adornment = kHIThemeTabPaneAdornmentNormal,
};
bounds.origin.y -= kThemeMetricTabFrameOverlap;
bounds.size.height += kThemeMetricTabFrameOverlap;
BEGIN_DRAWING(d)
ChkErr(HIThemeDrawTabPane, &bounds, &info, dc.context, HIOrientation);
END_DRAWING
}
static Ttk_ElementSpec PaneElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
PaneElementSize,
PaneElementDraw
};
/*
* Labelframe borders:
* Use "primary group box ..."
* Quoth DrawThemePrimaryGroup reference:
* "The primary group box frame is drawn inside the specified
* rectangle and is a maximum of 2 pixels thick."
*
* "Maximum of 2 pixels thick" is apparently a lie;
* looks more like 4 to me with shading.
*/
static void GroupElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
*paddingPtr = Ttk_UniformPadding(4);
}
示例15: FillFocusElementDraw
/* @@@ FIX THIS */
static void FillFocusElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
FillFocusElement *focus = elementRecord;
if (state & TTK_STATE_FOCUS) {
RECT rc = BoxToRect(b);
TkWinDCState dcState;
XColor *fillColor = Tk_GetColorFromObj(tkwin, focus->fillColorObj);
GC gc = Tk_GCForColor(fillColor, d);
HDC hdc;
XFillRectangle(Tk_Display(tkwin),d,gc, b.x,b.y,b.width,b.height);
hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
DrawFocusRect(hdc, &rc);
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
}