]>
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(); | |
ca8f0290 DW |
22 | wxTextCtrl( wxWindow* pParent |
23 | ,wxWindowID vId | |
24 | ,const wxString& rsValue = wxEmptyString | |
25 | ,const wxPoint& rPos = wxDefaultPosition | |
26 | ,const wxSize& rSize = wxDefaultSize | |
27 | ,long lStyle = 0 | |
57c4d796 | 28 | #if wxUSE_VALIDATORS |
ca8f0290 | 29 | ,const wxValidator& rValidator = wxDefaultValidator |
57c4d796 | 30 | #endif |
ca8f0290 DW |
31 | ,const wxString& rsName = wxTextCtrlNameStr |
32 | ) | |
d90895ac | 33 | { |
ca8f0290 | 34 | Create(pParent, vId, rsValue, rPos, rSize, lStyle, rValidator, rsName); |
d90895ac DW |
35 | } |
36 | ||
ca8f0290 DW |
37 | bool Create( wxWindow* pParent |
38 | ,wxWindowID vId | |
39 | ,const wxString& rsValue = wxEmptyString | |
40 | ,const wxPoint& rPos = wxDefaultPosition | |
41 | ,const wxSize& rSize = wxDefaultSize | |
42 | ,long lStyle = 0 | |
57c4d796 | 43 | #if wxUSE_VALIDATORS |
ca8f0290 | 44 | ,const wxValidator& rValidator = wxDefaultValidator |
57c4d796 | 45 | #endif |
ca8f0290 DW |
46 | ,const wxString& rsName = wxTextCtrlNameStr |
47 | ); | |
d90895ac DW |
48 | |
49 | // implement base class pure virtuals | |
50 | // ---------------------------------- | |
51 | ||
ca8f0290 DW |
52 | virtual wxString GetValue(void) const; |
53 | virtual void SetValue(const wxString& rsValue); | |
d90895ac | 54 | |
ca8f0290 DW |
55 | virtual int GetLineLength(long nLineNo) const; |
56 | virtual wxString GetLineText(long nLineNo) const; | |
57 | virtual int GetNumberOfLines(void) const; | |
d90895ac | 58 | |
ca8f0290 DW |
59 | virtual bool IsModified(void) const; |
60 | virtual bool IsEditable(void) const; | |
d90895ac DW |
61 | |
62 | // If the return values from and to are the same, there is no selection. | |
ca8f0290 DW |
63 | virtual void GetSelection( long* pFrom |
64 | ,long* pTo | |
65 | ) const; | |
d90895ac DW |
66 | |
67 | // operations | |
68 | // ---------- | |
69 | ||
70 | // editing | |
ca8f0290 DW |
71 | virtual void Clear(void); |
72 | virtual void Replace( long lFrom | |
73 | ,long lTo | |
74 | ,const wxString& rsValue | |
75 | ); | |
76 | virtual void Remove( long lFrom | |
77 | ,long lTo | |
78 | ); | |
d90895ac DW |
79 | |
80 | // load the controls contents from the file | |
ca8f0290 | 81 | virtual bool LoadFile(const wxString& rsFile); |
d90895ac DW |
82 | |
83 | // clears the dirty flag | |
ca8f0290 | 84 | virtual void DiscardEdits(void); |
d90895ac DW |
85 | |
86 | // writing text inserts it at the current position, appending always | |
87 | // inserts it at the end | |
ca8f0290 DW |
88 | virtual void WriteText(const wxString& rsText); |
89 | virtual void AppendText(const wxString& rsText); | |
d90895ac DW |
90 | |
91 | // translate between the position (which is just an index in the text ctrl | |
92 | // considering all its contents as a single strings) and (x, y) coordinates | |
93 | // which represent column and line. | |
ca8f0290 DW |
94 | virtual long XYToPosition( long lX |
95 | ,long lY | |
96 | ) const; | |
97 | virtual bool PositionToXY( long lPos | |
98 | ,long* plX | |
99 | ,long* plY | |
100 | ) const; | |
d90895ac | 101 | |
ca8f0290 | 102 | virtual void ShowPosition(long lPos); |
d90895ac DW |
103 | |
104 | // Clipboard operations | |
ca8f0290 DW |
105 | virtual void Copy(void); |
106 | virtual void Cut(void); | |
107 | virtual void Paste(void); | |
d90895ac | 108 | |
ca8f0290 DW |
109 | virtual bool CanCopy(void) const; |
110 | virtual bool CanCut(void) const; | |
111 | virtual bool CanPaste(void) const; | |
d90895ac DW |
112 | |
113 | // Undo/redo | |
ca8f0290 DW |
114 | virtual void Undo(void); |
115 | virtual void Redo(void); | |
d90895ac | 116 | |
ca8f0290 DW |
117 | virtual bool CanUndo(void) const; |
118 | virtual bool CanRedo(void) const; | |
d90895ac DW |
119 | |
120 | // Insertion point | |
ca8f0290 DW |
121 | virtual void SetInsertionPoint(long lPos); |
122 | virtual void SetInsertionPointEnd(void); | |
123 | virtual long GetInsertionPoint(void) const; | |
124 | virtual long GetLastPosition(void) const; | |
d90895ac | 125 | |
ca8f0290 DW |
126 | virtual void SetSelection( long lFrom |
127 | ,long lTo | |
128 | ); | |
129 | virtual void SetEditable(bool bEditable); | |
d90895ac | 130 | |
ca8f0290 | 131 | // |
d90895ac DW |
132 | // Implementation from now on |
133 | // -------------------------- | |
ca8f0290 DW |
134 | // |
135 | virtual void Command(wxCommandEvent& rEvent); | |
136 | virtual bool OS2Command( WXUINT uParam | |
137 | ,WXWORD wId | |
138 | ); | |
d90895ac | 139 | |
ca8f0290 DW |
140 | virtual WXHBRUSH OnCtlColor( WXHDC hDC |
141 | ,WXHWND pWnd | |
142 | ,WXUINT nCtlColor | |
143 | ,WXUINT message | |
144 | ,WXWPARAM wParam | |
145 | ,WXLPARAM lParam | |
146 | ); | |
d90895ac | 147 | |
ca8f0290 DW |
148 | virtual bool SetBackgroundColour(const wxColour& colour); |
149 | virtual bool SetForegroundColour(const wxColour& colour); | |
d90895ac | 150 | |
ca8f0290 DW |
151 | virtual void AdoptAttributesFromHWND(void); |
152 | virtual void SetupColours(void); | |
d90895ac | 153 | |
ca8f0290 | 154 | virtual bool AcceptsFocus(void) const; |
d90895ac DW |
155 | |
156 | // callbacks | |
ca8f0290 DW |
157 | void OnDropFiles(wxDropFilesEvent& rEvent); |
158 | void OnChar(wxKeyEvent& rEvent); // Process 'enter' if required | |
0e320a79 | 159 | |
ca8f0290 DW |
160 | void OnCut(wxCommandEvent& rEvent); |
161 | void OnCopy(wxCommandEvent& rEvent); | |
162 | void OnPaste(wxCommandEvent& rEvent); | |
163 | void OnUndo(wxCommandEvent& rEvent); | |
164 | void OnRedo(wxCommandEvent& rEvent); | |
0e320a79 | 165 | |
ca8f0290 DW |
166 | void OnUpdateCut(wxUpdateUIEvent& rEvent); |
167 | void OnUpdateCopy(wxUpdateUIEvent& rEvent); | |
168 | void OnUpdatePaste(wxUpdateUIEvent& rEvent); | |
169 | void OnUpdateUndo(wxUpdateUIEvent& rEvent); | |
170 | void OnUpdateRedo(wxUpdateUIEvent& rEvent); | |
171 | ||
172 | inline bool IsMLE(void) {return m_bIsMLE;} | |
173 | inline void SetMLE(bool bIsMLE) {m_bIsMLE = bIsMLE;} | |
0e320a79 | 174 | |
d90895ac | 175 | protected: |
ca8f0290 | 176 | // |
d90895ac DW |
177 | // call this to increase the size limit (will do nothing if the current |
178 | // limit is big enough) | |
ca8f0290 DW |
179 | // |
180 | void AdjustSpaceLimit(void); | |
181 | virtual wxSize DoGetBestSize(void) const; | |
0e320a79 | 182 | |
d90895ac | 183 | private: |
ca8f0290 | 184 | bool m_bIsMLE; |
d90895ac DW |
185 | DECLARE_EVENT_TABLE() |
186 | DECLARE_DYNAMIC_CLASS(wxTextCtrl) | |
ca8f0290 | 187 | }; // end of CLASS wxTextCtrl |
0e320a79 DW |
188 | |
189 | #endif | |
190 | // _WX_TEXTCTRL_H_ |