]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/textctrl.mm
Implement SetValue() and GetValue()
[wxWidgets.git] / src / cocoa / textctrl.mm
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
12 #include "wx/app.h"
13 #include "wx/textctrl.h"
14
15 #include "wx/cocoa/string.h"
16
17 #import <Foundation/NSString.h>
18 #import <AppKit/NSTextField.h>
19
20 IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
21 BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
22 END_EVENT_TABLE()
23 WX_IMPLEMENT_COCOA_OWNER(wxTextCtrl,NSTextField,NSControl,NSView)
24
25 bool wxTextCtrl::Create(wxWindow *parent, wxWindowID winid,
26 const wxString& value,
27 const wxPoint& pos,
28 const wxSize& size,
29 long style,
30 const wxValidator& validator,
31 const wxString& name)
32 {
33 if(!CreateControl(parent,winid,pos,size,style,validator,name))
34 return false;
35 m_cocoaNSView = NULL;
36 SetNSTextField([[NSTextField alloc] initWithFrame:NSMakeRect(0,0,30,30)]);
37 [m_cocoaNSView release];
38 [GetNSTextField() setStringValue:[NSString stringWithCString:value.c_str()]];
39 [GetNSControl() sizeToFit];
40 if(m_parent)
41 m_parent->CocoaAddChild(this);
42 return true;
43 }
44
45 wxTextCtrl::~wxTextCtrl()
46 {
47 CocoaRemoveFromParent();
48 SetNSTextField(NULL);
49 }
50
51 void wxTextCtrl::Cocoa_didChangeText(void)
52 {
53 }
54
55 void wxTextCtrl::AppendText(wxString const&)
56 {
57 }
58
59 void wxTextCtrl::SetEditable(bool)
60 {
61 }
62
63 void wxTextCtrl::DiscardEdits()
64 {
65 }
66
67 void wxTextCtrl::SetSelection(long, long)
68 {
69 }
70
71 void wxTextCtrl::ShowPosition(long)
72 {
73 }
74
75 void wxTextCtrl::SetInsertionPoint(long)
76 {
77 }
78
79 void wxTextCtrl::SetInsertionPointEnd()
80 {
81 }
82
83 void wxTextCtrl::Cut()
84 {
85 }
86
87 void wxTextCtrl::Copy()
88 {
89 }
90
91 void wxTextCtrl::Redo()
92 {
93 }
94
95 void wxTextCtrl::Undo()
96 {
97 }
98
99 void wxTextCtrl::Clear()
100 {
101 }
102
103 void wxTextCtrl::Paste()
104 {
105 }
106
107 void wxTextCtrl::Remove(long, long)
108 {
109 }
110
111 void wxTextCtrl::Replace(long, long, wxString const&)
112 {
113 }
114
115 void wxTextCtrl::SetValue(wxString const& value)
116 {
117 [GetNSTextField() setStringValue: wxNSStringWithWxString(value)];
118 }
119
120 void wxTextCtrl::WriteText(wxString const&)
121 {
122 }
123
124 bool wxTextCtrl::IsEditable() const
125 {
126 return true;
127 }
128
129 bool wxTextCtrl::IsModified() const
130 {
131 return false;
132 }
133
134 wxString wxTextCtrl::GetLineText(long) const
135 {
136 return wxEmptyString;
137 }
138
139 void wxTextCtrl::GetSelection(long*, long*) const
140 {
141 }
142
143 bool wxTextCtrl::PositionToXY(long, long*, long*) const
144 {
145 return false;
146 }
147
148 long wxTextCtrl::XYToPosition(long, long) const
149 {
150 return 0;
151 }
152
153 int wxTextCtrl::GetLineLength(long) const
154 {
155 return 0;
156 }
157
158 long wxTextCtrl::GetLastPosition() const
159 {
160 return 0;
161 }
162
163 int wxTextCtrl::GetNumberOfLines() const
164 {
165 return 0;
166 }
167
168 long wxTextCtrl::GetInsertionPoint() const
169 {
170 return 0;
171 }
172
173 bool wxTextCtrl::CanRedo() const
174 {
175 return false;
176 }
177
178 bool wxTextCtrl::CanUndo() const
179 {
180 return false;
181 }
182
183 wxString wxTextCtrl::GetValue() const
184 {
185 return wxString([[GetNSTextField() stringValue] lossyCString]);
186 }
187