1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/window.cpp
3 // Purpose: common (to all ports) wxWindow functions
4 // Author: Julian Smart, Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
28 #include "wx/string.h"
32 #include "wx/window.h"
33 #include "wx/control.h"
34 #include "wx/checkbox.h"
35 #include "wx/radiobut.h"
36 #include "wx/statbox.h"
37 #include "wx/textctrl.h"
38 #include "wx/settings.h"
39 #include "wx/dialog.h"
40 #include "wx/msgdlg.h"
41 #include "wx/msgout.h"
42 #include "wx/statusbr.h"
43 #include "wx/toolbar.h"
44 #include "wx/dcclient.h"
45 #include "wx/scrolbar.h"
46 #include "wx/layout.h"
51 #if wxUSE_DRAG_AND_DROP
53 #endif // wxUSE_DRAG_AND_DROP
55 #if wxUSE_ACCESSIBILITY
56 #include "wx/access.h"
60 #include "wx/cshelp.h"
64 #include "wx/tooltip.h"
65 #endif // wxUSE_TOOLTIPS
71 #if wxUSE_SYSTEM_OPTIONS
72 #include "wx/sysopt.h"
75 #include "wx/platinfo.h"
78 WXDLLIMPEXP_DATA_CORE(wxWindowList
) wxTopLevelWindows
;
82 wxMenu
*wxCurrentPopupMenu
= NULL
;
85 // ----------------------------------------------------------------------------
87 // ----------------------------------------------------------------------------
90 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase
, wxEvtHandler
)
92 // ----------------------------------------------------------------------------
94 // ----------------------------------------------------------------------------
96 BEGIN_EVENT_TABLE(wxWindowBase
, wxEvtHandler
)
97 EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged
)
98 EVT_INIT_DIALOG(wxWindowBase::OnInitDialog
)
99 EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick
)
102 EVT_HELP(wxID_ANY
, wxWindowBase::OnHelp
)
105 EVT_SIZE(wxWindowBase::InternalOnSize
)
108 // ============================================================================
109 // implementation of the common functionality of the wxWindow class
110 // ============================================================================
112 // ----------------------------------------------------------------------------
114 // ----------------------------------------------------------------------------
116 // the default initialization
117 wxWindowBase::wxWindowBase()
119 // no window yet, no parent nor children
121 m_windowId
= wxID_ANY
;
123 // no constraints on the minimal window size
125 m_maxWidth
= wxDefaultCoord
;
127 m_maxHeight
= wxDefaultCoord
;
129 // invalidiated cache value
130 m_bestSizeCache
= wxDefaultSize
;
132 // window are created enabled and visible by default
136 // the default event handler is just this window
137 m_eventHandler
= this;
141 m_windowValidator
= NULL
;
142 #endif // wxUSE_VALIDATORS
144 // the colours/fonts are default for now, so leave m_font,
145 // m_backgroundColour and m_foregroundColour uninitialized and set those
151 m_inheritFont
= false;
157 m_backgroundStyle
= wxBG_STYLE_ERASE
;
159 #if wxUSE_CONSTRAINTS
160 // no constraints whatsoever
161 m_constraints
= NULL
;
162 m_constraintsInvolvedIn
= NULL
;
163 #endif // wxUSE_CONSTRAINTS
165 m_windowSizer
= NULL
;
166 m_containingSizer
= NULL
;
167 m_autoLayout
= false;
169 #if wxUSE_DRAG_AND_DROP
171 #endif // wxUSE_DRAG_AND_DROP
175 #endif // wxUSE_TOOLTIPS
179 #endif // wxUSE_CARET
182 m_hasCustomPalette
= false;
183 #endif // wxUSE_PALETTE
185 #if wxUSE_ACCESSIBILITY
189 m_virtualSize
= wxDefaultSize
;
191 m_scrollHelper
= NULL
;
193 m_windowVariant
= wxWINDOW_VARIANT_NORMAL
;
194 #if wxUSE_SYSTEM_OPTIONS
195 if ( wxSystemOptions::HasOption(wxWINDOW_DEFAULT_VARIANT
) )
197 m_windowVariant
= (wxWindowVariant
) wxSystemOptions::GetOptionInt( wxWINDOW_DEFAULT_VARIANT
) ;
201 // Whether we're using the current theme for this window (wxGTK only for now)
202 m_themeEnabled
= false;
204 // This is set to true by SendDestroyEvent() which should be called by the
205 // most derived class to ensure that the destruction event is sent as soon
206 // as possible to allow its handlers to still see the undestroyed window
207 m_isBeingDeleted
= false;
212 // common part of window creation process
213 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
215 const wxPoint
& WXUNUSED(pos
),
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 wxT("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
;
242 // assume the user doesn't want this window to shrink beneath its initial
243 // size, this worked like this in wxWidgets 2.8 and before and generally
244 // often makes sense for child windows (for top level ones it definitely
245 // does not as the user should be able to resize the window)
247 // note that we can't use IsTopLevel() from ctor
248 if ( !wxTopLevelWindows
.Find((wxWindow
*)this) )
257 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
262 const wxValidator
& wxVALIDATOR_PARAM(validator
),
263 const wxString
& name
)
265 if ( !CreateBase(parent
, id
, pos
, size
, style
, name
) )
269 SetValidator(validator
);
270 #endif // wxUSE_VALIDATORS
272 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
273 // have it too - like this it's possible to set it only in the top level
274 // dialog/frame and all children will inherit it by defult
275 if ( parent
&& (parent
->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) )
277 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY
);
283 bool wxWindowBase::ToggleWindowStyle(int flag
)
285 wxASSERT_MSG( flag
, wxT("flags with 0 value can't be toggled") );
288 long style
= GetWindowStyleFlag();
294 else // currently off
300 SetWindowStyleFlag(style
);
305 // ----------------------------------------------------------------------------
307 // ----------------------------------------------------------------------------
310 wxWindowBase::~wxWindowBase()
312 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
314 // FIXME if these 2 cases result from programming errors in the user code
315 // we should probably assert here instead of silently fixing them
317 // Just in case the window has been Closed, but we're then deleting
318 // immediately: don't leave dangling pointers.
319 wxPendingDelete
.DeleteObject(this);
321 // Just in case we've loaded a top-level window via LoadNativeDialog but
322 // we weren't a dialog class
323 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
326 // The associated popup menu can still be alive, disassociate from it in
328 if ( wxCurrentPopupMenu
&& wxCurrentPopupMenu
->GetInvokingWindow() == this )
329 wxCurrentPopupMenu
->SetInvokingWindow(NULL
);
330 #endif // wxUSE_MENUS
332 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
334 // notify the parent about this window destruction
336 m_parent
->RemoveChild(this);
340 #endif // wxUSE_CARET
343 delete m_windowValidator
;
344 #endif // wxUSE_VALIDATORS
346 #if wxUSE_CONSTRAINTS
347 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
348 // at deleted windows as they delete themselves.
349 DeleteRelatedConstraints();
353 // This removes any dangling pointers to this window in other windows'
354 // constraintsInvolvedIn lists.
355 UnsetConstraints(m_constraints
);
356 delete m_constraints
;
357 m_constraints
= NULL
;
359 #endif // wxUSE_CONSTRAINTS
361 if ( m_containingSizer
)
362 m_containingSizer
->Detach( (wxWindow
*)this );
364 delete m_windowSizer
;
366 #if wxUSE_DRAG_AND_DROP
368 #endif // wxUSE_DRAG_AND_DROP
372 #endif // wxUSE_TOOLTIPS
374 #if wxUSE_ACCESSIBILITY
379 // NB: this has to be called unconditionally, because we don't know
380 // whether this window has associated help text or not
381 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
383 helpProvider
->RemoveHelp(this);
387 bool wxWindowBase::IsBeingDeleted() const
389 return m_isBeingDeleted
||
390 (!IsTopLevel() && m_parent
&& m_parent
->IsBeingDeleted());
393 void wxWindowBase::SendDestroyEvent()
395 if ( m_isBeingDeleted
)
397 // we could have been already called from a more derived class dtor,
398 // e.g. ~wxTLW calls us and so does ~wxWindow and the latter call
399 // should be simply ignored
403 m_isBeingDeleted
= true;
405 wxWindowDestroyEvent event
;
406 event
.SetEventObject(this);
407 event
.SetId(GetId());
408 GetEventHandler()->ProcessEvent(event
);
411 bool wxWindowBase::Destroy()
420 bool wxWindowBase::Close(bool force
)
422 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
423 event
.SetEventObject(this);
424 event
.SetCanVeto(!force
);
426 // return false if window wasn't closed because the application vetoed the
428 return HandleWindowEvent(event
) && !event
.GetVeto();
431 bool wxWindowBase::DestroyChildren()
433 wxWindowList::compatibility_iterator node
;
436 // we iterate until the list becomes empty
437 node
= GetChildren().GetFirst();
441 wxWindow
*child
= node
->GetData();
443 // note that we really want to delete it immediately so don't call the
444 // possible overridden Destroy() version which might not delete the
445 // child immediately resulting in problems with our (top level) child
446 // outliving its parent
447 child
->wxWindowBase::Destroy();
449 wxASSERT_MSG( !GetChildren().Find(child
),
450 wxT("child didn't remove itself using RemoveChild()") );
456 // ----------------------------------------------------------------------------
457 // size/position related methods
458 // ----------------------------------------------------------------------------
460 // centre the window with respect to its parent in either (or both) directions
461 void wxWindowBase::DoCentre(int dir
)
463 wxCHECK_RET( !(dir
& wxCENTRE_ON_SCREEN
) && GetParent(),
464 wxT("this method only implements centering child windows") );
466 SetSize(GetRect().CentreIn(GetParent()->GetClientSize(), dir
));
469 // fits the window around the children
470 void wxWindowBase::Fit()
472 if ( !GetChildren().empty() )
474 SetSize(GetBestSize());
476 //else: do nothing if we have no children
479 // fits virtual size (ie. scrolled area etc.) around children
480 void wxWindowBase::FitInside()
482 if ( GetChildren().GetCount() > 0 )
484 SetVirtualSize( GetBestVirtualSize() );
488 // On Mac, scrollbars are explicitly children.
489 #if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__)
490 static bool wxHasRealChildren(const wxWindowBase
* win
)
492 int realChildCount
= 0;
494 for ( wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
496 node
= node
->GetNext() )
498 wxWindow
*win
= node
->GetData();
499 if ( !win
->IsTopLevel() && win
->IsShown()
501 && !win
->IsKindOf(CLASSINFO(wxScrollBar
))
506 return (realChildCount
> 0);
510 void wxWindowBase::InvalidateBestSize()
512 m_bestSizeCache
= wxDefaultSize
;
514 // parent's best size calculation may depend on its children's
515 // as long as child window we are in is not top level window itself
516 // (because the TLW size is never resized automatically)
517 // so let's invalidate it as well to be safe:
518 if (m_parent
&& !IsTopLevel())
519 m_parent
->InvalidateBestSize();
522 // return the size best suited for the current window
523 wxSize
wxWindowBase::DoGetBestSize() const
529 best
= m_windowSizer
->GetMinSize();
531 #if wxUSE_CONSTRAINTS
532 else if ( m_constraints
)
534 wxConstCast(this, wxWindowBase
)->SatisfyConstraints();
536 // our minimal acceptable size is such that all our windows fit inside
540 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
542 node
= node
->GetNext() )
544 wxLayoutConstraints
*c
= node
->GetData()->GetConstraints();
547 // it's not normal that we have an unconstrained child, but
548 // what can we do about it?
552 int x
= c
->right
.GetValue(),
553 y
= c
->bottom
.GetValue();
561 // TODO: we must calculate the overlaps somehow, otherwise we
562 // will never return a size bigger than the current one :-(
565 best
= wxSize(maxX
, maxY
);
567 #endif // wxUSE_CONSTRAINTS
568 else if ( !GetChildren().empty()
569 #if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__)
570 && wxHasRealChildren(this)
574 // our minimal acceptable size is such that all our visible child
575 // windows fit inside
579 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
581 node
= node
->GetNext() )
583 wxWindow
*win
= node
->GetData();
584 if ( win
->IsTopLevel()
587 || wxDynamicCast(win
, wxStatusBar
)
588 #endif // wxUSE_STATUSBAR
591 // dialogs and frames lie in different top level windows -
592 // don't deal with them here; as for the status bars, they
593 // don't lie in the client area at all
598 win
->GetPosition(&wx
, &wy
);
600 // if the window hadn't been positioned yet, assume that it is in
602 if ( wx
== wxDefaultCoord
)
604 if ( wy
== wxDefaultCoord
)
607 win
->GetSize(&ww
, &wh
);
608 if ( wx
+ ww
> maxX
)
610 if ( wy
+ wh
> maxY
)
614 best
= wxSize(maxX
, maxY
);
616 else // ! has children
618 wxSize size
= GetMinSize();
619 if ( !size
.IsFullySpecified() )
621 // if the window doesn't define its best size we assume that it can
622 // be arbitrarily small -- usually this is not the case, of course,
623 // but we have no way to know what the limit is, it should really
624 // override DoGetBestClientSize() itself to tell us
625 size
.SetDefaults(wxSize(1, 1));
628 // return as-is, unadjusted by the client size difference.
632 // Add any difference between size and client size
633 wxSize diff
= GetSize() - GetClientSize();
634 best
.x
+= wxMax(0, diff
.x
);
635 best
.y
+= wxMax(0, diff
.y
);
640 // helper of GetWindowBorderSize(): as many ports don't implement support for
641 // wxSYS_BORDER/EDGE_X/Y metrics in their wxSystemSettings, use hard coded
642 // fallbacks in this case
643 static int wxGetMetricOrDefault(wxSystemMetric what
, const wxWindowBase
* win
)
645 int rc
= wxSystemSettings::GetMetric(
646 what
, static_cast<wxWindow
*>(const_cast<wxWindowBase
*>(win
)));
653 // 2D border is by default 1 pixel wide
659 // 3D borders are by default 2 pixels
664 wxFAIL_MSG( wxT("unexpected wxGetMetricOrDefault() argument") );
672 wxSize
wxWindowBase::GetWindowBorderSize() const
676 switch ( GetBorder() )
679 // nothing to do, size is already (0, 0)
682 case wxBORDER_SIMPLE
:
683 case wxBORDER_STATIC
:
684 size
.x
= wxGetMetricOrDefault(wxSYS_BORDER_X
, this);
685 size
.y
= wxGetMetricOrDefault(wxSYS_BORDER_Y
, this);
688 case wxBORDER_SUNKEN
:
689 case wxBORDER_RAISED
:
690 size
.x
= wxMax(wxGetMetricOrDefault(wxSYS_EDGE_X
, this),
691 wxGetMetricOrDefault(wxSYS_BORDER_X
, this));
692 size
.y
= wxMax(wxGetMetricOrDefault(wxSYS_EDGE_Y
, this),
693 wxGetMetricOrDefault(wxSYS_BORDER_Y
, this));
696 case wxBORDER_DOUBLE
:
697 size
.x
= wxGetMetricOrDefault(wxSYS_EDGE_X
, this) +
698 wxGetMetricOrDefault(wxSYS_BORDER_X
, this);
699 size
.y
= wxGetMetricOrDefault(wxSYS_EDGE_Y
, this) +
700 wxGetMetricOrDefault(wxSYS_BORDER_Y
, this);
704 wxFAIL_MSG(wxT("Unknown border style."));
708 // we have borders on both sides
712 wxSize
wxWindowBase::GetEffectiveMinSize() const
714 // merge the best size with the min size, giving priority to the min size
715 wxSize min
= GetMinSize();
717 if (min
.x
== wxDefaultCoord
|| min
.y
== wxDefaultCoord
)
719 wxSize best
= GetBestSize();
720 if (min
.x
== wxDefaultCoord
) min
.x
= best
.x
;
721 if (min
.y
== wxDefaultCoord
) min
.y
= best
.y
;
727 wxSize
wxWindowBase::DoGetBorderSize() const
729 // there is one case in which we can implement it for all ports easily:
730 // do it as some classes used by both wxUniv and native ports (e.g.
731 // wxGenericStaticText) do override DoGetBestClientSize() and so this
732 // method must work for them and that ensures that it does, at least in
734 if ( GetBorder() == wxBORDER_NONE
)
737 wxFAIL_MSG( "must be overridden if called" );
739 return wxDefaultSize
;
742 wxSize
wxWindowBase::GetBestSize() const
744 if ( !m_windowSizer
&& m_bestSizeCache
.IsFullySpecified() )
745 return m_bestSizeCache
;
747 // call DoGetBestClientSize() first, if a derived class overrides it wants
749 wxSize size
= DoGetBestClientSize();
750 if ( size
!= wxDefaultSize
)
752 size
+= DoGetBorderSize();
758 return DoGetBestSize();
761 void wxWindowBase::SetMinSize(const wxSize
& minSize
)
763 m_minWidth
= minSize
.x
;
764 m_minHeight
= minSize
.y
;
767 void wxWindowBase::SetMaxSize(const wxSize
& maxSize
)
769 m_maxWidth
= maxSize
.x
;
770 m_maxHeight
= maxSize
.y
;
773 void wxWindowBase::SetInitialSize(const wxSize
& size
)
775 // Set the min size to the size passed in. This will usually either be
776 // wxDefaultSize or the size passed to this window's ctor/Create function.
779 // Merge the size with the best size if needed
780 wxSize best
= GetEffectiveMinSize();
782 // If the current size doesn't match then change it
783 if (GetSize() != best
)
788 // by default the origin is not shifted
789 wxPoint
wxWindowBase::GetClientAreaOrigin() const
794 wxSize
wxWindowBase::ClientToWindowSize(const wxSize
& size
) const
796 const wxSize
diff(GetSize() - GetClientSize());
798 return wxSize(size
.x
== -1 ? -1 : size
.x
+ diff
.x
,
799 size
.y
== -1 ? -1 : size
.y
+ diff
.y
);
802 wxSize
wxWindowBase::WindowToClientSize(const wxSize
& size
) const
804 const wxSize
diff(GetSize() - GetClientSize());
806 return wxSize(size
.x
== -1 ? -1 : size
.x
- diff
.x
,
807 size
.y
== -1 ? -1 : size
.y
- diff
.y
);
810 void wxWindowBase::SetWindowVariant( wxWindowVariant variant
)
812 if ( m_windowVariant
!= variant
)
814 m_windowVariant
= variant
;
816 DoSetWindowVariant(variant
);
820 void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant
)
822 // adjust the font height to correspond to our new variant (notice that
823 // we're only called if something really changed)
824 wxFont font
= GetFont();
825 int size
= font
.GetPointSize();
828 case wxWINDOW_VARIANT_NORMAL
:
831 case wxWINDOW_VARIANT_SMALL
:
836 case wxWINDOW_VARIANT_MINI
:
841 case wxWINDOW_VARIANT_LARGE
:
847 wxFAIL_MSG(wxT("unexpected window variant"));
851 font
.SetPointSize(size
);
855 void wxWindowBase::DoSetSizeHints( int minW
, int minH
,
857 int WXUNUSED(incW
), int WXUNUSED(incH
) )
859 wxCHECK_RET( (minW
== wxDefaultCoord
|| maxW
== wxDefaultCoord
|| minW
<= maxW
) &&
860 (minH
== wxDefaultCoord
|| maxH
== wxDefaultCoord
|| minH
<= maxH
),
861 wxT("min width/height must be less than max width/height!") );
870 #if WXWIN_COMPATIBILITY_2_8
871 void wxWindowBase::SetVirtualSizeHints(int WXUNUSED(minW
), int WXUNUSED(minH
),
872 int WXUNUSED(maxW
), int WXUNUSED(maxH
))
876 void wxWindowBase::SetVirtualSizeHints(const wxSize
& WXUNUSED(minsize
),
877 const wxSize
& WXUNUSED(maxsize
))
880 #endif // WXWIN_COMPATIBILITY_2_8
882 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
884 m_virtualSize
= wxSize(x
, y
);
887 wxSize
wxWindowBase::DoGetVirtualSize() const
889 // we should use the entire client area so if it is greater than our
890 // virtual size, expand it to fit (otherwise if the window is big enough we
891 // wouldn't be using parts of it)
892 wxSize size
= GetClientSize();
893 if ( m_virtualSize
.x
> size
.x
)
894 size
.x
= m_virtualSize
.x
;
896 if ( m_virtualSize
.y
>= size
.y
)
897 size
.y
= m_virtualSize
.y
;
902 void wxWindowBase::DoGetScreenPosition(int *x
, int *y
) const
904 // screen position is the same as (0, 0) in client coords for non TLWs (and
905 // TLWs override this method)
911 ClientToScreen(x
, y
);
914 void wxWindowBase::SendSizeEvent(int flags
)
916 wxSizeEvent
event(GetSize(), GetId());
917 event
.SetEventObject(this);
918 if ( flags
& wxSEND_EVENT_POST
)
919 wxPostEvent(this, event
);
921 HandleWindowEvent(event
);
924 void wxWindowBase::SendSizeEventToParent(int flags
)
926 wxWindow
* const parent
= GetParent();
927 if ( parent
&& !parent
->IsBeingDeleted() )
928 parent
->SendSizeEvent(flags
);
931 bool wxWindowBase::HasScrollbar(int orient
) const
933 // if scrolling in the given direction is disabled, we can't have the
934 // corresponding scrollbar no matter what
935 if ( !CanScroll(orient
) )
938 const wxSize sizeVirt
= GetVirtualSize();
939 const wxSize sizeClient
= GetClientSize();
941 return orient
== wxHORIZONTAL
? sizeVirt
.x
> sizeClient
.x
942 : sizeVirt
.y
> sizeClient
.y
;
945 // ----------------------------------------------------------------------------
946 // show/hide/enable/disable the window
947 // ----------------------------------------------------------------------------
949 bool wxWindowBase::Show(bool show
)
951 if ( show
!= m_isShown
)
963 bool wxWindowBase::IsEnabled() const
965 return IsThisEnabled() && (IsTopLevel() || !GetParent() || GetParent()->IsEnabled());
968 void wxWindowBase::NotifyWindowOnEnableChange(bool enabled
)
970 #ifndef wxHAS_NATIVE_ENABLED_MANAGEMENT
972 #endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
976 // If we are top-level then the logic doesn't apply - otherwise
977 // showing a modal dialog would result in total greying out (and ungreying
978 // out later) of everything which would be really ugly
982 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
984 node
= node
->GetNext() )
986 wxWindowBase
* const child
= node
->GetData();
987 if ( !child
->IsTopLevel() && child
->IsThisEnabled() )
988 child
->NotifyWindowOnEnableChange(enabled
);
992 bool wxWindowBase::Enable(bool enable
)
994 if ( enable
== IsThisEnabled() )
997 m_isEnabled
= enable
;
999 #ifdef wxHAS_NATIVE_ENABLED_MANAGEMENT
1001 #else // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
1002 wxWindowBase
* const parent
= GetParent();
1003 if( !IsTopLevel() && parent
&& !parent
->IsEnabled() )
1007 #endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
1009 NotifyWindowOnEnableChange(enable
);
1014 bool wxWindowBase::IsShownOnScreen() const
1016 // A window is shown on screen if it itself is shown and so are all its
1017 // parents. But if a window is toplevel one, then its always visible on
1018 // screen if IsShown() returns true, even if it has a hidden parent.
1020 (IsTopLevel() || GetParent() == NULL
|| GetParent()->IsShownOnScreen());
1023 // ----------------------------------------------------------------------------
1025 // ----------------------------------------------------------------------------
1027 bool wxWindowBase::IsTopLevel() const
1032 // ----------------------------------------------------------------------------
1034 // ----------------------------------------------------------------------------
1036 void wxWindowBase::Freeze()
1038 if ( !m_freezeCount
++ )
1040 // physically freeze this window:
1043 // and recursively freeze all children:
1044 for ( wxWindowList::iterator i
= GetChildren().begin();
1045 i
!= GetChildren().end(); ++i
)
1047 wxWindow
*child
= *i
;
1048 if ( child
->IsTopLevel() )
1056 void wxWindowBase::Thaw()
1058 wxASSERT_MSG( m_freezeCount
, "Thaw() without matching Freeze()" );
1060 if ( !--m_freezeCount
)
1062 // recursively thaw all children:
1063 for ( wxWindowList::iterator i
= GetChildren().begin();
1064 i
!= GetChildren().end(); ++i
)
1066 wxWindow
*child
= *i
;
1067 if ( child
->IsTopLevel() )
1073 // physically thaw this window:
1078 // ----------------------------------------------------------------------------
1079 // reparenting the window
1080 // ----------------------------------------------------------------------------
1082 void wxWindowBase::AddChild(wxWindowBase
*child
)
1084 wxCHECK_RET( child
, wxT("can't add a NULL child") );
1086 // this should never happen and it will lead to a crash later if it does
1087 // because RemoveChild() will remove only one node from the children list
1088 // and the other(s) one(s) will be left with dangling pointers in them
1089 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), wxT("AddChild() called twice") );
1091 GetChildren().Append((wxWindow
*)child
);
1092 child
->SetParent(this);
1094 // adding a child while frozen will assert when thawed, so freeze it as if
1095 // it had been already present when we were frozen
1096 if ( IsFrozen() && !child
->IsTopLevel() )
1100 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
1102 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
1104 // removing a child while frozen may result in permanently frozen window
1105 // if used e.g. from Reparent(), so thaw it
1107 // NB: IsTopLevel() doesn't return true any more when a TLW child is being
1108 // removed from its ~wxWindowBase, so check for IsBeingDeleted() too
1109 if ( IsFrozen() && !child
->IsBeingDeleted() && !child
->IsTopLevel() )
1112 GetChildren().DeleteObject((wxWindow
*)child
);
1113 child
->SetParent(NULL
);
1116 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
1118 wxWindow
*oldParent
= GetParent();
1119 if ( newParent
== oldParent
)
1125 const bool oldEnabledState
= IsEnabled();
1127 // unlink this window from the existing parent.
1130 oldParent
->RemoveChild(this);
1134 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
1137 // add it to the new one
1140 newParent
->AddChild(this);
1144 wxTopLevelWindows
.Append((wxWindow
*)this);
1147 // We need to notify window (and its subwindows) if by changing the parent
1148 // we also change our enabled/disabled status.
1149 const bool newEnabledState
= IsEnabled();
1150 if ( newEnabledState
!= oldEnabledState
)
1152 NotifyWindowOnEnableChange(newEnabledState
);
1158 // ----------------------------------------------------------------------------
1159 // event handler stuff
1160 // ----------------------------------------------------------------------------
1162 void wxWindowBase::SetEventHandler(wxEvtHandler
*handler
)
1164 wxCHECK_RET(handler
!= NULL
, "SetEventHandler(NULL) called");
1166 m_eventHandler
= handler
;
1169 void wxWindowBase::SetNextHandler(wxEvtHandler
*WXUNUSED(handler
))
1171 // disable wxEvtHandler chain mechanism for wxWindows:
1172 // wxWindow uses its own stack mechanism which doesn't mix well with wxEvtHandler's one
1174 wxFAIL_MSG("wxWindow cannot be part of a wxEvtHandler chain");
1176 void wxWindowBase::SetPreviousHandler(wxEvtHandler
*WXUNUSED(handler
))
1178 // we can't simply wxFAIL here as in SetNextHandler: in fact the last
1179 // handler of our stack when is destroyed will be Unlink()ed and thus
1180 // will call this function to update the pointer of this window...
1182 //wxFAIL_MSG("wxWindow cannot be part of a wxEvtHandler chain");
1185 void wxWindowBase::PushEventHandler(wxEvtHandler
*handlerToPush
)
1187 wxCHECK_RET( handlerToPush
!= NULL
, "PushEventHandler(NULL) called" );
1189 // the new handler is going to be part of the wxWindow stack of event handlers:
1190 // it can't be part also of an event handler double-linked chain:
1191 wxASSERT_MSG(handlerToPush
->IsUnlinked(),
1192 "The handler being pushed in the wxWindow stack shouldn't be part of "
1193 "a wxEvtHandler chain; call Unlink() on it first");
1195 wxEvtHandler
*handlerOld
= GetEventHandler();
1196 wxCHECK_RET( handlerOld
, "an old event handler is NULL?" );
1198 // now use wxEvtHandler double-linked list to implement a stack:
1199 handlerToPush
->SetNextHandler(handlerOld
);
1201 if (handlerOld
!= this)
1202 handlerOld
->SetPreviousHandler(handlerToPush
);
1204 SetEventHandler(handlerToPush
);
1207 // final checks of the operations done above:
1208 wxASSERT_MSG( handlerToPush
->GetPreviousHandler() == NULL
,
1209 "the first handler of the wxWindow stack should "
1210 "have no previous handlers set" );
1211 wxASSERT_MSG( handlerToPush
->GetNextHandler() != NULL
,
1212 "the first handler of the wxWindow stack should "
1213 "have non-NULL next handler" );
1215 wxEvtHandler
* pLast
= handlerToPush
;
1216 while ( pLast
&& pLast
!= this )
1217 pLast
= pLast
->GetNextHandler();
1218 wxASSERT_MSG( pLast
->GetNextHandler() == NULL
,
1219 "the last handler of the wxWindow stack should "
1220 "have this window as next handler" );
1221 #endif // wxDEBUG_LEVEL
1224 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
1226 // we need to pop the wxWindow stack, i.e. we need to remove the first handler
1228 wxEvtHandler
*firstHandler
= GetEventHandler();
1229 wxCHECK_MSG( firstHandler
!= NULL
, NULL
, "wxWindow cannot have a NULL event handler" );
1230 wxCHECK_MSG( firstHandler
!= this, NULL
, "cannot pop the wxWindow itself" );
1231 wxCHECK_MSG( firstHandler
->GetPreviousHandler() == NULL
, NULL
,
1232 "the first handler of the wxWindow stack should have no previous handlers set" );
1234 wxEvtHandler
*secondHandler
= firstHandler
->GetNextHandler();
1235 wxCHECK_MSG( secondHandler
!= NULL
, NULL
,
1236 "the first handler of the wxWindow stack should have non-NULL next handler" );
1238 firstHandler
->SetNextHandler(NULL
);
1239 secondHandler
->SetPreviousHandler(NULL
);
1241 // now firstHandler is completely unlinked; set secondHandler as the new window event handler
1242 SetEventHandler(secondHandler
);
1244 if ( deleteHandler
)
1246 delete firstHandler
;
1247 firstHandler
= NULL
;
1250 return firstHandler
;
1253 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handlerToRemove
)
1255 wxCHECK_MSG( handlerToRemove
!= NULL
, false, "RemoveEventHandler(NULL) called" );
1256 wxCHECK_MSG( handlerToRemove
!= this, false, "Cannot remove the window itself" );
1258 if (handlerToRemove
== GetEventHandler())
1260 // removing the first event handler is equivalent to "popping" the stack
1261 PopEventHandler(false);
1265 // NOTE: the wxWindow event handler list is always terminated with "this" handler
1266 wxEvtHandler
*handlerCur
= GetEventHandler()->GetNextHandler();
1267 while ( handlerCur
!= this )
1269 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
1271 if ( handlerCur
== handlerToRemove
)
1273 handlerCur
->Unlink();
1275 wxASSERT_MSG( handlerCur
!= GetEventHandler(),
1276 "the case Remove == Pop should was already handled" );
1280 handlerCur
= handlerNext
;
1283 wxFAIL_MSG( wxT("where has the event handler gone?") );
1288 bool wxWindowBase::HandleWindowEvent(wxEvent
& event
) const
1290 // SafelyProcessEvent() will handle exceptions nicely
1291 return GetEventHandler()->SafelyProcessEvent(event
);
1294 // ----------------------------------------------------------------------------
1295 // colours, fonts &c
1296 // ----------------------------------------------------------------------------
1298 void wxWindowBase::InheritAttributes()
1300 const wxWindowBase
* const parent
= GetParent();
1304 // we only inherit attributes which had been explicitly set for the parent
1305 // which ensures that this only happens if the user really wants it and
1306 // not by default which wouldn't make any sense in modern GUIs where the
1307 // controls don't all use the same fonts (nor colours)
1308 if ( parent
->m_inheritFont
&& !m_hasFont
)
1309 SetFont(parent
->GetFont());
1311 // in addition, there is a possibility to explicitly forbid inheriting
1312 // colours at each class level by overriding ShouldInheritColours()
1313 if ( ShouldInheritColours() )
1315 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
1316 SetForegroundColour(parent
->GetForegroundColour());
1318 // inheriting (solid) background colour is wrong as it totally breaks
1319 // any kind of themed backgrounds
1321 // instead, the controls should use the same background as their parent
1322 // (ideally by not drawing it at all)
1324 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
1325 SetBackgroundColour(parent
->GetBackgroundColour());
1330 /* static */ wxVisualAttributes
1331 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
1333 // it is important to return valid values for all attributes from here,
1334 // GetXXX() below rely on this
1335 wxVisualAttributes attrs
;
1336 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
1337 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
1339 // On Smartphone/PocketPC, wxSYS_COLOUR_WINDOW is a better reflection of
1340 // the usual background colour than wxSYS_COLOUR_BTNFACE.
1341 // It's a pity that wxSYS_COLOUR_WINDOW isn't always a suitable background
1342 // colour on other platforms.
1344 #if defined(__WXWINCE__) && (defined(__SMARTPHONE__) || defined(__POCKETPC__))
1345 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1347 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
1352 wxColour
wxWindowBase::GetBackgroundColour() const
1354 if ( !m_backgroundColour
.IsOk() )
1356 wxASSERT_MSG( !m_hasBgCol
, wxT("we have invalid explicit bg colour?") );
1358 // get our default background colour
1359 wxColour colBg
= GetDefaultAttributes().colBg
;
1361 // we must return some valid colour to avoid redoing this every time
1362 // and also to avoid surprizing the applications written for older
1363 // wxWidgets versions where GetBackgroundColour() always returned
1364 // something -- so give them something even if it doesn't make sense
1365 // for this window (e.g. it has a themed background)
1367 colBg
= GetClassDefaultAttributes().colBg
;
1372 return m_backgroundColour
;
1375 wxColour
wxWindowBase::GetForegroundColour() const
1377 // logic is the same as above
1378 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
1380 wxColour colFg
= GetDefaultAttributes().colFg
;
1382 if ( !colFg
.IsOk() )
1383 colFg
= GetClassDefaultAttributes().colFg
;
1388 return m_foregroundColour
;
1391 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
1393 if ( colour
== m_backgroundColour
)
1396 m_hasBgCol
= colour
.IsOk();
1398 m_inheritBgCol
= m_hasBgCol
;
1399 m_backgroundColour
= colour
;
1400 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1404 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1406 if (colour
== m_foregroundColour
)
1409 m_hasFgCol
= colour
.IsOk();
1410 m_inheritFgCol
= m_hasFgCol
;
1411 m_foregroundColour
= colour
;
1412 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1416 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1418 // setting an invalid cursor is ok, it means that we don't have any special
1420 if ( m_cursor
.IsSameAs(cursor
) )
1431 wxFont
wxWindowBase::GetFont() const
1433 // logic is the same as in GetBackgroundColour()
1434 if ( !m_font
.IsOk() )
1436 wxASSERT_MSG( !m_hasFont
, wxT("we have invalid explicit font?") );
1438 wxFont font
= GetDefaultAttributes().font
;
1440 font
= GetClassDefaultAttributes().font
;
1448 bool wxWindowBase::SetFont(const wxFont
& font
)
1450 if ( font
== m_font
)
1457 m_hasFont
= font
.IsOk();
1458 m_inheritFont
= m_hasFont
;
1460 InvalidateBestSize();
1467 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1469 m_hasCustomPalette
= true;
1472 // VZ: can anyone explain me what do we do here?
1473 wxWindowDC
d((wxWindow
*) this);
1477 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1479 wxWindow
*win
= (wxWindow
*)this;
1480 while ( win
&& !win
->HasCustomPalette() )
1482 win
= win
->GetParent();
1488 #endif // wxUSE_PALETTE
1491 void wxWindowBase::SetCaret(wxCaret
*caret
)
1502 wxASSERT_MSG( m_caret
->GetWindow() == this,
1503 wxT("caret should be created associated to this window") );
1506 #endif // wxUSE_CARET
1508 #if wxUSE_VALIDATORS
1509 // ----------------------------------------------------------------------------
1511 // ----------------------------------------------------------------------------
1513 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1515 if ( m_windowValidator
)
1516 delete m_windowValidator
;
1518 m_windowValidator
= (wxValidator
*)validator
.Clone();
1520 if ( m_windowValidator
)
1521 m_windowValidator
->SetWindow(this);
1523 #endif // wxUSE_VALIDATORS
1525 // ----------------------------------------------------------------------------
1526 // update region stuff
1527 // ----------------------------------------------------------------------------
1529 wxRect
wxWindowBase::GetUpdateClientRect() const
1531 wxRegion rgnUpdate
= GetUpdateRegion();
1532 rgnUpdate
.Intersect(GetClientRect());
1533 wxRect rectUpdate
= rgnUpdate
.GetBox();
1534 wxPoint ptOrigin
= GetClientAreaOrigin();
1535 rectUpdate
.x
-= ptOrigin
.x
;
1536 rectUpdate
.y
-= ptOrigin
.y
;
1541 bool wxWindowBase::DoIsExposed(int x
, int y
) const
1543 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1546 bool wxWindowBase::DoIsExposed(int x
, int y
, int w
, int h
) const
1548 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1551 void wxWindowBase::ClearBackground()
1553 // wxGTK uses its own version, no need to add never used code
1555 wxClientDC
dc((wxWindow
*)this);
1556 wxBrush
brush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID
);
1557 dc
.SetBackground(brush
);
1562 // ----------------------------------------------------------------------------
1563 // find child window by id or name
1564 // ----------------------------------------------------------------------------
1566 wxWindow
*wxWindowBase::FindWindow(long id
) const
1568 if ( id
== m_windowId
)
1569 return (wxWindow
*)this;
1571 wxWindowBase
*res
= NULL
;
1572 wxWindowList::compatibility_iterator node
;
1573 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1575 wxWindowBase
*child
= node
->GetData();
1576 res
= child
->FindWindow( id
);
1579 return (wxWindow
*)res
;
1582 wxWindow
*wxWindowBase::FindWindow(const wxString
& name
) const
1584 if ( name
== m_windowName
)
1585 return (wxWindow
*)this;
1587 wxWindowBase
*res
= NULL
;
1588 wxWindowList::compatibility_iterator node
;
1589 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1591 wxWindow
*child
= node
->GetData();
1592 res
= child
->FindWindow(name
);
1595 return (wxWindow
*)res
;
1599 // find any window by id or name or label: If parent is non-NULL, look through
1600 // children for a label or title matching the specified string. If NULL, look
1601 // through all top-level windows.
1603 // to avoid duplicating code we reuse the same helper function but with
1604 // different comparators
1606 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1607 const wxString
& label
, long id
);
1610 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1613 return win
->GetLabel() == label
;
1617 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1620 return win
->GetName() == label
;
1624 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1627 return win
->GetId() == id
;
1630 // recursive helper for the FindWindowByXXX() functions
1632 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1633 const wxString
& label
,
1635 wxFindWindowCmp cmp
)
1639 // see if this is the one we're looking for
1640 if ( (*cmp
)(parent
, label
, id
) )
1641 return (wxWindow
*)parent
;
1643 // It wasn't, so check all its children
1644 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1646 node
= node
->GetNext() )
1648 // recursively check each child
1649 wxWindow
*win
= (wxWindow
*)node
->GetData();
1650 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1660 // helper for FindWindowByXXX()
1662 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1663 const wxString
& label
,
1665 wxFindWindowCmp cmp
)
1669 // just check parent and all its children
1670 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1673 // start at very top of wx's windows
1674 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1676 node
= node
->GetNext() )
1678 // recursively check each window & its children
1679 wxWindow
*win
= node
->GetData();
1680 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1690 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1692 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1697 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1699 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1703 // fall back to the label
1704 win
= FindWindowByLabel(title
, parent
);
1712 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1714 return wxFindWindowHelper(parent
, wxEmptyString
, id
, wxFindWindowCmpIds
);
1717 // ----------------------------------------------------------------------------
1718 // dialog oriented functions
1719 // ----------------------------------------------------------------------------
1721 void wxWindowBase::MakeModal(bool modal
)
1723 // Disable all other windows
1726 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1729 wxWindow
*win
= node
->GetData();
1731 win
->Enable(!modal
);
1733 node
= node
->GetNext();
1738 bool wxWindowBase::Validate()
1740 #if wxUSE_VALIDATORS
1741 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1743 wxWindowList::compatibility_iterator node
;
1744 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1746 wxWindowBase
*child
= node
->GetData();
1747 wxValidator
*validator
= child
->GetValidator();
1748 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1753 if ( recurse
&& !child
->Validate() )
1758 #endif // wxUSE_VALIDATORS
1763 bool wxWindowBase::TransferDataToWindow()
1765 #if wxUSE_VALIDATORS
1766 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1768 wxWindowList::compatibility_iterator node
;
1769 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1771 wxWindowBase
*child
= node
->GetData();
1772 wxValidator
*validator
= child
->GetValidator();
1773 if ( validator
&& !validator
->TransferToWindow() )
1775 wxLogWarning(_("Could not transfer data to window"));
1777 wxLog::FlushActive();
1785 if ( !child
->TransferDataToWindow() )
1787 // warning already given
1792 #endif // wxUSE_VALIDATORS
1797 bool wxWindowBase::TransferDataFromWindow()
1799 #if wxUSE_VALIDATORS
1800 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1802 wxWindowList::compatibility_iterator node
;
1803 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1805 wxWindow
*child
= node
->GetData();
1806 wxValidator
*validator
= child
->GetValidator();
1807 if ( validator
&& !validator
->TransferFromWindow() )
1809 // nop warning here because the application is supposed to give
1810 // one itself - we don't know here what might have gone wrongly
1817 if ( !child
->TransferDataFromWindow() )
1819 // warning already given
1824 #endif // wxUSE_VALIDATORS
1829 void wxWindowBase::InitDialog()
1831 wxInitDialogEvent
event(GetId());
1832 event
.SetEventObject( this );
1833 GetEventHandler()->ProcessEvent(event
);
1836 // ----------------------------------------------------------------------------
1837 // context-sensitive help support
1838 // ----------------------------------------------------------------------------
1842 // associate this help text with this window
1843 void wxWindowBase::SetHelpText(const wxString
& text
)
1845 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1848 helpProvider
->AddHelp(this, text
);
1852 #if WXWIN_COMPATIBILITY_2_8
1853 // associate this help text with all windows with the same id as this
1855 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1857 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1860 helpProvider
->AddHelp(GetId(), text
);
1863 #endif // WXWIN_COMPATIBILITY_2_8
1865 // get the help string associated with this window (may be empty)
1866 // default implementation forwards calls to the help provider
1868 wxWindowBase::GetHelpTextAtPoint(const wxPoint
& WXUNUSED(pt
),
1869 wxHelpEvent::Origin
WXUNUSED(origin
)) const
1872 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1875 text
= helpProvider
->GetHelp(this);
1881 // show help for this window
1882 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1884 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1887 wxPoint pos
= event
.GetPosition();
1888 const wxHelpEvent::Origin origin
= event
.GetOrigin();
1889 if ( origin
== wxHelpEvent::Origin_Keyboard
)
1891 // if the help event was generated from keyboard it shouldn't
1892 // appear at the mouse position (which is still the only position
1893 // associated with help event) if the mouse is far away, although
1894 // we still do use the mouse position if it's over the window
1895 // because we suppose the user looks approximately at the mouse
1896 // already and so it would be more convenient than showing tooltip
1897 // at some arbitrary position which can be quite far from it
1898 const wxRect rectClient
= GetClientRect();
1899 if ( !rectClient
.Contains(ScreenToClient(pos
)) )
1901 // position help slightly under and to the right of this window
1902 pos
= ClientToScreen(wxPoint(
1904 rectClient
.height
+ GetCharHeight()
1909 if ( helpProvider
->ShowHelpAtPoint(this, pos
, origin
) )
1911 // skip the event.Skip() below
1919 #endif // wxUSE_HELP
1921 // ----------------------------------------------------------------------------
1923 // ----------------------------------------------------------------------------
1927 wxString
wxWindowBase::GetToolTipText() const
1929 return m_tooltip
? m_tooltip
->GetTip() : wxString();
1932 void wxWindowBase::SetToolTip( const wxString
&tip
)
1934 // don't create the new tooltip if we already have one
1937 m_tooltip
->SetTip( tip
);
1941 SetToolTip( new wxToolTip( tip
) );
1944 // setting empty tooltip text does not remove the tooltip any more - use
1945 // SetToolTip(NULL) for this
1948 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1950 if ( m_tooltip
!= tooltip
)
1955 m_tooltip
= tooltip
;
1959 #endif // wxUSE_TOOLTIPS
1961 // ----------------------------------------------------------------------------
1962 // constraints and sizers
1963 // ----------------------------------------------------------------------------
1965 #if wxUSE_CONSTRAINTS
1967 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1969 if ( m_constraints
)
1971 UnsetConstraints(m_constraints
);
1972 delete m_constraints
;
1974 m_constraints
= constraints
;
1975 if ( m_constraints
)
1977 // Make sure other windows know they're part of a 'meaningful relationship'
1978 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1979 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1980 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1981 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1982 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1983 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1984 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1985 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1986 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1987 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1988 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1989 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1990 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1991 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1992 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1993 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1997 // This removes any dangling pointers to this window in other windows'
1998 // constraintsInvolvedIn lists.
1999 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
2003 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
2004 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
2005 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
2006 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
2007 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
2008 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
2009 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
2010 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
2011 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
2012 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
2013 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
2014 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
2015 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
2016 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
2017 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
2018 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
2022 // Back-pointer to other windows we're involved with, so if we delete this
2023 // window, we must delete any constraints we're involved with.
2024 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
2026 if ( !m_constraintsInvolvedIn
)
2027 m_constraintsInvolvedIn
= new wxWindowList
;
2028 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
2029 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
2032 // REMOVE back-pointer to other windows we're involved with.
2033 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
2035 if ( m_constraintsInvolvedIn
)
2036 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
2039 // Reset any constraints that mention this window
2040 void wxWindowBase::DeleteRelatedConstraints()
2042 if ( m_constraintsInvolvedIn
)
2044 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
2047 wxWindow
*win
= node
->GetData();
2048 wxLayoutConstraints
*constr
= win
->GetConstraints();
2050 // Reset any constraints involving this window
2053 constr
->left
.ResetIfWin(this);
2054 constr
->top
.ResetIfWin(this);
2055 constr
->right
.ResetIfWin(this);
2056 constr
->bottom
.ResetIfWin(this);
2057 constr
->width
.ResetIfWin(this);
2058 constr
->height
.ResetIfWin(this);
2059 constr
->centreX
.ResetIfWin(this);
2060 constr
->centreY
.ResetIfWin(this);
2063 wxWindowList::compatibility_iterator next
= node
->GetNext();
2064 m_constraintsInvolvedIn
->Erase(node
);
2068 delete m_constraintsInvolvedIn
;
2069 m_constraintsInvolvedIn
= NULL
;
2073 #endif // wxUSE_CONSTRAINTS
2075 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
2077 if ( sizer
== m_windowSizer
)
2080 if ( m_windowSizer
)
2082 m_windowSizer
->SetContainingWindow(NULL
);
2085 delete m_windowSizer
;
2088 m_windowSizer
= sizer
;
2089 if ( m_windowSizer
)
2091 m_windowSizer
->SetContainingWindow((wxWindow
*)this);
2094 SetAutoLayout(m_windowSizer
!= NULL
);
2097 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
2099 SetSizer( sizer
, deleteOld
);
2100 sizer
->SetSizeHints( (wxWindow
*) this );
2104 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
2106 // adding a window to a sizer twice is going to result in fatal and
2107 // hard to debug problems later because when deleting the second
2108 // associated wxSizerItem we're going to dereference a dangling
2109 // pointer; so try to detect this as early as possible
2110 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
2111 wxT("Adding a window to the same sizer twice?") );
2113 m_containingSizer
= sizer
;
2116 #if wxUSE_CONSTRAINTS
2118 void wxWindowBase::SatisfyConstraints()
2120 wxLayoutConstraints
*constr
= GetConstraints();
2121 bool wasOk
= constr
&& constr
->AreSatisfied();
2123 ResetConstraints(); // Mark all constraints as unevaluated
2127 // if we're a top level panel (i.e. our parent is frame/dialog), our
2128 // own constraints will never be satisfied any more unless we do it
2132 while ( noChanges
> 0 )
2134 LayoutPhase1(&noChanges
);
2138 LayoutPhase2(&noChanges
);
2141 #endif // wxUSE_CONSTRAINTS
2143 bool wxWindowBase::Layout()
2145 // If there is a sizer, use it instead of the constraints
2149 GetVirtualSize(&w
, &h
);
2150 GetSizer()->SetDimension( 0, 0, w
, h
);
2152 #if wxUSE_CONSTRAINTS
2155 SatisfyConstraints(); // Find the right constraints values
2156 SetConstraintSizes(); // Recursively set the real window sizes
2163 void wxWindowBase::InternalOnSize(wxSizeEvent
& event
)
2165 if ( GetAutoLayout() )
2171 #if wxUSE_CONSTRAINTS
2173 // first phase of the constraints evaluation: set our own constraints
2174 bool wxWindowBase::LayoutPhase1(int *noChanges
)
2176 wxLayoutConstraints
*constr
= GetConstraints();
2178 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
2181 // second phase: set the constraints for our children
2182 bool wxWindowBase::LayoutPhase2(int *noChanges
)
2189 // Layout grand children
2195 // Do a phase of evaluating child constraints
2196 bool wxWindowBase::DoPhase(int phase
)
2198 // the list containing the children for which the constraints are already
2200 wxWindowList succeeded
;
2202 // the max number of iterations we loop before concluding that we can't set
2204 static const int maxIterations
= 500;
2206 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
2210 // loop over all children setting their constraints
2211 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2213 node
= node
->GetNext() )
2215 wxWindow
*child
= node
->GetData();
2216 if ( child
->IsTopLevel() )
2218 // top level children are not inside our client area
2222 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
2224 // this one is either already ok or nothing we can do about it
2228 int tempNoChanges
= 0;
2229 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
2230 : child
->LayoutPhase2(&tempNoChanges
);
2231 noChanges
+= tempNoChanges
;
2235 succeeded
.Append(child
);
2241 // constraints are set
2249 void wxWindowBase::ResetConstraints()
2251 wxLayoutConstraints
*constr
= GetConstraints();
2254 constr
->left
.SetDone(false);
2255 constr
->top
.SetDone(false);
2256 constr
->right
.SetDone(false);
2257 constr
->bottom
.SetDone(false);
2258 constr
->width
.SetDone(false);
2259 constr
->height
.SetDone(false);
2260 constr
->centreX
.SetDone(false);
2261 constr
->centreY
.SetDone(false);
2264 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2267 wxWindow
*win
= node
->GetData();
2268 if ( !win
->IsTopLevel() )
2269 win
->ResetConstraints();
2270 node
= node
->GetNext();
2274 // Need to distinguish between setting the 'fake' size for windows and sizers,
2275 // and setting the real values.
2276 void wxWindowBase::SetConstraintSizes(bool recurse
)
2278 wxLayoutConstraints
*constr
= GetConstraints();
2279 if ( constr
&& constr
->AreSatisfied() )
2281 int x
= constr
->left
.GetValue();
2282 int y
= constr
->top
.GetValue();
2283 int w
= constr
->width
.GetValue();
2284 int h
= constr
->height
.GetValue();
2286 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
2287 (constr
->height
.GetRelationship() != wxAsIs
) )
2289 SetSize(x
, y
, w
, h
);
2293 // If we don't want to resize this window, just move it...
2299 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
2300 GetClassInfo()->GetClassName(),
2306 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2309 wxWindow
*win
= node
->GetData();
2310 if ( !win
->IsTopLevel() && win
->GetConstraints() )
2311 win
->SetConstraintSizes();
2312 node
= node
->GetNext();
2317 // Only set the size/position of the constraint (if any)
2318 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
2320 wxLayoutConstraints
*constr
= GetConstraints();
2323 if ( x
!= wxDefaultCoord
)
2325 constr
->left
.SetValue(x
);
2326 constr
->left
.SetDone(true);
2328 if ( y
!= wxDefaultCoord
)
2330 constr
->top
.SetValue(y
);
2331 constr
->top
.SetDone(true);
2333 if ( w
!= wxDefaultCoord
)
2335 constr
->width
.SetValue(w
);
2336 constr
->width
.SetDone(true);
2338 if ( h
!= wxDefaultCoord
)
2340 constr
->height
.SetValue(h
);
2341 constr
->height
.SetDone(true);
2346 void wxWindowBase::MoveConstraint(int x
, int y
)
2348 wxLayoutConstraints
*constr
= GetConstraints();
2351 if ( x
!= wxDefaultCoord
)
2353 constr
->left
.SetValue(x
);
2354 constr
->left
.SetDone(true);
2356 if ( y
!= wxDefaultCoord
)
2358 constr
->top
.SetValue(y
);
2359 constr
->top
.SetDone(true);
2364 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
2366 wxLayoutConstraints
*constr
= GetConstraints();
2369 *w
= constr
->width
.GetValue();
2370 *h
= constr
->height
.GetValue();
2376 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
2378 wxLayoutConstraints
*constr
= GetConstraints();
2381 *w
= constr
->width
.GetValue();
2382 *h
= constr
->height
.GetValue();
2385 GetClientSize(w
, h
);
2388 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
2390 wxLayoutConstraints
*constr
= GetConstraints();
2393 *x
= constr
->left
.GetValue();
2394 *y
= constr
->top
.GetValue();
2400 #endif // wxUSE_CONSTRAINTS
2402 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
2404 // don't do it for the dialogs/frames - they float independently of their
2406 if ( !IsTopLevel() )
2408 wxWindow
*parent
= GetParent();
2409 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
2411 wxPoint
pt(parent
->GetClientAreaOrigin());
2418 // ----------------------------------------------------------------------------
2419 // Update UI processing
2420 // ----------------------------------------------------------------------------
2422 void wxWindowBase::UpdateWindowUI(long flags
)
2424 wxUpdateUIEvent
event(GetId());
2425 event
.SetEventObject(this);
2427 if ( GetEventHandler()->ProcessEvent(event
) )
2429 DoUpdateWindowUI(event
);
2432 if (flags
& wxUPDATE_UI_RECURSE
)
2434 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2437 wxWindow
* child
= (wxWindow
*) node
->GetData();
2438 child
->UpdateWindowUI(flags
);
2439 node
= node
->GetNext();
2444 // do the window-specific processing after processing the update event
2445 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
2447 if ( event
.GetSetEnabled() )
2448 Enable(event
.GetEnabled());
2450 if ( event
.GetSetShown() )
2451 Show(event
.GetShown());
2454 // ----------------------------------------------------------------------------
2455 // dialog units translations
2456 // ----------------------------------------------------------------------------
2458 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
2460 int charWidth
= GetCharWidth();
2461 int charHeight
= GetCharHeight();
2462 wxPoint pt2
= wxDefaultPosition
;
2463 if (pt
.x
!= wxDefaultCoord
)
2464 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
);
2465 if (pt
.y
!= wxDefaultCoord
)
2466 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2471 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2473 int charWidth
= GetCharWidth();
2474 int charHeight
= GetCharHeight();
2475 wxPoint pt2
= wxDefaultPosition
;
2476 if (pt
.x
!= wxDefaultCoord
)
2477 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2478 if (pt
.y
!= wxDefaultCoord
)
2479 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2484 // ----------------------------------------------------------------------------
2486 // ----------------------------------------------------------------------------
2488 // propagate the colour change event to the subwindows
2489 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(event
))
2491 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2494 // Only propagate to non-top-level windows
2495 wxWindow
*win
= node
->GetData();
2496 if ( !win
->IsTopLevel() )
2498 wxSysColourChangedEvent event2
;
2499 event2
.SetEventObject(win
);
2500 win
->GetEventHandler()->ProcessEvent(event2
);
2503 node
= node
->GetNext();
2509 // the default action is to populate dialog with data when it's created,
2510 // and nudge the UI into displaying itself correctly in case
2511 // we've turned the wxUpdateUIEvents frequency down low.
2512 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2514 TransferDataToWindow();
2516 // Update the UI at this point
2517 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2520 // ----------------------------------------------------------------------------
2521 // menu-related functions
2522 // ----------------------------------------------------------------------------
2526 bool wxWindowBase::PopupMenu(wxMenu
*menu
, int x
, int y
)
2528 wxCHECK_MSG( menu
, false, "can't popup NULL menu" );
2530 wxCurrentPopupMenu
= menu
;
2531 const bool rc
= DoPopupMenu(menu
, x
, y
);
2532 wxCurrentPopupMenu
= NULL
;
2537 // this is used to pass the id of the selected item from the menu event handler
2538 // to the main function itself
2540 // it's ok to use a global here as there can be at most one popup menu shown at
2542 static int gs_popupMenuSelection
= wxID_NONE
;
2544 void wxWindowBase::InternalOnPopupMenu(wxCommandEvent
& event
)
2546 // store the id in a global variable where we'll retrieve it from later
2547 gs_popupMenuSelection
= event
.GetId();
2550 void wxWindowBase::InternalOnPopupMenuUpdate(wxUpdateUIEvent
& WXUNUSED(event
))
2552 // nothing to do but do not skip it
2556 wxWindowBase::DoGetPopupMenuSelectionFromUser(wxMenu
& menu
, int x
, int y
)
2558 gs_popupMenuSelection
= wxID_NONE
;
2560 Connect(wxEVT_COMMAND_MENU_SELECTED
,
2561 wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu
),
2565 // it is common to construct the menu passed to this function dynamically
2566 // using some fixed range of ids which could clash with the ids used
2567 // elsewhere in the program, which could result in some menu items being
2568 // unintentionally disabled or otherwise modified by update UI handlers
2569 // elsewhere in the program code and this is difficult to avoid in the
2570 // program itself, so instead we just temporarily suspend UI updating while
2571 // this menu is shown
2572 Connect(wxEVT_UPDATE_UI
,
2573 wxUpdateUIEventHandler(wxWindowBase::InternalOnPopupMenuUpdate
),
2577 PopupMenu(&menu
, x
, y
);
2579 Disconnect(wxEVT_UPDATE_UI
,
2580 wxUpdateUIEventHandler(wxWindowBase::InternalOnPopupMenuUpdate
),
2583 Disconnect(wxEVT_COMMAND_MENU_SELECTED
,
2584 wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu
),
2588 return gs_popupMenuSelection
;
2591 #endif // wxUSE_MENUS
2593 // methods for drawing the sizers in a visible way: this is currently only
2594 // enabled for "full debug" builds with wxDEBUG_LEVEL==2 as it doesn't work
2595 // that well and also because we don't want to leave it enabled in default
2596 // builds used for production
2597 #if wxDEBUG_LEVEL > 1
2599 static void DrawSizers(wxWindowBase
*win
);
2601 static void DrawBorder(wxWindowBase
*win
, const wxRect
& rect
, bool fill
, const wxPen
* pen
)
2603 wxClientDC
dc((wxWindow
*)win
);
2605 dc
.SetBrush(fill
? wxBrush(pen
->GetColour(), wxBRUSHSTYLE_CROSSDIAG_HATCH
) :
2606 *wxTRANSPARENT_BRUSH
);
2607 dc
.DrawRectangle(rect
.Deflate(1, 1));
2610 static void DrawSizer(wxWindowBase
*win
, wxSizer
*sizer
)
2612 const wxSizerItemList
& items
= sizer
->GetChildren();
2613 for ( wxSizerItemList::const_iterator i
= items
.begin(),
2618 wxSizerItem
*item
= *i
;
2619 if ( item
->IsSizer() )
2621 DrawBorder(win
, item
->GetRect().Deflate(2), false, wxRED_PEN
);
2622 DrawSizer(win
, item
->GetSizer());
2624 else if ( item
->IsSpacer() )
2626 DrawBorder(win
, item
->GetRect().Deflate(2), true, wxBLUE_PEN
);
2628 else if ( item
->IsWindow() )
2630 DrawSizers(item
->GetWindow());
2633 wxFAIL_MSG("inconsistent wxSizerItem status!");
2637 static void DrawSizers(wxWindowBase
*win
)
2639 DrawBorder(win
, win
->GetClientSize(), false, wxGREEN_PEN
);
2641 wxSizer
*sizer
= win
->GetSizer();
2644 DrawSizer(win
, sizer
);
2646 else // no sizer, still recurse into the children
2648 const wxWindowList
& children
= win
->GetChildren();
2649 for ( wxWindowList::const_iterator i
= children
.begin(),
2650 end
= children
.end();
2657 // show all kind of sizes of this window; see the "window sizing" topic
2658 // overview for more info about the various differences:
2659 wxSize fullSz
= win
->GetSize();
2660 wxSize clientSz
= win
->GetClientSize();
2661 wxSize bestSz
= win
->GetBestSize();
2662 wxSize minSz
= win
->GetMinSize();
2663 wxSize maxSz
= win
->GetMaxSize();
2664 wxSize virtualSz
= win
->GetVirtualSize();
2666 wxMessageOutputDebug dbgout
;
2668 "%-10s => fullsz=%4d;%-4d clientsz=%4d;%-4d bestsz=%4d;%-4d minsz=%4d;%-4d maxsz=%4d;%-4d virtualsz=%4d;%-4d\n",
2671 clientSz
.x
, clientSz
.y
,
2675 virtualSz
.x
, virtualSz
.y
);
2679 #endif // wxDEBUG_LEVEL
2681 // process special middle clicks
2682 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2684 if ( event
.ControlDown() && event
.AltDown() )
2686 #if wxDEBUG_LEVEL > 1
2687 // Ctrl-Alt-Shift-mclick makes the sizers visible in debug builds
2688 if ( event
.ShiftDown() )
2693 #endif // __WXDEBUG__
2695 // just Ctrl-Alt-middle click shows information about wx version
2696 ::wxInfoMessageBox((wxWindow
*)this);
2705 // ----------------------------------------------------------------------------
2707 // ----------------------------------------------------------------------------
2709 #if wxUSE_ACCESSIBILITY
2710 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2712 if (m_accessible
&& (accessible
!= m_accessible
))
2713 delete m_accessible
;
2714 m_accessible
= accessible
;
2716 m_accessible
->SetWindow((wxWindow
*) this);
2719 // Returns the accessible object, creating if necessary.
2720 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2723 m_accessible
= CreateAccessible();
2724 return m_accessible
;
2727 // Override to create a specific accessible object.
2728 wxAccessible
* wxWindowBase::CreateAccessible()
2730 return new wxWindowAccessible((wxWindow
*) this);
2735 // ----------------------------------------------------------------------------
2736 // list classes implementation
2737 // ----------------------------------------------------------------------------
2741 #include "wx/listimpl.cpp"
2742 WX_DEFINE_LIST(wxWindowList
)
2746 void wxWindowListNode::DeleteData()
2748 delete (wxWindow
*)GetData();
2751 #endif // wxUSE_STL/!wxUSE_STL
2753 // ----------------------------------------------------------------------------
2755 // ----------------------------------------------------------------------------
2757 wxBorder
wxWindowBase::GetBorder(long flags
) const
2759 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2760 if ( border
== wxBORDER_DEFAULT
)
2762 border
= GetDefaultBorder();
2764 else if ( border
== wxBORDER_THEME
)
2766 border
= GetDefaultBorderForControl();
2772 wxBorder
wxWindowBase::GetDefaultBorder() const
2774 return wxBORDER_NONE
;
2777 // ----------------------------------------------------------------------------
2779 // ----------------------------------------------------------------------------
2781 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2783 // here we just check if the point is inside the window or not
2785 // check the top and left border first
2786 bool outside
= x
< 0 || y
< 0;
2789 // check the right and bottom borders too
2790 wxSize size
= GetSize();
2791 outside
= x
>= size
.x
|| y
>= size
.y
;
2794 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2797 // ----------------------------------------------------------------------------
2799 // ----------------------------------------------------------------------------
2801 struct WXDLLEXPORT wxWindowNext
2805 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2806 wxWindow
*wxWindowBase::ms_winCaptureCurrent
= NULL
;
2807 bool wxWindowBase::ms_winCaptureChanging
= false;
2809 void wxWindowBase::CaptureMouse()
2811 wxLogTrace(wxT("mousecapture"), wxT("CaptureMouse(%p)"), static_cast<void*>(this));
2813 wxASSERT_MSG( !ms_winCaptureChanging
, wxT("recursive CaptureMouse call?") );
2815 ms_winCaptureChanging
= true;
2817 wxWindow
*winOld
= GetCapture();
2820 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2823 wxWindowNext
*item
= new wxWindowNext
;
2825 item
->next
= ms_winCaptureNext
;
2826 ms_winCaptureNext
= item
;
2828 //else: no mouse capture to save
2831 ms_winCaptureCurrent
= (wxWindow
*)this;
2833 ms_winCaptureChanging
= false;
2836 void wxWindowBase::ReleaseMouse()
2838 wxLogTrace(wxT("mousecapture"), wxT("ReleaseMouse(%p)"), static_cast<void*>(this));
2840 wxASSERT_MSG( !ms_winCaptureChanging
, wxT("recursive ReleaseMouse call?") );
2842 wxASSERT_MSG( GetCapture() == this,
2843 "attempt to release mouse, but this window hasn't captured it" );
2844 wxASSERT_MSG( ms_winCaptureCurrent
== this,
2845 "attempt to release mouse, but this window hasn't captured it" );
2847 ms_winCaptureChanging
= true;
2850 ms_winCaptureCurrent
= NULL
;
2852 if ( ms_winCaptureNext
)
2854 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2855 ms_winCaptureCurrent
= ms_winCaptureNext
->win
;
2857 wxWindowNext
*item
= ms_winCaptureNext
;
2858 ms_winCaptureNext
= item
->next
;
2861 //else: stack is empty, no previous capture
2863 ms_winCaptureChanging
= false;
2865 wxLogTrace(wxT("mousecapture"),
2866 (const wxChar
*) wxT("After ReleaseMouse() mouse is captured by %p"),
2867 static_cast<void*>(GetCapture()));
2870 static void DoNotifyWindowAboutCaptureLost(wxWindow
*win
)
2872 wxMouseCaptureLostEvent
event(win
->GetId());
2873 event
.SetEventObject(win
);
2874 if ( !win
->GetEventHandler()->ProcessEvent(event
) )
2876 // windows must handle this event, otherwise the app wouldn't behave
2877 // correctly if it loses capture unexpectedly; see the discussion here:
2878 // http://sourceforge.net/tracker/index.php?func=detail&aid=1153662&group_id=9863&atid=109863
2879 // http://article.gmane.org/gmane.comp.lib.wxwidgets.devel/82376
2880 wxFAIL_MSG( wxT("window that captured the mouse didn't process wxEVT_MOUSE_CAPTURE_LOST") );
2885 void wxWindowBase::NotifyCaptureLost()
2887 // don't do anything if capture lost was expected, i.e. resulted from
2888 // a wx call to ReleaseMouse or CaptureMouse:
2889 if ( ms_winCaptureChanging
)
2892 // if the capture was lost unexpectedly, notify every window that has
2893 // capture (on stack or current) about it and clear the stack:
2895 if ( ms_winCaptureCurrent
)
2897 DoNotifyWindowAboutCaptureLost(ms_winCaptureCurrent
);
2898 ms_winCaptureCurrent
= NULL
;
2901 while ( ms_winCaptureNext
)
2903 wxWindowNext
*item
= ms_winCaptureNext
;
2904 ms_winCaptureNext
= item
->next
;
2906 DoNotifyWindowAboutCaptureLost(item
->win
);
2915 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2916 int WXUNUSED(modifiers
),
2917 int WXUNUSED(keycode
))
2923 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2929 #endif // wxUSE_HOTKEY
2931 // ----------------------------------------------------------------------------
2933 // ----------------------------------------------------------------------------
2935 bool wxWindowBase::TryBefore(wxEvent
& event
)
2937 #if wxUSE_VALIDATORS
2938 // Can only use the validator of the window which
2939 // is receiving the event
2940 if ( event
.GetEventObject() == this )
2942 wxValidator
* const validator
= GetValidator();
2943 if ( validator
&& validator
->ProcessEventHere(event
) )
2948 #endif // wxUSE_VALIDATORS
2950 return wxEvtHandler::TryBefore(event
);
2953 bool wxWindowBase::TryAfter(wxEvent
& event
)
2955 // carry on up the parent-child hierarchy if the propagation count hasn't
2957 if ( event
.ShouldPropagate() )
2959 // honour the requests to stop propagation at this window: this is
2960 // used by the dialogs, for example, to prevent processing the events
2961 // from the dialog controls in the parent frame which rarely, if ever,
2963 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2965 wxWindow
*parent
= GetParent();
2966 if ( parent
&& !parent
->IsBeingDeleted() )
2968 wxPropagateOnce
propagateOnce(event
);
2970 return parent
->GetEventHandler()->ProcessEvent(event
);
2975 return wxEvtHandler::TryAfter(event
);
2978 // ----------------------------------------------------------------------------
2979 // window relationships
2980 // ----------------------------------------------------------------------------
2982 wxWindow
*wxWindowBase::DoGetSibling(WindowOrder order
) const
2984 wxCHECK_MSG( GetParent(), NULL
,
2985 wxT("GetPrev/NextSibling() don't work for TLWs!") );
2987 wxWindowList
& siblings
= GetParent()->GetChildren();
2988 wxWindowList::compatibility_iterator i
= siblings
.Find((wxWindow
*)this);
2989 wxCHECK_MSG( i
, NULL
, wxT("window not a child of its parent?") );
2991 if ( order
== OrderBefore
)
2992 i
= i
->GetPrevious();
2996 return i
? i
->GetData() : NULL
;
2999 // ----------------------------------------------------------------------------
3000 // keyboard navigation
3001 // ----------------------------------------------------------------------------
3003 // Navigates in the specified direction inside this window
3004 bool wxWindowBase::DoNavigateIn(int flags
)
3006 #ifdef wxHAS_NATIVE_TAB_TRAVERSAL
3007 // native code doesn't process our wxNavigationKeyEvents anyhow
3010 #else // !wxHAS_NATIVE_TAB_TRAVERSAL
3011 wxNavigationKeyEvent eventNav
;
3012 wxWindow
*focused
= FindFocus();
3013 eventNav
.SetCurrentFocus(focused
);
3014 eventNav
.SetEventObject(focused
);
3015 eventNav
.SetFlags(flags
);
3016 return GetEventHandler()->ProcessEvent(eventNav
);
3017 #endif // wxHAS_NATIVE_TAB_TRAVERSAL/!wxHAS_NATIVE_TAB_TRAVERSAL
3020 bool wxWindowBase::HandleAsNavigationKey(const wxKeyEvent
& event
)
3022 if ( event
.GetKeyCode() != WXK_TAB
)
3025 int flags
= wxNavigationKeyEvent::FromTab
;
3027 if ( event
.ShiftDown() )
3028 flags
|= wxNavigationKeyEvent::IsBackward
;
3030 flags
|= wxNavigationKeyEvent::IsForward
;
3032 if ( event
.ControlDown() )
3033 flags
|= wxNavigationKeyEvent::WinChange
;
3039 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, WindowOrder move
)
3041 // check that we're not a top level window
3042 wxCHECK_RET( GetParent(),
3043 wxT("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
3045 // detect the special case when we have nothing to do anyhow and when the
3046 // code below wouldn't work
3050 // find the target window in the siblings list
3051 wxWindowList
& siblings
= GetParent()->GetChildren();
3052 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
3053 wxCHECK_RET( i
, wxT("MoveBefore/AfterInTabOrder(): win is not a sibling") );
3055 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
3056 // can't just move the node around
3057 wxWindow
*self
= (wxWindow
*)this;
3058 siblings
.DeleteObject(self
);
3059 if ( move
== OrderAfter
)
3066 siblings
.Insert(i
, self
);
3068 else // OrderAfter and win was the last sibling
3070 siblings
.Append(self
);
3074 // ----------------------------------------------------------------------------
3076 // ----------------------------------------------------------------------------
3078 /*static*/ wxWindow
* wxWindowBase::FindFocus()
3080 wxWindowBase
*win
= DoFindFocus();
3081 return win
? win
->GetMainWindowOfCompositeControl() : NULL
;
3084 bool wxWindowBase::HasFocus() const
3086 wxWindowBase
*win
= DoFindFocus();
3087 return win
== this ||
3088 win
== wxConstCast(this, wxWindowBase
)->GetMainWindowOfCompositeControl();
3091 // ----------------------------------------------------------------------------
3093 // ----------------------------------------------------------------------------
3095 #if wxUSE_DRAG_AND_DROP && !defined(__WXMSW__)
3100 class DragAcceptFilesTarget
: public wxFileDropTarget
3103 DragAcceptFilesTarget(wxWindowBase
*win
) : m_win(win
) {}
3105 virtual bool OnDropFiles(wxCoord x
, wxCoord y
,
3106 const wxArrayString
& filenames
)
3108 wxDropFilesEvent
event(wxEVT_DROP_FILES
,
3110 wxCArrayString(filenames
).Release());
3111 event
.SetEventObject(m_win
);
3115 return m_win
->HandleWindowEvent(event
);
3119 wxWindowBase
* const m_win
;
3121 wxDECLARE_NO_COPY_CLASS(DragAcceptFilesTarget
);
3125 } // anonymous namespace
3127 // Generic version of DragAcceptFiles(). It works by installing a simple
3128 // wxFileDropTarget-to-EVT_DROP_FILES adaptor and therefore cannot be used
3129 // together with explicit SetDropTarget() calls.
3130 void wxWindowBase::DragAcceptFiles(bool accept
)
3134 wxASSERT_MSG( !GetDropTarget(),
3135 "cannot use DragAcceptFiles() and SetDropTarget() together" );
3136 SetDropTarget(new DragAcceptFilesTarget(this));
3140 SetDropTarget(NULL
);
3144 #endif // wxUSE_DRAG_AND_DROP && !defined(__WXMSW__)
3146 // ----------------------------------------------------------------------------
3148 // ----------------------------------------------------------------------------
3150 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
3152 while ( win
&& !win
->IsTopLevel() )
3153 win
= win
->GetParent();
3158 #if wxUSE_ACCESSIBILITY
3159 // ----------------------------------------------------------------------------
3160 // accessible object for windows
3161 // ----------------------------------------------------------------------------
3163 // Can return either a child object, or an integer
3164 // representing the child element, starting from 1.
3165 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
3167 wxASSERT( GetWindow() != NULL
);
3171 return wxACC_NOT_IMPLEMENTED
;
3174 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
3175 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
3177 wxASSERT( GetWindow() != NULL
);
3181 wxWindow
* win
= NULL
;
3188 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
3190 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
3197 rect
= win
->GetRect();
3198 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
3199 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
3203 return wxACC_NOT_IMPLEMENTED
;
3206 // Navigates from fromId to toId/toObject.
3207 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
3208 int* WXUNUSED(toId
), wxAccessible
** toObject
)
3210 wxASSERT( GetWindow() != NULL
);
3216 case wxNAVDIR_FIRSTCHILD
:
3218 if (GetWindow()->GetChildren().GetCount() == 0)
3220 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
3221 *toObject
= childWindow
->GetOrCreateAccessible();
3225 case wxNAVDIR_LASTCHILD
:
3227 if (GetWindow()->GetChildren().GetCount() == 0)
3229 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
3230 *toObject
= childWindow
->GetOrCreateAccessible();
3234 case wxNAVDIR_RIGHT
:
3238 wxWindowList::compatibility_iterator node
=
3239 wxWindowList::compatibility_iterator();
3242 // Can't navigate to sibling of this window
3243 // if we're a top-level window.
3244 if (!GetWindow()->GetParent())
3245 return wxACC_NOT_IMPLEMENTED
;
3247 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
3251 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
3252 node
= GetWindow()->GetChildren().Item(fromId
-1);
3255 if (node
&& node
->GetNext())
3257 wxWindow
* nextWindow
= node
->GetNext()->GetData();
3258 *toObject
= nextWindow
->GetOrCreateAccessible();
3266 case wxNAVDIR_PREVIOUS
:
3268 wxWindowList::compatibility_iterator node
=
3269 wxWindowList::compatibility_iterator();
3272 // Can't navigate to sibling of this window
3273 // if we're a top-level window.
3274 if (!GetWindow()->GetParent())
3275 return wxACC_NOT_IMPLEMENTED
;
3277 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
3281 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
3282 node
= GetWindow()->GetChildren().Item(fromId
-1);
3285 if (node
&& node
->GetPrevious())
3287 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
3288 *toObject
= previousWindow
->GetOrCreateAccessible();
3296 return wxACC_NOT_IMPLEMENTED
;
3299 // Gets the name of the specified object.
3300 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
3302 wxASSERT( GetWindow() != NULL
);
3308 // If a child, leave wxWidgets to call the function on the actual
3311 return wxACC_NOT_IMPLEMENTED
;
3313 // This will eventually be replaced by specialised
3314 // accessible classes, one for each kind of wxWidgets
3315 // control or window.
3317 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
3318 title
= ((wxButton
*) GetWindow())->GetLabel();
3321 title
= GetWindow()->GetName();
3329 return wxACC_NOT_IMPLEMENTED
;
3332 // Gets the number of children.
3333 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
3335 wxASSERT( GetWindow() != NULL
);
3339 *childId
= (int) GetWindow()->GetChildren().GetCount();
3343 // Gets the specified child (starting from 1).
3344 // If *child is NULL and return value is wxACC_OK,
3345 // this means that the child is a simple element and
3346 // not an accessible object.
3347 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
3349 wxASSERT( GetWindow() != NULL
);
3359 if (childId
> (int) GetWindow()->GetChildren().GetCount())
3362 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
3363 *child
= childWindow
->GetOrCreateAccessible();
3370 // Gets the parent, or NULL.
3371 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
3373 wxASSERT( GetWindow() != NULL
);
3377 wxWindow
* parentWindow
= GetWindow()->GetParent();
3385 *parent
= parentWindow
->GetOrCreateAccessible();
3393 // Performs the default action. childId is 0 (the action for this object)
3394 // or > 0 (the action for a child).
3395 // Return wxACC_NOT_SUPPORTED if there is no default action for this
3396 // window (e.g. an edit control).
3397 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
3399 wxASSERT( GetWindow() != NULL
);
3403 return wxACC_NOT_IMPLEMENTED
;
3406 // Gets the default action for this object (0) or > 0 (the action for a child).
3407 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
3408 // string if there is no action.
3409 // The retrieved string describes the action that is performed on an object,
3410 // not what the object does as a result. For example, a toolbar button that prints
3411 // a document has a default action of "Press" rather than "Prints the current document."
3412 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
3414 wxASSERT( GetWindow() != NULL
);
3418 return wxACC_NOT_IMPLEMENTED
;
3421 // Returns the description for this object or a child.
3422 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
3424 wxASSERT( GetWindow() != NULL
);
3428 wxString
ht(GetWindow()->GetHelpTextAtPoint(wxDefaultPosition
, wxHelpEvent::Origin_Keyboard
));
3434 return wxACC_NOT_IMPLEMENTED
;
3437 // Returns help text for this object or a child, similar to tooltip text.
3438 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
3440 wxASSERT( GetWindow() != NULL
);
3444 wxString
ht(GetWindow()->GetHelpTextAtPoint(wxDefaultPosition
, wxHelpEvent::Origin_Keyboard
));
3450 return wxACC_NOT_IMPLEMENTED
;
3453 // Returns the keyboard shortcut for this object or child.
3454 // Return e.g. ALT+K
3455 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
3457 wxASSERT( GetWindow() != NULL
);
3461 return wxACC_NOT_IMPLEMENTED
;
3464 // Returns a role constant.
3465 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
3467 wxASSERT( GetWindow() != NULL
);
3471 // If a child, leave wxWidgets to call the function on the actual
3474 return wxACC_NOT_IMPLEMENTED
;
3476 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
3477 return wxACC_NOT_IMPLEMENTED
;
3479 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
3480 return wxACC_NOT_IMPLEMENTED
;
3483 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
3484 return wxACC_NOT_IMPLEMENTED
;
3487 //*role = wxROLE_SYSTEM_CLIENT;
3488 *role
= wxROLE_SYSTEM_CLIENT
;
3492 return wxACC_NOT_IMPLEMENTED
;
3496 // Returns a state constant.
3497 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
3499 wxASSERT( GetWindow() != NULL
);
3503 // If a child, leave wxWidgets to call the function on the actual
3506 return wxACC_NOT_IMPLEMENTED
;
3508 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
3509 return wxACC_NOT_IMPLEMENTED
;
3512 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
3513 return wxACC_NOT_IMPLEMENTED
;
3516 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
3517 return wxACC_NOT_IMPLEMENTED
;
3524 return wxACC_NOT_IMPLEMENTED
;
3528 // Returns a localized string representing the value for the object
3530 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
3532 wxASSERT( GetWindow() != NULL
);
3536 return wxACC_NOT_IMPLEMENTED
;
3539 // Selects the object or child.
3540 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
3542 wxASSERT( GetWindow() != NULL
);
3546 return wxACC_NOT_IMPLEMENTED
;
3549 // Gets the window with the keyboard focus.
3550 // If childId is 0 and child is NULL, no object in
3551 // this subhierarchy has the focus.
3552 // If this object has the focus, child should be 'this'.
3553 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
3555 wxASSERT( GetWindow() != NULL
);
3559 return wxACC_NOT_IMPLEMENTED
;
3563 // Gets a variant representing the selected children
3565 // Acceptable values:
3566 // - a null variant (IsNull() returns true)
3567 // - a list variant (GetType() == wxT("list")
3568 // - an integer representing the selected child element,
3569 // or 0 if this object is selected (GetType() == wxT("long")
3570 // - a "void*" pointer to a wxAccessible child object
3571 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
3573 wxASSERT( GetWindow() != NULL
);
3577 return wxACC_NOT_IMPLEMENTED
;
3579 #endif // wxUSE_VARIANT
3581 #endif // wxUSE_ACCESSIBILITY
3583 // ----------------------------------------------------------------------------
3585 // ----------------------------------------------------------------------------
3588 wxWindowBase::AdjustForLayoutDirection(wxCoord x
,
3590 wxCoord widthTotal
) const
3592 if ( GetLayoutDirection() == wxLayout_RightToLeft
)
3594 x
= widthTotal
- x
- width
;