]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/textctrl.h
Corrected wxlistBox, wxRadioBox, wxComboBox and
[wxWidgets.git] / include / wx / msw / textctrl.h
CommitLineData
2bda0e17
KB
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$
bbcdf8bc 8// Copyright: (c) Julian Smart
5fb9fcfc 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_TEXTCTRL_H_
13#define _WX_TEXTCTRL_H_
2bda0e17
KB
14
15#ifdef __GNUG__
396bdd5a 16 #pragma interface "textctrl.h"
2bda0e17
KB
17#endif
18
a1b82138 19// can we use RICHEDIT class for wxTextCtrl implementation?
5ea105e0 20#if defined(__WIN95__) && !defined(__TWIN32__) && !defined(__WXWINE__)
396bdd5a
VZ
21 #define wxUSE_RICHEDIT 1
22#else
23 #define wxUSE_RICHEDIT 0
2bda0e17
KB
24#endif
25
a1b82138 26class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase
2bda0e17 27{
ae29de83 28public:
bfc6fde4
VZ
29 // creation
30 // --------
a1b82138 31
bfc6fde4
VZ
32 wxTextCtrl();
33 wxTextCtrl(wxWindow *parent, wxWindowID id,
a1b82138
VZ
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 }
bfc6fde4
VZ
43
44 bool Create(wxWindow *parent, wxWindowID id,
a1b82138
VZ
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);
bfc6fde4 51
a1b82138
VZ
52 // implement base class pure virtuals
53 // ----------------------------------
4438caf4
VZ
54
55 virtual wxString GetValue() const;
bfc6fde4
VZ
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
a1b82138
VZ
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
bfc6fde4
VZ
68 // operations
69 // ----------
70
a1b82138
VZ
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;
0efe5ba7 91 virtual bool PositionToXY(long pos, long *x, long *y) const;
a1b82138
VZ
92
93 virtual void ShowPosition(long pos);
94
bfc6fde4
VZ
95 // Clipboard operations
96 virtual void Copy();
97 virtual void Cut();
98 virtual void Paste();
99
ca8b28f2
JS
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
a1b82138 111 // Insertion point
bfc6fde4
VZ
112 virtual void SetInsertionPoint(long pos);
113 virtual void SetInsertionPointEnd();
a1b82138
VZ
114 virtual long GetInsertionPoint() const;
115 virtual long GetLastPosition() const;
116
bfc6fde4
VZ
117 virtual void SetSelection(long from, long to);
118 virtual void SetEditable(bool editable);
119
4438caf4
VZ
120 // Implementation from now on
121 // --------------------------
e702ff0f 122
bfc6fde4
VZ
123 virtual void Command(wxCommandEvent& event);
124 virtual bool MSWCommand(WXUINT param, WXWORD id);
396bdd5a
VZ
125
126#if wxUSE_RICHEDIT
bfc6fde4
VZ
127 bool IsRich() const { return m_isRich; }
128 void SetRichEdit(bool isRich) { m_isRich = isRich; }
a1b82138 129#endif // wxUSE_RICHEDIT
396bdd5a 130
bfc6fde4 131 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
a1b82138
VZ
132 WXUINT message, WXWPARAM wParam,
133 WXLPARAM lParam);
5fb9fcfc 134
bfc6fde4
VZ
135 virtual void AdoptAttributesFromHWND();
136 virtual void SetupColours();
5fb9fcfc 137
c50f1fb9
VZ
138 virtual bool AcceptsFocus() const;
139
4438caf4 140 // callbacks
4438caf4
VZ
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
2bda0e17 156protected:
396bdd5a 157#if wxUSE_RICHEDIT
bfc6fde4 158 bool m_isRich; // Are we using rich text edit to implement this?
396bdd5a
VZ
159#endif
160
789295bf
VZ
161 // call this to increase the size limit (will do nothing if the current
162 // limit is big enough)
163 void AdjustSpaceLimit();
164
4438caf4 165 virtual wxSize DoGetBestSize();
bfc6fde4
VZ
166
167private:
168 DECLARE_EVENT_TABLE()
a1b82138 169 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
2bda0e17
KB
170};
171
172#endif
bbcdf8bc 173 // _WX_TEXTCTRL_H_