]> git.saurik.com Git - wxWidgets.git/blob - src/osx/textentry_osx.cpp
non PCH compilation
[wxWidgets.git] / 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
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
51 wxString wxTextEntry::DoGetValue() const
52 {
53 return GetTextPeer()->GetStringValue() ;
54 }
55
56 void wxTextEntry::GetSelection(long* from, long* to) const
57 {
58 GetTextPeer()->GetSelection( from , to ) ;
59 }
60
61 void wxTextEntry::SetMaxLength(unsigned long len)
62 {
63 m_maxLength = len ;
64 }
65
66 // Clipboard operations
67
68 void wxTextEntry::Copy()
69 {
70 if (CanCopy())
71 GetTextPeer()->Copy() ;
72 }
73
74 void wxTextEntry::Cut()
75 {
76 if (CanCut())
77 GetTextPeer()->Cut() ;
78 }
79
80 void wxTextEntry::Paste()
81 {
82 if (CanPaste())
83 GetTextPeer()->Paste() ;
84 }
85
86 bool 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
95 bool 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
107 bool wxTextEntry::CanPaste() const
108 {
109 if (!IsEditable())
110 return false;
111
112 return GetTextPeer()->CanPaste() ;
113 }
114
115 void wxTextEntry::SetEditable(bool editable)
116 {
117 if ( editable != m_editable )
118 {
119 m_editable = editable ;
120 GetTextPeer()->SetEditable( editable ) ;
121 }
122 }
123
124 void wxTextEntry::SetInsertionPoint(long pos)
125 {
126 SetSelection( pos , pos ) ;
127 }
128
129 void wxTextEntry::SetInsertionPointEnd()
130 {
131 long pos = GetLastPosition();
132 SetInsertionPoint( pos );
133 }
134
135 long wxTextEntry::GetInsertionPoint() const
136 {
137 long begin, end ;
138 GetSelection( &begin , &end ) ;
139
140 return begin ;
141 }
142
143 wxTextPos wxTextEntry::GetLastPosition() const
144 {
145 return GetTextPeer()->GetLastPosition() ;
146 }
147
148 void wxTextEntry::Remove(long from, long to)
149 {
150 GetTextPeer()->Remove( from , to ) ;
151 }
152
153 void wxTextEntry::SetSelection(long from, long to)
154 {
155 GetTextPeer()->SetSelection( from , to ) ;
156 }
157
158 void wxTextEntry::WriteText(const wxString& str)
159 {
160 GetTextPeer()->WriteText( str ) ;
161 }
162
163 void wxTextEntry::Clear()
164 {
165 GetTextPeer()->Clear() ;
166 }
167
168 bool wxTextEntry::IsEditable() const
169 {
170 return m_editable ;
171 }
172
173 // ----------------------------------------------------------------------------
174 // Undo/redo
175 // ----------------------------------------------------------------------------
176
177 void wxTextEntry::Undo()
178 {
179 if (CanUndo())
180 GetTextPeer()->Undo() ;
181 }
182
183 void wxTextEntry::Redo()
184 {
185 if (CanRedo())
186 GetTextPeer()->Redo() ;
187 }
188
189 bool wxTextEntry::CanUndo() const
190 {
191 if ( !IsEditable() )
192 return false ;
193
194 return GetTextPeer()->CanUndo() ;
195 }
196
197 bool wxTextEntry::CanRedo() const
198 {
199 if ( !IsEditable() )
200 return false ;
201
202 return GetTextPeer()->CanRedo() ;
203 }
204
205 wxTextWidgetImpl * wxTextEntry::GetTextPeer() const
206 {
207 wxFAIL_MSG("You need to implement wxTextWidgetImpl* GetTextPeer() in your wxTextEntry subclass if you want to use the native impls of its methods.");
208 return NULL;
209 }
210 #endif // wxUSE_TEXTCTRL