OK, here you go.
Changes:
- I’ve adjusted the group sizes to put your buttons “inside” their parent
- I’ve made the exit callbacks hide the parent win, rather than just bombing on exit()
- I’ve added a dummy widget to the check box group to eat the resizing there too
- I’ve explicitly set the box type of the groups and “invisible” widgets, to make it more explicit what’s going on
Seems to work...
Build with fltk-config --compile...
#include <FL/Fl.H>
#include <FL/fl_ask.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Return_Button.H>
#include <FL/Fl_Check_Button.H>
#include <FL/Fl_Window.H>
#include <string>
#include <iostream>
#include <stdlib.h>
static int check_button_count = 4;
static Fl_Window *win;
static void cb_exit0_cb(Fl_Widget*)
{
win->hide();
}
static void cb_exit1_cb(Fl_Widget*)
{
win->hide();
}
int main(int argc, char **argv)
{
Fl_Group *g, *g_inside, *buttongroup;
Fl_Box *invisible;
Fl_Return_Button *but_ok;
Fl_Button *but_cancel;
int winh = (30 * check_button_count) + 56;
int mod_h = winh - 40;
win = new Fl_Window(420, winh, "Select your options");
win->callback(cb_exit1_cb);
{
g = new Fl_Group(0, 0, 420, mod_h);
{
g_inside = new Fl_Group(0, 0, 420, mod_h);
{
for (int i = 0; i < check_button_count; ++i)
{
new Fl_Check_Button(10, 10 + 30*i, 400, 30, "test");
}
}
Fl_Box *dummy2 = new Fl_Box (418, mod_h - 2, 1, 1);
dummy2->box(FL_NO_BOX);
g_inside->resizable(dummy2);
g_inside->end();
g_inside->box(FL_BORDER_BOX);
}
g->resizable(g_inside);
g->end();
g->box(FL_BORDER_BOX);
buttongroup = new Fl_Group(0, mod_h, 420, 36);
{
invisible = new Fl_Box(199, mod_h, 1, 1);
invisible->box(FL_NO_BOX);
but_ok = new Fl_Return_Button(220, mod_h + 4, 90, 26, fl_ok);
but_ok->callback(cb_exit0_cb);
but_cancel = new Fl_Button(320, mod_h + 4, 90, 26, fl_cancel);
but_cancel->callback(cb_exit1_cb);
}
buttongroup->resizable(invisible);
buttongroup->end();
buttongroup->box(FL_BORDER_BOX);
}
win->resizable(g);
win->end();
win->show();
return Fl::run();
}
/* end of file */