]>
Commit | Line | Data |
---|---|---|
fb896a32 DE |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: cocoa/textctrl.mm | |
3 | // Purpose: wxTextCtrl | |
4 | // Author: David Elliott | |
5 | // Modified by: | |
6 | // Created: 2003/03/16 | |
7 | // RCS-ID: $Id: | |
8 | // Copyright: (c) 2003 David Elliott | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
449c5673 DE |
12 | #include "wx/wxprec.h" |
13 | #ifndef WX_PRECOMP | |
14 | #include "wx/app.h" | |
15 | #include "wx/textctrl.h" | |
16 | #endif //WX_PRECOMP | |
fb896a32 | 17 | |
7d27dcf9 DE |
18 | #include "wx/cocoa/string.h" |
19 | ||
7fc77f30 DE |
20 | #include "wx/cocoa/autorelease.h" |
21 | ||
fb896a32 DE |
22 | #import <Foundation/NSString.h> |
23 | #import <AppKit/NSTextField.h> | |
24 | ||
25 | IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl) | |
26 | BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) | |
27 | END_EVENT_TABLE() | |
28 | WX_IMPLEMENT_COCOA_OWNER(wxTextCtrl,NSTextField,NSControl,NSView) | |
29 | ||
30 | bool wxTextCtrl::Create(wxWindow *parent, wxWindowID winid, | |
31 | const wxString& value, | |
32 | const wxPoint& pos, | |
33 | const wxSize& size, | |
34 | long style, | |
35 | const wxValidator& validator, | |
36 | const wxString& name) | |
37 | { | |
7fc77f30 | 38 | wxAutoNSAutoreleasePool pool; |
fb896a32 DE |
39 | if(!CreateControl(parent,winid,pos,size,style,validator,name)) |
40 | return false; | |
41 | m_cocoaNSView = NULL; | |
9ba1d264 | 42 | SetNSTextField([[NSTextField alloc] initWithFrame:MakeDefaultNSRect(size)]); |
fb896a32 DE |
43 | [m_cocoaNSView release]; |
44 | [GetNSTextField() setStringValue:[NSString stringWithCString:value.c_str()]]; | |
45 | [GetNSControl() sizeToFit]; | |
9ba1d264 DE |
46 | NSRect currentFrame = [m_cocoaNSView frame]; |
47 | if(currentFrame.size.width < 70) | |
48 | { | |
49 | currentFrame.size.width = 70; | |
50 | [m_cocoaNSView setFrame:currentFrame]; | |
51 | } | |
fb896a32 DE |
52 | if(m_parent) |
53 | m_parent->CocoaAddChild(this); | |
9ba1d264 | 54 | SetInitialFrameRect(pos,size); |
fb896a32 DE |
55 | return true; |
56 | } | |
57 | ||
58 | wxTextCtrl::~wxTextCtrl() | |
59 | { | |
911e17c6 | 60 | DisassociateNSTextField(GetNSTextField()); |
fb896a32 DE |
61 | } |
62 | ||
63 | void wxTextCtrl::Cocoa_didChangeText(void) | |
64 | { | |
65 | } | |
66 | ||
67 | void wxTextCtrl::AppendText(wxString const&) | |
68 | { | |
69 | } | |
70 | ||
71 | void wxTextCtrl::SetEditable(bool) | |
72 | { | |
73 | } | |
74 | ||
3a9fa0d6 VZ |
75 | void wxTextCtrl::MarkDirty() |
76 | { | |
77 | } | |
78 | ||
fb896a32 DE |
79 | void wxTextCtrl::DiscardEdits() |
80 | { | |
81 | } | |
82 | ||
83 | void wxTextCtrl::SetSelection(long, long) | |
84 | { | |
85 | } | |
86 | ||
87 | void wxTextCtrl::ShowPosition(long) | |
88 | { | |
89 | } | |
90 | ||
91 | void wxTextCtrl::SetInsertionPoint(long) | |
92 | { | |
93 | } | |
94 | ||
95 | void wxTextCtrl::SetInsertionPointEnd() | |
96 | { | |
97 | } | |
98 | ||
99 | void wxTextCtrl::Cut() | |
100 | { | |
101 | } | |
102 | ||
103 | void wxTextCtrl::Copy() | |
104 | { | |
105 | } | |
106 | ||
107 | void wxTextCtrl::Redo() | |
108 | { | |
109 | } | |
110 | ||
111 | void wxTextCtrl::Undo() | |
112 | { | |
113 | } | |
114 | ||
115 | void wxTextCtrl::Clear() | |
116 | { | |
117 | } | |
118 | ||
119 | void wxTextCtrl::Paste() | |
120 | { | |
121 | } | |
122 | ||
123 | void wxTextCtrl::Remove(long, long) | |
124 | { | |
125 | } | |
126 | ||
127 | void wxTextCtrl::Replace(long, long, wxString const&) | |
128 | { | |
129 | } | |
130 | ||
7d27dcf9 | 131 | void wxTextCtrl::SetValue(wxString const& value) |
fb896a32 | 132 | { |
7fc77f30 | 133 | wxAutoNSAutoreleasePool pool; |
7d27dcf9 | 134 | [GetNSTextField() setStringValue: wxNSStringWithWxString(value)]; |
fb896a32 DE |
135 | } |
136 | ||
137 | void wxTextCtrl::WriteText(wxString const&) | |
138 | { | |
139 | } | |
140 | ||
141 | bool wxTextCtrl::IsEditable() const | |
142 | { | |
143 | return true; | |
144 | } | |
145 | ||
146 | bool wxTextCtrl::IsModified() const | |
147 | { | |
148 | return false; | |
149 | } | |
150 | ||
151 | wxString wxTextCtrl::GetLineText(long) const | |
152 | { | |
153 | return wxEmptyString; | |
154 | } | |
155 | ||
156 | void wxTextCtrl::GetSelection(long*, long*) const | |
157 | { | |
158 | } | |
159 | ||
160 | bool wxTextCtrl::PositionToXY(long, long*, long*) const | |
161 | { | |
162 | return false; | |
163 | } | |
164 | ||
165 | long wxTextCtrl::XYToPosition(long, long) const | |
166 | { | |
167 | return 0; | |
168 | } | |
169 | ||
170 | int wxTextCtrl::GetLineLength(long) const | |
171 | { | |
172 | return 0; | |
173 | } | |
174 | ||
175 | long wxTextCtrl::GetLastPosition() const | |
176 | { | |
177 | return 0; | |
178 | } | |
179 | ||
180 | int wxTextCtrl::GetNumberOfLines() const | |
181 | { | |
182 | return 0; | |
183 | } | |
184 | ||
185 | long wxTextCtrl::GetInsertionPoint() const | |
186 | { | |
187 | return 0; | |
188 | } | |
189 | ||
190 | bool wxTextCtrl::CanRedo() const | |
191 | { | |
192 | return false; | |
193 | } | |
194 | ||
195 | bool wxTextCtrl::CanUndo() const | |
196 | { | |
197 | return false; | |
198 | } | |
199 | ||
200 | wxString wxTextCtrl::GetValue() const | |
201 | { | |
7fc77f30 | 202 | wxAutoNSAutoreleasePool pool; |
7d27dcf9 | 203 | return wxString([[GetNSTextField() stringValue] lossyCString]); |
fb896a32 DE |
204 | } |
205 |