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