]>
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 void 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 WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
132 WXUINT message
, WXWPARAM wParam
,
135 virtual void AdoptAttributesFromHWND();
136 virtual void SetupColours();
138 virtual bool AcceptsFocus() const;
141 void OnDropFiles(wxDropFilesEvent
& event
);
142 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
144 void OnCut(wxCommandEvent
& event
);
145 void OnCopy(wxCommandEvent
& event
);
146 void OnPaste(wxCommandEvent
& event
);
147 void OnUndo(wxCommandEvent
& event
);
148 void OnRedo(wxCommandEvent
& event
);
150 void OnUpdateCut(wxUpdateUIEvent
& event
);
151 void OnUpdateCopy(wxUpdateUIEvent
& event
);
152 void OnUpdatePaste(wxUpdateUIEvent
& event
);
153 void OnUpdateUndo(wxUpdateUIEvent
& event
);
154 void OnUpdateRedo(wxUpdateUIEvent
& event
);
158 bool m_isRich
; // Are we using rich text edit to implement this?
161 // call this to increase the size limit (will do nothing if the current
162 // limit is big enough)
163 void AdjustSpaceLimit();
165 virtual wxSize
DoGetBestSize();
168 DECLARE_EVENT_TABLE()
169 DECLARE_DYNAMIC_CLASS(wxTextCtrl
)