diff options
Diffstat (limited to 'generic/ttk/ttkLayout.c')
-rw-r--r-- | generic/ttk/ttkLayout.c | 64 |
1 files changed, 48 insertions, 16 deletions
diff --git a/generic/ttk/ttkLayout.c b/generic/ttk/ttkLayout.c index 3e77ba4..31c5ed2 100644 --- a/generic/ttk/ttkLayout.c +++ b/generic/ttk/ttkLayout.c @@ -3,7 +3,7 @@ * * Generic layout processing. * - * Copyright (c) 2003 Joe English. Freely redistributable. + * Copyright © 2003 Joe English. Freely redistributable. */ #include "tkInt.h" @@ -43,10 +43,10 @@ Ttk_NewBoxObj(Ttk_Box box) { Tcl_Obj *result[4]; - result[0] = Tcl_NewIntObj(box.x); - result[1] = Tcl_NewIntObj(box.y); - result[2] = Tcl_NewIntObj(box.width); - result[3] = Tcl_NewIntObj(box.height); + result[0] = Tcl_NewWideIntObj(box.x); + result[1] = Tcl_NewWideIntObj(box.y); + result[2] = Tcl_NewWideIntObj(box.width); + result[3] = Tcl_NewWideIntObj(box.height); return Tcl_NewListObj(4, result); } @@ -227,8 +227,7 @@ static Ttk_Sticky AnchorToSticky(Tk_Anchor anchor) case TK_ANCHOR_SW: return TTK_STICK_S | TTK_STICK_W; case TK_ANCHOR_W: return TTK_STICK_W; case TK_ANCHOR_NW: return TTK_STICK_N | TTK_STICK_W; - default: - case TK_ANCHOR_CENTER: return 0; + default: return 0; } } @@ -325,7 +324,8 @@ int Ttk_GetPaddingFromObj( Ttk_Padding *pad) { Tcl_Obj **padv; - int i, padc, pixels[4]; + Tcl_Size i, padc; + int pixels[4]; if (TCL_OK != Tcl_ListObjGetElements(interp, objPtr, &padc, &padv)) { goto error; @@ -363,7 +363,8 @@ error: int Ttk_GetBorderFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_Padding *pad) { Tcl_Obj **padv; - int i, padc, pixels[4]; + Tcl_Size i, padc; + int pixels[4]; if (TCL_OK != Tcl_ListObjGetElements(interp, objPtr, &padc, &padv)) { goto error; @@ -532,7 +533,7 @@ struct Ttk_LayoutNode_ static Ttk_LayoutNode *Ttk_NewLayoutNode( unsigned flags, Ttk_ElementClass *elementClass) { - Ttk_LayoutNode *node = ckalloc(sizeof(*node)); + Ttk_LayoutNode *node = (Ttk_LayoutNode *)ckalloc(sizeof(*node)); node->flags = flags; node->eclass = elementClass; @@ -565,8 +566,8 @@ struct Ttk_TemplateNode_ { static Ttk_TemplateNode *Ttk_NewTemplateNode(const char *name, unsigned flags) { - Ttk_TemplateNode *op = ckalloc(sizeof(*op)); - op->name = ckalloc(strlen(name) + 1); strcpy(op->name, name); + Ttk_TemplateNode *op = (Ttk_TemplateNode *)ckalloc(sizeof(*op)); + op->name = (char *)ckalloc(strlen(name) + 1); strcpy(op->name, name); op->flags = flags; op->next = op->child = 0; return op; @@ -620,7 +621,7 @@ Ttk_LayoutTemplate Ttk_ParseLayoutTemplate(Tcl_Interp *interp, Tcl_Obj *objPtr) static const char *const optStrings[] = { "-side", "-sticky", "-expand", "-border", "-unit", "-children", 0 }; - int i = 0, objc; + Tcl_Size i = 0, objc; Tcl_Obj **objv; Ttk_TemplateNode *head = 0, *tail = 0; @@ -851,7 +852,7 @@ static Ttk_Layout TTKNewLayout( void *recordPtr,Tk_OptionTable optionTable, Tk_Window tkwin, Ttk_LayoutNode *root) { - Ttk_Layout layout = ckalloc(sizeof(*layout)); + Ttk_Layout layout = (Ttk_Layout)ckalloc(sizeof(*layout)); layout->style = style; layout->recordPtr = recordPtr; layout->optionTable = optionTable; @@ -920,8 +921,8 @@ Ttk_CreateSublayout( Ttk_LayoutTemplate layoutTemplate; Tcl_DStringInit(&buf); - Tcl_DStringAppend(&buf, Ttk_StyleName(parentLayout->style), -1); - Tcl_DStringAppend(&buf, baseName, -1); + Tcl_DStringAppend(&buf, Ttk_StyleName(parentLayout->style), TCL_INDEX_NONE); + Tcl_DStringAppend(&buf, baseName, TCL_INDEX_NONE); styleName = Tcl_DStringValue(&buf); style = Ttk_GetStyle(themePtr, styleName); @@ -1256,6 +1257,37 @@ void Ttk_PlaceElement(Ttk_Layout layout, Ttk_Element node, Ttk_Box b) } /* + * AnchorToPosition -- + * Convert a Tk_Anchor enum to a position bitmask. + */ +static Ttk_PositionSpec AnchorToPosition(Tk_Anchor anchor) +{ + switch (anchor) + { + case TK_ANCHOR_N: return TTK_PACK_TOP; + case TK_ANCHOR_S: return TTK_PACK_BOTTOM; + case TK_ANCHOR_NE: return TTK_PACK_RIGHT|TTK_STICK_N; + case TK_ANCHOR_SE: return TTK_PACK_RIGHT|TTK_STICK_S; + case TK_ANCHOR_E: return TTK_PACK_RIGHT; + case TK_ANCHOR_NW: return TTK_PACK_LEFT|TTK_STICK_N; + case TK_ANCHOR_SW: return TTK_PACK_LEFT|TTK_STICK_S; + case TK_ANCHOR_W: return TTK_PACK_LEFT; + case TK_ANCHOR_CENTER: return 0; + default:; + } + return TTK_PACK_LEFT; +} + +/* + * Ttk_AnchorElement -- + * Explicitly specify an element's anchoring. + */ +void Ttk_AnchorElement(Ttk_Element node, Tk_Anchor anchor) +{ + node->flags = AnchorToPosition(anchor); +} + +/* * Ttk_ChangeElementState -- */ void Ttk_ChangeElementState(Ttk_LayoutNode *node,unsigned set,unsigned clr) |