]> git.saurik.com Git - wxWidgets.git/commitdiff
implemented SetSelection
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 22 Jan 2004 15:20:34 +0000 (15:20 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 22 Jan 2004 15:20:34 +0000 (15:20 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25308 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/spinctrl.h
include/wx/gtk1/spinctrl.h
src/gtk/spinctrl.cpp
src/gtk1/spinctrl.cpp

index b02797c3e74a1b2483a96188815f4031d189ce26..f39e5184e632f7d2c3f69c29651e5e161d23d1dc 100644 (file)
@@ -51,6 +51,7 @@ public:
                 const wxString& name = _T("wxSpinCtrl"));
 
     void SetValue(const wxString& text);
+    void SetSelection(long from, long to);
 
     virtual int GetValue() const;
     virtual void SetValue( int value );
index b02797c3e74a1b2483a96188815f4031d189ce26..f39e5184e632f7d2c3f69c29651e5e161d23d1dc 100644 (file)
@@ -51,6 +51,7 @@ public:
                 const wxString& name = _T("wxSpinCtrl"));
 
     void SetValue(const wxString& text);
+    void SetSelection(long from, long to);
 
     virtual int GetValue() const;
     virtual void SetValue( int value );
index e071efbce9a94a46406eaa9255424e3d98e6123c..ff4ee9faeb5008591cc8952dacb123278df4c998 100644 (file)
@@ -228,6 +228,19 @@ void wxSpinCtrl::SetValue( int value )
     GtkEnableEvents();
 }
 
+void wxSpinCtrl::SetSelection(long from, long to)
+{
+    // translate from wxWindows conventions to GTK+ ones: (-1, -1) means the
+    // entire range
+    if ( from == -1 && to == -1 )
+    {
+        from = 0;
+        to = INT_MAX;
+    }
+
+    gtk_editable_select_region( GTK_EDITABLE(m_widget), (gint)from, (gint)to );
+}
+
 void wxSpinCtrl::SetRange(int minVal, int maxVal)
 {
     wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") );
index e071efbce9a94a46406eaa9255424e3d98e6123c..ff4ee9faeb5008591cc8952dacb123278df4c998 100644 (file)
@@ -228,6 +228,19 @@ void wxSpinCtrl::SetValue( int value )
     GtkEnableEvents();
 }
 
+void wxSpinCtrl::SetSelection(long from, long to)
+{
+    // translate from wxWindows conventions to GTK+ ones: (-1, -1) means the
+    // entire range
+    if ( from == -1 && to == -1 )
+    {
+        from = 0;
+        to = INT_MAX;
+    }
+
+    gtk_editable_select_region( GTK_EDITABLE(m_widget), (gint)from, (gint)to );
+}
+
 void wxSpinCtrl::SetRange(int minVal, int maxVal)
 {
     wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") );