static void SquareDoLayout(void *clientData) { WidgetCore *corePtr = (WidgetCore *)clientData; Ttk_Box winBox; Ttk_Element squareNode; squareNode = Ttk_FindElement(corePtr->layout, "square"); winBox = Ttk_WinBox(corePtr->tkwin); Ttk_PlaceLayout(corePtr->layout, corePtr->state, winBox); /* * Adjust the position of the square element within the widget according * to the -anchor option. */ if (squareNode) { Square *squarePtr = clientData; Tk_Anchor anchor = TK_ANCHOR_CENTER; Ttk_Box b; b = Ttk_ElementParcel(squareNode); if (squarePtr->square.anchorObj != NULL) Tk_GetAnchorFromObj(NULL, squarePtr->square.anchorObj, &anchor); b = Ttk_AnchorBox(winBox, b.width, b.height, anchor); Ttk_PlaceElement(corePtr->layout, squareNode, b); } }
static void ScaleDoLayout(void *clientData) { WidgetCore *corePtr = clientData; Ttk_Element slider = Ttk_FindElement(corePtr->layout, "slider"); Ttk_PlaceLayout(corePtr->layout,corePtr->state,Ttk_WinBox(corePtr->tkwin)); /* Adjust the slider position: */ if (slider) { Scale *scalePtr = clientData; Ttk_Box troughBox = TroughBox(scalePtr); Ttk_Box sliderBox = Ttk_ElementParcel(slider); double value = 0.0; double fraction; int range; Tcl_GetDoubleFromObj(NULL, scalePtr->scale.valueObj, &value); fraction = ScaleFraction(scalePtr, value); if (scalePtr->scale.orient == TTK_ORIENT_HORIZONTAL) { range = troughBox.width - sliderBox.width; sliderBox.x += (int)(fraction * range); } else { range = troughBox.height - sliderBox.height; sliderBox.y += (int)(fraction * range); } Ttk_PlaceElement(corePtr->layout, slider, sliderBox); } }
static void BackgroundElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { FillElementDraw( clientData, elementRecord, tkwin, d, Ttk_WinBox(tkwin), state); }
/*---------------------------------------------------------------------- * +++ 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 }
/*---------------------------------------------------------------------- * +++ 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; Rect bounds = BoxToRect(d, Ttk_WinBox(tkwin)); BEGIN_DRAWING(d) ChkErr(SetThemeBackground, brush, 32, true); QDSetPatternOrigin(PatternOrigin(tkwin, d)); EraseRect(&bounds); END_DRAWING }
/* * ScrollbarDoLayout -- * Layout hook. Adjusts the position of the scrollbar thumb. * * Side effects: * Sets sb->troughBox and sb->minSize. */ static void ScrollbarDoLayout(void *recordPtr) { Scrollbar *sb = recordPtr; WidgetCore *corePtr = &sb->core; Ttk_LayoutNode *thumb; Ttk_Box thumbBox; int thumbWidth, thumbHeight; double first, last, size; int minSize; /* * Use generic layout manager to compute initial layout: */ Ttk_PlaceLayout(corePtr->layout,corePtr->state,Ttk_WinBox(corePtr->tkwin)); /* * Locate thumb element, extract parcel and requested minimum size: */ thumb = Ttk_LayoutFindNode(corePtr->layout, "thumb"); if (!thumb) /* Something has gone wrong -- bail */ return; sb->scrollbar.troughBox = thumbBox = Ttk_LayoutNodeParcel(thumb); Ttk_LayoutNodeReqSize( corePtr->layout, thumb, &thumbWidth,&thumbHeight); /* * Adjust thumb element parcel: */ first = sb->scrollbar.first; last = sb->scrollbar.last; if (sb->scrollbar.orient == TTK_ORIENT_VERTICAL) { minSize = thumbHeight; size = thumbBox.height - minSize; thumbBox.y += (int)(size * first); thumbBox.height = (int)(size * last) + minSize - (int)(size * first); } else { minSize = thumbWidth; size = thumbBox.width - minSize; thumbBox.x += (int)(size * first); thumbBox.width = (int)(size * last) + minSize - (int)(size * first); } sb->scrollbar.minSize = minSize; Ttk_PlaceLayoutNode(corePtr->layout, thumb, thumbBox); }
static void LabelframeDoLayout(void *recordPtr) { Labelframe *lframePtr = recordPtr; WidgetCore *corePtr = &lframePtr->core; int lw, lh; /* Label width and height */ LabelframeStyle style; Ttk_Box borderParcel = Ttk_WinBox(lframePtr->core.tkwin); Ttk_Box labelParcel; /* * Compute label parcel: */ LabelframeStyleOptions(lframePtr, &style); LabelframeLabelSize(lframePtr, &lw, &lh); lw += Ttk_PaddingWidth(style.labelMargins); lh += Ttk_PaddingHeight(style.labelMargins); labelParcel = Ttk_PadBox( Ttk_PositionBox(&borderParcel, lw, lh, style.labelAnchor), style.labelMargins); if (!style.labelOutside) { /* Move border edge so it's over label: */ switch (LabelAnchorSide(style.labelAnchor)) { case TTK_SIDE_LEFT: borderParcel.x -= lw / 2; case TTK_SIDE_RIGHT: borderParcel.width += lw/2; break; case TTK_SIDE_TOP: borderParcel.y -= lh / 2; case TTK_SIDE_BOTTOM: borderParcel.height += lh / 2; break; } } /* * Place border and label: */ Ttk_PlaceLayout(corePtr->layout, corePtr->state, borderParcel); if (lframePtr->label.labelLayout) { Ttk_PlaceLayout( lframePtr->label.labelLayout, corePtr->state, labelParcel); } /* labelWidget placed in LabelframePlaceSlaves GM hook */ lframePtr->label.labelParcel = labelParcel; }