]>
git.saurik.com Git - wxWidgets.git/blob - src/osx/textentry_osx.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/textentry_osx.cpp
3 // Purpose: wxTextEntry
4 // Author: Stefan Csomor
5 // Modified by: Kevin Ollivier
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #include "wx/textctrl.h"
23 #include "wx/button.h"
25 #include "wx/settings.h"
26 #include "wx/msgdlg.h"
27 #include "wx/toplevel.h"
31 #include <sys/types.h>
37 #if wxUSE_STD_IOSTREAM
45 #include "wx/filefn.h"
46 #include "wx/sysopt.h"
47 #include "wx/thread.h"
48 #include "wx/textcompleter.h"
50 #include "wx/osx/private.h"
52 wxTextEntry::wxTextEntry()
59 wxTextEntry::~wxTextEntry()
64 wxString
wxTextEntry::DoGetValue() const
66 return GetTextPeer()->GetStringValue() ;
69 void wxTextEntry::GetSelection(long* from
, long* to
) const
71 GetTextPeer()->GetSelection( from
, to
) ;
74 void wxTextEntry::SetMaxLength(unsigned long len
)
79 // Clipboard operations
81 void wxTextEntry::Copy()
84 GetTextPeer()->Copy() ;
87 void wxTextEntry::Cut()
90 GetTextPeer()->Cut() ;
93 void wxTextEntry::Paste()
96 GetTextPeer()->Paste() ;
99 bool wxTextEntry::CanCopy() const
101 // Can copy if there's a selection
103 GetSelection( &from
, &to
);
108 bool wxTextEntry::CanCut() const
113 // Can cut if there's a selection
115 GetSelection( &from
, &to
);
120 bool wxTextEntry::CanPaste() const
125 return GetTextPeer()->CanPaste() ;
128 void wxTextEntry::SetEditable(bool editable
)
130 if ( editable
!= m_editable
)
132 m_editable
= editable
;
133 GetTextPeer()->SetEditable( editable
) ;
137 void wxTextEntry::SetInsertionPoint(long pos
)
139 SetSelection( pos
, pos
) ;
142 void wxTextEntry::SetInsertionPointEnd()
144 long pos
= GetLastPosition();
145 SetInsertionPoint( pos
);
148 long wxTextEntry::GetInsertionPoint() const
151 GetSelection( &begin
, &end
) ;
156 wxTextPos
wxTextEntry::GetLastPosition() const
158 return GetTextPeer()->GetLastPosition() ;
161 void wxTextEntry::Remove(long from
, long to
)
164 EventsSuppressor
noevents(this);
165 GetTextPeer()->Remove( from
, to
);
168 SendTextUpdatedEventIfAllowed();
171 void wxTextEntry::SetSelection(long from
, long to
)
173 GetTextPeer()->SetSelection( from
, to
) ;
176 void wxTextEntry::WriteText(const wxString
& str
)
179 EventsSuppressor
noevents(this);
180 GetTextPeer()->WriteText( str
);
183 SendTextUpdatedEventIfAllowed();
186 void wxTextEntry::Clear()
189 EventsSuppressor
noevents(this);
190 GetTextPeer()->Clear();
193 SendTextUpdatedEventIfAllowed();
196 bool wxTextEntry::IsEditable() const
201 // ----------------------------------------------------------------------------
203 // ----------------------------------------------------------------------------
205 void wxTextEntry::Undo()
208 GetTextPeer()->Undo() ;
211 void wxTextEntry::Redo()
214 GetTextPeer()->Redo() ;
217 bool wxTextEntry::CanUndo() const
222 return GetTextPeer()->CanUndo() ;
225 bool wxTextEntry::CanRedo() const
230 return GetTextPeer()->CanRedo() ;
233 wxTextWidgetImpl
* wxTextEntry::GetTextPeer() const
235 wxWindow
* const win
= const_cast<wxTextEntry
*>(this)->GetEditableWindow();
237 return win
? dynamic_cast<wxTextWidgetImpl
*>(win
->GetPeer()) : NULL
;
240 // ----------------------------------------------------------------------------
242 // ----------------------------------------------------------------------------
244 bool wxTextEntry::DoAutoCompleteStrings(const wxArrayString
& choices
)
246 wxTextCompleterFixed
* const completer
= new wxTextCompleterFixed
;
247 completer
->SetCompletions(choices
);
249 return DoAutoCompleteCustom(completer
);
252 bool wxTextEntry::DoAutoCompleteCustom(wxTextCompleter
*completer
)
254 m_completer
= completer
;
259 #endif // wxUSE_TEXTCTRL