]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTextCtrl class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_TEXTCTRL_H_
13 #define _WX_TEXTCTRL_H_
16 #pragma interface "textctrl.h"
20 #include "wx/control.h"
28 #if defined(__WIN95__) && !defined(__TWIN32__) && !defined(__WXWINE__)
29 #define wxUSE_RICHEDIT 1
31 #define wxUSE_RICHEDIT 0
34 WXDLLEXPORT_DATA(extern const wxChar
*) wxTextCtrlNameStr
;
35 WXDLLEXPORT_DATA(extern const wxChar
*) wxEmptyString
;
37 // Single-line text item
38 class WXDLLEXPORT wxTextCtrl
: public wxControl
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 :-(
44 #if (defined(__BORLANDC__)) || defined(__MWERKS__) || defined(_WINDLL) || defined(WXUSINGDLL) || defined(WXMAKINGDLL)
45 #define NO_TEXT_WINDOW_STREAM
48 #ifndef NO_TEXT_WINDOW_STREAM
53 DECLARE_DYNAMIC_CLASS(wxTextCtrl
)
59 wxTextCtrl(wxWindow
*parent
, wxWindowID id
,
60 const wxString
& value
= wxEmptyString
,
61 const wxPoint
& pos
= wxDefaultPosition
,
62 const wxSize
& size
= wxDefaultSize
,
64 const wxValidator
& validator
= wxDefaultValidator
,
65 const wxString
& name
= wxTextCtrlNameStr
)
66 #ifndef NO_TEXT_WINDOW_STREAM
70 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
73 bool Create(wxWindow
*parent
, wxWindowID id
,
74 const wxString
& value
= wxEmptyString
,
75 const wxPoint
& pos
= wxDefaultPosition
,
76 const wxSize
& size
= wxDefaultSize
,
78 const wxValidator
& validator
= wxDefaultValidator
,
79 const wxString
& name
= wxTextCtrlNameStr
);
84 virtual wxString
GetValue() const;
85 virtual void SetValue(const wxString
& value
);
87 virtual int GetLineLength(long lineNo
) const;
88 virtual wxString
GetLineText(long lineNo
) const;
89 virtual int GetNumberOfLines() const;
94 // Clipboard operations
99 virtual bool CanCopy() const;
100 virtual bool CanCut() const;
101 virtual bool CanPaste() const;
107 virtual bool CanUndo() const;
108 virtual bool CanRedo() const;
110 virtual void SetInsertionPoint(long pos
);
111 virtual void SetInsertionPointEnd();
112 virtual long GetInsertionPoint() const ;
113 virtual long GetLastPosition() const ;
114 virtual void Replace(long from
, long to
, const wxString
& value
);
115 virtual void Remove(long from
, long to
);
116 virtual void SetSelection(long from
, long to
);
117 virtual void SetEditable(bool editable
);
119 // If the return values from and to are the same, there is no
121 virtual void GetSelection(long* from
, long* to
) const;
122 virtual bool IsEditable() const ;
124 // streambuf implementation
125 #ifndef NO_TEXT_WINDOW_STREAM
131 wxTextCtrl
& operator<<(const wxString
& s
);
132 wxTextCtrl
& operator<<(int i
);
133 wxTextCtrl
& operator<<(long i
);
134 wxTextCtrl
& operator<<(float f
);
135 wxTextCtrl
& operator<<(double d
);
136 wxTextCtrl
& operator<<(const char c
);
138 virtual bool LoadFile(const wxString
& file
);
139 virtual bool SaveFile(const wxString
& file
);
140 virtual void WriteText(const wxString
& text
);
141 virtual void AppendText(const wxString
& text
);
142 virtual void DiscardEdits();
143 virtual bool IsModified() const;
145 #if WXWIN_COMPATIBILITY
146 inline bool Modified() const { return IsModified(); }
149 virtual long XYToPosition(long x
, long y
) const ;
150 virtual void PositionToXY(long pos
, long *x
, long *y
) const ;
151 virtual void ShowPosition(long pos
);
152 virtual void Clear();
154 // Implementation from now on
155 // --------------------------
157 virtual void Command(wxCommandEvent
& event
);
158 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
161 bool IsRich() const { return m_isRich
; }
162 void SetRichEdit(bool isRich
) { m_isRich
= isRich
; }
165 virtual WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
166 WXUINT message
, WXWPARAM wParam
,
169 virtual void AdoptAttributesFromHWND();
170 virtual void SetupColours();
172 virtual bool AcceptsFocus() const;
176 void OnDropFiles(wxDropFilesEvent
& event
);
177 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
179 void OnCut(wxCommandEvent
& event
);
180 void OnCopy(wxCommandEvent
& event
);
181 void OnPaste(wxCommandEvent
& event
);
182 void OnUndo(wxCommandEvent
& event
);
183 void OnRedo(wxCommandEvent
& event
);
185 void OnUpdateCut(wxUpdateUIEvent
& event
);
186 void OnUpdateCopy(wxUpdateUIEvent
& event
);
187 void OnUpdatePaste(wxUpdateUIEvent
& event
);
188 void OnUpdateUndo(wxUpdateUIEvent
& event
);
189 void OnUpdateRedo(wxUpdateUIEvent
& event
);
193 bool m_isRich
; // Are we using rich text edit to implement this?
198 // call this to increase the size limit (will do nothing if the current
199 // limit is big enough)
200 void AdjustSpaceLimit();
202 virtual wxSize
DoGetBestSize();
205 DECLARE_EVENT_TABLE()