]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/gtk1/textctrl.h
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / include / wx / gtk1 / textctrl.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/gtk1/textctrl.h
3// Purpose:
4// Author: Robert Roebling
5// Created: 01/02/97
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifndef __GTKTEXTCTRLH__
11#define __GTKTEXTCTRLH__
12
13//-----------------------------------------------------------------------------
14// wxTextCtrl
15//-----------------------------------------------------------------------------
16
17class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase
18{
19public:
20 wxTextCtrl() { Init(); }
21 wxTextCtrl(wxWindow *parent,
22 wxWindowID id,
23 const wxString &value = wxEmptyString,
24 const wxPoint &pos = wxDefaultPosition,
25 const wxSize &size = wxDefaultSize,
26 long style = 0,
27 const wxValidator& validator = wxDefaultValidator,
28 const wxString &name = wxTextCtrlNameStr);
29
30 virtual ~wxTextCtrl();
31
32 bool Create(wxWindow *parent,
33 wxWindowID id,
34 const wxString &value = wxEmptyString,
35 const wxPoint &pos = wxDefaultPosition,
36 const wxSize &size = wxDefaultSize,
37 long style = 0,
38 const wxValidator& validator = wxDefaultValidator,
39 const wxString &name = wxTextCtrlNameStr);
40
41 // implement base class pure virtuals
42 // ----------------------------------
43
44 virtual int GetLineLength(long lineNo) const;
45 virtual wxString GetLineText(long lineNo) const;
46 virtual int GetNumberOfLines() const;
47
48 virtual bool IsModified() const;
49 virtual bool IsEditable() const;
50
51 // If the return values from and to are the same, there is no selection.
52 virtual void GetSelection(long* from, long* to) const;
53
54 // operations
55 // ----------
56
57 // editing
58 virtual void Clear();
59 virtual void Replace(long from, long to, const wxString& value);
60 virtual void Remove(long from, long to);
61
62 // sets/clears the dirty flag
63 virtual void MarkDirty();
64 virtual void DiscardEdits();
65
66 virtual void SetMaxLength(unsigned long len);
67
68 // writing text inserts it at the current position, appending always
69 // inserts it at the end
70 virtual void WriteText(const wxString& text);
71 virtual void AppendText(const wxString& text);
72
73 // apply text attribute to the range of text (only works with richedit
74 // controls)
75 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
76
77 // translate between the position (which is just an index in the text ctrl
78 // considering all its contents as a single strings) and (x, y) coordinates
79 // which represent column and line.
80 virtual long XYToPosition(long x, long y) const;
81 virtual bool PositionToXY(long pos, long *x, long *y) const;
82
83 virtual void ShowPosition(long pos);
84
85 // Clipboard operations
86 virtual void Copy();
87 virtual void Cut();
88 virtual void Paste();
89
90 // Undo/redo
91 virtual void Undo();
92 virtual void Redo();
93
94 virtual bool CanUndo() const;
95 virtual bool CanRedo() const;
96
97 // Insertion point
98 virtual void SetInsertionPoint(long pos);
99 virtual void SetInsertionPointEnd();
100 virtual long GetInsertionPoint() const;
101 virtual wxTextPos GetLastPosition() const;
102
103 virtual void SetSelection(long from, long to);
104 virtual void SetEditable(bool editable);
105
106 virtual void DoEnable( bool enable );
107
108 // Implementation from now on
109 void OnDropFiles( wxDropFilesEvent &event );
110 void OnChar( wxKeyEvent &event );
111
112 void OnCut(wxCommandEvent& event);
113 void OnCopy(wxCommandEvent& event);
114 void OnPaste(wxCommandEvent& event);
115 void OnUndo(wxCommandEvent& event);
116 void OnRedo(wxCommandEvent& event);
117
118 void OnUpdateCut(wxUpdateUIEvent& event);
119 void OnUpdateCopy(wxUpdateUIEvent& event);
120 void OnUpdatePaste(wxUpdateUIEvent& event);
121 void OnUpdateUndo(wxUpdateUIEvent& event);
122 void OnUpdateRedo(wxUpdateUIEvent& event);
123
124 bool SetFont(const wxFont& font);
125 bool SetForegroundColour(const wxColour& colour);
126 bool SetBackgroundColour(const wxColour& colour);
127
128 GtkWidget* GetConnectWidget();
129 bool IsOwnGtkWindow( GdkWindow *window );
130 void DoApplyWidgetStyle(GtkRcStyle *style);
131 void CalculateScrollbar();
132 void OnInternalIdle();
133
134 void SetUpdateFont(bool update) { m_updateFont = update; }
135 void UpdateFontIfNeeded();
136
137 void SetModified() { m_modified = true; }
138
139 // textctrl specific scrolling
140 virtual bool ScrollLines(int lines);
141 virtual bool ScrollPages(int pages);
142
143 // implementation only from now on
144
145 // tell the control to ignore next text changed signal
146 void IgnoreNextTextUpdate();
147
148 // should we ignore the changed signal? always resets the flag
149 bool IgnoreTextUpdate();
150
151 static wxVisualAttributes
152 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
153
154protected:
155 virtual wxSize DoGetBestSize() const;
156
157 // common part of all ctors
158 void Init();
159
160 // overridden wxWindow methods
161 virtual void DoFreeze();
162 virtual void DoThaw();
163
164 // get the vertical adjustment, if any, NULL otherwise
165 GtkAdjustment *GetVAdj() const;
166
167 // scroll the control by the given number of pixels, return true if the
168 // scroll position changed
169 bool DoScroll(GtkAdjustment *adj, int diff);
170
171 // Widgets that use the style->base colour for the BG colour should
172 // override this and return true.
173 virtual bool UseGTKStyleBase() const { return true; }
174
175 virtual void DoSetValue(const wxString &value, int flags = 0);
176 virtual wxString DoGetValue() const;
177
178private:
179 // change the font for everything in this control
180 void ChangeFontGlobally();
181
182 GtkWidget *m_text;
183 GtkWidget *m_vScrollbar;
184
185 bool m_modified:1;
186 bool m_vScrollbarVisible:1;
187 bool m_updateFont:1;
188 bool m_ignoreNextUpdate:1;
189
190 DECLARE_EVENT_TABLE()
191 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
192};
193
194#endif // __GTKTEXTCTRLH__
195