1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/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 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
28 #include "wx/string.h"
33 #include "wx/window.h"
34 #include "wx/control.h"
35 #include "wx/checkbox.h"
36 #include "wx/radiobut.h"
37 #include "wx/statbox.h"
38 #include "wx/textctrl.h"
39 #include "wx/settings.h"
40 #include "wx/dialog.h"
41 #include "wx/msgdlg.h"
42 #include "wx/statusbr.h"
43 #include "wx/toolbar.h"
44 #include "wx/dcclient.h"
47 #if defined(__WXMAC__) && wxUSE_SCROLLBAR
48 #include "wx/scrolbar.h"
52 #include "wx/layout.h"
53 #endif // wxUSE_CONSTRAINTS
57 #if wxUSE_DRAG_AND_DROP
59 #endif // wxUSE_DRAG_AND_DROP
61 #if wxUSE_ACCESSIBILITY
62 #include "wx/access.h"
66 #include "wx/cshelp.h"
70 #include "wx/tooltip.h"
71 #endif // wxUSE_TOOLTIPS
77 #if wxUSE_SYSTEM_OPTIONS
78 #include "wx/sysopt.h"
81 // For reporting compile- and runtime version of GTK+ in the ctrl+alt+mclick dialog.
82 // The gtk includes don't pull any other headers in, at least not on my system - MR
85 #include <gtk/gtkversion.h>
87 #include <gtk/gtkfeatures.h>
89 extern const unsigned int gtk_major_version
;
90 extern const unsigned int gtk_minor_version
;
91 extern const unsigned int gtk_micro_version
;
94 // ----------------------------------------------------------------------------
96 // ----------------------------------------------------------------------------
98 #if defined(__WXPALMOS__)
99 int wxWindowBase::ms_lastControlId
= 32767;
100 #elif defined(__WXPM__)
101 int wxWindowBase::ms_lastControlId
= 2000;
103 int wxWindowBase::ms_lastControlId
= -200;
106 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase
, wxEvtHandler
)
108 // ----------------------------------------------------------------------------
110 // ----------------------------------------------------------------------------
112 BEGIN_EVENT_TABLE(wxWindowBase
, wxEvtHandler
)
113 EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged
)
114 EVT_INIT_DIALOG(wxWindowBase::OnInitDialog
)
115 EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick
)
118 EVT_HELP(wxID_ANY
, wxWindowBase::OnHelp
)
123 // ============================================================================
124 // implementation of the common functionality of the wxWindow class
125 // ============================================================================
127 // ----------------------------------------------------------------------------
129 // ----------------------------------------------------------------------------
131 // the default initialization
132 wxWindowBase::wxWindowBase()
134 // no window yet, no parent nor children
135 m_parent
= (wxWindow
*)NULL
;
136 m_windowId
= wxID_ANY
;
138 // no constraints on the minimal window size
140 m_maxWidth
= wxDefaultCoord
;
142 m_maxHeight
= wxDefaultCoord
;
144 // invalidiated cache value
145 m_bestSizeCache
= wxDefaultSize
;
147 // window are created enabled and visible by default
151 // the default event handler is just this window
152 m_eventHandler
= this;
156 m_windowValidator
= (wxValidator
*) NULL
;
157 #endif // wxUSE_VALIDATORS
159 // the colours/fonts are default for now, so leave m_font,
160 // m_backgroundColour and m_foregroundColour uninitialized and set those
166 m_inheritFont
= false;
172 m_backgroundStyle
= wxBG_STYLE_SYSTEM
;
174 #if wxUSE_CONSTRAINTS
175 // no constraints whatsoever
176 m_constraints
= (wxLayoutConstraints
*) NULL
;
177 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
178 #endif // wxUSE_CONSTRAINTS
180 m_windowSizer
= (wxSizer
*) NULL
;
181 m_containingSizer
= (wxSizer
*) NULL
;
182 m_autoLayout
= false;
184 #if wxUSE_DRAG_AND_DROP
185 m_dropTarget
= (wxDropTarget
*)NULL
;
186 #endif // wxUSE_DRAG_AND_DROP
189 m_tooltip
= (wxToolTip
*)NULL
;
190 #endif // wxUSE_TOOLTIPS
193 m_caret
= (wxCaret
*)NULL
;
194 #endif // wxUSE_CARET
197 m_hasCustomPalette
= false;
198 #endif // wxUSE_PALETTE
200 #if wxUSE_ACCESSIBILITY
204 m_virtualSize
= wxDefaultSize
;
207 m_maxVirtualWidth
= wxDefaultCoord
;
209 m_maxVirtualHeight
= wxDefaultCoord
;
211 m_windowVariant
= wxWINDOW_VARIANT_NORMAL
;
212 #if wxUSE_SYSTEM_OPTIONS
213 if ( wxSystemOptions::HasOption(wxWINDOW_DEFAULT_VARIANT
) )
215 m_windowVariant
= (wxWindowVariant
) wxSystemOptions::GetOptionInt( wxWINDOW_DEFAULT_VARIANT
) ;
219 // Whether we're using the current theme for this window (wxGTK only for now)
220 m_themeEnabled
= false;
222 // VZ: this one shouldn't exist...
223 m_isBeingDeleted
= false;
226 // common part of window creation process
227 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
229 const wxPoint
& WXUNUSED(pos
),
230 const wxSize
& WXUNUSED(size
),
232 const wxValidator
& wxVALIDATOR_PARAM(validator
),
233 const wxString
& name
)
236 // wxGTK doesn't allow to create controls with static box as the parent so
237 // this will result in a crash when the program is ported to wxGTK so warn
240 // if you get this assert, the correct solution is to create the controls
241 // as siblings of the static box
242 wxASSERT_MSG( !parent
|| !wxDynamicCast(parent
, wxStaticBox
),
243 _T("wxStaticBox can't be used as a window parent!") );
244 #endif // wxUSE_STATBOX
246 // ids are limited to 16 bits under MSW so if you care about portability,
247 // it's not a good idea to use ids out of this range (and negative ids are
248 // reserved for wxWidgets own usage)
249 wxASSERT_MSG( id
== wxID_ANY
|| (id
>= 0 && id
< 32767),
250 _T("invalid id value") );
252 // generate a new id if the user doesn't care about it
253 m_windowId
= id
== wxID_ANY
? NewControlId() : id
;
256 SetWindowStyleFlag(style
);
260 SetValidator(validator
);
261 #endif // wxUSE_VALIDATORS
263 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
264 // have it too - like this it's possible to set it only in the top level
265 // dialog/frame and all children will inherit it by defult
266 if ( parent
&& (parent
->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) )
268 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY
);
274 // ----------------------------------------------------------------------------
276 // ----------------------------------------------------------------------------
279 wxWindowBase::~wxWindowBase()
281 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
283 // FIXME if these 2 cases result from programming errors in the user code
284 // we should probably assert here instead of silently fixing them
286 // Just in case the window has been Closed, but we're then deleting
287 // immediately: don't leave dangling pointers.
288 wxPendingDelete
.DeleteObject(this);
290 // Just in case we've loaded a top-level window via LoadNativeDialog but
291 // we weren't a dialog class
292 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
294 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
296 // reset the dangling pointer our parent window may keep to us
299 if ( m_parent
->GetDefaultItem() == this )
301 m_parent
->SetDefaultItem(NULL
);
304 m_parent
->RemoveChild(this);
309 #endif // wxUSE_CARET
312 delete m_windowValidator
;
313 #endif // wxUSE_VALIDATORS
315 #if wxUSE_CONSTRAINTS
316 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
317 // at deleted windows as they delete themselves.
318 DeleteRelatedConstraints();
322 // This removes any dangling pointers to this window in other windows'
323 // constraintsInvolvedIn lists.
324 UnsetConstraints(m_constraints
);
325 delete m_constraints
;
326 m_constraints
= NULL
;
328 #endif // wxUSE_CONSTRAINTS
330 if ( m_containingSizer
)
331 m_containingSizer
->Detach( (wxWindow
*)this );
333 delete m_windowSizer
;
335 #if wxUSE_DRAG_AND_DROP
337 #endif // wxUSE_DRAG_AND_DROP
341 #endif // wxUSE_TOOLTIPS
343 #if wxUSE_ACCESSIBILITY
348 bool wxWindowBase::Destroy()
355 bool wxWindowBase::Close(bool force
)
357 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
358 event
.SetEventObject(this);
359 event
.SetCanVeto(!force
);
361 // return false if window wasn't closed because the application vetoed the
363 return GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto();
366 bool wxWindowBase::DestroyChildren()
368 wxWindowList::compatibility_iterator node
;
371 // we iterate until the list becomes empty
372 node
= GetChildren().GetFirst();
376 wxWindow
*child
= node
->GetData();
378 // note that we really want to call delete and not ->Destroy() here
379 // because we want to delete the child immediately, before we are
380 // deleted, and delayed deletion would result in problems as our (top
381 // level) child could outlive its parent
384 wxASSERT_MSG( !GetChildren().Find(child
),
385 wxT("child didn't remove itself using RemoveChild()") );
391 // ----------------------------------------------------------------------------
392 // size/position related methods
393 // ----------------------------------------------------------------------------
395 // centre the window with respect to its parent in either (or both) directions
396 void wxWindowBase::DoCentre(int dir
)
398 wxCHECK_RET( !(dir
& wxCENTRE_ON_SCREEN
) && GetParent(),
399 _T("this method only implements centering child windows") );
401 SetSize(GetRect().CentreIn(GetParent()->GetClientSize(), dir
));
404 // fits the window around the children
405 void wxWindowBase::Fit()
407 if ( !GetChildren().empty() )
409 SetClientSize(GetBestSize());
411 //else: do nothing if we have no children
414 // fits virtual size (ie. scrolled area etc.) around children
415 void wxWindowBase::FitInside()
417 if ( GetChildren().GetCount() > 0 )
419 SetVirtualSize( GetBestVirtualSize() );
423 // On Mac, scrollbars are explicitly children.
425 static bool wxHasRealChildren(const wxWindowBase
* win
)
427 int realChildCount
= 0;
429 for ( wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
431 node
= node
->GetNext() )
433 wxWindow
*win
= node
->GetData();
434 if ( !win
->IsTopLevel() && win
->IsShown() && !win
->IsKindOf(CLASSINFO(wxScrollBar
)))
437 return (realChildCount
> 0);
441 void wxWindowBase::InvalidateBestSize()
443 m_bestSizeCache
= wxDefaultSize
;
445 // parent's best size calculation may depend on its children's
446 // as long as child window we are in is not top level window itself
447 // (because the TLW size is never resized automatically)
448 // so let's invalidate it as well to be safe:
449 if (m_parent
&& !IsTopLevel())
450 m_parent
->InvalidateBestSize();
453 // return the size best suited for the current window
454 wxSize
wxWindowBase::DoGetBestSize() const
460 best
= GetWindowSizeForVirtualSize(m_windowSizer
->GetMinSize());
462 #if wxUSE_CONSTRAINTS
463 else if ( m_constraints
)
465 wxConstCast(this, wxWindowBase
)->SatisfyConstraints();
467 // our minimal acceptable size is such that all our windows fit inside
471 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
473 node
= node
->GetNext() )
475 wxLayoutConstraints
*c
= node
->GetData()->GetConstraints();
478 // it's not normal that we have an unconstrained child, but
479 // what can we do about it?
483 int x
= c
->right
.GetValue(),
484 y
= c
->bottom
.GetValue();
492 // TODO: we must calculate the overlaps somehow, otherwise we
493 // will never return a size bigger than the current one :-(
496 best
= wxSize(maxX
, maxY
);
498 #endif // wxUSE_CONSTRAINTS
499 else if ( !GetChildren().empty()
501 && wxHasRealChildren(this)
505 // our minimal acceptable size is such that all our visible child windows fit inside
509 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
511 node
= node
->GetNext() )
513 wxWindow
*win
= node
->GetData();
514 if ( win
->IsTopLevel() || ( ! win
->IsShown() )
516 || wxDynamicCast(win
, wxStatusBar
)
517 #endif // wxUSE_STATUSBAR
520 // dialogs and frames lie in different top level windows -
521 // don't deal with them here; as for the status bars, they
522 // don't lie in the client area at all
527 win
->GetPosition(&wx
, &wy
);
529 // if the window hadn't been positioned yet, assume that it is in
531 if ( wx
== wxDefaultCoord
)
533 if ( wy
== wxDefaultCoord
)
536 win
->GetSize(&ww
, &wh
);
537 if ( wx
+ ww
> maxX
)
539 if ( wy
+ wh
> maxY
)
543 // for compatibility with the old versions and because it really looks
544 // slightly more pretty like this, add a pad
548 best
= wxSize(maxX
, maxY
);
550 else // ! has children
552 // for a generic window there is no natural best size so, if the
553 // minimal size is not set, use the current size but take care to
554 // remember it as minimal size for the next time because our best size
555 // should be constant: otherwise we could get into a situation when the
556 // window is initially at some size, then expanded to a larger size and
557 // then, when the containing window is shrunk back (because our initial
558 // best size had been used for computing the parent min size), we can't
559 // be shrunk back any more because our best size is now bigger
560 wxSize size
= GetMinSize();
561 if ( !size
.IsFullySpecified() )
563 size
.SetDefaults(GetSize());
564 wxConstCast(this, wxWindowBase
)->SetMinSize(size
);
567 // return as-is, unadjusted by the client size difference.
571 // Add any difference between size and client size
572 wxSize diff
= GetSize() - GetClientSize();
573 best
.x
+= wxMax(0, diff
.x
);
574 best
.y
+= wxMax(0, diff
.y
);
580 wxSize
wxWindowBase::GetBestFittingSize() const
582 // merge the best size with the min size, giving priority to the min size
583 wxSize min
= GetMinSize();
584 if (min
.x
== wxDefaultCoord
|| min
.y
== wxDefaultCoord
)
586 wxSize best
= GetBestSize();
587 if (min
.x
== wxDefaultCoord
) min
.x
= best
.x
;
588 if (min
.y
== wxDefaultCoord
) min
.y
= best
.y
;
594 void wxWindowBase::SetBestFittingSize(const wxSize
& size
)
596 // Set the min size to the size passed in. This will usually either be
597 // wxDefaultSize or the size passed to this window's ctor/Create function.
600 // Merge the size with the best size if needed
601 wxSize best
= GetBestFittingSize();
603 // If the current size doesn't match then change it
604 if (GetSize() != best
)
609 // by default the origin is not shifted
610 wxPoint
wxWindowBase::GetClientAreaOrigin() const
615 // set the min/max size of the window
616 void wxWindowBase::DoSetSizeHints(int minW
, int minH
,
618 int WXUNUSED(incW
), int WXUNUSED(incH
))
620 // setting min width greater than max width leads to infinite loops under
621 // X11 and generally doesn't make any sense, so don't allow it
622 wxCHECK_RET( (minW
== wxDefaultCoord
|| maxW
== wxDefaultCoord
|| minW
<= maxW
) &&
623 (minH
== wxDefaultCoord
|| maxH
== wxDefaultCoord
|| minH
<= maxH
),
624 _T("min width/height must be less than max width/height!") );
632 void wxWindowBase::SetWindowVariant( wxWindowVariant variant
)
634 if ( m_windowVariant
!= variant
)
636 m_windowVariant
= variant
;
638 DoSetWindowVariant(variant
);
642 void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant
)
644 // adjust the font height to correspond to our new variant (notice that
645 // we're only called if something really changed)
646 wxFont font
= GetFont();
647 int size
= font
.GetPointSize();
650 case wxWINDOW_VARIANT_NORMAL
:
653 case wxWINDOW_VARIANT_SMALL
:
658 case wxWINDOW_VARIANT_MINI
:
663 case wxWINDOW_VARIANT_LARGE
:
669 wxFAIL_MSG(_T("unexpected window variant"));
673 font
.SetPointSize(size
);
677 void wxWindowBase::SetVirtualSizeHints( int minW
, int minH
,
680 m_minVirtualWidth
= minW
;
681 m_maxVirtualWidth
= maxW
;
682 m_minVirtualHeight
= minH
;
683 m_maxVirtualHeight
= maxH
;
686 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
688 if ( m_minVirtualWidth
!= wxDefaultCoord
&& m_minVirtualWidth
> x
)
689 x
= m_minVirtualWidth
;
690 if ( m_maxVirtualWidth
!= wxDefaultCoord
&& m_maxVirtualWidth
< x
)
691 x
= m_maxVirtualWidth
;
692 if ( m_minVirtualHeight
!= wxDefaultCoord
&& m_minVirtualHeight
> y
)
693 y
= m_minVirtualHeight
;
694 if ( m_maxVirtualHeight
!= wxDefaultCoord
&& m_maxVirtualHeight
< y
)
695 y
= m_maxVirtualHeight
;
697 m_virtualSize
= wxSize(x
, y
);
700 wxSize
wxWindowBase::DoGetVirtualSize() const
702 // we should use the entire client area so if it is greater than our
703 // virtual size, expand it to fit (otherwise if the window is big enough we
704 // wouldn't be using parts of it)
705 wxSize size
= GetClientSize();
706 if ( m_virtualSize
.x
> size
.x
)
707 size
.x
= m_virtualSize
.x
;
709 if ( m_virtualSize
.y
>= size
.y
)
710 size
.y
= m_virtualSize
.y
;
715 void wxWindowBase::DoGetScreenPosition(int *x
, int *y
) const
717 // screen position is the same as (0, 0) in client coords for non TLWs (and
718 // TLWs override this method)
724 ClientToScreen(x
, y
);
727 // ----------------------------------------------------------------------------
728 // show/hide/enable/disable the window
729 // ----------------------------------------------------------------------------
731 bool wxWindowBase::Show(bool show
)
733 if ( show
!= m_isShown
)
745 bool wxWindowBase::Enable(bool enable
)
747 if ( enable
!= m_isEnabled
)
749 m_isEnabled
= enable
;
758 // ----------------------------------------------------------------------------
760 // ----------------------------------------------------------------------------
762 bool wxWindowBase::IsTopLevel() const
767 // ----------------------------------------------------------------------------
768 // reparenting the window
769 // ----------------------------------------------------------------------------
771 void wxWindowBase::AddChild(wxWindowBase
*child
)
773 wxCHECK_RET( child
, wxT("can't add a NULL child") );
775 // this should never happen and it will lead to a crash later if it does
776 // because RemoveChild() will remove only one node from the children list
777 // and the other(s) one(s) will be left with dangling pointers in them
778 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), _T("AddChild() called twice") );
780 GetChildren().Append((wxWindow
*)child
);
781 child
->SetParent(this);
784 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
786 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
788 GetChildren().DeleteObject((wxWindow
*)child
);
789 child
->SetParent(NULL
);
792 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
794 wxWindow
*oldParent
= GetParent();
795 if ( newParent
== oldParent
)
801 // unlink this window from the existing parent.
804 oldParent
->RemoveChild(this);
808 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
811 // add it to the new one
814 newParent
->AddChild(this);
818 wxTopLevelWindows
.Append((wxWindow
*)this);
824 // ----------------------------------------------------------------------------
825 // event handler stuff
826 // ----------------------------------------------------------------------------
828 void wxWindowBase::PushEventHandler(wxEvtHandler
*handler
)
830 wxEvtHandler
*handlerOld
= GetEventHandler();
832 handler
->SetNextHandler(handlerOld
);
835 GetEventHandler()->SetPreviousHandler(handler
);
837 SetEventHandler(handler
);
840 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
842 wxEvtHandler
*handlerA
= GetEventHandler();
845 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
846 handlerA
->SetNextHandler((wxEvtHandler
*)NULL
);
849 handlerB
->SetPreviousHandler((wxEvtHandler
*)NULL
);
850 SetEventHandler(handlerB
);
855 handlerA
= (wxEvtHandler
*)NULL
;
862 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handler
)
864 wxCHECK_MSG( handler
, false, _T("RemoveEventHandler(NULL) called") );
866 wxEvtHandler
*handlerPrev
= NULL
,
867 *handlerCur
= GetEventHandler();
870 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
872 if ( handlerCur
== handler
)
876 handlerPrev
->SetNextHandler(handlerNext
);
880 SetEventHandler(handlerNext
);
885 handlerNext
->SetPreviousHandler ( handlerPrev
);
888 handler
->SetNextHandler(NULL
);
889 handler
->SetPreviousHandler(NULL
);
894 handlerPrev
= handlerCur
;
895 handlerCur
= handlerNext
;
898 wxFAIL_MSG( _T("where has the event handler gone?") );
903 // ----------------------------------------------------------------------------
905 // ----------------------------------------------------------------------------
907 void wxWindowBase::InheritAttributes()
909 const wxWindowBase
* const parent
= GetParent();
913 // we only inherit attributes which had been explicitly set for the parent
914 // which ensures that this only happens if the user really wants it and
915 // not by default which wouldn't make any sense in modern GUIs where the
916 // controls don't all use the same fonts (nor colours)
917 if ( parent
->m_inheritFont
&& !m_hasFont
)
918 SetFont(parent
->GetFont());
920 // in addition, there is a possibility to explicitly forbid inheriting
921 // colours at each class level by overriding ShouldInheritColours()
922 if ( ShouldInheritColours() )
924 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
925 SetForegroundColour(parent
->GetForegroundColour());
927 // inheriting (solid) background colour is wrong as it totally breaks
928 // any kind of themed backgrounds
930 // instead, the controls should use the same background as their parent
931 // (ideally by not drawing it at all)
933 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
934 SetBackgroundColour(parent
->GetBackgroundColour());
939 /* static */ wxVisualAttributes
940 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
942 // it is important to return valid values for all attributes from here,
943 // GetXXX() below rely on this
944 wxVisualAttributes attrs
;
945 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
946 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
948 // On Smartphone/PocketPC, wxSYS_COLOUR_WINDOW is a better reflection of
949 // the usual background colour than wxSYS_COLOUR_BTNFACE.
950 // It's a pity that wxSYS_COLOUR_WINDOW isn't always a suitable background
951 // colour on other platforms.
953 #if defined(__WXWINCE__) && (defined(__SMARTPHONE__) || defined(__POCKETPC__))
954 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
956 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
961 wxColour
wxWindowBase::GetBackgroundColour() const
963 if ( !m_backgroundColour
.Ok() )
965 wxASSERT_MSG( !m_hasBgCol
, _T("we have invalid explicit bg colour?") );
967 // get our default background colour
968 wxColour colBg
= GetDefaultAttributes().colBg
;
970 // we must return some valid colour to avoid redoing this every time
971 // and also to avoid surprizing the applications written for older
972 // wxWidgets versions where GetBackgroundColour() always returned
973 // something -- so give them something even if it doesn't make sense
974 // for this window (e.g. it has a themed background)
976 colBg
= GetClassDefaultAttributes().colBg
;
981 return m_backgroundColour
;
984 wxColour
wxWindowBase::GetForegroundColour() const
986 // logic is the same as above
987 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
989 wxASSERT_MSG( !m_hasFgCol
, _T("we have invalid explicit fg colour?") );
991 wxColour colFg
= GetDefaultAttributes().colFg
;
994 colFg
= GetClassDefaultAttributes().colFg
;
999 return m_foregroundColour
;
1002 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
1004 if ( colour
== m_backgroundColour
)
1007 m_hasBgCol
= colour
.Ok();
1008 if ( m_backgroundStyle
!= wxBG_STYLE_CUSTOM
)
1009 m_backgroundStyle
= m_hasBgCol
? wxBG_STYLE_COLOUR
: wxBG_STYLE_SYSTEM
;
1011 m_inheritBgCol
= m_hasBgCol
;
1012 m_backgroundColour
= colour
;
1013 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1017 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1019 if (colour
== m_foregroundColour
)
1022 m_hasFgCol
= colour
.Ok();
1023 m_inheritFgCol
= m_hasFgCol
;
1024 m_foregroundColour
= colour
;
1025 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1029 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1031 // setting an invalid cursor is ok, it means that we don't have any special
1033 if ( m_cursor
== cursor
)
1044 wxFont
wxWindowBase::GetFont() const
1046 // logic is the same as in GetBackgroundColour()
1049 wxASSERT_MSG( !m_hasFont
, _T("we have invalid explicit font?") );
1051 wxFont font
= GetDefaultAttributes().font
;
1053 font
= GetClassDefaultAttributes().font
;
1061 bool wxWindowBase::SetFont(const wxFont
& font
)
1063 if ( font
== m_font
)
1070 m_hasFont
= font
.Ok();
1071 m_inheritFont
= m_hasFont
;
1073 InvalidateBestSize();
1080 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1082 m_hasCustomPalette
= true;
1085 // VZ: can anyone explain me what do we do here?
1086 wxWindowDC
d((wxWindow
*) this);
1090 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1092 wxWindow
*win
= (wxWindow
*)this;
1093 while ( win
&& !win
->HasCustomPalette() )
1095 win
= win
->GetParent();
1101 #endif // wxUSE_PALETTE
1104 void wxWindowBase::SetCaret(wxCaret
*caret
)
1115 wxASSERT_MSG( m_caret
->GetWindow() == this,
1116 wxT("caret should be created associated to this window") );
1119 #endif // wxUSE_CARET
1121 #if wxUSE_VALIDATORS
1122 // ----------------------------------------------------------------------------
1124 // ----------------------------------------------------------------------------
1126 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1128 if ( m_windowValidator
)
1129 delete m_windowValidator
;
1131 m_windowValidator
= (wxValidator
*)validator
.Clone();
1133 if ( m_windowValidator
)
1134 m_windowValidator
->SetWindow(this);
1136 #endif // wxUSE_VALIDATORS
1138 // ----------------------------------------------------------------------------
1139 // update region stuff
1140 // ----------------------------------------------------------------------------
1142 wxRect
wxWindowBase::GetUpdateClientRect() const
1144 wxRegion rgnUpdate
= GetUpdateRegion();
1145 rgnUpdate
.Intersect(GetClientRect());
1146 wxRect rectUpdate
= rgnUpdate
.GetBox();
1147 wxPoint ptOrigin
= GetClientAreaOrigin();
1148 rectUpdate
.x
-= ptOrigin
.x
;
1149 rectUpdate
.y
-= ptOrigin
.y
;
1154 bool wxWindowBase::IsExposed(int x
, int y
) const
1156 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1159 bool wxWindowBase::IsExposed(int x
, int y
, int w
, int h
) const
1161 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1164 void wxWindowBase::ClearBackground()
1166 // wxGTK uses its own version, no need to add never used code
1168 wxClientDC
dc((wxWindow
*)this);
1169 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1170 dc
.SetBackground(brush
);
1175 // ----------------------------------------------------------------------------
1176 // find child window by id or name
1177 // ----------------------------------------------------------------------------
1179 wxWindow
*wxWindowBase::FindWindow(long id
) const
1181 if ( id
== m_windowId
)
1182 return (wxWindow
*)this;
1184 wxWindowBase
*res
= (wxWindow
*)NULL
;
1185 wxWindowList::compatibility_iterator node
;
1186 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1188 wxWindowBase
*child
= node
->GetData();
1189 res
= child
->FindWindow( id
);
1192 return (wxWindow
*)res
;
1195 wxWindow
*wxWindowBase::FindWindow(const wxString
& name
) const
1197 if ( name
== m_windowName
)
1198 return (wxWindow
*)this;
1200 wxWindowBase
*res
= (wxWindow
*)NULL
;
1201 wxWindowList::compatibility_iterator node
;
1202 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1204 wxWindow
*child
= node
->GetData();
1205 res
= child
->FindWindow(name
);
1208 return (wxWindow
*)res
;
1212 // find any window by id or name or label: If parent is non-NULL, look through
1213 // children for a label or title matching the specified string. If NULL, look
1214 // through all top-level windows.
1216 // to avoid duplicating code we reuse the same helper function but with
1217 // different comparators
1219 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1220 const wxString
& label
, long id
);
1223 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1226 return win
->GetLabel() == label
;
1230 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1233 return win
->GetName() == label
;
1237 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1240 return win
->GetId() == id
;
1243 // recursive helper for the FindWindowByXXX() functions
1245 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1246 const wxString
& label
,
1248 wxFindWindowCmp cmp
)
1252 // see if this is the one we're looking for
1253 if ( (*cmp
)(parent
, label
, id
) )
1254 return (wxWindow
*)parent
;
1256 // It wasn't, so check all its children
1257 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1259 node
= node
->GetNext() )
1261 // recursively check each child
1262 wxWindow
*win
= (wxWindow
*)node
->GetData();
1263 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1273 // helper for FindWindowByXXX()
1275 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1276 const wxString
& label
,
1278 wxFindWindowCmp cmp
)
1282 // just check parent and all its children
1283 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1286 // start at very top of wx's windows
1287 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1289 node
= node
->GetNext() )
1291 // recursively check each window & its children
1292 wxWindow
*win
= node
->GetData();
1293 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1303 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1305 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1310 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1312 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1316 // fall back to the label
1317 win
= FindWindowByLabel(title
, parent
);
1325 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1327 return wxFindWindowHelper(parent
, wxEmptyString
, id
, wxFindWindowCmpIds
);
1330 // ----------------------------------------------------------------------------
1331 // dialog oriented functions
1332 // ----------------------------------------------------------------------------
1334 void wxWindowBase::MakeModal(bool modal
)
1336 // Disable all other windows
1339 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1342 wxWindow
*win
= node
->GetData();
1344 win
->Enable(!modal
);
1346 node
= node
->GetNext();
1351 bool wxWindowBase::Validate()
1353 #if wxUSE_VALIDATORS
1354 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1356 wxWindowList::compatibility_iterator node
;
1357 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1359 wxWindowBase
*child
= node
->GetData();
1360 wxValidator
*validator
= child
->GetValidator();
1361 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1366 if ( recurse
&& !child
->Validate() )
1371 #endif // wxUSE_VALIDATORS
1376 bool wxWindowBase::TransferDataToWindow()
1378 #if wxUSE_VALIDATORS
1379 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1381 wxWindowList::compatibility_iterator node
;
1382 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1384 wxWindowBase
*child
= node
->GetData();
1385 wxValidator
*validator
= child
->GetValidator();
1386 if ( validator
&& !validator
->TransferToWindow() )
1388 wxLogWarning(_("Could not transfer data to window"));
1390 wxLog::FlushActive();
1398 if ( !child
->TransferDataToWindow() )
1400 // warning already given
1405 #endif // wxUSE_VALIDATORS
1410 bool wxWindowBase::TransferDataFromWindow()
1412 #if wxUSE_VALIDATORS
1413 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1415 wxWindowList::compatibility_iterator node
;
1416 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1418 wxWindow
*child
= node
->GetData();
1419 wxValidator
*validator
= child
->GetValidator();
1420 if ( validator
&& !validator
->TransferFromWindow() )
1422 // nop warning here because the application is supposed to give
1423 // one itself - we don't know here what might have gone wrongly
1430 if ( !child
->TransferDataFromWindow() )
1432 // warning already given
1437 #endif // wxUSE_VALIDATORS
1442 void wxWindowBase::InitDialog()
1444 wxInitDialogEvent
event(GetId());
1445 event
.SetEventObject( this );
1446 GetEventHandler()->ProcessEvent(event
);
1449 // ----------------------------------------------------------------------------
1450 // context-sensitive help support
1451 // ----------------------------------------------------------------------------
1455 // associate this help text with this window
1456 void wxWindowBase::SetHelpText(const wxString
& text
)
1458 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1461 helpProvider
->AddHelp(this, text
);
1465 // associate this help text with all windows with the same id as this
1467 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1469 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1472 helpProvider
->AddHelp(GetId(), text
);
1476 // get the help string associated with this window (may be empty)
1477 wxString
wxWindowBase::GetHelpText() const
1480 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1483 text
= helpProvider
->GetHelp(this);
1489 // show help for this window
1490 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1492 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1495 if ( helpProvider
->ShowHelp(this) )
1497 // skip the event.Skip() below
1505 #endif // wxUSE_HELP
1507 // ----------------------------------------------------------------------------
1508 // tooltipsroot.Replace("\\", "/");
1509 // ----------------------------------------------------------------------------
1513 void wxWindowBase::SetToolTip( const wxString
&tip
)
1515 // don't create the new tooltip if we already have one
1518 m_tooltip
->SetTip( tip
);
1522 SetToolTip( new wxToolTip( tip
) );
1525 // setting empty tooltip text does not remove the tooltip any more - use
1526 // SetToolTip((wxToolTip *)NULL) for this
1529 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1534 m_tooltip
= tooltip
;
1537 #endif // wxUSE_TOOLTIPS
1539 // ----------------------------------------------------------------------------
1540 // constraints and sizers
1541 // ----------------------------------------------------------------------------
1543 #if wxUSE_CONSTRAINTS
1545 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1547 if ( m_constraints
)
1549 UnsetConstraints(m_constraints
);
1550 delete m_constraints
;
1552 m_constraints
= constraints
;
1553 if ( m_constraints
)
1555 // Make sure other windows know they're part of a 'meaningful relationship'
1556 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1557 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1558 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1559 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1560 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1561 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1562 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1563 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1564 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1565 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1566 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1567 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1568 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1569 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1570 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1571 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1575 // This removes any dangling pointers to this window in other windows'
1576 // constraintsInvolvedIn lists.
1577 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1581 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1582 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1583 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1584 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1585 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1586 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1587 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1588 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1589 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1590 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1591 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1592 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1593 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1594 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1595 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1596 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1600 // Back-pointer to other windows we're involved with, so if we delete this
1601 // window, we must delete any constraints we're involved with.
1602 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
1604 if ( !m_constraintsInvolvedIn
)
1605 m_constraintsInvolvedIn
= new wxWindowList
;
1606 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
1607 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
1610 // REMOVE back-pointer to other windows we're involved with.
1611 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
1613 if ( m_constraintsInvolvedIn
)
1614 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
1617 // Reset any constraints that mention this window
1618 void wxWindowBase::DeleteRelatedConstraints()
1620 if ( m_constraintsInvolvedIn
)
1622 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
1625 wxWindow
*win
= node
->GetData();
1626 wxLayoutConstraints
*constr
= win
->GetConstraints();
1628 // Reset any constraints involving this window
1631 constr
->left
.ResetIfWin(this);
1632 constr
->top
.ResetIfWin(this);
1633 constr
->right
.ResetIfWin(this);
1634 constr
->bottom
.ResetIfWin(this);
1635 constr
->width
.ResetIfWin(this);
1636 constr
->height
.ResetIfWin(this);
1637 constr
->centreX
.ResetIfWin(this);
1638 constr
->centreY
.ResetIfWin(this);
1641 wxWindowList::compatibility_iterator next
= node
->GetNext();
1642 m_constraintsInvolvedIn
->Erase(node
);
1646 delete m_constraintsInvolvedIn
;
1647 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
1651 #endif // wxUSE_CONSTRAINTS
1653 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
1655 if ( sizer
== m_windowSizer
)
1659 delete m_windowSizer
;
1661 m_windowSizer
= sizer
;
1663 SetAutoLayout( sizer
!= NULL
);
1666 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
1668 SetSizer( sizer
, deleteOld
);
1669 sizer
->SetSizeHints( (wxWindow
*) this );
1673 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
1675 // adding a window to a sizer twice is going to result in fatal and
1676 // hard to debug problems later because when deleting the second
1677 // associated wxSizerItem we're going to dereference a dangling
1678 // pointer; so try to detect this as early as possible
1679 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
1680 _T("Adding a window to the same sizer twice?") );
1682 m_containingSizer
= sizer
;
1685 #if wxUSE_CONSTRAINTS
1687 void wxWindowBase::SatisfyConstraints()
1689 wxLayoutConstraints
*constr
= GetConstraints();
1690 bool wasOk
= constr
&& constr
->AreSatisfied();
1692 ResetConstraints(); // Mark all constraints as unevaluated
1696 // if we're a top level panel (i.e. our parent is frame/dialog), our
1697 // own constraints will never be satisfied any more unless we do it
1701 while ( noChanges
> 0 )
1703 LayoutPhase1(&noChanges
);
1707 LayoutPhase2(&noChanges
);
1710 #endif // wxUSE_CONSTRAINTS
1712 bool wxWindowBase::Layout()
1714 // If there is a sizer, use it instead of the constraints
1718 GetVirtualSize(&w
, &h
);
1719 GetSizer()->SetDimension( 0, 0, w
, h
);
1721 #if wxUSE_CONSTRAINTS
1724 SatisfyConstraints(); // Find the right constraints values
1725 SetConstraintSizes(); // Recursively set the real window sizes
1732 #if wxUSE_CONSTRAINTS
1734 // first phase of the constraints evaluation: set our own constraints
1735 bool wxWindowBase::LayoutPhase1(int *noChanges
)
1737 wxLayoutConstraints
*constr
= GetConstraints();
1739 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
1742 // second phase: set the constraints for our children
1743 bool wxWindowBase::LayoutPhase2(int *noChanges
)
1750 // Layout grand children
1756 // Do a phase of evaluating child constraints
1757 bool wxWindowBase::DoPhase(int phase
)
1759 // the list containing the children for which the constraints are already
1761 wxWindowList succeeded
;
1763 // the max number of iterations we loop before concluding that we can't set
1765 static const int maxIterations
= 500;
1767 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
1771 // loop over all children setting their constraints
1772 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1774 node
= node
->GetNext() )
1776 wxWindow
*child
= node
->GetData();
1777 if ( child
->IsTopLevel() )
1779 // top level children are not inside our client area
1783 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
1785 // this one is either already ok or nothing we can do about it
1789 int tempNoChanges
= 0;
1790 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
1791 : child
->LayoutPhase2(&tempNoChanges
);
1792 noChanges
+= tempNoChanges
;
1796 succeeded
.Append(child
);
1802 // constraints are set
1810 void wxWindowBase::ResetConstraints()
1812 wxLayoutConstraints
*constr
= GetConstraints();
1815 constr
->left
.SetDone(false);
1816 constr
->top
.SetDone(false);
1817 constr
->right
.SetDone(false);
1818 constr
->bottom
.SetDone(false);
1819 constr
->width
.SetDone(false);
1820 constr
->height
.SetDone(false);
1821 constr
->centreX
.SetDone(false);
1822 constr
->centreY
.SetDone(false);
1825 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1828 wxWindow
*win
= node
->GetData();
1829 if ( !win
->IsTopLevel() )
1830 win
->ResetConstraints();
1831 node
= node
->GetNext();
1835 // Need to distinguish between setting the 'fake' size for windows and sizers,
1836 // and setting the real values.
1837 void wxWindowBase::SetConstraintSizes(bool recurse
)
1839 wxLayoutConstraints
*constr
= GetConstraints();
1840 if ( constr
&& constr
->AreSatisfied() )
1842 int x
= constr
->left
.GetValue();
1843 int y
= constr
->top
.GetValue();
1844 int w
= constr
->width
.GetValue();
1845 int h
= constr
->height
.GetValue();
1847 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
1848 (constr
->height
.GetRelationship() != wxAsIs
) )
1850 SetSize(x
, y
, w
, h
);
1854 // If we don't want to resize this window, just move it...
1860 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
1861 GetClassInfo()->GetClassName(),
1867 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1870 wxWindow
*win
= node
->GetData();
1871 if ( !win
->IsTopLevel() && win
->GetConstraints() )
1872 win
->SetConstraintSizes();
1873 node
= node
->GetNext();
1878 // Only set the size/position of the constraint (if any)
1879 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
1881 wxLayoutConstraints
*constr
= GetConstraints();
1884 if ( x
!= wxDefaultCoord
)
1886 constr
->left
.SetValue(x
);
1887 constr
->left
.SetDone(true);
1889 if ( y
!= wxDefaultCoord
)
1891 constr
->top
.SetValue(y
);
1892 constr
->top
.SetDone(true);
1894 if ( w
!= wxDefaultCoord
)
1896 constr
->width
.SetValue(w
);
1897 constr
->width
.SetDone(true);
1899 if ( h
!= wxDefaultCoord
)
1901 constr
->height
.SetValue(h
);
1902 constr
->height
.SetDone(true);
1907 void wxWindowBase::MoveConstraint(int x
, int y
)
1909 wxLayoutConstraints
*constr
= GetConstraints();
1912 if ( x
!= wxDefaultCoord
)
1914 constr
->left
.SetValue(x
);
1915 constr
->left
.SetDone(true);
1917 if ( y
!= wxDefaultCoord
)
1919 constr
->top
.SetValue(y
);
1920 constr
->top
.SetDone(true);
1925 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
1927 wxLayoutConstraints
*constr
= GetConstraints();
1930 *w
= constr
->width
.GetValue();
1931 *h
= constr
->height
.GetValue();
1937 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
1939 wxLayoutConstraints
*constr
= GetConstraints();
1942 *w
= constr
->width
.GetValue();
1943 *h
= constr
->height
.GetValue();
1946 GetClientSize(w
, h
);
1949 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
1951 wxLayoutConstraints
*constr
= GetConstraints();
1954 *x
= constr
->left
.GetValue();
1955 *y
= constr
->top
.GetValue();
1961 #endif // wxUSE_CONSTRAINTS
1963 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
1965 // don't do it for the dialogs/frames - they float independently of their
1967 if ( !IsTopLevel() )
1969 wxWindow
*parent
= GetParent();
1970 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
1972 wxPoint
pt(parent
->GetClientAreaOrigin());
1979 // ----------------------------------------------------------------------------
1980 // do Update UI processing for child controls
1981 // ----------------------------------------------------------------------------
1983 void wxWindowBase::UpdateWindowUI(long flags
)
1985 wxUpdateUIEvent
event(GetId());
1986 event
.SetEventObject(this);
1988 if ( GetEventHandler()->ProcessEvent(event
) )
1990 DoUpdateWindowUI(event
);
1993 if (flags
& wxUPDATE_UI_RECURSE
)
1995 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1998 wxWindow
* child
= (wxWindow
*) node
->GetData();
1999 child
->UpdateWindowUI(flags
);
2000 node
= node
->GetNext();
2005 // do the window-specific processing after processing the update event
2006 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
2008 if ( event
.GetSetEnabled() )
2009 Enable(event
.GetEnabled());
2011 if ( event
.GetSetShown() )
2012 Show(event
.GetShown());
2016 // call internal idle recursively
2017 // may be obsolete (wait until OnIdle scheme stabilises)
2018 void wxWindowBase::ProcessInternalIdle()
2022 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2025 wxWindow
*child
= node
->GetData();
2026 child
->ProcessInternalIdle();
2027 node
= node
->GetNext();
2032 // ----------------------------------------------------------------------------
2033 // dialog units translations
2034 // ----------------------------------------------------------------------------
2036 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
2038 int charWidth
= GetCharWidth();
2039 int charHeight
= GetCharHeight();
2040 wxPoint pt2
= wxDefaultPosition
;
2041 if (pt
.x
!= wxDefaultCoord
)
2042 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
);
2043 if (pt
.y
!= wxDefaultCoord
)
2044 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2049 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2051 int charWidth
= GetCharWidth();
2052 int charHeight
= GetCharHeight();
2053 wxPoint pt2
= wxDefaultPosition
;
2054 if (pt
.x
!= wxDefaultCoord
)
2055 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2056 if (pt
.y
!= wxDefaultCoord
)
2057 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2062 // ----------------------------------------------------------------------------
2064 // ----------------------------------------------------------------------------
2066 // propagate the colour change event to the subwindows
2067 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2069 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2072 // Only propagate to non-top-level windows
2073 wxWindow
*win
= node
->GetData();
2074 if ( !win
->IsTopLevel() )
2076 wxSysColourChangedEvent event2
;
2077 event
.SetEventObject(win
);
2078 win
->GetEventHandler()->ProcessEvent(event2
);
2081 node
= node
->GetNext();
2087 // the default action is to populate dialog with data when it's created,
2088 // and nudge the UI into displaying itself correctly in case
2089 // we've turned the wxUpdateUIEvents frequency down low.
2090 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2092 TransferDataToWindow();
2094 // Update the UI at this point
2095 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2098 // methods for drawing the sizers in a visible way
2101 static void DrawSizers(wxWindowBase
*win
);
2103 static void DrawBorder(wxWindowBase
*win
, const wxRect
& rect
, bool fill
= false)
2105 wxClientDC
dc((wxWindow
*)win
);
2106 dc
.SetPen(*wxRED_PEN
);
2107 dc
.SetBrush(fill
? wxBrush(*wxRED
, wxCROSSDIAG_HATCH
): *wxTRANSPARENT_BRUSH
);
2108 dc
.DrawRectangle(rect
.Deflate(1, 1));
2111 static void DrawSizer(wxWindowBase
*win
, wxSizer
*sizer
)
2113 const wxSizerItemList
& items
= sizer
->GetChildren();
2114 for ( wxSizerItemList::const_iterator i
= items
.begin(),
2119 wxSizerItem
*item
= *i
;
2120 if ( item
->IsSizer() )
2122 DrawBorder(win
, item
->GetRect().Deflate(2));
2123 DrawSizer(win
, item
->GetSizer());
2125 else if ( item
->IsSpacer() )
2127 DrawBorder(win
, item
->GetRect().Deflate(2), true);
2129 else if ( item
->IsWindow() )
2131 DrawSizers(item
->GetWindow());
2136 static void DrawSizers(wxWindowBase
*win
)
2138 wxSizer
*sizer
= win
->GetSizer();
2141 DrawBorder(win
, win
->GetClientSize());
2142 DrawSizer(win
, sizer
);
2144 else // no sizer, still recurse into the children
2146 const wxWindowList
& children
= win
->GetChildren();
2147 for ( wxWindowList::const_iterator i
= children
.begin(),
2148 end
= children
.end();
2157 #endif // __WXDEBUG__
2159 // process special middle clicks
2160 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2162 if ( event
.ControlDown() && event
.AltDown() )
2165 // Ctrl-Alt-Shift-mclick makes the sizers visible in debug builds
2166 if ( event
.ShiftDown() )
2171 #endif // __WXDEBUG__
2174 // don't translate these strings
2177 #ifdef __WXUNIVERSAL__
2179 #endif // __WXUNIVERSAL__
2181 switch ( wxGetOsVersion() )
2183 case wxMOTIF_X
: port
+= _T("Motif"); break;
2185 case wxMAC_DARWIN
: port
+= _T("Mac"); break;
2186 case wxBEOS
: port
+= _T("BeOS"); break;
2190 case wxGTK_BEOS
: port
+= _T("GTK"); break;
2196 case wxWIN386
: port
+= _T("MS Windows"); break;
2200 case wxMGL_OS2
: port
+= _T("MGL"); break;
2202 case wxOS2_PM
: port
+= _T("OS/2"); break;
2203 case wxPALMOS
: port
+= _T("Palm OS"); break;
2204 case wxWINDOWS_CE
: port
+= _T("Windows CE (generic)"); break;
2205 case wxWINDOWS_POCKETPC
: port
+= _T("Windows CE PocketPC"); break;
2206 case wxWINDOWS_SMARTPHONE
: port
+= _T("Windows CE Smartphone"); break;
2207 default: port
+= _T("unknown"); break;
2210 wxMessageBox(wxString::Format(
2212 " wxWidgets Library (%s port)\nVersion %d.%d.%d%s%s, compiled at %s %s%s\n Copyright (c) 1995-2006 wxWidgets team"
2231 wxString::Format(_T("\nagainst GTK+ %d.%d.%d. Runtime GTK+ version: %d.%d.%d"), GTK_MAJOR_VERSION
, GTK_MINOR_VERSION
, GTK_MICRO_VERSION
, gtk_major_version
, gtk_minor_version
, gtk_micro_version
).c_str()
2236 _T("wxWidgets information"),
2237 wxICON_INFORMATION
| wxOK
,
2241 #endif // wxUSE_MSGDLG
2247 // ----------------------------------------------------------------------------
2249 // ----------------------------------------------------------------------------
2251 #if wxUSE_ACCESSIBILITY
2252 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2254 if (m_accessible
&& (accessible
!= m_accessible
))
2255 delete m_accessible
;
2256 m_accessible
= accessible
;
2258 m_accessible
->SetWindow((wxWindow
*) this);
2261 // Returns the accessible object, creating if necessary.
2262 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2265 m_accessible
= CreateAccessible();
2266 return m_accessible
;
2269 // Override to create a specific accessible object.
2270 wxAccessible
* wxWindowBase::CreateAccessible()
2272 return new wxWindowAccessible((wxWindow
*) this);
2277 // ----------------------------------------------------------------------------
2278 // list classes implementation
2279 // ----------------------------------------------------------------------------
2283 #include "wx/listimpl.cpp"
2284 WX_DEFINE_LIST(wxWindowList
)
2288 void wxWindowListNode::DeleteData()
2290 delete (wxWindow
*)GetData();
2295 // ----------------------------------------------------------------------------
2297 // ----------------------------------------------------------------------------
2299 wxBorder
wxWindowBase::GetBorder(long flags
) const
2301 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2302 if ( border
== wxBORDER_DEFAULT
)
2304 border
= GetDefaultBorder();
2310 wxBorder
wxWindowBase::GetDefaultBorder() const
2312 return wxBORDER_NONE
;
2315 // ----------------------------------------------------------------------------
2317 // ----------------------------------------------------------------------------
2319 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2321 // here we just check if the point is inside the window or not
2323 // check the top and left border first
2324 bool outside
= x
< 0 || y
< 0;
2327 // check the right and bottom borders too
2328 wxSize size
= GetSize();
2329 outside
= x
>= size
.x
|| y
>= size
.y
;
2332 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2335 // ----------------------------------------------------------------------------
2337 // ----------------------------------------------------------------------------
2339 struct WXDLLEXPORT wxWindowNext
2343 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2345 void wxWindowBase::CaptureMouse()
2347 wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), this);
2349 wxWindow
*winOld
= GetCapture();
2352 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2355 wxWindowNext
*item
= new wxWindowNext
;
2357 item
->next
= ms_winCaptureNext
;
2358 ms_winCaptureNext
= item
;
2360 //else: no mouse capture to save
2365 void wxWindowBase::ReleaseMouse()
2367 wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), this);
2369 wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") );
2373 if ( ms_winCaptureNext
)
2375 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2377 wxWindowNext
*item
= ms_winCaptureNext
;
2378 ms_winCaptureNext
= item
->next
;
2381 //else: stack is empty, no previous capture
2383 wxLogTrace(_T("mousecapture"),
2384 (const wxChar
*) _T("After ReleaseMouse() mouse is captured by %p"),
2391 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2392 int WXUNUSED(modifiers
),
2393 int WXUNUSED(keycode
))
2399 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2405 #endif // wxUSE_HOTKEY
2407 void wxWindowBase::SendDestroyEvent()
2409 wxWindowDestroyEvent event
;
2410 event
.SetEventObject(this);
2411 event
.SetId(GetId());
2412 GetEventHandler()->ProcessEvent(event
);
2415 // ----------------------------------------------------------------------------
2417 // ----------------------------------------------------------------------------
2419 bool wxWindowBase::TryValidator(wxEvent
& wxVALIDATOR_PARAM(event
))
2421 #if wxUSE_VALIDATORS
2422 // Can only use the validator of the window which
2423 // is receiving the event
2424 if ( event
.GetEventObject() == this )
2426 wxValidator
*validator
= GetValidator();
2427 if ( validator
&& validator
->ProcessEvent(event
) )
2432 #endif // wxUSE_VALIDATORS
2437 bool wxWindowBase::TryParent(wxEvent
& event
)
2439 // carry on up the parent-child hierarchy if the propagation count hasn't
2441 if ( event
.ShouldPropagate() )
2443 // honour the requests to stop propagation at this window: this is
2444 // used by the dialogs, for example, to prevent processing the events
2445 // from the dialog controls in the parent frame which rarely, if ever,
2447 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2449 wxWindow
*parent
= GetParent();
2450 if ( parent
&& !parent
->IsBeingDeleted() )
2452 wxPropagateOnce
propagateOnce(event
);
2454 return parent
->GetEventHandler()->ProcessEvent(event
);
2459 return wxEvtHandler::TryParent(event
);
2462 // ----------------------------------------------------------------------------
2463 // keyboard navigation
2464 // ----------------------------------------------------------------------------
2466 // Navigates in the specified direction.
2467 bool wxWindowBase::Navigate(int flags
)
2469 wxNavigationKeyEvent eventNav
;
2470 eventNav
.SetFlags(flags
);
2471 eventNav
.SetEventObject(this);
2472 if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav
) )
2479 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, MoveKind move
)
2481 // check that we're not a top level window
2482 wxCHECK_RET( GetParent(),
2483 _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
2485 // detect the special case when we have nothing to do anyhow and when the
2486 // code below wouldn't work
2490 // find the target window in the siblings list
2491 wxWindowList
& siblings
= GetParent()->GetChildren();
2492 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
2493 wxCHECK_RET( i
, _T("MoveBefore/AfterInTabOrder(): win is not a sibling") );
2495 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
2496 // can't just move the node around
2497 wxWindow
*self
= (wxWindow
*)this;
2498 siblings
.DeleteObject(self
);
2499 if ( move
== MoveAfter
)
2506 siblings
.Insert(i
, self
);
2508 else // MoveAfter and win was the last sibling
2510 siblings
.Append(self
);
2514 // ----------------------------------------------------------------------------
2516 // ----------------------------------------------------------------------------
2518 /*static*/ wxWindow
* wxWindowBase::FindFocus()
2520 wxWindowBase
*win
= DoFindFocus();
2521 return win
? win
->GetMainWindowOfCompositeControl() : NULL
;
2524 // ----------------------------------------------------------------------------
2526 // ----------------------------------------------------------------------------
2528 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
2530 while ( win
&& !win
->IsTopLevel() )
2531 win
= win
->GetParent();
2536 #if wxUSE_ACCESSIBILITY
2537 // ----------------------------------------------------------------------------
2538 // accessible object for windows
2539 // ----------------------------------------------------------------------------
2541 // Can return either a child object, or an integer
2542 // representing the child element, starting from 1.
2543 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
2545 wxASSERT( GetWindow() != NULL
);
2549 return wxACC_NOT_IMPLEMENTED
;
2552 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
2553 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
2555 wxASSERT( GetWindow() != NULL
);
2559 wxWindow
* win
= NULL
;
2566 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
2568 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
2575 rect
= win
->GetRect();
2576 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
2577 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
2581 return wxACC_NOT_IMPLEMENTED
;
2584 // Navigates from fromId to toId/toObject.
2585 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
2586 int* WXUNUSED(toId
), wxAccessible
** toObject
)
2588 wxASSERT( GetWindow() != NULL
);
2594 case wxNAVDIR_FIRSTCHILD
:
2596 if (GetWindow()->GetChildren().GetCount() == 0)
2598 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
2599 *toObject
= childWindow
->GetOrCreateAccessible();
2603 case wxNAVDIR_LASTCHILD
:
2605 if (GetWindow()->GetChildren().GetCount() == 0)
2607 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
2608 *toObject
= childWindow
->GetOrCreateAccessible();
2612 case wxNAVDIR_RIGHT
:
2616 wxWindowList::compatibility_iterator node
=
2617 wxWindowList::compatibility_iterator();
2620 // Can't navigate to sibling of this window
2621 // if we're a top-level window.
2622 if (!GetWindow()->GetParent())
2623 return wxACC_NOT_IMPLEMENTED
;
2625 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2629 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2630 node
= GetWindow()->GetChildren().Item(fromId
-1);
2633 if (node
&& node
->GetNext())
2635 wxWindow
* nextWindow
= node
->GetNext()->GetData();
2636 *toObject
= nextWindow
->GetOrCreateAccessible();
2644 case wxNAVDIR_PREVIOUS
:
2646 wxWindowList::compatibility_iterator node
=
2647 wxWindowList::compatibility_iterator();
2650 // Can't navigate to sibling of this window
2651 // if we're a top-level window.
2652 if (!GetWindow()->GetParent())
2653 return wxACC_NOT_IMPLEMENTED
;
2655 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2659 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2660 node
= GetWindow()->GetChildren().Item(fromId
-1);
2663 if (node
&& node
->GetPrevious())
2665 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
2666 *toObject
= previousWindow
->GetOrCreateAccessible();
2674 return wxACC_NOT_IMPLEMENTED
;
2677 // Gets the name of the specified object.
2678 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
2680 wxASSERT( GetWindow() != NULL
);
2686 // If a child, leave wxWidgets to call the function on the actual
2689 return wxACC_NOT_IMPLEMENTED
;
2691 // This will eventually be replaced by specialised
2692 // accessible classes, one for each kind of wxWidgets
2693 // control or window.
2695 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
2696 title
= ((wxButton
*) GetWindow())->GetLabel();
2699 title
= GetWindow()->GetName();
2707 return wxACC_NOT_IMPLEMENTED
;
2710 // Gets the number of children.
2711 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
2713 wxASSERT( GetWindow() != NULL
);
2717 *childId
= (int) GetWindow()->GetChildren().GetCount();
2721 // Gets the specified child (starting from 1).
2722 // If *child is NULL and return value is wxACC_OK,
2723 // this means that the child is a simple element and
2724 // not an accessible object.
2725 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
2727 wxASSERT( GetWindow() != NULL
);
2737 if (childId
> (int) GetWindow()->GetChildren().GetCount())
2740 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
2741 *child
= childWindow
->GetOrCreateAccessible();
2748 // Gets the parent, or NULL.
2749 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
2751 wxASSERT( GetWindow() != NULL
);
2755 wxWindow
* parentWindow
= GetWindow()->GetParent();
2763 *parent
= parentWindow
->GetOrCreateAccessible();
2771 // Performs the default action. childId is 0 (the action for this object)
2772 // or > 0 (the action for a child).
2773 // Return wxACC_NOT_SUPPORTED if there is no default action for this
2774 // window (e.g. an edit control).
2775 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
2777 wxASSERT( GetWindow() != NULL
);
2781 return wxACC_NOT_IMPLEMENTED
;
2784 // Gets the default action for this object (0) or > 0 (the action for a child).
2785 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
2786 // string if there is no action.
2787 // The retrieved string describes the action that is performed on an object,
2788 // not what the object does as a result. For example, a toolbar button that prints
2789 // a document has a default action of "Press" rather than "Prints the current document."
2790 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
2792 wxASSERT( GetWindow() != NULL
);
2796 return wxACC_NOT_IMPLEMENTED
;
2799 // Returns the description for this object or a child.
2800 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
2802 wxASSERT( GetWindow() != NULL
);
2806 wxString
ht(GetWindow()->GetHelpText());
2812 return wxACC_NOT_IMPLEMENTED
;
2815 // Returns help text for this object or a child, similar to tooltip text.
2816 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
2818 wxASSERT( GetWindow() != NULL
);
2822 wxString
ht(GetWindow()->GetHelpText());
2828 return wxACC_NOT_IMPLEMENTED
;
2831 // Returns the keyboard shortcut for this object or child.
2832 // Return e.g. ALT+K
2833 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
2835 wxASSERT( GetWindow() != NULL
);
2839 return wxACC_NOT_IMPLEMENTED
;
2842 // Returns a role constant.
2843 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
2845 wxASSERT( GetWindow() != NULL
);
2849 // If a child, leave wxWidgets to call the function on the actual
2852 return wxACC_NOT_IMPLEMENTED
;
2854 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2855 return wxACC_NOT_IMPLEMENTED
;
2857 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2858 return wxACC_NOT_IMPLEMENTED
;
2861 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2862 return wxACC_NOT_IMPLEMENTED
;
2865 //*role = wxROLE_SYSTEM_CLIENT;
2866 *role
= wxROLE_SYSTEM_CLIENT
;
2870 return wxACC_NOT_IMPLEMENTED
;
2874 // Returns a state constant.
2875 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
2877 wxASSERT( GetWindow() != NULL
);
2881 // If a child, leave wxWidgets to call the function on the actual
2884 return wxACC_NOT_IMPLEMENTED
;
2886 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2887 return wxACC_NOT_IMPLEMENTED
;
2890 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2891 return wxACC_NOT_IMPLEMENTED
;
2894 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2895 return wxACC_NOT_IMPLEMENTED
;
2902 return wxACC_NOT_IMPLEMENTED
;
2906 // Returns a localized string representing the value for the object
2908 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
2910 wxASSERT( GetWindow() != NULL
);
2914 return wxACC_NOT_IMPLEMENTED
;
2917 // Selects the object or child.
2918 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
2920 wxASSERT( GetWindow() != NULL
);
2924 return wxACC_NOT_IMPLEMENTED
;
2927 // Gets the window with the keyboard focus.
2928 // If childId is 0 and child is NULL, no object in
2929 // this subhierarchy has the focus.
2930 // If this object has the focus, child should be 'this'.
2931 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
2933 wxASSERT( GetWindow() != NULL
);
2937 return wxACC_NOT_IMPLEMENTED
;
2940 // Gets a variant representing the selected children
2942 // Acceptable values:
2943 // - a null variant (IsNull() returns true)
2944 // - a list variant (GetType() == wxT("list")
2945 // - an integer representing the selected child element,
2946 // or 0 if this object is selected (GetType() == wxT("long")
2947 // - a "void*" pointer to a wxAccessible child object
2948 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
2950 wxASSERT( GetWindow() != NULL
);
2954 return wxACC_NOT_IMPLEMENTED
;
2957 #endif // wxUSE_ACCESSIBILITY