]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/textctrl.h
warning fix
[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 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 // writing text inserts it at the current position, appending always
81 // inserts it at the end
82 virtual void WriteText(const wxString& text);
83 virtual void AppendText(const wxString& text);
84
85 // translate between the position (which is just an index in the text ctrl
86 // considering all its contents as a single strings) and (x, y) coordinates
87 // which represent column and line.
88 virtual long XYToPosition(long x, long y) const;
89 virtual bool PositionToXY(long pos, long *x, long *y) const;
90
91 virtual void ShowPosition(long pos);
92
93 // Clipboard operations
94 virtual void Copy();
95 virtual void Cut();
96 virtual void Paste();
97
98 virtual bool CanCopy() const;
99 virtual bool CanCut() const;
100 virtual bool CanPaste() const;
101
102 // Undo/redo
103 virtual void Undo();
104 virtual void Redo();
105
106 virtual bool CanUndo() const;
107 virtual bool CanRedo() const;
108
109 // Insertion point
110 virtual void SetInsertionPoint(long pos);
111 virtual void SetInsertionPointEnd();
112 virtual long GetInsertionPoint() const;
113 virtual long GetLastPosition() const;
114
115 virtual void SetSelection(long from, long to);
116 virtual void SetEditable(bool editable);
117
118 // Implementation from now on
119 // --------------------------
120
121 // Implementation
122 // --------------
123 virtual void Command(wxCommandEvent& event);
124
125 virtual bool AcceptsFocus() const;
126
127 // callbacks
128 void OnDropFiles(wxDropFilesEvent& event);
129 void OnChar(wxKeyEvent& event); // Process 'enter' if required
130
131 void OnCut(wxCommandEvent& event);
132 void OnCopy(wxCommandEvent& event);
133 void OnPaste(wxCommandEvent& event);
134 void OnUndo(wxCommandEvent& event);
135 void OnRedo(wxCommandEvent& event);
136
137 void OnUpdateCut(wxUpdateUIEvent& event);
138 void OnUpdateCopy(wxUpdateUIEvent& event);
139 void OnUpdatePaste(wxUpdateUIEvent& event);
140 void OnUpdateUndo(wxUpdateUIEvent& event);
141 void OnUpdateRedo(wxUpdateUIEvent& event);
142
143 virtual bool MacCanFocus() const { return true ; }
144
145 protected:
146 virtual wxSize DoGetBestSize() const;
147
148 DECLARE_EVENT_TABLE()
149 };
150
151 #endif
152 // _WX_TEXTCTRL_H_