]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/textctrl.h
added wxVListBox::OnDrawBackground(); fixed warnings
[wxWidgets.git] / include / wx / mac / textctrl.h
CommitLineData
0dbd6262
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: textctrl.h
3// Purpose: wxTextCtrl class
a31a5f85 4// Author: Stefan Csomor
0dbd6262 5// Modified by:
a31a5f85 6// Created: 1998-01-01
0dbd6262 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
e40298d5 9// Licence: wxWindows licence
0dbd6262
SC
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_TEXTCTRL_H_
13#define _WX_TEXTCTRL_H_
14
af49c4b8 15#if defined(__GNUG__) && !defined(__APPLE__)
0dbd6262
SC
16#pragma interface "textctrl.h"
17#endif
18
19#include "wx/control.h"
20
c4e41ce3 21WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr;
0dbd6262
SC
22
23// Single-line text item
05adb9d2 24class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase
0dbd6262
SC
25{
26 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
27
28public:
29 // creation
30 // --------
31 wxTextCtrl();
8481948e 32 ~wxTextCtrl();
0dbd6262
SC
33 inline 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)
0dbd6262
SC
39 {
40 Create(parent, id, value, pos, size, style, validator, name);
41 }
42
43 bool Create(wxWindow *parent, wxWindowID id,
44 const wxString& value = wxEmptyString,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize, long style = 0,
47 const wxValidator& validator = wxDefaultValidator,
48 const wxString& name = wxTextCtrlNameStr);
49
50 // accessors
51 // ---------
52 virtual wxString GetValue() const ;
53 virtual void SetValue(const wxString& value);
54
55 virtual int GetLineLength(long lineNo) const;
56 virtual wxString GetLineText(long lineNo) const;
57 virtual int GetNumberOfLines() const;
58
05adb9d2
SC
59 virtual bool IsModified() const;
60 virtual bool IsEditable() const;
61
62 // If the return values from and to are the same, there is no selection.
63 virtual void GetSelection(long* from, long* to) const;
64
0dbd6262
SC
65 // operations
66 // ----------
05adb9d2
SC
67
68 // editing
69
70 virtual void Clear();
71 virtual void Replace(long from, long to, const wxString& value);
72 virtual void Remove(long from, long to);
73
74 // load the controls contents from the file
75 virtual bool LoadFile(const wxString& file);
76
77 // clears the dirty flag
78 virtual void DiscardEdits();
79
f8d5f1e2
SC
80 // set the max number of characters which may be entered in a single line
81 // text control
82 virtual void SetMaxLength(unsigned long len) ;
83
84 // text control under some platforms supports the text styles: these
85 // methods allow to apply the given text style to the given selection or to
86 // set/get the style which will be used for all appended text
87 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
88 virtual bool SetDefaultStyle(const wxTextAttr& style);
89
05adb9d2
SC
90 // writing text inserts it at the current position, appending always
91 // inserts it at the end
92 virtual void WriteText(const wxString& text);
93 virtual void AppendText(const wxString& text);
94
95 // translate between the position (which is just an index in the text ctrl
96 // considering all its contents as a single strings) and (x, y) coordinates
97 // which represent column and line.
98 virtual long XYToPosition(long x, long y) const;
99 virtual bool PositionToXY(long pos, long *x, long *y) const;
100
101 virtual void ShowPosition(long pos);
102
0dbd6262
SC
103 // Clipboard operations
104 virtual void Copy();
105 virtual void Cut();
106 virtual void Paste();
107
05adb9d2
SC
108 virtual bool CanCopy() const;
109 virtual bool CanCut() const;
110 virtual bool CanPaste() const;
111
112 // Undo/redo
113 virtual void Undo();
114 virtual void Redo();
115
116 virtual bool CanUndo() const;
117 virtual bool CanRedo() const;
118
119 // Insertion point
0dbd6262
SC
120 virtual void SetInsertionPoint(long pos);
121 virtual void SetInsertionPointEnd();
05adb9d2
SC
122 virtual long GetInsertionPoint() const;
123 virtual long GetLastPosition() const;
124
0dbd6262
SC
125 virtual void SetSelection(long from, long to);
126 virtual void SetEditable(bool editable);
0dbd6262 127
05adb9d2
SC
128 // Implementation from now on
129 // --------------------------
130
131 // Implementation
132 // --------------
133 virtual void Command(wxCommandEvent& event);
134
135 virtual bool AcceptsFocus() const;
136
137 // callbacks
138 void OnDropFiles(wxDropFilesEvent& event);
139 void OnChar(wxKeyEvent& event); // Process 'enter' if required
140
141 void OnCut(wxCommandEvent& event);
142 void OnCopy(wxCommandEvent& event);
143 void OnPaste(wxCommandEvent& event);
144 void OnUndo(wxCommandEvent& event);
145 void OnRedo(wxCommandEvent& event);
146
147 void OnUpdateCut(wxUpdateUIEvent& event);
148 void OnUpdateCopy(wxUpdateUIEvent& event);
149 void OnUpdatePaste(wxUpdateUIEvent& event);
150 void OnUpdateUndo(wxUpdateUIEvent& event);
151 void OnUpdateRedo(wxUpdateUIEvent& event);
152
e40298d5 153 virtual bool MacCanFocus() const { return true ; }
2b5f62a0
VZ
154 virtual bool MacSetupCursor( const wxPoint& pt ) ;
155
e40298d5
JS
156 virtual void MacSuperShown( bool show ) ;
157 virtual bool Show(bool show = TRUE) ;
6fda4e7a 158
0dbd6262 159protected:
05adb9d2 160 virtual wxSize DoGetBestSize() const;
8481948e
SC
161
162 bool m_editable ;
163 // one of the following objects is used for representation, the other one is NULL
164 void* m_macTE ;
165 void* m_macTXN ;
166 void* m_macTXNvars ;
167 bool m_macUsesTXN ;
f8d5f1e2 168 unsigned long m_maxLength ;
0dbd6262
SC
169
170 DECLARE_EVENT_TABLE()
171};
172
173#endif
174 // _WX_TEXTCTRL_H_