]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/textctrl.h
removed WXUSINGDLL_FOO, one WXUSINGDLL is enough
[wxWidgets.git] / include / wx / mac / textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: textctrl.h
3 // Purpose: wxTextCtrl class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TEXTCTRL_H_
13 #define _WX_TEXTCTRL_H_
14
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "textctrl.h"
17 #endif
18
19 #include "wx/control.h"
20
21 WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr;
22
23 // Single-line text item
24 class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase
25 {
26 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
27
28 public:
29 // creation
30 // --------
31 wxTextCtrl();
32 ~wxTextCtrl();
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)
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
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
65 // operations
66 // ----------
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
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
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
103 // Clipboard operations
104 virtual void Copy();
105 virtual void Cut();
106 virtual void Paste();
107
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
120 virtual void SetInsertionPoint(long pos);
121 virtual void SetInsertionPointEnd();
122 virtual long GetInsertionPoint() const;
123 virtual long GetLastPosition() const;
124
125 virtual void SetSelection(long from, long to);
126 virtual void SetEditable(bool editable);
127
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
153 virtual bool MacCanFocus() const { return true ; }
154 virtual bool MacSetupCursor( const wxPoint& pt ) ;
155
156 virtual void MacSuperShown( bool show ) ;
157 virtual bool Show(bool show = TRUE) ;
158
159 protected:
160 virtual wxSize DoGetBestSize() const;
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 ;
168 unsigned long m_maxLength ;
169
170 DECLARE_EVENT_TABLE()
171 };
172
173 #endif
174 // _WX_TEXTCTRL_H_