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"
32 #include "wx/window.h"
33 #include "wx/control.h"
34 #include "wx/checkbox.h"
35 #include "wx/radiobut.h"
36 #include "wx/statbox.h"
37 #include "wx/textctrl.h"
38 #include "wx/settings.h"
39 #include "wx/dialog.h"
40 #include "wx/msgdlg.h"
41 #include "wx/statusbr.h"
42 #include "wx/toolbar.h"
43 #include "wx/dcclient.h"
46 #if defined(__WXMAC__) && wxUSE_SCROLLBAR
47 #include "wx/scrolbar.h"
51 #include "wx/layout.h"
52 #endif // wxUSE_CONSTRAINTS
56 #if wxUSE_DRAG_AND_DROP
58 #endif // wxUSE_DRAG_AND_DROP
60 #if wxUSE_ACCESSIBILITY
61 #include "wx/access.h"
65 #include "wx/cshelp.h"
69 #include "wx/tooltip.h"
70 #endif // wxUSE_TOOLTIPS
76 #if wxUSE_SYSTEM_OPTIONS
77 #include "wx/sysopt.h"
80 // For reporting compile- and runtime version of GTK+ in the ctrl+alt+mclick dialog.
81 // The gtk includes don't pull any other headers in, at least not on my system - MR
84 #include <gtk/gtkversion.h>
86 #include <gtk/gtkfeatures.h>
88 extern const unsigned int gtk_major_version
;
89 extern const unsigned int gtk_minor_version
;
90 extern const unsigned int gtk_micro_version
;
93 // ----------------------------------------------------------------------------
95 // ----------------------------------------------------------------------------
97 #if defined(__WXPALMOS__)
98 int wxWindowBase::ms_lastControlId
= 32767;
99 #elif defined(__WXPM__)
100 int wxWindowBase::ms_lastControlId
= 2000;
102 int wxWindowBase::ms_lastControlId
= -200;
105 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase
, wxEvtHandler
)
107 // ----------------------------------------------------------------------------
109 // ----------------------------------------------------------------------------
111 BEGIN_EVENT_TABLE(wxWindowBase
, wxEvtHandler
)
112 EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged
)
113 EVT_INIT_DIALOG(wxWindowBase::OnInitDialog
)
114 EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick
)
117 EVT_HELP(wxID_ANY
, wxWindowBase::OnHelp
)
122 // ============================================================================
123 // implementation of the common functionality of the wxWindow class
124 // ============================================================================
126 // ----------------------------------------------------------------------------
128 // ----------------------------------------------------------------------------
130 // the default initialization
131 wxWindowBase::wxWindowBase()
133 // no window yet, no parent nor children
134 m_parent
= (wxWindow
*)NULL
;
135 m_windowId
= wxID_ANY
;
137 // no constraints on the minimal window size
139 m_maxWidth
= wxDefaultCoord
;
141 m_maxHeight
= wxDefaultCoord
;
143 // invalidiated cache value
144 m_bestSizeCache
= wxDefaultSize
;
146 // window are created enabled and visible by default
150 // the default event handler is just this window
151 m_eventHandler
= this;
155 m_windowValidator
= (wxValidator
*) NULL
;
156 #endif // wxUSE_VALIDATORS
158 // the colours/fonts are default for now, so leave m_font,
159 // m_backgroundColour and m_foregroundColour uninitialized and set those
165 m_inheritFont
= false;
171 m_backgroundStyle
= wxBG_STYLE_SYSTEM
;
173 #if wxUSE_CONSTRAINTS
174 // no constraints whatsoever
175 m_constraints
= (wxLayoutConstraints
*) NULL
;
176 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
177 #endif // wxUSE_CONSTRAINTS
179 m_windowSizer
= (wxSizer
*) NULL
;
180 m_containingSizer
= (wxSizer
*) NULL
;
181 m_autoLayout
= false;
183 #if wxUSE_DRAG_AND_DROP
184 m_dropTarget
= (wxDropTarget
*)NULL
;
185 #endif // wxUSE_DRAG_AND_DROP
188 m_tooltip
= (wxToolTip
*)NULL
;
189 #endif // wxUSE_TOOLTIPS
192 m_caret
= (wxCaret
*)NULL
;
193 #endif // wxUSE_CARET
196 m_hasCustomPalette
= false;
197 #endif // wxUSE_PALETTE
199 #if wxUSE_ACCESSIBILITY
203 m_virtualSize
= wxDefaultSize
;
206 m_maxVirtualWidth
= wxDefaultCoord
;
208 m_maxVirtualHeight
= wxDefaultCoord
;
210 m_windowVariant
= wxWINDOW_VARIANT_NORMAL
;
211 #if wxUSE_SYSTEM_OPTIONS
212 if ( wxSystemOptions::HasOption(wxWINDOW_DEFAULT_VARIANT
) )
214 m_windowVariant
= (wxWindowVariant
) wxSystemOptions::GetOptionInt( wxWINDOW_DEFAULT_VARIANT
) ;
218 // Whether we're using the current theme for this window (wxGTK only for now)
219 m_themeEnabled
= false;
221 // VZ: this one shouldn't exist...
222 m_isBeingDeleted
= false;
225 // common part of window creation process
226 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
228 const wxPoint
& WXUNUSED(pos
),
229 const wxSize
& WXUNUSED(size
),
231 const wxValidator
& wxVALIDATOR_PARAM(validator
),
232 const wxString
& name
)
235 // wxGTK doesn't allow to create controls with static box as the parent so
236 // this will result in a crash when the program is ported to wxGTK so warn
239 // if you get this assert, the correct solution is to create the controls
240 // as siblings of the static box
241 wxASSERT_MSG( !parent
|| !wxDynamicCast(parent
, wxStaticBox
),
242 _T("wxStaticBox can't be used as a window parent!") );
243 #endif // wxUSE_STATBOX
245 // ids are limited to 16 bits under MSW so if you care about portability,
246 // it's not a good idea to use ids out of this range (and negative ids are
247 // reserved for wxWidgets own usage)
248 wxASSERT_MSG( id
== wxID_ANY
|| (id
>= 0 && id
< 32767),
249 _T("invalid id value") );
251 // generate a new id if the user doesn't care about it
252 m_windowId
= id
== wxID_ANY
? NewControlId() : id
;
255 SetWindowStyleFlag(style
);
259 SetValidator(validator
);
260 #endif // wxUSE_VALIDATORS
262 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
263 // have it too - like this it's possible to set it only in the top level
264 // dialog/frame and all children will inherit it by defult
265 if ( parent
&& (parent
->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) )
267 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY
);
273 // ----------------------------------------------------------------------------
275 // ----------------------------------------------------------------------------
278 wxWindowBase::~wxWindowBase()
280 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
282 // FIXME if these 2 cases result from programming errors in the user code
283 // we should probably assert here instead of silently fixing them
285 // Just in case the window has been Closed, but we're then deleting
286 // immediately: don't leave dangling pointers.
287 wxPendingDelete
.DeleteObject(this);
289 // Just in case we've loaded a top-level window via LoadNativeDialog but
290 // we weren't a dialog class
291 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
293 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
295 // reset the dangling pointer our parent window may keep to us
298 if ( m_parent
->GetDefaultItem() == this )
300 m_parent
->SetDefaultItem(NULL
);
303 m_parent
->RemoveChild(this);
308 #endif // wxUSE_CARET
311 delete m_windowValidator
;
312 #endif // wxUSE_VALIDATORS
314 #if wxUSE_CONSTRAINTS
315 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
316 // at deleted windows as they delete themselves.
317 DeleteRelatedConstraints();
321 // This removes any dangling pointers to this window in other windows'
322 // constraintsInvolvedIn lists.
323 UnsetConstraints(m_constraints
);
324 delete m_constraints
;
325 m_constraints
= NULL
;
327 #endif // wxUSE_CONSTRAINTS
329 if ( m_containingSizer
)
330 m_containingSizer
->Detach( (wxWindow
*)this );
332 delete m_windowSizer
;
334 #if wxUSE_DRAG_AND_DROP
336 #endif // wxUSE_DRAG_AND_DROP
340 #endif // wxUSE_TOOLTIPS
342 #if wxUSE_ACCESSIBILITY
347 bool wxWindowBase::Destroy()
354 bool wxWindowBase::Close(bool force
)
356 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
357 event
.SetEventObject(this);
358 event
.SetCanVeto(!force
);
360 // return false if window wasn't closed because the application vetoed the
362 return GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto();
365 bool wxWindowBase::DestroyChildren()
367 wxWindowList::compatibility_iterator node
;
370 // we iterate until the list becomes empty
371 node
= GetChildren().GetFirst();
375 wxWindow
*child
= node
->GetData();
377 // note that we really want to call delete and not ->Destroy() here
378 // because we want to delete the child immediately, before we are
379 // deleted, and delayed deletion would result in problems as our (top
380 // level) child could outlive its parent
383 wxASSERT_MSG( !GetChildren().Find(child
),
384 wxT("child didn't remove itself using RemoveChild()") );
390 // ----------------------------------------------------------------------------
391 // size/position related methods
392 // ----------------------------------------------------------------------------
394 // centre the window with respect to its parent in either (or both) directions
395 void wxWindowBase::DoCentre(int dir
)
397 wxCHECK_RET( !(dir
& wxCENTRE_ON_SCREEN
) && GetParent(),
398 _T("this method only implements centering child windows") );
400 SetSize(GetRect().CentreIn(GetParent()->GetClientSize(), dir
));
403 // fits the window around the children
404 void wxWindowBase::Fit()
406 if ( !GetChildren().empty() )
408 SetClientSize(GetBestSize());
410 //else: do nothing if we have no children
413 // fits virtual size (ie. scrolled area etc.) around children
414 void wxWindowBase::FitInside()
416 if ( GetChildren().GetCount() > 0 )
418 SetVirtualSize( GetBestVirtualSize() );
422 // On Mac, scrollbars are explicitly children.
424 static bool wxHasRealChildren(const wxWindowBase
* win
)
426 int realChildCount
= 0;
428 for ( wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
430 node
= node
->GetNext() )
432 wxWindow
*win
= node
->GetData();
433 if ( !win
->IsTopLevel() && win
->IsShown() && !win
->IsKindOf(CLASSINFO(wxScrollBar
)))
436 return (realChildCount
> 0);
440 void wxWindowBase::InvalidateBestSize()
442 m_bestSizeCache
= wxDefaultSize
;
444 // parent's best size calculation may depend on its children's
445 // as long as child window we are in is not top level window itself
446 // (because the TLW size is never resized automatically)
447 // so let's invalidate it as well to be safe:
448 if (m_parent
&& !IsTopLevel())
449 m_parent
->InvalidateBestSize();
452 // return the size best suited for the current window
453 wxSize
wxWindowBase::DoGetBestSize() const
459 best
= GetWindowSizeForVirtualSize(m_windowSizer
->GetMinSize());
461 #if wxUSE_CONSTRAINTS
462 else if ( m_constraints
)
464 wxConstCast(this, wxWindowBase
)->SatisfyConstraints();
466 // our minimal acceptable size is such that all our windows fit inside
470 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
472 node
= node
->GetNext() )
474 wxLayoutConstraints
*c
= node
->GetData()->GetConstraints();
477 // it's not normal that we have an unconstrained child, but
478 // what can we do about it?
482 int x
= c
->right
.GetValue(),
483 y
= c
->bottom
.GetValue();
491 // TODO: we must calculate the overlaps somehow, otherwise we
492 // will never return a size bigger than the current one :-(
495 best
= wxSize(maxX
, maxY
);
497 #endif // wxUSE_CONSTRAINTS
498 else if ( !GetChildren().empty()
500 && wxHasRealChildren(this)
504 // our minimal acceptable size is such that all our visible child windows fit inside
508 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
510 node
= node
->GetNext() )
512 wxWindow
*win
= node
->GetData();
513 if ( win
->IsTopLevel() || ( ! win
->IsShown() )
515 || wxDynamicCast(win
, wxStatusBar
)
516 #endif // wxUSE_STATUSBAR
519 // dialogs and frames lie in different top level windows -
520 // don't deal with them here; as for the status bars, they
521 // don't lie in the client area at all
526 win
->GetPosition(&wx
, &wy
);
528 // if the window hadn't been positioned yet, assume that it is in
530 if ( wx
== wxDefaultCoord
)
532 if ( wy
== wxDefaultCoord
)
535 win
->GetSize(&ww
, &wh
);
536 if ( wx
+ ww
> maxX
)
538 if ( wy
+ wh
> maxY
)
542 // for compatibility with the old versions and because it really looks
543 // slightly more pretty like this, add a pad
547 best
= wxSize(maxX
, maxY
);
549 else // ! has children
551 // for a generic window there is no natural best size so, if the
552 // minimal size is not set, use the current size but take care to
553 // remember it as minimal size for the next time because our best size
554 // should be constant: otherwise we could get into a situation when the
555 // window is initially at some size, then expanded to a larger size and
556 // then, when the containing window is shrunk back (because our initial
557 // best size had been used for computing the parent min size), we can't
558 // be shrunk back any more because our best size is now bigger
559 wxSize size
= GetMinSize();
560 if ( !size
.IsFullySpecified() )
562 size
.SetDefaults(GetSize());
563 wxConstCast(this, wxWindowBase
)->SetMinSize(size
);
566 // return as-is, unadjusted by the client size difference.
570 // Add any difference between size and client size
571 wxSize diff
= GetSize() - GetClientSize();
572 best
.x
+= wxMax(0, diff
.x
);
573 best
.y
+= wxMax(0, diff
.y
);
579 wxSize
wxWindowBase::GetBestFittingSize() const
581 // merge the best size with the min size, giving priority to the min size
582 wxSize min
= GetMinSize();
583 if (min
.x
== wxDefaultCoord
|| min
.y
== wxDefaultCoord
)
585 wxSize best
= GetBestSize();
586 if (min
.x
== wxDefaultCoord
) min
.x
= best
.x
;
587 if (min
.y
== wxDefaultCoord
) min
.y
= best
.y
;
593 void wxWindowBase::SetBestFittingSize(const wxSize
& size
)
595 // Set the min size to the size passed in. This will usually either be
596 // wxDefaultSize or the size passed to this window's ctor/Create function.
599 // Merge the size with the best size if needed
600 wxSize best
= GetBestFittingSize();
602 // If the current size doesn't match then change it
603 if (GetSize() != best
)
608 // by default the origin is not shifted
609 wxPoint
wxWindowBase::GetClientAreaOrigin() const
614 // set the min/max size of the window
615 void wxWindowBase::DoSetSizeHints(int minW
, int minH
,
617 int WXUNUSED(incW
), int WXUNUSED(incH
))
619 // setting min width greater than max width leads to infinite loops under
620 // X11 and generally doesn't make any sense, so don't allow it
621 wxCHECK_RET( (minW
== wxDefaultCoord
|| maxW
== wxDefaultCoord
|| minW
<= maxW
) &&
622 (minH
== wxDefaultCoord
|| maxH
== wxDefaultCoord
|| minH
<= maxH
),
623 _T("min width/height must be less than max width/height!") );
631 void wxWindowBase::SetWindowVariant( wxWindowVariant variant
)
633 if ( m_windowVariant
!= variant
)
635 m_windowVariant
= variant
;
637 DoSetWindowVariant(variant
);
641 void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant
)
643 // adjust the font height to correspond to our new variant (notice that
644 // we're only called if something really changed)
645 wxFont font
= GetFont();
646 int size
= font
.GetPointSize();
649 case wxWINDOW_VARIANT_NORMAL
:
652 case wxWINDOW_VARIANT_SMALL
:
657 case wxWINDOW_VARIANT_MINI
:
662 case wxWINDOW_VARIANT_LARGE
:
668 wxFAIL_MSG(_T("unexpected window variant"));
672 font
.SetPointSize(size
);
676 void wxWindowBase::SetVirtualSizeHints( int minW
, int minH
,
679 m_minVirtualWidth
= minW
;
680 m_maxVirtualWidth
= maxW
;
681 m_minVirtualHeight
= minH
;
682 m_maxVirtualHeight
= maxH
;
685 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
687 if ( m_minVirtualWidth
!= wxDefaultCoord
&& m_minVirtualWidth
> x
)
688 x
= m_minVirtualWidth
;
689 if ( m_maxVirtualWidth
!= wxDefaultCoord
&& m_maxVirtualWidth
< x
)
690 x
= m_maxVirtualWidth
;
691 if ( m_minVirtualHeight
!= wxDefaultCoord
&& m_minVirtualHeight
> y
)
692 y
= m_minVirtualHeight
;
693 if ( m_maxVirtualHeight
!= wxDefaultCoord
&& m_maxVirtualHeight
< y
)
694 y
= m_maxVirtualHeight
;
696 m_virtualSize
= wxSize(x
, y
);
699 wxSize
wxWindowBase::DoGetVirtualSize() const
701 // we should use the entire client area so if it is greater than our
702 // virtual size, expand it to fit (otherwise if the window is big enough we
703 // wouldn't be using parts of it)
704 wxSize size
= GetClientSize();
705 if ( m_virtualSize
.x
> size
.x
)
706 size
.x
= m_virtualSize
.x
;
708 if ( m_virtualSize
.y
>= size
.y
)
709 size
.y
= m_virtualSize
.y
;
714 void wxWindowBase::DoGetScreenPosition(int *x
, int *y
) const
716 // screen position is the same as (0, 0) in client coords for non TLWs (and
717 // TLWs override this method)
723 ClientToScreen(x
, y
);
726 // ----------------------------------------------------------------------------
727 // show/hide/enable/disable the window
728 // ----------------------------------------------------------------------------
730 bool wxWindowBase::Show(bool show
)
732 if ( show
!= m_isShown
)
744 bool wxWindowBase::Enable(bool enable
)
746 if ( enable
!= m_isEnabled
)
748 m_isEnabled
= enable
;
757 // ----------------------------------------------------------------------------
759 // ----------------------------------------------------------------------------
761 bool wxWindowBase::IsTopLevel() const
766 // ----------------------------------------------------------------------------
767 // reparenting the window
768 // ----------------------------------------------------------------------------
770 void wxWindowBase::AddChild(wxWindowBase
*child
)
772 wxCHECK_RET( child
, wxT("can't add a NULL child") );
774 // this should never happen and it will lead to a crash later if it does
775 // because RemoveChild() will remove only one node from the children list
776 // and the other(s) one(s) will be left with dangling pointers in them
777 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), _T("AddChild() called twice") );
779 GetChildren().Append((wxWindow
*)child
);
780 child
->SetParent(this);
783 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
785 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
787 GetChildren().DeleteObject((wxWindow
*)child
);
788 child
->SetParent(NULL
);
791 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
793 wxWindow
*oldParent
= GetParent();
794 if ( newParent
== oldParent
)
800 // unlink this window from the existing parent.
803 oldParent
->RemoveChild(this);
807 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
810 // add it to the new one
813 newParent
->AddChild(this);
817 wxTopLevelWindows
.Append((wxWindow
*)this);
823 // ----------------------------------------------------------------------------
824 // event handler stuff
825 // ----------------------------------------------------------------------------
827 void wxWindowBase::PushEventHandler(wxEvtHandler
*handler
)
829 wxEvtHandler
*handlerOld
= GetEventHandler();
831 handler
->SetNextHandler(handlerOld
);
834 GetEventHandler()->SetPreviousHandler(handler
);
836 SetEventHandler(handler
);
839 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
841 wxEvtHandler
*handlerA
= GetEventHandler();
844 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
845 handlerA
->SetNextHandler((wxEvtHandler
*)NULL
);
848 handlerB
->SetPreviousHandler((wxEvtHandler
*)NULL
);
849 SetEventHandler(handlerB
);
854 handlerA
= (wxEvtHandler
*)NULL
;
861 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handler
)
863 wxCHECK_MSG( handler
, false, _T("RemoveEventHandler(NULL) called") );
865 wxEvtHandler
*handlerPrev
= NULL
,
866 *handlerCur
= GetEventHandler();
869 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
871 if ( handlerCur
== handler
)
875 handlerPrev
->SetNextHandler(handlerNext
);
879 SetEventHandler(handlerNext
);
884 handlerNext
->SetPreviousHandler ( handlerPrev
);
887 handler
->SetNextHandler(NULL
);
888 handler
->SetPreviousHandler(NULL
);
893 handlerPrev
= handlerCur
;
894 handlerCur
= handlerNext
;
897 wxFAIL_MSG( _T("where has the event handler gone?") );
902 // ----------------------------------------------------------------------------
904 // ----------------------------------------------------------------------------
906 void wxWindowBase::InheritAttributes()
908 const wxWindowBase
* const parent
= GetParent();
912 // we only inherit attributes which had been explicitly set for the parent
913 // which ensures that this only happens if the user really wants it and
914 // not by default which wouldn't make any sense in modern GUIs where the
915 // controls don't all use the same fonts (nor colours)
916 if ( parent
->m_inheritFont
&& !m_hasFont
)
917 SetFont(parent
->GetFont());
919 // in addition, there is a possibility to explicitly forbid inheriting
920 // colours at each class level by overriding ShouldInheritColours()
921 if ( ShouldInheritColours() )
923 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
924 SetForegroundColour(parent
->GetForegroundColour());
926 // inheriting (solid) background colour is wrong as it totally breaks
927 // any kind of themed backgrounds
929 // instead, the controls should use the same background as their parent
930 // (ideally by not drawing it at all)
932 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
933 SetBackgroundColour(parent
->GetBackgroundColour());
938 /* static */ wxVisualAttributes
939 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
941 // it is important to return valid values for all attributes from here,
942 // GetXXX() below rely on this
943 wxVisualAttributes attrs
;
944 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
945 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
947 // On Smartphone/PocketPC, wxSYS_COLOUR_WINDOW is a better reflection of
948 // the usual background colour than wxSYS_COLOUR_BTNFACE.
949 // It's a pity that wxSYS_COLOUR_WINDOW isn't always a suitable background
950 // colour on other platforms.
952 #if defined(__WXWINCE__) && (defined(__SMARTPHONE__) || defined(__POCKETPC__))
953 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
955 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
960 wxColour
wxWindowBase::GetBackgroundColour() const
962 if ( !m_backgroundColour
.Ok() )
964 wxASSERT_MSG( !m_hasBgCol
, _T("we have invalid explicit bg colour?") );
966 // get our default background colour
967 wxColour colBg
= GetDefaultAttributes().colBg
;
969 // we must return some valid colour to avoid redoing this every time
970 // and also to avoid surprizing the applications written for older
971 // wxWidgets versions where GetBackgroundColour() always returned
972 // something -- so give them something even if it doesn't make sense
973 // for this window (e.g. it has a themed background)
975 colBg
= GetClassDefaultAttributes().colBg
;
980 return m_backgroundColour
;
983 wxColour
wxWindowBase::GetForegroundColour() const
985 // logic is the same as above
986 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
988 wxASSERT_MSG( !m_hasFgCol
, _T("we have invalid explicit fg colour?") );
990 wxColour colFg
= GetDefaultAttributes().colFg
;
993 colFg
= GetClassDefaultAttributes().colFg
;
998 return m_foregroundColour
;
1001 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
1003 if ( colour
== m_backgroundColour
)
1006 m_hasBgCol
= colour
.Ok();
1007 if ( m_backgroundStyle
!= wxBG_STYLE_CUSTOM
)
1008 m_backgroundStyle
= m_hasBgCol
? wxBG_STYLE_COLOUR
: wxBG_STYLE_SYSTEM
;
1010 m_inheritBgCol
= m_hasBgCol
;
1011 m_backgroundColour
= colour
;
1012 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1016 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1018 if (colour
== m_foregroundColour
)
1021 m_hasFgCol
= colour
.Ok();
1022 m_inheritFgCol
= m_hasFgCol
;
1023 m_foregroundColour
= colour
;
1024 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1028 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1030 // setting an invalid cursor is ok, it means that we don't have any special
1032 if ( m_cursor
== cursor
)
1043 wxFont
wxWindowBase::GetFont() const
1045 // logic is the same as in GetBackgroundColour()
1048 wxASSERT_MSG( !m_hasFont
, _T("we have invalid explicit font?") );
1050 wxFont font
= GetDefaultAttributes().font
;
1052 font
= GetClassDefaultAttributes().font
;
1060 bool wxWindowBase::SetFont(const wxFont
& font
)
1062 if ( font
== m_font
)
1069 m_hasFont
= font
.Ok();
1070 m_inheritFont
= m_hasFont
;
1072 InvalidateBestSize();
1079 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1081 m_hasCustomPalette
= true;
1084 // VZ: can anyone explain me what do we do here?
1085 wxWindowDC
d((wxWindow
*) this);
1089 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1091 wxWindow
*win
= (wxWindow
*)this;
1092 while ( win
&& !win
->HasCustomPalette() )
1094 win
= win
->GetParent();
1100 #endif // wxUSE_PALETTE
1103 void wxWindowBase::SetCaret(wxCaret
*caret
)
1114 wxASSERT_MSG( m_caret
->GetWindow() == this,
1115 wxT("caret should be created associated to this window") );
1118 #endif // wxUSE_CARET
1120 #if wxUSE_VALIDATORS
1121 // ----------------------------------------------------------------------------
1123 // ----------------------------------------------------------------------------
1125 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1127 if ( m_windowValidator
)
1128 delete m_windowValidator
;
1130 m_windowValidator
= (wxValidator
*)validator
.Clone();
1132 if ( m_windowValidator
)
1133 m_windowValidator
->SetWindow(this);
1135 #endif // wxUSE_VALIDATORS
1137 // ----------------------------------------------------------------------------
1138 // update region stuff
1139 // ----------------------------------------------------------------------------
1141 wxRect
wxWindowBase::GetUpdateClientRect() const
1143 wxRegion rgnUpdate
= GetUpdateRegion();
1144 rgnUpdate
.Intersect(GetClientRect());
1145 wxRect rectUpdate
= rgnUpdate
.GetBox();
1146 wxPoint ptOrigin
= GetClientAreaOrigin();
1147 rectUpdate
.x
-= ptOrigin
.x
;
1148 rectUpdate
.y
-= ptOrigin
.y
;
1153 bool wxWindowBase::IsExposed(int x
, int y
) const
1155 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1158 bool wxWindowBase::IsExposed(int x
, int y
, int w
, int h
) const
1160 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1163 void wxWindowBase::ClearBackground()
1165 // wxGTK uses its own version, no need to add never used code
1167 wxClientDC
dc((wxWindow
*)this);
1168 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1169 dc
.SetBackground(brush
);
1174 // ----------------------------------------------------------------------------
1175 // find child window by id or name
1176 // ----------------------------------------------------------------------------
1178 wxWindow
*wxWindowBase::FindWindow(long id
) const
1180 if ( id
== m_windowId
)
1181 return (wxWindow
*)this;
1183 wxWindowBase
*res
= (wxWindow
*)NULL
;
1184 wxWindowList::compatibility_iterator node
;
1185 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1187 wxWindowBase
*child
= node
->GetData();
1188 res
= child
->FindWindow( id
);
1191 return (wxWindow
*)res
;
1194 wxWindow
*wxWindowBase::FindWindow(const wxString
& name
) const
1196 if ( name
== m_windowName
)
1197 return (wxWindow
*)this;
1199 wxWindowBase
*res
= (wxWindow
*)NULL
;
1200 wxWindowList::compatibility_iterator node
;
1201 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1203 wxWindow
*child
= node
->GetData();
1204 res
= child
->FindWindow(name
);
1207 return (wxWindow
*)res
;
1211 // find any window by id or name or label: If parent is non-NULL, look through
1212 // children for a label or title matching the specified string. If NULL, look
1213 // through all top-level windows.
1215 // to avoid duplicating code we reuse the same helper function but with
1216 // different comparators
1218 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1219 const wxString
& label
, long id
);
1222 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1225 return win
->GetLabel() == label
;
1229 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1232 return win
->GetName() == label
;
1236 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1239 return win
->GetId() == id
;
1242 // recursive helper for the FindWindowByXXX() functions
1244 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1245 const wxString
& label
,
1247 wxFindWindowCmp cmp
)
1251 // see if this is the one we're looking for
1252 if ( (*cmp
)(parent
, label
, id
) )
1253 return (wxWindow
*)parent
;
1255 // It wasn't, so check all its children
1256 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1258 node
= node
->GetNext() )
1260 // recursively check each child
1261 wxWindow
*win
= (wxWindow
*)node
->GetData();
1262 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1272 // helper for FindWindowByXXX()
1274 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1275 const wxString
& label
,
1277 wxFindWindowCmp cmp
)
1281 // just check parent and all its children
1282 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1285 // start at very top of wx's windows
1286 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1288 node
= node
->GetNext() )
1290 // recursively check each window & its children
1291 wxWindow
*win
= node
->GetData();
1292 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1302 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1304 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1309 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1311 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1315 // fall back to the label
1316 win
= FindWindowByLabel(title
, parent
);
1324 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1326 return wxFindWindowHelper(parent
, wxEmptyString
, id
, wxFindWindowCmpIds
);
1329 // ----------------------------------------------------------------------------
1330 // dialog oriented functions
1331 // ----------------------------------------------------------------------------
1333 void wxWindowBase::MakeModal(bool modal
)
1335 // Disable all other windows
1338 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1341 wxWindow
*win
= node
->GetData();
1343 win
->Enable(!modal
);
1345 node
= node
->GetNext();
1350 bool wxWindowBase::Validate()
1352 #if wxUSE_VALIDATORS
1353 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1355 wxWindowList::compatibility_iterator node
;
1356 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1358 wxWindowBase
*child
= node
->GetData();
1359 wxValidator
*validator
= child
->GetValidator();
1360 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1365 if ( recurse
&& !child
->Validate() )
1370 #endif // wxUSE_VALIDATORS
1375 bool wxWindowBase::TransferDataToWindow()
1377 #if wxUSE_VALIDATORS
1378 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1380 wxWindowList::compatibility_iterator node
;
1381 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1383 wxWindowBase
*child
= node
->GetData();
1384 wxValidator
*validator
= child
->GetValidator();
1385 if ( validator
&& !validator
->TransferToWindow() )
1387 wxLogWarning(_("Could not transfer data to window"));
1389 wxLog::FlushActive();
1397 if ( !child
->TransferDataToWindow() )
1399 // warning already given
1404 #endif // wxUSE_VALIDATORS
1409 bool wxWindowBase::TransferDataFromWindow()
1411 #if wxUSE_VALIDATORS
1412 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1414 wxWindowList::compatibility_iterator node
;
1415 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1417 wxWindow
*child
= node
->GetData();
1418 wxValidator
*validator
= child
->GetValidator();
1419 if ( validator
&& !validator
->TransferFromWindow() )
1421 // nop warning here because the application is supposed to give
1422 // one itself - we don't know here what might have gone wrongly
1429 if ( !child
->TransferDataFromWindow() )
1431 // warning already given
1436 #endif // wxUSE_VALIDATORS
1441 void wxWindowBase::InitDialog()
1443 wxInitDialogEvent
event(GetId());
1444 event
.SetEventObject( this );
1445 GetEventHandler()->ProcessEvent(event
);
1448 // ----------------------------------------------------------------------------
1449 // context-sensitive help support
1450 // ----------------------------------------------------------------------------
1454 // associate this help text with this window
1455 void wxWindowBase::SetHelpText(const wxString
& text
)
1457 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1460 helpProvider
->AddHelp(this, text
);
1464 // associate this help text with all windows with the same id as this
1466 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1468 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1471 helpProvider
->AddHelp(GetId(), text
);
1475 // get the help string associated with this window (may be empty)
1476 wxString
wxWindowBase::GetHelpText() const
1479 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1482 text
= helpProvider
->GetHelp(this);
1488 // show help for this window
1489 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1491 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1494 if ( helpProvider
->ShowHelp(this) )
1496 // skip the event.Skip() below
1504 #endif // wxUSE_HELP
1506 // ----------------------------------------------------------------------------
1507 // tooltipsroot.Replace("\\", "/");
1508 // ----------------------------------------------------------------------------
1512 void wxWindowBase::SetToolTip( const wxString
&tip
)
1514 // don't create the new tooltip if we already have one
1517 m_tooltip
->SetTip( tip
);
1521 SetToolTip( new wxToolTip( tip
) );
1524 // setting empty tooltip text does not remove the tooltip any more - use
1525 // SetToolTip((wxToolTip *)NULL) for this
1528 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1530 if ( m_tooltip
!= tooltip
)
1535 m_tooltip
= tooltip
;
1539 #endif // wxUSE_TOOLTIPS
1541 // ----------------------------------------------------------------------------
1542 // constraints and sizers
1543 // ----------------------------------------------------------------------------
1545 #if wxUSE_CONSTRAINTS
1547 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1549 if ( m_constraints
)
1551 UnsetConstraints(m_constraints
);
1552 delete m_constraints
;
1554 m_constraints
= constraints
;
1555 if ( m_constraints
)
1557 // Make sure other windows know they're part of a 'meaningful relationship'
1558 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1559 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1560 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1561 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1562 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1563 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1564 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1565 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1566 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1567 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1568 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1569 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1570 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1571 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1572 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1573 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1577 // This removes any dangling pointers to this window in other windows'
1578 // constraintsInvolvedIn lists.
1579 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1583 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1584 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1585 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1586 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1587 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1588 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1589 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1590 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1591 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1592 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1593 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1594 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1595 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1596 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1597 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1598 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1602 // Back-pointer to other windows we're involved with, so if we delete this
1603 // window, we must delete any constraints we're involved with.
1604 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
1606 if ( !m_constraintsInvolvedIn
)
1607 m_constraintsInvolvedIn
= new wxWindowList
;
1608 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
1609 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
1612 // REMOVE back-pointer to other windows we're involved with.
1613 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
1615 if ( m_constraintsInvolvedIn
)
1616 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
1619 // Reset any constraints that mention this window
1620 void wxWindowBase::DeleteRelatedConstraints()
1622 if ( m_constraintsInvolvedIn
)
1624 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
1627 wxWindow
*win
= node
->GetData();
1628 wxLayoutConstraints
*constr
= win
->GetConstraints();
1630 // Reset any constraints involving this window
1633 constr
->left
.ResetIfWin(this);
1634 constr
->top
.ResetIfWin(this);
1635 constr
->right
.ResetIfWin(this);
1636 constr
->bottom
.ResetIfWin(this);
1637 constr
->width
.ResetIfWin(this);
1638 constr
->height
.ResetIfWin(this);
1639 constr
->centreX
.ResetIfWin(this);
1640 constr
->centreY
.ResetIfWin(this);
1643 wxWindowList::compatibility_iterator next
= node
->GetNext();
1644 m_constraintsInvolvedIn
->Erase(node
);
1648 delete m_constraintsInvolvedIn
;
1649 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
1653 #endif // wxUSE_CONSTRAINTS
1655 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
1657 if ( sizer
== m_windowSizer
)
1661 delete m_windowSizer
;
1663 m_windowSizer
= sizer
;
1665 SetAutoLayout( sizer
!= NULL
);
1668 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
1670 SetSizer( sizer
, deleteOld
);
1671 sizer
->SetSizeHints( (wxWindow
*) this );
1675 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
1677 // adding a window to a sizer twice is going to result in fatal and
1678 // hard to debug problems later because when deleting the second
1679 // associated wxSizerItem we're going to dereference a dangling
1680 // pointer; so try to detect this as early as possible
1681 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
1682 _T("Adding a window to the same sizer twice?") );
1684 m_containingSizer
= sizer
;
1687 #if wxUSE_CONSTRAINTS
1689 void wxWindowBase::SatisfyConstraints()
1691 wxLayoutConstraints
*constr
= GetConstraints();
1692 bool wasOk
= constr
&& constr
->AreSatisfied();
1694 ResetConstraints(); // Mark all constraints as unevaluated
1698 // if we're a top level panel (i.e. our parent is frame/dialog), our
1699 // own constraints will never be satisfied any more unless we do it
1703 while ( noChanges
> 0 )
1705 LayoutPhase1(&noChanges
);
1709 LayoutPhase2(&noChanges
);
1712 #endif // wxUSE_CONSTRAINTS
1714 bool wxWindowBase::Layout()
1716 // If there is a sizer, use it instead of the constraints
1720 GetVirtualSize(&w
, &h
);
1721 GetSizer()->SetDimension( 0, 0, w
, h
);
1723 #if wxUSE_CONSTRAINTS
1726 SatisfyConstraints(); // Find the right constraints values
1727 SetConstraintSizes(); // Recursively set the real window sizes
1734 #if wxUSE_CONSTRAINTS
1736 // first phase of the constraints evaluation: set our own constraints
1737 bool wxWindowBase::LayoutPhase1(int *noChanges
)
1739 wxLayoutConstraints
*constr
= GetConstraints();
1741 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
1744 // second phase: set the constraints for our children
1745 bool wxWindowBase::LayoutPhase2(int *noChanges
)
1752 // Layout grand children
1758 // Do a phase of evaluating child constraints
1759 bool wxWindowBase::DoPhase(int phase
)
1761 // the list containing the children for which the constraints are already
1763 wxWindowList succeeded
;
1765 // the max number of iterations we loop before concluding that we can't set
1767 static const int maxIterations
= 500;
1769 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
1773 // loop over all children setting their constraints
1774 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1776 node
= node
->GetNext() )
1778 wxWindow
*child
= node
->GetData();
1779 if ( child
->IsTopLevel() )
1781 // top level children are not inside our client area
1785 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
1787 // this one is either already ok or nothing we can do about it
1791 int tempNoChanges
= 0;
1792 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
1793 : child
->LayoutPhase2(&tempNoChanges
);
1794 noChanges
+= tempNoChanges
;
1798 succeeded
.Append(child
);
1804 // constraints are set
1812 void wxWindowBase::ResetConstraints()
1814 wxLayoutConstraints
*constr
= GetConstraints();
1817 constr
->left
.SetDone(false);
1818 constr
->top
.SetDone(false);
1819 constr
->right
.SetDone(false);
1820 constr
->bottom
.SetDone(false);
1821 constr
->width
.SetDone(false);
1822 constr
->height
.SetDone(false);
1823 constr
->centreX
.SetDone(false);
1824 constr
->centreY
.SetDone(false);
1827 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1830 wxWindow
*win
= node
->GetData();
1831 if ( !win
->IsTopLevel() )
1832 win
->ResetConstraints();
1833 node
= node
->GetNext();
1837 // Need to distinguish between setting the 'fake' size for windows and sizers,
1838 // and setting the real values.
1839 void wxWindowBase::SetConstraintSizes(bool recurse
)
1841 wxLayoutConstraints
*constr
= GetConstraints();
1842 if ( constr
&& constr
->AreSatisfied() )
1844 int x
= constr
->left
.GetValue();
1845 int y
= constr
->top
.GetValue();
1846 int w
= constr
->width
.GetValue();
1847 int h
= constr
->height
.GetValue();
1849 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
1850 (constr
->height
.GetRelationship() != wxAsIs
) )
1852 SetSize(x
, y
, w
, h
);
1856 // If we don't want to resize this window, just move it...
1862 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
1863 GetClassInfo()->GetClassName(),
1869 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1872 wxWindow
*win
= node
->GetData();
1873 if ( !win
->IsTopLevel() && win
->GetConstraints() )
1874 win
->SetConstraintSizes();
1875 node
= node
->GetNext();
1880 // Only set the size/position of the constraint (if any)
1881 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
1883 wxLayoutConstraints
*constr
= GetConstraints();
1886 if ( x
!= wxDefaultCoord
)
1888 constr
->left
.SetValue(x
);
1889 constr
->left
.SetDone(true);
1891 if ( y
!= wxDefaultCoord
)
1893 constr
->top
.SetValue(y
);
1894 constr
->top
.SetDone(true);
1896 if ( w
!= wxDefaultCoord
)
1898 constr
->width
.SetValue(w
);
1899 constr
->width
.SetDone(true);
1901 if ( h
!= wxDefaultCoord
)
1903 constr
->height
.SetValue(h
);
1904 constr
->height
.SetDone(true);
1909 void wxWindowBase::MoveConstraint(int x
, int y
)
1911 wxLayoutConstraints
*constr
= GetConstraints();
1914 if ( x
!= wxDefaultCoord
)
1916 constr
->left
.SetValue(x
);
1917 constr
->left
.SetDone(true);
1919 if ( y
!= wxDefaultCoord
)
1921 constr
->top
.SetValue(y
);
1922 constr
->top
.SetDone(true);
1927 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
1929 wxLayoutConstraints
*constr
= GetConstraints();
1932 *w
= constr
->width
.GetValue();
1933 *h
= constr
->height
.GetValue();
1939 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
1941 wxLayoutConstraints
*constr
= GetConstraints();
1944 *w
= constr
->width
.GetValue();
1945 *h
= constr
->height
.GetValue();
1948 GetClientSize(w
, h
);
1951 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
1953 wxLayoutConstraints
*constr
= GetConstraints();
1956 *x
= constr
->left
.GetValue();
1957 *y
= constr
->top
.GetValue();
1963 #endif // wxUSE_CONSTRAINTS
1965 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
1967 // don't do it for the dialogs/frames - they float independently of their
1969 if ( !IsTopLevel() )
1971 wxWindow
*parent
= GetParent();
1972 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
1974 wxPoint
pt(parent
->GetClientAreaOrigin());
1981 // ----------------------------------------------------------------------------
1982 // do Update UI processing for child controls
1983 // ----------------------------------------------------------------------------
1985 void wxWindowBase::UpdateWindowUI(long flags
)
1987 wxUpdateUIEvent
event(GetId());
1988 event
.SetEventObject(this);
1990 if ( GetEventHandler()->ProcessEvent(event
) )
1992 DoUpdateWindowUI(event
);
1995 if (flags
& wxUPDATE_UI_RECURSE
)
1997 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2000 wxWindow
* child
= (wxWindow
*) node
->GetData();
2001 child
->UpdateWindowUI(flags
);
2002 node
= node
->GetNext();
2007 // do the window-specific processing after processing the update event
2008 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
2010 if ( event
.GetSetEnabled() )
2011 Enable(event
.GetEnabled());
2013 if ( event
.GetSetShown() )
2014 Show(event
.GetShown());
2018 // call internal idle recursively
2019 // may be obsolete (wait until OnIdle scheme stabilises)
2020 void wxWindowBase::ProcessInternalIdle()
2024 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2027 wxWindow
*child
= node
->GetData();
2028 child
->ProcessInternalIdle();
2029 node
= node
->GetNext();
2034 // ----------------------------------------------------------------------------
2035 // dialog units translations
2036 // ----------------------------------------------------------------------------
2038 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
2040 int charWidth
= GetCharWidth();
2041 int charHeight
= GetCharHeight();
2042 wxPoint pt2
= wxDefaultPosition
;
2043 if (pt
.x
!= wxDefaultCoord
)
2044 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
);
2045 if (pt
.y
!= wxDefaultCoord
)
2046 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2051 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2053 int charWidth
= GetCharWidth();
2054 int charHeight
= GetCharHeight();
2055 wxPoint pt2
= wxDefaultPosition
;
2056 if (pt
.x
!= wxDefaultCoord
)
2057 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2058 if (pt
.y
!= wxDefaultCoord
)
2059 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2064 // ----------------------------------------------------------------------------
2066 // ----------------------------------------------------------------------------
2068 // propagate the colour change event to the subwindows
2069 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2071 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2074 // Only propagate to non-top-level windows
2075 wxWindow
*win
= node
->GetData();
2076 if ( !win
->IsTopLevel() )
2078 wxSysColourChangedEvent event2
;
2079 event
.SetEventObject(win
);
2080 win
->GetEventHandler()->ProcessEvent(event2
);
2083 node
= node
->GetNext();
2089 // the default action is to populate dialog with data when it's created,
2090 // and nudge the UI into displaying itself correctly in case
2091 // we've turned the wxUpdateUIEvents frequency down low.
2092 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2094 TransferDataToWindow();
2096 // Update the UI at this point
2097 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2100 // methods for drawing the sizers in a visible way
2103 static void DrawSizers(wxWindowBase
*win
);
2105 static void DrawBorder(wxWindowBase
*win
, const wxRect
& rect
, bool fill
= false)
2107 wxClientDC
dc((wxWindow
*)win
);
2108 dc
.SetPen(*wxRED_PEN
);
2109 dc
.SetBrush(fill
? wxBrush(*wxRED
, wxCROSSDIAG_HATCH
): *wxTRANSPARENT_BRUSH
);
2110 dc
.DrawRectangle(rect
.Deflate(1, 1));
2113 static void DrawSizer(wxWindowBase
*win
, wxSizer
*sizer
)
2115 const wxSizerItemList
& items
= sizer
->GetChildren();
2116 for ( wxSizerItemList::const_iterator i
= items
.begin(),
2121 wxSizerItem
*item
= *i
;
2122 if ( item
->IsSizer() )
2124 DrawBorder(win
, item
->GetRect().Deflate(2));
2125 DrawSizer(win
, item
->GetSizer());
2127 else if ( item
->IsSpacer() )
2129 DrawBorder(win
, item
->GetRect().Deflate(2), true);
2131 else if ( item
->IsWindow() )
2133 DrawSizers(item
->GetWindow());
2138 static void DrawSizers(wxWindowBase
*win
)
2140 wxSizer
*sizer
= win
->GetSizer();
2143 DrawBorder(win
, win
->GetClientSize());
2144 DrawSizer(win
, sizer
);
2146 else // no sizer, still recurse into the children
2148 const wxWindowList
& children
= win
->GetChildren();
2149 for ( wxWindowList::const_iterator i
= children
.begin(),
2150 end
= children
.end();
2159 #endif // __WXDEBUG__
2161 // process special middle clicks
2162 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2164 if ( event
.ControlDown() && event
.AltDown() )
2167 // Ctrl-Alt-Shift-mclick makes the sizers visible in debug builds
2168 if ( event
.ShiftDown() )
2173 #endif // __WXDEBUG__
2176 // don't translate these strings
2179 #ifdef __WXUNIVERSAL__
2181 #endif // __WXUNIVERSAL__
2183 switch ( wxGetOsVersion() )
2185 case wxMOTIF_X
: port
+= _T("Motif"); break;
2187 case wxMAC_DARWIN
: port
+= _T("Mac"); break;
2188 case wxBEOS
: port
+= _T("BeOS"); break;
2192 case wxGTK_BEOS
: port
+= _T("GTK"); break;
2198 case wxWIN386
: port
+= _T("MS Windows"); break;
2202 case wxMGL_OS2
: port
+= _T("MGL"); break;
2204 case wxOS2_PM
: port
+= _T("OS/2"); break;
2205 case wxPALMOS
: port
+= _T("Palm OS"); break;
2206 case wxWINDOWS_CE
: port
+= _T("Windows CE (generic)"); break;
2207 case wxWINDOWS_POCKETPC
: port
+= _T("Windows CE PocketPC"); break;
2208 case wxWINDOWS_SMARTPHONE
: port
+= _T("Windows CE Smartphone"); break;
2209 default: port
+= _T("unknown"); break;
2212 wxMessageBox(wxString::Format(
2214 " wxWidgets Library (%s port)\nVersion %d.%d.%d%s%s, compiled at %s %s%s\n Copyright (c) 1995-2006 wxWidgets team"
2233 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()
2238 _T("wxWidgets information"),
2239 wxICON_INFORMATION
| wxOK
,
2243 #endif // wxUSE_MSGDLG
2249 // ----------------------------------------------------------------------------
2251 // ----------------------------------------------------------------------------
2253 #if wxUSE_ACCESSIBILITY
2254 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2256 if (m_accessible
&& (accessible
!= m_accessible
))
2257 delete m_accessible
;
2258 m_accessible
= accessible
;
2260 m_accessible
->SetWindow((wxWindow
*) this);
2263 // Returns the accessible object, creating if necessary.
2264 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2267 m_accessible
= CreateAccessible();
2268 return m_accessible
;
2271 // Override to create a specific accessible object.
2272 wxAccessible
* wxWindowBase::CreateAccessible()
2274 return new wxWindowAccessible((wxWindow
*) this);
2279 // ----------------------------------------------------------------------------
2280 // list classes implementation
2281 // ----------------------------------------------------------------------------
2285 #include "wx/listimpl.cpp"
2286 WX_DEFINE_LIST(wxWindowList
)
2290 void wxWindowListNode::DeleteData()
2292 delete (wxWindow
*)GetData();
2297 // ----------------------------------------------------------------------------
2299 // ----------------------------------------------------------------------------
2301 wxBorder
wxWindowBase::GetBorder(long flags
) const
2303 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2304 if ( border
== wxBORDER_DEFAULT
)
2306 border
= GetDefaultBorder();
2312 wxBorder
wxWindowBase::GetDefaultBorder() const
2314 return wxBORDER_NONE
;
2317 // ----------------------------------------------------------------------------
2319 // ----------------------------------------------------------------------------
2321 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2323 // here we just check if the point is inside the window or not
2325 // check the top and left border first
2326 bool outside
= x
< 0 || y
< 0;
2329 // check the right and bottom borders too
2330 wxSize size
= GetSize();
2331 outside
= x
>= size
.x
|| y
>= size
.y
;
2334 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2337 // ----------------------------------------------------------------------------
2339 // ----------------------------------------------------------------------------
2341 struct WXDLLEXPORT wxWindowNext
2345 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2347 void wxWindowBase::CaptureMouse()
2349 wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), this);
2351 wxWindow
*winOld
= GetCapture();
2354 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2357 wxWindowNext
*item
= new wxWindowNext
;
2359 item
->next
= ms_winCaptureNext
;
2360 ms_winCaptureNext
= item
;
2362 //else: no mouse capture to save
2367 void wxWindowBase::ReleaseMouse()
2369 wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), this);
2371 wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") );
2375 if ( ms_winCaptureNext
)
2377 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2379 wxWindowNext
*item
= ms_winCaptureNext
;
2380 ms_winCaptureNext
= item
->next
;
2383 //else: stack is empty, no previous capture
2385 wxLogTrace(_T("mousecapture"),
2386 (const wxChar
*) _T("After ReleaseMouse() mouse is captured by %p"),
2393 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2394 int WXUNUSED(modifiers
),
2395 int WXUNUSED(keycode
))
2401 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2407 #endif // wxUSE_HOTKEY
2409 void wxWindowBase::SendDestroyEvent()
2411 wxWindowDestroyEvent event
;
2412 event
.SetEventObject(this);
2413 event
.SetId(GetId());
2414 GetEventHandler()->ProcessEvent(event
);
2417 // ----------------------------------------------------------------------------
2419 // ----------------------------------------------------------------------------
2421 bool wxWindowBase::TryValidator(wxEvent
& wxVALIDATOR_PARAM(event
))
2423 #if wxUSE_VALIDATORS
2424 // Can only use the validator of the window which
2425 // is receiving the event
2426 if ( event
.GetEventObject() == this )
2428 wxValidator
*validator
= GetValidator();
2429 if ( validator
&& validator
->ProcessEvent(event
) )
2434 #endif // wxUSE_VALIDATORS
2439 bool wxWindowBase::TryParent(wxEvent
& event
)
2441 // carry on up the parent-child hierarchy if the propagation count hasn't
2443 if ( event
.ShouldPropagate() )
2445 // honour the requests to stop propagation at this window: this is
2446 // used by the dialogs, for example, to prevent processing the events
2447 // from the dialog controls in the parent frame which rarely, if ever,
2449 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2451 wxWindow
*parent
= GetParent();
2452 if ( parent
&& !parent
->IsBeingDeleted() )
2454 wxPropagateOnce
propagateOnce(event
);
2456 return parent
->GetEventHandler()->ProcessEvent(event
);
2461 return wxEvtHandler::TryParent(event
);
2464 // ----------------------------------------------------------------------------
2465 // keyboard navigation
2466 // ----------------------------------------------------------------------------
2468 // Navigates in the specified direction.
2469 bool wxWindowBase::Navigate(int flags
)
2471 wxNavigationKeyEvent eventNav
;
2472 eventNav
.SetFlags(flags
);
2473 eventNav
.SetEventObject(this);
2474 if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav
) )
2481 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, MoveKind move
)
2483 // check that we're not a top level window
2484 wxCHECK_RET( GetParent(),
2485 _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
2487 // detect the special case when we have nothing to do anyhow and when the
2488 // code below wouldn't work
2492 // find the target window in the siblings list
2493 wxWindowList
& siblings
= GetParent()->GetChildren();
2494 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
2495 wxCHECK_RET( i
, _T("MoveBefore/AfterInTabOrder(): win is not a sibling") );
2497 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
2498 // can't just move the node around
2499 wxWindow
*self
= (wxWindow
*)this;
2500 siblings
.DeleteObject(self
);
2501 if ( move
== MoveAfter
)
2508 siblings
.Insert(i
, self
);
2510 else // MoveAfter and win was the last sibling
2512 siblings
.Append(self
);
2516 // ----------------------------------------------------------------------------
2518 // ----------------------------------------------------------------------------
2520 /*static*/ wxWindow
* wxWindowBase::FindFocus()
2522 wxWindowBase
*win
= DoFindFocus();
2523 return win
? win
->GetMainWindowOfCompositeControl() : NULL
;
2526 // ----------------------------------------------------------------------------
2528 // ----------------------------------------------------------------------------
2530 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
2532 while ( win
&& !win
->IsTopLevel() )
2533 win
= win
->GetParent();
2538 #if wxUSE_ACCESSIBILITY
2539 // ----------------------------------------------------------------------------
2540 // accessible object for windows
2541 // ----------------------------------------------------------------------------
2543 // Can return either a child object, or an integer
2544 // representing the child element, starting from 1.
2545 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
2547 wxASSERT( GetWindow() != NULL
);
2551 return wxACC_NOT_IMPLEMENTED
;
2554 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
2555 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
2557 wxASSERT( GetWindow() != NULL
);
2561 wxWindow
* win
= NULL
;
2568 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
2570 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
2577 rect
= win
->GetRect();
2578 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
2579 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
2583 return wxACC_NOT_IMPLEMENTED
;
2586 // Navigates from fromId to toId/toObject.
2587 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
2588 int* WXUNUSED(toId
), wxAccessible
** toObject
)
2590 wxASSERT( GetWindow() != NULL
);
2596 case wxNAVDIR_FIRSTCHILD
:
2598 if (GetWindow()->GetChildren().GetCount() == 0)
2600 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
2601 *toObject
= childWindow
->GetOrCreateAccessible();
2605 case wxNAVDIR_LASTCHILD
:
2607 if (GetWindow()->GetChildren().GetCount() == 0)
2609 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
2610 *toObject
= childWindow
->GetOrCreateAccessible();
2614 case wxNAVDIR_RIGHT
:
2618 wxWindowList::compatibility_iterator node
=
2619 wxWindowList::compatibility_iterator();
2622 // Can't navigate to sibling of this window
2623 // if we're a top-level window.
2624 if (!GetWindow()->GetParent())
2625 return wxACC_NOT_IMPLEMENTED
;
2627 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2631 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2632 node
= GetWindow()->GetChildren().Item(fromId
-1);
2635 if (node
&& node
->GetNext())
2637 wxWindow
* nextWindow
= node
->GetNext()->GetData();
2638 *toObject
= nextWindow
->GetOrCreateAccessible();
2646 case wxNAVDIR_PREVIOUS
:
2648 wxWindowList::compatibility_iterator node
=
2649 wxWindowList::compatibility_iterator();
2652 // Can't navigate to sibling of this window
2653 // if we're a top-level window.
2654 if (!GetWindow()->GetParent())
2655 return wxACC_NOT_IMPLEMENTED
;
2657 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2661 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2662 node
= GetWindow()->GetChildren().Item(fromId
-1);
2665 if (node
&& node
->GetPrevious())
2667 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
2668 *toObject
= previousWindow
->GetOrCreateAccessible();
2676 return wxACC_NOT_IMPLEMENTED
;
2679 // Gets the name of the specified object.
2680 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
2682 wxASSERT( GetWindow() != NULL
);
2688 // If a child, leave wxWidgets to call the function on the actual
2691 return wxACC_NOT_IMPLEMENTED
;
2693 // This will eventually be replaced by specialised
2694 // accessible classes, one for each kind of wxWidgets
2695 // control or window.
2697 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
2698 title
= ((wxButton
*) GetWindow())->GetLabel();
2701 title
= GetWindow()->GetName();
2709 return wxACC_NOT_IMPLEMENTED
;
2712 // Gets the number of children.
2713 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
2715 wxASSERT( GetWindow() != NULL
);
2719 *childId
= (int) GetWindow()->GetChildren().GetCount();
2723 // Gets the specified child (starting from 1).
2724 // If *child is NULL and return value is wxACC_OK,
2725 // this means that the child is a simple element and
2726 // not an accessible object.
2727 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
2729 wxASSERT( GetWindow() != NULL
);
2739 if (childId
> (int) GetWindow()->GetChildren().GetCount())
2742 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
2743 *child
= childWindow
->GetOrCreateAccessible();
2750 // Gets the parent, or NULL.
2751 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
2753 wxASSERT( GetWindow() != NULL
);
2757 wxWindow
* parentWindow
= GetWindow()->GetParent();
2765 *parent
= parentWindow
->GetOrCreateAccessible();
2773 // Performs the default action. childId is 0 (the action for this object)
2774 // or > 0 (the action for a child).
2775 // Return wxACC_NOT_SUPPORTED if there is no default action for this
2776 // window (e.g. an edit control).
2777 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
2779 wxASSERT( GetWindow() != NULL
);
2783 return wxACC_NOT_IMPLEMENTED
;
2786 // Gets the default action for this object (0) or > 0 (the action for a child).
2787 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
2788 // string if there is no action.
2789 // The retrieved string describes the action that is performed on an object,
2790 // not what the object does as a result. For example, a toolbar button that prints
2791 // a document has a default action of "Press" rather than "Prints the current document."
2792 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
2794 wxASSERT( GetWindow() != NULL
);
2798 return wxACC_NOT_IMPLEMENTED
;
2801 // Returns the description for this object or a child.
2802 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
2804 wxASSERT( GetWindow() != NULL
);
2808 wxString
ht(GetWindow()->GetHelpText());
2814 return wxACC_NOT_IMPLEMENTED
;
2817 // Returns help text for this object or a child, similar to tooltip text.
2818 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
2820 wxASSERT( GetWindow() != NULL
);
2824 wxString
ht(GetWindow()->GetHelpText());
2830 return wxACC_NOT_IMPLEMENTED
;
2833 // Returns the keyboard shortcut for this object or child.
2834 // Return e.g. ALT+K
2835 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
2837 wxASSERT( GetWindow() != NULL
);
2841 return wxACC_NOT_IMPLEMENTED
;
2844 // Returns a role constant.
2845 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
2847 wxASSERT( GetWindow() != NULL
);
2851 // If a child, leave wxWidgets to call the function on the actual
2854 return wxACC_NOT_IMPLEMENTED
;
2856 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2857 return wxACC_NOT_IMPLEMENTED
;
2859 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2860 return wxACC_NOT_IMPLEMENTED
;
2863 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2864 return wxACC_NOT_IMPLEMENTED
;
2867 //*role = wxROLE_SYSTEM_CLIENT;
2868 *role
= wxROLE_SYSTEM_CLIENT
;
2872 return wxACC_NOT_IMPLEMENTED
;
2876 // Returns a state constant.
2877 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
2879 wxASSERT( GetWindow() != NULL
);
2883 // If a child, leave wxWidgets to call the function on the actual
2886 return wxACC_NOT_IMPLEMENTED
;
2888 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2889 return wxACC_NOT_IMPLEMENTED
;
2892 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2893 return wxACC_NOT_IMPLEMENTED
;
2896 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2897 return wxACC_NOT_IMPLEMENTED
;
2904 return wxACC_NOT_IMPLEMENTED
;
2908 // Returns a localized string representing the value for the object
2910 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
2912 wxASSERT( GetWindow() != NULL
);
2916 return wxACC_NOT_IMPLEMENTED
;
2919 // Selects the object or child.
2920 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
2922 wxASSERT( GetWindow() != NULL
);
2926 return wxACC_NOT_IMPLEMENTED
;
2929 // Gets the window with the keyboard focus.
2930 // If childId is 0 and child is NULL, no object in
2931 // this subhierarchy has the focus.
2932 // If this object has the focus, child should be 'this'.
2933 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
2935 wxASSERT( GetWindow() != NULL
);
2939 return wxACC_NOT_IMPLEMENTED
;
2942 // Gets a variant representing the selected children
2944 // Acceptable values:
2945 // - a null variant (IsNull() returns true)
2946 // - a list variant (GetType() == wxT("list")
2947 // - an integer representing the selected child element,
2948 // or 0 if this object is selected (GetType() == wxT("long")
2949 // - a "void*" pointer to a wxAccessible child object
2950 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
2952 wxASSERT( GetWindow() != NULL
);
2956 return wxACC_NOT_IMPLEMENTED
;
2959 #endif // wxUSE_ACCESSIBILITY