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