On 27.08.2008, at 23:58, rlseal wrote:

> This policy is justifiable? So I should create storage for all of my
> labels and then pass via pointers to all of my other widgets -  
> making me
> maintain this storage for the lifetime of the widget? Then I decide to
> delete my widget; leaving my label to live a free and happy life,
> unbound from that nasty widget, free to roam on its own, and possibly
> even escape death at the end of the program's life if I'm really not
> careful. I think I would rather have the widget responsible for its  
> own
> stinking labels and let me place my worries elsewhere.


Oh c'mon, now you are going overboard. A common way to create Widgets  
is to write something like:

Fl_Box *b = new Fl_Box(10, 10, 20, 20, "My Box");

Now, "My Box" is part of the program memory and will be available  
throughout the lifetime of your application anyways. No additional  
work for you at all.

If you do need the label copied, all you write is this:

Fl_Box *b = new Fl_Box(10, 10, 20, 20);
b->copy_label(translate_to_german("My Box"));

and the widget will manage memory for you. There is no need to have  
your label monitored at all. And your label will never "escape death  
at the end of the program" simply because all memory an application  
allocates is freed when the app terminates (unless you are programming  
Amiga OS 1.3 and earlier).


Matthias


----
http://robowerk.com/


_______________________________________________
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to