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
)
107 // ============================================================================
108 // implementation of the common functionality of the wxWindow class
109 // ============================================================================
111 // ----------------------------------------------------------------------------
113 // ----------------------------------------------------------------------------
115 // the default initialization
116 wxWindowBase::wxWindowBase()
118 // no window yet, no parent nor children
120 m_windowId
= wxID_ANY
;
122 // no constraints on the minimal window size
124 m_maxWidth
= wxDefaultCoord
;
126 m_maxHeight
= wxDefaultCoord
;
128 // invalidiated cache value
129 m_bestSizeCache
= wxDefaultSize
;
131 // window are created enabled and visible by default
135 // the default event handler is just this window
136 m_eventHandler
= this;
140 m_windowValidator
= NULL
;
141 #endif // wxUSE_VALIDATORS
143 // the colours/fonts are default for now, so leave m_font,
144 // m_backgroundColour and m_foregroundColour uninitialized and set those
150 m_inheritFont
= false;
156 m_backgroundStyle
= wxBG_STYLE_SYSTEM
;
158 #if wxUSE_CONSTRAINTS
159 // no constraints whatsoever
160 m_constraints
= NULL
;
161 m_constraintsInvolvedIn
= NULL
;
162 #endif // wxUSE_CONSTRAINTS
164 m_windowSizer
= NULL
;
165 m_containingSizer
= NULL
;
166 m_autoLayout
= false;
168 #if wxUSE_DRAG_AND_DROP
170 #endif // wxUSE_DRAG_AND_DROP
174 #endif // wxUSE_TOOLTIPS
178 #endif // wxUSE_CARET
181 m_hasCustomPalette
= false;
182 #endif // wxUSE_PALETTE
184 #if wxUSE_ACCESSIBILITY
188 m_virtualSize
= wxDefaultSize
;
190 m_scrollHelper
= NULL
;
192 m_windowVariant
= wxWINDOW_VARIANT_NORMAL
;
193 #if wxUSE_SYSTEM_OPTIONS
194 if ( wxSystemOptions::HasOption(wxWINDOW_DEFAULT_VARIANT
) )
196 m_windowVariant
= (wxWindowVariant
) wxSystemOptions::GetOptionInt( wxWINDOW_DEFAULT_VARIANT
) ;
200 // Whether we're using the current theme for this window (wxGTK only for now)
201 m_themeEnabled
= false;
203 // This is set to true by SendDestroyEvent() which should be called by the
204 // most derived class to ensure that the destruction event is sent as soon
205 // as possible to allow its handlers to still see the undestroyed window
206 m_isBeingDeleted
= false;
211 // common part of window creation process
212 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
214 const wxPoint
& WXUNUSED(pos
),
215 const wxSize
& WXUNUSED(size
),
217 const wxValidator
& wxVALIDATOR_PARAM(validator
),
218 const wxString
& name
)
221 // wxGTK doesn't allow to create controls with static box as the parent so
222 // this will result in a crash when the program is ported to wxGTK so warn
225 // if you get this assert, the correct solution is to create the controls
226 // as siblings of the static box
227 wxASSERT_MSG( !parent
|| !wxDynamicCast(parent
, wxStaticBox
),
228 _T("wxStaticBox can't be used as a window parent!") );
229 #endif // wxUSE_STATBOX
231 // ids are limited to 16 bits under MSW so if you care about portability,
232 // it's not a good idea to use ids out of this range (and negative ids are
233 // reserved for wxWidgets own usage)
234 wxASSERT_MSG( id
== wxID_ANY
|| (id
>= 0 && id
< 32767) ||
235 (id
>= wxID_AUTO_LOWEST
&& id
<= wxID_AUTO_HIGHEST
),
236 _T("invalid id value") );
238 // generate a new id if the user doesn't care about it
239 if ( id
== wxID_ANY
)
241 m_windowId
= NewControlId();
243 else // valid id specified
248 // don't use SetWindowStyleFlag() here, this function should only be called
249 // to change the flag after creation as it tries to reflect the changes in
250 // flags by updating the window dynamically and we don't need this here
251 m_windowStyle
= style
;
257 SetValidator(validator
);
258 #endif // wxUSE_VALIDATORS
260 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
261 // have it too - like this it's possible to set it only in the top level
262 // dialog/frame and all children will inherit it by defult
263 if ( parent
&& (parent
->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) )
265 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY
);
271 bool wxWindowBase::ToggleWindowStyle(int flag
)
273 wxASSERT_MSG( flag
, _T("flags with 0 value can't be toggled") );
276 long style
= GetWindowStyleFlag();
282 else // currently off
288 SetWindowStyleFlag(style
);
293 // ----------------------------------------------------------------------------
295 // ----------------------------------------------------------------------------
298 wxWindowBase::~wxWindowBase()
300 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
302 // FIXME if these 2 cases result from programming errors in the user code
303 // we should probably assert here instead of silently fixing them
305 // Just in case the window has been Closed, but we're then deleting
306 // immediately: don't leave dangling pointers.
307 wxPendingDelete
.DeleteObject(this);
309 // Just in case we've loaded a top-level window via LoadNativeDialog but
310 // we weren't a dialog class
311 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
314 // The associated popup menu can still be alive, disassociate from it in
316 if ( wxCurrentPopupMenu
&& wxCurrentPopupMenu
->GetInvokingWindow() == this )
317 wxCurrentPopupMenu
->SetInvokingWindow(NULL
);
318 #endif // wxUSE_MENUS
320 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
322 // notify the parent about this window destruction
324 m_parent
->RemoveChild(this);
328 #endif // wxUSE_CARET
331 delete m_windowValidator
;
332 #endif // wxUSE_VALIDATORS
334 #if wxUSE_CONSTRAINTS
335 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
336 // at deleted windows as they delete themselves.
337 DeleteRelatedConstraints();
341 // This removes any dangling pointers to this window in other windows'
342 // constraintsInvolvedIn lists.
343 UnsetConstraints(m_constraints
);
344 delete m_constraints
;
345 m_constraints
= NULL
;
347 #endif // wxUSE_CONSTRAINTS
349 if ( m_containingSizer
)
350 m_containingSizer
->Detach( (wxWindow
*)this );
352 delete m_windowSizer
;
354 #if wxUSE_DRAG_AND_DROP
356 #endif // wxUSE_DRAG_AND_DROP
360 #endif // wxUSE_TOOLTIPS
362 #if wxUSE_ACCESSIBILITY
367 // NB: this has to be called unconditionally, because we don't know
368 // whether this window has associated help text or not
369 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
371 helpProvider
->RemoveHelp(this);
375 bool wxWindowBase::IsBeingDeleted() const
377 return m_isBeingDeleted
||
378 (!IsTopLevel() && m_parent
&& m_parent
->IsBeingDeleted());
381 void wxWindowBase::SendDestroyEvent()
383 if ( m_isBeingDeleted
)
385 // we could have been already called from a more derived class dtor,
386 // e.g. ~wxTLW calls us and so does ~wxWindow and the latter call
387 // should be simply ignored
391 m_isBeingDeleted
= true;
393 wxWindowDestroyEvent event
;
394 event
.SetEventObject(this);
395 event
.SetId(GetId());
396 GetEventHandler()->ProcessEvent(event
);
399 bool wxWindowBase::Destroy()
408 bool wxWindowBase::Close(bool force
)
410 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
411 event
.SetEventObject(this);
412 event
.SetCanVeto(!force
);
414 // return false if window wasn't closed because the application vetoed the
416 return HandleWindowEvent(event
) && !event
.GetVeto();
419 bool wxWindowBase::DestroyChildren()
421 wxWindowList::compatibility_iterator node
;
424 // we iterate until the list becomes empty
425 node
= GetChildren().GetFirst();
429 wxWindow
*child
= node
->GetData();
431 // note that we really want to delete it immediately so don't call the
432 // possible overridden Destroy() version which might not delete the
433 // child immediately resulting in problems with our (top level) child
434 // outliving its parent
435 child
->wxWindowBase::Destroy();
437 wxASSERT_MSG( !GetChildren().Find(child
),
438 wxT("child didn't remove itself using RemoveChild()") );
444 // ----------------------------------------------------------------------------
445 // size/position related methods
446 // ----------------------------------------------------------------------------
448 // centre the window with respect to its parent in either (or both) directions
449 void wxWindowBase::DoCentre(int dir
)
451 wxCHECK_RET( !(dir
& wxCENTRE_ON_SCREEN
) && GetParent(),
452 _T("this method only implements centering child windows") );
454 SetSize(GetRect().CentreIn(GetParent()->GetClientSize(), dir
));
457 // fits the window around the children
458 void wxWindowBase::Fit()
460 if ( !GetChildren().empty() )
462 SetSize(GetBestSize());
464 //else: do nothing if we have no children
467 // fits virtual size (ie. scrolled area etc.) around children
468 void wxWindowBase::FitInside()
470 if ( GetChildren().GetCount() > 0 )
472 SetVirtualSize( GetBestVirtualSize() );
476 // On Mac, scrollbars are explicitly children.
478 static bool wxHasRealChildren(const wxWindowBase
* win
)
480 int realChildCount
= 0;
482 for ( wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
484 node
= node
->GetNext() )
486 wxWindow
*win
= node
->GetData();
487 if ( !win
->IsTopLevel() && win
->IsShown() && !win
->IsKindOf(CLASSINFO(wxScrollBar
)))
490 return (realChildCount
> 0);
494 void wxWindowBase::InvalidateBestSize()
496 m_bestSizeCache
= wxDefaultSize
;
498 // parent's best size calculation may depend on its children's
499 // as long as child window we are in is not top level window itself
500 // (because the TLW size is never resized automatically)
501 // so let's invalidate it as well to be safe:
502 if (m_parent
&& !IsTopLevel())
503 m_parent
->InvalidateBestSize();
506 // return the size best suited for the current window
507 wxSize
wxWindowBase::DoGetBestSize() const
513 best
= m_windowSizer
->GetMinSize();
515 #if wxUSE_CONSTRAINTS
516 else if ( m_constraints
)
518 wxConstCast(this, wxWindowBase
)->SatisfyConstraints();
520 // our minimal acceptable size is such that all our windows fit inside
524 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
526 node
= node
->GetNext() )
528 wxLayoutConstraints
*c
= node
->GetData()->GetConstraints();
531 // it's not normal that we have an unconstrained child, but
532 // what can we do about it?
536 int x
= c
->right
.GetValue(),
537 y
= c
->bottom
.GetValue();
545 // TODO: we must calculate the overlaps somehow, otherwise we
546 // will never return a size bigger than the current one :-(
549 best
= wxSize(maxX
, maxY
);
551 #endif // wxUSE_CONSTRAINTS
552 else if ( !GetChildren().empty()
554 && wxHasRealChildren(this)
558 // our minimal acceptable size is such that all our visible child
559 // windows fit inside
563 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
565 node
= node
->GetNext() )
567 wxWindow
*win
= node
->GetData();
568 if ( win
->IsTopLevel()
571 || wxDynamicCast(win
, wxStatusBar
)
572 #endif // wxUSE_STATUSBAR
575 // dialogs and frames lie in different top level windows -
576 // don't deal with them here; as for the status bars, they
577 // don't lie in the client area at all
582 win
->GetPosition(&wx
, &wy
);
584 // if the window hadn't been positioned yet, assume that it is in
586 if ( wx
== wxDefaultCoord
)
588 if ( wy
== wxDefaultCoord
)
591 win
->GetSize(&ww
, &wh
);
592 if ( wx
+ ww
> maxX
)
594 if ( wy
+ wh
> maxY
)
598 best
= wxSize(maxX
, maxY
);
600 else // ! has children
602 // for a generic window there is no natural best size so, if the
603 // minimal size is not set, use the current size but take care to
604 // remember it as minimal size for the next time because our best size
605 // should be constant: otherwise we could get into a situation when the
606 // window is initially at some size, then expanded to a larger size and
607 // then, when the containing window is shrunk back (because our initial
608 // best size had been used for computing the parent min size), we can't
609 // be shrunk back any more because our best size is now bigger
610 wxSize size
= GetMinSize();
611 if ( !size
.IsFullySpecified() )
613 size
.SetDefaults(GetSize());
614 wxConstCast(this, wxWindowBase
)->SetMinSize(size
);
617 // return as-is, unadjusted by the client size difference.
621 // Add any difference between size and client size
622 wxSize diff
= GetSize() - GetClientSize();
623 best
.x
+= wxMax(0, diff
.x
);
624 best
.y
+= wxMax(0, diff
.y
);
629 // helper of GetWindowBorderSize(): as many ports don't implement support for
630 // wxSYS_BORDER/EDGE_X/Y metrics in their wxSystemSettings, use hard coded
631 // fallbacks in this case
632 static int wxGetMetricOrDefault(wxSystemMetric what
, const wxWindowBase
* win
)
634 int rc
= wxSystemSettings::GetMetric(
635 what
, static_cast<wxWindow
*>(const_cast<wxWindowBase
*>(win
)));
642 // 2D border is by default 1 pixel wide
648 // 3D borders are by default 2 pixels
653 wxFAIL_MSG( _T("unexpected wxGetMetricOrDefault() argument") );
661 wxSize
wxWindowBase::GetWindowBorderSize() const
665 switch ( GetBorder() )
668 // nothing to do, size is already (0, 0)
671 case wxBORDER_SIMPLE
:
672 case wxBORDER_STATIC
:
673 size
.x
= wxGetMetricOrDefault(wxSYS_BORDER_X
, this);
674 size
.y
= wxGetMetricOrDefault(wxSYS_BORDER_Y
, this);
677 case wxBORDER_SUNKEN
:
678 case wxBORDER_RAISED
:
679 size
.x
= wxMax(wxGetMetricOrDefault(wxSYS_EDGE_X
, this),
680 wxGetMetricOrDefault(wxSYS_BORDER_X
, this));
681 size
.y
= wxMax(wxGetMetricOrDefault(wxSYS_EDGE_Y
, this),
682 wxGetMetricOrDefault(wxSYS_BORDER_Y
, this));
685 case wxBORDER_DOUBLE
:
686 size
.x
= wxGetMetricOrDefault(wxSYS_EDGE_X
, this) +
687 wxGetMetricOrDefault(wxSYS_BORDER_X
, this);
688 size
.y
= wxGetMetricOrDefault(wxSYS_EDGE_Y
, this) +
689 wxGetMetricOrDefault(wxSYS_BORDER_Y
, this);
693 wxFAIL_MSG(_T("Unknown border style."));
697 // we have borders on both sides
701 wxSize
wxWindowBase::GetEffectiveMinSize() const
703 // merge the best size with the min size, giving priority to the min size
704 wxSize min
= GetMinSize();
706 if (min
.x
== wxDefaultCoord
|| min
.y
== wxDefaultCoord
)
708 wxSize best
= GetBestSize();
709 if (min
.x
== wxDefaultCoord
) min
.x
= best
.x
;
710 if (min
.y
== wxDefaultCoord
) min
.y
= best
.y
;
716 wxSize
wxWindowBase::GetBestSize() const
718 if ((!m_windowSizer
) && (m_bestSizeCache
.IsFullySpecified()))
719 return m_bestSizeCache
;
721 return DoGetBestSize();
724 void wxWindowBase::SetMinSize(const wxSize
& minSize
)
726 m_minWidth
= minSize
.x
;
727 m_minHeight
= minSize
.y
;
730 void wxWindowBase::SetMaxSize(const wxSize
& maxSize
)
732 m_maxWidth
= maxSize
.x
;
733 m_maxHeight
= maxSize
.y
;
736 void wxWindowBase::SetInitialSize(const wxSize
& size
)
738 // Set the min size to the size passed in. This will usually either be
739 // wxDefaultSize or the size passed to this window's ctor/Create function.
742 // Merge the size with the best size if needed
743 wxSize best
= GetEffectiveMinSize();
745 // If the current size doesn't match then change it
746 if (GetSize() != best
)
751 // by default the origin is not shifted
752 wxPoint
wxWindowBase::GetClientAreaOrigin() const
757 wxSize
wxWindowBase::ClientToWindowSize(const wxSize
& size
) const
759 const wxSize
diff(GetSize() - GetClientSize());
761 return wxSize(size
.x
== -1 ? -1 : size
.x
+ diff
.x
,
762 size
.y
== -1 ? -1 : size
.y
+ diff
.y
);
765 wxSize
wxWindowBase::WindowToClientSize(const wxSize
& size
) const
767 const wxSize
diff(GetSize() - GetClientSize());
769 return wxSize(size
.x
== -1 ? -1 : size
.x
- diff
.x
,
770 size
.y
== -1 ? -1 : size
.y
- diff
.y
);
773 void wxWindowBase::SetWindowVariant( wxWindowVariant variant
)
775 if ( m_windowVariant
!= variant
)
777 m_windowVariant
= variant
;
779 DoSetWindowVariant(variant
);
783 void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant
)
785 // adjust the font height to correspond to our new variant (notice that
786 // we're only called if something really changed)
787 wxFont font
= GetFont();
788 int size
= font
.GetPointSize();
791 case wxWINDOW_VARIANT_NORMAL
:
794 case wxWINDOW_VARIANT_SMALL
:
799 case wxWINDOW_VARIANT_MINI
:
804 case wxWINDOW_VARIANT_LARGE
:
810 wxFAIL_MSG(_T("unexpected window variant"));
814 font
.SetPointSize(size
);
818 void wxWindowBase::DoSetSizeHints( int minW
, int minH
,
820 int WXUNUSED(incW
), int WXUNUSED(incH
) )
822 wxCHECK_RET( (minW
== wxDefaultCoord
|| maxW
== wxDefaultCoord
|| minW
<= maxW
) &&
823 (minH
== wxDefaultCoord
|| maxH
== wxDefaultCoord
|| minH
<= maxH
),
824 _T("min width/height must be less than max width/height!") );
833 #if WXWIN_COMPATIBILITY_2_8
834 void wxWindowBase::SetVirtualSizeHints(int WXUNUSED(minW
), int WXUNUSED(minH
),
835 int WXUNUSED(maxW
), int WXUNUSED(maxH
))
839 void wxWindowBase::SetVirtualSizeHints(const wxSize
& WXUNUSED(minsize
),
840 const wxSize
& WXUNUSED(maxsize
))
843 #endif // WXWIN_COMPATIBILITY_2_8
845 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
847 m_virtualSize
= wxSize(x
, y
);
850 wxSize
wxWindowBase::DoGetVirtualSize() const
852 // we should use the entire client area so if it is greater than our
853 // virtual size, expand it to fit (otherwise if the window is big enough we
854 // wouldn't be using parts of it)
855 wxSize size
= GetClientSize();
856 if ( m_virtualSize
.x
> size
.x
)
857 size
.x
= m_virtualSize
.x
;
859 if ( m_virtualSize
.y
>= size
.y
)
860 size
.y
= m_virtualSize
.y
;
865 void wxWindowBase::DoGetScreenPosition(int *x
, int *y
) const
867 // screen position is the same as (0, 0) in client coords for non TLWs (and
868 // TLWs override this method)
874 ClientToScreen(x
, y
);
877 void wxWindowBase::SendSizeEvent(int flags
)
879 wxSizeEvent
event(GetSize(), GetId());
880 event
.SetEventObject(this);
881 if ( flags
& wxSEND_EVENT_POST
)
882 wxPostEvent(this, event
);
884 HandleWindowEvent(event
);
887 void wxWindowBase::SendSizeEventToParent(int flags
)
889 wxWindow
* const parent
= GetParent();
890 if ( parent
&& !parent
->IsBeingDeleted() )
891 parent
->SendSizeEvent(flags
);
894 // ----------------------------------------------------------------------------
895 // show/hide/enable/disable the window
896 // ----------------------------------------------------------------------------
898 bool wxWindowBase::Show(bool show
)
900 if ( show
!= m_isShown
)
912 bool wxWindowBase::IsEnabled() const
914 return IsThisEnabled() && (IsTopLevel() || !GetParent() || GetParent()->IsEnabled());
917 void wxWindowBase::NotifyWindowOnEnableChange(bool enabled
)
919 #ifndef wxHAS_NATIVE_ENABLED_MANAGEMENT
921 #endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
925 // If we are top-level then the logic doesn't apply - otherwise
926 // showing a modal dialog would result in total greying out (and ungreying
927 // out later) of everything which would be really ugly
931 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
933 node
= node
->GetNext() )
935 wxWindowBase
* const child
= node
->GetData();
936 if ( !child
->IsTopLevel() && child
->IsThisEnabled() )
937 child
->NotifyWindowOnEnableChange(enabled
);
941 bool wxWindowBase::Enable(bool enable
)
943 if ( enable
== IsThisEnabled() )
946 m_isEnabled
= enable
;
948 #ifdef wxHAS_NATIVE_ENABLED_MANAGEMENT
950 #else // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
951 wxWindowBase
* const parent
= GetParent();
952 if( !IsTopLevel() && parent
&& !parent
->IsEnabled() )
956 #endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
958 NotifyWindowOnEnableChange(enable
);
963 bool wxWindowBase::IsShownOnScreen() const
965 // A window is shown on screen if it itself is shown and so are all its
966 // parents. But if a window is toplevel one, then its always visible on
967 // screen if IsShown() returns true, even if it has a hidden parent.
969 (IsTopLevel() || GetParent() == NULL
|| GetParent()->IsShownOnScreen());
972 // ----------------------------------------------------------------------------
974 // ----------------------------------------------------------------------------
976 bool wxWindowBase::IsTopLevel() const
981 // ----------------------------------------------------------------------------
983 // ----------------------------------------------------------------------------
985 void wxWindowBase::Freeze()
987 if ( !m_freezeCount
++ )
989 // physically freeze this window:
992 // and recursively freeze all children:
993 for ( wxWindowList::iterator i
= GetChildren().begin();
994 i
!= GetChildren().end(); ++i
)
996 wxWindow
*child
= *i
;
997 if ( child
->IsTopLevel() )
1005 void wxWindowBase::Thaw()
1007 wxASSERT_MSG( m_freezeCount
, "Thaw() without matching Freeze()" );
1009 if ( !--m_freezeCount
)
1011 // recursively thaw all children:
1012 for ( wxWindowList::iterator i
= GetChildren().begin();
1013 i
!= GetChildren().end(); ++i
)
1015 wxWindow
*child
= *i
;
1016 if ( child
->IsTopLevel() )
1022 // physically thaw this window:
1027 // ----------------------------------------------------------------------------
1028 // reparenting the window
1029 // ----------------------------------------------------------------------------
1031 void wxWindowBase::AddChild(wxWindowBase
*child
)
1033 wxCHECK_RET( child
, wxT("can't add a NULL child") );
1035 // this should never happen and it will lead to a crash later if it does
1036 // because RemoveChild() will remove only one node from the children list
1037 // and the other(s) one(s) will be left with dangling pointers in them
1038 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), _T("AddChild() called twice") );
1040 GetChildren().Append((wxWindow
*)child
);
1041 child
->SetParent(this);
1043 // adding a child while frozen will assert when thawed, so freeze it as if
1044 // it had been already present when we were frozen
1045 if ( IsFrozen() && !child
->IsTopLevel() )
1049 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
1051 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
1053 // removing a child while frozen may result in permanently frozen window
1054 // if used e.g. from Reparent(), so thaw it
1056 // NB: IsTopLevel() doesn't return true any more when a TLW child is being
1057 // removed from its ~wxWindowBase, so check for IsBeingDeleted() too
1058 if ( IsFrozen() && !child
->IsBeingDeleted() && !child
->IsTopLevel() )
1061 GetChildren().DeleteObject((wxWindow
*)child
);
1062 child
->SetParent(NULL
);
1065 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
1067 wxWindow
*oldParent
= GetParent();
1068 if ( newParent
== oldParent
)
1074 const bool oldEnabledState
= IsEnabled();
1076 // unlink this window from the existing parent.
1079 oldParent
->RemoveChild(this);
1083 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
1086 // add it to the new one
1089 newParent
->AddChild(this);
1093 wxTopLevelWindows
.Append((wxWindow
*)this);
1096 // We need to notify window (and its subwindows) if by changing the parent
1097 // we also change our enabled/disabled status.
1098 const bool newEnabledState
= IsEnabled();
1099 if ( newEnabledState
!= oldEnabledState
)
1101 NotifyWindowOnEnableChange(newEnabledState
);
1107 // ----------------------------------------------------------------------------
1108 // event handler stuff
1109 // ----------------------------------------------------------------------------
1111 void wxWindowBase::SetEventHandler(wxEvtHandler
*handler
)
1113 wxCHECK_RET(handler
!= NULL
, "SetEventHandler(NULL) called");
1115 m_eventHandler
= handler
;
1118 void wxWindowBase::SetNextHandler(wxEvtHandler
*WXUNUSED(handler
))
1120 // disable wxEvtHandler chain mechanism for wxWindows:
1121 // wxWindow uses its own stack mechanism which doesn't mix well with wxEvtHandler's one
1123 wxFAIL_MSG("wxWindow cannot be part of a wxEvtHandler chain");
1125 void wxWindowBase::SetPreviousHandler(wxEvtHandler
*WXUNUSED(handler
))
1127 // we can't simply wxFAIL here as in SetNextHandler: in fact the last
1128 // handler of our stack when is destroyed will be Unlink()ed and thus
1129 // will call this function to update the pointer of this window...
1131 //wxFAIL_MSG("wxWindow cannot be part of a wxEvtHandler chain");
1134 void wxWindowBase::PushEventHandler(wxEvtHandler
*handlerToPush
)
1136 wxCHECK_RET( handlerToPush
!= NULL
, "PushEventHandler(NULL) called" );
1138 // the new handler is going to be part of the wxWindow stack of event handlers:
1139 // it can't be part also of an event handler double-linked chain:
1140 wxASSERT_MSG(handlerToPush
->IsUnlinked(),
1141 "The handler being pushed in the wxWindow stack shouldn't be part of "
1142 "a wxEvtHandler chain; call Unlink() on it first");
1144 wxEvtHandler
*handlerOld
= GetEventHandler();
1145 wxCHECK_RET( handlerOld
, "an old event handler is NULL?" );
1147 // now use wxEvtHandler double-linked list to implement a stack:
1148 handlerToPush
->SetNextHandler(handlerOld
);
1150 if (handlerOld
!= this)
1151 handlerOld
->SetPreviousHandler(handlerToPush
);
1153 SetEventHandler(handlerToPush
);
1156 // final checks of the operations done above:
1157 wxASSERT_MSG( handlerToPush
->GetPreviousHandler() == NULL
,
1158 "the first handler of the wxWindow stack should "
1159 "have no previous handlers set" );
1160 wxASSERT_MSG( handlerToPush
->GetNextHandler() != NULL
,
1161 "the first handler of the wxWindow stack should "
1162 "have non-NULL next handler" );
1164 wxEvtHandler
* pLast
= handlerToPush
;
1165 while ( pLast
&& pLast
!= this )
1166 pLast
= pLast
->GetNextHandler();
1167 wxASSERT_MSG( pLast
->GetNextHandler() == NULL
,
1168 "the last handler of the wxWindow stack should "
1169 "have this window as next handler" );
1170 #endif // wxDEBUG_LEVEL
1173 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
1175 // we need to pop the wxWindow stack, i.e. we need to remove the first handler
1177 wxEvtHandler
*firstHandler
= GetEventHandler();
1178 wxCHECK_MSG( firstHandler
!= NULL
, NULL
, "wxWindow cannot have a NULL event handler" );
1179 wxCHECK_MSG( firstHandler
!= this, NULL
, "cannot pop the wxWindow itself" );
1180 wxCHECK_MSG( firstHandler
->GetPreviousHandler() == NULL
, NULL
,
1181 "the first handler of the wxWindow stack should have no previous handlers set" );
1183 wxEvtHandler
*secondHandler
= firstHandler
->GetNextHandler();
1184 wxCHECK_MSG( secondHandler
!= NULL
, NULL
,
1185 "the first handler of the wxWindow stack should have non-NULL next handler" );
1187 firstHandler
->SetNextHandler(NULL
);
1188 secondHandler
->SetPreviousHandler(NULL
);
1190 // now firstHandler is completely unlinked; set secondHandler as the new window event handler
1191 SetEventHandler(secondHandler
);
1193 if ( deleteHandler
)
1195 delete firstHandler
;
1196 firstHandler
= NULL
;
1199 return firstHandler
;
1202 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handlerToRemove
)
1204 wxCHECK_MSG( handlerToRemove
!= NULL
, false, "RemoveEventHandler(NULL) called" );
1205 wxCHECK_MSG( handlerToRemove
!= this, false, "Cannot remove the window itself" );
1207 if (handlerToRemove
== GetEventHandler())
1209 // removing the first event handler is equivalent to "popping" the stack
1210 PopEventHandler(false);
1214 // NOTE: the wxWindow event handler list is always terminated with "this" handler
1215 wxEvtHandler
*handlerCur
= GetEventHandler()->GetNextHandler();
1216 while ( handlerCur
!= this )
1218 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
1220 if ( handlerCur
== handlerToRemove
)
1222 handlerCur
->Unlink();
1224 wxASSERT_MSG( handlerCur
!= GetEventHandler(),
1225 "the case Remove == Pop should was already handled" );
1229 handlerCur
= handlerNext
;
1232 wxFAIL_MSG( _T("where has the event handler gone?") );
1237 bool wxWindowBase::HandleWindowEvent(wxEvent
& event
) const
1239 // SafelyProcessEvent() will handle exceptions nicely
1240 return GetEventHandler()->SafelyProcessEvent(event
);
1243 // ----------------------------------------------------------------------------
1244 // colours, fonts &c
1245 // ----------------------------------------------------------------------------
1247 void wxWindowBase::InheritAttributes()
1249 const wxWindowBase
* const parent
= GetParent();
1253 // we only inherit attributes which had been explicitly set for the parent
1254 // which ensures that this only happens if the user really wants it and
1255 // not by default which wouldn't make any sense in modern GUIs where the
1256 // controls don't all use the same fonts (nor colours)
1257 if ( parent
->m_inheritFont
&& !m_hasFont
)
1258 SetFont(parent
->GetFont());
1260 // in addition, there is a possibility to explicitly forbid inheriting
1261 // colours at each class level by overriding ShouldInheritColours()
1262 if ( ShouldInheritColours() )
1264 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
1265 SetForegroundColour(parent
->GetForegroundColour());
1267 // inheriting (solid) background colour is wrong as it totally breaks
1268 // any kind of themed backgrounds
1270 // instead, the controls should use the same background as their parent
1271 // (ideally by not drawing it at all)
1273 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
1274 SetBackgroundColour(parent
->GetBackgroundColour());
1279 /* static */ wxVisualAttributes
1280 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
1282 // it is important to return valid values for all attributes from here,
1283 // GetXXX() below rely on this
1284 wxVisualAttributes attrs
;
1285 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
1286 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
1288 // On Smartphone/PocketPC, wxSYS_COLOUR_WINDOW is a better reflection of
1289 // the usual background colour than wxSYS_COLOUR_BTNFACE.
1290 // It's a pity that wxSYS_COLOUR_WINDOW isn't always a suitable background
1291 // colour on other platforms.
1293 #if defined(__WXWINCE__) && (defined(__SMARTPHONE__) || defined(__POCKETPC__))
1294 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1296 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
1301 wxColour
wxWindowBase::GetBackgroundColour() const
1303 if ( !m_backgroundColour
.IsOk() )
1305 wxASSERT_MSG( !m_hasBgCol
, _T("we have invalid explicit bg colour?") );
1307 // get our default background colour
1308 wxColour colBg
= GetDefaultAttributes().colBg
;
1310 // we must return some valid colour to avoid redoing this every time
1311 // and also to avoid surprizing the applications written for older
1312 // wxWidgets versions where GetBackgroundColour() always returned
1313 // something -- so give them something even if it doesn't make sense
1314 // for this window (e.g. it has a themed background)
1316 colBg
= GetClassDefaultAttributes().colBg
;
1321 return m_backgroundColour
;
1324 wxColour
wxWindowBase::GetForegroundColour() const
1326 // logic is the same as above
1327 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
1329 wxColour colFg
= GetDefaultAttributes().colFg
;
1331 if ( !colFg
.IsOk() )
1332 colFg
= GetClassDefaultAttributes().colFg
;
1337 return m_foregroundColour
;
1340 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
1342 if ( colour
== m_backgroundColour
)
1345 m_hasBgCol
= colour
.IsOk();
1346 if ( m_backgroundStyle
!= wxBG_STYLE_CUSTOM
)
1347 m_backgroundStyle
= m_hasBgCol
? wxBG_STYLE_COLOUR
: wxBG_STYLE_SYSTEM
;
1349 m_inheritBgCol
= m_hasBgCol
;
1350 m_backgroundColour
= colour
;
1351 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1355 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1357 if (colour
== m_foregroundColour
)
1360 m_hasFgCol
= colour
.IsOk();
1361 m_inheritFgCol
= m_hasFgCol
;
1362 m_foregroundColour
= colour
;
1363 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1367 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1369 // setting an invalid cursor is ok, it means that we don't have any special
1371 if ( m_cursor
.IsSameAs(cursor
) )
1382 wxFont
wxWindowBase::GetFont() const
1384 // logic is the same as in GetBackgroundColour()
1385 if ( !m_font
.IsOk() )
1387 wxASSERT_MSG( !m_hasFont
, _T("we have invalid explicit font?") );
1389 wxFont font
= GetDefaultAttributes().font
;
1391 font
= GetClassDefaultAttributes().font
;
1399 bool wxWindowBase::SetFont(const wxFont
& font
)
1401 if ( font
== m_font
)
1408 m_hasFont
= font
.IsOk();
1409 m_inheritFont
= m_hasFont
;
1411 InvalidateBestSize();
1418 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1420 m_hasCustomPalette
= true;
1423 // VZ: can anyone explain me what do we do here?
1424 wxWindowDC
d((wxWindow
*) this);
1428 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1430 wxWindow
*win
= (wxWindow
*)this;
1431 while ( win
&& !win
->HasCustomPalette() )
1433 win
= win
->GetParent();
1439 #endif // wxUSE_PALETTE
1442 void wxWindowBase::SetCaret(wxCaret
*caret
)
1453 wxASSERT_MSG( m_caret
->GetWindow() == this,
1454 wxT("caret should be created associated to this window") );
1457 #endif // wxUSE_CARET
1459 #if wxUSE_VALIDATORS
1460 // ----------------------------------------------------------------------------
1462 // ----------------------------------------------------------------------------
1464 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1466 if ( m_windowValidator
)
1467 delete m_windowValidator
;
1469 m_windowValidator
= (wxValidator
*)validator
.Clone();
1471 if ( m_windowValidator
)
1472 m_windowValidator
->SetWindow(this);
1474 #endif // wxUSE_VALIDATORS
1476 // ----------------------------------------------------------------------------
1477 // update region stuff
1478 // ----------------------------------------------------------------------------
1480 wxRect
wxWindowBase::GetUpdateClientRect() const
1482 wxRegion rgnUpdate
= GetUpdateRegion();
1483 rgnUpdate
.Intersect(GetClientRect());
1484 wxRect rectUpdate
= rgnUpdate
.GetBox();
1485 wxPoint ptOrigin
= GetClientAreaOrigin();
1486 rectUpdate
.x
-= ptOrigin
.x
;
1487 rectUpdate
.y
-= ptOrigin
.y
;
1492 bool wxWindowBase::DoIsExposed(int x
, int y
) const
1494 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1497 bool wxWindowBase::DoIsExposed(int x
, int y
, int w
, int h
) const
1499 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1502 void wxWindowBase::ClearBackground()
1504 // wxGTK uses its own version, no need to add never used code
1506 wxClientDC
dc((wxWindow
*)this);
1507 wxBrush
brush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID
);
1508 dc
.SetBackground(brush
);
1513 // ----------------------------------------------------------------------------
1514 // find child window by id or name
1515 // ----------------------------------------------------------------------------
1517 wxWindow
*wxWindowBase::FindWindow(long id
) const
1519 if ( id
== m_windowId
)
1520 return (wxWindow
*)this;
1522 wxWindowBase
*res
= NULL
;
1523 wxWindowList::compatibility_iterator node
;
1524 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1526 wxWindowBase
*child
= node
->GetData();
1527 res
= child
->FindWindow( id
);
1530 return (wxWindow
*)res
;
1533 wxWindow
*wxWindowBase::FindWindow(const wxString
& name
) const
1535 if ( name
== m_windowName
)
1536 return (wxWindow
*)this;
1538 wxWindowBase
*res
= NULL
;
1539 wxWindowList::compatibility_iterator node
;
1540 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1542 wxWindow
*child
= node
->GetData();
1543 res
= child
->FindWindow(name
);
1546 return (wxWindow
*)res
;
1550 // find any window by id or name or label: If parent is non-NULL, look through
1551 // children for a label or title matching the specified string. If NULL, look
1552 // through all top-level windows.
1554 // to avoid duplicating code we reuse the same helper function but with
1555 // different comparators
1557 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1558 const wxString
& label
, long id
);
1561 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1564 return win
->GetLabel() == label
;
1568 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1571 return win
->GetName() == label
;
1575 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1578 return win
->GetId() == id
;
1581 // recursive helper for the FindWindowByXXX() functions
1583 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1584 const wxString
& label
,
1586 wxFindWindowCmp cmp
)
1590 // see if this is the one we're looking for
1591 if ( (*cmp
)(parent
, label
, id
) )
1592 return (wxWindow
*)parent
;
1594 // It wasn't, so check all its children
1595 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1597 node
= node
->GetNext() )
1599 // recursively check each child
1600 wxWindow
*win
= (wxWindow
*)node
->GetData();
1601 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1611 // helper for FindWindowByXXX()
1613 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1614 const wxString
& label
,
1616 wxFindWindowCmp cmp
)
1620 // just check parent and all its children
1621 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1624 // start at very top of wx's windows
1625 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1627 node
= node
->GetNext() )
1629 // recursively check each window & its children
1630 wxWindow
*win
= node
->GetData();
1631 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1641 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1643 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1648 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1650 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1654 // fall back to the label
1655 win
= FindWindowByLabel(title
, parent
);
1663 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1665 return wxFindWindowHelper(parent
, wxEmptyString
, id
, wxFindWindowCmpIds
);
1668 // ----------------------------------------------------------------------------
1669 // dialog oriented functions
1670 // ----------------------------------------------------------------------------
1672 void wxWindowBase::MakeModal(bool modal
)
1674 // Disable all other windows
1677 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1680 wxWindow
*win
= node
->GetData();
1682 win
->Enable(!modal
);
1684 node
= node
->GetNext();
1689 bool wxWindowBase::Validate()
1691 #if wxUSE_VALIDATORS
1692 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1694 wxWindowList::compatibility_iterator node
;
1695 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1697 wxWindowBase
*child
= node
->GetData();
1698 wxValidator
*validator
= child
->GetValidator();
1699 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1704 if ( recurse
&& !child
->Validate() )
1709 #endif // wxUSE_VALIDATORS
1714 bool wxWindowBase::TransferDataToWindow()
1716 #if wxUSE_VALIDATORS
1717 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1719 wxWindowList::compatibility_iterator node
;
1720 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1722 wxWindowBase
*child
= node
->GetData();
1723 wxValidator
*validator
= child
->GetValidator();
1724 if ( validator
&& !validator
->TransferToWindow() )
1726 wxLogWarning(_("Could not transfer data to window"));
1728 wxLog::FlushActive();
1736 if ( !child
->TransferDataToWindow() )
1738 // warning already given
1743 #endif // wxUSE_VALIDATORS
1748 bool wxWindowBase::TransferDataFromWindow()
1750 #if wxUSE_VALIDATORS
1751 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1753 wxWindowList::compatibility_iterator node
;
1754 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1756 wxWindow
*child
= node
->GetData();
1757 wxValidator
*validator
= child
->GetValidator();
1758 if ( validator
&& !validator
->TransferFromWindow() )
1760 // nop warning here because the application is supposed to give
1761 // one itself - we don't know here what might have gone wrongly
1768 if ( !child
->TransferDataFromWindow() )
1770 // warning already given
1775 #endif // wxUSE_VALIDATORS
1780 void wxWindowBase::InitDialog()
1782 wxInitDialogEvent
event(GetId());
1783 event
.SetEventObject( this );
1784 GetEventHandler()->ProcessEvent(event
);
1787 // ----------------------------------------------------------------------------
1788 // context-sensitive help support
1789 // ----------------------------------------------------------------------------
1793 // associate this help text with this window
1794 void wxWindowBase::SetHelpText(const wxString
& text
)
1796 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1799 helpProvider
->AddHelp(this, text
);
1803 #if WXWIN_COMPATIBILITY_2_8
1804 // associate this help text with all windows with the same id as this
1806 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1808 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1811 helpProvider
->AddHelp(GetId(), text
);
1814 #endif // WXWIN_COMPATIBILITY_2_8
1816 // get the help string associated with this window (may be empty)
1817 // default implementation forwards calls to the help provider
1819 wxWindowBase::GetHelpTextAtPoint(const wxPoint
& WXUNUSED(pt
),
1820 wxHelpEvent::Origin
WXUNUSED(origin
)) const
1823 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1826 text
= helpProvider
->GetHelp(this);
1832 // show help for this window
1833 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1835 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1838 wxPoint pos
= event
.GetPosition();
1839 const wxHelpEvent::Origin origin
= event
.GetOrigin();
1840 if ( origin
== wxHelpEvent::Origin_Keyboard
)
1842 // if the help event was generated from keyboard it shouldn't
1843 // appear at the mouse position (which is still the only position
1844 // associated with help event) if the mouse is far away, although
1845 // we still do use the mouse position if it's over the window
1846 // because we suppose the user looks approximately at the mouse
1847 // already and so it would be more convenient than showing tooltip
1848 // at some arbitrary position which can be quite far from it
1849 const wxRect rectClient
= GetClientRect();
1850 if ( !rectClient
.Contains(ScreenToClient(pos
)) )
1852 // position help slightly under and to the right of this window
1853 pos
= ClientToScreen(wxPoint(
1855 rectClient
.height
+ GetCharHeight()
1860 if ( helpProvider
->ShowHelpAtPoint(this, pos
, origin
) )
1862 // skip the event.Skip() below
1870 #endif // wxUSE_HELP
1872 // ----------------------------------------------------------------------------
1874 // ----------------------------------------------------------------------------
1878 void wxWindowBase::SetToolTip( const wxString
&tip
)
1880 // don't create the new tooltip if we already have one
1883 m_tooltip
->SetTip( tip
);
1887 SetToolTip( new wxToolTip( tip
) );
1890 // setting empty tooltip text does not remove the tooltip any more - use
1891 // SetToolTip(NULL) for this
1894 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1896 if ( m_tooltip
!= tooltip
)
1901 m_tooltip
= tooltip
;
1905 #endif // wxUSE_TOOLTIPS
1907 // ----------------------------------------------------------------------------
1908 // constraints and sizers
1909 // ----------------------------------------------------------------------------
1911 #if wxUSE_CONSTRAINTS
1913 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1915 if ( m_constraints
)
1917 UnsetConstraints(m_constraints
);
1918 delete m_constraints
;
1920 m_constraints
= constraints
;
1921 if ( m_constraints
)
1923 // Make sure other windows know they're part of a 'meaningful relationship'
1924 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1925 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1926 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1927 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1928 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1929 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1930 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1931 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1932 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1933 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1934 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1935 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1936 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1937 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1938 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1939 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1943 // This removes any dangling pointers to this window in other windows'
1944 // constraintsInvolvedIn lists.
1945 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1949 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1950 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1951 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1952 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1953 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1954 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1955 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1956 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1957 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1958 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1959 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1960 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1961 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1962 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1963 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1964 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1968 // Back-pointer to other windows we're involved with, so if we delete this
1969 // window, we must delete any constraints we're involved with.
1970 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
1972 if ( !m_constraintsInvolvedIn
)
1973 m_constraintsInvolvedIn
= new wxWindowList
;
1974 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
1975 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
1978 // REMOVE back-pointer to other windows we're involved with.
1979 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
1981 if ( m_constraintsInvolvedIn
)
1982 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
1985 // Reset any constraints that mention this window
1986 void wxWindowBase::DeleteRelatedConstraints()
1988 if ( m_constraintsInvolvedIn
)
1990 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
1993 wxWindow
*win
= node
->GetData();
1994 wxLayoutConstraints
*constr
= win
->GetConstraints();
1996 // Reset any constraints involving this window
1999 constr
->left
.ResetIfWin(this);
2000 constr
->top
.ResetIfWin(this);
2001 constr
->right
.ResetIfWin(this);
2002 constr
->bottom
.ResetIfWin(this);
2003 constr
->width
.ResetIfWin(this);
2004 constr
->height
.ResetIfWin(this);
2005 constr
->centreX
.ResetIfWin(this);
2006 constr
->centreY
.ResetIfWin(this);
2009 wxWindowList::compatibility_iterator next
= node
->GetNext();
2010 m_constraintsInvolvedIn
->Erase(node
);
2014 delete m_constraintsInvolvedIn
;
2015 m_constraintsInvolvedIn
= NULL
;
2019 #endif // wxUSE_CONSTRAINTS
2021 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
2023 if ( sizer
== m_windowSizer
)
2026 if ( m_windowSizer
)
2028 m_windowSizer
->SetContainingWindow(NULL
);
2031 delete m_windowSizer
;
2034 m_windowSizer
= sizer
;
2035 if ( m_windowSizer
)
2037 m_windowSizer
->SetContainingWindow((wxWindow
*)this);
2040 SetAutoLayout(m_windowSizer
!= NULL
);
2043 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
2045 SetSizer( sizer
, deleteOld
);
2046 sizer
->SetSizeHints( (wxWindow
*) this );
2050 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
2052 // adding a window to a sizer twice is going to result in fatal and
2053 // hard to debug problems later because when deleting the second
2054 // associated wxSizerItem we're going to dereference a dangling
2055 // pointer; so try to detect this as early as possible
2056 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
2057 _T("Adding a window to the same sizer twice?") );
2059 m_containingSizer
= sizer
;
2062 #if wxUSE_CONSTRAINTS
2064 void wxWindowBase::SatisfyConstraints()
2066 wxLayoutConstraints
*constr
= GetConstraints();
2067 bool wasOk
= constr
&& constr
->AreSatisfied();
2069 ResetConstraints(); // Mark all constraints as unevaluated
2073 // if we're a top level panel (i.e. our parent is frame/dialog), our
2074 // own constraints will never be satisfied any more unless we do it
2078 while ( noChanges
> 0 )
2080 LayoutPhase1(&noChanges
);
2084 LayoutPhase2(&noChanges
);
2087 #endif // wxUSE_CONSTRAINTS
2089 bool wxWindowBase::Layout()
2091 // If there is a sizer, use it instead of the constraints
2095 GetVirtualSize(&w
, &h
);
2096 GetSizer()->SetDimension( 0, 0, w
, h
);
2098 #if wxUSE_CONSTRAINTS
2101 SatisfyConstraints(); // Find the right constraints values
2102 SetConstraintSizes(); // Recursively set the real window sizes
2109 #if wxUSE_CONSTRAINTS
2111 // first phase of the constraints evaluation: set our own constraints
2112 bool wxWindowBase::LayoutPhase1(int *noChanges
)
2114 wxLayoutConstraints
*constr
= GetConstraints();
2116 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
2119 // second phase: set the constraints for our children
2120 bool wxWindowBase::LayoutPhase2(int *noChanges
)
2127 // Layout grand children
2133 // Do a phase of evaluating child constraints
2134 bool wxWindowBase::DoPhase(int phase
)
2136 // the list containing the children for which the constraints are already
2138 wxWindowList succeeded
;
2140 // the max number of iterations we loop before concluding that we can't set
2142 static const int maxIterations
= 500;
2144 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
2148 // loop over all children setting their constraints
2149 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2151 node
= node
->GetNext() )
2153 wxWindow
*child
= node
->GetData();
2154 if ( child
->IsTopLevel() )
2156 // top level children are not inside our client area
2160 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
2162 // this one is either already ok or nothing we can do about it
2166 int tempNoChanges
= 0;
2167 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
2168 : child
->LayoutPhase2(&tempNoChanges
);
2169 noChanges
+= tempNoChanges
;
2173 succeeded
.Append(child
);
2179 // constraints are set
2187 void wxWindowBase::ResetConstraints()
2189 wxLayoutConstraints
*constr
= GetConstraints();
2192 constr
->left
.SetDone(false);
2193 constr
->top
.SetDone(false);
2194 constr
->right
.SetDone(false);
2195 constr
->bottom
.SetDone(false);
2196 constr
->width
.SetDone(false);
2197 constr
->height
.SetDone(false);
2198 constr
->centreX
.SetDone(false);
2199 constr
->centreY
.SetDone(false);
2202 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2205 wxWindow
*win
= node
->GetData();
2206 if ( !win
->IsTopLevel() )
2207 win
->ResetConstraints();
2208 node
= node
->GetNext();
2212 // Need to distinguish between setting the 'fake' size for windows and sizers,
2213 // and setting the real values.
2214 void wxWindowBase::SetConstraintSizes(bool recurse
)
2216 wxLayoutConstraints
*constr
= GetConstraints();
2217 if ( constr
&& constr
->AreSatisfied() )
2219 int x
= constr
->left
.GetValue();
2220 int y
= constr
->top
.GetValue();
2221 int w
= constr
->width
.GetValue();
2222 int h
= constr
->height
.GetValue();
2224 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
2225 (constr
->height
.GetRelationship() != wxAsIs
) )
2227 SetSize(x
, y
, w
, h
);
2231 // If we don't want to resize this window, just move it...
2237 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
2238 GetClassInfo()->GetClassName(),
2244 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2247 wxWindow
*win
= node
->GetData();
2248 if ( !win
->IsTopLevel() && win
->GetConstraints() )
2249 win
->SetConstraintSizes();
2250 node
= node
->GetNext();
2255 // Only set the size/position of the constraint (if any)
2256 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
2258 wxLayoutConstraints
*constr
= GetConstraints();
2261 if ( x
!= wxDefaultCoord
)
2263 constr
->left
.SetValue(x
);
2264 constr
->left
.SetDone(true);
2266 if ( y
!= wxDefaultCoord
)
2268 constr
->top
.SetValue(y
);
2269 constr
->top
.SetDone(true);
2271 if ( w
!= wxDefaultCoord
)
2273 constr
->width
.SetValue(w
);
2274 constr
->width
.SetDone(true);
2276 if ( h
!= wxDefaultCoord
)
2278 constr
->height
.SetValue(h
);
2279 constr
->height
.SetDone(true);
2284 void wxWindowBase::MoveConstraint(int x
, int y
)
2286 wxLayoutConstraints
*constr
= GetConstraints();
2289 if ( x
!= wxDefaultCoord
)
2291 constr
->left
.SetValue(x
);
2292 constr
->left
.SetDone(true);
2294 if ( y
!= wxDefaultCoord
)
2296 constr
->top
.SetValue(y
);
2297 constr
->top
.SetDone(true);
2302 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
2304 wxLayoutConstraints
*constr
= GetConstraints();
2307 *w
= constr
->width
.GetValue();
2308 *h
= constr
->height
.GetValue();
2314 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
2316 wxLayoutConstraints
*constr
= GetConstraints();
2319 *w
= constr
->width
.GetValue();
2320 *h
= constr
->height
.GetValue();
2323 GetClientSize(w
, h
);
2326 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
2328 wxLayoutConstraints
*constr
= GetConstraints();
2331 *x
= constr
->left
.GetValue();
2332 *y
= constr
->top
.GetValue();
2338 #endif // wxUSE_CONSTRAINTS
2340 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
2342 // don't do it for the dialogs/frames - they float independently of their
2344 if ( !IsTopLevel() )
2346 wxWindow
*parent
= GetParent();
2347 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
2349 wxPoint
pt(parent
->GetClientAreaOrigin());
2356 // ----------------------------------------------------------------------------
2357 // Update UI processing
2358 // ----------------------------------------------------------------------------
2360 void wxWindowBase::UpdateWindowUI(long flags
)
2362 wxUpdateUIEvent
event(GetId());
2363 event
.SetEventObject(this);
2365 if ( GetEventHandler()->ProcessEvent(event
) )
2367 DoUpdateWindowUI(event
);
2370 if (flags
& wxUPDATE_UI_RECURSE
)
2372 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2375 wxWindow
* child
= (wxWindow
*) node
->GetData();
2376 child
->UpdateWindowUI(flags
);
2377 node
= node
->GetNext();
2382 // do the window-specific processing after processing the update event
2383 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
2385 if ( event
.GetSetEnabled() )
2386 Enable(event
.GetEnabled());
2388 if ( event
.GetSetShown() )
2389 Show(event
.GetShown());
2392 // ----------------------------------------------------------------------------
2393 // dialog units translations
2394 // ----------------------------------------------------------------------------
2396 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
2398 int charWidth
= GetCharWidth();
2399 int charHeight
= GetCharHeight();
2400 wxPoint pt2
= wxDefaultPosition
;
2401 if (pt
.x
!= wxDefaultCoord
)
2402 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
);
2403 if (pt
.y
!= wxDefaultCoord
)
2404 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2409 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2411 int charWidth
= GetCharWidth();
2412 int charHeight
= GetCharHeight();
2413 wxPoint pt2
= wxDefaultPosition
;
2414 if (pt
.x
!= wxDefaultCoord
)
2415 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2416 if (pt
.y
!= wxDefaultCoord
)
2417 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2422 // ----------------------------------------------------------------------------
2424 // ----------------------------------------------------------------------------
2426 // propagate the colour change event to the subwindows
2427 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2429 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2432 // Only propagate to non-top-level windows
2433 wxWindow
*win
= node
->GetData();
2434 if ( !win
->IsTopLevel() )
2436 wxSysColourChangedEvent event2
;
2437 event
.SetEventObject(win
);
2438 win
->GetEventHandler()->ProcessEvent(event2
);
2441 node
= node
->GetNext();
2447 // the default action is to populate dialog with data when it's created,
2448 // and nudge the UI into displaying itself correctly in case
2449 // we've turned the wxUpdateUIEvents frequency down low.
2450 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2452 TransferDataToWindow();
2454 // Update the UI at this point
2455 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2458 // ----------------------------------------------------------------------------
2459 // menu-related functions
2460 // ----------------------------------------------------------------------------
2464 bool wxWindowBase::PopupMenu(wxMenu
*menu
, int x
, int y
)
2466 wxCHECK_MSG( menu
, false, "can't popup NULL menu" );
2468 wxCurrentPopupMenu
= menu
;
2469 const bool rc
= DoPopupMenu(menu
, x
, y
);
2470 wxCurrentPopupMenu
= NULL
;
2475 // this is used to pass the id of the selected item from the menu event handler
2476 // to the main function itself
2478 // it's ok to use a global here as there can be at most one popup menu shown at
2480 static int gs_popupMenuSelection
= wxID_NONE
;
2482 void wxWindowBase::InternalOnPopupMenu(wxCommandEvent
& event
)
2484 // store the id in a global variable where we'll retrieve it from later
2485 gs_popupMenuSelection
= event
.GetId();
2488 void wxWindowBase::InternalOnPopupMenuUpdate(wxUpdateUIEvent
& WXUNUSED(event
))
2490 // nothing to do but do not skip it
2494 wxWindowBase::DoGetPopupMenuSelectionFromUser(wxMenu
& menu
, int x
, int y
)
2496 gs_popupMenuSelection
= wxID_NONE
;
2498 Connect(wxEVT_COMMAND_MENU_SELECTED
,
2499 wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu
),
2503 // it is common to construct the menu passed to this function dynamically
2504 // using some fixed range of ids which could clash with the ids used
2505 // elsewhere in the program, which could result in some menu items being
2506 // unintentionally disabled or otherwise modified by update UI handlers
2507 // elsewhere in the program code and this is difficult to avoid in the
2508 // program itself, so instead we just temporarily suspend UI updating while
2509 // this menu is shown
2510 Connect(wxEVT_UPDATE_UI
,
2511 wxUpdateUIEventHandler(wxWindowBase::InternalOnPopupMenuUpdate
),
2515 PopupMenu(&menu
, x
, y
);
2517 Disconnect(wxEVT_UPDATE_UI
,
2518 wxUpdateUIEventHandler(wxWindowBase::InternalOnPopupMenuUpdate
),
2521 Disconnect(wxEVT_COMMAND_MENU_SELECTED
,
2522 wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu
),
2526 return gs_popupMenuSelection
;
2529 #endif // wxUSE_MENUS
2531 // methods for drawing the sizers in a visible way
2534 static void DrawSizers(wxWindowBase
*win
);
2536 static void DrawBorder(wxWindowBase
*win
, const wxRect
& rect
, bool fill
, const wxPen
* pen
)
2538 wxClientDC
dc((wxWindow
*)win
);
2540 dc
.SetBrush(fill
? wxBrush(pen
->GetColour(), wxBRUSHSTYLE_CROSSDIAG_HATCH
) :
2541 *wxTRANSPARENT_BRUSH
);
2542 dc
.DrawRectangle(rect
.Deflate(1, 1));
2545 static void DrawSizer(wxWindowBase
*win
, wxSizer
*sizer
)
2547 const wxSizerItemList
& items
= sizer
->GetChildren();
2548 for ( wxSizerItemList::const_iterator i
= items
.begin(),
2553 wxSizerItem
*item
= *i
;
2554 if ( item
->IsSizer() )
2556 DrawBorder(win
, item
->GetRect().Deflate(2), false, wxRED_PEN
);
2557 DrawSizer(win
, item
->GetSizer());
2559 else if ( item
->IsSpacer() )
2561 DrawBorder(win
, item
->GetRect().Deflate(2), true, wxBLUE_PEN
);
2563 else if ( item
->IsWindow() )
2565 DrawSizers(item
->GetWindow());
2568 wxFAIL_MSG("inconsistent wxSizerItem status!");
2572 static void DrawSizers(wxWindowBase
*win
)
2574 DrawBorder(win
, win
->GetClientSize(), false, wxGREEN_PEN
);
2576 wxSizer
*sizer
= win
->GetSizer();
2579 DrawSizer(win
, sizer
);
2581 else // no sizer, still recurse into the children
2583 const wxWindowList
& children
= win
->GetChildren();
2584 for ( wxWindowList::const_iterator i
= children
.begin(),
2585 end
= children
.end();
2592 // show all kind of sizes of this window; see the "window sizing" topic
2593 // overview for more info about the various differences:
2594 wxSize fullSz
= win
->GetSize();
2595 wxSize clientSz
= win
->GetClientSize();
2596 wxSize bestSz
= win
->GetBestSize();
2597 wxSize minSz
= win
->GetMinSize();
2598 wxSize maxSz
= win
->GetMaxSize();
2599 wxSize virtualSz
= win
->GetVirtualSize();
2601 wxMessageOutputDebug dbgout
;
2603 "%-10s => fullsz=%4d;%-4d clientsz=%4d;%-4d bestsz=%4d;%-4d minsz=%4d;%-4d maxsz=%4d;%-4d virtualsz=%4d;%-4d\n",
2606 clientSz
.x
, clientSz
.y
,
2610 virtualSz
.x
, virtualSz
.y
);
2614 #endif // __WXDEBUG__
2616 // process special middle clicks
2617 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2619 if ( event
.ControlDown() && event
.AltDown() )
2622 // Ctrl-Alt-Shift-mclick makes the sizers visible in debug builds
2623 if ( event
.ShiftDown() )
2628 #endif // __WXDEBUG__
2629 ::wxInfoMessageBox((wxWindow
*)this);
2637 // ----------------------------------------------------------------------------
2639 // ----------------------------------------------------------------------------
2641 #if wxUSE_ACCESSIBILITY
2642 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2644 if (m_accessible
&& (accessible
!= m_accessible
))
2645 delete m_accessible
;
2646 m_accessible
= accessible
;
2648 m_accessible
->SetWindow((wxWindow
*) this);
2651 // Returns the accessible object, creating if necessary.
2652 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2655 m_accessible
= CreateAccessible();
2656 return m_accessible
;
2659 // Override to create a specific accessible object.
2660 wxAccessible
* wxWindowBase::CreateAccessible()
2662 return new wxWindowAccessible((wxWindow
*) this);
2667 // ----------------------------------------------------------------------------
2668 // list classes implementation
2669 // ----------------------------------------------------------------------------
2673 #include "wx/listimpl.cpp"
2674 WX_DEFINE_LIST(wxWindowList
)
2678 void wxWindowListNode::DeleteData()
2680 delete (wxWindow
*)GetData();
2683 #endif // wxUSE_STL/!wxUSE_STL
2685 // ----------------------------------------------------------------------------
2687 // ----------------------------------------------------------------------------
2689 wxBorder
wxWindowBase::GetBorder(long flags
) const
2691 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2692 if ( border
== wxBORDER_DEFAULT
)
2694 border
= GetDefaultBorder();
2696 else if ( border
== wxBORDER_THEME
)
2698 border
= GetDefaultBorderForControl();
2704 wxBorder
wxWindowBase::GetDefaultBorder() const
2706 return wxBORDER_NONE
;
2709 // ----------------------------------------------------------------------------
2711 // ----------------------------------------------------------------------------
2713 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2715 // here we just check if the point is inside the window or not
2717 // check the top and left border first
2718 bool outside
= x
< 0 || y
< 0;
2721 // check the right and bottom borders too
2722 wxSize size
= GetSize();
2723 outside
= x
>= size
.x
|| y
>= size
.y
;
2726 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2729 // ----------------------------------------------------------------------------
2731 // ----------------------------------------------------------------------------
2733 struct WXDLLEXPORT wxWindowNext
2737 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2738 wxWindow
*wxWindowBase::ms_winCaptureCurrent
= NULL
;
2739 bool wxWindowBase::ms_winCaptureChanging
= false;
2741 void wxWindowBase::CaptureMouse()
2743 wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), static_cast<void*>(this));
2745 wxASSERT_MSG( !ms_winCaptureChanging
, _T("recursive CaptureMouse call?") );
2747 ms_winCaptureChanging
= true;
2749 wxWindow
*winOld
= GetCapture();
2752 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2755 wxWindowNext
*item
= new wxWindowNext
;
2757 item
->next
= ms_winCaptureNext
;
2758 ms_winCaptureNext
= item
;
2760 //else: no mouse capture to save
2763 ms_winCaptureCurrent
= (wxWindow
*)this;
2765 ms_winCaptureChanging
= false;
2768 void wxWindowBase::ReleaseMouse()
2770 wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), static_cast<void*>(this));
2772 wxASSERT_MSG( !ms_winCaptureChanging
, _T("recursive ReleaseMouse call?") );
2774 wxASSERT_MSG( GetCapture() == this,
2775 "attempt to release mouse, but this window hasn't captured it" );
2776 wxASSERT_MSG( ms_winCaptureCurrent
== this,
2777 "attempt to release mouse, but this window hasn't captured it" );
2779 ms_winCaptureChanging
= true;
2782 ms_winCaptureCurrent
= NULL
;
2784 if ( ms_winCaptureNext
)
2786 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2787 ms_winCaptureCurrent
= ms_winCaptureNext
->win
;
2789 wxWindowNext
*item
= ms_winCaptureNext
;
2790 ms_winCaptureNext
= item
->next
;
2793 //else: stack is empty, no previous capture
2795 ms_winCaptureChanging
= false;
2797 wxLogTrace(_T("mousecapture"),
2798 (const wxChar
*) _T("After ReleaseMouse() mouse is captured by %p"),
2799 static_cast<void*>(GetCapture()));
2802 static void DoNotifyWindowAboutCaptureLost(wxWindow
*win
)
2804 wxMouseCaptureLostEvent
event(win
->GetId());
2805 event
.SetEventObject(win
);
2806 if ( !win
->GetEventHandler()->ProcessEvent(event
) )
2808 // windows must handle this event, otherwise the app wouldn't behave
2809 // correctly if it loses capture unexpectedly; see the discussion here:
2810 // http://sourceforge.net/tracker/index.php?func=detail&aid=1153662&group_id=9863&atid=109863
2811 // http://article.gmane.org/gmane.comp.lib.wxwidgets.devel/82376
2812 wxFAIL_MSG( _T("window that captured the mouse didn't process wxEVT_MOUSE_CAPTURE_LOST") );
2817 void wxWindowBase::NotifyCaptureLost()
2819 // don't do anything if capture lost was expected, i.e. resulted from
2820 // a wx call to ReleaseMouse or CaptureMouse:
2821 if ( ms_winCaptureChanging
)
2824 // if the capture was lost unexpectedly, notify every window that has
2825 // capture (on stack or current) about it and clear the stack:
2827 if ( ms_winCaptureCurrent
)
2829 DoNotifyWindowAboutCaptureLost(ms_winCaptureCurrent
);
2830 ms_winCaptureCurrent
= NULL
;
2833 while ( ms_winCaptureNext
)
2835 wxWindowNext
*item
= ms_winCaptureNext
;
2836 ms_winCaptureNext
= item
->next
;
2838 DoNotifyWindowAboutCaptureLost(item
->win
);
2847 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2848 int WXUNUSED(modifiers
),
2849 int WXUNUSED(keycode
))
2855 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2861 #endif // wxUSE_HOTKEY
2863 // ----------------------------------------------------------------------------
2865 // ----------------------------------------------------------------------------
2867 bool wxWindowBase::TryBefore(wxEvent
& event
)
2869 #if wxUSE_VALIDATORS
2870 // Can only use the validator of the window which
2871 // is receiving the event
2872 if ( event
.GetEventObject() == this )
2874 wxValidator
* const validator
= GetValidator();
2875 if ( validator
&& validator
->ProcessEventHere(event
) )
2880 #endif // wxUSE_VALIDATORS
2882 return wxEvtHandler::TryBefore(event
);
2885 bool wxWindowBase::TryAfter(wxEvent
& event
)
2887 // carry on up the parent-child hierarchy if the propagation count hasn't
2889 if ( event
.ShouldPropagate() )
2891 // honour the requests to stop propagation at this window: this is
2892 // used by the dialogs, for example, to prevent processing the events
2893 // from the dialog controls in the parent frame which rarely, if ever,
2895 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2897 wxWindow
*parent
= GetParent();
2898 if ( parent
&& !parent
->IsBeingDeleted() )
2900 wxPropagateOnce
propagateOnce(event
);
2902 return parent
->GetEventHandler()->ProcessEvent(event
);
2907 return wxEvtHandler::TryAfter(event
);
2910 // ----------------------------------------------------------------------------
2911 // window relationships
2912 // ----------------------------------------------------------------------------
2914 wxWindow
*wxWindowBase::DoGetSibling(WindowOrder order
) const
2916 wxCHECK_MSG( GetParent(), NULL
,
2917 _T("GetPrev/NextSibling() don't work for TLWs!") );
2919 wxWindowList
& siblings
= GetParent()->GetChildren();
2920 wxWindowList::compatibility_iterator i
= siblings
.Find((wxWindow
*)this);
2921 wxCHECK_MSG( i
, NULL
, _T("window not a child of its parent?") );
2923 if ( order
== OrderBefore
)
2924 i
= i
->GetPrevious();
2928 return i
? i
->GetData() : NULL
;
2931 // ----------------------------------------------------------------------------
2932 // keyboard navigation
2933 // ----------------------------------------------------------------------------
2935 // Navigates in the specified direction inside this window
2936 bool wxWindowBase::DoNavigateIn(int flags
)
2938 #ifdef wxHAS_NATIVE_TAB_TRAVERSAL
2939 // native code doesn't process our wxNavigationKeyEvents anyhow
2942 #else // !wxHAS_NATIVE_TAB_TRAVERSAL
2943 wxNavigationKeyEvent eventNav
;
2944 wxWindow
*focused
= FindFocus();
2945 eventNav
.SetCurrentFocus(focused
);
2946 eventNav
.SetEventObject(focused
);
2947 eventNav
.SetFlags(flags
);
2948 return GetEventHandler()->ProcessEvent(eventNav
);
2949 #endif // wxHAS_NATIVE_TAB_TRAVERSAL/!wxHAS_NATIVE_TAB_TRAVERSAL
2952 bool wxWindowBase::HandleAsNavigationKey(const wxKeyEvent
& event
)
2954 if ( event
.GetKeyCode() != WXK_TAB
)
2957 int flags
= wxNavigationKeyEvent::FromTab
;
2959 if ( event
.ShiftDown() )
2960 flags
|= wxNavigationKeyEvent::IsBackward
;
2962 flags
|= wxNavigationKeyEvent::IsForward
;
2964 if ( event
.ControlDown() )
2965 flags
|= wxNavigationKeyEvent::WinChange
;
2971 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, WindowOrder move
)
2973 // check that we're not a top level window
2974 wxCHECK_RET( GetParent(),
2975 _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
2977 // detect the special case when we have nothing to do anyhow and when the
2978 // code below wouldn't work
2982 // find the target window in the siblings list
2983 wxWindowList
& siblings
= GetParent()->GetChildren();
2984 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
2985 wxCHECK_RET( i
, _T("MoveBefore/AfterInTabOrder(): win is not a sibling") );
2987 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
2988 // can't just move the node around
2989 wxWindow
*self
= (wxWindow
*)this;
2990 siblings
.DeleteObject(self
);
2991 if ( move
== OrderAfter
)
2998 siblings
.Insert(i
, self
);
3000 else // OrderAfter and win was the last sibling
3002 siblings
.Append(self
);
3006 // ----------------------------------------------------------------------------
3008 // ----------------------------------------------------------------------------
3010 /*static*/ wxWindow
* wxWindowBase::FindFocus()
3012 wxWindowBase
*win
= DoFindFocus();
3013 return win
? win
->GetMainWindowOfCompositeControl() : NULL
;
3016 bool wxWindowBase::HasFocus() const
3018 wxWindowBase
*win
= DoFindFocus();
3019 return win
== this ||
3020 win
== wxConstCast(this, wxWindowBase
)->GetMainWindowOfCompositeControl();
3023 // ----------------------------------------------------------------------------
3025 // ----------------------------------------------------------------------------
3027 #if wxUSE_DRAG_AND_DROP && !defined(__WXMSW__)
3032 class DragAcceptFilesTarget
: public wxFileDropTarget
3035 DragAcceptFilesTarget(wxWindowBase
*win
) : m_win(win
) {}
3037 virtual bool OnDropFiles(wxCoord x
, wxCoord y
,
3038 const wxArrayString
& filenames
)
3040 wxDropFilesEvent
event(wxEVT_DROP_FILES
,
3042 wxCArrayString(filenames
).Release());
3043 event
.SetEventObject(m_win
);
3047 return m_win
->HandleWindowEvent(event
);
3051 wxWindowBase
* const m_win
;
3053 wxDECLARE_NO_COPY_CLASS(DragAcceptFilesTarget
);
3057 } // anonymous namespace
3059 // Generic version of DragAcceptFiles(). It works by installing a simple
3060 // wxFileDropTarget-to-EVT_DROP_FILES adaptor and therefore cannot be used
3061 // together with explicit SetDropTarget() calls.
3062 void wxWindowBase::DragAcceptFiles(bool accept
)
3066 wxASSERT_MSG( !GetDropTarget(),
3067 "cannot use DragAcceptFiles() and SetDropTarget() together" );
3068 SetDropTarget(new DragAcceptFilesTarget(this));
3072 SetDropTarget(NULL
);
3076 #endif // wxUSE_DRAG_AND_DROP && !defined(__WXMSW__)
3078 // ----------------------------------------------------------------------------
3080 // ----------------------------------------------------------------------------
3082 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
3084 while ( win
&& !win
->IsTopLevel() )
3085 win
= win
->GetParent();
3090 #if wxUSE_ACCESSIBILITY
3091 // ----------------------------------------------------------------------------
3092 // accessible object for windows
3093 // ----------------------------------------------------------------------------
3095 // Can return either a child object, or an integer
3096 // representing the child element, starting from 1.
3097 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
3099 wxASSERT( GetWindow() != NULL
);
3103 return wxACC_NOT_IMPLEMENTED
;
3106 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
3107 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
3109 wxASSERT( GetWindow() != NULL
);
3113 wxWindow
* win
= NULL
;
3120 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
3122 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
3129 rect
= win
->GetRect();
3130 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
3131 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
3135 return wxACC_NOT_IMPLEMENTED
;
3138 // Navigates from fromId to toId/toObject.
3139 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
3140 int* WXUNUSED(toId
), wxAccessible
** toObject
)
3142 wxASSERT( GetWindow() != NULL
);
3148 case wxNAVDIR_FIRSTCHILD
:
3150 if (GetWindow()->GetChildren().GetCount() == 0)
3152 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
3153 *toObject
= childWindow
->GetOrCreateAccessible();
3157 case wxNAVDIR_LASTCHILD
:
3159 if (GetWindow()->GetChildren().GetCount() == 0)
3161 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
3162 *toObject
= childWindow
->GetOrCreateAccessible();
3166 case wxNAVDIR_RIGHT
:
3170 wxWindowList::compatibility_iterator node
=
3171 wxWindowList::compatibility_iterator();
3174 // Can't navigate to sibling of this window
3175 // if we're a top-level window.
3176 if (!GetWindow()->GetParent())
3177 return wxACC_NOT_IMPLEMENTED
;
3179 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
3183 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
3184 node
= GetWindow()->GetChildren().Item(fromId
-1);
3187 if (node
&& node
->GetNext())
3189 wxWindow
* nextWindow
= node
->GetNext()->GetData();
3190 *toObject
= nextWindow
->GetOrCreateAccessible();
3198 case wxNAVDIR_PREVIOUS
:
3200 wxWindowList::compatibility_iterator node
=
3201 wxWindowList::compatibility_iterator();
3204 // Can't navigate to sibling of this window
3205 // if we're a top-level window.
3206 if (!GetWindow()->GetParent())
3207 return wxACC_NOT_IMPLEMENTED
;
3209 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
3213 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
3214 node
= GetWindow()->GetChildren().Item(fromId
-1);
3217 if (node
&& node
->GetPrevious())
3219 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
3220 *toObject
= previousWindow
->GetOrCreateAccessible();
3228 return wxACC_NOT_IMPLEMENTED
;
3231 // Gets the name of the specified object.
3232 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
3234 wxASSERT( GetWindow() != NULL
);
3240 // If a child, leave wxWidgets to call the function on the actual
3243 return wxACC_NOT_IMPLEMENTED
;
3245 // This will eventually be replaced by specialised
3246 // accessible classes, one for each kind of wxWidgets
3247 // control or window.
3249 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
3250 title
= ((wxButton
*) GetWindow())->GetLabel();
3253 title
= GetWindow()->GetName();
3261 return wxACC_NOT_IMPLEMENTED
;
3264 // Gets the number of children.
3265 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
3267 wxASSERT( GetWindow() != NULL
);
3271 *childId
= (int) GetWindow()->GetChildren().GetCount();
3275 // Gets the specified child (starting from 1).
3276 // If *child is NULL and return value is wxACC_OK,
3277 // this means that the child is a simple element and
3278 // not an accessible object.
3279 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
3281 wxASSERT( GetWindow() != NULL
);
3291 if (childId
> (int) GetWindow()->GetChildren().GetCount())
3294 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
3295 *child
= childWindow
->GetOrCreateAccessible();
3302 // Gets the parent, or NULL.
3303 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
3305 wxASSERT( GetWindow() != NULL
);
3309 wxWindow
* parentWindow
= GetWindow()->GetParent();
3317 *parent
= parentWindow
->GetOrCreateAccessible();
3325 // Performs the default action. childId is 0 (the action for this object)
3326 // or > 0 (the action for a child).
3327 // Return wxACC_NOT_SUPPORTED if there is no default action for this
3328 // window (e.g. an edit control).
3329 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
3331 wxASSERT( GetWindow() != NULL
);
3335 return wxACC_NOT_IMPLEMENTED
;
3338 // Gets the default action for this object (0) or > 0 (the action for a child).
3339 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
3340 // string if there is no action.
3341 // The retrieved string describes the action that is performed on an object,
3342 // not what the object does as a result. For example, a toolbar button that prints
3343 // a document has a default action of "Press" rather than "Prints the current document."
3344 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
3346 wxASSERT( GetWindow() != NULL
);
3350 return wxACC_NOT_IMPLEMENTED
;
3353 // Returns the description for this object or a child.
3354 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
3356 wxASSERT( GetWindow() != NULL
);
3360 wxString
ht(GetWindow()->GetHelpTextAtPoint(wxDefaultPosition
, wxHelpEvent::Origin_Keyboard
));
3366 return wxACC_NOT_IMPLEMENTED
;
3369 // Returns help text for this object or a child, similar to tooltip text.
3370 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
3372 wxASSERT( GetWindow() != NULL
);
3376 wxString
ht(GetWindow()->GetHelpTextAtPoint(wxDefaultPosition
, wxHelpEvent::Origin_Keyboard
));
3382 return wxACC_NOT_IMPLEMENTED
;
3385 // Returns the keyboard shortcut for this object or child.
3386 // Return e.g. ALT+K
3387 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
3389 wxASSERT( GetWindow() != NULL
);
3393 return wxACC_NOT_IMPLEMENTED
;
3396 // Returns a role constant.
3397 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
3399 wxASSERT( GetWindow() != NULL
);
3403 // If a child, leave wxWidgets to call the function on the actual
3406 return wxACC_NOT_IMPLEMENTED
;
3408 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
3409 return wxACC_NOT_IMPLEMENTED
;
3411 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
3412 return wxACC_NOT_IMPLEMENTED
;
3415 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
3416 return wxACC_NOT_IMPLEMENTED
;
3419 //*role = wxROLE_SYSTEM_CLIENT;
3420 *role
= wxROLE_SYSTEM_CLIENT
;
3424 return wxACC_NOT_IMPLEMENTED
;
3428 // Returns a state constant.
3429 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
3431 wxASSERT( GetWindow() != NULL
);
3435 // If a child, leave wxWidgets to call the function on the actual
3438 return wxACC_NOT_IMPLEMENTED
;
3440 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
3441 return wxACC_NOT_IMPLEMENTED
;
3444 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
3445 return wxACC_NOT_IMPLEMENTED
;
3448 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
3449 return wxACC_NOT_IMPLEMENTED
;
3456 return wxACC_NOT_IMPLEMENTED
;
3460 // Returns a localized string representing the value for the object
3462 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
3464 wxASSERT( GetWindow() != NULL
);
3468 return wxACC_NOT_IMPLEMENTED
;
3471 // Selects the object or child.
3472 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
3474 wxASSERT( GetWindow() != NULL
);
3478 return wxACC_NOT_IMPLEMENTED
;
3481 // Gets the window with the keyboard focus.
3482 // If childId is 0 and child is NULL, no object in
3483 // this subhierarchy has the focus.
3484 // If this object has the focus, child should be 'this'.
3485 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
3487 wxASSERT( GetWindow() != NULL
);
3491 return wxACC_NOT_IMPLEMENTED
;
3495 // Gets a variant representing the selected children
3497 // Acceptable values:
3498 // - a null variant (IsNull() returns true)
3499 // - a list variant (GetType() == wxT("list")
3500 // - an integer representing the selected child element,
3501 // or 0 if this object is selected (GetType() == wxT("long")
3502 // - a "void*" pointer to a wxAccessible child object
3503 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
3505 wxASSERT( GetWindow() != NULL
);
3509 return wxACC_NOT_IMPLEMENTED
;
3511 #endif // wxUSE_VARIANT
3513 #endif // wxUSE_ACCESSIBILITY
3515 // ----------------------------------------------------------------------------
3517 // ----------------------------------------------------------------------------
3520 wxWindowBase::AdjustForLayoutDirection(wxCoord x
,
3522 wxCoord widthTotal
) const
3524 if ( GetLayoutDirection() == wxLayout_RightToLeft
)
3526 x
= widthTotal
- x
- width
;