Mercurial > hg > octave-nkf
diff src/DLD-FUNCTIONS/fltk_backend.cc @ 10008:b6261d776a82
handle window title correctly in fltk_backend
author | Shai Ayal <shaiay@users.sourceforge.net> |
---|---|
date | Sun, 20 Dec 2009 23:02:08 +0200 |
parents | 1300d9ced492 |
children | 360de61b2722 |
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/fltk_backend.cc +++ b/src/DLD-FUNCTIONS/fltk_backend.cc @@ -283,13 +283,10 @@ autoscale->show (); togglegrid->show (); + set_name (); resizable (canvas); size_range (4*status_h, 2*status_h); - std::stringstream name; - name << "octave: figure " << number (); - window_label = name.str (); - label (window_label.c_str ()); } ~plot_window (void) @@ -320,6 +317,23 @@ canvas->damage (FL_DAMAGE_ALL); } + void set_name (void) + { + std::stringstream name; + std::string sep; + + if (fp.is_numbertitle ()) + { + name << "Figure " << number (); + sep = ": "; + } + if (fp.get_name ().size ()) + name << sep << fp.get_name (); + + window_label = name.str (); + label (window_label.c_str ()); + } + private: // window name -- this must exists for the duration of the window's // life @@ -708,6 +722,17 @@ mark_modified (hnd2idx (gh)); } + static void set_name (int idx) + { + if (instance_ok ()) + instance->do_set_name (idx); + } + + static void set_name (std::string idx_str) + { + set_name (str2idx (idx_str)); + } + static Matrix get_size (int idx) { return instance_ok () ? instance->do_get_size (idx) : Matrix (); @@ -797,6 +822,15 @@ } } + void do_set_name (int idx) + { + wm_iterator win; + if ((win = windows.find (idx)) != windows.end ()) + { + win->second->set_name (); + } + } + Matrix do_get_size (int idx) { Matrix sz (1, 2, 0.0); @@ -953,8 +987,13 @@ switch (id) { case base_properties::VISIBLE: - figure_manager::toggle_window_visibility (ov.string_value(), fp.is_visible ()); + figure_manager::toggle_window_visibility (ov.string_value (), fp.is_visible ()); break; + + case figure::properties::NAME: + case figure::properties::NUMBERTITLE: + figure_manager::set_name (ov.string_value ()); + break; } } }