Lucas Sanner
unread,Jul 30, 2025, 12:49:32 AMJul 30Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to fltk.general
Hi all,
I want my application's main window resizable but I also want all visible widgets retain fixed size and position.
This is what I've come up with so far:
void Change_CB(Fl_Widget *w, void *) {
Fl_Menu_Bar *menu = (Fl_Menu_Bar*)w;
Fl_Menu_Item *p;
// Change submenu name
p = (Fl_Menu_Item*)menu->find_item("Edit/Submenu");
if ( p ) p->label("New Submenu Name");
// Change item name
p = (Fl_Menu_Item*)menu->find_item("Edit/New Submenu Name/Aaa");
if ( p ) p->label("New Aaa Name");
}
void Quit_CB(Fl_Widget *, void *) {
exit(0);
}
int main() {
Fl_Window *win = new Fl_Double_Window(400,400);
Fl_Menu_Bar *menu = new Fl_Menu_Bar(0,0,400,25);
Fl_Menu_Bar *toolbar = new Fl_Menu_Bar(0,25,400,25);
menu->add("File/Quit", FL_CTRL+'q', Quit_CB);
menu->add("Edit/Change", FL_CTRL+'c', Change_CB);
menu->add("Edit/Submenu/Aaa");
menu->add("Edit/Submenu/Bbb");
Fl_Group *g = new Fl_Group(0,50,400,375); // container for other widgets
g->resizable(nullptr); // prevent children from being resized
Fl_Button *button = new Fl_Button(25, 60, 150, 50, "Start");
// put other widgets here
g->end();
// Add an invisible box to absorb resizing
// It must be placed over the remaining space
Fl_Box *filler = new Fl_Box(0, 50, 400, 350); // matches group size
filler->hide(); // make it invisible
win->resizable(filler); // set this box as the resizable area
win->end();
win->show();
return(Fl::run());
}
It works (ie: the button is not resized while resizing the window).
However it's just a workaround and it looks a bit DIY to me.
Did I miss something ?
Is there a specific and cleaner way to achieve this ?
Thanks for your help.