]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/textctrl.h
test
[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
VZ
131 virtual void AdoptAttributesFromHWND();
132 virtual void SetupColours();
5fb9fcfc 133
c50f1fb9
VZ
134 virtual bool AcceptsFocus() const;
135
4438caf4 136 // callbacks
4438caf4
VZ
137 void OnDropFiles(wxDropFilesEvent& event);
138 void OnChar(wxKeyEvent& event); // Process 'enter' if required
139
140 void OnCut(wxCommandEvent& event);
141 void OnCopy(wxCommandEvent& event);
142 void OnPaste(wxCommandEvent& event);
143 void OnUndo(wxCommandEvent& event);
144 void OnRedo(wxCommandEvent& event);
145
146 void OnUpdateCut(wxUpdateUIEvent& event);
147 void OnUpdateCopy(wxUpdateUIEvent& event);
148 void OnUpdatePaste(wxUpdateUIEvent& event);
149 void OnUpdateUndo(wxUpdateUIEvent& event);
150 void OnUpdateRedo(wxUpdateUIEvent& event);
151
2bda0e17 152protected:
396bdd5a 153#if wxUSE_RICHEDIT
bfc6fde4 154 bool m_isRich; // Are we using rich text edit to implement this?
396bdd5a
VZ
155#endif
156
789295bf
VZ
157 // call this to increase the size limit (will do nothing if the current
158 // limit is big enough)
159 void AdjustSpaceLimit();
160
f68586e5 161 virtual wxSize DoGetBestSize() const;
bfc6fde4
VZ
162
163private:
164 DECLARE_EVENT_TABLE()
a1b82138 165 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
2bda0e17
KB
166};
167
168#endif
bbcdf8bc 169 // _WX_TEXTCTRL_H_