From f8f9ec5563b78655cfb49f501f0fda306e831642 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 Jan 2004 15:20:34 +0000 Subject: [PATCH] implemented SetSelection git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25308 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/spinctrl.h | 1 + include/wx/gtk1/spinctrl.h | 1 + src/gtk/spinctrl.cpp | 13 +++++++++++++ src/gtk1/spinctrl.cpp | 13 +++++++++++++ 4 files changed, 28 insertions(+) diff --git a/include/wx/gtk/spinctrl.h b/include/wx/gtk/spinctrl.h index b02797c3e7..f39e5184e6 100644 --- a/include/wx/gtk/spinctrl.h +++ b/include/wx/gtk/spinctrl.h @@ -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 ); diff --git a/include/wx/gtk1/spinctrl.h b/include/wx/gtk1/spinctrl.h index b02797c3e7..f39e5184e6 100644 --- a/include/wx/gtk1/spinctrl.h +++ b/include/wx/gtk1/spinctrl.h @@ -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 ); diff --git a/src/gtk/spinctrl.cpp b/src/gtk/spinctrl.cpp index e071efbce9..ff4ee9faeb 100644 --- a/src/gtk/spinctrl.cpp +++ b/src/gtk/spinctrl.cpp @@ -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") ); diff --git a/src/gtk1/spinctrl.cpp b/src/gtk1/spinctrl.cpp index e071efbce9..ff4ee9faeb 100644 --- a/src/gtk1/spinctrl.cpp +++ b/src/gtk1/spinctrl.cpp @@ -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") ); -- 2.47.2