]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/textctrl.h
Convert wxFSW_EVENT_{WARNING,ERROR} to string correctly.
[wxWidgets.git] / include / wx / osx / textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/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 wxUSE_SYSTEM_OPTIONS
16 // set this to 'true' if you want to use the 'classic' MLTE-based implementation
17 // instead of the HIView-based implementation in 10.3 and upwards, the former
18 // has more features (backgrounds etc.), but may show redraw artefacts and other
19 // problems depending on your usage; hence, the default is 'false'.
20 #define wxMAC_TEXTCONTROL_USE_MLTE wxT("mac.textcontrol-use-mlte")
21 // set this to 'true' if you want editable text controls to have spell checking turned
22 // on by default, you can change this setting individually on a control using MacCheckSpelling
23 #define wxMAC_TEXTCONTROL_USE_SPELL_CHECKER wxT("mac.textcontrol-use-spell-checker")
24 #endif
25
26 #include "wx/control.h"
27 #include "wx/textctrl.h"
28
29 class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase
30 {
31 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
32
33 public:
34 wxTextCtrl()
35 { Init(); }
36
37 wxTextCtrl(wxWindow *parent,
38 wxWindowID id,
39 const wxString& value = wxEmptyString,
40 const wxPoint& pos = wxDefaultPosition,
41 const wxSize& size = wxDefaultSize,
42 long style = 0,
43 const wxValidator& validator = wxDefaultValidator,
44 const wxString& name = wxTextCtrlNameStr)
45 {
46 Init();
47 Create(parent, id, value, pos, size, style, validator, name);
48 }
49
50 virtual ~wxTextCtrl() wxNOEXCEPT;
51
52 bool Create(wxWindow *parent,
53 wxWindowID id,
54 const wxString& value = wxEmptyString,
55 const wxPoint& pos = wxDefaultPosition,
56 const wxSize& size = wxDefaultSize,
57 long style = 0,
58 const wxValidator& validator = wxDefaultValidator,
59 const wxString& name = wxTextCtrlNameStr);
60
61 // accessors
62 // ---------
63
64 virtual int GetLineLength(long lineNo) const;
65 virtual wxString GetLineText(long lineNo) const;
66 virtual int GetNumberOfLines() const;
67
68 virtual bool IsModified() const;
69
70 // operations
71 // ----------
72
73
74 // sets/clears the dirty flag
75 virtual void MarkDirty();
76 virtual void DiscardEdits();
77
78 // set the grayed out hint text
79 virtual bool SetHint(const wxString& hint);
80 virtual wxString GetHint() const;
81
82 // text control under some platforms supports the text styles: these
83 // methods apply the given text style to the given selection or to
84 // set/get the style which will be used for all appended text
85 virtual bool SetFont( const wxFont &font );
86 virtual bool GetStyle(long position, wxTextAttr& style);
87 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
88 virtual bool SetDefaultStyle(const wxTextAttr& style);
89
90 // translate between the position (which is just an index into the textctrl
91 // considering all its contents as a single strings) and (x, y) coordinates
92 // which represent column and line.
93 virtual long XYToPosition(long x, long y) const;
94 virtual bool PositionToXY(long pos, long *x, long *y) const;
95
96 virtual void ShowPosition(long pos);
97
98 // overrides so that we can send text updated events
99 virtual void Copy();
100 virtual void Cut();
101 virtual void Paste();
102
103 // Implementation
104 // --------------
105 virtual void Command(wxCommandEvent& event);
106
107 virtual bool AcceptsFocus() const;
108
109 // callbacks
110 void OnDropFiles(wxDropFilesEvent& event);
111 void OnChar(wxKeyEvent& event); // Process 'enter' if required
112 void OnKeyDown(wxKeyEvent& event); // Process clipboard shortcuts
113
114 void OnCut(wxCommandEvent& event);
115 void OnCopy(wxCommandEvent& event);
116 void OnPaste(wxCommandEvent& event);
117 void OnUndo(wxCommandEvent& event);
118 void OnRedo(wxCommandEvent& event);
119 void OnDelete(wxCommandEvent& event);
120 void OnSelectAll(wxCommandEvent& event);
121
122 void OnUpdateCut(wxUpdateUIEvent& event);
123 void OnUpdateCopy(wxUpdateUIEvent& event);
124 void OnUpdatePaste(wxUpdateUIEvent& event);
125 void OnUpdateUndo(wxUpdateUIEvent& event);
126 void OnUpdateRedo(wxUpdateUIEvent& event);
127 void OnUpdateDelete(wxUpdateUIEvent& event);
128 void OnUpdateSelectAll(wxUpdateUIEvent& event);
129
130 void OnContextMenu(wxContextMenuEvent& event);
131
132 virtual bool MacSetupCursor( const wxPoint& pt );
133
134 virtual void MacVisibilityChanged();
135 virtual void MacSuperChangedPosition();
136 virtual void MacCheckSpelling(bool check);
137
138 protected:
139 // common part of all ctors
140 void Init();
141
142 virtual wxSize DoGetBestSize() const;
143
144 // flag is set to true when the user edits the controls contents
145 bool m_dirty;
146
147 virtual void EnableTextChangedEvents(bool WXUNUSED(enable))
148 {
149 // nothing to do here as the events are never generated when we change
150 // the controls value programmatically anyhow
151 }
152
153 private :
154 wxMenu *m_privateContextMenu;
155 wxString m_hintString;
156
157 DECLARE_EVENT_TABLE()
158 };
159
160 #endif // _WX_TEXTCTRL_H_