]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/osx/textentry_osx.cpp
Spell contributor name correctly.
[wxWidgets.git] / src / osx / textentry_osx.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/osx/textentry_osx.cpp
3// Purpose: wxTextEntry
4// Author: Stefan Csomor
5// Modified by: Kevin Ollivier
6// Created: 1998-01-01
7// RCS-ID: $Id: textctrl.cpp 54820 2008-07-29 20:04:11Z SC $
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#if wxUSE_TEXTCTRL
15
16#include "wx/textctrl.h"
17
18#ifndef WX_PRECOMP
19 #include "wx/intl.h"
20 #include "wx/app.h"
21 #include "wx/utils.h"
22 #include "wx/dc.h"
23 #include "wx/button.h"
24 #include "wx/menu.h"
25 #include "wx/settings.h"
26 #include "wx/msgdlg.h"
27 #include "wx/toplevel.h"
28#endif
29
30#ifdef __DARWIN__
31 #include <sys/types.h>
32 #include <sys/stat.h>
33#else
34 #include <stat.h>
35#endif
36
37#if wxUSE_STD_IOSTREAM
38 #if wxUSE_IOSTREAMH
39 #include <fstream.h>
40 #else
41 #include <fstream>
42 #endif
43#endif
44
45#include "wx/filefn.h"
46#include "wx/sysopt.h"
47#include "wx/thread.h"
48
49#include "wx/osx/private.h"
50
51wxString wxTextEntry::DoGetValue() const
52{
53 return GetTextPeer()->GetStringValue() ;
54}
55
56void wxTextEntry::GetSelection(long* from, long* to) const
57{
58 GetTextPeer()->GetSelection( from , to ) ;
59}
60
61void wxTextEntry::SetMaxLength(unsigned long len)
62{
63 m_maxLength = len ;
64}
65
66// Clipboard operations
67
68void wxTextEntry::Copy()
69{
70 if (CanCopy())
71 GetTextPeer()->Copy() ;
72}
73
74void wxTextEntry::Cut()
75{
76 if (CanCut())
77 GetTextPeer()->Cut() ;
78}
79
80void wxTextEntry::Paste()
81{
82 if (CanPaste())
83 GetTextPeer()->Paste() ;
84}
85
86bool wxTextEntry::CanCopy() const
87{
88 // Can copy if there's a selection
89 long from, to;
90 GetSelection( &from, &to );
91
92 return (from != to);
93}
94
95bool wxTextEntry::CanCut() const
96{
97 if ( !IsEditable() )
98 return false;
99
100 // Can cut if there's a selection
101 long from, to;
102 GetSelection( &from, &to );
103
104 return (from != to);
105}
106
107bool wxTextEntry::CanPaste() const
108{
109 if (!IsEditable())
110 return false;
111
112 return GetTextPeer()->CanPaste() ;
113}
114
115void wxTextEntry::SetEditable(bool editable)
116{
117 if ( editable != m_editable )
118 {
119 m_editable = editable ;
120 GetTextPeer()->SetEditable( editable ) ;
121 }
122}
123
124void wxTextEntry::SetInsertionPoint(long pos)
125{
126 SetSelection( pos , pos ) ;
127}
128
129void wxTextEntry::SetInsertionPointEnd()
130{
131 long pos = GetLastPosition();
132 SetInsertionPoint( pos );
133}
134
135long wxTextEntry::GetInsertionPoint() const
136{
137 long begin, end ;
138 GetSelection( &begin , &end ) ;
139
140 return begin ;
141}
142
143wxTextPos wxTextEntry::GetLastPosition() const
144{
145 return GetTextPeer()->GetLastPosition() ;
146}
147
148void wxTextEntry::Remove(long from, long to)
149{
150 GetTextPeer()->Remove( from , to ) ;
151
152 SendTextUpdatedEventIfAllowed();
153}
154
155void wxTextEntry::SetSelection(long from, long to)
156{
157 GetTextPeer()->SetSelection( from , to ) ;
158}
159
160void wxTextEntry::WriteText(const wxString& str)
161{
162 GetTextPeer()->WriteText( str ) ;
163
164 SendTextUpdatedEventIfAllowed();
165}
166
167void wxTextEntry::Clear()
168{
169 GetTextPeer()->Clear() ;
170
171 SendTextUpdatedEventIfAllowed();
172}
173
174bool wxTextEntry::IsEditable() const
175{
176 return m_editable ;
177}
178
179// ----------------------------------------------------------------------------
180// Undo/redo
181// ----------------------------------------------------------------------------
182
183void wxTextEntry::Undo()
184{
185 if (CanUndo())
186 GetTextPeer()->Undo() ;
187}
188
189void wxTextEntry::Redo()
190{
191 if (CanRedo())
192 GetTextPeer()->Redo() ;
193}
194
195bool wxTextEntry::CanUndo() const
196{
197 if ( !IsEditable() )
198 return false ;
199
200 return GetTextPeer()->CanUndo() ;
201}
202
203bool wxTextEntry::CanRedo() const
204{
205 if ( !IsEditable() )
206 return false ;
207
208 return GetTextPeer()->CanRedo() ;
209}
210
211wxTextWidgetImpl * wxTextEntry::GetTextPeer() const
212{
213 wxWindow * const win = const_cast<wxTextEntry *>(this)->GetEditableWindow();
214
215 return win ? dynamic_cast<wxTextWidgetImpl *>(win->GetPeer()) : NULL;
216}
217
218#endif // wxUSE_TEXTCTRL