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