## typedef fltk::Box

`fltk::Box` is a pointer to the structure `fltk::Box_`, which contains the information needed to draw the rectangles around and inside widgets.

Boxtypes are stored in the box, button_box, and focus_box fields of the fltk::Style structure, and typically used by the draw() methods of fltk::Widgets.

### Members

#### virtual void fltk::Box_::draw(int x, int y, int w, int h, fltk::Color fill, fltk::Flags) const;

This is the function that draws the box. The four integers are the x,y,w,h of the rectangle to fill with the box. The color is used to fill the interior of the box with (except for FRAME types which use it to draw the edge). The last argument is a set of bitflags, the following ones are useful (ignore any other bits that are on):

- `fltk::INACTIVE` - gray out the widget.
- `fltk::VALUE` - draw the box pushed in. Typically this is implemented by calling another boxtype to do the drawing.
- `fltk::HIGHLIGHT` - draw the box highlighted. Usually you can ignore this because the fill color will also be changed.
- `fltk::SELECTED` - the widget has the focus.
- `fltk::INVISIBLE` - you should only draw the outer edge of the box and not fill it in. This is used to draw the boxes around browsers and text widgets, and to draw the focus box. You can ignore this and things will still draw ok, but they may flicker more than necessary.

A simple drawing function might fill a rectangle with the given color and then draw a black outline:

    void MyBoxtype::draw(int x, int y, int w, int h, fltk::Color c, fltk::Flags f) const
    {
      // draw the interior:
      if (!(f&fltk::INVISIBLE)) {
        fltk::color(c);
        fltk::rectf(x+1, y+1, w-2, h-2);
      }
      // draw the edge:
      fltk::color(fltk::BLACK);
      fltk::rect(x, y, w, h);
    }

#### int fltk::Box_::fills_rectangle() const;

Returns true if the draw function completely fills all the pixels in the rectangle passed to it (ignoring any `fltk::INVISIBLE` flag). Many parts of fltk will take advantage of this to speed up drawing and eliminate blinking.

This is an inline funcion, if you are making a subclass your constructor should set the protected member variable `fills_rectangle_` with the value you want returned.

#### int fltk::Box::dx() const;
int fltk::Box::dy() const;
int fltk::Box::dw() const;
int fltk::Box::dh() const;

Return the offsets for the bounding box that should be subtracted when drawing the label inside the box. These are all positive numbers, so dx() and dy() are added to the x and y, while dw() and dh() are subtracted from the width and height. Usually dw() is two times dx(), and dh() is two times dy(), and usually dx() and dy() are equal.

These are inline functions, if you are making a subclass your constructor should set the protected members `dx_, dy_, dw_`, and `dh_` to initialize the return value.

#### void fltk::Box::inset(int& x, int& y, int& w, int& h) const;

Changes the passed rectangle into a rectangle that matches the "interior" of the box. This is an inline function that just adds or subtracts dx(), dy(), dw(), and dh() from the passed values.

#### fltk::Box_::Boxtype_()

Default constructor.

#### fltk::Box_::Boxtype_(const char* name)

This constructs a "named" boxtype. It is added to a linked list of all named boxtypes. This list may be searched by the find() function to find a boxtype by name. This is useful for themes that want to parse a text file describing the theme.

#### static const fltk::Box_* fltk::Box_::find(const char* name);

Locate the first boxtype with the given name. Case is ignored when doing the comparison. Returns NULL if no matching name is found.