Here is an example of what I'm using to test.
# data file for the Fltk User Interface Designer (fluid)
version 1.0300
header_name {.h}
code_name {.cxx}
decl {\#include <vector>} {public global
}
decl {\#include <FL/fl_ask.h>} {private local
}
decl {typedef struct {
int x, y, w, h;
Fl_Fontsize labelsize, textsize;
Fl_Widget *wdg;
} st_size;} {public global
}
widget_class Resizable_Window {
label {Resizabe font by +/-} open
xywh {140 215 580 389} type Double resizable
class Fl_Double_Window visible
} {
Fl_Browser browse {selected
xywh {25 25 155 304} type Hold
}
Fl_Input {} {
label Name
xywh {260 30 285 24}
code0 {o->value("Karl Marks");}
}
Fl_Input {} {
label Address
xywh {260 70 285 25}
code0 {o->value("Dream Ville");}
}
Fl_Input {} {
label ZIP
xywh {260 105 75 25}
code0 {o->value("007");}
}
Fl_Input {} {
label City
xywh {405 105 140 25}
code0 {o->value("Utopia");}
}
Fl_Input notes {
label Notes
xywh {260 140 285 153} type Multiline
code0 {o->value("Some notes here !");}
}
Fl_Button {} {
label Save
callback {//do resize
//fl_alert("resize");
char buf[32];
int value = atoi(font_size->value());
itoa(--value, buf, 10);
font_size->value(buf);}
xywh {260 303 100 29}
}
Fl_Button {} {
label Cancel
callback {//do resize
fl_alert("resize");}
xywh {450 303 95 29}
}
Fl_Input font_size {
xywh {374 302 61 30} type Int
code0 {font_size->value("12");}
}
Function {resize(int x, int y, int w, int h)} {open return_type void
} {
code {Fl_Double_Window::resize(x,y,w,h);
for(unsigned i=0; i < sizes_at_start.size(); i++)
{
const st_size& tmp = sizes_at_start[i];
//float xratio = this->w() / w;
float fh = tmp.h;
float yratio = tmp.wdg->h() / fh;
tmp.wdg->labelsize( tmp.labelsize * yratio);
if (tmp.textsize)
((Fl_Input_*)tmp.wdg)->textsize( tmp.textsize * yratio);
}} {}
}
decl {std::vector<st_size> sizes_at_start;} {protected local
}
Fl_Pack rbox {open
xywh {25 341 520 31} type HORIZONTAL box ENGRAVED_FRAME labelsize 18
} {
Fl_Round_Button {} {
label button
xywh {35 346 82 16} down_box ROUND_DOWN_BOX labelsize 18
}
}
Function {get_initial_sizes(Fl_Group *grp)} {open return_type void
} {
code {const char *cidIn = Fl_Input_::className();
const char *cidBrow = Fl_Browser_::className();
const char *cidGrp = Fl_Group::className();
int childs = grp->children();
for(int i=0; i < childs; i++)
{
st_size tmp;
tmp.wdg = grp->child(i);
//const char *tc = tmp.wdg->classId();
tmp.x = tmp.wdg->x();
tmp.y = tmp.wdg->y();
tmp.w = tmp.wdg->w();
tmp.h = tmp.wdg->h();
tmp.labelsize = tmp.wdg->labelsize();
if (tmp.wdg->inherits_from(cidIn))
tmp.textsize = ((Fl_Input_*)tmp.wdg)->textsize();
else if (tmp.wdg->inherits_from(cidBrow))
tmp.textsize = ((Fl_Browser_*)tmp.wdg)->textsize();
else tmp.textsize = 0;
sizes_at_start.push_back(tmp);
if(tmp.wdg->inherits_from(cidGrp))
get_initial_sizes((Fl_Group*)tmp.wdg);
}} {}
}
code {get_initial_sizes(this);} {}
Function {reset_sizes_at_start()} {open return_type void
} {
code {sizes_at_start.clear();
get_initial_sizes(this);} {}
}
}
Function {} {open
} {
code {Resizable_Window win;
win.browse->add("Martin");
win.browse->add("Peter");
for(int i=0; i< 4; i++){
win.rbox->add(new Fl_Round_Button(0, 0, 100, 20, "Another B") );
}
win.reset_sizes_at_start();
win.show();} {}
}
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev