]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/gtk1/window.h | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
5 | // Id: $Id$ | |
6 | // Copyright: (c) 1998 Robert Roebling | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifndef __GTKWINDOWH__ | |
11 | #define __GTKWINDOWH__ | |
12 | ||
13 | typedef struct _GtkTooltips GtkTooltips; | |
14 | #ifdef HAVE_XIM | |
15 | typedef struct _GdkIC GdkIC; | |
16 | typedef struct _GdkICAttr GdkICAttr; | |
17 | #endif | |
18 | ||
19 | // helper structure that holds class that holds GtkIMContext object and | |
20 | // some additional data needed for key events processing | |
21 | struct wxGtkIMData; | |
22 | ||
23 | //----------------------------------------------------------------------------- | |
24 | // callback definition for inserting a window (internal) | |
25 | //----------------------------------------------------------------------------- | |
26 | ||
27 | class WXDLLIMPEXP_FWD_CORE wxWindowGTK; | |
28 | typedef void (*wxInsertChildFunction)( wxWindowGTK*, wxWindowGTK* ); | |
29 | ||
30 | //----------------------------------------------------------------------------- | |
31 | // wxWindowGTK | |
32 | //----------------------------------------------------------------------------- | |
33 | ||
34 | class WXDLLIMPEXP_CORE wxWindowGTK : public wxWindowBase | |
35 | { | |
36 | public: | |
37 | // creating the window | |
38 | // ------------------- | |
39 | wxWindowGTK(); | |
40 | wxWindowGTK(wxWindow *parent, | |
41 | wxWindowID id, | |
42 | const wxPoint& pos = wxDefaultPosition, | |
43 | const wxSize& size = wxDefaultSize, | |
44 | long style = 0, | |
45 | const wxString& name = wxPanelNameStr); | |
46 | bool Create(wxWindow *parent, | |
47 | wxWindowID id, | |
48 | const wxPoint& pos = wxDefaultPosition, | |
49 | const wxSize& size = wxDefaultSize, | |
50 | long style = 0, | |
51 | const wxString& name = wxPanelNameStr); | |
52 | virtual ~wxWindowGTK(); | |
53 | ||
54 | // implement base class (pure) virtual methods | |
55 | // ------------------------------------------- | |
56 | ||
57 | virtual void SetLabel(const wxString& WXUNUSED(label)) { } | |
58 | virtual wxString GetLabel() const { return wxEmptyString; } | |
59 | ||
60 | virtual bool Destroy(); | |
61 | ||
62 | virtual void Raise(); | |
63 | virtual void Lower(); | |
64 | ||
65 | virtual bool Show( bool show = true ); | |
66 | virtual void DoEnable( bool enable ); | |
67 | ||
68 | virtual void SetWindowStyleFlag( long style ); | |
69 | ||
70 | virtual bool IsRetained() const; | |
71 | ||
72 | virtual void SetFocus(); | |
73 | virtual bool AcceptsFocus() const; | |
74 | ||
75 | virtual bool Reparent( wxWindowBase *newParent ); | |
76 | ||
77 | virtual void WarpPointer(int x, int y); | |
78 | ||
79 | virtual void Refresh( bool eraseBackground = true, | |
80 | const wxRect *rect = (const wxRect *) NULL ); | |
81 | virtual void Update(); | |
82 | virtual void ClearBackground(); | |
83 | ||
84 | virtual bool SetBackgroundColour( const wxColour &colour ); | |
85 | virtual bool SetForegroundColour( const wxColour &colour ); | |
86 | virtual bool SetCursor( const wxCursor &cursor ); | |
87 | virtual bool SetFont( const wxFont &font ); | |
88 | ||
89 | virtual bool SetBackgroundStyle(wxBackgroundStyle style) ; | |
90 | ||
91 | virtual int GetCharHeight() const; | |
92 | virtual int GetCharWidth() const; | |
93 | ||
94 | virtual void SetScrollbar( int orient, int pos, int thumbVisible, | |
95 | int range, bool refresh = true ); | |
96 | virtual void SetScrollPos( int orient, int pos, bool refresh = true ); | |
97 | virtual int GetScrollPos( int orient ) const; | |
98 | virtual int GetScrollThumb( int orient ) const; | |
99 | virtual int GetScrollRange( int orient ) const; | |
100 | virtual void ScrollWindow( int dx, int dy, | |
101 | const wxRect* rect = NULL ); | |
102 | ||
103 | #if wxUSE_DRAG_AND_DROP | |
104 | virtual void SetDropTarget( wxDropTarget *dropTarget ); | |
105 | #endif // wxUSE_DRAG_AND_DROP | |
106 | ||
107 | virtual bool IsDoubleBuffered() const { return false; } | |
108 | ||
109 | GdkWindow* GTKGetDrawingWindow() const; | |
110 | ||
111 | // implementation | |
112 | // -------------- | |
113 | ||
114 | virtual WXWidget GetHandle() const { return m_widget; } | |
115 | ||
116 | // I don't want users to override what's done in idle so everything that | |
117 | // has to be done in idle time in order for wxGTK to work is done in | |
118 | // OnInternalIdle | |
119 | virtual void OnInternalIdle(); | |
120 | ||
121 | // Internal representation of Update() | |
122 | void GtkUpdate(); | |
123 | ||
124 | // For compatibility across platforms (not in event table) | |
125 | void OnIdle(wxIdleEvent& WXUNUSED(event)) {} | |
126 | ||
127 | // Used by all window classes in the widget creation process. | |
128 | bool PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size ); | |
129 | void PostCreation(); | |
130 | ||
131 | // Internal addition of child windows. differs from class | |
132 | // to class not by using virtual functions but by using | |
133 | // the m_insertCallback. | |
134 | void DoAddChild(wxWindowGTK *child); | |
135 | ||
136 | // This methods sends wxPaintEvents to the window. It reads the | |
137 | // update region, breaks it up into rects and sends an event | |
138 | // for each rect. It is also responsible for background erase | |
139 | // events and NC paint events. It is called from "draw" and | |
140 | // "expose" handlers as well as from ::Update() | |
141 | void GtkSendPaintEvents(); | |
142 | ||
143 | // The methods below are required because many native widgets | |
144 | // are composed of several subwidgets and setting a style for | |
145 | // the widget means setting it for all subwidgets as well. | |
146 | // also, it is not clear which native widget is the top | |
147 | // widget where (most of) the input goes. even tooltips have | |
148 | // to be applied to all subwidgets. | |
149 | virtual GtkWidget* GetConnectWidget(); | |
150 | virtual bool IsOwnGtkWindow( GdkWindow *window ); | |
151 | void ConnectWidget( GtkWidget *widget ); | |
152 | ||
153 | #if wxUSE_TOOLTIPS | |
154 | virtual void ApplyToolTip( GtkTooltips *tips, const wxChar *tip ); | |
155 | #endif // wxUSE_TOOLTIPS | |
156 | ||
157 | // Call after modifing the value of m_hAdjust or m_vAdjust to bring the | |
158 | // scrolbar in sync (this does not generate any wx events) | |
159 | void GtkUpdateScrollbar(int orient); | |
160 | ||
161 | // Called from GTK signal handlers. it indicates that | |
162 | // the layout functions have to be called later on | |
163 | // (i.e. in idle time, implemented in OnInternalIdle() ). | |
164 | void GtkUpdateSize() { m_sizeSet = false; } | |
165 | ||
166 | // fix up the mouse event coords, used by wxListBox only so far | |
167 | virtual void FixUpMouseEvent(GtkWidget * WXUNUSED(widget), | |
168 | wxCoord& WXUNUSED(x), | |
169 | wxCoord& WXUNUSED(y)) { } | |
170 | ||
171 | // is this window transparent for the mouse events (as wxStaticBox is)? | |
172 | virtual bool IsTransparentForMouse() const { return false; } | |
173 | ||
174 | // is this a radiobutton (used by radiobutton code itself only)? | |
175 | virtual bool IsRadioButton() const { return false; } | |
176 | ||
177 | // position and size of the window | |
178 | int m_x, m_y; | |
179 | int m_width, m_height; | |
180 | int m_oldClientWidth,m_oldClientHeight; | |
181 | ||
182 | // see the docs in src/gtk/window.cpp | |
183 | GtkWidget *m_widget; // mostly the widget seen by the rest of GTK | |
184 | GtkWidget *m_wxwindow; // mostly the client area as per wxWidgets | |
185 | ||
186 | // this widget will be queried for GTK's focus events | |
187 | GtkWidget *m_focusWidget; | |
188 | ||
189 | #ifdef HAVE_XIM | |
190 | // XIM support for wxWidgets | |
191 | GdkIC *m_ic; | |
192 | GdkICAttr *m_icattr; | |
193 | #endif // HAVE_XIM | |
194 | ||
195 | // The area to be cleared (and not just refreshed) | |
196 | // We cannot make this distinction under GTK 2.0. | |
197 | wxRegion m_clearRegion; | |
198 | ||
199 | // scrolling stuff | |
200 | GtkAdjustment *m_hAdjust,*m_vAdjust; | |
201 | float m_oldHorizontalPos; | |
202 | float m_oldVerticalPos; | |
203 | ||
204 | // extra (wxGTK-specific) flags | |
205 | bool m_needParent:1; // ! wxFrame, wxDialog, wxNotebookPage ? | |
206 | bool m_noExpose:1; // wxGLCanvas has its own redrawing | |
207 | bool m_nativeSizeEvent:1; // wxGLCanvas sends wxSizeEvent upon "alloc_size" | |
208 | bool m_hasScrolling:1; | |
209 | bool m_hasVMT:1; | |
210 | bool m_sizeSet:1; | |
211 | bool m_resizing:1; | |
212 | bool m_acceptsFocus:1; // true if not static | |
213 | bool m_hasFocus:1; // true if == FindFocus() | |
214 | bool m_isScrolling:1; // dragging scrollbar thumb? | |
215 | bool m_clipPaintRegion:1; // true after ScrollWindow() | |
216 | bool m_needsStyleChange:1; // May not be able to change | |
217 | // background style until OnIdle | |
218 | ||
219 | // C++ has no virtual methods in the constrcutor of any class but we need | |
220 | // different methods of inserting a child window into a wxFrame, | |
221 | // wxMDIFrame, wxNotebook etc. this is the callback that will get used. | |
222 | wxInsertChildFunction m_insertCallback; | |
223 | ||
224 | // implement the base class pure virtuals | |
225 | virtual void DoGetTextExtent(const wxString& string, | |
226 | int *x, int *y, | |
227 | int *descent = NULL, | |
228 | int *externalLeading = NULL, | |
229 | const wxFont *theFont = NULL) const; | |
230 | ||
231 | #if wxUSE_MENUS_NATIVE | |
232 | virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); | |
233 | #endif // wxUSE_MENUS_NATIVE | |
234 | ||
235 | virtual void DoClientToScreen( int *x, int *y ) const; | |
236 | virtual void DoScreenToClient( int *x, int *y ) const; | |
237 | virtual void DoGetPosition( int *x, int *y ) const; | |
238 | virtual void DoGetSize( int *width, int *height ) const; | |
239 | virtual void DoGetClientSize( int *width, int *height ) const; | |
240 | virtual void DoSetSize(int x, int y, | |
241 | int width, int height, | |
242 | int sizeFlags = wxSIZE_AUTO); | |
243 | virtual void DoSetClientSize(int width, int height); | |
244 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
245 | ||
246 | virtual void DoCaptureMouse(); | |
247 | virtual void DoReleaseMouse(); | |
248 | ||
249 | #if wxUSE_TOOLTIPS | |
250 | virtual void DoSetToolTip( wxToolTip *tip ); | |
251 | #endif // wxUSE_TOOLTIPS | |
252 | ||
253 | protected: | |
254 | // common part of all ctors (not virtual because called from ctor) | |
255 | void Init(); | |
256 | ||
257 | // Called by ApplyWidgetStyle (which is called by SetFont() and | |
258 | // SetXXXColour etc to apply style changed to native widgets) to create | |
259 | // modified GTK style with non-standard attributes. If forceStyle=true, | |
260 | // creates empty GtkRcStyle if there are no modifications, otherwise | |
261 | // returns NULL in such case. | |
262 | GtkRcStyle *CreateWidgetStyle(bool forceStyle = false); | |
263 | ||
264 | // Overridden in many GTK widgets who have to handle subwidgets | |
265 | virtual void ApplyWidgetStyle(bool forceStyle = false); | |
266 | ||
267 | // helper function to ease native widgets wrapping, called by | |
268 | // ApplyWidgetStyle -- override this, not ApplyWidgetStyle | |
269 | virtual void DoApplyWidgetStyle(GtkRcStyle *style); | |
270 | ||
271 | private: | |
272 | DECLARE_DYNAMIC_CLASS(wxWindowGTK) | |
273 | wxDECLARE_NO_COPY_CLASS(wxWindowGTK); | |
274 | }; | |
275 | ||
276 | extern WXDLLIMPEXP_CORE wxWindow *wxFindFocusedChild(wxWindowGTK *win); | |
277 | ||
278 | #endif // __GTKWINDOWH__ |