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