]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/textctrl.h
last fixes to fixes (MSW compilation works now)
[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 #include "wx/setup.h"
20 #include "wx/control.h"
21
22 #if wxUSE_IOSTREAMH
23 #include <iostream.h>
24 #else
25 #include <iostream>
26 #endif
27
28 #if defined(__WIN95__) && !defined(__TWIN32__)
29 #define wxUSE_RICHEDIT 1
30 #else
31 #define wxUSE_RICHEDIT 0
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
44 #if (defined(__BORLANDC__)) || defined(__MWERKS__) || defined(_WINDLL) || defined(WXUSINGDLL) || defined(WXMAKINGDLL)
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)
54
55 public:
56 // creation
57 // --------
58 wxTextCtrl();
59 wxTextCtrl(wxWindow *parent, wxWindowID id,
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)
65 #ifndef NO_TEXT_WINDOW_STREAM
66 :streambuf()
67 #endif
68 {
69 Create(parent, id, value, pos, size, style, validator, name);
70 }
71
72 bool Create(wxWindow *parent, wxWindowID id,
73 const wxString& value = wxEmptyString,
74 const wxPoint& pos = wxDefaultPosition,
75 const wxSize& size = wxDefaultSize, long style = wxTE_PROCESS_TAB,
76 const wxValidator& validator = wxDefaultValidator,
77 const wxString& name = wxTextCtrlNameStr);
78
79 // accessors
80 // ---------
81 virtual wxString GetValue() const ;
82 virtual void SetValue(const wxString& value);
83
84 virtual int GetLineLength(long lineNo) const;
85 virtual wxString GetLineText(long lineNo) const;
86 virtual int GetNumberOfLines() const;
87
88 // operations
89 // ----------
90
91 // Clipboard operations
92 virtual void Copy();
93 virtual void Cut();
94 virtual void Paste();
95
96 virtual void SetInsertionPoint(long pos);
97 virtual void SetInsertionPointEnd();
98 virtual long GetInsertionPoint() const ;
99 virtual long GetLastPosition() const ;
100 virtual void Replace(long from, long to, const wxString& value);
101 virtual void Remove(long from, long to);
102 virtual void SetSelection(long from, long to);
103 virtual void SetEditable(bool editable);
104
105 // streambuf implementation
106 #ifndef NO_TEXT_WINDOW_STREAM
107 int overflow(int i);
108 int sync();
109 int underflow();
110 #endif
111
112 wxTextCtrl& operator<<(const wxString& s);
113 wxTextCtrl& operator<<(int i);
114 wxTextCtrl& operator<<(long i);
115 wxTextCtrl& operator<<(float f);
116 wxTextCtrl& operator<<(double d);
117 wxTextCtrl& operator<<(const char c);
118
119 virtual bool LoadFile(const wxString& file);
120 virtual bool SaveFile(const wxString& file);
121 virtual void WriteText(const wxString& text);
122 virtual void AppendText(const wxString& text);
123 virtual void DiscardEdits();
124 virtual bool IsModified() const;
125
126 #if WXWIN_COMPATIBILITY
127 inline bool Modified() const { return IsModified(); }
128 #endif
129
130 virtual long XYToPosition(long x, long y) const ;
131 virtual void PositionToXY(long pos, long *x, long *y) const ;
132 virtual void ShowPosition(long pos);
133 virtual void Clear();
134
135 // callbacks
136 // ---------
137 void OnDropFiles(wxDropFilesEvent& event);
138 void OnChar(wxKeyEvent& event); // Process 'enter' if required
139 void OnEraseBackground(wxEraseEvent& event);
140
141 // Implementation
142 // --------------
143 virtual void Command(wxCommandEvent& event);
144 virtual bool MSWCommand(WXUINT param, WXWORD id);
145
146 #if wxUSE_RICHEDIT
147 bool IsRich() const { return m_isRich; }
148 void SetRichEdit(bool isRich) { m_isRich = isRich; }
149 #endif
150
151 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
152 WXUINT message, WXWPARAM wParam,
153 WXLPARAM lParam);
154
155 virtual void AdoptAttributesFromHWND();
156 virtual void SetupColours();
157 virtual long MSWGetDlgCode();
158
159 protected:
160 #if wxUSE_RICHEDIT
161 bool m_isRich; // Are we using rich text edit to implement this?
162 #endif
163
164 wxString m_fileName;
165
166 virtual void DoSetSize(int x, int y,
167 int width, int height,
168 int sizeFlags = wxSIZE_AUTO);
169
170 private:
171 DECLARE_EVENT_TABLE()
172 };
173
174 #endif
175 // _WX_TEXTCTRL_H_