From 05060eeb83b10065edb0f94357102fb6b55cbb29 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 1 Jun 1999 11:10:17 +0000 Subject: [PATCH] Added wxTextCtrl::IsEditable(), GetSelection() and ShowPosition() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/textctrl.cpp | 25 ++++++++++++++++--------- src/gtk1/textctrl.cpp | 25 ++++++++++++++++--------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 73293accf3..a97f3bb552 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -693,9 +693,9 @@ void wxTextCtrl::SetSelection( long from, long to ) gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to ); } -void wxTextCtrl::ShowPosition( long WXUNUSED(pos) ) +void wxTextCtrl::ShowPosition( long pos ) { - wxFAIL_MSG( _T("wxTextCtrl::ShowPosition not implemented") ); + SetInsertionPoint( pos ); } long wxTextCtrl::GetInsertionPoint() const @@ -825,17 +825,24 @@ bool wxTextCtrl::CanRedo() const // selection. void wxTextCtrl::GetSelection(long* from, long* to) const { - // TODO - *from = 0; - *to = 0; - wxFAIL_MSG( _T("wxTextCtrl::GetSelection not implemented") ); + wxCHECK_RET( m_text != NULL, _T("invalid text ctrl") ); + + if (!(GTK_EDITABLE(m_text)->has_selection)) + { + if (from) *from = 0; + if (to) *to = 0; + return; + } + + if (from) *from = (long) GTK_EDITABLE(m_text)->selection_start_pos; + if (to) *to = (long) GTK_EDITABLE(m_text)->selection_end_pos; } bool wxTextCtrl::IsEditable() const { - // TODO - wxFAIL_MSG( _T("wxTextCtrl::IsEditable not implemented") ); - return FALSE; + wxCHECK_MSG( m_text != NULL, FALSE, _T("invalid text ctrl") ); + + return GTK_EDITABLE(m_text)->editable; } void wxTextCtrl::Clear() diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index 73293accf3..a97f3bb552 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -693,9 +693,9 @@ void wxTextCtrl::SetSelection( long from, long to ) gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to ); } -void wxTextCtrl::ShowPosition( long WXUNUSED(pos) ) +void wxTextCtrl::ShowPosition( long pos ) { - wxFAIL_MSG( _T("wxTextCtrl::ShowPosition not implemented") ); + SetInsertionPoint( pos ); } long wxTextCtrl::GetInsertionPoint() const @@ -825,17 +825,24 @@ bool wxTextCtrl::CanRedo() const // selection. void wxTextCtrl::GetSelection(long* from, long* to) const { - // TODO - *from = 0; - *to = 0; - wxFAIL_MSG( _T("wxTextCtrl::GetSelection not implemented") ); + wxCHECK_RET( m_text != NULL, _T("invalid text ctrl") ); + + if (!(GTK_EDITABLE(m_text)->has_selection)) + { + if (from) *from = 0; + if (to) *to = 0; + return; + } + + if (from) *from = (long) GTK_EDITABLE(m_text)->selection_start_pos; + if (to) *to = (long) GTK_EDITABLE(m_text)->selection_end_pos; } bool wxTextCtrl::IsEditable() const { - // TODO - wxFAIL_MSG( _T("wxTextCtrl::IsEditable not implemented") ); - return FALSE; + wxCHECK_MSG( m_text != NULL, FALSE, _T("invalid text ctrl") ); + + return GTK_EDITABLE(m_text)->editable; } void wxTextCtrl::Clear() -- 2.45.2