]>
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 | ||
b466e85a | 54 | WXCOCOAIMPL_COMMON_IMPLEMENTATION |
dbeddfb9 SC |
55 | |
56 | // use our common calls | |
57 | - (void) setTitle:(NSString *) title | |
58 | { | |
59 | [self setStringValue: title]; | |
60 | } | |
61 | ||
62 | @end | |
63 | ||
1e181c7a SC |
64 | wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w) |
65 | { | |
66 | } | |
67 | ||
68 | wxNSTextFieldControl::~wxNSTextFieldControl() | |
69 | { | |
70 | } | |
71 | ||
72 | wxString wxNSTextFieldControl::GetStringValue() const | |
73 | { | |
74 | wxCFStringRef cf( (CFStringRef) [[(wxNSTextField*) m_osxView stringValue] retain] ); | |
75 | return cf.AsString(m_wxPeer->GetFont().GetEncoding()); | |
76 | } | |
77 | void wxNSTextFieldControl::SetStringValue( const wxString &str) | |
78 | { | |
79 | [(wxNSTextField*) m_osxView setStringValue: wxCFStringRef( str , m_wxPeer->GetFont().GetEncoding() ).AsNSString()]; | |
80 | } | |
81 | void wxNSTextFieldControl::Copy() | |
82 | { | |
83 | } | |
84 | ||
85 | void wxNSTextFieldControl::Cut() | |
86 | { | |
87 | } | |
88 | ||
89 | void wxNSTextFieldControl::Paste() | |
90 | { | |
91 | } | |
92 | ||
93 | bool wxNSTextFieldControl::CanPaste() const | |
94 | { | |
95 | return false; | |
96 | } | |
97 | ||
98 | void wxNSTextFieldControl::SetEditable(bool editable) | |
99 | { | |
100 | } | |
101 | ||
102 | void wxNSTextFieldControl::GetSelection( long* from, long* to) const | |
103 | { | |
104 | } | |
105 | ||
106 | void wxNSTextFieldControl::SetSelection( long from , long to ) | |
107 | { | |
108 | } | |
109 | ||
110 | void wxNSTextFieldControl::WriteText(const wxString& str) | |
111 | { | |
112 | // temp hack to get logging working early | |
113 | wxString former = GetStringValue(); | |
114 | SetStringValue( former + str ); | |
115 | } | |
dbeddfb9 SC |
116 | |
117 | wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer, | |
118 | wxWindowMac* parent, | |
119 | wxWindowID id, | |
120 | const wxString& str, | |
121 | const wxPoint& pos, | |
122 | const wxSize& size, | |
123 | long style, | |
124 | long extraStyle) | |
125 | { | |
dbeddfb9 SC |
126 | NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; |
127 | wxNSTextField* v = [[wxNSTextField alloc] initWithFrame:r]; | |
b15f9375 SC |
128 | |
129 | if ( style & wxNO_BORDER ) | |
130 | { | |
131 | [v setBezeled:NO]; | |
132 | [v setBordered:NO]; | |
133 | } | |
dbeddfb9 SC |
134 | |
135 | //[v setBezeled:NO]; | |
136 | //[v setEditable:NO]; | |
137 | //[v setDrawsBackground:NO]; | |
138 | ||
139 | wxWidgetCocoaImpl* c = new wxNSTextFieldControl( wxpeer, v ); | |
140 | [v setImplementation:c]; | |
141 | return c; | |
142 | } | |
143 | ||
144 | ||
145 | #endif // wxUSE_TEXTCTRL |