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