]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/msw/textctrl.h
added wxUSE_PROTOCOL[_XXX] and wxUSE_URL settings
[wxWidgets.git] / include / wx / msw / textctrl.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/msw/textctrl.h
3// Purpose: wxTextCtrl class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_TEXTCTRL_H_
13#define _WX_TEXTCTRL_H_
14
15#ifdef __GNUG__
16 #pragma interface "textctrl.h"
17#endif
18
19class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase
20{
21public:
22 // creation
23 // --------
24
25 wxTextCtrl() { Init(); }
26 wxTextCtrl(wxWindow *parent, wxWindowID id,
27 const wxString& value = wxEmptyString,
28 const wxPoint& pos = wxDefaultPosition,
29 const wxSize& size = wxDefaultSize,
30 long style = 0,
31 const wxValidator& validator = wxDefaultValidator,
32 const wxString& name = wxTextCtrlNameStr)
33 {
34 Init();
35
36 Create(parent, id, value, pos, size, style, validator, name);
37 }
38
39 bool Create(wxWindow *parent, wxWindowID id,
40 const wxString& value = wxEmptyString,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 long style = 0,
44 const wxValidator& validator = wxDefaultValidator,
45 const wxString& name = wxTextCtrlNameStr);
46
47 // implement base class pure virtuals
48 // ----------------------------------
49
50 virtual wxString GetValue() const;
51 virtual void SetValue(const wxString& value);
52
53 virtual int GetLineLength(long lineNo) const;
54 virtual wxString GetLineText(long lineNo) const;
55 virtual int GetNumberOfLines() const;
56
57 virtual bool IsModified() const;
58 virtual bool IsEditable() const;
59
60 virtual void GetSelection(long* from, long* to) const;
61 virtual wxString GetStringSelection() const;
62
63 // operations
64 // ----------
65
66 // editing
67 virtual void Clear();
68 virtual void Replace(long from, long to, const wxString& value);
69 virtual void Remove(long from, long to);
70
71 // load the controls contents from the file
72 virtual bool LoadFile(const wxString& file);
73
74 // clears the dirty flag
75 virtual void DiscardEdits();
76
77 virtual void SetMaxLength(unsigned long len);
78
79 // writing text inserts it at the current position, appending always
80 // inserts it at the end
81 virtual void WriteText(const wxString& text);
82 virtual void AppendText(const wxString& text);
83
84#if wxUSE_RICHEDIT
85 // apply text attribute to the range of text (only works with richedit
86 // controls)
87 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
88#endif // wxUSE_RICHEDIT
89
90 // translate between the position (which is just an index in the text ctrl
91 // considering all its contents as a single strings) and (x, y) coordinates
92 // which represent column and line.
93 virtual long XYToPosition(long x, long y) const;
94 virtual bool PositionToXY(long pos, long *x, long *y) const;
95
96 virtual void ShowPosition(long pos);
97
98 // Clipboard operations
99 virtual void Copy();
100 virtual void Cut();
101 virtual void Paste();
102
103 virtual bool CanCopy() const;
104 virtual bool CanCut() const;
105 virtual bool CanPaste() const;
106
107 // Undo/redo
108 virtual void Undo();
109 virtual void Redo();
110
111 virtual bool CanUndo() const;
112 virtual bool CanRedo() const;
113
114 // Insertion point
115 virtual void SetInsertionPoint(long pos);
116 virtual void SetInsertionPointEnd();
117 virtual long GetInsertionPoint() const;
118 virtual long GetLastPosition() const;
119
120 virtual void SetSelection(long from, long to);
121 virtual void SetEditable(bool editable);
122
123 // Implementation from now on
124 // --------------------------
125
126 virtual void Command(wxCommandEvent& event);
127 virtual bool MSWCommand(WXUINT param, WXWORD id);
128 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
129 WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
130
131 // In WIN16, need to override normal erasing because
132 // Ctl3D doesn't use the wxWindows background colour.
133#ifdef __WIN16__
134 void OnEraseBackground(wxEraseEvent& event);
135#endif
136
137#if wxUSE_RICHEDIT
138 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
139
140 int GetRichVersion() const { return m_verRichEdit; }
141 bool IsRich() const { return m_verRichEdit != 0; }
142
143 // rich edit controls are not compatible with normal ones and wem ust set
144 // the colours for them otherwise
145 virtual bool SetBackgroundColour(const wxColour& colour);
146 virtual bool SetForegroundColour(const wxColour& colour);
147#endif // wxUSE_RICHEDIT
148
149 virtual void AdoptAttributesFromHWND();
150
151 virtual bool AcceptsFocus() const;
152
153 // callbacks
154 void OnDropFiles(wxDropFilesEvent& event);
155 void OnChar(wxKeyEvent& event); // Process 'enter' if required
156
157 void OnCut(wxCommandEvent& event);
158 void OnCopy(wxCommandEvent& event);
159 void OnPaste(wxCommandEvent& event);
160 void OnUndo(wxCommandEvent& event);
161 void OnRedo(wxCommandEvent& event);
162
163 void OnUpdateCut(wxUpdateUIEvent& event);
164 void OnUpdateCopy(wxUpdateUIEvent& event);
165 void OnUpdatePaste(wxUpdateUIEvent& event);
166 void OnUpdateUndo(wxUpdateUIEvent& event);
167 void OnUpdateRedo(wxUpdateUIEvent& event);
168
169protected:
170 // common part of all ctors
171 void Init();
172
173 // call this to increase the size limit (will do nothing if the current
174 // limit is big enough)
175 //
176 // returns true if we increased the limit to allow entering more text,
177 // false if we hit the limit set by SetMaxLength() and so didn't change it
178 bool AdjustSpaceLimit();
179
180#if wxUSE_RICHEDIT
181 // replace the selection with the given text in the specified encoding
182 bool StreamIn(const wxString& value, wxFontEncoding encoding);
183#endif // wxUSE_RICHEDIT
184
185 // set the selection possibly without scrolling the caret into view
186 void DoSetSelection(long from, long to, bool scrollCaret = TRUE);
187
188 // override some base class virtuals
189 virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg);
190 virtual wxSize DoGetBestSize() const;
191
192#if wxUSE_RICHEDIT
193 // we're using RICHEDIT (and not simple EDIT) control if this field is not
194 // 0, it also gives the version of the RICHEDIT control being used (1, 2 or
195 // 3 so far)
196 int m_verRichEdit;
197#endif // wxUSE_RICHEDIT
198
199private:
200 DECLARE_EVENT_TABLE()
201 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
202};
203
204#endif
205 // _WX_TEXTCTRL_H_