X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e567904ae6f502226659fac12f22b6a18beb2179..8a31648287be0ef976f133de2786b137f1e98340:/src/osx/textentry_osx.cpp diff --git a/src/osx/textentry_osx.cpp b/src/osx/textentry_osx.cpp index 2d9d79a0e2..d7175f8238 100644 --- a/src/osx/textentry_osx.cpp +++ b/src/osx/textentry_osx.cpp @@ -4,7 +4,7 @@ // Author: Stefan Csomor // Modified by: Kevin Ollivier // Created: 1998-01-01 -// RCS-ID: $Id: textctrl.cpp 54820 2008-07-29 20:04:11Z SC $ +// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -45,16 +45,33 @@ #include "wx/filefn.h" #include "wx/sysopt.h" #include "wx/thread.h" +#include "wx/textcompleter.h" #include "wx/osx/private.h" +wxTextEntry::wxTextEntry() +{ + m_completer = NULL; + m_editable = true; + m_maxLength = 0; +} + +wxTextEntry::~wxTextEntry() +{ + delete m_completer; +} + wxString wxTextEntry::DoGetValue() const { + wxCHECK_MSG( GetTextPeer(), wxString(), "Must create the control first" ); + return GetTextPeer()->GetStringValue() ; } void wxTextEntry::GetSelection(long* from, long* to) const { + wxCHECK_RET( GetTextPeer(), "Must create the control first" ); + GetTextPeer()->GetSelection( from , to ) ; } @@ -67,18 +84,24 @@ void wxTextEntry::SetMaxLength(unsigned long len) void wxTextEntry::Copy() { + wxCHECK_RET( GetTextPeer(), "Must create the control first" ); + if (CanCopy()) GetTextPeer()->Copy() ; } void wxTextEntry::Cut() { + wxCHECK_RET( GetTextPeer(), "Must create the control first" ); + if (CanCut()) GetTextPeer()->Cut() ; } void wxTextEntry::Paste() { + wxCHECK_RET( GetTextPeer(), "Must create the control first" ); + if (CanPaste()) GetTextPeer()->Paste() ; } @@ -109,16 +132,20 @@ bool wxTextEntry::CanPaste() const if (!IsEditable()) return false; + wxCHECK_MSG( GetTextPeer(), false, "Must create the control first" ); + return GetTextPeer()->CanPaste() ; } void wxTextEntry::SetEditable(bool editable) { - if ( editable != m_editable ) - { - m_editable = editable ; - GetTextPeer()->SetEditable( editable ) ; - } + if ( editable == m_editable ) + return; + + m_editable = editable ; + + wxCHECK_RET( GetTextPeer(), "Must create the control first" ); + GetTextPeer()->SetEditable( editable ) ; } void wxTextEntry::SetInsertionPoint(long pos) @@ -142,31 +169,50 @@ long wxTextEntry::GetInsertionPoint() const wxTextPos wxTextEntry::GetLastPosition() const { + wxCHECK_MSG( GetTextPeer(), -1, "Must create the control first" ); + return GetTextPeer()->GetLastPosition() ; } void wxTextEntry::Remove(long from, long to) { - GetTextPeer()->Remove( from , to ) ; + wxCHECK_RET( GetTextPeer(), "Must create the control first" ); + + { + EventsSuppressor noevents(this); + GetTextPeer()->Remove( from , to ); + } SendTextUpdatedEventIfAllowed(); } void wxTextEntry::SetSelection(long from, long to) { + wxCHECK_RET( GetTextPeer(), "Must create the control first" ); + GetTextPeer()->SetSelection( from , to ) ; } void wxTextEntry::WriteText(const wxString& str) { - GetTextPeer()->WriteText( str ) ; + wxCHECK_RET( GetTextPeer(), "Must create the control first" ); + + { + EventsSuppressor noevents(this); + GetTextPeer()->WriteText( str ); + } SendTextUpdatedEventIfAllowed(); } void wxTextEntry::Clear() { - GetTextPeer()->Clear() ; + wxCHECK_RET( GetTextPeer(), "Must create the control first" ); + + { + EventsSuppressor noevents(this); + GetTextPeer()->Clear(); + } SendTextUpdatedEventIfAllowed(); } @@ -182,12 +228,16 @@ bool wxTextEntry::IsEditable() const void wxTextEntry::Undo() { + wxCHECK_RET( GetTextPeer(), "Must create the control first" ); + if (CanUndo()) GetTextPeer()->Undo() ; } void wxTextEntry::Redo() { + wxCHECK_RET( GetTextPeer(), "Must create the control first" ); + if (CanRedo()) GetTextPeer()->Redo() ; } @@ -197,6 +247,8 @@ bool wxTextEntry::CanUndo() const if ( !IsEditable() ) return false ; + wxCHECK_MSG( GetTextPeer(), false, "Must create the control first" ); + return GetTextPeer()->CanUndo() ; } @@ -205,6 +257,8 @@ bool wxTextEntry::CanRedo() const if ( !IsEditable() ) return false ; + wxCHECK_MSG( GetTextPeer(), false, "Must create the control first" ); + return GetTextPeer()->CanRedo() ; } @@ -215,4 +269,23 @@ wxTextWidgetImpl * wxTextEntry::GetTextPeer() const return win ? dynamic_cast(win->GetPeer()) : NULL; } +// ---------------------------------------------------------------------------- +// Auto-completion +// ---------------------------------------------------------------------------- + +bool wxTextEntry::DoAutoCompleteStrings(const wxArrayString& choices) +{ + wxTextCompleterFixed * const completer = new wxTextCompleterFixed; + completer->SetCompletions(choices); + + return DoAutoCompleteCustom(completer); +} + +bool wxTextEntry::DoAutoCompleteCustom(wxTextCompleter *completer) +{ + m_completer = completer; + + return true; +} + #endif // wxUSE_TEXTCTRL