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