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 #if wxUSE_SYSTEM_OPTIONS
81 #include "wx/sysopt.h"
84 // ----------------------------------------------------------------------------
86 // ----------------------------------------------------------------------------
89 int wxWindowBase::ms_lastControlId
= 2000;
91 int wxWindowBase::ms_lastControlId
= -200;
94 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase
, wxEvtHandler
)
96 // ----------------------------------------------------------------------------
98 // ----------------------------------------------------------------------------
100 BEGIN_EVENT_TABLE(wxWindowBase
, wxEvtHandler
)
101 EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged
)
102 EVT_INIT_DIALOG(wxWindowBase::OnInitDialog
)
103 EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick
)
106 EVT_HELP(wxID_ANY
, wxWindowBase::OnHelp
)
111 // ============================================================================
112 // implementation of the common functionality of the wxWindow class
113 // ============================================================================
115 // ----------------------------------------------------------------------------
117 // ----------------------------------------------------------------------------
119 // the default initialization
120 wxWindowBase::wxWindowBase()
122 // no window yet, no parent nor children
123 m_parent
= (wxWindow
*)NULL
;
124 m_windowId
= wxID_ANY
;
126 // no constraints on the minimal window size
128 m_maxWidth
= wxDefaultCoord
;
130 m_maxHeight
= wxDefaultCoord
;
132 // invalidiated cache value
133 m_bestSizeCache
= wxDefaultSize
;
135 // window are created enabled and visible by default
139 // the default event handler is just this window
140 m_eventHandler
= this;
144 m_windowValidator
= (wxValidator
*) NULL
;
145 #endif // wxUSE_VALIDATORS
147 // the colours/fonts are default for now, so leave m_font,
148 // m_backgroundColour and m_foregroundColour uninitialized and set those
154 m_inheritFont
= false;
160 m_backgroundStyle
= wxBG_STYLE_SYSTEM
;
162 #if wxUSE_CONSTRAINTS
163 // no constraints whatsoever
164 m_constraints
= (wxLayoutConstraints
*) NULL
;
165 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
166 #endif // wxUSE_CONSTRAINTS
168 m_windowSizer
= (wxSizer
*) NULL
;
169 m_containingSizer
= (wxSizer
*) NULL
;
170 m_autoLayout
= false;
172 #if wxUSE_DRAG_AND_DROP
173 m_dropTarget
= (wxDropTarget
*)NULL
;
174 #endif // wxUSE_DRAG_AND_DROP
177 m_tooltip
= (wxToolTip
*)NULL
;
178 #endif // wxUSE_TOOLTIPS
181 m_caret
= (wxCaret
*)NULL
;
182 #endif // wxUSE_CARET
185 m_hasCustomPalette
= false;
186 #endif // wxUSE_PALETTE
188 #if wxUSE_ACCESSIBILITY
192 m_virtualSize
= wxDefaultSize
;
195 m_maxVirtualWidth
= wxDefaultCoord
;
197 m_maxVirtualHeight
= wxDefaultCoord
;
199 m_windowVariant
= wxWINDOW_VARIANT_NORMAL
;
200 #if wxUSE_SYSTEM_OPTIONS
201 if ( wxSystemOptions::HasOption(wxWINDOW_DEFAULT_VARIANT
) )
203 m_windowVariant
= (wxWindowVariant
) wxSystemOptions::GetOptionInt( wxWINDOW_DEFAULT_VARIANT
) ;
207 // Whether we're using the current theme for this window (wxGTK only for now)
208 m_themeEnabled
= false;
210 // VZ: this one shouldn't exist...
211 m_isBeingDeleted
= false;
214 // common part of window creation process
215 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
217 const wxPoint
& WXUNUSED(pos
),
218 const wxSize
& WXUNUSED(size
),
220 const wxValidator
& wxVALIDATOR_PARAM(validator
),
221 const wxString
& name
)
224 // wxGTK doesn't allow to create controls with static box as the parent so
225 // this will result in a crash when the program is ported to wxGTK so warn
228 // if you get this assert, the correct solution is to create the controls
229 // as siblings of the static box
230 wxASSERT_MSG( !parent
|| !wxDynamicCast(parent
, wxStaticBox
),
231 _T("wxStaticBox can't be used as a window parent!") );
232 #endif // wxUSE_STATBOX
234 // ids are limited to 16 bits under MSW so if you care about portability,
235 // it's not a good idea to use ids out of this range (and negative ids are
236 // reserved for wxWidgets own usage)
237 wxASSERT_MSG( id
== wxID_ANY
|| (id
>= 0 && id
< 32767),
238 _T("invalid id value") );
240 // generate a new id if the user doesn't care about it
241 m_windowId
= id
== wxID_ANY
? NewControlId() : id
;
244 SetWindowStyleFlag(style
);
248 SetValidator(validator
);
249 #endif // wxUSE_VALIDATORS
251 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
252 // have it too - like this it's possible to set it only in the top level
253 // dialog/frame and all children will inherit it by defult
254 if ( parent
&& (parent
->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) )
256 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY
);
262 // ----------------------------------------------------------------------------
264 // ----------------------------------------------------------------------------
267 wxWindowBase::~wxWindowBase()
269 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
271 // FIXME if these 2 cases result from programming errors in the user code
272 // we should probably assert here instead of silently fixing them
274 // Just in case the window has been Closed, but we're then deleting
275 // immediately: don't leave dangling pointers.
276 wxPendingDelete
.DeleteObject(this);
278 // Just in case we've loaded a top-level window via LoadNativeDialog but
279 // we weren't a dialog class
280 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
282 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
284 // reset the dangling pointer our parent window may keep to us
287 if ( m_parent
->GetDefaultItem() == this )
289 m_parent
->SetDefaultItem(NULL
);
292 m_parent
->RemoveChild(this);
297 #endif // wxUSE_CARET
300 delete m_windowValidator
;
301 #endif // wxUSE_VALIDATORS
303 #if wxUSE_CONSTRAINTS
304 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
305 // at deleted windows as they delete themselves.
306 DeleteRelatedConstraints();
310 // This removes any dangling pointers to this window in other windows'
311 // constraintsInvolvedIn lists.
312 UnsetConstraints(m_constraints
);
313 delete m_constraints
;
314 m_constraints
= NULL
;
316 #endif // wxUSE_CONSTRAINTS
318 if ( m_containingSizer
)
319 m_containingSizer
->Detach( (wxWindow
*)this );
321 delete m_windowSizer
;
323 #if wxUSE_DRAG_AND_DROP
325 #endif // wxUSE_DRAG_AND_DROP
329 #endif // wxUSE_TOOLTIPS
331 #if wxUSE_ACCESSIBILITY
336 bool wxWindowBase::Destroy()
343 bool wxWindowBase::Close(bool force
)
345 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
346 event
.SetEventObject(this);
347 event
.SetCanVeto(!force
);
349 // return false if window wasn't closed because the application vetoed the
351 return GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto();
354 bool wxWindowBase::DestroyChildren()
356 wxWindowList::compatibility_iterator node
;
359 // we iterate until the list becomes empty
360 node
= GetChildren().GetFirst();
364 wxWindow
*child
= node
->GetData();
366 // note that we really want to call delete and not ->Destroy() here
367 // because we want to delete the child immediately, before we are
368 // deleted, and delayed deletion would result in problems as our (top
369 // level) child could outlive its parent
372 wxASSERT_MSG( !GetChildren().Find(child
),
373 wxT("child didn't remove itself using RemoveChild()") );
379 // ----------------------------------------------------------------------------
380 // size/position related methods
381 // ----------------------------------------------------------------------------
383 // centre the window with respect to its parent in either (or both) directions
384 void wxWindowBase::Centre(int direction
)
386 // the position/size of the parent window or of the entire screen
388 int widthParent
, heightParent
;
390 wxWindow
*parent
= NULL
;
392 if ( !(direction
& wxCENTRE_ON_SCREEN
) )
394 // find the parent to centre this window on: it should be the
395 // immediate parent for the controls but the top level parent for the
396 // top level windows (like dialogs)
397 parent
= GetParent();
400 while ( parent
&& !parent
->IsTopLevel() )
402 parent
= parent
->GetParent();
406 // there is no wxTopLevelWindow under wxMotif yet
408 // we shouldn't center the dialog on the iconized window: under
409 // Windows, for example, this places it completely off the screen
412 wxTopLevelWindow
*winTop
= wxDynamicCast(parent
, wxTopLevelWindow
);
413 if ( winTop
&& winTop
->IsIconized() )
418 #endif // __WXMOTIF__
420 // did we find the parent?
424 direction
|= wxCENTRE_ON_SCREEN
;
428 if ( direction
& wxCENTRE_ON_SCREEN
)
430 // centre with respect to the whole screen
431 wxDisplaySize(&widthParent
, &heightParent
);
437 // centre on the parent
438 parent
->GetSize(&widthParent
, &heightParent
);
440 // adjust to the parents position
441 posParent
= parent
->GetPosition();
445 // centre inside the parents client rectangle
446 parent
->GetClientSize(&widthParent
, &heightParent
);
451 GetSize(&width
, &height
);
453 int xNew
= wxDefaultCoord
,
454 yNew
= wxDefaultCoord
;
456 if ( direction
& wxHORIZONTAL
)
457 xNew
= (widthParent
- width
)/2;
459 if ( direction
& wxVERTICAL
)
460 yNew
= (heightParent
- height
)/2;
465 // Base size of the visible dimensions of the display
466 // to take into account the taskbar. And the Mac menu bar at top.
467 wxRect clientrect
= wxGetClientDisplayRect();
469 // NB: in wxMSW, negative position may not neccessary mean "out of screen",
470 // but it may mean that the window is placed on other than the main
471 // display. Therefore we only make sure centered window is on the main display
472 // if the parent is at least partially present here.
473 if (posParent
.x
+ widthParent
>= 0) // if parent is (partially) on the main display
475 if (xNew
< clientrect
.GetLeft())
476 xNew
= clientrect
.GetLeft();
477 else if (xNew
+ width
> clientrect
.GetRight())
478 xNew
= clientrect
.GetRight() - width
;
480 if (posParent
.y
+ heightParent
>= 0) // if parent is (partially) on the main display
482 if (yNew
+ height
> clientrect
.GetBottom())
483 yNew
= clientrect
.GetBottom() - height
;
485 // Make certain that the title bar is initially visible
486 // always, even if this would push the bottom of the
487 // dialog off the visible area of the display
488 if (yNew
< clientrect
.GetTop())
489 yNew
= clientrect
.GetTop();
492 // move the window to this position (keeping the old size but using
493 // SetSize() and not Move() to allow xNew and/or yNew to be wxDefaultCoord)
494 SetSize(xNew
, yNew
, width
, height
, wxSIZE_ALLOW_MINUS_ONE
);
497 // fits the window around the children
498 void wxWindowBase::Fit()
500 if ( GetChildren().GetCount() > 0 )
502 SetClientSize(GetBestSize());
504 //else: do nothing if we have no children
507 // fits virtual size (ie. scrolled area etc.) around children
508 void wxWindowBase::FitInside()
510 if ( GetChildren().GetCount() > 0 )
512 SetVirtualSize( GetBestVirtualSize() );
516 // On Mac, scrollbars are explicitly children.
518 static bool wxHasRealChildren(const wxWindowBase
* win
)
520 int realChildCount
= 0;
522 for ( wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
524 node
= node
->GetNext() )
526 wxWindow
*win
= node
->GetData();
527 if ( !win
->IsTopLevel() && win
->IsShown() && !win
->IsKindOf(CLASSINFO(wxScrollBar
)))
530 return (realChildCount
> 0);
534 // return the size best suited for the current window
535 wxSize
wxWindowBase::DoGetBestSize() const
539 return m_windowSizer
->GetMinSize();
541 #if wxUSE_CONSTRAINTS
542 else if ( m_constraints
)
544 wxConstCast(this, wxWindowBase
)->SatisfyConstraints();
546 // our minimal acceptable size is such that all our windows fit inside
550 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
552 node
= node
->GetNext() )
554 wxLayoutConstraints
*c
= node
->GetData()->GetConstraints();
557 // it's not normal that we have an unconstrained child, but
558 // what can we do about it?
562 int x
= c
->right
.GetValue(),
563 y
= c
->bottom
.GetValue();
571 // TODO: we must calculate the overlaps somehow, otherwise we
572 // will never return a size bigger than the current one :-(
575 return wxSize(maxX
, maxY
);
577 #endif // wxUSE_CONSTRAINTS
578 else if ( !GetChildren().empty()
580 && wxHasRealChildren(this)
584 // our minimal acceptable size is such that all our visible child windows fit inside
588 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
590 node
= node
->GetNext() )
592 wxWindow
*win
= node
->GetData();
593 if ( win
->IsTopLevel() || ( ! win
->IsShown() )
595 || wxDynamicCast(win
, wxStatusBar
)
596 #endif // wxUSE_STATUSBAR
599 // dialogs and frames lie in different top level windows -
600 // don't deal with them here; as for the status bars, they
601 // don't lie in the client area at all
606 win
->GetPosition(&wx
, &wy
);
608 // if the window hadn't been positioned yet, assume that it is in
610 if ( wx
== wxDefaultCoord
)
612 if ( wy
== wxDefaultCoord
)
615 win
->GetSize(&ww
, &wh
);
616 if ( wx
+ ww
> maxX
)
618 if ( wy
+ wh
> maxY
)
622 // for compatibility with the old versions and because it really looks
623 // slightly more pretty like this, add a pad
627 return wxSize(maxX
, maxY
);
629 else // ! has children
631 // for a generic window there is no natural best size - just use either the
632 // minimum size if there is one, or the current size
633 if ( GetMinSize().IsFullySpecified() )
641 wxSize
wxWindowBase::GetBestFittingSize() const
643 // merge the best size with the min size, giving priority to the min size
644 wxSize min
= GetMinSize();
645 if (min
.x
== wxDefaultCoord
|| min
.y
== wxDefaultCoord
)
647 wxSize best
= GetBestSize();
648 if (min
.x
== wxDefaultCoord
) min
.x
= best
.x
;
649 if (min
.y
== wxDefaultCoord
) min
.y
= best
.y
;
655 void wxWindowBase::SetBestFittingSize(const wxSize
& size
)
657 // Set the min size to the size passed in. This will usually either be
658 // wxDefaultSize or the size passed to this window's ctor/Create function.
661 // Merge the size with the best size if needed
662 wxSize best
= GetBestFittingSize();
664 // If the current size doesn't match then change it
665 if (GetSize() != best
)
670 // by default the origin is not shifted
671 wxPoint
wxWindowBase::GetClientAreaOrigin() const
673 return wxPoint(0, 0);
676 // set the min/max size of the window
677 void wxWindowBase::DoSetSizeHints(int minW
, int minH
,
679 int WXUNUSED(incW
), int WXUNUSED(incH
))
681 // setting min width greater than max width leads to infinite loops under
682 // X11 and generally doesn't make any sense, so don't allow it
683 wxCHECK_RET( (minW
== wxDefaultCoord
|| maxW
== wxDefaultCoord
|| minW
<= maxW
) &&
684 (minH
== wxDefaultCoord
|| maxH
== wxDefaultCoord
|| minH
<= maxH
),
685 _T("min width/height must be less than max width/height!") );
693 void wxWindowBase::SetWindowVariant( wxWindowVariant variant
)
695 if ( m_windowVariant
!= variant
)
697 m_windowVariant
= variant
;
699 DoSetWindowVariant(variant
);
703 void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant
)
705 // adjust the font height to correspond to our new variant (notice that
706 // we're only called if something really changed)
707 wxFont font
= GetFont();
708 int size
= font
.GetPointSize();
711 case wxWINDOW_VARIANT_NORMAL
:
714 case wxWINDOW_VARIANT_SMALL
:
719 case wxWINDOW_VARIANT_MINI
:
724 case wxWINDOW_VARIANT_LARGE
:
730 wxFAIL_MSG(_T("unexpected window variant"));
734 font
.SetPointSize(size
);
738 void wxWindowBase::SetVirtualSizeHints( int minW
, int minH
,
741 m_minVirtualWidth
= minW
;
742 m_maxVirtualWidth
= maxW
;
743 m_minVirtualHeight
= minH
;
744 m_maxVirtualHeight
= maxH
;
747 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
749 if ( m_minVirtualWidth
!= wxDefaultCoord
&& m_minVirtualWidth
> x
)
750 x
= m_minVirtualWidth
;
751 if ( m_maxVirtualWidth
!= wxDefaultCoord
&& m_maxVirtualWidth
< x
)
752 x
= m_maxVirtualWidth
;
753 if ( m_minVirtualHeight
!= wxDefaultCoord
&& m_minVirtualHeight
> y
)
754 y
= m_minVirtualHeight
;
755 if ( m_maxVirtualHeight
!= wxDefaultCoord
&& m_maxVirtualHeight
< y
)
756 y
= m_maxVirtualHeight
;
758 m_virtualSize
= wxSize(x
, y
);
761 wxSize
wxWindowBase::DoGetVirtualSize() const
763 wxSize
s( GetClientSize() );
765 return wxSize( wxMax( m_virtualSize
.GetWidth(), s
.GetWidth() ),
766 wxMax( m_virtualSize
.GetHeight(), s
.GetHeight() ) );
769 // ----------------------------------------------------------------------------
770 // show/hide/enable/disable the window
771 // ----------------------------------------------------------------------------
773 bool wxWindowBase::Show(bool show
)
775 if ( show
!= m_isShown
)
787 bool wxWindowBase::Enable(bool enable
)
789 if ( enable
!= m_isEnabled
)
791 m_isEnabled
= enable
;
800 // ----------------------------------------------------------------------------
802 // ----------------------------------------------------------------------------
804 bool wxWindowBase::IsTopLevel() const
809 // ----------------------------------------------------------------------------
810 // reparenting the window
811 // ----------------------------------------------------------------------------
813 void wxWindowBase::AddChild(wxWindowBase
*child
)
815 wxCHECK_RET( child
, wxT("can't add a NULL child") );
817 // this should never happen and it will lead to a crash later if it does
818 // because RemoveChild() will remove only one node from the children list
819 // and the other(s) one(s) will be left with dangling pointers in them
820 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), _T("AddChild() called twice") );
822 GetChildren().Append((wxWindow
*)child
);
823 child
->SetParent(this);
826 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
828 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
830 GetChildren().DeleteObject((wxWindow
*)child
);
831 child
->SetParent(NULL
);
834 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
836 wxWindow
*oldParent
= GetParent();
837 if ( newParent
== oldParent
)
843 // unlink this window from the existing parent.
846 oldParent
->RemoveChild(this);
850 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
853 // add it to the new one
856 newParent
->AddChild(this);
860 wxTopLevelWindows
.Append((wxWindow
*)this);
866 // ----------------------------------------------------------------------------
867 // event handler stuff
868 // ----------------------------------------------------------------------------
870 void wxWindowBase::PushEventHandler(wxEvtHandler
*handler
)
872 wxEvtHandler
*handlerOld
= GetEventHandler();
874 handler
->SetNextHandler(handlerOld
);
877 GetEventHandler()->SetPreviousHandler(handler
);
879 SetEventHandler(handler
);
882 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
884 wxEvtHandler
*handlerA
= GetEventHandler();
887 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
888 handlerA
->SetNextHandler((wxEvtHandler
*)NULL
);
891 handlerB
->SetPreviousHandler((wxEvtHandler
*)NULL
);
892 SetEventHandler(handlerB
);
897 handlerA
= (wxEvtHandler
*)NULL
;
904 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handler
)
906 wxCHECK_MSG( handler
, false, _T("RemoveEventHandler(NULL) called") );
908 wxEvtHandler
*handlerPrev
= NULL
,
909 *handlerCur
= GetEventHandler();
912 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
914 if ( handlerCur
== handler
)
918 handlerPrev
->SetNextHandler(handlerNext
);
922 SetEventHandler(handlerNext
);
927 handlerNext
->SetPreviousHandler ( handlerPrev
);
930 handler
->SetNextHandler(NULL
);
931 handler
->SetPreviousHandler(NULL
);
936 handlerPrev
= handlerCur
;
937 handlerCur
= handlerNext
;
940 wxFAIL_MSG( _T("where has the event handler gone?") );
945 // ----------------------------------------------------------------------------
947 // ----------------------------------------------------------------------------
949 void wxWindowBase::InheritAttributes()
951 const wxWindowBase
* const parent
= GetParent();
955 // we only inherit attributes which had been explicitly set for the parent
956 // which ensures that this only happens if the user really wants it and
957 // not by default which wouldn't make any sense in modern GUIs where the
958 // controls don't all use the same fonts (nor colours)
959 if ( parent
->m_inheritFont
&& !m_hasFont
)
960 SetFont(parent
->GetFont());
962 // in addition, there is a possibility to explicitly forbid inheriting
963 // colours at each class level by overriding ShouldInheritColours()
964 if ( ShouldInheritColours() )
966 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
967 SetForegroundColour(parent
->GetForegroundColour());
969 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
970 SetBackgroundColour(parent
->GetBackgroundColour());
974 /* static */ wxVisualAttributes
975 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
977 // it is important to return valid values for all attributes from here,
978 // GetXXX() below rely on this
979 wxVisualAttributes attrs
;
980 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
981 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
982 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
987 wxColour
wxWindowBase::GetBackgroundColour() const
989 if ( !m_backgroundColour
.Ok() )
991 wxASSERT_MSG( !m_hasBgCol
, _T("we have invalid explicit bg colour?") );
993 // get our default background colour
994 wxColour colBg
= GetDefaultAttributes().colBg
;
996 // we must return some valid colour to avoid redoing this every time
997 // and also to avoid surprizing the applications written for older
998 // wxWidgets versions where GetBackgroundColour() always returned
999 // something -- so give them something even if it doesn't make sense
1000 // for this window (e.g. it has a themed background)
1002 colBg
= GetClassDefaultAttributes().colBg
;
1007 return m_backgroundColour
;
1010 wxColour
wxWindowBase::GetForegroundColour() const
1012 // logic is the same as above
1013 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
1015 wxASSERT_MSG( !m_hasFgCol
, _T("we have invalid explicit fg colour?") );
1017 wxColour colFg
= GetDefaultAttributes().colFg
;
1020 colFg
= GetClassDefaultAttributes().colFg
;
1025 return m_foregroundColour
;
1028 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
1030 if ( colour
== m_backgroundColour
)
1033 m_hasBgCol
= colour
.Ok();
1034 m_inheritBgCol
= m_hasBgCol
;
1035 m_backgroundColour
= colour
;
1036 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1040 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1042 if (colour
== m_foregroundColour
)
1045 m_hasFgCol
= colour
.Ok();
1046 m_inheritFgCol
= m_hasFgCol
;
1047 m_foregroundColour
= colour
;
1048 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1052 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1054 // setting an invalid cursor is ok, it means that we don't have any special
1056 if ( m_cursor
== cursor
)
1067 wxFont
wxWindowBase::GetFont() const
1069 // logic is the same as in GetBackgroundColour()
1072 wxASSERT_MSG( !m_hasFont
, _T("we have invalid explicit font?") );
1074 wxFont font
= GetDefaultAttributes().font
;
1076 font
= GetClassDefaultAttributes().font
;
1084 bool wxWindowBase::SetFont(const wxFont
& font
)
1086 if ( font
== m_font
)
1093 m_hasFont
= font
.Ok();
1094 m_inheritFont
= m_hasFont
;
1096 InvalidateBestSize();
1103 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1105 m_hasCustomPalette
= true;
1108 // VZ: can anyone explain me what do we do here?
1109 wxWindowDC
d((wxWindow
*) this);
1113 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1115 wxWindow
*win
= (wxWindow
*)this;
1116 while ( win
&& !win
->HasCustomPalette() )
1118 win
= win
->GetParent();
1124 #endif // wxUSE_PALETTE
1127 void wxWindowBase::SetCaret(wxCaret
*caret
)
1138 wxASSERT_MSG( m_caret
->GetWindow() == this,
1139 wxT("caret should be created associated to this window") );
1142 #endif // wxUSE_CARET
1144 #if wxUSE_VALIDATORS
1145 // ----------------------------------------------------------------------------
1147 // ----------------------------------------------------------------------------
1149 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1151 if ( m_windowValidator
)
1152 delete m_windowValidator
;
1154 m_windowValidator
= (wxValidator
*)validator
.Clone();
1156 if ( m_windowValidator
)
1157 m_windowValidator
->SetWindow(this);
1159 #endif // wxUSE_VALIDATORS
1161 // ----------------------------------------------------------------------------
1162 // update region stuff
1163 // ----------------------------------------------------------------------------
1165 wxRect
wxWindowBase::GetUpdateClientRect() const
1167 wxRegion rgnUpdate
= GetUpdateRegion();
1168 rgnUpdate
.Intersect(GetClientRect());
1169 wxRect rectUpdate
= rgnUpdate
.GetBox();
1170 wxPoint ptOrigin
= GetClientAreaOrigin();
1171 rectUpdate
.x
-= ptOrigin
.x
;
1172 rectUpdate
.y
-= ptOrigin
.y
;
1177 bool wxWindowBase::IsExposed(int x
, int y
) const
1179 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1182 bool wxWindowBase::IsExposed(int x
, int y
, int w
, int h
) const
1184 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1187 void wxWindowBase::ClearBackground()
1189 // wxGTK uses its own version, no need to add never used code
1191 wxClientDC
dc((wxWindow
*)this);
1192 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1193 dc
.SetBackground(brush
);
1198 // ----------------------------------------------------------------------------
1199 // find child window by id or name
1200 // ----------------------------------------------------------------------------
1202 wxWindow
*wxWindowBase::FindWindow( long id
)
1204 if ( id
== m_windowId
)
1205 return (wxWindow
*)this;
1207 wxWindowBase
*res
= (wxWindow
*)NULL
;
1208 wxWindowList::compatibility_iterator node
;
1209 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1211 wxWindowBase
*child
= node
->GetData();
1212 res
= child
->FindWindow( id
);
1215 return (wxWindow
*)res
;
1218 wxWindow
*wxWindowBase::FindWindow( const wxString
& name
)
1220 if ( name
== m_windowName
)
1221 return (wxWindow
*)this;
1223 wxWindowBase
*res
= (wxWindow
*)NULL
;
1224 wxWindowList::compatibility_iterator node
;
1225 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1227 wxWindow
*child
= node
->GetData();
1228 res
= child
->FindWindow(name
);
1231 return (wxWindow
*)res
;
1235 // find any window by id or name or label: If parent is non-NULL, look through
1236 // children for a label or title matching the specified string. If NULL, look
1237 // through all top-level windows.
1239 // to avoid duplicating code we reuse the same helper function but with
1240 // different comparators
1242 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1243 const wxString
& label
, long id
);
1246 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1249 return win
->GetLabel() == label
;
1253 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1256 return win
->GetName() == label
;
1260 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1263 return win
->GetId() == id
;
1266 // recursive helper for the FindWindowByXXX() functions
1268 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1269 const wxString
& label
,
1271 wxFindWindowCmp cmp
)
1275 // see if this is the one we're looking for
1276 if ( (*cmp
)(parent
, label
, id
) )
1277 return (wxWindow
*)parent
;
1279 // It wasn't, so check all its children
1280 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1282 node
= node
->GetNext() )
1284 // recursively check each child
1285 wxWindow
*win
= (wxWindow
*)node
->GetData();
1286 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1296 // helper for FindWindowByXXX()
1298 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1299 const wxString
& label
,
1301 wxFindWindowCmp cmp
)
1305 // just check parent and all its children
1306 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1309 // start at very top of wx's windows
1310 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1312 node
= node
->GetNext() )
1314 // recursively check each window & its children
1315 wxWindow
*win
= node
->GetData();
1316 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1326 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1328 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1333 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1335 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1339 // fall back to the label
1340 win
= FindWindowByLabel(title
, parent
);
1348 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1350 return wxFindWindowHelper(parent
, _T(""), id
, wxFindWindowCmpIds
);
1353 // ----------------------------------------------------------------------------
1354 // dialog oriented functions
1355 // ----------------------------------------------------------------------------
1357 void wxWindowBase::MakeModal(bool modal
)
1359 // Disable all other windows
1362 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1365 wxWindow
*win
= node
->GetData();
1367 win
->Enable(!modal
);
1369 node
= node
->GetNext();
1374 bool wxWindowBase::Validate()
1376 #if wxUSE_VALIDATORS
1377 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1379 wxWindowList::compatibility_iterator node
;
1380 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1382 wxWindowBase
*child
= node
->GetData();
1383 wxValidator
*validator
= child
->GetValidator();
1384 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1389 if ( recurse
&& !child
->Validate() )
1394 #endif // wxUSE_VALIDATORS
1399 bool wxWindowBase::TransferDataToWindow()
1401 #if wxUSE_VALIDATORS
1402 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1404 wxWindowList::compatibility_iterator node
;
1405 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1407 wxWindowBase
*child
= node
->GetData();
1408 wxValidator
*validator
= child
->GetValidator();
1409 if ( validator
&& !validator
->TransferToWindow() )
1411 wxLogWarning(_("Could not transfer data to window"));
1413 wxLog::FlushActive();
1421 if ( !child
->TransferDataToWindow() )
1423 // warning already given
1428 #endif // wxUSE_VALIDATORS
1433 bool wxWindowBase::TransferDataFromWindow()
1435 #if wxUSE_VALIDATORS
1436 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1438 wxWindowList::compatibility_iterator node
;
1439 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1441 wxWindow
*child
= node
->GetData();
1442 wxValidator
*validator
= child
->GetValidator();
1443 if ( validator
&& !validator
->TransferFromWindow() )
1445 // nop warning here because the application is supposed to give
1446 // one itself - we don't know here what might have gone wrongly
1453 if ( !child
->TransferDataFromWindow() )
1455 // warning already given
1460 #endif // wxUSE_VALIDATORS
1465 void wxWindowBase::InitDialog()
1467 wxInitDialogEvent
event(GetId());
1468 event
.SetEventObject( this );
1469 GetEventHandler()->ProcessEvent(event
);
1472 // ----------------------------------------------------------------------------
1473 // context-sensitive help support
1474 // ----------------------------------------------------------------------------
1478 // associate this help text with this window
1479 void wxWindowBase::SetHelpText(const wxString
& text
)
1481 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1484 helpProvider
->AddHelp(this, text
);
1488 // associate this help text with all windows with the same id as this
1490 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1492 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1495 helpProvider
->AddHelp(GetId(), text
);
1499 // get the help string associated with this window (may be empty)
1500 wxString
wxWindowBase::GetHelpText() const
1503 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1506 text
= helpProvider
->GetHelp(this);
1512 // show help for this window
1513 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1515 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1518 if ( helpProvider
->ShowHelp(this) )
1520 // skip the event.Skip() below
1528 #endif // wxUSE_HELP
1530 // ----------------------------------------------------------------------------
1531 // tooltipsroot.Replace("\\", "/");
1532 // ----------------------------------------------------------------------------
1536 void wxWindowBase::SetToolTip( const wxString
&tip
)
1538 // don't create the new tooltip if we already have one
1541 m_tooltip
->SetTip( tip
);
1545 SetToolTip( new wxToolTip( tip
) );
1548 // setting empty tooltip text does not remove the tooltip any more - use
1549 // SetToolTip((wxToolTip *)NULL) for this
1552 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1557 m_tooltip
= tooltip
;
1560 #endif // wxUSE_TOOLTIPS
1562 // ----------------------------------------------------------------------------
1563 // constraints and sizers
1564 // ----------------------------------------------------------------------------
1566 #if wxUSE_CONSTRAINTS
1568 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1570 if ( m_constraints
)
1572 UnsetConstraints(m_constraints
);
1573 delete m_constraints
;
1575 m_constraints
= constraints
;
1576 if ( m_constraints
)
1578 // Make sure other windows know they're part of a 'meaningful relationship'
1579 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1580 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1581 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1582 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1583 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1584 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1585 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1586 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1587 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1588 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1589 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1590 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1591 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1592 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1593 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1594 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1598 // This removes any dangling pointers to this window in other windows'
1599 // constraintsInvolvedIn lists.
1600 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1604 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1605 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1606 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1607 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1608 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1609 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1610 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1611 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1612 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1613 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1614 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1615 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1616 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1617 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1618 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1619 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1623 // Back-pointer to other windows we're involved with, so if we delete this
1624 // window, we must delete any constraints we're involved with.
1625 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
1627 if ( !m_constraintsInvolvedIn
)
1628 m_constraintsInvolvedIn
= new wxWindowList
;
1629 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
1630 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
1633 // REMOVE back-pointer to other windows we're involved with.
1634 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
1636 if ( m_constraintsInvolvedIn
)
1637 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
1640 // Reset any constraints that mention this window
1641 void wxWindowBase::DeleteRelatedConstraints()
1643 if ( m_constraintsInvolvedIn
)
1645 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
1648 wxWindow
*win
= node
->GetData();
1649 wxLayoutConstraints
*constr
= win
->GetConstraints();
1651 // Reset any constraints involving this window
1654 constr
->left
.ResetIfWin(this);
1655 constr
->top
.ResetIfWin(this);
1656 constr
->right
.ResetIfWin(this);
1657 constr
->bottom
.ResetIfWin(this);
1658 constr
->width
.ResetIfWin(this);
1659 constr
->height
.ResetIfWin(this);
1660 constr
->centreX
.ResetIfWin(this);
1661 constr
->centreY
.ResetIfWin(this);
1664 wxWindowList::compatibility_iterator next
= node
->GetNext();
1665 m_constraintsInvolvedIn
->Erase(node
);
1669 delete m_constraintsInvolvedIn
;
1670 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
1674 #endif // wxUSE_CONSTRAINTS
1676 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
1678 if ( sizer
== m_windowSizer
)
1682 delete m_windowSizer
;
1684 m_windowSizer
= sizer
;
1686 SetAutoLayout( sizer
!= NULL
);
1689 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
1691 SetSizer( sizer
, deleteOld
);
1692 sizer
->SetSizeHints( (wxWindow
*) this );
1696 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
1698 // adding a window to a sizer twice is going to result in fatal and
1699 // hard to debug problems later because when deleting the second
1700 // associated wxSizerItem we're going to dereference a dangling
1701 // pointer; so try to detect this as early as possible
1702 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
1703 _T("Adding a window to the same sizer twice?") );
1705 m_containingSizer
= sizer
;
1708 #if wxUSE_CONSTRAINTS
1710 void wxWindowBase::SatisfyConstraints()
1712 wxLayoutConstraints
*constr
= GetConstraints();
1713 bool wasOk
= constr
&& constr
->AreSatisfied();
1715 ResetConstraints(); // Mark all constraints as unevaluated
1719 // if we're a top level panel (i.e. our parent is frame/dialog), our
1720 // own constraints will never be satisfied any more unless we do it
1724 while ( noChanges
> 0 )
1726 LayoutPhase1(&noChanges
);
1730 LayoutPhase2(&noChanges
);
1733 #endif // wxUSE_CONSTRAINTS
1735 bool wxWindowBase::Layout()
1737 // If there is a sizer, use it instead of the constraints
1741 GetVirtualSize(&w
, &h
);
1742 GetSizer()->SetDimension( 0, 0, w
, h
);
1744 #if wxUSE_CONSTRAINTS
1747 SatisfyConstraints(); // Find the right constraints values
1748 SetConstraintSizes(); // Recursively set the real window sizes
1755 #if wxUSE_CONSTRAINTS
1757 // first phase of the constraints evaluation: set our own constraints
1758 bool wxWindowBase::LayoutPhase1(int *noChanges
)
1760 wxLayoutConstraints
*constr
= GetConstraints();
1762 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
1765 // second phase: set the constraints for our children
1766 bool wxWindowBase::LayoutPhase2(int *noChanges
)
1773 // Layout grand children
1779 // Do a phase of evaluating child constraints
1780 bool wxWindowBase::DoPhase(int phase
)
1782 // the list containing the children for which the constraints are already
1784 wxWindowList succeeded
;
1786 // the max number of iterations we loop before concluding that we can't set
1788 static const int maxIterations
= 500;
1790 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
1794 // loop over all children setting their constraints
1795 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1797 node
= node
->GetNext() )
1799 wxWindow
*child
= node
->GetData();
1800 if ( child
->IsTopLevel() )
1802 // top level children are not inside our client area
1806 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
1808 // this one is either already ok or nothing we can do about it
1812 int tempNoChanges
= 0;
1813 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
1814 : child
->LayoutPhase2(&tempNoChanges
);
1815 noChanges
+= tempNoChanges
;
1819 succeeded
.Append(child
);
1825 // constraints are set
1833 void wxWindowBase::ResetConstraints()
1835 wxLayoutConstraints
*constr
= GetConstraints();
1838 constr
->left
.SetDone(false);
1839 constr
->top
.SetDone(false);
1840 constr
->right
.SetDone(false);
1841 constr
->bottom
.SetDone(false);
1842 constr
->width
.SetDone(false);
1843 constr
->height
.SetDone(false);
1844 constr
->centreX
.SetDone(false);
1845 constr
->centreY
.SetDone(false);
1848 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1851 wxWindow
*win
= node
->GetData();
1852 if ( !win
->IsTopLevel() )
1853 win
->ResetConstraints();
1854 node
= node
->GetNext();
1858 // Need to distinguish between setting the 'fake' size for windows and sizers,
1859 // and setting the real values.
1860 void wxWindowBase::SetConstraintSizes(bool recurse
)
1862 wxLayoutConstraints
*constr
= GetConstraints();
1863 if ( constr
&& constr
->AreSatisfied() )
1865 int x
= constr
->left
.GetValue();
1866 int y
= constr
->top
.GetValue();
1867 int w
= constr
->width
.GetValue();
1868 int h
= constr
->height
.GetValue();
1870 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
1871 (constr
->height
.GetRelationship() != wxAsIs
) )
1873 SetSize(x
, y
, w
, h
);
1877 // If we don't want to resize this window, just move it...
1883 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
1884 GetClassInfo()->GetClassName(),
1890 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1893 wxWindow
*win
= node
->GetData();
1894 if ( !win
->IsTopLevel() && win
->GetConstraints() )
1895 win
->SetConstraintSizes();
1896 node
= node
->GetNext();
1901 // Only set the size/position of the constraint (if any)
1902 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
1904 wxLayoutConstraints
*constr
= GetConstraints();
1907 if ( x
!= wxDefaultCoord
)
1909 constr
->left
.SetValue(x
);
1910 constr
->left
.SetDone(true);
1912 if ( y
!= wxDefaultCoord
)
1914 constr
->top
.SetValue(y
);
1915 constr
->top
.SetDone(true);
1917 if ( w
!= wxDefaultCoord
)
1919 constr
->width
.SetValue(w
);
1920 constr
->width
.SetDone(true);
1922 if ( h
!= wxDefaultCoord
)
1924 constr
->height
.SetValue(h
);
1925 constr
->height
.SetDone(true);
1930 void wxWindowBase::MoveConstraint(int x
, int y
)
1932 wxLayoutConstraints
*constr
= GetConstraints();
1935 if ( x
!= wxDefaultCoord
)
1937 constr
->left
.SetValue(x
);
1938 constr
->left
.SetDone(true);
1940 if ( y
!= wxDefaultCoord
)
1942 constr
->top
.SetValue(y
);
1943 constr
->top
.SetDone(true);
1948 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
1950 wxLayoutConstraints
*constr
= GetConstraints();
1953 *w
= constr
->width
.GetValue();
1954 *h
= constr
->height
.GetValue();
1960 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
1962 wxLayoutConstraints
*constr
= GetConstraints();
1965 *w
= constr
->width
.GetValue();
1966 *h
= constr
->height
.GetValue();
1969 GetClientSize(w
, h
);
1972 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
1974 wxLayoutConstraints
*constr
= GetConstraints();
1977 *x
= constr
->left
.GetValue();
1978 *y
= constr
->top
.GetValue();
1984 #endif // wxUSE_CONSTRAINTS
1986 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
1988 // don't do it for the dialogs/frames - they float independently of their
1990 if ( !IsTopLevel() )
1992 wxWindow
*parent
= GetParent();
1993 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
1995 wxPoint
pt(parent
->GetClientAreaOrigin());
2002 // ----------------------------------------------------------------------------
2003 // do Update UI processing for child controls
2004 // ----------------------------------------------------------------------------
2006 void wxWindowBase::UpdateWindowUI(long flags
)
2008 wxUpdateUIEvent
event(GetId());
2009 event
.m_eventObject
= this;
2011 if ( GetEventHandler()->ProcessEvent(event
) )
2013 DoUpdateWindowUI(event
);
2016 if (flags
& wxUPDATE_UI_RECURSE
)
2018 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2021 wxWindow
* child
= (wxWindow
*) node
->GetData();
2022 child
->UpdateWindowUI(flags
);
2023 node
= node
->GetNext();
2028 // do the window-specific processing after processing the update event
2029 // TODO: take specific knowledge out of this function and
2030 // put in each control's base class. Unfortunately we don't
2031 // yet have base implementation files for wxCheckBox and wxRadioButton.
2032 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
2034 if ( event
.GetSetEnabled() )
2035 Enable(event
.GetEnabled());
2038 if ( event
.GetSetText() )
2040 wxControl
*control
= wxDynamicCastThis(wxControl
);
2043 if ( event
.GetText() != control
->GetLabel() )
2044 control
->SetLabel(event
.GetText());
2047 #endif // wxUSE_CONTROLS
2049 if ( event
.GetSetChecked() )
2052 wxCheckBox
*checkbox
= wxDynamicCastThis(wxCheckBox
);
2055 checkbox
->SetValue(event
.GetChecked());
2057 #endif // wxUSE_CHECKBOX
2060 wxRadioButton
*radiobtn
= wxDynamicCastThis(wxRadioButton
);
2063 radiobtn
->SetValue(event
.GetChecked());
2065 #endif // wxUSE_RADIOBTN
2070 // call internal idle recursively
2071 // may be obsolete (wait until OnIdle scheme stabilises)
2072 void wxWindowBase::ProcessInternalIdle()
2076 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2079 wxWindow
*child
= node
->GetData();
2080 child
->ProcessInternalIdle();
2081 node
= node
->GetNext();
2086 // ----------------------------------------------------------------------------
2087 // dialog units translations
2088 // ----------------------------------------------------------------------------
2090 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
2092 int charWidth
= GetCharWidth();
2093 int charHeight
= GetCharHeight();
2094 wxPoint pt2
= wxDefaultPosition
;
2095 if (pt
.x
!= wxDefaultCoord
)
2096 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
);
2097 if (pt
.y
!= wxDefaultCoord
)
2098 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2103 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2105 int charWidth
= GetCharWidth();
2106 int charHeight
= GetCharHeight();
2107 wxPoint pt2
= wxDefaultPosition
;
2108 if (pt
.x
!= wxDefaultCoord
)
2109 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2110 if (pt
.y
!= wxDefaultCoord
)
2111 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2116 // ----------------------------------------------------------------------------
2118 // ----------------------------------------------------------------------------
2120 // propagate the colour change event to the subwindows
2121 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2123 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2126 // Only propagate to non-top-level windows
2127 wxWindow
*win
= node
->GetData();
2128 if ( !win
->IsTopLevel() )
2130 wxSysColourChangedEvent event2
;
2131 event
.m_eventObject
= win
;
2132 win
->GetEventHandler()->ProcessEvent(event2
);
2135 node
= node
->GetNext();
2141 // the default action is to populate dialog with data when it's created,
2142 // and nudge the UI into displaying itself correctly in case
2143 // we've turned the wxUpdateUIEvents frequency down low.
2144 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2146 TransferDataToWindow();
2148 // Update the UI at this point
2149 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2152 // process Ctrl-Alt-mclick
2153 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2156 if ( event
.ControlDown() && event
.AltDown() )
2158 // don't translate these strings
2161 #ifdef __WXUNIVERSAL__
2163 #endif // __WXUNIVERSAL__
2165 switch ( wxGetOsVersion() )
2167 case wxMOTIF_X
: port
+= _T("Motif"); break;
2169 case wxMAC_DARWIN
: port
+= _T("Mac"); break;
2170 case wxBEOS
: port
+= _T("BeOS"); break;
2174 case wxGTK_BEOS
: port
+= _T("GTK"); break;
2180 case wxWIN386
: port
+= _T("MS Windows"); break;
2184 case wxMGL_OS2
: port
+= _T("MGL"); break;
2186 case wxOS2_PM
: port
+= _T("OS/2"); break;
2187 default: port
+= _T("unknown"); break;
2190 wxMessageBox(wxString::Format(
2192 " wxWidgets Library (%s port)\nVersion %u.%u.%u%s, compiled at %s %s\n Copyright (c) 1995-2002 wxWidgets team"
2206 _T("wxWidgets information"),
2207 wxICON_INFORMATION
| wxOK
,
2211 #endif // wxUSE_MSGDLG
2217 // ----------------------------------------------------------------------------
2219 // ----------------------------------------------------------------------------
2221 #if wxUSE_ACCESSIBILITY
2222 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2224 if (m_accessible
&& (accessible
!= m_accessible
))
2225 delete m_accessible
;
2226 m_accessible
= accessible
;
2228 m_accessible
->SetWindow((wxWindow
*) this);
2231 // Returns the accessible object, creating if necessary.
2232 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2235 m_accessible
= CreateAccessible();
2236 return m_accessible
;
2239 // Override to create a specific accessible object.
2240 wxAccessible
* wxWindowBase::CreateAccessible()
2242 return new wxWindowAccessible((wxWindow
*) this);
2248 // ----------------------------------------------------------------------------
2249 // list classes implementation
2250 // ----------------------------------------------------------------------------
2252 void wxWindowListNode::DeleteData()
2254 delete (wxWindow
*)GetData();
2258 // ----------------------------------------------------------------------------
2260 // ----------------------------------------------------------------------------
2262 wxBorder
wxWindowBase::GetBorder(long flags
) const
2264 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2265 if ( border
== wxBORDER_DEFAULT
)
2267 border
= GetDefaultBorder();
2273 wxBorder
wxWindowBase::GetDefaultBorder() const
2275 return wxBORDER_NONE
;
2278 // ----------------------------------------------------------------------------
2280 // ----------------------------------------------------------------------------
2282 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2284 // here we just check if the point is inside the window or not
2286 // check the top and left border first
2287 bool outside
= x
< 0 || y
< 0;
2290 // check the right and bottom borders too
2291 wxSize size
= GetSize();
2292 outside
= x
>= size
.x
|| y
>= size
.y
;
2295 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2298 // ----------------------------------------------------------------------------
2300 // ----------------------------------------------------------------------------
2302 struct WXDLLEXPORT wxWindowNext
2306 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2308 void wxWindowBase::CaptureMouse()
2310 wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), this);
2312 wxWindow
*winOld
= GetCapture();
2315 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2318 wxWindowNext
*item
= new wxWindowNext
;
2320 item
->next
= ms_winCaptureNext
;
2321 ms_winCaptureNext
= item
;
2323 //else: no mouse capture to save
2328 void wxWindowBase::ReleaseMouse()
2330 wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), this);
2332 wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") );
2336 if ( ms_winCaptureNext
)
2338 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2340 wxWindowNext
*item
= ms_winCaptureNext
;
2341 ms_winCaptureNext
= item
->next
;
2344 //else: stack is empty, no previous capture
2346 wxLogTrace(_T("mousecapture"),
2347 (const wxChar
*) _T("After ReleaseMouse() mouse is captured by %p"),
2354 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2355 int WXUNUSED(modifiers
),
2356 int WXUNUSED(keycode
))
2362 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2368 #endif // wxUSE_HOTKEY
2370 void wxWindowBase::SendDestroyEvent()
2372 wxWindowDestroyEvent event
;
2373 event
.SetEventObject(this);
2374 event
.SetId(GetId());
2375 GetEventHandler()->ProcessEvent(event
);
2378 // ----------------------------------------------------------------------------
2380 // ----------------------------------------------------------------------------
2382 bool wxWindowBase::TryValidator(wxEvent
& wxVALIDATOR_PARAM(event
))
2384 #if wxUSE_VALIDATORS
2385 // Can only use the validator of the window which
2386 // is receiving the event
2387 if ( event
.GetEventObject() == this )
2389 wxValidator
*validator
= GetValidator();
2390 if ( validator
&& validator
->ProcessEvent(event
) )
2395 #endif // wxUSE_VALIDATORS
2400 bool wxWindowBase::TryParent(wxEvent
& event
)
2402 // carry on up the parent-child hierarchy if the propgation count hasn't
2404 if ( event
.ShouldPropagate() )
2406 // honour the requests to stop propagation at this window: this is
2407 // used by the dialogs, for example, to prevent processing the events
2408 // from the dialog controls in the parent frame which rarely, if ever,
2410 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2412 wxWindow
*parent
= GetParent();
2413 if ( parent
&& !parent
->IsBeingDeleted() )
2415 wxPropagateOnce
propagateOnce(event
);
2417 return parent
->GetEventHandler()->ProcessEvent(event
);
2422 return wxEvtHandler::TryParent(event
);
2425 // ----------------------------------------------------------------------------
2426 // keyboard navigation
2427 // ----------------------------------------------------------------------------
2429 // Navigates in the specified direction.
2430 bool wxWindowBase::Navigate(int flags
)
2432 wxNavigationKeyEvent eventNav
;
2433 eventNav
.SetFlags(flags
);
2434 eventNav
.SetEventObject(this);
2435 if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav
) )
2442 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, MoveKind move
)
2444 // check that we're not a top level window
2445 wxCHECK_RET( GetParent(),
2446 _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
2448 // find the target window in the siblings list
2449 wxWindowList
& siblings
= GetParent()->GetChildren();
2450 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
2451 wxCHECK_RET( i
, _T("MoveBefore/AfterInTabOrder(): win is not a sibling") );
2453 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
2454 // can't just move the node around
2455 wxWindow
*self
= (wxWindow
*)this;
2456 siblings
.DeleteObject(self
);
2457 if ( move
== MoveAfter
)
2464 siblings
.Insert(i
, self
);
2466 else // MoveAfter and win was the last sibling
2468 siblings
.Append(self
);
2472 // ----------------------------------------------------------------------------
2474 // ----------------------------------------------------------------------------
2476 /*static*/ wxWindow
* wxWindowBase::FindFocus()
2478 wxWindowBase
*win
= DoFindFocus();
2479 return win
? win
->GetMainWindowOfCompositeControl() : NULL
;
2482 // ----------------------------------------------------------------------------
2484 // ----------------------------------------------------------------------------
2486 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
2488 while ( win
&& !win
->IsTopLevel() )
2489 win
= win
->GetParent();
2494 #if wxUSE_ACCESSIBILITY
2495 // ----------------------------------------------------------------------------
2496 // accessible object for windows
2497 // ----------------------------------------------------------------------------
2499 // Can return either a child object, or an integer
2500 // representing the child element, starting from 1.
2501 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
2503 wxASSERT( GetWindow() != NULL
);
2507 return wxACC_NOT_IMPLEMENTED
;
2510 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
2511 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
2513 wxASSERT( GetWindow() != NULL
);
2517 wxWindow
* win
= NULL
;
2524 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
2526 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
2533 rect
= win
->GetRect();
2534 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
2535 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
2539 return wxACC_NOT_IMPLEMENTED
;
2542 // Navigates from fromId to toId/toObject.
2543 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
2544 int* WXUNUSED(toId
), wxAccessible
** toObject
)
2546 wxASSERT( GetWindow() != NULL
);
2552 case wxNAVDIR_FIRSTCHILD
:
2554 if (GetWindow()->GetChildren().GetCount() == 0)
2556 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
2557 *toObject
= childWindow
->GetOrCreateAccessible();
2561 case wxNAVDIR_LASTCHILD
:
2563 if (GetWindow()->GetChildren().GetCount() == 0)
2565 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
2566 *toObject
= childWindow
->GetOrCreateAccessible();
2570 case wxNAVDIR_RIGHT
:
2574 wxWindowList::compatibility_iterator node
=
2575 wxWindowList::compatibility_iterator();
2578 // Can't navigate to sibling of this window
2579 // if we're a top-level window.
2580 if (!GetWindow()->GetParent())
2581 return wxACC_NOT_IMPLEMENTED
;
2583 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2587 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2588 node
= GetWindow()->GetChildren().Item(fromId
-1);
2591 if (node
&& node
->GetNext())
2593 wxWindow
* nextWindow
= node
->GetNext()->GetData();
2594 *toObject
= nextWindow
->GetOrCreateAccessible();
2602 case wxNAVDIR_PREVIOUS
:
2604 wxWindowList::compatibility_iterator node
=
2605 wxWindowList::compatibility_iterator();
2608 // Can't navigate to sibling of this window
2609 // if we're a top-level window.
2610 if (!GetWindow()->GetParent())
2611 return wxACC_NOT_IMPLEMENTED
;
2613 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2617 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2618 node
= GetWindow()->GetChildren().Item(fromId
-1);
2621 if (node
&& node
->GetPrevious())
2623 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
2624 *toObject
= previousWindow
->GetOrCreateAccessible();
2632 return wxACC_NOT_IMPLEMENTED
;
2635 // Gets the name of the specified object.
2636 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
2638 wxASSERT( GetWindow() != NULL
);
2644 // If a child, leave wxWidgets to call the function on the actual
2647 return wxACC_NOT_IMPLEMENTED
;
2649 // This will eventually be replaced by specialised
2650 // accessible classes, one for each kind of wxWidgets
2651 // control or window.
2653 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
2654 title
= ((wxButton
*) GetWindow())->GetLabel();
2657 title
= GetWindow()->GetName();
2659 if (!title
.IsEmpty())
2665 return wxACC_NOT_IMPLEMENTED
;
2668 // Gets the number of children.
2669 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
2671 wxASSERT( GetWindow() != NULL
);
2675 *childId
= (int) GetWindow()->GetChildren().GetCount();
2679 // Gets the specified child (starting from 1).
2680 // If *child is NULL and return value is wxACC_OK,
2681 // this means that the child is a simple element and
2682 // not an accessible object.
2683 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
2685 wxASSERT( GetWindow() != NULL
);
2695 if (childId
> (int) GetWindow()->GetChildren().GetCount())
2698 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
2699 *child
= childWindow
->GetOrCreateAccessible();
2706 // Gets the parent, or NULL.
2707 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
2709 wxASSERT( GetWindow() != NULL
);
2713 wxWindow
* parentWindow
= GetWindow()->GetParent();
2721 *parent
= parentWindow
->GetOrCreateAccessible();
2729 // Performs the default action. childId is 0 (the action for this object)
2730 // or > 0 (the action for a child).
2731 // Return wxACC_NOT_SUPPORTED if there is no default action for this
2732 // window (e.g. an edit control).
2733 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
2735 wxASSERT( GetWindow() != NULL
);
2739 return wxACC_NOT_IMPLEMENTED
;
2742 // Gets the default action for this object (0) or > 0 (the action for a child).
2743 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
2744 // string if there is no action.
2745 // The retrieved string describes the action that is performed on an object,
2746 // not what the object does as a result. For example, a toolbar button that prints
2747 // a document has a default action of "Press" rather than "Prints the current document."
2748 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
2750 wxASSERT( GetWindow() != NULL
);
2754 return wxACC_NOT_IMPLEMENTED
;
2757 // Returns the description for this object or a child.
2758 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
2760 wxASSERT( GetWindow() != NULL
);
2764 wxString
ht(GetWindow()->GetHelpText());
2770 return wxACC_NOT_IMPLEMENTED
;
2773 // Returns help text for this object or a child, similar to tooltip text.
2774 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
2776 wxASSERT( GetWindow() != NULL
);
2780 wxString
ht(GetWindow()->GetHelpText());
2786 return wxACC_NOT_IMPLEMENTED
;
2789 // Returns the keyboard shortcut for this object or child.
2790 // Return e.g. ALT+K
2791 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
2793 wxASSERT( GetWindow() != NULL
);
2797 return wxACC_NOT_IMPLEMENTED
;
2800 // Returns a role constant.
2801 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
2803 wxASSERT( GetWindow() != NULL
);
2807 // If a child, leave wxWidgets to call the function on the actual
2810 return wxACC_NOT_IMPLEMENTED
;
2812 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2813 return wxACC_NOT_IMPLEMENTED
;
2815 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2816 return wxACC_NOT_IMPLEMENTED
;
2819 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2820 return wxACC_NOT_IMPLEMENTED
;
2823 //*role = wxROLE_SYSTEM_CLIENT;
2824 *role
= wxROLE_SYSTEM_CLIENT
;
2828 return wxACC_NOT_IMPLEMENTED
;
2832 // Returns a state constant.
2833 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
2835 wxASSERT( GetWindow() != NULL
);
2839 // If a child, leave wxWidgets to call the function on the actual
2842 return wxACC_NOT_IMPLEMENTED
;
2844 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2845 return wxACC_NOT_IMPLEMENTED
;
2848 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2849 return wxACC_NOT_IMPLEMENTED
;
2852 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2853 return wxACC_NOT_IMPLEMENTED
;
2860 return wxACC_NOT_IMPLEMENTED
;
2864 // Returns a localized string representing the value for the object
2866 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
2868 wxASSERT( GetWindow() != NULL
);
2872 return wxACC_NOT_IMPLEMENTED
;
2875 // Selects the object or child.
2876 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
2878 wxASSERT( GetWindow() != NULL
);
2882 return wxACC_NOT_IMPLEMENTED
;
2885 // Gets the window with the keyboard focus.
2886 // If childId is 0 and child is NULL, no object in
2887 // this subhierarchy has the focus.
2888 // If this object has the focus, child should be 'this'.
2889 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
2891 wxASSERT( GetWindow() != NULL
);
2895 return wxACC_NOT_IMPLEMENTED
;
2898 // Gets a variant representing the selected children
2900 // Acceptable values:
2901 // - a null variant (IsNull() returns true)
2902 // - a list variant (GetType() == wxT("list")
2903 // - an integer representing the selected child element,
2904 // or 0 if this object is selected (GetType() == wxT("long")
2905 // - a "void*" pointer to a wxAccessible child object
2906 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
2908 wxASSERT( GetWindow() != NULL
);
2912 return wxACC_NOT_IMPLEMENTED
;
2915 #endif // wxUSE_ACCESSIBILITY