static void DiamondIndicatorElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { IndicatorElement *indicator = elementRecord; Tk_3DBorder border = 0, interior = 0; int borderWidth = 2; int relief = TK_RELIEF_RAISED; int diameter, radius; XPoint points[4]; Ttk_Padding padding; interior = Tk_Get3DBorderFromObj(tkwin, indicator->colorObj); border = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj); Tcl_GetIntFromObj(NULL,indicator->borderWidthObj,&borderWidth); Tk_GetReliefFromObj(NULL,indicator->reliefObj,&relief); Ttk_GetPaddingFromObj(NULL,tkwin,indicator->marginObj,&padding); b = Ttk_PadBox(b, padding); diameter = b.width < b.height ? b.width : b.height; radius = diameter / 2; points[0].x = b.x; points[0].y = b.y + radius; points[1].x = b.x + radius; points[1].y = b.y + 2*radius; points[2].x = b.x + 2*radius; points[2].y = b.y + radius; points[3].x = b.x + radius; points[3].y = b.y; Tk_Fill3DPolygon(tkwin,d,interior,points,4,borderWidth,TK_RELIEF_FLAT); Tk_Draw3DPolygon(tkwin,d,border,points,4,borderWidth,relief); }
static void SquareIndicatorElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { IndicatorElement *indicator = elementRecord; Tk_3DBorder border = 0, interior = 0; int relief = TK_RELIEF_RAISED; Ttk_Padding padding; int borderWidth = 2; int diameter; interior = Tk_Get3DBorderFromObj(tkwin, indicator->colorObj); border = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj); Tcl_GetIntFromObj(NULL,indicator->borderWidthObj,&borderWidth); Tk_GetReliefFromObj(NULL,indicator->reliefObj,&relief); Ttk_GetPaddingFromObj(NULL,tkwin,indicator->marginObj,&padding); b = Ttk_PadBox(b, padding); diameter = b.width < b.height ? b.width : b.height; Tk_Fill3DRectangle(tkwin, d, interior, b.x, b.y, diameter, diameter,borderWidth, TK_RELIEF_FLAT); Tk_Draw3DRectangle(tkwin, d, border, b.x, b.y, diameter, diameter, borderWidth, relief); }
static void TroughElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { TroughElement *troughPtr = elementRecord; Tk_3DBorder border = NULL; int borderWidth = 2, relief = TK_RELIEF_SUNKEN, groove = -1, orient; border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj); Ttk_GetOrientFromObj(NULL, troughPtr->orientObj, &orient); Tk_GetReliefFromObj(NULL, troughPtr->reliefObj, &relief); Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth); Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &groove); if (groove != -1 && groove < b.height && groove < b.width) { if (orient == TTK_ORIENT_HORIZONTAL) { b.y = b.y + b.height/2 - groove/2; b.height = groove; } else { b.x = b.x + b.width/2 - groove/2; b.width = groove; } } Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth, relief); }
static void SquareElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { SquareElement *square = elementRecord; Tk_3DBorder border = NULL, foreground = NULL; int borderWidth = 1, relief = TK_RELIEF_FLAT; border = Tk_Get3DBorderFromObj(tkwin, square->borderObj); foreground = Tk_Get3DBorderFromObj(tkwin, square->foregroundObj); Tcl_GetIntFromObj(NULL, square->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, square->reliefObj, &relief); Tk_Fill3DRectangle(tkwin, d, foreground, b.x, b.y, b.width, b.height, borderWidth, relief); }
static void BorderElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { BorderElement *bd = elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, bd->borderObj); XColor *borderColor = Tk_GetColorFromObj(tkwin, bd->borderColorObj); int borderWidth = 2; int relief = TK_RELIEF_FLAT; int defaultState = TTK_BUTTON_DEFAULT_DISABLED; /* * Get option values. */ Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, bd->reliefObj, &relief); Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState); if (defaultState == TTK_BUTTON_DEFAULT_ACTIVE) { GC gc = Tk_GCForColor(borderColor, d); XDrawRectangle(Tk_Display(tkwin), d, gc, b.x, b.y, b.width-1, b.height-1); } if (defaultState != TTK_BUTTON_DEFAULT_DISABLED) { /* Space for default ring: */ b = Ttk_PadBox(b, Ttk_UniformPadding(1)); } DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief); }
static void DrawMenuSeparator( TkMenu *menuPtr, /* The menu we are drawing */ TkMenuEntry *mePtr, /* The entry we are drawing */ Drawable d, /* The drawable we are using */ GC gc, /* The gc to draw into */ Tk_Font tkfont, /* The font to draw with */ const Tk_FontMetrics *fmPtr,/* The font metrics from the font */ int x, int y, int width, int height) { XPoint points[2]; Tk_3DBorder border; if (menuPtr->menuType == MENUBAR) { return; } points[0].x = x; points[0].y = y + height/2; points[1].x = width - 1; points[1].y = points[0].y; border = Tk_Get3DBorderFromObj(menuPtr->tkwin, menuPtr->borderPtr); Tk_Draw3DPolygon(menuPtr->tkwin, d, border, points, 2, 1, TK_RELIEF_RAISED); }
static void SashElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { SashElement *sash = elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, sash->borderObj); GC gc1,gc2; int relief = TK_RELIEF_RAISED; int handleSize = 8, handlePad = 8; int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL; Ttk_Box hb; Tk_GetPixelsFromObj(NULL, tkwin, sash->handleSizeObj, &handleSize); Tk_GetPixelsFromObj(NULL, tkwin, sash->handlePadObj, &handlePad); Tk_GetReliefFromObj(NULL, sash->sashReliefObj, &relief); switch (relief) { case TK_RELIEF_RAISED: case TK_RELIEF_RIDGE: gc1 = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC); gc2 = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC); break; case TK_RELIEF_SUNKEN: case TK_RELIEF_GROOVE: gc1 = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC); gc2 = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC); break; case TK_RELIEF_SOLID: gc1 = gc2 = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC); break; case TK_RELIEF_FLAT: default: gc1 = gc2 = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC); break; } /* Draw sash line: */ if (horizontal) { int y = b.y + b.height/2 - 1; XDrawLine(Tk_Display(tkwin), d, gc1, b.x, y, b.x+b.width, y); ++y; XDrawLine(Tk_Display(tkwin), d, gc2, b.x, y, b.x+b.width, y); } else { int x = b.x + b.width/2 - 1; XDrawLine(Tk_Display(tkwin), d, gc1, x, b.y, x, b.y+b.height); ++x; XDrawLine(Tk_Display(tkwin), d, gc2, x, b.y, x, b.y+b.height); } /* Draw handle: */ if (handleSize >= 0) { if (horizontal) { hb = Ttk_StickBox(b, handleSize, handleSize, TTK_STICK_W); hb.x += handlePad; } else { hb = Ttk_StickBox(b, handleSize, handleSize, TTK_STICK_N); hb.y += handlePad; } Tk_Fill3DRectangle(tkwin, d, border, hb.x, hb.y, hb.width, hb.height, 1, TK_RELIEF_RAISED); } }
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); }
void Tk_Free3DBorderFromObj( Tk_Window tkwin, /* The window this border lives in. Needed for * the screen and colormap values. */ Tcl_Obj *objPtr) /* The Tcl_Obj * to be freed. */ { Tk_Free3DBorder(Tk_Get3DBorderFromObj(tkwin, objPtr)); FreeBorderObjProc(objPtr); }
static void FillElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { BackgroundElement *bg = elementRecord; Tk_3DBorder backgroundPtr = Tk_Get3DBorderFromObj(tkwin,bg->backgroundObj); XFillRectangle(Tk_Display(tkwin), d, Tk_3DBorderGC(tkwin, backgroundPtr, TK_3D_FLAT_GC), b.x, b.y, b.width, b.height); }
static void FieldElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { FieldElement *field = elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, field->borderObj); int borderWidth = 2; Tk_GetPixelsFromObj(NULL, tkwin, field->borderWidthObj, &borderWidth); Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth, TK_RELIEF_SUNKEN); }
static void VerticalSeparatorElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { SeparatorElement *separator = elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, separator->borderObj); GC lightGC = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC); GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC); XDrawLine(Tk_Display(tkwin), d, darkGC, b.x, b.y, b.x, b.y + b.height); XDrawLine(Tk_Display(tkwin), d, lightGC, b.x+1, b.y, b.x+1, b.y+b.height); }
static void FieldElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { FieldElement *field = elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, field->borderObj); XColor *borderColor = Tk_GetColorFromObj(tkwin, field->borderColorObj); Tk_Fill3DRectangle( tkwin, d, border, b.x, b.y, b.width, b.height, 0, TK_RELIEF_SUNKEN); DrawFieldBorder(tkwin, d, border, borderColor, b); }
/* * (@@@ Note: ButtonBorderElement still still still buggy: * padding for default ring is drawn in the wrong color * when the button is active.) */ static void ButtonBorderElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { ButtonBorderElement *bd = elementRecord; Tk_3DBorder border = NULL; int borderWidth = 1, relief = TK_RELIEF_FLAT; int defaultState = TTK_BUTTON_DEFAULT_DISABLED; int inset = 0; /* * Get option values. */ border = Tk_Get3DBorderFromObj(tkwin, bd->borderObj); Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, bd->reliefObj, &relief); Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState); /* * Default ring: */ switch (defaultState) { case TTK_BUTTON_DEFAULT_DISABLED : break; case TTK_BUTTON_DEFAULT_NORMAL : inset += 5; break; case TTK_BUTTON_DEFAULT_ACTIVE : Tk_Draw3DRectangle(tkwin, d, border, b.x+inset, b.y+inset, b.width - 2*inset, b.height - 2*inset, 2, TK_RELIEF_FLAT); inset += 2; Tk_Draw3DRectangle(tkwin, d, border, b.x+inset, b.y+inset, b.width - 2*inset, b.height - 2*inset, 1, TK_RELIEF_SUNKEN); ++inset; Tk_Draw3DRectangle(tkwin, d, border, b.x+inset, b.y+inset, b.width - 2*inset, b.height - 2*inset, 2, TK_RELIEF_FLAT); inset += 2; break; } /* * 3-D border: */ if (border && borderWidth > 0) { Tk_Draw3DRectangle(tkwin, d, border, b.x+inset, b.y+inset, b.width - 2*inset, b.height - 2*inset, borderWidth,relief); } }
static void ClientElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { ClientElement *ce = elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, ce->backgroundObj); int borderWidth = 1; Tcl_GetIntFromObj(NULL, ce->borderWidthObj, &borderWidth); Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth,TK_RELIEF_RAISED); }
static void ClientElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { NotebookElement *ce = elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, ce->backgroundObj); int borderWidth = 2; Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth,TK_RELIEF_FLAT); DrawSmoothBorder(tkwin, d, b, ce->borderColorObj, ce->lightColorObj, ce->darkColorObj); }
static void ThumbElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { ThumbElement *thumb = elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, thumb->borderObj); int borderWidth = 2, relief = TK_RELIEF_RAISED; Tk_GetPixelsFromObj(NULL, tkwin, thumb->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, thumb->reliefObj, &relief); Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth, relief); }
static void TabElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { TabElement *tab = elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, tab->backgroundObj); int borderWidth = 1; int cut = 2; XPoint pts[6]; int n = 0; Tcl_GetIntFromObj(NULL, tab->borderWidthObj, &borderWidth); if (state & TTK_STATE_SELECTED) { /* * Draw slightly outside of the allocated parcel, * to overwrite the client area border. */ b.height += borderWidth; } pts[n].x = b.x; pts[n].y = b.y + b.height - 1; ++n; pts[n].x = b.x; pts[n].y = b.y + cut; ++n; pts[n].x = b.x + cut; pts[n].y = b.y; ++n; pts[n].x = b.x + b.width-1-cut; pts[n].y = b.y; ++n; pts[n].x = b.x + b.width-1; pts[n].y = b.y + cut; ++n; pts[n].x = b.x + b.width-1; pts[n].y = b.y + b.height; ++n; XFillPolygon(Tk_Display(tkwin), d, Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC), pts, 6, Convex, CoordModeOrigin); #ifndef WIN32 /* * Account for whether XDrawLines draws endpoints by platform */ --pts[5].y; #endif while (borderWidth--) { XDrawLines(Tk_Display(tkwin), d, Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC), pts, 4, CoordModeOrigin); XDrawLines(Tk_Display(tkwin), d, Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC), pts+3, 3, CoordModeOrigin); ++pts[0].x; ++pts[1].x; ++pts[2].x; --pts[4].x; --pts[5].x; ++pts[2].y; ++pts[3].y; } }
static void FieldElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned state) { FieldElement *field = elementRecord; Tk_3DBorder bg = Tk_Get3DBorderFromObj(tkwin, field->backgroundObj); Ttk_Box f = Ttk_PadBox(b, Ttk_UniformPadding(2)); Tcl_Obj *outer = field->borderColorObj, *inner = field->lightColorObj; DrawSmoothBorder(tkwin, d, b, outer, inner, inner); Tk_Fill3DRectangle( tkwin, d, bg, f.x, f.y, f.width, f.height, 0, TK_RELIEF_SUNKEN); }
static void ArrowElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { int direction = *(int *)clientData; ArrowElement *arrow = elementRecord; Tk_3DBorder border; int borderWidth; int relief = TK_RELIEF_RAISED; int size; XPoint points[3]; Tk_GetPixelsFromObj(NULL, tkwin, arrow->borderWidthObj, &borderWidth); border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj); Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief); size = b.width < b.height ? b.width : b.height; /* * @@@ There are off-by-one pixel errors in the way these are drawn; * @@@ need to take a look at Tk_Fill3DPolygon and X11 to find the * @@@ exact rules. */ switch (direction) { case ARROW_UP: points[2].x = b.x; points[2].y = b.y + size; points[1].x = b.x + size/2; points[1].y = b.y; points[0].x = b.x + size; points[0].y = b.y + size; break; case ARROW_DOWN: points[0].x = b.x; points[0].y = b.y; points[1].x = b.x + size/2; points[1].y = b.y + size; points[2].x = b.x + size; points[2].y = b.y; break; case ARROW_LEFT: points[0].x = b.x; points[0].y = b.y + size / 2; points[1].x = b.x + size; points[1].y = b.y + size; points[2].x = b.x + size; points[2].y = b.y; break; case ARROW_RIGHT: points[0].x = b.x + size; points[0].y = b.y + size / 2; points[1].x = b.x; points[1].y = b.y; points[2].x = b.x; points[2].y = b.y + size; break; } Tk_Fill3DPolygon(tkwin, d, border, points, 3, borderWidth, relief); }
static void PbarElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { PbarElement *pbar = elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, pbar->borderObj); int relief = TK_RELIEF_RAISED, borderWidth = 2; Tk_GetPixelsFromObj(NULL, tkwin, pbar->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, pbar->reliefObj, &relief); Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth, relief); }
static void MenuIndicatorElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { MenuIndicatorElement *mi = elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, mi->backgroundObj); Ttk_Padding margins; int borderWidth = 2; Ttk_GetPaddingFromObj(NULL,tkwin,mi->marginObj,&margins); b = Ttk_PadBox(b, margins); Tk_GetPixelsFromObj(NULL, tkwin, mi->borderWidthObj, &borderWidth); Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth, TK_RELIEF_RAISED); }
static void TroughElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { TroughElement *troughPtr = elementRecord; Tk_3DBorder border = NULL; int borderWidth = 2, relief = TK_RELIEF_SUNKEN; border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj); Tk_GetReliefFromObj(NULL, troughPtr->reliefObj, &relief); Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth); Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth, relief); }
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); }
static void SliderElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { SliderElement *slider = elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, slider->borderObj); XColor *borderColor = Tk_GetColorFromObj(tkwin, slider->borderColorObj); int relief = TK_RELIEF_RAISED, borderWidth = 2; Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, slider->reliefObj, &relief); Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth, TK_RELIEF_FLAT); DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief); }
static void BorderElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { BorderElement *bd = elementRecord; Tk_3DBorder border = NULL; int borderWidth = 1, relief = TK_RELIEF_FLAT; border = Tk_Get3DBorderFromObj(tkwin, bd->borderObj); Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, bd->reliefObj, &relief); if (border && borderWidth > 0 && relief != TK_RELIEF_FLAT) { Tk_Draw3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth,relief); } }
static void SizegripDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { SizegripElement *grip = elementRecord; int gripCount = 3, gripSpace = 2; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, grip->backgroundObj); GC lightGC = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC); GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC); int x1 = b.x + b.width-1, y1 = b.y + b.height-1, x2 = x1, y2 = y1; while (gripCount--) { x1 -= gripSpace; y2 -= gripSpace; XDrawLine(Tk_Display(tkwin), d, darkGC, x1,y1, x2,y2); --x1; --y2; XDrawLine(Tk_Display(tkwin), d, darkGC, x1,y1, x2,y2); --x1; --y2; XDrawLine(Tk_Display(tkwin), d, lightGC, x1,y1, x2,y2); --x1; --y2; } }
static void ArrowElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { int direction = *(int *)clientData; ArrowElement *arrow = elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj); XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj); int relief = TK_RELIEF_RAISED; int borderWidth = 1; Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief); Tk_Fill3DRectangle( tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth, relief); TtkFillArrow(Tk_Display(tkwin), d, Tk_GCForColor(arrowColor, d), Ttk_PadBox(b, ArrowMargins), direction); }
static void SliderElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { SliderElement *slider = elementRecord; Tk_3DBorder border = NULL; int relief = TK_RELIEF_RAISED, borderWidth = 2, orient; border = Tk_Get3DBorderFromObj(tkwin, slider->borderObj); Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient); Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, slider->reliefObj, &relief); Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth, relief); if (relief != TK_RELIEF_FLAT) { if (orient == TTK_ORIENT_HORIZONTAL) { if (b.width > 4) { b.x += b.width/2; XDrawLine(Tk_Display(tkwin), d, Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC), b.x-1, b.y+borderWidth, b.x-1, b.y+b.height-borderWidth); XDrawLine(Tk_Display(tkwin), d, Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC), b.x, b.y+borderWidth, b.x, b.y+b.height-borderWidth); } } else { if (b.height > 4) { b.y += b.height/2; XDrawLine(Tk_Display(tkwin), d, Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC), b.x+borderWidth, b.y-1, b.x+b.width-borderWidth, b.y-1); XDrawLine(Tk_Display(tkwin), d, Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC), b.x+borderWidth, b.y, b.x+b.width-borderWidth, b.y); } } } }
static void ThumbElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { ThumbElement *thumb = elementRecord; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, thumb->borderObj); XColor *borderColor = Tk_GetColorFromObj(tkwin, thumb->borderColorObj); int relief = TK_RELIEF_RAISED; int borderWidth = 2; /* * Don't draw the thumb if we are disabled. * This makes it behave like Windows ... if that's what we want. if (state & TTK_STATE_DISABLED) return; */ Tk_GetReliefFromObj(NULL, thumb->reliefObj, &relief); Tk_Fill3DRectangle( tkwin, d, border, b.x,b.y,b.width,b.height, 0, TK_RELIEF_FLAT); DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief); }