]> git.saurik.com Git - wxWidgets.git/blame - src/common/wincmn.cpp
Move m_isShown = false; into base class constructor
[wxWidgets.git] / src / common / wincmn.cpp
CommitLineData
7ec1983b 1/////////////////////////////////////////////////////////////////////////////
f03fc89f 2// Name: common/window.cpp
7ec1983b
VZ
3// Purpose: common (to all ports) wxWindow functions
4// Author: Julian Smart, Vadim Zeitlin
5// Modified by:
6// Created: 13/07/98
7// RCS-ID: $Id$
f03fc89f 8// Copyright: (c) wxWindows team
55d99c7a 9// Licence: wxWindows licence
7ec1983b
VZ
10/////////////////////////////////////////////////////////////////////////////
11
f03fc89f
VZ
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
f701d7ab 19
14f355c2 20#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
58654ed0
VZ
21 #pragma implementation "windowbase.h"
22#endif
23
341287bf
JS
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
f701d7ab 27#ifdef __BORLANDC__
f03fc89f 28 #pragma hdrstop
f701d7ab
JS
29#endif
30
f03fc89f
VZ
31#ifndef WX_PRECOMP
32 #include "wx/string.h"
33 #include "wx/log.h"
34 #include "wx/intl.h"
35 #include "wx/frame.h"
36 #include "wx/defs.h"
37 #include "wx/window.h"
1e6feb95 38 #include "wx/control.h"
f03fc89f
VZ
39 #include "wx/checkbox.h"
40 #include "wx/radiobut.h"
106844da 41 #include "wx/statbox.h"
26bf1ce0 42 #include "wx/textctrl.h"
f03fc89f
VZ
43 #include "wx/settings.h"
44 #include "wx/dialog.h"
a02dc3e3 45 #include "wx/msgdlg.h"
a37a5a73 46 #include "wx/statusbr.h"
ed39ff57 47 #include "wx/dcclient.h"
f03fc89f
VZ
48#endif //WX_PRECOMP
49
50#if wxUSE_CONSTRAINTS
51 #include "wx/layout.h"
52#endif // wxUSE_CONSTRAINTS
53
461e93f9
JS
54#include "wx/sizer.h"
55
f03fc89f
VZ
56#if wxUSE_DRAG_AND_DROP
57 #include "wx/dnd.h"
58#endif // wxUSE_DRAG_AND_DROP
59
ed5317e5 60#if wxUSE_ACCESSIBILITY
7de59551 61 #include "wx/access.h"
ed5317e5
JS
62#endif
63
bd83cb56
VZ
64#if wxUSE_HELP
65 #include "wx/cshelp.h"
66#endif // wxUSE_HELP
67
f03fc89f
VZ
68#if wxUSE_TOOLTIPS
69 #include "wx/tooltip.h"
70#endif // wxUSE_TOOLTIPS
71
789295bf
VZ
72#if wxUSE_CARET
73 #include "wx/caret.h"
74#endif // wxUSE_CARET
75
f03fc89f
VZ
76// ----------------------------------------------------------------------------
77// static data
78// ----------------------------------------------------------------------------
79
edd802c6
DW
80#if defined(__WXPM__)
81int wxWindowBase::ms_lastControlId = 2000;
82#else
42e69d6b 83int wxWindowBase::ms_lastControlId = -200;
edd802c6 84#endif
f03fc89f
VZ
85
86IMPLEMENT_ABSTRACT_CLASS(wxWindowBase, wxEvtHandler)
87
88// ----------------------------------------------------------------------------
89// event table
90// ----------------------------------------------------------------------------
91
92BEGIN_EVENT_TABLE(wxWindowBase, wxEvtHandler)
93 EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged)
94 EVT_INIT_DIALOG(wxWindowBase::OnInitDialog)
a02dc3e3 95 EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick)
bd83cb56
VZ
96
97#if wxUSE_HELP
e11f4636 98 EVT_HELP(wxID_ANY, wxWindowBase::OnHelp)
bd83cb56
VZ
99#endif // wxUSE_HELP
100
f03fc89f
VZ
101END_EVENT_TABLE()
102
103// ============================================================================
104// implementation of the common functionality of the wxWindow class
105// ============================================================================
106
107// ----------------------------------------------------------------------------
108// initialization
109// ----------------------------------------------------------------------------
110
111// the default initialization
72795335 112wxWindowBase::wxWindowBase()
f03fc89f
VZ
113{
114 // no window yet, no parent nor children
f03fc89f 115 m_parent = (wxWindow *)NULL;
e11f4636 116 m_windowId = wxID_ANY;
f03fc89f
VZ
117
118 // no constraints on the minimal window size
119 m_minWidth =
120 m_minHeight =
121 m_maxWidth =
122 m_maxHeight = -1;
123
eefe6d4b
VZ
124 // window are created enabled and visible by default
125 m_isShown =
e11f4636 126 m_isEnabled = true;
f03fc89f 127
f03fc89f
VZ
128 // the default event handler is just this window
129 m_eventHandler = this;
130
88ac883a 131#if wxUSE_VALIDATORS
f03fc89f
VZ
132 // no validator
133 m_windowValidator = (wxValidator *) NULL;
88ac883a 134#endif // wxUSE_VALIDATORS
f03fc89f
VZ
135
136 // use the system default colours
a756f210
VS
137 m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
138 m_foregroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
f6e4e9ea 139
8bf30fe9
VZ
140 // don't set the font here for wxMSW as we don't call WM_SETFONT here and
141 // so the font is *not* really set - but calls to SetFont() later won't do
142 // anything because m_font appears to be already set!
143#ifndef __WXMSW__
a756f210 144 m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
8bf30fe9 145#endif // __WXMSW__
807a903e 146
08df3e44
VZ
147 // the colours/fonts are default for now
148 m_hasBgCol =
149 m_hasFgCol =
e11f4636
DS
150 m_hasFont = false;
151
152 m_isBeingDeleted = false;
08df3e44 153
f03fc89f 154 // no style bits
d80cd92a 155 m_exStyle =
f03fc89f
VZ
156 m_windowStyle = 0;
157
f03fc89f
VZ
158#if wxUSE_CONSTRAINTS
159 // no constraints whatsoever
160 m_constraints = (wxLayoutConstraints *) NULL;
161 m_constraintsInvolvedIn = (wxWindowList *) NULL;
461e93f9
JS
162#endif // wxUSE_CONSTRAINTS
163
f03fc89f 164 m_windowSizer = (wxSizer *) NULL;
be90c029 165 m_containingSizer = (wxSizer *) NULL;
e11f4636 166 m_autoLayout = false;
f03fc89f
VZ
167
168#if wxUSE_DRAG_AND_DROP
169 m_dropTarget = (wxDropTarget *)NULL;
170#endif // wxUSE_DRAG_AND_DROP
171
172#if wxUSE_TOOLTIPS
173 m_tooltip = (wxToolTip *)NULL;
174#endif // wxUSE_TOOLTIPS
789295bf
VZ
175
176#if wxUSE_CARET
177 m_caret = (wxCaret *)NULL;
178#endif // wxUSE_CARET
a2d93e73 179
574c939e 180#if wxUSE_PALETTE
e11f4636 181 m_hasCustomPalette = false;
574c939e
KB
182#endif // wxUSE_PALETTE
183
ed5317e5
JS
184#if wxUSE_ACCESSIBILITY
185 m_accessible = NULL;
186#endif
187
566d84a7 188 m_virtualSize = wxDefaultSize;
69d90995 189
1e2a653b
VZ
190 m_minVirtualWidth =
191 m_minVirtualHeight =
192 m_maxVirtualWidth =
566d84a7
RL
193 m_maxVirtualHeight = -1;
194
69d90995
SC
195 m_windowVariant = wxWINDOW_VARIANT_DEFAULT ;
196
a2d93e73 197 // Whether we're using the current theme for this window (wxGTK only for now)
e11f4636 198 m_themeEnabled = false;
f03fc89f
VZ
199}
200
201// common part of window creation process
202bool wxWindowBase::CreateBase(wxWindowBase *parent,
203 wxWindowID id,
74e3313b
VZ
204 const wxPoint& WXUNUSED(pos),
205 const wxSize& WXUNUSED(size),
f03fc89f 206 long style,
ac8d0c11 207 const wxValidator& wxVALIDATOR_PARAM(validator),
f03fc89f
VZ
208 const wxString& name)
209{
106844da
VZ
210#if wxUSE_STATBOX
211 // wxGTK doesn't allow to create controls with static box as the parent so
212 // this will result in a crash when the program is ported to wxGTK so warn
213 // the user about it
214
215 // if you get this assert, the correct solution is to create the controls
216 // as siblings of the static box
217 wxASSERT_MSG( !parent || !wxDynamicCast(parent, wxStaticBox),
218 _T("wxStaticBox can't be used as a window parent!") );
219#endif // wxUSE_STATBOX
220
925f154d
VZ
221 // ids are limited to 16 bits under MSW so if you care about portability,
222 // it's not a good idea to use ids out of this range (and negative ids are
223 // reserved for wxWindows own usage)
224 wxASSERT_MSG( id == wxID_ANY || (id >= 0 && id < 32767),
225 _T("invalid id value") );
226
f03fc89f 227 // generate a new id if the user doesn't care about it
925f154d 228 m_windowId = id == wxID_ANY ? NewControlId() : id;
f03fc89f
VZ
229
230 SetName(name);
231 SetWindowStyleFlag(style);
232 SetParent(parent);
674ac8b9
VZ
233
234#if wxUSE_VALIDATORS
8d99be5f 235 SetValidator(validator);
674ac8b9 236#endif // wxUSE_VALIDATORS
f03fc89f 237
8ae6ce07
VZ
238 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
239 // have it too - like this it's possible to set it only in the top level
240 // dialog/frame and all children will inherit it by defult
241 if ( parent && (parent->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) )
242 {
9cb98d89 243 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY);
8ae6ce07
VZ
244 }
245
e11f4636 246 return true;
f03fc89f
VZ
247}
248
249// ----------------------------------------------------------------------------
250// destruction
251// ----------------------------------------------------------------------------
252
253// common clean up
254wxWindowBase::~wxWindowBase()
255{
349d1942
VS
256 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
257
f03fc89f
VZ
258 // FIXME if these 2 cases result from programming errors in the user code
259 // we should probably assert here instead of silently fixing them
260
261 // Just in case the window has been Closed, but we're then deleting
262 // immediately: don't leave dangling pointers.
263 wxPendingDelete.DeleteObject(this);
264
265 // Just in case we've loaded a top-level window via LoadNativeDialog but
266 // we weren't a dialog class
222ed1d6 267 wxTopLevelWindows.DeleteObject((wxWindow*)this);
a23fd0e1 268
223d09f6 269 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
f03fc89f 270
8e35ab96
VZ
271 // reset the dangling pointer our parent window may keep to us
272 if ( m_parent )
273 {
274 if ( m_parent->GetDefaultItem() == this )
275 {
276 m_parent->SetDefaultItem(NULL);
277 }
278
279 m_parent->RemoveChild(this);
280 }
281
789295bf 282#if wxUSE_CARET
a2b436fb 283 delete m_caret;
789295bf
VZ
284#endif // wxUSE_CARET
285
88ac883a 286#if wxUSE_VALIDATORS
a2b436fb 287 delete m_windowValidator;
88ac883a 288#endif // wxUSE_VALIDATORS
f03fc89f 289
f03fc89f
VZ
290#if wxUSE_CONSTRAINTS
291 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
292 // at deleted windows as they delete themselves.
293 DeleteRelatedConstraints();
294
295 if ( m_constraints )
296 {
297 // This removes any dangling pointers to this window in other windows'
298 // constraintsInvolvedIn lists.
299 UnsetConstraints(m_constraints);
300 delete m_constraints;
301 m_constraints = NULL;
302 }
461e93f9
JS
303#endif // wxUSE_CONSTRAINTS
304
be90c029 305 if ( m_containingSizer )
12a3f227 306 m_containingSizer->Detach( (wxWindow*)this );
be90c029 307
a2b436fb 308 delete m_windowSizer;
f03fc89f 309
f03fc89f 310#if wxUSE_DRAG_AND_DROP
a2b436fb 311 delete m_dropTarget;
f03fc89f
VZ
312#endif // wxUSE_DRAG_AND_DROP
313
314#if wxUSE_TOOLTIPS
a2b436fb 315 delete m_tooltip;
f03fc89f 316#endif // wxUSE_TOOLTIPS
b0ee47ff 317
ed5317e5 318#if wxUSE_ACCESSIBILITY
a2b436fb 319 delete m_accessible;
ed5317e5 320#endif
f03fc89f
VZ
321}
322
323bool wxWindowBase::Destroy()
324{
325 delete this;
326
e11f4636 327 return true;
f03fc89f
VZ
328}
329
330bool wxWindowBase::Close(bool force)
331{
332 wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
333 event.SetEventObject(this);
f03fc89f
VZ
334 event.SetCanVeto(!force);
335
e11f4636 336 // return false if window wasn't closed because the application vetoed the
f03fc89f
VZ
337 // close event
338 return GetEventHandler()->ProcessEvent(event) && !event.GetVeto();
339}
340
341bool wxWindowBase::DestroyChildren()
342{
222ed1d6 343 wxWindowList::compatibility_iterator node;
a23fd0e1 344 for ( ;; )
f03fc89f 345 {
a23fd0e1
VZ
346 // we iterate until the list becomes empty
347 node = GetChildren().GetFirst();
348 if ( !node )
349 break;
350
f03fc89f 351 wxWindow *child = node->GetData();
a23fd0e1 352
f303564d
VZ
353 // note that we really want to call delete and not ->Destroy() here
354 // because we want to delete the child immediately, before we are
355 // deleted, and delayed deletion would result in problems as our (top
356 // level) child could outlive its parent
357 delete child;
a23fd0e1
VZ
358
359 wxASSERT_MSG( !GetChildren().Find(child),
223d09f6 360 wxT("child didn't remove itself using RemoveChild()") );
f03fc89f
VZ
361 }
362
e11f4636 363 return true;
f03fc89f
VZ
364}
365
366// ----------------------------------------------------------------------------
f68586e5 367// size/position related methods
f03fc89f
VZ
368// ----------------------------------------------------------------------------
369
370// centre the window with respect to its parent in either (or both) directions
371void wxWindowBase::Centre(int direction)
372{
f6bcfd97
BP
373 // the position/size of the parent window or of the entire screen
374 wxPoint posParent;
f03fc89f
VZ
375 int widthParent, heightParent;
376
f6bcfd97
BP
377 wxWindow *parent = NULL;
378
379 if ( !(direction & wxCENTRE_ON_SCREEN) )
f03fc89f 380 {
f6bcfd97
BP
381 // find the parent to centre this window on: it should be the
382 // immediate parent for the controls but the top level parent for the
383 // top level windows (like dialogs)
384 parent = GetParent();
385 if ( IsTopLevel() )
386 {
387 while ( parent && !parent->IsTopLevel() )
388 {
389 parent = parent->GetParent();
390 }
391 }
392
e28b0102
VZ
393 // there is no wxTopLevelWindow under wxMotif yet
394#ifndef __WXMOTIF__
085ad686
VZ
395 // we shouldn't center the dialog on the iconized window: under
396 // Windows, for example, this places it completely off the screen
397 if ( parent )
398 {
399 wxTopLevelWindow *winTop = wxDynamicCast(parent, wxTopLevelWindow);
400 if ( winTop && winTop->IsIconized() )
401 {
402 parent = NULL;
403 }
404 }
e28b0102 405#endif // __WXMOTIF__
085ad686 406
f6bcfd97
BP
407 // did we find the parent?
408 if ( !parent )
409 {
410 // no other choice
411 direction |= wxCENTRE_ON_SCREEN;
412 }
f03fc89f 413 }
10fcf31a
VZ
414
415 if ( direction & wxCENTRE_ON_SCREEN )
f03fc89f
VZ
416 {
417 // centre with respect to the whole screen
418 wxDisplaySize(&widthParent, &heightParent);
419 }
10fcf31a
VZ
420 else
421 {
f6bcfd97
BP
422 if ( IsTopLevel() )
423 {
424 // centre on the parent
425 parent->GetSize(&widthParent, &heightParent);
426
427 // adjust to the parents position
428 posParent = parent->GetPosition();
429 }
430 else
431 {
432 // centre inside the parents client rectangle
433 parent->GetClientSize(&widthParent, &heightParent);
434 }
10fcf31a 435 }
f03fc89f
VZ
436
437 int width, height;
438 GetSize(&width, &height);
439
c39eda94
VZ
440 int xNew = -1,
441 yNew = -1;
f03fc89f
VZ
442
443 if ( direction & wxHORIZONTAL )
c39eda94 444 xNew = (widthParent - width)/2;
f03fc89f
VZ
445
446 if ( direction & wxVERTICAL )
c39eda94 447 yNew = (heightParent - height)/2;
f03fc89f 448
f6bcfd97
BP
449 xNew += posParent.x;
450 yNew += posParent.y;
7631a292 451
ef397583
GT
452 // Base size of the visible dimensions of the display
453 // to take into account the taskbar
454 wxRect rect = wxGetClientDisplayRect();
455 wxSize size (rect.width,rect.height);
456
ede7020a
VS
457 // NB: in wxMSW, negative position may not neccessary mean "out of screen",
458 // but it may mean that the window is placed on other than the main
459 // display. Therefore we only make sure centered window is on the main display
460 // if the parent is at least partially present here.
461 if (posParent.x + widthParent >= 0) // if parent is (partially) on the main display
ef397583
GT
462 {
463 if (xNew < 0)
464 xNew = 0;
465 else if (xNew+width > size.x)
466 xNew = size.x-width-1;
467 }
ede7020a 468 if (posParent.y + heightParent >= 0) // if parent is (partially) on the main display
ef397583
GT
469 {
470 if (yNew+height > size.y)
471 yNew = size.y-height-1;
472
473 // Make certain that the title bar is initially visible
474 // always, even if this would push the bottom of the
475 // dialog of the visible area of the display
476 if (yNew < 0)
477 yNew = 0;
478 }
479
0fff366e
VZ
480 // move the window to this position (keeping the old size but using
481 // SetSize() and not Move() to allow xNew and/or yNew to be -1)
db89aa76 482 SetSize(xNew, yNew, width, height, wxSIZE_ALLOW_MINUS_ONE);
7631a292
RD
483}
484
f03fc89f
VZ
485// fits the window around the children
486void wxWindowBase::Fit()
487{
f68586e5
VZ
488 if ( GetChildren().GetCount() > 0 )
489 {
ec5bb70d 490 SetClientSize(DoGetBestSize());
f68586e5
VZ
491 }
492 //else: do nothing if we have no children
493}
f03fc89f 494
2b5f62a0
VZ
495// fits virtual size (ie. scrolled area etc.) around children
496void wxWindowBase::FitInside()
497{
498 if ( GetChildren().GetCount() > 0 )
499 {
500 SetVirtualSize( GetBestVirtualSize() );
501 }
502}
503
f68586e5
VZ
504// return the size best suited for the current window
505wxSize wxWindowBase::DoGetBestSize() const
506{
ec5bb70d
VZ
507 if ( m_windowSizer )
508 {
509 return m_windowSizer->GetMinSize();
510 }
511#if wxUSE_CONSTRAINTS
512 else if ( m_constraints )
513 {
514 wxConstCast(this, wxWindowBase)->SatisfyConstraints();
515
516 // our minimal acceptable size is such that all our windows fit inside
517 int maxX = 0,
518 maxY = 0;
519
222ed1d6 520 for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
ec5bb70d
VZ
521 node;
522 node = node->GetNext() )
523 {
524 wxLayoutConstraints *c = node->GetData()->GetConstraints();
525 if ( !c )
526 {
527 // it's not normal that we have an unconstrained child, but
528 // what can we do about it?
529 continue;
530 }
531
532 int x = c->right.GetValue(),
533 y = c->bottom.GetValue();
534
535 if ( x > maxX )
536 maxX = x;
537
538 if ( y > maxY )
539 maxY = y;
540
541 // TODO: we must calculate the overlaps somehow, otherwise we
542 // will never return a size bigger than the current one :-(
543 }
544
545 return wxSize(maxX, maxY);
546 }
547#endif // wxUSE_CONSTRAINTS
548 else if ( GetChildren().GetCount() > 0 )
f03fc89f 549 {
f68586e5
VZ
550 // our minimal acceptable size is such that all our windows fit inside
551 int maxX = 0,
552 maxY = 0;
553
222ed1d6 554 for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
f68586e5
VZ
555 node;
556 node = node->GetNext() )
42e69d6b 557 {
f68586e5 558 wxWindow *win = node->GetData();
1e6feb95
VZ
559 if ( win->IsTopLevel()
560#if wxUSE_STATUSBAR
561 || wxDynamicCast(win, wxStatusBar)
562#endif // wxUSE_STATUSBAR
563 )
f68586e5
VZ
564 {
565 // dialogs and frames lie in different top level windows -
7d9fd004
VZ
566 // don't deal with them here; as for the status bars, they
567 // don't lie in the client area at all
f68586e5
VZ
568 continue;
569 }
570
571 int wx, wy, ww, wh;
572 win->GetPosition(&wx, &wy);
3f5513f5
VZ
573
574 // if the window hadn't been positioned yet, assume that it is in
575 // the origin
576 if ( wx == -1 )
577 wx = 0;
578 if ( wy == -1 )
579 wy = 0;
580
f68586e5
VZ
581 win->GetSize(&ww, &wh);
582 if ( wx + ww > maxX )
583 maxX = wx + ww;
584 if ( wy + wh > maxY )
585 maxY = wy + wh;
42e69d6b
VZ
586 }
587
ec5bb70d
VZ
588 // for compatibility with the old versions and because it really looks
589 // slightly more pretty like this, add a pad
590 maxX += 7;
591 maxY += 14;
592
ba81034d 593 return wxSize(maxX, maxY);
f68586e5
VZ
594 }
595 else
596 {
597 // for a generic window there is no natural best size - just use the
598 // current one
599 return GetSize();
f03fc89f 600 }
f03fc89f
VZ
601}
602
1e6feb95
VZ
603// by default the origin is not shifted
604wxPoint wxWindowBase::GetClientAreaOrigin() const
605{
606 return wxPoint(0, 0);
607}
608
f03fc89f 609// set the min/max size of the window
f03fc89f
VZ
610void wxWindowBase::SetSizeHints(int minW, int minH,
611 int maxW, int maxH,
612 int WXUNUSED(incW), int WXUNUSED(incH))
613{
e587e144
VZ
614 // setting min width greater than max width leads to infinite loops under
615 // X11 and generally doesn't make any sense, so don't allow it
616 wxCHECK_RET( (minW == -1 || maxW == -1 || minW <= maxW) &&
77b0d411 617 (minH == -1 || maxH == -1 || minH <= maxH),
e587e144
VZ
618 _T("min width/height must be less than max width/height!") );
619
f03fc89f
VZ
620 m_minWidth = minW;
621 m_maxWidth = maxW;
622 m_minHeight = minH;
623 m_maxHeight = maxH;
624}
625
69d90995
SC
626void wxWindowBase::SetWindowVariant( wxWindowVariant variant )
627{
628 if ( m_windowVariant == variant )
629 return ;
630
631 m_windowVariant = variant ;
632
633 DoSetWindowVariant( variant ) ;
634 return ;
635}
636
637void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant )
638{
639 wxFont font = wxSystemSettings::GetSystemFont( wxSYS_DEFAULT_GUI_FONT ) ;
640 int size = font.GetPointSize() ;
641 switch ( variant )
642 {
643 case wxWINDOW_VARIANT_NORMAL :
644 break ;
645 case wxWINDOW_VARIANT_SMALL :
646 font.SetPointSize( size * 3 / 4 ) ;
647 break ;
648 case wxWINDOW_VARIANT_MINI :
649 font.SetPointSize( size * 2 / 3 ) ;
650 break ;
651 case wxWINDOW_VARIANT_LARGE :
652 font.SetPointSize( size * 5 / 4 ) ;
653 break ;
654 case wxWINDOW_VARIANT_DEFAULT :
655 break ;
656 default:
657 wxFAIL_MSG(_T("unexpected window variant"));
658 break ;
659 }
660 SetFont( font ) ;
661}
662
566d84a7
RL
663void wxWindowBase::SetVirtualSizeHints( int minW, int minH,
664 int maxW, int maxH )
665{
666 m_minVirtualWidth = minW;
667 m_maxVirtualWidth = maxW;
668 m_minVirtualHeight = minH;
669 m_maxVirtualHeight = maxH;
566d84a7
RL
670}
671
672void wxWindowBase::DoSetVirtualSize( int x, int y )
673{
1e2a653b
VZ
674 if ( m_minVirtualWidth != -1 && m_minVirtualWidth > x )
675 x = m_minVirtualWidth;
676 if ( m_maxVirtualWidth != -1 && m_maxVirtualWidth < x )
677 x = m_maxVirtualWidth;
678 if ( m_minVirtualHeight != -1 && m_minVirtualHeight > y )
679 y = m_minVirtualHeight;
680 if ( m_maxVirtualHeight != -1 && m_maxVirtualHeight < y )
681 y = m_maxVirtualHeight;
682
683 m_virtualSize = wxSize(x, y);
566d84a7
RL
684}
685
686wxSize wxWindowBase::DoGetVirtualSize() const
687{
688 wxSize s( GetClientSize() );
689
150c8d89
RL
690 return wxSize( wxMax( m_virtualSize.GetWidth(), s.GetWidth() ),
691 wxMax( m_virtualSize.GetHeight(), s.GetHeight() ) );
566d84a7
RL
692}
693
f03fc89f
VZ
694// ----------------------------------------------------------------------------
695// show/hide/enable/disable the window
696// ----------------------------------------------------------------------------
697
698bool wxWindowBase::Show(bool show)
699{
700 if ( show != m_isShown )
701 {
702 m_isShown = show;
703
e11f4636 704 return true;
f03fc89f
VZ
705 }
706 else
707 {
e11f4636 708 return false;
f03fc89f
VZ
709 }
710}
711
712bool wxWindowBase::Enable(bool enable)
713{
714 if ( enable != m_isEnabled )
715 {
716 m_isEnabled = enable;
717
e11f4636 718 return true;
f03fc89f
VZ
719 }
720 else
721 {
e11f4636 722 return false;
f03fc89f
VZ
723 }
724}
34636400
VZ
725// ----------------------------------------------------------------------------
726// RTTI
727// ----------------------------------------------------------------------------
728
729bool wxWindowBase::IsTopLevel() const
730{
e11f4636 731 return false;
34636400 732}
f03fc89f
VZ
733
734// ----------------------------------------------------------------------------
735// reparenting the window
736// ----------------------------------------------------------------------------
737
738void wxWindowBase::AddChild(wxWindowBase *child)
739{
223d09f6 740 wxCHECK_RET( child, wxT("can't add a NULL child") );
f03fc89f 741
f6bcfd97
BP
742 // this should never happen and it will lead to a crash later if it does
743 // because RemoveChild() will remove only one node from the children list
744 // and the other(s) one(s) will be left with dangling pointers in them
222ed1d6 745 wxASSERT_MSG( !GetChildren().Find((wxWindow*)child), _T("AddChild() called twice") );
f6bcfd97 746
222ed1d6 747 GetChildren().Append((wxWindow*)child);
f03fc89f
VZ
748 child->SetParent(this);
749}
750
751void wxWindowBase::RemoveChild(wxWindowBase *child)
752{
223d09f6 753 wxCHECK_RET( child, wxT("can't remove a NULL child") );
f03fc89f 754
222ed1d6
MB
755 GetChildren().DeleteObject((wxWindow *)child);
756 child->SetParent(NULL);
f03fc89f 757}
439b3bf1 758
f03fc89f
VZ
759bool wxWindowBase::Reparent(wxWindowBase *newParent)
760{
761 wxWindow *oldParent = GetParent();
762 if ( newParent == oldParent )
763 {
764 // nothing done
e11f4636 765 return false;
f03fc89f
VZ
766 }
767
768 // unlink this window from the existing parent.
769 if ( oldParent )
770 {
771 oldParent->RemoveChild(this);
772 }
773 else
774 {
222ed1d6 775 wxTopLevelWindows.DeleteObject((wxWindow *)this);
f03fc89f
VZ
776 }
777
778 // add it to the new one
779 if ( newParent )
780 {
781 newParent->AddChild(this);
782 }
783 else
784 {
222ed1d6 785 wxTopLevelWindows.Append((wxWindow *)this);
f03fc89f
VZ
786 }
787
e11f4636 788 return true;
f03fc89f
VZ
789}
790
791// ----------------------------------------------------------------------------
792// event handler stuff
793// ----------------------------------------------------------------------------
794
795void wxWindowBase::PushEventHandler(wxEvtHandler *handler)
796{
3a074ba8
VZ
797 wxEvtHandler *handlerOld = GetEventHandler();
798
799 handler->SetNextHandler(handlerOld);
800
801 if ( handlerOld )
802 GetEventHandler()->SetPreviousHandler(handler);
803
f03fc89f
VZ
804 SetEventHandler(handler);
805}
806
807wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler)
808{
809 wxEvtHandler *handlerA = GetEventHandler();
810 if ( handlerA )
811 {
812 wxEvtHandler *handlerB = handlerA->GetNextHandler();
813 handlerA->SetNextHandler((wxEvtHandler *)NULL);
3a074ba8
VZ
814
815 if ( handlerB )
816 handlerB->SetPreviousHandler((wxEvtHandler *)NULL);
f03fc89f 817 SetEventHandler(handlerB);
3a074ba8 818
f03fc89f
VZ
819 if ( deleteHandler )
820 {
821 delete handlerA;
822 handlerA = (wxEvtHandler *)NULL;
823 }
824 }
825
826 return handlerA;
827}
828
2e36d5cf
VZ
829bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handler)
830{
e11f4636 831 wxCHECK_MSG( handler, false, _T("RemoveEventHandler(NULL) called") );
2e36d5cf
VZ
832
833 wxEvtHandler *handlerPrev = NULL,
834 *handlerCur = GetEventHandler();
835 while ( handlerCur )
836 {
837 wxEvtHandler *handlerNext = handlerCur->GetNextHandler();
838
839 if ( handlerCur == handler )
840 {
841 if ( handlerPrev )
842 {
843 handlerPrev->SetNextHandler(handlerNext);
844 }
845 else
846 {
847 SetEventHandler(handlerNext);
848 }
849
7a9c8d74
JS
850 if ( handlerNext )
851 {
852 handlerNext->SetPreviousHandler ( handlerPrev );
853 }
489bbac9 854
2e36d5cf 855 handler->SetNextHandler(NULL);
489bbac9 856 handler->SetPreviousHandler(NULL);
2e36d5cf 857
e11f4636 858 return true;
2e36d5cf
VZ
859 }
860
861 handlerPrev = handlerCur;
862 handlerCur = handlerNext;
863 }
864
865 wxFAIL_MSG( _T("where has the event handler gone?") );
866
e11f4636 867 return false;
2e36d5cf
VZ
868}
869
f03fc89f
VZ
870// ----------------------------------------------------------------------------
871// cursors, fonts &c
872// ----------------------------------------------------------------------------
873
874bool wxWindowBase::SetBackgroundColour( const wxColour &colour )
875{
876 if ( !colour.Ok() || (colour == m_backgroundColour) )
e11f4636 877 return false;
f03fc89f
VZ
878
879 m_backgroundColour = colour;
880
e11f4636 881 m_hasBgCol = true;
23895080 882
e11f4636 883 return true;
f03fc89f
VZ
884}
885
886bool wxWindowBase::SetForegroundColour( const wxColour &colour )
887{
888 if ( !colour.Ok() || (colour == m_foregroundColour) )
e11f4636 889 return false;
f03fc89f
VZ
890
891 m_foregroundColour = colour;
892
e11f4636 893 m_hasFgCol = true;
23895080 894
e11f4636 895 return true;
f03fc89f
VZ
896}
897
898bool wxWindowBase::SetCursor(const wxCursor& cursor)
899{
8a9c2246
VZ
900 // setting an invalid cursor is ok, it means that we don't have any special
901 // cursor
13588544 902 if ( m_cursor == cursor )
f03fc89f
VZ
903 {
904 // no change
e11f4636 905 return false;
f03fc89f
VZ
906 }
907
8a9c2246 908 m_cursor = cursor;
f03fc89f 909
e11f4636 910 return true;
f03fc89f
VZ
911}
912
913bool wxWindowBase::SetFont(const wxFont& font)
914{
915 // don't try to set invalid font, always fall back to the default
916 const wxFont& fontOk = font.Ok() ? font : *wxSWISS_FONT;
917
8bf30fe9 918 if ( fontOk == m_font )
f03fc89f
VZ
919 {
920 // no change
e11f4636 921 return false;
f03fc89f
VZ
922 }
923
924 m_font = fontOk;
925
e11f4636 926 m_hasFont = true;
23895080 927
e11f4636 928 return true;
f03fc89f
VZ
929}
930
b95edd47
VZ
931#if wxUSE_PALETTE
932
933void wxWindowBase::SetPalette(const wxPalette& pal)
934{
e11f4636 935 m_hasCustomPalette = true;
b95edd47
VZ
936 m_palette = pal;
937
938 // VZ: can anyone explain me what do we do here?
939 wxWindowDC d((wxWindow *) this);
940 d.SetPalette(pal);
941}
942
943wxWindow *wxWindowBase::GetAncestorWithCustomPalette() const
944{
945 wxWindow *win = (wxWindow *)this;
946 while ( win && !win->HasCustomPalette() )
947 {
948 win = win->GetParent();
949 }
950
951 return win;
952}
953
954#endif // wxUSE_PALETTE
955
789295bf
VZ
956#if wxUSE_CARET
957void wxWindowBase::SetCaret(wxCaret *caret)
958{
959 if ( m_caret )
960 {
961 delete m_caret;
962 }
963
964 m_caret = caret;
965
966 if ( m_caret )
967 {
968 wxASSERT_MSG( m_caret->GetWindow() == this,
223d09f6 969 wxT("caret should be created associated to this window") );
789295bf
VZ
970 }
971}
972#endif // wxUSE_CARET
973
88ac883a 974#if wxUSE_VALIDATORS
f03fc89f
VZ
975// ----------------------------------------------------------------------------
976// validators
977// ----------------------------------------------------------------------------
978
979void wxWindowBase::SetValidator(const wxValidator& validator)
980{
981 if ( m_windowValidator )
982 delete m_windowValidator;
983
984 m_windowValidator = (wxValidator *)validator.Clone();
985
986 if ( m_windowValidator )
987 m_windowValidator->SetWindow(this) ;
988}
88ac883a 989#endif // wxUSE_VALIDATORS
f03fc89f
VZ
990
991// ----------------------------------------------------------------------------
1e6feb95 992// update region stuff
f03fc89f
VZ
993// ----------------------------------------------------------------------------
994
1e6feb95
VZ
995wxRect wxWindowBase::GetUpdateClientRect() const
996{
997 wxRegion rgnUpdate = GetUpdateRegion();
998 rgnUpdate.Intersect(GetClientRect());
999 wxRect rectUpdate = rgnUpdate.GetBox();
1000 wxPoint ptOrigin = GetClientAreaOrigin();
1001 rectUpdate.x -= ptOrigin.x;
1002 rectUpdate.y -= ptOrigin.y;
1003
1004 return rectUpdate;
1005}
1006
f03fc89f
VZ
1007bool wxWindowBase::IsExposed(int x, int y) const
1008{
1009 return m_updateRegion.Contains(x, y) != wxOutRegion;
1010}
1011
1012bool wxWindowBase::IsExposed(int x, int y, int w, int h) const
1013{
1014 return m_updateRegion.Contains(x, y, w, h) != wxOutRegion;
1015}
1016
5da0803c
VZ
1017void wxWindowBase::ClearBackground()
1018{
1019 // wxGTK uses its own version, no need to add never used code
1020#ifndef __WXGTK__
1021 wxClientDC dc((wxWindow *)this);
1022 wxBrush brush(GetBackgroundColour(), wxSOLID);
1023 dc.SetBackground(brush);
1024 dc.Clear();
1025#endif // __WXGTK__
1026}
1027
f03fc89f 1028// ----------------------------------------------------------------------------
146ba0fe 1029// find child window by id or name
f03fc89f
VZ
1030// ----------------------------------------------------------------------------
1031
1032wxWindow *wxWindowBase::FindWindow( long id )
1033{
1034 if ( id == m_windowId )
1035 return (wxWindow *)this;
1036
1037 wxWindowBase *res = (wxWindow *)NULL;
222ed1d6 1038 wxWindowList::compatibility_iterator node;
f03fc89f
VZ
1039 for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() )
1040 {
1041 wxWindowBase *child = node->GetData();
1042 res = child->FindWindow( id );
1043 }
1044
1045 return (wxWindow *)res;
1046}
1047
1048wxWindow *wxWindowBase::FindWindow( const wxString& name )
1049{
1050 if ( name == m_windowName )
1051 return (wxWindow *)this;
1052
1053 wxWindowBase *res = (wxWindow *)NULL;
222ed1d6 1054 wxWindowList::compatibility_iterator node;
f03fc89f
VZ
1055 for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() )
1056 {
1057 wxWindow *child = node->GetData();
1058 res = child->FindWindow(name);
1059 }
1060
1061 return (wxWindow *)res;
1062}
1063
146ba0fe
VZ
1064
1065// find any window by id or name or label: If parent is non-NULL, look through
1066// children for a label or title matching the specified string. If NULL, look
1067// through all top-level windows.
1068//
1069// to avoid duplicating code we reuse the same helper function but with
1070// different comparators
1071
1072typedef bool (*wxFindWindowCmp)(const wxWindow *win,
1073 const wxString& label, long id);
1074
1075static
1076bool wxFindWindowCmpLabels(const wxWindow *win, const wxString& label,
1077 long WXUNUSED(id))
1078{
1079 return win->GetLabel() == label;
1080}
1081
1082static
1083bool wxFindWindowCmpNames(const wxWindow *win, const wxString& label,
1084 long WXUNUSED(id))
1085{
1086 return win->GetName() == label;
1087}
1088
1089static
1090bool wxFindWindowCmpIds(const wxWindow *win, const wxString& WXUNUSED(label),
1091 long id)
1092{
1093 return win->GetId() == id;
1094}
1095
1096// recursive helper for the FindWindowByXXX() functions
1097static
1098wxWindow *wxFindWindowRecursively(const wxWindow *parent,
1099 const wxString& label,
1100 long id,
1101 wxFindWindowCmp cmp)
1102{
1103 if ( parent )
1104 {
1105 // see if this is the one we're looking for
1106 if ( (*cmp)(parent, label, id) )
1107 return (wxWindow *)parent;
1108
1109 // It wasn't, so check all its children
222ed1d6 1110 for ( wxWindowList::compatibility_iterator node = parent->GetChildren().GetFirst();
146ba0fe
VZ
1111 node;
1112 node = node->GetNext() )
1113 {
1114 // recursively check each child
1115 wxWindow *win = (wxWindow *)node->GetData();
1116 wxWindow *retwin = wxFindWindowRecursively(win, label, id, cmp);
1117 if (retwin)
1118 return retwin;
1119 }
1120 }
1121
1122 // Not found
1123 return NULL;
1124}
1125
1126// helper for FindWindowByXXX()
1127static
1128wxWindow *wxFindWindowHelper(const wxWindow *parent,
1129 const wxString& label,
1130 long id,
1131 wxFindWindowCmp cmp)
1132{
1133 if ( parent )
1134 {
1135 // just check parent and all its children
1136 return wxFindWindowRecursively(parent, label, id, cmp);
1137 }
1138
1139 // start at very top of wx's windows
222ed1d6 1140 for ( wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
146ba0fe
VZ
1141 node;
1142 node = node->GetNext() )
1143 {
1144 // recursively check each window & its children
1145 wxWindow *win = node->GetData();
1146 wxWindow *retwin = wxFindWindowRecursively(win, label, id, cmp);
1147 if (retwin)
1148 return retwin;
1149 }
1150
1151 return NULL;
1152}
1153
1154/* static */
1155wxWindow *
1156wxWindowBase::FindWindowByLabel(const wxString& title, const wxWindow *parent)
1157{
1158 return wxFindWindowHelper(parent, title, 0, wxFindWindowCmpLabels);
1159}
1160
1161/* static */
1162wxWindow *
1163wxWindowBase::FindWindowByName(const wxString& title, const wxWindow *parent)
1164{
1165 wxWindow *win = wxFindWindowHelper(parent, title, 0, wxFindWindowCmpNames);
1166
1167 if ( !win )
1168 {
1169 // fall back to the label
1170 win = FindWindowByLabel(title, parent);
1171 }
1172
1173 return win;
1174}
1175
1176/* static */
1177wxWindow *
1178wxWindowBase::FindWindowById( long id, const wxWindow* parent )
1179{
1180 return wxFindWindowHelper(parent, _T(""), id, wxFindWindowCmpIds);
1181}
1182
f03fc89f
VZ
1183// ----------------------------------------------------------------------------
1184// dialog oriented functions
1185// ----------------------------------------------------------------------------
1186
34636400 1187void wxWindowBase::MakeModal(bool modal)
f03fc89f 1188{
34636400
VZ
1189 // Disable all other windows
1190 if ( IsTopLevel() )
1191 {
222ed1d6 1192 wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
34636400
VZ
1193 while (node)
1194 {
1195 wxWindow *win = node->GetData();
1196 if (win != this)
1197 win->Enable(!modal);
1198
1199 node = node->GetNext();
1200 }
1201 }
f03fc89f
VZ
1202}
1203
1204bool wxWindowBase::Validate()
1205{
88ac883a 1206#if wxUSE_VALIDATORS
d80cd92a
VZ
1207 bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0;
1208
222ed1d6 1209 wxWindowList::compatibility_iterator node;
f03fc89f
VZ
1210 for ( node = m_children.GetFirst(); node; node = node->GetNext() )
1211 {
1212 wxWindowBase *child = node->GetData();
1213 wxValidator *validator = child->GetValidator();
dcd6b914 1214 if ( validator && !validator->Validate((wxWindow *)this) )
f03fc89f 1215 {
e11f4636 1216 return false;
f03fc89f 1217 }
d80cd92a
VZ
1218
1219 if ( recurse && !child->Validate() )
1220 {
e11f4636 1221 return false;
d80cd92a 1222 }
f03fc89f 1223 }
88ac883a 1224#endif // wxUSE_VALIDATORS
f03fc89f 1225
e11f4636 1226 return true;
f03fc89f
VZ
1227}
1228
1229bool wxWindowBase::TransferDataToWindow()
1230{
88ac883a 1231#if wxUSE_VALIDATORS
d80cd92a
VZ
1232 bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0;
1233
222ed1d6 1234 wxWindowList::compatibility_iterator node;
f03fc89f
VZ
1235 for ( node = m_children.GetFirst(); node; node = node->GetNext() )
1236 {
1237 wxWindowBase *child = node->GetData();
1238 wxValidator *validator = child->GetValidator();
1239 if ( validator && !validator->TransferToWindow() )
1240 {
d80cd92a 1241 wxLogWarning(_("Could not transfer data to window"));
e30285ab 1242#if wxUSE_LOG
d80cd92a 1243 wxLog::FlushActive();
e30285ab 1244#endif // wxUSE_LOG
f03fc89f 1245
e11f4636 1246 return false;
f03fc89f 1247 }
d80cd92a
VZ
1248
1249 if ( recurse )
1250 {
a58a12e9 1251 if ( !child->TransferDataToWindow() )
d80cd92a
VZ
1252 {
1253 // warning already given
e11f4636 1254 return false;
d80cd92a
VZ
1255 }
1256 }
f03fc89f 1257 }
88ac883a 1258#endif // wxUSE_VALIDATORS
f03fc89f 1259
e11f4636 1260 return true;
f03fc89f
VZ
1261}
1262
1263bool wxWindowBase::TransferDataFromWindow()
1264{
88ac883a 1265#if wxUSE_VALIDATORS
d80cd92a
VZ
1266 bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0;
1267
222ed1d6 1268 wxWindowList::compatibility_iterator node;
f03fc89f
VZ
1269 for ( node = m_children.GetFirst(); node; node = node->GetNext() )
1270 {
1271 wxWindow *child = node->GetData();
d80cd92a
VZ
1272 wxValidator *validator = child->GetValidator();
1273 if ( validator && !validator->TransferFromWindow() )
f03fc89f 1274 {
d80cd92a
VZ
1275 // nop warning here because the application is supposed to give
1276 // one itself - we don't know here what might have gone wrongly
1277
e11f4636 1278 return false;
f03fc89f 1279 }
d80cd92a
VZ
1280
1281 if ( recurse )
1282 {
a58a12e9 1283 if ( !child->TransferDataFromWindow() )
d80cd92a
VZ
1284 {
1285 // warning already given
e11f4636 1286 return false;
d80cd92a
VZ
1287 }
1288 }
f03fc89f 1289 }
88ac883a 1290#endif // wxUSE_VALIDATORS
f03fc89f 1291
e11f4636 1292 return true;
f03fc89f
VZ
1293}
1294
1295void wxWindowBase::InitDialog()
1296{
1297 wxInitDialogEvent event(GetId());
1298 event.SetEventObject( this );
1299 GetEventHandler()->ProcessEvent(event);
1300}
1301
1302// ----------------------------------------------------------------------------
bd83cb56
VZ
1303// context-sensitive help support
1304// ----------------------------------------------------------------------------
1305
1306#if wxUSE_HELP
1307
1308// associate this help text with this window
1309void wxWindowBase::SetHelpText(const wxString& text)
1310{
1311 wxHelpProvider *helpProvider = wxHelpProvider::Get();
1312 if ( helpProvider )
1313 {
1314 helpProvider->AddHelp(this, text);
1315 }
1316}
1317
1318// associate this help text with all windows with the same id as this
1319// one
1320void wxWindowBase::SetHelpTextForId(const wxString& text)
1321{
1322 wxHelpProvider *helpProvider = wxHelpProvider::Get();
1323 if ( helpProvider )
1324 {
1325 helpProvider->AddHelp(GetId(), text);
1326 }
1327}
1328
1329// get the help string associated with this window (may be empty)
1330wxString wxWindowBase::GetHelpText() const
1331{
1332 wxString text;
1333 wxHelpProvider *helpProvider = wxHelpProvider::Get();
1334 if ( helpProvider )
1335 {
1336 text = helpProvider->GetHelp(this);
1337 }
1338
1339 return text;
1340}
1341
1342// show help for this window
1343void wxWindowBase::OnHelp(wxHelpEvent& event)
1344{
1345 wxHelpProvider *helpProvider = wxHelpProvider::Get();
1346 if ( helpProvider )
1347 {
1348 if ( helpProvider->ShowHelp(this) )
1349 {
1350 // skip the event.Skip() below
1351 return;
1352 }
1353 }
1354
1355 event.Skip();
1356}
1357
1358#endif // wxUSE_HELP
1359
1360// ----------------------------------------------------------------------------
574c939e 1361// tooltipsroot.Replace("\\", "/");
f03fc89f
VZ
1362// ----------------------------------------------------------------------------
1363
1364#if wxUSE_TOOLTIPS
1365
1366void wxWindowBase::SetToolTip( const wxString &tip )
1367{
1368 // don't create the new tooltip if we already have one
1369 if ( m_tooltip )
1370 {
1371 m_tooltip->SetTip( tip );
1372 }
1373 else
1374 {
1375 SetToolTip( new wxToolTip( tip ) );
1376 }
1377
1378 // setting empty tooltip text does not remove the tooltip any more - use
1379 // SetToolTip((wxToolTip *)NULL) for this
1380}
1381
1382void wxWindowBase::DoSetToolTip(wxToolTip *tooltip)
1383{
1384 if ( m_tooltip )
1385 delete m_tooltip;
1386
1387 m_tooltip = tooltip;
1388}
1389
1390#endif // wxUSE_TOOLTIPS
1391
1392// ----------------------------------------------------------------------------
1393// constraints and sizers
1394// ----------------------------------------------------------------------------
1395
1396#if wxUSE_CONSTRAINTS
1397
1398void wxWindowBase::SetConstraints( wxLayoutConstraints *constraints )
1399{
1400 if ( m_constraints )
1401 {
1402 UnsetConstraints(m_constraints);
1403 delete m_constraints;
1404 }
1405 m_constraints = constraints;
1406 if ( m_constraints )
1407 {
1408 // Make sure other windows know they're part of a 'meaningful relationship'
1409 if ( m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this) )
1410 m_constraints->left.GetOtherWindow()->AddConstraintReference(this);
1411 if ( m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this) )
1412 m_constraints->top.GetOtherWindow()->AddConstraintReference(this);
1413 if ( m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this) )
1414 m_constraints->right.GetOtherWindow()->AddConstraintReference(this);
1415 if ( m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this) )
1416 m_constraints->bottom.GetOtherWindow()->AddConstraintReference(this);
1417 if ( m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this) )
1418 m_constraints->width.GetOtherWindow()->AddConstraintReference(this);
1419 if ( m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this) )
1420 m_constraints->height.GetOtherWindow()->AddConstraintReference(this);
1421 if ( m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this) )
1422 m_constraints->centreX.GetOtherWindow()->AddConstraintReference(this);
1423 if ( m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this) )
1424 m_constraints->centreY.GetOtherWindow()->AddConstraintReference(this);
1425 }
1426}
1427
1428// This removes any dangling pointers to this window in other windows'
1429// constraintsInvolvedIn lists.
1430void wxWindowBase::UnsetConstraints(wxLayoutConstraints *c)
1431{
1432 if ( c )
1433 {
1434 if ( c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this) )
1435 c->left.GetOtherWindow()->RemoveConstraintReference(this);
1436 if ( c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this) )
1437 c->top.GetOtherWindow()->RemoveConstraintReference(this);
1438 if ( c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this) )
1439 c->right.GetOtherWindow()->RemoveConstraintReference(this);
1440 if ( c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this) )
1441 c->bottom.GetOtherWindow()->RemoveConstraintReference(this);
1442 if ( c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this) )
1443 c->width.GetOtherWindow()->RemoveConstraintReference(this);
1444 if ( c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this) )
1445 c->height.GetOtherWindow()->RemoveConstraintReference(this);
1446 if ( c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this) )
1447 c->centreX.GetOtherWindow()->RemoveConstraintReference(this);
1448 if ( c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this) )
1449 c->centreY.GetOtherWindow()->RemoveConstraintReference(this);
1450 }
1451}
1452
1453// Back-pointer to other windows we're involved with, so if we delete this
1454// window, we must delete any constraints we're involved with.
1455void wxWindowBase::AddConstraintReference(wxWindowBase *otherWin)
1456{
1457 if ( !m_constraintsInvolvedIn )
1458 m_constraintsInvolvedIn = new wxWindowList;
222ed1d6
MB
1459 if ( !m_constraintsInvolvedIn->Find((wxWindow *)otherWin) )
1460 m_constraintsInvolvedIn->Append((wxWindow *)otherWin);
f03fc89f
VZ
1461}
1462
1463// REMOVE back-pointer to other windows we're involved with.
1464void wxWindowBase::RemoveConstraintReference(wxWindowBase *otherWin)
1465{
1466 if ( m_constraintsInvolvedIn )
222ed1d6 1467 m_constraintsInvolvedIn->DeleteObject((wxWindow *)otherWin);
f03fc89f
VZ
1468}
1469
1470// Reset any constraints that mention this window
1471void wxWindowBase::DeleteRelatedConstraints()
1472{
1473 if ( m_constraintsInvolvedIn )
1474 {
222ed1d6 1475 wxWindowList::compatibility_iterator node = m_constraintsInvolvedIn->GetFirst();
f03fc89f
VZ
1476 while (node)
1477 {
1478 wxWindow *win = node->GetData();
1479 wxLayoutConstraints *constr = win->GetConstraints();
1480
1481 // Reset any constraints involving this window
1482 if ( constr )
1483 {
1484 constr->left.ResetIfWin(this);
1485 constr->top.ResetIfWin(this);
1486 constr->right.ResetIfWin(this);
1487 constr->bottom.ResetIfWin(this);
1488 constr->width.ResetIfWin(this);
1489 constr->height.ResetIfWin(this);
1490 constr->centreX.ResetIfWin(this);
1491 constr->centreY.ResetIfWin(this);
1492 }
1493
222ed1d6
MB
1494 wxWindowList::compatibility_iterator next = node->GetNext();
1495 m_constraintsInvolvedIn->Erase(node);
f03fc89f
VZ
1496 node = next;
1497 }
1498
1499 delete m_constraintsInvolvedIn;
1500 m_constraintsInvolvedIn = (wxWindowList *) NULL;
1501 }
1502}
ec5bb70d
VZ
1503
1504#endif // wxUSE_CONSTRAINTS
f03fc89f 1505
3aa5d532 1506void wxWindowBase::SetSizer(wxSizer *sizer, bool deleteOld)
f03fc89f 1507{
fb89cfc5
RD
1508 if ( sizer == m_windowSizer)
1509 return;
1510
ec5bb70d
VZ
1511 if ( deleteOld )
1512 delete m_windowSizer;
3417c2cd 1513
f03fc89f 1514 m_windowSizer = sizer;
566d84a7 1515
ec5bb70d 1516 SetAutoLayout( sizer != NULL );
566d84a7
RL
1517}
1518
1519void wxWindowBase::SetSizerAndFit(wxSizer *sizer, bool deleteOld)
1520{
1521 SetSizer( sizer, deleteOld );
1522 sizer->SetSizeHints( (wxWindow*) this );
f03fc89f
VZ
1523}
1524
ec5bb70d
VZ
1525#if wxUSE_CONSTRAINTS
1526
1527void wxWindowBase::SatisfyConstraints()
1528{
1529 wxLayoutConstraints *constr = GetConstraints();
1530 bool wasOk = constr && constr->AreSatisfied();
1531
1532 ResetConstraints(); // Mark all constraints as unevaluated
1533
1534 int noChanges = 1;
1535
1536 // if we're a top level panel (i.e. our parent is frame/dialog), our
1537 // own constraints will never be satisfied any more unless we do it
1538 // here
1539 if ( wasOk )
1540 {
1541 while ( noChanges > 0 )
1542 {
1543 LayoutPhase1(&noChanges);
1544 }
1545 }
1546
1547 LayoutPhase2(&noChanges);
1548}
1549
1550#endif // wxUSE_CONSTRAINTS
1551
f03fc89f
VZ
1552bool wxWindowBase::Layout()
1553{
3417c2cd 1554 // If there is a sizer, use it instead of the constraints
f03fc89f
VZ
1555 if ( GetSizer() )
1556 {
f1df0927 1557 int w, h;
566d84a7 1558 GetVirtualSize(&w, &h);
3417c2cd 1559 GetSizer()->SetDimension( 0, 0, w, h );
f03fc89f 1560 }
461e93f9 1561#if wxUSE_CONSTRAINTS
f1df0927 1562 else
f03fc89f 1563 {
ec5bb70d 1564 SatisfyConstraints(); // Find the right constraints values
f1df0927 1565 SetConstraintSizes(); // Recursively set the real window sizes
f03fc89f 1566 }
461e93f9 1567#endif
5d4b632b 1568
e11f4636 1569 return true;
f03fc89f
VZ
1570}
1571
461e93f9 1572#if wxUSE_CONSTRAINTS
ec5bb70d
VZ
1573
1574// first phase of the constraints evaluation: set our own constraints
f03fc89f
VZ
1575bool wxWindowBase::LayoutPhase1(int *noChanges)
1576{
1577 wxLayoutConstraints *constr = GetConstraints();
ec5bb70d
VZ
1578
1579 return !constr || constr->SatisfyConstraints(this, noChanges);
f03fc89f
VZ
1580}
1581
ec5bb70d 1582// second phase: set the constraints for our children
f03fc89f
VZ
1583bool wxWindowBase::LayoutPhase2(int *noChanges)
1584{
1585 *noChanges = 0;
1586
1587 // Layout children
1588 DoPhase(1);
ec5bb70d
VZ
1589
1590 // Layout grand children
f03fc89f 1591 DoPhase(2);
ec5bb70d 1592
e11f4636 1593 return true;
f03fc89f
VZ
1594}
1595
1596// Do a phase of evaluating child constraints
1597bool wxWindowBase::DoPhase(int phase)
1598{
ec5bb70d
VZ
1599 // the list containing the children for which the constraints are already
1600 // set correctly
f03fc89f 1601 wxWindowList succeeded;
ec5bb70d
VZ
1602
1603 // the max number of iterations we loop before concluding that we can't set
1604 // the constraints
1605 static const int maxIterations = 500;
1606
1607 for ( int noIterations = 0; noIterations < maxIterations; noIterations++ )
f03fc89f 1608 {
ec5bb70d
VZ
1609 int noChanges = 0;
1610
1611 // loop over all children setting their constraints
222ed1d6 1612 for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
ec5bb70d
VZ
1613 node;
1614 node = node->GetNext() )
f03fc89f
VZ
1615 {
1616 wxWindow *child = node->GetData();
ec5bb70d 1617 if ( child->IsTopLevel() )
f03fc89f 1618 {
ec5bb70d
VZ
1619 // top level children are not inside our client area
1620 continue;
1621 }
1622
1623 if ( !child->GetConstraints() || succeeded.Find(child) )
1624 {
1625 // this one is either already ok or nothing we can do about it
1626 continue;
1627 }
1628
1629 int tempNoChanges = 0;
1630 bool success = phase == 1 ? child->LayoutPhase1(&tempNoChanges)
1631 : child->LayoutPhase2(&tempNoChanges);
1632 noChanges += tempNoChanges;
1633
1634 if ( success )
1635 {
1636 succeeded.Append(child);
f03fc89f 1637 }
f03fc89f
VZ
1638 }
1639
ec5bb70d
VZ
1640 if ( !noChanges )
1641 {
1642 // constraints are set
1643 break;
1644 }
f03fc89f
VZ
1645 }
1646
e11f4636 1647 return true;
f03fc89f
VZ
1648}
1649
1650void wxWindowBase::ResetConstraints()
1651{
1652 wxLayoutConstraints *constr = GetConstraints();
1653 if ( constr )
1654 {
e11f4636
DS
1655 constr->left.SetDone(false);
1656 constr->top.SetDone(false);
1657 constr->right.SetDone(false);
1658 constr->bottom.SetDone(false);
1659 constr->width.SetDone(false);
1660 constr->height.SetDone(false);
1661 constr->centreX.SetDone(false);
1662 constr->centreY.SetDone(false);
f03fc89f 1663 }
f1df0927 1664
222ed1d6 1665 wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
f03fc89f
VZ
1666 while (node)
1667 {
1668 wxWindow *win = node->GetData();
34636400 1669 if ( !win->IsTopLevel() )
f03fc89f
VZ
1670 win->ResetConstraints();
1671 node = node->GetNext();
1672 }
1673}
1674
1675// Need to distinguish between setting the 'fake' size for windows and sizers,
1676// and setting the real values.
1677void wxWindowBase::SetConstraintSizes(bool recurse)
1678{
1679 wxLayoutConstraints *constr = GetConstraints();
4b7f2165 1680 if ( constr && constr->AreSatisfied() )
f03fc89f
VZ
1681 {
1682 int x = constr->left.GetValue();
1683 int y = constr->top.GetValue();
1684 int w = constr->width.GetValue();
1685 int h = constr->height.GetValue();
1686
f03fc89f 1687 if ( (constr->width.GetRelationship() != wxAsIs ) ||
3417c2cd 1688 (constr->height.GetRelationship() != wxAsIs) )
f03fc89f 1689 {
3417c2cd 1690 SetSize(x, y, w, h);
f03fc89f
VZ
1691 }
1692 else
1693 {
3417c2cd
RR
1694 // If we don't want to resize this window, just move it...
1695 Move(x, y);
f03fc89f
VZ
1696 }
1697 }
1698 else if ( constr )
1699 {
4b7f2165 1700 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
f1df0927 1701 GetClassInfo()->GetClassName(),
4b7f2165 1702 GetName().c_str());
f03fc89f
VZ
1703 }
1704
1705 if ( recurse )
1706 {
222ed1d6 1707 wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
f03fc89f
VZ
1708 while (node)
1709 {
1710 wxWindow *win = node->GetData();
e2f9212c 1711 if ( !win->IsTopLevel() && win->GetConstraints() )
f03fc89f
VZ
1712 win->SetConstraintSizes();
1713 node = node->GetNext();
1714 }
1715 }
1716}
1717
f03fc89f
VZ
1718// Only set the size/position of the constraint (if any)
1719void wxWindowBase::SetSizeConstraint(int x, int y, int w, int h)
1720{
1721 wxLayoutConstraints *constr = GetConstraints();
1722 if ( constr )
1723 {
1724 if ( x != -1 )
1725 {
1726 constr->left.SetValue(x);
e11f4636 1727 constr->left.SetDone(true);
f03fc89f
VZ
1728 }
1729 if ( y != -1 )
1730 {
1731 constr->top.SetValue(y);
e11f4636 1732 constr->top.SetDone(true);
f03fc89f
VZ
1733 }
1734 if ( w != -1 )
1735 {
1736 constr->width.SetValue(w);
e11f4636 1737 constr->width.SetDone(true);
f03fc89f
VZ
1738 }
1739 if ( h != -1 )
1740 {
1741 constr->height.SetValue(h);
e11f4636 1742 constr->height.SetDone(true);
f03fc89f
VZ
1743 }
1744 }
1745}
1746
1747void wxWindowBase::MoveConstraint(int x, int y)
1748{
1749 wxLayoutConstraints *constr = GetConstraints();
1750 if ( constr )
1751 {
1752 if ( x != -1 )
1753 {
1754 constr->left.SetValue(x);
e11f4636 1755 constr->left.SetDone(true);
f03fc89f
VZ
1756 }
1757 if ( y != -1 )
1758 {
1759 constr->top.SetValue(y);
e11f4636 1760 constr->top.SetDone(true);
f03fc89f
VZ
1761 }
1762 }
1763}
1764
1765void wxWindowBase::GetSizeConstraint(int *w, int *h) const
1766{
1767 wxLayoutConstraints *constr = GetConstraints();
1768 if ( constr )
1769 {
1770 *w = constr->width.GetValue();
1771 *h = constr->height.GetValue();
1772 }
1773 else
1774 GetSize(w, h);
1775}
1776
1777void wxWindowBase::GetClientSizeConstraint(int *w, int *h) const
1778{
1779 wxLayoutConstraints *constr = GetConstraints();
1780 if ( constr )
1781 {
1782 *w = constr->width.GetValue();
1783 *h = constr->height.GetValue();
1784 }
1785 else
1786 GetClientSize(w, h);
1787}
1788
461e93f9
JS
1789void wxWindowBase::GetPositionConstraint(int *x, int *y) const
1790{
1791 wxLayoutConstraints *constr = GetConstraints();
1792 if ( constr )
1793 {
1794 *x = constr->left.GetValue();
1795 *y = constr->top.GetValue();
1796 }
1797 else
1798 GetPosition(x, y);
1799}
1800
1801#endif // wxUSE_CONSTRAINTS
1802
20a1eea1 1803void wxWindowBase::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) const
a200c35e
VS
1804{
1805 // don't do it for the dialogs/frames - they float independently of their
1806 // parent
1807 if ( !IsTopLevel() )
1808 {
1809 wxWindow *parent = GetParent();
1810 if ( !(sizeFlags & wxSIZE_NO_ADJUSTMENTS) && parent )
1811 {
1812 wxPoint pt(parent->GetClientAreaOrigin());
1813 x += pt.x;
1814 y += pt.y;
1815 }
1816 }
1817}
1818
f03fc89f
VZ
1819// ----------------------------------------------------------------------------
1820// do Update UI processing for child controls
1821// ----------------------------------------------------------------------------
7ec1983b 1822
e39af974 1823void wxWindowBase::UpdateWindowUI(long flags)
7ec1983b 1824{
26bf1ce0
VZ
1825 wxUpdateUIEvent event(GetId());
1826 event.m_eventObject = this;
1827
1828 if ( GetEventHandler()->ProcessEvent(event) )
7ec1983b 1829 {
e39af974
JS
1830 DoUpdateWindowUI(event);
1831 }
7ec1983b 1832
e39af974
JS
1833 if (flags & wxUPDATE_UI_RECURSE)
1834 {
222ed1d6 1835 wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
e39af974 1836 while (node)
f03fc89f 1837 {
e39af974
JS
1838 wxWindow* child = (wxWindow*) node->GetData();
1839 child->UpdateWindowUI(flags);
1840 node = node->GetNext();
26bf1ce0 1841 }
e39af974
JS
1842 }
1843}
f03fc89f 1844
e39af974
JS
1845// do the window-specific processing after processing the update event
1846// TODO: take specific knowledge out of this function and
1847// put in each control's base class. Unfortunately we don't
1848// yet have base implementation files for wxCheckBox and wxRadioButton.
1849void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent& event)
1850{
1851 if ( event.GetSetEnabled() )
1852 Enable(event.GetEnabled());
e11f4636 1853
e39af974
JS
1854#if wxUSE_CONTROLS
1855 if ( event.GetSetText() )
1856 {
1857 wxControl *control = wxDynamicCastThis(wxControl);
1858 if ( control )
1859 {
1860 if ( event.GetText() != control->GetLabel() )
1861 control->SetLabel(event.GetText());
1862 }
88ac883a 1863#if wxUSE_CHECKBOX
f7637829 1864 wxCheckBox *checkbox = wxDynamicCastThis(wxCheckBox);
26bf1ce0
VZ
1865 if ( checkbox )
1866 {
1867 if ( event.GetSetChecked() )
1868 checkbox->SetValue(event.GetChecked());
1869 }
88ac883a
VZ
1870#endif // wxUSE_CHECKBOX
1871
b3402d0d 1872#if wxUSE_RADIOBTN
f7637829 1873 wxRadioButton *radiobtn = wxDynamicCastThis(wxRadioButton);
26bf1ce0
VZ
1874 if ( radiobtn )
1875 {
1876 if ( event.GetSetChecked() )
1877 radiobtn->SetValue(event.GetChecked());
f03fc89f 1878 }
b3402d0d 1879#endif // wxUSE_RADIOBTN
e11f4636 1880 }
e39af974
JS
1881#endif
1882}
1883
5109ae5d 1884#if 0
e39af974 1885// call internal idle recursively
5109ae5d 1886// may be obsolete (wait until OnIdle scheme stabilises)
e39af974
JS
1887void wxWindowBase::ProcessInternalIdle()
1888{
1889 OnInternalIdle();
1890
222ed1d6 1891 wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
e39af974
JS
1892 while (node)
1893 {
1894 wxWindow *child = node->GetData();
1895 child->ProcessInternalIdle();
1896 node = node->GetNext();
7ec1983b 1897 }
7ec1983b 1898}
5109ae5d 1899#endif
fd71308f 1900
f03fc89f
VZ
1901// ----------------------------------------------------------------------------
1902// dialog units translations
1903// ----------------------------------------------------------------------------
1904
1905wxPoint wxWindowBase::ConvertPixelsToDialog(const wxPoint& pt)
fd71308f
JS
1906{
1907 int charWidth = GetCharWidth();
1908 int charHeight = GetCharHeight();
5d9c2818
RD
1909 wxPoint pt2(-1, -1);
1910 if (pt.x != -1)
1911 pt2.x = (int) ((pt.x * 4) / charWidth) ;
1912 if (pt.y != -1)
1913 pt2.y = (int) ((pt.y * 8) / charHeight) ;
fd71308f
JS
1914
1915 return pt2;
1916}
1917
f03fc89f 1918wxPoint wxWindowBase::ConvertDialogToPixels(const wxPoint& pt)
fd71308f
JS
1919{
1920 int charWidth = GetCharWidth();
1921 int charHeight = GetCharHeight();
5d9c2818
RD
1922 wxPoint pt2(-1, -1);
1923 if (pt.x != -1)
1924 pt2.x = (int) ((pt.x * charWidth) / 4) ;
1925 if (pt.y != -1)
1926 pt2.y = (int) ((pt.y * charHeight) / 8) ;
fd71308f
JS
1927
1928 return pt2;
1929}
1930
f03fc89f
VZ
1931// ----------------------------------------------------------------------------
1932// event handlers
1933// ----------------------------------------------------------------------------
1934
1935// propagate the colour change event to the subwindows
1936void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& event)
1937{
222ed1d6 1938 wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
f03fc89f
VZ
1939 while ( node )
1940 {
1941 // Only propagate to non-top-level windows
1942 wxWindow *win = node->GetData();
1943 if ( !win->IsTopLevel() )
1944 {
1945 wxSysColourChangedEvent event2;
1946 event.m_eventObject = win;
1947 win->GetEventHandler()->ProcessEvent(event2);
1948 }
1949
1950 node = node->GetNext();
1951 }
1952}
1953
e39af974
JS
1954// the default action is to populate dialog with data when it's created,
1955// and nudge the UI into displaying itself correctly in case
1956// we've turned the wxUpdateUIEvents frequency down low.
f03fc89f
VZ
1957void wxWindowBase::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) )
1958{
1959 TransferDataToWindow();
e11f4636 1960
e39af974
JS
1961 // Update the UI at this point
1962 UpdateWindowUI(wxUPDATE_UI_RECURSE);
f03fc89f
VZ
1963}
1964
a02dc3e3
VZ
1965// process Ctrl-Alt-mclick
1966void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
1967{
1e6feb95 1968#if wxUSE_MSGDLG
a02dc3e3
VZ
1969 if ( event.ControlDown() && event.AltDown() )
1970 {
1971 // don't translate these strings
1972 wxString port;
af3062a8
VZ
1973
1974#ifdef __WXUNIVERSAL__
1975 port = _T("Univ/");
1976#endif // __WXUNIVERSAL__
1977
a02dc3e3
VZ
1978 switch ( wxGetOsVersion() )
1979 {
ea8e90b7 1980 case wxMOTIF_X: port += _T("Motif"); break;
ff8fda36 1981 case wxMAC:
ea8e90b7
VZ
1982 case wxMAC_DARWIN: port += _T("Mac"); break;
1983 case wxBEOS: port += _T("BeOS"); break;
a02dc3e3
VZ
1984 case wxGTK:
1985 case wxGTK_WIN32:
1986 case wxGTK_OS2:
ea8e90b7 1987 case wxGTK_BEOS: port += _T("GTK"); break;
a02dc3e3
VZ
1988 case wxWINDOWS:
1989 case wxPENWINDOWS:
1990 case wxWINDOWS_NT:
1991 case wxWIN32S:
1992 case wxWIN95:
ea8e90b7 1993 case wxWIN386: port += _T("MS Windows"); break;
a02dc3e3
VZ
1994 case wxMGL_UNIX:
1995 case wxMGL_X:
1996 case wxMGL_WIN32:
ea8e90b7 1997 case wxMGL_OS2: port += _T("MGL"); break;
a02dc3e3 1998 case wxWINDOWS_OS2:
ea8e90b7
VZ
1999 case wxOS2_PM: port += _T("OS/2"); break;
2000 default: port += _T("unknown"); break;
a02dc3e3
VZ
2001 }
2002
2003 wxMessageBox(wxString::Format(
2004 _T(
af3062a8 2005 " wxWindows Library (%s port)\nVersion %u.%u.%u%s, compiled at %s %s\n Copyright (c) 1995-2002 wxWindows team"
a02dc3e3
VZ
2006 ),
2007 port.c_str(),
2008 wxMAJOR_VERSION,
2009 wxMINOR_VERSION,
2010 wxRELEASE_NUMBER,
3f562374
VZ
2011#if wxUSE_UNICODE
2012 L" (Unicode)",
2013#else
2014 "",
2015#endif
2016 __TDATE__,
2017 __TTIME__
a02dc3e3
VZ
2018 ),
2019 _T("wxWindows information"),
2020 wxICON_INFORMATION | wxOK,
2021 (wxWindow *)this);
2022 }
2023 else
1e6feb95 2024#endif // wxUSE_MSGDLG
a02dc3e3
VZ
2025 {
2026 event.Skip();
2027 }
2028}
2029
ed5317e5
JS
2030// ----------------------------------------------------------------------------
2031// accessibility
2032// ----------------------------------------------------------------------------
2033
2034#if wxUSE_ACCESSIBILITY
2035void wxWindowBase::SetAccessible(wxAccessible* accessible)
2036{
2aefc528 2037 if (m_accessible && (accessible != m_accessible))
ed5317e5
JS
2038 delete m_accessible;
2039 m_accessible = accessible;
2040 if (m_accessible)
2041 m_accessible->SetWindow((wxWindow*) this);
2042}
2043
2044// Returns the accessible object, creating if necessary.
2045wxAccessible* wxWindowBase::GetOrCreateAccessible()
2046{
2047 if (!m_accessible)
2048 m_accessible = CreateAccessible();
2049 return m_accessible;
2050}
2051
2052// Override to create a specific accessible object.
2053wxAccessible* wxWindowBase::CreateAccessible()
2054{
2055 return new wxWindowAccessible((wxWindow*) this);
2056}
2057
2058#endif
2059
222ed1d6 2060#if !wxUSE_STL
f03fc89f
VZ
2061// ----------------------------------------------------------------------------
2062// list classes implementation
2063// ----------------------------------------------------------------------------
2064
2065void wxWindowListNode::DeleteData()
2066{
2067 delete (wxWindow *)GetData();
2068}
222ed1d6 2069#endif
f03fc89f 2070
1e6feb95
VZ
2071// ----------------------------------------------------------------------------
2072// borders
2073// ----------------------------------------------------------------------------
2074
aede4ebb 2075wxBorder wxWindowBase::GetBorder(long flags) const
1e6feb95 2076{
aede4ebb 2077 wxBorder border = (wxBorder)(flags & wxBORDER_MASK);
1e6feb95
VZ
2078 if ( border == wxBORDER_DEFAULT )
2079 {
2080 border = GetDefaultBorder();
2081 }
2082
2083 return border;
2084}
2085
2086wxBorder wxWindowBase::GetDefaultBorder() const
2087{
2088 return wxBORDER_NONE;
2089}
2090
2091// ----------------------------------------------------------------------------
2092// hit testing
2093// ----------------------------------------------------------------------------
2094
2095wxHitTest wxWindowBase::DoHitTest(wxCoord x, wxCoord y) const
2096{
2097 // here we just check if the point is inside the window or not
2098
2099 // check the top and left border first
2100 bool outside = x < 0 || y < 0;
2101 if ( !outside )
2102 {
2103 // check the right and bottom borders too
2104 wxSize size = GetSize();
2105 outside = x >= size.x || y >= size.y;
2106 }
2107
2108 return outside ? wxHT_WINDOW_OUTSIDE : wxHT_WINDOW_INSIDE;
2109}
2110
94633ad9
VZ
2111// ----------------------------------------------------------------------------
2112// mouse capture
2113// ----------------------------------------------------------------------------
2114
2115struct WXDLLEXPORT wxWindowNext
2116{
2117 wxWindow *win;
2118 wxWindowNext *next;
786646f3 2119} *wxWindowBase::ms_winCaptureNext = NULL;
94633ad9 2120
a83e1475 2121void wxWindowBase::CaptureMouse()
94633ad9 2122{
7e555446 2123 wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), this);
45e0dc94 2124
94633ad9
VZ
2125 wxWindow *winOld = GetCapture();
2126 if ( winOld )
2127 {
df2f507b 2128 ((wxWindowBase*) winOld)->DoReleaseMouse();
edd802c6 2129
94633ad9
VZ
2130 // save it on stack
2131 wxWindowNext *item = new wxWindowNext;
2132 item->win = winOld;
2133 item->next = ms_winCaptureNext;
2134 ms_winCaptureNext = item;
2135 }
2136 //else: no mouse capture to save
2137
2138 DoCaptureMouse();
2139}
2140
a83e1475 2141void wxWindowBase::ReleaseMouse()
94633ad9 2142{
7e555446 2143 wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), this);
349d1942 2144
63fd5f0b 2145 wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") );
a7b09001 2146
94633ad9
VZ
2147 DoReleaseMouse();
2148
2149 if ( ms_winCaptureNext )
2150 {
44f8caa7 2151 ((wxWindowBase*)ms_winCaptureNext->win)->DoCaptureMouse();
edd802c6 2152
94633ad9
VZ
2153 wxWindowNext *item = ms_winCaptureNext;
2154 ms_winCaptureNext = item->next;
2155 delete item;
2156 }
2157 //else: stack is empty, no previous capture
2158
2159 wxLogTrace(_T("mousecapture"),
e11f4636
DS
2160 (const wxChar *) _T("After ReleaseMouse() mouse is captured by %p"),
2161 GetCapture());
94633ad9
VZ
2162}
2163
5048c832 2164#if wxUSE_HOTKEY
540b6b09
VZ
2165
2166bool
2167wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId),
2168 int WXUNUSED(modifiers),
2169 int WXUNUSED(keycode))
5048c832
JS
2170{
2171 // not implemented
2172 return false;
2173}
2174
540b6b09 2175bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId))
5048c832
JS
2176{
2177 // not implemented
2178 return false;
2179}
540b6b09
VZ
2180
2181#endif // wxUSE_HOTKEY
7de59551
RD
2182
2183void wxWindowBase::SendDestroyEvent()
2184{
2185 wxWindowDestroyEvent event;
2186 event.SetEventObject(this);
2187 event.SetId(GetId());
2188 GetEventHandler()->ProcessEvent(event);
2189}
2190
4caf847c
VZ
2191// ----------------------------------------------------------------------------
2192// event processing
2193// ----------------------------------------------------------------------------
2194
ac8d0c11 2195bool wxWindowBase::TryValidator(wxEvent& wxVALIDATOR_PARAM(event))
4caf847c 2196{
6eabf58c 2197#if wxUSE_VALIDATORS
4caf847c
VZ
2198 // Can only use the validator of the window which
2199 // is receiving the event
2200 if ( event.GetEventObject() == this )
2201 {
2202 wxValidator *validator = GetValidator();
2203 if ( validator && validator->ProcessEvent(event) )
2204 {
6eabf58c 2205 return true;
4caf847c
VZ
2206 }
2207 }
6eabf58c 2208#endif // wxUSE_VALIDATORS
4caf847c 2209
6eabf58c 2210 return false;
4caf847c
VZ
2211}
2212
4caf847c
VZ
2213bool wxWindowBase::TryParent(wxEvent& event)
2214{
040e234d
VZ
2215 // carry on up the parent-child hierarchy if the propgation count hasn't
2216 // reached zero yet
2217 if ( event.ShouldPropagate() )
4caf847c
VZ
2218 {
2219 // honour the requests to stop propagation at this window: this is
2220 // used by the dialogs, for example, to prevent processing the events
2221 // from the dialog controls in the parent frame which rarely, if ever,
2222 // makes sense
2223 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS) )
2224 {
2225 wxWindow *parent = GetParent();
2226 if ( parent && !parent->IsBeingDeleted() )
040e234d
VZ
2227 {
2228 wxPropagateOnce propagateOnce(event);
2229
4caf847c 2230 return parent->GetEventHandler()->ProcessEvent(event);
040e234d 2231 }
4caf847c
VZ
2232 }
2233 }
2234
2235 return wxEvtHandler::TryParent(event);
2236}
2237
33b494d6
VZ
2238// ----------------------------------------------------------------------------
2239// global functions
2240// ----------------------------------------------------------------------------
2241
2242wxWindow* wxGetTopLevelParent(wxWindow *win)
2243{
2244 while ( win && !win->IsTopLevel() )
2245 win = win->GetParent();
2246
2247 return win;
2248}
2249
ed5317e5
JS
2250#if wxUSE_ACCESSIBILITY
2251// ----------------------------------------------------------------------------
2252// accessible object for windows
2253// ----------------------------------------------------------------------------
2254
2255// Can return either a child object, or an integer
2256// representing the child element, starting from 1.
66b9ec3d 2257wxAccStatus wxWindowAccessible::HitTest(const wxPoint& WXUNUSED(pt), int* WXUNUSED(childId), wxAccessible** WXUNUSED(childObject))
ed5317e5
JS
2258{
2259 wxASSERT( GetWindow() != NULL );
2260 if (!GetWindow())
2261 return wxACC_FAIL;
2262
2263 return wxACC_NOT_IMPLEMENTED;
2264}
2265
2266// Returns the rectangle for this object (id = 0) or a child element (id > 0).
2267wxAccStatus wxWindowAccessible::GetLocation(wxRect& rect, int elementId)
2268{
2269 wxASSERT( GetWindow() != NULL );
2270 if (!GetWindow())
2271 return wxACC_FAIL;
2272
c6e2af45
JS
2273 wxWindow* win = NULL;
2274 if (elementId == 0)
2275 {
2276 win = GetWindow();
2277 }
2278 else
2279 {
2280 if (elementId <= (int) GetWindow()->GetChildren().GetCount())
2281 {
ee6eb8d8 2282 win = GetWindow()->GetChildren().Item(elementId-1)->GetData();
c6e2af45
JS
2283 }
2284 else
2285 return wxACC_FAIL;
2286 }
2287 if (win)
2288 {
2289 rect = win->GetRect();
2290 if (win->GetParent() && !win->IsKindOf(CLASSINFO(wxTopLevelWindow)))
2291 rect.SetPosition(win->GetParent()->ClientToScreen(rect.GetPosition()));
2292 return wxACC_OK;
2293 }
2294
ed5317e5
JS
2295 return wxACC_NOT_IMPLEMENTED;
2296}
2297
2298// Navigates from fromId to toId/toObject.
2299wxAccStatus wxWindowAccessible::Navigate(wxNavDir navDir, int fromId,
66b9ec3d 2300 int* WXUNUSED(toId), wxAccessible** toObject)
ed5317e5
JS
2301{
2302 wxASSERT( GetWindow() != NULL );
2303 if (!GetWindow())
2304 return wxACC_FAIL;
2305
c6e2af45
JS
2306 switch (navDir)
2307 {
2308 case wxNAVDIR_FIRSTCHILD:
2309 {
2310 if (GetWindow()->GetChildren().GetCount() == 0)
2311 return wxACC_FALSE;
2312 wxWindow* childWindow = (wxWindow*) GetWindow()->GetChildren().GetFirst()->GetData();
2313 *toObject = childWindow->GetOrCreateAccessible();
2314
2315 return wxACC_OK;
2316 }
2317 case wxNAVDIR_LASTCHILD:
2318 {
2319 if (GetWindow()->GetChildren().GetCount() == 0)
2320 return wxACC_FALSE;
2321 wxWindow* childWindow = (wxWindow*) GetWindow()->GetChildren().GetLast()->GetData();
2322 *toObject = childWindow->GetOrCreateAccessible();
2323
2324 return wxACC_OK;
2325 }
2326 case wxNAVDIR_RIGHT:
2327 case wxNAVDIR_DOWN:
2328 case wxNAVDIR_NEXT:
2329 {
ee6eb8d8
MB
2330 wxWindowList::compatibility_iterator node =
2331 wxWindowList::compatibility_iterator();
c6e2af45
JS
2332 if (fromId == 0)
2333 {
2334 // Can't navigate to sibling of this window
2335 // if we're a top-level window.
2336 if (!GetWindow()->GetParent())
2337 return wxACC_NOT_IMPLEMENTED;
2338
2339 node = GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2340 }
2341 else
2342 {
2343 if (fromId <= (int) GetWindow()->GetChildren().GetCount())
33b3f7c3 2344 node = GetWindow()->GetChildren().Item(fromId-1);
c6e2af45
JS
2345 }
2346
2347 if (node && node->GetNext())
2348 {
ee6eb8d8 2349 wxWindow* nextWindow = node->GetNext()->GetData();
c6e2af45
JS
2350 *toObject = nextWindow->GetOrCreateAccessible();
2351 return wxACC_OK;
2352 }
2353 else
2354 return wxACC_FALSE;
2355 }
2356 case wxNAVDIR_LEFT:
2357 case wxNAVDIR_UP:
2358 case wxNAVDIR_PREVIOUS:
2359 {
ee6eb8d8
MB
2360 wxWindowList::compatibility_iterator node =
2361 wxWindowList::compatibility_iterator();
c6e2af45
JS
2362 if (fromId == 0)
2363 {
2364 // Can't navigate to sibling of this window
2365 // if we're a top-level window.
2366 if (!GetWindow()->GetParent())
2367 return wxACC_NOT_IMPLEMENTED;
2368
2369 node = GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2370 }
2371 else
2372 {
2373 if (fromId <= (int) GetWindow()->GetChildren().GetCount())
33b3f7c3 2374 node = GetWindow()->GetChildren().Item(fromId-1);
c6e2af45
JS
2375 }
2376
2377 if (node && node->GetPrevious())
2378 {
ee6eb8d8 2379 wxWindow* previousWindow = node->GetPrevious()->GetData();
c6e2af45
JS
2380 *toObject = previousWindow->GetOrCreateAccessible();
2381 return wxACC_OK;
2382 }
2383 else
2384 return wxACC_FALSE;
2385 }
2386 }
2387
ed5317e5
JS
2388 return wxACC_NOT_IMPLEMENTED;
2389}
2390
2391// Gets the name of the specified object.
2392wxAccStatus wxWindowAccessible::GetName(int childId, wxString* name)
2393{
2394 wxASSERT( GetWindow() != NULL );
2395 if (!GetWindow())
2396 return wxACC_FAIL;
2397
2aefc528
JS
2398 wxString title;
2399
2400 // If a child, leave wxWindows to call the function on the actual
2401 // child object.
2402 if (childId > 0)
2403 return wxACC_NOT_IMPLEMENTED;
2404
2405 // This will eventually be replaced by specialised
2406 // accessible classes, one for each kind of wxWindows
2407 // control or window.
2408 if (GetWindow()->IsKindOf(CLASSINFO(wxButton)))
2409 title = ((wxButton*) GetWindow())->GetLabel();
2410 else
2411 title = GetWindow()->GetName();
e11f4636 2412
ed5317e5
JS
2413 if (!title.IsEmpty())
2414 {
2415 *name = title;
2416 return wxACC_OK;
2417 }
2418 else
2419 return wxACC_NOT_IMPLEMENTED;
2420}
2421
2422// Gets the number of children.
2423wxAccStatus wxWindowAccessible::GetChildCount(int* childId)
2424{
2425 wxASSERT( GetWindow() != NULL );
2426 if (!GetWindow())
2427 return wxACC_FAIL;
2428
2429 *childId = (int) GetWindow()->GetChildren().GetCount();
2430 return wxACC_OK;
2431}
2432
2433// Gets the specified child (starting from 1).
2434// If *child is NULL and return value is wxACC_OK,
2435// this means that the child is a simple element and
2436// not an accessible object.
2437wxAccStatus wxWindowAccessible::GetChild(int childId, wxAccessible** child)
2438{
2439 wxASSERT( GetWindow() != NULL );
2440 if (!GetWindow())
2441 return wxACC_FAIL;
2442
2443 if (childId == 0)
2444 {
2445 *child = this;
2446 return wxACC_OK;
2447 }
2448
2449 if (childId > (int) GetWindow()->GetChildren().GetCount())
2450 return wxACC_FAIL;
2451
ee6eb8d8 2452 wxWindow* childWindow = GetWindow()->GetChildren().Item(childId-1)->GetData();
ed5317e5
JS
2453 *child = childWindow->GetOrCreateAccessible();
2454 if (*child)
2455 return wxACC_OK;
2456 else
2457 return wxACC_FAIL;
2458}
2459
2460// Gets the parent, or NULL.
2461wxAccStatus wxWindowAccessible::GetParent(wxAccessible** parent)
2462{
2463 wxASSERT( GetWindow() != NULL );
2464 if (!GetWindow())
2465 return wxACC_FAIL;
2466
2467 wxWindow* parentWindow = GetWindow()->GetParent();
c6e2af45 2468 if (!parentWindow)
ed5317e5
JS
2469 {
2470 *parent = NULL;
2471 return wxACC_OK;
2472 }
2473 else
2474 {
2475 *parent = parentWindow->GetOrCreateAccessible();
2476 if (*parent)
2477 return wxACC_OK;
2478 else
2479 return wxACC_FAIL;
2480 }
2481}
2482
2483// Performs the default action. childId is 0 (the action for this object)
2484// or > 0 (the action for a child).
2485// Return wxACC_NOT_SUPPORTED if there is no default action for this
2486// window (e.g. an edit control).
66b9ec3d 2487wxAccStatus wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId))
ed5317e5
JS
2488{
2489 wxASSERT( GetWindow() != NULL );
2490 if (!GetWindow())
2491 return wxACC_FAIL;
2492
2493 return wxACC_NOT_IMPLEMENTED;
2494}
2495
2496// Gets the default action for this object (0) or > 0 (the action for a child).
2497// Return wxACC_OK even if there is no action. actionName is the action, or the empty
2498// string if there is no action.
2499// The retrieved string describes the action that is performed on an object,
2500// not what the object does as a result. For example, a toolbar button that prints
2501// a document has a default action of "Press" rather than "Prints the current document."
66b9ec3d 2502wxAccStatus wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId), wxString* WXUNUSED(actionName))
ed5317e5
JS
2503{
2504 wxASSERT( GetWindow() != NULL );
2505 if (!GetWindow())
2506 return wxACC_FAIL;
2507
2508 return wxACC_NOT_IMPLEMENTED;
2509}
2510
2511// Returns the description for this object or a child.
66b9ec3d 2512wxAccStatus wxWindowAccessible::GetDescription(int WXUNUSED(childId), wxString* description)
ed5317e5
JS
2513{
2514 wxASSERT( GetWindow() != NULL );
2515 if (!GetWindow())
2516 return wxACC_FAIL;
2517
2aefc528
JS
2518 wxString ht(GetWindow()->GetHelpText());
2519 if (!ht.IsEmpty())
2520 {
2521 *description = ht;
2522 return wxACC_OK;
2523 }
ed5317e5
JS
2524 return wxACC_NOT_IMPLEMENTED;
2525}
2526
2527// Returns help text for this object or a child, similar to tooltip text.
66b9ec3d 2528wxAccStatus wxWindowAccessible::GetHelpText(int WXUNUSED(childId), wxString* helpText)
ed5317e5
JS
2529{
2530 wxASSERT( GetWindow() != NULL );
2531 if (!GetWindow())
2532 return wxACC_FAIL;
2533
2534 wxString ht(GetWindow()->GetHelpText());
2535 if (!ht.IsEmpty())
2536 {
2537 *helpText = ht;
2538 return wxACC_OK;
2539 }
2540 return wxACC_NOT_IMPLEMENTED;
2541}
2542
2543// Returns the keyboard shortcut for this object or child.
2544// Return e.g. ALT+K
66b9ec3d 2545wxAccStatus wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId), wxString* WXUNUSED(shortcut))
ed5317e5
JS
2546{
2547 wxASSERT( GetWindow() != NULL );
2548 if (!GetWindow())
2549 return wxACC_FAIL;
2550
2551 return wxACC_NOT_IMPLEMENTED;
2552}
2553
2554// Returns a role constant.
2555wxAccStatus wxWindowAccessible::GetRole(int childId, wxAccRole* role)
2556{
2557 wxASSERT( GetWindow() != NULL );
2558 if (!GetWindow())
2559 return wxACC_FAIL;
2560
2aefc528
JS
2561 // If a child, leave wxWindows to call the function on the actual
2562 // child object.
2563 if (childId > 0)
2564 return wxACC_NOT_IMPLEMENTED;
2565
2566 if (GetWindow()->IsKindOf(CLASSINFO(wxControl)))
2567 return wxACC_NOT_IMPLEMENTED;
2568#if wxUSE_STATUSBAR
2569 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar)))
2570 return wxACC_NOT_IMPLEMENTED;
2571#endif
2572#if wxUSE_TOOLBAR
2573 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar)))
2574 return wxACC_NOT_IMPLEMENTED;
2575#endif
2576
2577 //*role = wxROLE_SYSTEM_CLIENT;
2578 *role = wxROLE_SYSTEM_CLIENT;
2579 return wxACC_OK;
2580
66b9ec3d 2581 #if 0
ed5317e5 2582 return wxACC_NOT_IMPLEMENTED;
66b9ec3d 2583 #endif
ed5317e5
JS
2584}
2585
2586// Returns a state constant.
2587wxAccStatus wxWindowAccessible::GetState(int childId, long* state)
2588{
2589 wxASSERT( GetWindow() != NULL );
2590 if (!GetWindow())
2591 return wxACC_FAIL;
2592
2aefc528
JS
2593 // If a child, leave wxWindows to call the function on the actual
2594 // child object.
2595 if (childId > 0)
2596 return wxACC_NOT_IMPLEMENTED;
2597
2598 if (GetWindow()->IsKindOf(CLASSINFO(wxControl)))
2599 return wxACC_NOT_IMPLEMENTED;
2600
2601#if wxUSE_STATUSBAR
2602 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar)))
2603 return wxACC_NOT_IMPLEMENTED;
2604#endif
2605#if wxUSE_TOOLBAR
2606 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar)))
2607 return wxACC_NOT_IMPLEMENTED;
2608#endif
2609
2610 *state = 0;
2611 return wxACC_OK;
2612
66b9ec3d 2613 #if 0
ed5317e5 2614 return wxACC_NOT_IMPLEMENTED;
66b9ec3d 2615 #endif
ed5317e5
JS
2616}
2617
2618// Returns a localized string representing the value for the object
2619// or child.
66b9ec3d 2620wxAccStatus wxWindowAccessible::GetValue(int WXUNUSED(childId), wxString* WXUNUSED(strValue))
ed5317e5
JS
2621{
2622 wxASSERT( GetWindow() != NULL );
2623 if (!GetWindow())
2624 return wxACC_FAIL;
2625
2626 return wxACC_NOT_IMPLEMENTED;
2627}
2628
2629// Selects the object or child.
66b9ec3d 2630wxAccStatus wxWindowAccessible::Select(int WXUNUSED(childId), wxAccSelectionFlags WXUNUSED(selectFlags))
ed5317e5
JS
2631{
2632 wxASSERT( GetWindow() != NULL );
2633 if (!GetWindow())
2634 return wxACC_FAIL;
2635
2636 return wxACC_NOT_IMPLEMENTED;
2637}
2638
2639// Gets the window with the keyboard focus.
2640// If childId is 0 and child is NULL, no object in
2641// this subhierarchy has the focus.
2642// If this object has the focus, child should be 'this'.
66b9ec3d 2643wxAccStatus wxWindowAccessible::GetFocus(int* WXUNUSED(childId), wxAccessible** WXUNUSED(child))
ed5317e5
JS
2644{
2645 wxASSERT( GetWindow() != NULL );
2646 if (!GetWindow())
2647 return wxACC_FAIL;
2648
2649 return wxACC_NOT_IMPLEMENTED;
2650}
2651
2652// Gets a variant representing the selected children
2653// of this object.
2654// Acceptable values:
2655// - a null variant (IsNull() returns TRUE)
2656// - a list variant (GetType() == wxT("list")
2657// - an integer representing the selected child element,
2658// or 0 if this object is selected (GetType() == wxT("long")
2659// - a "void*" pointer to a wxAccessible child object
66b9ec3d 2660wxAccStatus wxWindowAccessible::GetSelections(wxVariant* WXUNUSED(selections))
ed5317e5
JS
2661{
2662 wxASSERT( GetWindow() != NULL );
2663 if (!GetWindow())
2664 return wxACC_FAIL;
2665
2666 return wxACC_NOT_IMPLEMENTED;
2667}
2668
2669#endif // wxUSE_ACCESSIBILITY