]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/textctrl.h
1. regenerated the makefiles to include menucmn.cpp
[wxWidgets.git] / include / wx / msw / textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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
19 // can we use RICHEDIT class for wxTextCtrl implementation?
20 #if defined(__WIN95__) && !defined(__TWIN32__) && !defined(__WXWINE__)
21 #define wxUSE_RICHEDIT 1
22 #else
23 #define wxUSE_RICHEDIT 0
24 #endif
25
26 class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase
27 {
28 public:
29 // creation
30 // --------
31
32 wxTextCtrl();
33 wxTextCtrl(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 Create(parent, id, value, pos, size, style, validator, name);
42 }
43
44 bool Create(wxWindow *parent, wxWindowID id,
45 const wxString& value = wxEmptyString,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize,
48 long style = 0,
49 const wxValidator& validator = wxDefaultValidator,
50 const wxString& name = wxTextCtrlNameStr);
51
52 // implement base class pure virtuals
53 // ----------------------------------
54
55 virtual wxString GetValue() const;
56 virtual void SetValue(const wxString& value);
57
58 virtual int GetLineLength(long lineNo) const;
59 virtual wxString GetLineText(long lineNo) const;
60 virtual int GetNumberOfLines() const;
61
62 virtual bool IsModified() const;
63 virtual bool IsEditable() const;
64
65 // If the return values from and to are the same, there is no selection.
66 virtual void GetSelection(long* from, long* to) const;
67
68 // operations
69 // ----------
70
71 // editing
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
79 // clears the dirty flag
80 virtual void DiscardEdits();
81
82 // writing text inserts it at the current position, appending always
83 // inserts it at the end
84 virtual void WriteText(const wxString& text);
85 virtual void AppendText(const wxString& text);
86
87 // translate between the position (which is just an index in the text ctrl
88 // considering all its contents as a single strings) and (x, y) coordinates
89 // which represent column and line.
90 virtual long XYToPosition(long x, long y) const;
91 virtual bool PositionToXY(long pos, long *x, long *y) const;
92
93 virtual void ShowPosition(long pos);
94
95 // Clipboard operations
96 virtual void Copy();
97 virtual void Cut();
98 virtual void Paste();
99
100 virtual bool CanCopy() const;
101 virtual bool CanCut() const;
102 virtual bool CanPaste() const;
103
104 // Undo/redo
105 virtual void Undo();
106 virtual void Redo();
107
108 virtual bool CanUndo() const;
109 virtual bool CanRedo() const;
110
111 // Insertion point
112 virtual void SetInsertionPoint(long pos);
113 virtual void SetInsertionPointEnd();
114 virtual long GetInsertionPoint() const;
115 virtual long GetLastPosition() const;
116
117 virtual void SetSelection(long from, long to);
118 virtual void SetEditable(bool editable);
119
120 // Implementation from now on
121 // --------------------------
122
123 virtual void Command(wxCommandEvent& event);
124 virtual bool MSWCommand(WXUINT param, WXWORD id);
125
126 #if wxUSE_RICHEDIT
127 bool IsRich() const { return m_isRich; }
128 void SetRichEdit(bool isRich) { m_isRich = isRich; }
129 #endif // wxUSE_RICHEDIT
130
131 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
132 WXUINT message, WXWPARAM wParam,
133 WXLPARAM lParam);
134
135 virtual void AdoptAttributesFromHWND();
136 virtual void SetupColours();
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
156 protected:
157 #if wxUSE_RICHEDIT
158 bool m_isRich; // Are we using rich text edit to implement this?
159 #endif
160
161 // call this to increase the size limit (will do nothing if the current
162 // limit is big enough)
163 void AdjustSpaceLimit();
164
165 virtual wxSize DoGetBestSize();
166
167 private:
168 DECLARE_EVENT_TABLE()
169 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
170 };
171
172 #endif
173 // _WX_TEXTCTRL_H_