]>
Commit | Line | Data |
---|---|---|
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 | ||
396bdd5a | 19 | #include "wx/setup.h" |
2bda0e17 KB |
20 | #include "wx/control.h" |
21 | ||
47d67540 | 22 | #if wxUSE_IOSTREAMH |
396bdd5a | 23 | #include <iostream.h> |
2bda0e17 | 24 | #else |
396bdd5a VZ |
25 | #include <iostream> |
26 | #endif | |
27 | ||
28 | #if defined(__WIN95__) && !defined(__TWIN32__) | |
29 | #define wxUSE_RICHEDIT 1 | |
30 | #else | |
31 | #define wxUSE_RICHEDIT 0 | |
2bda0e17 KB |
32 | #endif |
33 | ||
34 | WXDLLEXPORT_DATA(extern const char*) wxTextCtrlNameStr; | |
35 | WXDLLEXPORT_DATA(extern const char*) wxEmptyString; | |
36 | ||
37 | // Single-line text item | |
38 | class WXDLLEXPORT wxTextCtrl: public wxControl | |
39 | ||
40 | // 16-bit Borland 4.0 doesn't seem to allow multiple inheritance with wxWindow and streambuf: | |
41 | // it complains about deriving a huge class from the huge class streambuf. !! | |
42 | // Also, can't use streambuf if making or using a DLL :-( | |
43 | ||
3f1af920 | 44 | #if (defined(__BORLANDC__)) || defined(__MWERKS__) || defined(_WINDLL) || defined(WXUSINGDLL) || defined(WXMAKINGDLL) |
2bda0e17 KB |
45 | #define NO_TEXT_WINDOW_STREAM |
46 | #endif | |
47 | ||
48 | #ifndef NO_TEXT_WINDOW_STREAM | |
49 | , public streambuf | |
50 | #endif | |
51 | ||
52 | { | |
53 | DECLARE_DYNAMIC_CLASS(wxTextCtrl) | |
5fb9fcfc | 54 | |
ae29de83 VZ |
55 | public: |
56 | // creation | |
57 | // -------- | |
58 | wxTextCtrl(); | |
debe6624 | 59 | inline wxTextCtrl(wxWindow *parent, wxWindowID id, |
ae29de83 VZ |
60 | const wxString& value = wxEmptyString, |
61 | const wxPoint& pos = wxDefaultPosition, | |
62 | const wxSize& size = wxDefaultSize, long style = 0, | |
63 | const wxValidator& validator = wxDefaultValidator, | |
64 | const wxString& name = wxTextCtrlNameStr) | |
2bda0e17 | 65 | #ifndef NO_TEXT_WINDOW_STREAM |
ae29de83 | 66 | :streambuf() |
2bda0e17 KB |
67 | #endif |
68 | { | |
ae29de83 | 69 | Create(parent, id, value, pos, size, style, validator, name); |
2bda0e17 | 70 | } |
5fb9fcfc | 71 | |
debe6624 | 72 | bool Create(wxWindow *parent, wxWindowID id, |
ae29de83 VZ |
73 | const wxString& value = wxEmptyString, |
74 | const wxPoint& pos = wxDefaultPosition, | |
2004484f | 75 | const wxSize& size = wxDefaultSize, long style = wxTE_PROCESS_TAB, |
ae29de83 VZ |
76 | const wxValidator& validator = wxDefaultValidator, |
77 | const wxString& name = wxTextCtrlNameStr); | |
5fb9fcfc | 78 | |
ae29de83 VZ |
79 | // accessors |
80 | // --------- | |
81 | virtual wxString GetValue() const ; | |
2bda0e17 | 82 | virtual void SetValue(const wxString& value); |
2bda0e17 | 83 | |
ae29de83 VZ |
84 | virtual int GetLineLength(long lineNo) const; |
85 | virtual wxString GetLineText(long lineNo) const; | |
86 | virtual int GetNumberOfLines() const; | |
2bda0e17 | 87 | |
ae29de83 VZ |
88 | // operations |
89 | // ---------- | |
90 | virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); | |
4fabb575 JS |
91 | void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO) |
92 | { wxWindow::SetSize(rect, sizeFlags); } | |
93 | void SetSize(const wxSize& size) { wxWindow::SetSize(size); } | |
5fb9fcfc | 94 | |
ae29de83 VZ |
95 | // Clipboard operations |
96 | virtual void Copy(); | |
97 | virtual void Cut(); | |
98 | virtual void Paste(); | |
5fb9fcfc | 99 | |
debe6624 | 100 | virtual void SetInsertionPoint(long pos); |
ae29de83 VZ |
101 | virtual void SetInsertionPointEnd(); |
102 | virtual long GetInsertionPoint() const ; | |
103 | virtual long GetLastPosition() const ; | |
debe6624 JS |
104 | virtual void Replace(long from, long to, const wxString& value); |
105 | virtual void Remove(long from, long to); | |
106 | virtual void SetSelection(long from, long to); | |
debe6624 | 107 | virtual void SetEditable(bool editable); |
5fb9fcfc | 108 | |
ae29de83 | 109 | // streambuf implementation |
2bda0e17 KB |
110 | #ifndef NO_TEXT_WINDOW_STREAM |
111 | int overflow(int i); | |
ae29de83 VZ |
112 | int sync(); |
113 | int underflow(); | |
2bda0e17 | 114 | #endif |
5fb9fcfc | 115 | |
2bda0e17 | 116 | wxTextCtrl& operator<<(const wxString& s); |
debe6624 JS |
117 | wxTextCtrl& operator<<(int i); |
118 | wxTextCtrl& operator<<(long i); | |
119 | wxTextCtrl& operator<<(float f); | |
120 | wxTextCtrl& operator<<(double d); | |
2bda0e17 | 121 | wxTextCtrl& operator<<(const char c); |
5fb9fcfc | 122 | |
2bda0e17 KB |
123 | virtual bool LoadFile(const wxString& file); |
124 | virtual bool SaveFile(const wxString& file); | |
125 | virtual void WriteText(const wxString& text); | |
5fb9fcfc | 126 | virtual void AppendText(const wxString& text); |
ae29de83 VZ |
127 | virtual void DiscardEdits(); |
128 | virtual bool IsModified() const; | |
5fb9fcfc | 129 | |
2bda0e17 | 130 | #if WXWIN_COMPATIBILITY |
ae29de83 | 131 | inline bool Modified() const { return IsModified(); } |
2bda0e17 | 132 | #endif |
5fb9fcfc | 133 | |
debe6624 JS |
134 | virtual long XYToPosition(long x, long y) const ; |
135 | virtual void PositionToXY(long pos, long *x, long *y) const ; | |
136 | virtual void ShowPosition(long pos); | |
ae29de83 | 137 | virtual void Clear(); |
5fb9fcfc | 138 | |
ae29de83 VZ |
139 | // callbacks |
140 | // --------- | |
141 | void OnDropFiles(wxDropFilesEvent& event); | |
142 | void OnChar(wxKeyEvent& event); // Process 'enter' if required | |
2bda0e17 | 143 | void OnEraseBackground(wxEraseEvent& event); |
5fb9fcfc | 144 | |
2bda0e17 | 145 | // Implementation |
ae29de83 VZ |
146 | // -------------- |
147 | virtual void Command(wxCommandEvent& event); | |
debe6624 | 148 | virtual bool MSWCommand(WXUINT param, WXWORD id); |
396bdd5a VZ |
149 | |
150 | #if wxUSE_RICHEDIT | |
151 | bool IsRich() const { return m_isRich; } | |
152 | void SetRichEdit(bool isRich) { m_isRich = isRich; } | |
153 | #endif | |
154 | ||
debe6624 | 155 | virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, |
ae29de83 VZ |
156 | WXUINT message, WXWPARAM wParam, |
157 | WXLPARAM lParam); | |
5fb9fcfc | 158 | |
ae29de83 VZ |
159 | virtual void AdoptAttributesFromHWND(); |
160 | virtual void SetupColours(); | |
161 | virtual long MSWGetDlgCode(); | |
5fb9fcfc | 162 | |
2bda0e17 | 163 | protected: |
396bdd5a | 164 | #if wxUSE_RICHEDIT |
ae29de83 | 165 | bool m_isRich; // Are we using rich text edit to implement this? |
396bdd5a VZ |
166 | #endif |
167 | ||
b823f5a1 | 168 | wxString m_fileName; |
5fb9fcfc | 169 | |
ae29de83 | 170 | DECLARE_EVENT_TABLE() |
2bda0e17 KB |
171 | }; |
172 | ||
173 | #endif | |
bbcdf8bc | 174 | // _WX_TEXTCTRL_H_ |