]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/textctrl.h
cleanup
[wxWidgets.git] / include / wx / mac / carbon / textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/textctrl.h
3 // Purpose: wxTextCtrl class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TEXTCTRL_H_
13 #define _WX_TEXTCTRL_H_
14
15 #if wxUSE_SYSTEM_OPTIONS
16 // set this to 'true' if you want to use the 'classic' MLTE-based implementation
17 // instead of the HIView-based implementation in 10.3 and upwards, the former
18 // has more features (backgrounds etc.), but may show redraw artefacts and other
19 // problems depending on your usage; hence, the default is 'false'.
20 #define wxMAC_TEXTCONTROL_USE_MLTE wxT("mac.textcontrol-use-mlte")
21 #endif
22
23 #include "wx/control.h"
24 #include "wx/textctrl.h"
25
26 class wxMacTextControl;
27
28
29 class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase
30 {
31 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
32
33 public:
34 wxTextCtrl()
35 { Init(); }
36
37 wxTextCtrl(wxWindow *parent,
38 wxWindowID id,
39 const wxString& value = wxEmptyString,
40 const wxPoint& pos = wxDefaultPosition,
41 const wxSize& size = wxDefaultSize,
42 long style = 0,
43 const wxValidator& validator = wxDefaultValidator,
44 const wxString& name = wxTextCtrlNameStr)
45 {
46 Init();
47 Create(parent, id, value, pos, size, style, validator, name);
48 }
49
50 virtual ~wxTextCtrl();
51
52 bool Create(wxWindow *parent,
53 wxWindowID id,
54 const wxString& value = wxEmptyString,
55 const wxPoint& pos = wxDefaultPosition,
56 const wxSize& size = wxDefaultSize,
57 long style = 0,
58 const wxValidator& validator = wxDefaultValidator,
59 const wxString& name = wxTextCtrlNameStr);
60
61 // accessors
62 // ---------
63 virtual wxString GetValue() const;
64 virtual void SetValue(const wxString& value);
65
66 virtual int GetLineLength(long lineNo) const;
67 virtual wxString GetLineText(long lineNo) const;
68 virtual int GetNumberOfLines() const;
69
70 virtual bool IsModified() const;
71 virtual bool IsEditable() const;
72
73 // If the return values from and to are the same, there is no selection.
74 virtual void GetSelection(long* from, long* to) const;
75
76 // operations
77 // ----------
78
79 // editing
80 virtual void Clear();
81 virtual void Replace(long from, long to, const wxString& value);
82 virtual void Remove(long from, long to);
83
84 // load the controls contents from the file
85 virtual bool LoadFile(const wxString& file);
86 virtual bool LoadFile(const wxString& file, int WXUNUSED(fileType)) { return LoadFile(file); }
87
88 // sets/clears the dirty flag
89 virtual void MarkDirty();
90 virtual void DiscardEdits();
91
92 // set the max number of characters which may be entered
93 // in a single line text control
94 virtual void SetMaxLength(unsigned long len);
95
96 // text control under some platforms supports the text styles: these
97 // methods apply the given text style to the given selection or to
98 // set/get the style which will be used for all appended text
99 virtual bool SetFont( const wxFont &font );
100 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
101 virtual bool SetDefaultStyle(const wxTextAttr& style);
102
103 // writing text inserts it at the current position;
104 // appending always inserts it at the end
105 virtual void WriteText(const wxString& text);
106 virtual void AppendText(const wxString& text);
107
108 // translate between the position (which is just an index into the textctrl
109 // considering all its contents as a single strings) and (x, y) coordinates
110 // which represent column and line.
111 virtual long XYToPosition(long x, long y) const;
112 virtual bool PositionToXY(long pos, long *x, long *y) const;
113
114 virtual void ShowPosition(long pos);
115
116 // Clipboard operations
117 virtual void Copy();
118 virtual void Cut();
119 virtual void Paste();
120
121 virtual bool CanCopy() const;
122 virtual bool CanCut() const;
123 virtual bool CanPaste() const;
124
125 // Undo/redo
126 virtual void Undo();
127 virtual void Redo();
128
129 virtual bool CanUndo() const;
130 virtual bool CanRedo() const;
131
132 // Insertion point
133 virtual void SetInsertionPoint(long pos);
134 virtual void SetInsertionPointEnd();
135 virtual long GetInsertionPoint() const;
136 virtual wxTextPos GetLastPosition() const;
137
138 virtual void SetSelection(long from, long to);
139 virtual void SetEditable(bool editable);
140
141 // Implementation
142 // --------------
143 virtual void Command(wxCommandEvent& event);
144
145 virtual bool AcceptsFocus() const;
146
147 // callbacks
148 void OnDropFiles(wxDropFilesEvent& event);
149 void OnChar(wxKeyEvent& event); // Process 'enter' if required
150
151 void OnCut(wxCommandEvent& event);
152 void OnCopy(wxCommandEvent& event);
153 void OnPaste(wxCommandEvent& event);
154 void OnUndo(wxCommandEvent& event);
155 void OnRedo(wxCommandEvent& event);
156 void OnDelete(wxCommandEvent& event);
157 void OnSelectAll(wxCommandEvent& event);
158
159 void OnUpdateCut(wxUpdateUIEvent& event);
160 void OnUpdateCopy(wxUpdateUIEvent& event);
161 void OnUpdatePaste(wxUpdateUIEvent& event);
162 void OnUpdateUndo(wxUpdateUIEvent& event);
163 void OnUpdateRedo(wxUpdateUIEvent& event);
164 void OnUpdateDelete(wxUpdateUIEvent& event);
165 void OnUpdateSelectAll(wxUpdateUIEvent& event);
166
167 void OnEraseBackground(wxEraseEvent& event);
168 void OnContextMenu(wxContextMenuEvent& event);
169
170 virtual bool MacCanFocus() const
171 { return true; }
172
173 virtual bool MacSetupCursor( const wxPoint& pt );
174
175 virtual void MacVisibilityChanged();
176 virtual void MacEnabledStateChanged();
177 virtual void MacSuperChangedPosition();
178
179 #ifndef __WXMAC_OSX__
180 virtual void MacControlUserPaneDrawProc(wxInt16 part);
181 virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y);
182 virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc);
183 virtual void MacControlUserPaneIdleProc();
184 virtual wxInt16 MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers);
185 virtual void MacControlUserPaneActivateProc(bool activating);
186 virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action);
187 virtual void MacControlUserPaneBackgroundProc(void* info);
188 #endif
189
190 wxMacTextControl * GetPeer() const
191 { return (wxMacTextControl*) m_peer; }
192
193 protected:
194 // common part of all ctors
195 void Init();
196
197 virtual wxSize DoGetBestSize() const;
198
199 bool m_editable;
200
201 // flag is set to true when the user edits the controls contents
202 bool m_dirty;
203
204 // need to make this public because of the current implementation via callbacks
205 unsigned long m_maxLength;
206
207 bool GetTriggerOnSetValue() const
208 {
209 return m_triggerOnSetValue;
210 }
211
212 void SetTriggerOnSetValue(bool trigger)
213 {
214 m_triggerOnSetValue = trigger;
215 }
216
217 bool m_triggerOnSetValue ;
218
219 private :
220 wxMenu *m_privateContextMenu;
221
222 DECLARE_EVENT_TABLE()
223 };
224
225 #endif // _WX_TEXTCTRL_H_