]>
Commit | Line | Data |
---|---|---|
dbeddfb9 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: src/osx/cocoa/textctrl.mm | |
3 | // Purpose: wxTextCtrl | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: Ryan Norton (MLTE GetLineLength and GetLineText) | |
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" | |
1e181c7a | 50 | #include "wx/osx/cocoa/private/textimpl.h" |
dbeddfb9 SC |
51 | |
52 | @implementation wxNSTextField | |
53 | ||
54 | - (void)setImplementation: (wxWidgetImpl *) theImplementation | |
55 | { | |
56 | impl = theImplementation; | |
57 | } | |
58 | ||
59 | - (wxWidgetImpl*) implementation | |
60 | { | |
61 | return impl; | |
62 | } | |
63 | ||
64 | - (BOOL) isFlipped | |
65 | { | |
66 | return YES; | |
67 | } | |
68 | ||
69 | // use our common calls | |
70 | - (void) setTitle:(NSString *) title | |
71 | { | |
72 | [self setStringValue: title]; | |
73 | } | |
74 | ||
75 | @end | |
76 | ||
1e181c7a SC |
77 | wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w) |
78 | { | |
79 | } | |
80 | ||
81 | wxNSTextFieldControl::~wxNSTextFieldControl() | |
82 | { | |
83 | } | |
84 | ||
85 | wxString wxNSTextFieldControl::GetStringValue() const | |
86 | { | |
87 | wxCFStringRef cf( (CFStringRef) [[(wxNSTextField*) m_osxView stringValue] retain] ); | |
88 | return cf.AsString(m_wxPeer->GetFont().GetEncoding()); | |
89 | } | |
90 | void wxNSTextFieldControl::SetStringValue( const wxString &str) | |
91 | { | |
92 | [(wxNSTextField*) m_osxView setStringValue: wxCFStringRef( str , m_wxPeer->GetFont().GetEncoding() ).AsNSString()]; | |
93 | } | |
94 | void wxNSTextFieldControl::Copy() | |
95 | { | |
96 | } | |
97 | ||
98 | void wxNSTextFieldControl::Cut() | |
99 | { | |
100 | } | |
101 | ||
102 | void wxNSTextFieldControl::Paste() | |
103 | { | |
104 | } | |
105 | ||
106 | bool wxNSTextFieldControl::CanPaste() const | |
107 | { | |
108 | return false; | |
109 | } | |
110 | ||
111 | void wxNSTextFieldControl::SetEditable(bool editable) | |
112 | { | |
113 | } | |
114 | ||
115 | void wxNSTextFieldControl::GetSelection( long* from, long* to) const | |
116 | { | |
117 | } | |
118 | ||
119 | void wxNSTextFieldControl::SetSelection( long from , long to ) | |
120 | { | |
121 | } | |
122 | ||
123 | void wxNSTextFieldControl::WriteText(const wxString& str) | |
124 | { | |
125 | // temp hack to get logging working early | |
126 | wxString former = GetStringValue(); | |
127 | SetStringValue( former + str ); | |
128 | } | |
dbeddfb9 SC |
129 | |
130 | wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer, | |
131 | wxWindowMac* parent, | |
132 | wxWindowID id, | |
133 | const wxString& str, | |
134 | const wxPoint& pos, | |
135 | const wxSize& size, | |
136 | long style, | |
137 | long extraStyle) | |
138 | { | |
dbeddfb9 SC |
139 | NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; |
140 | wxNSTextField* v = [[wxNSTextField alloc] initWithFrame:r]; | |
b15f9375 SC |
141 | |
142 | if ( style & wxNO_BORDER ) | |
143 | { | |
144 | [v setBezeled:NO]; | |
145 | [v setBordered:NO]; | |
146 | } | |
dbeddfb9 SC |
147 | |
148 | //[v setBezeled:NO]; | |
149 | //[v setEditable:NO]; | |
150 | //[v setDrawsBackground:NO]; | |
151 | ||
152 | wxWidgetCocoaImpl* c = new wxNSTextFieldControl( wxpeer, v ); | |
153 | [v setImplementation:c]; | |
154 | return c; | |
155 | } | |
156 | ||
157 | ||
158 | #endif // wxUSE_TEXTCTRL |