1

With FLTK (version 1.4.0), is it possible to set minimum size for an Fl_Group widget? Either explicitly or automatically so that it wouldn't resize smaller than needed to display all its children? The Fl_Window class has method size_range which allows to set the smallest window size, however Fl_Group doesn't have such a method.

If this is not available, then maybe there are some other way to enforce a constraint on how small a non-window group widget can be?

It is possible to partly achieve this by using the size_range method of the top-most window, however if we use Fl_Tile than each tile would not be constrained in any way. Yes, an Fl_Box widget inside an Fl_Tile can limit minimal sizes of the outer tiles, but it's not exactly what I need here.

scrutari
  • 1,378
  • 2
  • 17
  • 33

1 Answers1

1

You can override the resize method of an Fl_Group widget. The resize method is triggered automatically when resizing even if not called explicitly.

#include <FL/Enumerations.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Group.H>
#include <FL/Fl.H>

struct MyGroup : public Fl_Group {
    MyGroup(int x, int y, int w, int h, const char *label = 0): Fl_Group(x, y, w, h, label) {
        box(FL_ENGRAVED_FRAME);
    }
    virtual void resize(int x, int y, int w, int h) override {
        Fl_Group::resize(x, y, w, h);
        if (w < 300 || h < 200) {
            resize(x, y, 300, 200);
        }
        
    }
};

int main() {
    Fl_Double_Window w(400, 300);
    MyGroup g(20, 20, 360, 260);
    w.end();
    w.resizable(&w);
    w.show();
    return Fl::run();
}

You will notice that the window is resizable, and if you try to decrease its size the group widget will get smaller to a certain point only.

mo_al_
  • 561
  • 4
  • 9