1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/window.cpp
3 // Purpose: common (to all ports) wxWindow functions
4 // Author: Julian Smart, Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
28 #include "wx/string.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/msgout.h"
42 #include "wx/statusbr.h"
43 #include "wx/toolbar.h"
44 #include "wx/dcclient.h"
45 #include "wx/scrolbar.h"
46 #include "wx/layout.h"
51 #if wxUSE_DRAG_AND_DROP
53 #endif // wxUSE_DRAG_AND_DROP
55 #if wxUSE_ACCESSIBILITY
56 #include "wx/access.h"
60 #include "wx/cshelp.h"
64 #include "wx/tooltip.h"
65 #endif // wxUSE_TOOLTIPS
71 #if wxUSE_SYSTEM_OPTIONS
72 #include "wx/sysopt.h"
75 #include "wx/platinfo.h"
78 WXDLLIMPEXP_DATA_CORE(wxWindowList
) wxTopLevelWindows
;
82 wxMenu
*wxCurrentPopupMenu
= NULL
;
85 // ----------------------------------------------------------------------------
87 // ----------------------------------------------------------------------------
90 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase
, wxEvtHandler
)
92 // ----------------------------------------------------------------------------
94 // ----------------------------------------------------------------------------
96 BEGIN_EVENT_TABLE(wxWindowBase
, wxEvtHandler
)
97 EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged
)
98 EVT_INIT_DIALOG(wxWindowBase::OnInitDialog
)
99 EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick
)
102 EVT_HELP(wxID_ANY
, wxWindowBase::OnHelp
)
105 EVT_SIZE(wxWindowBase::InternalOnSize
)
108 // ============================================================================
109 // implementation of the common functionality of the wxWindow class
110 // ============================================================================
112 // ----------------------------------------------------------------------------
114 // ----------------------------------------------------------------------------
116 // the default initialization
117 wxWindowBase::wxWindowBase()
119 // no window yet, no parent nor children
121 m_windowId
= wxID_ANY
;
123 // no constraints on the minimal window size
125 m_maxWidth
= wxDefaultCoord
;
127 m_maxHeight
= wxDefaultCoord
;
129 // invalidiated cache value
130 m_bestSizeCache
= wxDefaultSize
;
132 // window are created enabled and visible by default
136 // the default event handler is just this window
137 m_eventHandler
= this;
141 m_windowValidator
= NULL
;
142 #endif // wxUSE_VALIDATORS
144 // the colours/fonts are default for now, so leave m_font,
145 // m_backgroundColour and m_foregroundColour uninitialized and set those
151 m_inheritFont
= false;
157 m_backgroundStyle
= wxBG_STYLE_ERASE
;
159 #if wxUSE_CONSTRAINTS
160 // no constraints whatsoever
161 m_constraints
= NULL
;
162 m_constraintsInvolvedIn
= NULL
;
163 #endif // wxUSE_CONSTRAINTS
165 m_windowSizer
= NULL
;
166 m_containingSizer
= NULL
;
167 m_autoLayout
= false;
169 #if wxUSE_DRAG_AND_DROP
171 #endif // wxUSE_DRAG_AND_DROP
175 #endif // wxUSE_TOOLTIPS
179 #endif // wxUSE_CARET
182 m_hasCustomPalette
= false;
183 #endif // wxUSE_PALETTE
185 #if wxUSE_ACCESSIBILITY
189 m_virtualSize
= wxDefaultSize
;
191 m_scrollHelper
= NULL
;
193 m_windowVariant
= wxWINDOW_VARIANT_NORMAL
;
194 #if wxUSE_SYSTEM_OPTIONS
195 if ( wxSystemOptions::HasOption(wxWINDOW_DEFAULT_VARIANT
) )
197 m_windowVariant
= (wxWindowVariant
) wxSystemOptions::GetOptionInt( wxWINDOW_DEFAULT_VARIANT
) ;
201 // Whether we're using the current theme for this window (wxGTK only for now)
202 m_themeEnabled
= false;
204 // This is set to true by SendDestroyEvent() which should be called by the
205 // most derived class to ensure that the destruction event is sent as soon
206 // as possible to allow its handlers to still see the undestroyed window
207 m_isBeingDeleted
= false;
212 // common part of window creation process
213 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
215 const wxPoint
& WXUNUSED(pos
),
216 const wxSize
& WXUNUSED(size
),
218 const wxValidator
& wxVALIDATOR_PARAM(validator
),
219 const wxString
& name
)
221 // ids are limited to 16 bits under MSW so if you care about portability,
222 // it's not a good idea to use ids out of this range (and negative ids are
223 // reserved for wxWidgets own usage)
224 wxASSERT_MSG( id
== wxID_ANY
|| (id
>= 0 && id
< 32767) ||
225 (id
>= wxID_AUTO_LOWEST
&& id
<= wxID_AUTO_HIGHEST
),
226 wxT("invalid id value") );
228 // generate a new id if the user doesn't care about it
229 if ( id
== wxID_ANY
)
231 m_windowId
= NewControlId();
233 else // valid id specified
238 // don't use SetWindowStyleFlag() here, this function should only be called
239 // to change the flag after creation as it tries to reflect the changes in
240 // flags by updating the window dynamically and we don't need this here
241 m_windowStyle
= style
;
247 SetValidator(validator
);
248 #endif // wxUSE_VALIDATORS
250 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
251 // have it too - like this it's possible to set it only in the top level
252 // dialog/frame and all children will inherit it by defult
253 if ( parent
&& (parent
->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) )
255 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY
);
261 bool wxWindowBase::ToggleWindowStyle(int flag
)
263 wxASSERT_MSG( flag
, wxT("flags with 0 value can't be toggled") );
266 long style
= GetWindowStyleFlag();
272 else // currently off
278 SetWindowStyleFlag(style
);
283 // ----------------------------------------------------------------------------
285 // ----------------------------------------------------------------------------
288 wxWindowBase::~wxWindowBase()
290 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
292 // FIXME if these 2 cases result from programming errors in the user code
293 // we should probably assert here instead of silently fixing them
295 // Just in case the window has been Closed, but we're then deleting
296 // immediately: don't leave dangling pointers.
297 wxPendingDelete
.DeleteObject(this);
299 // Just in case we've loaded a top-level window via LoadNativeDialog but
300 // we weren't a dialog class
301 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
304 // The associated popup menu can still be alive, disassociate from it in
306 if ( wxCurrentPopupMenu
&& wxCurrentPopupMenu
->GetInvokingWindow() == this )
307 wxCurrentPopupMenu
->SetInvokingWindow(NULL
);
308 #endif // wxUSE_MENUS
310 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
312 // notify the parent about this window destruction
314 m_parent
->RemoveChild(this);
318 #endif // wxUSE_CARET
321 delete m_windowValidator
;
322 #endif // wxUSE_VALIDATORS
324 #if wxUSE_CONSTRAINTS
325 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
326 // at deleted windows as they delete themselves.
327 DeleteRelatedConstraints();
331 // This removes any dangling pointers to this window in other windows'
332 // constraintsInvolvedIn lists.
333 UnsetConstraints(m_constraints
);
334 delete m_constraints
;
335 m_constraints
= NULL
;
337 #endif // wxUSE_CONSTRAINTS
339 if ( m_containingSizer
)
340 m_containingSizer
->Detach( (wxWindow
*)this );
342 delete m_windowSizer
;
344 #if wxUSE_DRAG_AND_DROP
346 #endif // wxUSE_DRAG_AND_DROP
350 #endif // wxUSE_TOOLTIPS
352 #if wxUSE_ACCESSIBILITY
357 // NB: this has to be called unconditionally, because we don't know
358 // whether this window has associated help text or not
359 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
361 helpProvider
->RemoveHelp(this);
365 bool wxWindowBase::IsBeingDeleted() const
367 return m_isBeingDeleted
||
368 (!IsTopLevel() && m_parent
&& m_parent
->IsBeingDeleted());
371 void wxWindowBase::SendDestroyEvent()
373 if ( m_isBeingDeleted
)
375 // we could have been already called from a more derived class dtor,
376 // e.g. ~wxTLW calls us and so does ~wxWindow and the latter call
377 // should be simply ignored
381 m_isBeingDeleted
= true;
383 wxWindowDestroyEvent event
;
384 event
.SetEventObject(this);
385 event
.SetId(GetId());
386 GetEventHandler()->ProcessEvent(event
);
389 bool wxWindowBase::Destroy()
398 bool wxWindowBase::Close(bool force
)
400 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
401 event
.SetEventObject(this);
402 event
.SetCanVeto(!force
);
404 // return false if window wasn't closed because the application vetoed the
406 return HandleWindowEvent(event
) && !event
.GetVeto();
409 bool wxWindowBase::DestroyChildren()
411 wxWindowList::compatibility_iterator node
;
414 // we iterate until the list becomes empty
415 node
= GetChildren().GetFirst();
419 wxWindow
*child
= node
->GetData();
421 // note that we really want to delete it immediately so don't call the
422 // possible overridden Destroy() version which might not delete the
423 // child immediately resulting in problems with our (top level) child
424 // outliving its parent
425 child
->wxWindowBase::Destroy();
427 wxASSERT_MSG( !GetChildren().Find(child
),
428 wxT("child didn't remove itself using RemoveChild()") );
434 // ----------------------------------------------------------------------------
435 // size/position related methods
436 // ----------------------------------------------------------------------------
438 // centre the window with respect to its parent in either (or both) directions
439 void wxWindowBase::DoCentre(int dir
)
441 wxCHECK_RET( !(dir
& wxCENTRE_ON_SCREEN
) && GetParent(),
442 wxT("this method only implements centering child windows") );
444 SetSize(GetRect().CentreIn(GetParent()->GetClientSize(), dir
));
447 // fits the window around the children
448 void wxWindowBase::Fit()
450 if ( !GetChildren().empty() )
452 SetSize(GetBestSize());
454 //else: do nothing if we have no children
457 // fits virtual size (ie. scrolled area etc.) around children
458 void wxWindowBase::FitInside()
460 if ( GetChildren().GetCount() > 0 )
462 SetVirtualSize( GetBestVirtualSize() );
466 // On Mac, scrollbars are explicitly children.
467 #if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__)
468 static bool wxHasRealChildren(const wxWindowBase
* win
)
470 int realChildCount
= 0;
472 for ( wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
474 node
= node
->GetNext() )
476 wxWindow
*win
= node
->GetData();
477 if ( !win
->IsTopLevel() && win
->IsShown()
479 && !win
->IsKindOf(CLASSINFO(wxScrollBar
))
484 return (realChildCount
> 0);
488 void wxWindowBase::InvalidateBestSize()
490 m_bestSizeCache
= wxDefaultSize
;
492 // parent's best size calculation may depend on its children's
493 // as long as child window we are in is not top level window itself
494 // (because the TLW size is never resized automatically)
495 // so let's invalidate it as well to be safe:
496 if (m_parent
&& !IsTopLevel())
497 m_parent
->InvalidateBestSize();
500 // return the size best suited for the current window
501 wxSize
wxWindowBase::DoGetBestSize() const
507 best
= m_windowSizer
->GetMinSize();
509 #if wxUSE_CONSTRAINTS
510 else if ( m_constraints
)
512 wxConstCast(this, wxWindowBase
)->SatisfyConstraints();
514 // our minimal acceptable size is such that all our windows fit inside
518 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
520 node
= node
->GetNext() )
522 wxLayoutConstraints
*c
= node
->GetData()->GetConstraints();
525 // it's not normal that we have an unconstrained child, but
526 // what can we do about it?
530 int x
= c
->right
.GetValue(),
531 y
= c
->bottom
.GetValue();
539 // TODO: we must calculate the overlaps somehow, otherwise we
540 // will never return a size bigger than the current one :-(
543 best
= wxSize(maxX
, maxY
);
545 #endif // wxUSE_CONSTRAINTS
546 else if ( !GetChildren().empty()
547 #if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__)
548 && wxHasRealChildren(this)
552 // our minimal acceptable size is such that all our visible child
553 // windows fit inside
557 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
559 node
= node
->GetNext() )
561 wxWindow
*win
= node
->GetData();
562 if ( win
->IsTopLevel()
565 || wxDynamicCast(win
, wxStatusBar
)
566 #endif // wxUSE_STATUSBAR
569 // dialogs and frames lie in different top level windows -
570 // don't deal with them here; as for the status bars, they
571 // don't lie in the client area at all
576 win
->GetPosition(&wx
, &wy
);
578 // if the window hadn't been positioned yet, assume that it is in
580 if ( wx
== wxDefaultCoord
)
582 if ( wy
== wxDefaultCoord
)
585 win
->GetSize(&ww
, &wh
);
586 if ( wx
+ ww
> maxX
)
588 if ( wy
+ wh
> maxY
)
592 best
= wxSize(maxX
, maxY
);
594 else // ! has children
596 // for a generic window there is no natural best size so, if the
597 // minimal size is not set, use the current size but take care to
598 // remember it as minimal size for the next time because our best size
599 // should be constant: otherwise we could get into a situation when the
600 // window is initially at some size, then expanded to a larger size and
601 // then, when the containing window is shrunk back (because our initial
602 // best size had been used for computing the parent min size), we can't
603 // be shrunk back any more because our best size is now bigger
604 wxSize size
= GetMinSize();
605 if ( !size
.IsFullySpecified() )
607 size
.SetDefaults(GetSize());
608 wxConstCast(this, wxWindowBase
)->SetMinSize(size
);
611 // return as-is, unadjusted by the client size difference.
615 // Add any difference between size and client size
616 wxSize diff
= GetSize() - GetClientSize();
617 best
.x
+= wxMax(0, diff
.x
);
618 best
.y
+= wxMax(0, diff
.y
);
623 // helper of GetWindowBorderSize(): as many ports don't implement support for
624 // wxSYS_BORDER/EDGE_X/Y metrics in their wxSystemSettings, use hard coded
625 // fallbacks in this case
626 static int wxGetMetricOrDefault(wxSystemMetric what
, const wxWindowBase
* win
)
628 int rc
= wxSystemSettings::GetMetric(
629 what
, static_cast<wxWindow
*>(const_cast<wxWindowBase
*>(win
)));
636 // 2D border is by default 1 pixel wide
642 // 3D borders are by default 2 pixels
647 wxFAIL_MSG( wxT("unexpected wxGetMetricOrDefault() argument") );
655 wxSize
wxWindowBase::GetWindowBorderSize() const
659 switch ( GetBorder() )
662 // nothing to do, size is already (0, 0)
665 case wxBORDER_SIMPLE
:
666 case wxBORDER_STATIC
:
667 size
.x
= wxGetMetricOrDefault(wxSYS_BORDER_X
, this);
668 size
.y
= wxGetMetricOrDefault(wxSYS_BORDER_Y
, this);
671 case wxBORDER_SUNKEN
:
672 case wxBORDER_RAISED
:
673 size
.x
= wxMax(wxGetMetricOrDefault(wxSYS_EDGE_X
, this),
674 wxGetMetricOrDefault(wxSYS_BORDER_X
, this));
675 size
.y
= wxMax(wxGetMetricOrDefault(wxSYS_EDGE_Y
, this),
676 wxGetMetricOrDefault(wxSYS_BORDER_Y
, this));
679 case wxBORDER_DOUBLE
:
680 size
.x
= wxGetMetricOrDefault(wxSYS_EDGE_X
, this) +
681 wxGetMetricOrDefault(wxSYS_BORDER_X
, this);
682 size
.y
= wxGetMetricOrDefault(wxSYS_EDGE_Y
, this) +
683 wxGetMetricOrDefault(wxSYS_BORDER_Y
, this);
687 wxFAIL_MSG(wxT("Unknown border style."));
691 // we have borders on both sides
695 wxSize
wxWindowBase::GetEffectiveMinSize() const
697 // merge the best size with the min size, giving priority to the min size
698 wxSize min
= GetMinSize();
700 if (min
.x
== wxDefaultCoord
|| min
.y
== wxDefaultCoord
)
702 wxSize best
= GetBestSize();
703 if (min
.x
== wxDefaultCoord
) min
.x
= best
.x
;
704 if (min
.y
== wxDefaultCoord
) min
.y
= best
.y
;
710 wxSize
wxWindowBase::GetBestSize() const
712 if ( !m_windowSizer
&& m_bestSizeCache
.IsFullySpecified() )
713 return m_bestSizeCache
;
715 // call DoGetBestClientSize() first, if a derived class overrides it wants
717 wxSize size
= DoGetBestClientSize();
718 if ( size
!= wxDefaultSize
)
720 size
+= DoGetBorderSize();
726 return DoGetBestSize();
729 void wxWindowBase::SetMinSize(const wxSize
& minSize
)
731 m_minWidth
= minSize
.x
;
732 m_minHeight
= minSize
.y
;
735 void wxWindowBase::SetMaxSize(const wxSize
& maxSize
)
737 m_maxWidth
= maxSize
.x
;
738 m_maxHeight
= maxSize
.y
;
741 void wxWindowBase::SetInitialSize(const wxSize
& size
)
743 // Set the min size to the size passed in. This will usually either be
744 // wxDefaultSize or the size passed to this window's ctor/Create function.
747 // Merge the size with the best size if needed
748 wxSize best
= GetEffectiveMinSize();
750 // If the current size doesn't match then change it
751 if (GetSize() != best
)
756 // by default the origin is not shifted
757 wxPoint
wxWindowBase::GetClientAreaOrigin() const
762 wxSize
wxWindowBase::ClientToWindowSize(const wxSize
& size
) const
764 const wxSize
diff(GetSize() - GetClientSize());
766 return wxSize(size
.x
== -1 ? -1 : size
.x
+ diff
.x
,
767 size
.y
== -1 ? -1 : size
.y
+ diff
.y
);
770 wxSize
wxWindowBase::WindowToClientSize(const wxSize
& size
) const
772 const wxSize
diff(GetSize() - GetClientSize());
774 return wxSize(size
.x
== -1 ? -1 : size
.x
- diff
.x
,
775 size
.y
== -1 ? -1 : size
.y
- diff
.y
);
778 void wxWindowBase::SetWindowVariant( wxWindowVariant variant
)
780 if ( m_windowVariant
!= variant
)
782 m_windowVariant
= variant
;
784 DoSetWindowVariant(variant
);
788 void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant
)
790 // adjust the font height to correspond to our new variant (notice that
791 // we're only called if something really changed)
792 wxFont font
= GetFont();
793 int size
= font
.GetPointSize();
796 case wxWINDOW_VARIANT_NORMAL
:
799 case wxWINDOW_VARIANT_SMALL
:
804 case wxWINDOW_VARIANT_MINI
:
809 case wxWINDOW_VARIANT_LARGE
:
815 wxFAIL_MSG(wxT("unexpected window variant"));
819 font
.SetPointSize(size
);
823 void wxWindowBase::DoSetSizeHints( int minW
, int minH
,
825 int WXUNUSED(incW
), int WXUNUSED(incH
) )
827 wxCHECK_RET( (minW
== wxDefaultCoord
|| maxW
== wxDefaultCoord
|| minW
<= maxW
) &&
828 (minH
== wxDefaultCoord
|| maxH
== wxDefaultCoord
|| minH
<= maxH
),
829 wxT("min width/height must be less than max width/height!") );
838 #if WXWIN_COMPATIBILITY_2_8
839 void wxWindowBase::SetVirtualSizeHints(int WXUNUSED(minW
), int WXUNUSED(minH
),
840 int WXUNUSED(maxW
), int WXUNUSED(maxH
))
844 void wxWindowBase::SetVirtualSizeHints(const wxSize
& WXUNUSED(minsize
),
845 const wxSize
& WXUNUSED(maxsize
))
848 #endif // WXWIN_COMPATIBILITY_2_8
850 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
852 m_virtualSize
= wxSize(x
, y
);
855 wxSize
wxWindowBase::DoGetVirtualSize() const
857 // we should use the entire client area so if it is greater than our
858 // virtual size, expand it to fit (otherwise if the window is big enough we
859 // wouldn't be using parts of it)
860 wxSize size
= GetClientSize();
861 if ( m_virtualSize
.x
> size
.x
)
862 size
.x
= m_virtualSize
.x
;
864 if ( m_virtualSize
.y
>= size
.y
)
865 size
.y
= m_virtualSize
.y
;
870 void wxWindowBase::DoGetScreenPosition(int *x
, int *y
) const
872 // screen position is the same as (0, 0) in client coords for non TLWs (and
873 // TLWs override this method)
879 ClientToScreen(x
, y
);
882 void wxWindowBase::SendSizeEvent(int flags
)
884 wxSizeEvent
event(GetSize(), GetId());
885 event
.SetEventObject(this);
886 if ( flags
& wxSEND_EVENT_POST
)
887 wxPostEvent(this, event
);
889 HandleWindowEvent(event
);
892 void wxWindowBase::SendSizeEventToParent(int flags
)
894 wxWindow
* const parent
= GetParent();
895 if ( parent
&& !parent
->IsBeingDeleted() )
896 parent
->SendSizeEvent(flags
);
899 // ----------------------------------------------------------------------------
900 // show/hide/enable/disable the window
901 // ----------------------------------------------------------------------------
903 bool wxWindowBase::Show(bool show
)
905 if ( show
!= m_isShown
)
917 bool wxWindowBase::IsEnabled() const
919 return IsThisEnabled() && (IsTopLevel() || !GetParent() || GetParent()->IsEnabled());
922 void wxWindowBase::NotifyWindowOnEnableChange(bool enabled
)
924 #ifndef wxHAS_NATIVE_ENABLED_MANAGEMENT
926 #endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
930 // If we are top-level then the logic doesn't apply - otherwise
931 // showing a modal dialog would result in total greying out (and ungreying
932 // out later) of everything which would be really ugly
936 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
938 node
= node
->GetNext() )
940 wxWindowBase
* const child
= node
->GetData();
941 if ( !child
->IsTopLevel() && child
->IsThisEnabled() )
942 child
->NotifyWindowOnEnableChange(enabled
);
946 bool wxWindowBase::Enable(bool enable
)
948 if ( enable
== IsThisEnabled() )
951 m_isEnabled
= enable
;
953 #ifdef wxHAS_NATIVE_ENABLED_MANAGEMENT
955 #else // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
956 wxWindowBase
* const parent
= GetParent();
957 if( !IsTopLevel() && parent
&& !parent
->IsEnabled() )
961 #endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
963 NotifyWindowOnEnableChange(enable
);
968 bool wxWindowBase::IsShownOnScreen() const
970 // A window is shown on screen if it itself is shown and so are all its
971 // parents. But if a window is toplevel one, then its always visible on
972 // screen if IsShown() returns true, even if it has a hidden parent.
974 (IsTopLevel() || GetParent() == NULL
|| GetParent()->IsShownOnScreen());
977 // ----------------------------------------------------------------------------
979 // ----------------------------------------------------------------------------
981 bool wxWindowBase::IsTopLevel() const
986 // ----------------------------------------------------------------------------
988 // ----------------------------------------------------------------------------
990 void wxWindowBase::Freeze()
992 if ( !m_freezeCount
++ )
994 // physically freeze this window:
997 // and recursively freeze all children:
998 for ( wxWindowList::iterator i
= GetChildren().begin();
999 i
!= GetChildren().end(); ++i
)
1001 wxWindow
*child
= *i
;
1002 if ( child
->IsTopLevel() )
1010 void wxWindowBase::Thaw()
1012 wxASSERT_MSG( m_freezeCount
, "Thaw() without matching Freeze()" );
1014 if ( !--m_freezeCount
)
1016 // recursively thaw all children:
1017 for ( wxWindowList::iterator i
= GetChildren().begin();
1018 i
!= GetChildren().end(); ++i
)
1020 wxWindow
*child
= *i
;
1021 if ( child
->IsTopLevel() )
1027 // physically thaw this window:
1032 // ----------------------------------------------------------------------------
1033 // reparenting the window
1034 // ----------------------------------------------------------------------------
1036 void wxWindowBase::AddChild(wxWindowBase
*child
)
1038 wxCHECK_RET( child
, wxT("can't add a NULL child") );
1040 // this should never happen and it will lead to a crash later if it does
1041 // because RemoveChild() will remove only one node from the children list
1042 // and the other(s) one(s) will be left with dangling pointers in them
1043 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), wxT("AddChild() called twice") );
1045 GetChildren().Append((wxWindow
*)child
);
1046 child
->SetParent(this);
1048 // adding a child while frozen will assert when thawed, so freeze it as if
1049 // it had been already present when we were frozen
1050 if ( IsFrozen() && !child
->IsTopLevel() )
1054 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
1056 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
1058 // removing a child while frozen may result in permanently frozen window
1059 // if used e.g. from Reparent(), so thaw it
1061 // NB: IsTopLevel() doesn't return true any more when a TLW child is being
1062 // removed from its ~wxWindowBase, so check for IsBeingDeleted() too
1063 if ( IsFrozen() && !child
->IsBeingDeleted() && !child
->IsTopLevel() )
1066 GetChildren().DeleteObject((wxWindow
*)child
);
1067 child
->SetParent(NULL
);
1070 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
1072 wxWindow
*oldParent
= GetParent();
1073 if ( newParent
== oldParent
)
1079 const bool oldEnabledState
= IsEnabled();
1081 // unlink this window from the existing parent.
1084 oldParent
->RemoveChild(this);
1088 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
1091 // add it to the new one
1094 newParent
->AddChild(this);
1098 wxTopLevelWindows
.Append((wxWindow
*)this);
1101 // We need to notify window (and its subwindows) if by changing the parent
1102 // we also change our enabled/disabled status.
1103 const bool newEnabledState
= IsEnabled();
1104 if ( newEnabledState
!= oldEnabledState
)
1106 NotifyWindowOnEnableChange(newEnabledState
);
1112 // ----------------------------------------------------------------------------
1113 // event handler stuff
1114 // ----------------------------------------------------------------------------
1116 void wxWindowBase::SetEventHandler(wxEvtHandler
*handler
)
1118 wxCHECK_RET(handler
!= NULL
, "SetEventHandler(NULL) called");
1120 m_eventHandler
= handler
;
1123 void wxWindowBase::SetNextHandler(wxEvtHandler
*WXUNUSED(handler
))
1125 // disable wxEvtHandler chain mechanism for wxWindows:
1126 // wxWindow uses its own stack mechanism which doesn't mix well with wxEvtHandler's one
1128 wxFAIL_MSG("wxWindow cannot be part of a wxEvtHandler chain");
1130 void wxWindowBase::SetPreviousHandler(wxEvtHandler
*WXUNUSED(handler
))
1132 // we can't simply wxFAIL here as in SetNextHandler: in fact the last
1133 // handler of our stack when is destroyed will be Unlink()ed and thus
1134 // will call this function to update the pointer of this window...
1136 //wxFAIL_MSG("wxWindow cannot be part of a wxEvtHandler chain");
1139 void wxWindowBase::PushEventHandler(wxEvtHandler
*handlerToPush
)
1141 wxCHECK_RET( handlerToPush
!= NULL
, "PushEventHandler(NULL) called" );
1143 // the new handler is going to be part of the wxWindow stack of event handlers:
1144 // it can't be part also of an event handler double-linked chain:
1145 wxASSERT_MSG(handlerToPush
->IsUnlinked(),
1146 "The handler being pushed in the wxWindow stack shouldn't be part of "
1147 "a wxEvtHandler chain; call Unlink() on it first");
1149 wxEvtHandler
*handlerOld
= GetEventHandler();
1150 wxCHECK_RET( handlerOld
, "an old event handler is NULL?" );
1152 // now use wxEvtHandler double-linked list to implement a stack:
1153 handlerToPush
->SetNextHandler(handlerOld
);
1155 if (handlerOld
!= this)
1156 handlerOld
->SetPreviousHandler(handlerToPush
);
1158 SetEventHandler(handlerToPush
);
1161 // final checks of the operations done above:
1162 wxASSERT_MSG( handlerToPush
->GetPreviousHandler() == NULL
,
1163 "the first handler of the wxWindow stack should "
1164 "have no previous handlers set" );
1165 wxASSERT_MSG( handlerToPush
->GetNextHandler() != NULL
,
1166 "the first handler of the wxWindow stack should "
1167 "have non-NULL next handler" );
1169 wxEvtHandler
* pLast
= handlerToPush
;
1170 while ( pLast
&& pLast
!= this )
1171 pLast
= pLast
->GetNextHandler();
1172 wxASSERT_MSG( pLast
->GetNextHandler() == NULL
,
1173 "the last handler of the wxWindow stack should "
1174 "have this window as next handler" );
1175 #endif // wxDEBUG_LEVEL
1178 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
1180 // we need to pop the wxWindow stack, i.e. we need to remove the first handler
1182 wxEvtHandler
*firstHandler
= GetEventHandler();
1183 wxCHECK_MSG( firstHandler
!= NULL
, NULL
, "wxWindow cannot have a NULL event handler" );
1184 wxCHECK_MSG( firstHandler
!= this, NULL
, "cannot pop the wxWindow itself" );
1185 wxCHECK_MSG( firstHandler
->GetPreviousHandler() == NULL
, NULL
,
1186 "the first handler of the wxWindow stack should have no previous handlers set" );
1188 wxEvtHandler
*secondHandler
= firstHandler
->GetNextHandler();
1189 wxCHECK_MSG( secondHandler
!= NULL
, NULL
,
1190 "the first handler of the wxWindow stack should have non-NULL next handler" );
1192 firstHandler
->SetNextHandler(NULL
);
1193 secondHandler
->SetPreviousHandler(NULL
);
1195 // now firstHandler is completely unlinked; set secondHandler as the new window event handler
1196 SetEventHandler(secondHandler
);
1198 if ( deleteHandler
)
1200 delete firstHandler
;
1201 firstHandler
= NULL
;
1204 return firstHandler
;
1207 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handlerToRemove
)
1209 wxCHECK_MSG( handlerToRemove
!= NULL
, false, "RemoveEventHandler(NULL) called" );
1210 wxCHECK_MSG( handlerToRemove
!= this, false, "Cannot remove the window itself" );
1212 if (handlerToRemove
== GetEventHandler())
1214 // removing the first event handler is equivalent to "popping" the stack
1215 PopEventHandler(false);
1219 // NOTE: the wxWindow event handler list is always terminated with "this" handler
1220 wxEvtHandler
*handlerCur
= GetEventHandler()->GetNextHandler();
1221 while ( handlerCur
!= this )
1223 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
1225 if ( handlerCur
== handlerToRemove
)
1227 handlerCur
->Unlink();
1229 wxASSERT_MSG( handlerCur
!= GetEventHandler(),
1230 "the case Remove == Pop should was already handled" );
1234 handlerCur
= handlerNext
;
1237 wxFAIL_MSG( wxT("where has the event handler gone?") );
1242 bool wxWindowBase::HandleWindowEvent(wxEvent
& event
) const
1244 // SafelyProcessEvent() will handle exceptions nicely
1245 return GetEventHandler()->SafelyProcessEvent(event
);
1248 // ----------------------------------------------------------------------------
1249 // colours, fonts &c
1250 // ----------------------------------------------------------------------------
1252 void wxWindowBase::InheritAttributes()
1254 const wxWindowBase
* const parent
= GetParent();
1258 // we only inherit attributes which had been explicitly set for the parent
1259 // which ensures that this only happens if the user really wants it and
1260 // not by default which wouldn't make any sense in modern GUIs where the
1261 // controls don't all use the same fonts (nor colours)
1262 if ( parent
->m_inheritFont
&& !m_hasFont
)
1263 SetFont(parent
->GetFont());
1265 // in addition, there is a possibility to explicitly forbid inheriting
1266 // colours at each class level by overriding ShouldInheritColours()
1267 if ( ShouldInheritColours() )
1269 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
1270 SetForegroundColour(parent
->GetForegroundColour());
1272 // inheriting (solid) background colour is wrong as it totally breaks
1273 // any kind of themed backgrounds
1275 // instead, the controls should use the same background as their parent
1276 // (ideally by not drawing it at all)
1278 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
1279 SetBackgroundColour(parent
->GetBackgroundColour());
1284 /* static */ wxVisualAttributes
1285 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
1287 // it is important to return valid values for all attributes from here,
1288 // GetXXX() below rely on this
1289 wxVisualAttributes attrs
;
1290 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
1291 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
1293 // On Smartphone/PocketPC, wxSYS_COLOUR_WINDOW is a better reflection of
1294 // the usual background colour than wxSYS_COLOUR_BTNFACE.
1295 // It's a pity that wxSYS_COLOUR_WINDOW isn't always a suitable background
1296 // colour on other platforms.
1298 #if defined(__WXWINCE__) && (defined(__SMARTPHONE__) || defined(__POCKETPC__))
1299 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1301 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
1306 wxColour
wxWindowBase::GetBackgroundColour() const
1308 if ( !m_backgroundColour
.IsOk() )
1310 wxASSERT_MSG( !m_hasBgCol
, wxT("we have invalid explicit bg colour?") );
1312 // get our default background colour
1313 wxColour colBg
= GetDefaultAttributes().colBg
;
1315 // we must return some valid colour to avoid redoing this every time
1316 // and also to avoid surprizing the applications written for older
1317 // wxWidgets versions where GetBackgroundColour() always returned
1318 // something -- so give them something even if it doesn't make sense
1319 // for this window (e.g. it has a themed background)
1321 colBg
= GetClassDefaultAttributes().colBg
;
1326 return m_backgroundColour
;
1329 wxColour
wxWindowBase::GetForegroundColour() const
1331 // logic is the same as above
1332 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
1334 wxColour colFg
= GetDefaultAttributes().colFg
;
1336 if ( !colFg
.IsOk() )
1337 colFg
= GetClassDefaultAttributes().colFg
;
1342 return m_foregroundColour
;
1345 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
1347 if ( colour
== m_backgroundColour
)
1350 m_hasBgCol
= colour
.IsOk();
1352 m_inheritBgCol
= m_hasBgCol
;
1353 m_backgroundColour
= colour
;
1354 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1358 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1360 if (colour
== m_foregroundColour
)
1363 m_hasFgCol
= colour
.IsOk();
1364 m_inheritFgCol
= m_hasFgCol
;
1365 m_foregroundColour
= colour
;
1366 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1370 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1372 // setting an invalid cursor is ok, it means that we don't have any special
1374 if ( m_cursor
.IsSameAs(cursor
) )
1385 wxFont
wxWindowBase::GetFont() const
1387 // logic is the same as in GetBackgroundColour()
1388 if ( !m_font
.IsOk() )
1390 wxASSERT_MSG( !m_hasFont
, wxT("we have invalid explicit font?") );
1392 wxFont font
= GetDefaultAttributes().font
;
1394 font
= GetClassDefaultAttributes().font
;
1402 bool wxWindowBase::SetFont(const wxFont
& font
)
1404 if ( font
== m_font
)
1411 m_hasFont
= font
.IsOk();
1412 m_inheritFont
= m_hasFont
;
1414 InvalidateBestSize();
1421 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1423 m_hasCustomPalette
= true;
1426 // VZ: can anyone explain me what do we do here?
1427 wxWindowDC
d((wxWindow
*) this);
1431 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1433 wxWindow
*win
= (wxWindow
*)this;
1434 while ( win
&& !win
->HasCustomPalette() )
1436 win
= win
->GetParent();
1442 #endif // wxUSE_PALETTE
1445 void wxWindowBase::SetCaret(wxCaret
*caret
)
1456 wxASSERT_MSG( m_caret
->GetWindow() == this,
1457 wxT("caret should be created associated to this window") );
1460 #endif // wxUSE_CARET
1462 #if wxUSE_VALIDATORS
1463 // ----------------------------------------------------------------------------
1465 // ----------------------------------------------------------------------------
1467 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1469 if ( m_windowValidator
)
1470 delete m_windowValidator
;
1472 m_windowValidator
= (wxValidator
*)validator
.Clone();
1474 if ( m_windowValidator
)
1475 m_windowValidator
->SetWindow(this);
1477 #endif // wxUSE_VALIDATORS
1479 // ----------------------------------------------------------------------------
1480 // update region stuff
1481 // ----------------------------------------------------------------------------
1483 wxRect
wxWindowBase::GetUpdateClientRect() const
1485 wxRegion rgnUpdate
= GetUpdateRegion();
1486 rgnUpdate
.Intersect(GetClientRect());
1487 wxRect rectUpdate
= rgnUpdate
.GetBox();
1488 wxPoint ptOrigin
= GetClientAreaOrigin();
1489 rectUpdate
.x
-= ptOrigin
.x
;
1490 rectUpdate
.y
-= ptOrigin
.y
;
1495 bool wxWindowBase::DoIsExposed(int x
, int y
) const
1497 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1500 bool wxWindowBase::DoIsExposed(int x
, int y
, int w
, int h
) const
1502 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1505 void wxWindowBase::ClearBackground()
1507 // wxGTK uses its own version, no need to add never used code
1509 wxClientDC
dc((wxWindow
*)this);
1510 wxBrush
brush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID
);
1511 dc
.SetBackground(brush
);
1516 // ----------------------------------------------------------------------------
1517 // find child window by id or name
1518 // ----------------------------------------------------------------------------
1520 wxWindow
*wxWindowBase::FindWindow(long id
) const
1522 if ( id
== m_windowId
)
1523 return (wxWindow
*)this;
1525 wxWindowBase
*res
= NULL
;
1526 wxWindowList::compatibility_iterator node
;
1527 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1529 wxWindowBase
*child
= node
->GetData();
1530 res
= child
->FindWindow( id
);
1533 return (wxWindow
*)res
;
1536 wxWindow
*wxWindowBase::FindWindow(const wxString
& name
) const
1538 if ( name
== m_windowName
)
1539 return (wxWindow
*)this;
1541 wxWindowBase
*res
= NULL
;
1542 wxWindowList::compatibility_iterator node
;
1543 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1545 wxWindow
*child
= node
->GetData();
1546 res
= child
->FindWindow(name
);
1549 return (wxWindow
*)res
;
1553 // find any window by id or name or label: If parent is non-NULL, look through
1554 // children for a label or title matching the specified string. If NULL, look
1555 // through all top-level windows.
1557 // to avoid duplicating code we reuse the same helper function but with
1558 // different comparators
1560 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1561 const wxString
& label
, long id
);
1564 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1567 return win
->GetLabel() == label
;
1571 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1574 return win
->GetName() == label
;
1578 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1581 return win
->GetId() == id
;
1584 // recursive helper for the FindWindowByXXX() functions
1586 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1587 const wxString
& label
,
1589 wxFindWindowCmp cmp
)
1593 // see if this is the one we're looking for
1594 if ( (*cmp
)(parent
, label
, id
) )
1595 return (wxWindow
*)parent
;
1597 // It wasn't, so check all its children
1598 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1600 node
= node
->GetNext() )
1602 // recursively check each child
1603 wxWindow
*win
= (wxWindow
*)node
->GetData();
1604 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1614 // helper for FindWindowByXXX()
1616 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1617 const wxString
& label
,
1619 wxFindWindowCmp cmp
)
1623 // just check parent and all its children
1624 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1627 // start at very top of wx's windows
1628 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1630 node
= node
->GetNext() )
1632 // recursively check each window & its children
1633 wxWindow
*win
= node
->GetData();
1634 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1644 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1646 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1651 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1653 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1657 // fall back to the label
1658 win
= FindWindowByLabel(title
, parent
);
1666 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1668 return wxFindWindowHelper(parent
, wxEmptyString
, id
, wxFindWindowCmpIds
);
1671 // ----------------------------------------------------------------------------
1672 // dialog oriented functions
1673 // ----------------------------------------------------------------------------
1675 void wxWindowBase::MakeModal(bool modal
)
1677 // Disable all other windows
1680 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1683 wxWindow
*win
= node
->GetData();
1685 win
->Enable(!modal
);
1687 node
= node
->GetNext();
1692 bool wxWindowBase::Validate()
1694 #if wxUSE_VALIDATORS
1695 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1697 wxWindowList::compatibility_iterator node
;
1698 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1700 wxWindowBase
*child
= node
->GetData();
1701 wxValidator
*validator
= child
->GetValidator();
1702 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1707 if ( recurse
&& !child
->Validate() )
1712 #endif // wxUSE_VALIDATORS
1717 bool wxWindowBase::TransferDataToWindow()
1719 #if wxUSE_VALIDATORS
1720 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1722 wxWindowList::compatibility_iterator node
;
1723 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1725 wxWindowBase
*child
= node
->GetData();
1726 wxValidator
*validator
= child
->GetValidator();
1727 if ( validator
&& !validator
->TransferToWindow() )
1729 wxLogWarning(_("Could not transfer data to window"));
1731 wxLog::FlushActive();
1739 if ( !child
->TransferDataToWindow() )
1741 // warning already given
1746 #endif // wxUSE_VALIDATORS
1751 bool wxWindowBase::TransferDataFromWindow()
1753 #if wxUSE_VALIDATORS
1754 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1756 wxWindowList::compatibility_iterator node
;
1757 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1759 wxWindow
*child
= node
->GetData();
1760 wxValidator
*validator
= child
->GetValidator();
1761 if ( validator
&& !validator
->TransferFromWindow() )
1763 // nop warning here because the application is supposed to give
1764 // one itself - we don't know here what might have gone wrongly
1771 if ( !child
->TransferDataFromWindow() )
1773 // warning already given
1778 #endif // wxUSE_VALIDATORS
1783 void wxWindowBase::InitDialog()
1785 wxInitDialogEvent
event(GetId());
1786 event
.SetEventObject( this );
1787 GetEventHandler()->ProcessEvent(event
);
1790 // ----------------------------------------------------------------------------
1791 // context-sensitive help support
1792 // ----------------------------------------------------------------------------
1796 // associate this help text with this window
1797 void wxWindowBase::SetHelpText(const wxString
& text
)
1799 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1802 helpProvider
->AddHelp(this, text
);
1806 #if WXWIN_COMPATIBILITY_2_8
1807 // associate this help text with all windows with the same id as this
1809 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1811 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1814 helpProvider
->AddHelp(GetId(), text
);
1817 #endif // WXWIN_COMPATIBILITY_2_8
1819 // get the help string associated with this window (may be empty)
1820 // default implementation forwards calls to the help provider
1822 wxWindowBase::GetHelpTextAtPoint(const wxPoint
& WXUNUSED(pt
),
1823 wxHelpEvent::Origin
WXUNUSED(origin
)) const
1826 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1829 text
= helpProvider
->GetHelp(this);
1835 // show help for this window
1836 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1838 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1841 wxPoint pos
= event
.GetPosition();
1842 const wxHelpEvent::Origin origin
= event
.GetOrigin();
1843 if ( origin
== wxHelpEvent::Origin_Keyboard
)
1845 // if the help event was generated from keyboard it shouldn't
1846 // appear at the mouse position (which is still the only position
1847 // associated with help event) if the mouse is far away, although
1848 // we still do use the mouse position if it's over the window
1849 // because we suppose the user looks approximately at the mouse
1850 // already and so it would be more convenient than showing tooltip
1851 // at some arbitrary position which can be quite far from it
1852 const wxRect rectClient
= GetClientRect();
1853 if ( !rectClient
.Contains(ScreenToClient(pos
)) )
1855 // position help slightly under and to the right of this window
1856 pos
= ClientToScreen(wxPoint(
1858 rectClient
.height
+ GetCharHeight()
1863 if ( helpProvider
->ShowHelpAtPoint(this, pos
, origin
) )
1865 // skip the event.Skip() below
1873 #endif // wxUSE_HELP
1875 // ----------------------------------------------------------------------------
1877 // ----------------------------------------------------------------------------
1881 wxString
wxWindowBase::GetToolTipText() const
1883 return m_tooltip
? m_tooltip
->GetTip() : wxString();
1886 void wxWindowBase::SetToolTip( const wxString
&tip
)
1888 // don't create the new tooltip if we already have one
1891 m_tooltip
->SetTip( tip
);
1895 SetToolTip( new wxToolTip( tip
) );
1898 // setting empty tooltip text does not remove the tooltip any more - use
1899 // SetToolTip(NULL) for this
1902 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1904 if ( m_tooltip
!= tooltip
)
1909 m_tooltip
= tooltip
;
1913 #endif // wxUSE_TOOLTIPS
1915 // ----------------------------------------------------------------------------
1916 // constraints and sizers
1917 // ----------------------------------------------------------------------------
1919 #if wxUSE_CONSTRAINTS
1921 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1923 if ( m_constraints
)
1925 UnsetConstraints(m_constraints
);
1926 delete m_constraints
;
1928 m_constraints
= constraints
;
1929 if ( m_constraints
)
1931 // Make sure other windows know they're part of a 'meaningful relationship'
1932 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1933 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1934 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1935 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1936 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1937 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1938 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1939 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1940 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1941 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1942 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1943 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1944 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1945 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1946 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1947 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1951 // This removes any dangling pointers to this window in other windows'
1952 // constraintsInvolvedIn lists.
1953 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1957 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1958 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1959 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1960 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1961 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1962 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1963 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1964 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1965 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1966 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1967 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1968 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1969 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1970 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1971 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1972 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1976 // Back-pointer to other windows we're involved with, so if we delete this
1977 // window, we must delete any constraints we're involved with.
1978 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
1980 if ( !m_constraintsInvolvedIn
)
1981 m_constraintsInvolvedIn
= new wxWindowList
;
1982 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
1983 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
1986 // REMOVE back-pointer to other windows we're involved with.
1987 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
1989 if ( m_constraintsInvolvedIn
)
1990 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
1993 // Reset any constraints that mention this window
1994 void wxWindowBase::DeleteRelatedConstraints()
1996 if ( m_constraintsInvolvedIn
)
1998 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
2001 wxWindow
*win
= node
->GetData();
2002 wxLayoutConstraints
*constr
= win
->GetConstraints();
2004 // Reset any constraints involving this window
2007 constr
->left
.ResetIfWin(this);
2008 constr
->top
.ResetIfWin(this);
2009 constr
->right
.ResetIfWin(this);
2010 constr
->bottom
.ResetIfWin(this);
2011 constr
->width
.ResetIfWin(this);
2012 constr
->height
.ResetIfWin(this);
2013 constr
->centreX
.ResetIfWin(this);
2014 constr
->centreY
.ResetIfWin(this);
2017 wxWindowList::compatibility_iterator next
= node
->GetNext();
2018 m_constraintsInvolvedIn
->Erase(node
);
2022 delete m_constraintsInvolvedIn
;
2023 m_constraintsInvolvedIn
= NULL
;
2027 #endif // wxUSE_CONSTRAINTS
2029 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
2031 if ( sizer
== m_windowSizer
)
2034 if ( m_windowSizer
)
2036 m_windowSizer
->SetContainingWindow(NULL
);
2039 delete m_windowSizer
;
2042 m_windowSizer
= sizer
;
2043 if ( m_windowSizer
)
2045 m_windowSizer
->SetContainingWindow((wxWindow
*)this);
2048 SetAutoLayout(m_windowSizer
!= NULL
);
2051 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
2053 SetSizer( sizer
, deleteOld
);
2054 sizer
->SetSizeHints( (wxWindow
*) this );
2058 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
2060 // adding a window to a sizer twice is going to result in fatal and
2061 // hard to debug problems later because when deleting the second
2062 // associated wxSizerItem we're going to dereference a dangling
2063 // pointer; so try to detect this as early as possible
2064 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
2065 wxT("Adding a window to the same sizer twice?") );
2067 m_containingSizer
= sizer
;
2070 #if wxUSE_CONSTRAINTS
2072 void wxWindowBase::SatisfyConstraints()
2074 wxLayoutConstraints
*constr
= GetConstraints();
2075 bool wasOk
= constr
&& constr
->AreSatisfied();
2077 ResetConstraints(); // Mark all constraints as unevaluated
2081 // if we're a top level panel (i.e. our parent is frame/dialog), our
2082 // own constraints will never be satisfied any more unless we do it
2086 while ( noChanges
> 0 )
2088 LayoutPhase1(&noChanges
);
2092 LayoutPhase2(&noChanges
);
2095 #endif // wxUSE_CONSTRAINTS
2097 bool wxWindowBase::Layout()
2099 // If there is a sizer, use it instead of the constraints
2103 GetVirtualSize(&w
, &h
);
2104 GetSizer()->SetDimension( 0, 0, w
, h
);
2106 #if wxUSE_CONSTRAINTS
2109 SatisfyConstraints(); // Find the right constraints values
2110 SetConstraintSizes(); // Recursively set the real window sizes
2117 void wxWindowBase::InternalOnSize(wxSizeEvent
& event
)
2119 if ( GetAutoLayout() )
2125 #if wxUSE_CONSTRAINTS
2127 // first phase of the constraints evaluation: set our own constraints
2128 bool wxWindowBase::LayoutPhase1(int *noChanges
)
2130 wxLayoutConstraints
*constr
= GetConstraints();
2132 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
2135 // second phase: set the constraints for our children
2136 bool wxWindowBase::LayoutPhase2(int *noChanges
)
2143 // Layout grand children
2149 // Do a phase of evaluating child constraints
2150 bool wxWindowBase::DoPhase(int phase
)
2152 // the list containing the children for which the constraints are already
2154 wxWindowList succeeded
;
2156 // the max number of iterations we loop before concluding that we can't set
2158 static const int maxIterations
= 500;
2160 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
2164 // loop over all children setting their constraints
2165 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2167 node
= node
->GetNext() )
2169 wxWindow
*child
= node
->GetData();
2170 if ( child
->IsTopLevel() )
2172 // top level children are not inside our client area
2176 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
2178 // this one is either already ok or nothing we can do about it
2182 int tempNoChanges
= 0;
2183 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
2184 : child
->LayoutPhase2(&tempNoChanges
);
2185 noChanges
+= tempNoChanges
;
2189 succeeded
.Append(child
);
2195 // constraints are set
2203 void wxWindowBase::ResetConstraints()
2205 wxLayoutConstraints
*constr
= GetConstraints();
2208 constr
->left
.SetDone(false);
2209 constr
->top
.SetDone(false);
2210 constr
->right
.SetDone(false);
2211 constr
->bottom
.SetDone(false);
2212 constr
->width
.SetDone(false);
2213 constr
->height
.SetDone(false);
2214 constr
->centreX
.SetDone(false);
2215 constr
->centreY
.SetDone(false);
2218 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2221 wxWindow
*win
= node
->GetData();
2222 if ( !win
->IsTopLevel() )
2223 win
->ResetConstraints();
2224 node
= node
->GetNext();
2228 // Need to distinguish between setting the 'fake' size for windows and sizers,
2229 // and setting the real values.
2230 void wxWindowBase::SetConstraintSizes(bool recurse
)
2232 wxLayoutConstraints
*constr
= GetConstraints();
2233 if ( constr
&& constr
->AreSatisfied() )
2235 int x
= constr
->left
.GetValue();
2236 int y
= constr
->top
.GetValue();
2237 int w
= constr
->width
.GetValue();
2238 int h
= constr
->height
.GetValue();
2240 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
2241 (constr
->height
.GetRelationship() != wxAsIs
) )
2243 SetSize(x
, y
, w
, h
);
2247 // If we don't want to resize this window, just move it...
2253 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
2254 GetClassInfo()->GetClassName(),
2260 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2263 wxWindow
*win
= node
->GetData();
2264 if ( !win
->IsTopLevel() && win
->GetConstraints() )
2265 win
->SetConstraintSizes();
2266 node
= node
->GetNext();
2271 // Only set the size/position of the constraint (if any)
2272 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
2274 wxLayoutConstraints
*constr
= GetConstraints();
2277 if ( x
!= wxDefaultCoord
)
2279 constr
->left
.SetValue(x
);
2280 constr
->left
.SetDone(true);
2282 if ( y
!= wxDefaultCoord
)
2284 constr
->top
.SetValue(y
);
2285 constr
->top
.SetDone(true);
2287 if ( w
!= wxDefaultCoord
)
2289 constr
->width
.SetValue(w
);
2290 constr
->width
.SetDone(true);
2292 if ( h
!= wxDefaultCoord
)
2294 constr
->height
.SetValue(h
);
2295 constr
->height
.SetDone(true);
2300 void wxWindowBase::MoveConstraint(int x
, int y
)
2302 wxLayoutConstraints
*constr
= GetConstraints();
2305 if ( x
!= wxDefaultCoord
)
2307 constr
->left
.SetValue(x
);
2308 constr
->left
.SetDone(true);
2310 if ( y
!= wxDefaultCoord
)
2312 constr
->top
.SetValue(y
);
2313 constr
->top
.SetDone(true);
2318 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
2320 wxLayoutConstraints
*constr
= GetConstraints();
2323 *w
= constr
->width
.GetValue();
2324 *h
= constr
->height
.GetValue();
2330 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
2332 wxLayoutConstraints
*constr
= GetConstraints();
2335 *w
= constr
->width
.GetValue();
2336 *h
= constr
->height
.GetValue();
2339 GetClientSize(w
, h
);
2342 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
2344 wxLayoutConstraints
*constr
= GetConstraints();
2347 *x
= constr
->left
.GetValue();
2348 *y
= constr
->top
.GetValue();
2354 #endif // wxUSE_CONSTRAINTS
2356 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
2358 // don't do it for the dialogs/frames - they float independently of their
2360 if ( !IsTopLevel() )
2362 wxWindow
*parent
= GetParent();
2363 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
2365 wxPoint
pt(parent
->GetClientAreaOrigin());
2372 // ----------------------------------------------------------------------------
2373 // Update UI processing
2374 // ----------------------------------------------------------------------------
2376 void wxWindowBase::UpdateWindowUI(long flags
)
2378 wxUpdateUIEvent
event(GetId());
2379 event
.SetEventObject(this);
2381 if ( GetEventHandler()->ProcessEvent(event
) )
2383 DoUpdateWindowUI(event
);
2386 if (flags
& wxUPDATE_UI_RECURSE
)
2388 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2391 wxWindow
* child
= (wxWindow
*) node
->GetData();
2392 child
->UpdateWindowUI(flags
);
2393 node
= node
->GetNext();
2398 // do the window-specific processing after processing the update event
2399 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
2401 if ( event
.GetSetEnabled() )
2402 Enable(event
.GetEnabled());
2404 if ( event
.GetSetShown() )
2405 Show(event
.GetShown());
2408 // ----------------------------------------------------------------------------
2409 // dialog units translations
2410 // ----------------------------------------------------------------------------
2412 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
2414 int charWidth
= GetCharWidth();
2415 int charHeight
= GetCharHeight();
2416 wxPoint pt2
= wxDefaultPosition
;
2417 if (pt
.x
!= wxDefaultCoord
)
2418 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
);
2419 if (pt
.y
!= wxDefaultCoord
)
2420 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2425 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2427 int charWidth
= GetCharWidth();
2428 int charHeight
= GetCharHeight();
2429 wxPoint pt2
= wxDefaultPosition
;
2430 if (pt
.x
!= wxDefaultCoord
)
2431 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2432 if (pt
.y
!= wxDefaultCoord
)
2433 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2438 // ----------------------------------------------------------------------------
2440 // ----------------------------------------------------------------------------
2442 // propagate the colour change event to the subwindows
2443 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2445 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2448 // Only propagate to non-top-level windows
2449 wxWindow
*win
= node
->GetData();
2450 if ( !win
->IsTopLevel() )
2452 wxSysColourChangedEvent event2
;
2453 event
.SetEventObject(win
);
2454 win
->GetEventHandler()->ProcessEvent(event2
);
2457 node
= node
->GetNext();
2463 // the default action is to populate dialog with data when it's created,
2464 // and nudge the UI into displaying itself correctly in case
2465 // we've turned the wxUpdateUIEvents frequency down low.
2466 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2468 TransferDataToWindow();
2470 // Update the UI at this point
2471 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2474 // ----------------------------------------------------------------------------
2475 // menu-related functions
2476 // ----------------------------------------------------------------------------
2480 bool wxWindowBase::PopupMenu(wxMenu
*menu
, int x
, int y
)
2482 wxCHECK_MSG( menu
, false, "can't popup NULL menu" );
2484 wxCurrentPopupMenu
= menu
;
2485 const bool rc
= DoPopupMenu(menu
, x
, y
);
2486 wxCurrentPopupMenu
= NULL
;
2491 // this is used to pass the id of the selected item from the menu event handler
2492 // to the main function itself
2494 // it's ok to use a global here as there can be at most one popup menu shown at
2496 static int gs_popupMenuSelection
= wxID_NONE
;
2498 void wxWindowBase::InternalOnPopupMenu(wxCommandEvent
& event
)
2500 // store the id in a global variable where we'll retrieve it from later
2501 gs_popupMenuSelection
= event
.GetId();
2504 void wxWindowBase::InternalOnPopupMenuUpdate(wxUpdateUIEvent
& WXUNUSED(event
))
2506 // nothing to do but do not skip it
2510 wxWindowBase::DoGetPopupMenuSelectionFromUser(wxMenu
& menu
, int x
, int y
)
2512 gs_popupMenuSelection
= wxID_NONE
;
2514 Connect(wxEVT_COMMAND_MENU_SELECTED
,
2515 wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu
),
2519 // it is common to construct the menu passed to this function dynamically
2520 // using some fixed range of ids which could clash with the ids used
2521 // elsewhere in the program, which could result in some menu items being
2522 // unintentionally disabled or otherwise modified by update UI handlers
2523 // elsewhere in the program code and this is difficult to avoid in the
2524 // program itself, so instead we just temporarily suspend UI updating while
2525 // this menu is shown
2526 Connect(wxEVT_UPDATE_UI
,
2527 wxUpdateUIEventHandler(wxWindowBase::InternalOnPopupMenuUpdate
),
2531 PopupMenu(&menu
, x
, y
);
2533 Disconnect(wxEVT_UPDATE_UI
,
2534 wxUpdateUIEventHandler(wxWindowBase::InternalOnPopupMenuUpdate
),
2537 Disconnect(wxEVT_COMMAND_MENU_SELECTED
,
2538 wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu
),
2542 return gs_popupMenuSelection
;
2545 #endif // wxUSE_MENUS
2547 // methods for drawing the sizers in a visible way
2550 static void DrawSizers(wxWindowBase
*win
);
2552 static void DrawBorder(wxWindowBase
*win
, const wxRect
& rect
, bool fill
, const wxPen
* pen
)
2554 wxClientDC
dc((wxWindow
*)win
);
2556 dc
.SetBrush(fill
? wxBrush(pen
->GetColour(), wxBRUSHSTYLE_CROSSDIAG_HATCH
) :
2557 *wxTRANSPARENT_BRUSH
);
2558 dc
.DrawRectangle(rect
.Deflate(1, 1));
2561 static void DrawSizer(wxWindowBase
*win
, wxSizer
*sizer
)
2563 const wxSizerItemList
& items
= sizer
->GetChildren();
2564 for ( wxSizerItemList::const_iterator i
= items
.begin(),
2569 wxSizerItem
*item
= *i
;
2570 if ( item
->IsSizer() )
2572 DrawBorder(win
, item
->GetRect().Deflate(2), false, wxRED_PEN
);
2573 DrawSizer(win
, item
->GetSizer());
2575 else if ( item
->IsSpacer() )
2577 DrawBorder(win
, item
->GetRect().Deflate(2), true, wxBLUE_PEN
);
2579 else if ( item
->IsWindow() )
2581 DrawSizers(item
->GetWindow());
2584 wxFAIL_MSG("inconsistent wxSizerItem status!");
2588 static void DrawSizers(wxWindowBase
*win
)
2590 DrawBorder(win
, win
->GetClientSize(), false, wxGREEN_PEN
);
2592 wxSizer
*sizer
= win
->GetSizer();
2595 DrawSizer(win
, sizer
);
2597 else // no sizer, still recurse into the children
2599 const wxWindowList
& children
= win
->GetChildren();
2600 for ( wxWindowList::const_iterator i
= children
.begin(),
2601 end
= children
.end();
2608 // show all kind of sizes of this window; see the "window sizing" topic
2609 // overview for more info about the various differences:
2610 wxSize fullSz
= win
->GetSize();
2611 wxSize clientSz
= win
->GetClientSize();
2612 wxSize bestSz
= win
->GetBestSize();
2613 wxSize minSz
= win
->GetMinSize();
2614 wxSize maxSz
= win
->GetMaxSize();
2615 wxSize virtualSz
= win
->GetVirtualSize();
2617 wxMessageOutputDebug dbgout
;
2619 "%-10s => fullsz=%4d;%-4d clientsz=%4d;%-4d bestsz=%4d;%-4d minsz=%4d;%-4d maxsz=%4d;%-4d virtualsz=%4d;%-4d\n",
2622 clientSz
.x
, clientSz
.y
,
2626 virtualSz
.x
, virtualSz
.y
);
2630 #endif // __WXDEBUG__
2632 // process special middle clicks
2633 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2635 if ( event
.ControlDown() && event
.AltDown() )
2638 // Ctrl-Alt-Shift-mclick makes the sizers visible in debug builds
2639 if ( event
.ShiftDown() )
2644 #endif // __WXDEBUG__
2645 ::wxInfoMessageBox((wxWindow
*)this);
2653 // ----------------------------------------------------------------------------
2655 // ----------------------------------------------------------------------------
2657 #if wxUSE_ACCESSIBILITY
2658 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2660 if (m_accessible
&& (accessible
!= m_accessible
))
2661 delete m_accessible
;
2662 m_accessible
= accessible
;
2664 m_accessible
->SetWindow((wxWindow
*) this);
2667 // Returns the accessible object, creating if necessary.
2668 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2671 m_accessible
= CreateAccessible();
2672 return m_accessible
;
2675 // Override to create a specific accessible object.
2676 wxAccessible
* wxWindowBase::CreateAccessible()
2678 return new wxWindowAccessible((wxWindow
*) this);
2683 // ----------------------------------------------------------------------------
2684 // list classes implementation
2685 // ----------------------------------------------------------------------------
2689 #include "wx/listimpl.cpp"
2690 WX_DEFINE_LIST(wxWindowList
)
2694 void wxWindowListNode::DeleteData()
2696 delete (wxWindow
*)GetData();
2699 #endif // wxUSE_STL/!wxUSE_STL
2701 // ----------------------------------------------------------------------------
2703 // ----------------------------------------------------------------------------
2705 wxBorder
wxWindowBase::GetBorder(long flags
) const
2707 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2708 if ( border
== wxBORDER_DEFAULT
)
2710 border
= GetDefaultBorder();
2712 else if ( border
== wxBORDER_THEME
)
2714 border
= GetDefaultBorderForControl();
2720 wxBorder
wxWindowBase::GetDefaultBorder() const
2722 return wxBORDER_NONE
;
2725 // ----------------------------------------------------------------------------
2727 // ----------------------------------------------------------------------------
2729 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2731 // here we just check if the point is inside the window or not
2733 // check the top and left border first
2734 bool outside
= x
< 0 || y
< 0;
2737 // check the right and bottom borders too
2738 wxSize size
= GetSize();
2739 outside
= x
>= size
.x
|| y
>= size
.y
;
2742 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2745 // ----------------------------------------------------------------------------
2747 // ----------------------------------------------------------------------------
2749 struct WXDLLEXPORT wxWindowNext
2753 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2754 wxWindow
*wxWindowBase::ms_winCaptureCurrent
= NULL
;
2755 bool wxWindowBase::ms_winCaptureChanging
= false;
2757 void wxWindowBase::CaptureMouse()
2759 wxLogTrace(wxT("mousecapture"), wxT("CaptureMouse(%p)"), static_cast<void*>(this));
2761 wxASSERT_MSG( !ms_winCaptureChanging
, wxT("recursive CaptureMouse call?") );
2763 ms_winCaptureChanging
= true;
2765 wxWindow
*winOld
= GetCapture();
2768 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2771 wxWindowNext
*item
= new wxWindowNext
;
2773 item
->next
= ms_winCaptureNext
;
2774 ms_winCaptureNext
= item
;
2776 //else: no mouse capture to save
2779 ms_winCaptureCurrent
= (wxWindow
*)this;
2781 ms_winCaptureChanging
= false;
2784 void wxWindowBase::ReleaseMouse()
2786 wxLogTrace(wxT("mousecapture"), wxT("ReleaseMouse(%p)"), static_cast<void*>(this));
2788 wxASSERT_MSG( !ms_winCaptureChanging
, wxT("recursive ReleaseMouse call?") );
2790 wxASSERT_MSG( GetCapture() == this,
2791 "attempt to release mouse, but this window hasn't captured it" );
2792 wxASSERT_MSG( ms_winCaptureCurrent
== this,
2793 "attempt to release mouse, but this window hasn't captured it" );
2795 ms_winCaptureChanging
= true;
2798 ms_winCaptureCurrent
= NULL
;
2800 if ( ms_winCaptureNext
)
2802 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2803 ms_winCaptureCurrent
= ms_winCaptureNext
->win
;
2805 wxWindowNext
*item
= ms_winCaptureNext
;
2806 ms_winCaptureNext
= item
->next
;
2809 //else: stack is empty, no previous capture
2811 ms_winCaptureChanging
= false;
2813 wxLogTrace(wxT("mousecapture"),
2814 (const wxChar
*) wxT("After ReleaseMouse() mouse is captured by %p"),
2815 static_cast<void*>(GetCapture()));
2818 static void DoNotifyWindowAboutCaptureLost(wxWindow
*win
)
2820 wxMouseCaptureLostEvent
event(win
->GetId());
2821 event
.SetEventObject(win
);
2822 if ( !win
->GetEventHandler()->ProcessEvent(event
) )
2824 // windows must handle this event, otherwise the app wouldn't behave
2825 // correctly if it loses capture unexpectedly; see the discussion here:
2826 // http://sourceforge.net/tracker/index.php?func=detail&aid=1153662&group_id=9863&atid=109863
2827 // http://article.gmane.org/gmane.comp.lib.wxwidgets.devel/82376
2828 wxFAIL_MSG( wxT("window that captured the mouse didn't process wxEVT_MOUSE_CAPTURE_LOST") );
2833 void wxWindowBase::NotifyCaptureLost()
2835 // don't do anything if capture lost was expected, i.e. resulted from
2836 // a wx call to ReleaseMouse or CaptureMouse:
2837 if ( ms_winCaptureChanging
)
2840 // if the capture was lost unexpectedly, notify every window that has
2841 // capture (on stack or current) about it and clear the stack:
2843 if ( ms_winCaptureCurrent
)
2845 DoNotifyWindowAboutCaptureLost(ms_winCaptureCurrent
);
2846 ms_winCaptureCurrent
= NULL
;
2849 while ( ms_winCaptureNext
)
2851 wxWindowNext
*item
= ms_winCaptureNext
;
2852 ms_winCaptureNext
= item
->next
;
2854 DoNotifyWindowAboutCaptureLost(item
->win
);
2863 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2864 int WXUNUSED(modifiers
),
2865 int WXUNUSED(keycode
))
2871 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2877 #endif // wxUSE_HOTKEY
2879 // ----------------------------------------------------------------------------
2881 // ----------------------------------------------------------------------------
2883 bool wxWindowBase::TryBefore(wxEvent
& event
)
2885 #if wxUSE_VALIDATORS
2886 // Can only use the validator of the window which
2887 // is receiving the event
2888 if ( event
.GetEventObject() == this )
2890 wxValidator
* const validator
= GetValidator();
2891 if ( validator
&& validator
->ProcessEventHere(event
) )
2896 #endif // wxUSE_VALIDATORS
2898 return wxEvtHandler::TryBefore(event
);
2901 bool wxWindowBase::TryAfter(wxEvent
& event
)
2903 // carry on up the parent-child hierarchy if the propagation count hasn't
2905 if ( event
.ShouldPropagate() )
2907 // honour the requests to stop propagation at this window: this is
2908 // used by the dialogs, for example, to prevent processing the events
2909 // from the dialog controls in the parent frame which rarely, if ever,
2911 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2913 wxWindow
*parent
= GetParent();
2914 if ( parent
&& !parent
->IsBeingDeleted() )
2916 wxPropagateOnce
propagateOnce(event
);
2918 return parent
->GetEventHandler()->ProcessEvent(event
);
2923 return wxEvtHandler::TryAfter(event
);
2926 // ----------------------------------------------------------------------------
2927 // window relationships
2928 // ----------------------------------------------------------------------------
2930 wxWindow
*wxWindowBase::DoGetSibling(WindowOrder order
) const
2932 wxCHECK_MSG( GetParent(), NULL
,
2933 wxT("GetPrev/NextSibling() don't work for TLWs!") );
2935 wxWindowList
& siblings
= GetParent()->GetChildren();
2936 wxWindowList::compatibility_iterator i
= siblings
.Find((wxWindow
*)this);
2937 wxCHECK_MSG( i
, NULL
, wxT("window not a child of its parent?") );
2939 if ( order
== OrderBefore
)
2940 i
= i
->GetPrevious();
2944 return i
? i
->GetData() : NULL
;
2947 // ----------------------------------------------------------------------------
2948 // keyboard navigation
2949 // ----------------------------------------------------------------------------
2951 // Navigates in the specified direction inside this window
2952 bool wxWindowBase::DoNavigateIn(int flags
)
2954 #ifdef wxHAS_NATIVE_TAB_TRAVERSAL
2955 // native code doesn't process our wxNavigationKeyEvents anyhow
2958 #else // !wxHAS_NATIVE_TAB_TRAVERSAL
2959 wxNavigationKeyEvent eventNav
;
2960 wxWindow
*focused
= FindFocus();
2961 eventNav
.SetCurrentFocus(focused
);
2962 eventNav
.SetEventObject(focused
);
2963 eventNav
.SetFlags(flags
);
2964 return GetEventHandler()->ProcessEvent(eventNav
);
2965 #endif // wxHAS_NATIVE_TAB_TRAVERSAL/!wxHAS_NATIVE_TAB_TRAVERSAL
2968 bool wxWindowBase::HandleAsNavigationKey(const wxKeyEvent
& event
)
2970 if ( event
.GetKeyCode() != WXK_TAB
)
2973 int flags
= wxNavigationKeyEvent::FromTab
;
2975 if ( event
.ShiftDown() )
2976 flags
|= wxNavigationKeyEvent::IsBackward
;
2978 flags
|= wxNavigationKeyEvent::IsForward
;
2980 if ( event
.ControlDown() )
2981 flags
|= wxNavigationKeyEvent::WinChange
;
2987 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, WindowOrder move
)
2989 // check that we're not a top level window
2990 wxCHECK_RET( GetParent(),
2991 wxT("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
2993 // detect the special case when we have nothing to do anyhow and when the
2994 // code below wouldn't work
2998 // find the target window in the siblings list
2999 wxWindowList
& siblings
= GetParent()->GetChildren();
3000 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
3001 wxCHECK_RET( i
, wxT("MoveBefore/AfterInTabOrder(): win is not a sibling") );
3003 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
3004 // can't just move the node around
3005 wxWindow
*self
= (wxWindow
*)this;
3006 siblings
.DeleteObject(self
);
3007 if ( move
== OrderAfter
)
3014 siblings
.Insert(i
, self
);
3016 else // OrderAfter and win was the last sibling
3018 siblings
.Append(self
);
3022 // ----------------------------------------------------------------------------
3024 // ----------------------------------------------------------------------------
3026 /*static*/ wxWindow
* wxWindowBase::FindFocus()
3028 wxWindowBase
*win
= DoFindFocus();
3029 return win
? win
->GetMainWindowOfCompositeControl() : NULL
;
3032 bool wxWindowBase::HasFocus() const
3034 wxWindowBase
*win
= DoFindFocus();
3035 return win
== this ||
3036 win
== wxConstCast(this, wxWindowBase
)->GetMainWindowOfCompositeControl();
3039 // ----------------------------------------------------------------------------
3041 // ----------------------------------------------------------------------------
3043 #if wxUSE_DRAG_AND_DROP && !defined(__WXMSW__)
3048 class DragAcceptFilesTarget
: public wxFileDropTarget
3051 DragAcceptFilesTarget(wxWindowBase
*win
) : m_win(win
) {}
3053 virtual bool OnDropFiles(wxCoord x
, wxCoord y
,
3054 const wxArrayString
& filenames
)
3056 wxDropFilesEvent
event(wxEVT_DROP_FILES
,
3058 wxCArrayString(filenames
).Release());
3059 event
.SetEventObject(m_win
);
3063 return m_win
->HandleWindowEvent(event
);
3067 wxWindowBase
* const m_win
;
3069 wxDECLARE_NO_COPY_CLASS(DragAcceptFilesTarget
);
3073 } // anonymous namespace
3075 // Generic version of DragAcceptFiles(). It works by installing a simple
3076 // wxFileDropTarget-to-EVT_DROP_FILES adaptor and therefore cannot be used
3077 // together with explicit SetDropTarget() calls.
3078 void wxWindowBase::DragAcceptFiles(bool accept
)
3082 wxASSERT_MSG( !GetDropTarget(),
3083 "cannot use DragAcceptFiles() and SetDropTarget() together" );
3084 SetDropTarget(new DragAcceptFilesTarget(this));
3088 SetDropTarget(NULL
);
3092 #endif // wxUSE_DRAG_AND_DROP && !defined(__WXMSW__)
3094 // ----------------------------------------------------------------------------
3096 // ----------------------------------------------------------------------------
3098 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
3100 while ( win
&& !win
->IsTopLevel() )
3101 win
= win
->GetParent();
3106 #if wxUSE_ACCESSIBILITY
3107 // ----------------------------------------------------------------------------
3108 // accessible object for windows
3109 // ----------------------------------------------------------------------------
3111 // Can return either a child object, or an integer
3112 // representing the child element, starting from 1.
3113 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
3115 wxASSERT( GetWindow() != NULL
);
3119 return wxACC_NOT_IMPLEMENTED
;
3122 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
3123 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
3125 wxASSERT( GetWindow() != NULL
);
3129 wxWindow
* win
= NULL
;
3136 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
3138 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
3145 rect
= win
->GetRect();
3146 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
3147 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
3151 return wxACC_NOT_IMPLEMENTED
;
3154 // Navigates from fromId to toId/toObject.
3155 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
3156 int* WXUNUSED(toId
), wxAccessible
** toObject
)
3158 wxASSERT( GetWindow() != NULL
);
3164 case wxNAVDIR_FIRSTCHILD
:
3166 if (GetWindow()->GetChildren().GetCount() == 0)
3168 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
3169 *toObject
= childWindow
->GetOrCreateAccessible();
3173 case wxNAVDIR_LASTCHILD
:
3175 if (GetWindow()->GetChildren().GetCount() == 0)
3177 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
3178 *toObject
= childWindow
->GetOrCreateAccessible();
3182 case wxNAVDIR_RIGHT
:
3186 wxWindowList::compatibility_iterator node
=
3187 wxWindowList::compatibility_iterator();
3190 // Can't navigate to sibling of this window
3191 // if we're a top-level window.
3192 if (!GetWindow()->GetParent())
3193 return wxACC_NOT_IMPLEMENTED
;
3195 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
3199 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
3200 node
= GetWindow()->GetChildren().Item(fromId
-1);
3203 if (node
&& node
->GetNext())
3205 wxWindow
* nextWindow
= node
->GetNext()->GetData();
3206 *toObject
= nextWindow
->GetOrCreateAccessible();
3214 case wxNAVDIR_PREVIOUS
:
3216 wxWindowList::compatibility_iterator node
=
3217 wxWindowList::compatibility_iterator();
3220 // Can't navigate to sibling of this window
3221 // if we're a top-level window.
3222 if (!GetWindow()->GetParent())
3223 return wxACC_NOT_IMPLEMENTED
;
3225 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
3229 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
3230 node
= GetWindow()->GetChildren().Item(fromId
-1);
3233 if (node
&& node
->GetPrevious())
3235 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
3236 *toObject
= previousWindow
->GetOrCreateAccessible();
3244 return wxACC_NOT_IMPLEMENTED
;
3247 // Gets the name of the specified object.
3248 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
3250 wxASSERT( GetWindow() != NULL
);
3256 // If a child, leave wxWidgets to call the function on the actual
3259 return wxACC_NOT_IMPLEMENTED
;
3261 // This will eventually be replaced by specialised
3262 // accessible classes, one for each kind of wxWidgets
3263 // control or window.
3265 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
3266 title
= ((wxButton
*) GetWindow())->GetLabel();
3269 title
= GetWindow()->GetName();
3277 return wxACC_NOT_IMPLEMENTED
;
3280 // Gets the number of children.
3281 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
3283 wxASSERT( GetWindow() != NULL
);
3287 *childId
= (int) GetWindow()->GetChildren().GetCount();
3291 // Gets the specified child (starting from 1).
3292 // If *child is NULL and return value is wxACC_OK,
3293 // this means that the child is a simple element and
3294 // not an accessible object.
3295 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
3297 wxASSERT( GetWindow() != NULL
);
3307 if (childId
> (int) GetWindow()->GetChildren().GetCount())
3310 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
3311 *child
= childWindow
->GetOrCreateAccessible();
3318 // Gets the parent, or NULL.
3319 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
3321 wxASSERT( GetWindow() != NULL
);
3325 wxWindow
* parentWindow
= GetWindow()->GetParent();
3333 *parent
= parentWindow
->GetOrCreateAccessible();
3341 // Performs the default action. childId is 0 (the action for this object)
3342 // or > 0 (the action for a child).
3343 // Return wxACC_NOT_SUPPORTED if there is no default action for this
3344 // window (e.g. an edit control).
3345 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
3347 wxASSERT( GetWindow() != NULL
);
3351 return wxACC_NOT_IMPLEMENTED
;
3354 // Gets the default action for this object (0) or > 0 (the action for a child).
3355 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
3356 // string if there is no action.
3357 // The retrieved string describes the action that is performed on an object,
3358 // not what the object does as a result. For example, a toolbar button that prints
3359 // a document has a default action of "Press" rather than "Prints the current document."
3360 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
3362 wxASSERT( GetWindow() != NULL
);
3366 return wxACC_NOT_IMPLEMENTED
;
3369 // Returns the description for this object or a child.
3370 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
3372 wxASSERT( GetWindow() != NULL
);
3376 wxString
ht(GetWindow()->GetHelpTextAtPoint(wxDefaultPosition
, wxHelpEvent::Origin_Keyboard
));
3382 return wxACC_NOT_IMPLEMENTED
;
3385 // Returns help text for this object or a child, similar to tooltip text.
3386 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
3388 wxASSERT( GetWindow() != NULL
);
3392 wxString
ht(GetWindow()->GetHelpTextAtPoint(wxDefaultPosition
, wxHelpEvent::Origin_Keyboard
));
3398 return wxACC_NOT_IMPLEMENTED
;
3401 // Returns the keyboard shortcut for this object or child.
3402 // Return e.g. ALT+K
3403 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
3405 wxASSERT( GetWindow() != NULL
);
3409 return wxACC_NOT_IMPLEMENTED
;
3412 // Returns a role constant.
3413 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
3415 wxASSERT( GetWindow() != NULL
);
3419 // If a child, leave wxWidgets to call the function on the actual
3422 return wxACC_NOT_IMPLEMENTED
;
3424 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
3425 return wxACC_NOT_IMPLEMENTED
;
3427 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
3428 return wxACC_NOT_IMPLEMENTED
;
3431 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
3432 return wxACC_NOT_IMPLEMENTED
;
3435 //*role = wxROLE_SYSTEM_CLIENT;
3436 *role
= wxROLE_SYSTEM_CLIENT
;
3440 return wxACC_NOT_IMPLEMENTED
;
3444 // Returns a state constant.
3445 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
3447 wxASSERT( GetWindow() != NULL
);
3451 // If a child, leave wxWidgets to call the function on the actual
3454 return wxACC_NOT_IMPLEMENTED
;
3456 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
3457 return wxACC_NOT_IMPLEMENTED
;
3460 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
3461 return wxACC_NOT_IMPLEMENTED
;
3464 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
3465 return wxACC_NOT_IMPLEMENTED
;
3472 return wxACC_NOT_IMPLEMENTED
;
3476 // Returns a localized string representing the value for the object
3478 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
3480 wxASSERT( GetWindow() != NULL
);
3484 return wxACC_NOT_IMPLEMENTED
;
3487 // Selects the object or child.
3488 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
3490 wxASSERT( GetWindow() != NULL
);
3494 return wxACC_NOT_IMPLEMENTED
;
3497 // Gets the window with the keyboard focus.
3498 // If childId is 0 and child is NULL, no object in
3499 // this subhierarchy has the focus.
3500 // If this object has the focus, child should be 'this'.
3501 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
3503 wxASSERT( GetWindow() != NULL
);
3507 return wxACC_NOT_IMPLEMENTED
;
3511 // Gets a variant representing the selected children
3513 // Acceptable values:
3514 // - a null variant (IsNull() returns true)
3515 // - a list variant (GetType() == wxT("list")
3516 // - an integer representing the selected child element,
3517 // or 0 if this object is selected (GetType() == wxT("long")
3518 // - a "void*" pointer to a wxAccessible child object
3519 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
3521 wxASSERT( GetWindow() != NULL
);
3525 return wxACC_NOT_IMPLEMENTED
;
3527 #endif // wxUSE_VARIANT
3529 #endif // wxUSE_ACCESSIBILITY
3531 // ----------------------------------------------------------------------------
3533 // ----------------------------------------------------------------------------
3536 wxWindowBase::AdjustForLayoutDirection(wxCoord x
,
3538 wxCoord widthTotal
) const
3540 if ( GetLayoutDirection() == wxLayout_RightToLeft
)
3542 x
= widthTotal
- x
- width
;