/
textctrl.h
173 lines (136 loc) · 6.11 KB
/
textctrl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/textctrl.h
// Purpose: wxTextCtrl class
// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TEXTCTRL_H_
#define _WX_TEXTCTRL_H_
#if wxUSE_SYSTEM_OPTIONS
// set this to 'true' if you want to use the 'classic' MLTE-based implementation
// instead of the HIView-based implementation in 10.3 and upwards, the former
// has more features (backgrounds etc.), but may show redraw artefacts and other
// problems depending on your usage; hence, the default is 'false'.
#define wxMAC_TEXTCONTROL_USE_MLTE wxT("mac.textcontrol-use-mlte")
// set this to 'true' if you want editable text controls to have spell checking turned
// on by default, you can change this setting individually on a control using MacCheckSpelling
#define wxMAC_TEXTCONTROL_USE_SPELL_CHECKER wxT("mac.textcontrol-use-spell-checker")
#endif
#include "wx/control.h"
#include "wx/textctrl.h"
class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase
{
wxDECLARE_DYNAMIC_CLASS(wxTextCtrl);
public:
wxTextCtrl()
{ Init(); }
wxTextCtrl(wxWindow *parent,
wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxTextCtrlNameStr))
{
Init();
Create(parent, id, value, pos, size, style, validator, name);
}
virtual ~wxTextCtrl();
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxTextCtrlNameStr));
// accessors
// ---------
virtual int GetLineLength(long lineNo) const wxOVERRIDE;
virtual wxString GetLineText(long lineNo) const wxOVERRIDE;
virtual int GetNumberOfLines() const wxOVERRIDE;
virtual bool IsModified() const wxOVERRIDE;
// operations
// ----------
// sets/clears the dirty flag
virtual void MarkDirty() wxOVERRIDE;
virtual void DiscardEdits() wxOVERRIDE;
virtual void EmptyUndoBuffer() wxOVERRIDE;
// text control under some platforms supports the text styles: these
// methods apply the given text style to the given selection or to
// set/get the style which will be used for all appended text
virtual bool SetFont( const wxFont &font ) wxOVERRIDE;
virtual bool GetStyle(long position, wxTextAttr& style) wxOVERRIDE;
virtual bool SetStyle(long start, long end, const wxTextAttr& style) wxOVERRIDE;
virtual bool SetDefaultStyle(const wxTextAttr& style) wxOVERRIDE;
// translate between the position (which is just an index into the textctrl
// considering all its contents as a single strings) and (x, y) coordinates
// which represent column and line.
virtual long XYToPosition(long x, long y) const wxOVERRIDE;
virtual bool PositionToXY(long pos, long *x, long *y) const wxOVERRIDE;
virtual void ShowPosition(long pos) wxOVERRIDE;
// overrides so that we can send text updated events
virtual void Copy() wxOVERRIDE;
virtual void Cut() wxOVERRIDE;
virtual void Paste() wxOVERRIDE;
#if wxUSE_SPELLCHECK
// Use native spelling and grammar checking functions (multiline only).
virtual bool EnableProofCheck(const wxTextProofOptions& options
= wxTextProofOptions::Default()) wxOVERRIDE;
virtual wxTextProofOptions GetProofCheckOptions() const wxOVERRIDE;
#endif // wxUSE_SPELLCHECK
// Implementation
// --------------
virtual void Command(wxCommandEvent& event) wxOVERRIDE;
virtual void SetWindowStyleFlag(long style) wxOVERRIDE;
// callbacks
void OnDropFiles(wxDropFilesEvent& event);
void OnChar(wxKeyEvent& event); // Process 'enter' if required
void OnKeyDown(wxKeyEvent& event); // Process clipboard shortcuts
void OnCut(wxCommandEvent& event);
void OnCopy(wxCommandEvent& event);
void OnPaste(wxCommandEvent& event);
void OnUndo(wxCommandEvent& event);
void OnRedo(wxCommandEvent& event);
void OnDelete(wxCommandEvent& event);
void OnSelectAll(wxCommandEvent& event);
void OnUpdateCut(wxUpdateUIEvent& event);
void OnUpdateCopy(wxUpdateUIEvent& event);
void OnUpdatePaste(wxUpdateUIEvent& event);
void OnUpdateUndo(wxUpdateUIEvent& event);
void OnUpdateRedo(wxUpdateUIEvent& event);
void OnUpdateDelete(wxUpdateUIEvent& event);
void OnUpdateSelectAll(wxUpdateUIEvent& event);
void OnContextMenu(wxContextMenuEvent& event);
virtual bool MacSetupCursor( const wxPoint& pt ) wxOVERRIDE;
virtual void MacVisibilityChanged() wxOVERRIDE;
virtual void MacSuperChangedPosition() wxOVERRIDE;
// Use portable EnableProofCheck() instead now.
#if WXWIN_COMPATIBILITY_3_0 && wxUSE_SPELLCHECK
wxDEPRECATED( virtual void MacCheckSpelling(bool check) );
#endif // WXWIN_COMPATIBILITY_3_0 && wxUSE_SPELLCHECK
void OSXEnableNewLineReplacement(bool enable);
void OSXEnableAutomaticQuoteSubstitution(bool enable);
void OSXEnableAutomaticDashSubstitution(bool enable);
void OSXDisableAllSmartSubstitutions();
protected:
// common part of all ctors
void Init();
virtual wxSize DoGetBestSize() const wxOVERRIDE;
virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen) const wxOVERRIDE;
// flag is set to true when the user edits the controls contents
bool m_dirty;
virtual void EnableTextChangedEvents(bool WXUNUSED(enable)) wxOVERRIDE
{
// nothing to do here as the events are never generated when we change
// the controls value programmatically anyhow
}
private :
wxMenu *m_privateContextMenu;
wxDECLARE_EVENT_TABLE();
};
#endif // _WX_TEXTCTRL_H_