]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/classic/textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTextCtrl class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_TEXTCTRL_H_
13 #define _WX_TEXTCTRL_H_
15 #include "wx/control.h"
17 WXDLLEXPORT_DATA(extern const wxChar
) wxTextCtrlNameStr
[];
19 // Single-line text item
20 class WXDLLEXPORT wxTextCtrl
: public wxTextCtrlBase
22 DECLARE_DYNAMIC_CLASS(wxTextCtrl
)
27 wxTextCtrl() { Init(); }
28 virtual ~wxTextCtrl();
29 wxTextCtrl(wxWindow
*parent
, wxWindowID id
,
30 const wxString
& value
= wxEmptyString
,
31 const wxPoint
& pos
= wxDefaultPosition
,
32 const wxSize
& size
= wxDefaultSize
, long style
= 0,
33 const wxValidator
& validator
= wxDefaultValidator
,
34 const wxString
& name
= wxTextCtrlNameStr
)
38 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
41 bool Create(wxWindow
*parent
, wxWindowID id
,
42 const wxString
& value
= wxEmptyString
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
, long style
= 0,
45 const wxValidator
& validator
= wxDefaultValidator
,
46 const wxString
& name
= wxTextCtrlNameStr
);
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 // If the return values from and to are the same, there is no selection.
61 virtual void GetSelection(long* from
, long* to
) const;
69 virtual void Replace(long from
, long to
, const wxString
& value
);
70 virtual void Remove(long from
, long to
);
72 // sets/clears the dirty flag
73 virtual void MarkDirty();
74 virtual void DiscardEdits();
76 // set the max number of characters which may be entered in a single line
78 virtual void SetMaxLength(unsigned long len
) ;
80 // text control under some platforms supports the text styles: these
81 // methods allow to apply the given text style to the given selection or to
82 // set/get the style which will be used for all appended text
83 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
84 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
86 // writing text inserts it at the current position, appending always
87 // inserts it at the end
88 virtual void WriteText(const wxString
& text
);
89 virtual void AppendText(const wxString
& text
);
91 // translate between the position (which is just an index in the text ctrl
92 // considering all its contents as a single strings) and (x, y) coordinates
93 // which represent column and line.
94 virtual long XYToPosition(long x
, long y
) const;
95 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
97 virtual void ShowPosition(long pos
);
99 // Clipboard operations
102 virtual void Paste();
104 virtual bool CanCopy() const;
105 virtual bool CanCut() const;
106 virtual bool CanPaste() const;
112 virtual bool CanUndo() const;
113 virtual bool CanRedo() const;
116 virtual void SetInsertionPoint(long pos
);
117 virtual void SetInsertionPointEnd();
118 virtual long GetInsertionPoint() const;
119 virtual wxTextPos
GetLastPosition() const;
121 virtual void SetSelection(long from
, long to
);
122 virtual void SetEditable(bool editable
);
124 // Implementation from now on
125 // --------------------------
129 virtual void Command(wxCommandEvent
& event
);
131 virtual bool AcceptsFocus() const;
134 void OnDropFiles(wxDropFilesEvent
& event
);
135 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
137 void OnCut(wxCommandEvent
& event
);
138 void OnCopy(wxCommandEvent
& event
);
139 void OnPaste(wxCommandEvent
& event
);
140 void OnUndo(wxCommandEvent
& event
);
141 void OnRedo(wxCommandEvent
& event
);
143 void OnUpdateCut(wxUpdateUIEvent
& event
);
144 void OnUpdateCopy(wxUpdateUIEvent
& event
);
145 void OnUpdatePaste(wxUpdateUIEvent
& event
);
146 void OnUpdateUndo(wxUpdateUIEvent
& event
);
147 void OnUpdateRedo(wxUpdateUIEvent
& event
);
149 virtual bool MacCanFocus() const { return true ; }
150 virtual bool MacSetupCursor( const wxPoint
& pt
) ;
152 virtual void MacSuperShown( bool show
) ;
153 virtual bool Show(bool show
= true) ;
156 // common part of all ctors
159 virtual wxSize
DoGetBestSize() const;
163 // flag is set to true when the user edits the controls contents
166 // one of the following objects is used for representation, the other one is NULL
171 unsigned long m_maxLength
;
173 DECLARE_EVENT_TABLE()