]>
Commit | Line | Data |
---|---|---|
f03fc89f | 1 | /////////////////////////////////////////////////////////////////////////////// |
23895080 | 2 | // Name: wx/window.h |
789295bf | 3 | // Purpose: wxWindowBase class - the interface of wxWindow |
f03fc89f VZ |
4 | // Author: Vadim Zeitlin |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) wxWindows team | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
34138703 JS |
12 | #ifndef _WX_WINDOW_H_BASE_ |
13 | #define _WX_WINDOW_H_BASE_ | |
c801d85f | 14 | |
58654ed0 VZ |
15 | #ifdef __GNUG__ |
16 | #pragma interface "windowbase.h" | |
17 | #endif | |
18 | ||
f03fc89f VZ |
19 | // ---------------------------------------------------------------------------- |
20 | // headers which we must include here | |
21 | // ---------------------------------------------------------------------------- | |
22 | ||
23 | #include "wx/event.h" // the base class | |
24 | ||
25 | #include "wx/list.h" // defines wxWindowList | |
26 | ||
27 | #include "wx/cursor.h" // we have member variables of these classes | |
28 | #include "wx/font.h" // so we can't do without them | |
29 | #include "wx/colour.h" | |
30 | #include "wx/region.h" | |
5e4ff78a | 31 | #include "wx/utils.h" |
88ac883a | 32 | |
674ac8b9 | 33 | #include "wx/validate.h" // for wxDefaultValidator (always include it) |
8d99be5f | 34 | |
574c939e KB |
35 | #if wxUSE_PALETTE |
36 | #include "wx/dcclient.h" | |
37 | #include "wx/palette.h" | |
38 | #endif // wxUSE_PALETTE | |
39 | ||
88ac883a VZ |
40 | #if wxUSE_ACCEL |
41 | #include "wx/accel.h" | |
42 | #endif // wxUSE_ACCEL | |
f03fc89f | 43 | |
6522713c VZ |
44 | // when building wxUniv/Foo we don't want the code for native menu use to be |
45 | // compiled in - it should only be used when building real wxFoo | |
46 | #ifdef __WXUNIVERSAL__ | |
47 | #define wxUSE_MENUS_NATIVE 0 | |
48 | #else // __WXMSW__ | |
49 | #define wxUSE_MENUS_NATIVE wxUSE_MENUS | |
50 | #endif // __WXUNIVERSAL__/__WXMSW__ | |
51 | ||
f03fc89f VZ |
52 | // ---------------------------------------------------------------------------- |
53 | // forward declarations | |
54 | // ---------------------------------------------------------------------------- | |
55 | ||
789295bf | 56 | class WXDLLEXPORT wxCaret; |
f03fc89f VZ |
57 | class WXDLLEXPORT wxControl; |
58 | class WXDLLEXPORT wxCursor; | |
eb082a08 | 59 | class WXDLLEXPORT wxDC; |
f03fc89f VZ |
60 | class WXDLLEXPORT wxDropTarget; |
61 | class WXDLLEXPORT wxItemResource; | |
62 | class WXDLLEXPORT wxLayoutConstraints; | |
63 | class WXDLLEXPORT wxResourceTable; | |
64 | class WXDLLEXPORT wxSizer; | |
65 | class WXDLLEXPORT wxToolTip; | |
f03fc89f VZ |
66 | class WXDLLEXPORT wxWindowBase; |
67 | class WXDLLEXPORT wxWindow; | |
68 | ||
69 | // ---------------------------------------------------------------------------- | |
70 | // (pseudo)template list classes | |
71 | // ---------------------------------------------------------------------------- | |
72 | ||
f6bcfd97 | 73 | WX_DECLARE_LIST_3(wxWindow, wxWindowBase, wxWindowList, wxWindowListNode, class WXDLLEXPORT); |
f03fc89f VZ |
74 | |
75 | // ---------------------------------------------------------------------------- | |
76 | // global variables | |
77 | // ---------------------------------------------------------------------------- | |
78 | ||
79 | WXDLLEXPORT_DATA(extern wxWindowList) wxTopLevelWindows; | |
80 | ||
f03fc89f VZ |
81 | // ---------------------------------------------------------------------------- |
82 | // wxWindowBase is the base class for all GUI controls/widgets, this is the public | |
83 | // interface of this class. | |
84 | // | |
85 | // Event handler: windows have themselves as their event handlers by default, | |
86 | // but their event handlers could be set to another object entirely. This | |
87 | // separation can reduce the amount of derivation required, and allow | |
88 | // alteration of a window's functionality (e.g. by a resource editor that | |
89 | // temporarily switches event handlers). | |
90 | // ---------------------------------------------------------------------------- | |
91 | ||
92 | class WXDLLEXPORT wxWindowBase : public wxEvtHandler | |
93 | { | |
f03fc89f VZ |
94 | public: |
95 | // creating the window | |
96 | // ------------------- | |
97 | ||
98 | // default ctor | |
99 | wxWindowBase() { InitBase(); } | |
100 | ||
101 | // pseudo ctor (can't be virtual, called from ctor) | |
102 | bool CreateBase(wxWindowBase *parent, | |
103 | wxWindowID id, | |
104 | const wxPoint& pos = wxDefaultPosition, | |
105 | const wxSize& size = wxDefaultSize, | |
106 | long style = 0, | |
8d99be5f | 107 | const wxValidator& validator = wxDefaultValidator, |
f03fc89f VZ |
108 | const wxString& name = wxPanelNameStr); |
109 | ||
110 | virtual ~wxWindowBase(); | |
111 | ||
112 | #if wxUSE_WX_RESOURCES | |
113 | // these functions are implemented in resource.cpp and resourc2.cpp | |
114 | virtual bool LoadFromResource(wxWindow *parent, | |
115 | const wxString& resourceName, | |
116 | const wxResourceTable *table = (const wxResourceTable *) NULL); | |
117 | virtual wxControl *CreateItem(const wxItemResource* childResource, | |
118 | const wxItemResource* parentResource, | |
119 | const wxResourceTable *table = (const wxResourceTable *) NULL); | |
120 | #endif // wxUSE_WX_RESOURCES | |
121 | ||
122 | // deleting the window | |
123 | // ------------------- | |
124 | ||
125 | // ask the window to close itself, return TRUE if the event handler | |
126 | // honoured our request | |
127 | bool Close( bool force = FALSE ); | |
128 | ||
129 | // the following functions delete the C++ objects (the window itself | |
130 | // or its children) as well as the GUI windows and normally should | |
131 | // never be used directly | |
132 | ||
133 | // delete window unconditionally (dangerous!), returns TRUE if ok | |
134 | virtual bool Destroy(); | |
135 | // delete all children of this window, returns TRUE if ok | |
136 | bool DestroyChildren(); | |
137 | ||
138 | // is the window being deleted? | |
139 | bool IsBeingDeleted() const { return m_isBeingDeleted; } | |
140 | ||
141 | // window attributes | |
142 | // ----------------- | |
143 | ||
456bc6d9 VZ |
144 | // NB: in future versions of wxWindows Set/GetTitle() will only work |
145 | // with the top level windows (such as dialogs and frames) and | |
146 | // Set/GetLabel() only with the other ones (i.e. all controls). | |
147 | ||
f03fc89f VZ |
148 | // the title (or label, see below) of the window: the text which the |
149 | // window shows | |
fe6b43a3 VS |
150 | virtual void SetTitle( const wxString& WXUNUSED(title) ) {} |
151 | virtual wxString GetTitle() const { return wxEmptyString; } | |
f03fc89f VZ |
152 | |
153 | // label is just the same as the title (but for, e.g., buttons it | |
154 | // makes more sense to speak about labels) | |
eba0e4d4 RR |
155 | virtual void SetLabel(const wxString& label) { SetTitle(label); } |
156 | virtual wxString GetLabel() const { return GetTitle(); } | |
f03fc89f VZ |
157 | |
158 | // the window name is used for ressource setting in X, it is not the | |
159 | // same as the window title/label | |
160 | virtual void SetName( const wxString &name ) { m_windowName = name; } | |
161 | virtual wxString GetName() const { return m_windowName; } | |
162 | ||
163 | // window id uniquely identifies the window among its siblings unless | |
164 | // it is -1 which means "don't care" | |
165 | void SetId( wxWindowID id ) { m_windowId = id; } | |
166 | wxWindowID GetId() const { return m_windowId; } | |
167 | ||
168 | // generate a control id for the controls which were not given one by | |
169 | // user | |
69418a8e | 170 | static int NewControlId() { return --ms_lastControlId; } |
c539ab55 VZ |
171 | // get the id of the control following the one with the given |
172 | // (autogenerated) id | |
173 | static int NextControlId(int id) { return id - 1; } | |
174 | // get the id of the control preceding the one with the given | |
175 | // (autogenerated) id | |
176 | static int PrevControlId(int id) { return id + 1; } | |
f03fc89f VZ |
177 | |
178 | // moving/resizing | |
179 | // --------------- | |
180 | ||
181 | // set the window size and/or position | |
182 | void SetSize( int x, int y, int width, int height, | |
183 | int sizeFlags = wxSIZE_AUTO ) | |
184 | { DoSetSize(x, y, width, height, sizeFlags); } | |
185 | ||
186 | void SetSize( int width, int height ) | |
187 | { DoSetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); } | |
188 | ||
189 | void SetSize( const wxSize& size ) | |
190 | { SetSize( size.x, size.y); } | |
191 | ||
192 | void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO) | |
193 | { DoSetSize(rect.x, rect.y, rect.width, rect.height, sizeFlags); } | |
194 | ||
1e6feb95 VZ |
195 | void Move(int x, int y, int flags = wxSIZE_USE_EXISTING) |
196 | { DoSetSize(x, y, -1, -1, flags); } | |
f03fc89f | 197 | |
1e6feb95 VZ |
198 | void Move(const wxPoint& pt, int flags = wxSIZE_USE_EXISTING) |
199 | { Move(pt.x, pt.y, flags); } | |
f03fc89f VZ |
200 | |
201 | // Z-order | |
202 | virtual void Raise() = 0; | |
203 | virtual void Lower() = 0; | |
204 | ||
205 | // client size is the size of area available for subwindows | |
206 | void SetClientSize( int width, int height ) | |
207 | { DoSetClientSize(width, height); } | |
208 | ||
209 | void SetClientSize( const wxSize& size ) | |
210 | { DoSetClientSize(size.x, size.y); } | |
211 | ||
212 | void SetClientSize(const wxRect& rect) | |
213 | { SetClientSize( rect.width, rect.height ); } | |
214 | ||
215 | // get the window position and/or size (pointers may be NULL) | |
216 | void GetPosition( int *x, int *y ) const { DoGetPosition(x, y); } | |
217 | wxPoint GetPosition() const | |
218 | { | |
219 | int w, h; | |
220 | DoGetPosition(&w, &h); | |
221 | ||
222 | return wxPoint(w, h); | |
223 | } | |
224 | ||
225 | void GetSize( int *w, int *h ) const { DoGetSize(w, h); } | |
226 | wxSize GetSize() const | |
227 | { | |
228 | int w, h; | |
229 | DoGetSize(& w, & h); | |
230 | return wxSize(w, h); | |
231 | } | |
232 | ||
233 | wxRect GetRect() const | |
234 | { | |
235 | int x, y, w, h; | |
236 | GetPosition(& x, & y); | |
237 | GetSize(& w, & h); | |
238 | ||
239 | return wxRect(x, y, w, h); | |
240 | } | |
241 | ||
242 | void GetClientSize( int *w, int *h ) const { DoGetClientSize(w, h); } | |
243 | wxSize GetClientSize() const | |
244 | { | |
245 | int w, h; | |
246 | DoGetClientSize(& w, & h); | |
247 | ||
248 | return wxSize(w, h); | |
249 | } | |
250 | ||
1e6feb95 VZ |
251 | // get the origin of the client area of the window relative to the |
252 | // window top left corner (the client area may be shifted because of | |
253 | // the borders, scrollbars, other decorations...) | |
254 | virtual wxPoint GetClientAreaOrigin() const; | |
255 | ||
256 | // get the client rectangle in window (i.e. client) coordinates | |
257 | wxRect GetClientRect() const | |
258 | { | |
259 | return wxRect(GetClientAreaOrigin(), GetClientSize()); | |
260 | } | |
261 | ||
f68586e5 VZ |
262 | // get the size best suited for the window (in fact, minimal |
263 | // acceptable size using which it will still look "nice") | |
264 | wxSize GetBestSize() const { return DoGetBestSize(); } | |
265 | void GetBestSize(int *w, int *h) const | |
266 | { | |
267 | wxSize s = DoGetBestSize(); | |
268 | if ( w ) | |
269 | *w = s.x; | |
270 | if ( h ) | |
271 | *h = s.y; | |
272 | } | |
273 | ||
7eb4e9cc VZ |
274 | // the generic centre function - centers the window on parent by |
275 | // default or on screen if it doesn't have parent or | |
276 | // wxCENTER_ON_SCREEN flag is given | |
c39eda94 VZ |
277 | void Centre( int direction = wxBOTH ); |
278 | void Center( int direction = wxBOTH ) { Centre(direction); } | |
7eb4e9cc VZ |
279 | |
280 | // centre on screen (only works for top level windows) | |
281 | void CentreOnScreen(int dir = wxBOTH) { Centre(dir | wxCENTER_ON_SCREEN); } | |
282 | void CenterOnScreen(int dir = wxBOTH) { CentreOnScreen(dir); } | |
283 | ||
284 | // centre with respect to the the parent window | |
285 | void CentreOnParent(int dir = wxBOTH) { Centre(dir | wxCENTER_FRAME); } | |
286 | void CenterOnParent(int dir = wxBOTH) { CentreOnParent(dir); } | |
f03fc89f VZ |
287 | |
288 | // set window size to wrap around its children | |
289 | virtual void Fit(); | |
290 | ||
291 | // set min/max size of the window | |
292 | virtual void SetSizeHints( int minW, int minH, | |
293 | int maxW = -1, int maxH = -1, | |
294 | int incW = -1, int incH = -1 ); | |
295 | ||
e7dda1ff VS |
296 | virtual int GetMinWidth() const { return m_minWidth; } |
297 | virtual int GetMinHeight() const { return m_minHeight; } | |
738f9e5a RR |
298 | int GetMaxWidth() const { return m_maxWidth; } |
299 | int GetMaxHeight() const { return m_maxHeight; } | |
57c4d796 | 300 | |
f03fc89f VZ |
301 | // window state |
302 | // ------------ | |
303 | ||
304 | // returns TRUE if window was shown/hidden, FALSE if the nothing was | |
305 | // done (window was already shown/hidden) | |
306 | virtual bool Show( bool show = TRUE ); | |
307 | bool Hide() { return Show(FALSE); } | |
308 | ||
309 | // returns TRUE if window was enabled/disabled, FALSE if nothing done | |
310 | virtual bool Enable( bool enable = TRUE ); | |
311 | bool Disable() { return Enable(FALSE); } | |
312 | ||
313 | bool IsShown() const { return m_isShown; } | |
314 | bool IsEnabled() const { return m_isEnabled; } | |
315 | ||
316 | // get/set window style (setting style won't update the window and so | |
317 | // is only useful for internal usage) | |
318 | virtual void SetWindowStyleFlag( long style ) { m_windowStyle = style; } | |
319 | virtual long GetWindowStyleFlag() const { return m_windowStyle; } | |
320 | ||
321 | // just some (somewhat shorter) synonims | |
322 | void SetWindowStyle( long style ) { SetWindowStyleFlag(style); } | |
323 | long GetWindowStyle() const { return GetWindowStyleFlag(); } | |
324 | ||
325 | bool HasFlag(int flag) const { return (m_windowStyle & flag) != 0; } | |
d80cd92a | 326 | virtual bool IsRetained() const { return HasFlag(wxRETAINED); } |
f03fc89f | 327 | |
d80cd92a VZ |
328 | // extra style: the less often used style bits which can't be set with |
329 | // SetWindowStyleFlag() | |
330 | void SetExtraStyle(long exStyle) { m_exStyle = exStyle; } | |
331 | long GetExtraStyle() const { return m_exStyle; } | |
f03fc89f VZ |
332 | |
333 | // make the window modal (all other windows unresponsive) | |
334 | virtual void MakeModal(bool modal = TRUE); | |
335 | ||
a2d93e73 JS |
336 | virtual void SetThemeEnabled(bool enableTheme) { m_themeEnabled = enableTheme; } |
337 | virtual bool GetThemeEnabled() const { return m_themeEnabled; } | |
338 | ||
456bc6d9 VZ |
339 | // focus and keyboard handling |
340 | // --------------------------- | |
f03fc89f VZ |
341 | |
342 | // set focus to this window | |
343 | virtual void SetFocus() = 0; | |
344 | ||
345 | // return the window which currently has the focus or NULL | |
346 | static wxWindow *FindFocus() /* = 0: implement in derived classes */; | |
347 | ||
348 | // can this window have focus? | |
349 | virtual bool AcceptsFocus() const { return IsShown() && IsEnabled(); } | |
350 | ||
1e6feb95 VZ |
351 | // can this window be given focus by keyboard navigation? if not, the |
352 | // only way to give it focus (provided it accepts it at all) is to | |
353 | // click it | |
354 | virtual bool AcceptsFocusFromKeyboard() const { return AcceptsFocus(); } | |
355 | ||
456bc6d9 VZ |
356 | // NB: these methods really don't belong here but with the current |
357 | // class hierarchy there is no other place for them :-( | |
358 | ||
359 | // get the default child of this parent, i.e. the one which is | |
360 | // activated by pressing <Enter> | |
361 | virtual wxWindow *GetDefaultItem() const { return NULL; } | |
362 | ||
363 | // set this child as default, return the old default | |
364 | virtual wxWindow *SetDefaultItem(wxWindow * WXUNUSED(child)) | |
365 | { return NULL; } | |
366 | ||
f03fc89f VZ |
367 | // parent/children relations |
368 | // ------------------------- | |
369 | ||
370 | // get the list of children | |
371 | const wxWindowList& GetChildren() const { return m_children; } | |
372 | wxWindowList& GetChildren() { return m_children; } | |
373 | ||
374 | // get the parent or the parent of the parent | |
375 | wxWindow *GetParent() const { return m_parent; } | |
376 | inline wxWindow *GetGrandParent() const; | |
377 | ||
378 | // is this window a top level one? | |
8487f887 | 379 | virtual bool IsTopLevel() const; |
f03fc89f VZ |
380 | |
381 | // it doesn't really change parent, use ReParent() instead | |
382 | void SetParent( wxWindowBase *parent ) { m_parent = (wxWindow *)parent; } | |
383 | // change the real parent of this window, return TRUE if the parent | |
384 | // was changed, FALSE otherwise (error or newParent == oldParent) | |
385 | virtual bool Reparent( wxWindowBase *newParent ); | |
386 | ||
387 | // find window among the descendants of this one either by id or by | |
388 | // name (return NULL if not found) | |
389 | wxWindow *FindWindow( long id ); | |
390 | wxWindow *FindWindow( const wxString& name ); | |
391 | ||
392 | // implementation mostly | |
393 | virtual void AddChild( wxWindowBase *child ); | |
394 | virtual void RemoveChild( wxWindowBase *child ); | |
395 | ||
396 | // event handler stuff | |
397 | // ------------------- | |
398 | ||
399 | // get the current event handler | |
400 | wxEvtHandler *GetEventHandler() const { return m_eventHandler; } | |
401 | ||
402 | // replace the event handler (allows to completely subclass the | |
403 | // window) | |
404 | void SetEventHandler( wxEvtHandler *handler ) { m_eventHandler = handler; } | |
405 | ||
406 | // push/pop event handler: allows to chain a custom event handler to | |
407 | // alreasy existing ones | |
408 | void PushEventHandler( wxEvtHandler *handler ); | |
409 | wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE ); | |
410 | ||
2e36d5cf VZ |
411 | // find the given handler in the event handler chain and remove (but |
412 | // not delete) it from the event handler chain, return TRUE if it was | |
413 | // found and FALSE otherwise (this also results in an assert failure so | |
414 | // this function should only be called when the handler is supposed to | |
415 | // be there) | |
416 | bool RemoveEventHandler(wxEvtHandler *handler); | |
417 | ||
1e6feb95 VZ |
418 | // validators |
419 | // ---------- | |
f03fc89f | 420 | |
88ac883a | 421 | #if wxUSE_VALIDATORS |
f03fc89f VZ |
422 | // a window may have an associated validator which is used to control |
423 | // user input | |
424 | virtual void SetValidator( const wxValidator &validator ); | |
425 | virtual wxValidator *GetValidator() { return m_windowValidator; } | |
88ac883a | 426 | #endif // wxUSE_VALIDATORS |
f03fc89f | 427 | |
f03fc89f VZ |
428 | |
429 | // dialog oriented functions | |
430 | // ------------------------- | |
431 | ||
432 | // validate the correctness of input, return TRUE if ok | |
433 | virtual bool Validate(); | |
434 | ||
435 | // transfer data between internal and GUI representations | |
436 | virtual bool TransferDataToWindow(); | |
437 | virtual bool TransferDataFromWindow(); | |
438 | ||
439 | virtual void InitDialog(); | |
440 | ||
88ac883a | 441 | #if wxUSE_ACCEL |
f03fc89f VZ |
442 | // accelerators |
443 | // ------------ | |
444 | virtual void SetAcceleratorTable( const wxAcceleratorTable& accel ) | |
445 | { m_acceleratorTable = accel; } | |
446 | wxAcceleratorTable *GetAcceleratorTable() | |
447 | { return &m_acceleratorTable; } | |
88ac883a | 448 | #endif // wxUSE_ACCEL |
f03fc89f VZ |
449 | |
450 | // dialog units translations | |
451 | // ------------------------- | |
452 | ||
453 | wxPoint ConvertPixelsToDialog( const wxPoint& pt ); | |
454 | wxPoint ConvertDialogToPixels( const wxPoint& pt ); | |
455 | wxSize ConvertPixelsToDialog( const wxSize& sz ) | |
456 | { | |
457 | wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); | |
458 | ||
459 | return wxSize(pt.x, pt.y); | |
460 | } | |
461 | ||
462 | wxSize ConvertDialogToPixels( const wxSize& sz ) | |
463 | { | |
464 | wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); | |
465 | ||
466 | return wxSize(pt.x, pt.y); | |
467 | } | |
468 | ||
469 | // mouse functions | |
470 | // --------------- | |
471 | ||
472 | // move the mouse to the specified position | |
473 | virtual void WarpPointer(int x, int y) = 0; | |
474 | ||
94633ad9 VZ |
475 | // start or end mouse capture, these functions maintain the stack of |
476 | // windows having captured the mouse and after calling ReleaseMouse() | |
477 | // the mouse is not released but returns to the window which had had | |
478 | // captured it previously (if any) | |
479 | void CaptureMouse(); | |
480 | void ReleaseMouse(); | |
f03fc89f | 481 | |
1e6feb95 VZ |
482 | // get the window which currently captures the mouse or NULL |
483 | static wxWindow *GetCapture(); | |
484 | ||
485 | // does this window have the capture? | |
486 | virtual bool HasCapture() const | |
487 | { return (wxWindow *)this == GetCapture(); } | |
488 | ||
f03fc89f VZ |
489 | // painting the window |
490 | // ------------------- | |
491 | ||
492 | // mark the specified rectangle (or the whole window) as "dirty" so it | |
493 | // will be repainted | |
494 | virtual void Refresh( bool eraseBackground = TRUE, | |
495 | const wxRect *rect = (const wxRect *) NULL ) = 0; | |
1e6feb95 VZ |
496 | |
497 | // a less awkward wrapper for Refresh | |
498 | void RefreshRect(const wxRect& rect) { Refresh(TRUE, &rect); } | |
499 | ||
500 | // repaint all invalid areas of the window immediately | |
501 | virtual void Update() { } | |
502 | ||
f03fc89f VZ |
503 | // clear the window entirely |
504 | virtual void Clear() = 0; | |
505 | ||
0cc7251e VZ |
506 | // freeze the window: don't redraw it until it is thawed |
507 | virtual void Freeze() { } | |
508 | ||
509 | // thaw the window: redraw it after it had been frozen | |
510 | virtual void Thaw() { } | |
511 | ||
f03fc89f | 512 | // adjust DC for drawing on this window |
f6147cfc | 513 | virtual void PrepareDC( wxDC & WXUNUSED(dc) ) { } |
f03fc89f VZ |
514 | |
515 | // the update region of the window contains the areas which must be | |
516 | // repainted by the program | |
517 | const wxRegion& GetUpdateRegion() const { return m_updateRegion; } | |
518 | wxRegion& GetUpdateRegion() { return m_updateRegion; } | |
519 | ||
1e6feb95 VZ |
520 | // get the update rectangleregion bounding box in client coords |
521 | wxRect GetUpdateClientRect() const; | |
522 | ||
f03fc89f VZ |
523 | // these functions verify whether the given point/rectangle belongs to |
524 | // (or at least intersects with) the update region | |
525 | bool IsExposed( int x, int y ) const; | |
526 | bool IsExposed( int x, int y, int w, int h ) const; | |
527 | ||
528 | bool IsExposed( const wxPoint& pt ) const | |
529 | { return IsExposed(pt.x, pt.y); } | |
530 | bool IsExposed( const wxRect& rect ) const | |
531 | { return IsExposed(rect.x, rect.y, rect.width, rect.height); } | |
532 | ||
533 | // colours, fonts and cursors | |
534 | // -------------------------- | |
535 | ||
536 | // set/retrieve the window colours (system defaults are used by | |
537 | // default): Set functions return TRUE if colour was changed | |
538 | virtual bool SetBackgroundColour( const wxColour &colour ); | |
539 | virtual bool SetForegroundColour( const wxColour &colour ); | |
540 | ||
541 | wxColour GetBackgroundColour() const { return m_backgroundColour; } | |
542 | wxColour GetForegroundColour() const { return m_foregroundColour; } | |
543 | ||
544 | // set/retrieve the cursor for this window (SetCursor() returns TRUE | |
545 | // if the cursor was really changed) | |
546 | virtual bool SetCursor( const wxCursor &cursor ); | |
547 | const wxCursor& GetCursor() const { return m_cursor; } | |
548 | wxCursor& GetCursor() { return m_cursor; } | |
549 | ||
550 | // set/retrieve the font for the window (SetFont() returns TRUE if the | |
551 | // font really changed) | |
552 | virtual bool SetFont( const wxFont &font ) = 0; | |
553 | const wxFont& GetFont() const { return m_font; } | |
554 | wxFont& GetFont() { return m_font; } | |
555 | ||
789295bf VZ |
556 | #if wxUSE_CARET |
557 | // associate a caret with the window | |
558 | void SetCaret(wxCaret *caret); | |
559 | // get the current caret (may be NULL) | |
560 | wxCaret *GetCaret() const { return m_caret; } | |
561 | #endif // wxUSE_CARET | |
562 | ||
f03fc89f VZ |
563 | // get the (average) character size for the current font |
564 | virtual int GetCharHeight() const = 0; | |
565 | virtual int GetCharWidth() const = 0; | |
566 | ||
567 | // get the width/height/... of the text using current or specified | |
568 | // font | |
569 | virtual void GetTextExtent(const wxString& string, | |
570 | int *x, int *y, | |
571 | int *descent = (int *) NULL, | |
572 | int *externalLeading = (int *) NULL, | |
573 | const wxFont *theFont = (const wxFont *) NULL) | |
574 | const = 0; | |
575 | ||
1e6feb95 VZ |
576 | // client <-> screen coords |
577 | // ------------------------ | |
578 | ||
f03fc89f | 579 | // translate to/from screen/client coordinates (pointers may be NULL) |
dabc0cd5 VZ |
580 | void ClientToScreen( int *x, int *y ) const |
581 | { DoClientToScreen(x, y); } | |
582 | void ScreenToClient( int *x, int *y ) const | |
583 | { DoScreenToClient(x, y); } | |
1e6feb95 VZ |
584 | |
585 | // wxPoint interface to do the same thing | |
dabc0cd5 VZ |
586 | wxPoint ClientToScreen(const wxPoint& pt) const |
587 | { | |
588 | int x = pt.x, y = pt.y; | |
589 | DoClientToScreen(&x, &y); | |
590 | ||
591 | return wxPoint(x, y); | |
592 | } | |
593 | ||
594 | wxPoint ScreenToClient(const wxPoint& pt) const | |
595 | { | |
596 | int x = pt.x, y = pt.y; | |
597 | DoScreenToClient(&x, &y); | |
598 | ||
599 | return wxPoint(x, y); | |
600 | } | |
f03fc89f | 601 | |
1e6feb95 VZ |
602 | // test where the given (in client coords) point lies |
603 | wxHitTest HitTest(wxCoord x, wxCoord y) const | |
604 | { return DoHitTest(x, y); } | |
605 | ||
606 | wxHitTest HitTest(const wxPoint& pt) const | |
607 | { return DoHitTest(pt.x, pt.y); } | |
608 | ||
f03fc89f VZ |
609 | // misc |
610 | // ---- | |
611 | ||
1e6feb95 VZ |
612 | // get the window border style: uses the current style and falls back to |
613 | // the default style for this class otherwise (see GetDefaultBorder()) | |
614 | wxBorder GetBorder() const; | |
615 | ||
f03fc89f VZ |
616 | void UpdateWindowUI(); |
617 | ||
1e6feb95 | 618 | #if wxUSE_MENUS |
a1665b22 VZ |
619 | bool PopupMenu( wxMenu *menu, const wxPoint& pos ) |
620 | { return DoPopupMenu(menu, pos.x, pos.y); } | |
621 | bool PopupMenu( wxMenu *menu, int x, int y ) | |
622 | { return DoPopupMenu(menu, x, y); } | |
1e6feb95 | 623 | #endif // wxUSE_MENUS |
f03fc89f VZ |
624 | |
625 | // scrollbars | |
626 | // ---------- | |
627 | ||
1e6feb95 VZ |
628 | // does the window have the scrollbar for this orientation? |
629 | bool HasScrollbar(int orient) const | |
630 | { | |
631 | return (m_windowStyle & | |
632 | (orient == wxHORIZONTAL ? wxHSCROLL : wxVSCROLL)) != 0; | |
633 | } | |
634 | ||
f03fc89f VZ |
635 | // configure the window scrollbars |
636 | virtual void SetScrollbar( int orient, | |
637 | int pos, | |
1e6feb95 | 638 | int thumbvisible, |
f03fc89f VZ |
639 | int range, |
640 | bool refresh = TRUE ) = 0; | |
641 | virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ) = 0; | |
642 | virtual int GetScrollPos( int orient ) const = 0; | |
643 | virtual int GetScrollThumb( int orient ) const = 0; | |
644 | virtual int GetScrollRange( int orient ) const = 0; | |
645 | ||
646 | // scroll window to the specified position | |
647 | virtual void ScrollWindow( int dx, int dy, | |
648 | const wxRect* rect = (wxRect *) NULL ) = 0; | |
649 | ||
b9b3393e | 650 | // scrolls window by line/page: note that not all controls support this |
9cd6d737 VZ |
651 | // |
652 | // return TRUE if the position changed, FALSE otherwise | |
653 | virtual bool ScrollLines(int WXUNUSED(lines)) { return FALSE; } | |
654 | virtual bool ScrollPages(int WXUNUSED(pages)) { return FALSE; } | |
655 | ||
656 | // convenient wrappers for ScrollLines/Pages | |
657 | bool LineUp() { return ScrollLines(-1); } | |
658 | bool LineDown() { return ScrollLines(1); } | |
659 | bool PageUp() { return ScrollPages(-1); } | |
660 | bool PageDown() { return ScrollPages(1); } | |
b9b3393e | 661 | |
bd83cb56 VZ |
662 | // context-sensitive help |
663 | // ---------------------- | |
664 | ||
665 | // these are the convenience functions wrapping wxHelpProvider methods | |
666 | ||
667 | #if wxUSE_HELP | |
668 | // associate this help text with this window | |
669 | void SetHelpText(const wxString& text); | |
670 | // associate this help text with all windows with the same id as this | |
671 | // one | |
672 | void SetHelpTextForId(const wxString& text); | |
673 | // get the help string associated with this window (may be empty) | |
674 | wxString GetHelpText() const; | |
675 | #endif // wxUSE_HELP | |
676 | ||
f03fc89f VZ |
677 | // tooltips |
678 | // -------- | |
bd83cb56 | 679 | |
f03fc89f VZ |
680 | #if wxUSE_TOOLTIPS |
681 | // the easiest way to set a tooltip for a window is to use this method | |
682 | void SetToolTip( const wxString &tip ); | |
683 | // attach a tooltip to the window | |
684 | void SetToolTip( wxToolTip *tip ) { DoSetToolTip(tip); } | |
685 | // get the associated tooltip or NULL if none | |
686 | wxToolTip* GetToolTip() const { return m_tooltip; } | |
687 | #endif // wxUSE_TOOLTIPS | |
688 | ||
689 | // drag and drop | |
690 | // ------------- | |
691 | #if wxUSE_DRAG_AND_DROP | |
692 | // set/retrieve the drop target associated with this window (may be | |
693 | // NULL; it's owned by the window and will be deleted by it) | |
694 | virtual void SetDropTarget( wxDropTarget *dropTarget ) = 0; | |
695 | virtual wxDropTarget *GetDropTarget() const { return m_dropTarget; } | |
696 | #endif // wxUSE_DRAG_AND_DROP | |
697 | ||
698 | // constraints and sizers | |
699 | // ---------------------- | |
700 | #if wxUSE_CONSTRAINTS | |
701 | // set the constraints for this window or retrieve them (may be NULL) | |
702 | void SetConstraints( wxLayoutConstraints *constraints ); | |
703 | wxLayoutConstraints *GetConstraints() const { return m_constraints; } | |
704 | ||
705 | // when using constraints, it makes sense to update children positions | |
706 | // automatically whenever the window is resized - this is done if | |
707 | // autoLayout is on | |
708 | void SetAutoLayout( bool autoLayout ) { m_autoLayout = autoLayout; } | |
709 | bool GetAutoLayout() const { return m_autoLayout; } | |
710 | ||
711 | // do layout the window and its children | |
712 | virtual bool Layout(); | |
713 | ||
714 | // implementation only | |
715 | void UnsetConstraints(wxLayoutConstraints *c); | |
716 | wxWindowList *GetConstraintsInvolvedIn() const | |
717 | { return m_constraintsInvolvedIn; } | |
718 | void AddConstraintReference(wxWindowBase *otherWin); | |
719 | void RemoveConstraintReference(wxWindowBase *otherWin); | |
720 | void DeleteRelatedConstraints(); | |
721 | void ResetConstraints(); | |
722 | ||
723 | // these methods may be overriden for special layout algorithms | |
724 | virtual void SetConstraintSizes(bool recurse = TRUE); | |
725 | virtual bool LayoutPhase1(int *noChanges); | |
726 | virtual bool LayoutPhase2(int *noChanges); | |
4b7f2165 | 727 | virtual bool DoPhase(int phase); |
f03fc89f VZ |
728 | |
729 | // these methods are virtual but normally won't be overridden | |
f03fc89f VZ |
730 | virtual void SetSizeConstraint(int x, int y, int w, int h); |
731 | virtual void MoveConstraint(int x, int y); | |
732 | virtual void GetSizeConstraint(int *w, int *h) const ; | |
733 | virtual void GetClientSizeConstraint(int *w, int *h) const ; | |
734 | virtual void GetPositionConstraint(int *x, int *y) const ; | |
735 | ||
736 | // sizers | |
737 | // TODO: what are they and how do they work?? | |
738 | void SetSizer( wxSizer *sizer ); | |
739 | wxSizer *GetSizer() const { return m_windowSizer; } | |
f03fc89f VZ |
740 | #endif // wxUSE_CONSTRAINTS |
741 | ||
742 | // backward compatibility | |
743 | // ---------------------- | |
744 | #if WXWIN_COMPATIBILITY | |
745 | bool Enabled() const { return IsEnabled(); } | |
746 | ||
747 | void SetButtonFont(const wxFont& font) { SetFont(font); } | |
748 | void SetLabelFont(const wxFont& font) { SetFont(font); } | |
749 | wxFont& GetLabelFont() { return GetFont(); }; | |
750 | wxFont& GetButtonFont() { return GetFont(); }; | |
751 | #endif // WXWIN_COMPATIBILITY | |
752 | ||
753 | // implementation | |
754 | // -------------- | |
755 | ||
756 | // event handlers | |
757 | void OnSysColourChanged( wxSysColourChangedEvent& event ); | |
758 | void OnInitDialog( wxInitDialogEvent &event ); | |
72fc5caf | 759 | void OnMiddleClick( wxMouseEvent& event ); |
bd83cb56 VZ |
760 | #if wxUSE_HELP |
761 | void OnHelp(wxHelpEvent& event); | |
762 | #endif // wxUSE_HELP | |
f03fc89f | 763 | |
d7c24517 VZ |
764 | // get the haqndle of the window for the underlying window system: this |
765 | // is only used for wxWin itself or for user code which wants to call | |
766 | // platform-specific APIs | |
d22699b5 | 767 | virtual WXWidget GetHandle() const = 0; |
cc2b7472 | 768 | |
574c939e KB |
769 | #if wxUSE_PALETTE |
770 | // Store the palette used by DCs in wxWindow so that the dcs can share | |
771 | // a palette. And we can respond to palette messages. | |
772 | wxPalette GetPalette() const { return m_palette; } | |
b95edd47 | 773 | |
574c939e KB |
774 | // When palette is changed tell the DC to set the system palette to the |
775 | // new one. | |
b95edd47 VZ |
776 | void SetPalette(const wxPalette& pal); |
777 | ||
778 | // return true if we have a specific palette | |
779 | bool HasCustomPalette() const { return m_hasCustomPalette; } | |
780 | ||
781 | // return the first parent window with a custom palette or NULL | |
782 | wxWindow *GetAncestorWithCustomPalette() const; | |
574c939e KB |
783 | #endif // wxUSE_PALETTE |
784 | ||
739730ca | 785 | protected: |
7af6f327 | 786 | // the window id - a number which uniquely identifies a window among |
d7c24517 | 787 | // its siblings unless it is -1 |
f03fc89f | 788 | wxWindowID m_windowId; |
456bc6d9 | 789 | |
f03fc89f VZ |
790 | // the parent window of this window (or NULL) and the list of the children |
791 | // of this window | |
792 | wxWindow *m_parent; | |
793 | wxWindowList m_children; | |
794 | ||
795 | // the minimal allowed size for the window (no minimal size if variable(s) | |
796 | // contain(s) -1) | |
797 | int m_minWidth, m_minHeight, m_maxWidth, m_maxHeight; | |
798 | ||
799 | // event handler for this window: usually is just 'this' but may be | |
800 | // changed with SetEventHandler() | |
801 | wxEvtHandler *m_eventHandler; | |
802 | ||
88ac883a | 803 | #if wxUSE_VALIDATORS |
f03fc89f VZ |
804 | // associated validator or NULL if none |
805 | wxValidator *m_windowValidator; | |
88ac883a | 806 | #endif // wxUSE_VALIDATORS |
f03fc89f VZ |
807 | |
808 | #if wxUSE_DRAG_AND_DROP | |
809 | wxDropTarget *m_dropTarget; | |
810 | #endif // wxUSE_DRAG_AND_DROP | |
811 | ||
812 | // visual window attributes | |
813 | wxCursor m_cursor; | |
814 | wxFont m_font; | |
815 | wxColour m_backgroundColour, m_foregroundColour; | |
816 | ||
789295bf VZ |
817 | #if wxUSE_CARET |
818 | wxCaret *m_caret; | |
819 | #endif // wxUSE_CARET | |
820 | ||
f03fc89f VZ |
821 | // the region which should be repainted in response to paint event |
822 | wxRegion m_updateRegion; | |
823 | ||
88ac883a | 824 | #if wxUSE_ACCEL |
f03fc89f VZ |
825 | // the accelerator table for the window which translates key strokes into |
826 | // command events | |
827 | wxAcceleratorTable m_acceleratorTable; | |
88ac883a | 828 | #endif // wxUSE_ACCEL |
f03fc89f | 829 | |
f03fc89f VZ |
830 | // the tooltip for this window (may be NULL) |
831 | #if wxUSE_TOOLTIPS | |
832 | wxToolTip *m_tooltip; | |
833 | #endif // wxUSE_TOOLTIPS | |
834 | ||
835 | // constraints and sizers | |
836 | #if wxUSE_CONSTRAINTS | |
837 | // the constraints for this window or NULL | |
838 | wxLayoutConstraints *m_constraints; | |
839 | ||
840 | // constraints this window is involved in | |
841 | wxWindowList *m_constraintsInvolvedIn; | |
842 | ||
843 | // top level and the parent sizers | |
844 | // TODO what's this and how does it work?) | |
845 | wxSizer *m_windowSizer; | |
846 | wxWindowBase *m_sizerParent; | |
847 | ||
848 | // Layout() window automatically when its size changes? | |
849 | bool m_autoLayout:1; | |
850 | #endif // wxUSE_CONSTRAINTS | |
851 | ||
852 | // window state | |
853 | bool m_isShown:1; | |
854 | bool m_isEnabled:1; | |
855 | bool m_isBeingDeleted:1; | |
856 | ||
23895080 VZ |
857 | // was the window colours/font explicitly changed by user? |
858 | bool m_hasBgCol:1; | |
859 | bool m_hasFgCol:1; | |
860 | bool m_hasFont:1; | |
861 | ||
f03fc89f | 862 | // window attributes |
d80cd92a VZ |
863 | long m_windowStyle, |
864 | m_exStyle; | |
f03fc89f | 865 | wxString m_windowName; |
a2d93e73 | 866 | bool m_themeEnabled; |
f03fc89f | 867 | |
574c939e KB |
868 | #ifdef wxUSE_PALETTE |
869 | wxPalette m_palette; | |
b95edd47 VZ |
870 | bool m_hasCustomPalette; |
871 | #endif // wxUSE_PALETTE | |
574c939e | 872 | |
f03fc89f | 873 | protected: |
45e0dc94 | 874 | |
f03fc89f VZ |
875 | // common part of all ctors: it is not virtual because it is called from |
876 | // ctor | |
877 | void InitBase(); | |
878 | ||
1e6feb95 VZ |
879 | // override this to change the default (i.e. used when no style is |
880 | // specified) border for the window class | |
881 | virtual wxBorder GetDefaultBorder() const; | |
882 | ||
f03fc89f VZ |
883 | // get the default size for the new window if no explicit size given |
884 | // FIXME why 20 and not 30, 10 or ...? | |
885 | static int WidthDefault(int w) { return w == -1 ? 20 : w; } | |
886 | static int HeightDefault(int h) { return h == -1 ? 20 : h; } | |
887 | ||
1e6feb95 VZ |
888 | // set the best size for the control if the default size was given: |
889 | // replaces the fields of size == -1 with the best values for them and | |
890 | // calls SetSize() if needed | |
891 | void SetBestSize(const wxSize& size) | |
f68586e5 VZ |
892 | { |
893 | if ( size.x == -1 || size.y == -1 ) | |
894 | { | |
1e6feb95 VZ |
895 | wxSize sizeBest = DoGetBestSize(); |
896 | if ( size.x != -1 ) | |
897 | sizeBest.x = size.x; | |
898 | if ( size.y != -1 ) | |
899 | sizeBest.y = size.y; | |
900 | ||
901 | SetSize(sizeBest); | |
f68586e5 VZ |
902 | } |
903 | } | |
904 | ||
f03fc89f VZ |
905 | // more pure virtual functions |
906 | // --------------------------- | |
907 | ||
908 | // NB: we must have DoSomething() function when Something() is an overloaded | |
909 | // method: indeed, we can't just have "virtual Something()" in case when | |
910 | // the function is overloaded because then we'd have to make virtual all | |
911 | // the variants (otherwise only the virtual function may be called on a | |
912 | // pointer to derived class according to C++ rules) which is, in | |
913 | // general, absolutely not needed. So instead we implement all | |
914 | // overloaded Something()s in terms of DoSomething() which will be the | |
915 | // only one to be virtual. | |
916 | ||
dabc0cd5 VZ |
917 | // coordinates translation |
918 | virtual void DoClientToScreen( int *x, int *y ) const = 0; | |
919 | virtual void DoScreenToClient( int *x, int *y ) const = 0; | |
920 | ||
1e6feb95 VZ |
921 | virtual wxHitTest DoHitTest(wxCoord x, wxCoord y) const; |
922 | ||
94633ad9 | 923 | // capture/release the mouse, used by Capture/ReleaseMouse() |
a83e1475 VZ |
924 | virtual void DoCaptureMouse() = 0; |
925 | virtual void DoReleaseMouse() = 0; | |
94633ad9 | 926 | |
f03fc89f VZ |
927 | // retrieve the position/size of the window |
928 | virtual void DoGetPosition( int *x, int *y ) const = 0; | |
929 | virtual void DoGetSize( int *width, int *height ) const = 0; | |
930 | virtual void DoGetClientSize( int *width, int *height ) const = 0; | |
931 | ||
f68586e5 VZ |
932 | // get the size which best suits the window: for a control, it would be |
933 | // the minimal size which doesn't truncate the control, for a panel - the | |
934 | // same size as it would have after a call to Fit() | |
935 | virtual wxSize DoGetBestSize() const; | |
936 | ||
f03fc89f VZ |
937 | // this is the virtual function to be overriden in any derived class which |
938 | // wants to change how SetSize() or Move() works - it is called by all | |
939 | // versions of these functions in the base class | |
940 | virtual void DoSetSize(int x, int y, | |
941 | int width, int height, | |
942 | int sizeFlags = wxSIZE_AUTO) = 0; | |
943 | ||
944 | // same as DoSetSize() for the client size | |
945 | virtual void DoSetClientSize(int width, int height) = 0; | |
946 | ||
9d9b7755 VZ |
947 | // move the window to the specified location and resize it: this is called |
948 | // from both DoSetSize() and DoSetClientSize() and would usually just | |
949 | // reposition this window except for composite controls which will want to | |
950 | // arrange themselves inside the given rectangle | |
951 | virtual void DoMoveWindow(int x, int y, int width, int height) = 0; | |
952 | ||
f03fc89f VZ |
953 | #if wxUSE_TOOLTIPS |
954 | virtual void DoSetToolTip( wxToolTip *tip ); | |
955 | #endif // wxUSE_TOOLTIPS | |
956 | ||
1e6feb95 | 957 | #if wxUSE_MENUS |
a1665b22 | 958 | virtual bool DoPopupMenu( wxMenu *menu, int x, int y ) = 0; |
1e6feb95 | 959 | #endif // wxUSE_MENUS |
a1665b22 | 960 | |
a200c35e VS |
961 | // Makes an adjustment to the window position (for example, a frame that has |
962 | // a toolbar that it manages itself). | |
963 | virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags); | |
8d99be5f | 964 | |
45e0dc94 | 965 | |
f03fc89f | 966 | private: |
45e0dc94 | 967 | |
f03fc89f VZ |
968 | // contains the last id generated by NewControlId |
969 | static int ms_lastControlId; | |
970 | ||
a83e1475 VZ |
971 | // the stack of windows which have captured the mouse |
972 | static struct WXDLLEXPORT wxWindowNext *ms_winCaptureNext; | |
973 | ||
1e6feb95 VZ |
974 | DECLARE_ABSTRACT_CLASS(wxWindowBase) |
975 | DECLARE_NO_COPY_CLASS(wxWindowBase) | |
f03fc89f VZ |
976 | DECLARE_EVENT_TABLE() |
977 | }; | |
978 | ||
979 | // ---------------------------------------------------------------------------- | |
980 | // now include the declaration of wxWindow class | |
981 | // ---------------------------------------------------------------------------- | |
982 | ||
1e6feb95 | 983 | // include the declaration of the platform-specific class |
2049ba38 | 984 | #if defined(__WXMSW__) |
a5b3669d VZ |
985 | #ifdef __WXUNIVERSAL__ |
986 | #define wxWindowNative wxWindowMSW | |
987 | #else // !wxUniv | |
1e6feb95 VZ |
988 | #define wxWindowMSW wxWindow |
989 | #define sm_classwxWindowMSW sm_classwxWindow | |
a5b3669d | 990 | #endif // wxUniv/!wxUniv |
f03fc89f | 991 | #include "wx/msw/window.h" |
2049ba38 | 992 | #elif defined(__WXMOTIF__) |
f03fc89f | 993 | #include "wx/motif/window.h" |
2049ba38 | 994 | #elif defined(__WXGTK__) |
a5b3669d VZ |
995 | #ifdef __WXUNIVERSAL__ |
996 | #define wxWindowNative wxWindowGTK | |
997 | #else // !wxUniv | |
1e6feb95 VZ |
998 | #define wxWindowGTK wxWindow |
999 | #define sm_classwxWindowGTK sm_classwxWindow | |
1000 | #endif // wxUniv | |
f03fc89f | 1001 | #include "wx/gtk/window.h" |
83df96d6 JS |
1002 | #elif defined(__WXX11__) |
1003 | #ifdef __WXUNIVERSAL__ | |
1004 | #define wxWindowNative wxWindowX11 | |
1005 | #else // !wxUniv | |
1006 | #define wxWindowX11 wxWindow | |
1007 | #define sm_classwxWindowX11 sm_classwxWindow | |
1008 | #endif // wxUniv | |
1009 | #include "wx/x11/window.h" | |
711c76db | 1010 | #elif defined(__WXMGL__) |
386c7058 VS |
1011 | #ifdef __WXUNIVERSAL__ |
1012 | #define wxWindowNative wxWindowMGL | |
1013 | #else // !wxUniv | |
1014 | #define wxWindowMGL wxWindow | |
1015 | #define sm_classwxWindowMGL sm_classwxWindow | |
1016 | #endif // wxUniv | |
1017 | #include "wx/mgl/window.h" | |
34138703 | 1018 | #elif defined(__WXMAC__) |
e766c8a9 SC |
1019 | #ifdef __WXUNIVERSAL__ |
1020 | #define wxWindowNative wxWindowMac | |
1021 | #else // !wxUniv | |
1022 | #define wxWindowMac wxWindow | |
1023 | #define sm_classwxWindowMac sm_classwxWindow | |
1024 | #endif // wxUniv | |
f03fc89f | 1025 | #include "wx/mac/window.h" |
1777b9bb | 1026 | #elif defined(__WXPM__) |
210a651b DW |
1027 | #ifdef __WXUNIVERSAL__ |
1028 | #define wxWindowNative wxWindowOS2 | |
1029 | #else // !wxUniv | |
1030 | #define wxWindowOS2 wxWindow | |
1031 | #define sm_classwxWindowOS2 sm_classwxWindow | |
1032 | #endif // wxUniv/!wxUniv | |
1777b9bb | 1033 | #include "wx/os2/window.h" |
c801d85f KB |
1034 | #endif |
1035 | ||
1e6feb95 VZ |
1036 | // for wxUniversal, we now derive the real wxWindow from wxWindow<platform>, |
1037 | // for the native ports we already have defined it above | |
1038 | #if defined(__WXUNIVERSAL__) | |
a5b3669d VZ |
1039 | #ifndef wxWindowNative |
1040 | #error "wxWindowNative must be defined above!" | |
1041 | #endif | |
1042 | ||
1e6feb95 VZ |
1043 | #include "wx/univ/window.h" |
1044 | #endif // wxUniv | |
1045 | ||
f03fc89f VZ |
1046 | // ---------------------------------------------------------------------------- |
1047 | // inline functions which couldn't be declared in the class body because of | |
1048 | // forward dependencies | |
1049 | // ---------------------------------------------------------------------------- | |
1050 | ||
bacd69f9 | 1051 | inline wxWindow *wxWindowBase::GetGrandParent() const |
f03fc89f VZ |
1052 | { |
1053 | return m_parent ? m_parent->GetParent() : (wxWindow *)NULL; | |
1054 | } | |
1055 | ||
1056 | // ---------------------------------------------------------------------------- | |
3723b7b1 | 1057 | // global functions |
f03fc89f VZ |
1058 | // ---------------------------------------------------------------------------- |
1059 | ||
3723b7b1 JS |
1060 | // Find the wxWindow at the current mouse position, also returning the mouse |
1061 | // position. | |
1062 | WXDLLEXPORT extern wxWindow* wxFindWindowAtPointer(wxPoint& pt); | |
1063 | ||
1064 | // Get the current mouse position. | |
1065 | WXDLLEXPORT extern wxPoint wxGetMousePosition(); | |
1066 | ||
1e6feb95 VZ |
1067 | // get the currently active window of this application or NULL |
1068 | WXDLLEXPORT extern wxWindow *wxGetActiveWindow(); | |
1069 | ||
f68586e5 | 1070 | // deprecated (doesn't start with 'wx' prefix), use wxWindow::NewControlId() |
6d56eb5c | 1071 | inline int NewControlId() { return wxWindowBase::NewControlId(); } |
f03fc89f | 1072 | |
c801d85f | 1073 | #endif |
34138703 | 1074 | // _WX_WINDOW_H_BASE_ |