Alvin wrote:

> Hello,
> 
> How can I make an Fl_Tile automatically resize its and its children when
> the Fl_Double_Window (its parent) resizes?

After having peeked at the source for Fl_Tile.cxx, I came up with this:

class Fl_Vertical_Tile : public Fl_Tile
{
   public:
      Fl_Vertical_Tile(int X, int Y, int W, int H, const char *L = 0)
         : Fl_Tile(X, Y, W, H, L)
      {}

      void resize(int X, int Y, int W, int H)
      {
         int old_w = w();
         int old_h = h();

         Fl_Tile::resize(X,Y,W,H);

         if(children() && (old_w < W || old_h < H))
         {
            Fl_Widget *o = child(children()-1);

            int dw = 0; /*(W - old_w); // causes veritcally stacked widgets
to widen strangly*/ 
            int dh = (H - old_h);

            o->damage_resize(o->x(), o->y(), o->w() + dw, o->h() + dh);
         }
      }
};


My limited testing has shown that this only works when the tile consists of
vertically stacked widgets who's width spans the Fl_Tile.

Basically, what this does is after the Fl_Tile has been resized, it attempts
to grow the last child so that it consumes any free realestate (e.g. dh).

What I'm not sure of is: why that when the Fl_Tile is resized width-wise
only, is that applying the change in width (dw) to the last child's current
width causes the last child to grow beyond the width of the Fl_Tile?

-- 
Alvin
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to