]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "textctrl.h"
19 #include "wx/control.h"
21 WXDLLEXPORT_DATA(extern const wxChar
*) wxTextCtrlNameStr
;
23 // Single-line text item
24 class WXDLLEXPORT wxTextCtrl
: public wxTextCtrlBase
26 DECLARE_DYNAMIC_CLASS(wxTextCtrl
)
31 wxTextCtrl() { Init(); }
33 wxTextCtrl(wxWindow
*parent
, wxWindowID id
,
34 const wxString
& value
= wxEmptyString
,
35 const wxPoint
& pos
= wxDefaultPosition
,
36 const wxSize
& size
= wxDefaultSize
, long style
= 0,
37 const wxValidator
& validator
= wxDefaultValidator
,
38 const wxString
& name
= wxTextCtrlNameStr
)
42 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
45 bool Create(wxWindow
*parent
, wxWindowID id
,
46 const wxString
& value
= wxEmptyString
,
47 const wxPoint
& pos
= wxDefaultPosition
,
48 const wxSize
& size
= wxDefaultSize
, long style
= 0,
49 const wxValidator
& validator
= wxDefaultValidator
,
50 const wxString
& name
= wxTextCtrlNameStr
);
54 virtual wxString
GetValue() const ;
55 virtual void SetValue(const wxString
& value
);
57 virtual int GetLineLength(long lineNo
) const;
58 virtual wxString
GetLineText(long lineNo
) const;
59 virtual int GetNumberOfLines() const;
61 virtual bool IsModified() const;
62 virtual bool IsEditable() const;
64 // If the return values from and to are the same, there is no selection.
65 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 // set the max number of characters which may be entered in a single line
84 virtual void SetMaxLength(unsigned long len
) ;
86 // text control under some platforms supports the text styles: these
87 // methods allow to apply the given text style to the given selection or to
88 // set/get the style which will be used for all appended text
89 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
90 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
92 // writing text inserts it at the current position, appending always
93 // inserts it at the end
94 virtual void WriteText(const wxString
& text
);
95 virtual void AppendText(const wxString
& text
);
97 // translate between the position (which is just an index in the text ctrl
98 // considering all its contents as a single strings) and (x, y) coordinates
99 // which represent column and line.
100 virtual long XYToPosition(long x
, long y
) const;
101 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
103 virtual void ShowPosition(long pos
);
105 // Clipboard operations
108 virtual void Paste();
110 virtual bool CanCopy() const;
111 virtual bool CanCut() const;
112 virtual bool CanPaste() const;
118 virtual bool CanUndo() const;
119 virtual bool CanRedo() const;
122 virtual void SetInsertionPoint(long pos
);
123 virtual void SetInsertionPointEnd();
124 virtual long GetInsertionPoint() const;
125 virtual long GetLastPosition() const;
127 virtual void SetSelection(long from
, long to
);
128 virtual void SetEditable(bool editable
);
130 // Implementation from now on
131 // --------------------------
135 virtual void Command(wxCommandEvent
& event
);
137 virtual bool AcceptsFocus() const;
140 void OnDropFiles(wxDropFilesEvent
& event
);
141 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
143 void OnCut(wxCommandEvent
& event
);
144 void OnCopy(wxCommandEvent
& event
);
145 void OnPaste(wxCommandEvent
& event
);
146 void OnUndo(wxCommandEvent
& event
);
147 void OnRedo(wxCommandEvent
& event
);
149 void OnUpdateCut(wxUpdateUIEvent
& event
);
150 void OnUpdateCopy(wxUpdateUIEvent
& event
);
151 void OnUpdatePaste(wxUpdateUIEvent
& event
);
152 void OnUpdateUndo(wxUpdateUIEvent
& event
);
153 void OnUpdateRedo(wxUpdateUIEvent
& event
);
155 virtual bool MacCanFocus() const { return true ; }
156 virtual bool MacSetupCursor( const wxPoint
& pt
) ;
158 virtual void MacSuperShown( bool show
) ;
159 virtual bool Show(bool show
= TRUE
) ;
162 // common part of all ctors
165 virtual wxSize
DoGetBestSize() const;
169 // flag is set to true when the user edits the controls contents
172 // one of the following objects is used for representation, the other one is NULL
177 unsigned long m_maxLength
;
179 DECLARE_EVENT_TABLE()