fltk::Rectangle Class Reference

Inherited by fltk::Monitor, and fltk::Widget.

List of all members.

Public Member Functions

int b () const
int baseline_y () const
int center_x () const
int center_y () const
bool contains (int x, int y) const
bool empty () const
void h (int v)
int h () const
void inset (int d)
void intersect (const Rectangle &r)
void merge (const Rectangle &r)
void move (int dx, int dy)
void move_b (int d)
void move_r (int d)
void move_x (int d)
void move_y (int d)
bool not_empty () const
int r () const
 Rectangle (const Rectangle &r, int w, int h, int flags=0)
 Rectangle (const Rectangle &r)
 Rectangle ()
 Rectangle (int x, int y, int w, int h)
 Rectangle (int w, int h)
void set (int x, int y, int w, int h)
void set (const Rectangle &r, int w, int h, int flags=0)
void set_b (int v)
void set_r (int v)
void set_x (int v)
void set_y (int v)
void w (int v)
int w () const
int x () const
void x (int v)
void y (int v)
int y () const

Detailed Description

Describes an integer-sized rectangle. This is the base class of Widget, and also used a lot to pass rectangular areas to drawing functions. Almost all the functions are inline.

Negative w() or h() is supposed to mean an empty and thus invisible rectangle, but some code will treat the rectangle as reflected about x or y. Set the size to zero to make sure you have an empty one.

Constructor & Destructor Documentation

Rectangle::Rectangle ( ) [inline]

The default constructor does not put anything into the fields! You can either call set() or just modify the x_, y_, w_, and h_ variables directly.

fltk::Rectangle::Rectangle ( int  x,
int  y,
int  w,
int  h 
) [inline]

Constructor that sets x(), y(), w(), and h().

fltk::Rectangle::Rectangle ( int  w,
int  h 
) [inline]

Constructor that sets x() and y() to zero, and sets w() and h().

fltk::Rectangle::Rectangle ( const Rectangle r) [inline]

Copy constructor.

fltk::Rectangle::Rectangle ( const Rectangle r,
int  w,
int  h,
int  flags = 0 
) [inline]

Constructor that calls set().

Member Function Documentation

int fltk::Rectangle::b ( ) const [inline]

Return y()+h(), the bottom edge of the rectangle.

int Rectangle::baseline_y ( ) const

Where to put baseline to center current font nicely

int fltk::Rectangle::center_x ( ) const [inline]

Integer center position. Rounded to the left if w() is odd.

int fltk::Rectangle::center_y ( ) const [inline]

Integer center position. Rounded to lower y if h() is odd.

bool fltk::Rectangle::contains ( int  x,
int  y 
) const [inline]

True if rectangle contains the pixel who's upper-left corner is at x,y

bool fltk::Rectangle::empty ( ) const [inline]

True if w() or h() are less or equal to zero.

void fltk::Rectangle::h ( int  v) [inline]

Change h() by moving the bottom edge. y() does not change.

int fltk::Rectangle::h ( ) const [inline]

Distance between top and bottom edges

void fltk::Rectangle::inset ( int  d) [inline]

Move all edges in by d. See also Symbol::inset()

void fltk::Rectangle::intersect ( const Rectangle r)

Replace the value with the intersection of this rectangle and R. If the rectangles do not intersect, the result may have negative width and/or height, this means empty() will return true, but some code may still draw this rectangle.

void fltk::Rectangle::merge ( const Rectangle r)

Replace the value with the union of this rectangle and R (ie the rectangle that surrounds both of these rectangles). If one rectangle is empty(), the other is returned unchanged (ie it does not union in the degenerate point of that rectangle).

void fltk::Rectangle::move ( int  dx,
int  dy 
) [inline]

Move entire rectangle by given distance in x and y.

void fltk::Rectangle::move_b ( int  d) [inline]

Add d to b() and h().

void fltk::Rectangle::move_r ( int  d) [inline]

Add d to r() and w().

void fltk::Rectangle::move_x ( int  d) [inline]

Add d to x() without changing r() (it reduces w() by d).

void fltk::Rectangle::move_y ( int  d) [inline]

Add d to y() without changing b() (it reduces h() by d).

bool fltk::Rectangle::not_empty ( ) const [inline]

Same as !empty(), true if w() and h() are both greater than zero.

int fltk::Rectangle::r ( ) const [inline]

Return x()+w(), the right edge of the rectangle.

void fltk::Rectangle::set ( const Rectangle r,
int  w,
int  h,
int  flags = 0 

Sets x, y, w, h so that's it's centered or aligned (if flags!=0) inside the source r

Initialize to the size w,h. The rectangle is placed inside the source rectangle r either centered or against an edge depending on the ALIGN values in flags. For centered alignment if the difference in sizes is odd, it always rounds up and left. Default value for flags is to center in both directions.

void fltk::Rectangle::set ( int  x,
int  y,
int  w,
int  h 
) [inline]

Set x(), y(), w(), and h() all at once.

void fltk::Rectangle::set_b ( int  v) [inline]

Change b() without changing y(), by changine the height.

void fltk::Rectangle::set_r ( int  v) [inline]

Change r() without changing x(), by changine the width.

void fltk::Rectangle::set_x ( int  v) [inline]

Change x() without changing r(), by changing the width.

void fltk::Rectangle::set_y ( int  v) [inline]

Change y() without changing b(), by changing the height.

void fltk::Rectangle::w ( int  v) [inline]

Change w() by moving the right edge. x() does not change.

int fltk::Rectangle::w ( ) const [inline]

Distance between left and right edges

int fltk::Rectangle::x ( ) const [inline]

Left edge

void fltk::Rectangle::x ( int  v) [inline]

Move the rectangle so the left edge is at v.

int fltk::Rectangle::y ( ) const [inline]

Top edge

void fltk::Rectangle::y ( int  v) [inline]

Move the rectangle so the top edge is at v.

The documentation for this class was generated from the following files: