diff --git a/FL/Fl_Group.H b/FL/Fl_Group.H index 3ede57cfa..ac1ad0876 100644 --- a/FL/Fl_Group.H +++ b/FL/Fl_Group.H @@ -48,6 +48,10 @@ class FL_EXPORT Fl_Group : public Fl_Widget { Fl_Group& operator=(const Fl_Group&); protected: + enum { CLIP_CHILDREN = 2048 }; + + void clip_children(int c) { if (c) set_flag(CLIP_CHILDREN); else clear_flag(CLIP_CHILDREN); } + int clip_children() { return (flags() & CLIP_CHILDREN) != 0; } void draw(); void draw_child(Fl_Widget&) const; diff --git a/documentation/Fl_Group.html b/documentation/Fl_Group.html index 1dab3a2f0..45dd288ce 100644 --- a/documentation/Fl_Group.html +++ b/documentation/Fl_Group.html @@ -39,18 +39,19 @@ behavior.
  • Fl_Group
  • ~Fl_Group
  • add
  • +
  • add_resizable
  • @@ -94,6 +95,16 @@ memory recursively.

    href='#Fl_Group.remove'>remove() method in that it affects all child widgets and deletes them from memory.

    +

    void Fl_Group::clip_children(int c);
    +int Fl_Group::clip_children();

    + +The first method controls whether the group widget clips the drawing of +child widgets to its bounding box. + +

    The second method returns the current clipping mode. + +

    The default is to not clip (0) the drawing of child widgets. +

    void Fl_Group::init_sizes()

    The Fl_Group widget keeps track of the original widget sizes and diff --git a/src/Fl_Group.cxx b/src/Fl_Group.cxx index a9aecf097..f2c2e1e21 100644 --- a/src/Fl_Group.cxx +++ b/src/Fl_Group.cxx @@ -536,6 +536,9 @@ void Fl_Group::resize(int X, int Y, int W, int H) { void Fl_Group::draw_children() { Fl_Widget*const* a = array(); + + if (clip_children()) fl_push_clip(x(), y(), w(), h()); + if (damage() & ~FL_DAMAGE_CHILD) { // redraw the entire thing: for (int i=children_; i--;) { Fl_Widget& o = **a++; @@ -545,6 +548,8 @@ void Fl_Group::draw_children() { } else { // only redraw the children that need it: for (int i=children_; i--;) update_child(**a++); } + + if (clip_children()) fl_pop_clip(); } void Fl_Group::draw() {