Control which group receives newly created widgets.
void begin(); // New widgets go into this groupvoid end(); // Stop adding to this groupFl_Group *group = new Fl_Group(10, 10, 200, 100);group->begin(); Fl_Button *btn1 = new Fl_Button(20, 20, 80, 30, "Button 1"); Fl_Button *btn2 = new Fl_Button(20, 60, 80, 30, "Button 2");group->end();// Widgets created after end() go to parent
Important: Always call end() after adding children!
int children() const; // Number of childrenFl_Widget* child(int n) const; // Get nth child (0-based)int find(const Fl_Widget *) const; // Get index of childfor (int i = 0; i < group->children(); i++) { Fl_Widget *w = group->child(i); printf("Child %d: %s\n", i, w->label());}
resizable() - Resize Behavior
Control how the group and its children resize.
void resizable(Fl_Widget *widget);Fl_Widget* resizable() const;// NULL = fixed size, children don't movegroup->resizable(NULL);// Group itself = children resize proportionallygroup->resizable(group);// Specific widget = defines resize boxFl_Box *spacer = new Fl_Box(50, 50, 100, 100);group->resizable(spacer);
The resizable widget defines a “resize box”. Widgets inside this box scale with the group, widgets outside it stay at fixed distance from edges.
clip_children() - Clip Drawing
Prevent children from drawing outside group bounds.
void clip_children(int c); // 1 = clip, 0 = no clipunsigned int clip_children() const;group->clip_children(1); // Enable clipping
An Fl_Group is typically invisible (FL_NO_BOX) but can have any box type. It defines a rectangular region containing child widgets. The group handles events and passes them to appropriate children.
// Window positioned by window managerFl_Window(int w, int h, const char *title = 0);// Window at specific position Fl_Window(int x, int y, int w, int h, const char *title = 0);
void show();void show(int argc, char **argv); // For main windowvoid hide();int shown() const; // Returns 1 if shownwin->show(argc, argv); // Main windowdialog->show(); // Other windows
void size_range(int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0);// Minimum 400x300, maximum 1920x1080win->size_range(400, 300, 1920, 1080);// Fixed size (not resizable)win->size_range(400, 300, 400, 300);// Minimum onlywin->size_range(400, 300);
position() - Set Window Position
Set window position on screen.
void position(int x, int y);void hotspot(int x, int y); // Position relative to mousewin->position(100, 100); // Top-left at (100, 100)
Modal Windows
Create modal dialogs that block other windows.
void set_modal(); // Modal to all windowsvoid set_non_modal(); // On top, but doesn't blockvoid clear_modal_states(); // Back to normalFl_Window *dialog = new Fl_Window(300, 150, "Confirm");dialog->set_modal();dialog->show();
fullscreen() - Full Screen Mode
Make window fill entire screen.
void fullscreen();void fullscreen_off();void fullscreen_off(int x, int y, int w, int h);unsigned int fullscreen_active() const;win->fullscreen(); // Go fullscreenwin->fullscreen_off(); // Restore
border() - Window Decorations
Control window manager border.
void border(int b); // 1 = with border, 0 = borderlessunsigned int border() const;win->border(0); // Borderless window
Fl_Window appears as a system window with title bar, close/minimize/maximize buttons (platform-dependent), and optional border. Background is typically gray (FL_BACKGROUND_COLOR).
void scroll_to(int x, int y); // Scroll to positionint xposition() const; // Current X scrollint yposition() const; // Current Y scrollscroll->scroll_to(0, 100); // Scroll down 100 pixels
Fl_Scroll *scroll = new Fl_Scroll(10, 10, 380, 280);scroll->type(Fl_Scroll::BOTH);scroll->begin(); // Add many widgets that exceed scroll area for (int i = 0; i < 20; i++) { new Fl_Button(20, 20 + i*40, 300, 30, ("Button " + std::to_string(i+1)).c_str()); }scroll->end();
Appears as a rectangular region with scrollbars on the right and/or bottom when content is larger than the visible area. Content can be scrolled by dragging scrollbars or mouse wheel.