---
name: "ttk_Geometry"
section: "3"
platform: "macos"
package: "tcl"
version: "152"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/ttk_Geometry"
---

# ttk\_Geometry(3)

Tk themed geometry utilities

## NAME

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

## 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

One of the symbolic constants **TK\_ANCHOR\_N**, **TK\_ANCHOR\_NE**, etc.  See *[Tk\_GetAnchorFromObj(3)](/Tk_GetAnchorFromObj/3.md)*. A rectangular region from which a parcel is allocated. Extra padding (in pixels) to add uniformly to each side of a region. Extra padding (in pixels) to add to the bottom of a region. Specifies a rectangular region. The height in pixels of a region. Used to store error messages. Extra padding (in pixels) to add to the left side of a region. 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. Extra padding to add on the inside of a region. A rectangular region, allocated from a cavity. One of the standard Tk relief options  (TK\_RELIEF\_RAISED, TK\_RELIEF\_SUNKEN, etc.).   See **Tk\_GetReliefFromObj**. Extra padding (in pixles) to add to the right side of a region. One of **TTK\_SIDE\_LEFT**, **TTK\_SIDE\_TOP**,  **TTK\_SIDE\_RIGHT**, or **TTK\_SIDE\_BOTTOM**. A bitmask containing one or more of the bits **TTK\_STICK\_W** (west, or left),  **TTK\_STICK\_E** (east, or right,  **TTK\_STICK\_N** (north, or top), and **TTK\_STICK\_S** (south, or bottom). **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** and **TTK\_STICK\_ALL** are synonyms for (TTK\_FILL\_X\|TTK\_FILL\_Y). See also: *[grid(n)](/grid/n.md)*. Window whose screen geometry determines  the conversion between absolute units and pixels. Extra padding at the top of a region. The width in pixels of a region. X coordinate of upper-left corner of region. 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.

**Ttk\_MakeBox** is a convenience routine that contsructs a **Ttk\_Box** structure representing a region *width* pixels wide, *height* pixels tall, 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 specified by *padding*.

**Ttk\_ExpandBox** is the inverse of **Ttk\_PadBox**: it returns a new box surrounding the specified *parcel*, expanded  according to the left, top, right, and bottom margins specified by *padding*.

**Ttk\_PackBox** allocates a parcel *width* by *height* pixels wide on the specified *side* of the *cavity*, and shrinks the *cavity* accordingly.

**Ttk\_StickBox** places a box with the requested *width* and *height* inside the *parcel* according to the *sticky* bits.

**Ttk\_PlaceBox** combines **Ttk\_PackBox** and **Ttk\_StickBox**: it 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 if the specified *x, y* coordinate lies within the rectangular region *box*.

## 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\_MakePadding** is a convenience routine that contsructs a **Ttk\_Padding** structure with the specified left, top, right, and bottom components.

**Ttk\_UniformPadding** constructs a **Ttk\_Padding** structure with all components equal to the specified *border*.

**Ttk\_AddPadding** adds two **Ttk\_Padding**s together and returns a combined padding containing the sum of the individual padding components.

**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 is **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 look for pushbuttons.

## CONVERSION ROUTINES

**Ttk\_GetPaddingFromObj** converts the string in *objPtr* to a **Ttk\_Padding** structure. The string representation is a list of  up to four length specifications  If fewer than four elements are specified,  *bottom* defaults to *top*, *right* defaults to *left*, and  *top* defaults to *left*. See **[Tk\_GetPixelsFromObj(3)](/Tk_GetPixelsFromObj/3.md)** for the syntax of length specifications.

**Ttk\_GetBorderFromObj** is the same as **Ttk\_GetPaddingFromObj** except that the lengths are specified as integers  (i.e., resolution-dependant values like *3m* are not allowed).

**Ttk\_GetStickyFromObj** converts the string in *objPtr* to a *sticky* bitmask.  The string contains zero or more of the characters **n**, **s**, **e**, or **w**.

## SEE ALSO

[Tk\_GetReliefFromObj(3)](/Tk_GetReliefFromObj/3.md), [Tk\_GetPixelsFromObj(3)](/Tk_GetPixelsFromObj/3.md), [Tk\_GetAnchorFromObj(3)](/Tk_GetAnchorFromObj/3.md)

## KEYWORDS

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