]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/gtk/textctrl.h
fix the run-time behaviour after the last compilation fixing patch
[wxWidgets.git] / include / wx / gtk / textctrl.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/gtk/textctrl.h
3// Purpose:
4// Author: Robert Roebling
5// Created: 01/02/97
6// Id: $Id$
7// Copyright: (c) 1998 Robert Roebling
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_GTK_TEXTCTRL_H_
12#define _WX_GTK_TEXTCTRL_H_
13
14typedef struct _GtkTextMark GtkTextMark;
15
16//-----------------------------------------------------------------------------
17// wxTextCtrl
18//-----------------------------------------------------------------------------
19
20class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase
21{
22public:
23 wxTextCtrl() { Init(); }
24 wxTextCtrl(wxWindow *parent,
25 wxWindowID id,
26 const wxString &value = wxEmptyString,
27 const wxPoint &pos = wxDefaultPosition,
28 const wxSize &size = wxDefaultSize,
29 long style = 0,
30 const wxValidator& validator = wxDefaultValidator,
31 const wxString &name = wxTextCtrlNameStr);
32
33 virtual ~wxTextCtrl();
34
35 bool Create(wxWindow *parent,
36 wxWindowID id,
37 const wxString &value = wxEmptyString,
38 const wxPoint &pos = wxDefaultPosition,
39 const wxSize &size = wxDefaultSize,
40 long style = 0,
41 const wxValidator& validator = wxDefaultValidator,
42 const wxString &name = wxTextCtrlNameStr);
43
44 // implement base class pure virtuals
45 // ----------------------------------
46
47 virtual wxString GetValue() const;
48 virtual bool IsEmpty() const;
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
57 // If the return values from and to are the same, there is no selection.
58 virtual void GetSelection(long* from, long* to) const;
59
60 // operations
61 // ----------
62
63 // editing
64 virtual void Clear();
65 virtual void Replace(long from, long to, const wxString& value);
66 virtual void Remove(long from, long to);
67
68 // sets/clears the dirty flag
69 virtual void MarkDirty();
70 virtual void DiscardEdits();
71
72 virtual void SetMaxLength(unsigned long len);
73
74 // writing text inserts it at the current position, appending always
75 // inserts it at the end
76 virtual void WriteText(const wxString& text);
77 virtual void AppendText(const wxString& text);
78
79 // apply text attribute to the range of text (only works with richedit
80 // controls)
81 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
82
83 // translate between the position (which is just an index in the text ctrl
84 // considering all its contents as a single strings) and (x, y) coordinates
85 // which represent column and line.
86 virtual long XYToPosition(long x, long y) const;
87 virtual bool PositionToXY(long pos, long *x, long *y) const;
88
89 virtual void ShowPosition(long pos);
90
91 virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
92 virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
93 wxTextCoord *col,
94 wxTextCoord *row) const
95 {
96 return wxTextCtrlBase::HitTest(pt, col, row);
97 }
98
99 // Clipboard operations
100 virtual void Copy();
101 virtual void Cut();
102 virtual void Paste();
103
104 // Undo/redo
105 virtual void Undo();
106 virtual void Redo();
107
108 virtual bool CanUndo() const;
109 virtual bool CanRedo() const;
110
111 // Insertion point
112 virtual void SetInsertionPoint(long pos);
113 virtual void SetInsertionPointEnd();
114 virtual long GetInsertionPoint() const;
115 virtual wxTextPos GetLastPosition() const;
116
117 virtual void SetSelection(long from, long to);
118 virtual void SetEditable(bool editable);
119
120 // Overridden wxWindow methods
121 virtual void SetWindowStyleFlag( long style );
122 virtual bool Enable( bool enable = true );
123
124 // Implementation from now on
125 void OnDropFiles( wxDropFilesEvent &event );
126 void OnChar( wxKeyEvent &event );
127
128 void OnCut(wxCommandEvent& event);
129 void OnCopy(wxCommandEvent& event);
130 void OnPaste(wxCommandEvent& event);
131 void OnUndo(wxCommandEvent& event);
132 void OnRedo(wxCommandEvent& event);
133
134 void OnUpdateCut(wxUpdateUIEvent& event);
135 void OnUpdateCopy(wxUpdateUIEvent& event);
136 void OnUpdatePaste(wxUpdateUIEvent& event);
137 void OnUpdateUndo(wxUpdateUIEvent& event);
138 void OnUpdateRedo(wxUpdateUIEvent& event);
139
140 bool SetFont(const wxFont& font);
141 bool SetForegroundColour(const wxColour& colour);
142 bool SetBackgroundColour(const wxColour& colour);
143
144 GtkWidget* GetConnectWidget();
145
146 void SetUpdateFont(bool WXUNUSED(update)) { }
147
148 // GTK+ textctrl is so dumb that you need to freeze/thaw it manually to
149 // avoid horrible flicker/scrolling back and forth
150 virtual void Freeze();
151 virtual void Thaw();
152
153 // implementation only from now on
154
155 // wxGTK-specific: called recursively by Enable,
156 // to give widgets an oppprtunity to correct their colours after they
157 // have been changed by Enable
158 virtual void OnParentEnable( bool enable ) ;
159
160 // tell the control to ignore next text changed signal
161 void IgnoreNextTextUpdate(int n = 1) { m_countUpdatesToIgnore = n; }
162
163 // should we ignore the changed signal? always resets the flag
164 bool IgnoreTextUpdate();
165
166 // call this to indicate that the control is about to be changed
167 // programmatically and so m_modified flag shouldn't be set
168 void DontMarkDirtyOnNextChange() { m_dontMarkDirty = true; }
169
170 // should we mark the control as dirty? always resets the flag
171 bool MarkDirtyOnChange();
172
173 // always let GTK have mouse release events for multiline controls
174 virtual bool GTKProcessEvent(wxEvent& event) const;
175
176
177 static wxVisualAttributes
178 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
179
180 // has the control been frozen by Freeze()?
181 bool IsFrozen() const { return m_freezeCount > 0; }
182
183protected:
184 virtual wxSize DoGetBestSize() const;
185 virtual void DoApplyWidgetStyle(GtkRcStyle *style);
186 virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
187
188 // common part of all ctors
189 void Init();
190
191 // Widgets that use the style->base colour for the BG colour should
192 // override this and return true.
193 virtual bool UseGTKStyleBase() const { return true; }
194
195 virtual void DoSetValue(const wxString &value, int flags = 0);
196
197 // wrappers hiding the differences between functions doing the same thing
198 // for GtkTextView and GtkEntry (all of them use current window style to
199 // set the given characteristic)
200 void GTKSetEditable();
201 void GTKSetVisibility();
202 void GTKSetWrapMode();
203 void GTKSetJustification();
204
205private:
206 // change the font for everything in this control
207 void ChangeFontGlobally();
208
209 // get the encoding which is used in this control: this looks at our font
210 // and default style but not the current style (i.e. the style for the
211 // current position); returns wxFONTENCODING_SYSTEM if we have no specific
212 // encoding
213 wxFontEncoding GetTextEncoding() const;
214
215
216 GtkWidget *m_text;
217
218 bool m_modified:1;
219 bool m_dontMarkDirty:1;
220
221 int m_countUpdatesToIgnore;
222
223 // Our text buffer. Convenient, and holds the buffer while using
224 // a dummy one when frozen
225 GtkTextBuffer *m_buffer;
226
227 // number of calls to Freeze() minus number of calls to Thaw()
228 unsigned m_freezeCount;
229 GtkTextMark* m_showPositionOnThaw;
230
231 // For wxTE_AUTO_URL
232 void OnUrlMouseEvent(wxMouseEvent&);
233 GdkCursor *m_gdkHandCursor;
234 GdkCursor *m_gdkXTermCursor;
235
236 DECLARE_EVENT_TABLE()
237 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
238};
239
240#endif // _WX_GTK_TEXTCTRL_H_