Rectangle Class Reference

Inherited by Monitor, and Widget.

List of all members.

Public Member Functions

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


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.

Rectangle::Rectangle int  x,
int  y,
int  w,
int  h
[inline]
 

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

Rectangle::Rectangle int  w,
int  h
[inline]
 

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

Rectangle::Rectangle const Rectangle r  )  [inline]
 

Copy constructor.

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

Constructor that calls set().


Member Function Documentation

int 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 Rectangle::center_x  )  const [inline]
 

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

int Rectangle::center_y  )  const [inline]
 

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

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

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

bool Rectangle::empty  )  const [inline]
 

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

void Rectangle::h int  v  )  [inline]
 

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

int Rectangle::h  )  const [inline]
 

Distance between top and bottom edges

void Rectangle::inset int  d  )  [inline]
 

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

void 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 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 Rectangle::move int  dx,
int  dy
[inline]
 

Move entire rectangle by given distance in x and y.

void Rectangle::move_b int  d  )  [inline]
 

Add d to b() and h().

void Rectangle::move_r int  d  )  [inline]
 

Add d to r() and w().

void Rectangle::move_x int  d  )  [inline]
 

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

void Rectangle::move_y int  d  )  [inline]
 

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

bool Rectangle::not_empty  )  const [inline]
 

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

int Rectangle::r  )  const [inline]
 

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

void 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

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

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

void Rectangle::set_b int  v  )  [inline]
 

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

void Rectangle::set_r int  v  )  [inline]
 

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

void Rectangle::set_x int  v  )  [inline]
 

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

void Rectangle::set_y int  v  )  [inline]
 

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

void Rectangle::w int  v  )  [inline]
 

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

int Rectangle::w  )  const [inline]
 

Distance between left and right edges

void Rectangle::x int  v  )  [inline]
 

Move the rectangle so the left edge is at v.

int Rectangle::x  )  const [inline]
 

Left edge

void Rectangle::y int  v  )  [inline]
 

Move the rectangle so the top edge is at v.

int Rectangle::y  )  const [inline]
 

Top edge


The documentation for this class was generated from the following files:
Sun Jan 7 00:55:18 2007. FLTK ©2006 Bill Spitzak and others.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.