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