diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2004-11-23 19:47:52 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2004-11-23 19:47:52 +0000 |
| commit | a42ded75e297cedfcb448537e77d13350df0fe92 (patch) | |
| tree | 3940e35fff5db18195b113bcb5055f7c5d0577a7 /src/Fl_Widget.cxx | |
| parent | 5cc0f07c8a18841ba32ec5b3a12737c9f7d13cc2 (diff) | |
Added the 2.0 Fl_Widget::copy_label() method to allow FLTK 1.x
applications to have their label strings managed by FLTK (STR
#630)
Added Fl::delete_widget() method to safely delete widgets in
callback methods (STR #629)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3917 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Widget.cxx')
| -rw-r--r-- | src/Fl_Widget.cxx | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/Fl_Widget.cxx b/src/Fl_Widget.cxx index 528ac5b81..ecf9fce33 100644 --- a/src/Fl_Widget.cxx +++ b/src/Fl_Widget.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Widget.cxx,v 1.5.2.4.2.24 2004/08/25 00:20:25 matthiaswm Exp $" +// "$Id: Fl_Widget.cxx,v 1.5.2.4.2.25 2004/11/23 19:47:52 easysw Exp $" // // Base widget class for the Fast Light Tool Kit (FLTK). // @@ -129,6 +129,7 @@ extern void fl_throw_focus(Fl_Widget*); // in Fl_x.cxx // However, it is only legal to destroy a "root" such as an Fl_Window, // and automatic destructors may be called. Fl_Widget::~Fl_Widget() { + if (flags() & COPIED_LABEL) free(label_.value); parent_ = 0; // Don't throw focus to a parent widget. fl_throw_focus(this); } @@ -244,6 +245,27 @@ int Fl_Widget::contains(const Fl_Widget *o) const { return 0; } + +void +Fl_Widget::label(const char *a) { + if (flags() & COPIED_LABEL) { + free(label_.value); + clear_flag(COPIED_LABEL); + } + label_.value=a; + redraw_label(); +} + + +void +Fl_Widget::copy_label(const char *a) { + if (flags() & COPIED_LABEL) free(label_.value); + set_flag(COPIED_LABEL); + label_.value=strdup(a); + redraw_label(); +} + + // -// End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.24 2004/08/25 00:20:25 matthiaswm Exp $". +// End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.25 2004/11/23 19:47:52 easysw Exp $". // |
