]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/textctrl.h
Dan 'Bud' Keith's Implementation
[wxWidgets.git] / include / wx / mac / textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: textctrl.h
3 // Purpose: wxTextCtrl class
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TEXTCTRL_H_
13 #define _WX_TEXTCTRL_H_
14
15 #ifdef __GNUG__
16 #pragma interface "textctrl.h"
17 #endif
18
19 #include "wx/control.h"
20
21 WXDLLEXPORT_DATA(extern const char*) wxTextCtrlNameStr;
22 WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
23
24 // Single-line text item
25 class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase
26 {
27 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
28
29 public:
30 // creation
31 // --------
32 wxTextCtrl();
33 ~wxTextCtrl();
34 inline wxTextCtrl(wxWindow *parent, wxWindowID id,
35 const wxString& value = wxEmptyString,
36 const wxPoint& pos = wxDefaultPosition,
37 const wxSize& size = wxDefaultSize, long style = 0,
38 const wxValidator& validator = wxDefaultValidator,
39 const wxString& name = wxTextCtrlNameStr)
40 {
41 Create(parent, id, value, pos, size, style, validator, name);
42 }
43
44 bool Create(wxWindow *parent, wxWindowID id,
45 const wxString& value = wxEmptyString,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize, long style = 0,
48 const wxValidator& validator = wxDefaultValidator,
49 const wxString& name = wxTextCtrlNameStr);
50
51 // accessors
52 // ---------
53 virtual wxString GetValue() const ;
54 virtual void SetValue(const wxString& value);
55
56 virtual int GetLineLength(long lineNo) const;
57 virtual wxString GetLineText(long lineNo) const;
58 virtual int GetNumberOfLines() const;
59
60 virtual bool IsModified() const;
61 virtual bool IsEditable() const;
62
63 // If the return values from and to are the same, there is no selection.
64 virtual void GetSelection(long* from, long* to) const;
65
66 // operations
67 // ----------
68
69 // editing
70
71 virtual void Clear();
72 virtual void Replace(long from, long to, const wxString& value);
73 virtual void Remove(long from, long to);
74
75 // load the controls contents from the file
76 virtual bool LoadFile(const wxString& file);
77
78 // clears the dirty flag
79 virtual void DiscardEdits();
80
81 // writing text inserts it at the current position, appending always
82 // inserts it at the end
83 virtual void WriteText(const wxString& text);
84 virtual void AppendText(const wxString& text);
85
86 // translate between the position (which is just an index in the text ctrl
87 // considering all its contents as a single strings) and (x, y) coordinates
88 // which represent column and line.
89 virtual long XYToPosition(long x, long y) const;
90 virtual bool PositionToXY(long pos, long *x, long *y) const;
91
92 virtual void ShowPosition(long pos);
93
94 // Clipboard operations
95 virtual void Copy();
96 virtual void Cut();
97 virtual void Paste();
98
99 virtual bool CanCopy() const;
100 virtual bool CanCut() const;
101 virtual bool CanPaste() const;
102
103 // Undo/redo
104 virtual void Undo();
105 virtual void Redo();
106
107 virtual bool CanUndo() const;
108 virtual bool CanRedo() const;
109
110 // Insertion point
111 virtual void SetInsertionPoint(long pos);
112 virtual void SetInsertionPointEnd();
113 virtual long GetInsertionPoint() const;
114 virtual long GetLastPosition() const;
115
116 virtual void SetSelection(long from, long to);
117 virtual void SetEditable(bool editable);
118
119 // Implementation from now on
120 // --------------------------
121
122 // Implementation
123 // --------------
124 virtual void Command(wxCommandEvent& event);
125
126 virtual bool AcceptsFocus() const;
127
128 // callbacks
129 void OnDropFiles(wxDropFilesEvent& event);
130 void OnChar(wxKeyEvent& event); // Process 'enter' if required
131
132 void OnCut(wxCommandEvent& event);
133 void OnCopy(wxCommandEvent& event);
134 void OnPaste(wxCommandEvent& event);
135 void OnUndo(wxCommandEvent& event);
136 void OnRedo(wxCommandEvent& event);
137
138 void OnUpdateCut(wxUpdateUIEvent& event);
139 void OnUpdateCopy(wxUpdateUIEvent& event);
140 void OnUpdatePaste(wxUpdateUIEvent& event);
141 void OnUpdateUndo(wxUpdateUIEvent& event);
142 void OnUpdateRedo(wxUpdateUIEvent& event);
143
144 virtual bool MacCanFocus() const { return true ; }
145
146 protected:
147 virtual wxSize DoGetBestSize() const;
148
149 bool m_editable ;
150 // one of the following objects is used for representation, the other one is NULL
151 void* m_macTE ;
152 void* m_macTXN ;
153 void* m_macTXNvars ;
154 bool m_macUsesTXN ;
155
156 DECLARE_EVENT_TABLE()
157 };
158
159 #endif
160 // _WX_TEXTCTRL_H_