]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/textctrl.h
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"
19 class WXDLLEXPORT wxTextCtrl
: public wxTextCtrlBase
25 wxTextCtrl() { Init(); }
26 wxTextCtrl(wxWindow
*parent
, wxWindowID id
,
27 const wxString
& value
= wxEmptyString
,
28 const wxPoint
& pos
= wxDefaultPosition
,
29 const wxSize
& size
= wxDefaultSize
,
31 const wxValidator
& validator
= wxDefaultValidator
,
32 const wxString
& name
= wxTextCtrlNameStr
)
36 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
39 bool Create(wxWindow
*parent
, wxWindowID id
,
40 const wxString
& value
= wxEmptyString
,
41 const wxPoint
& pos
= wxDefaultPosition
,
42 const wxSize
& size
= wxDefaultSize
,
44 const wxValidator
& validator
= wxDefaultValidator
,
45 const wxString
& name
= wxTextCtrlNameStr
);
47 // implement base class pure virtuals
48 // ----------------------------------
50 virtual wxString
GetValue() const;
51 virtual void SetValue(const wxString
& value
);
53 virtual int GetLineLength(long lineNo
) const;
54 virtual wxString
GetLineText(long lineNo
) const;
55 virtual int GetNumberOfLines() const;
57 virtual bool IsModified() const;
58 virtual bool IsEditable() const;
60 virtual void GetSelection(long* from
, long* to
) const;
61 virtual wxString
GetStringSelection() const;
68 virtual void Replace(long from
, long to
, const wxString
& value
);
69 virtual void Remove(long from
, long to
);
71 // load the controls contents from the file
72 virtual bool LoadFile(const wxString
& file
);
74 // clears the dirty flag
75 virtual void DiscardEdits();
77 virtual void SetMaxLength(unsigned long len
);
79 // writing text inserts it at the current position, appending always
80 // inserts it at the end
81 virtual void WriteText(const wxString
& text
);
82 virtual void AppendText(const wxString
& text
);
85 // apply text attribute to the range of text (only works with richedit
87 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
88 #endif // wxUSE_RICHEDIT
90 // translate between the position (which is just an index in the text ctrl
91 // considering all its contents as a single strings) and (x, y) coordinates
92 // which represent column and line.
93 virtual long XYToPosition(long x
, long y
) const;
94 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
96 virtual void ShowPosition(long pos
);
98 // Clipboard operations
101 virtual void Paste();
103 virtual bool CanCopy() const;
104 virtual bool CanCut() const;
105 virtual bool CanPaste() const;
111 virtual bool CanUndo() const;
112 virtual bool CanRedo() const;
115 virtual void SetInsertionPoint(long pos
);
116 virtual void SetInsertionPointEnd();
117 virtual long GetInsertionPoint() const;
118 virtual long GetLastPosition() const;
120 virtual void SetSelection(long from
, long to
);
121 virtual void SetEditable(bool editable
);
123 // Implementation from now on
124 // --------------------------
126 virtual void Command(wxCommandEvent
& event
);
127 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
128 virtual WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
129 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
131 // In WIN16, need to override normal erasing because
132 // Ctl3D doesn't use the wxWindows background colour.
134 void OnEraseBackground(wxEraseEvent
& event
);
138 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
140 int GetRichVersion() const { return m_verRichEdit
; }
141 bool IsRich() const { return m_verRichEdit
!= 0; }
143 // rich edit controls are not compatible with normal ones and wem ust set
144 // the colours for them otherwise
145 virtual bool SetBackgroundColour(const wxColour
& colour
);
146 virtual bool SetForegroundColour(const wxColour
& colour
);
147 #endif // wxUSE_RICHEDIT
149 virtual void AdoptAttributesFromHWND();
151 virtual bool AcceptsFocus() const;
154 void OnDropFiles(wxDropFilesEvent
& event
);
155 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
157 void OnCut(wxCommandEvent
& event
);
158 void OnCopy(wxCommandEvent
& event
);
159 void OnPaste(wxCommandEvent
& event
);
160 void OnUndo(wxCommandEvent
& event
);
161 void OnRedo(wxCommandEvent
& event
);
163 void OnUpdateCut(wxUpdateUIEvent
& event
);
164 void OnUpdateCopy(wxUpdateUIEvent
& event
);
165 void OnUpdatePaste(wxUpdateUIEvent
& event
);
166 void OnUpdateUndo(wxUpdateUIEvent
& event
);
167 void OnUpdateRedo(wxUpdateUIEvent
& event
);
170 // common part of all ctors
173 // call this to increase the size limit (will do nothing if the current
174 // limit is big enough)
176 // returns true if we increased the limit to allow entering more text,
177 // false if we hit the limit set by SetMaxLength() and so didn't change it
178 bool AdjustSpaceLimit();
181 // replace the selection with the given text in the specified encoding
182 bool StreamIn(const wxString
& value
, wxFontEncoding encoding
);
183 #endif // wxUSE_RICHEDIT
185 // set the selection possibly without scrolling the caret into view
186 void DoSetSelection(long from
, long to
, bool scrollCaret
= TRUE
);
188 // override some base class virtuals
189 virtual bool MSWShouldPreProcessMessage(WXMSG
* pMsg
);
190 virtual wxSize
DoGetBestSize() const;
193 // we're using RICHEDIT (and not simple EDIT) control if this field is not
194 // 0, it also gives the version of the RICHEDIT control being used (1, 2 or
197 #endif // wxUSE_RICHEDIT
200 DECLARE_EVENT_TABLE()
201 DECLARE_DYNAMIC_CLASS(wxTextCtrl
)