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