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