> I'd like to know from some of the more experienced users how they > usually go about updating the children Widgets of a Window. > > The first time I did it, I made a new class for each Window and for > each widget I made a pointer member. When the Widget was created, > its pointer was assigned to the appropriate member. > > This time, I put the name of the Widget into the user_data field, > and when I want to access a Widget, I cycle through the children > using 'children()' and 'child()', checking for the name of the > Widget I want using 'user_data()'. Is this generally how it's > done, or is there something simpler I can do?
It isn't clear to me whether "update" means redraw, or refresh based on new data in the main application. If you mean redraw, then as long as you use container widgets to group them together, and they don't overlap, fltk should handle the redrawing automatically. If you want some custom display, such as intelligent scrolling of a small section of data instead of the whole set, you will need to implement that particular draw() method, but it should be called at the right time automatically. If you mean refresh data fields and views based on new application data, then how you do it is up to you. Within your user interface classes you can have member variables for particular fields, and update them via those fields. Or maybe some logic in the redraw that fetches new data from the application and displays it in the field. There is also user_data() as you say, but not all widgets are going to need callbacks with user data, or the callback might require different user data, or it could change over time. Also, relying on particular user_data or labels might not be very robust if you want to allow preferences or internationalisation... Which method you use will depend on your own particular application. As the saying goes, there's more than one way to skin a cat. Cheers D _______________________________________________ fltk mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk

