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;
225 // Reserved for future use
226 m_windowReserved
= NULL
;
229 // common part of window creation process
230 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
232 const wxPoint
& WXUNUSED(pos
),
233 const wxSize
& WXUNUSED(size
),
235 const wxValidator
& wxVALIDATOR_PARAM(validator
),
236 const wxString
& name
)
239 // wxGTK doesn't allow to create controls with static box as the parent so
240 // this will result in a crash when the program is ported to wxGTK so warn
243 // if you get this assert, the correct solution is to create the controls
244 // as siblings of the static box
245 wxASSERT_MSG( !parent
|| !wxDynamicCast(parent
, wxStaticBox
),
246 _T("wxStaticBox can't be used as a window parent!") );
247 #endif // wxUSE_STATBOX
249 // ids are limited to 16 bits under MSW so if you care about portability,
250 // it's not a good idea to use ids out of this range (and negative ids are
251 // reserved for wxWidgets own usage)
252 wxASSERT_MSG( id
== wxID_ANY
|| (id
>= 0 && id
< 32767),
253 _T("invalid id value") );
255 // generate a new id if the user doesn't care about it
256 m_windowId
= id
== wxID_ANY
? NewControlId() : id
;
259 SetWindowStyleFlag(style
);
263 SetValidator(validator
);
264 #endif // wxUSE_VALIDATORS
266 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
267 // have it too - like this it's possible to set it only in the top level
268 // dialog/frame and all children will inherit it by defult
269 if ( parent
&& (parent
->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) )
271 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY
);
277 // ----------------------------------------------------------------------------
279 // ----------------------------------------------------------------------------
282 wxWindowBase::~wxWindowBase()
284 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
286 // FIXME if these 2 cases result from programming errors in the user code
287 // we should probably assert here instead of silently fixing them
289 // Just in case the window has been Closed, but we're then deleting
290 // immediately: don't leave dangling pointers.
291 wxPendingDelete
.DeleteObject(this);
293 // Just in case we've loaded a top-level window via LoadNativeDialog but
294 // we weren't a dialog class
295 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
297 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
299 // reset the dangling pointer our parent window may keep to us
302 if ( m_parent
->GetDefaultItem() == this )
304 m_parent
->SetDefaultItem(NULL
);
307 m_parent
->RemoveChild(this);
312 #endif // wxUSE_CARET
315 delete m_windowValidator
;
316 #endif // wxUSE_VALIDATORS
318 #if wxUSE_CONSTRAINTS
319 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
320 // at deleted windows as they delete themselves.
321 DeleteRelatedConstraints();
325 // This removes any dangling pointers to this window in other windows'
326 // constraintsInvolvedIn lists.
327 UnsetConstraints(m_constraints
);
328 delete m_constraints
;
329 m_constraints
= NULL
;
331 #endif // wxUSE_CONSTRAINTS
333 if ( m_containingSizer
)
334 m_containingSizer
->Detach( (wxWindow
*)this );
336 delete m_windowSizer
;
338 #if wxUSE_DRAG_AND_DROP
340 #endif // wxUSE_DRAG_AND_DROP
344 #endif // wxUSE_TOOLTIPS
346 #if wxUSE_ACCESSIBILITY
351 bool wxWindowBase::Destroy()
358 bool wxWindowBase::Close(bool force
)
360 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
361 event
.SetEventObject(this);
362 event
.SetCanVeto(!force
);
364 // return false if window wasn't closed because the application vetoed the
366 return GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto();
369 bool wxWindowBase::DestroyChildren()
371 wxWindowList::compatibility_iterator node
;
374 // we iterate until the list becomes empty
375 node
= GetChildren().GetFirst();
379 wxWindow
*child
= node
->GetData();
381 // note that we really want to call delete and not ->Destroy() here
382 // because we want to delete the child immediately, before we are
383 // deleted, and delayed deletion would result in problems as our (top
384 // level) child could outlive its parent
387 wxASSERT_MSG( !GetChildren().Find(child
),
388 wxT("child didn't remove itself using RemoveChild()") );
394 // ----------------------------------------------------------------------------
395 // size/position related methods
396 // ----------------------------------------------------------------------------
398 // centre the window with respect to its parent in either (or both) directions
399 void wxWindowBase::DoCentre(int dir
)
401 wxCHECK_RET( !(dir
& wxCENTRE_ON_SCREEN
) && GetParent(),
402 _T("this method only implements centering child windows") );
404 SetSize(GetRect().CentreIn(GetParent()->GetClientSize(), dir
));
407 // fits the window around the children
408 void wxWindowBase::Fit()
410 if ( !GetChildren().empty() )
412 SetClientSize(GetBestSize());
414 //else: do nothing if we have no children
417 // fits virtual size (ie. scrolled area etc.) around children
418 void wxWindowBase::FitInside()
420 if ( GetChildren().GetCount() > 0 )
422 SetVirtualSize( GetBestVirtualSize() );
426 // On Mac, scrollbars are explicitly children.
428 static bool wxHasRealChildren(const wxWindowBase
* win
)
430 int realChildCount
= 0;
432 for ( wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
434 node
= node
->GetNext() )
436 wxWindow
*win
= node
->GetData();
437 if ( !win
->IsTopLevel() && win
->IsShown() && !win
->IsKindOf(CLASSINFO(wxScrollBar
)))
440 return (realChildCount
> 0);
444 void wxWindowBase::InvalidateBestSize()
446 m_bestSizeCache
= wxDefaultSize
;
448 // parent's best size calculation may depend on its children's
449 // as long as child window we are in is not top level window itself
450 // (because the TLW size is never resized automatically)
451 // so let's invalidate it as well to be safe:
452 if (m_parent
&& !IsTopLevel())
453 m_parent
->InvalidateBestSize();
456 // return the size best suited for the current window
457 wxSize
wxWindowBase::DoGetBestSize() const
463 best
= GetWindowSizeForVirtualSize(m_windowSizer
->GetMinSize());
465 #if wxUSE_CONSTRAINTS
466 else if ( m_constraints
)
468 wxConstCast(this, wxWindowBase
)->SatisfyConstraints();
470 // our minimal acceptable size is such that all our windows fit inside
474 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
476 node
= node
->GetNext() )
478 wxLayoutConstraints
*c
= node
->GetData()->GetConstraints();
481 // it's not normal that we have an unconstrained child, but
482 // what can we do about it?
486 int x
= c
->right
.GetValue(),
487 y
= c
->bottom
.GetValue();
495 // TODO: we must calculate the overlaps somehow, otherwise we
496 // will never return a size bigger than the current one :-(
499 best
= wxSize(maxX
, maxY
);
501 #endif // wxUSE_CONSTRAINTS
502 else if ( !GetChildren().empty()
504 && wxHasRealChildren(this)
508 // our minimal acceptable size is such that all our visible child windows fit inside
512 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
514 node
= node
->GetNext() )
516 wxWindow
*win
= node
->GetData();
517 if ( win
->IsTopLevel() || ( ! win
->IsShown() )
519 || wxDynamicCast(win
, wxStatusBar
)
520 #endif // wxUSE_STATUSBAR
523 // dialogs and frames lie in different top level windows -
524 // don't deal with them here; as for the status bars, they
525 // don't lie in the client area at all
530 win
->GetPosition(&wx
, &wy
);
532 // if the window hadn't been positioned yet, assume that it is in
534 if ( wx
== wxDefaultCoord
)
536 if ( wy
== wxDefaultCoord
)
539 win
->GetSize(&ww
, &wh
);
540 if ( wx
+ ww
> maxX
)
542 if ( wy
+ wh
> maxY
)
546 // for compatibility with the old versions and because it really looks
547 // slightly more pretty like this, add a pad
551 best
= wxSize(maxX
, maxY
);
553 else // ! has children
555 // for a generic window there is no natural best size so, if the
556 // minimal size is not set, use the current size but take care to
557 // remember it as minimal size for the next time because our best size
558 // should be constant: otherwise we could get into a situation when the
559 // window is initially at some size, then expanded to a larger size and
560 // then, when the containing window is shrunk back (because our initial
561 // best size had been used for computing the parent min size), we can't
562 // be shrunk back any more because our best size is now bigger
563 wxSize size
= GetMinSize();
564 if ( !size
.IsFullySpecified() )
566 size
.SetDefaults(GetSize());
567 wxConstCast(this, wxWindowBase
)->SetMinSize(size
);
570 // return as-is, unadjusted by the client size difference.
574 // Add any difference between size and client size
575 wxSize diff
= GetSize() - GetClientSize();
576 best
.x
+= wxMax(0, diff
.x
);
577 best
.y
+= wxMax(0, diff
.y
);
583 wxSize
wxWindowBase::GetBestFittingSize() const
585 // merge the best size with the min size, giving priority to the min size
586 wxSize min
= GetMinSize();
587 if (min
.x
== wxDefaultCoord
|| min
.y
== wxDefaultCoord
)
589 wxSize best
= GetBestSize();
590 if (min
.x
== wxDefaultCoord
) min
.x
= best
.x
;
591 if (min
.y
== wxDefaultCoord
) min
.y
= best
.y
;
597 void wxWindowBase::SetBestFittingSize(const wxSize
& size
)
599 // Set the min size to the size passed in. This will usually either be
600 // wxDefaultSize or the size passed to this window's ctor/Create function.
603 // Merge the size with the best size if needed
604 wxSize best
= GetBestFittingSize();
606 // If the current size doesn't match then change it
607 if (GetSize() != best
)
612 // by default the origin is not shifted
613 wxPoint
wxWindowBase::GetClientAreaOrigin() const
618 // set the min/max size of the window
619 void wxWindowBase::DoSetSizeHints(int minW
, int minH
,
621 int WXUNUSED(incW
), int WXUNUSED(incH
))
623 // setting min width greater than max width leads to infinite loops under
624 // X11 and generally doesn't make any sense, so don't allow it
625 wxCHECK_RET( (minW
== wxDefaultCoord
|| maxW
== wxDefaultCoord
|| minW
<= maxW
) &&
626 (minH
== wxDefaultCoord
|| maxH
== wxDefaultCoord
|| minH
<= maxH
),
627 _T("min width/height must be less than max width/height!") );
635 void wxWindowBase::SetWindowVariant( wxWindowVariant variant
)
637 if ( m_windowVariant
!= variant
)
639 m_windowVariant
= variant
;
641 DoSetWindowVariant(variant
);
645 void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant
)
647 // adjust the font height to correspond to our new variant (notice that
648 // we're only called if something really changed)
649 wxFont font
= GetFont();
650 int size
= font
.GetPointSize();
653 case wxWINDOW_VARIANT_NORMAL
:
656 case wxWINDOW_VARIANT_SMALL
:
661 case wxWINDOW_VARIANT_MINI
:
666 case wxWINDOW_VARIANT_LARGE
:
672 wxFAIL_MSG(_T("unexpected window variant"));
676 font
.SetPointSize(size
);
680 void wxWindowBase::SetVirtualSizeHints( int minW
, int minH
,
683 m_minVirtualWidth
= minW
;
684 m_maxVirtualWidth
= maxW
;
685 m_minVirtualHeight
= minH
;
686 m_maxVirtualHeight
= maxH
;
689 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
691 if ( m_minVirtualWidth
!= wxDefaultCoord
&& m_minVirtualWidth
> x
)
692 x
= m_minVirtualWidth
;
693 if ( m_maxVirtualWidth
!= wxDefaultCoord
&& m_maxVirtualWidth
< x
)
694 x
= m_maxVirtualWidth
;
695 if ( m_minVirtualHeight
!= wxDefaultCoord
&& m_minVirtualHeight
> y
)
696 y
= m_minVirtualHeight
;
697 if ( m_maxVirtualHeight
!= wxDefaultCoord
&& m_maxVirtualHeight
< y
)
698 y
= m_maxVirtualHeight
;
700 m_virtualSize
= wxSize(x
, y
);
703 wxSize
wxWindowBase::DoGetVirtualSize() const
705 // we should use the entire client area so if it is greater than our
706 // virtual size, expand it to fit (otherwise if the window is big enough we
707 // wouldn't be using parts of it)
708 wxSize size
= GetClientSize();
709 if ( m_virtualSize
.x
> size
.x
)
710 size
.x
= m_virtualSize
.x
;
712 if ( m_virtualSize
.y
>= size
.y
)
713 size
.y
= m_virtualSize
.y
;
718 void wxWindowBase::DoGetScreenPosition(int *x
, int *y
) const
720 // screen position is the same as (0, 0) in client coords for non TLWs (and
721 // TLWs override this method)
727 return ClientToScreen(x
, y
);
730 // ----------------------------------------------------------------------------
731 // show/hide/enable/disable the window
732 // ----------------------------------------------------------------------------
734 bool wxWindowBase::Show(bool show
)
736 if ( show
!= m_isShown
)
748 bool wxWindowBase::Enable(bool enable
)
750 if ( enable
!= m_isEnabled
)
752 m_isEnabled
= enable
;
761 // ----------------------------------------------------------------------------
763 // ----------------------------------------------------------------------------
765 bool wxWindowBase::IsTopLevel() const
770 // ----------------------------------------------------------------------------
771 // reparenting the window
772 // ----------------------------------------------------------------------------
774 void wxWindowBase::AddChild(wxWindowBase
*child
)
776 wxCHECK_RET( child
, wxT("can't add a NULL child") );
778 // this should never happen and it will lead to a crash later if it does
779 // because RemoveChild() will remove only one node from the children list
780 // and the other(s) one(s) will be left with dangling pointers in them
781 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), _T("AddChild() called twice") );
783 GetChildren().Append((wxWindow
*)child
);
784 child
->SetParent(this);
787 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
789 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
791 GetChildren().DeleteObject((wxWindow
*)child
);
792 child
->SetParent(NULL
);
795 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
797 wxWindow
*oldParent
= GetParent();
798 if ( newParent
== oldParent
)
804 // unlink this window from the existing parent.
807 oldParent
->RemoveChild(this);
811 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
814 // add it to the new one
817 newParent
->AddChild(this);
821 wxTopLevelWindows
.Append((wxWindow
*)this);
827 // ----------------------------------------------------------------------------
828 // event handler stuff
829 // ----------------------------------------------------------------------------
831 void wxWindowBase::PushEventHandler(wxEvtHandler
*handler
)
833 wxEvtHandler
*handlerOld
= GetEventHandler();
835 handler
->SetNextHandler(handlerOld
);
838 GetEventHandler()->SetPreviousHandler(handler
);
840 SetEventHandler(handler
);
843 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
845 wxEvtHandler
*handlerA
= GetEventHandler();
848 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
849 handlerA
->SetNextHandler((wxEvtHandler
*)NULL
);
852 handlerB
->SetPreviousHandler((wxEvtHandler
*)NULL
);
853 SetEventHandler(handlerB
);
858 handlerA
= (wxEvtHandler
*)NULL
;
865 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handler
)
867 wxCHECK_MSG( handler
, false, _T("RemoveEventHandler(NULL) called") );
869 wxEvtHandler
*handlerPrev
= NULL
,
870 *handlerCur
= GetEventHandler();
873 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
875 if ( handlerCur
== handler
)
879 handlerPrev
->SetNextHandler(handlerNext
);
883 SetEventHandler(handlerNext
);
888 handlerNext
->SetPreviousHandler ( handlerPrev
);
891 handler
->SetNextHandler(NULL
);
892 handler
->SetPreviousHandler(NULL
);
897 handlerPrev
= handlerCur
;
898 handlerCur
= handlerNext
;
901 wxFAIL_MSG( _T("where has the event handler gone?") );
906 // ----------------------------------------------------------------------------
908 // ----------------------------------------------------------------------------
910 void wxWindowBase::InheritAttributes()
912 const wxWindowBase
* const parent
= GetParent();
916 // we only inherit attributes which had been explicitly set for the parent
917 // which ensures that this only happens if the user really wants it and
918 // not by default which wouldn't make any sense in modern GUIs where the
919 // controls don't all use the same fonts (nor colours)
920 if ( parent
->m_inheritFont
&& !m_hasFont
)
921 SetFont(parent
->GetFont());
923 // in addition, there is a possibility to explicitly forbid inheriting
924 // colours at each class level by overriding ShouldInheritColours()
925 if ( ShouldInheritColours() )
927 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
928 SetForegroundColour(parent
->GetForegroundColour());
930 // inheriting (solid) background colour is wrong as it totally breaks
931 // any kind of themed backgrounds
933 // instead, the controls should use the same background as their parent
934 // (ideally by not drawing it at all)
936 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
937 SetBackgroundColour(parent
->GetBackgroundColour());
942 /* static */ wxVisualAttributes
943 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
945 // it is important to return valid values for all attributes from here,
946 // GetXXX() below rely on this
947 wxVisualAttributes attrs
;
948 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
949 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
951 // On Smartphone/PocketPC, wxSYS_COLOUR_WINDOW is a better reflection of
952 // the usual background colour than wxSYS_COLOUR_BTNFACE.
953 // It's a pity that wxSYS_COLOUR_WINDOW isn't always a suitable background
954 // colour on other platforms.
956 #if defined(__WXWINCE__) && (defined(__SMARTPHONE__) || defined(__POCKETPC__))
957 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
959 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
964 wxColour
wxWindowBase::GetBackgroundColour() const
966 if ( !m_backgroundColour
.Ok() )
968 wxASSERT_MSG( !m_hasBgCol
, _T("we have invalid explicit bg colour?") );
970 // get our default background colour
971 wxColour colBg
= GetDefaultAttributes().colBg
;
973 // we must return some valid colour to avoid redoing this every time
974 // and also to avoid surprizing the applications written for older
975 // wxWidgets versions where GetBackgroundColour() always returned
976 // something -- so give them something even if it doesn't make sense
977 // for this window (e.g. it has a themed background)
979 colBg
= GetClassDefaultAttributes().colBg
;
984 return m_backgroundColour
;
987 wxColour
wxWindowBase::GetForegroundColour() const
989 // logic is the same as above
990 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
992 wxASSERT_MSG( !m_hasFgCol
, _T("we have invalid explicit fg colour?") );
994 wxColour colFg
= GetDefaultAttributes().colFg
;
997 colFg
= GetClassDefaultAttributes().colFg
;
1002 return m_foregroundColour
;
1005 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
1007 if ( colour
== m_backgroundColour
)
1010 m_hasBgCol
= colour
.Ok();
1011 if ( m_backgroundStyle
!= wxBG_STYLE_CUSTOM
)
1012 m_backgroundStyle
= m_hasBgCol
? wxBG_STYLE_COLOUR
: wxBG_STYLE_SYSTEM
;
1014 m_inheritBgCol
= m_hasBgCol
;
1015 m_backgroundColour
= colour
;
1016 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1020 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1022 if (colour
== m_foregroundColour
)
1025 m_hasFgCol
= colour
.Ok();
1026 m_inheritFgCol
= m_hasFgCol
;
1027 m_foregroundColour
= colour
;
1028 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1032 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1034 // setting an invalid cursor is ok, it means that we don't have any special
1036 if ( m_cursor
== cursor
)
1047 wxFont
wxWindowBase::GetFont() const
1049 // logic is the same as in GetBackgroundColour()
1052 wxASSERT_MSG( !m_hasFont
, _T("we have invalid explicit font?") );
1054 wxFont font
= GetDefaultAttributes().font
;
1056 font
= GetClassDefaultAttributes().font
;
1064 bool wxWindowBase::SetFont(const wxFont
& font
)
1066 if ( font
== m_font
)
1073 m_hasFont
= font
.Ok();
1074 m_inheritFont
= m_hasFont
;
1076 InvalidateBestSize();
1083 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1085 m_hasCustomPalette
= true;
1088 // VZ: can anyone explain me what do we do here?
1089 wxWindowDC
d((wxWindow
*) this);
1093 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1095 wxWindow
*win
= (wxWindow
*)this;
1096 while ( win
&& !win
->HasCustomPalette() )
1098 win
= win
->GetParent();
1104 #endif // wxUSE_PALETTE
1107 void wxWindowBase::SetCaret(wxCaret
*caret
)
1118 wxASSERT_MSG( m_caret
->GetWindow() == this,
1119 wxT("caret should be created associated to this window") );
1122 #endif // wxUSE_CARET
1124 #if wxUSE_VALIDATORS
1125 // ----------------------------------------------------------------------------
1127 // ----------------------------------------------------------------------------
1129 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1131 if ( m_windowValidator
)
1132 delete m_windowValidator
;
1134 m_windowValidator
= (wxValidator
*)validator
.Clone();
1136 if ( m_windowValidator
)
1137 m_windowValidator
->SetWindow(this);
1139 #endif // wxUSE_VALIDATORS
1141 // ----------------------------------------------------------------------------
1142 // update region stuff
1143 // ----------------------------------------------------------------------------
1145 wxRect
wxWindowBase::GetUpdateClientRect() const
1147 wxRegion rgnUpdate
= GetUpdateRegion();
1148 rgnUpdate
.Intersect(GetClientRect());
1149 wxRect rectUpdate
= rgnUpdate
.GetBox();
1150 wxPoint ptOrigin
= GetClientAreaOrigin();
1151 rectUpdate
.x
-= ptOrigin
.x
;
1152 rectUpdate
.y
-= ptOrigin
.y
;
1157 bool wxWindowBase::IsExposed(int x
, int y
) const
1159 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1162 bool wxWindowBase::IsExposed(int x
, int y
, int w
, int h
) const
1164 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1167 void wxWindowBase::ClearBackground()
1169 // wxGTK uses its own version, no need to add never used code
1171 wxClientDC
dc((wxWindow
*)this);
1172 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1173 dc
.SetBackground(brush
);
1178 // ----------------------------------------------------------------------------
1179 // find child window by id or name
1180 // ----------------------------------------------------------------------------
1182 wxWindow
*wxWindowBase::FindWindow(long id
) const
1184 if ( id
== m_windowId
)
1185 return (wxWindow
*)this;
1187 wxWindowBase
*res
= (wxWindow
*)NULL
;
1188 wxWindowList::compatibility_iterator node
;
1189 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1191 wxWindowBase
*child
= node
->GetData();
1192 res
= child
->FindWindow( id
);
1195 return (wxWindow
*)res
;
1198 wxWindow
*wxWindowBase::FindWindow(const wxString
& name
) const
1200 if ( name
== m_windowName
)
1201 return (wxWindow
*)this;
1203 wxWindowBase
*res
= (wxWindow
*)NULL
;
1204 wxWindowList::compatibility_iterator node
;
1205 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1207 wxWindow
*child
= node
->GetData();
1208 res
= child
->FindWindow(name
);
1211 return (wxWindow
*)res
;
1215 // find any window by id or name or label: If parent is non-NULL, look through
1216 // children for a label or title matching the specified string. If NULL, look
1217 // through all top-level windows.
1219 // to avoid duplicating code we reuse the same helper function but with
1220 // different comparators
1222 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1223 const wxString
& label
, long id
);
1226 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1229 return win
->GetLabel() == label
;
1233 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1236 return win
->GetName() == label
;
1240 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1243 return win
->GetId() == id
;
1246 // recursive helper for the FindWindowByXXX() functions
1248 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1249 const wxString
& label
,
1251 wxFindWindowCmp cmp
)
1255 // see if this is the one we're looking for
1256 if ( (*cmp
)(parent
, label
, id
) )
1257 return (wxWindow
*)parent
;
1259 // It wasn't, so check all its children
1260 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1262 node
= node
->GetNext() )
1264 // recursively check each child
1265 wxWindow
*win
= (wxWindow
*)node
->GetData();
1266 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1276 // helper for FindWindowByXXX()
1278 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1279 const wxString
& label
,
1281 wxFindWindowCmp cmp
)
1285 // just check parent and all its children
1286 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1289 // start at very top of wx's windows
1290 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1292 node
= node
->GetNext() )
1294 // recursively check each window & its children
1295 wxWindow
*win
= node
->GetData();
1296 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1306 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1308 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1313 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1315 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1319 // fall back to the label
1320 win
= FindWindowByLabel(title
, parent
);
1328 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1330 return wxFindWindowHelper(parent
, wxEmptyString
, id
, wxFindWindowCmpIds
);
1333 // ----------------------------------------------------------------------------
1334 // dialog oriented functions
1335 // ----------------------------------------------------------------------------
1337 void wxWindowBase::MakeModal(bool modal
)
1339 // Disable all other windows
1342 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1345 wxWindow
*win
= node
->GetData();
1347 win
->Enable(!modal
);
1349 node
= node
->GetNext();
1354 bool wxWindowBase::Validate()
1356 #if wxUSE_VALIDATORS
1357 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1359 wxWindowList::compatibility_iterator node
;
1360 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1362 wxWindowBase
*child
= node
->GetData();
1363 wxValidator
*validator
= child
->GetValidator();
1364 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1369 if ( recurse
&& !child
->Validate() )
1374 #endif // wxUSE_VALIDATORS
1379 bool wxWindowBase::TransferDataToWindow()
1381 #if wxUSE_VALIDATORS
1382 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1384 wxWindowList::compatibility_iterator node
;
1385 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1387 wxWindowBase
*child
= node
->GetData();
1388 wxValidator
*validator
= child
->GetValidator();
1389 if ( validator
&& !validator
->TransferToWindow() )
1391 wxLogWarning(_("Could not transfer data to window"));
1393 wxLog::FlushActive();
1401 if ( !child
->TransferDataToWindow() )
1403 // warning already given
1408 #endif // wxUSE_VALIDATORS
1413 bool wxWindowBase::TransferDataFromWindow()
1415 #if wxUSE_VALIDATORS
1416 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1418 wxWindowList::compatibility_iterator node
;
1419 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1421 wxWindow
*child
= node
->GetData();
1422 wxValidator
*validator
= child
->GetValidator();
1423 if ( validator
&& !validator
->TransferFromWindow() )
1425 // nop warning here because the application is supposed to give
1426 // one itself - we don't know here what might have gone wrongly
1433 if ( !child
->TransferDataFromWindow() )
1435 // warning already given
1440 #endif // wxUSE_VALIDATORS
1445 void wxWindowBase::InitDialog()
1447 wxInitDialogEvent
event(GetId());
1448 event
.SetEventObject( this );
1449 GetEventHandler()->ProcessEvent(event
);
1452 // ----------------------------------------------------------------------------
1453 // context-sensitive help support
1454 // ----------------------------------------------------------------------------
1458 // associate this help text with this window
1459 void wxWindowBase::SetHelpText(const wxString
& text
)
1461 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1464 helpProvider
->AddHelp(this, text
);
1468 // associate this help text with all windows with the same id as this
1470 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1472 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1475 helpProvider
->AddHelp(GetId(), text
);
1479 // get the help string associated with this window (may be empty)
1480 wxString
wxWindowBase::GetHelpText() const
1483 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1486 text
= helpProvider
->GetHelp(this);
1492 // show help for this window
1493 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1495 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1498 if ( helpProvider
->ShowHelp(this) )
1500 // skip the event.Skip() below
1508 #endif // wxUSE_HELP
1510 // ----------------------------------------------------------------------------
1511 // tooltipsroot.Replace("\\", "/");
1512 // ----------------------------------------------------------------------------
1516 void wxWindowBase::SetToolTip( const wxString
&tip
)
1518 // don't create the new tooltip if we already have one
1521 m_tooltip
->SetTip( tip
);
1525 SetToolTip( new wxToolTip( tip
) );
1528 // setting empty tooltip text does not remove the tooltip any more - use
1529 // SetToolTip((wxToolTip *)NULL) for this
1532 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1537 m_tooltip
= tooltip
;
1540 #endif // wxUSE_TOOLTIPS
1542 // ----------------------------------------------------------------------------
1543 // constraints and sizers
1544 // ----------------------------------------------------------------------------
1546 #if wxUSE_CONSTRAINTS
1548 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1550 if ( m_constraints
)
1552 UnsetConstraints(m_constraints
);
1553 delete m_constraints
;
1555 m_constraints
= constraints
;
1556 if ( m_constraints
)
1558 // Make sure other windows know they're part of a 'meaningful relationship'
1559 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1560 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1561 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1562 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1563 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1564 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1565 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1566 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1567 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1568 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1569 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1570 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1571 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1572 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1573 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1574 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1578 // This removes any dangling pointers to this window in other windows'
1579 // constraintsInvolvedIn lists.
1580 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1584 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1585 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1586 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1587 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1588 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1589 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1590 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1591 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1592 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1593 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1594 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1595 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1596 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1597 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1598 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1599 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1603 // Back-pointer to other windows we're involved with, so if we delete this
1604 // window, we must delete any constraints we're involved with.
1605 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
1607 if ( !m_constraintsInvolvedIn
)
1608 m_constraintsInvolvedIn
= new wxWindowList
;
1609 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
1610 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
1613 // REMOVE back-pointer to other windows we're involved with.
1614 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
1616 if ( m_constraintsInvolvedIn
)
1617 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
1620 // Reset any constraints that mention this window
1621 void wxWindowBase::DeleteRelatedConstraints()
1623 if ( m_constraintsInvolvedIn
)
1625 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
1628 wxWindow
*win
= node
->GetData();
1629 wxLayoutConstraints
*constr
= win
->GetConstraints();
1631 // Reset any constraints involving this window
1634 constr
->left
.ResetIfWin(this);
1635 constr
->top
.ResetIfWin(this);
1636 constr
->right
.ResetIfWin(this);
1637 constr
->bottom
.ResetIfWin(this);
1638 constr
->width
.ResetIfWin(this);
1639 constr
->height
.ResetIfWin(this);
1640 constr
->centreX
.ResetIfWin(this);
1641 constr
->centreY
.ResetIfWin(this);
1644 wxWindowList::compatibility_iterator next
= node
->GetNext();
1645 m_constraintsInvolvedIn
->Erase(node
);
1649 delete m_constraintsInvolvedIn
;
1650 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
1654 #endif // wxUSE_CONSTRAINTS
1656 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
1658 if ( sizer
== m_windowSizer
)
1662 delete m_windowSizer
;
1664 m_windowSizer
= sizer
;
1666 SetAutoLayout( sizer
!= NULL
);
1669 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
1671 SetSizer( sizer
, deleteOld
);
1672 sizer
->SetSizeHints( (wxWindow
*) this );
1676 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
1678 // adding a window to a sizer twice is going to result in fatal and
1679 // hard to debug problems later because when deleting the second
1680 // associated wxSizerItem we're going to dereference a dangling
1681 // pointer; so try to detect this as early as possible
1682 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
1683 _T("Adding a window to the same sizer twice?") );
1685 m_containingSizer
= sizer
;
1688 #if wxUSE_CONSTRAINTS
1690 void wxWindowBase::SatisfyConstraints()
1692 wxLayoutConstraints
*constr
= GetConstraints();
1693 bool wasOk
= constr
&& constr
->AreSatisfied();
1695 ResetConstraints(); // Mark all constraints as unevaluated
1699 // if we're a top level panel (i.e. our parent is frame/dialog), our
1700 // own constraints will never be satisfied any more unless we do it
1704 while ( noChanges
> 0 )
1706 LayoutPhase1(&noChanges
);
1710 LayoutPhase2(&noChanges
);
1713 #endif // wxUSE_CONSTRAINTS
1715 bool wxWindowBase::Layout()
1717 // If there is a sizer, use it instead of the constraints
1721 GetVirtualSize(&w
, &h
);
1722 GetSizer()->SetDimension( 0, 0, w
, h
);
1724 #if wxUSE_CONSTRAINTS
1727 SatisfyConstraints(); // Find the right constraints values
1728 SetConstraintSizes(); // Recursively set the real window sizes
1735 #if wxUSE_CONSTRAINTS
1737 // first phase of the constraints evaluation: set our own constraints
1738 bool wxWindowBase::LayoutPhase1(int *noChanges
)
1740 wxLayoutConstraints
*constr
= GetConstraints();
1742 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
1745 // second phase: set the constraints for our children
1746 bool wxWindowBase::LayoutPhase2(int *noChanges
)
1753 // Layout grand children
1759 // Do a phase of evaluating child constraints
1760 bool wxWindowBase::DoPhase(int phase
)
1762 // the list containing the children for which the constraints are already
1764 wxWindowList succeeded
;
1766 // the max number of iterations we loop before concluding that we can't set
1768 static const int maxIterations
= 500;
1770 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
1774 // loop over all children setting their constraints
1775 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1777 node
= node
->GetNext() )
1779 wxWindow
*child
= node
->GetData();
1780 if ( child
->IsTopLevel() )
1782 // top level children are not inside our client area
1786 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
1788 // this one is either already ok or nothing we can do about it
1792 int tempNoChanges
= 0;
1793 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
1794 : child
->LayoutPhase2(&tempNoChanges
);
1795 noChanges
+= tempNoChanges
;
1799 succeeded
.Append(child
);
1805 // constraints are set
1813 void wxWindowBase::ResetConstraints()
1815 wxLayoutConstraints
*constr
= GetConstraints();
1818 constr
->left
.SetDone(false);
1819 constr
->top
.SetDone(false);
1820 constr
->right
.SetDone(false);
1821 constr
->bottom
.SetDone(false);
1822 constr
->width
.SetDone(false);
1823 constr
->height
.SetDone(false);
1824 constr
->centreX
.SetDone(false);
1825 constr
->centreY
.SetDone(false);
1828 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1831 wxWindow
*win
= node
->GetData();
1832 if ( !win
->IsTopLevel() )
1833 win
->ResetConstraints();
1834 node
= node
->GetNext();
1838 // Need to distinguish between setting the 'fake' size for windows and sizers,
1839 // and setting the real values.
1840 void wxWindowBase::SetConstraintSizes(bool recurse
)
1842 wxLayoutConstraints
*constr
= GetConstraints();
1843 if ( constr
&& constr
->AreSatisfied() )
1845 int x
= constr
->left
.GetValue();
1846 int y
= constr
->top
.GetValue();
1847 int w
= constr
->width
.GetValue();
1848 int h
= constr
->height
.GetValue();
1850 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
1851 (constr
->height
.GetRelationship() != wxAsIs
) )
1853 SetSize(x
, y
, w
, h
);
1857 // If we don't want to resize this window, just move it...
1863 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
1864 GetClassInfo()->GetClassName(),
1870 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1873 wxWindow
*win
= node
->GetData();
1874 if ( !win
->IsTopLevel() && win
->GetConstraints() )
1875 win
->SetConstraintSizes();
1876 node
= node
->GetNext();
1881 // Only set the size/position of the constraint (if any)
1882 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
1884 wxLayoutConstraints
*constr
= GetConstraints();
1887 if ( x
!= wxDefaultCoord
)
1889 constr
->left
.SetValue(x
);
1890 constr
->left
.SetDone(true);
1892 if ( y
!= wxDefaultCoord
)
1894 constr
->top
.SetValue(y
);
1895 constr
->top
.SetDone(true);
1897 if ( w
!= wxDefaultCoord
)
1899 constr
->width
.SetValue(w
);
1900 constr
->width
.SetDone(true);
1902 if ( h
!= wxDefaultCoord
)
1904 constr
->height
.SetValue(h
);
1905 constr
->height
.SetDone(true);
1910 void wxWindowBase::MoveConstraint(int x
, int y
)
1912 wxLayoutConstraints
*constr
= GetConstraints();
1915 if ( x
!= wxDefaultCoord
)
1917 constr
->left
.SetValue(x
);
1918 constr
->left
.SetDone(true);
1920 if ( y
!= wxDefaultCoord
)
1922 constr
->top
.SetValue(y
);
1923 constr
->top
.SetDone(true);
1928 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
1930 wxLayoutConstraints
*constr
= GetConstraints();
1933 *w
= constr
->width
.GetValue();
1934 *h
= constr
->height
.GetValue();
1940 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
1942 wxLayoutConstraints
*constr
= GetConstraints();
1945 *w
= constr
->width
.GetValue();
1946 *h
= constr
->height
.GetValue();
1949 GetClientSize(w
, h
);
1952 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
1954 wxLayoutConstraints
*constr
= GetConstraints();
1957 *x
= constr
->left
.GetValue();
1958 *y
= constr
->top
.GetValue();
1964 #endif // wxUSE_CONSTRAINTS
1966 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
1968 // don't do it for the dialogs/frames - they float independently of their
1970 if ( !IsTopLevel() )
1972 wxWindow
*parent
= GetParent();
1973 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
1975 wxPoint
pt(parent
->GetClientAreaOrigin());
1982 // ----------------------------------------------------------------------------
1983 // do Update UI processing for child controls
1984 // ----------------------------------------------------------------------------
1986 void wxWindowBase::UpdateWindowUI(long flags
)
1988 wxUpdateUIEvent
event(GetId());
1989 event
.SetEventObject(this);
1991 if ( GetEventHandler()->ProcessEvent(event
) )
1993 DoUpdateWindowUI(event
);
1996 if (flags
& wxUPDATE_UI_RECURSE
)
1998 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2001 wxWindow
* child
= (wxWindow
*) node
->GetData();
2002 child
->UpdateWindowUI(flags
);
2003 node
= node
->GetNext();
2008 // do the window-specific processing after processing the update event
2009 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
2011 if ( event
.GetSetEnabled() )
2012 Enable(event
.GetEnabled());
2014 if ( event
.GetSetShown() )
2015 Show(event
.GetShown());
2019 // call internal idle recursively
2020 // may be obsolete (wait until OnIdle scheme stabilises)
2021 void wxWindowBase::ProcessInternalIdle()
2025 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2028 wxWindow
*child
= node
->GetData();
2029 child
->ProcessInternalIdle();
2030 node
= node
->GetNext();
2035 // ----------------------------------------------------------------------------
2036 // dialog units translations
2037 // ----------------------------------------------------------------------------
2039 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
2041 int charWidth
= GetCharWidth();
2042 int charHeight
= GetCharHeight();
2043 wxPoint pt2
= wxDefaultPosition
;
2044 if (pt
.x
!= wxDefaultCoord
)
2045 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
);
2046 if (pt
.y
!= wxDefaultCoord
)
2047 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2052 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2054 int charWidth
= GetCharWidth();
2055 int charHeight
= GetCharHeight();
2056 wxPoint pt2
= wxDefaultPosition
;
2057 if (pt
.x
!= wxDefaultCoord
)
2058 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2059 if (pt
.y
!= wxDefaultCoord
)
2060 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2065 // ----------------------------------------------------------------------------
2067 // ----------------------------------------------------------------------------
2069 // propagate the colour change event to the subwindows
2070 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2072 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2075 // Only propagate to non-top-level windows
2076 wxWindow
*win
= node
->GetData();
2077 if ( !win
->IsTopLevel() )
2079 wxSysColourChangedEvent event2
;
2080 event
.SetEventObject(win
);
2081 win
->GetEventHandler()->ProcessEvent(event2
);
2084 node
= node
->GetNext();
2090 // the default action is to populate dialog with data when it's created,
2091 // and nudge the UI into displaying itself correctly in case
2092 // we've turned the wxUpdateUIEvents frequency down low.
2093 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2095 TransferDataToWindow();
2097 // Update the UI at this point
2098 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2101 // methods for drawing the sizers in a visible way
2104 static void DrawSizers(wxWindowBase
*win
);
2106 static void DrawBorder(wxWindowBase
*win
, const wxRect
& rect
, bool fill
= false)
2108 wxClientDC
dc((wxWindow
*)win
);
2109 dc
.SetPen(*wxRED_PEN
);
2110 dc
.SetBrush(fill
? wxBrush(*wxRED
, wxCROSSDIAG_HATCH
): *wxTRANSPARENT_BRUSH
);
2111 dc
.DrawRectangle(rect
.Deflate(1, 1));
2114 static void DrawSizer(wxWindowBase
*win
, wxSizer
*sizer
)
2116 const wxSizerItemList
& items
= sizer
->GetChildren();
2117 for ( wxSizerItemList::const_iterator i
= items
.begin(),
2122 wxSizerItem
*item
= *i
;
2123 if ( item
->IsSizer() )
2125 DrawBorder(win
, item
->GetRect().Deflate(2));
2126 DrawSizer(win
, item
->GetSizer());
2128 else if ( item
->IsSpacer() )
2130 DrawBorder(win
, item
->GetRect().Deflate(2), true);
2132 else if ( item
->IsWindow() )
2134 DrawSizers(item
->GetWindow());
2139 static void DrawSizers(wxWindowBase
*win
)
2141 wxSizer
*sizer
= win
->GetSizer();
2144 DrawBorder(win
, win
->GetClientSize());
2145 DrawSizer(win
, sizer
);
2147 else // no sizer, still recurse into the children
2149 const wxWindowList
& children
= win
->GetChildren();
2150 for ( wxWindowList::const_iterator i
= children
.begin(),
2151 end
= children
.end();
2160 #endif // __WXDEBUG__
2162 // process special middle clicks
2163 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2165 if ( event
.ControlDown() && event
.AltDown() )
2168 // Ctrl-Alt-Shift-mclick makes the sizers visible in debug builds
2169 if ( event
.ShiftDown() )
2174 #endif // __WXDEBUG__
2177 // don't translate these strings
2180 #ifdef __WXUNIVERSAL__
2182 #endif // __WXUNIVERSAL__
2184 switch ( wxGetOsVersion() )
2186 case wxMOTIF_X
: port
+= _T("Motif"); break;
2188 case wxMAC_DARWIN
: port
+= _T("Mac"); break;
2189 case wxBEOS
: port
+= _T("BeOS"); break;
2193 case wxGTK_BEOS
: port
+= _T("GTK"); break;
2199 case wxWIN386
: port
+= _T("MS Windows"); break;
2203 case wxMGL_OS2
: port
+= _T("MGL"); break;
2205 case wxOS2_PM
: port
+= _T("OS/2"); break;
2206 case wxPALMOS
: port
+= _T("Palm OS"); break;
2207 case wxWINDOWS_CE
: port
+= _T("Windows CE (generic)"); break;
2208 case wxWINDOWS_POCKETPC
: port
+= _T("Windows CE PocketPC"); break;
2209 case wxWINDOWS_SMARTPHONE
: port
+= _T("Windows CE Smartphone"); break;
2210 default: port
+= _T("unknown"); break;
2213 wxMessageBox(wxString::Format(
2215 " wxWidgets Library (%s port)\nVersion %d.%d.%d%s%s, compiled at %s %s%s\n Copyright (c) 1995-2006 wxWidgets team"
2234 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()
2239 _T("wxWidgets information"),
2240 wxICON_INFORMATION
| wxOK
,
2244 #endif // wxUSE_MSGDLG
2250 // ----------------------------------------------------------------------------
2252 // ----------------------------------------------------------------------------
2254 #if wxUSE_ACCESSIBILITY
2255 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2257 if (m_accessible
&& (accessible
!= m_accessible
))
2258 delete m_accessible
;
2259 m_accessible
= accessible
;
2261 m_accessible
->SetWindow((wxWindow
*) this);
2264 // Returns the accessible object, creating if necessary.
2265 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2268 m_accessible
= CreateAccessible();
2269 return m_accessible
;
2272 // Override to create a specific accessible object.
2273 wxAccessible
* wxWindowBase::CreateAccessible()
2275 return new wxWindowAccessible((wxWindow
*) this);
2280 // ----------------------------------------------------------------------------
2281 // list classes implementation
2282 // ----------------------------------------------------------------------------
2286 #include "wx/listimpl.cpp"
2287 WX_DEFINE_LIST(wxWindowList
)
2291 void wxWindowListNode::DeleteData()
2293 delete (wxWindow
*)GetData();
2298 // ----------------------------------------------------------------------------
2300 // ----------------------------------------------------------------------------
2302 wxBorder
wxWindowBase::GetBorder(long flags
) const
2304 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2305 if ( border
== wxBORDER_DEFAULT
)
2307 border
= GetDefaultBorder();
2313 wxBorder
wxWindowBase::GetDefaultBorder() const
2315 return wxBORDER_NONE
;
2318 // ----------------------------------------------------------------------------
2320 // ----------------------------------------------------------------------------
2322 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2324 // here we just check if the point is inside the window or not
2326 // check the top and left border first
2327 bool outside
= x
< 0 || y
< 0;
2330 // check the right and bottom borders too
2331 wxSize size
= GetSize();
2332 outside
= x
>= size
.x
|| y
>= size
.y
;
2335 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2338 // ----------------------------------------------------------------------------
2340 // ----------------------------------------------------------------------------
2342 struct WXDLLEXPORT wxWindowNext
2346 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2348 void wxWindowBase::CaptureMouse()
2350 wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), this);
2352 wxWindow
*winOld
= GetCapture();
2355 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2358 wxWindowNext
*item
= new wxWindowNext
;
2360 item
->next
= ms_winCaptureNext
;
2361 ms_winCaptureNext
= item
;
2363 //else: no mouse capture to save
2368 void wxWindowBase::ReleaseMouse()
2370 wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), this);
2372 wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") );
2376 if ( ms_winCaptureNext
)
2378 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2380 wxWindowNext
*item
= ms_winCaptureNext
;
2381 ms_winCaptureNext
= item
->next
;
2384 //else: stack is empty, no previous capture
2386 wxLogTrace(_T("mousecapture"),
2387 (const wxChar
*) _T("After ReleaseMouse() mouse is captured by %p"),
2394 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2395 int WXUNUSED(modifiers
),
2396 int WXUNUSED(keycode
))
2402 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2408 #endif // wxUSE_HOTKEY
2410 void wxWindowBase::SendDestroyEvent()
2412 wxWindowDestroyEvent event
;
2413 event
.SetEventObject(this);
2414 event
.SetId(GetId());
2415 GetEventHandler()->ProcessEvent(event
);
2418 // ----------------------------------------------------------------------------
2420 // ----------------------------------------------------------------------------
2422 bool wxWindowBase::TryValidator(wxEvent
& wxVALIDATOR_PARAM(event
))
2424 #if wxUSE_VALIDATORS
2425 // Can only use the validator of the window which
2426 // is receiving the event
2427 if ( event
.GetEventObject() == this )
2429 wxValidator
*validator
= GetValidator();
2430 if ( validator
&& validator
->ProcessEvent(event
) )
2435 #endif // wxUSE_VALIDATORS
2440 bool wxWindowBase::TryParent(wxEvent
& event
)
2442 // carry on up the parent-child hierarchy if the propagation count hasn't
2444 if ( event
.ShouldPropagate() )
2446 // honour the requests to stop propagation at this window: this is
2447 // used by the dialogs, for example, to prevent processing the events
2448 // from the dialog controls in the parent frame which rarely, if ever,
2450 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2452 wxWindow
*parent
= GetParent();
2453 if ( parent
&& !parent
->IsBeingDeleted() )
2455 wxPropagateOnce
propagateOnce(event
);
2457 return parent
->GetEventHandler()->ProcessEvent(event
);
2462 return wxEvtHandler::TryParent(event
);
2465 // ----------------------------------------------------------------------------
2466 // keyboard navigation
2467 // ----------------------------------------------------------------------------
2469 // Navigates in the specified direction.
2470 bool wxWindowBase::Navigate(int flags
)
2472 wxNavigationKeyEvent eventNav
;
2473 eventNav
.SetFlags(flags
);
2474 eventNav
.SetEventObject(this);
2475 if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav
) )
2482 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, MoveKind move
)
2484 // check that we're not a top level window
2485 wxCHECK_RET( GetParent(),
2486 _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
2488 // detect the special case when we have nothing to do anyhow and when the
2489 // code below wouldn't work
2493 // find the target window in the siblings list
2494 wxWindowList
& siblings
= GetParent()->GetChildren();
2495 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
2496 wxCHECK_RET( i
, _T("MoveBefore/AfterInTabOrder(): win is not a sibling") );
2498 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
2499 // can't just move the node around
2500 wxWindow
*self
= (wxWindow
*)this;
2501 siblings
.DeleteObject(self
);
2502 if ( move
== MoveAfter
)
2509 siblings
.Insert(i
, self
);
2511 else // MoveAfter and win was the last sibling
2513 siblings
.Append(self
);
2517 // ----------------------------------------------------------------------------
2519 // ----------------------------------------------------------------------------
2521 /*static*/ wxWindow
* wxWindowBase::FindFocus()
2523 wxWindowBase
*win
= DoFindFocus();
2524 return win
? win
->GetMainWindowOfCompositeControl() : NULL
;
2527 // ----------------------------------------------------------------------------
2529 // ----------------------------------------------------------------------------
2531 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
2533 while ( win
&& !win
->IsTopLevel() )
2534 win
= win
->GetParent();
2539 #if wxUSE_ACCESSIBILITY
2540 // ----------------------------------------------------------------------------
2541 // accessible object for windows
2542 // ----------------------------------------------------------------------------
2544 // Can return either a child object, or an integer
2545 // representing the child element, starting from 1.
2546 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
2548 wxASSERT( GetWindow() != NULL
);
2552 return wxACC_NOT_IMPLEMENTED
;
2555 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
2556 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
2558 wxASSERT( GetWindow() != NULL
);
2562 wxWindow
* win
= NULL
;
2569 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
2571 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
2578 rect
= win
->GetRect();
2579 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
2580 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
2584 return wxACC_NOT_IMPLEMENTED
;
2587 // Navigates from fromId to toId/toObject.
2588 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
2589 int* WXUNUSED(toId
), wxAccessible
** toObject
)
2591 wxASSERT( GetWindow() != NULL
);
2597 case wxNAVDIR_FIRSTCHILD
:
2599 if (GetWindow()->GetChildren().GetCount() == 0)
2601 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
2602 *toObject
= childWindow
->GetOrCreateAccessible();
2606 case wxNAVDIR_LASTCHILD
:
2608 if (GetWindow()->GetChildren().GetCount() == 0)
2610 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
2611 *toObject
= childWindow
->GetOrCreateAccessible();
2615 case wxNAVDIR_RIGHT
:
2619 wxWindowList::compatibility_iterator node
=
2620 wxWindowList::compatibility_iterator();
2623 // Can't navigate to sibling of this window
2624 // if we're a top-level window.
2625 if (!GetWindow()->GetParent())
2626 return wxACC_NOT_IMPLEMENTED
;
2628 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2632 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2633 node
= GetWindow()->GetChildren().Item(fromId
-1);
2636 if (node
&& node
->GetNext())
2638 wxWindow
* nextWindow
= node
->GetNext()->GetData();
2639 *toObject
= nextWindow
->GetOrCreateAccessible();
2647 case wxNAVDIR_PREVIOUS
:
2649 wxWindowList::compatibility_iterator node
=
2650 wxWindowList::compatibility_iterator();
2653 // Can't navigate to sibling of this window
2654 // if we're a top-level window.
2655 if (!GetWindow()->GetParent())
2656 return wxACC_NOT_IMPLEMENTED
;
2658 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2662 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2663 node
= GetWindow()->GetChildren().Item(fromId
-1);
2666 if (node
&& node
->GetPrevious())
2668 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
2669 *toObject
= previousWindow
->GetOrCreateAccessible();
2677 return wxACC_NOT_IMPLEMENTED
;
2680 // Gets the name of the specified object.
2681 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
2683 wxASSERT( GetWindow() != NULL
);
2689 // If a child, leave wxWidgets to call the function on the actual
2692 return wxACC_NOT_IMPLEMENTED
;
2694 // This will eventually be replaced by specialised
2695 // accessible classes, one for each kind of wxWidgets
2696 // control or window.
2698 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
2699 title
= ((wxButton
*) GetWindow())->GetLabel();
2702 title
= GetWindow()->GetName();
2710 return wxACC_NOT_IMPLEMENTED
;
2713 // Gets the number of children.
2714 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
2716 wxASSERT( GetWindow() != NULL
);
2720 *childId
= (int) GetWindow()->GetChildren().GetCount();
2724 // Gets the specified child (starting from 1).
2725 // If *child is NULL and return value is wxACC_OK,
2726 // this means that the child is a simple element and
2727 // not an accessible object.
2728 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
2730 wxASSERT( GetWindow() != NULL
);
2740 if (childId
> (int) GetWindow()->GetChildren().GetCount())
2743 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
2744 *child
= childWindow
->GetOrCreateAccessible();
2751 // Gets the parent, or NULL.
2752 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
2754 wxASSERT( GetWindow() != NULL
);
2758 wxWindow
* parentWindow
= GetWindow()->GetParent();
2766 *parent
= parentWindow
->GetOrCreateAccessible();
2774 // Performs the default action. childId is 0 (the action for this object)
2775 // or > 0 (the action for a child).
2776 // Return wxACC_NOT_SUPPORTED if there is no default action for this
2777 // window (e.g. an edit control).
2778 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
2780 wxASSERT( GetWindow() != NULL
);
2784 return wxACC_NOT_IMPLEMENTED
;
2787 // Gets the default action for this object (0) or > 0 (the action for a child).
2788 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
2789 // string if there is no action.
2790 // The retrieved string describes the action that is performed on an object,
2791 // not what the object does as a result. For example, a toolbar button that prints
2792 // a document has a default action of "Press" rather than "Prints the current document."
2793 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
2795 wxASSERT( GetWindow() != NULL
);
2799 return wxACC_NOT_IMPLEMENTED
;
2802 // Returns the description for this object or a child.
2803 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
2805 wxASSERT( GetWindow() != NULL
);
2809 wxString
ht(GetWindow()->GetHelpText());
2815 return wxACC_NOT_IMPLEMENTED
;
2818 // Returns help text for this object or a child, similar to tooltip text.
2819 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
2821 wxASSERT( GetWindow() != NULL
);
2825 wxString
ht(GetWindow()->GetHelpText());
2831 return wxACC_NOT_IMPLEMENTED
;
2834 // Returns the keyboard shortcut for this object or child.
2835 // Return e.g. ALT+K
2836 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
2838 wxASSERT( GetWindow() != NULL
);
2842 return wxACC_NOT_IMPLEMENTED
;
2845 // Returns a role constant.
2846 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
2848 wxASSERT( GetWindow() != NULL
);
2852 // If a child, leave wxWidgets to call the function on the actual
2855 return wxACC_NOT_IMPLEMENTED
;
2857 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2858 return wxACC_NOT_IMPLEMENTED
;
2860 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2861 return wxACC_NOT_IMPLEMENTED
;
2864 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2865 return wxACC_NOT_IMPLEMENTED
;
2868 //*role = wxROLE_SYSTEM_CLIENT;
2869 *role
= wxROLE_SYSTEM_CLIENT
;
2873 return wxACC_NOT_IMPLEMENTED
;
2877 // Returns a state constant.
2878 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
2880 wxASSERT( GetWindow() != NULL
);
2884 // If a child, leave wxWidgets to call the function on the actual
2887 return wxACC_NOT_IMPLEMENTED
;
2889 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2890 return wxACC_NOT_IMPLEMENTED
;
2893 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2894 return wxACC_NOT_IMPLEMENTED
;
2897 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2898 return wxACC_NOT_IMPLEMENTED
;
2905 return wxACC_NOT_IMPLEMENTED
;
2909 // Returns a localized string representing the value for the object
2911 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
2913 wxASSERT( GetWindow() != NULL
);
2917 return wxACC_NOT_IMPLEMENTED
;
2920 // Selects the object or child.
2921 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
2923 wxASSERT( GetWindow() != NULL
);
2927 return wxACC_NOT_IMPLEMENTED
;
2930 // Gets the window with the keyboard focus.
2931 // If childId is 0 and child is NULL, no object in
2932 // this subhierarchy has the focus.
2933 // If this object has the focus, child should be 'this'.
2934 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
2936 wxASSERT( GetWindow() != NULL
);
2940 return wxACC_NOT_IMPLEMENTED
;
2943 // Gets a variant representing the selected children
2945 // Acceptable values:
2946 // - a null variant (IsNull() returns true)
2947 // - a list variant (GetType() == wxT("list")
2948 // - an integer representing the selected child element,
2949 // or 0 if this object is selected (GetType() == wxT("long")
2950 // - a "void*" pointer to a wxAccessible child object
2951 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
2953 wxASSERT( GetWindow() != NULL
);
2957 return wxACC_NOT_IMPLEMENTED
;
2960 #endif // wxUSE_ACCESSIBILITY