]>
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(); }
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 // load the controls contents from the file
73 virtual bool LoadFile(const wxString
& file
);
75 // sets/clears the dirty flag
76 virtual void MarkDirty();
77 virtual void DiscardEdits();
79 // set the max number of characters which may be entered in a single line
81 virtual void SetMaxLength(unsigned long len
) ;
83 // text control under some platforms supports the text styles: these
84 // methods allow to apply the given text style to the given selection or to
85 // set/get the style which will be used for all appended text
86 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
87 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
89 // writing text inserts it at the current position, appending always
90 // inserts it at the end
91 virtual void WriteText(const wxString
& text
);
92 virtual void AppendText(const wxString
& text
);
94 // translate between the position (which is just an index in the text ctrl
95 // considering all its contents as a single strings) and (x, y) coordinates
96 // which represent column and line.
97 virtual long XYToPosition(long x
, long y
) const;
98 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
100 virtual void ShowPosition(long pos
);
102 // Clipboard operations
105 virtual void Paste();
107 virtual bool CanCopy() const;
108 virtual bool CanCut() const;
109 virtual bool CanPaste() const;
115 virtual bool CanUndo() const;
116 virtual bool CanRedo() const;
119 virtual void SetInsertionPoint(long pos
);
120 virtual void SetInsertionPointEnd();
121 virtual long GetInsertionPoint() const;
122 virtual wxTextPos
GetLastPosition() const;
124 virtual void SetSelection(long from
, long to
);
125 virtual void SetEditable(bool editable
);
127 // Implementation from now on
128 // --------------------------
132 virtual void Command(wxCommandEvent
& event
);
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
);
152 virtual bool MacCanFocus() const { return true ; }
153 virtual bool MacSetupCursor( const wxPoint
& pt
) ;
155 virtual void MacSuperShown( bool show
) ;
156 virtual bool Show(bool show
= true) ;
159 // common part of all ctors
162 virtual wxSize
DoGetBestSize() const;
166 // flag is set to true when the user edits the controls contents
169 // one of the following objects is used for representation, the other one is NULL
174 unsigned long m_maxLength
;
176 DECLARE_EVENT_TABLE()