]>
Commit | Line | Data |
---|---|---|
0dbd6262 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: textctrl.h | |
3 | // Purpose: wxTextCtrl class | |
a31a5f85 | 4 | // Author: Stefan Csomor |
0dbd6262 | 5 | // Modified by: |
a31a5f85 | 6 | // Created: 1998-01-01 |
0dbd6262 | 7 | // RCS-ID: $Id$ |
a31a5f85 | 8 | // Copyright: (c) Stefan Csomor |
e40298d5 | 9 | // Licence: wxWindows licence |
0dbd6262 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_TEXTCTRL_H_ | |
13 | #define _WX_TEXTCTRL_H_ | |
14 | ||
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
0dbd6262 SC |
16 | #pragma interface "textctrl.h" |
17 | #endif | |
18 | ||
19 | #include "wx/control.h" | |
20 | ||
c4e41ce3 | 21 | WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr; |
0dbd6262 SC |
22 | |
23 | // Single-line text item | |
05adb9d2 | 24 | class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase |
0dbd6262 SC |
25 | { |
26 | DECLARE_DYNAMIC_CLASS(wxTextCtrl) | |
27 | ||
28 | public: | |
29 | // creation | |
30 | // -------- | |
1fa29bdc | 31 | wxTextCtrl() { Init(); } |
8481948e | 32 | ~wxTextCtrl(); |
1fa29bdc VZ |
33 | wxTextCtrl(wxWindow *parent, wxWindowID id, |
34 | const wxString& value = wxEmptyString, | |
35 | const wxPoint& pos = wxDefaultPosition, | |
36 | const wxSize& size = wxDefaultSize, long style = 0, | |
37 | const wxValidator& validator = wxDefaultValidator, | |
38 | const wxString& name = wxTextCtrlNameStr) | |
0dbd6262 | 39 | { |
1fa29bdc VZ |
40 | Init(); |
41 | ||
42 | Create(parent, id, value, pos, size, style, validator, name); | |
0dbd6262 SC |
43 | } |
44 | ||
45 | bool Create(wxWindow *parent, wxWindowID id, | |
46 | const wxString& value = wxEmptyString, | |
47 | const wxPoint& pos = wxDefaultPosition, | |
48 | const wxSize& size = wxDefaultSize, long style = 0, | |
49 | const wxValidator& validator = wxDefaultValidator, | |
50 | const wxString& name = wxTextCtrlNameStr); | |
51 | ||
52 | // accessors | |
53 | // --------- | |
54 | virtual wxString GetValue() const ; | |
55 | virtual void SetValue(const wxString& value); | |
56 | ||
57 | virtual int GetLineLength(long lineNo) const; | |
58 | virtual wxString GetLineText(long lineNo) const; | |
59 | virtual int GetNumberOfLines() const; | |
60 | ||
05adb9d2 SC |
61 | virtual bool IsModified() const; |
62 | virtual bool IsEditable() const; | |
63 | ||
64 | // If the return values from and to are the same, there is no selection. | |
65 | virtual void GetSelection(long* from, long* to) const; | |
66 | ||
0dbd6262 SC |
67 | // operations |
68 | // ---------- | |
05adb9d2 SC |
69 | |
70 | // editing | |
71 | ||
72 | virtual void Clear(); | |
73 | virtual void Replace(long from, long to, const wxString& value); | |
74 | virtual void Remove(long from, long to); | |
75 | ||
76 | // load the controls contents from the file | |
77 | virtual bool LoadFile(const wxString& file); | |
78 | ||
3a9fa0d6 VZ |
79 | // sets/clears the dirty flag |
80 | virtual void MarkDirty(); | |
05adb9d2 SC |
81 | virtual void DiscardEdits(); |
82 | ||
f8d5f1e2 SC |
83 | // set the max number of characters which may be entered in a single line |
84 | // text control | |
85 | virtual void SetMaxLength(unsigned long len) ; | |
86 | ||
87 | // text control under some platforms supports the text styles: these | |
88 | // methods allow to apply the given text style to the given selection or to | |
89 | // set/get the style which will be used for all appended text | |
90 | virtual bool SetStyle(long start, long end, const wxTextAttr& style); | |
91 | virtual bool SetDefaultStyle(const wxTextAttr& style); | |
92 | ||
05adb9d2 SC |
93 | // writing text inserts it at the current position, appending always |
94 | // inserts it at the end | |
95 | virtual void WriteText(const wxString& text); | |
96 | virtual void AppendText(const wxString& text); | |
97 | ||
98 | // translate between the position (which is just an index in the text ctrl | |
99 | // considering all its contents as a single strings) and (x, y) coordinates | |
100 | // which represent column and line. | |
101 | virtual long XYToPosition(long x, long y) const; | |
102 | virtual bool PositionToXY(long pos, long *x, long *y) const; | |
103 | ||
104 | virtual void ShowPosition(long pos); | |
105 | ||
0dbd6262 SC |
106 | // Clipboard operations |
107 | virtual void Copy(); | |
108 | virtual void Cut(); | |
109 | virtual void Paste(); | |
110 | ||
05adb9d2 SC |
111 | virtual bool CanCopy() const; |
112 | virtual bool CanCut() const; | |
113 | virtual bool CanPaste() const; | |
114 | ||
115 | // Undo/redo | |
116 | virtual void Undo(); | |
117 | virtual void Redo(); | |
118 | ||
119 | virtual bool CanUndo() const; | |
120 | virtual bool CanRedo() const; | |
121 | ||
122 | // Insertion point | |
0dbd6262 SC |
123 | virtual void SetInsertionPoint(long pos); |
124 | virtual void SetInsertionPointEnd(); | |
05adb9d2 SC |
125 | virtual long GetInsertionPoint() const; |
126 | virtual long GetLastPosition() const; | |
127 | ||
0dbd6262 SC |
128 | virtual void SetSelection(long from, long to); |
129 | virtual void SetEditable(bool editable); | |
0dbd6262 | 130 | |
05adb9d2 SC |
131 | // Implementation from now on |
132 | // -------------------------- | |
133 | ||
134 | // Implementation | |
135 | // -------------- | |
136 | virtual void Command(wxCommandEvent& event); | |
137 | ||
138 | virtual bool AcceptsFocus() const; | |
139 | ||
140 | // callbacks | |
141 | void OnDropFiles(wxDropFilesEvent& event); | |
142 | void OnChar(wxKeyEvent& event); // Process 'enter' if required | |
143 | ||
144 | void OnCut(wxCommandEvent& event); | |
145 | void OnCopy(wxCommandEvent& event); | |
146 | void OnPaste(wxCommandEvent& event); | |
147 | void OnUndo(wxCommandEvent& event); | |
148 | void OnRedo(wxCommandEvent& event); | |
149 | ||
150 | void OnUpdateCut(wxUpdateUIEvent& event); | |
151 | void OnUpdateCopy(wxUpdateUIEvent& event); | |
152 | void OnUpdatePaste(wxUpdateUIEvent& event); | |
153 | void OnUpdateUndo(wxUpdateUIEvent& event); | |
154 | void OnUpdateRedo(wxUpdateUIEvent& event); | |
155 | ||
e40298d5 | 156 | virtual bool MacCanFocus() const { return true ; } |
2b5f62a0 VZ |
157 | virtual bool MacSetupCursor( const wxPoint& pt ) ; |
158 | ||
e40298d5 JS |
159 | virtual void MacSuperShown( bool show ) ; |
160 | virtual bool Show(bool show = TRUE) ; | |
6fda4e7a | 161 | |
0dbd6262 | 162 | protected: |
1fa29bdc VZ |
163 | // common part of all ctors |
164 | void Init(); | |
165 | ||
05adb9d2 | 166 | virtual wxSize DoGetBestSize() const; |
8481948e SC |
167 | |
168 | bool m_editable ; | |
1fa29bdc VZ |
169 | |
170 | // flag is set to true when the user edits the controls contents | |
171 | bool m_dirty; | |
172 | ||
8481948e SC |
173 | // one of the following objects is used for representation, the other one is NULL |
174 | void* m_macTE ; | |
175 | void* m_macTXN ; | |
176 | void* m_macTXNvars ; | |
177 | bool m_macUsesTXN ; | |
f8d5f1e2 | 178 | unsigned long m_maxLength ; |
0dbd6262 SC |
179 | |
180 | DECLARE_EVENT_TABLE() | |
181 | }; | |
182 | ||
183 | #endif | |
184 | // _WX_TEXTCTRL_H_ |