Clipping
[Drawing Functions]


Functions

void fltk::clipout (const Rectangle &)
int fltk::intersect_with_clip (Rectangle &)
bool fltk::not_clipped (const Rectangle &)
void fltk::pop_clip ()
void fltk::push_clip (const Rectangle &)
void fltk::push_no_clip ()

Detailed Description

You can limit all your drawing to a region by calling fltk::push_clip(), and put the drawings back by using fltk::pop_clip(). Fltk may also set up clipping before draw() is called to limit the drawing to the region of the window that is damaged.

When drawing you can also test the current clip region with fltk::not_clipped() and fltk::clip_box(). By using these to skip over complex drawings that are clipped you can greatly speed up your program's redisplay.

The width and height of the clipping region is measured in transformed coordianates.


Function Documentation

void push_clip const Rectangle rectangle  ) 
 

Pushes the intersection of the current region and rectangle onto the clip stack.

void clipout const Rectangle rectangle  ) 
 

Remove rectangle from the current clip region, thus making it a more complex shape. This does not push the stack, it just replaces the top of it.

Some graphics backends (OpenGL and Cairo, at least) do not support non-rectangular clip regions. This call does nothing on those.

void pop_clip  ) 
 

Restore the previous clip region. You must call fltk::pop_clip() exactly once for every time you call fltk::push_clip(). If you return to FLTK with the clip stack not empty unpredictable results occur.

void push_no_clip  ) 
 

Pushes an empty clip region on the stack so nothing will be clipped. This lets you draw outside the current clip region. This should only be used to temporarily ignore the clip region to draw into an offscreen area.

bool not_clipped const Rectangle rectangle  ) 
 

Returns true if any or all of rectangle is inside the clip region.

int intersect_with_clip Rectangle r  ) 
 

Intersect a transform()'d rectangle with the current clip region and change it to the smaller rectangle that surrounds (and probably equals) this intersection area.

This can be used by device-specific drawing code to limit complex pixel operations (like drawing images) to the smallest rectangle needed to update the visible area.

Return values:

  • 0 if it does not intersect, and W and H are set to zero.
  • 1 if if the result is equal to the rectangle (i.e. it is entirely inside or equal to the clip region)
  • 2 if it is partially clipped.


Sun May 8 21:48:57 2005. FLTK ©2004 Bill Spitzak and others. See Main Page for details.