MacArthur, Ian (SELEX GALILEO, UK) wrote:
>> Let's suppose, your Image is a square (same width and height). In
>> your Scroll class, you can implement the virtual resize() method:
>>
>> Scroll::resize(int X, int Y, int W, int H)
>> {
>> Fl_Scroll::resize(X,Y,W,H); // resize Scroll widget
>> scroll_to(0,0); // makes things easier; YMMV
>> img->resize(X,Y,max(W,H),max(W,H)); // or something
>> like that
>> }
>>
>> where *img is your Image i.
>>
>> Thus, the Image i would always fill the full Scroll area, and
>> horizontal and vertical scrollbars would appear as needed.
>>
>> Of course, your Image class would need to be able to resize
>> itself accordingly.
>>
>> Is that what you want to do?
>
>
> That sounds like it might be it, I'll need to try that later on.
>
> I think it's the trick with the resize and propagating that to the child
> that I was missing...
>
> What I want is that the child can resize horizontally as the window is
> resized, but this will result in the child vertical dimension changing,
> so I need to propagate that changed vertical size back up to the
> scroll...
Right now, I think this (new calculation and resizing of the scrollbars)
would be done during the next draw() of Fl_Scroll, because that's where
the scrollbars are adjusted. Thus, you could simply call redraw() on the
Scroll widget.
However, adjusting the scrollbars in draw() is considered bad practice [1]
and should (will !) be changed soon (I'm planning to do this together with
another Fl_Scroll issue I'm working on, if nobody else claims to do it).
Then, resize() should adjust the scrollbars according to the (new) child
sizes, and that's it. Although I think that a redraw() would still be needed
somehow, but ... let's see then.
Albrecht
[1] http://www.fltk.org/str.php?L1895
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk