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