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 // ----------------------------------------------------------------------------
719 // show/hide/enable/disable the window
720 // ----------------------------------------------------------------------------
722 bool wxWindowBase::Show(bool show
)
724 if ( show
!= m_isShown
)
736 bool wxWindowBase::Enable(bool enable
)
738 if ( enable
!= m_isEnabled
)
740 m_isEnabled
= enable
;
749 // ----------------------------------------------------------------------------
751 // ----------------------------------------------------------------------------
753 bool wxWindowBase::IsTopLevel() const
758 // ----------------------------------------------------------------------------
759 // reparenting the window
760 // ----------------------------------------------------------------------------
762 void wxWindowBase::AddChild(wxWindowBase
*child
)
764 wxCHECK_RET( child
, wxT("can't add a NULL child") );
766 // this should never happen and it will lead to a crash later if it does
767 // because RemoveChild() will remove only one node from the children list
768 // and the other(s) one(s) will be left with dangling pointers in them
769 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), _T("AddChild() called twice") );
771 GetChildren().Append((wxWindow
*)child
);
772 child
->SetParent(this);
775 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
777 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
779 GetChildren().DeleteObject((wxWindow
*)child
);
780 child
->SetParent(NULL
);
783 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
785 wxWindow
*oldParent
= GetParent();
786 if ( newParent
== oldParent
)
792 // unlink this window from the existing parent.
795 oldParent
->RemoveChild(this);
799 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
802 // add it to the new one
805 newParent
->AddChild(this);
809 wxTopLevelWindows
.Append((wxWindow
*)this);
815 // ----------------------------------------------------------------------------
816 // event handler stuff
817 // ----------------------------------------------------------------------------
819 void wxWindowBase::PushEventHandler(wxEvtHandler
*handler
)
821 wxEvtHandler
*handlerOld
= GetEventHandler();
823 handler
->SetNextHandler(handlerOld
);
826 GetEventHandler()->SetPreviousHandler(handler
);
828 SetEventHandler(handler
);
831 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
833 wxEvtHandler
*handlerA
= GetEventHandler();
836 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
837 handlerA
->SetNextHandler((wxEvtHandler
*)NULL
);
840 handlerB
->SetPreviousHandler((wxEvtHandler
*)NULL
);
841 SetEventHandler(handlerB
);
846 handlerA
= (wxEvtHandler
*)NULL
;
853 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handler
)
855 wxCHECK_MSG( handler
, false, _T("RemoveEventHandler(NULL) called") );
857 wxEvtHandler
*handlerPrev
= NULL
,
858 *handlerCur
= GetEventHandler();
861 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
863 if ( handlerCur
== handler
)
867 handlerPrev
->SetNextHandler(handlerNext
);
871 SetEventHandler(handlerNext
);
876 handlerNext
->SetPreviousHandler ( handlerPrev
);
879 handler
->SetNextHandler(NULL
);
880 handler
->SetPreviousHandler(NULL
);
885 handlerPrev
= handlerCur
;
886 handlerCur
= handlerNext
;
889 wxFAIL_MSG( _T("where has the event handler gone?") );
894 // ----------------------------------------------------------------------------
896 // ----------------------------------------------------------------------------
898 void wxWindowBase::InheritAttributes()
900 const wxWindowBase
* const parent
= GetParent();
904 // we only inherit attributes which had been explicitly set for the parent
905 // which ensures that this only happens if the user really wants it and
906 // not by default which wouldn't make any sense in modern GUIs where the
907 // controls don't all use the same fonts (nor colours)
908 if ( parent
->m_inheritFont
&& !m_hasFont
)
909 SetFont(parent
->GetFont());
911 // in addition, there is a possibility to explicitly forbid inheriting
912 // colours at each class level by overriding ShouldInheritColours()
913 if ( ShouldInheritColours() )
915 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
916 SetForegroundColour(parent
->GetForegroundColour());
918 // inheriting (solid) background colour is wrong as it totally breaks
919 // any kind of themed backgrounds
921 // instead, the controls should use the same background as their parent
922 // (ideally by not drawing it at all)
924 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
925 SetBackgroundColour(parent
->GetBackgroundColour());
930 /* static */ wxVisualAttributes
931 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
933 // it is important to return valid values for all attributes from here,
934 // GetXXX() below rely on this
935 wxVisualAttributes attrs
;
936 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
937 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
939 // On Smartphone/PocketPC, wxSYS_COLOUR_WINDOW is a better reflection of
940 // the usual background colour than wxSYS_COLOUR_BTNFACE.
941 // It's a pity that wxSYS_COLOUR_WINDOW isn't always a suitable background
942 // colour on other platforms.
944 #if defined(__WXWINCE__) && (defined(__SMARTPHONE__) || defined(__POCKETPC__))
945 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
);
947 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
952 wxColour
wxWindowBase::GetBackgroundColour() const
954 if ( !m_backgroundColour
.Ok() )
956 wxASSERT_MSG( !m_hasBgCol
, _T("we have invalid explicit bg colour?") );
958 // get our default background colour
959 wxColour colBg
= GetDefaultAttributes().colBg
;
961 // we must return some valid colour to avoid redoing this every time
962 // and also to avoid surprizing the applications written for older
963 // wxWidgets versions where GetBackgroundColour() always returned
964 // something -- so give them something even if it doesn't make sense
965 // for this window (e.g. it has a themed background)
967 colBg
= GetClassDefaultAttributes().colBg
;
972 return m_backgroundColour
;
975 wxColour
wxWindowBase::GetForegroundColour() const
977 // logic is the same as above
978 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
980 wxASSERT_MSG( !m_hasFgCol
, _T("we have invalid explicit fg colour?") );
982 wxColour colFg
= GetDefaultAttributes().colFg
;
985 colFg
= GetClassDefaultAttributes().colFg
;
990 return m_foregroundColour
;
993 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
995 if ( colour
== m_backgroundColour
)
998 m_hasBgCol
= colour
.Ok();
999 if ( m_backgroundStyle
!= wxBG_STYLE_CUSTOM
)
1000 m_backgroundStyle
= m_hasBgCol
? wxBG_STYLE_COLOUR
: wxBG_STYLE_SYSTEM
;
1002 m_inheritBgCol
= m_hasBgCol
;
1003 m_backgroundColour
= colour
;
1004 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1008 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1010 if (colour
== m_foregroundColour
)
1013 m_hasFgCol
= colour
.Ok();
1014 m_inheritFgCol
= m_hasFgCol
;
1015 m_foregroundColour
= colour
;
1016 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1020 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1022 // setting an invalid cursor is ok, it means that we don't have any special
1024 if ( m_cursor
== cursor
)
1035 wxFont
wxWindowBase::GetFont() const
1037 // logic is the same as in GetBackgroundColour()
1040 wxASSERT_MSG( !m_hasFont
, _T("we have invalid explicit font?") );
1042 wxFont font
= GetDefaultAttributes().font
;
1044 font
= GetClassDefaultAttributes().font
;
1052 bool wxWindowBase::SetFont(const wxFont
& font
)
1054 if ( font
== m_font
)
1061 m_hasFont
= font
.Ok();
1062 m_inheritFont
= m_hasFont
;
1064 InvalidateBestSize();
1071 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1073 m_hasCustomPalette
= true;
1076 // VZ: can anyone explain me what do we do here?
1077 wxWindowDC
d((wxWindow
*) this);
1081 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1083 wxWindow
*win
= (wxWindow
*)this;
1084 while ( win
&& !win
->HasCustomPalette() )
1086 win
= win
->GetParent();
1092 #endif // wxUSE_PALETTE
1095 void wxWindowBase::SetCaret(wxCaret
*caret
)
1106 wxASSERT_MSG( m_caret
->GetWindow() == this,
1107 wxT("caret should be created associated to this window") );
1110 #endif // wxUSE_CARET
1112 #if wxUSE_VALIDATORS
1113 // ----------------------------------------------------------------------------
1115 // ----------------------------------------------------------------------------
1117 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1119 if ( m_windowValidator
)
1120 delete m_windowValidator
;
1122 m_windowValidator
= (wxValidator
*)validator
.Clone();
1124 if ( m_windowValidator
)
1125 m_windowValidator
->SetWindow(this);
1127 #endif // wxUSE_VALIDATORS
1129 // ----------------------------------------------------------------------------
1130 // update region stuff
1131 // ----------------------------------------------------------------------------
1133 wxRect
wxWindowBase::GetUpdateClientRect() const
1135 wxRegion rgnUpdate
= GetUpdateRegion();
1136 rgnUpdate
.Intersect(GetClientRect());
1137 wxRect rectUpdate
= rgnUpdate
.GetBox();
1138 wxPoint ptOrigin
= GetClientAreaOrigin();
1139 rectUpdate
.x
-= ptOrigin
.x
;
1140 rectUpdate
.y
-= ptOrigin
.y
;
1145 bool wxWindowBase::IsExposed(int x
, int y
) const
1147 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1150 bool wxWindowBase::IsExposed(int x
, int y
, int w
, int h
) const
1152 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1155 void wxWindowBase::ClearBackground()
1157 // wxGTK uses its own version, no need to add never used code
1159 wxClientDC
dc((wxWindow
*)this);
1160 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1161 dc
.SetBackground(brush
);
1166 // ----------------------------------------------------------------------------
1167 // find child window by id or name
1168 // ----------------------------------------------------------------------------
1170 wxWindow
*wxWindowBase::FindWindow(long id
) const
1172 if ( id
== m_windowId
)
1173 return (wxWindow
*)this;
1175 wxWindowBase
*res
= (wxWindow
*)NULL
;
1176 wxWindowList::compatibility_iterator node
;
1177 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1179 wxWindowBase
*child
= node
->GetData();
1180 res
= child
->FindWindow( id
);
1183 return (wxWindow
*)res
;
1186 wxWindow
*wxWindowBase::FindWindow(const wxString
& name
) const
1188 if ( name
== m_windowName
)
1189 return (wxWindow
*)this;
1191 wxWindowBase
*res
= (wxWindow
*)NULL
;
1192 wxWindowList::compatibility_iterator node
;
1193 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1195 wxWindow
*child
= node
->GetData();
1196 res
= child
->FindWindow(name
);
1199 return (wxWindow
*)res
;
1203 // find any window by id or name or label: If parent is non-NULL, look through
1204 // children for a label or title matching the specified string. If NULL, look
1205 // through all top-level windows.
1207 // to avoid duplicating code we reuse the same helper function but with
1208 // different comparators
1210 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1211 const wxString
& label
, long id
);
1214 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1217 return win
->GetLabel() == label
;
1221 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1224 return win
->GetName() == label
;
1228 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1231 return win
->GetId() == id
;
1234 // recursive helper for the FindWindowByXXX() functions
1236 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1237 const wxString
& label
,
1239 wxFindWindowCmp cmp
)
1243 // see if this is the one we're looking for
1244 if ( (*cmp
)(parent
, label
, id
) )
1245 return (wxWindow
*)parent
;
1247 // It wasn't, so check all its children
1248 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1250 node
= node
->GetNext() )
1252 // recursively check each child
1253 wxWindow
*win
= (wxWindow
*)node
->GetData();
1254 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1264 // helper for FindWindowByXXX()
1266 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1267 const wxString
& label
,
1269 wxFindWindowCmp cmp
)
1273 // just check parent and all its children
1274 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1277 // start at very top of wx's windows
1278 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1280 node
= node
->GetNext() )
1282 // recursively check each window & its children
1283 wxWindow
*win
= node
->GetData();
1284 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1294 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1296 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1301 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1303 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1307 // fall back to the label
1308 win
= FindWindowByLabel(title
, parent
);
1316 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1318 return wxFindWindowHelper(parent
, wxEmptyString
, id
, wxFindWindowCmpIds
);
1321 // ----------------------------------------------------------------------------
1322 // dialog oriented functions
1323 // ----------------------------------------------------------------------------
1325 void wxWindowBase::MakeModal(bool modal
)
1327 // Disable all other windows
1330 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1333 wxWindow
*win
= node
->GetData();
1335 win
->Enable(!modal
);
1337 node
= node
->GetNext();
1342 bool wxWindowBase::Validate()
1344 #if wxUSE_VALIDATORS
1345 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1347 wxWindowList::compatibility_iterator node
;
1348 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1350 wxWindowBase
*child
= node
->GetData();
1351 wxValidator
*validator
= child
->GetValidator();
1352 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1357 if ( recurse
&& !child
->Validate() )
1362 #endif // wxUSE_VALIDATORS
1367 bool wxWindowBase::TransferDataToWindow()
1369 #if wxUSE_VALIDATORS
1370 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1372 wxWindowList::compatibility_iterator node
;
1373 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1375 wxWindowBase
*child
= node
->GetData();
1376 wxValidator
*validator
= child
->GetValidator();
1377 if ( validator
&& !validator
->TransferToWindow() )
1379 wxLogWarning(_("Could not transfer data to window"));
1381 wxLog::FlushActive();
1389 if ( !child
->TransferDataToWindow() )
1391 // warning already given
1396 #endif // wxUSE_VALIDATORS
1401 bool wxWindowBase::TransferDataFromWindow()
1403 #if wxUSE_VALIDATORS
1404 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1406 wxWindowList::compatibility_iterator node
;
1407 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1409 wxWindow
*child
= node
->GetData();
1410 wxValidator
*validator
= child
->GetValidator();
1411 if ( validator
&& !validator
->TransferFromWindow() )
1413 // nop warning here because the application is supposed to give
1414 // one itself - we don't know here what might have gone wrongly
1421 if ( !child
->TransferDataFromWindow() )
1423 // warning already given
1428 #endif // wxUSE_VALIDATORS
1433 void wxWindowBase::InitDialog()
1435 wxInitDialogEvent
event(GetId());
1436 event
.SetEventObject( this );
1437 GetEventHandler()->ProcessEvent(event
);
1440 // ----------------------------------------------------------------------------
1441 // context-sensitive help support
1442 // ----------------------------------------------------------------------------
1446 // associate this help text with this window
1447 void wxWindowBase::SetHelpText(const wxString
& text
)
1449 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1452 helpProvider
->AddHelp(this, text
);
1456 // associate this help text with all windows with the same id as this
1458 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1460 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1463 helpProvider
->AddHelp(GetId(), text
);
1467 // get the help string associated with this window (may be empty)
1468 wxString
wxWindowBase::GetHelpText() const
1471 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1474 text
= helpProvider
->GetHelp(this);
1480 // show help for this window
1481 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1483 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1486 if ( helpProvider
->ShowHelp(this) )
1488 // skip the event.Skip() below
1496 #endif // wxUSE_HELP
1498 // ----------------------------------------------------------------------------
1499 // tooltipsroot.Replace("\\", "/");
1500 // ----------------------------------------------------------------------------
1504 void wxWindowBase::SetToolTip( const wxString
&tip
)
1506 // don't create the new tooltip if we already have one
1509 m_tooltip
->SetTip( tip
);
1513 SetToolTip( new wxToolTip( tip
) );
1516 // setting empty tooltip text does not remove the tooltip any more - use
1517 // SetToolTip((wxToolTip *)NULL) for this
1520 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1525 m_tooltip
= tooltip
;
1528 #endif // wxUSE_TOOLTIPS
1530 // ----------------------------------------------------------------------------
1531 // constraints and sizers
1532 // ----------------------------------------------------------------------------
1534 #if wxUSE_CONSTRAINTS
1536 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1538 if ( m_constraints
)
1540 UnsetConstraints(m_constraints
);
1541 delete m_constraints
;
1543 m_constraints
= constraints
;
1544 if ( m_constraints
)
1546 // Make sure other windows know they're part of a 'meaningful relationship'
1547 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1548 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1549 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1550 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1551 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1552 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1553 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1554 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1555 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1556 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1557 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1558 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1559 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1560 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1561 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1562 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1566 // This removes any dangling pointers to this window in other windows'
1567 // constraintsInvolvedIn lists.
1568 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1572 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1573 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1574 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1575 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1576 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1577 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1578 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1579 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1580 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1581 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1582 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1583 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1584 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1585 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1586 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1587 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1591 // Back-pointer to other windows we're involved with, so if we delete this
1592 // window, we must delete any constraints we're involved with.
1593 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
1595 if ( !m_constraintsInvolvedIn
)
1596 m_constraintsInvolvedIn
= new wxWindowList
;
1597 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
1598 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
1601 // REMOVE back-pointer to other windows we're involved with.
1602 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
1604 if ( m_constraintsInvolvedIn
)
1605 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
1608 // Reset any constraints that mention this window
1609 void wxWindowBase::DeleteRelatedConstraints()
1611 if ( m_constraintsInvolvedIn
)
1613 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
1616 wxWindow
*win
= node
->GetData();
1617 wxLayoutConstraints
*constr
= win
->GetConstraints();
1619 // Reset any constraints involving this window
1622 constr
->left
.ResetIfWin(this);
1623 constr
->top
.ResetIfWin(this);
1624 constr
->right
.ResetIfWin(this);
1625 constr
->bottom
.ResetIfWin(this);
1626 constr
->width
.ResetIfWin(this);
1627 constr
->height
.ResetIfWin(this);
1628 constr
->centreX
.ResetIfWin(this);
1629 constr
->centreY
.ResetIfWin(this);
1632 wxWindowList::compatibility_iterator next
= node
->GetNext();
1633 m_constraintsInvolvedIn
->Erase(node
);
1637 delete m_constraintsInvolvedIn
;
1638 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
1642 #endif // wxUSE_CONSTRAINTS
1644 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
1646 if ( sizer
== m_windowSizer
)
1650 delete m_windowSizer
;
1652 m_windowSizer
= sizer
;
1654 SetAutoLayout( sizer
!= NULL
);
1657 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
1659 SetSizer( sizer
, deleteOld
);
1660 sizer
->SetSizeHints( (wxWindow
*) this );
1664 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
1666 // adding a window to a sizer twice is going to result in fatal and
1667 // hard to debug problems later because when deleting the second
1668 // associated wxSizerItem we're going to dereference a dangling
1669 // pointer; so try to detect this as early as possible
1670 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
1671 _T("Adding a window to the same sizer twice?") );
1673 m_containingSizer
= sizer
;
1676 #if wxUSE_CONSTRAINTS
1678 void wxWindowBase::SatisfyConstraints()
1680 wxLayoutConstraints
*constr
= GetConstraints();
1681 bool wasOk
= constr
&& constr
->AreSatisfied();
1683 ResetConstraints(); // Mark all constraints as unevaluated
1687 // if we're a top level panel (i.e. our parent is frame/dialog), our
1688 // own constraints will never be satisfied any more unless we do it
1692 while ( noChanges
> 0 )
1694 LayoutPhase1(&noChanges
);
1698 LayoutPhase2(&noChanges
);
1701 #endif // wxUSE_CONSTRAINTS
1703 bool wxWindowBase::Layout()
1705 // If there is a sizer, use it instead of the constraints
1709 GetVirtualSize(&w
, &h
);
1710 GetSizer()->SetDimension( 0, 0, w
, h
);
1712 #if wxUSE_CONSTRAINTS
1715 SatisfyConstraints(); // Find the right constraints values
1716 SetConstraintSizes(); // Recursively set the real window sizes
1723 #if wxUSE_CONSTRAINTS
1725 // first phase of the constraints evaluation: set our own constraints
1726 bool wxWindowBase::LayoutPhase1(int *noChanges
)
1728 wxLayoutConstraints
*constr
= GetConstraints();
1730 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
1733 // second phase: set the constraints for our children
1734 bool wxWindowBase::LayoutPhase2(int *noChanges
)
1741 // Layout grand children
1747 // Do a phase of evaluating child constraints
1748 bool wxWindowBase::DoPhase(int phase
)
1750 // the list containing the children for which the constraints are already
1752 wxWindowList succeeded
;
1754 // the max number of iterations we loop before concluding that we can't set
1756 static const int maxIterations
= 500;
1758 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
1762 // loop over all children setting their constraints
1763 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1765 node
= node
->GetNext() )
1767 wxWindow
*child
= node
->GetData();
1768 if ( child
->IsTopLevel() )
1770 // top level children are not inside our client area
1774 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
1776 // this one is either already ok or nothing we can do about it
1780 int tempNoChanges
= 0;
1781 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
1782 : child
->LayoutPhase2(&tempNoChanges
);
1783 noChanges
+= tempNoChanges
;
1787 succeeded
.Append(child
);
1793 // constraints are set
1801 void wxWindowBase::ResetConstraints()
1803 wxLayoutConstraints
*constr
= GetConstraints();
1806 constr
->left
.SetDone(false);
1807 constr
->top
.SetDone(false);
1808 constr
->right
.SetDone(false);
1809 constr
->bottom
.SetDone(false);
1810 constr
->width
.SetDone(false);
1811 constr
->height
.SetDone(false);
1812 constr
->centreX
.SetDone(false);
1813 constr
->centreY
.SetDone(false);
1816 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1819 wxWindow
*win
= node
->GetData();
1820 if ( !win
->IsTopLevel() )
1821 win
->ResetConstraints();
1822 node
= node
->GetNext();
1826 // Need to distinguish between setting the 'fake' size for windows and sizers,
1827 // and setting the real values.
1828 void wxWindowBase::SetConstraintSizes(bool recurse
)
1830 wxLayoutConstraints
*constr
= GetConstraints();
1831 if ( constr
&& constr
->AreSatisfied() )
1833 int x
= constr
->left
.GetValue();
1834 int y
= constr
->top
.GetValue();
1835 int w
= constr
->width
.GetValue();
1836 int h
= constr
->height
.GetValue();
1838 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
1839 (constr
->height
.GetRelationship() != wxAsIs
) )
1841 SetSize(x
, y
, w
, h
);
1845 // If we don't want to resize this window, just move it...
1851 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
1852 GetClassInfo()->GetClassName(),
1858 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1861 wxWindow
*win
= node
->GetData();
1862 if ( !win
->IsTopLevel() && win
->GetConstraints() )
1863 win
->SetConstraintSizes();
1864 node
= node
->GetNext();
1869 // Only set the size/position of the constraint (if any)
1870 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
1872 wxLayoutConstraints
*constr
= GetConstraints();
1875 if ( x
!= wxDefaultCoord
)
1877 constr
->left
.SetValue(x
);
1878 constr
->left
.SetDone(true);
1880 if ( y
!= wxDefaultCoord
)
1882 constr
->top
.SetValue(y
);
1883 constr
->top
.SetDone(true);
1885 if ( w
!= wxDefaultCoord
)
1887 constr
->width
.SetValue(w
);
1888 constr
->width
.SetDone(true);
1890 if ( h
!= wxDefaultCoord
)
1892 constr
->height
.SetValue(h
);
1893 constr
->height
.SetDone(true);
1898 void wxWindowBase::MoveConstraint(int x
, int y
)
1900 wxLayoutConstraints
*constr
= GetConstraints();
1903 if ( x
!= wxDefaultCoord
)
1905 constr
->left
.SetValue(x
);
1906 constr
->left
.SetDone(true);
1908 if ( y
!= wxDefaultCoord
)
1910 constr
->top
.SetValue(y
);
1911 constr
->top
.SetDone(true);
1916 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
1918 wxLayoutConstraints
*constr
= GetConstraints();
1921 *w
= constr
->width
.GetValue();
1922 *h
= constr
->height
.GetValue();
1928 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
1930 wxLayoutConstraints
*constr
= GetConstraints();
1933 *w
= constr
->width
.GetValue();
1934 *h
= constr
->height
.GetValue();
1937 GetClientSize(w
, h
);
1940 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
1942 wxLayoutConstraints
*constr
= GetConstraints();
1945 *x
= constr
->left
.GetValue();
1946 *y
= constr
->top
.GetValue();
1952 #endif // wxUSE_CONSTRAINTS
1954 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
1956 // don't do it for the dialogs/frames - they float independently of their
1958 if ( !IsTopLevel() )
1960 wxWindow
*parent
= GetParent();
1961 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
1963 wxPoint
pt(parent
->GetClientAreaOrigin());
1970 // ----------------------------------------------------------------------------
1971 // do Update UI processing for child controls
1972 // ----------------------------------------------------------------------------
1974 void wxWindowBase::UpdateWindowUI(long flags
)
1976 wxUpdateUIEvent
event(GetId());
1977 event
.SetEventObject(this);
1979 if ( GetEventHandler()->ProcessEvent(event
) )
1981 DoUpdateWindowUI(event
);
1984 if (flags
& wxUPDATE_UI_RECURSE
)
1986 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1989 wxWindow
* child
= (wxWindow
*) node
->GetData();
1990 child
->UpdateWindowUI(flags
);
1991 node
= node
->GetNext();
1996 // do the window-specific processing after processing the update event
1997 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
1999 if ( event
.GetSetEnabled() )
2000 Enable(event
.GetEnabled());
2002 if ( event
.GetSetShown() )
2003 Show(event
.GetShown());
2007 // call internal idle recursively
2008 // may be obsolete (wait until OnIdle scheme stabilises)
2009 void wxWindowBase::ProcessInternalIdle()
2013 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2016 wxWindow
*child
= node
->GetData();
2017 child
->ProcessInternalIdle();
2018 node
= node
->GetNext();
2023 // ----------------------------------------------------------------------------
2024 // dialog units translations
2025 // ----------------------------------------------------------------------------
2027 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
2029 int charWidth
= GetCharWidth();
2030 int charHeight
= GetCharHeight();
2031 wxPoint pt2
= wxDefaultPosition
;
2032 if (pt
.x
!= wxDefaultCoord
)
2033 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
);
2034 if (pt
.y
!= wxDefaultCoord
)
2035 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2040 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2042 int charWidth
= GetCharWidth();
2043 int charHeight
= GetCharHeight();
2044 wxPoint pt2
= wxDefaultPosition
;
2045 if (pt
.x
!= wxDefaultCoord
)
2046 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2047 if (pt
.y
!= wxDefaultCoord
)
2048 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2053 // ----------------------------------------------------------------------------
2055 // ----------------------------------------------------------------------------
2057 // propagate the colour change event to the subwindows
2058 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2060 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2063 // Only propagate to non-top-level windows
2064 wxWindow
*win
= node
->GetData();
2065 if ( !win
->IsTopLevel() )
2067 wxSysColourChangedEvent event2
;
2068 event
.SetEventObject(win
);
2069 win
->GetEventHandler()->ProcessEvent(event2
);
2072 node
= node
->GetNext();
2078 // the default action is to populate dialog with data when it's created,
2079 // and nudge the UI into displaying itself correctly in case
2080 // we've turned the wxUpdateUIEvents frequency down low.
2081 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2083 TransferDataToWindow();
2085 // Update the UI at this point
2086 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2089 // methods for drawing the sizers in a visible way
2092 static void DrawSizers(wxWindowBase
*win
);
2094 static void DrawBorder(wxWindowBase
*win
, const wxRect
& rect
, bool fill
= false)
2096 wxClientDC
dc((wxWindow
*)win
);
2097 dc
.SetPen(*wxRED_PEN
);
2098 dc
.SetBrush(fill
? wxBrush(*wxRED
, wxCROSSDIAG_HATCH
): *wxTRANSPARENT_BRUSH
);
2099 dc
.DrawRectangle(rect
.Deflate(1, 1));
2102 static void DrawSizer(wxWindowBase
*win
, wxSizer
*sizer
)
2104 const wxSizerItemList
& items
= sizer
->GetChildren();
2105 for ( wxSizerItemList::const_iterator i
= items
.begin(),
2110 wxSizerItem
*item
= *i
;
2111 if ( item
->IsSizer() )
2113 DrawBorder(win
, item
->GetRect().Deflate(2));
2114 DrawSizer(win
, item
->GetSizer());
2116 else if ( item
->IsSpacer() )
2118 DrawBorder(win
, item
->GetRect().Deflate(2), true);
2120 else if ( item
->IsWindow() )
2122 DrawSizers(item
->GetWindow());
2127 static void DrawSizers(wxWindowBase
*win
)
2129 wxSizer
*sizer
= win
->GetSizer();
2132 DrawBorder(win
, win
->GetClientSize());
2133 DrawSizer(win
, sizer
);
2135 else // no sizer, still recurse into the children
2137 const wxWindowList
& children
= win
->GetChildren();
2138 for ( wxWindowList::const_iterator i
= children
.begin(),
2139 end
= children
.end();
2148 #endif // __WXDEBUG__
2150 // process special middle clicks
2151 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2153 if ( event
.ControlDown() && event
.AltDown() )
2156 // Ctrl-Alt-Shift-mclick makes the sizers visible in debug builds
2157 if ( event
.ShiftDown() )
2162 #endif // __WXDEBUG__
2165 // don't translate these strings
2168 #ifdef __WXUNIVERSAL__
2170 #endif // __WXUNIVERSAL__
2172 switch ( wxGetOsVersion() )
2174 case wxMOTIF_X
: port
+= _T("Motif"); break;
2176 case wxMAC_DARWIN
: port
+= _T("Mac"); break;
2177 case wxBEOS
: port
+= _T("BeOS"); break;
2181 case wxGTK_BEOS
: port
+= _T("GTK"); break;
2187 case wxWIN386
: port
+= _T("MS Windows"); break;
2191 case wxMGL_OS2
: port
+= _T("MGL"); break;
2193 case wxOS2_PM
: port
+= _T("OS/2"); break;
2194 case wxPALMOS
: port
+= _T("Palm OS"); break;
2195 case wxWINDOWS_CE
: port
+= _T("Windows CE (generic)"); break;
2196 case wxWINDOWS_POCKETPC
: port
+= _T("Windows CE PocketPC"); break;
2197 case wxWINDOWS_SMARTPHONE
: port
+= _T("Windows CE Smartphone"); break;
2198 default: port
+= _T("unknown"); break;
2201 wxMessageBox(wxString::Format(
2203 " wxWidgets Library (%s port)\nVersion %d.%d.%d%s%s, compiled at %s %s%s\n Copyright (c) 1995-2006 wxWidgets team"
2222 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()
2227 _T("wxWidgets information"),
2228 wxICON_INFORMATION
| wxOK
,
2232 #endif // wxUSE_MSGDLG
2238 // ----------------------------------------------------------------------------
2240 // ----------------------------------------------------------------------------
2242 #if wxUSE_ACCESSIBILITY
2243 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2245 if (m_accessible
&& (accessible
!= m_accessible
))
2246 delete m_accessible
;
2247 m_accessible
= accessible
;
2249 m_accessible
->SetWindow((wxWindow
*) this);
2252 // Returns the accessible object, creating if necessary.
2253 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2256 m_accessible
= CreateAccessible();
2257 return m_accessible
;
2260 // Override to create a specific accessible object.
2261 wxAccessible
* wxWindowBase::CreateAccessible()
2263 return new wxWindowAccessible((wxWindow
*) this);
2268 // ----------------------------------------------------------------------------
2269 // list classes implementation
2270 // ----------------------------------------------------------------------------
2274 #include "wx/listimpl.cpp"
2275 WX_DEFINE_LIST(wxWindowList
)
2279 void wxWindowListNode::DeleteData()
2281 delete (wxWindow
*)GetData();
2286 // ----------------------------------------------------------------------------
2288 // ----------------------------------------------------------------------------
2290 wxBorder
wxWindowBase::GetBorder(long flags
) const
2292 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2293 if ( border
== wxBORDER_DEFAULT
)
2295 border
= GetDefaultBorder();
2301 wxBorder
wxWindowBase::GetDefaultBorder() const
2303 return wxBORDER_NONE
;
2306 // ----------------------------------------------------------------------------
2308 // ----------------------------------------------------------------------------
2310 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2312 // here we just check if the point is inside the window or not
2314 // check the top and left border first
2315 bool outside
= x
< 0 || y
< 0;
2318 // check the right and bottom borders too
2319 wxSize size
= GetSize();
2320 outside
= x
>= size
.x
|| y
>= size
.y
;
2323 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2326 // ----------------------------------------------------------------------------
2328 // ----------------------------------------------------------------------------
2330 struct WXDLLEXPORT wxWindowNext
2334 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2336 void wxWindowBase::CaptureMouse()
2338 wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), this);
2340 wxWindow
*winOld
= GetCapture();
2343 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2346 wxWindowNext
*item
= new wxWindowNext
;
2348 item
->next
= ms_winCaptureNext
;
2349 ms_winCaptureNext
= item
;
2351 //else: no mouse capture to save
2356 void wxWindowBase::ReleaseMouse()
2358 wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), this);
2360 wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") );
2364 if ( ms_winCaptureNext
)
2366 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2368 wxWindowNext
*item
= ms_winCaptureNext
;
2369 ms_winCaptureNext
= item
->next
;
2372 //else: stack is empty, no previous capture
2374 wxLogTrace(_T("mousecapture"),
2375 (const wxChar
*) _T("After ReleaseMouse() mouse is captured by %p"),
2382 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2383 int WXUNUSED(modifiers
),
2384 int WXUNUSED(keycode
))
2390 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2396 #endif // wxUSE_HOTKEY
2398 void wxWindowBase::SendDestroyEvent()
2400 wxWindowDestroyEvent event
;
2401 event
.SetEventObject(this);
2402 event
.SetId(GetId());
2403 GetEventHandler()->ProcessEvent(event
);
2406 // ----------------------------------------------------------------------------
2408 // ----------------------------------------------------------------------------
2410 bool wxWindowBase::TryValidator(wxEvent
& wxVALIDATOR_PARAM(event
))
2412 #if wxUSE_VALIDATORS
2413 // Can only use the validator of the window which
2414 // is receiving the event
2415 if ( event
.GetEventObject() == this )
2417 wxValidator
*validator
= GetValidator();
2418 if ( validator
&& validator
->ProcessEvent(event
) )
2423 #endif // wxUSE_VALIDATORS
2428 bool wxWindowBase::TryParent(wxEvent
& event
)
2430 // carry on up the parent-child hierarchy if the propagation count hasn't
2432 if ( event
.ShouldPropagate() )
2434 // honour the requests to stop propagation at this window: this is
2435 // used by the dialogs, for example, to prevent processing the events
2436 // from the dialog controls in the parent frame which rarely, if ever,
2438 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2440 wxWindow
*parent
= GetParent();
2441 if ( parent
&& !parent
->IsBeingDeleted() )
2443 wxPropagateOnce
propagateOnce(event
);
2445 return parent
->GetEventHandler()->ProcessEvent(event
);
2450 return wxEvtHandler::TryParent(event
);
2453 // ----------------------------------------------------------------------------
2454 // keyboard navigation
2455 // ----------------------------------------------------------------------------
2457 // Navigates in the specified direction.
2458 bool wxWindowBase::Navigate(int flags
)
2460 wxNavigationKeyEvent eventNav
;
2461 eventNav
.SetFlags(flags
);
2462 eventNav
.SetEventObject(this);
2463 if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav
) )
2470 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, MoveKind move
)
2472 // check that we're not a top level window
2473 wxCHECK_RET( GetParent(),
2474 _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
2476 // detect the special case when we have nothing to do anyhow and when the
2477 // code below wouldn't work
2481 // find the target window in the siblings list
2482 wxWindowList
& siblings
= GetParent()->GetChildren();
2483 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
2484 wxCHECK_RET( i
, _T("MoveBefore/AfterInTabOrder(): win is not a sibling") );
2486 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
2487 // can't just move the node around
2488 wxWindow
*self
= (wxWindow
*)this;
2489 siblings
.DeleteObject(self
);
2490 if ( move
== MoveAfter
)
2497 siblings
.Insert(i
, self
);
2499 else // MoveAfter and win was the last sibling
2501 siblings
.Append(self
);
2505 // ----------------------------------------------------------------------------
2507 // ----------------------------------------------------------------------------
2509 /*static*/ wxWindow
* wxWindowBase::FindFocus()
2511 wxWindowBase
*win
= DoFindFocus();
2512 return win
? win
->GetMainWindowOfCompositeControl() : NULL
;
2515 // ----------------------------------------------------------------------------
2517 // ----------------------------------------------------------------------------
2519 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
2521 while ( win
&& !win
->IsTopLevel() )
2522 win
= win
->GetParent();
2527 #if wxUSE_ACCESSIBILITY
2528 // ----------------------------------------------------------------------------
2529 // accessible object for windows
2530 // ----------------------------------------------------------------------------
2532 // Can return either a child object, or an integer
2533 // representing the child element, starting from 1.
2534 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
2536 wxASSERT( GetWindow() != NULL
);
2540 return wxACC_NOT_IMPLEMENTED
;
2543 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
2544 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
2546 wxASSERT( GetWindow() != NULL
);
2550 wxWindow
* win
= NULL
;
2557 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
2559 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
2566 rect
= win
->GetRect();
2567 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
2568 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
2572 return wxACC_NOT_IMPLEMENTED
;
2575 // Navigates from fromId to toId/toObject.
2576 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
2577 int* WXUNUSED(toId
), wxAccessible
** toObject
)
2579 wxASSERT( GetWindow() != NULL
);
2585 case wxNAVDIR_FIRSTCHILD
:
2587 if (GetWindow()->GetChildren().GetCount() == 0)
2589 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
2590 *toObject
= childWindow
->GetOrCreateAccessible();
2594 case wxNAVDIR_LASTCHILD
:
2596 if (GetWindow()->GetChildren().GetCount() == 0)
2598 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
2599 *toObject
= childWindow
->GetOrCreateAccessible();
2603 case wxNAVDIR_RIGHT
:
2607 wxWindowList::compatibility_iterator node
=
2608 wxWindowList::compatibility_iterator();
2611 // Can't navigate to sibling of this window
2612 // if we're a top-level window.
2613 if (!GetWindow()->GetParent())
2614 return wxACC_NOT_IMPLEMENTED
;
2616 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2620 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2621 node
= GetWindow()->GetChildren().Item(fromId
-1);
2624 if (node
&& node
->GetNext())
2626 wxWindow
* nextWindow
= node
->GetNext()->GetData();
2627 *toObject
= nextWindow
->GetOrCreateAccessible();
2635 case wxNAVDIR_PREVIOUS
:
2637 wxWindowList::compatibility_iterator node
=
2638 wxWindowList::compatibility_iterator();
2641 // Can't navigate to sibling of this window
2642 // if we're a top-level window.
2643 if (!GetWindow()->GetParent())
2644 return wxACC_NOT_IMPLEMENTED
;
2646 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2650 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2651 node
= GetWindow()->GetChildren().Item(fromId
-1);
2654 if (node
&& node
->GetPrevious())
2656 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
2657 *toObject
= previousWindow
->GetOrCreateAccessible();
2665 return wxACC_NOT_IMPLEMENTED
;
2668 // Gets the name of the specified object.
2669 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
2671 wxASSERT( GetWindow() != NULL
);
2677 // If a child, leave wxWidgets to call the function on the actual
2680 return wxACC_NOT_IMPLEMENTED
;
2682 // This will eventually be replaced by specialised
2683 // accessible classes, one for each kind of wxWidgets
2684 // control or window.
2686 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
2687 title
= ((wxButton
*) GetWindow())->GetLabel();
2690 title
= GetWindow()->GetName();
2698 return wxACC_NOT_IMPLEMENTED
;
2701 // Gets the number of children.
2702 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
2704 wxASSERT( GetWindow() != NULL
);
2708 *childId
= (int) GetWindow()->GetChildren().GetCount();
2712 // Gets the specified child (starting from 1).
2713 // If *child is NULL and return value is wxACC_OK,
2714 // this means that the child is a simple element and
2715 // not an accessible object.
2716 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
2718 wxASSERT( GetWindow() != NULL
);
2728 if (childId
> (int) GetWindow()->GetChildren().GetCount())
2731 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
2732 *child
= childWindow
->GetOrCreateAccessible();
2739 // Gets the parent, or NULL.
2740 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
2742 wxASSERT( GetWindow() != NULL
);
2746 wxWindow
* parentWindow
= GetWindow()->GetParent();
2754 *parent
= parentWindow
->GetOrCreateAccessible();
2762 // Performs the default action. childId is 0 (the action for this object)
2763 // or > 0 (the action for a child).
2764 // Return wxACC_NOT_SUPPORTED if there is no default action for this
2765 // window (e.g. an edit control).
2766 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
2768 wxASSERT( GetWindow() != NULL
);
2772 return wxACC_NOT_IMPLEMENTED
;
2775 // Gets the default action for this object (0) or > 0 (the action for a child).
2776 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
2777 // string if there is no action.
2778 // The retrieved string describes the action that is performed on an object,
2779 // not what the object does as a result. For example, a toolbar button that prints
2780 // a document has a default action of "Press" rather than "Prints the current document."
2781 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
2783 wxASSERT( GetWindow() != NULL
);
2787 return wxACC_NOT_IMPLEMENTED
;
2790 // Returns the description for this object or a child.
2791 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
2793 wxASSERT( GetWindow() != NULL
);
2797 wxString
ht(GetWindow()->GetHelpText());
2803 return wxACC_NOT_IMPLEMENTED
;
2806 // Returns help text for this object or a child, similar to tooltip text.
2807 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
2809 wxASSERT( GetWindow() != NULL
);
2813 wxString
ht(GetWindow()->GetHelpText());
2819 return wxACC_NOT_IMPLEMENTED
;
2822 // Returns the keyboard shortcut for this object or child.
2823 // Return e.g. ALT+K
2824 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
2826 wxASSERT( GetWindow() != NULL
);
2830 return wxACC_NOT_IMPLEMENTED
;
2833 // Returns a role constant.
2834 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
2836 wxASSERT( GetWindow() != NULL
);
2840 // If a child, leave wxWidgets to call the function on the actual
2843 return wxACC_NOT_IMPLEMENTED
;
2845 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2846 return wxACC_NOT_IMPLEMENTED
;
2848 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2849 return wxACC_NOT_IMPLEMENTED
;
2852 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2853 return wxACC_NOT_IMPLEMENTED
;
2856 //*role = wxROLE_SYSTEM_CLIENT;
2857 *role
= wxROLE_SYSTEM_CLIENT
;
2861 return wxACC_NOT_IMPLEMENTED
;
2865 // Returns a state constant.
2866 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
2868 wxASSERT( GetWindow() != NULL
);
2872 // If a child, leave wxWidgets to call the function on the actual
2875 return wxACC_NOT_IMPLEMENTED
;
2877 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2878 return wxACC_NOT_IMPLEMENTED
;
2881 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2882 return wxACC_NOT_IMPLEMENTED
;
2885 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2886 return wxACC_NOT_IMPLEMENTED
;
2893 return wxACC_NOT_IMPLEMENTED
;
2897 // Returns a localized string representing the value for the object
2899 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
2901 wxASSERT( GetWindow() != NULL
);
2905 return wxACC_NOT_IMPLEMENTED
;
2908 // Selects the object or child.
2909 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
2911 wxASSERT( GetWindow() != NULL
);
2915 return wxACC_NOT_IMPLEMENTED
;
2918 // Gets the window with the keyboard focus.
2919 // If childId is 0 and child is NULL, no object in
2920 // this subhierarchy has the focus.
2921 // If this object has the focus, child should be 'this'.
2922 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
2924 wxASSERT( GetWindow() != NULL
);
2928 return wxACC_NOT_IMPLEMENTED
;
2931 // Gets a variant representing the selected children
2933 // Acceptable values:
2934 // - a null variant (IsNull() returns true)
2935 // - a list variant (GetType() == wxT("list")
2936 // - an integer representing the selected child element,
2937 // or 0 if this object is selected (GetType() == wxT("long")
2938 // - a "void*" pointer to a wxAccessible child object
2939 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
2941 wxASSERT( GetWindow() != NULL
);
2945 return wxACC_NOT_IMPLEMENTED
;
2948 #endif // wxUSE_ACCESSIBILITY