diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 1998-12-15 15:40:30 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 1998-12-15 15:40:30 +0000 |
| commit | 30800cc268109d8883c8383bf9e59bb886a7bd38 (patch) | |
| tree | c66881af061ad8b822935b4ca10c537cb1c1bb2e | |
| parent | 98b53249771c8c3989bff99ec06d215fb3165b93 (diff) | |
Merged damage changes into Fl.cxx.
git-svn-id: file:///fltk/svn/fltk/trunk@161 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | src/Fl.cxx | 78 |
1 files changed, 76 insertions, 2 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx index a3e7e1014..f43808daa 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl.cxx,v 1.9 1998/12/15 15:38:15 mike Exp $" +// "$Id: Fl.cxx,v 1.10 1998/12/15 15:40:30 mike Exp $" // // Main event handling code for the Fast Light Tool Kit (FLTK). // @@ -667,6 +667,80 @@ void Fl_Window::flush() { draw(); } +#include <FL/fl_draw.H> + +void Fl_Widget::damage(uchar flags) { + Fl_Widget* w = this; + while (w->type() < FL_WINDOW) { + w->damage_ |= flags; + w = w->parent(); + if (!w) return; + flags = FL_DAMAGE_CHILD; + } + Fl_X* i = Fl_X::i((Fl_Window*)w); + if (i) { + if (i->region) { + // if there already is an update region then merge the area + // of the child with it: + if (w->damage() && w != this) { + w->damage(flags, x(), y(), this->w(), h()); + return; + } + // otherwise it is faster to just damage the whole window and + // rely on Fl_Group only drawing the damaged children: + XDestroyRegion(i->region); + i->region = 0; + } + w->damage_ |= flags; + Fl::damage(FL_DAMAGE_CHILD); + } +} + +void Fl_Widget::redraw() {damage(FL_DAMAGE_ALL);} + +void Fl_Widget::damage(uchar flags, int X, int Y, int W, int H) { + Fl_Widget* w = this; + while (w->type() < FL_WINDOW) { + w->damage_ |= flags; + w = w->parent(); + if (!w) return; + flags = FL_DAMAGE_CHILD; + } + // see if damage covers entire window: + if (X<=0 && Y<=0 && W>=w->w() && H>=w->h()) {w->damage(flags); return;} + Fl_X* i = Fl_X::i((Fl_Window*)w); + if (i) { + if (w->damage()) { + // if we already have damage we must merge with existing region: + if (i->region) { +#ifndef WIN32 + XRectangle R; + R.x = X; R.y = Y; R.width = W; R.height = H; + XUnionRectWithRegion(&R, i->region, i->region); +#else + Region r = XRectangleRegion(X,Y,W,H); + CombineRgn(i->region,i->region,r,RGN_OR); + XDestroyRegion(r); +#endif + } + w->damage_ |= flags; + } else { + // create a new region: + if (i->region) XDestroyRegion(i->region); + i->region = XRectangleRegion(X,Y,W,H); + w->damage_ = flags; + } + Fl::damage(FL_DAMAGE_CHILD); + } +} + +void Fl_Window::flush() { + make_current(); +//if (damage() == FL_DAMAGE_EXPOSE && can_boxcheat(box())) fl_boxcheat = this; + fl_clip_region(i->region); i->region = 0; + draw(); +} + // -// End of "$Id: Fl.cxx,v 1.9 1998/12/15 15:38:15 mike Exp $". +// End of "$Id: Fl.cxx,v 1.10 1998/12/15 15:40:30 mike Exp $". // |
