Rename some Fl_Flex methods for FLTK compliance (#594)

Change some method names to comply with FLTK style as discussed
in fltk.coredev, thread "Fl_Flex method name question".

* Rename Fl_Flex::margins(...) to Fl_Flex::margin(...)
  (use singular form for all margin related methods)

* Remove Fl_Flex::setSize() and isSetSize() "backwards compatibility" methods

* Rename Fl_Flex::set_size(...) to fixed(...)

Note: the latter affects existing (pre-release) fluid (.fl) files: you may
  want to edit and replace "set_size_tuples" with "fixed_size_tuples"
This commit is contained in:
Albrecht Schlosser 2022-12-15 16:46:40 +01:00 committed by GitHub
parent 2fd1866f49
commit 44a2547394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 115 additions and 144 deletions

View File

@ -23,16 +23,17 @@
/**
Fl_Flex is a container (layout) widget for one row or one column of widgets.
It provides flexible positioning of its children either in one row or in one column.
It provides flexible positioning of its children either in one row or in one
column.
Fl_Flex is designed to be as simple as possible. You can set individual widget
sizes or let Fl_Flex position and size the widgets to fit in the container.
All "flexible" (i.e. non-fixed size) widgets are assigned the same width or
height, respectively. For details see below.
You can set the margins \b around all children at the inner side the box frame
(if any). Fl_Flex supports setting different margin sizes on top, bottom, left
and right sides.
You can set the margins \b around all children at the inner side of the box
frame (if any). Fl_Flex supports setting different margin sizes on top,
bottom, left, and right sides.
The default margin size is 0 on all edges of the container.
You can set the gap size \b between all children. The gap size is always the
@ -46,11 +47,11 @@
If type() == Fl_Flex::HORIZONTAL widgets are resized horizontally to fit in
the container and their height is the full Fl_Flex height minus border size
and margins. You can set a fixed widget width by using set_size().
and margins. You can set a fixed widget width by using fixed().
If type() == Fl_Flex::VERTICAL widgets are resized vertically to fit in
the container and their width is the full Fl_Flex width minus border size
and margins. You can set a fixed widget height by using set_size().
and margins. You can set a fixed widget height by using fixed().
To create arbitrary spacing you can use invisible boxes of flexible or
fixed sizes (see example below).
@ -77,8 +78,6 @@
Fl_Flex containers can be nested so you can create flexible layouts with
multiple columns and rows. However, if your UI design is more complex you
may want to use Fl_Grid instead.
At the time of this writing (Aug 7, 2022) Fl_Grid is not yet available
but will be added before FLTK 1.4.0 gets released.
Example:
\image html Fl_Flex_simple.png
@ -99,7 +98,7 @@
Fl_Button b2(0, 0, 0, 0, "Save");
Fl_Box bx(0, 0, 0, 0);
Fl_Button b3(0, 0, 0, 0, "Exit");
flex.set_size(bx, 60); // set fix width of invisible box
flex.fixed(bx, 60); // set fix width of invisible box
flex.gap(10);
flex.end();
window.resizable(flex);
@ -119,9 +118,9 @@ class FL_EXPORT Fl_Flex : public Fl_Group {
int margin_right_;
int margin_bottom_;
int gap_;
int set_size_size_;
int set_size_alloc_;
Fl_Widget **set_size_;
int fixed_size_size_;
int fixed_size_alloc_;
Fl_Widget **fixed_size_;
public:
@ -153,14 +152,14 @@ public:
\param[in] w widget to be affected
\param[in] size width (Fl_Flex::HORIZONTAL) or height (Fl_Flex::VERTICAL)
\see set_size(Fl_Widget *w, int size)
\see fixed(Fl_Widget *w, int size)
*/
void set_size(Fl_Widget &w, int size) {
set_size(&w, size);
void fixed(Fl_Widget &w, int size) {
fixed(&w, size);
}
void set_size(Fl_Widget *w, int size);
int set_size(Fl_Widget *w) const;
void fixed(Fl_Widget *w, int size);
int fixed(Fl_Widget *w) const;
protected:
@ -179,7 +178,7 @@ public:
\note This method is useful if you never set different margin sizes.
\see int margins(int *left, int *top, int *right, int *bottom)
\see int margin(int *left, int *top, int *right, int *bottom)
to get all four margin values.
\return size of left margin.
*/
@ -199,7 +198,7 @@ public:
\retval 1 all margins have the same size
\retval 0 at least one margin has a different size
*/
int margins(int *left, int *top, int *right, int *bottom) const {
int margin(int *left, int *top, int *right, int *bottom) const {
if (left) *left = margin_left_;
if (top) *top = margin_top_;
if (right) *right = margin_right_;
@ -215,15 +214,15 @@ public:
If you don't use the second parameter \p g or supply a negative value
the gap size is not changed.
The margin is some free space inside the widget border \b around all child widgets.
The margin is the free space inside the widget border \b around all child widgets.
This method sets the margin to the same size at all four edges of the Fl_Flex widget.
The gap size \p g is some free space \b between child widgets. Negative values
(the default if this argument is omitted) do not change the gap value.
The gap size \p g is the free space \b between child widgets. Negative values
do not change the gap value. This is the default if this argument is omitted.
\param[in] m margin size, must be \>= 0
\param[in] g gap size, ignored (if negative)
\param[in] g gap size (ignored, if negative)
\see gap(int)
*/
@ -243,15 +242,13 @@ public:
You must use all four parameters of this method to set the four margins in the
order \p left, \p top, \p right, \p bottom. Negative values are set to 0 (zero).
To set all margins to equal sizes, use margin(int m)
This method sets the margin to the same size at all four edges of the widget.
To set all margins to equal sizes, use margin(int m) which sets all four margins
to the same size.
\param[in] left,top,right,bottom margin sizes, must be \>= 0
\see margin(int, int)
*/
void margin(int left, int top, int right, int bottom) {
margin_left_ = left < 0 ? 0 : left;
margin_top_ = top < 0 ? 0 : top;
@ -330,32 +327,6 @@ public:
gap(i);
}
#if (1)
// Additional methods for backwards compatibility with "original" Fl_Flex widget
/**
Deprecated.
\deprecated Please use set_size(Fl_Widget *) instead.
\see int set_size(Fl_Widget *)
*/
bool isSetSize(Fl_Widget *w) const {
return (bool)set_size(w);
}
/**
Set the horizontal or vertical size of a child widget.
\deprecated Please use set_size(Fl_Widget *, int) instead.
\see set_size(Fl_Widget *, int)
*/
void setSize(Fl_Widget *w, int size) {
set_size(w, size);
}
#endif
};
#endif // Fl_Flex_H

View File

@ -49,7 +49,7 @@ int main(int argc, char **argv) {
// set gap between adjacent buttons and extra spacing (invisible box size)
flex.gap(10);
flex.set_size(bx, 30); // total 50: 2 * gap + 30
flex.fixed(bx, 30); // total 50: 2 * gap + 30
// end() groups
flex.end();

View File

@ -189,9 +189,9 @@ Fl_Widget *Fl_Flex_Type::enter_live_mode(int) {
int nc = s->children(), nd = d->children();
if (nc>nd) nc = nd;
for (int i=0; i<nc; i++) {
if (s->set_size(s->child(i))) {
if (s->fixed(s->child(i))) {
Fl_Widget *dc = d->child(i);
d->set_size(d->child(i), s->horizontal() ? dc->w() : dc->h());
d->fixed(d->child(i), s->horizontal() ? dc->w() : dc->h());
}
}
grp->end(); //this also updates the layout
@ -203,7 +203,7 @@ void Fl_Flex_Type::copy_properties()
Fl_Group_Type::copy_properties();
Fl_Flex *d = (Fl_Flex*)live_widget, *s =(Fl_Flex*)o;
int lm, tm, rm, bm;
s->margins(&lm, &tm, &rm, &bm);
s->margin(&lm, &tm, &rm, &bm);
d->margin(lm, tm, rm, bm);
d->gap( s->gap() );
}
@ -213,20 +213,20 @@ void Fl_Flex_Type::write_properties()
Fl_Group_Type::write_properties();
Fl_Flex* f = (Fl_Flex*)o;
int lm, tm, rm, bm;
f->margins(&lm, &tm, &rm, &bm);
f->margin(&lm, &tm, &rm, &bm);
if (lm!=0 || tm!=0 || rm!=0 || bm!=0)
write_string("margins {%d %d %d %d}", lm, tm, rm, bm);
write_string("margin {%d %d %d %d}", lm, tm, rm, bm);
if (f->gap())
write_string("gap %d", f->gap());
int nSet = 0;
for (int i=0; i<f->children(); i++)
if (f->set_size(f->child(i)))
if (f->fixed(f->child(i)))
nSet++;
if (nSet) {
write_string("set_size_tuples {%d", nSet);
write_string("fixed_size_tuples {%d", nSet);
for (int i=0; i<f->children(); i++) {
Fl_Widget *ci = f->child(i);
if (f->set_size(ci))
if (f->fixed(ci))
write_string(" %d %d", i, f->horizontal() ? ci->w() : ci->h());
}
write_string("}");
@ -237,7 +237,7 @@ void Fl_Flex_Type::read_property(const char *c)
{
Fl_Flex* f = (Fl_Flex*)o;
suspend_auto_layout = 1;
if (!strcmp(c,"margins")) {
if (!strcmp(c,"margin")) {
int lm, tm, rm, bm;
if (sscanf(read_word(),"%d %d %d %d",&lm,&tm,&rm,&bm) == 4)
f->margin(lm, tm, rm, bm);
@ -245,7 +245,7 @@ void Fl_Flex_Type::read_property(const char *c)
int g;
if (sscanf(read_word(),"%d",&g))
f->gap(g);
} else if (!strcmp(c,"set_size_tuples")) {
} else if (!strcmp(c,"fixed_size_tuples")) {
read_word(1); // must be '{'
const char *nStr = read_word(1); // number of indices in table
fixedSizeTupleSize = atoi(nStr);
@ -271,7 +271,7 @@ void Fl_Flex_Type::postprocess_read()
int size = fixedSizeTuple[2*i+1];
if (ix>=0 && ix<f->children()) {
Fl_Widget *ci = f->child(ix);
f->set_size(ci, size);
f->fixed(ci, size);
}
}
fixedSizeTupleSize = 0;
@ -285,15 +285,15 @@ void Fl_Flex_Type::write_code2() {
const char *var = name() ? name() : "o";
Fl_Flex* f = (Fl_Flex*)o;
int lm, tm, rm, bm;
f->margins(&lm, &tm, &rm, &bm);
f->margin(&lm, &tm, &rm, &bm);
if (lm!=0 || tm!=0 || rm!=0 || bm!=0)
write_c("%s%s->margin(%d, %d, %d, %d);\n", indent(), var, lm, tm, rm, bm);
if (f->gap())
write_c("%s%s->gap(%d);\n", indent(), var, f->gap());
for (int i=0; i<f->children(); ++i) {
Fl_Widget *ci = f->child(i);
if (f->set_size(ci))
write_c("%s%s->set_size(%s->child(%d), %d);\n", indent(), var, var, i,
if (f->fixed(ci))
write_c("%s%s->fixed(%s->child(%d), %d);\n", indent(), var, var, i,
f->horizontal() ? ci->w() : ci->h());
}
Fl_Group_Type::write_code2();
@ -313,7 +313,7 @@ void Fl_Flex_Type::move_child(Fl_Type* a, Fl_Type* b) {
void Fl_Flex_Type::remove_child(Fl_Type* a) {
if (a->is_widget())
((Fl_Flex*)o)->set_size(((Fl_Widget_Type*)a)->o, 0);
((Fl_Flex*)o)->fixed(((Fl_Widget_Type*)a)->o, 0);
Fl_Group_Type::remove_child(a);
((Fl_Flex*)o)->layout();
}
@ -331,7 +331,7 @@ void Fl_Flex_Type::change_subtype_to(int n) {
int dw = Fl::box_dw(f->box());
int dh = Fl::box_dh(f->box());
int lm, tm, rm, bm;
f->margins(&lm, &tm, &rm, &bm);
f->margin(&lm, &tm, &rm, &bm);
int gap = f->gap();
int fw = f->w()-dw-lm-rm-(nc*gap);
if (fw<=nc) fw = nc; // avoid division by zero
@ -369,7 +369,7 @@ int Fl_Flex_Type::size(Fl_Type *t, char fixed_only) {
Fl_Flex_Type* ft = (Fl_Flex_Type*)t->parent;
Fl_Flex* f = (Fl_Flex*)ft->o;
Fl_Widget *w = ((Fl_Widget_Type*)t)->o;
if (fixed_only && !f->set_size(w)) return 0;
if (fixed_only && !f->fixed(w)) return 0;
return f->horizontal() ? w->w() : w->h();
}
@ -380,7 +380,7 @@ int Fl_Flex_Type::is_fixed(Fl_Type *t) {
Fl_Flex_Type* ft = (Fl_Flex_Type*)t->parent;
Fl_Flex* f = (Fl_Flex*)ft->o;
Fl_Widget *w = ((Fl_Widget_Type*)t)->o;
return f->set_size(w);
return f->fixed(w);
}
////////////////////////////////////////////////////////////////

View File

@ -2183,14 +2183,14 @@ static void flex_margin_cb(Fl_Value_Input* i, void* v,
static void load_left_margin(Fl_Flex *w, Fl_Value_Input* i)
{
int v;
w->margins(&v, NULL, NULL, NULL);
w->margin(&v, NULL, NULL, NULL);
i->value((double)v);
}
static int update_left_margin(Fl_Flex *w, int new_value)
{
int l, t, r, b;
w->margins(&l, &t, &r, &b);
w->margin(&l, &t, &r, &b);
if (new_value!=l) {
w->margin(new_value, t, r, b);
return 1;
@ -2206,14 +2206,14 @@ void flex_margin_left_cb(Fl_Value_Input* i, void* v) {
static void load_top_margin(Fl_Flex *w, Fl_Value_Input* i)
{
int v;
w->margins(NULL, &v, NULL, NULL);
w->margin(NULL, &v, NULL, NULL);
i->value((double)v);
}
static int update_top_margin(Fl_Flex *w, int new_value)
{
int l, t, r, b;
w->margins(&l, &t, &r, &b);
w->margin(&l, &t, &r, &b);
if (new_value!=t) {
w->margin(l, new_value, r, b);
return 1;
@ -2229,14 +2229,14 @@ void flex_margin_top_cb(Fl_Value_Input* i, void* v) {
static void load_right_margin(Fl_Flex *w, Fl_Value_Input* i)
{
int v;
w->margins(NULL, NULL, &v, NULL);
w->margin(NULL, NULL, &v, NULL);
i->value((double)v);
}
static int update_right_margin(Fl_Flex *w, int new_value)
{
int l, t, r, b;
w->margins(&l, &t, &r, &b);
w->margin(&l, &t, &r, &b);
if (new_value!=r) {
w->margin(l, t, new_value, b);
return 1;
@ -2252,14 +2252,14 @@ void flex_margin_right_cb(Fl_Value_Input* i, void* v) {
static void load_bottom_margin(Fl_Flex *w, Fl_Value_Input* i)
{
int v;
w->margins(NULL, NULL, NULL, &v);
w->margin(NULL, NULL, NULL, &v);
i->value((double)v);
}
static int update_bottom_margin(Fl_Flex *w, int new_value)
{
int l, t, r, b;
w->margins(&l, &t, &r, &b);
w->margin(&l, &t, &r, &b);
if (new_value!=b) {
w->margin(l, t, r, new_value);
return 1;
@ -2327,10 +2327,10 @@ void flex_size_cb(Fl_Value_Input* i, void* v) {
if (o->selected && o->is_widget() && Fl_Flex_Type::parent_is_flex(o)) {
Fl_Widget* w = (Fl_Widget*)((Fl_Widget_Type*)o)->o;
Fl_Flex* f = (Fl_Flex*)((Fl_Flex_Type*)o->parent)->o;
int was_fixed = f->set_size(w);
int was_fixed = f->fixed(w);
if (new_size==0) {
if (was_fixed) {
f->set_size(w, 0);
f->fixed(w, 0);
f->layout();
widget_flex_fixed->value(0);
mod = 1;
@ -2338,7 +2338,7 @@ void flex_size_cb(Fl_Value_Input* i, void* v) {
} else {
int old_size = Fl_Flex_Type::size(o);
if (old_size!=new_size || !was_fixed) {
f->set_size(w, new_size);
f->fixed(w, new_size);
f->layout();
widget_flex_fixed->value(1);
mod = 1;
@ -2362,16 +2362,16 @@ void flex_fixed_cb(Fl_Check_Button* i, void* v) {
if (o->selected && o->is_widget() && Fl_Flex_Type::parent_is_flex(o)) {
Fl_Widget* w = (Fl_Widget*)((Fl_Widget_Type*)o)->o;
Fl_Flex* f = (Fl_Flex*)((Fl_Flex_Type*)o->parent)->o;
int was_fixed = f->set_size(w);
int was_fixed = f->fixed(w);
if (new_fixed==0) {
if (was_fixed) {
f->set_size(w, 0);
f->fixed(w, 0);
f->layout();
mod = 1;
}
} else {
if (!was_fixed) {
f->set_size(w, Fl_Flex_Type::size(o));
f->fixed(w, Fl_Flex_Type::size(o));
f->layout();
mod = 1;
}

View File

@ -1222,12 +1222,12 @@ void Fl_Window_Type::moveallchildren()
Fl_Flex* f = (Fl_Flex*)ft->o;
if (f->horizontal()) {
if (myo->o->w()!=ow) {
f->set_size(myo->o, myo->o->w());
f->fixed(myo->o, myo->o->w());
f->layout();
}
} else {
if (myo->o->h()!=oh) {
f->set_size(myo->o, myo->o->h());
f->fixed(myo->o, myo->o->h());
f->layout();
}
}

View File

@ -427,7 +427,7 @@ Type "Fl_Flex" <word> : C++ variable name
"margins" <word> : this Word is written with printf as "{%d %d %d %d}",
left, top, right, bottom
"gap" <word> : integer
"set_size_tuples" <word> : this Word is written with printf "{%d", where %d
"fixed_size_tuples" <word> : this Word is written with printf "{%d", where %d
encodes the number of tuples to follow, and zero or more " %d %d"
containing the index and size of that child, followed by a '}'.
... : inherits more from Fl_Group

View File

@ -39,8 +39,8 @@
*/
Fl_Flex::Fl_Flex(int X, int Y, int W, int H, const char *L)
: Fl_Group(X, Y, W, H, L) {
init();
}
init();
}
// special Fl_Flex constructors w/o label (backwards compatible with original Fl_Flex widget)
@ -54,7 +54,7 @@ Fl_Flex::Fl_Flex(int X, int Y, int W, int H, const char *L)
for nested Fl_Flex widgets. Use one of the other constructors to set the
desired position and size as well.
\param[in] direction horizontal (row) or vertical (column) layout
\param[in] direction horizontal (row) or vertical (column) layout
\see Fl_Flex::Fl_Flex(int w, int h, int direction)
\see Fl_Flex::Fl_Flex(int x, int y, int w, int h, int direction)
@ -75,9 +75,8 @@ Fl_Flex::Fl_Flex(int direction)
for nested Fl_Flex widgets. Use one of the other constructors to set the
desired position as well.
\param[in] w,h widget size
\param[in] direction horizontal (row) or vertical (column) layout
\param[in] w,h widget size
\param[in] direction horizontal (row) or vertical (column) layout
\see Fl_Flex::Fl_Flex(int direction)
\see Fl_Flex::Fl_Flex(int x, int y, int w, int h, int direction)
@ -115,22 +114,22 @@ Fl_Flex::Fl_Flex(int x, int y, int w, int h, int direction)
}
void Fl_Flex::init(int t) {
gap_ = 0; // default gap size
margin_left_ = 0; // default margin size
margin_top_ = 0; // default margin size
margin_right_ = 0; // default margin size
margin_bottom_ = 0; // default margin size
set_size_ = NULL; // array of fixed size widgets
set_size_size_ = 0; // number of fixed size widgets
set_size_alloc_ = 0; // allocated size of array of fixed size widgets
gap_ = 0; // default gap size
margin_left_ = 0; // default margin size
margin_top_ = 0; // default margin size
margin_right_ = 0; // default margin size
margin_bottom_ = 0; // default margin size
fixed_size_ = NULL; // array of fixed size widgets
fixed_size_size_ = 0; // number of fixed size widgets
fixed_size_alloc_ = 0; // allocated size of array of fixed size widgets
type(HORIZONTAL);
if (t == VERTICAL)
type(VERTICAL);
}
Fl_Flex::~Fl_Flex() {
if (set_size_)
free(set_size_);
if (fixed_size_)
free(fixed_size_);
}
/*
@ -138,7 +137,7 @@ Fl_Flex::~Fl_Flex() {
Make sure that the widget is also removed from our fixed list.
*/
void Fl_Flex::on_remove(int index) {
set_size(child(index), 0);
fixed(child(index), 0);
}
void Fl_Flex::resize(int x, int y, int w, int h) {
@ -171,7 +170,7 @@ void Fl_Flex::resize(int x, int y, int w, int h) {
for (int i = 0; i < cc; i++) {
Fl_Widget *c = child(i);
if (c->visible()) {
if (set_size(c)) {
if (fixed(c)) {
space -= (hori ? c->w() : c->h());
fw--;
}
@ -201,7 +200,7 @@ void Fl_Flex::resize(int x, int y, int w, int h) {
continue;
if (hori) {
if (set_size(c)) {
if (fixed(c)) {
c->resize(xp, yp, c->w(), hh);
} else {
c->resize(xp, yp, sp, hh);
@ -209,7 +208,7 @@ void Fl_Flex::resize(int x, int y, int w, int h) {
}
xp += c->w() + gap_;
} else {
if (set_size(c)) {
if (fixed(c)) {
c->resize(xp, yp, vw, c->h());
} else {
c->resize(xp, yp, vw, sp);
@ -237,7 +236,8 @@ void Fl_Flex::end() {
This sets either the width or height of a child widget, depending on the
type() of the Fl_Flex container (Fl_Flex::HORIZONTAL or Fl_Flex::VERTICAL).
The other dimension is set to the full width or height of the Fl_Flex widget.
The other dimension is set to the full width or height of the Fl_Flex widget
minus margin sizes.
This can be used to set a fixed widget width or height of children
of Fl_Flex so they are not resized dynamically.
@ -247,14 +247,14 @@ void Fl_Flex::end() {
\param[in] child widget to be affected
\param[in] size width (Fl_Flex::HORIZONTAL) or height (Fl_Flex::VERTICAL)
*/
void Fl_Flex::set_size(Fl_Widget *child, int size) {
void Fl_Flex::fixed(Fl_Widget *child, int size) {
if (size <= 0)
size = 0;
// find w in our fixed size list
int idx = -1;
for (int i = 0; i < set_size_size_; i++) {
if (set_size_[i] == child) {
for (int i = 0; i < fixed_size_size_; i++) {
if (fixed_size_[i] == child) {
idx = i;
break;
}
@ -262,10 +262,10 @@ void Fl_Flex::set_size(Fl_Widget *child, int size) {
// remove from array, if we want the widget to be flexible, but an entry was found
if (size == 0 && idx >= 0) {
for (int i = idx; i < set_size_size_ - 1; i++) {
set_size_[i] = set_size_[i+1];
for (int i = idx; i < fixed_size_size_ - 1; i++) {
fixed_size_[i] = fixed_size_[i+1];
}
set_size_size_--;
fixed_size_size_--;
return;
}
@ -275,12 +275,12 @@ void Fl_Flex::set_size(Fl_Widget *child, int size) {
// if we have no entry yet, add to array of fixed size widgets
if (idx == -1) {
if (set_size_size_ == set_size_alloc_) {
set_size_alloc_ = alloc_size(set_size_alloc_);
set_size_ = (Fl_Widget **)realloc(set_size_, set_size_alloc_ * sizeof(Fl_Widget *));
if (fixed_size_size_ == fixed_size_alloc_) {
fixed_size_alloc_ = alloc_size(fixed_size_alloc_);
fixed_size_ = (Fl_Widget **)realloc(fixed_size_, fixed_size_alloc_ * sizeof(Fl_Widget *));
}
set_size_[set_size_size_] = child;
set_size_size_++;
fixed_size_[fixed_size_size_] = child;
fixed_size_size_++;
}
// if the child size is meant to be fixed, set its new size
@ -298,9 +298,9 @@ void Fl_Flex::set_size(Fl_Widget *child, int size) {
\retval 1 the widget has a fixed size
\retval 0 the widget resizes dynamically
*/
int Fl_Flex::set_size(Fl_Widget *w) const {
for (int i = 0; i < set_size_size_; i++) {
if (w == set_size_[i]) {
int Fl_Flex::fixed(Fl_Widget *w) const {
for (int i = 0; i < fixed_size_size_; i++) {
if (w == fixed_size_[i]) {
return 1;
}
}

View File

@ -95,8 +95,8 @@ Fl_Flex *create_row() {
col2->color(fl_rgb_color(255, 128, 128));
}
row->set_size(box2, 50);
row->set_size(col2, 100);
row->fixed(box2, 50);
row->fixed(col2, 100);
row->end();
// TEST
@ -128,7 +128,7 @@ int main(int argc, char **argv) {
col1->end();
row1->end();
col->set_size(create_row(), 90); // sets height of created (anonymous) row #2
col->fixed(create_row(), 90); // sets height of created (anonymous) row #2
create_button("Something1"); // "row" #3
@ -136,13 +136,13 @@ int main(int argc, char **argv) {
Fl_Button *cancel = create_button("Cancel");
Fl_Button *ok = create_button("OK");
new Fl_Input(0, 0, 120, 10, "");
row4->set_size(cancel, 100);
row4->set_size(ok, 100);
row4->fixed(cancel, 100);
row4->fixed(ok, 100);
row4->end();
create_button("Something2"); // "row" #5
col->set_size(row4, 30);
col->fixed(row4, 30);
col->margin(6, 10, 6, 10);
col->gap(6);
col->end();

View File

@ -40,7 +40,7 @@ void buttons_panel(Fl_Flex *parent) {
b->align(FL_ALIGN_INSIDE | FL_ALIGN_RIGHT);
Fl_Input *username = new Fl_Input(0, 0, 0, 0, "");
urow->set_size(username, 180);
urow->fixed(username, 180);
urow->end();
}
@ -50,7 +50,7 @@ void buttons_panel(Fl_Flex *parent) {
b->align(FL_ALIGN_INSIDE | FL_ALIGN_RIGHT);
Fl_Input *password = new Fl_Input(0, 0, 0, 0, "");
prow->set_size(password, 180);
prow->fixed(password, 180);
prow->end();
}
@ -62,8 +62,8 @@ void buttons_panel(Fl_Flex *parent) {
Fl_Button *reg = create_button("Register");
Fl_Button *login = create_button("Login");
brow->set_size(reg, 80);
brow->set_size(login, 80);
brow->fixed(reg, 80);
brow->fixed(login, 80);
brow->gap(20);
brow->end();
@ -71,12 +71,12 @@ void buttons_panel(Fl_Flex *parent) {
Fl_Box *b = new Fl_Box(0, 0, 0, 0, "");
parent->set_size(w, 60);
parent->set_size(urow, 30);
parent->set_size(prow, 30);
parent->set_size(pad, 1);
parent->set_size(brow, 30);
parent->set_size(b, 30);
parent->fixed(w, 60);
parent->fixed(urow, 30);
parent->fixed(prow, 30);
parent->fixed(pad, 1);
parent->fixed(brow, 30);
parent->fixed(b, 30);
}
// create widgets inside a row, i.e. parent is type(ROW)
@ -95,9 +95,9 @@ void middle_panel(Fl_Flex *parent) {
new Fl_Box(0, 0, 0, 0, "");
parent->set_size(box, 200);
parent->set_size(spacer, 10);
parent->set_size(bp, 300);
parent->fixed(box, 200);
parent->fixed(spacer, 10);
parent->fixed(bp, 300);
}
// The main panel consists of three "rows" inside a column, i.e. parent is
@ -114,7 +114,7 @@ void mainPanel(Fl_Flex *parent) {
new Fl_Box(0, 0, 0, 0, ""); // flexible separator
parent->set_size(mp, 200);
parent->fixed(mp, 200);
}
int main(int argc, char **argv) {