Geometry(3)
okay bestie, this is Geometry(3), from the Tk Themed Widget manual β and it's literally your cheat sheet for Tk themed geometry utilities β¨π
π NAME π
The function friend group is: Ttk_MakeBox, Ttk_PadBox, Ttk_ExpandBox, Ttk_PackBox, Ttk_StickBox, Ttk_PlaceBox, Ttk_BoxContains, Ttk_MakePadding, Ttk_UniformPadding, Ttk_AddPadding, Ttk_RelievePadding, Ttk_GetPaddingFromObj, Ttk_GetBorderFromObj, Ttk_GetStickyFromObj β all your Tk themed geometry utilities. Also Ttk_AnchorBox pulls up in the synopsis and BOXES below, so don't leave her on read ππ
πΈ SYNOPSIS πΈ
First, the include, no cap:
#include <tkTheme.h>
Then every signature, copied exactly so nobody comes for me:
Ttk_Box
Ttk_MakeBox(int x, int y, int width, int height);
Ttk_Box
Ttk_PadBox(Ttk_Box parcel, Ttk_Padding padding);
Ttk_Box
Ttk_ExpandBox(Ttk_Box parcel, Ttk_Padding padding);
Ttk_Box
Ttk_PackBox(Ttk_Box *cavity, int width, int height, Ttk_Side side);
Ttk_Box
Ttk_StickBox(Ttk_Box parcel, int width, int height, unsigned sticky);
Ttk_Box
Ttk_PlaceBox(Ttk_Box *cavity, int width, int height, Ttk_Side side, unsigned sticky);
Ttk_Box
Ttk_AnchorBox(Ttk_Box parcel, int width, int height, Tk_Anchor anchor);
Ttk_Padding
Ttk_MakePadding(short left, short top, short right, short bottom);
Ttk_Padding
Ttk_UniformPadding(short border);
Ttk_Padding
Ttk_AddPadding(Ttk_Padding padding1, Ttk_Padding padding2;
Ttk_Padding
Ttk_RelievePadding(Ttk_Padding padding, int relief);
int
Ttk_BoxContains(Ttk_Box box, int x, int y);
int
Ttk_GetPaddingFromObj(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, Ttk_Padding *padding_rtn);
int
Ttk_GetBorderFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_Padding *padding_rtn);
int
Ttk_GetStickyFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *sticky_rtn);
yes, the Ttk_AddPadding line is giving semicolon-with-no-closing-paren energy, but that's exactly what the original says, so we're respecting the lore π
π ARGUMENTS π
Tk_Anchor anchor(in) β One of the symbolic constantsTK_ANCHOR_N,TK_ANCHOR_NE, etc. SeeTk_GetAnchorFromObj(3).Ttk_Box * cavity(in/out) β A rectangular region from which a parcel is allocated.short border(in) β Extra padding (in pixels) to add uniformly to each side of a region.short bottom(in) β Extra padding (in pixels) to add to the bottom of a region.Ttk_Box box(in) β Specifies a rectangular region.Ttk_Box * box_rtn(out) β A rectangular region.int height(in) β The height in pixels of a region.Tcl_Interp * interp(in) β Used to store error messages.int left(in) β Extra padding (in pixels) to add to the left side of a region.Tcl_Obj * objPtr(in) β String value contains a symbolic name to be converted to an enumerated value or bitmask. Internal rep may be be modified to cache corresponding value.Ttk_Padding padding(in) β Extra padding to add on the inside of a region.Ttk_Padding * padding_rtn(out) β Padding present in the inside of a region.Ttk_Box parcel(in) β A rectangular region, allocated from a cavity.int relief(in) β One of the standard Tk relief options (TK_RELIEF_RAISED,TK_RELIEF_SUNKEN, etc.). SeeTk_GetReliefFromObj.short right(in) β Extra padding (in pixels) to add to the right side of a region.Ttk_Side side(in) β One ofTTK_SIDE_LEFT,TTK_SIDE_TOP,TTK_SIDE_RIGHT, orTTK_SIDE_BOTTOM.unsigned sticky(in) β A bitmask containing one or more of the bitsTTK_STICK_W(west, or left),TTK_STICK_E(east, or right),TTK_STICK_N(north, or top), andTTK_STICK_S(south, or bottom).TTK_FILL_Xis defined as a synonym for (TTK_STICK_W|TTK_STICK_E),TTK_FILL_Yis a synonym for (TTK_STICK_N|TTK_STICK_S), andTTK_FILL_BOTHis a synonym for (TTK_FILL_X|TTK_FILL_Y). See also:grid(n).Tk_Window tkwin(in) β Window whose screen geometry determines the conversion between absolute units and pixels.short top(in) β Extra padding at the top of a region.int width(in) β The width in pixels of a region.int x(in) β X coordinate of upper-left corner of region.int y(in) β Y coordinate of upper-left corner of region.
π¦ BOXES π¦
The Ttk_Box structure represents a rectangular region of a window:
typedef struct {
int x;
int y;
int width;
int height;
} Ttk_Box;
All coordinates are relative to the window. Periodt.
Ttk_MakeBoxis a convenience routine that constructs aTtk_Boxstructure representing a regionwidthpixels wide,heightpixels tall, at the specifiedx,ycoordinates.Ttk_PadBoxreturns a new box located inside the specifiedparcel, shrunken according to theleft,top,right, andbottommargins specified bypadding.Ttk_ExpandBoxis the inverse ofTtk_PadBox: it returns a new box surrounding the specifiedparcel, expanded according to theleft,top,right, andbottommargins specified bypadding.Ttk_PackBoxallocates a parcelwidthbyheightpixels wide on the specified side of thecavity, and shrinks the cavity accordingly.Ttk_StickBoxplaces a box with the requestedwidthandheightinside theparcelaccording to thestickybits.Ttk_PlaceBoxcombinesTtk_PackBoxandTtk_StickBox: it allocates a parcel on the specified side of thecavity, places a box of the requested size inside the parcel according tosticky, and shrinks the cavity.Ttk_AnchorBoxplaces a box with the requestedwidthandheightinside theparcelaccording to the specifiedanchoroption.Ttk_BoxContainstests if the specifiedx,ycoordinate lies within the rectangular regionbox.
π PADDDING π
The Ttk_Padding structure is used to represent borders, internal padding, and external margins:
typedef struct {
short left;
short top;
short right;
short bottom;
} Ttk_Padding;
Ttk_MakePaddingis a convenience routine that constructs aTtk_Paddingstructure with the specifiedleft,top,right, andbottomcomponents.Ttk_UniformPaddingconstructs aTtk_Paddingstructure with all components equal to the specifiedborder.Ttk_AddPaddingadds twoTtk_Paddingstructs together and returns a combined padding containing the sum of the individual padding components.Ttk_RelievePaddingadds an extra 2 pixels of padding topaddingaccording to the specifiedrelief. IfreliefisTK_RELIEF_SUNKEN, adds two pixels at the top and left so the inner region is shifted down and to the left. If it isTK_RELIEF_RAISED, adds two pixels at the bottom and right so the inner region is shifted up and to the right. Otherwise, adds 1 pixel on all sides. This is typically used in element geometry procedures to simulate a βpressed-inβ look for pushbuttons.
β¨ CONVERSION ROUTINES β¨
Ttk_GetPaddingFromObjconverts the string inobjPtrto aTtk_Paddingstructure. The string representation is a list of up to four length specifications βleft top right bottomβ. If fewer than four elements are specified,bottomdefaults totop,rightdefaults toleft, andtopdefaults toleft. SeeTk_GetPixelsFromObj(3)for the syntax of length specifications.Ttk_GetBorderFromObjis the same asTtk_GetPaddingFromObjexcept that the lengths are specified as integers (i.e., resolution-dependent values like3mare not allowed).Ttk_GetStickyFromObjconverts the string inobjPtrto a sticky bitmask. The string contains zero or more of the charactersn,s,e, orw.
π SEE ALSO π
π KEYWORDS π
geometry, padding, margins, box, region, sticky, relief
sign-off: this iconic page comes from Tk version 8.5, with footer date/page energy Geometry(3) β muah πβ¨π«Ά
π¦ where this page comes from
- alpine 3.23: tk9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tk9-doc 9.0.3-r2 Β· TCL
- fedora 43: tk-devel 1:9.0.2-1.fc43 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 43: tk-devel 1:9.0.2-1.fc43 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 44: tk-devel 1:9.0.2-1.fc44 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 44: tk-devel 1:9.0.2-1.fc44 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- nixos 26.05: tk 9.0.3
- nixpkgs unstable: tk 9.1.0
- Copyright (c) 2004 Joe English
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms