1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/window.cpp
3 // Purpose: common (to all ports) wxWindow functions
4 // Author: Julian Smart, Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
28 #include "wx/string.h"
32 #include "wx/window.h"
33 #include "wx/control.h"
34 #include "wx/checkbox.h"
35 #include "wx/radiobut.h"
36 #include "wx/statbox.h"
37 #include "wx/textctrl.h"
38 #include "wx/settings.h"
39 #include "wx/dialog.h"
40 #include "wx/msgdlg.h"
41 #include "wx/msgout.h"
42 #include "wx/statusbr.h"
43 #include "wx/toolbar.h"
44 #include "wx/dcclient.h"
45 #include "wx/scrolbar.h"
46 #include "wx/layout.h"
51 #if wxUSE_DRAG_AND_DROP
53 #endif // wxUSE_DRAG_AND_DROP
55 #if wxUSE_ACCESSIBILITY
56 #include "wx/access.h"
60 #include "wx/cshelp.h"
64 #include "wx/tooltip.h"
65 #endif // wxUSE_TOOLTIPS
71 #if wxUSE_SYSTEM_OPTIONS
72 #include "wx/sysopt.h"
75 #include "wx/platinfo.h"
78 WXDLLIMPEXP_DATA_CORE(wxWindowList
) wxTopLevelWindows
;
82 wxMenu
*wxCurrentPopupMenu
= NULL
;
85 // ----------------------------------------------------------------------------
87 // ----------------------------------------------------------------------------
90 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase
, wxEvtHandler
)
92 // ----------------------------------------------------------------------------
94 // ----------------------------------------------------------------------------
96 BEGIN_EVENT_TABLE(wxWindowBase
, wxEvtHandler
)
97 EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged
)
98 EVT_INIT_DIALOG(wxWindowBase::OnInitDialog
)
99 EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick
)
102 EVT_HELP(wxID_ANY
, wxWindowBase::OnHelp
)
105 EVT_SIZE(wxWindowBase::InternalOnSize
)
108 // ============================================================================
109 // implementation of the common functionality of the wxWindow class
110 // ============================================================================
112 // ----------------------------------------------------------------------------
114 // ----------------------------------------------------------------------------
116 // the default initialization
117 wxWindowBase::wxWindowBase()
119 // no window yet, no parent nor children
121 m_windowId
= wxID_ANY
;
123 // no constraints on the minimal window size
125 m_maxWidth
= wxDefaultCoord
;
127 m_maxHeight
= wxDefaultCoord
;
129 // invalidiated cache value
130 m_bestSizeCache
= wxDefaultSize
;
132 // window are created enabled and visible by default
136 // the default event handler is just this window
137 m_eventHandler
= this;
141 m_windowValidator
= NULL
;
142 #endif // wxUSE_VALIDATORS
144 // the colours/fonts are default for now, so leave m_font,
145 // m_backgroundColour and m_foregroundColour uninitialized and set those
151 m_inheritFont
= false;
157 m_backgroundStyle
= wxBG_STYLE_ERASE
;
159 #if wxUSE_CONSTRAINTS
160 // no constraints whatsoever
161 m_constraints
= NULL
;
162 m_constraintsInvolvedIn
= NULL
;
163 #endif // wxUSE_CONSTRAINTS
165 m_windowSizer
= NULL
;
166 m_containingSizer
= NULL
;
167 m_autoLayout
= false;
169 #if wxUSE_DRAG_AND_DROP
171 #endif // wxUSE_DRAG_AND_DROP
175 #endif // wxUSE_TOOLTIPS
179 #endif // wxUSE_CARET
182 m_hasCustomPalette
= false;
183 #endif // wxUSE_PALETTE
185 #if wxUSE_ACCESSIBILITY
189 m_virtualSize
= wxDefaultSize
;
191 m_scrollHelper
= NULL
;
193 m_windowVariant
= wxWINDOW_VARIANT_NORMAL
;
194 #if wxUSE_SYSTEM_OPTIONS
195 if ( wxSystemOptions::HasOption(wxWINDOW_DEFAULT_VARIANT
) )
197 m_windowVariant
= (wxWindowVariant
) wxSystemOptions::GetOptionInt( wxWINDOW_DEFAULT_VARIANT
) ;
201 // Whether we're using the current theme for this window (wxGTK only for now)
202 m_themeEnabled
= false;
204 // This is set to true by SendDestroyEvent() which should be called by the
205 // most derived class to ensure that the destruction event is sent as soon
206 // as possible to allow its handlers to still see the undestroyed window
207 m_isBeingDeleted
= false;
212 // common part of window creation process
213 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
215 const wxPoint
& WXUNUSED(pos
),
216 const wxSize
& WXUNUSED(size
),
218 const 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
;
248 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
253 const wxValidator
& wxVALIDATOR_PARAM(validator
),
254 const wxString
& name
)
256 if ( !CreateBase(parent
, id
, pos
, size
, style
, name
) )
260 SetValidator(validator
);
261 #endif // wxUSE_VALIDATORS
263 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
264 // have it too - like this it's possible to set it only in the top level
265 // dialog/frame and all children will inherit it by defult
266 if ( parent
&& (parent
->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) )
268 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY
);
274 bool wxWindowBase::ToggleWindowStyle(int flag
)
276 wxASSERT_MSG( flag
, wxT("flags with 0 value can't be toggled") );
279 long style
= GetWindowStyleFlag();
285 else // currently off
291 SetWindowStyleFlag(style
);
296 // ----------------------------------------------------------------------------
298 // ----------------------------------------------------------------------------
301 wxWindowBase::~wxWindowBase()
303 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
305 // FIXME if these 2 cases result from programming errors in the user code
306 // we should probably assert here instead of silently fixing them
308 // Just in case the window has been Closed, but we're then deleting
309 // immediately: don't leave dangling pointers.
310 wxPendingDelete
.DeleteObject(this);
312 // Just in case we've loaded a top-level window via LoadNativeDialog but
313 // we weren't a dialog class
314 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
317 // The associated popup menu can still be alive, disassociate from it in
319 if ( wxCurrentPopupMenu
&& wxCurrentPopupMenu
->GetInvokingWindow() == this )
320 wxCurrentPopupMenu
->SetInvokingWindow(NULL
);
321 #endif // wxUSE_MENUS
323 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
325 // notify the parent about this window destruction
327 m_parent
->RemoveChild(this);
331 #endif // wxUSE_CARET
334 delete m_windowValidator
;
335 #endif // wxUSE_VALIDATORS
337 #if wxUSE_CONSTRAINTS
338 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
339 // at deleted windows as they delete themselves.
340 DeleteRelatedConstraints();
344 // This removes any dangling pointers to this window in other windows'
345 // constraintsInvolvedIn lists.
346 UnsetConstraints(m_constraints
);
347 delete m_constraints
;
348 m_constraints
= NULL
;
350 #endif // wxUSE_CONSTRAINTS
352 if ( m_containingSizer
)
353 m_containingSizer
->Detach( (wxWindow
*)this );
355 delete m_windowSizer
;
357 #if wxUSE_DRAG_AND_DROP
359 #endif // wxUSE_DRAG_AND_DROP
363 #endif // wxUSE_TOOLTIPS
365 #if wxUSE_ACCESSIBILITY
370 // NB: this has to be called unconditionally, because we don't know
371 // whether this window has associated help text or not
372 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
374 helpProvider
->RemoveHelp(this);
378 bool wxWindowBase::IsBeingDeleted() const
380 return m_isBeingDeleted
||
381 (!IsTopLevel() && m_parent
&& m_parent
->IsBeingDeleted());
384 void wxWindowBase::SendDestroyEvent()
386 if ( m_isBeingDeleted
)
388 // we could have been already called from a more derived class dtor,
389 // e.g. ~wxTLW calls us and so does ~wxWindow and the latter call
390 // should be simply ignored
394 m_isBeingDeleted
= true;
396 wxWindowDestroyEvent event
;
397 event
.SetEventObject(this);
398 event
.SetId(GetId());
399 GetEventHandler()->ProcessEvent(event
);
402 bool wxWindowBase::Destroy()
411 bool wxWindowBase::Close(bool force
)
413 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
414 event
.SetEventObject(this);
415 event
.SetCanVeto(!force
);
417 // return false if window wasn't closed because the application vetoed the
419 return HandleWindowEvent(event
) && !event
.GetVeto();
422 bool wxWindowBase::DestroyChildren()
424 wxWindowList::compatibility_iterator node
;
427 // we iterate until the list becomes empty
428 node
= GetChildren().GetFirst();
432 wxWindow
*child
= node
->GetData();
434 // note that we really want to delete it immediately so don't call the
435 // possible overridden Destroy() version which might not delete the
436 // child immediately resulting in problems with our (top level) child
437 // outliving its parent
438 child
->wxWindowBase::Destroy();
440 wxASSERT_MSG( !GetChildren().Find(child
),
441 wxT("child didn't remove itself using RemoveChild()") );
447 // ----------------------------------------------------------------------------
448 // size/position related methods
449 // ----------------------------------------------------------------------------
451 // centre the window with respect to its parent in either (or both) directions
452 void wxWindowBase::DoCentre(int dir
)
454 wxCHECK_RET( !(dir
& wxCENTRE_ON_SCREEN
) && GetParent(),
455 wxT("this method only implements centering child windows") );
457 SetSize(GetRect().CentreIn(GetParent()->GetClientSize(), dir
));
460 // fits the window around the children
461 void wxWindowBase::Fit()
463 if ( !GetChildren().empty() )
465 SetSize(GetBestSize());
467 //else: do nothing if we have no children
470 // fits virtual size (ie. scrolled area etc.) around children
471 void wxWindowBase::FitInside()
473 if ( GetChildren().GetCount() > 0 )
475 SetVirtualSize( GetBestVirtualSize() );
479 // On Mac, scrollbars are explicitly children.
480 #if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__)
481 static bool wxHasRealChildren(const wxWindowBase
* win
)
483 int realChildCount
= 0;
485 for ( wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
487 node
= node
->GetNext() )
489 wxWindow
*win
= node
->GetData();
490 if ( !win
->IsTopLevel() && win
->IsShown()
492 && !win
->IsKindOf(CLASSINFO(wxScrollBar
))
497 return (realChildCount
> 0);
501 void wxWindowBase::InvalidateBestSize()
503 m_bestSizeCache
= wxDefaultSize
;
505 // parent's best size calculation may depend on its children's
506 // as long as child window we are in is not top level window itself
507 // (because the TLW size is never resized automatically)
508 // so let's invalidate it as well to be safe:
509 if (m_parent
&& !IsTopLevel())
510 m_parent
->InvalidateBestSize();
513 // return the size best suited for the current window
514 wxSize
wxWindowBase::DoGetBestSize() const
520 best
= m_windowSizer
->GetMinSize();
522 #if wxUSE_CONSTRAINTS
523 else if ( m_constraints
)
525 wxConstCast(this, wxWindowBase
)->SatisfyConstraints();
527 // our minimal acceptable size is such that all our windows fit inside
531 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
533 node
= node
->GetNext() )
535 wxLayoutConstraints
*c
= node
->GetData()->GetConstraints();
538 // it's not normal that we have an unconstrained child, but
539 // what can we do about it?
543 int x
= c
->right
.GetValue(),
544 y
= c
->bottom
.GetValue();
552 // TODO: we must calculate the overlaps somehow, otherwise we
553 // will never return a size bigger than the current one :-(
556 best
= wxSize(maxX
, maxY
);
558 #endif // wxUSE_CONSTRAINTS
559 else if ( !GetChildren().empty()
560 #if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__)
561 && wxHasRealChildren(this)
565 // our minimal acceptable size is such that all our visible child
566 // windows fit inside
570 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
572 node
= node
->GetNext() )
574 wxWindow
*win
= node
->GetData();
575 if ( win
->IsTopLevel()
578 || wxDynamicCast(win
, wxStatusBar
)
579 #endif // wxUSE_STATUSBAR
582 // dialogs and frames lie in different top level windows -
583 // don't deal with them here; as for the status bars, they
584 // don't lie in the client area at all
589 win
->GetPosition(&wx
, &wy
);
591 // if the window hadn't been positioned yet, assume that it is in
593 if ( wx
== wxDefaultCoord
)
595 if ( wy
== wxDefaultCoord
)
598 win
->GetSize(&ww
, &wh
);
599 if ( wx
+ ww
> maxX
)
601 if ( wy
+ wh
> maxY
)
605 best
= wxSize(maxX
, maxY
);
607 else // ! has children
609 wxSize size
= GetMinSize();
610 if ( !size
.IsFullySpecified() )
612 // if the window doesn't define its best size we assume that it can
613 // be arbitrarily small -- usually this is not the case, of course,
614 // but we have no way to know what the limit is, it should really
615 // override DoGetBestClientSize() itself to tell us
616 size
.SetDefaults(wxSize(1, 1));
619 // return as-is, unadjusted by the client size difference.
623 // Add any difference between size and client size
624 wxSize diff
= GetSize() - GetClientSize();
625 best
.x
+= wxMax(0, diff
.x
);
626 best
.y
+= wxMax(0, diff
.y
);
631 // helper of GetWindowBorderSize(): as many ports don't implement support for
632 // wxSYS_BORDER/EDGE_X/Y metrics in their wxSystemSettings, use hard coded
633 // fallbacks in this case
634 static int wxGetMetricOrDefault(wxSystemMetric what
, const wxWindowBase
* win
)
636 int rc
= wxSystemSettings::GetMetric(
637 what
, static_cast<wxWindow
*>(const_cast<wxWindowBase
*>(win
)));
644 // 2D border is by default 1 pixel wide
650 // 3D borders are by default 2 pixels
655 wxFAIL_MSG( wxT("unexpected wxGetMetricOrDefault() argument") );
663 wxSize
wxWindowBase::GetWindowBorderSize() const
667 switch ( GetBorder() )
670 // nothing to do, size is already (0, 0)
673 case wxBORDER_SIMPLE
:
674 case wxBORDER_STATIC
:
675 size
.x
= wxGetMetricOrDefault(wxSYS_BORDER_X
, this);
676 size
.y
= wxGetMetricOrDefault(wxSYS_BORDER_Y
, this);
679 case wxBORDER_SUNKEN
:
680 case wxBORDER_RAISED
:
681 size
.x
= wxMax(wxGetMetricOrDefault(wxSYS_EDGE_X
, this),
682 wxGetMetricOrDefault(wxSYS_BORDER_X
, this));
683 size
.y
= wxMax(wxGetMetricOrDefault(wxSYS_EDGE_Y
, this),
684 wxGetMetricOrDefault(wxSYS_BORDER_Y
, this));
687 case wxBORDER_DOUBLE
:
688 size
.x
= wxGetMetricOrDefault(wxSYS_EDGE_X
, this) +
689 wxGetMetricOrDefault(wxSYS_BORDER_X
, this);
690 size
.y
= wxGetMetricOrDefault(wxSYS_EDGE_Y
, this) +
691 wxGetMetricOrDefault(wxSYS_BORDER_Y
, this);
695 wxFAIL_MSG(wxT("Unknown border style."));
699 // we have borders on both sides
703 wxSize
wxWindowBase::GetEffectiveMinSize() const
705 // merge the best size with the min size, giving priority to the min size
706 wxSize min
= GetMinSize();
708 if (min
.x
== wxDefaultCoord
|| min
.y
== wxDefaultCoord
)
710 wxSize best
= GetBestSize();
711 if (min
.x
== wxDefaultCoord
) min
.x
= best
.x
;
712 if (min
.y
== wxDefaultCoord
) min
.y
= best
.y
;
718 wxSize
wxWindowBase::GetBestSize() const
720 if ( !m_windowSizer
&& m_bestSizeCache
.IsFullySpecified() )
721 return m_bestSizeCache
;
723 // call DoGetBestClientSize() first, if a derived class overrides it wants
725 wxSize size
= DoGetBestClientSize();
726 if ( size
!= wxDefaultSize
)
728 size
+= DoGetBorderSize();
734 return DoGetBestSize();
737 void wxWindowBase::SetMinSize(const wxSize
& minSize
)
739 m_minWidth
= minSize
.x
;
740 m_minHeight
= minSize
.y
;
743 void wxWindowBase::SetMaxSize(const wxSize
& maxSize
)
745 m_maxWidth
= maxSize
.x
;
746 m_maxHeight
= maxSize
.y
;
749 void wxWindowBase::SetInitialSize(const wxSize
& size
)
751 // Set the min size to the size passed in. This will usually either be
752 // wxDefaultSize or the size passed to this window's ctor/Create function.
755 // Merge the size with the best size if needed
756 wxSize best
= GetEffectiveMinSize();
758 // If the current size doesn't match then change it
759 if (GetSize() != best
)
764 // by default the origin is not shifted
765 wxPoint
wxWindowBase::GetClientAreaOrigin() const
770 wxSize
wxWindowBase::ClientToWindowSize(const wxSize
& size
) const
772 const wxSize
diff(GetSize() - GetClientSize());
774 return wxSize(size
.x
== -1 ? -1 : size
.x
+ diff
.x
,
775 size
.y
== -1 ? -1 : size
.y
+ diff
.y
);
778 wxSize
wxWindowBase::WindowToClientSize(const wxSize
& size
) const
780 const wxSize
diff(GetSize() - GetClientSize());
782 return wxSize(size
.x
== -1 ? -1 : size
.x
- diff
.x
,
783 size
.y
== -1 ? -1 : size
.y
- diff
.y
);
786 void wxWindowBase::SetWindowVariant( wxWindowVariant variant
)
788 if ( m_windowVariant
!= variant
)
790 m_windowVariant
= variant
;
792 DoSetWindowVariant(variant
);
796 void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant
)
798 // adjust the font height to correspond to our new variant (notice that
799 // we're only called if something really changed)
800 wxFont font
= GetFont();
801 int size
= font
.GetPointSize();
804 case wxWINDOW_VARIANT_NORMAL
:
807 case wxWINDOW_VARIANT_SMALL
:
812 case wxWINDOW_VARIANT_MINI
:
817 case wxWINDOW_VARIANT_LARGE
:
823 wxFAIL_MSG(wxT("unexpected window variant"));
827 font
.SetPointSize(size
);
831 void wxWindowBase::DoSetSizeHints( int minW
, int minH
,
833 int WXUNUSED(incW
), int WXUNUSED(incH
) )
835 wxCHECK_RET( (minW
== wxDefaultCoord
|| maxW
== wxDefaultCoord
|| minW
<= maxW
) &&
836 (minH
== wxDefaultCoord
|| maxH
== wxDefaultCoord
|| minH
<= maxH
),
837 wxT("min width/height must be less than max width/height!") );
846 #if WXWIN_COMPATIBILITY_2_8
847 void wxWindowBase::SetVirtualSizeHints(int WXUNUSED(minW
), int WXUNUSED(minH
),
848 int WXUNUSED(maxW
), int WXUNUSED(maxH
))
852 void wxWindowBase::SetVirtualSizeHints(const wxSize
& WXUNUSED(minsize
),
853 const wxSize
& WXUNUSED(maxsize
))
856 #endif // WXWIN_COMPATIBILITY_2_8
858 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
860 m_virtualSize
= wxSize(x
, y
);
863 wxSize
wxWindowBase::DoGetVirtualSize() const
865 // we should use the entire client area so if it is greater than our
866 // virtual size, expand it to fit (otherwise if the window is big enough we
867 // wouldn't be using parts of it)
868 wxSize size
= GetClientSize();
869 if ( m_virtualSize
.x
> size
.x
)
870 size
.x
= m_virtualSize
.x
;
872 if ( m_virtualSize
.y
>= size
.y
)
873 size
.y
= m_virtualSize
.y
;
878 void wxWindowBase::DoGetScreenPosition(int *x
, int *y
) const
880 // screen position is the same as (0, 0) in client coords for non TLWs (and
881 // TLWs override this method)
887 ClientToScreen(x
, y
);
890 void wxWindowBase::SendSizeEvent(int flags
)
892 wxSizeEvent
event(GetSize(), GetId());
893 event
.SetEventObject(this);
894 if ( flags
& wxSEND_EVENT_POST
)
895 wxPostEvent(this, event
);
897 HandleWindowEvent(event
);
900 void wxWindowBase::SendSizeEventToParent(int flags
)
902 wxWindow
* const parent
= GetParent();
903 if ( parent
&& !parent
->IsBeingDeleted() )
904 parent
->SendSizeEvent(flags
);
907 bool wxWindowBase::HasScrollbar(int orient
) const
909 // if scrolling in the given direction is disabled, we can't have the
910 // corresponding scrollbar no matter what
911 if ( !CanScroll(orient
) )
914 const wxSize sizeVirt
= GetVirtualSize();
915 const wxSize sizeClient
= GetClientSize();
917 return orient
== wxHORIZONTAL
? sizeVirt
.x
> sizeClient
.x
918 : sizeVirt
.y
> sizeClient
.y
;
921 // ----------------------------------------------------------------------------
922 // show/hide/enable/disable the window
923 // ----------------------------------------------------------------------------
925 bool wxWindowBase::Show(bool show
)
927 if ( show
!= m_isShown
)
939 bool wxWindowBase::IsEnabled() const
941 return IsThisEnabled() && (IsTopLevel() || !GetParent() || GetParent()->IsEnabled());
944 void wxWindowBase::NotifyWindowOnEnableChange(bool enabled
)
946 #ifndef wxHAS_NATIVE_ENABLED_MANAGEMENT
948 #endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
952 // If we are top-level then the logic doesn't apply - otherwise
953 // showing a modal dialog would result in total greying out (and ungreying
954 // out later) of everything which would be really ugly
958 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
960 node
= node
->GetNext() )
962 wxWindowBase
* const child
= node
->GetData();
963 if ( !child
->IsTopLevel() && child
->IsThisEnabled() )
964 child
->NotifyWindowOnEnableChange(enabled
);
968 bool wxWindowBase::Enable(bool enable
)
970 if ( enable
== IsThisEnabled() )
973 m_isEnabled
= enable
;
975 #ifdef wxHAS_NATIVE_ENABLED_MANAGEMENT
977 #else // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
978 wxWindowBase
* const parent
= GetParent();
979 if( !IsTopLevel() && parent
&& !parent
->IsEnabled() )
983 #endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
985 NotifyWindowOnEnableChange(enable
);
990 bool wxWindowBase::IsShownOnScreen() const
992 // A window is shown on screen if it itself is shown and so are all its
993 // parents. But if a window is toplevel one, then its always visible on
994 // screen if IsShown() returns true, even if it has a hidden parent.
996 (IsTopLevel() || GetParent() == NULL
|| GetParent()->IsShownOnScreen());
999 // ----------------------------------------------------------------------------
1001 // ----------------------------------------------------------------------------
1003 bool wxWindowBase::IsTopLevel() const
1008 // ----------------------------------------------------------------------------
1010 // ----------------------------------------------------------------------------
1012 void wxWindowBase::Freeze()
1014 if ( !m_freezeCount
++ )
1016 // physically freeze this window:
1019 // and recursively freeze all children:
1020 for ( wxWindowList::iterator i
= GetChildren().begin();
1021 i
!= GetChildren().end(); ++i
)
1023 wxWindow
*child
= *i
;
1024 if ( child
->IsTopLevel() )
1032 void wxWindowBase::Thaw()
1034 wxASSERT_MSG( m_freezeCount
, "Thaw() without matching Freeze()" );
1036 if ( !--m_freezeCount
)
1038 // recursively thaw all children:
1039 for ( wxWindowList::iterator i
= GetChildren().begin();
1040 i
!= GetChildren().end(); ++i
)
1042 wxWindow
*child
= *i
;
1043 if ( child
->IsTopLevel() )
1049 // physically thaw this window:
1054 // ----------------------------------------------------------------------------
1055 // reparenting the window
1056 // ----------------------------------------------------------------------------
1058 void wxWindowBase::AddChild(wxWindowBase
*child
)
1060 wxCHECK_RET( child
, wxT("can't add a NULL child") );
1062 // this should never happen and it will lead to a crash later if it does
1063 // because RemoveChild() will remove only one node from the children list
1064 // and the other(s) one(s) will be left with dangling pointers in them
1065 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), wxT("AddChild() called twice") );
1067 GetChildren().Append((wxWindow
*)child
);
1068 child
->SetParent(this);
1070 // adding a child while frozen will assert when thawed, so freeze it as if
1071 // it had been already present when we were frozen
1072 if ( IsFrozen() && !child
->IsTopLevel() )
1076 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
1078 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
1080 // removing a child while frozen may result in permanently frozen window
1081 // if used e.g. from Reparent(), so thaw it
1083 // NB: IsTopLevel() doesn't return true any more when a TLW child is being
1084 // removed from its ~wxWindowBase, so check for IsBeingDeleted() too
1085 if ( IsFrozen() && !child
->IsBeingDeleted() && !child
->IsTopLevel() )
1088 GetChildren().DeleteObject((wxWindow
*)child
);
1089 child
->SetParent(NULL
);
1092 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
1094 wxWindow
*oldParent
= GetParent();
1095 if ( newParent
== oldParent
)
1101 const bool oldEnabledState
= IsEnabled();
1103 // unlink this window from the existing parent.
1106 oldParent
->RemoveChild(this);
1110 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
1113 // add it to the new one
1116 newParent
->AddChild(this);
1120 wxTopLevelWindows
.Append((wxWindow
*)this);
1123 // We need to notify window (and its subwindows) if by changing the parent
1124 // we also change our enabled/disabled status.
1125 const bool newEnabledState
= IsEnabled();
1126 if ( newEnabledState
!= oldEnabledState
)
1128 NotifyWindowOnEnableChange(newEnabledState
);
1134 // ----------------------------------------------------------------------------
1135 // event handler stuff
1136 // ----------------------------------------------------------------------------
1138 void wxWindowBase::SetEventHandler(wxEvtHandler
*handler
)
1140 wxCHECK_RET(handler
!= NULL
, "SetEventHandler(NULL) called");
1142 m_eventHandler
= handler
;
1145 void wxWindowBase::SetNextHandler(wxEvtHandler
*WXUNUSED(handler
))
1147 // disable wxEvtHandler chain mechanism for wxWindows:
1148 // wxWindow uses its own stack mechanism which doesn't mix well with wxEvtHandler's one
1150 wxFAIL_MSG("wxWindow cannot be part of a wxEvtHandler chain");
1152 void wxWindowBase::SetPreviousHandler(wxEvtHandler
*WXUNUSED(handler
))
1154 // we can't simply wxFAIL here as in SetNextHandler: in fact the last
1155 // handler of our stack when is destroyed will be Unlink()ed and thus
1156 // will call this function to update the pointer of this window...
1158 //wxFAIL_MSG("wxWindow cannot be part of a wxEvtHandler chain");
1161 void wxWindowBase::PushEventHandler(wxEvtHandler
*handlerToPush
)
1163 wxCHECK_RET( handlerToPush
!= NULL
, "PushEventHandler(NULL) called" );
1165 // the new handler is going to be part of the wxWindow stack of event handlers:
1166 // it can't be part also of an event handler double-linked chain:
1167 wxASSERT_MSG(handlerToPush
->IsUnlinked(),
1168 "The handler being pushed in the wxWindow stack shouldn't be part of "
1169 "a wxEvtHandler chain; call Unlink() on it first");
1171 wxEvtHandler
*handlerOld
= GetEventHandler();
1172 wxCHECK_RET( handlerOld
, "an old event handler is NULL?" );
1174 // now use wxEvtHandler double-linked list to implement a stack:
1175 handlerToPush
->SetNextHandler(handlerOld
);
1177 if (handlerOld
!= this)
1178 handlerOld
->SetPreviousHandler(handlerToPush
);
1180 SetEventHandler(handlerToPush
);
1183 // final checks of the operations done above:
1184 wxASSERT_MSG( handlerToPush
->GetPreviousHandler() == NULL
,
1185 "the first handler of the wxWindow stack should "
1186 "have no previous handlers set" );
1187 wxASSERT_MSG( handlerToPush
->GetNextHandler() != NULL
,
1188 "the first handler of the wxWindow stack should "
1189 "have non-NULL next handler" );
1191 wxEvtHandler
* pLast
= handlerToPush
;
1192 while ( pLast
&& pLast
!= this )
1193 pLast
= pLast
->GetNextHandler();
1194 wxASSERT_MSG( pLast
->GetNextHandler() == NULL
,
1195 "the last handler of the wxWindow stack should "
1196 "have this window as next handler" );
1197 #endif // wxDEBUG_LEVEL
1200 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
1202 // we need to pop the wxWindow stack, i.e. we need to remove the first handler
1204 wxEvtHandler
*firstHandler
= GetEventHandler();
1205 wxCHECK_MSG( firstHandler
!= NULL
, NULL
, "wxWindow cannot have a NULL event handler" );
1206 wxCHECK_MSG( firstHandler
!= this, NULL
, "cannot pop the wxWindow itself" );
1207 wxCHECK_MSG( firstHandler
->GetPreviousHandler() == NULL
, NULL
,
1208 "the first handler of the wxWindow stack should have no previous handlers set" );
1210 wxEvtHandler
*secondHandler
= firstHandler
->GetNextHandler();
1211 wxCHECK_MSG( secondHandler
!= NULL
, NULL
,
1212 "the first handler of the wxWindow stack should have non-NULL next handler" );
1214 firstHandler
->SetNextHandler(NULL
);
1215 secondHandler
->SetPreviousHandler(NULL
);
1217 // now firstHandler is completely unlinked; set secondHandler as the new window event handler
1218 SetEventHandler(secondHandler
);
1220 if ( deleteHandler
)
1222 delete firstHandler
;
1223 firstHandler
= NULL
;
1226 return firstHandler
;
1229 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handlerToRemove
)
1231 wxCHECK_MSG( handlerToRemove
!= NULL
, false, "RemoveEventHandler(NULL) called" );
1232 wxCHECK_MSG( handlerToRemove
!= this, false, "Cannot remove the window itself" );
1234 if (handlerToRemove
== GetEventHandler())
1236 // removing the first event handler is equivalent to "popping" the stack
1237 PopEventHandler(false);
1241 // NOTE: the wxWindow event handler list is always terminated with "this" handler
1242 wxEvtHandler
*handlerCur
= GetEventHandler()->GetNextHandler();
1243 while ( handlerCur
!= this )
1245 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
1247 if ( handlerCur
== handlerToRemove
)
1249 handlerCur
->Unlink();
1251 wxASSERT_MSG( handlerCur
!= GetEventHandler(),
1252 "the case Remove == Pop should was already handled" );
1256 handlerCur
= handlerNext
;
1259 wxFAIL_MSG( wxT("where has the event handler gone?") );
1264 bool wxWindowBase::HandleWindowEvent(wxEvent
& event
) const
1266 // SafelyProcessEvent() will handle exceptions nicely
1267 return GetEventHandler()->SafelyProcessEvent(event
);
1270 // ----------------------------------------------------------------------------
1271 // colours, fonts &c
1272 // ----------------------------------------------------------------------------
1274 void wxWindowBase::InheritAttributes()
1276 const wxWindowBase
* const parent
= GetParent();
1280 // we only inherit attributes which had been explicitly set for the parent
1281 // which ensures that this only happens if the user really wants it and
1282 // not by default which wouldn't make any sense in modern GUIs where the
1283 // controls don't all use the same fonts (nor colours)
1284 if ( parent
->m_inheritFont
&& !m_hasFont
)
1285 SetFont(parent
->GetFont());
1287 // in addition, there is a possibility to explicitly forbid inheriting
1288 // colours at each class level by overriding ShouldInheritColours()
1289 if ( ShouldInheritColours() )
1291 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
1292 SetForegroundColour(parent
->GetForegroundColour());
1294 // inheriting (solid) background colour is wrong as it totally breaks
1295 // any kind of themed backgrounds
1297 // instead, the controls should use the same background as their parent
1298 // (ideally by not drawing it at all)
1300 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
1301 SetBackgroundColour(parent
->GetBackgroundColour());
1306 /* static */ wxVisualAttributes
1307 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
1309 // it is important to return valid values for all attributes from here,
1310 // GetXXX() below rely on this
1311 wxVisualAttributes attrs
;
1312 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
1313 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
1315 // On Smartphone/PocketPC, wxSYS_COLOUR_WINDOW is a better reflection of
1316 // the usual background colour than wxSYS_COLOUR_BTNFACE.
1317 // It's a pity that wxSYS_COLOUR_WINDOW isn't always a suitable background
1318 // colour on other platforms.
1320 #if defined(__WXWINCE__) && (defined(__SMARTPHONE__) || defined(__POCKETPC__))
1321 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
1323 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
1328 wxColour
wxWindowBase::GetBackgroundColour() const
1330 if ( !m_backgroundColour
.IsOk() )
1332 wxASSERT_MSG( !m_hasBgCol
, wxT("we have invalid explicit bg colour?") );
1334 // get our default background colour
1335 wxColour colBg
= GetDefaultAttributes().colBg
;
1337 // we must return some valid colour to avoid redoing this every time
1338 // and also to avoid surprizing the applications written for older
1339 // wxWidgets versions where GetBackgroundColour() always returned
1340 // something -- so give them something even if it doesn't make sense
1341 // for this window (e.g. it has a themed background)
1343 colBg
= GetClassDefaultAttributes().colBg
;
1348 return m_backgroundColour
;
1351 wxColour
wxWindowBase::GetForegroundColour() const
1353 // logic is the same as above
1354 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
1356 wxColour colFg
= GetDefaultAttributes().colFg
;
1358 if ( !colFg
.IsOk() )
1359 colFg
= GetClassDefaultAttributes().colFg
;
1364 return m_foregroundColour
;
1367 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
1369 if ( colour
== m_backgroundColour
)
1372 m_hasBgCol
= colour
.IsOk();
1374 m_inheritBgCol
= m_hasBgCol
;
1375 m_backgroundColour
= colour
;
1376 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1380 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1382 if (colour
== m_foregroundColour
)
1385 m_hasFgCol
= colour
.IsOk();
1386 m_inheritFgCol
= m_hasFgCol
;
1387 m_foregroundColour
= colour
;
1388 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1392 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1394 // setting an invalid cursor is ok, it means that we don't have any special
1396 if ( m_cursor
.IsSameAs(cursor
) )
1407 wxFont
wxWindowBase::GetFont() const
1409 // logic is the same as in GetBackgroundColour()
1410 if ( !m_font
.IsOk() )
1412 wxASSERT_MSG( !m_hasFont
, wxT("we have invalid explicit font?") );
1414 wxFont font
= GetDefaultAttributes().font
;
1416 font
= GetClassDefaultAttributes().font
;
1424 bool wxWindowBase::SetFont(const wxFont
& font
)
1426 if ( font
== m_font
)
1433 m_hasFont
= font
.IsOk();
1434 m_inheritFont
= m_hasFont
;
1436 InvalidateBestSize();
1443 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1445 m_hasCustomPalette
= true;
1448 // VZ: can anyone explain me what do we do here?
1449 wxWindowDC
d((wxWindow
*) this);
1453 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1455 wxWindow
*win
= (wxWindow
*)this;
1456 while ( win
&& !win
->HasCustomPalette() )
1458 win
= win
->GetParent();
1464 #endif // wxUSE_PALETTE
1467 void wxWindowBase::SetCaret(wxCaret
*caret
)
1478 wxASSERT_MSG( m_caret
->GetWindow() == this,
1479 wxT("caret should be created associated to this window") );
1482 #endif // wxUSE_CARET
1484 #if wxUSE_VALIDATORS
1485 // ----------------------------------------------------------------------------
1487 // ----------------------------------------------------------------------------
1489 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1491 if ( m_windowValidator
)
1492 delete m_windowValidator
;
1494 m_windowValidator
= (wxValidator
*)validator
.Clone();
1496 if ( m_windowValidator
)
1497 m_windowValidator
->SetWindow(this);
1499 #endif // wxUSE_VALIDATORS
1501 // ----------------------------------------------------------------------------
1502 // update region stuff
1503 // ----------------------------------------------------------------------------
1505 wxRect
wxWindowBase::GetUpdateClientRect() const
1507 wxRegion rgnUpdate
= GetUpdateRegion();
1508 rgnUpdate
.Intersect(GetClientRect());
1509 wxRect rectUpdate
= rgnUpdate
.GetBox();
1510 wxPoint ptOrigin
= GetClientAreaOrigin();
1511 rectUpdate
.x
-= ptOrigin
.x
;
1512 rectUpdate
.y
-= ptOrigin
.y
;
1517 bool wxWindowBase::DoIsExposed(int x
, int y
) const
1519 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1522 bool wxWindowBase::DoIsExposed(int x
, int y
, int w
, int h
) const
1524 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1527 void wxWindowBase::ClearBackground()
1529 // wxGTK uses its own version, no need to add never used code
1531 wxClientDC
dc((wxWindow
*)this);
1532 wxBrush
brush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID
);
1533 dc
.SetBackground(brush
);
1538 // ----------------------------------------------------------------------------
1539 // find child window by id or name
1540 // ----------------------------------------------------------------------------
1542 wxWindow
*wxWindowBase::FindWindow(long id
) const
1544 if ( id
== m_windowId
)
1545 return (wxWindow
*)this;
1547 wxWindowBase
*res
= NULL
;
1548 wxWindowList::compatibility_iterator node
;
1549 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1551 wxWindowBase
*child
= node
->GetData();
1552 res
= child
->FindWindow( id
);
1555 return (wxWindow
*)res
;
1558 wxWindow
*wxWindowBase::FindWindow(const wxString
& name
) const
1560 if ( name
== m_windowName
)
1561 return (wxWindow
*)this;
1563 wxWindowBase
*res
= NULL
;
1564 wxWindowList::compatibility_iterator node
;
1565 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1567 wxWindow
*child
= node
->GetData();
1568 res
= child
->FindWindow(name
);
1571 return (wxWindow
*)res
;
1575 // find any window by id or name or label: If parent is non-NULL, look through
1576 // children for a label or title matching the specified string. If NULL, look
1577 // through all top-level windows.
1579 // to avoid duplicating code we reuse the same helper function but with
1580 // different comparators
1582 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1583 const wxString
& label
, long id
);
1586 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1589 return win
->GetLabel() == label
;
1593 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1596 return win
->GetName() == label
;
1600 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1603 return win
->GetId() == id
;
1606 // recursive helper for the FindWindowByXXX() functions
1608 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1609 const wxString
& label
,
1611 wxFindWindowCmp cmp
)
1615 // see if this is the one we're looking for
1616 if ( (*cmp
)(parent
, label
, id
) )
1617 return (wxWindow
*)parent
;
1619 // It wasn't, so check all its children
1620 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1622 node
= node
->GetNext() )
1624 // recursively check each child
1625 wxWindow
*win
= (wxWindow
*)node
->GetData();
1626 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1636 // helper for FindWindowByXXX()
1638 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1639 const wxString
& label
,
1641 wxFindWindowCmp cmp
)
1645 // just check parent and all its children
1646 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1649 // start at very top of wx's windows
1650 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1652 node
= node
->GetNext() )
1654 // recursively check each window & its children
1655 wxWindow
*win
= node
->GetData();
1656 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1666 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1668 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1673 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1675 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1679 // fall back to the label
1680 win
= FindWindowByLabel(title
, parent
);
1688 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1690 return wxFindWindowHelper(parent
, wxEmptyString
, id
, wxFindWindowCmpIds
);
1693 // ----------------------------------------------------------------------------
1694 // dialog oriented functions
1695 // ----------------------------------------------------------------------------
1697 void wxWindowBase::MakeModal(bool modal
)
1699 // Disable all other windows
1702 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1705 wxWindow
*win
= node
->GetData();
1707 win
->Enable(!modal
);
1709 node
= node
->GetNext();
1714 bool wxWindowBase::Validate()
1716 #if wxUSE_VALIDATORS
1717 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1719 wxWindowList::compatibility_iterator node
;
1720 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1722 wxWindowBase
*child
= node
->GetData();
1723 wxValidator
*validator
= child
->GetValidator();
1724 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1729 if ( recurse
&& !child
->Validate() )
1734 #endif // wxUSE_VALIDATORS
1739 bool wxWindowBase::TransferDataToWindow()
1741 #if wxUSE_VALIDATORS
1742 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1744 wxWindowList::compatibility_iterator node
;
1745 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1747 wxWindowBase
*child
= node
->GetData();
1748 wxValidator
*validator
= child
->GetValidator();
1749 if ( validator
&& !validator
->TransferToWindow() )
1751 wxLogWarning(_("Could not transfer data to window"));
1753 wxLog::FlushActive();
1761 if ( !child
->TransferDataToWindow() )
1763 // warning already given
1768 #endif // wxUSE_VALIDATORS
1773 bool wxWindowBase::TransferDataFromWindow()
1775 #if wxUSE_VALIDATORS
1776 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1778 wxWindowList::compatibility_iterator node
;
1779 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1781 wxWindow
*child
= node
->GetData();
1782 wxValidator
*validator
= child
->GetValidator();
1783 if ( validator
&& !validator
->TransferFromWindow() )
1785 // nop warning here because the application is supposed to give
1786 // one itself - we don't know here what might have gone wrongly
1793 if ( !child
->TransferDataFromWindow() )
1795 // warning already given
1800 #endif // wxUSE_VALIDATORS
1805 void wxWindowBase::InitDialog()
1807 wxInitDialogEvent
event(GetId());
1808 event
.SetEventObject( this );
1809 GetEventHandler()->ProcessEvent(event
);
1812 // ----------------------------------------------------------------------------
1813 // context-sensitive help support
1814 // ----------------------------------------------------------------------------
1818 // associate this help text with this window
1819 void wxWindowBase::SetHelpText(const wxString
& text
)
1821 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1824 helpProvider
->AddHelp(this, text
);
1828 #if WXWIN_COMPATIBILITY_2_8
1829 // associate this help text with all windows with the same id as this
1831 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1833 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1836 helpProvider
->AddHelp(GetId(), text
);
1839 #endif // WXWIN_COMPATIBILITY_2_8
1841 // get the help string associated with this window (may be empty)
1842 // default implementation forwards calls to the help provider
1844 wxWindowBase::GetHelpTextAtPoint(const wxPoint
& WXUNUSED(pt
),
1845 wxHelpEvent::Origin
WXUNUSED(origin
)) const
1848 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1851 text
= helpProvider
->GetHelp(this);
1857 // show help for this window
1858 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1860 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1863 wxPoint pos
= event
.GetPosition();
1864 const wxHelpEvent::Origin origin
= event
.GetOrigin();
1865 if ( origin
== wxHelpEvent::Origin_Keyboard
)
1867 // if the help event was generated from keyboard it shouldn't
1868 // appear at the mouse position (which is still the only position
1869 // associated with help event) if the mouse is far away, although
1870 // we still do use the mouse position if it's over the window
1871 // because we suppose the user looks approximately at the mouse
1872 // already and so it would be more convenient than showing tooltip
1873 // at some arbitrary position which can be quite far from it
1874 const wxRect rectClient
= GetClientRect();
1875 if ( !rectClient
.Contains(ScreenToClient(pos
)) )
1877 // position help slightly under and to the right of this window
1878 pos
= ClientToScreen(wxPoint(
1880 rectClient
.height
+ GetCharHeight()
1885 if ( helpProvider
->ShowHelpAtPoint(this, pos
, origin
) )
1887 // skip the event.Skip() below
1895 #endif // wxUSE_HELP
1897 // ----------------------------------------------------------------------------
1899 // ----------------------------------------------------------------------------
1903 wxString
wxWindowBase::GetToolTipText() const
1905 return m_tooltip
? m_tooltip
->GetTip() : wxString();
1908 void wxWindowBase::SetToolTip( const wxString
&tip
)
1910 // don't create the new tooltip if we already have one
1913 m_tooltip
->SetTip( tip
);
1917 SetToolTip( new wxToolTip( tip
) );
1920 // setting empty tooltip text does not remove the tooltip any more - use
1921 // SetToolTip(NULL) for this
1924 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1926 if ( m_tooltip
!= tooltip
)
1931 m_tooltip
= tooltip
;
1935 #endif // wxUSE_TOOLTIPS
1937 // ----------------------------------------------------------------------------
1938 // constraints and sizers
1939 // ----------------------------------------------------------------------------
1941 #if wxUSE_CONSTRAINTS
1943 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1945 if ( m_constraints
)
1947 UnsetConstraints(m_constraints
);
1948 delete m_constraints
;
1950 m_constraints
= constraints
;
1951 if ( m_constraints
)
1953 // Make sure other windows know they're part of a 'meaningful relationship'
1954 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1955 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1956 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1957 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1958 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1959 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1960 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1961 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1962 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1963 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1964 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1965 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1966 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1967 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1968 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1969 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1973 // This removes any dangling pointers to this window in other windows'
1974 // constraintsInvolvedIn lists.
1975 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1979 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1980 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1981 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1982 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1983 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1984 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1985 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1986 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1987 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1988 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1989 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1990 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1991 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1992 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1993 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1994 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1998 // Back-pointer to other windows we're involved with, so if we delete this
1999 // window, we must delete any constraints we're involved with.
2000 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
2002 if ( !m_constraintsInvolvedIn
)
2003 m_constraintsInvolvedIn
= new wxWindowList
;
2004 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
2005 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
2008 // REMOVE back-pointer to other windows we're involved with.
2009 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
2011 if ( m_constraintsInvolvedIn
)
2012 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
2015 // Reset any constraints that mention this window
2016 void wxWindowBase::DeleteRelatedConstraints()
2018 if ( m_constraintsInvolvedIn
)
2020 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
2023 wxWindow
*win
= node
->GetData();
2024 wxLayoutConstraints
*constr
= win
->GetConstraints();
2026 // Reset any constraints involving this window
2029 constr
->left
.ResetIfWin(this);
2030 constr
->top
.ResetIfWin(this);
2031 constr
->right
.ResetIfWin(this);
2032 constr
->bottom
.ResetIfWin(this);
2033 constr
->width
.ResetIfWin(this);
2034 constr
->height
.ResetIfWin(this);
2035 constr
->centreX
.ResetIfWin(this);
2036 constr
->centreY
.ResetIfWin(this);
2039 wxWindowList::compatibility_iterator next
= node
->GetNext();
2040 m_constraintsInvolvedIn
->Erase(node
);
2044 delete m_constraintsInvolvedIn
;
2045 m_constraintsInvolvedIn
= NULL
;
2049 #endif // wxUSE_CONSTRAINTS
2051 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
2053 if ( sizer
== m_windowSizer
)
2056 if ( m_windowSizer
)
2058 m_windowSizer
->SetContainingWindow(NULL
);
2061 delete m_windowSizer
;
2064 m_windowSizer
= sizer
;
2065 if ( m_windowSizer
)
2067 m_windowSizer
->SetContainingWindow((wxWindow
*)this);
2070 SetAutoLayout(m_windowSizer
!= NULL
);
2073 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
2075 SetSizer( sizer
, deleteOld
);
2076 sizer
->SetSizeHints( (wxWindow
*) this );
2080 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
2082 // adding a window to a sizer twice is going to result in fatal and
2083 // hard to debug problems later because when deleting the second
2084 // associated wxSizerItem we're going to dereference a dangling
2085 // pointer; so try to detect this as early as possible
2086 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
2087 wxT("Adding a window to the same sizer twice?") );
2089 m_containingSizer
= sizer
;
2092 #if wxUSE_CONSTRAINTS
2094 void wxWindowBase::SatisfyConstraints()
2096 wxLayoutConstraints
*constr
= GetConstraints();
2097 bool wasOk
= constr
&& constr
->AreSatisfied();
2099 ResetConstraints(); // Mark all constraints as unevaluated
2103 // if we're a top level panel (i.e. our parent is frame/dialog), our
2104 // own constraints will never be satisfied any more unless we do it
2108 while ( noChanges
> 0 )
2110 LayoutPhase1(&noChanges
);
2114 LayoutPhase2(&noChanges
);
2117 #endif // wxUSE_CONSTRAINTS
2119 bool wxWindowBase::Layout()
2121 // If there is a sizer, use it instead of the constraints
2125 GetVirtualSize(&w
, &h
);
2126 GetSizer()->SetDimension( 0, 0, w
, h
);
2128 #if wxUSE_CONSTRAINTS
2131 SatisfyConstraints(); // Find the right constraints values
2132 SetConstraintSizes(); // Recursively set the real window sizes
2139 void wxWindowBase::InternalOnSize(wxSizeEvent
& event
)
2141 if ( GetAutoLayout() )
2147 #if wxUSE_CONSTRAINTS
2149 // first phase of the constraints evaluation: set our own constraints
2150 bool wxWindowBase::LayoutPhase1(int *noChanges
)
2152 wxLayoutConstraints
*constr
= GetConstraints();
2154 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
2157 // second phase: set the constraints for our children
2158 bool wxWindowBase::LayoutPhase2(int *noChanges
)
2165 // Layout grand children
2171 // Do a phase of evaluating child constraints
2172 bool wxWindowBase::DoPhase(int phase
)
2174 // the list containing the children for which the constraints are already
2176 wxWindowList succeeded
;
2178 // the max number of iterations we loop before concluding that we can't set
2180 static const int maxIterations
= 500;
2182 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
2186 // loop over all children setting their constraints
2187 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2189 node
= node
->GetNext() )
2191 wxWindow
*child
= node
->GetData();
2192 if ( child
->IsTopLevel() )
2194 // top level children are not inside our client area
2198 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
2200 // this one is either already ok or nothing we can do about it
2204 int tempNoChanges
= 0;
2205 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
2206 : child
->LayoutPhase2(&tempNoChanges
);
2207 noChanges
+= tempNoChanges
;
2211 succeeded
.Append(child
);
2217 // constraints are set
2225 void wxWindowBase::ResetConstraints()
2227 wxLayoutConstraints
*constr
= GetConstraints();
2230 constr
->left
.SetDone(false);
2231 constr
->top
.SetDone(false);
2232 constr
->right
.SetDone(false);
2233 constr
->bottom
.SetDone(false);
2234 constr
->width
.SetDone(false);
2235 constr
->height
.SetDone(false);
2236 constr
->centreX
.SetDone(false);
2237 constr
->centreY
.SetDone(false);
2240 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2243 wxWindow
*win
= node
->GetData();
2244 if ( !win
->IsTopLevel() )
2245 win
->ResetConstraints();
2246 node
= node
->GetNext();
2250 // Need to distinguish between setting the 'fake' size for windows and sizers,
2251 // and setting the real values.
2252 void wxWindowBase::SetConstraintSizes(bool recurse
)
2254 wxLayoutConstraints
*constr
= GetConstraints();
2255 if ( constr
&& constr
->AreSatisfied() )
2257 int x
= constr
->left
.GetValue();
2258 int y
= constr
->top
.GetValue();
2259 int w
= constr
->width
.GetValue();
2260 int h
= constr
->height
.GetValue();
2262 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
2263 (constr
->height
.GetRelationship() != wxAsIs
) )
2265 SetSize(x
, y
, w
, h
);
2269 // If we don't want to resize this window, just move it...
2275 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
2276 GetClassInfo()->GetClassName(),
2282 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2285 wxWindow
*win
= node
->GetData();
2286 if ( !win
->IsTopLevel() && win
->GetConstraints() )
2287 win
->SetConstraintSizes();
2288 node
= node
->GetNext();
2293 // Only set the size/position of the constraint (if any)
2294 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
2296 wxLayoutConstraints
*constr
= GetConstraints();
2299 if ( x
!= wxDefaultCoord
)
2301 constr
->left
.SetValue(x
);
2302 constr
->left
.SetDone(true);
2304 if ( y
!= wxDefaultCoord
)
2306 constr
->top
.SetValue(y
);
2307 constr
->top
.SetDone(true);
2309 if ( w
!= wxDefaultCoord
)
2311 constr
->width
.SetValue(w
);
2312 constr
->width
.SetDone(true);
2314 if ( h
!= wxDefaultCoord
)
2316 constr
->height
.SetValue(h
);
2317 constr
->height
.SetDone(true);
2322 void wxWindowBase::MoveConstraint(int x
, int y
)
2324 wxLayoutConstraints
*constr
= GetConstraints();
2327 if ( x
!= wxDefaultCoord
)
2329 constr
->left
.SetValue(x
);
2330 constr
->left
.SetDone(true);
2332 if ( y
!= wxDefaultCoord
)
2334 constr
->top
.SetValue(y
);
2335 constr
->top
.SetDone(true);
2340 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
2342 wxLayoutConstraints
*constr
= GetConstraints();
2345 *w
= constr
->width
.GetValue();
2346 *h
= constr
->height
.GetValue();
2352 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
2354 wxLayoutConstraints
*constr
= GetConstraints();
2357 *w
= constr
->width
.GetValue();
2358 *h
= constr
->height
.GetValue();
2361 GetClientSize(w
, h
);
2364 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
2366 wxLayoutConstraints
*constr
= GetConstraints();
2369 *x
= constr
->left
.GetValue();
2370 *y
= constr
->top
.GetValue();
2376 #endif // wxUSE_CONSTRAINTS
2378 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
2380 // don't do it for the dialogs/frames - they float independently of their
2382 if ( !IsTopLevel() )
2384 wxWindow
*parent
= GetParent();
2385 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
2387 wxPoint
pt(parent
->GetClientAreaOrigin());
2394 // ----------------------------------------------------------------------------
2395 // Update UI processing
2396 // ----------------------------------------------------------------------------
2398 void wxWindowBase::UpdateWindowUI(long flags
)
2400 wxUpdateUIEvent
event(GetId());
2401 event
.SetEventObject(this);
2403 if ( GetEventHandler()->ProcessEvent(event
) )
2405 DoUpdateWindowUI(event
);
2408 if (flags
& wxUPDATE_UI_RECURSE
)
2410 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2413 wxWindow
* child
= (wxWindow
*) node
->GetData();
2414 child
->UpdateWindowUI(flags
);
2415 node
= node
->GetNext();
2420 // do the window-specific processing after processing the update event
2421 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
2423 if ( event
.GetSetEnabled() )
2424 Enable(event
.GetEnabled());
2426 if ( event
.GetSetShown() )
2427 Show(event
.GetShown());
2430 // ----------------------------------------------------------------------------
2431 // dialog units translations
2432 // ----------------------------------------------------------------------------
2434 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
2436 int charWidth
= GetCharWidth();
2437 int charHeight
= GetCharHeight();
2438 wxPoint pt2
= wxDefaultPosition
;
2439 if (pt
.x
!= wxDefaultCoord
)
2440 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
);
2441 if (pt
.y
!= wxDefaultCoord
)
2442 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2447 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2449 int charWidth
= GetCharWidth();
2450 int charHeight
= GetCharHeight();
2451 wxPoint pt2
= wxDefaultPosition
;
2452 if (pt
.x
!= wxDefaultCoord
)
2453 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2454 if (pt
.y
!= wxDefaultCoord
)
2455 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2460 // ----------------------------------------------------------------------------
2462 // ----------------------------------------------------------------------------
2464 // propagate the colour change event to the subwindows
2465 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2467 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2470 // Only propagate to non-top-level windows
2471 wxWindow
*win
= node
->GetData();
2472 if ( !win
->IsTopLevel() )
2474 wxSysColourChangedEvent event2
;
2475 event
.SetEventObject(win
);
2476 win
->GetEventHandler()->ProcessEvent(event2
);
2479 node
= node
->GetNext();
2485 // the default action is to populate dialog with data when it's created,
2486 // and nudge the UI into displaying itself correctly in case
2487 // we've turned the wxUpdateUIEvents frequency down low.
2488 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2490 TransferDataToWindow();
2492 // Update the UI at this point
2493 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2496 // ----------------------------------------------------------------------------
2497 // menu-related functions
2498 // ----------------------------------------------------------------------------
2502 bool wxWindowBase::PopupMenu(wxMenu
*menu
, int x
, int y
)
2504 wxCHECK_MSG( menu
, false, "can't popup NULL menu" );
2506 wxCurrentPopupMenu
= menu
;
2507 const bool rc
= DoPopupMenu(menu
, x
, y
);
2508 wxCurrentPopupMenu
= NULL
;
2513 // this is used to pass the id of the selected item from the menu event handler
2514 // to the main function itself
2516 // it's ok to use a global here as there can be at most one popup menu shown at
2518 static int gs_popupMenuSelection
= wxID_NONE
;
2520 void wxWindowBase::InternalOnPopupMenu(wxCommandEvent
& event
)
2522 // store the id in a global variable where we'll retrieve it from later
2523 gs_popupMenuSelection
= event
.GetId();
2526 void wxWindowBase::InternalOnPopupMenuUpdate(wxUpdateUIEvent
& WXUNUSED(event
))
2528 // nothing to do but do not skip it
2532 wxWindowBase::DoGetPopupMenuSelectionFromUser(wxMenu
& menu
, int x
, int y
)
2534 gs_popupMenuSelection
= wxID_NONE
;
2536 Connect(wxEVT_COMMAND_MENU_SELECTED
,
2537 wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu
),
2541 // it is common to construct the menu passed to this function dynamically
2542 // using some fixed range of ids which could clash with the ids used
2543 // elsewhere in the program, which could result in some menu items being
2544 // unintentionally disabled or otherwise modified by update UI handlers
2545 // elsewhere in the program code and this is difficult to avoid in the
2546 // program itself, so instead we just temporarily suspend UI updating while
2547 // this menu is shown
2548 Connect(wxEVT_UPDATE_UI
,
2549 wxUpdateUIEventHandler(wxWindowBase::InternalOnPopupMenuUpdate
),
2553 PopupMenu(&menu
, x
, y
);
2555 Disconnect(wxEVT_UPDATE_UI
,
2556 wxUpdateUIEventHandler(wxWindowBase::InternalOnPopupMenuUpdate
),
2559 Disconnect(wxEVT_COMMAND_MENU_SELECTED
,
2560 wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu
),
2564 return gs_popupMenuSelection
;
2567 #endif // wxUSE_MENUS
2569 // methods for drawing the sizers in a visible way: this is currently only
2570 // enabled for "full debug" builds with wxDEBUG_LEVEL==2 as it doesn't work
2571 // that well and also because we don't want to leave it enabled in default
2572 // builds used for production
2573 #if wxDEBUG_LEVEL > 1
2575 static void DrawSizers(wxWindowBase
*win
);
2577 static void DrawBorder(wxWindowBase
*win
, const wxRect
& rect
, bool fill
, const wxPen
* pen
)
2579 wxClientDC
dc((wxWindow
*)win
);
2581 dc
.SetBrush(fill
? wxBrush(pen
->GetColour(), wxBRUSHSTYLE_CROSSDIAG_HATCH
) :
2582 *wxTRANSPARENT_BRUSH
);
2583 dc
.DrawRectangle(rect
.Deflate(1, 1));
2586 static void DrawSizer(wxWindowBase
*win
, wxSizer
*sizer
)
2588 const wxSizerItemList
& items
= sizer
->GetChildren();
2589 for ( wxSizerItemList::const_iterator i
= items
.begin(),
2594 wxSizerItem
*item
= *i
;
2595 if ( item
->IsSizer() )
2597 DrawBorder(win
, item
->GetRect().Deflate(2), false, wxRED_PEN
);
2598 DrawSizer(win
, item
->GetSizer());
2600 else if ( item
->IsSpacer() )
2602 DrawBorder(win
, item
->GetRect().Deflate(2), true, wxBLUE_PEN
);
2604 else if ( item
->IsWindow() )
2606 DrawSizers(item
->GetWindow());
2609 wxFAIL_MSG("inconsistent wxSizerItem status!");
2613 static void DrawSizers(wxWindowBase
*win
)
2615 DrawBorder(win
, win
->GetClientSize(), false, wxGREEN_PEN
);
2617 wxSizer
*sizer
= win
->GetSizer();
2620 DrawSizer(win
, sizer
);
2622 else // no sizer, still recurse into the children
2624 const wxWindowList
& children
= win
->GetChildren();
2625 for ( wxWindowList::const_iterator i
= children
.begin(),
2626 end
= children
.end();
2633 // show all kind of sizes of this window; see the "window sizing" topic
2634 // overview for more info about the various differences:
2635 wxSize fullSz
= win
->GetSize();
2636 wxSize clientSz
= win
->GetClientSize();
2637 wxSize bestSz
= win
->GetBestSize();
2638 wxSize minSz
= win
->GetMinSize();
2639 wxSize maxSz
= win
->GetMaxSize();
2640 wxSize virtualSz
= win
->GetVirtualSize();
2642 wxMessageOutputDebug dbgout
;
2644 "%-10s => fullsz=%4d;%-4d clientsz=%4d;%-4d bestsz=%4d;%-4d minsz=%4d;%-4d maxsz=%4d;%-4d virtualsz=%4d;%-4d\n",
2647 clientSz
.x
, clientSz
.y
,
2651 virtualSz
.x
, virtualSz
.y
);
2655 #endif // wxDEBUG_LEVEL
2657 // process special middle clicks
2658 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2660 if ( event
.ControlDown() && event
.AltDown() )
2662 #if wxDEBUG_LEVEL > 1
2663 // Ctrl-Alt-Shift-mclick makes the sizers visible in debug builds
2664 if ( event
.ShiftDown() )
2669 #endif // __WXDEBUG__
2671 // just Ctrl-Alt-middle click shows information about wx version
2672 ::wxInfoMessageBox((wxWindow
*)this);
2681 // ----------------------------------------------------------------------------
2683 // ----------------------------------------------------------------------------
2685 #if wxUSE_ACCESSIBILITY
2686 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2688 if (m_accessible
&& (accessible
!= m_accessible
))
2689 delete m_accessible
;
2690 m_accessible
= accessible
;
2692 m_accessible
->SetWindow((wxWindow
*) this);
2695 // Returns the accessible object, creating if necessary.
2696 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2699 m_accessible
= CreateAccessible();
2700 return m_accessible
;
2703 // Override to create a specific accessible object.
2704 wxAccessible
* wxWindowBase::CreateAccessible()
2706 return new wxWindowAccessible((wxWindow
*) this);
2711 // ----------------------------------------------------------------------------
2712 // list classes implementation
2713 // ----------------------------------------------------------------------------
2717 #include "wx/listimpl.cpp"
2718 WX_DEFINE_LIST(wxWindowList
)
2722 void wxWindowListNode::DeleteData()
2724 delete (wxWindow
*)GetData();
2727 #endif // wxUSE_STL/!wxUSE_STL
2729 // ----------------------------------------------------------------------------
2731 // ----------------------------------------------------------------------------
2733 wxBorder
wxWindowBase::GetBorder(long flags
) const
2735 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2736 if ( border
== wxBORDER_DEFAULT
)
2738 border
= GetDefaultBorder();
2740 else if ( border
== wxBORDER_THEME
)
2742 border
= GetDefaultBorderForControl();
2748 wxBorder
wxWindowBase::GetDefaultBorder() const
2750 return wxBORDER_NONE
;
2753 // ----------------------------------------------------------------------------
2755 // ----------------------------------------------------------------------------
2757 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2759 // here we just check if the point is inside the window or not
2761 // check the top and left border first
2762 bool outside
= x
< 0 || y
< 0;
2765 // check the right and bottom borders too
2766 wxSize size
= GetSize();
2767 outside
= x
>= size
.x
|| y
>= size
.y
;
2770 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2773 // ----------------------------------------------------------------------------
2775 // ----------------------------------------------------------------------------
2777 struct WXDLLEXPORT wxWindowNext
2781 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2782 wxWindow
*wxWindowBase::ms_winCaptureCurrent
= NULL
;
2783 bool wxWindowBase::ms_winCaptureChanging
= false;
2785 void wxWindowBase::CaptureMouse()
2787 wxLogTrace(wxT("mousecapture"), wxT("CaptureMouse(%p)"), static_cast<void*>(this));
2789 wxASSERT_MSG( !ms_winCaptureChanging
, wxT("recursive CaptureMouse call?") );
2791 ms_winCaptureChanging
= true;
2793 wxWindow
*winOld
= GetCapture();
2796 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2799 wxWindowNext
*item
= new wxWindowNext
;
2801 item
->next
= ms_winCaptureNext
;
2802 ms_winCaptureNext
= item
;
2804 //else: no mouse capture to save
2807 ms_winCaptureCurrent
= (wxWindow
*)this;
2809 ms_winCaptureChanging
= false;
2812 void wxWindowBase::ReleaseMouse()
2814 wxLogTrace(wxT("mousecapture"), wxT("ReleaseMouse(%p)"), static_cast<void*>(this));
2816 wxASSERT_MSG( !ms_winCaptureChanging
, wxT("recursive ReleaseMouse call?") );
2818 wxASSERT_MSG( GetCapture() == this,
2819 "attempt to release mouse, but this window hasn't captured it" );
2820 wxASSERT_MSG( ms_winCaptureCurrent
== this,
2821 "attempt to release mouse, but this window hasn't captured it" );
2823 ms_winCaptureChanging
= true;
2826 ms_winCaptureCurrent
= NULL
;
2828 if ( ms_winCaptureNext
)
2830 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2831 ms_winCaptureCurrent
= ms_winCaptureNext
->win
;
2833 wxWindowNext
*item
= ms_winCaptureNext
;
2834 ms_winCaptureNext
= item
->next
;
2837 //else: stack is empty, no previous capture
2839 ms_winCaptureChanging
= false;
2841 wxLogTrace(wxT("mousecapture"),
2842 (const wxChar
*) wxT("After ReleaseMouse() mouse is captured by %p"),
2843 static_cast<void*>(GetCapture()));
2846 static void DoNotifyWindowAboutCaptureLost(wxWindow
*win
)
2848 wxMouseCaptureLostEvent
event(win
->GetId());
2849 event
.SetEventObject(win
);
2850 if ( !win
->GetEventHandler()->ProcessEvent(event
) )
2852 // windows must handle this event, otherwise the app wouldn't behave
2853 // correctly if it loses capture unexpectedly; see the discussion here:
2854 // http://sourceforge.net/tracker/index.php?func=detail&aid=1153662&group_id=9863&atid=109863
2855 // http://article.gmane.org/gmane.comp.lib.wxwidgets.devel/82376
2856 wxFAIL_MSG( wxT("window that captured the mouse didn't process wxEVT_MOUSE_CAPTURE_LOST") );
2861 void wxWindowBase::NotifyCaptureLost()
2863 // don't do anything if capture lost was expected, i.e. resulted from
2864 // a wx call to ReleaseMouse or CaptureMouse:
2865 if ( ms_winCaptureChanging
)
2868 // if the capture was lost unexpectedly, notify every window that has
2869 // capture (on stack or current) about it and clear the stack:
2871 if ( ms_winCaptureCurrent
)
2873 DoNotifyWindowAboutCaptureLost(ms_winCaptureCurrent
);
2874 ms_winCaptureCurrent
= NULL
;
2877 while ( ms_winCaptureNext
)
2879 wxWindowNext
*item
= ms_winCaptureNext
;
2880 ms_winCaptureNext
= item
->next
;
2882 DoNotifyWindowAboutCaptureLost(item
->win
);
2891 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2892 int WXUNUSED(modifiers
),
2893 int WXUNUSED(keycode
))
2899 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2905 #endif // wxUSE_HOTKEY
2907 // ----------------------------------------------------------------------------
2909 // ----------------------------------------------------------------------------
2911 bool wxWindowBase::TryBefore(wxEvent
& event
)
2913 #if wxUSE_VALIDATORS
2914 // Can only use the validator of the window which
2915 // is receiving the event
2916 if ( event
.GetEventObject() == this )
2918 wxValidator
* const validator
= GetValidator();
2919 if ( validator
&& validator
->ProcessEventHere(event
) )
2924 #endif // wxUSE_VALIDATORS
2926 return wxEvtHandler::TryBefore(event
);
2929 bool wxWindowBase::TryAfter(wxEvent
& event
)
2931 // carry on up the parent-child hierarchy if the propagation count hasn't
2933 if ( event
.ShouldPropagate() )
2935 // honour the requests to stop propagation at this window: this is
2936 // used by the dialogs, for example, to prevent processing the events
2937 // from the dialog controls in the parent frame which rarely, if ever,
2939 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2941 wxWindow
*parent
= GetParent();
2942 if ( parent
&& !parent
->IsBeingDeleted() )
2944 wxPropagateOnce
propagateOnce(event
);
2946 return parent
->GetEventHandler()->ProcessEvent(event
);
2951 return wxEvtHandler::TryAfter(event
);
2954 // ----------------------------------------------------------------------------
2955 // window relationships
2956 // ----------------------------------------------------------------------------
2958 wxWindow
*wxWindowBase::DoGetSibling(WindowOrder order
) const
2960 wxCHECK_MSG( GetParent(), NULL
,
2961 wxT("GetPrev/NextSibling() don't work for TLWs!") );
2963 wxWindowList
& siblings
= GetParent()->GetChildren();
2964 wxWindowList::compatibility_iterator i
= siblings
.Find((wxWindow
*)this);
2965 wxCHECK_MSG( i
, NULL
, wxT("window not a child of its parent?") );
2967 if ( order
== OrderBefore
)
2968 i
= i
->GetPrevious();
2972 return i
? i
->GetData() : NULL
;
2975 // ----------------------------------------------------------------------------
2976 // keyboard navigation
2977 // ----------------------------------------------------------------------------
2979 // Navigates in the specified direction inside this window
2980 bool wxWindowBase::DoNavigateIn(int flags
)
2982 #ifdef wxHAS_NATIVE_TAB_TRAVERSAL
2983 // native code doesn't process our wxNavigationKeyEvents anyhow
2986 #else // !wxHAS_NATIVE_TAB_TRAVERSAL
2987 wxNavigationKeyEvent eventNav
;
2988 wxWindow
*focused
= FindFocus();
2989 eventNav
.SetCurrentFocus(focused
);
2990 eventNav
.SetEventObject(focused
);
2991 eventNav
.SetFlags(flags
);
2992 return GetEventHandler()->ProcessEvent(eventNav
);
2993 #endif // wxHAS_NATIVE_TAB_TRAVERSAL/!wxHAS_NATIVE_TAB_TRAVERSAL
2996 bool wxWindowBase::HandleAsNavigationKey(const wxKeyEvent
& event
)
2998 if ( event
.GetKeyCode() != WXK_TAB
)
3001 int flags
= wxNavigationKeyEvent::FromTab
;
3003 if ( event
.ShiftDown() )
3004 flags
|= wxNavigationKeyEvent::IsBackward
;
3006 flags
|= wxNavigationKeyEvent::IsForward
;
3008 if ( event
.ControlDown() )
3009 flags
|= wxNavigationKeyEvent::WinChange
;
3015 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, WindowOrder move
)
3017 // check that we're not a top level window
3018 wxCHECK_RET( GetParent(),
3019 wxT("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
3021 // detect the special case when we have nothing to do anyhow and when the
3022 // code below wouldn't work
3026 // find the target window in the siblings list
3027 wxWindowList
& siblings
= GetParent()->GetChildren();
3028 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
3029 wxCHECK_RET( i
, wxT("MoveBefore/AfterInTabOrder(): win is not a sibling") );
3031 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
3032 // can't just move the node around
3033 wxWindow
*self
= (wxWindow
*)this;
3034 siblings
.DeleteObject(self
);
3035 if ( move
== OrderAfter
)
3042 siblings
.Insert(i
, self
);
3044 else // OrderAfter and win was the last sibling
3046 siblings
.Append(self
);
3050 // ----------------------------------------------------------------------------
3052 // ----------------------------------------------------------------------------
3054 /*static*/ wxWindow
* wxWindowBase::FindFocus()
3056 wxWindowBase
*win
= DoFindFocus();
3057 return win
? win
->GetMainWindowOfCompositeControl() : NULL
;
3060 bool wxWindowBase::HasFocus() const
3062 wxWindowBase
*win
= DoFindFocus();
3063 return win
== this ||
3064 win
== wxConstCast(this, wxWindowBase
)->GetMainWindowOfCompositeControl();
3067 // ----------------------------------------------------------------------------
3069 // ----------------------------------------------------------------------------
3071 #if wxUSE_DRAG_AND_DROP && !defined(__WXMSW__)
3076 class DragAcceptFilesTarget
: public wxFileDropTarget
3079 DragAcceptFilesTarget(wxWindowBase
*win
) : m_win(win
) {}
3081 virtual bool OnDropFiles(wxCoord x
, wxCoord y
,
3082 const wxArrayString
& filenames
)
3084 wxDropFilesEvent
event(wxEVT_DROP_FILES
,
3086 wxCArrayString(filenames
).Release());
3087 event
.SetEventObject(m_win
);
3091 return m_win
->HandleWindowEvent(event
);
3095 wxWindowBase
* const m_win
;
3097 wxDECLARE_NO_COPY_CLASS(DragAcceptFilesTarget
);
3101 } // anonymous namespace
3103 // Generic version of DragAcceptFiles(). It works by installing a simple
3104 // wxFileDropTarget-to-EVT_DROP_FILES adaptor and therefore cannot be used
3105 // together with explicit SetDropTarget() calls.
3106 void wxWindowBase::DragAcceptFiles(bool accept
)
3110 wxASSERT_MSG( !GetDropTarget(),
3111 "cannot use DragAcceptFiles() and SetDropTarget() together" );
3112 SetDropTarget(new DragAcceptFilesTarget(this));
3116 SetDropTarget(NULL
);
3120 #endif // wxUSE_DRAG_AND_DROP && !defined(__WXMSW__)
3122 // ----------------------------------------------------------------------------
3124 // ----------------------------------------------------------------------------
3126 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
3128 while ( win
&& !win
->IsTopLevel() )
3129 win
= win
->GetParent();
3134 #if wxUSE_ACCESSIBILITY
3135 // ----------------------------------------------------------------------------
3136 // accessible object for windows
3137 // ----------------------------------------------------------------------------
3139 // Can return either a child object, or an integer
3140 // representing the child element, starting from 1.
3141 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
3143 wxASSERT( GetWindow() != NULL
);
3147 return wxACC_NOT_IMPLEMENTED
;
3150 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
3151 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
3153 wxASSERT( GetWindow() != NULL
);
3157 wxWindow
* win
= NULL
;
3164 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
3166 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
3173 rect
= win
->GetRect();
3174 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
3175 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
3179 return wxACC_NOT_IMPLEMENTED
;
3182 // Navigates from fromId to toId/toObject.
3183 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
3184 int* WXUNUSED(toId
), wxAccessible
** toObject
)
3186 wxASSERT( GetWindow() != NULL
);
3192 case wxNAVDIR_FIRSTCHILD
:
3194 if (GetWindow()->GetChildren().GetCount() == 0)
3196 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
3197 *toObject
= childWindow
->GetOrCreateAccessible();
3201 case wxNAVDIR_LASTCHILD
:
3203 if (GetWindow()->GetChildren().GetCount() == 0)
3205 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
3206 *toObject
= childWindow
->GetOrCreateAccessible();
3210 case wxNAVDIR_RIGHT
:
3214 wxWindowList::compatibility_iterator node
=
3215 wxWindowList::compatibility_iterator();
3218 // Can't navigate to sibling of this window
3219 // if we're a top-level window.
3220 if (!GetWindow()->GetParent())
3221 return wxACC_NOT_IMPLEMENTED
;
3223 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
3227 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
3228 node
= GetWindow()->GetChildren().Item(fromId
-1);
3231 if (node
&& node
->GetNext())
3233 wxWindow
* nextWindow
= node
->GetNext()->GetData();
3234 *toObject
= nextWindow
->GetOrCreateAccessible();
3242 case wxNAVDIR_PREVIOUS
:
3244 wxWindowList::compatibility_iterator node
=
3245 wxWindowList::compatibility_iterator();
3248 // Can't navigate to sibling of this window
3249 // if we're a top-level window.
3250 if (!GetWindow()->GetParent())
3251 return wxACC_NOT_IMPLEMENTED
;
3253 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
3257 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
3258 node
= GetWindow()->GetChildren().Item(fromId
-1);
3261 if (node
&& node
->GetPrevious())
3263 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
3264 *toObject
= previousWindow
->GetOrCreateAccessible();
3272 return wxACC_NOT_IMPLEMENTED
;
3275 // Gets the name of the specified object.
3276 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
3278 wxASSERT( GetWindow() != NULL
);
3284 // If a child, leave wxWidgets to call the function on the actual
3287 return wxACC_NOT_IMPLEMENTED
;
3289 // This will eventually be replaced by specialised
3290 // accessible classes, one for each kind of wxWidgets
3291 // control or window.
3293 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
3294 title
= ((wxButton
*) GetWindow())->GetLabel();
3297 title
= GetWindow()->GetName();
3305 return wxACC_NOT_IMPLEMENTED
;
3308 // Gets the number of children.
3309 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
3311 wxASSERT( GetWindow() != NULL
);
3315 *childId
= (int) GetWindow()->GetChildren().GetCount();
3319 // Gets the specified child (starting from 1).
3320 // If *child is NULL and return value is wxACC_OK,
3321 // this means that the child is a simple element and
3322 // not an accessible object.
3323 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
3325 wxASSERT( GetWindow() != NULL
);
3335 if (childId
> (int) GetWindow()->GetChildren().GetCount())
3338 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
3339 *child
= childWindow
->GetOrCreateAccessible();
3346 // Gets the parent, or NULL.
3347 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
3349 wxASSERT( GetWindow() != NULL
);
3353 wxWindow
* parentWindow
= GetWindow()->GetParent();
3361 *parent
= parentWindow
->GetOrCreateAccessible();
3369 // Performs the default action. childId is 0 (the action for this object)
3370 // or > 0 (the action for a child).
3371 // Return wxACC_NOT_SUPPORTED if there is no default action for this
3372 // window (e.g. an edit control).
3373 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
3375 wxASSERT( GetWindow() != NULL
);
3379 return wxACC_NOT_IMPLEMENTED
;
3382 // Gets the default action for this object (0) or > 0 (the action for a child).
3383 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
3384 // string if there is no action.
3385 // The retrieved string describes the action that is performed on an object,
3386 // not what the object does as a result. For example, a toolbar button that prints
3387 // a document has a default action of "Press" rather than "Prints the current document."
3388 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
3390 wxASSERT( GetWindow() != NULL
);
3394 return wxACC_NOT_IMPLEMENTED
;
3397 // Returns the description for this object or a child.
3398 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
3400 wxASSERT( GetWindow() != NULL
);
3404 wxString
ht(GetWindow()->GetHelpTextAtPoint(wxDefaultPosition
, wxHelpEvent::Origin_Keyboard
));
3410 return wxACC_NOT_IMPLEMENTED
;
3413 // Returns help text for this object or a child, similar to tooltip text.
3414 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
3416 wxASSERT( GetWindow() != NULL
);
3420 wxString
ht(GetWindow()->GetHelpTextAtPoint(wxDefaultPosition
, wxHelpEvent::Origin_Keyboard
));
3426 return wxACC_NOT_IMPLEMENTED
;
3429 // Returns the keyboard shortcut for this object or child.
3430 // Return e.g. ALT+K
3431 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
3433 wxASSERT( GetWindow() != NULL
);
3437 return wxACC_NOT_IMPLEMENTED
;
3440 // Returns a role constant.
3441 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
3443 wxASSERT( GetWindow() != NULL
);
3447 // If a child, leave wxWidgets to call the function on the actual
3450 return wxACC_NOT_IMPLEMENTED
;
3452 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
3453 return wxACC_NOT_IMPLEMENTED
;
3455 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
3456 return wxACC_NOT_IMPLEMENTED
;
3459 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
3460 return wxACC_NOT_IMPLEMENTED
;
3463 //*role = wxROLE_SYSTEM_CLIENT;
3464 *role
= wxROLE_SYSTEM_CLIENT
;
3468 return wxACC_NOT_IMPLEMENTED
;
3472 // Returns a state constant.
3473 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
3475 wxASSERT( GetWindow() != NULL
);
3479 // If a child, leave wxWidgets to call the function on the actual
3482 return wxACC_NOT_IMPLEMENTED
;
3484 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
3485 return wxACC_NOT_IMPLEMENTED
;
3488 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
3489 return wxACC_NOT_IMPLEMENTED
;
3492 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
3493 return wxACC_NOT_IMPLEMENTED
;
3500 return wxACC_NOT_IMPLEMENTED
;
3504 // Returns a localized string representing the value for the object
3506 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
3508 wxASSERT( GetWindow() != NULL
);
3512 return wxACC_NOT_IMPLEMENTED
;
3515 // Selects the object or child.
3516 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
3518 wxASSERT( GetWindow() != NULL
);
3522 return wxACC_NOT_IMPLEMENTED
;
3525 // Gets the window with the keyboard focus.
3526 // If childId is 0 and child is NULL, no object in
3527 // this subhierarchy has the focus.
3528 // If this object has the focus, child should be 'this'.
3529 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
3531 wxASSERT( GetWindow() != NULL
);
3535 return wxACC_NOT_IMPLEMENTED
;
3539 // Gets a variant representing the selected children
3541 // Acceptable values:
3542 // - a null variant (IsNull() returns true)
3543 // - a list variant (GetType() == wxT("list")
3544 // - an integer representing the selected child element,
3545 // or 0 if this object is selected (GetType() == wxT("long")
3546 // - a "void*" pointer to a wxAccessible child object
3547 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
3549 wxASSERT( GetWindow() != NULL
);
3553 return wxACC_NOT_IMPLEMENTED
;
3555 #endif // wxUSE_VARIANT
3557 #endif // wxUSE_ACCESSIBILITY
3559 // ----------------------------------------------------------------------------
3561 // ----------------------------------------------------------------------------
3564 wxWindowBase::AdjustForLayoutDirection(wxCoord x
,
3566 wxCoord widthTotal
) const
3568 if ( GetLayoutDirection() == wxLayout_RightToLeft
)
3570 x
= widthTotal
- x
- width
;