1 /////////////////////////////////////////////////////////////////////////////
2 // Name: common/window.cpp
3 // Purpose: common (to all ports) wxWindow functions
4 // Author: Julian Smart, Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "windowbase.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
32 #include "wx/string.h"
37 #include "wx/window.h"
38 #include "wx/control.h"
39 #include "wx/checkbox.h"
40 #include "wx/radiobut.h"
41 #include "wx/statbox.h"
42 #include "wx/textctrl.h"
43 #include "wx/settings.h"
44 #include "wx/dialog.h"
45 #include "wx/msgdlg.h"
46 #include "wx/statusbr.h"
47 #include "wx/dcclient.h"
50 #if defined(__WXMAC__) && wxUSE_SCROLLBAR
51 #include "wx/scrolbar.h"
55 #include "wx/layout.h"
56 #endif // wxUSE_CONSTRAINTS
60 #if wxUSE_DRAG_AND_DROP
62 #endif // wxUSE_DRAG_AND_DROP
64 #if wxUSE_ACCESSIBILITY
65 #include "wx/access.h"
69 #include "wx/cshelp.h"
73 #include "wx/tooltip.h"
74 #endif // wxUSE_TOOLTIPS
80 #if wxUSE_SYSTEM_OPTIONS
81 #include "wx/sysopt.h"
84 // ----------------------------------------------------------------------------
86 // ----------------------------------------------------------------------------
88 #if defined(__WXPALMOS__)
89 int wxWindowBase::ms_lastControlId
= 32767;
90 #elif defined(__WXPM__)
91 int wxWindowBase::ms_lastControlId
= 2000;
93 int wxWindowBase::ms_lastControlId
= -200;
96 IMPLEMENT_ABSTRACT_CLASS(wxWindowBase
, wxEvtHandler
)
98 // ----------------------------------------------------------------------------
100 // ----------------------------------------------------------------------------
102 BEGIN_EVENT_TABLE(wxWindowBase
, wxEvtHandler
)
103 EVT_SYS_COLOUR_CHANGED(wxWindowBase::OnSysColourChanged
)
104 EVT_INIT_DIALOG(wxWindowBase::OnInitDialog
)
105 EVT_MIDDLE_DOWN(wxWindowBase::OnMiddleClick
)
108 EVT_HELP(wxID_ANY
, wxWindowBase::OnHelp
)
113 // ============================================================================
114 // implementation of the common functionality of the wxWindow class
115 // ============================================================================
117 // ----------------------------------------------------------------------------
119 // ----------------------------------------------------------------------------
121 // the default initialization
122 wxWindowBase::wxWindowBase()
124 // no window yet, no parent nor children
125 m_parent
= (wxWindow
*)NULL
;
126 m_windowId
= wxID_ANY
;
128 // no constraints on the minimal window size
130 m_maxWidth
= wxDefaultCoord
;
132 m_maxHeight
= wxDefaultCoord
;
134 // invalidiated cache value
135 m_bestSizeCache
= wxDefaultSize
;
137 // window are created enabled and visible by default
141 // the default event handler is just this window
142 m_eventHandler
= this;
146 m_windowValidator
= (wxValidator
*) NULL
;
147 #endif // wxUSE_VALIDATORS
149 // the colours/fonts are default for now, so leave m_font,
150 // m_backgroundColour and m_foregroundColour uninitialized and set those
156 m_inheritFont
= false;
162 m_backgroundStyle
= wxBG_STYLE_SYSTEM
;
164 #if wxUSE_CONSTRAINTS
165 // no constraints whatsoever
166 m_constraints
= (wxLayoutConstraints
*) NULL
;
167 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
168 #endif // wxUSE_CONSTRAINTS
170 m_windowSizer
= (wxSizer
*) NULL
;
171 m_containingSizer
= (wxSizer
*) NULL
;
172 m_autoLayout
= false;
174 #if wxUSE_DRAG_AND_DROP
175 m_dropTarget
= (wxDropTarget
*)NULL
;
176 #endif // wxUSE_DRAG_AND_DROP
179 m_tooltip
= (wxToolTip
*)NULL
;
180 #endif // wxUSE_TOOLTIPS
183 m_caret
= (wxCaret
*)NULL
;
184 #endif // wxUSE_CARET
187 m_hasCustomPalette
= false;
188 #endif // wxUSE_PALETTE
190 #if wxUSE_ACCESSIBILITY
194 m_virtualSize
= wxDefaultSize
;
197 m_maxVirtualWidth
= wxDefaultCoord
;
199 m_maxVirtualHeight
= wxDefaultCoord
;
201 m_windowVariant
= wxWINDOW_VARIANT_NORMAL
;
202 #if wxUSE_SYSTEM_OPTIONS
203 if ( wxSystemOptions::HasOption(wxWINDOW_DEFAULT_VARIANT
) )
205 m_windowVariant
= (wxWindowVariant
) wxSystemOptions::GetOptionInt( wxWINDOW_DEFAULT_VARIANT
) ;
209 // Whether we're using the current theme for this window (wxGTK only for now)
210 m_themeEnabled
= false;
212 // VZ: this one shouldn't exist...
213 m_isBeingDeleted
= false;
216 // common part of window creation process
217 bool wxWindowBase::CreateBase(wxWindowBase
*parent
,
219 const wxPoint
& WXUNUSED(pos
),
220 const wxSize
& WXUNUSED(size
),
222 const wxValidator
& wxVALIDATOR_PARAM(validator
),
223 const wxString
& name
)
226 // wxGTK doesn't allow to create controls with static box as the parent so
227 // this will result in a crash when the program is ported to wxGTK so warn
230 // if you get this assert, the correct solution is to create the controls
231 // as siblings of the static box
232 wxASSERT_MSG( !parent
|| !wxDynamicCast(parent
, wxStaticBox
),
233 _T("wxStaticBox can't be used as a window parent!") );
234 #endif // wxUSE_STATBOX
236 // ids are limited to 16 bits under MSW so if you care about portability,
237 // it's not a good idea to use ids out of this range (and negative ids are
238 // reserved for wxWidgets own usage)
239 wxASSERT_MSG( id
== wxID_ANY
|| (id
>= 0 && id
< 32767),
240 _T("invalid id value") );
242 // generate a new id if the user doesn't care about it
243 m_windowId
= id
== wxID_ANY
? NewControlId() : id
;
246 SetWindowStyleFlag(style
);
250 SetValidator(validator
);
251 #endif // wxUSE_VALIDATORS
253 // if the parent window has wxWS_EX_VALIDATE_RECURSIVELY set, we want to
254 // have it too - like this it's possible to set it only in the top level
255 // dialog/frame and all children will inherit it by defult
256 if ( parent
&& (parent
->GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) )
258 SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY
);
264 // ----------------------------------------------------------------------------
266 // ----------------------------------------------------------------------------
269 wxWindowBase::~wxWindowBase()
271 wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") );
273 // FIXME if these 2 cases result from programming errors in the user code
274 // we should probably assert here instead of silently fixing them
276 // Just in case the window has been Closed, but we're then deleting
277 // immediately: don't leave dangling pointers.
278 wxPendingDelete
.DeleteObject(this);
280 // Just in case we've loaded a top-level window via LoadNativeDialog but
281 // we weren't a dialog class
282 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
284 wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
286 // reset the dangling pointer our parent window may keep to us
289 if ( m_parent
->GetDefaultItem() == this )
291 m_parent
->SetDefaultItem(NULL
);
294 m_parent
->RemoveChild(this);
299 #endif // wxUSE_CARET
302 delete m_windowValidator
;
303 #endif // wxUSE_VALIDATORS
305 #if wxUSE_CONSTRAINTS
306 // Have to delete constraints/sizer FIRST otherwise sizers may try to look
307 // at deleted windows as they delete themselves.
308 DeleteRelatedConstraints();
312 // This removes any dangling pointers to this window in other windows'
313 // constraintsInvolvedIn lists.
314 UnsetConstraints(m_constraints
);
315 delete m_constraints
;
316 m_constraints
= NULL
;
318 #endif // wxUSE_CONSTRAINTS
320 if ( m_containingSizer
)
321 m_containingSizer
->Detach( (wxWindow
*)this );
323 delete m_windowSizer
;
325 #if wxUSE_DRAG_AND_DROP
327 #endif // wxUSE_DRAG_AND_DROP
331 #endif // wxUSE_TOOLTIPS
333 #if wxUSE_ACCESSIBILITY
338 bool wxWindowBase::Destroy()
345 bool wxWindowBase::Close(bool force
)
347 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
348 event
.SetEventObject(this);
349 event
.SetCanVeto(!force
);
351 // return false if window wasn't closed because the application vetoed the
353 return GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto();
356 bool wxWindowBase::DestroyChildren()
358 wxWindowList::compatibility_iterator node
;
361 // we iterate until the list becomes empty
362 node
= GetChildren().GetFirst();
366 wxWindow
*child
= node
->GetData();
368 // note that we really want to call delete and not ->Destroy() here
369 // because we want to delete the child immediately, before we are
370 // deleted, and delayed deletion would result in problems as our (top
371 // level) child could outlive its parent
374 wxASSERT_MSG( !GetChildren().Find(child
),
375 wxT("child didn't remove itself using RemoveChild()") );
381 // ----------------------------------------------------------------------------
382 // size/position related methods
383 // ----------------------------------------------------------------------------
385 // centre the window with respect to its parent in either (or both) directions
386 void wxWindowBase::Centre(int direction
)
388 // the position/size of the parent window or of the entire screen
390 int widthParent
, heightParent
;
392 wxWindow
*parent
= NULL
;
393 wxTopLevelWindow
*winTop
= NULL
;
395 if ( !(direction
& wxCENTRE_ON_SCREEN
) )
397 // find the parent to centre this window on: it should be the
398 // immediate parent for the controls but the top level parent for the
399 // top level windows (like dialogs)
400 parent
= GetParent();
403 while ( parent
&& !parent
->IsTopLevel() )
405 parent
= parent
->GetParent();
409 // there is no wxTopLevelWindow under wxMotif yet
411 // we shouldn't center the dialog on the iconized window: under
412 // Windows, for example, this places it completely off the screen
415 winTop
= wxDynamicCast(parent
, wxTopLevelWindow
);
416 if ( winTop
&& winTop
->IsIconized() )
422 #endif // __WXMOTIF__
424 // did we find the parent?
428 direction
|= wxCENTRE_ON_SCREEN
;
432 if ( direction
& wxCENTRE_ON_SCREEN
)
434 // centre with respect to the whole screen
435 wxDisplaySize(&widthParent
, &heightParent
);
442 winTop
->GetRectForTopLevelChildren(&posParent
.x
, &posParent
.y
, &widthParent
, &heightParent
);
445 // centre on the parent
446 parent
->GetSize(&widthParent
, &heightParent
);
448 // adjust to the parents position
449 posParent
= parent
->GetPosition();
454 // centre inside the parents client rectangle
455 parent
->GetClientSize(&widthParent
, &heightParent
);
460 GetSize(&width
, &height
);
462 int xNew
= wxDefaultCoord
,
463 yNew
= wxDefaultCoord
;
465 if ( direction
& wxHORIZONTAL
)
466 xNew
= (widthParent
- width
)/2;
468 if ( direction
& wxVERTICAL
)
469 yNew
= (heightParent
- height
)/2;
474 // Base size of the visible dimensions of the display
475 // to take into account the taskbar. And the Mac menu bar at top.
476 wxRect clientrect
= wxGetClientDisplayRect();
478 // NB: in wxMSW, negative position may not neccessary mean "out of screen",
479 // but it may mean that the window is placed on other than the main
480 // display. Therefore we only make sure centered window is on the main display
481 // if the parent is at least partially present here.
482 if (posParent
.x
+ widthParent
>= 0) // if parent is (partially) on the main display
484 if (xNew
< clientrect
.GetLeft())
485 xNew
= clientrect
.GetLeft();
486 else if (xNew
+ width
> clientrect
.GetRight())
487 xNew
= clientrect
.GetRight() - width
;
489 if (posParent
.y
+ heightParent
>= 0) // if parent is (partially) on the main display
491 if (yNew
+ height
> clientrect
.GetBottom())
492 yNew
= clientrect
.GetBottom() - height
;
494 // Make certain that the title bar is initially visible
495 // always, even if this would push the bottom of the
496 // dialog off the visible area of the display
497 if (yNew
< clientrect
.GetTop())
498 yNew
= clientrect
.GetTop();
501 // move the window to this position (keeping the old size but using
502 // SetSize() and not Move() to allow xNew and/or yNew to be wxDefaultCoord)
503 SetSize(xNew
, yNew
, width
, height
, wxSIZE_ALLOW_MINUS_ONE
);
506 // fits the window around the children
507 void wxWindowBase::Fit()
509 if ( GetChildren().GetCount() > 0 )
511 SetSize(GetBestSize());
513 //else: do nothing if we have no children
516 // fits virtual size (ie. scrolled area etc.) around children
517 void wxWindowBase::FitInside()
519 if ( GetChildren().GetCount() > 0 )
521 SetVirtualSize( GetBestVirtualSize() );
525 // On Mac, scrollbars are explicitly children.
527 static bool wxHasRealChildren(const wxWindowBase
* win
)
529 int realChildCount
= 0;
531 for ( wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
533 node
= node
->GetNext() )
535 wxWindow
*win
= node
->GetData();
536 if ( !win
->IsTopLevel() && win
->IsShown() && !win
->IsKindOf(CLASSINFO(wxScrollBar
)))
539 return (realChildCount
> 0);
543 void wxWindowBase::InvalidateBestSize()
545 m_bestSizeCache
= wxDefaultSize
;
547 // parent's best size calculation may depend on its children's
548 // best sizes, so let's invalidate it as well to be safe:
550 m_parent
->InvalidateBestSize();
553 // return the size best suited for the current window
554 wxSize
wxWindowBase::DoGetBestSize() const
560 best
= m_windowSizer
->GetMinSize();
562 #if wxUSE_CONSTRAINTS
563 else if ( m_constraints
)
565 wxConstCast(this, wxWindowBase
)->SatisfyConstraints();
567 // our minimal acceptable size is such that all our windows fit inside
571 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
573 node
= node
->GetNext() )
575 wxLayoutConstraints
*c
= node
->GetData()->GetConstraints();
578 // it's not normal that we have an unconstrained child, but
579 // what can we do about it?
583 int x
= c
->right
.GetValue(),
584 y
= c
->bottom
.GetValue();
592 // TODO: we must calculate the overlaps somehow, otherwise we
593 // will never return a size bigger than the current one :-(
596 best
= wxSize(maxX
, maxY
);
598 #endif // wxUSE_CONSTRAINTS
599 else if ( !GetChildren().empty()
601 && wxHasRealChildren(this)
605 // our minimal acceptable size is such that all our visible child windows fit inside
609 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
611 node
= node
->GetNext() )
613 wxWindow
*win
= node
->GetData();
614 if ( win
->IsTopLevel() || ( ! win
->IsShown() )
616 || wxDynamicCast(win
, wxStatusBar
)
617 #endif // wxUSE_STATUSBAR
620 // dialogs and frames lie in different top level windows -
621 // don't deal with them here; as for the status bars, they
622 // don't lie in the client area at all
627 win
->GetPosition(&wx
, &wy
);
629 // if the window hadn't been positioned yet, assume that it is in
631 if ( wx
== wxDefaultCoord
)
633 if ( wy
== wxDefaultCoord
)
636 win
->GetSize(&ww
, &wh
);
637 if ( wx
+ ww
> maxX
)
639 if ( wy
+ wh
> maxY
)
643 // for compatibility with the old versions and because it really looks
644 // slightly more pretty like this, add a pad
648 best
= wxSize(maxX
, maxY
);
650 else // ! has children
652 // For a generic window there is no natural best size - just use
653 // either the minimum size if there is one, or the current size.
654 // These are returned as-is, unadjusted by the client size difference.
655 if ( GetMinSize().IsFullySpecified() )
661 // Add any difference between size and client size
662 wxSize diff
= GetSize() - GetClientSize();
663 best
.x
+= wxMax(0, diff
.x
);
664 best
.y
+= wxMax(0, diff
.y
);
670 wxSize
wxWindowBase::GetBestFittingSize() const
672 // merge the best size with the min size, giving priority to the min size
673 wxSize min
= GetMinSize();
674 if (min
.x
== wxDefaultCoord
|| min
.y
== wxDefaultCoord
)
676 wxSize best
= GetBestSize();
677 if (min
.x
== wxDefaultCoord
) min
.x
= best
.x
;
678 if (min
.y
== wxDefaultCoord
) min
.y
= best
.y
;
684 void wxWindowBase::SetBestFittingSize(const wxSize
& size
)
686 // Set the min size to the size passed in. This will usually either be
687 // wxDefaultSize or the size passed to this window's ctor/Create function.
690 // Merge the size with the best size if needed
691 wxSize best
= GetBestFittingSize();
693 // If the current size doesn't match then change it
694 if (GetSize() != best
)
699 // by default the origin is not shifted
700 wxPoint
wxWindowBase::GetClientAreaOrigin() const
705 // set the min/max size of the window
706 void wxWindowBase::DoSetSizeHints(int minW
, int minH
,
708 int WXUNUSED(incW
), int WXUNUSED(incH
))
710 // setting min width greater than max width leads to infinite loops under
711 // X11 and generally doesn't make any sense, so don't allow it
712 wxCHECK_RET( (minW
== wxDefaultCoord
|| maxW
== wxDefaultCoord
|| minW
<= maxW
) &&
713 (minH
== wxDefaultCoord
|| maxH
== wxDefaultCoord
|| minH
<= maxH
),
714 _T("min width/height must be less than max width/height!") );
722 void wxWindowBase::SetWindowVariant( wxWindowVariant variant
)
724 if ( m_windowVariant
!= variant
)
726 m_windowVariant
= variant
;
728 DoSetWindowVariant(variant
);
732 void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant
)
734 // adjust the font height to correspond to our new variant (notice that
735 // we're only called if something really changed)
736 wxFont font
= GetFont();
737 int size
= font
.GetPointSize();
740 case wxWINDOW_VARIANT_NORMAL
:
743 case wxWINDOW_VARIANT_SMALL
:
748 case wxWINDOW_VARIANT_MINI
:
753 case wxWINDOW_VARIANT_LARGE
:
759 wxFAIL_MSG(_T("unexpected window variant"));
763 font
.SetPointSize(size
);
767 void wxWindowBase::SetVirtualSizeHints( int minW
, int minH
,
770 m_minVirtualWidth
= minW
;
771 m_maxVirtualWidth
= maxW
;
772 m_minVirtualHeight
= minH
;
773 m_maxVirtualHeight
= maxH
;
776 void wxWindowBase::DoSetVirtualSize( int x
, int y
)
778 if ( m_minVirtualWidth
!= wxDefaultCoord
&& m_minVirtualWidth
> x
)
779 x
= m_minVirtualWidth
;
780 if ( m_maxVirtualWidth
!= wxDefaultCoord
&& m_maxVirtualWidth
< x
)
781 x
= m_maxVirtualWidth
;
782 if ( m_minVirtualHeight
!= wxDefaultCoord
&& m_minVirtualHeight
> y
)
783 y
= m_minVirtualHeight
;
784 if ( m_maxVirtualHeight
!= wxDefaultCoord
&& m_maxVirtualHeight
< y
)
785 y
= m_maxVirtualHeight
;
787 m_virtualSize
= wxSize(x
, y
);
790 wxSize
wxWindowBase::DoGetVirtualSize() const
792 if (m_virtualSize
== wxDefaultSize
)
793 return GetClientSize();
795 return m_virtualSize
;
798 // ----------------------------------------------------------------------------
799 // show/hide/enable/disable the window
800 // ----------------------------------------------------------------------------
802 bool wxWindowBase::Show(bool show
)
804 if ( show
!= m_isShown
)
816 bool wxWindowBase::Enable(bool enable
)
818 if ( enable
!= m_isEnabled
)
820 m_isEnabled
= enable
;
829 // ----------------------------------------------------------------------------
831 // ----------------------------------------------------------------------------
833 bool wxWindowBase::IsTopLevel() const
838 // ----------------------------------------------------------------------------
839 // reparenting the window
840 // ----------------------------------------------------------------------------
842 void wxWindowBase::AddChild(wxWindowBase
*child
)
844 wxCHECK_RET( child
, wxT("can't add a NULL child") );
846 // this should never happen and it will lead to a crash later if it does
847 // because RemoveChild() will remove only one node from the children list
848 // and the other(s) one(s) will be left with dangling pointers in them
849 wxASSERT_MSG( !GetChildren().Find((wxWindow
*)child
), _T("AddChild() called twice") );
851 GetChildren().Append((wxWindow
*)child
);
852 child
->SetParent(this);
855 void wxWindowBase::RemoveChild(wxWindowBase
*child
)
857 wxCHECK_RET( child
, wxT("can't remove a NULL child") );
859 GetChildren().DeleteObject((wxWindow
*)child
);
860 child
->SetParent(NULL
);
863 bool wxWindowBase::Reparent(wxWindowBase
*newParent
)
865 wxWindow
*oldParent
= GetParent();
866 if ( newParent
== oldParent
)
872 // unlink this window from the existing parent.
875 oldParent
->RemoveChild(this);
879 wxTopLevelWindows
.DeleteObject((wxWindow
*)this);
882 // add it to the new one
885 newParent
->AddChild(this);
889 wxTopLevelWindows
.Append((wxWindow
*)this);
895 // ----------------------------------------------------------------------------
896 // event handler stuff
897 // ----------------------------------------------------------------------------
899 void wxWindowBase::PushEventHandler(wxEvtHandler
*handler
)
901 wxEvtHandler
*handlerOld
= GetEventHandler();
903 handler
->SetNextHandler(handlerOld
);
906 GetEventHandler()->SetPreviousHandler(handler
);
908 SetEventHandler(handler
);
911 wxEvtHandler
*wxWindowBase::PopEventHandler(bool deleteHandler
)
913 wxEvtHandler
*handlerA
= GetEventHandler();
916 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
917 handlerA
->SetNextHandler((wxEvtHandler
*)NULL
);
920 handlerB
->SetPreviousHandler((wxEvtHandler
*)NULL
);
921 SetEventHandler(handlerB
);
926 handlerA
= (wxEvtHandler
*)NULL
;
933 bool wxWindowBase::RemoveEventHandler(wxEvtHandler
*handler
)
935 wxCHECK_MSG( handler
, false, _T("RemoveEventHandler(NULL) called") );
937 wxEvtHandler
*handlerPrev
= NULL
,
938 *handlerCur
= GetEventHandler();
941 wxEvtHandler
*handlerNext
= handlerCur
->GetNextHandler();
943 if ( handlerCur
== handler
)
947 handlerPrev
->SetNextHandler(handlerNext
);
951 SetEventHandler(handlerNext
);
956 handlerNext
->SetPreviousHandler ( handlerPrev
);
959 handler
->SetNextHandler(NULL
);
960 handler
->SetPreviousHandler(NULL
);
965 handlerPrev
= handlerCur
;
966 handlerCur
= handlerNext
;
969 wxFAIL_MSG( _T("where has the event handler gone?") );
974 // ----------------------------------------------------------------------------
976 // ----------------------------------------------------------------------------
978 void wxWindowBase::InheritAttributes()
980 const wxWindowBase
* const parent
= GetParent();
984 // we only inherit attributes which had been explicitly set for the parent
985 // which ensures that this only happens if the user really wants it and
986 // not by default which wouldn't make any sense in modern GUIs where the
987 // controls don't all use the same fonts (nor colours)
988 if ( parent
->m_inheritFont
&& !m_hasFont
)
989 SetFont(parent
->GetFont());
991 // in addition, there is a possibility to explicitly forbid inheriting
992 // colours at each class level by overriding ShouldInheritColours()
993 if ( ShouldInheritColours() )
995 if ( parent
->m_inheritFgCol
&& !m_hasFgCol
)
996 SetForegroundColour(parent
->GetForegroundColour());
998 // inheriting (solid) background colour is wrong as it totally breaks
999 // any kind of themed backgrounds
1001 // instead, the controls should use the same background as their parent
1002 // (ideally by not drawing it at all)
1004 if ( parent
->m_inheritBgCol
&& !m_hasBgCol
)
1005 SetBackgroundColour(parent
->GetBackgroundColour());
1010 /* static */ wxVisualAttributes
1011 wxWindowBase::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
1013 // it is important to return valid values for all attributes from here,
1014 // GetXXX() below rely on this
1015 wxVisualAttributes attrs
;
1016 attrs
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
1017 attrs
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
1018 attrs
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
);
1023 wxColour
wxWindowBase::GetBackgroundColour() const
1025 if ( !m_backgroundColour
.Ok() )
1027 wxASSERT_MSG( !m_hasBgCol
, _T("we have invalid explicit bg colour?") );
1029 // get our default background colour
1030 wxColour colBg
= GetDefaultAttributes().colBg
;
1032 // we must return some valid colour to avoid redoing this every time
1033 // and also to avoid surprizing the applications written for older
1034 // wxWidgets versions where GetBackgroundColour() always returned
1035 // something -- so give them something even if it doesn't make sense
1036 // for this window (e.g. it has a themed background)
1038 colBg
= GetClassDefaultAttributes().colBg
;
1043 return m_backgroundColour
;
1046 wxColour
wxWindowBase::GetForegroundColour() const
1048 // logic is the same as above
1049 if ( !m_hasFgCol
&& !m_foregroundColour
.Ok() )
1051 wxASSERT_MSG( !m_hasFgCol
, _T("we have invalid explicit fg colour?") );
1053 wxColour colFg
= GetDefaultAttributes().colFg
;
1056 colFg
= GetClassDefaultAttributes().colFg
;
1061 return m_foregroundColour
;
1064 bool wxWindowBase::SetBackgroundColour( const wxColour
&colour
)
1066 if ( colour
== m_backgroundColour
)
1069 m_hasBgCol
= colour
.Ok();
1070 if ( m_backgroundStyle
!= wxBG_STYLE_CUSTOM
)
1071 m_backgroundStyle
= m_hasBgCol
? wxBG_STYLE_COLOUR
: wxBG_STYLE_SYSTEM
;
1073 m_inheritBgCol
= m_hasBgCol
;
1074 m_backgroundColour
= colour
;
1075 SetThemeEnabled( !m_hasBgCol
&& !m_foregroundColour
.Ok() );
1079 bool wxWindowBase::SetForegroundColour( const wxColour
&colour
)
1081 if (colour
== m_foregroundColour
)
1084 m_hasFgCol
= colour
.Ok();
1085 m_inheritFgCol
= m_hasFgCol
;
1086 m_foregroundColour
= colour
;
1087 SetThemeEnabled( !m_hasFgCol
&& !m_backgroundColour
.Ok() );
1091 bool wxWindowBase::SetCursor(const wxCursor
& cursor
)
1093 // setting an invalid cursor is ok, it means that we don't have any special
1095 if ( m_cursor
== cursor
)
1106 wxFont
wxWindowBase::GetFont() const
1108 // logic is the same as in GetBackgroundColour()
1111 wxASSERT_MSG( !m_hasFont
, _T("we have invalid explicit font?") );
1113 wxFont font
= GetDefaultAttributes().font
;
1115 font
= GetClassDefaultAttributes().font
;
1123 bool wxWindowBase::SetFont(const wxFont
& font
)
1125 if ( font
== m_font
)
1132 m_hasFont
= font
.Ok();
1133 m_inheritFont
= m_hasFont
;
1135 InvalidateBestSize();
1142 void wxWindowBase::SetPalette(const wxPalette
& pal
)
1144 m_hasCustomPalette
= true;
1147 // VZ: can anyone explain me what do we do here?
1148 wxWindowDC
d((wxWindow
*) this);
1152 wxWindow
*wxWindowBase::GetAncestorWithCustomPalette() const
1154 wxWindow
*win
= (wxWindow
*)this;
1155 while ( win
&& !win
->HasCustomPalette() )
1157 win
= win
->GetParent();
1163 #endif // wxUSE_PALETTE
1166 void wxWindowBase::SetCaret(wxCaret
*caret
)
1177 wxASSERT_MSG( m_caret
->GetWindow() == this,
1178 wxT("caret should be created associated to this window") );
1181 #endif // wxUSE_CARET
1183 #if wxUSE_VALIDATORS
1184 // ----------------------------------------------------------------------------
1186 // ----------------------------------------------------------------------------
1188 void wxWindowBase::SetValidator(const wxValidator
& validator
)
1190 if ( m_windowValidator
)
1191 delete m_windowValidator
;
1193 m_windowValidator
= (wxValidator
*)validator
.Clone();
1195 if ( m_windowValidator
)
1196 m_windowValidator
->SetWindow(this);
1198 #endif // wxUSE_VALIDATORS
1200 // ----------------------------------------------------------------------------
1201 // update region stuff
1202 // ----------------------------------------------------------------------------
1204 wxRect
wxWindowBase::GetUpdateClientRect() const
1206 wxRegion rgnUpdate
= GetUpdateRegion();
1207 rgnUpdate
.Intersect(GetClientRect());
1208 wxRect rectUpdate
= rgnUpdate
.GetBox();
1209 wxPoint ptOrigin
= GetClientAreaOrigin();
1210 rectUpdate
.x
-= ptOrigin
.x
;
1211 rectUpdate
.y
-= ptOrigin
.y
;
1216 bool wxWindowBase::IsExposed(int x
, int y
) const
1218 return m_updateRegion
.Contains(x
, y
) != wxOutRegion
;
1221 bool wxWindowBase::IsExposed(int x
, int y
, int w
, int h
) const
1223 return m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
;
1226 void wxWindowBase::ClearBackground()
1228 // wxGTK uses its own version, no need to add never used code
1230 wxClientDC
dc((wxWindow
*)this);
1231 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1232 dc
.SetBackground(brush
);
1237 // ----------------------------------------------------------------------------
1238 // find child window by id or name
1239 // ----------------------------------------------------------------------------
1241 wxWindow
*wxWindowBase::FindWindow(long id
) const
1243 if ( id
== m_windowId
)
1244 return (wxWindow
*)this;
1246 wxWindowBase
*res
= (wxWindow
*)NULL
;
1247 wxWindowList::compatibility_iterator node
;
1248 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1250 wxWindowBase
*child
= node
->GetData();
1251 res
= child
->FindWindow( id
);
1254 return (wxWindow
*)res
;
1257 wxWindow
*wxWindowBase::FindWindow(const wxString
& name
) const
1259 if ( name
== m_windowName
)
1260 return (wxWindow
*)this;
1262 wxWindowBase
*res
= (wxWindow
*)NULL
;
1263 wxWindowList::compatibility_iterator node
;
1264 for ( node
= m_children
.GetFirst(); node
&& !res
; node
= node
->GetNext() )
1266 wxWindow
*child
= node
->GetData();
1267 res
= child
->FindWindow(name
);
1270 return (wxWindow
*)res
;
1274 // find any window by id or name or label: If parent is non-NULL, look through
1275 // children for a label or title matching the specified string. If NULL, look
1276 // through all top-level windows.
1278 // to avoid duplicating code we reuse the same helper function but with
1279 // different comparators
1281 typedef bool (*wxFindWindowCmp
)(const wxWindow
*win
,
1282 const wxString
& label
, long id
);
1285 bool wxFindWindowCmpLabels(const wxWindow
*win
, const wxString
& label
,
1288 return win
->GetLabel() == label
;
1292 bool wxFindWindowCmpNames(const wxWindow
*win
, const wxString
& label
,
1295 return win
->GetName() == label
;
1299 bool wxFindWindowCmpIds(const wxWindow
*win
, const wxString
& WXUNUSED(label
),
1302 return win
->GetId() == id
;
1305 // recursive helper for the FindWindowByXXX() functions
1307 wxWindow
*wxFindWindowRecursively(const wxWindow
*parent
,
1308 const wxString
& label
,
1310 wxFindWindowCmp cmp
)
1314 // see if this is the one we're looking for
1315 if ( (*cmp
)(parent
, label
, id
) )
1316 return (wxWindow
*)parent
;
1318 // It wasn't, so check all its children
1319 for ( wxWindowList::compatibility_iterator node
= parent
->GetChildren().GetFirst();
1321 node
= node
->GetNext() )
1323 // recursively check each child
1324 wxWindow
*win
= (wxWindow
*)node
->GetData();
1325 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1335 // helper for FindWindowByXXX()
1337 wxWindow
*wxFindWindowHelper(const wxWindow
*parent
,
1338 const wxString
& label
,
1340 wxFindWindowCmp cmp
)
1344 // just check parent and all its children
1345 return wxFindWindowRecursively(parent
, label
, id
, cmp
);
1348 // start at very top of wx's windows
1349 for ( wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1351 node
= node
->GetNext() )
1353 // recursively check each window & its children
1354 wxWindow
*win
= node
->GetData();
1355 wxWindow
*retwin
= wxFindWindowRecursively(win
, label
, id
, cmp
);
1365 wxWindowBase::FindWindowByLabel(const wxString
& title
, const wxWindow
*parent
)
1367 return wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpLabels
);
1372 wxWindowBase::FindWindowByName(const wxString
& title
, const wxWindow
*parent
)
1374 wxWindow
*win
= wxFindWindowHelper(parent
, title
, 0, wxFindWindowCmpNames
);
1378 // fall back to the label
1379 win
= FindWindowByLabel(title
, parent
);
1387 wxWindowBase::FindWindowById( long id
, const wxWindow
* parent
)
1389 return wxFindWindowHelper(parent
, wxEmptyString
, id
, wxFindWindowCmpIds
);
1392 // ----------------------------------------------------------------------------
1393 // dialog oriented functions
1394 // ----------------------------------------------------------------------------
1396 void wxWindowBase::MakeModal(bool modal
)
1398 // Disable all other windows
1401 wxWindowList::compatibility_iterator node
= wxTopLevelWindows
.GetFirst();
1404 wxWindow
*win
= node
->GetData();
1406 win
->Enable(!modal
);
1408 node
= node
->GetNext();
1413 bool wxWindowBase::Validate()
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 wxWindowBase
*child
= node
->GetData();
1422 wxValidator
*validator
= child
->GetValidator();
1423 if ( validator
&& !validator
->Validate((wxWindow
*)this) )
1428 if ( recurse
&& !child
->Validate() )
1433 #endif // wxUSE_VALIDATORS
1438 bool wxWindowBase::TransferDataToWindow()
1440 #if wxUSE_VALIDATORS
1441 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1443 wxWindowList::compatibility_iterator node
;
1444 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1446 wxWindowBase
*child
= node
->GetData();
1447 wxValidator
*validator
= child
->GetValidator();
1448 if ( validator
&& !validator
->TransferToWindow() )
1450 wxLogWarning(_("Could not transfer data to window"));
1452 wxLog::FlushActive();
1460 if ( !child
->TransferDataToWindow() )
1462 // warning already given
1467 #endif // wxUSE_VALIDATORS
1472 bool wxWindowBase::TransferDataFromWindow()
1474 #if wxUSE_VALIDATORS
1475 bool recurse
= (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY
) != 0;
1477 wxWindowList::compatibility_iterator node
;
1478 for ( node
= m_children
.GetFirst(); node
; node
= node
->GetNext() )
1480 wxWindow
*child
= node
->GetData();
1481 wxValidator
*validator
= child
->GetValidator();
1482 if ( validator
&& !validator
->TransferFromWindow() )
1484 // nop warning here because the application is supposed to give
1485 // one itself - we don't know here what might have gone wrongly
1492 if ( !child
->TransferDataFromWindow() )
1494 // warning already given
1499 #endif // wxUSE_VALIDATORS
1504 void wxWindowBase::InitDialog()
1506 wxInitDialogEvent
event(GetId());
1507 event
.SetEventObject( this );
1508 GetEventHandler()->ProcessEvent(event
);
1511 // ----------------------------------------------------------------------------
1512 // context-sensitive help support
1513 // ----------------------------------------------------------------------------
1517 // associate this help text with this window
1518 void wxWindowBase::SetHelpText(const wxString
& text
)
1520 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1523 helpProvider
->AddHelp(this, text
);
1527 // associate this help text with all windows with the same id as this
1529 void wxWindowBase::SetHelpTextForId(const wxString
& text
)
1531 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1534 helpProvider
->AddHelp(GetId(), text
);
1538 // get the help string associated with this window (may be empty)
1539 wxString
wxWindowBase::GetHelpText() const
1542 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1545 text
= helpProvider
->GetHelp(this);
1551 // show help for this window
1552 void wxWindowBase::OnHelp(wxHelpEvent
& event
)
1554 wxHelpProvider
*helpProvider
= wxHelpProvider::Get();
1557 if ( helpProvider
->ShowHelp(this) )
1559 // skip the event.Skip() below
1567 #endif // wxUSE_HELP
1569 // ----------------------------------------------------------------------------
1570 // tooltipsroot.Replace("\\", "/");
1571 // ----------------------------------------------------------------------------
1575 void wxWindowBase::SetToolTip( const wxString
&tip
)
1577 // don't create the new tooltip if we already have one
1580 m_tooltip
->SetTip( tip
);
1584 SetToolTip( new wxToolTip( tip
) );
1587 // setting empty tooltip text does not remove the tooltip any more - use
1588 // SetToolTip((wxToolTip *)NULL) for this
1591 void wxWindowBase::DoSetToolTip(wxToolTip
*tooltip
)
1596 m_tooltip
= tooltip
;
1599 #endif // wxUSE_TOOLTIPS
1601 // ----------------------------------------------------------------------------
1602 // constraints and sizers
1603 // ----------------------------------------------------------------------------
1605 #if wxUSE_CONSTRAINTS
1607 void wxWindowBase::SetConstraints( wxLayoutConstraints
*constraints
)
1609 if ( m_constraints
)
1611 UnsetConstraints(m_constraints
);
1612 delete m_constraints
;
1614 m_constraints
= constraints
;
1615 if ( m_constraints
)
1617 // Make sure other windows know they're part of a 'meaningful relationship'
1618 if ( m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this) )
1619 m_constraints
->left
.GetOtherWindow()->AddConstraintReference(this);
1620 if ( m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this) )
1621 m_constraints
->top
.GetOtherWindow()->AddConstraintReference(this);
1622 if ( m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this) )
1623 m_constraints
->right
.GetOtherWindow()->AddConstraintReference(this);
1624 if ( m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this) )
1625 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference(this);
1626 if ( m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this) )
1627 m_constraints
->width
.GetOtherWindow()->AddConstraintReference(this);
1628 if ( m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this) )
1629 m_constraints
->height
.GetOtherWindow()->AddConstraintReference(this);
1630 if ( m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this) )
1631 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference(this);
1632 if ( m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this) )
1633 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference(this);
1637 // This removes any dangling pointers to this window in other windows'
1638 // constraintsInvolvedIn lists.
1639 void wxWindowBase::UnsetConstraints(wxLayoutConstraints
*c
)
1643 if ( c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1644 c
->left
.GetOtherWindow()->RemoveConstraintReference(this);
1645 if ( c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this) )
1646 c
->top
.GetOtherWindow()->RemoveConstraintReference(this);
1647 if ( c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this) )
1648 c
->right
.GetOtherWindow()->RemoveConstraintReference(this);
1649 if ( c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this) )
1650 c
->bottom
.GetOtherWindow()->RemoveConstraintReference(this);
1651 if ( c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this) )
1652 c
->width
.GetOtherWindow()->RemoveConstraintReference(this);
1653 if ( c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this) )
1654 c
->height
.GetOtherWindow()->RemoveConstraintReference(this);
1655 if ( c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this) )
1656 c
->centreX
.GetOtherWindow()->RemoveConstraintReference(this);
1657 if ( c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this) )
1658 c
->centreY
.GetOtherWindow()->RemoveConstraintReference(this);
1662 // Back-pointer to other windows we're involved with, so if we delete this
1663 // window, we must delete any constraints we're involved with.
1664 void wxWindowBase::AddConstraintReference(wxWindowBase
*otherWin
)
1666 if ( !m_constraintsInvolvedIn
)
1667 m_constraintsInvolvedIn
= new wxWindowList
;
1668 if ( !m_constraintsInvolvedIn
->Find((wxWindow
*)otherWin
) )
1669 m_constraintsInvolvedIn
->Append((wxWindow
*)otherWin
);
1672 // REMOVE back-pointer to other windows we're involved with.
1673 void wxWindowBase::RemoveConstraintReference(wxWindowBase
*otherWin
)
1675 if ( m_constraintsInvolvedIn
)
1676 m_constraintsInvolvedIn
->DeleteObject((wxWindow
*)otherWin
);
1679 // Reset any constraints that mention this window
1680 void wxWindowBase::DeleteRelatedConstraints()
1682 if ( m_constraintsInvolvedIn
)
1684 wxWindowList::compatibility_iterator node
= m_constraintsInvolvedIn
->GetFirst();
1687 wxWindow
*win
= node
->GetData();
1688 wxLayoutConstraints
*constr
= win
->GetConstraints();
1690 // Reset any constraints involving this window
1693 constr
->left
.ResetIfWin(this);
1694 constr
->top
.ResetIfWin(this);
1695 constr
->right
.ResetIfWin(this);
1696 constr
->bottom
.ResetIfWin(this);
1697 constr
->width
.ResetIfWin(this);
1698 constr
->height
.ResetIfWin(this);
1699 constr
->centreX
.ResetIfWin(this);
1700 constr
->centreY
.ResetIfWin(this);
1703 wxWindowList::compatibility_iterator next
= node
->GetNext();
1704 m_constraintsInvolvedIn
->Erase(node
);
1708 delete m_constraintsInvolvedIn
;
1709 m_constraintsInvolvedIn
= (wxWindowList
*) NULL
;
1713 #endif // wxUSE_CONSTRAINTS
1715 void wxWindowBase::SetSizer(wxSizer
*sizer
, bool deleteOld
)
1717 if ( sizer
== m_windowSizer
)
1721 delete m_windowSizer
;
1723 m_windowSizer
= sizer
;
1725 SetAutoLayout( sizer
!= NULL
);
1728 void wxWindowBase::SetSizerAndFit(wxSizer
*sizer
, bool deleteOld
)
1730 SetSizer( sizer
, deleteOld
);
1731 sizer
->SetSizeHints( (wxWindow
*) this );
1735 void wxWindowBase::SetContainingSizer(wxSizer
* sizer
)
1737 // adding a window to a sizer twice is going to result in fatal and
1738 // hard to debug problems later because when deleting the second
1739 // associated wxSizerItem we're going to dereference a dangling
1740 // pointer; so try to detect this as early as possible
1741 wxASSERT_MSG( !sizer
|| m_containingSizer
!= sizer
,
1742 _T("Adding a window to the same sizer twice?") );
1744 m_containingSizer
= sizer
;
1747 #if wxUSE_CONSTRAINTS
1749 void wxWindowBase::SatisfyConstraints()
1751 wxLayoutConstraints
*constr
= GetConstraints();
1752 bool wasOk
= constr
&& constr
->AreSatisfied();
1754 ResetConstraints(); // Mark all constraints as unevaluated
1758 // if we're a top level panel (i.e. our parent is frame/dialog), our
1759 // own constraints will never be satisfied any more unless we do it
1763 while ( noChanges
> 0 )
1765 LayoutPhase1(&noChanges
);
1769 LayoutPhase2(&noChanges
);
1772 #endif // wxUSE_CONSTRAINTS
1774 bool wxWindowBase::Layout()
1776 // If there is a sizer, use it instead of the constraints
1780 GetVirtualSize(&w
, &h
);
1781 GetSizer()->SetDimension( 0, 0, w
, h
);
1783 #if wxUSE_CONSTRAINTS
1786 SatisfyConstraints(); // Find the right constraints values
1787 SetConstraintSizes(); // Recursively set the real window sizes
1794 #if wxUSE_CONSTRAINTS
1796 // first phase of the constraints evaluation: set our own constraints
1797 bool wxWindowBase::LayoutPhase1(int *noChanges
)
1799 wxLayoutConstraints
*constr
= GetConstraints();
1801 return !constr
|| constr
->SatisfyConstraints(this, noChanges
);
1804 // second phase: set the constraints for our children
1805 bool wxWindowBase::LayoutPhase2(int *noChanges
)
1812 // Layout grand children
1818 // Do a phase of evaluating child constraints
1819 bool wxWindowBase::DoPhase(int phase
)
1821 // the list containing the children for which the constraints are already
1823 wxWindowList succeeded
;
1825 // the max number of iterations we loop before concluding that we can't set
1827 static const int maxIterations
= 500;
1829 for ( int noIterations
= 0; noIterations
< maxIterations
; noIterations
++ )
1833 // loop over all children setting their constraints
1834 for ( wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1836 node
= node
->GetNext() )
1838 wxWindow
*child
= node
->GetData();
1839 if ( child
->IsTopLevel() )
1841 // top level children are not inside our client area
1845 if ( !child
->GetConstraints() || succeeded
.Find(child
) )
1847 // this one is either already ok or nothing we can do about it
1851 int tempNoChanges
= 0;
1852 bool success
= phase
== 1 ? child
->LayoutPhase1(&tempNoChanges
)
1853 : child
->LayoutPhase2(&tempNoChanges
);
1854 noChanges
+= tempNoChanges
;
1858 succeeded
.Append(child
);
1864 // constraints are set
1872 void wxWindowBase::ResetConstraints()
1874 wxLayoutConstraints
*constr
= GetConstraints();
1877 constr
->left
.SetDone(false);
1878 constr
->top
.SetDone(false);
1879 constr
->right
.SetDone(false);
1880 constr
->bottom
.SetDone(false);
1881 constr
->width
.SetDone(false);
1882 constr
->height
.SetDone(false);
1883 constr
->centreX
.SetDone(false);
1884 constr
->centreY
.SetDone(false);
1887 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1890 wxWindow
*win
= node
->GetData();
1891 if ( !win
->IsTopLevel() )
1892 win
->ResetConstraints();
1893 node
= node
->GetNext();
1897 // Need to distinguish between setting the 'fake' size for windows and sizers,
1898 // and setting the real values.
1899 void wxWindowBase::SetConstraintSizes(bool recurse
)
1901 wxLayoutConstraints
*constr
= GetConstraints();
1902 if ( constr
&& constr
->AreSatisfied() )
1904 int x
= constr
->left
.GetValue();
1905 int y
= constr
->top
.GetValue();
1906 int w
= constr
->width
.GetValue();
1907 int h
= constr
->height
.GetValue();
1909 if ( (constr
->width
.GetRelationship() != wxAsIs
) ||
1910 (constr
->height
.GetRelationship() != wxAsIs
) )
1912 SetSize(x
, y
, w
, h
);
1916 // If we don't want to resize this window, just move it...
1922 wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
1923 GetClassInfo()->GetClassName(),
1929 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
1932 wxWindow
*win
= node
->GetData();
1933 if ( !win
->IsTopLevel() && win
->GetConstraints() )
1934 win
->SetConstraintSizes();
1935 node
= node
->GetNext();
1940 // Only set the size/position of the constraint (if any)
1941 void wxWindowBase::SetSizeConstraint(int x
, int y
, int w
, int h
)
1943 wxLayoutConstraints
*constr
= GetConstraints();
1946 if ( x
!= wxDefaultCoord
)
1948 constr
->left
.SetValue(x
);
1949 constr
->left
.SetDone(true);
1951 if ( y
!= wxDefaultCoord
)
1953 constr
->top
.SetValue(y
);
1954 constr
->top
.SetDone(true);
1956 if ( w
!= wxDefaultCoord
)
1958 constr
->width
.SetValue(w
);
1959 constr
->width
.SetDone(true);
1961 if ( h
!= wxDefaultCoord
)
1963 constr
->height
.SetValue(h
);
1964 constr
->height
.SetDone(true);
1969 void wxWindowBase::MoveConstraint(int x
, int y
)
1971 wxLayoutConstraints
*constr
= GetConstraints();
1974 if ( x
!= wxDefaultCoord
)
1976 constr
->left
.SetValue(x
);
1977 constr
->left
.SetDone(true);
1979 if ( y
!= wxDefaultCoord
)
1981 constr
->top
.SetValue(y
);
1982 constr
->top
.SetDone(true);
1987 void wxWindowBase::GetSizeConstraint(int *w
, int *h
) const
1989 wxLayoutConstraints
*constr
= GetConstraints();
1992 *w
= constr
->width
.GetValue();
1993 *h
= constr
->height
.GetValue();
1999 void wxWindowBase::GetClientSizeConstraint(int *w
, int *h
) const
2001 wxLayoutConstraints
*constr
= GetConstraints();
2004 *w
= constr
->width
.GetValue();
2005 *h
= constr
->height
.GetValue();
2008 GetClientSize(w
, h
);
2011 void wxWindowBase::GetPositionConstraint(int *x
, int *y
) const
2013 wxLayoutConstraints
*constr
= GetConstraints();
2016 *x
= constr
->left
.GetValue();
2017 *y
= constr
->top
.GetValue();
2023 #endif // wxUSE_CONSTRAINTS
2025 void wxWindowBase::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
) const
2027 // don't do it for the dialogs/frames - they float independently of their
2029 if ( !IsTopLevel() )
2031 wxWindow
*parent
= GetParent();
2032 if ( !(sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && parent
)
2034 wxPoint
pt(parent
->GetClientAreaOrigin());
2041 // ----------------------------------------------------------------------------
2042 // do Update UI processing for child controls
2043 // ----------------------------------------------------------------------------
2045 void wxWindowBase::UpdateWindowUI(long flags
)
2047 wxUpdateUIEvent
event(GetId());
2048 event
.SetEventObject(this);
2050 if ( GetEventHandler()->ProcessEvent(event
) )
2052 DoUpdateWindowUI(event
);
2055 if (flags
& wxUPDATE_UI_RECURSE
)
2057 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2060 wxWindow
* child
= (wxWindow
*) node
->GetData();
2061 child
->UpdateWindowUI(flags
);
2062 node
= node
->GetNext();
2067 // do the window-specific processing after processing the update event
2068 // TODO: take specific knowledge out of this function and
2069 // put in each control's base class. Unfortunately we don't
2070 // yet have base implementation files for wxCheckBox and wxRadioButton.
2071 void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent
& event
)
2073 if ( event
.GetSetEnabled() )
2074 Enable(event
.GetEnabled());
2077 if ( event
.GetSetText() )
2079 wxControl
*control
= wxDynamicCastThis(wxControl
);
2082 if ( event
.GetText() != control
->GetLabel() )
2083 control
->SetLabel(event
.GetText());
2086 #endif // wxUSE_CONTROLS
2088 if ( event
.GetSetChecked() )
2091 wxCheckBox
*checkbox
= wxDynamicCastThis(wxCheckBox
);
2094 checkbox
->SetValue(event
.GetChecked());
2096 #endif // wxUSE_CHECKBOX
2099 wxRadioButton
*radiobtn
= wxDynamicCastThis(wxRadioButton
);
2102 radiobtn
->SetValue(event
.GetChecked());
2104 #endif // wxUSE_RADIOBTN
2109 // call internal idle recursively
2110 // may be obsolete (wait until OnIdle scheme stabilises)
2111 void wxWindowBase::ProcessInternalIdle()
2115 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2118 wxWindow
*child
= node
->GetData();
2119 child
->ProcessInternalIdle();
2120 node
= node
->GetNext();
2125 // ----------------------------------------------------------------------------
2126 // dialog units translations
2127 // ----------------------------------------------------------------------------
2129 wxPoint
wxWindowBase::ConvertPixelsToDialog(const wxPoint
& pt
)
2131 int charWidth
= GetCharWidth();
2132 int charHeight
= GetCharHeight();
2133 wxPoint pt2
= wxDefaultPosition
;
2134 if (pt
.x
!= wxDefaultCoord
)
2135 pt2
.x
= (int) ((pt
.x
* 4) / charWidth
);
2136 if (pt
.y
!= wxDefaultCoord
)
2137 pt2
.y
= (int) ((pt
.y
* 8) / charHeight
);
2142 wxPoint
wxWindowBase::ConvertDialogToPixels(const wxPoint
& pt
)
2144 int charWidth
= GetCharWidth();
2145 int charHeight
= GetCharHeight();
2146 wxPoint pt2
= wxDefaultPosition
;
2147 if (pt
.x
!= wxDefaultCoord
)
2148 pt2
.x
= (int) ((pt
.x
* charWidth
) / 4);
2149 if (pt
.y
!= wxDefaultCoord
)
2150 pt2
.y
= (int) ((pt
.y
* charHeight
) / 8);
2155 // ----------------------------------------------------------------------------
2157 // ----------------------------------------------------------------------------
2159 // propagate the colour change event to the subwindows
2160 void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2162 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
2165 // Only propagate to non-top-level windows
2166 wxWindow
*win
= node
->GetData();
2167 if ( !win
->IsTopLevel() )
2169 wxSysColourChangedEvent event2
;
2170 event
.SetEventObject(win
);
2171 win
->GetEventHandler()->ProcessEvent(event2
);
2174 node
= node
->GetNext();
2180 // the default action is to populate dialog with data when it's created,
2181 // and nudge the UI into displaying itself correctly in case
2182 // we've turned the wxUpdateUIEvents frequency down low.
2183 void wxWindowBase::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2185 TransferDataToWindow();
2187 // Update the UI at this point
2188 UpdateWindowUI(wxUPDATE_UI_RECURSE
);
2191 // process Ctrl-Alt-mclick
2192 void wxWindowBase::OnMiddleClick( wxMouseEvent
& event
)
2195 if ( event
.ControlDown() && event
.AltDown() )
2197 // don't translate these strings
2200 #ifdef __WXUNIVERSAL__
2202 #endif // __WXUNIVERSAL__
2204 switch ( wxGetOsVersion() )
2206 case wxMOTIF_X
: port
+= _T("Motif"); break;
2208 case wxMAC_DARWIN
: port
+= _T("Mac"); break;
2209 case wxBEOS
: port
+= _T("BeOS"); break;
2213 case wxGTK_BEOS
: port
+= _T("GTK"); break;
2219 case wxWIN386
: port
+= _T("MS Windows"); break;
2223 case wxMGL_OS2
: port
+= _T("MGL"); break;
2225 case wxOS2_PM
: port
+= _T("OS/2"); break;
2226 default: port
+= _T("unknown"); break;
2229 wxMessageBox(wxString::Format(
2231 " wxWidgets Library (%s port)\nVersion %u.%u.%u%s%s, compiled at %s %s\n Copyright (c) 1995-2005 wxWidgets team"
2250 _T("wxWidgets information"),
2251 wxICON_INFORMATION
| wxOK
,
2255 #endif // wxUSE_MSGDLG
2261 // ----------------------------------------------------------------------------
2263 // ----------------------------------------------------------------------------
2265 #if wxUSE_ACCESSIBILITY
2266 void wxWindowBase::SetAccessible(wxAccessible
* accessible
)
2268 if (m_accessible
&& (accessible
!= m_accessible
))
2269 delete m_accessible
;
2270 m_accessible
= accessible
;
2272 m_accessible
->SetWindow((wxWindow
*) this);
2275 // Returns the accessible object, creating if necessary.
2276 wxAccessible
* wxWindowBase::GetOrCreateAccessible()
2279 m_accessible
= CreateAccessible();
2280 return m_accessible
;
2283 // Override to create a specific accessible object.
2284 wxAccessible
* wxWindowBase::CreateAccessible()
2286 return new wxWindowAccessible((wxWindow
*) this);
2291 // ----------------------------------------------------------------------------
2292 // list classes implementation
2293 // ----------------------------------------------------------------------------
2297 #include <wx/listimpl.cpp>
2298 WX_DEFINE_LIST(wxWindowList
);
2302 void wxWindowListNode::DeleteData()
2304 delete (wxWindow
*)GetData();
2309 // ----------------------------------------------------------------------------
2311 // ----------------------------------------------------------------------------
2313 wxBorder
wxWindowBase::GetBorder(long flags
) const
2315 wxBorder border
= (wxBorder
)(flags
& wxBORDER_MASK
);
2316 if ( border
== wxBORDER_DEFAULT
)
2318 border
= GetDefaultBorder();
2324 wxBorder
wxWindowBase::GetDefaultBorder() const
2326 return wxBORDER_NONE
;
2329 // ----------------------------------------------------------------------------
2331 // ----------------------------------------------------------------------------
2333 wxHitTest
wxWindowBase::DoHitTest(wxCoord x
, wxCoord y
) const
2335 // here we just check if the point is inside the window or not
2337 // check the top and left border first
2338 bool outside
= x
< 0 || y
< 0;
2341 // check the right and bottom borders too
2342 wxSize size
= GetSize();
2343 outside
= x
>= size
.x
|| y
>= size
.y
;
2346 return outside
? wxHT_WINDOW_OUTSIDE
: wxHT_WINDOW_INSIDE
;
2349 // ----------------------------------------------------------------------------
2351 // ----------------------------------------------------------------------------
2353 struct WXDLLEXPORT wxWindowNext
2357 } *wxWindowBase::ms_winCaptureNext
= NULL
;
2359 void wxWindowBase::CaptureMouse()
2361 wxLogTrace(_T("mousecapture"), _T("CaptureMouse(%p)"), this);
2363 wxWindow
*winOld
= GetCapture();
2366 ((wxWindowBase
*) winOld
)->DoReleaseMouse();
2369 wxWindowNext
*item
= new wxWindowNext
;
2371 item
->next
= ms_winCaptureNext
;
2372 ms_winCaptureNext
= item
;
2374 //else: no mouse capture to save
2379 void wxWindowBase::ReleaseMouse()
2381 wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(%p)"), this);
2383 wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") );
2387 if ( ms_winCaptureNext
)
2389 ((wxWindowBase
*)ms_winCaptureNext
->win
)->DoCaptureMouse();
2391 wxWindowNext
*item
= ms_winCaptureNext
;
2392 ms_winCaptureNext
= item
->next
;
2395 //else: stack is empty, no previous capture
2397 wxLogTrace(_T("mousecapture"),
2398 (const wxChar
*) _T("After ReleaseMouse() mouse is captured by %p"),
2405 wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId
),
2406 int WXUNUSED(modifiers
),
2407 int WXUNUSED(keycode
))
2413 bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId
))
2419 #endif // wxUSE_HOTKEY
2421 void wxWindowBase::SendDestroyEvent()
2423 wxWindowDestroyEvent event
;
2424 event
.SetEventObject(this);
2425 event
.SetId(GetId());
2426 GetEventHandler()->ProcessEvent(event
);
2429 // ----------------------------------------------------------------------------
2431 // ----------------------------------------------------------------------------
2433 bool wxWindowBase::TryValidator(wxEvent
& wxVALIDATOR_PARAM(event
))
2435 #if wxUSE_VALIDATORS
2436 // Can only use the validator of the window which
2437 // is receiving the event
2438 if ( event
.GetEventObject() == this )
2440 wxValidator
*validator
= GetValidator();
2441 if ( validator
&& validator
->ProcessEvent(event
) )
2446 #endif // wxUSE_VALIDATORS
2451 bool wxWindowBase::TryParent(wxEvent
& event
)
2453 // carry on up the parent-child hierarchy if the propgation count hasn't
2455 if ( event
.ShouldPropagate() )
2457 // honour the requests to stop propagation at this window: this is
2458 // used by the dialogs, for example, to prevent processing the events
2459 // from the dialog controls in the parent frame which rarely, if ever,
2461 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
2463 wxWindow
*parent
= GetParent();
2464 if ( parent
&& !parent
->IsBeingDeleted() )
2466 wxPropagateOnce
propagateOnce(event
);
2468 return parent
->GetEventHandler()->ProcessEvent(event
);
2473 return wxEvtHandler::TryParent(event
);
2476 // ----------------------------------------------------------------------------
2477 // keyboard navigation
2478 // ----------------------------------------------------------------------------
2480 // Navigates in the specified direction.
2481 bool wxWindowBase::Navigate(int flags
)
2483 wxNavigationKeyEvent eventNav
;
2484 eventNav
.SetFlags(flags
);
2485 eventNav
.SetEventObject(this);
2486 if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav
) )
2493 void wxWindowBase::DoMoveInTabOrder(wxWindow
*win
, MoveKind move
)
2495 // check that we're not a top level window
2496 wxCHECK_RET( GetParent(),
2497 _T("MoveBefore/AfterInTabOrder() don't work for TLWs!") );
2499 // detect the special case when we have nothing to do anyhow and when the
2500 // code below wouldn't work
2504 // find the target window in the siblings list
2505 wxWindowList
& siblings
= GetParent()->GetChildren();
2506 wxWindowList::compatibility_iterator i
= siblings
.Find(win
);
2507 wxCHECK_RET( i
, _T("MoveBefore/AfterInTabOrder(): win is not a sibling") );
2509 // unfortunately, when wxUSE_STL == 1 DetachNode() is not implemented so we
2510 // can't just move the node around
2511 wxWindow
*self
= (wxWindow
*)this;
2512 siblings
.DeleteObject(self
);
2513 if ( move
== MoveAfter
)
2520 siblings
.Insert(i
, self
);
2522 else // MoveAfter and win was the last sibling
2524 siblings
.Append(self
);
2528 // ----------------------------------------------------------------------------
2530 // ----------------------------------------------------------------------------
2532 /*static*/ wxWindow
* wxWindowBase::FindFocus()
2534 wxWindowBase
*win
= DoFindFocus();
2535 return win
? win
->GetMainWindowOfCompositeControl() : NULL
;
2538 // ----------------------------------------------------------------------------
2540 // ----------------------------------------------------------------------------
2542 wxWindow
* wxGetTopLevelParent(wxWindow
*win
)
2544 while ( win
&& !win
->IsTopLevel() )
2545 win
= win
->GetParent();
2550 #if wxUSE_ACCESSIBILITY
2551 // ----------------------------------------------------------------------------
2552 // accessible object for windows
2553 // ----------------------------------------------------------------------------
2555 // Can return either a child object, or an integer
2556 // representing the child element, starting from 1.
2557 wxAccStatus
wxWindowAccessible::HitTest(const wxPoint
& WXUNUSED(pt
), int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(childObject
))
2559 wxASSERT( GetWindow() != NULL
);
2563 return wxACC_NOT_IMPLEMENTED
;
2566 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
2567 wxAccStatus
wxWindowAccessible::GetLocation(wxRect
& rect
, int elementId
)
2569 wxASSERT( GetWindow() != NULL
);
2573 wxWindow
* win
= NULL
;
2580 if (elementId
<= (int) GetWindow()->GetChildren().GetCount())
2582 win
= GetWindow()->GetChildren().Item(elementId
-1)->GetData();
2589 rect
= win
->GetRect();
2590 if (win
->GetParent() && !win
->IsKindOf(CLASSINFO(wxTopLevelWindow
)))
2591 rect
.SetPosition(win
->GetParent()->ClientToScreen(rect
.GetPosition()));
2595 return wxACC_NOT_IMPLEMENTED
;
2598 // Navigates from fromId to toId/toObject.
2599 wxAccStatus
wxWindowAccessible::Navigate(wxNavDir navDir
, int fromId
,
2600 int* WXUNUSED(toId
), wxAccessible
** toObject
)
2602 wxASSERT( GetWindow() != NULL
);
2608 case wxNAVDIR_FIRSTCHILD
:
2610 if (GetWindow()->GetChildren().GetCount() == 0)
2612 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetFirst()->GetData();
2613 *toObject
= childWindow
->GetOrCreateAccessible();
2617 case wxNAVDIR_LASTCHILD
:
2619 if (GetWindow()->GetChildren().GetCount() == 0)
2621 wxWindow
* childWindow
= (wxWindow
*) GetWindow()->GetChildren().GetLast()->GetData();
2622 *toObject
= childWindow
->GetOrCreateAccessible();
2626 case wxNAVDIR_RIGHT
:
2630 wxWindowList::compatibility_iterator node
=
2631 wxWindowList::compatibility_iterator();
2634 // Can't navigate to sibling of this window
2635 // if we're a top-level window.
2636 if (!GetWindow()->GetParent())
2637 return wxACC_NOT_IMPLEMENTED
;
2639 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2643 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2644 node
= GetWindow()->GetChildren().Item(fromId
-1);
2647 if (node
&& node
->GetNext())
2649 wxWindow
* nextWindow
= node
->GetNext()->GetData();
2650 *toObject
= nextWindow
->GetOrCreateAccessible();
2658 case wxNAVDIR_PREVIOUS
:
2660 wxWindowList::compatibility_iterator node
=
2661 wxWindowList::compatibility_iterator();
2664 // Can't navigate to sibling of this window
2665 // if we're a top-level window.
2666 if (!GetWindow()->GetParent())
2667 return wxACC_NOT_IMPLEMENTED
;
2669 node
= GetWindow()->GetParent()->GetChildren().Find(GetWindow());
2673 if (fromId
<= (int) GetWindow()->GetChildren().GetCount())
2674 node
= GetWindow()->GetChildren().Item(fromId
-1);
2677 if (node
&& node
->GetPrevious())
2679 wxWindow
* previousWindow
= node
->GetPrevious()->GetData();
2680 *toObject
= previousWindow
->GetOrCreateAccessible();
2688 return wxACC_NOT_IMPLEMENTED
;
2691 // Gets the name of the specified object.
2692 wxAccStatus
wxWindowAccessible::GetName(int childId
, wxString
* name
)
2694 wxASSERT( GetWindow() != NULL
);
2700 // If a child, leave wxWidgets to call the function on the actual
2703 return wxACC_NOT_IMPLEMENTED
;
2705 // This will eventually be replaced by specialised
2706 // accessible classes, one for each kind of wxWidgets
2707 // control or window.
2709 if (GetWindow()->IsKindOf(CLASSINFO(wxButton
)))
2710 title
= ((wxButton
*) GetWindow())->GetLabel();
2713 title
= GetWindow()->GetName();
2721 return wxACC_NOT_IMPLEMENTED
;
2724 // Gets the number of children.
2725 wxAccStatus
wxWindowAccessible::GetChildCount(int* childId
)
2727 wxASSERT( GetWindow() != NULL
);
2731 *childId
= (int) GetWindow()->GetChildren().GetCount();
2735 // Gets the specified child (starting from 1).
2736 // If *child is NULL and return value is wxACC_OK,
2737 // this means that the child is a simple element and
2738 // not an accessible object.
2739 wxAccStatus
wxWindowAccessible::GetChild(int childId
, wxAccessible
** child
)
2741 wxASSERT( GetWindow() != NULL
);
2751 if (childId
> (int) GetWindow()->GetChildren().GetCount())
2754 wxWindow
* childWindow
= GetWindow()->GetChildren().Item(childId
-1)->GetData();
2755 *child
= childWindow
->GetOrCreateAccessible();
2762 // Gets the parent, or NULL.
2763 wxAccStatus
wxWindowAccessible::GetParent(wxAccessible
** parent
)
2765 wxASSERT( GetWindow() != NULL
);
2769 wxWindow
* parentWindow
= GetWindow()->GetParent();
2777 *parent
= parentWindow
->GetOrCreateAccessible();
2785 // Performs the default action. childId is 0 (the action for this object)
2786 // or > 0 (the action for a child).
2787 // Return wxACC_NOT_SUPPORTED if there is no default action for this
2788 // window (e.g. an edit control).
2789 wxAccStatus
wxWindowAccessible::DoDefaultAction(int WXUNUSED(childId
))
2791 wxASSERT( GetWindow() != NULL
);
2795 return wxACC_NOT_IMPLEMENTED
;
2798 // Gets the default action for this object (0) or > 0 (the action for a child).
2799 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
2800 // string if there is no action.
2801 // The retrieved string describes the action that is performed on an object,
2802 // not what the object does as a result. For example, a toolbar button that prints
2803 // a document has a default action of "Press" rather than "Prints the current document."
2804 wxAccStatus
wxWindowAccessible::GetDefaultAction(int WXUNUSED(childId
), wxString
* WXUNUSED(actionName
))
2806 wxASSERT( GetWindow() != NULL
);
2810 return wxACC_NOT_IMPLEMENTED
;
2813 // Returns the description for this object or a child.
2814 wxAccStatus
wxWindowAccessible::GetDescription(int WXUNUSED(childId
), wxString
* description
)
2816 wxASSERT( GetWindow() != NULL
);
2820 wxString
ht(GetWindow()->GetHelpText());
2826 return wxACC_NOT_IMPLEMENTED
;
2829 // Returns help text for this object or a child, similar to tooltip text.
2830 wxAccStatus
wxWindowAccessible::GetHelpText(int WXUNUSED(childId
), wxString
* helpText
)
2832 wxASSERT( GetWindow() != NULL
);
2836 wxString
ht(GetWindow()->GetHelpText());
2842 return wxACC_NOT_IMPLEMENTED
;
2845 // Returns the keyboard shortcut for this object or child.
2846 // Return e.g. ALT+K
2847 wxAccStatus
wxWindowAccessible::GetKeyboardShortcut(int WXUNUSED(childId
), wxString
* WXUNUSED(shortcut
))
2849 wxASSERT( GetWindow() != NULL
);
2853 return wxACC_NOT_IMPLEMENTED
;
2856 // Returns a role constant.
2857 wxAccStatus
wxWindowAccessible::GetRole(int childId
, wxAccRole
* role
)
2859 wxASSERT( GetWindow() != NULL
);
2863 // If a child, leave wxWidgets to call the function on the actual
2866 return wxACC_NOT_IMPLEMENTED
;
2868 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2869 return wxACC_NOT_IMPLEMENTED
;
2871 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2872 return wxACC_NOT_IMPLEMENTED
;
2875 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2876 return wxACC_NOT_IMPLEMENTED
;
2879 //*role = wxROLE_SYSTEM_CLIENT;
2880 *role
= wxROLE_SYSTEM_CLIENT
;
2884 return wxACC_NOT_IMPLEMENTED
;
2888 // Returns a state constant.
2889 wxAccStatus
wxWindowAccessible::GetState(int childId
, long* state
)
2891 wxASSERT( GetWindow() != NULL
);
2895 // If a child, leave wxWidgets to call the function on the actual
2898 return wxACC_NOT_IMPLEMENTED
;
2900 if (GetWindow()->IsKindOf(CLASSINFO(wxControl
)))
2901 return wxACC_NOT_IMPLEMENTED
;
2904 if (GetWindow()->IsKindOf(CLASSINFO(wxStatusBar
)))
2905 return wxACC_NOT_IMPLEMENTED
;
2908 if (GetWindow()->IsKindOf(CLASSINFO(wxToolBar
)))
2909 return wxACC_NOT_IMPLEMENTED
;
2916 return wxACC_NOT_IMPLEMENTED
;
2920 // Returns a localized string representing the value for the object
2922 wxAccStatus
wxWindowAccessible::GetValue(int WXUNUSED(childId
), wxString
* WXUNUSED(strValue
))
2924 wxASSERT( GetWindow() != NULL
);
2928 return wxACC_NOT_IMPLEMENTED
;
2931 // Selects the object or child.
2932 wxAccStatus
wxWindowAccessible::Select(int WXUNUSED(childId
), wxAccSelectionFlags
WXUNUSED(selectFlags
))
2934 wxASSERT( GetWindow() != NULL
);
2938 return wxACC_NOT_IMPLEMENTED
;
2941 // Gets the window with the keyboard focus.
2942 // If childId is 0 and child is NULL, no object in
2943 // this subhierarchy has the focus.
2944 // If this object has the focus, child should be 'this'.
2945 wxAccStatus
wxWindowAccessible::GetFocus(int* WXUNUSED(childId
), wxAccessible
** WXUNUSED(child
))
2947 wxASSERT( GetWindow() != NULL
);
2951 return wxACC_NOT_IMPLEMENTED
;
2954 // Gets a variant representing the selected children
2956 // Acceptable values:
2957 // - a null variant (IsNull() returns true)
2958 // - a list variant (GetType() == wxT("list")
2959 // - an integer representing the selected child element,
2960 // or 0 if this object is selected (GetType() == wxT("long")
2961 // - a "void*" pointer to a wxAccessible child object
2962 wxAccStatus
wxWindowAccessible::GetSelections(wxVariant
* WXUNUSED(selections
))
2964 wxASSERT( GetWindow() != NULL
);
2968 return wxACC_NOT_IMPLEMENTED
;
2971 #endif // wxUSE_ACCESSIBILITY