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 #if wxUSE_CONSTRAINTS
157 // no constraints whatsoever
158 m_constraints
= (wxLayoutConstraints
*) NULL
;
159 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
160 #endif // wxUSE_CONSTRAINTS
162 m_windowSizer
= (wxSizer
*) NULL
;
163 m_containingSizer
= (wxSizer
*) NULL
;
164 m_autoLayout
= false;
166 #if wxUSE_DRAG_AND_DROP
167 m_dropTarget
= (wxDropTarget
*)NULL
;
168 #endif // wxUSE_DRAG_AND_DROP
171 m_tooltip
= (wxToolTip
*)NULL
;
172 #endif // wxUSE_TOOLTIPS
175 m_caret
= (wxCaret
*)NULL
;
176 #endif // wxUSE_CARET
179 m_hasCustomPalette
= false;
180 #endif // wxUSE_PALETTE
182 #if wxUSE_ACCESSIBILITY
186 m_virtualSize
= wxDefaultSize
;
189 m_maxVirtualWidth
= wxDefaultCoord
;
191 m_maxVirtualHeight
= wxDefaultCoord
;
193 m_windowVariant
= wxWINDOW_VARIANT_NORMAL
;
195 // Whether we're using the current theme for this window (wxGTK only for now)
196 m_themeEnabled
= false;
198 // VZ: this one shouldn't exist...
199 m_isBeingDeleted
= false;
202 // common part of window creation process
203 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
205 const wxPoint
& WXUNUSED(pos
),
206 const wxSize
& WXUNUSED(size
),
208 const wxValidator
& wxVALIDATOR_PARAM(validator
),
209 const wxString
& name
)
212 // wxGTK doesn't allow to create controls with static box as the parent so
213 // this will result in a crash when the program is ported to wxGTK so warn
216 // if you get this assert, the correct solution is to create the controls
217 // as siblings of the static box
218 wxASSERT_MSG( !parent
|| !wxDynamicCast(parent
, wxStaticBox
),
219 _T("wxStaticBox can't be used as a window parent!") );
220 #endif // wxUSE_STATBOX
222 // ids are limited to 16 bits under MSW so if you care about portability,
223 // it's not a good idea to use ids out of this range (and negative ids are
224 // reserved for wxWidgets own usage)
225 wxASSERT_MSG( id
== wxID_ANY
|| (id
>= 0 && id
< 32767),
226 _T("invalid id value") );
228 // generate a new id if the user doesn't care about it
229 m_windowId
= id
== wxID_ANY
? NewControlId() : id
;
232 SetWindowStyleFlag(style
);
236 SetValidator(validator
);
237 #endif // wxUSE_VALIDATORS
239 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
240 // have it too - like this it's possible to set it only in the top level
241 // dialog/frame and all children will inherit it by defult
242 if ( parent
&& (parent
->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) )
244 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY
);
250 // ----------------------------------------------------------------------------
252 // ----------------------------------------------------------------------------
255 wxWindowBase::~wxWindowBase()
257 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
259 // FIXME if these 2 cases result from programming errors in the user code
260 // we should probably assert here instead of silently fixing them
262 // Just in case the window has been Closed, but we're then deleting
263 // immediately: don't leave dangling pointers.
264 wxPendingDelete
.DeleteObject(this);
266 // Just in case we've loaded a top-level window via LoadNativeDialog but
267 // we weren't a dialog class
268 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
270 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
272 // reset the dangling pointer our parent window may keep to us
275 if ( m_parent
->GetDefaultItem() == this )
277 m_parent
->SetDefaultItem(NULL
);
280 m_parent
->RemoveChild(this);
285 #endif // wxUSE_CARET
288 delete m_windowValidator
;
289 #endif // wxUSE_VALIDATORS
291 #if wxUSE_CONSTRAINTS
292 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
293 // at deleted windows as they delete themselves.
294 DeleteRelatedConstraints();
298 // This removes any dangling pointers to this window in other windows'
299 // constraintsInvolvedIn lists.
300 UnsetConstraints(m_constraints
);
301 delete m_constraints
;
302 m_constraints
= NULL
;
304 #endif // wxUSE_CONSTRAINTS
306 if ( m_containingSizer
)
307 m_containingSizer
->Detach( (wxWindow
*)this );
309 delete m_windowSizer
;
311 #if wxUSE_DRAG_AND_DROP
313 #endif // wxUSE_DRAG_AND_DROP
317 #endif // wxUSE_TOOLTIPS
319 #if wxUSE_ACCESSIBILITY
324 bool wxWindowBase::Destroy()
331 bool wxWindowBase::Close(bool force
)
333 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
334 event
.SetEventObject(this);
335 event
.SetCanVeto(!force
);
337 // return false if window wasn't closed because the application vetoed the
339 return GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto();
342 bool wxWindowBase::DestroyChildren()
344 wxWindowList::compatibility_iterator node
;
347 // we iterate until the list becomes empty
348 node
= GetChildren().GetFirst();
352 wxWindow
*child
= node
->GetData();
354 // note that we really want to call delete and not ->Destroy() here
355 // because we want to delete the child immediately, before we are
356 // deleted, and delayed deletion would result in problems as our (top
357 // level) child could outlive its parent
360 wxASSERT_MSG( !GetChildren().Find(child
),
361 wxT("child didn't remove itself using RemoveChild()") );
367 // ----------------------------------------------------------------------------
368 // size/position related methods
369 // ----------------------------------------------------------------------------
371 // centre the window with respect to its parent in either (or both) directions
372 void wxWindowBase::Centre(int direction
)
374 // the position/size of the parent window or of the entire screen
376 int widthParent
, heightParent
;
378 wxWindow
*parent
= NULL
;
380 if ( !(direction
& wxCENTRE_ON_SCREEN
) )
382 // find the parent to centre this window on: it should be the
383 // immediate parent for the controls but the top level parent for the
384 // top level windows (like dialogs)
385 parent
= GetParent();
388 while ( parent
&& !parent
->IsTopLevel() )
390 parent
= parent
->GetParent();
394 // there is no wxTopLevelWindow under wxMotif yet
396 // we shouldn't center the dialog on the iconized window: under
397 // Windows, for example, this places it completely off the screen
400 wxTopLevelWindow
*winTop
= wxDynamicCast(parent
, wxTopLevelWindow
);
401 if ( winTop
&& winTop
->IsIconized() )
406 #endif // __WXMOTIF__
408 // did we find the parent?
412 direction
|= wxCENTRE_ON_SCREEN
;
416 if ( direction
& wxCENTRE_ON_SCREEN
)
418 // centre with respect to the whole screen
419 wxDisplaySize(&widthParent
, &heightParent
);
425 // centre on the parent
426 parent
->GetSize(&widthParent
, &heightParent
);
428 // adjust to the parents position
429 posParent
= parent
->GetPosition();
433 // centre inside the parents client rectangle
434 parent
->GetClientSize(&widthParent
, &heightParent
);
439 GetSize(&width
, &height
);
441 int xNew
= wxDefaultCoord
,
442 yNew
= wxDefaultCoord
;
444 if ( direction
& wxHORIZONTAL
)
445 xNew
= (widthParent
- width
)/2;
447 if ( direction
& wxVERTICAL
)
448 yNew
= (heightParent
- height
)/2;
453 // Base size of the visible dimensions of the display
454 // to take into account the taskbar. And the Mac menu bar at top.
455 wxRect clientrect
= wxGetClientDisplayRect();
457 // NB: in wxMSW, negative position may not neccessary mean "out of screen",
458 // but it may mean that the window is placed on other than the main
459 // display. Therefore we only make sure centered window is on the main display
460 // if the parent is at least partially present here.
461 if (posParent
.x
+ widthParent
>= 0) // if parent is (partially) on the main display
463 if (xNew
< clientrect
.GetLeft())
464 xNew
= clientrect
.GetLeft();
465 else if (xNew
+ width
> clientrect
.GetRight())
466 xNew
= clientrect
.GetRight() - width
;
468 if (posParent
.y
+ heightParent
>= 0) // if parent is (partially) on the main display
470 if (yNew
+ height
> clientrect
.GetBottom())
471 yNew
= clientrect
.GetBottom() - height
;
473 // Make certain that the title bar is initially visible
474 // always, even if this would push the bottom of the
475 // dialog off the visible area of the display
476 if (yNew
< clientrect
.GetTop())
477 yNew
= clientrect
.GetTop();
480 // move the window to this position (keeping the old size but using
481 // SetSize() and not Move() to allow xNew and/or yNew to be -1)
482 SetSize(xNew
, yNew
, width
, height
, wxSIZE_ALLOW_MINUS_ONE
);
485 // fits the window around the children
486 void wxWindowBase::Fit()
488 if ( GetChildren().GetCount() > 0 )
490 SetClientSize(GetBestSize());
492 //else: do nothing if we have no children
495 // fits virtual size (ie. scrolled area etc.) around children
496 void wxWindowBase::FitInside()
498 if ( GetChildren().GetCount() > 0 )
500 SetVirtualSize( GetBestVirtualSize() );
504 // On Mac, scrollbars are explicitly children.
506 static bool wxHasRealChildren(const wxWindowBase
* win
)
508 int realChildCount
= 0;
510 for ( wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
512 node
= node
->GetNext() )
514 wxWindow
*win
= node
->GetData();
515 if ( !win
->IsTopLevel() && win
->IsShown() && !win
->IsKindOf(CLASSINFO(wxScrollBar
)))
518 return (realChildCount
> 0);
522 // return the size best suited for the current window
523 wxSize
wxWindowBase::DoGetBestSize() const
527 return m_windowSizer
->GetMinSize();
529 #if wxUSE_CONSTRAINTS
530 else if ( m_constraints
)
532 wxConstCast(this, wxWindowBase
)->SatisfyConstraints();
534 // our minimal acceptable size is such that all our windows fit inside
538 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
540 node
= node
->GetNext() )
542 wxLayoutConstraints
*c
= node
->GetData()->GetConstraints();
545 // it's not normal that we have an unconstrained child, but
546 // what can we do about it?
550 int x
= c
->right
.GetValue(),
551 y
= c
->bottom
.GetValue();
559 // TODO: we must calculate the overlaps somehow, otherwise we
560 // will never return a size bigger than the current one :-(
563 return wxSize(maxX
, maxY
);
565 #endif // wxUSE_CONSTRAINTS
566 else if ( !GetChildren().empty()
568 && wxHasRealChildren(this)
572 // our minimal acceptable size is such that all our visible child windows fit inside
576 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
578 node
= node
->GetNext() )
580 wxWindow
*win
= node
->GetData();
581 if ( win
->IsTopLevel() || ( ! win
->IsShown() )
583 || wxDynamicCast(win
, wxStatusBar
)
584 #endif // wxUSE_STATUSBAR
587 // dialogs and frames lie in different top level windows -
588 // don't deal with them here; as for the status bars, they
589 // don't lie in the client area at all
594 win
->GetPosition(&wx
, &wy
);
596 // if the window hadn't been positioned yet, assume that it is in
598 if ( wx
== wxDefaultCoord
)
600 if ( wy
== wxDefaultCoord
)
603 win
->GetSize(&ww
, &wh
);
604 if ( wx
+ ww
> maxX
)
606 if ( wy
+ wh
> maxY
)
610 // for compatibility with the old versions and because it really looks
611 // slightly more pretty like this, add a pad
615 return wxSize(maxX
, maxY
);
617 else // ! has children
619 // for a generic window there is no natural best size - just use either the
620 // minimum size if there is one, or the current size
621 if ( GetMinSize().IsFullySpecified() )
629 wxSize
wxWindowBase::GetBestFittingSize() const
631 // merge the best size with the min size, giving priority to the min size
632 wxSize min
= GetMinSize();
633 if (min
.x
== wxDefaultCoord
|| min
.y
== wxDefaultCoord
)
635 wxSize best
= GetBestSize();
636 if (min
.x
== wxDefaultCoord
) min
.x
= best
.x
;
637 if (min
.y
== wxDefaultCoord
) min
.y
= best
.y
;
643 void wxWindowBase::SetBestFittingSize(const wxSize
& size
)
645 // Set the min size to the size passed in. This will usually either be
646 // wxDefaultSize or the size passed to this window's ctor/Create function.
649 // Merge the size with the best size if needed
650 wxSize best
= GetBestFittingSize();
652 // If the current size doesn't match then change it
653 if (GetSize() != best
)
658 // by default the origin is not shifted
659 wxPoint
wxWindowBase::GetClientAreaOrigin() const
661 return wxPoint(0, 0);
664 // set the min/max size of the window
665 void wxWindowBase::SetSizeHints(int minW
, int minH
,
667 int WXUNUSED(incW
), int WXUNUSED(incH
))
669 // setting min width greater than max width leads to infinite loops under
670 // X11 and generally doesn't make any sense, so don't allow it
671 wxCHECK_RET( (minW
== wxDefaultCoord
|| maxW
== wxDefaultCoord
|| minW
<= maxW
) &&
672 (minH
== wxDefaultCoord
|| maxH
== wxDefaultCoord
|| minH
<= maxH
),
673 _T("min width/height must be less than max width/height!") );
681 void wxWindowBase::SetWindowVariant( wxWindowVariant variant
)
683 if ( m_windowVariant
!= variant
)
685 m_windowVariant
= variant
;
687 DoSetWindowVariant(variant
);
691 void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant
)
693 // adjust the font height to correspond to our new variant (notice that
694 // we're only called if something really changed)
695 wxFont font
= GetFont();
696 int size
= font
.GetPointSize();
699 case wxWINDOW_VARIANT_NORMAL
:
702 case wxWINDOW_VARIANT_SMALL
:
707 case wxWINDOW_VARIANT_MINI
:
712 case wxWINDOW_VARIANT_LARGE
:
718 wxFAIL_MSG(_T("unexpected window variant"));
722 font
.SetPointSize(size
);
726 void wxWindowBase::SetVirtualSizeHints( int minW
, int minH
,
729 m_minVirtualWidth
= minW
;
730 m_maxVirtualWidth
= maxW
;
731 m_minVirtualHeight
= minH
;
732 m_maxVirtualHeight
= maxH
;
735 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
737 if ( m_minVirtualWidth
!= wxDefaultCoord
&& m_minVirtualWidth
> x
)
738 x
= m_minVirtualWidth
;
739 if ( m_maxVirtualWidth
!= wxDefaultCoord
&& m_maxVirtualWidth
< x
)
740 x
= m_maxVirtualWidth
;
741 if ( m_minVirtualHeight
!= wxDefaultCoord
&& m_minVirtualHeight
> y
)
742 y
= m_minVirtualHeight
;
743 if ( m_maxVirtualHeight
!= wxDefaultCoord
&& m_maxVirtualHeight
< y
)
744 y
= m_maxVirtualHeight
;
746 m_virtualSize
= wxSize(x
, y
);
749 wxSize
wxWindowBase::DoGetVirtualSize() const
751 wxSize
s( GetClientSize() );
753 return wxSize( wxMax( m_virtualSize
.GetWidth(), s
.GetWidth() ),
754 wxMax( m_virtualSize
.GetHeight(), s
.GetHeight() ) );
757 // ----------------------------------------------------------------------------
758 // show/hide/enable/disable the window
759 // ----------------------------------------------------------------------------
761 bool wxWindowBase::Show(bool show
)
763 if ( show
!= m_isShown
)
775 bool wxWindowBase::Enable(bool enable
)
777 if ( enable
!= m_isEnabled
)
779 m_isEnabled
= enable
;
788 // ----------------------------------------------------------------------------
790 // ----------------------------------------------------------------------------
792 bool wxWindowBase::IsTopLevel() const
797 // ----------------------------------------------------------------------------
798 // reparenting the window
799 // ----------------------------------------------------------------------------
801 void wxWindowBase::AddChild(wxWindowBase
*child
)
803 wxCHECK_RET( child
, wxT("can't add a NULL child") );
805 // this should never happen and it will lead to a crash later if it does
806 // because RemoveChild() will remove only one node from the children list
807 // and the other(s) one(s) will be left with dangling pointers in them
808 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), _T("AddChild() called twice") );
810 GetChildren().Append((wxWindow
*)child
);
811 child
->SetParent(this);
814 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
816 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
818 GetChildren().DeleteObject((wxWindow
*)child
);
819 child
->SetParent(NULL
);
822 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
824 wxWindow
*oldParent
= GetParent();
825 if ( newParent
== oldParent
)
831 // unlink this window from the existing parent.
834 oldParent
->RemoveChild(this);
838 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
841 // add it to the new one
844 newParent
->AddChild(this);
848 wxTopLevelWindows
.Append((wxWindow
*)this);
854 // ----------------------------------------------------------------------------
855 // event handler stuff
856 // ----------------------------------------------------------------------------
858 void wxWindowBase::PushEventHandler(wxEvtHandler
*handler
)
860 wxEvtHandler
*handlerOld
= GetEventHandler();
862 handler
->SetNextHandler(handlerOld
);
865 GetEventHandler()->SetPreviousHandler(handler
);
867 SetEventHandler(handler
);
870 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
872 wxEvtHandler
*handlerA
= GetEventHandler();
875 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
876 handlerA
->SetNextHandler((wxEvtHandler
*)NULL
);
879 handlerB
->SetPreviousHandler((wxEvtHandler
*)NULL
);
880 SetEventHandler(handlerB
);
885 handlerA
= (wxEvtHandler
*)NULL
;
892 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handler
)
894 wxCHECK_MSG( handler
, false, _T("RemoveEventHandler(NULL) called") );
896 wxEvtHandler
*handlerPrev
= NULL
,
897 *handlerCur
= GetEventHandler();
900 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
902 if ( handlerCur
== handler
)
906 handlerPrev
->SetNextHandler(handlerNext
);
910 SetEventHandler(handlerNext
);
915 handlerNext
->SetPreviousHandler ( handlerPrev
);
918 handler
->SetNextHandler(NULL
);
919 handler
->SetPreviousHandler(NULL
);
924 handlerPrev
= handlerCur
;
925 handlerCur
= handlerNext
;
928 wxFAIL_MSG( _T("where has the event handler gone?") );
933 // ----------------------------------------------------------------------------
935 // ----------------------------------------------------------------------------
937 void wxWindowBase::InheritAttributes()
939 const wxWindowBase
* const parent
= GetParent();
943 // we only inherit attributes which had been explicitly set for the parent
944 // which ensures that this only happens if the user really wants it and
945 // not by default which wouldn't make any sense in modern GUIs where the
946 // controls don't all use the same fonts (nor colours)
947 if ( parent
->m_inheritFont
&& !m_hasFont
)
948 SetFont(parent
->GetFont());
950 // in addition, there is a possibility to explicitly forbid inheriting
951 // colours at each class level by overriding ShouldInheritColours()
952 if ( ShouldInheritColours() )
954 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
955 SetForegroundColour(parent
->GetForegroundColour());
957 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
958 SetBackgroundColour(parent
->GetBackgroundColour());
962 /* static */ wxVisualAttributes
963 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
965 // it is important to return valid values for all attributes from here,
966 // GetXXX() below rely on this
967 wxVisualAttributes attrs
;
968 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
969 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
970 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
975 wxColour
wxWindowBase::GetBackgroundColour() const
977 if ( !m_backgroundColour
.Ok() )
979 wxASSERT_MSG( !m_hasBgCol
, _T("we have invalid explicit bg colour?") );
981 // get our default background colour
982 wxColour colBg
= GetDefaultAttributes().colBg
;
984 // we must return some valid colour to avoid redoing this every time
985 // and also to avoid surprizing the applications written for older
986 // wxWidgets versions where GetBackgroundColour() always returned
987 // something -- so give them something even if it doesn't make sense
988 // for this window (e.g. it has a themed background)
990 colBg
= GetClassDefaultAttributes().colBg
;
995 return m_backgroundColour
;
998 wxColour
wxWindowBase::GetForegroundColour() const
1000 // logic is the same as above
1001 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
1003 wxASSERT_MSG( !m_hasFgCol
, _T("we have invalid explicit fg colour?") );
1005 wxColour colFg
= GetDefaultAttributes().colFg
;
1008 colFg
= GetClassDefaultAttributes().colFg
;
1013 return m_foregroundColour
;
1016 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
1018 if ( colour
== m_backgroundColour
)
1021 m_hasBgCol
= colour
.Ok();
1022 m_inheritBgCol
= m_hasBgCol
;
1023 m_backgroundColour
= colour
;
1024 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1028 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1030 if (colour
== m_foregroundColour
)
1033 m_hasFgCol
= colour
.Ok();
1034 m_inheritFgCol
= m_hasFgCol
;
1035 m_foregroundColour
= colour
;
1036 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1040 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1042 // setting an invalid cursor is ok, it means that we don't have any special
1044 if ( m_cursor
== cursor
)
1055 wxFont
wxWindowBase::GetFont() const
1057 // logic is the same as in GetBackgroundColour()
1060 wxASSERT_MSG( !m_hasFont
, _T("we have invalid explicit font?") );
1062 wxFont font
= GetDefaultAttributes().font
;
1064 font
= GetClassDefaultAttributes().font
;
1072 bool wxWindowBase::SetFont(const wxFont
& font
)
1074 if ( font
== m_font
)
1081 m_hasFont
= font
.Ok();
1082 m_inheritFont
= m_hasFont
;
1084 InvalidateBestSize();
1091 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1093 m_hasCustomPalette
= true;
1096 // VZ: can anyone explain me what do we do here?
1097 wxWindowDC
d((wxWindow
*) this);
1101 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1103 wxWindow
*win
= (wxWindow
*)this;
1104 while ( win
&& !win
->HasCustomPalette() )
1106 win
= win
->GetParent();
1112 #endif // wxUSE_PALETTE
1115 void wxWindowBase::SetCaret(wxCaret
*caret
)
1126 wxASSERT_MSG( m_caret
->GetWindow() == this,
1127 wxT("caret should be created associated to this window") );
1130 #endif // wxUSE_CARET
1132 #if wxUSE_VALIDATORS
1133 // ----------------------------------------------------------------------------
1135 // ----------------------------------------------------------------------------
1137 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1139 if ( m_windowValidator
)
1140 delete m_windowValidator
;
1142 m_windowValidator
= (wxValidator
*)validator
.Clone();
1144 if ( m_windowValidator
)
1145 m_windowValidator
->SetWindow(this);
1147 #endif // wxUSE_VALIDATORS
1149 // ----------------------------------------------------------------------------
1150 // update region stuff
1151 // ----------------------------------------------------------------------------
1153 wxRect
wxWindowBase::GetUpdateClientRect() const
1155 wxRegion rgnUpdate
= GetUpdateRegion();
1156 rgnUpdate
.Intersect(GetClientRect());
1157 wxRect rectUpdate
= rgnUpdate
.GetBox();
1158 wxPoint ptOrigin
= GetClientAreaOrigin();
1159 rectUpdate
.x
-= ptOrigin
.x
;
1160 rectUpdate
.y
-= ptOrigin
.y
;
1165 bool wxWindowBase::IsExposed(int x
, int y
) const
1167 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1170 bool wxWindowBase::IsExposed(int x
, int y
, int w
, int h
) const
1172 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1175 void wxWindowBase::ClearBackground()
1177 // wxGTK uses its own version, no need to add never used code
1179 wxClientDC
dc((wxWindow
*)this);
1180 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1181 dc
.SetBackground(brush
);
1186 // ----------------------------------------------------------------------------
1187 // find child window by id or name
1188 // ----------------------------------------------------------------------------
1190 wxWindow
*wxWindowBase::FindWindow( long id
)
1192 if ( id
== m_windowId
)
1193 return (wxWindow
*)this;
1195 wxWindowBase
*res
= (wxWindow
*)NULL
;
1196 wxWindowList::compatibility_iterator node
;
1197 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1199 wxWindowBase
*child
= node
->GetData();
1200 res
= child
->FindWindow( id
);
1203 return (wxWindow
*)res
;
1206 wxWindow
*wxWindowBase::FindWindow( const wxString
& name
)
1208 if ( name
== m_windowName
)
1209 return (wxWindow
*)this;
1211 wxWindowBase
*res
= (wxWindow
*)NULL
;
1212 wxWindowList::compatibility_iterator node
;
1213 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1215 wxWindow
*child
= node
->GetData();
1216 res
= child
->FindWindow(name
);
1219 return (wxWindow
*)res
;
1223 // find any window by id or name or label: If parent is non-NULL, look through
1224 // children for a label or title matching the specified string. If NULL, look
1225 // through all top-level windows.
1227 // to avoid duplicating code we reuse the same helper function but with
1228 // different comparators
1230 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1231 const wxString
& label
, long id
);
1234 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1237 return win
->GetLabel() == label
;
1241 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1244 return win
->GetName() == label
;
1248 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1251 return win
->GetId() == id
;
1254 // recursive helper for the FindWindowByXXX() functions
1256 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1257 const wxString
& label
,
1259 wxFindWindowCmp cmp
)
1263 // see if this is the one we're looking for
1264 if ( (*cmp
)(parent
, label
, id
) )
1265 return (wxWindow
*)parent
;
1267 // It wasn't, so check all its children
1268 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1270 node
= node
->GetNext() )
1272 // recursively check each child
1273 wxWindow
*win
= (wxWindow
*)node
->GetData();
1274 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1284 // helper for FindWindowByXXX()
1286 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1287 const wxString
& label
,
1289 wxFindWindowCmp cmp
)
1293 // just check parent and all its children
1294 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1297 // start at very top of wx's windows
1298 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1300 node
= node
->GetNext() )
1302 // recursively check each window & its children
1303 wxWindow
*win
= node
->GetData();
1304 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1314 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1316 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1321 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1323 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1327 // fall back to the label
1328 win
= FindWindowByLabel(title
, parent
);
1336 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1338 return wxFindWindowHelper(parent
, _T(""), id
, wxFindWindowCmpIds
);
1341 // ----------------------------------------------------------------------------
1342 // dialog oriented functions
1343 // ----------------------------------------------------------------------------
1345 void wxWindowBase::MakeModal(bool modal
)
1347 // Disable all other windows
1350 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1353 wxWindow
*win
= node
->GetData();
1355 win
->Enable(!modal
);
1357 node
= node
->GetNext();
1362 bool wxWindowBase::Validate()
1364 #if wxUSE_VALIDATORS
1365 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1367 wxWindowList::compatibility_iterator node
;
1368 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1370 wxWindowBase
*child
= node
->GetData();
1371 wxValidator
*validator
= child
->GetValidator();
1372 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1377 if ( recurse
&& !child
->Validate() )
1382 #endif // wxUSE_VALIDATORS
1387 bool wxWindowBase::TransferDataToWindow()
1389 #if wxUSE_VALIDATORS
1390 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1392 wxWindowList::compatibility_iterator node
;
1393 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1395 wxWindowBase
*child
= node
->GetData();
1396 wxValidator
*validator
= child
->GetValidator();
1397 if ( validator
&& !validator
->TransferToWindow() )
1399 wxLogWarning(_("Could not transfer data to window"));
1401 wxLog::FlushActive();
1409 if ( !child
->TransferDataToWindow() )
1411 // warning already given
1416 #endif // wxUSE_VALIDATORS
1421 bool wxWindowBase::TransferDataFromWindow()
1423 #if wxUSE_VALIDATORS
1424 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1426 wxWindowList::compatibility_iterator node
;
1427 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1429 wxWindow
*child
= node
->GetData();
1430 wxValidator
*validator
= child
->GetValidator();
1431 if ( validator
&& !validator
->TransferFromWindow() )
1433 // nop warning here because the application is supposed to give
1434 // one itself - we don't know here what might have gone wrongly
1441 if ( !child
->TransferDataFromWindow() )
1443 // warning already given
1448 #endif // wxUSE_VALIDATORS
1453 void wxWindowBase::InitDialog()
1455 wxInitDialogEvent
event(GetId());
1456 event
.SetEventObject( this );
1457 GetEventHandler()->ProcessEvent(event
);
1460 // ----------------------------------------------------------------------------
1461 // context-sensitive help support
1462 // ----------------------------------------------------------------------------
1466 // associate this help text with this window
1467 void wxWindowBase::SetHelpText(const wxString
& text
)
1469 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1472 helpProvider
->AddHelp(this, text
);
1476 // associate this help text with all windows with the same id as this
1478 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1480 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1483 helpProvider
->AddHelp(GetId(), text
);
1487 // get the help string associated with this window (may be empty)
1488 wxString
wxWindowBase::GetHelpText() const
1491 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1494 text
= helpProvider
->GetHelp(this);
1500 // show help for this window
1501 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1503 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1506 if ( helpProvider
->ShowHelp(this) )
1508 // skip the event.Skip() below
1516 #endif // wxUSE_HELP
1518 // ----------------------------------------------------------------------------
1519 // tooltipsroot.Replace("\\", "/");
1520 // ----------------------------------------------------------------------------
1524 void wxWindowBase::SetToolTip( const wxString
&tip
)
1526 // don't create the new tooltip if we already have one
1529 m_tooltip
->SetTip( tip
);
1533 SetToolTip( new wxToolTip( tip
) );
1536 // setting empty tooltip text does not remove the tooltip any more - use
1537 // SetToolTip((wxToolTip *)NULL) for this
1540 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1545 m_tooltip
= tooltip
;
1548 #endif // wxUSE_TOOLTIPS
1550 // ----------------------------------------------------------------------------
1551 // constraints and sizers
1552 // ----------------------------------------------------------------------------
1554 #if wxUSE_CONSTRAINTS
1556 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1558 if ( m_constraints
)
1560 UnsetConstraints(m_constraints
);
1561 delete m_constraints
;
1563 m_constraints
= constraints
;
1564 if ( m_constraints
)
1566 // Make sure other windows know they're part of a 'meaningful relationship'
1567 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1568 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1569 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1570 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1571 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1572 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1573 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1574 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1575 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1576 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1577 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1578 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1579 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1580 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1581 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1582 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1586 // This removes any dangling pointers to this window in other windows'
1587 // constraintsInvolvedIn lists.
1588 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1592 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1593 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1594 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1595 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1596 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1597 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1598 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1599 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1600 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1601 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1602 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1603 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1604 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1605 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1606 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1607 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1611 // Back-pointer to other windows we're involved with, so if we delete this
1612 // window, we must delete any constraints we're involved with.
1613 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
1615 if ( !m_constraintsInvolvedIn
)
1616 m_constraintsInvolvedIn
= new wxWindowList
;
1617 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
1618 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
1621 // REMOVE back-pointer to other windows we're involved with.
1622 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
1624 if ( m_constraintsInvolvedIn
)
1625 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
1628 // Reset any constraints that mention this window
1629 void wxWindowBase::DeleteRelatedConstraints()
1631 if ( m_constraintsInvolvedIn
)
1633 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
1636 wxWindow
*win
= node
->GetData();
1637 wxLayoutConstraints
*constr
= win
->GetConstraints();
1639 // Reset any constraints involving this window
1642 constr
->left
.ResetIfWin(this);
1643 constr
->top
.ResetIfWin(this);
1644 constr
->right
.ResetIfWin(this);
1645 constr
->bottom
.ResetIfWin(this);
1646 constr
->width
.ResetIfWin(this);
1647 constr
->height
.ResetIfWin(this);
1648 constr
->centreX
.ResetIfWin(this);
1649 constr
->centreY
.ResetIfWin(this);
1652 wxWindowList::compatibility_iterator next
= node
->GetNext();
1653 m_constraintsInvolvedIn
->Erase(node
);
1657 delete m_constraintsInvolvedIn
;
1658 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
1662 #endif // wxUSE_CONSTRAINTS
1664 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
1666 if ( sizer
== m_windowSizer
)
1670 delete m_windowSizer
;
1672 m_windowSizer
= sizer
;
1674 SetAutoLayout( sizer
!= NULL
);
1677 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
1679 SetSizer( sizer
, deleteOld
);
1680 sizer
->SetSizeHints( (wxWindow
*) this );
1684 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
1686 // adding a window to a sizer twice is going to result in fatal and
1687 // hard to debug problems later because when deleting the second
1688 // associated wxSizerItem we're going to dereference a dangling
1689 // pointer; so try to detect this as early as possible
1690 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
1691 _T("Adding a window to the same sizer twice?") );
1693 m_containingSizer
= sizer
;
1696 #if wxUSE_CONSTRAINTS
1698 void wxWindowBase::SatisfyConstraints()
1700 wxLayoutConstraints
*constr
= GetConstraints();
1701 bool wasOk
= constr
&& constr
->AreSatisfied();
1703 ResetConstraints(); // Mark all constraints as unevaluated
1707 // if we're a top level panel (i.e. our parent is frame/dialog), our
1708 // own constraints will never be satisfied any more unless we do it
1712 while ( noChanges
> 0 )
1714 LayoutPhase1(&noChanges
);
1718 LayoutPhase2(&noChanges
);
1721 #endif // wxUSE_CONSTRAINTS
1723 bool wxWindowBase::Layout()
1725 // If there is a sizer, use it instead of the constraints
1729 GetVirtualSize(&w
, &h
);
1730 GetSizer()->SetDimension( 0, 0, w
, h
);
1732 #if wxUSE_CONSTRAINTS
1735 SatisfyConstraints(); // Find the right constraints values
1736 SetConstraintSizes(); // Recursively set the real window sizes
1743 #if wxUSE_CONSTRAINTS
1745 // first phase of the constraints evaluation: set our own constraints
1746 bool wxWindowBase::LayoutPhase1(int *noChanges
)
1748 wxLayoutConstraints
*constr
= GetConstraints();
1750 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
1753 // second phase: set the constraints for our children
1754 bool wxWindowBase::LayoutPhase2(int *noChanges
)
1761 // Layout grand children
1767 // Do a phase of evaluating child constraints
1768 bool wxWindowBase::DoPhase(int phase
)
1770 // the list containing the children for which the constraints are already
1772 wxWindowList succeeded
;
1774 // the max number of iterations we loop before concluding that we can't set
1776 static const int maxIterations
= 500;
1778 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
1782 // loop over all children setting their constraints
1783 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1785 node
= node
->GetNext() )
1787 wxWindow
*child
= node
->GetData();
1788 if ( child
->IsTopLevel() )
1790 // top level children are not inside our client area
1794 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
1796 // this one is either already ok or nothing we can do about it
1800 int tempNoChanges
= 0;
1801 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
1802 : child
->LayoutPhase2(&tempNoChanges
);
1803 noChanges
+= tempNoChanges
;
1807 succeeded
.Append(child
);
1813 // constraints are set
1821 void wxWindowBase::ResetConstraints()
1823 wxLayoutConstraints
*constr
= GetConstraints();
1826 constr
->left
.SetDone(false);
1827 constr
->top
.SetDone(false);
1828 constr
->right
.SetDone(false);
1829 constr
->bottom
.SetDone(false);
1830 constr
->width
.SetDone(false);
1831 constr
->height
.SetDone(false);
1832 constr
->centreX
.SetDone(false);
1833 constr
->centreY
.SetDone(false);
1836 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1839 wxWindow
*win
= node
->GetData();
1840 if ( !win
->IsTopLevel() )
1841 win
->ResetConstraints();
1842 node
= node
->GetNext();
1846 // Need to distinguish between setting the 'fake' size for windows and sizers,
1847 // and setting the real values.
1848 void wxWindowBase::SetConstraintSizes(bool recurse
)
1850 wxLayoutConstraints
*constr
= GetConstraints();
1851 if ( constr
&& constr
->AreSatisfied() )
1853 int x
= constr
->left
.GetValue();
1854 int y
= constr
->top
.GetValue();
1855 int w
= constr
->width
.GetValue();
1856 int h
= constr
->height
.GetValue();
1858 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
1859 (constr
->height
.GetRelationship() != wxAsIs
) )
1861 SetSize(x
, y
, w
, h
);
1865 // If we don't want to resize this window, just move it...
1871 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
1872 GetClassInfo()->GetClassName(),
1878 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1881 wxWindow
*win
= node
->GetData();
1882 if ( !win
->IsTopLevel() && win
->GetConstraints() )
1883 win
->SetConstraintSizes();
1884 node
= node
->GetNext();
1889 // Only set the size/position of the constraint (if any)
1890 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
1892 wxLayoutConstraints
*constr
= GetConstraints();
1895 if ( x
!= wxDefaultCoord
)
1897 constr
->left
.SetValue(x
);
1898 constr
->left
.SetDone(true);
1900 if ( y
!= wxDefaultCoord
)
1902 constr
->top
.SetValue(y
);
1903 constr
->top
.SetDone(true);
1905 if ( w
!= wxDefaultCoord
)
1907 constr
->width
.SetValue(w
);
1908 constr
->width
.SetDone(true);
1910 if ( h
!= wxDefaultCoord
)
1912 constr
->height
.SetValue(h
);
1913 constr
->height
.SetDone(true);
1918 void wxWindowBase::MoveConstraint(int x
, int y
)
1920 wxLayoutConstraints
*constr
= GetConstraints();
1923 if ( x
!= wxDefaultCoord
)
1925 constr
->left
.SetValue(x
);
1926 constr
->left
.SetDone(true);
1928 if ( y
!= wxDefaultCoord
)
1930 constr
->top
.SetValue(y
);
1931 constr
->top
.SetDone(true);
1936 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
1938 wxLayoutConstraints
*constr
= GetConstraints();
1941 *w
= constr
->width
.GetValue();
1942 *h
= constr
->height
.GetValue();
1948 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
1950 wxLayoutConstraints
*constr
= GetConstraints();
1953 *w
= constr
->width
.GetValue();
1954 *h
= constr
->height
.GetValue();
1957 GetClientSize(w
, h
);
1960 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
1962 wxLayoutConstraints
*constr
= GetConstraints();
1965 *x
= constr
->left
.GetValue();
1966 *y
= constr
->top
.GetValue();
1972 #endif // wxUSE_CONSTRAINTS
1974 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
1976 // don't do it for the dialogs/frames - they float independently of their
1978 if ( !IsTopLevel() )
1980 wxWindow
*parent
= GetParent();
1981 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
1983 wxPoint
pt(parent
->GetClientAreaOrigin());
1990 // ----------------------------------------------------------------------------
1991 // do Update UI processing for child controls
1992 // ----------------------------------------------------------------------------
1994 void wxWindowBase::UpdateWindowUI(long flags
)
1996 wxUpdateUIEvent
event(GetId());
1997 event
.m_eventObject
= this;
1999 if ( GetEventHandler()->ProcessEvent(event
) )
2001 DoUpdateWindowUI(event
);
2004 if (flags
& wxUPDATE_UI_RECURSE
)
2006 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2009 wxWindow
* child
= (wxWindow
*) node
->GetData();
2010 child
->UpdateWindowUI(flags
);
2011 node
= node
->GetNext();
2016 // do the window-specific processing after processing the update event
2017 // TODO: take specific knowledge out of this function and
2018 // put in each control's base class. Unfortunately we don't
2019 // yet have base implementation files for wxCheckBox and wxRadioButton.
2020 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
2022 if ( event
.GetSetEnabled() )
2023 Enable(event
.GetEnabled());
2026 if ( event
.GetSetText() )
2028 wxControl
*control
= wxDynamicCastThis(wxControl
);
2031 if ( event
.GetText() != control
->GetLabel() )
2032 control
->SetLabel(event
.GetText());
2035 wxCheckBox
*checkbox
= wxDynamicCastThis(wxCheckBox
);
2038 if ( event
.GetSetChecked() )
2039 checkbox
->SetValue(event
.GetChecked());
2041 #endif // wxUSE_CHECKBOX
2044 wxRadioButton
*radiobtn
= wxDynamicCastThis(wxRadioButton
);
2047 if ( event
.GetSetChecked() )
2048 radiobtn
->SetValue(event
.GetChecked());
2050 #endif // wxUSE_RADIOBTN
2056 // call internal idle recursively
2057 // may be obsolete (wait until OnIdle scheme stabilises)
2058 void wxWindowBase::ProcessInternalIdle()
2062 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2065 wxWindow
*child
= node
->GetData();
2066 child
->ProcessInternalIdle();
2067 node
= node
->GetNext();
2072 // ----------------------------------------------------------------------------
2073 // dialog units translations
2074 // ----------------------------------------------------------------------------
2076 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
2078 int charWidth
= GetCharWidth();
2079 int charHeight
= GetCharHeight();
2080 wxPoint
pt2(-1, -1);
2082 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
);
2084 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2089 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2091 int charWidth
= GetCharWidth();
2092 int charHeight
= GetCharHeight();
2093 wxPoint
pt2(-1, -1);
2095 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2097 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2102 // ----------------------------------------------------------------------------
2104 // ----------------------------------------------------------------------------
2106 // propagate the colour change event to the subwindows
2107 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2109 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2112 // Only propagate to non-top-level windows
2113 wxWindow
*win
= node
->GetData();
2114 if ( !win
->IsTopLevel() )
2116 wxSysColourChangedEvent event2
;
2117 event
.m_eventObject
= win
;
2118 win
->GetEventHandler()->ProcessEvent(event2
);
2121 node
= node
->GetNext();
2127 // the default action is to populate dialog with data when it's created,
2128 // and nudge the UI into displaying itself correctly in case
2129 // we've turned the wxUpdateUIEvents frequency down low.
2130 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2132 TransferDataToWindow();
2134 // Update the UI at this point
2135 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2138 // process Ctrl-Alt-mclick
2139 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2142 if ( event
.ControlDown() && event
.AltDown() )
2144 // don't translate these strings
2147 #ifdef __WXUNIVERSAL__
2149 #endif // __WXUNIVERSAL__
2151 switch ( wxGetOsVersion() )
2153 case wxMOTIF_X
: port
+= _T("Motif"); break;
2155 case wxMAC_DARWIN
: port
+= _T("Mac"); break;
2156 case wxBEOS
: port
+= _T("BeOS"); break;
2160 case wxGTK_BEOS
: port
+= _T("GTK"); break;
2166 case wxWIN386
: port
+= _T("MS Windows"); break;
2170 case wxMGL_OS2
: port
+= _T("MGL"); break;
2172 case wxOS2_PM
: port
+= _T("OS/2"); break;
2173 default: port
+= _T("unknown"); break;
2176 wxMessageBox(wxString::Format(
2178 " wxWidgets Library (%s port)\nVersion %u.%u.%u%s, compiled at %s %s\n Copyright (c) 1995-2002 wxWidgets team"
2192 _T("wxWidgets information"),
2193 wxICON_INFORMATION
| wxOK
,
2197 #endif // wxUSE_MSGDLG
2203 // ----------------------------------------------------------------------------
2205 // ----------------------------------------------------------------------------
2207 #if wxUSE_ACCESSIBILITY
2208 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2210 if (m_accessible
&& (accessible
!= m_accessible
))
2211 delete m_accessible
;
2212 m_accessible
= accessible
;
2214 m_accessible
->SetWindow((wxWindow
*) this);
2217 // Returns the accessible object, creating if necessary.
2218 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2221 m_accessible
= CreateAccessible();
2222 return m_accessible
;
2225 // Override to create a specific accessible object.
2226 wxAccessible
* wxWindowBase::CreateAccessible()
2228 return new wxWindowAccessible((wxWindow
*) this);
2234 // ----------------------------------------------------------------------------
2235 // list classes implementation
2236 // ----------------------------------------------------------------------------
2238 void wxWindowListNode::DeleteData()
2240 delete (wxWindow
*)GetData();
2244 // ----------------------------------------------------------------------------
2246 // ----------------------------------------------------------------------------
2248 wxBorder
wxWindowBase::GetBorder(long flags
) const
2250 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2251 if ( border
== wxBORDER_DEFAULT
)
2253 border
= GetDefaultBorder();
2259 wxBorder
wxWindowBase::GetDefaultBorder() const
2261 return wxBORDER_NONE
;
2264 // ----------------------------------------------------------------------------
2266 // ----------------------------------------------------------------------------
2268 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2270 // here we just check if the point is inside the window or not
2272 // check the top and left border first
2273 bool outside
= x
< 0 || y
< 0;
2276 // check the right and bottom borders too
2277 wxSize size
= GetSize();
2278 outside
= x
>= size
.x
|| y
>= size
.y
;
2281 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2284 // ----------------------------------------------------------------------------
2286 // ----------------------------------------------------------------------------
2288 struct WXDLLEXPORT wxWindowNext
2292 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2294 void wxWindowBase::CaptureMouse()
2296 wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), this);
2298 wxWindow
*winOld
= GetCapture();
2301 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2304 wxWindowNext
*item
= new wxWindowNext
;
2306 item
->next
= ms_winCaptureNext
;
2307 ms_winCaptureNext
= item
;
2309 //else: no mouse capture to save
2314 void wxWindowBase::ReleaseMouse()
2316 wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), this);
2318 wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") );
2322 if ( ms_winCaptureNext
)
2324 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2326 wxWindowNext
*item
= ms_winCaptureNext
;
2327 ms_winCaptureNext
= item
->next
;
2330 //else: stack is empty, no previous capture
2332 wxLogTrace(_T("mousecapture"),
2333 (const wxChar
*) _T("After ReleaseMouse() mouse is captured by %p"),
2340 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2341 int WXUNUSED(modifiers
),
2342 int WXUNUSED(keycode
))
2348 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2354 #endif // wxUSE_HOTKEY
2356 void wxWindowBase::SendDestroyEvent()
2358 wxWindowDestroyEvent event
;
2359 event
.SetEventObject(this);
2360 event
.SetId(GetId());
2361 GetEventHandler()->ProcessEvent(event
);
2364 // ----------------------------------------------------------------------------
2366 // ----------------------------------------------------------------------------
2368 bool wxWindowBase::TryValidator(wxEvent
& wxVALIDATOR_PARAM(event
))
2370 #if wxUSE_VALIDATORS
2371 // Can only use the validator of the window which
2372 // is receiving the event
2373 if ( event
.GetEventObject() == this )
2375 wxValidator
*validator
= GetValidator();
2376 if ( validator
&& validator
->ProcessEvent(event
) )
2381 #endif // wxUSE_VALIDATORS
2386 bool wxWindowBase::TryParent(wxEvent
& event
)
2388 // carry on up the parent-child hierarchy if the propgation count hasn't
2390 if ( event
.ShouldPropagate() )
2392 // honour the requests to stop propagation at this window: this is
2393 // used by the dialogs, for example, to prevent processing the events
2394 // from the dialog controls in the parent frame which rarely, if ever,
2396 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2398 wxWindow
*parent
= GetParent();
2399 if ( parent
&& !parent
->IsBeingDeleted() )
2401 wxPropagateOnce
propagateOnce(event
);
2403 return parent
->GetEventHandler()->ProcessEvent(event
);
2408 return wxEvtHandler::TryParent(event
);
2411 // ----------------------------------------------------------------------------
2412 // keyboard navigation
2413 // ----------------------------------------------------------------------------
2415 // Navigates in the specified direction.
2416 bool wxWindowBase::Navigate(int flags
)
2418 wxNavigationKeyEvent eventNav
;
2419 eventNav
.SetFlags(flags
);
2420 eventNav
.SetEventObject(this);
2421 if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav
) )
2428 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, MoveKind move
)
2430 // check that we're not a top level window
2431 wxCHECK_RET( GetParent(),
2432 _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
2434 // find the target window in the siblings list
2435 wxWindowList
& siblings
= GetParent()->GetChildren();
2436 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
2437 wxCHECK_RET( i
, _T("MoveBefore/AfterInTabOrder(): win is not a sibling") );
2439 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
2440 // can't just move the node around
2441 wxWindow
*self
= (wxWindow
*)this;
2442 siblings
.DeleteObject(self
);
2443 if ( move
== MoveAfter
)
2450 siblings
.Insert(i
, self
);
2452 else // MoveAfter and win was the last sibling
2454 siblings
.Append(self
);
2458 // ----------------------------------------------------------------------------
2460 // ----------------------------------------------------------------------------
2462 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
2464 while ( win
&& !win
->IsTopLevel() )
2465 win
= win
->GetParent();
2470 #if wxUSE_ACCESSIBILITY
2471 // ----------------------------------------------------------------------------
2472 // accessible object for windows
2473 // ----------------------------------------------------------------------------
2475 // Can return either a child object, or an integer
2476 // representing the child element, starting from 1.
2477 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
2479 wxASSERT( GetWindow() != NULL
);
2483 return wxACC_NOT_IMPLEMENTED
;
2486 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
2487 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
2489 wxASSERT( GetWindow() != NULL
);
2493 wxWindow
* win
= NULL
;
2500 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
2502 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
2509 rect
= win
->GetRect();
2510 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
2511 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
2515 return wxACC_NOT_IMPLEMENTED
;
2518 // Navigates from fromId to toId/toObject.
2519 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
2520 int* WXUNUSED(toId
), wxAccessible
** toObject
)
2522 wxASSERT( GetWindow() != NULL
);
2528 case wxNAVDIR_FIRSTCHILD
:
2530 if (GetWindow()->GetChildren().GetCount() == 0)
2532 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
2533 *toObject
= childWindow
->GetOrCreateAccessible();
2537 case wxNAVDIR_LASTCHILD
:
2539 if (GetWindow()->GetChildren().GetCount() == 0)
2541 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
2542 *toObject
= childWindow
->GetOrCreateAccessible();
2546 case wxNAVDIR_RIGHT
:
2550 wxWindowList::compatibility_iterator node
=
2551 wxWindowList::compatibility_iterator();
2554 // Can't navigate to sibling of this window
2555 // if we're a top-level window.
2556 if (!GetWindow()->GetParent())
2557 return wxACC_NOT_IMPLEMENTED
;
2559 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2563 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2564 node
= GetWindow()->GetChildren().Item(fromId
-1);
2567 if (node
&& node
->GetNext())
2569 wxWindow
* nextWindow
= node
->GetNext()->GetData();
2570 *toObject
= nextWindow
->GetOrCreateAccessible();
2578 case wxNAVDIR_PREVIOUS
:
2580 wxWindowList::compatibility_iterator node
=
2581 wxWindowList::compatibility_iterator();
2584 // Can't navigate to sibling of this window
2585 // if we're a top-level window.
2586 if (!GetWindow()->GetParent())
2587 return wxACC_NOT_IMPLEMENTED
;
2589 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2593 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2594 node
= GetWindow()->GetChildren().Item(fromId
-1);
2597 if (node
&& node
->GetPrevious())
2599 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
2600 *toObject
= previousWindow
->GetOrCreateAccessible();
2608 return wxACC_NOT_IMPLEMENTED
;
2611 // Gets the name of the specified object.
2612 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
2614 wxASSERT( GetWindow() != NULL
);
2620 // If a child, leave wxWidgets to call the function on the actual
2623 return wxACC_NOT_IMPLEMENTED
;
2625 // This will eventually be replaced by specialised
2626 // accessible classes, one for each kind of wxWidgets
2627 // control or window.
2629 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
2630 title
= ((wxButton
*) GetWindow())->GetLabel();
2633 title
= GetWindow()->GetName();
2635 if (!title
.IsEmpty())
2641 return wxACC_NOT_IMPLEMENTED
;
2644 // Gets the number of children.
2645 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
2647 wxASSERT( GetWindow() != NULL
);
2651 *childId
= (int) GetWindow()->GetChildren().GetCount();
2655 // Gets the specified child (starting from 1).
2656 // If *child is NULL and return value is wxACC_OK,
2657 // this means that the child is a simple element and
2658 // not an accessible object.
2659 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
2661 wxASSERT( GetWindow() != NULL
);
2671 if (childId
> (int) GetWindow()->GetChildren().GetCount())
2674 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
2675 *child
= childWindow
->GetOrCreateAccessible();
2682 // Gets the parent, or NULL.
2683 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
2685 wxASSERT( GetWindow() != NULL
);
2689 wxWindow
* parentWindow
= GetWindow()->GetParent();
2697 *parent
= parentWindow
->GetOrCreateAccessible();
2705 // Performs the default action. childId is 0 (the action for this object)
2706 // or > 0 (the action for a child).
2707 // Return wxACC_NOT_SUPPORTED if there is no default action for this
2708 // window (e.g. an edit control).
2709 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
2711 wxASSERT( GetWindow() != NULL
);
2715 return wxACC_NOT_IMPLEMENTED
;
2718 // Gets the default action for this object (0) or > 0 (the action for a child).
2719 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
2720 // string if there is no action.
2721 // The retrieved string describes the action that is performed on an object,
2722 // not what the object does as a result. For example, a toolbar button that prints
2723 // a document has a default action of "Press" rather than "Prints the current document."
2724 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
2726 wxASSERT( GetWindow() != NULL
);
2730 return wxACC_NOT_IMPLEMENTED
;
2733 // Returns the description for this object or a child.
2734 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
2736 wxASSERT( GetWindow() != NULL
);
2740 wxString
ht(GetWindow()->GetHelpText());
2746 return wxACC_NOT_IMPLEMENTED
;
2749 // Returns help text for this object or a child, similar to tooltip text.
2750 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
2752 wxASSERT( GetWindow() != NULL
);
2756 wxString
ht(GetWindow()->GetHelpText());
2762 return wxACC_NOT_IMPLEMENTED
;
2765 // Returns the keyboard shortcut for this object or child.
2766 // Return e.g. ALT+K
2767 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
2769 wxASSERT( GetWindow() != NULL
);
2773 return wxACC_NOT_IMPLEMENTED
;
2776 // Returns a role constant.
2777 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
2779 wxASSERT( GetWindow() != NULL
);
2783 // If a child, leave wxWidgets to call the function on the actual
2786 return wxACC_NOT_IMPLEMENTED
;
2788 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2789 return wxACC_NOT_IMPLEMENTED
;
2791 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2792 return wxACC_NOT_IMPLEMENTED
;
2795 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2796 return wxACC_NOT_IMPLEMENTED
;
2799 //*role = wxROLE_SYSTEM_CLIENT;
2800 *role
= wxROLE_SYSTEM_CLIENT
;
2804 return wxACC_NOT_IMPLEMENTED
;
2808 // Returns a state constant.
2809 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
2811 wxASSERT( GetWindow() != NULL
);
2815 // If a child, leave wxWidgets to call the function on the actual
2818 return wxACC_NOT_IMPLEMENTED
;
2820 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2821 return wxACC_NOT_IMPLEMENTED
;
2824 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2825 return wxACC_NOT_IMPLEMENTED
;
2828 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2829 return wxACC_NOT_IMPLEMENTED
;
2836 return wxACC_NOT_IMPLEMENTED
;
2840 // Returns a localized string representing the value for the object
2842 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
2844 wxASSERT( GetWindow() != NULL
);
2848 return wxACC_NOT_IMPLEMENTED
;
2851 // Selects the object or child.
2852 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
2854 wxASSERT( GetWindow() != NULL
);
2858 return wxACC_NOT_IMPLEMENTED
;
2861 // Gets the window with the keyboard focus.
2862 // If childId is 0 and child is NULL, no object in
2863 // this subhierarchy has the focus.
2864 // If this object has the focus, child should be 'this'.
2865 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
2867 wxASSERT( GetWindow() != NULL
);
2871 return wxACC_NOT_IMPLEMENTED
;
2874 // Gets a variant representing the selected children
2876 // Acceptable values:
2877 // - a null variant (IsNull() returns TRUE)
2878 // - a list variant (GetType() == wxT("list")
2879 // - an integer representing the selected child element,
2880 // or 0 if this object is selected (GetType() == wxT("long")
2881 // - a "void*" pointer to a wxAccessible child object
2882 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
2884 wxASSERT( GetWindow() != NULL
);
2888 return wxACC_NOT_IMPLEMENTED
;
2891 #endif // wxUSE_ACCESSIBILITY