I'm looking at how to make fltk widgets resize fonts along with it's size and I 
miss a function that I'll call "get_full_size" I think it'll facilitate some 
layout management for instance Fl_Pack doesn't resize at all like other 
widgets, I implemented and tested this function with 1.3 trunk:

/**
Returns the full rectangle occupied by a widget plus it's external label if any
*/

#ifndef intmax
int intmax(int a, int b) {return a > b ? a : b;};
#endif

void Fl_Widget::get_full_size(int &full_x, int &full_y, int &full_w, int 
&full_h) {
    int W = 0, H = 0;
    label_.measure(W, H);
    W += 5; // Add a little to the size of the label to cover overflow
    H += 5;

    if (align() && !(align() & FL_ALIGN_INSIDE)) {
      // If the label is not inside the widget, compute the location of
      // the label and redraw the window within that bounding box...

      if (align() & FL_ALIGN_BOTTOM) {
          full_x = x();
          full_y = y();
          full_w = intmax(w(), W);
          full_h = h() + H;
          return;
      } else if (align() & FL_ALIGN_TOP) {
          full_x = x();
          full_y = y() - H;
          full_w = intmax(w(), W);
          full_h = h() + H;
          return;
      } else if (align() & FL_ALIGN_LEFT) {
          full_x = x() - W;
          full_y = y();
          full_w = w() + W;
          full_h = intmax(h(), H);
          return;
      } else if (align() & FL_ALIGN_RIGHT) {
          full_x = x();
          full_y = y();
          full_w = w() + W;
          full_h = intmax(h(), H);
          return;
      }
    }
        // The label is inside the widget, so just return the widget itself
        //plus adjustments in case the label overflow
    full_x = x();
    full_y = y();
    full_w = intmax(w(), W);
    full_h = intmax(h(), H);
}

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

Reply via email to