]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/textctrl.h
Add lambda-friendly wxDialog::ShowWindowModalThenDo().
[wxWidgets.git] / include / wx / gtk / textctrl.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
6b0d8a01 2// Name: wx/gtk/textctrl.h
c801d85f
KB
3// Purpose:
4// Author: Robert Roebling
5// Created: 01/02/97
371a5b4e 6// Copyright: (c) 1998 Robert Roebling
65571936 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
5a3ef194
PC
10#ifndef _WX_GTK_TEXTCTRL_H_
11#define _WX_GTK_TEXTCTRL_H_
12
13typedef struct _GtkTextMark GtkTextMark;
c801d85f 14
c801d85f 15//-----------------------------------------------------------------------------
a1b82138 16// wxTextCtrl
c801d85f
KB
17//-----------------------------------------------------------------------------
18
20123d49 19class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase
c801d85f 20{
a1b82138 21public:
01041145 22 wxTextCtrl() { Init(); }
13111b2a
VZ
23 wxTextCtrl(wxWindow *parent,
24 wxWindowID id,
25 const wxString &value = wxEmptyString,
26 const wxPoint &pos = wxDefaultPosition,
27 const wxSize &size = wxDefaultSize,
28 long style = 0,
29 const wxValidator& validator = wxDefaultValidator,
30 const wxString &name = wxTextCtrlNameStr);
31
a0e55920 32 virtual ~wxTextCtrl();
9440c3d0 33
13111b2a
VZ
34 bool Create(wxWindow *parent,
35 wxWindowID id,
36 const wxString &value = wxEmptyString,
37 const wxPoint &pos = wxDefaultPosition,
38 const wxSize &size = wxDefaultSize,
39 long style = 0,
40 const wxValidator& validator = wxDefaultValidator,
41 const wxString &name = wxTextCtrlNameStr);
a1b82138
VZ
42
43 // implement base class pure virtuals
44 // ----------------------------------
45
0ec1179b 46 virtual void WriteText(const wxString& text);
a1b82138 47 virtual wxString GetValue() const;
28fdd8db 48 virtual bool IsEmpty() const;
a1b82138
VZ
49
50 virtual int GetLineLength(long lineNo) const;
51 virtual wxString GetLineText(long lineNo) const;
52 virtual int GetNumberOfLines() const;
53
54 virtual bool IsModified() const;
55 virtual bool IsEditable() const;
56
a1b82138
VZ
57 virtual void GetSelection(long* from, long* to) const;
58
a1b82138
VZ
59 virtual void Remove(long from, long to);
60
3a9fa0d6 61 virtual void MarkDirty();
a1b82138
VZ
62 virtual void DiscardEdits();
63
17665a2b 64 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
e9ee2270 65 virtual bool GetStyle(long position, wxTextAttr& style);
17665a2b 66
a1b82138
VZ
67 // translate between the position (which is just an index in the text ctrl
68 // considering all its contents as a single strings) and (x, y) coordinates
69 // which represent column and line.
70 virtual long XYToPosition(long x, long y) const;
0efe5ba7 71 virtual bool PositionToXY(long pos, long *x, long *y) const;
a1b82138
VZ
72
73 virtual void ShowPosition(long pos);
74
c04ec496 75 virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
4aae4a08
RD
76 virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
77 wxTextCoord *col,
78 wxTextCoord *row) const
79 {
80 return wxTextCtrlBase::HitTest(pt, col, row);
81 }
c04ec496 82
a1b82138
VZ
83 // Clipboard operations
84 virtual void Copy();
85 virtual void Cut();
86 virtual void Paste();
7c41ac7b 87
a1b82138
VZ
88 // Insertion point
89 virtual void SetInsertionPoint(long pos);
a1b82138 90 virtual long GetInsertionPoint() const;
7d8268a1 91 virtual wxTextPos GetLastPosition() const;
a1b82138
VZ
92
93 virtual void SetSelection(long from, long to);
94 virtual void SetEditable(bool editable);
ca8b28f2 95
927637fd
VZ
96 // Overridden wxWindow methods
97 virtual void SetWindowStyleFlag( long style );
7d8268a1 98 virtual bool Enable( bool enable = true );
68df5777 99
a1b82138
VZ
100 // Implementation from now on
101 void OnDropFiles( wxDropFilesEvent &event );
c801d85f 102 void OnChar( wxKeyEvent &event );
7c41ac7b 103
e702ff0f
JS
104 void OnCut(wxCommandEvent& event);
105 void OnCopy(wxCommandEvent& event);
106 void OnPaste(wxCommandEvent& event);
107 void OnUndo(wxCommandEvent& event);
108 void OnRedo(wxCommandEvent& event);
109
110 void OnUpdateCut(wxUpdateUIEvent& event);
111 void OnUpdateCopy(wxUpdateUIEvent& event);
112 void OnUpdatePaste(wxUpdateUIEvent& event);
113 void OnUpdateUndo(wxUpdateUIEvent& event);
114 void OnUpdateRedo(wxUpdateUIEvent& event);
115
17665a2b
VZ
116 bool SetFont(const wxFont& font);
117 bool SetForegroundColour(const wxColour& colour);
118 bool SetBackgroundColour(const wxColour& colour);
68dda785 119
2830bf19 120 GtkWidget* GetConnectWidget();
c04ec496 121
c04ec496 122 void SetUpdateFont(bool WXUNUSED(update)) { }
a1b82138 123
ce2f50e3
VZ
124 // implementation only from now on
125
ce2f50e3 126 // tell the control to ignore next text changed signal
f6519b40 127 void IgnoreNextTextUpdate(int n = 1) { m_countUpdatesToIgnore = n; }
ce2f50e3
VZ
128
129 // should we ignore the changed signal? always resets the flag
130 bool IgnoreTextUpdate();
131
6964cbba
VZ
132 // call this to indicate that the control is about to be changed
133 // programmatically and so m_modified flag shouldn't be set
134 void DontMarkDirtyOnNextChange() { m_dontMarkDirty = true; }
135
136 // should we mark the control as dirty? always resets the flag
137 bool MarkDirtyOnChange();
138
8312c461
VZ
139 // always let GTK have mouse release events for multiline controls
140 virtual bool GTKProcessEvent(wxEvent& event) const;
141
6964cbba 142
9d522606
RD
143 static wxVisualAttributes
144 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
7d8268a1 145
f68586e5 146protected:
0ec1179b 147 // overridden wxWindow virtual methods
f68586e5 148 virtual wxSize DoGetBestSize() const;
ef5c70f9
VZ
149 virtual void DoApplyWidgetStyle(GtkRcStyle *style);
150 virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
f68586e5 151
7a78a937
VZ
152 virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const;
153
17808a75
VZ
154 virtual void DoFreeze();
155 virtual void DoThaw();
156
9d522606
RD
157 // Widgets that use the style->base colour for the BG colour should
158 // override this and return true.
159 virtual bool UseGTKStyleBase() const { return true; }
160
ee2ec18e 161 virtual void DoSetValue(const wxString &value, int flags = 0);
f6519b40 162
b2c35774
VZ
163 // Override this to use either GtkEntry or GtkTextView IME depending on the
164 // kind of control we are.
165 virtual int GTKIMFilterKeypress(GdkEventKey* event) const;
166
6ce83213
VZ
167 virtual wxPoint DoPositionToCoords(long pos) const;
168
927637fd
VZ
169 // wrappers hiding the differences between functions doing the same thing
170 // for GtkTextView and GtkEntry (all of them use current window style to
171 // set the given characteristic)
172 void GTKSetEditable();
173 void GTKSetVisibility();
ff805cac 174 void GTKSetActivatesDefault();
927637fd
VZ
175 void GTKSetWrapMode();
176 void GTKSetJustification();
177
a1b82138 178private:
95dc31e0
PC
179 void Init();
180
3c75d8ba 181 // overridden wxTextEntry virtual methods
3c75d8ba 182 virtual GtkEditable *GetEditable() const;
0847e36e 183 virtual GtkEntry *GetEntry() const;
3c75d8ba
PC
184 virtual void EnableTextChangedEvents(bool enable);
185
01041145
VZ
186 // change the font for everything in this control
187 void ChangeFontGlobally();
188
0d91b234
VZ
189 // get the encoding which is used in this control: this looks at our font
190 // and default style but not the current style (i.e. the style for the
191 // current position); returns wxFONTENCODING_SYSTEM if we have no specific
192 // encoding
193 wxFontEncoding GetTextEncoding() const;
194
86e37f69
VZ
195 // returns either m_text or m_buffer depending on whether the control is
196 // single- or multi-line; convenient for the GTK+ functions which work with
197 // both
198 void *GetTextObject() const
199 {
5c33522f
VZ
200 return IsMultiLine() ? static_cast<void *>(m_buffer)
201 : static_cast<void *>(m_text);
86e37f69
VZ
202 }
203
0d91b234 204
86e37f69 205 // the widget used for single line controls
903f689b 206 GtkWidget *m_text;
ce2f50e3
VZ
207
208 bool m_modified:1;
6964cbba 209 bool m_dontMarkDirty:1;
a1b82138 210
f6519b40
VZ
211 int m_countUpdatesToIgnore;
212
41b81aed 213 // Our text buffer. Convenient, and holds the buffer while using
5a3ef194 214 // a dummy one when frozen
41b81aed
RR
215 GtkTextBuffer *m_buffer;
216
5a3ef194 217 GtkTextMark* m_showPositionOnThaw;
385e8575 218 GSList* m_anonymousMarkList;
9440c3d0
KH
219
220 // For wxTE_AUTO_URL
221 void OnUrlMouseEvent(wxMouseEvent&);
41b81aed 222
a1b82138 223 DECLARE_EVENT_TABLE()
777105f2 224 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
c801d85f
KB
225};
226
5a3ef194 227#endif // _WX_GTK_TEXTCTRL_H_