On 15.05.2012 00:29, Eugenio Bargiacchi wrote:
> Thanks! It works now! It was simply the case of setting the resizable to null.
You're welcome. I'm glad I could help.
> I've one last problem though. This scrollbar, as you can see, it is a
> Vertical one. What I wanted to do is that if the Fl_Scroll is resized
> horizontally, this also resizes the Fl_Group inside.
>
> I've made a custom Fl_Scrollbar which reimplements the resize method like
> this:
>
> void CustomScrollbar::resize(int x, int y, int w, int z ) {
> Fl_Scroll::resize(x,y,w,z);
>
> if ( child(0) )
> child(0)->resize(x+s, y+2*s, w-4*s, child(0)->h());
> }
Hmm, I don't understand. What is your CustomScrollbar widget derived
from? The name is confusing. Fl_Scrollbar is the widget that provides
the slider and handles to move Fl_Scroll's contents. So it seems that
you meant a "CustomScroll" widget, derived from Fl_Scroll, as your
code seems to indicate when you call "Fl_Scroll::resize(x,y,w,z);".
I assume this is what you did and meant in the text.
> With this it still works fine, it resizes the Fl_Group and it displays
> everything correctly. However it does not resize the fields inside the
> Fl_Group.
Please see at my earlier post with the code in attachments. This one
sets a resize box and also uses Fl_Group::init_sizes() after resizing,
which is really important if you combine your own resizing by changing
widget positions with FLTK's auto-resizing (resizable()) feature.
Change this line:
Fl_Box * rb = new Fl_Box(320-3,340-3,3,3); // resize box
to
Fl_Box * rb = new Fl_Box(20,340-3,300,3); // full width resize box
and see if this helps.
If you want horizontal resizing only, you can put a resizable() widget
at the top or bottom of the group (or anywhere else above or below all
widgets that should keep their vertical sizes) over the full width of
the group. There are examples in the docs and the test folder ...
> But I'm not sure how to say to the Fl_Group to resize correctly. I've tried
> to add a Fl_Box inside it and setting resizable to it, but as soon as
> resizable is set the problem reappears.
With the trick above this *ought to* work, but I didn't test it.
> Any idea on how to get this functionality? Thanks again for all the help!
See above.
That said, I suggest to change the code to do full custom resizing,
particularly since you already derived your own class(es). Combining
and nesting FLTK's resizable()s with one's own custom resizing can
become difficult (you may need nested groups with resizables), and if
you want to add widgets dynamically (after the user might have resized
the window already), it can even become impossible to achieve the
results you want.
I won't go further into it now, but there can be rounding problems that
cause unwanted effects. Remember that you must call init_sizes() after
changing the layout (adding widgets, for instance).
Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk