]>
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"
19 // can we use RICHEDIT class for wxTextCtrl implementation?
20 #if defined(__WIN95__) && !defined(__TWIN32__) && !defined(__WXWINE__)
21 #define wxUSE_RICHEDIT 1
23 #define wxUSE_RICHEDIT 0
26 class WXDLLEXPORT wxTextCtrl
: public wxTextCtrlBase
33 wxTextCtrl(wxWindow
*parent
, wxWindowID id
,
34 const wxString
& value
= wxEmptyString
,
35 const wxPoint
& pos
= wxDefaultPosition
,
36 const wxSize
& size
= wxDefaultSize
,
38 const wxValidator
& validator
= wxDefaultValidator
,
39 const wxString
& name
= wxTextCtrlNameStr
)
41 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
44 bool Create(wxWindow
*parent
, wxWindowID id
,
45 const wxString
& value
= wxEmptyString
,
46 const wxPoint
& pos
= wxDefaultPosition
,
47 const wxSize
& size
= wxDefaultSize
,
49 const wxValidator
& validator
= wxDefaultValidator
,
50 const wxString
& name
= wxTextCtrlNameStr
);
52 // implement base class pure virtuals
53 // ----------------------------------
55 virtual wxString
GetValue() const;
56 virtual void SetValue(const wxString
& value
);
58 virtual int GetLineLength(long lineNo
) const;
59 virtual wxString
GetLineText(long lineNo
) const;
60 virtual int GetNumberOfLines() const;
62 virtual bool IsModified() const;
63 virtual bool IsEditable() const;
65 // If the return values from and to are the same, there is no selection.
66 virtual void GetSelection(long* from
, long* to
) const;
73 virtual void Replace(long from
, long to
, const wxString
& value
);
74 virtual void Remove(long from
, long to
);
76 // load the controls contents from the file
77 virtual bool LoadFile(const wxString
& file
);
79 // clears the dirty flag
80 virtual void DiscardEdits();
82 // writing text inserts it at the current position, appending always
83 // inserts it at the end
84 virtual void WriteText(const wxString
& text
);
85 virtual void AppendText(const wxString
& text
);
87 // translate between the position (which is just an index in the text ctrl
88 // considering all its contents as a single strings) and (x, y) coordinates
89 // which represent column and line.
90 virtual long XYToPosition(long x
, long y
) const;
91 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
93 virtual void ShowPosition(long pos
);
95 // Clipboard operations
100 virtual bool CanCopy() const;
101 virtual bool CanCut() const;
102 virtual bool CanPaste() const;
108 virtual bool CanUndo() const;
109 virtual bool CanRedo() const;
112 virtual void SetInsertionPoint(long pos
);
113 virtual void SetInsertionPointEnd();
114 virtual long GetInsertionPoint() const;
115 virtual long GetLastPosition() const;
117 virtual void SetSelection(long from
, long to
);
118 virtual void SetEditable(bool editable
);
120 // Implementation from now on
121 // --------------------------
123 virtual void Command(wxCommandEvent
& event
);
124 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
127 bool IsRich() const { return m_isRich
; }
128 void SetRichEdit(bool isRich
) { m_isRich
= isRich
; }
129 #endif // wxUSE_RICHEDIT
131 virtual void AdoptAttributesFromHWND();
132 virtual void SetupColours();
134 virtual bool AcceptsFocus() const;
137 void OnDropFiles(wxDropFilesEvent
& event
);
138 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
140 void OnCut(wxCommandEvent
& event
);
141 void OnCopy(wxCommandEvent
& event
);
142 void OnPaste(wxCommandEvent
& event
);
143 void OnUndo(wxCommandEvent
& event
);
144 void OnRedo(wxCommandEvent
& event
);
146 void OnUpdateCut(wxUpdateUIEvent
& event
);
147 void OnUpdateCopy(wxUpdateUIEvent
& event
);
148 void OnUpdatePaste(wxUpdateUIEvent
& event
);
149 void OnUpdateUndo(wxUpdateUIEvent
& event
);
150 void OnUpdateRedo(wxUpdateUIEvent
& event
);
154 bool m_isRich
; // Are we using rich text edit to implement this?
157 // call this to increase the size limit (will do nothing if the current
158 // limit is big enough)
159 void AdjustSpaceLimit();
161 virtual wxSize
DoGetBestSize() const;
164 DECLARE_EVENT_TABLE()
165 DECLARE_DYNAMIC_CLASS(wxTextCtrl
)