Geometry(3tk)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

okay so bestie, welcome to Geometry(3tk) β€” the Tk themed geometry utilities manual, and it's giving extremely useful if you're out here doing widget layouts. It covers:

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

✨ Tk themed geometry utilities ✨ β€” that's the whole vibe, no cap.


🌸 SYNOPSIS 🌸

#include <tkTheme.h>

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);

πŸ¦‹ ARGUMENTS πŸ¦‹

okay so here's the whole cast of characters, each one labeled with its direction, bestie:

  • Tk_Anchor anchor (in) β€” one of the symbolic constants TK_ANCHOR_N, TK_ANCHOR_NE, etc. Go peep Tk_GetAnchorFromObj(3tk) for the full lore.
  • Ttk_Box * cavity (in/out) β€” a rectangular region that a parcel gets allocated out of. She's both input and output, main character energy fr.
  • short border (in) β€” extra padding, in pixels, added uniformly to every single side of a region.
  • short bottom (in) β€” extra padding, in pixels, tacked onto the bottom of a region.
  • Ttk_Box box (in) β€” specifies a rectangular region.
  • Ttk_Box * box_rtn (out) β€” a rectangular region. (She's the output, the result, the payoff πŸ’…)
  • 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, added to the left side of a region.
  • Tcl_Obj * objPtr (in) β€” the string value holds a symbolic name that gets converted into an enumerated value or a bitmask.
  • Ttk_Padding padding (in) β€” extra padding to add on the inside of a region.
  • Ttk_Padding * padding_rtn (out) β€” the padding that's present on 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.). See Tk_GetReliefFromObj.
  • short right (in) β€” extra padding, in pixels, added to the right side of a region.
  • Ttk_Side side (in) β€” one of TTK_SIDE_LEFT, TTK_SIDE_TOP, TTK_SIDE_RIGHT, or TTK_SIDE_BOTTOM.
  • unsigned sticky (in) β€” a bitmask holding one or more of the bits TTK_STICK_W (west, aka left), TTK_STICK_E (east, aka right), TTK_STICK_N (north, aka top), and TTK_STICK_S (south, aka bottom). Also: TTK_FILL_X is defined as a synonym for (TTK_STICK_W|TTK_STICK_E), TTK_FILL_Y is a synonym for (TTK_STICK_N|TTK_STICK_S), and TTK_FILL_BOTH is a synonym for (TTK_FILL_X|TTK_FILL_Y). Also also: go see grid(3tk).
  • Tk_Window tkwin (in) β€” the window whose screen geometry decides how absolute units convert into 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 the upper-left corner of the region.
  • int y (in) β€” Y coordinate of the upper-left corner of the region.
🫢 tiny lil heads-up bestie: with objPtr, the internal rep may be modified to cache the corresponding value. That's not me being dramatic, that's literally what it says.

πŸ“¦ 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. ✨

  • Ttk_MakeBox β€” the convenience routine, the little helper bestie. She constructs a Ttk_Box structure for a region that's width pixels wide, height pixels tall, sitting at the specified x, y coordinates.
  • Ttk_PadBox β€” returns a new box located inside the specified parcel, shrunken according to the left, top, right, and bottom margins given by padding.
  • Ttk_ExpandBox β€” she's the inverse of Ttk_PadBox πŸ’« she returns a new box surrounding the specified parcel, expanded according to the left, top, right, and bottom margins given by padding.
  • Ttk_PackBox β€” allocates a parcel that's width by height pixels, on the specified side of the cavity, and then shrinks the cavity accordingly. She takes what she needs and the cavity gets smaller, periodt.
  • Ttk_StickBox β€” places a box with the requested width and height inside the parcel, according to the sticky bits.
  • Ttk_PlaceBox β€” the collab we didn't know we needed πŸ”₯ she combines Ttk_PackBox and Ttk_StickBox: allocates a parcel on the specified side of the cavity, places a box of the requested size inside the parcel according to sticky, and shrinks the cavity.
  • Ttk_AnchorBox β€” places a box with the requested width and height inside the parcel, according to the specified anchor option.
  • Ttk_BoxContains β€” tests whether the specified x, y coordinate lies within the rectangular region box. Is she in or is she out, that's the whole question.

πŸ“ PADDDING πŸ“

(that's the section name, I don't make the rules, I just deliver them with flair)

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_MakePadding β€” convenience routine, she constructs a Ttk_Padding structure with the specified left, top, right, and bottom components.
  • Ttk_UniformPadding β€” constructs a Ttk_Padding structure where all components are equal to the specified border.
  • Ttk_AddPadding β€” adds two Ttk_Paddings together and hands you back a combined padding containing the sum of the individual padding components. Math but make it fashion πŸ’…
  • Ttk_RelievePadding β€” adds an extra 2 pixels of padding to padding according to the specified relief:
    • if relief is TK_RELIEF_SUNKEN, adds two pixels at the top and left so the inner region is shifted down and to the left.
    • if it's TK_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. iykyk. πŸ‘‘


🌈 CONVERSION ROUTINES 🌈

  • Ttk_GetPaddingFromObj β€” converts the string in objPtr into a Ttk_Padding structure. The string representation is a list of up to four length specifications: β€œleft top right bottom”. If fewer than four elements are specified, bottom defaults to top, right defaults to left, and top defaults to left. For the syntax of length specifications, go see Tk_GetPixelsFromObj(3tk).
  • Ttk_GetBorderFromObj β€” same as Ttk_GetPaddingFromObj, except the lengths are specified as integers (i.e., resolution-dependent values like 3m are not allowed). Sorry bestie.
  • Ttk_GetStickyFromObj β€” converts the string in objPtr into a sticky bitmask. The string contains zero or more of the characters n, s, e, or w. That's it, that's the whole alphabet of sticking.

πŸŽ€ SEE ALSO πŸŽ€

Tk_GetReliefFromObj(3tk), Tk_GetPixelsFromObj(3tk), Tk_GetAnchorFromObj(3tk)


⭐ KEYWORDS ⭐

geometry, padding, margins, box, region, sticky, relief


and that's the whole page bestie, you ate it up 🫢 this was Tk 8.5, Geometry(3tk), the Tk themed geometry utilities manual β€” go build something iconic with your boxes and your padding, mwah πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from