]> git.saurik.com Git - wxWidgets.git/blame - src/osx/textentry_osx.cpp
adapting inheritance to other osx ports
[wxWidgets.git] / src / osx / textentry_osx.cpp
CommitLineData
c84030e0
KO
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
b5b208a1 7// RCS-ID: $Id$
c84030e0
KO
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{
4275201b
SC
150 {
151 EventsSuppressor noevents(this);
152 GetTextPeer()->Remove( from , to );
153 }
ce00f59b 154
e567904a 155 SendTextUpdatedEventIfAllowed();
c84030e0
KO
156}
157
158void wxTextEntry::SetSelection(long from, long to)
159{
160 GetTextPeer()->SetSelection( from , to ) ;
161}
162
163void wxTextEntry::WriteText(const wxString& str)
164{
4275201b
SC
165 {
166 EventsSuppressor noevents(this);
167 GetTextPeer()->WriteText( str );
168 }
e567904a
VZ
169
170 SendTextUpdatedEventIfAllowed();
c84030e0
KO
171}
172
173void wxTextEntry::Clear()
174{
4275201b
SC
175 {
176 EventsSuppressor noevents(this);
177 GetTextPeer()->Clear();
178 }
e567904a
VZ
179
180 SendTextUpdatedEventIfAllowed();
c84030e0
KO
181}
182
183bool wxTextEntry::IsEditable() const
184{
185 return m_editable ;
186}
187
188// ----------------------------------------------------------------------------
189// Undo/redo
190// ----------------------------------------------------------------------------
191
192void wxTextEntry::Undo()
193{
194 if (CanUndo())
195 GetTextPeer()->Undo() ;
196}
197
198void wxTextEntry::Redo()
199{
200 if (CanRedo())
201 GetTextPeer()->Redo() ;
202}
203
204bool wxTextEntry::CanUndo() const
205{
206 if ( !IsEditable() )
207 return false ;
208
209 return GetTextPeer()->CanUndo() ;
210}
211
212bool wxTextEntry::CanRedo() const
213{
214 if ( !IsEditable() )
215 return false ;
216
217 return GetTextPeer()->CanRedo() ;
218}
219
220wxTextWidgetImpl * wxTextEntry::GetTextPeer() const
221{
005ac806
VZ
222 wxWindow * const win = const_cast<wxTextEntry *>(this)->GetEditableWindow();
223
224 return win ? dynamic_cast<wxTextWidgetImpl *>(win->GetPeer()) : NULL;
c84030e0 225}
005ac806 226
c84030e0 227#endif // wxUSE_TEXTCTRL