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 // ----------------------------------------------------------------------------
88 #if defined(__WXPALMOS__)
89 int wxWindowBase::ms_lastControlId
= 32767;
90 #elif defined(__WXPM__)
91 int wxWindowBase::ms_lastControlId
= 2000;
93 int wxWindowBase::ms_lastControlId
= -200;
96 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase
, wxEvtHandler
)
98 // ----------------------------------------------------------------------------
100 // ----------------------------------------------------------------------------
102 BEGIN_EVENT_TABLE(wxWindowBase
, wxEvtHandler
)
103 EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged
)
104 EVT_INIT_DIALOG(wxWindowBase::OnInitDialog
)
105 EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick
)
108 EVT_HELP(wxID_ANY
, wxWindowBase::OnHelp
)
113 // ============================================================================
114 // implementation of the common functionality of the wxWindow class
115 // ============================================================================
117 // ----------------------------------------------------------------------------
119 // ----------------------------------------------------------------------------
121 // the default initialization
122 wxWindowBase::wxWindowBase()
124 // no window yet, no parent nor children
125 m_parent
= (wxWindow
*)NULL
;
126 m_windowId
= wxID_ANY
;
128 // no constraints on the minimal window size
130 m_maxWidth
= wxDefaultCoord
;
132 m_maxHeight
= wxDefaultCoord
;
134 // invalidiated cache value
135 m_bestSizeCache
= wxDefaultSize
;
137 // window are created enabled and visible by default
141 // the default event handler is just this window
142 m_eventHandler
= this;
146 m_windowValidator
= (wxValidator
*) NULL
;
147 #endif // wxUSE_VALIDATORS
149 // the colours/fonts are default for now, so leave m_font,
150 // m_backgroundColour and m_foregroundColour uninitialized and set those
156 m_inheritFont
= false;
162 m_backgroundStyle
= wxBG_STYLE_SYSTEM
;
164 #if wxUSE_CONSTRAINTS
165 // no constraints whatsoever
166 m_constraints
= (wxLayoutConstraints
*) NULL
;
167 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
168 #endif // wxUSE_CONSTRAINTS
170 m_windowSizer
= (wxSizer
*) NULL
;
171 m_containingSizer
= (wxSizer
*) NULL
;
172 m_autoLayout
= false;
174 #if wxUSE_DRAG_AND_DROP
175 m_dropTarget
= (wxDropTarget
*)NULL
;
176 #endif // wxUSE_DRAG_AND_DROP
179 m_tooltip
= (wxToolTip
*)NULL
;
180 #endif // wxUSE_TOOLTIPS
183 m_caret
= (wxCaret
*)NULL
;
184 #endif // wxUSE_CARET
187 m_hasCustomPalette
= false;
188 #endif // wxUSE_PALETTE
190 #if wxUSE_ACCESSIBILITY
194 m_virtualSize
= wxDefaultSize
;
197 m_maxVirtualWidth
= wxDefaultCoord
;
199 m_maxVirtualHeight
= wxDefaultCoord
;
201 m_windowVariant
= wxWINDOW_VARIANT_NORMAL
;
202 #if wxUSE_SYSTEM_OPTIONS
203 if ( wxSystemOptions::HasOption(wxWINDOW_DEFAULT_VARIANT
) )
205 m_windowVariant
= (wxWindowVariant
) wxSystemOptions::GetOptionInt( wxWINDOW_DEFAULT_VARIANT
) ;
209 // Whether we're using the current theme for this window (wxGTK only for now)
210 m_themeEnabled
= false;
212 // VZ: this one shouldn't exist...
213 m_isBeingDeleted
= false;
216 // common part of window creation process
217 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
219 const wxPoint
& WXUNUSED(pos
),
220 const wxSize
& WXUNUSED(size
),
222 const wxValidator
& wxVALIDATOR_PARAM(validator
),
223 const wxString
& name
)
226 // wxGTK doesn't allow to create controls with static box as the parent so
227 // this will result in a crash when the program is ported to wxGTK so warn
230 // if you get this assert, the correct solution is to create the controls
231 // as siblings of the static box
232 wxASSERT_MSG( !parent
|| !wxDynamicCast(parent
, wxStaticBox
),
233 _T("wxStaticBox can't be used as a window parent!") );
234 #endif // wxUSE_STATBOX
236 // ids are limited to 16 bits under MSW so if you care about portability,
237 // it's not a good idea to use ids out of this range (and negative ids are
238 // reserved for wxWidgets own usage)
239 wxASSERT_MSG( id
== wxID_ANY
|| (id
>= 0 && id
< 32767),
240 _T("invalid id value") );
242 // generate a new id if the user doesn't care about it
243 m_windowId
= id
== wxID_ANY
? NewControlId() : id
;
246 SetWindowStyleFlag(style
);
250 SetValidator(validator
);
251 #endif // wxUSE_VALIDATORS
253 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
254 // have it too - like this it's possible to set it only in the top level
255 // dialog/frame and all children will inherit it by defult
256 if ( parent
&& (parent
->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) )
258 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY
);
264 // ----------------------------------------------------------------------------
266 // ----------------------------------------------------------------------------
269 wxWindowBase::~wxWindowBase()
271 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
273 // FIXME if these 2 cases result from programming errors in the user code
274 // we should probably assert here instead of silently fixing them
276 // Just in case the window has been Closed, but we're then deleting
277 // immediately: don't leave dangling pointers.
278 wxPendingDelete
.DeleteObject(this);
280 // Just in case we've loaded a top-level window via LoadNativeDialog but
281 // we weren't a dialog class
282 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
284 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
286 // reset the dangling pointer our parent window may keep to us
289 if ( m_parent
->GetDefaultItem() == this )
291 m_parent
->SetDefaultItem(NULL
);
294 m_parent
->RemoveChild(this);
299 #endif // wxUSE_CARET
302 delete m_windowValidator
;
303 #endif // wxUSE_VALIDATORS
305 #if wxUSE_CONSTRAINTS
306 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
307 // at deleted windows as they delete themselves.
308 DeleteRelatedConstraints();
312 // This removes any dangling pointers to this window in other windows'
313 // constraintsInvolvedIn lists.
314 UnsetConstraints(m_constraints
);
315 delete m_constraints
;
316 m_constraints
= NULL
;
318 #endif // wxUSE_CONSTRAINTS
320 if ( m_containingSizer
)
321 m_containingSizer
->Detach( (wxWindow
*)this );
323 delete m_windowSizer
;
325 #if wxUSE_DRAG_AND_DROP
327 #endif // wxUSE_DRAG_AND_DROP
331 #endif // wxUSE_TOOLTIPS
333 #if wxUSE_ACCESSIBILITY
338 bool wxWindowBase::Destroy()
345 bool wxWindowBase::Close(bool force
)
347 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
348 event
.SetEventObject(this);
349 event
.SetCanVeto(!force
);
351 // return false if window wasn't closed because the application vetoed the
353 return GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto();
356 bool wxWindowBase::DestroyChildren()
358 wxWindowList::compatibility_iterator node
;
361 // we iterate until the list becomes empty
362 node
= GetChildren().GetFirst();
366 wxWindow
*child
= node
->GetData();
368 // note that we really want to call delete and not ->Destroy() here
369 // because we want to delete the child immediately, before we are
370 // deleted, and delayed deletion would result in problems as our (top
371 // level) child could outlive its parent
374 wxASSERT_MSG( !GetChildren().Find(child
),
375 wxT("child didn't remove itself using RemoveChild()") );
381 // ----------------------------------------------------------------------------
382 // size/position related methods
383 // ----------------------------------------------------------------------------
385 // centre the window with respect to its parent in either (or both) directions
386 void wxWindowBase::Centre(int direction
)
388 // the position/size of the parent window or of the entire screen
390 int widthParent
, heightParent
;
392 wxWindow
*parent
= NULL
;
393 wxTopLevelWindow
*winTop
= NULL
;
395 if ( !(direction
& wxCENTRE_ON_SCREEN
) )
397 // find the parent to centre this window on: it should be the
398 // immediate parent for the controls but the top level parent for the
399 // top level windows (like dialogs)
400 parent
= GetParent();
403 while ( parent
&& !parent
->IsTopLevel() )
405 parent
= parent
->GetParent();
409 // there is no wxTopLevelWindow under wxMotif yet
411 // we shouldn't center the dialog on the iconized window: under
412 // Windows, for example, this places it completely off the screen
415 winTop
= wxDynamicCast(parent
, wxTopLevelWindow
);
416 if ( winTop
&& winTop
->IsIconized() )
422 #endif // __WXMOTIF__
424 // did we find the parent?
428 direction
|= wxCENTRE_ON_SCREEN
;
432 if ( direction
& wxCENTRE_ON_SCREEN
)
434 // centre with respect to the whole screen
435 wxDisplaySize(&widthParent
, &heightParent
);
442 winTop
->GetRectForTopLevelChildren(&posParent
.x
, &posParent
.y
, &widthParent
, &heightParent
);
445 // centre on the parent
446 parent
->GetSize(&widthParent
, &heightParent
);
448 // adjust to the parents position
449 posParent
= parent
->GetPosition();
454 // centre inside the parents client rectangle
455 parent
->GetClientSize(&widthParent
, &heightParent
);
460 GetSize(&width
, &height
);
462 int xNew
= wxDefaultCoord
,
463 yNew
= wxDefaultCoord
;
465 if ( direction
& wxHORIZONTAL
)
466 xNew
= (widthParent
- width
)/2;
468 if ( direction
& wxVERTICAL
)
469 yNew
= (heightParent
- height
)/2;
474 // Base size of the visible dimensions of the display
475 // to take into account the taskbar. And the Mac menu bar at top.
476 wxRect clientrect
= wxGetClientDisplayRect();
478 // NB: in wxMSW, negative position may not neccessary mean "out of screen",
479 // but it may mean that the window is placed on other than the main
480 // display. Therefore we only make sure centered window is on the main display
481 // if the parent is at least partially present here.
482 if (posParent
.x
+ widthParent
>= 0) // if parent is (partially) on the main display
484 if (xNew
< clientrect
.GetLeft())
485 xNew
= clientrect
.GetLeft();
486 else if (xNew
+ width
> clientrect
.GetRight())
487 xNew
= clientrect
.GetRight() - width
;
489 if (posParent
.y
+ heightParent
>= 0) // if parent is (partially) on the main display
491 if (yNew
+ height
> clientrect
.GetBottom())
492 yNew
= clientrect
.GetBottom() - height
;
494 // Make certain that the title bar is initially visible
495 // always, even if this would push the bottom of the
496 // dialog off the visible area of the display
497 if (yNew
< clientrect
.GetTop())
498 yNew
= clientrect
.GetTop();
501 // move the window to this position (keeping the old size but using
502 // SetSize() and not Move() to allow xNew and/or yNew to be wxDefaultCoord)
503 SetSize(xNew
, yNew
, width
, height
, wxSIZE_ALLOW_MINUS_ONE
);
506 // fits the window around the children
507 void wxWindowBase::Fit()
509 if ( GetChildren().GetCount() > 0 )
511 SetClientSize(GetBestSize());
513 //else: do nothing if we have no children
516 // fits virtual size (ie. scrolled area etc.) around children
517 void wxWindowBase::FitInside()
519 if ( GetChildren().GetCount() > 0 )
521 SetVirtualSize( GetBestVirtualSize() );
525 // On Mac, scrollbars are explicitly children.
527 static bool wxHasRealChildren(const wxWindowBase
* win
)
529 int realChildCount
= 0;
531 for ( wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
533 node
= node
->GetNext() )
535 wxWindow
*win
= node
->GetData();
536 if ( !win
->IsTopLevel() && win
->IsShown() && !win
->IsKindOf(CLASSINFO(wxScrollBar
)))
539 return (realChildCount
> 0);
543 void wxWindowBase::InvalidateBestSize()
545 m_bestSizeCache
= wxDefaultSize
;
547 // parent's best size calculation may depend on its children's
548 // best sizes, so let's invalidate it as well to be safe:
550 m_parent
->InvalidateBestSize();
553 // return the size best suited for the current window
554 wxSize
wxWindowBase::DoGetBestSize() const
558 return m_windowSizer
->GetMinSize();
560 #if wxUSE_CONSTRAINTS
561 else if ( m_constraints
)
563 wxConstCast(this, wxWindowBase
)->SatisfyConstraints();
565 // our minimal acceptable size is such that all our windows fit inside
569 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
571 node
= node
->GetNext() )
573 wxLayoutConstraints
*c
= node
->GetData()->GetConstraints();
576 // it's not normal that we have an unconstrained child, but
577 // what can we do about it?
581 int x
= c
->right
.GetValue(),
582 y
= c
->bottom
.GetValue();
590 // TODO: we must calculate the overlaps somehow, otherwise we
591 // will never return a size bigger than the current one :-(
594 return wxSize(maxX
, maxY
);
596 #endif // wxUSE_CONSTRAINTS
597 else if ( !GetChildren().empty()
599 && wxHasRealChildren(this)
603 // our minimal acceptable size is such that all our visible child windows fit inside
607 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
609 node
= node
->GetNext() )
611 wxWindow
*win
= node
->GetData();
612 if ( win
->IsTopLevel() || ( ! win
->IsShown() )
614 || wxDynamicCast(win
, wxStatusBar
)
615 #endif // wxUSE_STATUSBAR
618 // dialogs and frames lie in different top level windows -
619 // don't deal with them here; as for the status bars, they
620 // don't lie in the client area at all
625 win
->GetPosition(&wx
, &wy
);
627 // if the window hadn't been positioned yet, assume that it is in
629 if ( wx
== wxDefaultCoord
)
631 if ( wy
== wxDefaultCoord
)
634 win
->GetSize(&ww
, &wh
);
635 if ( wx
+ ww
> maxX
)
637 if ( wy
+ wh
> maxY
)
641 // for compatibility with the old versions and because it really looks
642 // slightly more pretty like this, add a pad
646 return wxSize(maxX
, maxY
);
648 else // ! has children
650 // for a generic window there is no natural best size - just use either the
651 // minimum size if there is one, or the current size
652 if ( GetMinSize().IsFullySpecified() )
660 wxSize
wxWindowBase::GetBestFittingSize() const
662 // merge the best size with the min size, giving priority to the min size
663 wxSize min
= GetMinSize();
664 if (min
.x
== wxDefaultCoord
|| min
.y
== wxDefaultCoord
)
666 wxSize best
= GetBestSize();
667 if (min
.x
== wxDefaultCoord
) min
.x
= best
.x
;
668 if (min
.y
== wxDefaultCoord
) min
.y
= best
.y
;
674 void wxWindowBase::SetBestFittingSize(const wxSize
& size
)
676 // Set the min size to the size passed in. This will usually either be
677 // wxDefaultSize or the size passed to this window's ctor/Create function.
680 // Merge the size with the best size if needed
681 wxSize best
= GetBestFittingSize();
683 // If the current size doesn't match then change it
684 if (GetSize() != best
)
689 // by default the origin is not shifted
690 wxPoint
wxWindowBase::GetClientAreaOrigin() const
692 return wxPoint(0, 0);
695 // set the min/max size of the window
696 void wxWindowBase::DoSetSizeHints(int minW
, int minH
,
698 int WXUNUSED(incW
), int WXUNUSED(incH
))
700 // setting min width greater than max width leads to infinite loops under
701 // X11 and generally doesn't make any sense, so don't allow it
702 wxCHECK_RET( (minW
== wxDefaultCoord
|| maxW
== wxDefaultCoord
|| minW
<= maxW
) &&
703 (minH
== wxDefaultCoord
|| maxH
== wxDefaultCoord
|| minH
<= maxH
),
704 _T("min width/height must be less than max width/height!") );
712 void wxWindowBase::SetWindowVariant( wxWindowVariant variant
)
714 if ( m_windowVariant
!= variant
)
716 m_windowVariant
= variant
;
718 DoSetWindowVariant(variant
);
722 void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant
)
724 // adjust the font height to correspond to our new variant (notice that
725 // we're only called if something really changed)
726 wxFont font
= GetFont();
727 int size
= font
.GetPointSize();
730 case wxWINDOW_VARIANT_NORMAL
:
733 case wxWINDOW_VARIANT_SMALL
:
738 case wxWINDOW_VARIANT_MINI
:
743 case wxWINDOW_VARIANT_LARGE
:
749 wxFAIL_MSG(_T("unexpected window variant"));
753 font
.SetPointSize(size
);
757 void wxWindowBase::SetVirtualSizeHints( int minW
, int minH
,
760 m_minVirtualWidth
= minW
;
761 m_maxVirtualWidth
= maxW
;
762 m_minVirtualHeight
= minH
;
763 m_maxVirtualHeight
= maxH
;
766 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
768 if ( m_minVirtualWidth
!= wxDefaultCoord
&& m_minVirtualWidth
> x
)
769 x
= m_minVirtualWidth
;
770 if ( m_maxVirtualWidth
!= wxDefaultCoord
&& m_maxVirtualWidth
< x
)
771 x
= m_maxVirtualWidth
;
772 if ( m_minVirtualHeight
!= wxDefaultCoord
&& m_minVirtualHeight
> y
)
773 y
= m_minVirtualHeight
;
774 if ( m_maxVirtualHeight
!= wxDefaultCoord
&& m_maxVirtualHeight
< y
)
775 y
= m_maxVirtualHeight
;
777 m_virtualSize
= wxSize(x
, y
);
780 wxSize
wxWindowBase::DoGetVirtualSize() const
782 wxSize
s( GetClientSize() );
784 return wxSize( wxMax( m_virtualSize
.GetWidth(), s
.GetWidth() ),
785 wxMax( m_virtualSize
.GetHeight(), s
.GetHeight() ) );
788 // ----------------------------------------------------------------------------
789 // show/hide/enable/disable the window
790 // ----------------------------------------------------------------------------
792 bool wxWindowBase::Show(bool show
)
794 if ( show
!= m_isShown
)
806 bool wxWindowBase::Enable(bool enable
)
808 if ( enable
!= m_isEnabled
)
810 m_isEnabled
= enable
;
819 // ----------------------------------------------------------------------------
821 // ----------------------------------------------------------------------------
823 bool wxWindowBase::IsTopLevel() const
828 // ----------------------------------------------------------------------------
829 // reparenting the window
830 // ----------------------------------------------------------------------------
832 void wxWindowBase::AddChild(wxWindowBase
*child
)
834 wxCHECK_RET( child
, wxT("can't add a NULL child") );
836 // this should never happen and it will lead to a crash later if it does
837 // because RemoveChild() will remove only one node from the children list
838 // and the other(s) one(s) will be left with dangling pointers in them
839 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), _T("AddChild() called twice") );
841 GetChildren().Append((wxWindow
*)child
);
842 child
->SetParent(this);
845 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
847 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
849 GetChildren().DeleteObject((wxWindow
*)child
);
850 child
->SetParent(NULL
);
853 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
855 wxWindow
*oldParent
= GetParent();
856 if ( newParent
== oldParent
)
862 // unlink this window from the existing parent.
865 oldParent
->RemoveChild(this);
869 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
872 // add it to the new one
875 newParent
->AddChild(this);
879 wxTopLevelWindows
.Append((wxWindow
*)this);
885 // ----------------------------------------------------------------------------
886 // event handler stuff
887 // ----------------------------------------------------------------------------
889 void wxWindowBase::PushEventHandler(wxEvtHandler
*handler
)
891 wxEvtHandler
*handlerOld
= GetEventHandler();
893 handler
->SetNextHandler(handlerOld
);
896 GetEventHandler()->SetPreviousHandler(handler
);
898 SetEventHandler(handler
);
901 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
903 wxEvtHandler
*handlerA
= GetEventHandler();
906 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
907 handlerA
->SetNextHandler((wxEvtHandler
*)NULL
);
910 handlerB
->SetPreviousHandler((wxEvtHandler
*)NULL
);
911 SetEventHandler(handlerB
);
916 handlerA
= (wxEvtHandler
*)NULL
;
923 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handler
)
925 wxCHECK_MSG( handler
, false, _T("RemoveEventHandler(NULL) called") );
927 wxEvtHandler
*handlerPrev
= NULL
,
928 *handlerCur
= GetEventHandler();
931 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
933 if ( handlerCur
== handler
)
937 handlerPrev
->SetNextHandler(handlerNext
);
941 SetEventHandler(handlerNext
);
946 handlerNext
->SetPreviousHandler ( handlerPrev
);
949 handler
->SetNextHandler(NULL
);
950 handler
->SetPreviousHandler(NULL
);
955 handlerPrev
= handlerCur
;
956 handlerCur
= handlerNext
;
959 wxFAIL_MSG( _T("where has the event handler gone?") );
964 // ----------------------------------------------------------------------------
966 // ----------------------------------------------------------------------------
968 void wxWindowBase::InheritAttributes()
970 const wxWindowBase
* const parent
= GetParent();
974 // we only inherit attributes which had been explicitly set for the parent
975 // which ensures that this only happens if the user really wants it and
976 // not by default which wouldn't make any sense in modern GUIs where the
977 // controls don't all use the same fonts (nor colours)
978 if ( parent
->m_inheritFont
&& !m_hasFont
)
979 SetFont(parent
->GetFont());
981 // in addition, there is a possibility to explicitly forbid inheriting
982 // colours at each class level by overriding ShouldInheritColours()
983 if ( ShouldInheritColours() )
985 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
986 SetForegroundColour(parent
->GetForegroundColour());
988 // inheriting (solid) background colour is wrong as it totally breaks
989 // any kind of themed backgrounds
991 // instead, the controls should use the same background as their parent
992 // (ideally by not drawing it at all)
994 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
995 SetBackgroundColour(parent
->GetBackgroundColour());
1000 /* static */ wxVisualAttributes
1001 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
1003 // it is important to return valid values for all attributes from here,
1004 // GetXXX() below rely on this
1005 wxVisualAttributes attrs
;
1006 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
1007 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
1008 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
1013 wxColour
wxWindowBase::GetBackgroundColour() const
1015 if ( !m_backgroundColour
.Ok() )
1017 wxASSERT_MSG( !m_hasBgCol
, _T("we have invalid explicit bg colour?") );
1019 // get our default background colour
1020 wxColour colBg
= GetDefaultAttributes().colBg
;
1022 // we must return some valid colour to avoid redoing this every time
1023 // and also to avoid surprizing the applications written for older
1024 // wxWidgets versions where GetBackgroundColour() always returned
1025 // something -- so give them something even if it doesn't make sense
1026 // for this window (e.g. it has a themed background)
1028 colBg
= GetClassDefaultAttributes().colBg
;
1033 return m_backgroundColour
;
1036 wxColour
wxWindowBase::GetForegroundColour() const
1038 // logic is the same as above
1039 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
1041 wxASSERT_MSG( !m_hasFgCol
, _T("we have invalid explicit fg colour?") );
1043 wxColour colFg
= GetDefaultAttributes().colFg
;
1046 colFg
= GetClassDefaultAttributes().colFg
;
1051 return m_foregroundColour
;
1054 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
1056 if ( colour
== m_backgroundColour
)
1059 m_hasBgCol
= colour
.Ok();
1060 if ( m_backgroundStyle
!= wxBG_STYLE_CUSTOM
)
1061 m_backgroundStyle
= m_hasBgCol
? wxBG_STYLE_COLOUR
: wxBG_STYLE_SYSTEM
;
1063 m_inheritBgCol
= m_hasBgCol
;
1064 m_backgroundColour
= colour
;
1065 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1069 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1071 if (colour
== m_foregroundColour
)
1074 m_hasFgCol
= colour
.Ok();
1075 m_inheritFgCol
= m_hasFgCol
;
1076 m_foregroundColour
= colour
;
1077 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1081 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1083 // setting an invalid cursor is ok, it means that we don't have any special
1085 if ( m_cursor
== cursor
)
1096 wxFont
wxWindowBase::GetFont() const
1098 // logic is the same as in GetBackgroundColour()
1101 wxASSERT_MSG( !m_hasFont
, _T("we have invalid explicit font?") );
1103 wxFont font
= GetDefaultAttributes().font
;
1105 font
= GetClassDefaultAttributes().font
;
1113 bool wxWindowBase::SetFont(const wxFont
& font
)
1115 if ( font
== m_font
)
1122 m_hasFont
= font
.Ok();
1123 m_inheritFont
= m_hasFont
;
1125 InvalidateBestSize();
1132 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1134 m_hasCustomPalette
= true;
1137 // VZ: can anyone explain me what do we do here?
1138 wxWindowDC
d((wxWindow
*) this);
1142 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1144 wxWindow
*win
= (wxWindow
*)this;
1145 while ( win
&& !win
->HasCustomPalette() )
1147 win
= win
->GetParent();
1153 #endif // wxUSE_PALETTE
1156 void wxWindowBase::SetCaret(wxCaret
*caret
)
1167 wxASSERT_MSG( m_caret
->GetWindow() == this,
1168 wxT("caret should be created associated to this window") );
1171 #endif // wxUSE_CARET
1173 #if wxUSE_VALIDATORS
1174 // ----------------------------------------------------------------------------
1176 // ----------------------------------------------------------------------------
1178 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1180 if ( m_windowValidator
)
1181 delete m_windowValidator
;
1183 m_windowValidator
= (wxValidator
*)validator
.Clone();
1185 if ( m_windowValidator
)
1186 m_windowValidator
->SetWindow(this);
1188 #endif // wxUSE_VALIDATORS
1190 // ----------------------------------------------------------------------------
1191 // update region stuff
1192 // ----------------------------------------------------------------------------
1194 wxRect
wxWindowBase::GetUpdateClientRect() const
1196 wxRegion rgnUpdate
= GetUpdateRegion();
1197 rgnUpdate
.Intersect(GetClientRect());
1198 wxRect rectUpdate
= rgnUpdate
.GetBox();
1199 wxPoint ptOrigin
= GetClientAreaOrigin();
1200 rectUpdate
.x
-= ptOrigin
.x
;
1201 rectUpdate
.y
-= ptOrigin
.y
;
1206 bool wxWindowBase::IsExposed(int x
, int y
) const
1208 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1211 bool wxWindowBase::IsExposed(int x
, int y
, int w
, int h
) const
1213 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1216 void wxWindowBase::ClearBackground()
1218 // wxGTK uses its own version, no need to add never used code
1220 wxClientDC
dc((wxWindow
*)this);
1221 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1222 dc
.SetBackground(brush
);
1227 // ----------------------------------------------------------------------------
1228 // find child window by id or name
1229 // ----------------------------------------------------------------------------
1231 wxWindow
*wxWindowBase::FindWindow(long id
) const
1233 if ( id
== m_windowId
)
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 wxWindowBase
*child
= node
->GetData();
1241 res
= child
->FindWindow( id
);
1244 return (wxWindow
*)res
;
1247 wxWindow
*wxWindowBase::FindWindow(const wxString
& name
) const
1249 if ( name
== m_windowName
)
1250 return (wxWindow
*)this;
1252 wxWindowBase
*res
= (wxWindow
*)NULL
;
1253 wxWindowList::compatibility_iterator node
;
1254 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1256 wxWindow
*child
= node
->GetData();
1257 res
= child
->FindWindow(name
);
1260 return (wxWindow
*)res
;
1264 // find any window by id or name or label: If parent is non-NULL, look through
1265 // children for a label or title matching the specified string. If NULL, look
1266 // through all top-level windows.
1268 // to avoid duplicating code we reuse the same helper function but with
1269 // different comparators
1271 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1272 const wxString
& label
, long id
);
1275 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1278 return win
->GetLabel() == label
;
1282 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1285 return win
->GetName() == label
;
1289 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1292 return win
->GetId() == id
;
1295 // recursive helper for the FindWindowByXXX() functions
1297 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1298 const wxString
& label
,
1300 wxFindWindowCmp cmp
)
1304 // see if this is the one we're looking for
1305 if ( (*cmp
)(parent
, label
, id
) )
1306 return (wxWindow
*)parent
;
1308 // It wasn't, so check all its children
1309 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1311 node
= node
->GetNext() )
1313 // recursively check each child
1314 wxWindow
*win
= (wxWindow
*)node
->GetData();
1315 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1325 // helper for FindWindowByXXX()
1327 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1328 const wxString
& label
,
1330 wxFindWindowCmp cmp
)
1334 // just check parent and all its children
1335 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1338 // start at very top of wx's windows
1339 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1341 node
= node
->GetNext() )
1343 // recursively check each window & its children
1344 wxWindow
*win
= node
->GetData();
1345 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1355 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1357 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1362 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1364 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1368 // fall back to the label
1369 win
= FindWindowByLabel(title
, parent
);
1377 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1379 return wxFindWindowHelper(parent
, _T(""), id
, wxFindWindowCmpIds
);
1382 // ----------------------------------------------------------------------------
1383 // dialog oriented functions
1384 // ----------------------------------------------------------------------------
1386 void wxWindowBase::MakeModal(bool modal
)
1388 // Disable all other windows
1391 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1394 wxWindow
*win
= node
->GetData();
1396 win
->Enable(!modal
);
1398 node
= node
->GetNext();
1403 bool wxWindowBase::Validate()
1405 #if wxUSE_VALIDATORS
1406 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1408 wxWindowList::compatibility_iterator node
;
1409 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1411 wxWindowBase
*child
= node
->GetData();
1412 wxValidator
*validator
= child
->GetValidator();
1413 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1418 if ( recurse
&& !child
->Validate() )
1423 #endif // wxUSE_VALIDATORS
1428 bool wxWindowBase::TransferDataToWindow()
1430 #if wxUSE_VALIDATORS
1431 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1433 wxWindowList::compatibility_iterator node
;
1434 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1436 wxWindowBase
*child
= node
->GetData();
1437 wxValidator
*validator
= child
->GetValidator();
1438 if ( validator
&& !validator
->TransferToWindow() )
1440 wxLogWarning(_("Could not transfer data to window"));
1442 wxLog::FlushActive();
1450 if ( !child
->TransferDataToWindow() )
1452 // warning already given
1457 #endif // wxUSE_VALIDATORS
1462 bool wxWindowBase::TransferDataFromWindow()
1464 #if wxUSE_VALIDATORS
1465 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1467 wxWindowList::compatibility_iterator node
;
1468 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1470 wxWindow
*child
= node
->GetData();
1471 wxValidator
*validator
= child
->GetValidator();
1472 if ( validator
&& !validator
->TransferFromWindow() )
1474 // nop warning here because the application is supposed to give
1475 // one itself - we don't know here what might have gone wrongly
1482 if ( !child
->TransferDataFromWindow() )
1484 // warning already given
1489 #endif // wxUSE_VALIDATORS
1494 void wxWindowBase::InitDialog()
1496 wxInitDialogEvent
event(GetId());
1497 event
.SetEventObject( this );
1498 GetEventHandler()->ProcessEvent(event
);
1501 // ----------------------------------------------------------------------------
1502 // context-sensitive help support
1503 // ----------------------------------------------------------------------------
1507 // associate this help text with this window
1508 void wxWindowBase::SetHelpText(const wxString
& text
)
1510 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1513 helpProvider
->AddHelp(this, text
);
1517 // associate this help text with all windows with the same id as this
1519 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1521 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1524 helpProvider
->AddHelp(GetId(), text
);
1528 // get the help string associated with this window (may be empty)
1529 wxString
wxWindowBase::GetHelpText() const
1532 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1535 text
= helpProvider
->GetHelp(this);
1541 // show help for this window
1542 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1544 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1547 if ( helpProvider
->ShowHelp(this) )
1549 // skip the event.Skip() below
1557 #endif // wxUSE_HELP
1559 // ----------------------------------------------------------------------------
1560 // tooltipsroot.Replace("\\", "/");
1561 // ----------------------------------------------------------------------------
1565 void wxWindowBase::SetToolTip( const wxString
&tip
)
1567 // don't create the new tooltip if we already have one
1570 m_tooltip
->SetTip( tip
);
1574 SetToolTip( new wxToolTip( tip
) );
1577 // setting empty tooltip text does not remove the tooltip any more - use
1578 // SetToolTip((wxToolTip *)NULL) for this
1581 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1586 m_tooltip
= tooltip
;
1589 #endif // wxUSE_TOOLTIPS
1591 // ----------------------------------------------------------------------------
1592 // constraints and sizers
1593 // ----------------------------------------------------------------------------
1595 #if wxUSE_CONSTRAINTS
1597 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1599 if ( m_constraints
)
1601 UnsetConstraints(m_constraints
);
1602 delete m_constraints
;
1604 m_constraints
= constraints
;
1605 if ( m_constraints
)
1607 // Make sure other windows know they're part of a 'meaningful relationship'
1608 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1609 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1610 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1611 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1612 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1613 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1614 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1615 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1616 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1617 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1618 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1619 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1620 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1621 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1622 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1623 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1627 // This removes any dangling pointers to this window in other windows'
1628 // constraintsInvolvedIn lists.
1629 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1633 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1634 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1635 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1636 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1637 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1638 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1639 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1640 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1641 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1642 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1643 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1644 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1645 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1646 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1647 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1648 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1652 // Back-pointer to other windows we're involved with, so if we delete this
1653 // window, we must delete any constraints we're involved with.
1654 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
1656 if ( !m_constraintsInvolvedIn
)
1657 m_constraintsInvolvedIn
= new wxWindowList
;
1658 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
1659 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
1662 // REMOVE back-pointer to other windows we're involved with.
1663 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
1665 if ( m_constraintsInvolvedIn
)
1666 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
1669 // Reset any constraints that mention this window
1670 void wxWindowBase::DeleteRelatedConstraints()
1672 if ( m_constraintsInvolvedIn
)
1674 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
1677 wxWindow
*win
= node
->GetData();
1678 wxLayoutConstraints
*constr
= win
->GetConstraints();
1680 // Reset any constraints involving this window
1683 constr
->left
.ResetIfWin(this);
1684 constr
->top
.ResetIfWin(this);
1685 constr
->right
.ResetIfWin(this);
1686 constr
->bottom
.ResetIfWin(this);
1687 constr
->width
.ResetIfWin(this);
1688 constr
->height
.ResetIfWin(this);
1689 constr
->centreX
.ResetIfWin(this);
1690 constr
->centreY
.ResetIfWin(this);
1693 wxWindowList::compatibility_iterator next
= node
->GetNext();
1694 m_constraintsInvolvedIn
->Erase(node
);
1698 delete m_constraintsInvolvedIn
;
1699 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
1703 #endif // wxUSE_CONSTRAINTS
1705 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
1707 if ( sizer
== m_windowSizer
)
1711 delete m_windowSizer
;
1713 m_windowSizer
= sizer
;
1715 SetAutoLayout( sizer
!= NULL
);
1718 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
1720 SetSizer( sizer
, deleteOld
);
1721 sizer
->SetSizeHints( (wxWindow
*) this );
1725 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
1727 // adding a window to a sizer twice is going to result in fatal and
1728 // hard to debug problems later because when deleting the second
1729 // associated wxSizerItem we're going to dereference a dangling
1730 // pointer; so try to detect this as early as possible
1731 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
1732 _T("Adding a window to the same sizer twice?") );
1734 m_containingSizer
= sizer
;
1737 #if wxUSE_CONSTRAINTS
1739 void wxWindowBase::SatisfyConstraints()
1741 wxLayoutConstraints
*constr
= GetConstraints();
1742 bool wasOk
= constr
&& constr
->AreSatisfied();
1744 ResetConstraints(); // Mark all constraints as unevaluated
1748 // if we're a top level panel (i.e. our parent is frame/dialog), our
1749 // own constraints will never be satisfied any more unless we do it
1753 while ( noChanges
> 0 )
1755 LayoutPhase1(&noChanges
);
1759 LayoutPhase2(&noChanges
);
1762 #endif // wxUSE_CONSTRAINTS
1764 bool wxWindowBase::Layout()
1766 // If there is a sizer, use it instead of the constraints
1770 GetVirtualSize(&w
, &h
);
1771 GetSizer()->SetDimension( 0, 0, w
, h
);
1773 #if wxUSE_CONSTRAINTS
1776 SatisfyConstraints(); // Find the right constraints values
1777 SetConstraintSizes(); // Recursively set the real window sizes
1784 #if wxUSE_CONSTRAINTS
1786 // first phase of the constraints evaluation: set our own constraints
1787 bool wxWindowBase::LayoutPhase1(int *noChanges
)
1789 wxLayoutConstraints
*constr
= GetConstraints();
1791 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
1794 // second phase: set the constraints for our children
1795 bool wxWindowBase::LayoutPhase2(int *noChanges
)
1802 // Layout grand children
1808 // Do a phase of evaluating child constraints
1809 bool wxWindowBase::DoPhase(int phase
)
1811 // the list containing the children for which the constraints are already
1813 wxWindowList succeeded
;
1815 // the max number of iterations we loop before concluding that we can't set
1817 static const int maxIterations
= 500;
1819 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
1823 // loop over all children setting their constraints
1824 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1826 node
= node
->GetNext() )
1828 wxWindow
*child
= node
->GetData();
1829 if ( child
->IsTopLevel() )
1831 // top level children are not inside our client area
1835 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
1837 // this one is either already ok or nothing we can do about it
1841 int tempNoChanges
= 0;
1842 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
1843 : child
->LayoutPhase2(&tempNoChanges
);
1844 noChanges
+= tempNoChanges
;
1848 succeeded
.Append(child
);
1854 // constraints are set
1862 void wxWindowBase::ResetConstraints()
1864 wxLayoutConstraints
*constr
= GetConstraints();
1867 constr
->left
.SetDone(false);
1868 constr
->top
.SetDone(false);
1869 constr
->right
.SetDone(false);
1870 constr
->bottom
.SetDone(false);
1871 constr
->width
.SetDone(false);
1872 constr
->height
.SetDone(false);
1873 constr
->centreX
.SetDone(false);
1874 constr
->centreY
.SetDone(false);
1877 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1880 wxWindow
*win
= node
->GetData();
1881 if ( !win
->IsTopLevel() )
1882 win
->ResetConstraints();
1883 node
= node
->GetNext();
1887 // Need to distinguish between setting the 'fake' size for windows and sizers,
1888 // and setting the real values.
1889 void wxWindowBase::SetConstraintSizes(bool recurse
)
1891 wxLayoutConstraints
*constr
= GetConstraints();
1892 if ( constr
&& constr
->AreSatisfied() )
1894 int x
= constr
->left
.GetValue();
1895 int y
= constr
->top
.GetValue();
1896 int w
= constr
->width
.GetValue();
1897 int h
= constr
->height
.GetValue();
1899 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
1900 (constr
->height
.GetRelationship() != wxAsIs
) )
1902 SetSize(x
, y
, w
, h
);
1906 // If we don't want to resize this window, just move it...
1912 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
1913 GetClassInfo()->GetClassName(),
1919 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1922 wxWindow
*win
= node
->GetData();
1923 if ( !win
->IsTopLevel() && win
->GetConstraints() )
1924 win
->SetConstraintSizes();
1925 node
= node
->GetNext();
1930 // Only set the size/position of the constraint (if any)
1931 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
1933 wxLayoutConstraints
*constr
= GetConstraints();
1936 if ( x
!= wxDefaultCoord
)
1938 constr
->left
.SetValue(x
);
1939 constr
->left
.SetDone(true);
1941 if ( y
!= wxDefaultCoord
)
1943 constr
->top
.SetValue(y
);
1944 constr
->top
.SetDone(true);
1946 if ( w
!= wxDefaultCoord
)
1948 constr
->width
.SetValue(w
);
1949 constr
->width
.SetDone(true);
1951 if ( h
!= wxDefaultCoord
)
1953 constr
->height
.SetValue(h
);
1954 constr
->height
.SetDone(true);
1959 void wxWindowBase::MoveConstraint(int x
, int y
)
1961 wxLayoutConstraints
*constr
= GetConstraints();
1964 if ( x
!= wxDefaultCoord
)
1966 constr
->left
.SetValue(x
);
1967 constr
->left
.SetDone(true);
1969 if ( y
!= wxDefaultCoord
)
1971 constr
->top
.SetValue(y
);
1972 constr
->top
.SetDone(true);
1977 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
1979 wxLayoutConstraints
*constr
= GetConstraints();
1982 *w
= constr
->width
.GetValue();
1983 *h
= constr
->height
.GetValue();
1989 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
1991 wxLayoutConstraints
*constr
= GetConstraints();
1994 *w
= constr
->width
.GetValue();
1995 *h
= constr
->height
.GetValue();
1998 GetClientSize(w
, h
);
2001 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
2003 wxLayoutConstraints
*constr
= GetConstraints();
2006 *x
= constr
->left
.GetValue();
2007 *y
= constr
->top
.GetValue();
2013 #endif // wxUSE_CONSTRAINTS
2015 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
2017 // don't do it for the dialogs/frames - they float independently of their
2019 if ( !IsTopLevel() )
2021 wxWindow
*parent
= GetParent();
2022 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
2024 wxPoint
pt(parent
->GetClientAreaOrigin());
2031 // ----------------------------------------------------------------------------
2032 // do Update UI processing for child controls
2033 // ----------------------------------------------------------------------------
2035 void wxWindowBase::UpdateWindowUI(long flags
)
2037 wxUpdateUIEvent
event(GetId());
2038 event
.SetEventObject(this);
2040 if ( GetEventHandler()->ProcessEvent(event
) )
2042 DoUpdateWindowUI(event
);
2045 if (flags
& wxUPDATE_UI_RECURSE
)
2047 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2050 wxWindow
* child
= (wxWindow
*) node
->GetData();
2051 child
->UpdateWindowUI(flags
);
2052 node
= node
->GetNext();
2057 // do the window-specific processing after processing the update event
2058 // TODO: take specific knowledge out of this function and
2059 // put in each control's base class. Unfortunately we don't
2060 // yet have base implementation files for wxCheckBox and wxRadioButton.
2061 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
2063 if ( event
.GetSetEnabled() )
2064 Enable(event
.GetEnabled());
2067 if ( event
.GetSetText() )
2069 wxControl
*control
= wxDynamicCastThis(wxControl
);
2072 if ( event
.GetText() != control
->GetLabel() )
2073 control
->SetLabel(event
.GetText());
2076 #endif // wxUSE_CONTROLS
2078 if ( event
.GetSetChecked() )
2081 wxCheckBox
*checkbox
= wxDynamicCastThis(wxCheckBox
);
2084 checkbox
->SetValue(event
.GetChecked());
2086 #endif // wxUSE_CHECKBOX
2089 wxRadioButton
*radiobtn
= wxDynamicCastThis(wxRadioButton
);
2092 radiobtn
->SetValue(event
.GetChecked());
2094 #endif // wxUSE_RADIOBTN
2099 // call internal idle recursively
2100 // may be obsolete (wait until OnIdle scheme stabilises)
2101 void wxWindowBase::ProcessInternalIdle()
2105 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2108 wxWindow
*child
= node
->GetData();
2109 child
->ProcessInternalIdle();
2110 node
= node
->GetNext();
2115 // ----------------------------------------------------------------------------
2116 // dialog units translations
2117 // ----------------------------------------------------------------------------
2119 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
2121 int charWidth
= GetCharWidth();
2122 int charHeight
= GetCharHeight();
2123 wxPoint pt2
= wxDefaultPosition
;
2124 if (pt
.x
!= wxDefaultCoord
)
2125 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
);
2126 if (pt
.y
!= wxDefaultCoord
)
2127 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2132 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2134 int charWidth
= GetCharWidth();
2135 int charHeight
= GetCharHeight();
2136 wxPoint pt2
= wxDefaultPosition
;
2137 if (pt
.x
!= wxDefaultCoord
)
2138 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2139 if (pt
.y
!= wxDefaultCoord
)
2140 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2145 // ----------------------------------------------------------------------------
2147 // ----------------------------------------------------------------------------
2149 // propagate the colour change event to the subwindows
2150 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2152 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2155 // Only propagate to non-top-level windows
2156 wxWindow
*win
= node
->GetData();
2157 if ( !win
->IsTopLevel() )
2159 wxSysColourChangedEvent event2
;
2160 event
.SetEventObject(win
);
2161 win
->GetEventHandler()->ProcessEvent(event2
);
2164 node
= node
->GetNext();
2170 // the default action is to populate dialog with data when it's created,
2171 // and nudge the UI into displaying itself correctly in case
2172 // we've turned the wxUpdateUIEvents frequency down low.
2173 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2175 TransferDataToWindow();
2177 // Update the UI at this point
2178 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2181 // process Ctrl-Alt-mclick
2182 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2185 if ( event
.ControlDown() && event
.AltDown() )
2187 // don't translate these strings
2190 #ifdef __WXUNIVERSAL__
2192 #endif // __WXUNIVERSAL__
2194 switch ( wxGetOsVersion() )
2196 case wxMOTIF_X
: port
+= _T("Motif"); break;
2198 case wxMAC_DARWIN
: port
+= _T("Mac"); break;
2199 case wxBEOS
: port
+= _T("BeOS"); break;
2203 case wxGTK_BEOS
: port
+= _T("GTK"); break;
2209 case wxWIN386
: port
+= _T("MS Windows"); break;
2213 case wxMGL_OS2
: port
+= _T("MGL"); break;
2215 case wxOS2_PM
: port
+= _T("OS/2"); break;
2216 default: port
+= _T("unknown"); break;
2219 wxMessageBox(wxString::Format(
2221 " wxWidgets Library (%s port)\nVersion %u.%u.%u%s%s, compiled at %s %s\n Copyright (c) 1995-2004 wxWidgets team"
2240 _T("wxWidgets information"),
2241 wxICON_INFORMATION
| wxOK
,
2245 #endif // wxUSE_MSGDLG
2251 // ----------------------------------------------------------------------------
2253 // ----------------------------------------------------------------------------
2255 #if wxUSE_ACCESSIBILITY
2256 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2258 if (m_accessible
&& (accessible
!= m_accessible
))
2259 delete m_accessible
;
2260 m_accessible
= accessible
;
2262 m_accessible
->SetWindow((wxWindow
*) this);
2265 // Returns the accessible object, creating if necessary.
2266 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2269 m_accessible
= CreateAccessible();
2270 return m_accessible
;
2273 // Override to create a specific accessible object.
2274 wxAccessible
* wxWindowBase::CreateAccessible()
2276 return new wxWindowAccessible((wxWindow
*) this);
2282 // ----------------------------------------------------------------------------
2283 // list classes implementation
2284 // ----------------------------------------------------------------------------
2286 void wxWindowListNode::DeleteData()
2288 delete (wxWindow
*)GetData();
2292 // ----------------------------------------------------------------------------
2294 // ----------------------------------------------------------------------------
2296 wxBorder
wxWindowBase::GetBorder(long flags
) const
2298 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2299 if ( border
== wxBORDER_DEFAULT
)
2301 border
= GetDefaultBorder();
2307 wxBorder
wxWindowBase::GetDefaultBorder() const
2309 return wxBORDER_NONE
;
2312 // ----------------------------------------------------------------------------
2314 // ----------------------------------------------------------------------------
2316 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2318 // here we just check if the point is inside the window or not
2320 // check the top and left border first
2321 bool outside
= x
< 0 || y
< 0;
2324 // check the right and bottom borders too
2325 wxSize size
= GetSize();
2326 outside
= x
>= size
.x
|| y
>= size
.y
;
2329 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2332 // ----------------------------------------------------------------------------
2334 // ----------------------------------------------------------------------------
2336 struct WXDLLEXPORT wxWindowNext
2340 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2342 void wxWindowBase::CaptureMouse()
2344 wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), this);
2346 wxWindow
*winOld
= GetCapture();
2349 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2352 wxWindowNext
*item
= new wxWindowNext
;
2354 item
->next
= ms_winCaptureNext
;
2355 ms_winCaptureNext
= item
;
2357 //else: no mouse capture to save
2362 void wxWindowBase::ReleaseMouse()
2364 wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), this);
2366 wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") );
2370 if ( ms_winCaptureNext
)
2372 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2374 wxWindowNext
*item
= ms_winCaptureNext
;
2375 ms_winCaptureNext
= item
->next
;
2378 //else: stack is empty, no previous capture
2380 wxLogTrace(_T("mousecapture"),
2381 (const wxChar
*) _T("After ReleaseMouse() mouse is captured by %p"),
2388 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2389 int WXUNUSED(modifiers
),
2390 int WXUNUSED(keycode
))
2396 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2402 #endif // wxUSE_HOTKEY
2404 void wxWindowBase::SendDestroyEvent()
2406 wxWindowDestroyEvent event
;
2407 event
.SetEventObject(this);
2408 event
.SetId(GetId());
2409 GetEventHandler()->ProcessEvent(event
);
2412 // ----------------------------------------------------------------------------
2414 // ----------------------------------------------------------------------------
2416 bool wxWindowBase::TryValidator(wxEvent
& wxVALIDATOR_PARAM(event
))
2418 #if wxUSE_VALIDATORS
2419 // Can only use the validator of the window which
2420 // is receiving the event
2421 if ( event
.GetEventObject() == this )
2423 wxValidator
*validator
= GetValidator();
2424 if ( validator
&& validator
->ProcessEvent(event
) )
2429 #endif // wxUSE_VALIDATORS
2434 bool wxWindowBase::TryParent(wxEvent
& event
)
2436 // carry on up the parent-child hierarchy if the propgation count hasn't
2438 if ( event
.ShouldPropagate() )
2440 // honour the requests to stop propagation at this window: this is
2441 // used by the dialogs, for example, to prevent processing the events
2442 // from the dialog controls in the parent frame which rarely, if ever,
2444 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2446 wxWindow
*parent
= GetParent();
2447 if ( parent
&& !parent
->IsBeingDeleted() )
2449 wxPropagateOnce
propagateOnce(event
);
2451 return parent
->GetEventHandler()->ProcessEvent(event
);
2456 return wxEvtHandler::TryParent(event
);
2459 // ----------------------------------------------------------------------------
2460 // keyboard navigation
2461 // ----------------------------------------------------------------------------
2463 // Navigates in the specified direction.
2464 bool wxWindowBase::Navigate(int flags
)
2466 wxNavigationKeyEvent eventNav
;
2467 eventNav
.SetFlags(flags
);
2468 eventNav
.SetEventObject(this);
2469 if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav
) )
2476 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, MoveKind move
)
2478 // check that we're not a top level window
2479 wxCHECK_RET( GetParent(),
2480 _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
2482 // detect the special case when we have nothing to do anyhow and when the
2483 // code below wouldn't work
2487 // find the target window in the siblings list
2488 wxWindowList
& siblings
= GetParent()->GetChildren();
2489 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
2490 wxCHECK_RET( i
, _T("MoveBefore/AfterInTabOrder(): win is not a sibling") );
2492 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
2493 // can't just move the node around
2494 wxWindow
*self
= (wxWindow
*)this;
2495 siblings
.DeleteObject(self
);
2496 if ( move
== MoveAfter
)
2503 siblings
.Insert(i
, self
);
2505 else // MoveAfter and win was the last sibling
2507 siblings
.Append(self
);
2511 // ----------------------------------------------------------------------------
2513 // ----------------------------------------------------------------------------
2515 /*static*/ wxWindow
* wxWindowBase::FindFocus()
2517 wxWindowBase
*win
= DoFindFocus();
2518 return win
? win
->GetMainWindowOfCompositeControl() : NULL
;
2521 // ----------------------------------------------------------------------------
2523 // ----------------------------------------------------------------------------
2525 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
2527 while ( win
&& !win
->IsTopLevel() )
2528 win
= win
->GetParent();
2533 #if wxUSE_ACCESSIBILITY
2534 // ----------------------------------------------------------------------------
2535 // accessible object for windows
2536 // ----------------------------------------------------------------------------
2538 // Can return either a child object, or an integer
2539 // representing the child element, starting from 1.
2540 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
2542 wxASSERT( GetWindow() != NULL
);
2546 return wxACC_NOT_IMPLEMENTED
;
2549 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
2550 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
2552 wxASSERT( GetWindow() != NULL
);
2556 wxWindow
* win
= NULL
;
2563 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
2565 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
2572 rect
= win
->GetRect();
2573 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
2574 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
2578 return wxACC_NOT_IMPLEMENTED
;
2581 // Navigates from fromId to toId/toObject.
2582 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
2583 int* WXUNUSED(toId
), wxAccessible
** toObject
)
2585 wxASSERT( GetWindow() != NULL
);
2591 case wxNAVDIR_FIRSTCHILD
:
2593 if (GetWindow()->GetChildren().GetCount() == 0)
2595 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
2596 *toObject
= childWindow
->GetOrCreateAccessible();
2600 case wxNAVDIR_LASTCHILD
:
2602 if (GetWindow()->GetChildren().GetCount() == 0)
2604 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
2605 *toObject
= childWindow
->GetOrCreateAccessible();
2609 case wxNAVDIR_RIGHT
:
2613 wxWindowList::compatibility_iterator node
=
2614 wxWindowList::compatibility_iterator();
2617 // Can't navigate to sibling of this window
2618 // if we're a top-level window.
2619 if (!GetWindow()->GetParent())
2620 return wxACC_NOT_IMPLEMENTED
;
2622 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2626 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2627 node
= GetWindow()->GetChildren().Item(fromId
-1);
2630 if (node
&& node
->GetNext())
2632 wxWindow
* nextWindow
= node
->GetNext()->GetData();
2633 *toObject
= nextWindow
->GetOrCreateAccessible();
2641 case wxNAVDIR_PREVIOUS
:
2643 wxWindowList::compatibility_iterator node
=
2644 wxWindowList::compatibility_iterator();
2647 // Can't navigate to sibling of this window
2648 // if we're a top-level window.
2649 if (!GetWindow()->GetParent())
2650 return wxACC_NOT_IMPLEMENTED
;
2652 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2656 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2657 node
= GetWindow()->GetChildren().Item(fromId
-1);
2660 if (node
&& node
->GetPrevious())
2662 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
2663 *toObject
= previousWindow
->GetOrCreateAccessible();
2671 return wxACC_NOT_IMPLEMENTED
;
2674 // Gets the name of the specified object.
2675 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
2677 wxASSERT( GetWindow() != NULL
);
2683 // If a child, leave wxWidgets to call the function on the actual
2686 return wxACC_NOT_IMPLEMENTED
;
2688 // This will eventually be replaced by specialised
2689 // accessible classes, one for each kind of wxWidgets
2690 // control or window.
2692 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
2693 title
= ((wxButton
*) GetWindow())->GetLabel();
2696 title
= GetWindow()->GetName();
2704 return wxACC_NOT_IMPLEMENTED
;
2707 // Gets the number of children.
2708 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
2710 wxASSERT( GetWindow() != NULL
);
2714 *childId
= (int) GetWindow()->GetChildren().GetCount();
2718 // Gets the specified child (starting from 1).
2719 // If *child is NULL and return value is wxACC_OK,
2720 // this means that the child is a simple element and
2721 // not an accessible object.
2722 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
2724 wxASSERT( GetWindow() != NULL
);
2734 if (childId
> (int) GetWindow()->GetChildren().GetCount())
2737 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
2738 *child
= childWindow
->GetOrCreateAccessible();
2745 // Gets the parent, or NULL.
2746 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
2748 wxASSERT( GetWindow() != NULL
);
2752 wxWindow
* parentWindow
= GetWindow()->GetParent();
2760 *parent
= parentWindow
->GetOrCreateAccessible();
2768 // Performs the default action. childId is 0 (the action for this object)
2769 // or > 0 (the action for a child).
2770 // Return wxACC_NOT_SUPPORTED if there is no default action for this
2771 // window (e.g. an edit control).
2772 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
2774 wxASSERT( GetWindow() != NULL
);
2778 return wxACC_NOT_IMPLEMENTED
;
2781 // Gets the default action for this object (0) or > 0 (the action for a child).
2782 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
2783 // string if there is no action.
2784 // The retrieved string describes the action that is performed on an object,
2785 // not what the object does as a result. For example, a toolbar button that prints
2786 // a document has a default action of "Press" rather than "Prints the current document."
2787 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
2789 wxASSERT( GetWindow() != NULL
);
2793 return wxACC_NOT_IMPLEMENTED
;
2796 // Returns the description for this object or a child.
2797 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
2799 wxASSERT( GetWindow() != NULL
);
2803 wxString
ht(GetWindow()->GetHelpText());
2809 return wxACC_NOT_IMPLEMENTED
;
2812 // Returns help text for this object or a child, similar to tooltip text.
2813 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
2815 wxASSERT( GetWindow() != NULL
);
2819 wxString
ht(GetWindow()->GetHelpText());
2825 return wxACC_NOT_IMPLEMENTED
;
2828 // Returns the keyboard shortcut for this object or child.
2829 // Return e.g. ALT+K
2830 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
2832 wxASSERT( GetWindow() != NULL
);
2836 return wxACC_NOT_IMPLEMENTED
;
2839 // Returns a role constant.
2840 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
2842 wxASSERT( GetWindow() != NULL
);
2846 // If a child, leave wxWidgets to call the function on the actual
2849 return wxACC_NOT_IMPLEMENTED
;
2851 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2852 return wxACC_NOT_IMPLEMENTED
;
2854 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2855 return wxACC_NOT_IMPLEMENTED
;
2858 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2859 return wxACC_NOT_IMPLEMENTED
;
2862 //*role = wxROLE_SYSTEM_CLIENT;
2863 *role
= wxROLE_SYSTEM_CLIENT
;
2867 return wxACC_NOT_IMPLEMENTED
;
2871 // Returns a state constant.
2872 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
2874 wxASSERT( GetWindow() != NULL
);
2878 // If a child, leave wxWidgets to call the function on the actual
2881 return wxACC_NOT_IMPLEMENTED
;
2883 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2884 return wxACC_NOT_IMPLEMENTED
;
2887 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2888 return wxACC_NOT_IMPLEMENTED
;
2891 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2892 return wxACC_NOT_IMPLEMENTED
;
2899 return wxACC_NOT_IMPLEMENTED
;
2903 // Returns a localized string representing the value for the object
2905 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
2907 wxASSERT( GetWindow() != NULL
);
2911 return wxACC_NOT_IMPLEMENTED
;
2914 // Selects the object or child.
2915 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
2917 wxASSERT( GetWindow() != NULL
);
2921 return wxACC_NOT_IMPLEMENTED
;
2924 // Gets the window with the keyboard focus.
2925 // If childId is 0 and child is NULL, no object in
2926 // this subhierarchy has the focus.
2927 // If this object has the focus, child should be 'this'.
2928 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
2930 wxASSERT( GetWindow() != NULL
);
2934 return wxACC_NOT_IMPLEMENTED
;
2937 // Gets a variant representing the selected children
2939 // Acceptable values:
2940 // - a null variant (IsNull() returns true)
2941 // - a list variant (GetType() == wxT("list")
2942 // - an integer representing the selected child element,
2943 // or 0 if this object is selected (GetType() == wxT("long")
2944 // - a "void*" pointer to a wxAccessible child object
2945 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
2947 wxASSERT( GetWindow() != NULL
);
2951 return wxACC_NOT_IMPLEMENTED
;
2954 #endif // wxUSE_ACCESSIBILITY