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