[gtkmm/spread-table] ComboBox: Added get_entry() and get_entry_text().



commit 18f0632f408ea86da7cc93b1a1814e89986902b6
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Oct 14 13:35:50 2010 +0200

    ComboBox: Added get_entry() and get_entry_text().
    
    * gtk/src/combobox.[hg|ccg]: Added our custom get_entry() method that was
      previously in ComboBoxEntry. It avoids the need to call get_child() and
      dynamic_cast<>. Added get_entry_text(), wrappping get_active_text(), which
      was previously only in ComboBoxEntry.

 ChangeLog            |    9 +++++++++
 gtk/src/combobox.ccg |   13 +++++++++++++
 gtk/src/combobox.hg  |   13 +++++++++++++
 3 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index be44d88..29640b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-10-14  Murray Cumming  <murrayc murrayc com>
+
+	ComboBox: Added get_entry() and get_entry_text().
+
+	* gtk/src/combobox.[hg|ccg]: Added our custom get_entry() method that was
+  previously in ComboBoxEntry. It avoids the need to call get_child() and
+  dynamic_cast<>. Added get_entry_text(), wrappping get_active_text(), which
+  was previously only in ComboBoxEntry.
+
 2010-10-11  Murray Cumming  <murrayc murrayc com>
 
 	SpreadTable: Add get_child_line().
diff --git a/gtk/src/combobox.ccg b/gtk/src/combobox.ccg
index dd2292d..64244bf 100644
--- a/gtk/src/combobox.ccg
+++ b/gtk/src/combobox.ccg
@@ -98,4 +98,17 @@ void ComboBox::unset_row_separator_func()
   gtk_combo_box_set_row_separator_func(gobj(), 0, 0, 0 /* See C docs. */);
 }
 
+Entry* ComboBox::get_entry()
+{
+  Gtk::Widget* widget = Glib::wrap(gtk_bin_get_child(GTK_BIN(gobj())));
+  return dynamic_cast<Gtk::Entry*>(widget);
+}
+
+const Entry* ComboBox::get_entry() const
+{
+  const Gtk::Widget* widget = Glib::wrap(gtk_bin_get_child(GTK_BIN(gobj())));
+  return dynamic_cast<const Gtk::Entry*>(widget);
+}
+
+
 } // namespace Gtk
diff --git a/gtk/src/combobox.hg b/gtk/src/combobox.hg
index 1ffc062..47bcdc0 100644
--- a/gtk/src/combobox.hg
+++ b/gtk/src/combobox.hg
@@ -115,6 +115,10 @@ public:
   _WRAP_METHOD(void set_active(int index), gtk_combo_box_set_active)
   _WRAP_METHOD(void set_active(const TreeModel::iterator& iter), gtk_combo_box_set_active_iter)
 
+  //This can be used with either a text-based model (see ComboBoxText) or one that uses has_entry=true,
+  //which is awkward. So we rename it.
+  _WRAP_METHOD(Glib::ustring get_entry_text() const, gtk_combo_box_get_active_text)
+
   /** Causes no item to be active. See also set_active().
    */
   void unset_active();
@@ -162,6 +166,15 @@ public:
 
   _IGNORE(gtk_combo_box_append_text, gtk_combo_box_insert_text, gtk_combo_box_prepend_text, gtk_combo_box_remove_text, gtk_combo_box_get_active_text) //These are in ComboBoxText.
 
+  /** @see Bin::get_child().
+   */
+  Entry* get_entry();
+
+  /** @see Bin::get_child().
+   */
+  const Entry* get_entry() const;
+
+
   _WRAP_PROPERTY("model", Glib::RefPtr<TreeModel>)
   _WRAP_PROPERTY("wrap_width", int)
   _WRAP_PROPERTY("row_span_column", int)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]