]>
Commit | Line | Data |
---|---|---|
9b6dbb09 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: textctrl.h | |
3 | // Purpose: wxTextCtrl class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
c27eab7e | 9 | // Licence: wxWindows licence |
9b6dbb09 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_TEXTCTRL_H_ | |
13 | #define _WX_TEXTCTRL_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
c27eab7e | 16 | #pragma interface "textctrl.h" |
9b6dbb09 JS |
17 | #endif |
18 | ||
c27eab7e | 19 | #include "wx/ioswrap.h" |
9b6dbb09 JS |
20 | #include "wx/control.h" |
21 | ||
c27eab7e VZ |
22 | // TODO Some platforms/compilers don't like inheritance from streambuf. |
23 | #if (defined(__BORLANDC__) && !defined(__WIN32__)) || defined(__MWERKS__) | |
24 | #define NO_TEXT_WINDOW_STREAM | |
9b6dbb09 JS |
25 | #endif |
26 | ||
27 | WXDLLEXPORT_DATA(extern const char*) wxTextCtrlNameStr; | |
28 | WXDLLEXPORT_DATA(extern const char*) wxEmptyString; | |
29 | ||
30 | // Single-line text item | |
31 | class WXDLLEXPORT wxTextCtrl: public wxControl | |
9b6dbb09 | 32 | #ifndef NO_TEXT_WINDOW_STREAM |
c27eab7e | 33 | , public streambuf |
9b6dbb09 | 34 | #endif |
9b6dbb09 | 35 | { |
c27eab7e VZ |
36 | DECLARE_DYNAMIC_CLASS(wxTextCtrl) |
37 | ||
9b6dbb09 | 38 | public: |
c27eab7e VZ |
39 | // creation |
40 | // -------- | |
41 | wxTextCtrl(); | |
42 | wxTextCtrl(wxWindow *parent, | |
43 | wxWindowID id, | |
44 | const wxString& value = wxEmptyString, | |
45 | const wxPoint& pos = wxDefaultPosition, | |
46 | const wxSize& size = wxDefaultSize, | |
47 | long style = 0, | |
48 | const wxValidator& validator = wxDefaultValidator, | |
49 | const wxString& name = wxTextCtrlNameStr) | |
9b6dbb09 | 50 | #ifndef NO_TEXT_WINDOW_STREAM |
c27eab7e | 51 | : streambuf() |
9b6dbb09 | 52 | #endif |
c27eab7e VZ |
53 | { |
54 | Create(parent, id, value, pos, size, style, validator, name); | |
55 | } | |
56 | ||
57 | bool Create(wxWindow *parent, wxWindowID id, | |
58 | const wxString& value = wxEmptyString, | |
59 | const wxPoint& pos = wxDefaultPosition, | |
60 | const wxSize& size = wxDefaultSize, long style = 0, | |
61 | const wxValidator& validator = wxDefaultValidator, | |
62 | const wxString& name = wxTextCtrlNameStr); | |
63 | ||
64 | // accessors | |
65 | // --------- | |
66 | virtual wxString GetValue() const; | |
67 | virtual void SetValue(const wxString& value); | |
68 | ||
69 | virtual int GetLineLength(long lineNo) const; | |
70 | virtual wxString GetLineText(long lineNo) const; | |
71 | virtual int GetNumberOfLines() const; | |
72 | ||
73 | // operations | |
74 | // ---------- | |
75 | ||
76 | // Clipboard operations | |
77 | virtual void Copy(); | |
78 | virtual void Cut(); | |
79 | virtual void Paste(); | |
80 | ||
81 | virtual void SetInsertionPoint(long pos); | |
82 | virtual void SetInsertionPointEnd(); | |
83 | virtual long GetInsertionPoint() const; | |
84 | virtual long GetLastPosition() const; | |
85 | virtual void Replace(long from, long to, const wxString& value); | |
86 | virtual void Remove(long from, long to); | |
87 | virtual void SetSelection(long from, long to); | |
88 | virtual void SetEditable(bool editable); | |
89 | ||
90 | // streambuf implementation | |
9b6dbb09 | 91 | #ifndef NO_TEXT_WINDOW_STREAM |
c27eab7e VZ |
92 | int overflow(int i); |
93 | int sync(); | |
94 | int underflow(); | |
9b6dbb09 | 95 | #endif |
c27eab7e VZ |
96 | |
97 | wxTextCtrl& operator<<(const wxString& s); | |
98 | wxTextCtrl& operator<<(int i); | |
99 | wxTextCtrl& operator<<(long i); | |
100 | wxTextCtrl& operator<<(float f); | |
101 | wxTextCtrl& operator<<(double d); | |
102 | wxTextCtrl& operator<<(const char c); | |
103 | ||
104 | virtual bool LoadFile(const wxString& file); | |
105 | virtual bool SaveFile(const wxString& file); | |
106 | virtual void WriteText(const wxString& text); | |
107 | virtual void AppendText(const wxString& text); | |
108 | virtual void DiscardEdits(); | |
109 | virtual bool IsModified() const; | |
110 | ||
111 | virtual long XYToPosition(long x, long y) const; | |
112 | virtual void PositionToXY(long pos, long *x, long *y) const; | |
113 | virtual void ShowPosition(long pos); | |
114 | virtual void Clear(); | |
115 | ||
116 | // callbacks | |
117 | // --------- | |
118 | void OnDropFiles(wxDropFilesEvent& event); | |
119 | void OnChar(wxKeyEvent& event); | |
120 | // void OnEraseBackground(wxEraseEvent& event); | |
121 | ||
122 | virtual void Command(wxCommandEvent& event); | |
123 | ||
124 | // implementation from here to the end | |
125 | // ----------------------------------- | |
126 | virtual void ChangeFont(bool keepOriginalSize = TRUE); | |
127 | virtual void ChangeBackgroundColour(); | |
128 | virtual void ChangeForegroundColour(); | |
129 | void SetModified(bool mod) { m_modified = mod; } | |
130 | virtual WXWidget GetTopWidget() const; | |
131 | ||
132 | // send the CHAR and TEXT_UPDATED events | |
133 | void DoSendEvents(void /* XmTextVerifyCallbackStruct */ *cbs, | |
134 | long keycode); | |
02e8b2f9 | 135 | |
9b6dbb09 | 136 | protected: |
c27eab7e VZ |
137 | wxString m_fileName; |
138 | ||
02e8b2f9 | 139 | public: |
c27eab7e VZ |
140 | // Motif-specific |
141 | void* m_tempCallbackStruct; | |
142 | bool m_modified; | |
143 | wxString m_value; // Required for password text controls | |
144 | ||
145 | // Did we call wxTextCtrl::OnChar? If so, generate a command event. | |
146 | bool m_processedDefault; | |
147 | ||
148 | private: | |
149 | DECLARE_EVENT_TABLE() | |
9b6dbb09 JS |
150 | }; |
151 | ||
152 | #endif | |
153 | // _WX_TEXTCTRL_H_ |