---
name: "Ttk_MakeBox"
section: "3"
platform: "linux"
package: "tk"
version: "8.6.16-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/Ttk_AddPadding"
---

# Ttk\_MakeBox(3)

Tk themed geometry utilities

Part of [Ttk\_AddPadding(3)](/Ttk_AddPadding/3.md).

```

```

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

- Tk\_Anchor *anchor* (in)

  One of the symbolic constants **TK\_ANCHOR\_N**, **TK\_ANCHOR\_NE**, etc.  See *[Tk\_GetAnchorFromObj(3)](/Tk_GetAnchorFromObj/3.md)*.

- 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.). See **Tk\_GetReliefFromObj**.

- short *right* (in)

  Extra padding (in pixels) to add 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 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** is a synonym for (**TTK\_FILL\_X**\|**TTK\_FILL\_Y**). See also: *[grid(n)](/grid/n.md)*.

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

**Ttk\_MakeBox** is a convenience routine that constructs 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 constructs 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 “pressed-in” 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 “*left top right bottom*”. 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-dependent 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
