1 /////////////////////////////////////////////////////////////////////////////
2 // Name: common/window.cpp
3 // Purpose: common (to all ports) wxWindow functions
4 // Author: Julian Smart, Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "windowbase.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
32 #include "wx/string.h"
37 #include "wx/window.h"
38 #include "wx/control.h"
39 #include "wx/checkbox.h"
40 #include "wx/radiobut.h"
41 #include "wx/statbox.h"
42 #include "wx/textctrl.h"
43 #include "wx/settings.h"
44 #include "wx/dialog.h"
45 #include "wx/msgdlg.h"
46 #include "wx/statusbr.h"
47 #include "wx/dcclient.h"
50 #if defined(__WXMAC__) && wxUSE_SCROLLBAR
51 #include "wx/scrolbar.h"
55 #include "wx/layout.h"
56 #endif // wxUSE_CONSTRAINTS
60 #if wxUSE_DRAG_AND_DROP
62 #endif // wxUSE_DRAG_AND_DROP
64 #if wxUSE_ACCESSIBILITY
65 #include "wx/access.h"
69 #include "wx/cshelp.h"
73 #include "wx/tooltip.h"
74 #endif // wxUSE_TOOLTIPS
80 // ----------------------------------------------------------------------------
82 // ----------------------------------------------------------------------------
85 int wxWindowBase::ms_lastControlId
= 2000;
87 int wxWindowBase::ms_lastControlId
= -200;
90 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase
, wxEvtHandler
)
92 // ----------------------------------------------------------------------------
94 // ----------------------------------------------------------------------------
96 BEGIN_EVENT_TABLE(wxWindowBase
, wxEvtHandler
)
97 EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged
)
98 EVT_INIT_DIALOG(wxWindowBase::OnInitDialog
)
99 EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick
)
102 EVT_HELP(wxID_ANY
, wxWindowBase::OnHelp
)
107 // ============================================================================
108 // implementation of the common functionality of the wxWindow class
109 // ============================================================================
111 // ----------------------------------------------------------------------------
113 // ----------------------------------------------------------------------------
115 // the default initialization
116 wxWindowBase::wxWindowBase()
118 // no window yet, no parent nor children
119 m_parent
= (wxWindow
*)NULL
;
120 m_windowId
= wxID_ANY
;
122 // no constraints on the minimal window size
124 m_maxWidth
= wxDefaultCoord
;
126 m_maxHeight
= wxDefaultCoord
;
128 // invalidiated cache value
129 m_bestSizeCache
= wxDefaultSize
;
131 // window are created enabled and visible by default
135 // the default event handler is just this window
136 m_eventHandler
= this;
140 m_windowValidator
= (wxValidator
*) NULL
;
141 #endif // wxUSE_VALIDATORS
143 // the colours/fonts are default for now, so leave m_font,
144 // m_backgroundColour and m_foregroundColour uninitialized and set those
150 m_inheritFont
= false;
156 #if wxUSE_CONSTRAINTS
157 // no constraints whatsoever
158 m_constraints
= (wxLayoutConstraints
*) NULL
;
159 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
160 #endif // wxUSE_CONSTRAINTS
162 m_windowSizer
= (wxSizer
*) NULL
;
163 m_containingSizer
= (wxSizer
*) NULL
;
164 m_autoLayout
= false;
166 #if wxUSE_DRAG_AND_DROP
167 m_dropTarget
= (wxDropTarget
*)NULL
;
168 #endif // wxUSE_DRAG_AND_DROP
171 m_tooltip
= (wxToolTip
*)NULL
;
172 #endif // wxUSE_TOOLTIPS
175 m_caret
= (wxCaret
*)NULL
;
176 #endif // wxUSE_CARET
179 m_hasCustomPalette
= false;
180 #endif // wxUSE_PALETTE
182 #if wxUSE_ACCESSIBILITY
186 m_virtualSize
= wxDefaultSize
;
189 m_maxVirtualWidth
= wxDefaultCoord
;
191 m_maxVirtualHeight
= wxDefaultCoord
;
193 m_windowVariant
= wxWINDOW_VARIANT_NORMAL
;
195 // Whether we're using the current theme for this window (wxGTK only for now)
196 m_themeEnabled
= false;
198 // VZ: this one shouldn't exist...
199 m_isBeingDeleted
= false;
202 // common part of window creation process
203 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
205 const wxPoint
& WXUNUSED(pos
),
206 const wxSize
& WXUNUSED(size
),
208 const wxValidator
& wxVALIDATOR_PARAM(validator
),
209 const wxString
& name
)
212 // wxGTK doesn't allow to create controls with static box as the parent so
213 // this will result in a crash when the program is ported to wxGTK so warn
216 // if you get this assert, the correct solution is to create the controls
217 // as siblings of the static box
218 wxASSERT_MSG( !parent
|| !wxDynamicCast(parent
, wxStaticBox
),
219 _T("wxStaticBox can't be used as a window parent!") );
220 #endif // wxUSE_STATBOX
222 // ids are limited to 16 bits under MSW so if you care about portability,
223 // it's not a good idea to use ids out of this range (and negative ids are
224 // reserved for wxWidgets own usage)
225 wxASSERT_MSG( id
== wxID_ANY
|| (id
>= 0 && id
< 32767),
226 _T("invalid id value") );
228 // generate a new id if the user doesn't care about it
229 m_windowId
= id
== wxID_ANY
? NewControlId() : id
;
232 SetWindowStyleFlag(style
);
236 SetValidator(validator
);
237 #endif // wxUSE_VALIDATORS
239 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
240 // have it too - like this it's possible to set it only in the top level
241 // dialog/frame and all children will inherit it by defult
242 if ( parent
&& (parent
->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) )
244 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY
);
250 // ----------------------------------------------------------------------------
252 // ----------------------------------------------------------------------------
255 wxWindowBase::~wxWindowBase()
257 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
259 // FIXME if these 2 cases result from programming errors in the user code
260 // we should probably assert here instead of silently fixing them
262 // Just in case the window has been Closed, but we're then deleting
263 // immediately: don't leave dangling pointers.
264 wxPendingDelete
.DeleteObject(this);
266 // Just in case we've loaded a top-level window via LoadNativeDialog but
267 // we weren't a dialog class
268 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
270 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
272 // reset the dangling pointer our parent window may keep to us
275 if ( m_parent
->GetDefaultItem() == this )
277 m_parent
->SetDefaultItem(NULL
);
280 m_parent
->RemoveChild(this);
285 #endif // wxUSE_CARET
288 delete m_windowValidator
;
289 #endif // wxUSE_VALIDATORS
291 #if wxUSE_CONSTRAINTS
292 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
293 // at deleted windows as they delete themselves.
294 DeleteRelatedConstraints();
298 // This removes any dangling pointers to this window in other windows'
299 // constraintsInvolvedIn lists.
300 UnsetConstraints(m_constraints
);
301 delete m_constraints
;
302 m_constraints
= NULL
;
304 #endif // wxUSE_CONSTRAINTS
306 if ( m_containingSizer
)
307 m_containingSizer
->Detach( (wxWindow
*)this );
309 delete m_windowSizer
;
311 #if wxUSE_DRAG_AND_DROP
313 #endif // wxUSE_DRAG_AND_DROP
317 #endif // wxUSE_TOOLTIPS
319 #if wxUSE_ACCESSIBILITY
324 bool wxWindowBase::Destroy()
331 bool wxWindowBase::Close(bool force
)
333 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
334 event
.SetEventObject(this);
335 event
.SetCanVeto(!force
);
337 // return false if window wasn't closed because the application vetoed the
339 return GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto();
342 bool wxWindowBase::DestroyChildren()
344 wxWindowList::compatibility_iterator node
;
347 // we iterate until the list becomes empty
348 node
= GetChildren().GetFirst();
352 wxWindow
*child
= node
->GetData();
354 // note that we really want to call delete and not ->Destroy() here
355 // because we want to delete the child immediately, before we are
356 // deleted, and delayed deletion would result in problems as our (top
357 // level) child could outlive its parent
360 wxASSERT_MSG( !GetChildren().Find(child
),
361 wxT("child didn't remove itself using RemoveChild()") );
367 // ----------------------------------------------------------------------------
368 // size/position related methods
369 // ----------------------------------------------------------------------------
371 // centre the window with respect to its parent in either (or both) directions
372 void wxWindowBase::Centre(int direction
)
374 // the position/size of the parent window or of the entire screen
376 int widthParent
, heightParent
;
378 wxWindow
*parent
= NULL
;
380 if ( !(direction
& wxCENTRE_ON_SCREEN
) )
382 // find the parent to centre this window on: it should be the
383 // immediate parent for the controls but the top level parent for the
384 // top level windows (like dialogs)
385 parent
= GetParent();
388 while ( parent
&& !parent
->IsTopLevel() )
390 parent
= parent
->GetParent();
394 // there is no wxTopLevelWindow under wxMotif yet
396 // we shouldn't center the dialog on the iconized window: under
397 // Windows, for example, this places it completely off the screen
400 wxTopLevelWindow
*winTop
= wxDynamicCast(parent
, wxTopLevelWindow
);
401 if ( winTop
&& winTop
->IsIconized() )
406 #endif // __WXMOTIF__
408 // did we find the parent?
412 direction
|= wxCENTRE_ON_SCREEN
;
416 if ( direction
& wxCENTRE_ON_SCREEN
)
418 // centre with respect to the whole screen
419 wxDisplaySize(&widthParent
, &heightParent
);
425 // centre on the parent
426 parent
->GetSize(&widthParent
, &heightParent
);
428 // adjust to the parents position
429 posParent
= parent
->GetPosition();
433 // centre inside the parents client rectangle
434 parent
->GetClientSize(&widthParent
, &heightParent
);
439 GetSize(&width
, &height
);
441 int xNew
= wxDefaultCoord
,
442 yNew
= wxDefaultCoord
;
444 if ( direction
& wxHORIZONTAL
)
445 xNew
= (widthParent
- width
)/2;
447 if ( direction
& wxVERTICAL
)
448 yNew
= (heightParent
- height
)/2;
453 // Base size of the visible dimensions of the display
454 // to take into account the taskbar
455 wxRect rect
= wxGetClientDisplayRect();
456 wxSize
size (rect
.width
,rect
.height
);
458 // NB: in wxMSW, negative position may not neccessary mean "out of screen",
459 // but it may mean that the window is placed on other than the main
460 // display. Therefore we only make sure centered window is on the main display
461 // if the parent is at least partially present here.
462 if (posParent
.x
+ widthParent
>= 0) // if parent is (partially) on the main display
466 else if (xNew
+width
> size
.x
)
467 xNew
= size
.x
-width
-1;
469 if (posParent
.y
+ heightParent
>= 0) // if parent is (partially) on the main display
471 if (yNew
+height
> size
.y
)
472 yNew
= size
.y
-height
-1;
474 // Make certain that the title bar is initially visible
475 // always, even if this would push the bottom of the
476 // dialog of the visible area of the display
481 // move the window to this position (keeping the old size but using
482 // SetSize() and not Move() to allow xNew and/or yNew to be -1)
483 SetSize(xNew
, yNew
, width
, height
, wxSIZE_ALLOW_MINUS_ONE
);
486 // fits the window around the children
487 void wxWindowBase::Fit()
489 if ( GetChildren().GetCount() > 0 )
491 SetClientSize(GetBestSize());
493 //else: do nothing if we have no children
496 // fits virtual size (ie. scrolled area etc.) around children
497 void wxWindowBase::FitInside()
499 if ( GetChildren().GetCount() > 0 )
501 SetVirtualSize( GetBestVirtualSize() );
505 // On Mac, scrollbars are explicitly children.
507 static bool wxHasRealChildren(const wxWindowBase
* win
)
509 int realChildCount
= 0;
511 for ( wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
513 node
= node
->GetNext() )
515 wxWindow
*win
= node
->GetData();
516 if ( !win
->IsTopLevel() && win
->IsShown() && !win
->IsKindOf(CLASSINFO(wxScrollBar
)))
519 return (realChildCount
> 0);
523 // return the size best suited for the current window
524 wxSize
wxWindowBase::DoGetBestSize() const
528 return m_windowSizer
->GetMinSize();
530 #if wxUSE_CONSTRAINTS
531 else if ( m_constraints
)
533 wxConstCast(this, wxWindowBase
)->SatisfyConstraints();
535 // our minimal acceptable size is such that all our windows fit inside
539 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
541 node
= node
->GetNext() )
543 wxLayoutConstraints
*c
= node
->GetData()->GetConstraints();
546 // it's not normal that we have an unconstrained child, but
547 // what can we do about it?
551 int x
= c
->right
.GetValue(),
552 y
= c
->bottom
.GetValue();
560 // TODO: we must calculate the overlaps somehow, otherwise we
561 // will never return a size bigger than the current one :-(
564 return wxSize(maxX
, maxY
);
566 #endif // wxUSE_CONSTRAINTS
567 else if ( !GetChildren().empty()
569 && wxHasRealChildren(this)
573 // our minimal acceptable size is such that all our visible child windows fit inside
577 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
579 node
= node
->GetNext() )
581 wxWindow
*win
= node
->GetData();
582 if ( win
->IsTopLevel() || ( ! win
->IsShown() )
584 || wxDynamicCast(win
, wxStatusBar
)
585 #endif // wxUSE_STATUSBAR
588 // dialogs and frames lie in different top level windows -
589 // don't deal with them here; as for the status bars, they
590 // don't lie in the client area at all
595 win
->GetPosition(&wx
, &wy
);
597 // if the window hadn't been positioned yet, assume that it is in
599 if ( wx
== wxDefaultCoord
)
601 if ( wy
== wxDefaultCoord
)
604 win
->GetSize(&ww
, &wh
);
605 if ( wx
+ ww
> maxX
)
607 if ( wy
+ wh
> maxY
)
611 // for compatibility with the old versions and because it really looks
612 // slightly more pretty like this, add a pad
616 return wxSize(maxX
, maxY
);
618 else // ! has children
620 // for a generic window there is no natural best size - just use either the
621 // minimum size if there is one, or the current size
622 if ( GetMinSize().IsFullySpecified() )
630 wxSize
wxWindowBase::GetBestFittingSize() const
632 // merge the best size with the min size, giving priority to the min size
633 wxSize min
= GetMinSize();
634 if (min
.x
== wxDefaultCoord
|| min
.y
== wxDefaultCoord
)
636 wxSize best
= GetBestSize();
637 if (min
.x
== wxDefaultCoord
) min
.x
= best
.x
;
638 if (min
.y
== wxDefaultCoord
) min
.y
= best
.y
;
644 void wxWindowBase::SetBestFittingSize(const wxSize
& size
)
646 // Set the min size to the size passed in. This will usually either be
647 // wxDefaultSize or the size passed to this window's ctor/Create function.
650 // Merge the size with the best size if needed
651 wxSize best
= GetBestFittingSize();
653 // If the current size doesn't match then change it
654 if (GetSize() != best
)
659 // by default the origin is not shifted
660 wxPoint
wxWindowBase::GetClientAreaOrigin() const
662 return wxPoint(0, 0);
665 // set the min/max size of the window
666 void wxWindowBase::SetSizeHints(int minW
, int minH
,
668 int WXUNUSED(incW
), int WXUNUSED(incH
))
670 // setting min width greater than max width leads to infinite loops under
671 // X11 and generally doesn't make any sense, so don't allow it
672 wxCHECK_RET( (minW
== wxDefaultCoord
|| maxW
== wxDefaultCoord
|| minW
<= maxW
) &&
673 (minH
== wxDefaultCoord
|| maxH
== wxDefaultCoord
|| minH
<= maxH
),
674 _T("min width/height must be less than max width/height!") );
682 void wxWindowBase::SetWindowVariant( wxWindowVariant variant
)
684 if ( m_windowVariant
!= variant
)
686 m_windowVariant
= variant
;
688 DoSetWindowVariant(variant
);
692 void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant
)
694 // adjust the font height to correspond to our new variant (notice that
695 // we're only called if something really changed)
696 wxFont font
= GetFont();
697 int size
= font
.GetPointSize();
700 case wxWINDOW_VARIANT_NORMAL
:
703 case wxWINDOW_VARIANT_SMALL
:
708 case wxWINDOW_VARIANT_MINI
:
713 case wxWINDOW_VARIANT_LARGE
:
719 wxFAIL_MSG(_T("unexpected window variant"));
723 font
.SetPointSize(size
);
727 void wxWindowBase::SetVirtualSizeHints( int minW
, int minH
,
730 m_minVirtualWidth
= minW
;
731 m_maxVirtualWidth
= maxW
;
732 m_minVirtualHeight
= minH
;
733 m_maxVirtualHeight
= maxH
;
736 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
738 if ( m_minVirtualWidth
!= wxDefaultCoord
&& m_minVirtualWidth
> x
)
739 x
= m_minVirtualWidth
;
740 if ( m_maxVirtualWidth
!= wxDefaultCoord
&& m_maxVirtualWidth
< x
)
741 x
= m_maxVirtualWidth
;
742 if ( m_minVirtualHeight
!= wxDefaultCoord
&& m_minVirtualHeight
> y
)
743 y
= m_minVirtualHeight
;
744 if ( m_maxVirtualHeight
!= wxDefaultCoord
&& m_maxVirtualHeight
< y
)
745 y
= m_maxVirtualHeight
;
747 m_virtualSize
= wxSize(x
, y
);
750 wxSize
wxWindowBase::DoGetVirtualSize() const
752 wxSize
s( GetClientSize() );
754 return wxSize( wxMax( m_virtualSize
.GetWidth(), s
.GetWidth() ),
755 wxMax( m_virtualSize
.GetHeight(), s
.GetHeight() ) );
758 // ----------------------------------------------------------------------------
759 // show/hide/enable/disable the window
760 // ----------------------------------------------------------------------------
762 bool wxWindowBase::Show(bool show
)
764 if ( show
!= m_isShown
)
776 bool wxWindowBase::Enable(bool enable
)
778 if ( enable
!= m_isEnabled
)
780 m_isEnabled
= enable
;
789 // ----------------------------------------------------------------------------
791 // ----------------------------------------------------------------------------
793 bool wxWindowBase::IsTopLevel() const
798 // ----------------------------------------------------------------------------
799 // reparenting the window
800 // ----------------------------------------------------------------------------
802 void wxWindowBase::AddChild(wxWindowBase
*child
)
804 wxCHECK_RET( child
, wxT("can't add a NULL child") );
806 // this should never happen and it will lead to a crash later if it does
807 // because RemoveChild() will remove only one node from the children list
808 // and the other(s) one(s) will be left with dangling pointers in them
809 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), _T("AddChild() called twice") );
811 GetChildren().Append((wxWindow
*)child
);
812 child
->SetParent(this);
815 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
817 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
819 GetChildren().DeleteObject((wxWindow
*)child
);
820 child
->SetParent(NULL
);
823 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
825 wxWindow
*oldParent
= GetParent();
826 if ( newParent
== oldParent
)
832 // unlink this window from the existing parent.
835 oldParent
->RemoveChild(this);
839 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
842 // add it to the new one
845 newParent
->AddChild(this);
849 wxTopLevelWindows
.Append((wxWindow
*)this);
855 // ----------------------------------------------------------------------------
856 // event handler stuff
857 // ----------------------------------------------------------------------------
859 void wxWindowBase::PushEventHandler(wxEvtHandler
*handler
)
861 wxEvtHandler
*handlerOld
= GetEventHandler();
863 handler
->SetNextHandler(handlerOld
);
866 GetEventHandler()->SetPreviousHandler(handler
);
868 SetEventHandler(handler
);
871 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
873 wxEvtHandler
*handlerA
= GetEventHandler();
876 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
877 handlerA
->SetNextHandler((wxEvtHandler
*)NULL
);
880 handlerB
->SetPreviousHandler((wxEvtHandler
*)NULL
);
881 SetEventHandler(handlerB
);
886 handlerA
= (wxEvtHandler
*)NULL
;
893 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handler
)
895 wxCHECK_MSG( handler
, false, _T("RemoveEventHandler(NULL) called") );
897 wxEvtHandler
*handlerPrev
= NULL
,
898 *handlerCur
= GetEventHandler();
901 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
903 if ( handlerCur
== handler
)
907 handlerPrev
->SetNextHandler(handlerNext
);
911 SetEventHandler(handlerNext
);
916 handlerNext
->SetPreviousHandler ( handlerPrev
);
919 handler
->SetNextHandler(NULL
);
920 handler
->SetPreviousHandler(NULL
);
925 handlerPrev
= handlerCur
;
926 handlerCur
= handlerNext
;
929 wxFAIL_MSG( _T("where has the event handler gone?") );
934 // ----------------------------------------------------------------------------
936 // ----------------------------------------------------------------------------
938 void wxWindowBase::InheritAttributes()
940 const wxWindowBase
* const parent
= GetParent();
944 // we only inherit attributes which had been explicitly set for the parent
945 // which ensures that this only happens if the user really wants it and
946 // not by default which wouldn't make any sense in modern GUIs where the
947 // controls don't all use the same fonts (nor colours)
948 if ( parent
->m_inheritFont
&& !m_hasFont
)
949 SetFont(parent
->GetFont());
951 // in addition, there is a possibility to explicitly forbid inheriting
952 // colours at each class level by overriding ShouldInheritColours()
953 if ( ShouldInheritColours() )
955 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
956 SetForegroundColour(parent
->GetForegroundColour());
958 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
959 SetBackgroundColour(parent
->GetBackgroundColour());
963 /* static */ wxVisualAttributes
964 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
966 // it is important to return valid values for all attributes from here,
967 // GetXXX() below rely on this
968 wxVisualAttributes attrs
;
969 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
970 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
971 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
976 wxColour
wxWindowBase::GetBackgroundColour() const
978 if ( !m_backgroundColour
.Ok() )
980 wxASSERT_MSG( !m_hasBgCol
, _T("we have invalid explicit bg colour?") );
982 // get our default background colour
983 wxColour colBg
= GetDefaultAttributes().colBg
;
985 // we must return some valid colour to avoid redoing this every time
986 // and also to avoid surprizing the applications written for older
987 // wxWidgets versions where GetBackgroundColour() always returned
988 // something -- so give them something even if it doesn't make sense
989 // for this window (e.g. it has a themed background)
991 colBg
= GetClassDefaultAttributes().colBg
;
996 return m_backgroundColour
;
999 wxColour
wxWindowBase::GetForegroundColour() const
1001 // logic is the same as above
1002 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
1004 wxASSERT_MSG( !m_hasFgCol
, _T("we have invalid explicit fg colour?") );
1006 wxColour colFg
= GetDefaultAttributes().colFg
;
1009 colFg
= GetClassDefaultAttributes().colFg
;
1014 return m_foregroundColour
;
1017 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
1019 if ( colour
== m_backgroundColour
)
1022 m_hasBgCol
= colour
.Ok();
1023 m_inheritBgCol
= m_hasBgCol
;
1024 m_backgroundColour
= colour
;
1025 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1029 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1031 if (colour
== m_foregroundColour
)
1034 m_hasFgCol
= colour
.Ok();
1035 m_inheritFgCol
= m_hasFgCol
;
1036 m_foregroundColour
= colour
;
1037 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1041 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1043 // setting an invalid cursor is ok, it means that we don't have any special
1045 if ( m_cursor
== cursor
)
1056 wxFont
wxWindowBase::GetFont() const
1058 // logic is the same as in GetBackgroundColour()
1061 wxASSERT_MSG( !m_hasFont
, _T("we have invalid explicit font?") );
1063 wxFont font
= GetDefaultAttributes().font
;
1065 font
= GetClassDefaultAttributes().font
;
1073 bool wxWindowBase::SetFont(const wxFont
& font
)
1075 if ( font
== m_font
)
1082 m_hasFont
= font
.Ok();
1083 m_inheritFont
= m_hasFont
;
1090 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1092 m_hasCustomPalette
= true;
1095 // VZ: can anyone explain me what do we do here?
1096 wxWindowDC
d((wxWindow
*) this);
1100 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1102 wxWindow
*win
= (wxWindow
*)this;
1103 while ( win
&& !win
->HasCustomPalette() )
1105 win
= win
->GetParent();
1111 #endif // wxUSE_PALETTE
1114 void wxWindowBase::SetCaret(wxCaret
*caret
)
1125 wxASSERT_MSG( m_caret
->GetWindow() == this,
1126 wxT("caret should be created associated to this window") );
1129 #endif // wxUSE_CARET
1131 #if wxUSE_VALIDATORS
1132 // ----------------------------------------------------------------------------
1134 // ----------------------------------------------------------------------------
1136 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1138 if ( m_windowValidator
)
1139 delete m_windowValidator
;
1141 m_windowValidator
= (wxValidator
*)validator
.Clone();
1143 if ( m_windowValidator
)
1144 m_windowValidator
->SetWindow(this);
1146 #endif // wxUSE_VALIDATORS
1148 // ----------------------------------------------------------------------------
1149 // update region stuff
1150 // ----------------------------------------------------------------------------
1152 wxRect
wxWindowBase::GetUpdateClientRect() const
1154 wxRegion rgnUpdate
= GetUpdateRegion();
1155 rgnUpdate
.Intersect(GetClientRect());
1156 wxRect rectUpdate
= rgnUpdate
.GetBox();
1157 wxPoint ptOrigin
= GetClientAreaOrigin();
1158 rectUpdate
.x
-= ptOrigin
.x
;
1159 rectUpdate
.y
-= ptOrigin
.y
;
1164 bool wxWindowBase::IsExposed(int x
, int y
) const
1166 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1169 bool wxWindowBase::IsExposed(int x
, int y
, int w
, int h
) const
1171 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1174 void wxWindowBase::ClearBackground()
1176 // wxGTK uses its own version, no need to add never used code
1178 wxClientDC
dc((wxWindow
*)this);
1179 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1180 dc
.SetBackground(brush
);
1185 // ----------------------------------------------------------------------------
1186 // find child window by id or name
1187 // ----------------------------------------------------------------------------
1189 wxWindow
*wxWindowBase::FindWindow( long id
)
1191 if ( id
== m_windowId
)
1192 return (wxWindow
*)this;
1194 wxWindowBase
*res
= (wxWindow
*)NULL
;
1195 wxWindowList::compatibility_iterator node
;
1196 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1198 wxWindowBase
*child
= node
->GetData();
1199 res
= child
->FindWindow( id
);
1202 return (wxWindow
*)res
;
1205 wxWindow
*wxWindowBase::FindWindow( const wxString
& name
)
1207 if ( name
== m_windowName
)
1208 return (wxWindow
*)this;
1210 wxWindowBase
*res
= (wxWindow
*)NULL
;
1211 wxWindowList::compatibility_iterator node
;
1212 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1214 wxWindow
*child
= node
->GetData();
1215 res
= child
->FindWindow(name
);
1218 return (wxWindow
*)res
;
1222 // find any window by id or name or label: If parent is non-NULL, look through
1223 // children for a label or title matching the specified string. If NULL, look
1224 // through all top-level windows.
1226 // to avoid duplicating code we reuse the same helper function but with
1227 // different comparators
1229 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1230 const wxString
& label
, long id
);
1233 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1236 return win
->GetLabel() == label
;
1240 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1243 return win
->GetName() == label
;
1247 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1250 return win
->GetId() == id
;
1253 // recursive helper for the FindWindowByXXX() functions
1255 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1256 const wxString
& label
,
1258 wxFindWindowCmp cmp
)
1262 // see if this is the one we're looking for
1263 if ( (*cmp
)(parent
, label
, id
) )
1264 return (wxWindow
*)parent
;
1266 // It wasn't, so check all its children
1267 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1269 node
= node
->GetNext() )
1271 // recursively check each child
1272 wxWindow
*win
= (wxWindow
*)node
->GetData();
1273 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1283 // helper for FindWindowByXXX()
1285 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1286 const wxString
& label
,
1288 wxFindWindowCmp cmp
)
1292 // just check parent and all its children
1293 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1296 // start at very top of wx's windows
1297 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1299 node
= node
->GetNext() )
1301 // recursively check each window & its children
1302 wxWindow
*win
= node
->GetData();
1303 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1313 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1315 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1320 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1322 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1326 // fall back to the label
1327 win
= FindWindowByLabel(title
, parent
);
1335 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1337 return wxFindWindowHelper(parent
, _T(""), id
, wxFindWindowCmpIds
);
1340 // ----------------------------------------------------------------------------
1341 // dialog oriented functions
1342 // ----------------------------------------------------------------------------
1344 void wxWindowBase::MakeModal(bool modal
)
1346 // Disable all other windows
1349 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1352 wxWindow
*win
= node
->GetData();
1354 win
->Enable(!modal
);
1356 node
= node
->GetNext();
1361 bool wxWindowBase::Validate()
1363 #if wxUSE_VALIDATORS
1364 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1366 wxWindowList::compatibility_iterator node
;
1367 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1369 wxWindowBase
*child
= node
->GetData();
1370 wxValidator
*validator
= child
->GetValidator();
1371 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1376 if ( recurse
&& !child
->Validate() )
1381 #endif // wxUSE_VALIDATORS
1386 bool wxWindowBase::TransferDataToWindow()
1388 #if wxUSE_VALIDATORS
1389 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1391 wxWindowList::compatibility_iterator node
;
1392 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1394 wxWindowBase
*child
= node
->GetData();
1395 wxValidator
*validator
= child
->GetValidator();
1396 if ( validator
&& !validator
->TransferToWindow() )
1398 wxLogWarning(_("Could not transfer data to window"));
1400 wxLog::FlushActive();
1408 if ( !child
->TransferDataToWindow() )
1410 // warning already given
1415 #endif // wxUSE_VALIDATORS
1420 bool wxWindowBase::TransferDataFromWindow()
1422 #if wxUSE_VALIDATORS
1423 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1425 wxWindowList::compatibility_iterator node
;
1426 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1428 wxWindow
*child
= node
->GetData();
1429 wxValidator
*validator
= child
->GetValidator();
1430 if ( validator
&& !validator
->TransferFromWindow() )
1432 // nop warning here because the application is supposed to give
1433 // one itself - we don't know here what might have gone wrongly
1440 if ( !child
->TransferDataFromWindow() )
1442 // warning already given
1447 #endif // wxUSE_VALIDATORS
1452 void wxWindowBase::InitDialog()
1454 wxInitDialogEvent
event(GetId());
1455 event
.SetEventObject( this );
1456 GetEventHandler()->ProcessEvent(event
);
1459 // ----------------------------------------------------------------------------
1460 // context-sensitive help support
1461 // ----------------------------------------------------------------------------
1465 // associate this help text with this window
1466 void wxWindowBase::SetHelpText(const wxString
& text
)
1468 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1471 helpProvider
->AddHelp(this, text
);
1475 // associate this help text with all windows with the same id as this
1477 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1479 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1482 helpProvider
->AddHelp(GetId(), text
);
1486 // get the help string associated with this window (may be empty)
1487 wxString
wxWindowBase::GetHelpText() const
1490 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1493 text
= helpProvider
->GetHelp(this);
1499 // show help for this window
1500 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1502 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1505 if ( helpProvider
->ShowHelp(this) )
1507 // skip the event.Skip() below
1515 #endif // wxUSE_HELP
1517 // ----------------------------------------------------------------------------
1518 // tooltipsroot.Replace("\\", "/");
1519 // ----------------------------------------------------------------------------
1523 void wxWindowBase::SetToolTip( const wxString
&tip
)
1525 // don't create the new tooltip if we already have one
1528 m_tooltip
->SetTip( tip
);
1532 SetToolTip( new wxToolTip( tip
) );
1535 // setting empty tooltip text does not remove the tooltip any more - use
1536 // SetToolTip((wxToolTip *)NULL) for this
1539 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1544 m_tooltip
= tooltip
;
1547 #endif // wxUSE_TOOLTIPS
1549 // ----------------------------------------------------------------------------
1550 // constraints and sizers
1551 // ----------------------------------------------------------------------------
1553 #if wxUSE_CONSTRAINTS
1555 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1557 if ( m_constraints
)
1559 UnsetConstraints(m_constraints
);
1560 delete m_constraints
;
1562 m_constraints
= constraints
;
1563 if ( m_constraints
)
1565 // Make sure other windows know they're part of a 'meaningful relationship'
1566 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1567 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1568 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1569 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1570 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1571 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1572 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1573 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1574 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1575 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1576 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1577 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1578 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1579 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1580 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1581 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1585 // This removes any dangling pointers to this window in other windows'
1586 // constraintsInvolvedIn lists.
1587 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1591 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1592 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1593 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1594 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1595 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1596 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1597 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1598 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1599 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1600 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1601 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1602 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1603 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1604 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1605 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1606 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1610 // Back-pointer to other windows we're involved with, so if we delete this
1611 // window, we must delete any constraints we're involved with.
1612 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
1614 if ( !m_constraintsInvolvedIn
)
1615 m_constraintsInvolvedIn
= new wxWindowList
;
1616 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
1617 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
1620 // REMOVE back-pointer to other windows we're involved with.
1621 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
1623 if ( m_constraintsInvolvedIn
)
1624 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
1627 // Reset any constraints that mention this window
1628 void wxWindowBase::DeleteRelatedConstraints()
1630 if ( m_constraintsInvolvedIn
)
1632 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
1635 wxWindow
*win
= node
->GetData();
1636 wxLayoutConstraints
*constr
= win
->GetConstraints();
1638 // Reset any constraints involving this window
1641 constr
->left
.ResetIfWin(this);
1642 constr
->top
.ResetIfWin(this);
1643 constr
->right
.ResetIfWin(this);
1644 constr
->bottom
.ResetIfWin(this);
1645 constr
->width
.ResetIfWin(this);
1646 constr
->height
.ResetIfWin(this);
1647 constr
->centreX
.ResetIfWin(this);
1648 constr
->centreY
.ResetIfWin(this);
1651 wxWindowList::compatibility_iterator next
= node
->GetNext();
1652 m_constraintsInvolvedIn
->Erase(node
);
1656 delete m_constraintsInvolvedIn
;
1657 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
1661 #endif // wxUSE_CONSTRAINTS
1663 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
1665 if ( sizer
== m_windowSizer
)
1669 delete m_windowSizer
;
1671 m_windowSizer
= sizer
;
1673 SetAutoLayout( sizer
!= NULL
);
1676 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
1678 SetSizer( sizer
, deleteOld
);
1679 sizer
->SetSizeHints( (wxWindow
*) this );
1683 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
1685 // adding a window to a sizer twice is going to result in fatal and
1686 // hard to debug problems later because when deleting the second
1687 // associated wxSizerItem we're going to dereference a dangling
1688 // pointer; so try to detect this as early as possible
1689 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
1690 _T("Adding a window to the same sizer twice?") );
1692 m_containingSizer
= sizer
;
1695 #if wxUSE_CONSTRAINTS
1697 void wxWindowBase::SatisfyConstraints()
1699 wxLayoutConstraints
*constr
= GetConstraints();
1700 bool wasOk
= constr
&& constr
->AreSatisfied();
1702 ResetConstraints(); // Mark all constraints as unevaluated
1706 // if we're a top level panel (i.e. our parent is frame/dialog), our
1707 // own constraints will never be satisfied any more unless we do it
1711 while ( noChanges
> 0 )
1713 LayoutPhase1(&noChanges
);
1717 LayoutPhase2(&noChanges
);
1720 #endif // wxUSE_CONSTRAINTS
1722 bool wxWindowBase::Layout()
1724 // If there is a sizer, use it instead of the constraints
1728 GetVirtualSize(&w
, &h
);
1729 GetSizer()->SetDimension( 0, 0, w
, h
);
1731 #if wxUSE_CONSTRAINTS
1734 SatisfyConstraints(); // Find the right constraints values
1735 SetConstraintSizes(); // Recursively set the real window sizes
1742 #if wxUSE_CONSTRAINTS
1744 // first phase of the constraints evaluation: set our own constraints
1745 bool wxWindowBase::LayoutPhase1(int *noChanges
)
1747 wxLayoutConstraints
*constr
= GetConstraints();
1749 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
1752 // second phase: set the constraints for our children
1753 bool wxWindowBase::LayoutPhase2(int *noChanges
)
1760 // Layout grand children
1766 // Do a phase of evaluating child constraints
1767 bool wxWindowBase::DoPhase(int phase
)
1769 // the list containing the children for which the constraints are already
1771 wxWindowList succeeded
;
1773 // the max number of iterations we loop before concluding that we can't set
1775 static const int maxIterations
= 500;
1777 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
1781 // loop over all children setting their constraints
1782 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1784 node
= node
->GetNext() )
1786 wxWindow
*child
= node
->GetData();
1787 if ( child
->IsTopLevel() )
1789 // top level children are not inside our client area
1793 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
1795 // this one is either already ok or nothing we can do about it
1799 int tempNoChanges
= 0;
1800 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
1801 : child
->LayoutPhase2(&tempNoChanges
);
1802 noChanges
+= tempNoChanges
;
1806 succeeded
.Append(child
);
1812 // constraints are set
1820 void wxWindowBase::ResetConstraints()
1822 wxLayoutConstraints
*constr
= GetConstraints();
1825 constr
->left
.SetDone(false);
1826 constr
->top
.SetDone(false);
1827 constr
->right
.SetDone(false);
1828 constr
->bottom
.SetDone(false);
1829 constr
->width
.SetDone(false);
1830 constr
->height
.SetDone(false);
1831 constr
->centreX
.SetDone(false);
1832 constr
->centreY
.SetDone(false);
1835 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1838 wxWindow
*win
= node
->GetData();
1839 if ( !win
->IsTopLevel() )
1840 win
->ResetConstraints();
1841 node
= node
->GetNext();
1845 // Need to distinguish between setting the 'fake' size for windows and sizers,
1846 // and setting the real values.
1847 void wxWindowBase::SetConstraintSizes(bool recurse
)
1849 wxLayoutConstraints
*constr
= GetConstraints();
1850 if ( constr
&& constr
->AreSatisfied() )
1852 int x
= constr
->left
.GetValue();
1853 int y
= constr
->top
.GetValue();
1854 int w
= constr
->width
.GetValue();
1855 int h
= constr
->height
.GetValue();
1857 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
1858 (constr
->height
.GetRelationship() != wxAsIs
) )
1860 SetSize(x
, y
, w
, h
);
1864 // If we don't want to resize this window, just move it...
1870 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
1871 GetClassInfo()->GetClassName(),
1877 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1880 wxWindow
*win
= node
->GetData();
1881 if ( !win
->IsTopLevel() && win
->GetConstraints() )
1882 win
->SetConstraintSizes();
1883 node
= node
->GetNext();
1888 // Only set the size/position of the constraint (if any)
1889 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
1891 wxLayoutConstraints
*constr
= GetConstraints();
1894 if ( x
!= wxDefaultCoord
)
1896 constr
->left
.SetValue(x
);
1897 constr
->left
.SetDone(true);
1899 if ( y
!= wxDefaultCoord
)
1901 constr
->top
.SetValue(y
);
1902 constr
->top
.SetDone(true);
1904 if ( w
!= wxDefaultCoord
)
1906 constr
->width
.SetValue(w
);
1907 constr
->width
.SetDone(true);
1909 if ( h
!= wxDefaultCoord
)
1911 constr
->height
.SetValue(h
);
1912 constr
->height
.SetDone(true);
1917 void wxWindowBase::MoveConstraint(int x
, int y
)
1919 wxLayoutConstraints
*constr
= GetConstraints();
1922 if ( x
!= wxDefaultCoord
)
1924 constr
->left
.SetValue(x
);
1925 constr
->left
.SetDone(true);
1927 if ( y
!= wxDefaultCoord
)
1929 constr
->top
.SetValue(y
);
1930 constr
->top
.SetDone(true);
1935 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
1937 wxLayoutConstraints
*constr
= GetConstraints();
1940 *w
= constr
->width
.GetValue();
1941 *h
= constr
->height
.GetValue();
1947 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
1949 wxLayoutConstraints
*constr
= GetConstraints();
1952 *w
= constr
->width
.GetValue();
1953 *h
= constr
->height
.GetValue();
1956 GetClientSize(w
, h
);
1959 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
1961 wxLayoutConstraints
*constr
= GetConstraints();
1964 *x
= constr
->left
.GetValue();
1965 *y
= constr
->top
.GetValue();
1971 #endif // wxUSE_CONSTRAINTS
1973 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
1975 // don't do it for the dialogs/frames - they float independently of their
1977 if ( !IsTopLevel() )
1979 wxWindow
*parent
= GetParent();
1980 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
1982 wxPoint
pt(parent
->GetClientAreaOrigin());
1989 // ----------------------------------------------------------------------------
1990 // do Update UI processing for child controls
1991 // ----------------------------------------------------------------------------
1993 void wxWindowBase::UpdateWindowUI(long flags
)
1995 wxUpdateUIEvent
event(GetId());
1996 event
.m_eventObject
= this;
1998 if ( GetEventHandler()->ProcessEvent(event
) )
2000 DoUpdateWindowUI(event
);
2003 if (flags
& wxUPDATE_UI_RECURSE
)
2005 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2008 wxWindow
* child
= (wxWindow
*) node
->GetData();
2009 child
->UpdateWindowUI(flags
);
2010 node
= node
->GetNext();
2015 // do the window-specific processing after processing the update event
2016 // TODO: take specific knowledge out of this function and
2017 // put in each control's base class. Unfortunately we don't
2018 // yet have base implementation files for wxCheckBox and wxRadioButton.
2019 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
2021 if ( event
.GetSetEnabled() )
2022 Enable(event
.GetEnabled());
2025 if ( event
.GetSetText() )
2027 wxControl
*control
= wxDynamicCastThis(wxControl
);
2030 if ( event
.GetText() != control
->GetLabel() )
2031 control
->SetLabel(event
.GetText());
2034 wxCheckBox
*checkbox
= wxDynamicCastThis(wxCheckBox
);
2037 if ( event
.GetSetChecked() )
2038 checkbox
->SetValue(event
.GetChecked());
2040 #endif // wxUSE_CHECKBOX
2043 wxRadioButton
*radiobtn
= wxDynamicCastThis(wxRadioButton
);
2046 if ( event
.GetSetChecked() )
2047 radiobtn
->SetValue(event
.GetChecked());
2049 #endif // wxUSE_RADIOBTN
2055 // call internal idle recursively
2056 // may be obsolete (wait until OnIdle scheme stabilises)
2057 void wxWindowBase::ProcessInternalIdle()
2061 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2064 wxWindow
*child
= node
->GetData();
2065 child
->ProcessInternalIdle();
2066 node
= node
->GetNext();
2071 // ----------------------------------------------------------------------------
2072 // dialog units translations
2073 // ----------------------------------------------------------------------------
2075 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
2077 int charWidth
= GetCharWidth();
2078 int charHeight
= GetCharHeight();
2079 wxPoint
pt2(-1, -1);
2081 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
);
2083 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2088 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2090 int charWidth
= GetCharWidth();
2091 int charHeight
= GetCharHeight();
2092 wxPoint
pt2(-1, -1);
2094 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2096 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2101 // ----------------------------------------------------------------------------
2103 // ----------------------------------------------------------------------------
2105 // propagate the colour change event to the subwindows
2106 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2108 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2111 // Only propagate to non-top-level windows
2112 wxWindow
*win
= node
->GetData();
2113 if ( !win
->IsTopLevel() )
2115 wxSysColourChangedEvent event2
;
2116 event
.m_eventObject
= win
;
2117 win
->GetEventHandler()->ProcessEvent(event2
);
2120 node
= node
->GetNext();
2126 // the default action is to populate dialog with data when it's created,
2127 // and nudge the UI into displaying itself correctly in case
2128 // we've turned the wxUpdateUIEvents frequency down low.
2129 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2131 TransferDataToWindow();
2133 // Update the UI at this point
2134 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2137 // process Ctrl-Alt-mclick
2138 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2141 if ( event
.ControlDown() && event
.AltDown() )
2143 // don't translate these strings
2146 #ifdef __WXUNIVERSAL__
2148 #endif // __WXUNIVERSAL__
2150 switch ( wxGetOsVersion() )
2152 case wxMOTIF_X
: port
+= _T("Motif"); break;
2154 case wxMAC_DARWIN
: port
+= _T("Mac"); break;
2155 case wxBEOS
: port
+= _T("BeOS"); break;
2159 case wxGTK_BEOS
: port
+= _T("GTK"); break;
2165 case wxWIN386
: port
+= _T("MS Windows"); break;
2169 case wxMGL_OS2
: port
+= _T("MGL"); break;
2171 case wxOS2_PM
: port
+= _T("OS/2"); break;
2172 default: port
+= _T("unknown"); break;
2175 wxMessageBox(wxString::Format(
2177 " wxWidgets Library (%s port)\nVersion %u.%u.%u%s, compiled at %s %s\n Copyright (c) 1995-2002 wxWidgets team"
2191 _T("wxWidgets information"),
2192 wxICON_INFORMATION
| wxOK
,
2196 #endif // wxUSE_MSGDLG
2202 // ----------------------------------------------------------------------------
2204 // ----------------------------------------------------------------------------
2206 #if wxUSE_ACCESSIBILITY
2207 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2209 if (m_accessible
&& (accessible
!= m_accessible
))
2210 delete m_accessible
;
2211 m_accessible
= accessible
;
2213 m_accessible
->SetWindow((wxWindow
*) this);
2216 // Returns the accessible object, creating if necessary.
2217 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2220 m_accessible
= CreateAccessible();
2221 return m_accessible
;
2224 // Override to create a specific accessible object.
2225 wxAccessible
* wxWindowBase::CreateAccessible()
2227 return new wxWindowAccessible((wxWindow
*) this);
2233 // ----------------------------------------------------------------------------
2234 // list classes implementation
2235 // ----------------------------------------------------------------------------
2237 void wxWindowListNode::DeleteData()
2239 delete (wxWindow
*)GetData();
2243 // ----------------------------------------------------------------------------
2245 // ----------------------------------------------------------------------------
2247 wxBorder
wxWindowBase::GetBorder(long flags
) const
2249 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2250 if ( border
== wxBORDER_DEFAULT
)
2252 border
= GetDefaultBorder();
2258 wxBorder
wxWindowBase::GetDefaultBorder() const
2260 return wxBORDER_NONE
;
2263 // ----------------------------------------------------------------------------
2265 // ----------------------------------------------------------------------------
2267 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2269 // here we just check if the point is inside the window or not
2271 // check the top and left border first
2272 bool outside
= x
< 0 || y
< 0;
2275 // check the right and bottom borders too
2276 wxSize size
= GetSize();
2277 outside
= x
>= size
.x
|| y
>= size
.y
;
2280 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2283 // ----------------------------------------------------------------------------
2285 // ----------------------------------------------------------------------------
2287 struct WXDLLEXPORT wxWindowNext
2291 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2293 void wxWindowBase::CaptureMouse()
2295 wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), this);
2297 wxWindow
*winOld
= GetCapture();
2300 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2303 wxWindowNext
*item
= new wxWindowNext
;
2305 item
->next
= ms_winCaptureNext
;
2306 ms_winCaptureNext
= item
;
2308 //else: no mouse capture to save
2313 void wxWindowBase::ReleaseMouse()
2315 wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), this);
2317 wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") );
2321 if ( ms_winCaptureNext
)
2323 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2325 wxWindowNext
*item
= ms_winCaptureNext
;
2326 ms_winCaptureNext
= item
->next
;
2329 //else: stack is empty, no previous capture
2331 wxLogTrace(_T("mousecapture"),
2332 (const wxChar
*) _T("After ReleaseMouse() mouse is captured by %p"),
2339 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2340 int WXUNUSED(modifiers
),
2341 int WXUNUSED(keycode
))
2347 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2353 #endif // wxUSE_HOTKEY
2355 void wxWindowBase::SendDestroyEvent()
2357 wxWindowDestroyEvent event
;
2358 event
.SetEventObject(this);
2359 event
.SetId(GetId());
2360 GetEventHandler()->ProcessEvent(event
);
2363 // ----------------------------------------------------------------------------
2365 // ----------------------------------------------------------------------------
2367 bool wxWindowBase::TryValidator(wxEvent
& wxVALIDATOR_PARAM(event
))
2369 #if wxUSE_VALIDATORS
2370 // Can only use the validator of the window which
2371 // is receiving the event
2372 if ( event
.GetEventObject() == this )
2374 wxValidator
*validator
= GetValidator();
2375 if ( validator
&& validator
->ProcessEvent(event
) )
2380 #endif // wxUSE_VALIDATORS
2385 bool wxWindowBase::TryParent(wxEvent
& event
)
2387 // carry on up the parent-child hierarchy if the propgation count hasn't
2389 if ( event
.ShouldPropagate() )
2391 // honour the requests to stop propagation at this window: this is
2392 // used by the dialogs, for example, to prevent processing the events
2393 // from the dialog controls in the parent frame which rarely, if ever,
2395 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2397 wxWindow
*parent
= GetParent();
2398 if ( parent
&& !parent
->IsBeingDeleted() )
2400 wxPropagateOnce
propagateOnce(event
);
2402 return parent
->GetEventHandler()->ProcessEvent(event
);
2407 return wxEvtHandler::TryParent(event
);
2410 // ----------------------------------------------------------------------------
2411 // keyboard navigation
2412 // ----------------------------------------------------------------------------
2414 // Navigates in the specified direction.
2415 bool wxWindowBase::Navigate(int flags
)
2417 wxNavigationKeyEvent eventNav
;
2418 eventNav
.SetFlags(flags
);
2419 eventNav
.SetEventObject(this);
2420 if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav
) )
2427 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, MoveKind move
)
2429 // check that we're not a top level window
2430 wxCHECK_RET( GetParent(),
2431 _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
2433 // find the target window in the siblings list
2434 wxWindowList
& siblings
= GetParent()->GetChildren();
2435 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
2436 wxCHECK_RET( i
, _T("MoveBefore/AfterInTabOrder(): win is not a sibling") );
2438 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
2439 // can't just move the node around
2440 wxWindow
*self
= (wxWindow
*)this;
2441 siblings
.DeleteObject(self
);
2442 if ( move
== MoveAfter
)
2449 siblings
.Insert(i
, self
);
2451 else // MoveAfter and win was the last sibling
2453 siblings
.Append(self
);
2457 // ----------------------------------------------------------------------------
2459 // ----------------------------------------------------------------------------
2461 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
2463 while ( win
&& !win
->IsTopLevel() )
2464 win
= win
->GetParent();
2469 #if wxUSE_ACCESSIBILITY
2470 // ----------------------------------------------------------------------------
2471 // accessible object for windows
2472 // ----------------------------------------------------------------------------
2474 // Can return either a child object, or an integer
2475 // representing the child element, starting from 1.
2476 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
2478 wxASSERT( GetWindow() != NULL
);
2482 return wxACC_NOT_IMPLEMENTED
;
2485 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
2486 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
2488 wxASSERT( GetWindow() != NULL
);
2492 wxWindow
* win
= NULL
;
2499 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
2501 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
2508 rect
= win
->GetRect();
2509 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
2510 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
2514 return wxACC_NOT_IMPLEMENTED
;
2517 // Navigates from fromId to toId/toObject.
2518 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
2519 int* WXUNUSED(toId
), wxAccessible
** toObject
)
2521 wxASSERT( GetWindow() != NULL
);
2527 case wxNAVDIR_FIRSTCHILD
:
2529 if (GetWindow()->GetChildren().GetCount() == 0)
2531 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
2532 *toObject
= childWindow
->GetOrCreateAccessible();
2536 case wxNAVDIR_LASTCHILD
:
2538 if (GetWindow()->GetChildren().GetCount() == 0)
2540 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
2541 *toObject
= childWindow
->GetOrCreateAccessible();
2545 case wxNAVDIR_RIGHT
:
2549 wxWindowList::compatibility_iterator node
=
2550 wxWindowList::compatibility_iterator();
2553 // Can't navigate to sibling of this window
2554 // if we're a top-level window.
2555 if (!GetWindow()->GetParent())
2556 return wxACC_NOT_IMPLEMENTED
;
2558 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2562 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2563 node
= GetWindow()->GetChildren().Item(fromId
-1);
2566 if (node
&& node
->GetNext())
2568 wxWindow
* nextWindow
= node
->GetNext()->GetData();
2569 *toObject
= nextWindow
->GetOrCreateAccessible();
2577 case wxNAVDIR_PREVIOUS
:
2579 wxWindowList::compatibility_iterator node
=
2580 wxWindowList::compatibility_iterator();
2583 // Can't navigate to sibling of this window
2584 // if we're a top-level window.
2585 if (!GetWindow()->GetParent())
2586 return wxACC_NOT_IMPLEMENTED
;
2588 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2592 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2593 node
= GetWindow()->GetChildren().Item(fromId
-1);
2596 if (node
&& node
->GetPrevious())
2598 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
2599 *toObject
= previousWindow
->GetOrCreateAccessible();
2607 return wxACC_NOT_IMPLEMENTED
;
2610 // Gets the name of the specified object.
2611 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
2613 wxASSERT( GetWindow() != NULL
);
2619 // If a child, leave wxWidgets to call the function on the actual
2622 return wxACC_NOT_IMPLEMENTED
;
2624 // This will eventually be replaced by specialised
2625 // accessible classes, one for each kind of wxWidgets
2626 // control or window.
2628 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
2629 title
= ((wxButton
*) GetWindow())->GetLabel();
2632 title
= GetWindow()->GetName();
2634 if (!title
.IsEmpty())
2640 return wxACC_NOT_IMPLEMENTED
;
2643 // Gets the number of children.
2644 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
2646 wxASSERT( GetWindow() != NULL
);
2650 *childId
= (int) GetWindow()->GetChildren().GetCount();
2654 // Gets the specified child (starting from 1).
2655 // If *child is NULL and return value is wxACC_OK,
2656 // this means that the child is a simple element and
2657 // not an accessible object.
2658 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
2660 wxASSERT( GetWindow() != NULL
);
2670 if (childId
> (int) GetWindow()->GetChildren().GetCount())
2673 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
2674 *child
= childWindow
->GetOrCreateAccessible();
2681 // Gets the parent, or NULL.
2682 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
2684 wxASSERT( GetWindow() != NULL
);
2688 wxWindow
* parentWindow
= GetWindow()->GetParent();
2696 *parent
= parentWindow
->GetOrCreateAccessible();
2704 // Performs the default action. childId is 0 (the action for this object)
2705 // or > 0 (the action for a child).
2706 // Return wxACC_NOT_SUPPORTED if there is no default action for this
2707 // window (e.g. an edit control).
2708 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
2710 wxASSERT( GetWindow() != NULL
);
2714 return wxACC_NOT_IMPLEMENTED
;
2717 // Gets the default action for this object (0) or > 0 (the action for a child).
2718 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
2719 // string if there is no action.
2720 // The retrieved string describes the action that is performed on an object,
2721 // not what the object does as a result. For example, a toolbar button that prints
2722 // a document has a default action of "Press" rather than "Prints the current document."
2723 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
2725 wxASSERT( GetWindow() != NULL
);
2729 return wxACC_NOT_IMPLEMENTED
;
2732 // Returns the description for this object or a child.
2733 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
2735 wxASSERT( GetWindow() != NULL
);
2739 wxString
ht(GetWindow()->GetHelpText());
2745 return wxACC_NOT_IMPLEMENTED
;
2748 // Returns help text for this object or a child, similar to tooltip text.
2749 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
2751 wxASSERT( GetWindow() != NULL
);
2755 wxString
ht(GetWindow()->GetHelpText());
2761 return wxACC_NOT_IMPLEMENTED
;
2764 // Returns the keyboard shortcut for this object or child.
2765 // Return e.g. ALT+K
2766 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
2768 wxASSERT( GetWindow() != NULL
);
2772 return wxACC_NOT_IMPLEMENTED
;
2775 // Returns a role constant.
2776 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
2778 wxASSERT( GetWindow() != NULL
);
2782 // If a child, leave wxWidgets to call the function on the actual
2785 return wxACC_NOT_IMPLEMENTED
;
2787 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2788 return wxACC_NOT_IMPLEMENTED
;
2790 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2791 return wxACC_NOT_IMPLEMENTED
;
2794 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2795 return wxACC_NOT_IMPLEMENTED
;
2798 //*role = wxROLE_SYSTEM_CLIENT;
2799 *role
= wxROLE_SYSTEM_CLIENT
;
2803 return wxACC_NOT_IMPLEMENTED
;
2807 // Returns a state constant.
2808 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
2810 wxASSERT( GetWindow() != NULL
);
2814 // If a child, leave wxWidgets to call the function on the actual
2817 return wxACC_NOT_IMPLEMENTED
;
2819 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2820 return wxACC_NOT_IMPLEMENTED
;
2823 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2824 return wxACC_NOT_IMPLEMENTED
;
2827 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2828 return wxACC_NOT_IMPLEMENTED
;
2835 return wxACC_NOT_IMPLEMENTED
;
2839 // Returns a localized string representing the value for the object
2841 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
2843 wxASSERT( GetWindow() != NULL
);
2847 return wxACC_NOT_IMPLEMENTED
;
2850 // Selects the object or child.
2851 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
2853 wxASSERT( GetWindow() != NULL
);
2857 return wxACC_NOT_IMPLEMENTED
;
2860 // Gets the window with the keyboard focus.
2861 // If childId is 0 and child is NULL, no object in
2862 // this subhierarchy has the focus.
2863 // If this object has the focus, child should be 'this'.
2864 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
2866 wxASSERT( GetWindow() != NULL
);
2870 return wxACC_NOT_IMPLEMENTED
;
2873 // Gets a variant representing the selected children
2875 // Acceptable values:
2876 // - a null variant (IsNull() returns TRUE)
2877 // - a list variant (GetType() == wxT("list")
2878 // - an integer representing the selected child element,
2879 // or 0 if this object is selected (GetType() == wxT("long")
2880 // - a "void*" pointer to a wxAccessible child object
2881 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
2883 wxASSERT( GetWindow() != NULL
);
2887 return wxACC_NOT_IMPLEMENTED
;
2890 #endif // wxUSE_ACCESSIBILITY