Sorry for the late reply, but anyway, FTR: On 27.09.2012 22:20, Eric Sokolowsky wrote: >>> On 09/27/12 10:47, Eric Sokolowsky wrote: >>>> I'm using FLTK 1.3.0 and have a list of widgets in a Fl_Pack. This Fl_Pack >>>> is inside a Fl_Scroll. When I add a new item to the Fl_Pack I want the >>>> item to be visible right away, scrolling if necessary. Is there a way to >>>> do this easily, or do I have to figure out where the new item is and if >>>> offscreen figure out how much to adjust the scrollbar. I tried using the >>>> latter method but the screen does not update right after the item is >>>> inserted until I move the cursor again, even if I put the code to update >>>> the scrollbar position at the beginning of my Fl_Scroll's draw() function. >>> >>> When you add the item to the pack, position the scroller, >>> then call the parent window's redraw() method, eg. >>> scroll->window()->redraw(); >>> and see if that does it. >>> >> > > After trying a few more things I found a recipe that seems to work, but it is > a bit of a kludge. At the end of my class's draw() function (this is the > class that derives from Fl_Scroll, and has a Fl_Pack as a member) I check to > see if the window needs to scroll, and if it does, I recursively call the > draw function just once. I think that the widget's position is not updated > until sometime in the draw() code so perhaps I need to just find where that > is done and put my scroll check right after that to see if I can avoid the > recursive draw() call.
Unfortunately Fl_Scroll and Fl_Pack both do their internal calculations of widget dimensions, scrollbars, etc. inside their draw() method(s). Doing one's own changes of widgets during draw() is something that should be avoided, for the reasons mentioned above (i.e. maybe the necessity of recursive draw() calls). AFAICT off the top of my head, Fl_Scroll calls its children's draw() methods first (to allow adjustments like those done in Fl_Pack), and then calculates its own sizes and scrollbars. So, in theory, it should work, somehow at least... The problem may be that you can't set the scroll position successfully before the Fl_Scroll (and its child Fl_Pack) has been drawn at least once. So, yes, I think that your solution is feasible and currently maybe the only way to do what you want. -- Albrecht _______________________________________________ fltk mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk

