]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
8ef94bfc | 2 | // Name: wx/gtk1/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 | ||
c801d85f KB |
10 | #ifndef __GTKTEXTCTRLH__ |
11 | #define __GTKTEXTCTRLH__ | |
12 | ||
c801d85f | 13 | //----------------------------------------------------------------------------- |
a1b82138 | 14 | // wxTextCtrl |
c801d85f KB |
15 | //----------------------------------------------------------------------------- |
16 | ||
20123d49 | 17 | class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase |
c801d85f | 18 | { |
a1b82138 | 19 | public: |
01041145 | 20 | wxTextCtrl() { Init(); } |
13111b2a VZ |
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 | ||
a0e55920 | 30 | virtual ~wxTextCtrl(); |
9440c3d0 | 31 | |
13111b2a VZ |
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); | |
a1b82138 VZ |
40 | |
41 | // implement base class pure virtuals | |
42 | // ---------------------------------- | |
43 | ||
a1b82138 VZ |
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 | ||
3a9fa0d6 VZ |
62 | // sets/clears the dirty flag |
63 | virtual void MarkDirty(); | |
a1b82138 VZ |
64 | virtual void DiscardEdits(); |
65 | ||
d7eee191 VZ |
66 | virtual void SetMaxLength(unsigned long len); |
67 | ||
a1b82138 VZ |
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 | ||
17665a2b VZ |
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 | ||
a1b82138 VZ |
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; | |
0efe5ba7 | 81 | virtual bool PositionToXY(long pos, long *x, long *y) const; |
a1b82138 VZ |
82 | |
83 | virtual void ShowPosition(long pos); | |
84 | ||
85 | // Clipboard operations | |
86 | virtual void Copy(); | |
87 | virtual void Cut(); | |
88 | virtual void Paste(); | |
7c41ac7b | 89 | |
ca8b28f2 JS |
90 | // Undo/redo |
91 | virtual void Undo(); | |
92 | virtual void Redo(); | |
93 | ||
94 | virtual bool CanUndo() const; | |
95 | virtual bool CanRedo() const; | |
96 | ||
a1b82138 VZ |
97 | // Insertion point |
98 | virtual void SetInsertionPoint(long pos); | |
99 | virtual void SetInsertionPointEnd(); | |
100 | virtual long GetInsertionPoint() const; | |
7d8268a1 | 101 | virtual wxTextPos GetLastPosition() const; |
a1b82138 VZ |
102 | |
103 | virtual void SetSelection(long from, long to); | |
104 | virtual void SetEditable(bool editable); | |
ca8b28f2 | 105 | |
47a8a4d5 | 106 | virtual void DoEnable( bool enable ); |
68df5777 | 107 | |
a1b82138 VZ |
108 | // Implementation from now on |
109 | void OnDropFiles( wxDropFilesEvent &event ); | |
c801d85f | 110 | void OnChar( wxKeyEvent &event ); |
7c41ac7b | 111 | |
e702ff0f JS |
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 | ||
17665a2b VZ |
124 | bool SetFont(const wxFont& font); |
125 | bool SetForegroundColour(const wxColour& colour); | |
126 | bool SetBackgroundColour(const wxColour& colour); | |
68dda785 | 127 | |
2830bf19 | 128 | GtkWidget* GetConnectWidget(); |
b4071e91 | 129 | bool IsOwnGtkWindow( GdkWindow *window ); |
f40fdaa3 | 130 | void DoApplyWidgetStyle(GtkRcStyle *style); |
2830bf19 | 131 | void CalculateScrollbar(); |
65045edd | 132 | void OnInternalIdle(); |
c04ec496 | 133 | |
c04ec496 | 134 | void SetUpdateFont(bool update) { m_updateFont = update; } |
01041145 | 135 | void UpdateFontIfNeeded(); |
a1b82138 | 136 | |
7d8268a1 | 137 | void SetModified() { m_modified = true; } |
0efe5ba7 | 138 | |
9cd6d737 VZ |
139 | // textctrl specific scrolling |
140 | virtual bool ScrollLines(int lines); | |
141 | virtual bool ScrollPages(int pages); | |
142 | ||
ce2f50e3 VZ |
143 | // implementation only from now on |
144 | ||
ce2f50e3 VZ |
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 | ||
9d522606 RD |
151 | static wxVisualAttributes |
152 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
7d8268a1 | 153 | |
f68586e5 VZ |
154 | protected: |
155 | virtual wxSize DoGetBestSize() const; | |
156 | ||
01041145 VZ |
157 | // common part of all ctors |
158 | void Init(); | |
159 | ||
17808a75 VZ |
160 | // overridden wxWindow methods |
161 | virtual void DoFreeze(); | |
162 | virtual void DoThaw(); | |
163 | ||
9cd6d737 VZ |
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 | ||
9d522606 RD |
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 | ||
ee2ec18e | 175 | virtual void DoSetValue(const wxString &value, int flags = 0); |
55410bb4 | 176 | virtual wxString DoGetValue() const; |
f6519b40 | 177 | |
a1b82138 | 178 | private: |
01041145 VZ |
179 | // change the font for everything in this control |
180 | void ChangeFontGlobally(); | |
181 | ||
903f689b | 182 | GtkWidget *m_text; |
2830bf19 | 183 | GtkWidget *m_vScrollbar; |
ce2f50e3 VZ |
184 | |
185 | bool m_modified:1; | |
186 | bool m_vScrollbarVisible:1; | |
187 | bool m_updateFont:1; | |
188 | bool m_ignoreNextUpdate:1; | |
a1b82138 VZ |
189 | |
190 | DECLARE_EVENT_TABLE() | |
777105f2 | 191 | DECLARE_DYNAMIC_CLASS(wxTextCtrl) |
c801d85f KB |
192 | }; |
193 | ||
194 | #endif // __GTKTEXTCTRLH__ | |
195 |