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
)
220 // ids are limited to 16 bits under MSW so if you care about portability,
221 // it's not a good idea to use ids out of this range (and negative ids are
222 // reserved for wxWidgets own usage)
223 wxASSERT_MSG( id
== wxID_ANY
|| (id
>= 0 && id
< 32767) ||
224 (id
>= wxID_AUTO_LOWEST
&& id
<= wxID_AUTO_HIGHEST
),
225 _T("invalid id value") );
227 // generate a new id if the user doesn't care about it
228 if ( id
== wxID_ANY
)
230 m_windowId
= NewControlId();
232 else // valid id specified
237 // don't use SetWindowStyleFlag() here, this function should only be called
238 // to change the flag after creation as it tries to reflect the changes in
239 // flags by updating the window dynamically and we don't need this here
240 m_windowStyle
= style
;
246 SetValidator(validator
);
247 #endif // wxUSE_VALIDATORS
249 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
250 // have it too - like this it's possible to set it only in the top level
251 // dialog/frame and all children will inherit it by defult
252 if ( parent
&& (parent
->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) )
254 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY
);
260 bool wxWindowBase::ToggleWindowStyle(int flag
)
262 wxASSERT_MSG( flag
, _T("flags with 0 value can't be toggled") );
265 long style
= GetWindowStyleFlag();
271 else // currently off
277 SetWindowStyleFlag(style
);
282 // ----------------------------------------------------------------------------
284 // ----------------------------------------------------------------------------
287 wxWindowBase::~wxWindowBase()
289 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
291 // FIXME if these 2 cases result from programming errors in the user code
292 // we should probably assert here instead of silently fixing them
294 // Just in case the window has been Closed, but we're then deleting
295 // immediately: don't leave dangling pointers.
296 wxPendingDelete
.DeleteObject(this);
298 // Just in case we've loaded a top-level window via LoadNativeDialog but
299 // we weren't a dialog class
300 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
303 // The associated popup menu can still be alive, disassociate from it in
305 if ( wxCurrentPopupMenu
&& wxCurrentPopupMenu
->GetInvokingWindow() == this )
306 wxCurrentPopupMenu
->SetInvokingWindow(NULL
);
307 #endif // wxUSE_MENUS
309 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
311 // notify the parent about this window destruction
313 m_parent
->RemoveChild(this);
317 #endif // wxUSE_CARET
320 delete m_windowValidator
;
321 #endif // wxUSE_VALIDATORS
323 #if wxUSE_CONSTRAINTS
324 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
325 // at deleted windows as they delete themselves.
326 DeleteRelatedConstraints();
330 // This removes any dangling pointers to this window in other windows'
331 // constraintsInvolvedIn lists.
332 UnsetConstraints(m_constraints
);
333 delete m_constraints
;
334 m_constraints
= NULL
;
336 #endif // wxUSE_CONSTRAINTS
338 if ( m_containingSizer
)
339 m_containingSizer
->Detach( (wxWindow
*)this );
341 delete m_windowSizer
;
343 #if wxUSE_DRAG_AND_DROP
345 #endif // wxUSE_DRAG_AND_DROP
349 #endif // wxUSE_TOOLTIPS
351 #if wxUSE_ACCESSIBILITY
356 // NB: this has to be called unconditionally, because we don't know
357 // whether this window has associated help text or not
358 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
360 helpProvider
->RemoveHelp(this);
364 bool wxWindowBase::IsBeingDeleted() const
366 return m_isBeingDeleted
||
367 (!IsTopLevel() && m_parent
&& m_parent
->IsBeingDeleted());
370 void wxWindowBase::SendDestroyEvent()
372 if ( m_isBeingDeleted
)
374 // we could have been already called from a more derived class dtor,
375 // e.g. ~wxTLW calls us and so does ~wxWindow and the latter call
376 // should be simply ignored
380 m_isBeingDeleted
= true;
382 wxWindowDestroyEvent event
;
383 event
.SetEventObject(this);
384 event
.SetId(GetId());
385 GetEventHandler()->ProcessEvent(event
);
388 bool wxWindowBase::Destroy()
397 bool wxWindowBase::Close(bool force
)
399 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
400 event
.SetEventObject(this);
401 event
.SetCanVeto(!force
);
403 // return false if window wasn't closed because the application vetoed the
405 return HandleWindowEvent(event
) && !event
.GetVeto();
408 bool wxWindowBase::DestroyChildren()
410 wxWindowList::compatibility_iterator node
;
413 // we iterate until the list becomes empty
414 node
= GetChildren().GetFirst();
418 wxWindow
*child
= node
->GetData();
420 // note that we really want to delete it immediately so don't call the
421 // possible overridden Destroy() version which might not delete the
422 // child immediately resulting in problems with our (top level) child
423 // outliving its parent
424 child
->wxWindowBase::Destroy();
426 wxASSERT_MSG( !GetChildren().Find(child
),
427 wxT("child didn't remove itself using RemoveChild()") );
433 // ----------------------------------------------------------------------------
434 // size/position related methods
435 // ----------------------------------------------------------------------------
437 // centre the window with respect to its parent in either (or both) directions
438 void wxWindowBase::DoCentre(int dir
)
440 wxCHECK_RET( !(dir
& wxCENTRE_ON_SCREEN
) && GetParent(),
441 _T("this method only implements centering child windows") );
443 SetSize(GetRect().CentreIn(GetParent()->GetClientSize(), dir
));
446 // fits the window around the children
447 void wxWindowBase::Fit()
449 if ( !GetChildren().empty() )
451 SetSize(GetBestSize());
453 //else: do nothing if we have no children
456 // fits virtual size (ie. scrolled area etc.) around children
457 void wxWindowBase::FitInside()
459 if ( GetChildren().GetCount() > 0 )
461 SetVirtualSize( GetBestVirtualSize() );
465 // On Mac, scrollbars are explicitly children.
466 #if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__)
467 static bool wxHasRealChildren(const wxWindowBase
* win
)
469 int realChildCount
= 0;
471 for ( wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
473 node
= node
->GetNext() )
475 wxWindow
*win
= node
->GetData();
476 if ( !win
->IsTopLevel() && win
->IsShown() && !win
->IsKindOf(CLASSINFO(wxScrollBar
)))
479 return (realChildCount
> 0);
483 void wxWindowBase::InvalidateBestSize()
485 m_bestSizeCache
= wxDefaultSize
;
487 // parent's best size calculation may depend on its children's
488 // as long as child window we are in is not top level window itself
489 // (because the TLW size is never resized automatically)
490 // so let's invalidate it as well to be safe:
491 if (m_parent
&& !IsTopLevel())
492 m_parent
->InvalidateBestSize();
495 // return the size best suited for the current window
496 wxSize
wxWindowBase::DoGetBestSize() const
502 best
= m_windowSizer
->GetMinSize();
504 #if wxUSE_CONSTRAINTS
505 else if ( m_constraints
)
507 wxConstCast(this, wxWindowBase
)->SatisfyConstraints();
509 // our minimal acceptable size is such that all our windows fit inside
513 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
515 node
= node
->GetNext() )
517 wxLayoutConstraints
*c
= node
->GetData()->GetConstraints();
520 // it's not normal that we have an unconstrained child, but
521 // what can we do about it?
525 int x
= c
->right
.GetValue(),
526 y
= c
->bottom
.GetValue();
534 // TODO: we must calculate the overlaps somehow, otherwise we
535 // will never return a size bigger than the current one :-(
538 best
= wxSize(maxX
, maxY
);
540 #endif // wxUSE_CONSTRAINTS
541 else if ( !GetChildren().empty()
542 #if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__)
543 && wxHasRealChildren(this)
547 // our minimal acceptable size is such that all our visible child
548 // windows fit inside
552 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
554 node
= node
->GetNext() )
556 wxWindow
*win
= node
->GetData();
557 if ( win
->IsTopLevel()
560 || wxDynamicCast(win
, wxStatusBar
)
561 #endif // wxUSE_STATUSBAR
564 // dialogs and frames lie in different top level windows -
565 // don't deal with them here; as for the status bars, they
566 // don't lie in the client area at all
571 win
->GetPosition(&wx
, &wy
);
573 // if the window hadn't been positioned yet, assume that it is in
575 if ( wx
== wxDefaultCoord
)
577 if ( wy
== wxDefaultCoord
)
580 win
->GetSize(&ww
, &wh
);
581 if ( wx
+ ww
> maxX
)
583 if ( wy
+ wh
> maxY
)
587 best
= wxSize(maxX
, maxY
);
589 else // ! has children
591 // for a generic window there is no natural best size so, if the
592 // minimal size is not set, use the current size but take care to
593 // remember it as minimal size for the next time because our best size
594 // should be constant: otherwise we could get into a situation when the
595 // window is initially at some size, then expanded to a larger size and
596 // then, when the containing window is shrunk back (because our initial
597 // best size had been used for computing the parent min size), we can't
598 // be shrunk back any more because our best size is now bigger
599 wxSize size
= GetMinSize();
600 if ( !size
.IsFullySpecified() )
602 size
.SetDefaults(GetSize());
603 wxConstCast(this, wxWindowBase
)->SetMinSize(size
);
606 // return as-is, unadjusted by the client size difference.
610 // Add any difference between size and client size
611 wxSize diff
= GetSize() - GetClientSize();
612 best
.x
+= wxMax(0, diff
.x
);
613 best
.y
+= wxMax(0, diff
.y
);
618 // helper of GetWindowBorderSize(): as many ports don't implement support for
619 // wxSYS_BORDER/EDGE_X/Y metrics in their wxSystemSettings, use hard coded
620 // fallbacks in this case
621 static int wxGetMetricOrDefault(wxSystemMetric what
, const wxWindowBase
* win
)
623 int rc
= wxSystemSettings::GetMetric(
624 what
, static_cast<wxWindow
*>(const_cast<wxWindowBase
*>(win
)));
631 // 2D border is by default 1 pixel wide
637 // 3D borders are by default 2 pixels
642 wxFAIL_MSG( _T("unexpected wxGetMetricOrDefault() argument") );
650 wxSize
wxWindowBase::GetWindowBorderSize() const
654 switch ( GetBorder() )
657 // nothing to do, size is already (0, 0)
660 case wxBORDER_SIMPLE
:
661 case wxBORDER_STATIC
:
662 size
.x
= wxGetMetricOrDefault(wxSYS_BORDER_X
, this);
663 size
.y
= wxGetMetricOrDefault(wxSYS_BORDER_Y
, this);
666 case wxBORDER_SUNKEN
:
667 case wxBORDER_RAISED
:
668 size
.x
= wxMax(wxGetMetricOrDefault(wxSYS_EDGE_X
, this),
669 wxGetMetricOrDefault(wxSYS_BORDER_X
, this));
670 size
.y
= wxMax(wxGetMetricOrDefault(wxSYS_EDGE_Y
, this),
671 wxGetMetricOrDefault(wxSYS_BORDER_Y
, this));
674 case wxBORDER_DOUBLE
:
675 size
.x
= wxGetMetricOrDefault(wxSYS_EDGE_X
, this) +
676 wxGetMetricOrDefault(wxSYS_BORDER_X
, this);
677 size
.y
= wxGetMetricOrDefault(wxSYS_EDGE_Y
, this) +
678 wxGetMetricOrDefault(wxSYS_BORDER_Y
, this);
682 wxFAIL_MSG(_T("Unknown border style."));
686 // we have borders on both sides
690 wxSize
wxWindowBase::GetEffectiveMinSize() const
692 // merge the best size with the min size, giving priority to the min size
693 wxSize min
= GetMinSize();
695 if (min
.x
== wxDefaultCoord
|| min
.y
== wxDefaultCoord
)
697 wxSize best
= GetBestSize();
698 if (min
.x
== wxDefaultCoord
) min
.x
= best
.x
;
699 if (min
.y
== wxDefaultCoord
) min
.y
= best
.y
;
705 wxSize
wxWindowBase::GetBestSize() const
707 if ((!m_windowSizer
) && (m_bestSizeCache
.IsFullySpecified()))
708 return m_bestSizeCache
;
710 return DoGetBestSize();
713 void wxWindowBase::SetMinSize(const wxSize
& minSize
)
715 m_minWidth
= minSize
.x
;
716 m_minHeight
= minSize
.y
;
719 void wxWindowBase::SetMaxSize(const wxSize
& maxSize
)
721 m_maxWidth
= maxSize
.x
;
722 m_maxHeight
= maxSize
.y
;
725 void wxWindowBase::SetInitialSize(const wxSize
& size
)
727 // Set the min size to the size passed in. This will usually either be
728 // wxDefaultSize or the size passed to this window's ctor/Create function.
731 // Merge the size with the best size if needed
732 wxSize best
= GetEffectiveMinSize();
734 // If the current size doesn't match then change it
735 if (GetSize() != best
)
740 // by default the origin is not shifted
741 wxPoint
wxWindowBase::GetClientAreaOrigin() const
746 wxSize
wxWindowBase::ClientToWindowSize(const wxSize
& size
) const
748 const wxSize
diff(GetSize() - GetClientSize());
750 return wxSize(size
.x
== -1 ? -1 : size
.x
+ diff
.x
,
751 size
.y
== -1 ? -1 : size
.y
+ diff
.y
);
754 wxSize
wxWindowBase::WindowToClientSize(const wxSize
& size
) const
756 const wxSize
diff(GetSize() - GetClientSize());
758 return wxSize(size
.x
== -1 ? -1 : size
.x
- diff
.x
,
759 size
.y
== -1 ? -1 : size
.y
- diff
.y
);
762 void wxWindowBase::SetWindowVariant( wxWindowVariant variant
)
764 if ( m_windowVariant
!= variant
)
766 m_windowVariant
= variant
;
768 DoSetWindowVariant(variant
);
772 void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant
)
774 // adjust the font height to correspond to our new variant (notice that
775 // we're only called if something really changed)
776 wxFont font
= GetFont();
777 int size
= font
.GetPointSize();
780 case wxWINDOW_VARIANT_NORMAL
:
783 case wxWINDOW_VARIANT_SMALL
:
788 case wxWINDOW_VARIANT_MINI
:
793 case wxWINDOW_VARIANT_LARGE
:
799 wxFAIL_MSG(_T("unexpected window variant"));
803 font
.SetPointSize(size
);
807 void wxWindowBase::DoSetSizeHints( int minW
, int minH
,
809 int WXUNUSED(incW
), int WXUNUSED(incH
) )
811 wxCHECK_RET( (minW
== wxDefaultCoord
|| maxW
== wxDefaultCoord
|| minW
<= maxW
) &&
812 (minH
== wxDefaultCoord
|| maxH
== wxDefaultCoord
|| minH
<= maxH
),
813 _T("min width/height must be less than max width/height!") );
822 #if WXWIN_COMPATIBILITY_2_8
823 void wxWindowBase::SetVirtualSizeHints(int WXUNUSED(minW
), int WXUNUSED(minH
),
824 int WXUNUSED(maxW
), int WXUNUSED(maxH
))
828 void wxWindowBase::SetVirtualSizeHints(const wxSize
& WXUNUSED(minsize
),
829 const wxSize
& WXUNUSED(maxsize
))
832 #endif // WXWIN_COMPATIBILITY_2_8
834 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
836 m_virtualSize
= wxSize(x
, y
);
839 wxSize
wxWindowBase::DoGetVirtualSize() const
841 // we should use the entire client area so if it is greater than our
842 // virtual size, expand it to fit (otherwise if the window is big enough we
843 // wouldn't be using parts of it)
844 wxSize size
= GetClientSize();
845 if ( m_virtualSize
.x
> size
.x
)
846 size
.x
= m_virtualSize
.x
;
848 if ( m_virtualSize
.y
>= size
.y
)
849 size
.y
= m_virtualSize
.y
;
854 void wxWindowBase::DoGetScreenPosition(int *x
, int *y
) const
856 // screen position is the same as (0, 0) in client coords for non TLWs (and
857 // TLWs override this method)
863 ClientToScreen(x
, y
);
866 void wxWindowBase::SendSizeEvent(int flags
)
868 wxSizeEvent
event(GetSize(), GetId());
869 event
.SetEventObject(this);
870 if ( flags
& wxSEND_EVENT_POST
)
871 wxPostEvent(this, event
);
873 HandleWindowEvent(event
);
876 void wxWindowBase::SendSizeEventToParent(int flags
)
878 wxWindow
* const parent
= GetParent();
879 if ( parent
&& !parent
->IsBeingDeleted() )
880 parent
->SendSizeEvent(flags
);
883 // ----------------------------------------------------------------------------
884 // show/hide/enable/disable the window
885 // ----------------------------------------------------------------------------
887 bool wxWindowBase::Show(bool show
)
889 if ( show
!= m_isShown
)
901 bool wxWindowBase::IsEnabled() const
903 return IsThisEnabled() && (IsTopLevel() || !GetParent() || GetParent()->IsEnabled());
906 void wxWindowBase::NotifyWindowOnEnableChange(bool enabled
)
908 #ifndef wxHAS_NATIVE_ENABLED_MANAGEMENT
910 #endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
914 // If we are top-level then the logic doesn't apply - otherwise
915 // showing a modal dialog would result in total greying out (and ungreying
916 // out later) of everything which would be really ugly
920 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
922 node
= node
->GetNext() )
924 wxWindowBase
* const child
= node
->GetData();
925 if ( !child
->IsTopLevel() && child
->IsThisEnabled() )
926 child
->NotifyWindowOnEnableChange(enabled
);
930 bool wxWindowBase::Enable(bool enable
)
932 if ( enable
== IsThisEnabled() )
935 m_isEnabled
= enable
;
937 #ifdef wxHAS_NATIVE_ENABLED_MANAGEMENT
939 #else // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
940 wxWindowBase
* const parent
= GetParent();
941 if( !IsTopLevel() && parent
&& !parent
->IsEnabled() )
945 #endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
947 NotifyWindowOnEnableChange(enable
);
952 bool wxWindowBase::IsShownOnScreen() const
954 // A window is shown on screen if it itself is shown and so are all its
955 // parents. But if a window is toplevel one, then its always visible on
956 // screen if IsShown() returns true, even if it has a hidden parent.
958 (IsTopLevel() || GetParent() == NULL
|| GetParent()->IsShownOnScreen());
961 // ----------------------------------------------------------------------------
963 // ----------------------------------------------------------------------------
965 bool wxWindowBase::IsTopLevel() const
970 // ----------------------------------------------------------------------------
972 // ----------------------------------------------------------------------------
974 void wxWindowBase::Freeze()
976 if ( !m_freezeCount
++ )
978 // physically freeze this window:
981 // and recursively freeze all children:
982 for ( wxWindowList::iterator i
= GetChildren().begin();
983 i
!= GetChildren().end(); ++i
)
985 wxWindow
*child
= *i
;
986 if ( child
->IsTopLevel() )
994 void wxWindowBase::Thaw()
996 wxASSERT_MSG( m_freezeCount
, "Thaw() without matching Freeze()" );
998 if ( !--m_freezeCount
)
1000 // recursively thaw all children:
1001 for ( wxWindowList::iterator i
= GetChildren().begin();
1002 i
!= GetChildren().end(); ++i
)
1004 wxWindow
*child
= *i
;
1005 if ( child
->IsTopLevel() )
1011 // physically thaw this window:
1016 // ----------------------------------------------------------------------------
1017 // reparenting the window
1018 // ----------------------------------------------------------------------------
1020 void wxWindowBase::AddChild(wxWindowBase
*child
)
1022 wxCHECK_RET( child
, wxT("can't add a NULL child") );
1024 // this should never happen and it will lead to a crash later if it does
1025 // because RemoveChild() will remove only one node from the children list
1026 // and the other(s) one(s) will be left with dangling pointers in them
1027 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), _T("AddChild() called twice") );
1029 GetChildren().Append((wxWindow
*)child
);
1030 child
->SetParent(this);
1032 // adding a child while frozen will assert when thawed, so freeze it as if
1033 // it had been already present when we were frozen
1034 if ( IsFrozen() && !child
->IsTopLevel() )
1038 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
1040 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
1042 // removing a child while frozen may result in permanently frozen window
1043 // if used e.g. from Reparent(), so thaw it
1045 // NB: IsTopLevel() doesn't return true any more when a TLW child is being
1046 // removed from its ~wxWindowBase, so check for IsBeingDeleted() too
1047 if ( IsFrozen() && !child
->IsBeingDeleted() && !child
->IsTopLevel() )
1050 GetChildren().DeleteObject((wxWindow
*)child
);
1051 child
->SetParent(NULL
);
1054 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
1056 wxWindow
*oldParent
= GetParent();
1057 if ( newParent
== oldParent
)
1063 const bool oldEnabledState
= IsEnabled();
1065 // unlink this window from the existing parent.
1068 oldParent
->RemoveChild(this);
1072 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
1075 // add it to the new one
1078 newParent
->AddChild(this);
1082 wxTopLevelWindows
.Append((wxWindow
*)this);
1085 // We need to notify window (and its subwindows) if by changing the parent
1086 // we also change our enabled/disabled status.
1087 const bool newEnabledState
= IsEnabled();
1088 if ( newEnabledState
!= oldEnabledState
)
1090 NotifyWindowOnEnableChange(newEnabledState
);
1096 // ----------------------------------------------------------------------------
1097 // event handler stuff
1098 // ----------------------------------------------------------------------------
1100 void wxWindowBase::SetEventHandler(wxEvtHandler
*handler
)
1102 wxCHECK_RET(handler
!= NULL
, "SetEventHandler(NULL) called");
1104 m_eventHandler
= handler
;
1107 void wxWindowBase::SetNextHandler(wxEvtHandler
*WXUNUSED(handler
))
1109 // disable wxEvtHandler chain mechanism for wxWindows:
1110 // wxWindow uses its own stack mechanism which doesn't mix well with wxEvtHandler's one
1112 wxFAIL_MSG("wxWindow cannot be part of a wxEvtHandler chain");
1114 void wxWindowBase::SetPreviousHandler(wxEvtHandler
*WXUNUSED(handler
))
1116 // we can't simply wxFAIL here as in SetNextHandler: in fact the last
1117 // handler of our stack when is destroyed will be Unlink()ed and thus
1118 // will call this function to update the pointer of this window...
1120 //wxFAIL_MSG("wxWindow cannot be part of a wxEvtHandler chain");
1123 void wxWindowBase::PushEventHandler(wxEvtHandler
*handlerToPush
)
1125 wxCHECK_RET( handlerToPush
!= NULL
, "PushEventHandler(NULL) called" );
1127 // the new handler is going to be part of the wxWindow stack of event handlers:
1128 // it can't be part also of an event handler double-linked chain:
1129 wxASSERT_MSG(handlerToPush
->IsUnlinked(),
1130 "The handler being pushed in the wxWindow stack shouldn't be part of "
1131 "a wxEvtHandler chain; call Unlink() on it first");
1133 wxEvtHandler
*handlerOld
= GetEventHandler();
1134 wxCHECK_RET( handlerOld
, "an old event handler is NULL?" );
1136 // now use wxEvtHandler double-linked list to implement a stack:
1137 handlerToPush
->SetNextHandler(handlerOld
);
1139 if (handlerOld
!= this)
1140 handlerOld
->SetPreviousHandler(handlerToPush
);
1142 SetEventHandler(handlerToPush
);
1145 // final checks of the operations done above:
1146 wxASSERT_MSG( handlerToPush
->GetPreviousHandler() == NULL
,
1147 "the first handler of the wxWindow stack should "
1148 "have no previous handlers set" );
1149 wxASSERT_MSG( handlerToPush
->GetNextHandler() != NULL
,
1150 "the first handler of the wxWindow stack should "
1151 "have non-NULL next handler" );
1153 wxEvtHandler
* pLast
= handlerToPush
;
1154 while ( pLast
&& pLast
!= this )
1155 pLast
= pLast
->GetNextHandler();
1156 wxASSERT_MSG( pLast
->GetNextHandler() == NULL
,
1157 "the last handler of the wxWindow stack should "
1158 "have this window as next handler" );
1159 #endif // wxDEBUG_LEVEL
1162 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
1164 // we need to pop the wxWindow stack, i.e. we need to remove the first handler
1166 wxEvtHandler
*firstHandler
= GetEventHandler();
1167 wxCHECK_MSG( firstHandler
!= NULL
, NULL
, "wxWindow cannot have a NULL event handler" );
1168 wxCHECK_MSG( firstHandler
!= this, NULL
, "cannot pop the wxWindow itself" );
1169 wxCHECK_MSG( firstHandler
->GetPreviousHandler() == NULL
, NULL
,
1170 "the first handler of the wxWindow stack should have no previous handlers set" );
1172 wxEvtHandler
*secondHandler
= firstHandler
->GetNextHandler();
1173 wxCHECK_MSG( secondHandler
!= NULL
, NULL
,
1174 "the first handler of the wxWindow stack should have non-NULL next handler" );
1176 firstHandler
->SetNextHandler(NULL
);
1177 secondHandler
->SetPreviousHandler(NULL
);
1179 // now firstHandler is completely unlinked; set secondHandler as the new window event handler
1180 SetEventHandler(secondHandler
);
1182 if ( deleteHandler
)
1184 delete firstHandler
;
1185 firstHandler
= NULL
;
1188 return firstHandler
;
1191 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handlerToRemove
)
1193 wxCHECK_MSG( handlerToRemove
!= NULL
, false, "RemoveEventHandler(NULL) called" );
1194 wxCHECK_MSG( handlerToRemove
!= this, false, "Cannot remove the window itself" );
1196 if (handlerToRemove
== GetEventHandler())
1198 // removing the first event handler is equivalent to "popping" the stack
1199 PopEventHandler(false);
1203 // NOTE: the wxWindow event handler list is always terminated with "this" handler
1204 wxEvtHandler
*handlerCur
= GetEventHandler()->GetNextHandler();
1205 while ( handlerCur
!= this )
1207 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
1209 if ( handlerCur
== handlerToRemove
)
1211 handlerCur
->Unlink();
1213 wxASSERT_MSG( handlerCur
!= GetEventHandler(),
1214 "the case Remove == Pop should was already handled" );
1218 handlerCur
= handlerNext
;
1221 wxFAIL_MSG( _T("where has the event handler gone?") );
1226 bool wxWindowBase::HandleWindowEvent(wxEvent
& event
) const
1228 // SafelyProcessEvent() will handle exceptions nicely
1229 return GetEventHandler()->SafelyProcessEvent(event
);
1232 // ----------------------------------------------------------------------------
1233 // colours, fonts &c
1234 // ----------------------------------------------------------------------------
1236 void wxWindowBase::InheritAttributes()
1238 const wxWindowBase
* const parent
= GetParent();
1242 // we only inherit attributes which had been explicitly set for the parent
1243 // which ensures that this only happens if the user really wants it and
1244 // not by default which wouldn't make any sense in modern GUIs where the
1245 // controls don't all use the same fonts (nor colours)
1246 if ( parent
->m_inheritFont
&& !m_hasFont
)
1247 SetFont(parent
->GetFont());
1249 // in addition, there is a possibility to explicitly forbid inheriting
1250 // colours at each class level by overriding ShouldInheritColours()
1251 if ( ShouldInheritColours() )
1253 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
1254 SetForegroundColour(parent
->GetForegroundColour());
1256 // inheriting (solid) background colour is wrong as it totally breaks
1257 // any kind of themed backgrounds
1259 // instead, the controls should use the same background as their parent
1260 // (ideally by not drawing it at all)
1262 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
1263 SetBackgroundColour(parent
->GetBackgroundColour());
1268 /* static */ wxVisualAttributes
1269 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
1271 // it is important to return valid values for all attributes from here,
1272 // GetXXX() below rely on this
1273 wxVisualAttributes attrs
;
1274 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
1275 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
1277 // On Smartphone/PocketPC, wxSYS_COLOUR_WINDOW is a better reflection of
1278 // the usual background colour than wxSYS_COLOUR_BTNFACE.
1279 // It's a pity that wxSYS_COLOUR_WINDOW isn't always a suitable background
1280 // colour on other platforms.
1282 #if defined(__WXWINCE__) && (defined(__SMARTPHONE__) || defined(__POCKETPC__))
1283 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1285 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
1290 wxColour
wxWindowBase::GetBackgroundColour() const
1292 if ( !m_backgroundColour
.IsOk() )
1294 wxASSERT_MSG( !m_hasBgCol
, _T("we have invalid explicit bg colour?") );
1296 // get our default background colour
1297 wxColour colBg
= GetDefaultAttributes().colBg
;
1299 // we must return some valid colour to avoid redoing this every time
1300 // and also to avoid surprizing the applications written for older
1301 // wxWidgets versions where GetBackgroundColour() always returned
1302 // something -- so give them something even if it doesn't make sense
1303 // for this window (e.g. it has a themed background)
1305 colBg
= GetClassDefaultAttributes().colBg
;
1310 return m_backgroundColour
;
1313 wxColour
wxWindowBase::GetForegroundColour() const
1315 // logic is the same as above
1316 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
1318 wxColour colFg
= GetDefaultAttributes().colFg
;
1320 if ( !colFg
.IsOk() )
1321 colFg
= GetClassDefaultAttributes().colFg
;
1326 return m_foregroundColour
;
1329 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
1331 if ( colour
== m_backgroundColour
)
1334 m_hasBgCol
= colour
.IsOk();
1335 if ( m_backgroundStyle
!= wxBG_STYLE_CUSTOM
)
1336 m_backgroundStyle
= m_hasBgCol
? wxBG_STYLE_COLOUR
: wxBG_STYLE_SYSTEM
;
1338 m_inheritBgCol
= m_hasBgCol
;
1339 m_backgroundColour
= colour
;
1340 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1344 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1346 if (colour
== m_foregroundColour
)
1349 m_hasFgCol
= colour
.IsOk();
1350 m_inheritFgCol
= m_hasFgCol
;
1351 m_foregroundColour
= colour
;
1352 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1356 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1358 // setting an invalid cursor is ok, it means that we don't have any special
1360 if ( m_cursor
.IsSameAs(cursor
) )
1371 wxFont
wxWindowBase::GetFont() const
1373 // logic is the same as in GetBackgroundColour()
1374 if ( !m_font
.IsOk() )
1376 wxASSERT_MSG( !m_hasFont
, _T("we have invalid explicit font?") );
1378 wxFont font
= GetDefaultAttributes().font
;
1380 font
= GetClassDefaultAttributes().font
;
1388 bool wxWindowBase::SetFont(const wxFont
& font
)
1390 if ( font
== m_font
)
1397 m_hasFont
= font
.IsOk();
1398 m_inheritFont
= m_hasFont
;
1400 InvalidateBestSize();
1407 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1409 m_hasCustomPalette
= true;
1412 // VZ: can anyone explain me what do we do here?
1413 wxWindowDC
d((wxWindow
*) this);
1417 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1419 wxWindow
*win
= (wxWindow
*)this;
1420 while ( win
&& !win
->HasCustomPalette() )
1422 win
= win
->GetParent();
1428 #endif // wxUSE_PALETTE
1431 void wxWindowBase::SetCaret(wxCaret
*caret
)
1442 wxASSERT_MSG( m_caret
->GetWindow() == this,
1443 wxT("caret should be created associated to this window") );
1446 #endif // wxUSE_CARET
1448 #if wxUSE_VALIDATORS
1449 // ----------------------------------------------------------------------------
1451 // ----------------------------------------------------------------------------
1453 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1455 if ( m_windowValidator
)
1456 delete m_windowValidator
;
1458 m_windowValidator
= (wxValidator
*)validator
.Clone();
1460 if ( m_windowValidator
)
1461 m_windowValidator
->SetWindow(this);
1463 #endif // wxUSE_VALIDATORS
1465 // ----------------------------------------------------------------------------
1466 // update region stuff
1467 // ----------------------------------------------------------------------------
1469 wxRect
wxWindowBase::GetUpdateClientRect() const
1471 wxRegion rgnUpdate
= GetUpdateRegion();
1472 rgnUpdate
.Intersect(GetClientRect());
1473 wxRect rectUpdate
= rgnUpdate
.GetBox();
1474 wxPoint ptOrigin
= GetClientAreaOrigin();
1475 rectUpdate
.x
-= ptOrigin
.x
;
1476 rectUpdate
.y
-= ptOrigin
.y
;
1481 bool wxWindowBase::DoIsExposed(int x
, int y
) const
1483 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1486 bool wxWindowBase::DoIsExposed(int x
, int y
, int w
, int h
) const
1488 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1491 void wxWindowBase::ClearBackground()
1493 // wxGTK uses its own version, no need to add never used code
1495 wxClientDC
dc((wxWindow
*)this);
1496 wxBrush
brush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID
);
1497 dc
.SetBackground(brush
);
1502 // ----------------------------------------------------------------------------
1503 // find child window by id or name
1504 // ----------------------------------------------------------------------------
1506 wxWindow
*wxWindowBase::FindWindow(long id
) const
1508 if ( id
== m_windowId
)
1509 return (wxWindow
*)this;
1511 wxWindowBase
*res
= NULL
;
1512 wxWindowList::compatibility_iterator node
;
1513 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1515 wxWindowBase
*child
= node
->GetData();
1516 res
= child
->FindWindow( id
);
1519 return (wxWindow
*)res
;
1522 wxWindow
*wxWindowBase::FindWindow(const wxString
& name
) const
1524 if ( name
== m_windowName
)
1525 return (wxWindow
*)this;
1527 wxWindowBase
*res
= NULL
;
1528 wxWindowList::compatibility_iterator node
;
1529 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1531 wxWindow
*child
= node
->GetData();
1532 res
= child
->FindWindow(name
);
1535 return (wxWindow
*)res
;
1539 // find any window by id or name or label: If parent is non-NULL, look through
1540 // children for a label or title matching the specified string. If NULL, look
1541 // through all top-level windows.
1543 // to avoid duplicating code we reuse the same helper function but with
1544 // different comparators
1546 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1547 const wxString
& label
, long id
);
1550 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1553 return win
->GetLabel() == label
;
1557 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1560 return win
->GetName() == label
;
1564 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1567 return win
->GetId() == id
;
1570 // recursive helper for the FindWindowByXXX() functions
1572 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1573 const wxString
& label
,
1575 wxFindWindowCmp cmp
)
1579 // see if this is the one we're looking for
1580 if ( (*cmp
)(parent
, label
, id
) )
1581 return (wxWindow
*)parent
;
1583 // It wasn't, so check all its children
1584 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1586 node
= node
->GetNext() )
1588 // recursively check each child
1589 wxWindow
*win
= (wxWindow
*)node
->GetData();
1590 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1600 // helper for FindWindowByXXX()
1602 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1603 const wxString
& label
,
1605 wxFindWindowCmp cmp
)
1609 // just check parent and all its children
1610 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1613 // start at very top of wx's windows
1614 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1616 node
= node
->GetNext() )
1618 // recursively check each window & its children
1619 wxWindow
*win
= node
->GetData();
1620 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1630 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1632 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1637 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1639 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1643 // fall back to the label
1644 win
= FindWindowByLabel(title
, parent
);
1652 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1654 return wxFindWindowHelper(parent
, wxEmptyString
, id
, wxFindWindowCmpIds
);
1657 // ----------------------------------------------------------------------------
1658 // dialog oriented functions
1659 // ----------------------------------------------------------------------------
1661 void wxWindowBase::MakeModal(bool modal
)
1663 // Disable all other windows
1666 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1669 wxWindow
*win
= node
->GetData();
1671 win
->Enable(!modal
);
1673 node
= node
->GetNext();
1678 bool wxWindowBase::Validate()
1680 #if wxUSE_VALIDATORS
1681 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1683 wxWindowList::compatibility_iterator node
;
1684 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1686 wxWindowBase
*child
= node
->GetData();
1687 wxValidator
*validator
= child
->GetValidator();
1688 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1693 if ( recurse
&& !child
->Validate() )
1698 #endif // wxUSE_VALIDATORS
1703 bool wxWindowBase::TransferDataToWindow()
1705 #if wxUSE_VALIDATORS
1706 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1708 wxWindowList::compatibility_iterator node
;
1709 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1711 wxWindowBase
*child
= node
->GetData();
1712 wxValidator
*validator
= child
->GetValidator();
1713 if ( validator
&& !validator
->TransferToWindow() )
1715 wxLogWarning(_("Could not transfer data to window"));
1717 wxLog::FlushActive();
1725 if ( !child
->TransferDataToWindow() )
1727 // warning already given
1732 #endif // wxUSE_VALIDATORS
1737 bool wxWindowBase::TransferDataFromWindow()
1739 #if wxUSE_VALIDATORS
1740 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1742 wxWindowList::compatibility_iterator node
;
1743 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1745 wxWindow
*child
= node
->GetData();
1746 wxValidator
*validator
= child
->GetValidator();
1747 if ( validator
&& !validator
->TransferFromWindow() )
1749 // nop warning here because the application is supposed to give
1750 // one itself - we don't know here what might have gone wrongly
1757 if ( !child
->TransferDataFromWindow() )
1759 // warning already given
1764 #endif // wxUSE_VALIDATORS
1769 void wxWindowBase::InitDialog()
1771 wxInitDialogEvent
event(GetId());
1772 event
.SetEventObject( this );
1773 GetEventHandler()->ProcessEvent(event
);
1776 // ----------------------------------------------------------------------------
1777 // context-sensitive help support
1778 // ----------------------------------------------------------------------------
1782 // associate this help text with this window
1783 void wxWindowBase::SetHelpText(const wxString
& text
)
1785 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1788 helpProvider
->AddHelp(this, text
);
1792 #if WXWIN_COMPATIBILITY_2_8
1793 // associate this help text with all windows with the same id as this
1795 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1797 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1800 helpProvider
->AddHelp(GetId(), text
);
1803 #endif // WXWIN_COMPATIBILITY_2_8
1805 // get the help string associated with this window (may be empty)
1806 // default implementation forwards calls to the help provider
1808 wxWindowBase::GetHelpTextAtPoint(const wxPoint
& WXUNUSED(pt
),
1809 wxHelpEvent::Origin
WXUNUSED(origin
)) const
1812 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1815 text
= helpProvider
->GetHelp(this);
1821 // show help for this window
1822 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1824 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1827 wxPoint pos
= event
.GetPosition();
1828 const wxHelpEvent::Origin origin
= event
.GetOrigin();
1829 if ( origin
== wxHelpEvent::Origin_Keyboard
)
1831 // if the help event was generated from keyboard it shouldn't
1832 // appear at the mouse position (which is still the only position
1833 // associated with help event) if the mouse is far away, although
1834 // we still do use the mouse position if it's over the window
1835 // because we suppose the user looks approximately at the mouse
1836 // already and so it would be more convenient than showing tooltip
1837 // at some arbitrary position which can be quite far from it
1838 const wxRect rectClient
= GetClientRect();
1839 if ( !rectClient
.Contains(ScreenToClient(pos
)) )
1841 // position help slightly under and to the right of this window
1842 pos
= ClientToScreen(wxPoint(
1844 rectClient
.height
+ GetCharHeight()
1849 if ( helpProvider
->ShowHelpAtPoint(this, pos
, origin
) )
1851 // skip the event.Skip() below
1859 #endif // wxUSE_HELP
1861 // ----------------------------------------------------------------------------
1863 // ----------------------------------------------------------------------------
1867 void wxWindowBase::SetToolTip( const wxString
&tip
)
1869 // don't create the new tooltip if we already have one
1872 m_tooltip
->SetTip( tip
);
1876 SetToolTip( new wxToolTip( tip
) );
1879 // setting empty tooltip text does not remove the tooltip any more - use
1880 // SetToolTip(NULL) for this
1883 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1885 if ( m_tooltip
!= tooltip
)
1890 m_tooltip
= tooltip
;
1894 #endif // wxUSE_TOOLTIPS
1896 // ----------------------------------------------------------------------------
1897 // constraints and sizers
1898 // ----------------------------------------------------------------------------
1900 #if wxUSE_CONSTRAINTS
1902 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1904 if ( m_constraints
)
1906 UnsetConstraints(m_constraints
);
1907 delete m_constraints
;
1909 m_constraints
= constraints
;
1910 if ( m_constraints
)
1912 // Make sure other windows know they're part of a 'meaningful relationship'
1913 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1914 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1915 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1916 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1917 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1918 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1919 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1920 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1921 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1922 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1923 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1924 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1925 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1926 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1927 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1928 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1932 // This removes any dangling pointers to this window in other windows'
1933 // constraintsInvolvedIn lists.
1934 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1938 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1939 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1940 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1941 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1942 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1943 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1944 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1945 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1946 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1947 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1948 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1949 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1950 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1951 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1952 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1953 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1957 // Back-pointer to other windows we're involved with, so if we delete this
1958 // window, we must delete any constraints we're involved with.
1959 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
1961 if ( !m_constraintsInvolvedIn
)
1962 m_constraintsInvolvedIn
= new wxWindowList
;
1963 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
1964 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
1967 // REMOVE back-pointer to other windows we're involved with.
1968 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
1970 if ( m_constraintsInvolvedIn
)
1971 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
1974 // Reset any constraints that mention this window
1975 void wxWindowBase::DeleteRelatedConstraints()
1977 if ( m_constraintsInvolvedIn
)
1979 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
1982 wxWindow
*win
= node
->GetData();
1983 wxLayoutConstraints
*constr
= win
->GetConstraints();
1985 // Reset any constraints involving this window
1988 constr
->left
.ResetIfWin(this);
1989 constr
->top
.ResetIfWin(this);
1990 constr
->right
.ResetIfWin(this);
1991 constr
->bottom
.ResetIfWin(this);
1992 constr
->width
.ResetIfWin(this);
1993 constr
->height
.ResetIfWin(this);
1994 constr
->centreX
.ResetIfWin(this);
1995 constr
->centreY
.ResetIfWin(this);
1998 wxWindowList::compatibility_iterator next
= node
->GetNext();
1999 m_constraintsInvolvedIn
->Erase(node
);
2003 delete m_constraintsInvolvedIn
;
2004 m_constraintsInvolvedIn
= NULL
;
2008 #endif // wxUSE_CONSTRAINTS
2010 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
2012 if ( sizer
== m_windowSizer
)
2015 if ( m_windowSizer
)
2017 m_windowSizer
->SetContainingWindow(NULL
);
2020 delete m_windowSizer
;
2023 m_windowSizer
= sizer
;
2024 if ( m_windowSizer
)
2026 m_windowSizer
->SetContainingWindow((wxWindow
*)this);
2029 SetAutoLayout(m_windowSizer
!= NULL
);
2032 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
2034 SetSizer( sizer
, deleteOld
);
2035 sizer
->SetSizeHints( (wxWindow
*) this );
2039 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
2041 // adding a window to a sizer twice is going to result in fatal and
2042 // hard to debug problems later because when deleting the second
2043 // associated wxSizerItem we're going to dereference a dangling
2044 // pointer; so try to detect this as early as possible
2045 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
2046 _T("Adding a window to the same sizer twice?") );
2048 m_containingSizer
= sizer
;
2051 #if wxUSE_CONSTRAINTS
2053 void wxWindowBase::SatisfyConstraints()
2055 wxLayoutConstraints
*constr
= GetConstraints();
2056 bool wasOk
= constr
&& constr
->AreSatisfied();
2058 ResetConstraints(); // Mark all constraints as unevaluated
2062 // if we're a top level panel (i.e. our parent is frame/dialog), our
2063 // own constraints will never be satisfied any more unless we do it
2067 while ( noChanges
> 0 )
2069 LayoutPhase1(&noChanges
);
2073 LayoutPhase2(&noChanges
);
2076 #endif // wxUSE_CONSTRAINTS
2078 bool wxWindowBase::Layout()
2080 // If there is a sizer, use it instead of the constraints
2084 GetVirtualSize(&w
, &h
);
2085 GetSizer()->SetDimension( 0, 0, w
, h
);
2087 #if wxUSE_CONSTRAINTS
2090 SatisfyConstraints(); // Find the right constraints values
2091 SetConstraintSizes(); // Recursively set the real window sizes
2098 #if wxUSE_CONSTRAINTS
2100 // first phase of the constraints evaluation: set our own constraints
2101 bool wxWindowBase::LayoutPhase1(int *noChanges
)
2103 wxLayoutConstraints
*constr
= GetConstraints();
2105 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
2108 // second phase: set the constraints for our children
2109 bool wxWindowBase::LayoutPhase2(int *noChanges
)
2116 // Layout grand children
2122 // Do a phase of evaluating child constraints
2123 bool wxWindowBase::DoPhase(int phase
)
2125 // the list containing the children for which the constraints are already
2127 wxWindowList succeeded
;
2129 // the max number of iterations we loop before concluding that we can't set
2131 static const int maxIterations
= 500;
2133 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
2137 // loop over all children setting their constraints
2138 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2140 node
= node
->GetNext() )
2142 wxWindow
*child
= node
->GetData();
2143 if ( child
->IsTopLevel() )
2145 // top level children are not inside our client area
2149 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
2151 // this one is either already ok or nothing we can do about it
2155 int tempNoChanges
= 0;
2156 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
2157 : child
->LayoutPhase2(&tempNoChanges
);
2158 noChanges
+= tempNoChanges
;
2162 succeeded
.Append(child
);
2168 // constraints are set
2176 void wxWindowBase::ResetConstraints()
2178 wxLayoutConstraints
*constr
= GetConstraints();
2181 constr
->left
.SetDone(false);
2182 constr
->top
.SetDone(false);
2183 constr
->right
.SetDone(false);
2184 constr
->bottom
.SetDone(false);
2185 constr
->width
.SetDone(false);
2186 constr
->height
.SetDone(false);
2187 constr
->centreX
.SetDone(false);
2188 constr
->centreY
.SetDone(false);
2191 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2194 wxWindow
*win
= node
->GetData();
2195 if ( !win
->IsTopLevel() )
2196 win
->ResetConstraints();
2197 node
= node
->GetNext();
2201 // Need to distinguish between setting the 'fake' size for windows and sizers,
2202 // and setting the real values.
2203 void wxWindowBase::SetConstraintSizes(bool recurse
)
2205 wxLayoutConstraints
*constr
= GetConstraints();
2206 if ( constr
&& constr
->AreSatisfied() )
2208 int x
= constr
->left
.GetValue();
2209 int y
= constr
->top
.GetValue();
2210 int w
= constr
->width
.GetValue();
2211 int h
= constr
->height
.GetValue();
2213 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
2214 (constr
->height
.GetRelationship() != wxAsIs
) )
2216 SetSize(x
, y
, w
, h
);
2220 // If we don't want to resize this window, just move it...
2226 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
2227 GetClassInfo()->GetClassName(),
2233 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2236 wxWindow
*win
= node
->GetData();
2237 if ( !win
->IsTopLevel() && win
->GetConstraints() )
2238 win
->SetConstraintSizes();
2239 node
= node
->GetNext();
2244 // Only set the size/position of the constraint (if any)
2245 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
2247 wxLayoutConstraints
*constr
= GetConstraints();
2250 if ( x
!= wxDefaultCoord
)
2252 constr
->left
.SetValue(x
);
2253 constr
->left
.SetDone(true);
2255 if ( y
!= wxDefaultCoord
)
2257 constr
->top
.SetValue(y
);
2258 constr
->top
.SetDone(true);
2260 if ( w
!= wxDefaultCoord
)
2262 constr
->width
.SetValue(w
);
2263 constr
->width
.SetDone(true);
2265 if ( h
!= wxDefaultCoord
)
2267 constr
->height
.SetValue(h
);
2268 constr
->height
.SetDone(true);
2273 void wxWindowBase::MoveConstraint(int x
, int y
)
2275 wxLayoutConstraints
*constr
= GetConstraints();
2278 if ( x
!= wxDefaultCoord
)
2280 constr
->left
.SetValue(x
);
2281 constr
->left
.SetDone(true);
2283 if ( y
!= wxDefaultCoord
)
2285 constr
->top
.SetValue(y
);
2286 constr
->top
.SetDone(true);
2291 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
2293 wxLayoutConstraints
*constr
= GetConstraints();
2296 *w
= constr
->width
.GetValue();
2297 *h
= constr
->height
.GetValue();
2303 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
2305 wxLayoutConstraints
*constr
= GetConstraints();
2308 *w
= constr
->width
.GetValue();
2309 *h
= constr
->height
.GetValue();
2312 GetClientSize(w
, h
);
2315 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
2317 wxLayoutConstraints
*constr
= GetConstraints();
2320 *x
= constr
->left
.GetValue();
2321 *y
= constr
->top
.GetValue();
2327 #endif // wxUSE_CONSTRAINTS
2329 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
2331 // don't do it for the dialogs/frames - they float independently of their
2333 if ( !IsTopLevel() )
2335 wxWindow
*parent
= GetParent();
2336 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
2338 wxPoint
pt(parent
->GetClientAreaOrigin());
2345 // ----------------------------------------------------------------------------
2346 // Update UI processing
2347 // ----------------------------------------------------------------------------
2349 void wxWindowBase::UpdateWindowUI(long flags
)
2351 wxUpdateUIEvent
event(GetId());
2352 event
.SetEventObject(this);
2354 if ( GetEventHandler()->ProcessEvent(event
) )
2356 DoUpdateWindowUI(event
);
2359 if (flags
& wxUPDATE_UI_RECURSE
)
2361 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2364 wxWindow
* child
= (wxWindow
*) node
->GetData();
2365 child
->UpdateWindowUI(flags
);
2366 node
= node
->GetNext();
2371 // do the window-specific processing after processing the update event
2372 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
2374 if ( event
.GetSetEnabled() )
2375 Enable(event
.GetEnabled());
2377 if ( event
.GetSetShown() )
2378 Show(event
.GetShown());
2381 // ----------------------------------------------------------------------------
2382 // dialog units translations
2383 // ----------------------------------------------------------------------------
2385 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
2387 int charWidth
= GetCharWidth();
2388 int charHeight
= GetCharHeight();
2389 wxPoint pt2
= wxDefaultPosition
;
2390 if (pt
.x
!= wxDefaultCoord
)
2391 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
);
2392 if (pt
.y
!= wxDefaultCoord
)
2393 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2398 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2400 int charWidth
= GetCharWidth();
2401 int charHeight
= GetCharHeight();
2402 wxPoint pt2
= wxDefaultPosition
;
2403 if (pt
.x
!= wxDefaultCoord
)
2404 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2405 if (pt
.y
!= wxDefaultCoord
)
2406 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2411 // ----------------------------------------------------------------------------
2413 // ----------------------------------------------------------------------------
2415 // propagate the colour change event to the subwindows
2416 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2418 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2421 // Only propagate to non-top-level windows
2422 wxWindow
*win
= node
->GetData();
2423 if ( !win
->IsTopLevel() )
2425 wxSysColourChangedEvent event2
;
2426 event
.SetEventObject(win
);
2427 win
->GetEventHandler()->ProcessEvent(event2
);
2430 node
= node
->GetNext();
2436 // the default action is to populate dialog with data when it's created,
2437 // and nudge the UI into displaying itself correctly in case
2438 // we've turned the wxUpdateUIEvents frequency down low.
2439 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2441 TransferDataToWindow();
2443 // Update the UI at this point
2444 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2447 // ----------------------------------------------------------------------------
2448 // menu-related functions
2449 // ----------------------------------------------------------------------------
2453 bool wxWindowBase::PopupMenu(wxMenu
*menu
, int x
, int y
)
2455 wxCHECK_MSG( menu
, false, "can't popup NULL menu" );
2457 wxCurrentPopupMenu
= menu
;
2458 const bool rc
= DoPopupMenu(menu
, x
, y
);
2459 wxCurrentPopupMenu
= NULL
;
2464 // this is used to pass the id of the selected item from the menu event handler
2465 // to the main function itself
2467 // it's ok to use a global here as there can be at most one popup menu shown at
2469 static int gs_popupMenuSelection
= wxID_NONE
;
2471 void wxWindowBase::InternalOnPopupMenu(wxCommandEvent
& event
)
2473 // store the id in a global variable where we'll retrieve it from later
2474 gs_popupMenuSelection
= event
.GetId();
2477 void wxWindowBase::InternalOnPopupMenuUpdate(wxUpdateUIEvent
& WXUNUSED(event
))
2479 // nothing to do but do not skip it
2483 wxWindowBase::DoGetPopupMenuSelectionFromUser(wxMenu
& menu
, int x
, int y
)
2485 gs_popupMenuSelection
= wxID_NONE
;
2487 Connect(wxEVT_COMMAND_MENU_SELECTED
,
2488 wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu
),
2492 // it is common to construct the menu passed to this function dynamically
2493 // using some fixed range of ids which could clash with the ids used
2494 // elsewhere in the program, which could result in some menu items being
2495 // unintentionally disabled or otherwise modified by update UI handlers
2496 // elsewhere in the program code and this is difficult to avoid in the
2497 // program itself, so instead we just temporarily suspend UI updating while
2498 // this menu is shown
2499 Connect(wxEVT_UPDATE_UI
,
2500 wxUpdateUIEventHandler(wxWindowBase::InternalOnPopupMenuUpdate
),
2504 PopupMenu(&menu
, x
, y
);
2506 Disconnect(wxEVT_UPDATE_UI
,
2507 wxUpdateUIEventHandler(wxWindowBase::InternalOnPopupMenuUpdate
),
2510 Disconnect(wxEVT_COMMAND_MENU_SELECTED
,
2511 wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu
),
2515 return gs_popupMenuSelection
;
2518 #endif // wxUSE_MENUS
2520 // methods for drawing the sizers in a visible way
2523 static void DrawSizers(wxWindowBase
*win
);
2525 static void DrawBorder(wxWindowBase
*win
, const wxRect
& rect
, bool fill
, const wxPen
* pen
)
2527 wxClientDC
dc((wxWindow
*)win
);
2529 dc
.SetBrush(fill
? wxBrush(pen
->GetColour(), wxBRUSHSTYLE_CROSSDIAG_HATCH
) :
2530 *wxTRANSPARENT_BRUSH
);
2531 dc
.DrawRectangle(rect
.Deflate(1, 1));
2534 static void DrawSizer(wxWindowBase
*win
, wxSizer
*sizer
)
2536 const wxSizerItemList
& items
= sizer
->GetChildren();
2537 for ( wxSizerItemList::const_iterator i
= items
.begin(),
2542 wxSizerItem
*item
= *i
;
2543 if ( item
->IsSizer() )
2545 DrawBorder(win
, item
->GetRect().Deflate(2), false, wxRED_PEN
);
2546 DrawSizer(win
, item
->GetSizer());
2548 else if ( item
->IsSpacer() )
2550 DrawBorder(win
, item
->GetRect().Deflate(2), true, wxBLUE_PEN
);
2552 else if ( item
->IsWindow() )
2554 DrawSizers(item
->GetWindow());
2557 wxFAIL_MSG("inconsistent wxSizerItem status!");
2561 static void DrawSizers(wxWindowBase
*win
)
2563 DrawBorder(win
, win
->GetClientSize(), false, wxGREEN_PEN
);
2565 wxSizer
*sizer
= win
->GetSizer();
2568 DrawSizer(win
, sizer
);
2570 else // no sizer, still recurse into the children
2572 const wxWindowList
& children
= win
->GetChildren();
2573 for ( wxWindowList::const_iterator i
= children
.begin(),
2574 end
= children
.end();
2581 // show all kind of sizes of this window; see the "window sizing" topic
2582 // overview for more info about the various differences:
2583 wxSize fullSz
= win
->GetSize();
2584 wxSize clientSz
= win
->GetClientSize();
2585 wxSize bestSz
= win
->GetBestSize();
2586 wxSize minSz
= win
->GetMinSize();
2587 wxSize maxSz
= win
->GetMaxSize();
2588 wxSize virtualSz
= win
->GetVirtualSize();
2590 wxMessageOutputDebug dbgout
;
2592 "%-10s => fullsz=%4d;%-4d clientsz=%4d;%-4d bestsz=%4d;%-4d minsz=%4d;%-4d maxsz=%4d;%-4d virtualsz=%4d;%-4d\n",
2595 clientSz
.x
, clientSz
.y
,
2599 virtualSz
.x
, virtualSz
.y
);
2603 #endif // __WXDEBUG__
2605 // process special middle clicks
2606 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2608 if ( event
.ControlDown() && event
.AltDown() )
2611 // Ctrl-Alt-Shift-mclick makes the sizers visible in debug builds
2612 if ( event
.ShiftDown() )
2617 #endif // __WXDEBUG__
2618 ::wxInfoMessageBox((wxWindow
*)this);
2626 // ----------------------------------------------------------------------------
2628 // ----------------------------------------------------------------------------
2630 #if wxUSE_ACCESSIBILITY
2631 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2633 if (m_accessible
&& (accessible
!= m_accessible
))
2634 delete m_accessible
;
2635 m_accessible
= accessible
;
2637 m_accessible
->SetWindow((wxWindow
*) this);
2640 // Returns the accessible object, creating if necessary.
2641 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2644 m_accessible
= CreateAccessible();
2645 return m_accessible
;
2648 // Override to create a specific accessible object.
2649 wxAccessible
* wxWindowBase::CreateAccessible()
2651 return new wxWindowAccessible((wxWindow
*) this);
2656 // ----------------------------------------------------------------------------
2657 // list classes implementation
2658 // ----------------------------------------------------------------------------
2662 #include "wx/listimpl.cpp"
2663 WX_DEFINE_LIST(wxWindowList
)
2667 void wxWindowListNode::DeleteData()
2669 delete (wxWindow
*)GetData();
2672 #endif // wxUSE_STL/!wxUSE_STL
2674 // ----------------------------------------------------------------------------
2676 // ----------------------------------------------------------------------------
2678 wxBorder
wxWindowBase::GetBorder(long flags
) const
2680 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2681 if ( border
== wxBORDER_DEFAULT
)
2683 border
= GetDefaultBorder();
2685 else if ( border
== wxBORDER_THEME
)
2687 border
= GetDefaultBorderForControl();
2693 wxBorder
wxWindowBase::GetDefaultBorder() const
2695 return wxBORDER_NONE
;
2698 // ----------------------------------------------------------------------------
2700 // ----------------------------------------------------------------------------
2702 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2704 // here we just check if the point is inside the window or not
2706 // check the top and left border first
2707 bool outside
= x
< 0 || y
< 0;
2710 // check the right and bottom borders too
2711 wxSize size
= GetSize();
2712 outside
= x
>= size
.x
|| y
>= size
.y
;
2715 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2718 // ----------------------------------------------------------------------------
2720 // ----------------------------------------------------------------------------
2722 struct WXDLLEXPORT wxWindowNext
2726 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2727 wxWindow
*wxWindowBase::ms_winCaptureCurrent
= NULL
;
2728 bool wxWindowBase::ms_winCaptureChanging
= false;
2730 void wxWindowBase::CaptureMouse()
2732 wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), static_cast<void*>(this));
2734 wxASSERT_MSG( !ms_winCaptureChanging
, _T("recursive CaptureMouse call?") );
2736 ms_winCaptureChanging
= true;
2738 wxWindow
*winOld
= GetCapture();
2741 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2744 wxWindowNext
*item
= new wxWindowNext
;
2746 item
->next
= ms_winCaptureNext
;
2747 ms_winCaptureNext
= item
;
2749 //else: no mouse capture to save
2752 ms_winCaptureCurrent
= (wxWindow
*)this;
2754 ms_winCaptureChanging
= false;
2757 void wxWindowBase::ReleaseMouse()
2759 wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), static_cast<void*>(this));
2761 wxASSERT_MSG( !ms_winCaptureChanging
, _T("recursive ReleaseMouse call?") );
2763 wxASSERT_MSG( GetCapture() == this,
2764 "attempt to release mouse, but this window hasn't captured it" );
2765 wxASSERT_MSG( ms_winCaptureCurrent
== this,
2766 "attempt to release mouse, but this window hasn't captured it" );
2768 ms_winCaptureChanging
= true;
2771 ms_winCaptureCurrent
= NULL
;
2773 if ( ms_winCaptureNext
)
2775 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2776 ms_winCaptureCurrent
= ms_winCaptureNext
->win
;
2778 wxWindowNext
*item
= ms_winCaptureNext
;
2779 ms_winCaptureNext
= item
->next
;
2782 //else: stack is empty, no previous capture
2784 ms_winCaptureChanging
= false;
2786 wxLogTrace(_T("mousecapture"),
2787 (const wxChar
*) _T("After ReleaseMouse() mouse is captured by %p"),
2788 static_cast<void*>(GetCapture()));
2791 static void DoNotifyWindowAboutCaptureLost(wxWindow
*win
)
2793 wxMouseCaptureLostEvent
event(win
->GetId());
2794 event
.SetEventObject(win
);
2795 if ( !win
->GetEventHandler()->ProcessEvent(event
) )
2797 // windows must handle this event, otherwise the app wouldn't behave
2798 // correctly if it loses capture unexpectedly; see the discussion here:
2799 // http://sourceforge.net/tracker/index.php?func=detail&aid=1153662&group_id=9863&atid=109863
2800 // http://article.gmane.org/gmane.comp.lib.wxwidgets.devel/82376
2801 wxFAIL_MSG( _T("window that captured the mouse didn't process wxEVT_MOUSE_CAPTURE_LOST") );
2806 void wxWindowBase::NotifyCaptureLost()
2808 // don't do anything if capture lost was expected, i.e. resulted from
2809 // a wx call to ReleaseMouse or CaptureMouse:
2810 if ( ms_winCaptureChanging
)
2813 // if the capture was lost unexpectedly, notify every window that has
2814 // capture (on stack or current) about it and clear the stack:
2816 if ( ms_winCaptureCurrent
)
2818 DoNotifyWindowAboutCaptureLost(ms_winCaptureCurrent
);
2819 ms_winCaptureCurrent
= NULL
;
2822 while ( ms_winCaptureNext
)
2824 wxWindowNext
*item
= ms_winCaptureNext
;
2825 ms_winCaptureNext
= item
->next
;
2827 DoNotifyWindowAboutCaptureLost(item
->win
);
2836 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2837 int WXUNUSED(modifiers
),
2838 int WXUNUSED(keycode
))
2844 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2850 #endif // wxUSE_HOTKEY
2852 // ----------------------------------------------------------------------------
2854 // ----------------------------------------------------------------------------
2856 bool wxWindowBase::TryBefore(wxEvent
& event
)
2858 #if wxUSE_VALIDATORS
2859 // Can only use the validator of the window which
2860 // is receiving the event
2861 if ( event
.GetEventObject() == this )
2863 wxValidator
* const validator
= GetValidator();
2864 if ( validator
&& validator
->ProcessEventHere(event
) )
2869 #endif // wxUSE_VALIDATORS
2871 return wxEvtHandler::TryBefore(event
);
2874 bool wxWindowBase::TryAfter(wxEvent
& event
)
2876 // carry on up the parent-child hierarchy if the propagation count hasn't
2878 if ( event
.ShouldPropagate() )
2880 // honour the requests to stop propagation at this window: this is
2881 // used by the dialogs, for example, to prevent processing the events
2882 // from the dialog controls in the parent frame which rarely, if ever,
2884 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2886 wxWindow
*parent
= GetParent();
2887 if ( parent
&& !parent
->IsBeingDeleted() )
2889 wxPropagateOnce
propagateOnce(event
);
2891 return parent
->GetEventHandler()->ProcessEvent(event
);
2896 return wxEvtHandler::TryAfter(event
);
2899 // ----------------------------------------------------------------------------
2900 // window relationships
2901 // ----------------------------------------------------------------------------
2903 wxWindow
*wxWindowBase::DoGetSibling(WindowOrder order
) const
2905 wxCHECK_MSG( GetParent(), NULL
,
2906 _T("GetPrev/NextSibling() don't work for TLWs!") );
2908 wxWindowList
& siblings
= GetParent()->GetChildren();
2909 wxWindowList::compatibility_iterator i
= siblings
.Find((wxWindow
*)this);
2910 wxCHECK_MSG( i
, NULL
, _T("window not a child of its parent?") );
2912 if ( order
== OrderBefore
)
2913 i
= i
->GetPrevious();
2917 return i
? i
->GetData() : NULL
;
2920 // ----------------------------------------------------------------------------
2921 // keyboard navigation
2922 // ----------------------------------------------------------------------------
2924 // Navigates in the specified direction inside this window
2925 bool wxWindowBase::DoNavigateIn(int flags
)
2927 #ifdef wxHAS_NATIVE_TAB_TRAVERSAL
2928 // native code doesn't process our wxNavigationKeyEvents anyhow
2931 #else // !wxHAS_NATIVE_TAB_TRAVERSAL
2932 wxNavigationKeyEvent eventNav
;
2933 wxWindow
*focused
= FindFocus();
2934 eventNav
.SetCurrentFocus(focused
);
2935 eventNav
.SetEventObject(focused
);
2936 eventNav
.SetFlags(flags
);
2937 return GetEventHandler()->ProcessEvent(eventNav
);
2938 #endif // wxHAS_NATIVE_TAB_TRAVERSAL/!wxHAS_NATIVE_TAB_TRAVERSAL
2941 bool wxWindowBase::HandleAsNavigationKey(const wxKeyEvent
& event
)
2943 if ( event
.GetKeyCode() != WXK_TAB
)
2946 int flags
= wxNavigationKeyEvent::FromTab
;
2948 if ( event
.ShiftDown() )
2949 flags
|= wxNavigationKeyEvent::IsBackward
;
2951 flags
|= wxNavigationKeyEvent::IsForward
;
2953 if ( event
.ControlDown() )
2954 flags
|= wxNavigationKeyEvent::WinChange
;
2960 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, WindowOrder move
)
2962 // check that we're not a top level window
2963 wxCHECK_RET( GetParent(),
2964 _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
2966 // detect the special case when we have nothing to do anyhow and when the
2967 // code below wouldn't work
2971 // find the target window in the siblings list
2972 wxWindowList
& siblings
= GetParent()->GetChildren();
2973 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
2974 wxCHECK_RET( i
, _T("MoveBefore/AfterInTabOrder(): win is not a sibling") );
2976 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
2977 // can't just move the node around
2978 wxWindow
*self
= (wxWindow
*)this;
2979 siblings
.DeleteObject(self
);
2980 if ( move
== OrderAfter
)
2987 siblings
.Insert(i
, self
);
2989 else // OrderAfter and win was the last sibling
2991 siblings
.Append(self
);
2995 // ----------------------------------------------------------------------------
2997 // ----------------------------------------------------------------------------
2999 /*static*/ wxWindow
* wxWindowBase::FindFocus()
3001 wxWindowBase
*win
= DoFindFocus();
3002 return win
? win
->GetMainWindowOfCompositeControl() : NULL
;
3005 bool wxWindowBase::HasFocus() const
3007 wxWindowBase
*win
= DoFindFocus();
3008 return win
== this ||
3009 win
== wxConstCast(this, wxWindowBase
)->GetMainWindowOfCompositeControl();
3012 // ----------------------------------------------------------------------------
3014 // ----------------------------------------------------------------------------
3016 #if wxUSE_DRAG_AND_DROP && !defined(__WXMSW__)
3021 class DragAcceptFilesTarget
: public wxFileDropTarget
3024 DragAcceptFilesTarget(wxWindowBase
*win
) : m_win(win
) {}
3026 virtual bool OnDropFiles(wxCoord x
, wxCoord y
,
3027 const wxArrayString
& filenames
)
3029 wxDropFilesEvent
event(wxEVT_DROP_FILES
,
3031 wxCArrayString(filenames
).Release());
3032 event
.SetEventObject(m_win
);
3036 return m_win
->HandleWindowEvent(event
);
3040 wxWindowBase
* const m_win
;
3042 wxDECLARE_NO_COPY_CLASS(DragAcceptFilesTarget
);
3046 } // anonymous namespace
3048 // Generic version of DragAcceptFiles(). It works by installing a simple
3049 // wxFileDropTarget-to-EVT_DROP_FILES adaptor and therefore cannot be used
3050 // together with explicit SetDropTarget() calls.
3051 void wxWindowBase::DragAcceptFiles(bool accept
)
3055 wxASSERT_MSG( !GetDropTarget(),
3056 "cannot use DragAcceptFiles() and SetDropTarget() together" );
3057 SetDropTarget(new DragAcceptFilesTarget(this));
3061 SetDropTarget(NULL
);
3065 #endif // wxUSE_DRAG_AND_DROP && !defined(__WXMSW__)
3067 // ----------------------------------------------------------------------------
3069 // ----------------------------------------------------------------------------
3071 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
3073 while ( win
&& !win
->IsTopLevel() )
3074 win
= win
->GetParent();
3079 #if wxUSE_ACCESSIBILITY
3080 // ----------------------------------------------------------------------------
3081 // accessible object for windows
3082 // ----------------------------------------------------------------------------
3084 // Can return either a child object, or an integer
3085 // representing the child element, starting from 1.
3086 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
3088 wxASSERT( GetWindow() != NULL
);
3092 return wxACC_NOT_IMPLEMENTED
;
3095 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
3096 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
3098 wxASSERT( GetWindow() != NULL
);
3102 wxWindow
* win
= NULL
;
3109 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
3111 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
3118 rect
= win
->GetRect();
3119 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
3120 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
3124 return wxACC_NOT_IMPLEMENTED
;
3127 // Navigates from fromId to toId/toObject.
3128 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
3129 int* WXUNUSED(toId
), wxAccessible
** toObject
)
3131 wxASSERT( GetWindow() != NULL
);
3137 case wxNAVDIR_FIRSTCHILD
:
3139 if (GetWindow()->GetChildren().GetCount() == 0)
3141 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
3142 *toObject
= childWindow
->GetOrCreateAccessible();
3146 case wxNAVDIR_LASTCHILD
:
3148 if (GetWindow()->GetChildren().GetCount() == 0)
3150 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
3151 *toObject
= childWindow
->GetOrCreateAccessible();
3155 case wxNAVDIR_RIGHT
:
3159 wxWindowList::compatibility_iterator node
=
3160 wxWindowList::compatibility_iterator();
3163 // Can't navigate to sibling of this window
3164 // if we're a top-level window.
3165 if (!GetWindow()->GetParent())
3166 return wxACC_NOT_IMPLEMENTED
;
3168 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
3172 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
3173 node
= GetWindow()->GetChildren().Item(fromId
-1);
3176 if (node
&& node
->GetNext())
3178 wxWindow
* nextWindow
= node
->GetNext()->GetData();
3179 *toObject
= nextWindow
->GetOrCreateAccessible();
3187 case wxNAVDIR_PREVIOUS
:
3189 wxWindowList::compatibility_iterator node
=
3190 wxWindowList::compatibility_iterator();
3193 // Can't navigate to sibling of this window
3194 // if we're a top-level window.
3195 if (!GetWindow()->GetParent())
3196 return wxACC_NOT_IMPLEMENTED
;
3198 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
3202 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
3203 node
= GetWindow()->GetChildren().Item(fromId
-1);
3206 if (node
&& node
->GetPrevious())
3208 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
3209 *toObject
= previousWindow
->GetOrCreateAccessible();
3217 return wxACC_NOT_IMPLEMENTED
;
3220 // Gets the name of the specified object.
3221 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
3223 wxASSERT( GetWindow() != NULL
);
3229 // If a child, leave wxWidgets to call the function on the actual
3232 return wxACC_NOT_IMPLEMENTED
;
3234 // This will eventually be replaced by specialised
3235 // accessible classes, one for each kind of wxWidgets
3236 // control or window.
3238 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
3239 title
= ((wxButton
*) GetWindow())->GetLabel();
3242 title
= GetWindow()->GetName();
3250 return wxACC_NOT_IMPLEMENTED
;
3253 // Gets the number of children.
3254 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
3256 wxASSERT( GetWindow() != NULL
);
3260 *childId
= (int) GetWindow()->GetChildren().GetCount();
3264 // Gets the specified child (starting from 1).
3265 // If *child is NULL and return value is wxACC_OK,
3266 // this means that the child is a simple element and
3267 // not an accessible object.
3268 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
3270 wxASSERT( GetWindow() != NULL
);
3280 if (childId
> (int) GetWindow()->GetChildren().GetCount())
3283 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
3284 *child
= childWindow
->GetOrCreateAccessible();
3291 // Gets the parent, or NULL.
3292 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
3294 wxASSERT( GetWindow() != NULL
);
3298 wxWindow
* parentWindow
= GetWindow()->GetParent();
3306 *parent
= parentWindow
->GetOrCreateAccessible();
3314 // Performs the default action. childId is 0 (the action for this object)
3315 // or > 0 (the action for a child).
3316 // Return wxACC_NOT_SUPPORTED if there is no default action for this
3317 // window (e.g. an edit control).
3318 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
3320 wxASSERT( GetWindow() != NULL
);
3324 return wxACC_NOT_IMPLEMENTED
;
3327 // Gets the default action for this object (0) or > 0 (the action for a child).
3328 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
3329 // string if there is no action.
3330 // The retrieved string describes the action that is performed on an object,
3331 // not what the object does as a result. For example, a toolbar button that prints
3332 // a document has a default action of "Press" rather than "Prints the current document."
3333 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
3335 wxASSERT( GetWindow() != NULL
);
3339 return wxACC_NOT_IMPLEMENTED
;
3342 // Returns the description for this object or a child.
3343 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
3345 wxASSERT( GetWindow() != NULL
);
3349 wxString
ht(GetWindow()->GetHelpTextAtPoint(wxDefaultPosition
, wxHelpEvent::Origin_Keyboard
));
3355 return wxACC_NOT_IMPLEMENTED
;
3358 // Returns help text for this object or a child, similar to tooltip text.
3359 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
3361 wxASSERT( GetWindow() != NULL
);
3365 wxString
ht(GetWindow()->GetHelpTextAtPoint(wxDefaultPosition
, wxHelpEvent::Origin_Keyboard
));
3371 return wxACC_NOT_IMPLEMENTED
;
3374 // Returns the keyboard shortcut for this object or child.
3375 // Return e.g. ALT+K
3376 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
3378 wxASSERT( GetWindow() != NULL
);
3382 return wxACC_NOT_IMPLEMENTED
;
3385 // Returns a role constant.
3386 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
3388 wxASSERT( GetWindow() != NULL
);
3392 // If a child, leave wxWidgets to call the function on the actual
3395 return wxACC_NOT_IMPLEMENTED
;
3397 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
3398 return wxACC_NOT_IMPLEMENTED
;
3400 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
3401 return wxACC_NOT_IMPLEMENTED
;
3404 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
3405 return wxACC_NOT_IMPLEMENTED
;
3408 //*role = wxROLE_SYSTEM_CLIENT;
3409 *role
= wxROLE_SYSTEM_CLIENT
;
3413 return wxACC_NOT_IMPLEMENTED
;
3417 // Returns a state constant.
3418 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
3420 wxASSERT( GetWindow() != NULL
);
3424 // If a child, leave wxWidgets to call the function on the actual
3427 return wxACC_NOT_IMPLEMENTED
;
3429 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
3430 return wxACC_NOT_IMPLEMENTED
;
3433 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
3434 return wxACC_NOT_IMPLEMENTED
;
3437 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
3438 return wxACC_NOT_IMPLEMENTED
;
3445 return wxACC_NOT_IMPLEMENTED
;
3449 // Returns a localized string representing the value for the object
3451 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
3453 wxASSERT( GetWindow() != NULL
);
3457 return wxACC_NOT_IMPLEMENTED
;
3460 // Selects the object or child.
3461 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
3463 wxASSERT( GetWindow() != NULL
);
3467 return wxACC_NOT_IMPLEMENTED
;
3470 // Gets the window with the keyboard focus.
3471 // If childId is 0 and child is NULL, no object in
3472 // this subhierarchy has the focus.
3473 // If this object has the focus, child should be 'this'.
3474 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
3476 wxASSERT( GetWindow() != NULL
);
3480 return wxACC_NOT_IMPLEMENTED
;
3484 // Gets a variant representing the selected children
3486 // Acceptable values:
3487 // - a null variant (IsNull() returns true)
3488 // - a list variant (GetType() == wxT("list")
3489 // - an integer representing the selected child element,
3490 // or 0 if this object is selected (GetType() == wxT("long")
3491 // - a "void*" pointer to a wxAccessible child object
3492 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
3494 wxASSERT( GetWindow() != NULL
);
3498 return wxACC_NOT_IMPLEMENTED
;
3500 #endif // wxUSE_VARIANT
3502 #endif // wxUSE_ACCESSIBILITY
3504 // ----------------------------------------------------------------------------
3506 // ----------------------------------------------------------------------------
3509 wxWindowBase::AdjustForLayoutDirection(wxCoord x
,
3511 wxCoord widthTotal
) const
3513 if ( GetLayoutDirection() == wxLayout_RightToLeft
)
3515 x
= widthTotal
- x
- width
;