]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: textctrl.h | |
3 | // Purpose: wxTextCtrl class | |
d90895ac | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
d90895ac | 6 | // Created: 10/17/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
d90895ac DW |
8 | // Copyright: (c) David Webster |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_TEXTCTRL_H_ | |
13 | #define _WX_TEXTCTRL_H_ | |
14 | ||
d90895ac DW |
15 | class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase |
16 | { | |
17 | public: | |
18 | // creation | |
19 | // -------- | |
20 | ||
21 | wxTextCtrl(); | |
22 | wxTextCtrl(wxWindow *parent, wxWindowID id, | |
23 | const wxString& value = wxEmptyString, | |
24 | const wxPoint& pos = wxDefaultPosition, | |
25 | const wxSize& size = wxDefaultSize, | |
26 | long style = 0, | |
27 | const wxValidator& validator = wxDefaultValidator, | |
28 | const wxString& name = wxTextCtrlNameStr) | |
29 | { | |
30 | Create(parent, id, value, pos, size, style, validator, name); | |
31 | } | |
32 | ||
33 | bool Create(wxWindow *parent, wxWindowID id, | |
34 | const wxString& value = wxEmptyString, | |
35 | const wxPoint& pos = wxDefaultPosition, | |
36 | const wxSize& size = wxDefaultSize, | |
37 | long style = 0, | |
38 | const wxValidator& validator = wxDefaultValidator, | |
39 | const wxString& name = wxTextCtrlNameStr); | |
40 | ||
41 | // implement base class pure virtuals | |
42 | // ---------------------------------- | |
43 | ||
44 | virtual wxString GetValue() const; | |
45 | virtual void SetValue(const wxString& value); | |
46 | ||
47 | virtual int GetLineLength(long lineNo) const; | |
48 | virtual wxString GetLineText(long lineNo) const; | |
49 | virtual int GetNumberOfLines() const; | |
50 | ||
51 | virtual bool IsModified() const; | |
52 | virtual bool IsEditable() const; | |
53 | ||
54 | // If the return values from and to are the same, there is no selection. | |
55 | virtual void GetSelection(long* from, long* to) const; | |
56 | ||
57 | // operations | |
58 | // ---------- | |
59 | ||
60 | // editing | |
61 | virtual void Clear(); | |
62 | virtual void Replace(long from, long to, const wxString& value); | |
63 | virtual void Remove(long from, long to); | |
64 | ||
65 | // load the controls contents from the file | |
66 | virtual bool LoadFile(const wxString& file); | |
67 | ||
68 | // clears the dirty flag | |
69 | virtual void DiscardEdits(); | |
70 | ||
71 | // writing text inserts it at the current position, appending always | |
72 | // inserts it at the end | |
73 | virtual void WriteText(const wxString& text); | |
74 | virtual void AppendText(const wxString& text); | |
75 | ||
76 | // translate between the position (which is just an index in the text ctrl | |
77 | // considering all its contents as a single strings) and (x, y) coordinates | |
78 | // which represent column and line. | |
79 | virtual long XYToPosition(long x, long y) const; | |
80 | virtual bool PositionToXY(long pos, long *x, long *y) const; | |
81 | ||
82 | virtual void ShowPosition(long pos); | |
83 | ||
84 | // Clipboard operations | |
85 | virtual void Copy(); | |
86 | virtual void Cut(); | |
87 | virtual void Paste(); | |
88 | ||
89 | virtual bool CanCopy() const; | |
90 | virtual bool CanCut() const; | |
91 | virtual bool CanPaste() const; | |
92 | ||
93 | // Undo/redo | |
94 | virtual void Undo(); | |
95 | virtual void Redo(); | |
96 | ||
97 | virtual bool CanUndo() const; | |
98 | virtual bool CanRedo() const; | |
99 | ||
100 | // Insertion point | |
101 | virtual void SetInsertionPoint(long pos); | |
102 | virtual void SetInsertionPointEnd(); | |
103 | virtual long GetInsertionPoint() const; | |
104 | virtual long GetLastPosition() const; | |
105 | ||
106 | virtual void SetSelection(long from, long to); | |
107 | virtual void SetEditable(bool editable); | |
108 | ||
109 | // Implementation from now on | |
110 | // -------------------------- | |
111 | ||
112 | virtual void Command(wxCommandEvent& event); | |
113 | virtual bool OS2Command(WXUINT param, WXWORD id); | |
114 | ||
115 | virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, | |
116 | WXUINT message, WXWPARAM wParam, | |
117 | WXLPARAM lParam); | |
118 | ||
119 | virtual void AdoptAttributesFromHWND(); | |
120 | virtual void SetupColours(); | |
121 | ||
122 | virtual bool AcceptsFocus() const; | |
123 | ||
124 | // callbacks | |
125 | void OnDropFiles(wxDropFilesEvent& event); | |
126 | void OnChar(wxKeyEvent& event); // Process 'enter' if required | |
0e320a79 | 127 | |
d90895ac DW |
128 | void OnCut(wxCommandEvent& event); |
129 | void OnCopy(wxCommandEvent& event); | |
130 | void OnPaste(wxCommandEvent& event); | |
131 | void OnUndo(wxCommandEvent& event); | |
132 | void OnRedo(wxCommandEvent& event); | |
0e320a79 | 133 | |
d90895ac DW |
134 | void OnUpdateCut(wxUpdateUIEvent& event); |
135 | void OnUpdateCopy(wxUpdateUIEvent& event); | |
136 | void OnUpdatePaste(wxUpdateUIEvent& event); | |
137 | void OnUpdateUndo(wxUpdateUIEvent& event); | |
138 | void OnUpdateRedo(wxUpdateUIEvent& event); | |
0e320a79 | 139 | |
d90895ac DW |
140 | protected: |
141 | // call this to increase the size limit (will do nothing if the current | |
142 | // limit is big enough) | |
143 | void AdjustSpaceLimit(); | |
0e320a79 | 144 | |
d90895ac | 145 | virtual wxSize DoGetBestSize(); |
0e320a79 | 146 | |
d90895ac DW |
147 | private: |
148 | DECLARE_EVENT_TABLE() | |
149 | DECLARE_DYNAMIC_CLASS(wxTextCtrl) | |
0e320a79 DW |
150 | }; |
151 | ||
152 | #endif | |
153 | // _WX_TEXTCTRL_H_ |