]>
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__)
29 #define wxUSE_RICHEDIT 1
31 #define wxUSE_RICHEDIT 0
34 WXDLLEXPORT_DATA(extern const char*) wxTextCtrlNameStr
;
35 WXDLLEXPORT_DATA(extern const char*) 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 inline 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
69 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
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
);
81 virtual wxString
GetValue() const ;
82 virtual void SetValue(const wxString
& value
);
84 virtual int GetLineLength(long lineNo
) const;
85 virtual wxString
GetLineText(long lineNo
) const;
86 virtual int GetNumberOfLines() const;
90 virtual void SetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
91 void SetSize(const wxRect
& rect
, int sizeFlags
= wxSIZE_AUTO
)
92 { wxWindow::SetSize(rect
, sizeFlags
); }
93 void SetSize(const wxSize
& size
) { wxWindow::SetSize(size
); }
95 // Clipboard operations
100 virtual void SetInsertionPoint(long pos
);
101 virtual void SetInsertionPointEnd();
102 virtual long GetInsertionPoint() const ;
103 virtual long GetLastPosition() const ;
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
);
107 virtual void SetEditable(bool editable
);
109 // streambuf implementation
110 #ifndef NO_TEXT_WINDOW_STREAM
116 wxTextCtrl
& operator<<(const wxString
& s
);
117 wxTextCtrl
& operator<<(int i
);
118 wxTextCtrl
& operator<<(long i
);
119 wxTextCtrl
& operator<<(float f
);
120 wxTextCtrl
& operator<<(double d
);
121 wxTextCtrl
& operator<<(const char c
);
123 virtual bool LoadFile(const wxString
& file
);
124 virtual bool SaveFile(const wxString
& file
);
125 virtual void WriteText(const wxString
& text
);
126 virtual void AppendText(const wxString
& text
);
127 virtual void DiscardEdits();
128 virtual bool IsModified() const;
130 #if WXWIN_COMPATIBILITY
131 inline bool Modified() const { return IsModified(); }
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
);
137 virtual void Clear();
141 void OnDropFiles(wxDropFilesEvent
& event
);
142 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
143 void OnEraseBackground(wxEraseEvent
& event
);
147 virtual void Command(wxCommandEvent
& event
);
148 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
151 bool IsRich() const { return m_isRich
; }
152 void SetRichEdit(bool isRich
) { m_isRich
= isRich
; }
155 virtual WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
156 WXUINT message
, WXWPARAM wParam
,
159 virtual void AdoptAttributesFromHWND();
160 virtual void SetupColours();
161 virtual long MSWGetDlgCode();
165 bool m_isRich
; // Are we using rich text edit to implement this?
170 DECLARE_EVENT_TABLE()