1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "windowbase.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
32 #include "wx/string.h"
37 #include "wx/window.h"
38 #include "wx/control.h"
39 #include "wx/checkbox.h"
40 #include "wx/radiobut.h"
41 #include "wx/statbox.h"
42 #include "wx/textctrl.h"
43 #include "wx/settings.h"
44 #include "wx/dialog.h"
45 #include "wx/msgdlg.h"
46 #include "wx/statusbr.h"
47 #include "wx/dcclient.h"
50 #if defined(__WXMAC__) && wxUSE_SCROLLBAR
51 #include "wx/scrolbar.h"
55 #include "wx/layout.h"
56 #endif // wxUSE_CONSTRAINTS
60 #if wxUSE_DRAG_AND_DROP
62 #endif // wxUSE_DRAG_AND_DROP
64 #if wxUSE_ACCESSIBILITY
65 #include "wx/access.h"
69 #include "wx/cshelp.h"
73 #include "wx/tooltip.h"
74 #endif // wxUSE_TOOLTIPS
80 // ----------------------------------------------------------------------------
82 // ----------------------------------------------------------------------------
85 int wxWindowBase::ms_lastControlId
= 2000;
87 int wxWindowBase::ms_lastControlId
= -200;
90 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase
, wxEvtHandler
)
92 // ----------------------------------------------------------------------------
94 // ----------------------------------------------------------------------------
96 BEGIN_EVENT_TABLE(wxWindowBase
, wxEvtHandler
)
97 EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged
)
98 EVT_INIT_DIALOG(wxWindowBase::OnInitDialog
)
99 EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick
)
102 EVT_HELP(wxID_ANY
, wxWindowBase::OnHelp
)
107 // ============================================================================
108 // implementation of the common functionality of the wxWindow class
109 // ============================================================================
111 // ----------------------------------------------------------------------------
113 // ----------------------------------------------------------------------------
115 // the default initialization
116 wxWindowBase::wxWindowBase()
118 // no window yet, no parent nor children
119 m_parent
= (wxWindow
*)NULL
;
120 m_windowId
= wxID_ANY
;
122 // no constraints on the minimal window size
124 m_maxWidth
= wxDefaultCoord
;
126 m_maxHeight
= wxDefaultCoord
;
128 // invalidiated cache value
129 m_bestSizeCache
= wxDefaultSize
;
131 // window are created enabled and visible by default
135 // the default event handler is just this window
136 m_eventHandler
= this;
140 m_windowValidator
= (wxValidator
*) NULL
;
141 #endif // wxUSE_VALIDATORS
143 // the colours/fonts are default for now, so leave m_font,
144 // m_backgroundColour and m_foregroundColour uninitialized and set those
150 m_inheritFont
= false;
156 m_backgroundStyle
= wxBG_STYLE_SYSTEM
;
158 #if wxUSE_CONSTRAINTS
159 // no constraints whatsoever
160 m_constraints
= (wxLayoutConstraints
*) NULL
;
161 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
162 #endif // wxUSE_CONSTRAINTS
164 m_windowSizer
= (wxSizer
*) NULL
;
165 m_containingSizer
= (wxSizer
*) NULL
;
166 m_autoLayout
= false;
168 #if wxUSE_DRAG_AND_DROP
169 m_dropTarget
= (wxDropTarget
*)NULL
;
170 #endif // wxUSE_DRAG_AND_DROP
173 m_tooltip
= (wxToolTip
*)NULL
;
174 #endif // wxUSE_TOOLTIPS
177 m_caret
= (wxCaret
*)NULL
;
178 #endif // wxUSE_CARET
181 m_hasCustomPalette
= false;
182 #endif // wxUSE_PALETTE
184 #if wxUSE_ACCESSIBILITY
188 m_virtualSize
= wxDefaultSize
;
191 m_maxVirtualWidth
= wxDefaultCoord
;
193 m_maxVirtualHeight
= wxDefaultCoord
;
195 m_windowVariant
= wxWINDOW_VARIANT_NORMAL
;
197 // Whether we're using the current theme for this window (wxGTK only for now)
198 m_themeEnabled
= false;
200 // VZ: this one shouldn't exist...
201 m_isBeingDeleted
= false;
204 // common part of window creation process
205 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
207 const wxPoint
& WXUNUSED(pos
),
208 const wxSize
& WXUNUSED(size
),
210 const wxValidator
& wxVALIDATOR_PARAM(validator
),
211 const wxString
& name
)
214 // wxGTK doesn't allow to create controls with static box as the parent so
215 // this will result in a crash when the program is ported to wxGTK so warn
218 // if you get this assert, the correct solution is to create the controls
219 // as siblings of the static box
220 wxASSERT_MSG( !parent
|| !wxDynamicCast(parent
, wxStaticBox
),
221 _T("wxStaticBox can't be used as a window parent!") );
222 #endif // wxUSE_STATBOX
224 // ids are limited to 16 bits under MSW so if you care about portability,
225 // it's not a good idea to use ids out of this range (and negative ids are
226 // reserved for wxWidgets own usage)
227 wxASSERT_MSG( id
== wxID_ANY
|| (id
>= 0 && id
< 32767),
228 _T("invalid id value") );
230 // generate a new id if the user doesn't care about it
231 m_windowId
= id
== wxID_ANY
? NewControlId() : id
;
234 SetWindowStyleFlag(style
);
238 SetValidator(validator
);
239 #endif // wxUSE_VALIDATORS
241 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
242 // have it too - like this it's possible to set it only in the top level
243 // dialog/frame and all children will inherit it by defult
244 if ( parent
&& (parent
->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) )
246 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY
);
252 // ----------------------------------------------------------------------------
254 // ----------------------------------------------------------------------------
257 wxWindowBase::~wxWindowBase()
259 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
261 // FIXME if these 2 cases result from programming errors in the user code
262 // we should probably assert here instead of silently fixing them
264 // Just in case the window has been Closed, but we're then deleting
265 // immediately: don't leave dangling pointers.
266 wxPendingDelete
.DeleteObject(this);
268 // Just in case we've loaded a top-level window via LoadNativeDialog but
269 // we weren't a dialog class
270 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
272 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
274 // reset the dangling pointer our parent window may keep to us
277 if ( m_parent
->GetDefaultItem() == this )
279 m_parent
->SetDefaultItem(NULL
);
282 m_parent
->RemoveChild(this);
287 #endif // wxUSE_CARET
290 delete m_windowValidator
;
291 #endif // wxUSE_VALIDATORS
293 #if wxUSE_CONSTRAINTS
294 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
295 // at deleted windows as they delete themselves.
296 DeleteRelatedConstraints();
300 // This removes any dangling pointers to this window in other windows'
301 // constraintsInvolvedIn lists.
302 UnsetConstraints(m_constraints
);
303 delete m_constraints
;
304 m_constraints
= NULL
;
306 #endif // wxUSE_CONSTRAINTS
308 if ( m_containingSizer
)
309 m_containingSizer
->Detach( (wxWindow
*)this );
311 delete m_windowSizer
;
313 #if wxUSE_DRAG_AND_DROP
315 #endif // wxUSE_DRAG_AND_DROP
319 #endif // wxUSE_TOOLTIPS
321 #if wxUSE_ACCESSIBILITY
326 bool wxWindowBase::Destroy()
333 bool wxWindowBase::Close(bool force
)
335 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
336 event
.SetEventObject(this);
337 event
.SetCanVeto(!force
);
339 // return false if window wasn't closed because the application vetoed the
341 return GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto();
344 bool wxWindowBase::DestroyChildren()
346 wxWindowList::compatibility_iterator node
;
349 // we iterate until the list becomes empty
350 node
= GetChildren().GetFirst();
354 wxWindow
*child
= node
->GetData();
356 // note that we really want to call delete and not ->Destroy() here
357 // because we want to delete the child immediately, before we are
358 // deleted, and delayed deletion would result in problems as our (top
359 // level) child could outlive its parent
362 wxASSERT_MSG( !GetChildren().Find(child
),
363 wxT("child didn't remove itself using RemoveChild()") );
369 // ----------------------------------------------------------------------------
370 // size/position related methods
371 // ----------------------------------------------------------------------------
373 // centre the window with respect to its parent in either (or both) directions
374 void wxWindowBase::Centre(int direction
)
376 // the position/size of the parent window or of the entire screen
378 int widthParent
, heightParent
;
380 wxWindow
*parent
= NULL
;
382 if ( !(direction
& wxCENTRE_ON_SCREEN
) )
384 // find the parent to centre this window on: it should be the
385 // immediate parent for the controls but the top level parent for the
386 // top level windows (like dialogs)
387 parent
= GetParent();
390 while ( parent
&& !parent
->IsTopLevel() )
392 parent
= parent
->GetParent();
396 // there is no wxTopLevelWindow under wxMotif yet
398 // we shouldn't center the dialog on the iconized window: under
399 // Windows, for example, this places it completely off the screen
402 wxTopLevelWindow
*winTop
= wxDynamicCast(parent
, wxTopLevelWindow
);
403 if ( winTop
&& winTop
->IsIconized() )
408 #endif // __WXMOTIF__
410 // did we find the parent?
414 direction
|= wxCENTRE_ON_SCREEN
;
418 if ( direction
& wxCENTRE_ON_SCREEN
)
420 // centre with respect to the whole screen
421 wxDisplaySize(&widthParent
, &heightParent
);
427 // centre on the parent
428 parent
->GetSize(&widthParent
, &heightParent
);
430 // adjust to the parents position
431 posParent
= parent
->GetPosition();
435 // centre inside the parents client rectangle
436 parent
->GetClientSize(&widthParent
, &heightParent
);
441 GetSize(&width
, &height
);
443 int xNew
= wxDefaultCoord
,
444 yNew
= wxDefaultCoord
;
446 if ( direction
& wxHORIZONTAL
)
447 xNew
= (widthParent
- width
)/2;
449 if ( direction
& wxVERTICAL
)
450 yNew
= (heightParent
- height
)/2;
455 // Base size of the visible dimensions of the display
456 // to take into account the taskbar. And the Mac menu bar at top.
457 wxRect clientrect
= wxGetClientDisplayRect();
459 // NB: in wxMSW, negative position may not neccessary mean "out of screen",
460 // but it may mean that the window is placed on other than the main
461 // display. Therefore we only make sure centered window is on the main display
462 // if the parent is at least partially present here.
463 if (posParent
.x
+ widthParent
>= 0) // if parent is (partially) on the main display
465 if (xNew
< clientrect
.GetLeft())
466 xNew
= clientrect
.GetLeft();
467 else if (xNew
+ width
> clientrect
.GetRight())
468 xNew
= clientrect
.GetRight() - width
;
470 if (posParent
.y
+ heightParent
>= 0) // if parent is (partially) on the main display
472 if (yNew
+ height
> clientrect
.GetBottom())
473 yNew
= clientrect
.GetBottom() - height
;
475 // Make certain that the title bar is initially visible
476 // always, even if this would push the bottom of the
477 // dialog off the visible area of the display
478 if (yNew
< clientrect
.GetTop())
479 yNew
= clientrect
.GetTop();
482 // move the window to this position (keeping the old size but using
483 // SetSize() and not Move() to allow xNew and/or yNew to be -1)
484 SetSize(xNew
, yNew
, width
, height
, wxSIZE_ALLOW_MINUS_ONE
);
487 // fits the window around the children
488 void wxWindowBase::Fit()
490 if ( GetChildren().GetCount() > 0 )
492 SetClientSize(GetBestSize());
494 //else: do nothing if we have no children
497 // fits virtual size (ie. scrolled area etc.) around children
498 void wxWindowBase::FitInside()
500 if ( GetChildren().GetCount() > 0 )
502 SetVirtualSize( GetBestVirtualSize() );
506 // On Mac, scrollbars are explicitly children.
508 static bool wxHasRealChildren(const wxWindowBase
* win
)
510 int realChildCount
= 0;
512 for ( wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
514 node
= node
->GetNext() )
516 wxWindow
*win
= node
->GetData();
517 if ( !win
->IsTopLevel() && win
->IsShown() && !win
->IsKindOf(CLASSINFO(wxScrollBar
)))
520 return (realChildCount
> 0);
524 // return the size best suited for the current window
525 wxSize
wxWindowBase::DoGetBestSize() const
529 return 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 return wxSize(maxX
, maxY
);
567 #endif // wxUSE_CONSTRAINTS
568 else if ( !GetChildren().empty()
570 && wxHasRealChildren(this)
574 // our minimal acceptable size is such that all our visible child windows fit inside
578 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
580 node
= node
->GetNext() )
582 wxWindow
*win
= node
->GetData();
583 if ( win
->IsTopLevel() || ( ! win
->IsShown() )
585 || wxDynamicCast(win
, wxStatusBar
)
586 #endif // wxUSE_STATUSBAR
589 // dialogs and frames lie in different top level windows -
590 // don't deal with them here; as for the status bars, they
591 // don't lie in the client area at all
596 win
->GetPosition(&wx
, &wy
);
598 // if the window hadn't been positioned yet, assume that it is in
600 if ( wx
== wxDefaultCoord
)
602 if ( wy
== wxDefaultCoord
)
605 win
->GetSize(&ww
, &wh
);
606 if ( wx
+ ww
> maxX
)
608 if ( wy
+ wh
> maxY
)
612 // for compatibility with the old versions and because it really looks
613 // slightly more pretty like this, add a pad
617 return wxSize(maxX
, maxY
);
619 else // ! has children
621 // for a generic window there is no natural best size - just use either the
622 // minimum size if there is one, or the current size
623 if ( GetMinSize().IsFullySpecified() )
631 wxSize
wxWindowBase::GetBestFittingSize() const
633 // merge the best size with the min size, giving priority to the min size
634 wxSize min
= GetMinSize();
635 if (min
.x
== wxDefaultCoord
|| min
.y
== wxDefaultCoord
)
637 wxSize best
= GetBestSize();
638 if (min
.x
== wxDefaultCoord
) min
.x
= best
.x
;
639 if (min
.y
== wxDefaultCoord
) min
.y
= best
.y
;
645 void wxWindowBase::SetBestFittingSize(const wxSize
& size
)
647 // Set the min size to the size passed in. This will usually either be
648 // wxDefaultSize or the size passed to this window's ctor/Create function.
651 // Merge the size with the best size if needed
652 wxSize best
= GetBestFittingSize();
654 // If the current size doesn't match then change it
655 if (GetSize() != best
)
660 // by default the origin is not shifted
661 wxPoint
wxWindowBase::GetClientAreaOrigin() const
663 return wxPoint(0, 0);
666 // set the min/max size of the window
667 void wxWindowBase::SetSizeHints(int minW
, int minH
,
669 int WXUNUSED(incW
), int WXUNUSED(incH
))
671 // setting min width greater than max width leads to infinite loops under
672 // X11 and generally doesn't make any sense, so don't allow it
673 wxCHECK_RET( (minW
== wxDefaultCoord
|| maxW
== wxDefaultCoord
|| minW
<= maxW
) &&
674 (minH
== wxDefaultCoord
|| maxH
== wxDefaultCoord
|| minH
<= maxH
),
675 _T("min width/height must be less than max width/height!") );
683 void wxWindowBase::SetWindowVariant( wxWindowVariant variant
)
685 if ( m_windowVariant
!= variant
)
687 m_windowVariant
= variant
;
689 DoSetWindowVariant(variant
);
693 void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant
)
695 // adjust the font height to correspond to our new variant (notice that
696 // we're only called if something really changed)
697 wxFont font
= GetFont();
698 int size
= font
.GetPointSize();
701 case wxWINDOW_VARIANT_NORMAL
:
704 case wxWINDOW_VARIANT_SMALL
:
709 case wxWINDOW_VARIANT_MINI
:
714 case wxWINDOW_VARIANT_LARGE
:
720 wxFAIL_MSG(_T("unexpected window variant"));
724 font
.SetPointSize(size
);
728 void wxWindowBase::SetVirtualSizeHints( int minW
, int minH
,
731 m_minVirtualWidth
= minW
;
732 m_maxVirtualWidth
= maxW
;
733 m_minVirtualHeight
= minH
;
734 m_maxVirtualHeight
= maxH
;
737 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
739 if ( m_minVirtualWidth
!= wxDefaultCoord
&& m_minVirtualWidth
> x
)
740 x
= m_minVirtualWidth
;
741 if ( m_maxVirtualWidth
!= wxDefaultCoord
&& m_maxVirtualWidth
< x
)
742 x
= m_maxVirtualWidth
;
743 if ( m_minVirtualHeight
!= wxDefaultCoord
&& m_minVirtualHeight
> y
)
744 y
= m_minVirtualHeight
;
745 if ( m_maxVirtualHeight
!= wxDefaultCoord
&& m_maxVirtualHeight
< y
)
746 y
= m_maxVirtualHeight
;
748 m_virtualSize
= wxSize(x
, y
);
751 wxSize
wxWindowBase::DoGetVirtualSize() const
753 wxSize
s( GetClientSize() );
755 return wxSize( wxMax( m_virtualSize
.GetWidth(), s
.GetWidth() ),
756 wxMax( m_virtualSize
.GetHeight(), s
.GetHeight() ) );
759 // ----------------------------------------------------------------------------
760 // show/hide/enable/disable the window
761 // ----------------------------------------------------------------------------
763 bool wxWindowBase::Show(bool show
)
765 if ( show
!= m_isShown
)
777 bool wxWindowBase::Enable(bool enable
)
779 if ( enable
!= m_isEnabled
)
781 m_isEnabled
= enable
;
790 // ----------------------------------------------------------------------------
792 // ----------------------------------------------------------------------------
794 bool wxWindowBase::IsTopLevel() const
799 // ----------------------------------------------------------------------------
800 // reparenting the window
801 // ----------------------------------------------------------------------------
803 void wxWindowBase::AddChild(wxWindowBase
*child
)
805 wxCHECK_RET( child
, wxT("can't add a NULL child") );
807 // this should never happen and it will lead to a crash later if it does
808 // because RemoveChild() will remove only one node from the children list
809 // and the other(s) one(s) will be left with dangling pointers in them
810 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), _T("AddChild() called twice") );
812 GetChildren().Append((wxWindow
*)child
);
813 child
->SetParent(this);
816 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
818 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
820 GetChildren().DeleteObject((wxWindow
*)child
);
821 child
->SetParent(NULL
);
824 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
826 wxWindow
*oldParent
= GetParent();
827 if ( newParent
== oldParent
)
833 // unlink this window from the existing parent.
836 oldParent
->RemoveChild(this);
840 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
843 // add it to the new one
846 newParent
->AddChild(this);
850 wxTopLevelWindows
.Append((wxWindow
*)this);
856 // ----------------------------------------------------------------------------
857 // event handler stuff
858 // ----------------------------------------------------------------------------
860 void wxWindowBase::PushEventHandler(wxEvtHandler
*handler
)
862 wxEvtHandler
*handlerOld
= GetEventHandler();
864 handler
->SetNextHandler(handlerOld
);
867 GetEventHandler()->SetPreviousHandler(handler
);
869 SetEventHandler(handler
);
872 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
874 wxEvtHandler
*handlerA
= GetEventHandler();
877 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
878 handlerA
->SetNextHandler((wxEvtHandler
*)NULL
);
881 handlerB
->SetPreviousHandler((wxEvtHandler
*)NULL
);
882 SetEventHandler(handlerB
);
887 handlerA
= (wxEvtHandler
*)NULL
;
894 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handler
)
896 wxCHECK_MSG( handler
, false, _T("RemoveEventHandler(NULL) called") );
898 wxEvtHandler
*handlerPrev
= NULL
,
899 *handlerCur
= GetEventHandler();
902 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
904 if ( handlerCur
== handler
)
908 handlerPrev
->SetNextHandler(handlerNext
);
912 SetEventHandler(handlerNext
);
917 handlerNext
->SetPreviousHandler ( handlerPrev
);
920 handler
->SetNextHandler(NULL
);
921 handler
->SetPreviousHandler(NULL
);
926 handlerPrev
= handlerCur
;
927 handlerCur
= handlerNext
;
930 wxFAIL_MSG( _T("where has the event handler gone?") );
935 // ----------------------------------------------------------------------------
937 // ----------------------------------------------------------------------------
939 void wxWindowBase::InheritAttributes()
941 const wxWindowBase
* const parent
= GetParent();
945 // we only inherit attributes which had been explicitly set for the parent
946 // which ensures that this only happens if the user really wants it and
947 // not by default which wouldn't make any sense in modern GUIs where the
948 // controls don't all use the same fonts (nor colours)
949 if ( parent
->m_inheritFont
&& !m_hasFont
)
950 SetFont(parent
->GetFont());
952 // in addition, there is a possibility to explicitly forbid inheriting
953 // colours at each class level by overriding ShouldInheritColours()
954 if ( ShouldInheritColours() )
956 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
957 SetForegroundColour(parent
->GetForegroundColour());
959 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
960 SetBackgroundColour(parent
->GetBackgroundColour());
964 /* static */ wxVisualAttributes
965 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
967 // it is important to return valid values for all attributes from here,
968 // GetXXX() below rely on this
969 wxVisualAttributes attrs
;
970 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
971 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
972 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
977 wxColour
wxWindowBase::GetBackgroundColour() const
979 if ( !m_backgroundColour
.Ok() )
981 wxASSERT_MSG( !m_hasBgCol
, _T("we have invalid explicit bg colour?") );
983 // get our default background colour
984 wxColour colBg
= GetDefaultAttributes().colBg
;
986 // we must return some valid colour to avoid redoing this every time
987 // and also to avoid surprizing the applications written for older
988 // wxWidgets versions where GetBackgroundColour() always returned
989 // something -- so give them something even if it doesn't make sense
990 // for this window (e.g. it has a themed background)
992 colBg
= GetClassDefaultAttributes().colBg
;
997 return m_backgroundColour
;
1000 wxColour
wxWindowBase::GetForegroundColour() const
1002 // logic is the same as above
1003 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
1005 wxASSERT_MSG( !m_hasFgCol
, _T("we have invalid explicit fg colour?") );
1007 wxColour colFg
= GetDefaultAttributes().colFg
;
1010 colFg
= GetClassDefaultAttributes().colFg
;
1015 return m_foregroundColour
;
1018 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
1020 if ( colour
== m_backgroundColour
)
1023 m_hasBgCol
= colour
.Ok();
1024 m_inheritBgCol
= m_hasBgCol
;
1025 m_backgroundColour
= colour
;
1026 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1030 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1032 if (colour
== m_foregroundColour
)
1035 m_hasFgCol
= colour
.Ok();
1036 m_inheritFgCol
= m_hasFgCol
;
1037 m_foregroundColour
= colour
;
1038 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1042 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1044 // setting an invalid cursor is ok, it means that we don't have any special
1046 if ( m_cursor
== cursor
)
1057 wxFont
wxWindowBase::GetFont() const
1059 // logic is the same as in GetBackgroundColour()
1062 wxASSERT_MSG( !m_hasFont
, _T("we have invalid explicit font?") );
1064 wxFont font
= GetDefaultAttributes().font
;
1066 font
= GetClassDefaultAttributes().font
;
1074 bool wxWindowBase::SetFont(const wxFont
& font
)
1076 if ( font
== m_font
)
1083 m_hasFont
= font
.Ok();
1084 m_inheritFont
= m_hasFont
;
1086 InvalidateBestSize();
1093 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1095 m_hasCustomPalette
= true;
1098 // VZ: can anyone explain me what do we do here?
1099 wxWindowDC
d((wxWindow
*) this);
1103 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1105 wxWindow
*win
= (wxWindow
*)this;
1106 while ( win
&& !win
->HasCustomPalette() )
1108 win
= win
->GetParent();
1114 #endif // wxUSE_PALETTE
1117 void wxWindowBase::SetCaret(wxCaret
*caret
)
1128 wxASSERT_MSG( m_caret
->GetWindow() == this,
1129 wxT("caret should be created associated to this window") );
1132 #endif // wxUSE_CARET
1134 #if wxUSE_VALIDATORS
1135 // ----------------------------------------------------------------------------
1137 // ----------------------------------------------------------------------------
1139 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1141 if ( m_windowValidator
)
1142 delete m_windowValidator
;
1144 m_windowValidator
= (wxValidator
*)validator
.Clone();
1146 if ( m_windowValidator
)
1147 m_windowValidator
->SetWindow(this);
1149 #endif // wxUSE_VALIDATORS
1151 // ----------------------------------------------------------------------------
1152 // update region stuff
1153 // ----------------------------------------------------------------------------
1155 wxRect
wxWindowBase::GetUpdateClientRect() const
1157 wxRegion rgnUpdate
= GetUpdateRegion();
1158 rgnUpdate
.Intersect(GetClientRect());
1159 wxRect rectUpdate
= rgnUpdate
.GetBox();
1160 wxPoint ptOrigin
= GetClientAreaOrigin();
1161 rectUpdate
.x
-= ptOrigin
.x
;
1162 rectUpdate
.y
-= ptOrigin
.y
;
1167 bool wxWindowBase::IsExposed(int x
, int y
) const
1169 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1172 bool wxWindowBase::IsExposed(int x
, int y
, int w
, int h
) const
1174 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1177 void wxWindowBase::ClearBackground()
1179 // wxGTK uses its own version, no need to add never used code
1181 wxClientDC
dc((wxWindow
*)this);
1182 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1183 dc
.SetBackground(brush
);
1188 // ----------------------------------------------------------------------------
1189 // find child window by id or name
1190 // ----------------------------------------------------------------------------
1192 wxWindow
*wxWindowBase::FindWindow( long id
)
1194 if ( id
== m_windowId
)
1195 return (wxWindow
*)this;
1197 wxWindowBase
*res
= (wxWindow
*)NULL
;
1198 wxWindowList::compatibility_iterator node
;
1199 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1201 wxWindowBase
*child
= node
->GetData();
1202 res
= child
->FindWindow( id
);
1205 return (wxWindow
*)res
;
1208 wxWindow
*wxWindowBase::FindWindow( const wxString
& name
)
1210 if ( name
== m_windowName
)
1211 return (wxWindow
*)this;
1213 wxWindowBase
*res
= (wxWindow
*)NULL
;
1214 wxWindowList::compatibility_iterator node
;
1215 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1217 wxWindow
*child
= node
->GetData();
1218 res
= child
->FindWindow(name
);
1221 return (wxWindow
*)res
;
1225 // find any window by id or name or label: If parent is non-NULL, look through
1226 // children for a label or title matching the specified string. If NULL, look
1227 // through all top-level windows.
1229 // to avoid duplicating code we reuse the same helper function but with
1230 // different comparators
1232 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1233 const wxString
& label
, long id
);
1236 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1239 return win
->GetLabel() == label
;
1243 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1246 return win
->GetName() == label
;
1250 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1253 return win
->GetId() == id
;
1256 // recursive helper for the FindWindowByXXX() functions
1258 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1259 const wxString
& label
,
1261 wxFindWindowCmp cmp
)
1265 // see if this is the one we're looking for
1266 if ( (*cmp
)(parent
, label
, id
) )
1267 return (wxWindow
*)parent
;
1269 // It wasn't, so check all its children
1270 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1272 node
= node
->GetNext() )
1274 // recursively check each child
1275 wxWindow
*win
= (wxWindow
*)node
->GetData();
1276 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1286 // helper for FindWindowByXXX()
1288 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1289 const wxString
& label
,
1291 wxFindWindowCmp cmp
)
1295 // just check parent and all its children
1296 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1299 // start at very top of wx's windows
1300 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1302 node
= node
->GetNext() )
1304 // recursively check each window & its children
1305 wxWindow
*win
= node
->GetData();
1306 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1316 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1318 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1323 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1325 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1329 // fall back to the label
1330 win
= FindWindowByLabel(title
, parent
);
1338 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1340 return wxFindWindowHelper(parent
, _T(""), id
, wxFindWindowCmpIds
);
1343 // ----------------------------------------------------------------------------
1344 // dialog oriented functions
1345 // ----------------------------------------------------------------------------
1347 void wxWindowBase::MakeModal(bool modal
)
1349 // Disable all other windows
1352 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1355 wxWindow
*win
= node
->GetData();
1357 win
->Enable(!modal
);
1359 node
= node
->GetNext();
1364 bool wxWindowBase::Validate()
1366 #if wxUSE_VALIDATORS
1367 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1369 wxWindowList::compatibility_iterator node
;
1370 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1372 wxWindowBase
*child
= node
->GetData();
1373 wxValidator
*validator
= child
->GetValidator();
1374 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1379 if ( recurse
&& !child
->Validate() )
1384 #endif // wxUSE_VALIDATORS
1389 bool wxWindowBase::TransferDataToWindow()
1391 #if wxUSE_VALIDATORS
1392 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1394 wxWindowList::compatibility_iterator node
;
1395 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1397 wxWindowBase
*child
= node
->GetData();
1398 wxValidator
*validator
= child
->GetValidator();
1399 if ( validator
&& !validator
->TransferToWindow() )
1401 wxLogWarning(_("Could not transfer data to window"));
1403 wxLog::FlushActive();
1411 if ( !child
->TransferDataToWindow() )
1413 // warning already given
1418 #endif // wxUSE_VALIDATORS
1423 bool wxWindowBase::TransferDataFromWindow()
1425 #if wxUSE_VALIDATORS
1426 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1428 wxWindowList::compatibility_iterator node
;
1429 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1431 wxWindow
*child
= node
->GetData();
1432 wxValidator
*validator
= child
->GetValidator();
1433 if ( validator
&& !validator
->TransferFromWindow() )
1435 // nop warning here because the application is supposed to give
1436 // one itself - we don't know here what might have gone wrongly
1443 if ( !child
->TransferDataFromWindow() )
1445 // warning already given
1450 #endif // wxUSE_VALIDATORS
1455 void wxWindowBase::InitDialog()
1457 wxInitDialogEvent
event(GetId());
1458 event
.SetEventObject( this );
1459 GetEventHandler()->ProcessEvent(event
);
1462 // ----------------------------------------------------------------------------
1463 // context-sensitive help support
1464 // ----------------------------------------------------------------------------
1468 // associate this help text with this window
1469 void wxWindowBase::SetHelpText(const wxString
& text
)
1471 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1474 helpProvider
->AddHelp(this, text
);
1478 // associate this help text with all windows with the same id as this
1480 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1482 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1485 helpProvider
->AddHelp(GetId(), text
);
1489 // get the help string associated with this window (may be empty)
1490 wxString
wxWindowBase::GetHelpText() const
1493 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1496 text
= helpProvider
->GetHelp(this);
1502 // show help for this window
1503 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1505 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1508 if ( helpProvider
->ShowHelp(this) )
1510 // skip the event.Skip() below
1518 #endif // wxUSE_HELP
1520 // ----------------------------------------------------------------------------
1521 // tooltipsroot.Replace("\\", "/");
1522 // ----------------------------------------------------------------------------
1526 void wxWindowBase::SetToolTip( const wxString
&tip
)
1528 // don't create the new tooltip if we already have one
1531 m_tooltip
->SetTip( tip
);
1535 SetToolTip( new wxToolTip( tip
) );
1538 // setting empty tooltip text does not remove the tooltip any more - use
1539 // SetToolTip((wxToolTip *)NULL) for this
1542 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1547 m_tooltip
= tooltip
;
1550 #endif // wxUSE_TOOLTIPS
1552 // ----------------------------------------------------------------------------
1553 // constraints and sizers
1554 // ----------------------------------------------------------------------------
1556 #if wxUSE_CONSTRAINTS
1558 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1560 if ( m_constraints
)
1562 UnsetConstraints(m_constraints
);
1563 delete m_constraints
;
1565 m_constraints
= constraints
;
1566 if ( m_constraints
)
1568 // Make sure other windows know they're part of a 'meaningful relationship'
1569 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1570 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1571 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1572 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1573 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1574 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1575 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1576 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1577 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1578 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1579 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1580 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1581 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1582 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1583 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1584 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1588 // This removes any dangling pointers to this window in other windows'
1589 // constraintsInvolvedIn lists.
1590 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1594 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1595 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1596 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1597 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1598 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1599 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1600 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1601 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1602 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1603 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1604 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1605 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1606 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1607 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1608 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1609 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1613 // Back-pointer to other windows we're involved with, so if we delete this
1614 // window, we must delete any constraints we're involved with.
1615 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
1617 if ( !m_constraintsInvolvedIn
)
1618 m_constraintsInvolvedIn
= new wxWindowList
;
1619 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
1620 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
1623 // REMOVE back-pointer to other windows we're involved with.
1624 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
1626 if ( m_constraintsInvolvedIn
)
1627 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
1630 // Reset any constraints that mention this window
1631 void wxWindowBase::DeleteRelatedConstraints()
1633 if ( m_constraintsInvolvedIn
)
1635 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
1638 wxWindow
*win
= node
->GetData();
1639 wxLayoutConstraints
*constr
= win
->GetConstraints();
1641 // Reset any constraints involving this window
1644 constr
->left
.ResetIfWin(this);
1645 constr
->top
.ResetIfWin(this);
1646 constr
->right
.ResetIfWin(this);
1647 constr
->bottom
.ResetIfWin(this);
1648 constr
->width
.ResetIfWin(this);
1649 constr
->height
.ResetIfWin(this);
1650 constr
->centreX
.ResetIfWin(this);
1651 constr
->centreY
.ResetIfWin(this);
1654 wxWindowList::compatibility_iterator next
= node
->GetNext();
1655 m_constraintsInvolvedIn
->Erase(node
);
1659 delete m_constraintsInvolvedIn
;
1660 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
1664 #endif // wxUSE_CONSTRAINTS
1666 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
1668 if ( sizer
== m_windowSizer
)
1672 delete m_windowSizer
;
1674 m_windowSizer
= sizer
;
1676 SetAutoLayout( sizer
!= NULL
);
1679 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
1681 SetSizer( sizer
, deleteOld
);
1682 sizer
->SetSizeHints( (wxWindow
*) this );
1686 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
1688 // adding a window to a sizer twice is going to result in fatal and
1689 // hard to debug problems later because when deleting the second
1690 // associated wxSizerItem we're going to dereference a dangling
1691 // pointer; so try to detect this as early as possible
1692 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
1693 _T("Adding a window to the same sizer twice?") );
1695 m_containingSizer
= sizer
;
1698 #if wxUSE_CONSTRAINTS
1700 void wxWindowBase::SatisfyConstraints()
1702 wxLayoutConstraints
*constr
= GetConstraints();
1703 bool wasOk
= constr
&& constr
->AreSatisfied();
1705 ResetConstraints(); // Mark all constraints as unevaluated
1709 // if we're a top level panel (i.e. our parent is frame/dialog), our
1710 // own constraints will never be satisfied any more unless we do it
1714 while ( noChanges
> 0 )
1716 LayoutPhase1(&noChanges
);
1720 LayoutPhase2(&noChanges
);
1723 #endif // wxUSE_CONSTRAINTS
1725 bool wxWindowBase::Layout()
1727 // If there is a sizer, use it instead of the constraints
1731 GetVirtualSize(&w
, &h
);
1732 GetSizer()->SetDimension( 0, 0, w
, h
);
1734 #if wxUSE_CONSTRAINTS
1737 SatisfyConstraints(); // Find the right constraints values
1738 SetConstraintSizes(); // Recursively set the real window sizes
1745 #if wxUSE_CONSTRAINTS
1747 // first phase of the constraints evaluation: set our own constraints
1748 bool wxWindowBase::LayoutPhase1(int *noChanges
)
1750 wxLayoutConstraints
*constr
= GetConstraints();
1752 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
1755 // second phase: set the constraints for our children
1756 bool wxWindowBase::LayoutPhase2(int *noChanges
)
1763 // Layout grand children
1769 // Do a phase of evaluating child constraints
1770 bool wxWindowBase::DoPhase(int phase
)
1772 // the list containing the children for which the constraints are already
1774 wxWindowList succeeded
;
1776 // the max number of iterations we loop before concluding that we can't set
1778 static const int maxIterations
= 500;
1780 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
1784 // loop over all children setting their constraints
1785 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1787 node
= node
->GetNext() )
1789 wxWindow
*child
= node
->GetData();
1790 if ( child
->IsTopLevel() )
1792 // top level children are not inside our client area
1796 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
1798 // this one is either already ok or nothing we can do about it
1802 int tempNoChanges
= 0;
1803 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
1804 : child
->LayoutPhase2(&tempNoChanges
);
1805 noChanges
+= tempNoChanges
;
1809 succeeded
.Append(child
);
1815 // constraints are set
1823 void wxWindowBase::ResetConstraints()
1825 wxLayoutConstraints
*constr
= GetConstraints();
1828 constr
->left
.SetDone(false);
1829 constr
->top
.SetDone(false);
1830 constr
->right
.SetDone(false);
1831 constr
->bottom
.SetDone(false);
1832 constr
->width
.SetDone(false);
1833 constr
->height
.SetDone(false);
1834 constr
->centreX
.SetDone(false);
1835 constr
->centreY
.SetDone(false);
1838 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1841 wxWindow
*win
= node
->GetData();
1842 if ( !win
->IsTopLevel() )
1843 win
->ResetConstraints();
1844 node
= node
->GetNext();
1848 // Need to distinguish between setting the 'fake' size for windows and sizers,
1849 // and setting the real values.
1850 void wxWindowBase::SetConstraintSizes(bool recurse
)
1852 wxLayoutConstraints
*constr
= GetConstraints();
1853 if ( constr
&& constr
->AreSatisfied() )
1855 int x
= constr
->left
.GetValue();
1856 int y
= constr
->top
.GetValue();
1857 int w
= constr
->width
.GetValue();
1858 int h
= constr
->height
.GetValue();
1860 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
1861 (constr
->height
.GetRelationship() != wxAsIs
) )
1863 SetSize(x
, y
, w
, h
);
1867 // If we don't want to resize this window, just move it...
1873 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
1874 GetClassInfo()->GetClassName(),
1880 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1883 wxWindow
*win
= node
->GetData();
1884 if ( !win
->IsTopLevel() && win
->GetConstraints() )
1885 win
->SetConstraintSizes();
1886 node
= node
->GetNext();
1891 // Only set the size/position of the constraint (if any)
1892 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
1894 wxLayoutConstraints
*constr
= GetConstraints();
1897 if ( x
!= wxDefaultCoord
)
1899 constr
->left
.SetValue(x
);
1900 constr
->left
.SetDone(true);
1902 if ( y
!= wxDefaultCoord
)
1904 constr
->top
.SetValue(y
);
1905 constr
->top
.SetDone(true);
1907 if ( w
!= wxDefaultCoord
)
1909 constr
->width
.SetValue(w
);
1910 constr
->width
.SetDone(true);
1912 if ( h
!= wxDefaultCoord
)
1914 constr
->height
.SetValue(h
);
1915 constr
->height
.SetDone(true);
1920 void wxWindowBase::MoveConstraint(int x
, int y
)
1922 wxLayoutConstraints
*constr
= GetConstraints();
1925 if ( x
!= wxDefaultCoord
)
1927 constr
->left
.SetValue(x
);
1928 constr
->left
.SetDone(true);
1930 if ( y
!= wxDefaultCoord
)
1932 constr
->top
.SetValue(y
);
1933 constr
->top
.SetDone(true);
1938 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
1940 wxLayoutConstraints
*constr
= GetConstraints();
1943 *w
= constr
->width
.GetValue();
1944 *h
= constr
->height
.GetValue();
1950 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
1952 wxLayoutConstraints
*constr
= GetConstraints();
1955 *w
= constr
->width
.GetValue();
1956 *h
= constr
->height
.GetValue();
1959 GetClientSize(w
, h
);
1962 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
1964 wxLayoutConstraints
*constr
= GetConstraints();
1967 *x
= constr
->left
.GetValue();
1968 *y
= constr
->top
.GetValue();
1974 #endif // wxUSE_CONSTRAINTS
1976 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
1978 // don't do it for the dialogs/frames - they float independently of their
1980 if ( !IsTopLevel() )
1982 wxWindow
*parent
= GetParent();
1983 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
1985 wxPoint
pt(parent
->GetClientAreaOrigin());
1992 // ----------------------------------------------------------------------------
1993 // do Update UI processing for child controls
1994 // ----------------------------------------------------------------------------
1996 void wxWindowBase::UpdateWindowUI(long flags
)
1998 wxUpdateUIEvent
event(GetId());
1999 event
.m_eventObject
= this;
2001 if ( GetEventHandler()->ProcessEvent(event
) )
2003 DoUpdateWindowUI(event
);
2006 if (flags
& wxUPDATE_UI_RECURSE
)
2008 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2011 wxWindow
* child
= (wxWindow
*) node
->GetData();
2012 child
->UpdateWindowUI(flags
);
2013 node
= node
->GetNext();
2018 // do the window-specific processing after processing the update event
2019 // TODO: take specific knowledge out of this function and
2020 // put in each control's base class. Unfortunately we don't
2021 // yet have base implementation files for wxCheckBox and wxRadioButton.
2022 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
2024 if ( event
.GetSetEnabled() )
2025 Enable(event
.GetEnabled());
2028 if ( event
.GetSetText() )
2030 wxControl
*control
= wxDynamicCastThis(wxControl
);
2033 if ( event
.GetText() != control
->GetLabel() )
2034 control
->SetLabel(event
.GetText());
2037 wxCheckBox
*checkbox
= wxDynamicCastThis(wxCheckBox
);
2040 if ( event
.GetSetChecked() )
2041 checkbox
->SetValue(event
.GetChecked());
2043 #endif // wxUSE_CHECKBOX
2046 wxRadioButton
*radiobtn
= wxDynamicCastThis(wxRadioButton
);
2049 if ( event
.GetSetChecked() )
2050 radiobtn
->SetValue(event
.GetChecked());
2052 #endif // wxUSE_RADIOBTN
2058 // call internal idle recursively
2059 // may be obsolete (wait until OnIdle scheme stabilises)
2060 void wxWindowBase::ProcessInternalIdle()
2064 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2067 wxWindow
*child
= node
->GetData();
2068 child
->ProcessInternalIdle();
2069 node
= node
->GetNext();
2074 // ----------------------------------------------------------------------------
2075 // dialog units translations
2076 // ----------------------------------------------------------------------------
2078 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
2080 int charWidth
= GetCharWidth();
2081 int charHeight
= GetCharHeight();
2082 wxPoint
pt2(-1, -1);
2084 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
);
2086 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2091 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2093 int charWidth
= GetCharWidth();
2094 int charHeight
= GetCharHeight();
2095 wxPoint
pt2(-1, -1);
2097 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2099 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2104 // ----------------------------------------------------------------------------
2106 // ----------------------------------------------------------------------------
2108 // propagate the colour change event to the subwindows
2109 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2111 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2114 // Only propagate to non-top-level windows
2115 wxWindow
*win
= node
->GetData();
2116 if ( !win
->IsTopLevel() )
2118 wxSysColourChangedEvent event2
;
2119 event
.m_eventObject
= win
;
2120 win
->GetEventHandler()->ProcessEvent(event2
);
2123 node
= node
->GetNext();
2129 // the default action is to populate dialog with data when it's created,
2130 // and nudge the UI into displaying itself correctly in case
2131 // we've turned the wxUpdateUIEvents frequency down low.
2132 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2134 TransferDataToWindow();
2136 // Update the UI at this point
2137 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2140 // process Ctrl-Alt-mclick
2141 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2144 if ( event
.ControlDown() && event
.AltDown() )
2146 // don't translate these strings
2149 #ifdef __WXUNIVERSAL__
2151 #endif // __WXUNIVERSAL__
2153 switch ( wxGetOsVersion() )
2155 case wxMOTIF_X
: port
+= _T("Motif"); break;
2157 case wxMAC_DARWIN
: port
+= _T("Mac"); break;
2158 case wxBEOS
: port
+= _T("BeOS"); break;
2162 case wxGTK_BEOS
: port
+= _T("GTK"); break;
2168 case wxWIN386
: port
+= _T("MS Windows"); break;
2172 case wxMGL_OS2
: port
+= _T("MGL"); break;
2174 case wxOS2_PM
: port
+= _T("OS/2"); break;
2175 default: port
+= _T("unknown"); break;
2178 wxMessageBox(wxString::Format(
2180 " wxWidgets Library (%s port)\nVersion %u.%u.%u%s, compiled at %s %s\n Copyright (c) 1995-2002 wxWidgets team"
2194 _T("wxWidgets information"),
2195 wxICON_INFORMATION
| wxOK
,
2199 #endif // wxUSE_MSGDLG
2205 // ----------------------------------------------------------------------------
2207 // ----------------------------------------------------------------------------
2209 #if wxUSE_ACCESSIBILITY
2210 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2212 if (m_accessible
&& (accessible
!= m_accessible
))
2213 delete m_accessible
;
2214 m_accessible
= accessible
;
2216 m_accessible
->SetWindow((wxWindow
*) this);
2219 // Returns the accessible object, creating if necessary.
2220 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2223 m_accessible
= CreateAccessible();
2224 return m_accessible
;
2227 // Override to create a specific accessible object.
2228 wxAccessible
* wxWindowBase::CreateAccessible()
2230 return new wxWindowAccessible((wxWindow
*) this);
2236 // ----------------------------------------------------------------------------
2237 // list classes implementation
2238 // ----------------------------------------------------------------------------
2240 void wxWindowListNode::DeleteData()
2242 delete (wxWindow
*)GetData();
2246 // ----------------------------------------------------------------------------
2248 // ----------------------------------------------------------------------------
2250 wxBorder
wxWindowBase::GetBorder(long flags
) const
2252 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2253 if ( border
== wxBORDER_DEFAULT
)
2255 border
= GetDefaultBorder();
2261 wxBorder
wxWindowBase::GetDefaultBorder() const
2263 return wxBORDER_NONE
;
2266 // ----------------------------------------------------------------------------
2268 // ----------------------------------------------------------------------------
2270 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2272 // here we just check if the point is inside the window or not
2274 // check the top and left border first
2275 bool outside
= x
< 0 || y
< 0;
2278 // check the right and bottom borders too
2279 wxSize size
= GetSize();
2280 outside
= x
>= size
.x
|| y
>= size
.y
;
2283 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2286 // ----------------------------------------------------------------------------
2288 // ----------------------------------------------------------------------------
2290 struct WXDLLEXPORT wxWindowNext
2294 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2296 void wxWindowBase::CaptureMouse()
2298 wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), this);
2300 wxWindow
*winOld
= GetCapture();
2303 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2306 wxWindowNext
*item
= new wxWindowNext
;
2308 item
->next
= ms_winCaptureNext
;
2309 ms_winCaptureNext
= item
;
2311 //else: no mouse capture to save
2316 void wxWindowBase::ReleaseMouse()
2318 wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), this);
2320 wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") );
2324 if ( ms_winCaptureNext
)
2326 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2328 wxWindowNext
*item
= ms_winCaptureNext
;
2329 ms_winCaptureNext
= item
->next
;
2332 //else: stack is empty, no previous capture
2334 wxLogTrace(_T("mousecapture"),
2335 (const wxChar
*) _T("After ReleaseMouse() mouse is captured by %p"),
2342 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2343 int WXUNUSED(modifiers
),
2344 int WXUNUSED(keycode
))
2350 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2356 #endif // wxUSE_HOTKEY
2358 void wxWindowBase::SendDestroyEvent()
2360 wxWindowDestroyEvent event
;
2361 event
.SetEventObject(this);
2362 event
.SetId(GetId());
2363 GetEventHandler()->ProcessEvent(event
);
2366 // ----------------------------------------------------------------------------
2368 // ----------------------------------------------------------------------------
2370 bool wxWindowBase::TryValidator(wxEvent
& wxVALIDATOR_PARAM(event
))
2372 #if wxUSE_VALIDATORS
2373 // Can only use the validator of the window which
2374 // is receiving the event
2375 if ( event
.GetEventObject() == this )
2377 wxValidator
*validator
= GetValidator();
2378 if ( validator
&& validator
->ProcessEvent(event
) )
2383 #endif // wxUSE_VALIDATORS
2388 bool wxWindowBase::TryParent(wxEvent
& event
)
2390 // carry on up the parent-child hierarchy if the propgation count hasn't
2392 if ( event
.ShouldPropagate() )
2394 // honour the requests to stop propagation at this window: this is
2395 // used by the dialogs, for example, to prevent processing the events
2396 // from the dialog controls in the parent frame which rarely, if ever,
2398 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2400 wxWindow
*parent
= GetParent();
2401 if ( parent
&& !parent
->IsBeingDeleted() )
2403 wxPropagateOnce
propagateOnce(event
);
2405 return parent
->GetEventHandler()->ProcessEvent(event
);
2410 return wxEvtHandler::TryParent(event
);
2413 // ----------------------------------------------------------------------------
2414 // keyboard navigation
2415 // ----------------------------------------------------------------------------
2417 // Navigates in the specified direction.
2418 bool wxWindowBase::Navigate(int flags
)
2420 wxNavigationKeyEvent eventNav
;
2421 eventNav
.SetFlags(flags
);
2422 eventNav
.SetEventObject(this);
2423 if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav
) )
2430 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, MoveKind move
)
2432 // check that we're not a top level window
2433 wxCHECK_RET( GetParent(),
2434 _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
2436 // find the target window in the siblings list
2437 wxWindowList
& siblings
= GetParent()->GetChildren();
2438 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
2439 wxCHECK_RET( i
, _T("MoveBefore/AfterInTabOrder(): win is not a sibling") );
2441 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
2442 // can't just move the node around
2443 wxWindow
*self
= (wxWindow
*)this;
2444 siblings
.DeleteObject(self
);
2445 if ( move
== MoveAfter
)
2452 siblings
.Insert(i
, self
);
2454 else // MoveAfter and win was the last sibling
2456 siblings
.Append(self
);
2460 // ----------------------------------------------------------------------------
2462 // ----------------------------------------------------------------------------
2464 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
2466 while ( win
&& !win
->IsTopLevel() )
2467 win
= win
->GetParent();
2472 #if wxUSE_ACCESSIBILITY
2473 // ----------------------------------------------------------------------------
2474 // accessible object for windows
2475 // ----------------------------------------------------------------------------
2477 // Can return either a child object, or an integer
2478 // representing the child element, starting from 1.
2479 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
2481 wxASSERT( GetWindow() != NULL
);
2485 return wxACC_NOT_IMPLEMENTED
;
2488 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
2489 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
2491 wxASSERT( GetWindow() != NULL
);
2495 wxWindow
* win
= NULL
;
2502 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
2504 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
2511 rect
= win
->GetRect();
2512 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
2513 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
2517 return wxACC_NOT_IMPLEMENTED
;
2520 // Navigates from fromId to toId/toObject.
2521 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
2522 int* WXUNUSED(toId
), wxAccessible
** toObject
)
2524 wxASSERT( GetWindow() != NULL
);
2530 case wxNAVDIR_FIRSTCHILD
:
2532 if (GetWindow()->GetChildren().GetCount() == 0)
2534 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
2535 *toObject
= childWindow
->GetOrCreateAccessible();
2539 case wxNAVDIR_LASTCHILD
:
2541 if (GetWindow()->GetChildren().GetCount() == 0)
2543 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
2544 *toObject
= childWindow
->GetOrCreateAccessible();
2548 case wxNAVDIR_RIGHT
:
2552 wxWindowList::compatibility_iterator node
=
2553 wxWindowList::compatibility_iterator();
2556 // Can't navigate to sibling of this window
2557 // if we're a top-level window.
2558 if (!GetWindow()->GetParent())
2559 return wxACC_NOT_IMPLEMENTED
;
2561 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2565 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2566 node
= GetWindow()->GetChildren().Item(fromId
-1);
2569 if (node
&& node
->GetNext())
2571 wxWindow
* nextWindow
= node
->GetNext()->GetData();
2572 *toObject
= nextWindow
->GetOrCreateAccessible();
2580 case wxNAVDIR_PREVIOUS
:
2582 wxWindowList::compatibility_iterator node
=
2583 wxWindowList::compatibility_iterator();
2586 // Can't navigate to sibling of this window
2587 // if we're a top-level window.
2588 if (!GetWindow()->GetParent())
2589 return wxACC_NOT_IMPLEMENTED
;
2591 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2595 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2596 node
= GetWindow()->GetChildren().Item(fromId
-1);
2599 if (node
&& node
->GetPrevious())
2601 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
2602 *toObject
= previousWindow
->GetOrCreateAccessible();
2610 return wxACC_NOT_IMPLEMENTED
;
2613 // Gets the name of the specified object.
2614 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
2616 wxASSERT( GetWindow() != NULL
);
2622 // If a child, leave wxWidgets to call the function on the actual
2625 return wxACC_NOT_IMPLEMENTED
;
2627 // This will eventually be replaced by specialised
2628 // accessible classes, one for each kind of wxWidgets
2629 // control or window.
2631 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
2632 title
= ((wxButton
*) GetWindow())->GetLabel();
2635 title
= GetWindow()->GetName();
2637 if (!title
.IsEmpty())
2643 return wxACC_NOT_IMPLEMENTED
;
2646 // Gets the number of children.
2647 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
2649 wxASSERT( GetWindow() != NULL
);
2653 *childId
= (int) GetWindow()->GetChildren().GetCount();
2657 // Gets the specified child (starting from 1).
2658 // If *child is NULL and return value is wxACC_OK,
2659 // this means that the child is a simple element and
2660 // not an accessible object.
2661 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
2663 wxASSERT( GetWindow() != NULL
);
2673 if (childId
> (int) GetWindow()->GetChildren().GetCount())
2676 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
2677 *child
= childWindow
->GetOrCreateAccessible();
2684 // Gets the parent, or NULL.
2685 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
2687 wxASSERT( GetWindow() != NULL
);
2691 wxWindow
* parentWindow
= GetWindow()->GetParent();
2699 *parent
= parentWindow
->GetOrCreateAccessible();
2707 // Performs the default action. childId is 0 (the action for this object)
2708 // or > 0 (the action for a child).
2709 // Return wxACC_NOT_SUPPORTED if there is no default action for this
2710 // window (e.g. an edit control).
2711 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
2713 wxASSERT( GetWindow() != NULL
);
2717 return wxACC_NOT_IMPLEMENTED
;
2720 // Gets the default action for this object (0) or > 0 (the action for a child).
2721 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
2722 // string if there is no action.
2723 // The retrieved string describes the action that is performed on an object,
2724 // not what the object does as a result. For example, a toolbar button that prints
2725 // a document has a default action of "Press" rather than "Prints the current document."
2726 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
2728 wxASSERT( GetWindow() != NULL
);
2732 return wxACC_NOT_IMPLEMENTED
;
2735 // Returns the description for this object or a child.
2736 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
2738 wxASSERT( GetWindow() != NULL
);
2742 wxString
ht(GetWindow()->GetHelpText());
2748 return wxACC_NOT_IMPLEMENTED
;
2751 // Returns help text for this object or a child, similar to tooltip text.
2752 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
2754 wxASSERT( GetWindow() != NULL
);
2758 wxString
ht(GetWindow()->GetHelpText());
2764 return wxACC_NOT_IMPLEMENTED
;
2767 // Returns the keyboard shortcut for this object or child.
2768 // Return e.g. ALT+K
2769 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
2771 wxASSERT( GetWindow() != NULL
);
2775 return wxACC_NOT_IMPLEMENTED
;
2778 // Returns a role constant.
2779 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
2781 wxASSERT( GetWindow() != NULL
);
2785 // If a child, leave wxWidgets to call the function on the actual
2788 return wxACC_NOT_IMPLEMENTED
;
2790 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2791 return wxACC_NOT_IMPLEMENTED
;
2793 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2794 return wxACC_NOT_IMPLEMENTED
;
2797 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2798 return wxACC_NOT_IMPLEMENTED
;
2801 //*role = wxROLE_SYSTEM_CLIENT;
2802 *role
= wxROLE_SYSTEM_CLIENT
;
2806 return wxACC_NOT_IMPLEMENTED
;
2810 // Returns a state constant.
2811 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
2813 wxASSERT( GetWindow() != NULL
);
2817 // If a child, leave wxWidgets to call the function on the actual
2820 return wxACC_NOT_IMPLEMENTED
;
2822 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2823 return wxACC_NOT_IMPLEMENTED
;
2826 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2827 return wxACC_NOT_IMPLEMENTED
;
2830 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2831 return wxACC_NOT_IMPLEMENTED
;
2838 return wxACC_NOT_IMPLEMENTED
;
2842 // Returns a localized string representing the value for the object
2844 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
2846 wxASSERT( GetWindow() != NULL
);
2850 return wxACC_NOT_IMPLEMENTED
;
2853 // Selects the object or child.
2854 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
2856 wxASSERT( GetWindow() != NULL
);
2860 return wxACC_NOT_IMPLEMENTED
;
2863 // Gets the window with the keyboard focus.
2864 // If childId is 0 and child is NULL, no object in
2865 // this subhierarchy has the focus.
2866 // If this object has the focus, child should be 'this'.
2867 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
2869 wxASSERT( GetWindow() != NULL
);
2873 return wxACC_NOT_IMPLEMENTED
;
2876 // Gets a variant representing the selected children
2878 // Acceptable values:
2879 // - a null variant (IsNull() returns TRUE)
2880 // - a list variant (GetType() == wxT("list")
2881 // - an integer representing the selected child element,
2882 // or 0 if this object is selected (GetType() == wxT("long")
2883 // - a "void*" pointer to a wxAccessible child object
2884 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
2886 wxASSERT( GetWindow() != NULL
);
2890 return wxACC_NOT_IMPLEMENTED
;
2893 #endif // wxUSE_ACCESSIBILITY