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 void wxWindowBase::InvalidateBestSize()
536 m_bestSizeCache
= wxDefaultSize
;
538 // parent's best size calculation may depend on its children's
539 // best sizes, so let's invalidate it as well to be safe:
541 m_parent
->InvalidateBestSize();
544 // return the size best suited for the current window
545 wxSize
wxWindowBase::DoGetBestSize() const
549 return m_windowSizer
->GetMinSize();
551 #if wxUSE_CONSTRAINTS
552 else if ( m_constraints
)
554 wxConstCast(this, wxWindowBase
)->SatisfyConstraints();
556 // our minimal acceptable size is such that all our windows fit inside
560 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
562 node
= node
->GetNext() )
564 wxLayoutConstraints
*c
= node
->GetData()->GetConstraints();
567 // it's not normal that we have an unconstrained child, but
568 // what can we do about it?
572 int x
= c
->right
.GetValue(),
573 y
= c
->bottom
.GetValue();
581 // TODO: we must calculate the overlaps somehow, otherwise we
582 // will never return a size bigger than the current one :-(
585 return wxSize(maxX
, maxY
);
587 #endif // wxUSE_CONSTRAINTS
588 else if ( !GetChildren().empty()
590 && wxHasRealChildren(this)
594 // our minimal acceptable size is such that all our visible child windows fit inside
598 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
600 node
= node
->GetNext() )
602 wxWindow
*win
= node
->GetData();
603 if ( win
->IsTopLevel() || ( ! win
->IsShown() )
605 || wxDynamicCast(win
, wxStatusBar
)
606 #endif // wxUSE_STATUSBAR
609 // dialogs and frames lie in different top level windows -
610 // don't deal with them here; as for the status bars, they
611 // don't lie in the client area at all
616 win
->GetPosition(&wx
, &wy
);
618 // if the window hadn't been positioned yet, assume that it is in
620 if ( wx
== wxDefaultCoord
)
622 if ( wy
== wxDefaultCoord
)
625 win
->GetSize(&ww
, &wh
);
626 if ( wx
+ ww
> maxX
)
628 if ( wy
+ wh
> maxY
)
632 // for compatibility with the old versions and because it really looks
633 // slightly more pretty like this, add a pad
637 return wxSize(maxX
, maxY
);
639 else // ! has children
641 // for a generic window there is no natural best size - just use either the
642 // minimum size if there is one, or the current size
643 if ( GetMinSize().IsFullySpecified() )
651 wxSize
wxWindowBase::GetBestFittingSize() const
653 // merge the best size with the min size, giving priority to the min size
654 wxSize min
= GetMinSize();
655 if (min
.x
== wxDefaultCoord
|| min
.y
== wxDefaultCoord
)
657 wxSize best
= GetBestSize();
658 if (min
.x
== wxDefaultCoord
) min
.x
= best
.x
;
659 if (min
.y
== wxDefaultCoord
) min
.y
= best
.y
;
665 void wxWindowBase::SetBestFittingSize(const wxSize
& size
)
667 // Set the min size to the size passed in. This will usually either be
668 // wxDefaultSize or the size passed to this window's ctor/Create function.
671 // Merge the size with the best size if needed
672 wxSize best
= GetBestFittingSize();
674 // If the current size doesn't match then change it
675 if (GetSize() != best
)
680 // by default the origin is not shifted
681 wxPoint
wxWindowBase::GetClientAreaOrigin() const
683 return wxPoint(0, 0);
686 // set the min/max size of the window
687 void wxWindowBase::DoSetSizeHints(int minW
, int minH
,
689 int WXUNUSED(incW
), int WXUNUSED(incH
))
691 // setting min width greater than max width leads to infinite loops under
692 // X11 and generally doesn't make any sense, so don't allow it
693 wxCHECK_RET( (minW
== wxDefaultCoord
|| maxW
== wxDefaultCoord
|| minW
<= maxW
) &&
694 (minH
== wxDefaultCoord
|| maxH
== wxDefaultCoord
|| minH
<= maxH
),
695 _T("min width/height must be less than max width/height!") );
703 void wxWindowBase::SetWindowVariant( wxWindowVariant variant
)
705 if ( m_windowVariant
!= variant
)
707 m_windowVariant
= variant
;
709 DoSetWindowVariant(variant
);
713 void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant
)
715 // adjust the font height to correspond to our new variant (notice that
716 // we're only called if something really changed)
717 wxFont font
= GetFont();
718 int size
= font
.GetPointSize();
721 case wxWINDOW_VARIANT_NORMAL
:
724 case wxWINDOW_VARIANT_SMALL
:
729 case wxWINDOW_VARIANT_MINI
:
734 case wxWINDOW_VARIANT_LARGE
:
740 wxFAIL_MSG(_T("unexpected window variant"));
744 font
.SetPointSize(size
);
748 void wxWindowBase::SetVirtualSizeHints( int minW
, int minH
,
751 m_minVirtualWidth
= minW
;
752 m_maxVirtualWidth
= maxW
;
753 m_minVirtualHeight
= minH
;
754 m_maxVirtualHeight
= maxH
;
757 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
759 if ( m_minVirtualWidth
!= wxDefaultCoord
&& m_minVirtualWidth
> x
)
760 x
= m_minVirtualWidth
;
761 if ( m_maxVirtualWidth
!= wxDefaultCoord
&& m_maxVirtualWidth
< x
)
762 x
= m_maxVirtualWidth
;
763 if ( m_minVirtualHeight
!= wxDefaultCoord
&& m_minVirtualHeight
> y
)
764 y
= m_minVirtualHeight
;
765 if ( m_maxVirtualHeight
!= wxDefaultCoord
&& m_maxVirtualHeight
< y
)
766 y
= m_maxVirtualHeight
;
768 m_virtualSize
= wxSize(x
, y
);
771 wxSize
wxWindowBase::DoGetVirtualSize() const
773 wxSize
s( GetClientSize() );
775 return wxSize( wxMax( m_virtualSize
.GetWidth(), s
.GetWidth() ),
776 wxMax( m_virtualSize
.GetHeight(), s
.GetHeight() ) );
779 // ----------------------------------------------------------------------------
780 // show/hide/enable/disable the window
781 // ----------------------------------------------------------------------------
783 bool wxWindowBase::Show(bool show
)
785 if ( show
!= m_isShown
)
797 bool wxWindowBase::Enable(bool enable
)
799 if ( enable
!= m_isEnabled
)
801 m_isEnabled
= enable
;
810 // ----------------------------------------------------------------------------
812 // ----------------------------------------------------------------------------
814 bool wxWindowBase::IsTopLevel() const
819 // ----------------------------------------------------------------------------
820 // reparenting the window
821 // ----------------------------------------------------------------------------
823 void wxWindowBase::AddChild(wxWindowBase
*child
)
825 wxCHECK_RET( child
, wxT("can't add a NULL child") );
827 // this should never happen and it will lead to a crash later if it does
828 // because RemoveChild() will remove only one node from the children list
829 // and the other(s) one(s) will be left with dangling pointers in them
830 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), _T("AddChild() called twice") );
832 GetChildren().Append((wxWindow
*)child
);
833 child
->SetParent(this);
836 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
838 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
840 GetChildren().DeleteObject((wxWindow
*)child
);
841 child
->SetParent(NULL
);
844 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
846 wxWindow
*oldParent
= GetParent();
847 if ( newParent
== oldParent
)
853 // unlink this window from the existing parent.
856 oldParent
->RemoveChild(this);
860 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
863 // add it to the new one
866 newParent
->AddChild(this);
870 wxTopLevelWindows
.Append((wxWindow
*)this);
876 // ----------------------------------------------------------------------------
877 // event handler stuff
878 // ----------------------------------------------------------------------------
880 void wxWindowBase::PushEventHandler(wxEvtHandler
*handler
)
882 wxEvtHandler
*handlerOld
= GetEventHandler();
884 handler
->SetNextHandler(handlerOld
);
887 GetEventHandler()->SetPreviousHandler(handler
);
889 SetEventHandler(handler
);
892 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
894 wxEvtHandler
*handlerA
= GetEventHandler();
897 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
898 handlerA
->SetNextHandler((wxEvtHandler
*)NULL
);
901 handlerB
->SetPreviousHandler((wxEvtHandler
*)NULL
);
902 SetEventHandler(handlerB
);
907 handlerA
= (wxEvtHandler
*)NULL
;
914 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handler
)
916 wxCHECK_MSG( handler
, false, _T("RemoveEventHandler(NULL) called") );
918 wxEvtHandler
*handlerPrev
= NULL
,
919 *handlerCur
= GetEventHandler();
922 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
924 if ( handlerCur
== handler
)
928 handlerPrev
->SetNextHandler(handlerNext
);
932 SetEventHandler(handlerNext
);
937 handlerNext
->SetPreviousHandler ( handlerPrev
);
940 handler
->SetNextHandler(NULL
);
941 handler
->SetPreviousHandler(NULL
);
946 handlerPrev
= handlerCur
;
947 handlerCur
= handlerNext
;
950 wxFAIL_MSG( _T("where has the event handler gone?") );
955 // ----------------------------------------------------------------------------
957 // ----------------------------------------------------------------------------
959 void wxWindowBase::InheritAttributes()
961 const wxWindowBase
* const parent
= GetParent();
965 // we only inherit attributes which had been explicitly set for the parent
966 // which ensures that this only happens if the user really wants it and
967 // not by default which wouldn't make any sense in modern GUIs where the
968 // controls don't all use the same fonts (nor colours)
969 if ( parent
->m_inheritFont
&& !m_hasFont
)
970 SetFont(parent
->GetFont());
972 // in addition, there is a possibility to explicitly forbid inheriting
973 // colours at each class level by overriding ShouldInheritColours()
974 if ( ShouldInheritColours() )
976 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
977 SetForegroundColour(parent
->GetForegroundColour());
979 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
980 SetBackgroundColour(parent
->GetBackgroundColour());
984 /* static */ wxVisualAttributes
985 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
987 // it is important to return valid values for all attributes from here,
988 // GetXXX() below rely on this
989 wxVisualAttributes attrs
;
990 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
991 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
992 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
997 wxColour
wxWindowBase::GetBackgroundColour() const
999 if ( !m_backgroundColour
.Ok() )
1001 wxASSERT_MSG( !m_hasBgCol
, _T("we have invalid explicit bg colour?") );
1003 // get our default background colour
1004 wxColour colBg
= GetDefaultAttributes().colBg
;
1006 // we must return some valid colour to avoid redoing this every time
1007 // and also to avoid surprizing the applications written for older
1008 // wxWidgets versions where GetBackgroundColour() always returned
1009 // something -- so give them something even if it doesn't make sense
1010 // for this window (e.g. it has a themed background)
1012 colBg
= GetClassDefaultAttributes().colBg
;
1017 return m_backgroundColour
;
1020 wxColour
wxWindowBase::GetForegroundColour() const
1022 // logic is the same as above
1023 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
1025 wxASSERT_MSG( !m_hasFgCol
, _T("we have invalid explicit fg colour?") );
1027 wxColour colFg
= GetDefaultAttributes().colFg
;
1030 colFg
= GetClassDefaultAttributes().colFg
;
1035 return m_foregroundColour
;
1038 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
1040 if ( colour
== m_backgroundColour
)
1043 m_hasBgCol
= colour
.Ok();
1044 if ( m_backgroundStyle
!= wxBG_STYLE_CUSTOM
)
1045 m_backgroundStyle
= m_hasBgCol
? wxBG_STYLE_COLOUR
: wxBG_STYLE_SYSTEM
;
1047 m_inheritBgCol
= m_hasBgCol
;
1048 m_backgroundColour
= colour
;
1049 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1053 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1055 if (colour
== m_foregroundColour
)
1058 m_hasFgCol
= colour
.Ok();
1059 m_inheritFgCol
= m_hasFgCol
;
1060 m_foregroundColour
= colour
;
1061 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1065 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1067 // setting an invalid cursor is ok, it means that we don't have any special
1069 if ( m_cursor
== cursor
)
1080 wxFont
wxWindowBase::GetFont() const
1082 // logic is the same as in GetBackgroundColour()
1085 wxASSERT_MSG( !m_hasFont
, _T("we have invalid explicit font?") );
1087 wxFont font
= GetDefaultAttributes().font
;
1089 font
= GetClassDefaultAttributes().font
;
1097 bool wxWindowBase::SetFont(const wxFont
& font
)
1099 if ( font
== m_font
)
1106 m_hasFont
= font
.Ok();
1107 m_inheritFont
= m_hasFont
;
1109 InvalidateBestSize();
1116 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1118 m_hasCustomPalette
= true;
1121 // VZ: can anyone explain me what do we do here?
1122 wxWindowDC
d((wxWindow
*) this);
1126 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1128 wxWindow
*win
= (wxWindow
*)this;
1129 while ( win
&& !win
->HasCustomPalette() )
1131 win
= win
->GetParent();
1137 #endif // wxUSE_PALETTE
1140 void wxWindowBase::SetCaret(wxCaret
*caret
)
1151 wxASSERT_MSG( m_caret
->GetWindow() == this,
1152 wxT("caret should be created associated to this window") );
1155 #endif // wxUSE_CARET
1157 #if wxUSE_VALIDATORS
1158 // ----------------------------------------------------------------------------
1160 // ----------------------------------------------------------------------------
1162 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1164 if ( m_windowValidator
)
1165 delete m_windowValidator
;
1167 m_windowValidator
= (wxValidator
*)validator
.Clone();
1169 if ( m_windowValidator
)
1170 m_windowValidator
->SetWindow(this);
1172 #endif // wxUSE_VALIDATORS
1174 // ----------------------------------------------------------------------------
1175 // update region stuff
1176 // ----------------------------------------------------------------------------
1178 wxRect
wxWindowBase::GetUpdateClientRect() const
1180 wxRegion rgnUpdate
= GetUpdateRegion();
1181 rgnUpdate
.Intersect(GetClientRect());
1182 wxRect rectUpdate
= rgnUpdate
.GetBox();
1183 wxPoint ptOrigin
= GetClientAreaOrigin();
1184 rectUpdate
.x
-= ptOrigin
.x
;
1185 rectUpdate
.y
-= ptOrigin
.y
;
1190 bool wxWindowBase::IsExposed(int x
, int y
) const
1192 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1195 bool wxWindowBase::IsExposed(int x
, int y
, int w
, int h
) const
1197 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1200 void wxWindowBase::ClearBackground()
1202 // wxGTK uses its own version, no need to add never used code
1204 wxClientDC
dc((wxWindow
*)this);
1205 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1206 dc
.SetBackground(brush
);
1211 // ----------------------------------------------------------------------------
1212 // find child window by id or name
1213 // ----------------------------------------------------------------------------
1215 wxWindow
*wxWindowBase::FindWindow( long id
)
1217 if ( id
== m_windowId
)
1218 return (wxWindow
*)this;
1220 wxWindowBase
*res
= (wxWindow
*)NULL
;
1221 wxWindowList::compatibility_iterator node
;
1222 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1224 wxWindowBase
*child
= node
->GetData();
1225 res
= child
->FindWindow( id
);
1228 return (wxWindow
*)res
;
1231 wxWindow
*wxWindowBase::FindWindow( const wxString
& name
)
1233 if ( name
== m_windowName
)
1234 return (wxWindow
*)this;
1236 wxWindowBase
*res
= (wxWindow
*)NULL
;
1237 wxWindowList::compatibility_iterator node
;
1238 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1240 wxWindow
*child
= node
->GetData();
1241 res
= child
->FindWindow(name
);
1244 return (wxWindow
*)res
;
1248 // find any window by id or name or label: If parent is non-NULL, look through
1249 // children for a label or title matching the specified string. If NULL, look
1250 // through all top-level windows.
1252 // to avoid duplicating code we reuse the same helper function but with
1253 // different comparators
1255 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1256 const wxString
& label
, long id
);
1259 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1262 return win
->GetLabel() == label
;
1266 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1269 return win
->GetName() == label
;
1273 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1276 return win
->GetId() == id
;
1279 // recursive helper for the FindWindowByXXX() functions
1281 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1282 const wxString
& label
,
1284 wxFindWindowCmp cmp
)
1288 // see if this is the one we're looking for
1289 if ( (*cmp
)(parent
, label
, id
) )
1290 return (wxWindow
*)parent
;
1292 // It wasn't, so check all its children
1293 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1295 node
= node
->GetNext() )
1297 // recursively check each child
1298 wxWindow
*win
= (wxWindow
*)node
->GetData();
1299 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1309 // helper for FindWindowByXXX()
1311 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1312 const wxString
& label
,
1314 wxFindWindowCmp cmp
)
1318 // just check parent and all its children
1319 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1322 // start at very top of wx's windows
1323 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1325 node
= node
->GetNext() )
1327 // recursively check each window & its children
1328 wxWindow
*win
= node
->GetData();
1329 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1339 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1341 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1346 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1348 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1352 // fall back to the label
1353 win
= FindWindowByLabel(title
, parent
);
1361 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1363 return wxFindWindowHelper(parent
, _T(""), id
, wxFindWindowCmpIds
);
1366 // ----------------------------------------------------------------------------
1367 // dialog oriented functions
1368 // ----------------------------------------------------------------------------
1370 void wxWindowBase::MakeModal(bool modal
)
1372 // Disable all other windows
1375 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1378 wxWindow
*win
= node
->GetData();
1380 win
->Enable(!modal
);
1382 node
= node
->GetNext();
1387 bool wxWindowBase::Validate()
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
->Validate((wxWindow
*)this) )
1402 if ( recurse
&& !child
->Validate() )
1407 #endif // wxUSE_VALIDATORS
1412 bool wxWindowBase::TransferDataToWindow()
1414 #if wxUSE_VALIDATORS
1415 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1417 wxWindowList::compatibility_iterator node
;
1418 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1420 wxWindowBase
*child
= node
->GetData();
1421 wxValidator
*validator
= child
->GetValidator();
1422 if ( validator
&& !validator
->TransferToWindow() )
1424 wxLogWarning(_("Could not transfer data to window"));
1426 wxLog::FlushActive();
1434 if ( !child
->TransferDataToWindow() )
1436 // warning already given
1441 #endif // wxUSE_VALIDATORS
1446 bool wxWindowBase::TransferDataFromWindow()
1448 #if wxUSE_VALIDATORS
1449 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1451 wxWindowList::compatibility_iterator node
;
1452 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1454 wxWindow
*child
= node
->GetData();
1455 wxValidator
*validator
= child
->GetValidator();
1456 if ( validator
&& !validator
->TransferFromWindow() )
1458 // nop warning here because the application is supposed to give
1459 // one itself - we don't know here what might have gone wrongly
1466 if ( !child
->TransferDataFromWindow() )
1468 // warning already given
1473 #endif // wxUSE_VALIDATORS
1478 void wxWindowBase::InitDialog()
1480 wxInitDialogEvent
event(GetId());
1481 event
.SetEventObject( this );
1482 GetEventHandler()->ProcessEvent(event
);
1485 // ----------------------------------------------------------------------------
1486 // context-sensitive help support
1487 // ----------------------------------------------------------------------------
1491 // associate this help text with this window
1492 void wxWindowBase::SetHelpText(const wxString
& text
)
1494 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1497 helpProvider
->AddHelp(this, text
);
1501 // associate this help text with all windows with the same id as this
1503 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1505 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1508 helpProvider
->AddHelp(GetId(), text
);
1512 // get the help string associated with this window (may be empty)
1513 wxString
wxWindowBase::GetHelpText() const
1516 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1519 text
= helpProvider
->GetHelp(this);
1525 // show help for this window
1526 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1528 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1531 if ( helpProvider
->ShowHelp(this) )
1533 // skip the event.Skip() below
1541 #endif // wxUSE_HELP
1543 // ----------------------------------------------------------------------------
1544 // tooltipsroot.Replace("\\", "/");
1545 // ----------------------------------------------------------------------------
1549 void wxWindowBase::SetToolTip( const wxString
&tip
)
1551 // don't create the new tooltip if we already have one
1554 m_tooltip
->SetTip( tip
);
1558 SetToolTip( new wxToolTip( tip
) );
1561 // setting empty tooltip text does not remove the tooltip any more - use
1562 // SetToolTip((wxToolTip *)NULL) for this
1565 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1570 m_tooltip
= tooltip
;
1573 #endif // wxUSE_TOOLTIPS
1575 // ----------------------------------------------------------------------------
1576 // constraints and sizers
1577 // ----------------------------------------------------------------------------
1579 #if wxUSE_CONSTRAINTS
1581 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1583 if ( m_constraints
)
1585 UnsetConstraints(m_constraints
);
1586 delete m_constraints
;
1588 m_constraints
= constraints
;
1589 if ( m_constraints
)
1591 // Make sure other windows know they're part of a 'meaningful relationship'
1592 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1593 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1594 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1595 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1596 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1597 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1598 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1599 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1600 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1601 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1602 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1603 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1604 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1605 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1606 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1607 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1611 // This removes any dangling pointers to this window in other windows'
1612 // constraintsInvolvedIn lists.
1613 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1617 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1618 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1619 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1620 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1621 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1622 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1623 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1624 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1625 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1626 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1627 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1628 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1629 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1630 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1631 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1632 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1636 // Back-pointer to other windows we're involved with, so if we delete this
1637 // window, we must delete any constraints we're involved with.
1638 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
1640 if ( !m_constraintsInvolvedIn
)
1641 m_constraintsInvolvedIn
= new wxWindowList
;
1642 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
1643 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
1646 // REMOVE back-pointer to other windows we're involved with.
1647 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
1649 if ( m_constraintsInvolvedIn
)
1650 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
1653 // Reset any constraints that mention this window
1654 void wxWindowBase::DeleteRelatedConstraints()
1656 if ( m_constraintsInvolvedIn
)
1658 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
1661 wxWindow
*win
= node
->GetData();
1662 wxLayoutConstraints
*constr
= win
->GetConstraints();
1664 // Reset any constraints involving this window
1667 constr
->left
.ResetIfWin(this);
1668 constr
->top
.ResetIfWin(this);
1669 constr
->right
.ResetIfWin(this);
1670 constr
->bottom
.ResetIfWin(this);
1671 constr
->width
.ResetIfWin(this);
1672 constr
->height
.ResetIfWin(this);
1673 constr
->centreX
.ResetIfWin(this);
1674 constr
->centreY
.ResetIfWin(this);
1677 wxWindowList::compatibility_iterator next
= node
->GetNext();
1678 m_constraintsInvolvedIn
->Erase(node
);
1682 delete m_constraintsInvolvedIn
;
1683 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
1687 #endif // wxUSE_CONSTRAINTS
1689 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
1691 if ( sizer
== m_windowSizer
)
1695 delete m_windowSizer
;
1697 m_windowSizer
= sizer
;
1699 SetAutoLayout( sizer
!= NULL
);
1702 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
1704 SetSizer( sizer
, deleteOld
);
1705 sizer
->SetSizeHints( (wxWindow
*) this );
1709 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
1711 // adding a window to a sizer twice is going to result in fatal and
1712 // hard to debug problems later because when deleting the second
1713 // associated wxSizerItem we're going to dereference a dangling
1714 // pointer; so try to detect this as early as possible
1715 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
1716 _T("Adding a window to the same sizer twice?") );
1718 m_containingSizer
= sizer
;
1721 #if wxUSE_CONSTRAINTS
1723 void wxWindowBase::SatisfyConstraints()
1725 wxLayoutConstraints
*constr
= GetConstraints();
1726 bool wasOk
= constr
&& constr
->AreSatisfied();
1728 ResetConstraints(); // Mark all constraints as unevaluated
1732 // if we're a top level panel (i.e. our parent is frame/dialog), our
1733 // own constraints will never be satisfied any more unless we do it
1737 while ( noChanges
> 0 )
1739 LayoutPhase1(&noChanges
);
1743 LayoutPhase2(&noChanges
);
1746 #endif // wxUSE_CONSTRAINTS
1748 bool wxWindowBase::Layout()
1750 // If there is a sizer, use it instead of the constraints
1754 GetVirtualSize(&w
, &h
);
1755 GetSizer()->SetDimension( 0, 0, w
, h
);
1757 #if wxUSE_CONSTRAINTS
1760 SatisfyConstraints(); // Find the right constraints values
1761 SetConstraintSizes(); // Recursively set the real window sizes
1768 #if wxUSE_CONSTRAINTS
1770 // first phase of the constraints evaluation: set our own constraints
1771 bool wxWindowBase::LayoutPhase1(int *noChanges
)
1773 wxLayoutConstraints
*constr
= GetConstraints();
1775 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
1778 // second phase: set the constraints for our children
1779 bool wxWindowBase::LayoutPhase2(int *noChanges
)
1786 // Layout grand children
1792 // Do a phase of evaluating child constraints
1793 bool wxWindowBase::DoPhase(int phase
)
1795 // the list containing the children for which the constraints are already
1797 wxWindowList succeeded
;
1799 // the max number of iterations we loop before concluding that we can't set
1801 static const int maxIterations
= 500;
1803 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
1807 // loop over all children setting their constraints
1808 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1810 node
= node
->GetNext() )
1812 wxWindow
*child
= node
->GetData();
1813 if ( child
->IsTopLevel() )
1815 // top level children are not inside our client area
1819 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
1821 // this one is either already ok or nothing we can do about it
1825 int tempNoChanges
= 0;
1826 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
1827 : child
->LayoutPhase2(&tempNoChanges
);
1828 noChanges
+= tempNoChanges
;
1832 succeeded
.Append(child
);
1838 // constraints are set
1846 void wxWindowBase::ResetConstraints()
1848 wxLayoutConstraints
*constr
= GetConstraints();
1851 constr
->left
.SetDone(false);
1852 constr
->top
.SetDone(false);
1853 constr
->right
.SetDone(false);
1854 constr
->bottom
.SetDone(false);
1855 constr
->width
.SetDone(false);
1856 constr
->height
.SetDone(false);
1857 constr
->centreX
.SetDone(false);
1858 constr
->centreY
.SetDone(false);
1861 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1864 wxWindow
*win
= node
->GetData();
1865 if ( !win
->IsTopLevel() )
1866 win
->ResetConstraints();
1867 node
= node
->GetNext();
1871 // Need to distinguish between setting the 'fake' size for windows and sizers,
1872 // and setting the real values.
1873 void wxWindowBase::SetConstraintSizes(bool recurse
)
1875 wxLayoutConstraints
*constr
= GetConstraints();
1876 if ( constr
&& constr
->AreSatisfied() )
1878 int x
= constr
->left
.GetValue();
1879 int y
= constr
->top
.GetValue();
1880 int w
= constr
->width
.GetValue();
1881 int h
= constr
->height
.GetValue();
1883 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
1884 (constr
->height
.GetRelationship() != wxAsIs
) )
1886 SetSize(x
, y
, w
, h
);
1890 // If we don't want to resize this window, just move it...
1896 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
1897 GetClassInfo()->GetClassName(),
1903 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1906 wxWindow
*win
= node
->GetData();
1907 if ( !win
->IsTopLevel() && win
->GetConstraints() )
1908 win
->SetConstraintSizes();
1909 node
= node
->GetNext();
1914 // Only set the size/position of the constraint (if any)
1915 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
1917 wxLayoutConstraints
*constr
= GetConstraints();
1920 if ( x
!= wxDefaultCoord
)
1922 constr
->left
.SetValue(x
);
1923 constr
->left
.SetDone(true);
1925 if ( y
!= wxDefaultCoord
)
1927 constr
->top
.SetValue(y
);
1928 constr
->top
.SetDone(true);
1930 if ( w
!= wxDefaultCoord
)
1932 constr
->width
.SetValue(w
);
1933 constr
->width
.SetDone(true);
1935 if ( h
!= wxDefaultCoord
)
1937 constr
->height
.SetValue(h
);
1938 constr
->height
.SetDone(true);
1943 void wxWindowBase::MoveConstraint(int x
, int y
)
1945 wxLayoutConstraints
*constr
= GetConstraints();
1948 if ( x
!= wxDefaultCoord
)
1950 constr
->left
.SetValue(x
);
1951 constr
->left
.SetDone(true);
1953 if ( y
!= wxDefaultCoord
)
1955 constr
->top
.SetValue(y
);
1956 constr
->top
.SetDone(true);
1961 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
1963 wxLayoutConstraints
*constr
= GetConstraints();
1966 *w
= constr
->width
.GetValue();
1967 *h
= constr
->height
.GetValue();
1973 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
1975 wxLayoutConstraints
*constr
= GetConstraints();
1978 *w
= constr
->width
.GetValue();
1979 *h
= constr
->height
.GetValue();
1982 GetClientSize(w
, h
);
1985 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
1987 wxLayoutConstraints
*constr
= GetConstraints();
1990 *x
= constr
->left
.GetValue();
1991 *y
= constr
->top
.GetValue();
1997 #endif // wxUSE_CONSTRAINTS
1999 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
2001 // don't do it for the dialogs/frames - they float independently of their
2003 if ( !IsTopLevel() )
2005 wxWindow
*parent
= GetParent();
2006 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
2008 wxPoint
pt(parent
->GetClientAreaOrigin());
2015 // ----------------------------------------------------------------------------
2016 // do Update UI processing for child controls
2017 // ----------------------------------------------------------------------------
2019 void wxWindowBase::UpdateWindowUI(long flags
)
2021 wxUpdateUIEvent
event(GetId());
2022 event
.m_eventObject
= this;
2024 if ( GetEventHandler()->ProcessEvent(event
) )
2026 DoUpdateWindowUI(event
);
2029 if (flags
& wxUPDATE_UI_RECURSE
)
2031 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2034 wxWindow
* child
= (wxWindow
*) node
->GetData();
2035 child
->UpdateWindowUI(flags
);
2036 node
= node
->GetNext();
2041 // do the window-specific processing after processing the update event
2042 // TODO: take specific knowledge out of this function and
2043 // put in each control's base class. Unfortunately we don't
2044 // yet have base implementation files for wxCheckBox and wxRadioButton.
2045 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
2047 if ( event
.GetSetEnabled() )
2048 Enable(event
.GetEnabled());
2051 if ( event
.GetSetText() )
2053 wxControl
*control
= wxDynamicCastThis(wxControl
);
2056 if ( event
.GetText() != control
->GetLabel() )
2057 control
->SetLabel(event
.GetText());
2060 #endif // wxUSE_CONTROLS
2062 if ( event
.GetSetChecked() )
2065 wxCheckBox
*checkbox
= wxDynamicCastThis(wxCheckBox
);
2068 checkbox
->SetValue(event
.GetChecked());
2070 #endif // wxUSE_CHECKBOX
2073 wxRadioButton
*radiobtn
= wxDynamicCastThis(wxRadioButton
);
2076 radiobtn
->SetValue(event
.GetChecked());
2078 #endif // wxUSE_RADIOBTN
2083 // call internal idle recursively
2084 // may be obsolete (wait until OnIdle scheme stabilises)
2085 void wxWindowBase::ProcessInternalIdle()
2089 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2092 wxWindow
*child
= node
->GetData();
2093 child
->ProcessInternalIdle();
2094 node
= node
->GetNext();
2099 // ----------------------------------------------------------------------------
2100 // dialog units translations
2101 // ----------------------------------------------------------------------------
2103 wxPoint
wxWindowBase::ConvertPixelsToDialog(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
* 4) / charWidth
);
2110 if (pt
.y
!= wxDefaultCoord
)
2111 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2116 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2118 int charWidth
= GetCharWidth();
2119 int charHeight
= GetCharHeight();
2120 wxPoint pt2
= wxDefaultPosition
;
2121 if (pt
.x
!= wxDefaultCoord
)
2122 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2123 if (pt
.y
!= wxDefaultCoord
)
2124 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2129 // ----------------------------------------------------------------------------
2131 // ----------------------------------------------------------------------------
2133 // propagate the colour change event to the subwindows
2134 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2136 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2139 // Only propagate to non-top-level windows
2140 wxWindow
*win
= node
->GetData();
2141 if ( !win
->IsTopLevel() )
2143 wxSysColourChangedEvent event2
;
2144 event
.m_eventObject
= win
;
2145 win
->GetEventHandler()->ProcessEvent(event2
);
2148 node
= node
->GetNext();
2154 // the default action is to populate dialog with data when it's created,
2155 // and nudge the UI into displaying itself correctly in case
2156 // we've turned the wxUpdateUIEvents frequency down low.
2157 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2159 TransferDataToWindow();
2161 // Update the UI at this point
2162 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2165 // process Ctrl-Alt-mclick
2166 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2169 if ( event
.ControlDown() && event
.AltDown() )
2171 // don't translate these strings
2174 #ifdef __WXUNIVERSAL__
2176 #endif // __WXUNIVERSAL__
2178 switch ( wxGetOsVersion() )
2180 case wxMOTIF_X
: port
+= _T("Motif"); break;
2182 case wxMAC_DARWIN
: port
+= _T("Mac"); break;
2183 case wxBEOS
: port
+= _T("BeOS"); break;
2187 case wxGTK_BEOS
: port
+= _T("GTK"); break;
2193 case wxWIN386
: port
+= _T("MS Windows"); break;
2197 case wxMGL_OS2
: port
+= _T("MGL"); break;
2199 case wxOS2_PM
: port
+= _T("OS/2"); break;
2200 default: port
+= _T("unknown"); break;
2203 wxMessageBox(wxString::Format(
2205 " wxWidgets Library (%s port)\nVersion %u.%u.%u%s%s, compiled at %s %s\n Copyright (c) 1995-2004 wxWidgets team"
2224 _T("wxWidgets information"),
2225 wxICON_INFORMATION
| wxOK
,
2229 #endif // wxUSE_MSGDLG
2235 // ----------------------------------------------------------------------------
2237 // ----------------------------------------------------------------------------
2239 #if wxUSE_ACCESSIBILITY
2240 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2242 if (m_accessible
&& (accessible
!= m_accessible
))
2243 delete m_accessible
;
2244 m_accessible
= accessible
;
2246 m_accessible
->SetWindow((wxWindow
*) this);
2249 // Returns the accessible object, creating if necessary.
2250 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2253 m_accessible
= CreateAccessible();
2254 return m_accessible
;
2257 // Override to create a specific accessible object.
2258 wxAccessible
* wxWindowBase::CreateAccessible()
2260 return new wxWindowAccessible((wxWindow
*) this);
2266 // ----------------------------------------------------------------------------
2267 // list classes implementation
2268 // ----------------------------------------------------------------------------
2270 void wxWindowListNode::DeleteData()
2272 delete (wxWindow
*)GetData();
2276 // ----------------------------------------------------------------------------
2278 // ----------------------------------------------------------------------------
2280 wxBorder
wxWindowBase::GetBorder(long flags
) const
2282 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2283 if ( border
== wxBORDER_DEFAULT
)
2285 border
= GetDefaultBorder();
2291 wxBorder
wxWindowBase::GetDefaultBorder() const
2293 return wxBORDER_NONE
;
2296 // ----------------------------------------------------------------------------
2298 // ----------------------------------------------------------------------------
2300 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2302 // here we just check if the point is inside the window or not
2304 // check the top and left border first
2305 bool outside
= x
< 0 || y
< 0;
2308 // check the right and bottom borders too
2309 wxSize size
= GetSize();
2310 outside
= x
>= size
.x
|| y
>= size
.y
;
2313 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2316 // ----------------------------------------------------------------------------
2318 // ----------------------------------------------------------------------------
2320 struct WXDLLEXPORT wxWindowNext
2324 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2326 void wxWindowBase::CaptureMouse()
2328 wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), this);
2330 wxWindow
*winOld
= GetCapture();
2333 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2336 wxWindowNext
*item
= new wxWindowNext
;
2338 item
->next
= ms_winCaptureNext
;
2339 ms_winCaptureNext
= item
;
2341 //else: no mouse capture to save
2346 void wxWindowBase::ReleaseMouse()
2348 wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), this);
2350 wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") );
2354 if ( ms_winCaptureNext
)
2356 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2358 wxWindowNext
*item
= ms_winCaptureNext
;
2359 ms_winCaptureNext
= item
->next
;
2362 //else: stack is empty, no previous capture
2364 wxLogTrace(_T("mousecapture"),
2365 (const wxChar
*) _T("After ReleaseMouse() mouse is captured by %p"),
2372 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2373 int WXUNUSED(modifiers
),
2374 int WXUNUSED(keycode
))
2380 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2386 #endif // wxUSE_HOTKEY
2388 void wxWindowBase::SendDestroyEvent()
2390 wxWindowDestroyEvent event
;
2391 event
.SetEventObject(this);
2392 event
.SetId(GetId());
2393 GetEventHandler()->ProcessEvent(event
);
2396 // ----------------------------------------------------------------------------
2398 // ----------------------------------------------------------------------------
2400 bool wxWindowBase::TryValidator(wxEvent
& wxVALIDATOR_PARAM(event
))
2402 #if wxUSE_VALIDATORS
2403 // Can only use the validator of the window which
2404 // is receiving the event
2405 if ( event
.GetEventObject() == this )
2407 wxValidator
*validator
= GetValidator();
2408 if ( validator
&& validator
->ProcessEvent(event
) )
2413 #endif // wxUSE_VALIDATORS
2418 bool wxWindowBase::TryParent(wxEvent
& event
)
2420 // carry on up the parent-child hierarchy if the propgation count hasn't
2422 if ( event
.ShouldPropagate() )
2424 // honour the requests to stop propagation at this window: this is
2425 // used by the dialogs, for example, to prevent processing the events
2426 // from the dialog controls in the parent frame which rarely, if ever,
2428 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2430 wxWindow
*parent
= GetParent();
2431 if ( parent
&& !parent
->IsBeingDeleted() )
2433 wxPropagateOnce
propagateOnce(event
);
2435 return parent
->GetEventHandler()->ProcessEvent(event
);
2440 return wxEvtHandler::TryParent(event
);
2443 // ----------------------------------------------------------------------------
2444 // keyboard navigation
2445 // ----------------------------------------------------------------------------
2447 // Navigates in the specified direction.
2448 bool wxWindowBase::Navigate(int flags
)
2450 wxNavigationKeyEvent eventNav
;
2451 eventNav
.SetFlags(flags
);
2452 eventNav
.SetEventObject(this);
2453 if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav
) )
2460 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, MoveKind move
)
2462 // check that we're not a top level window
2463 wxCHECK_RET( GetParent(),
2464 _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
2466 // detect the special case when we have nothing to do anyhow and when the
2467 // code below wouldn't work
2471 // find the target window in the siblings list
2472 wxWindowList
& siblings
= GetParent()->GetChildren();
2473 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
2474 wxCHECK_RET( i
, _T("MoveBefore/AfterInTabOrder(): win is not a sibling") );
2476 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
2477 // can't just move the node around
2478 wxWindow
*self
= (wxWindow
*)this;
2479 siblings
.DeleteObject(self
);
2480 if ( move
== MoveAfter
)
2487 siblings
.Insert(i
, self
);
2489 else // MoveAfter and win was the last sibling
2491 siblings
.Append(self
);
2495 // ----------------------------------------------------------------------------
2497 // ----------------------------------------------------------------------------
2499 /*static*/ wxWindow
* wxWindowBase::FindFocus()
2501 wxWindowBase
*win
= DoFindFocus();
2502 return win
? win
->GetMainWindowOfCompositeControl() : NULL
;
2505 // ----------------------------------------------------------------------------
2507 // ----------------------------------------------------------------------------
2509 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
2511 while ( win
&& !win
->IsTopLevel() )
2512 win
= win
->GetParent();
2517 #if wxUSE_ACCESSIBILITY
2518 // ----------------------------------------------------------------------------
2519 // accessible object for windows
2520 // ----------------------------------------------------------------------------
2522 // Can return either a child object, or an integer
2523 // representing the child element, starting from 1.
2524 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
2526 wxASSERT( GetWindow() != NULL
);
2530 return wxACC_NOT_IMPLEMENTED
;
2533 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
2534 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
2536 wxASSERT( GetWindow() != NULL
);
2540 wxWindow
* win
= NULL
;
2547 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
2549 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
2556 rect
= win
->GetRect();
2557 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
2558 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
2562 return wxACC_NOT_IMPLEMENTED
;
2565 // Navigates from fromId to toId/toObject.
2566 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
2567 int* WXUNUSED(toId
), wxAccessible
** toObject
)
2569 wxASSERT( GetWindow() != NULL
);
2575 case wxNAVDIR_FIRSTCHILD
:
2577 if (GetWindow()->GetChildren().GetCount() == 0)
2579 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
2580 *toObject
= childWindow
->GetOrCreateAccessible();
2584 case wxNAVDIR_LASTCHILD
:
2586 if (GetWindow()->GetChildren().GetCount() == 0)
2588 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
2589 *toObject
= childWindow
->GetOrCreateAccessible();
2593 case wxNAVDIR_RIGHT
:
2597 wxWindowList::compatibility_iterator node
=
2598 wxWindowList::compatibility_iterator();
2601 // Can't navigate to sibling of this window
2602 // if we're a top-level window.
2603 if (!GetWindow()->GetParent())
2604 return wxACC_NOT_IMPLEMENTED
;
2606 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2610 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2611 node
= GetWindow()->GetChildren().Item(fromId
-1);
2614 if (node
&& node
->GetNext())
2616 wxWindow
* nextWindow
= node
->GetNext()->GetData();
2617 *toObject
= nextWindow
->GetOrCreateAccessible();
2625 case wxNAVDIR_PREVIOUS
:
2627 wxWindowList::compatibility_iterator node
=
2628 wxWindowList::compatibility_iterator();
2631 // Can't navigate to sibling of this window
2632 // if we're a top-level window.
2633 if (!GetWindow()->GetParent())
2634 return wxACC_NOT_IMPLEMENTED
;
2636 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2640 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2641 node
= GetWindow()->GetChildren().Item(fromId
-1);
2644 if (node
&& node
->GetPrevious())
2646 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
2647 *toObject
= previousWindow
->GetOrCreateAccessible();
2655 return wxACC_NOT_IMPLEMENTED
;
2658 // Gets the name of the specified object.
2659 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
2661 wxASSERT( GetWindow() != NULL
);
2667 // If a child, leave wxWidgets to call the function on the actual
2670 return wxACC_NOT_IMPLEMENTED
;
2672 // This will eventually be replaced by specialised
2673 // accessible classes, one for each kind of wxWidgets
2674 // control or window.
2676 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
2677 title
= ((wxButton
*) GetWindow())->GetLabel();
2680 title
= GetWindow()->GetName();
2682 if (!title
.IsEmpty())
2688 return wxACC_NOT_IMPLEMENTED
;
2691 // Gets the number of children.
2692 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
2694 wxASSERT( GetWindow() != NULL
);
2698 *childId
= (int) GetWindow()->GetChildren().GetCount();
2702 // Gets the specified child (starting from 1).
2703 // If *child is NULL and return value is wxACC_OK,
2704 // this means that the child is a simple element and
2705 // not an accessible object.
2706 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
2708 wxASSERT( GetWindow() != NULL
);
2718 if (childId
> (int) GetWindow()->GetChildren().GetCount())
2721 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
2722 *child
= childWindow
->GetOrCreateAccessible();
2729 // Gets the parent, or NULL.
2730 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
2732 wxASSERT( GetWindow() != NULL
);
2736 wxWindow
* parentWindow
= GetWindow()->GetParent();
2744 *parent
= parentWindow
->GetOrCreateAccessible();
2752 // Performs the default action. childId is 0 (the action for this object)
2753 // or > 0 (the action for a child).
2754 // Return wxACC_NOT_SUPPORTED if there is no default action for this
2755 // window (e.g. an edit control).
2756 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
2758 wxASSERT( GetWindow() != NULL
);
2762 return wxACC_NOT_IMPLEMENTED
;
2765 // Gets the default action for this object (0) or > 0 (the action for a child).
2766 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
2767 // string if there is no action.
2768 // The retrieved string describes the action that is performed on an object,
2769 // not what the object does as a result. For example, a toolbar button that prints
2770 // a document has a default action of "Press" rather than "Prints the current document."
2771 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
2773 wxASSERT( GetWindow() != NULL
);
2777 return wxACC_NOT_IMPLEMENTED
;
2780 // Returns the description for this object or a child.
2781 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
2783 wxASSERT( GetWindow() != NULL
);
2787 wxString
ht(GetWindow()->GetHelpText());
2793 return wxACC_NOT_IMPLEMENTED
;
2796 // Returns help text for this object or a child, similar to tooltip text.
2797 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
2799 wxASSERT( GetWindow() != NULL
);
2803 wxString
ht(GetWindow()->GetHelpText());
2809 return wxACC_NOT_IMPLEMENTED
;
2812 // Returns the keyboard shortcut for this object or child.
2813 // Return e.g. ALT+K
2814 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
2816 wxASSERT( GetWindow() != NULL
);
2820 return wxACC_NOT_IMPLEMENTED
;
2823 // Returns a role constant.
2824 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
2826 wxASSERT( GetWindow() != NULL
);
2830 // If a child, leave wxWidgets to call the function on the actual
2833 return wxACC_NOT_IMPLEMENTED
;
2835 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2836 return wxACC_NOT_IMPLEMENTED
;
2838 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2839 return wxACC_NOT_IMPLEMENTED
;
2842 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2843 return wxACC_NOT_IMPLEMENTED
;
2846 //*role = wxROLE_SYSTEM_CLIENT;
2847 *role
= wxROLE_SYSTEM_CLIENT
;
2851 return wxACC_NOT_IMPLEMENTED
;
2855 // Returns a state constant.
2856 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
2858 wxASSERT( GetWindow() != NULL
);
2862 // If a child, leave wxWidgets to call the function on the actual
2865 return wxACC_NOT_IMPLEMENTED
;
2867 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2868 return wxACC_NOT_IMPLEMENTED
;
2871 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2872 return wxACC_NOT_IMPLEMENTED
;
2875 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2876 return wxACC_NOT_IMPLEMENTED
;
2883 return wxACC_NOT_IMPLEMENTED
;
2887 // Returns a localized string representing the value for the object
2889 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
2891 wxASSERT( GetWindow() != NULL
);
2895 return wxACC_NOT_IMPLEMENTED
;
2898 // Selects the object or child.
2899 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
2901 wxASSERT( GetWindow() != NULL
);
2905 return wxACC_NOT_IMPLEMENTED
;
2908 // Gets the window with the keyboard focus.
2909 // If childId is 0 and child is NULL, no object in
2910 // this subhierarchy has the focus.
2911 // If this object has the focus, child should be 'this'.
2912 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
2914 wxASSERT( GetWindow() != NULL
);
2918 return wxACC_NOT_IMPLEMENTED
;
2921 // Gets a variant representing the selected children
2923 // Acceptable values:
2924 // - a null variant (IsNull() returns true)
2925 // - a list variant (GetType() == wxT("list")
2926 // - an integer representing the selected child element,
2927 // or 0 if this object is selected (GetType() == wxT("long")
2928 // - a "void*" pointer to a wxAccessible child object
2929 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
2931 wxASSERT( GetWindow() != NULL
);
2935 return wxACC_NOT_IMPLEMENTED
;
2938 #endif // wxUSE_ACCESSIBILITY