From 049908c57372c671516be6f1a853d35761327e81 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 13 Jun 2007 16:29:23 +0000 Subject: [PATCH] make wxFrame a wxControlContainer too, so that it behaves in the same way as wxDialog git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46452 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/dialog.h | 2 -- include/wx/frame.h | 4 ++++ include/wx/mac/carbon/window.h | 7 ++++++- include/wx/toplevel.h | 5 ++--- include/wx/univ/window.h | 10 ++++++++++ include/wx/window.h | 5 +++++ src/common/containr.cpp | 11 ++++------- src/common/dlgcmn.cpp | 6 ------ src/common/toplvcmn.cpp | 18 +++++++----------- 9 files changed, 38 insertions(+), 30 deletions(-) diff --git a/include/wx/dialog.h b/include/wx/dialog.h index 58a30e2d0c..2d6f8ee580 100644 --- a/include/wx/dialog.h +++ b/include/wx/dialog.h @@ -13,7 +13,6 @@ #define _WX_DIALOG_H_BASE_ #include "wx/defs.h" -#include "wx/containr.h" #include "wx/toplevel.h" class WXDLLEXPORT wxSizer; @@ -141,7 +140,6 @@ private: DECLARE_NO_COPY_CLASS(wxDialogBase) DECLARE_EVENT_TABLE() - WX_DECLARE_CONTROL_CONTAINER(); }; diff --git a/include/wx/frame.h b/include/wx/frame.h index 2d3a8988c9..0f65132d71 100644 --- a/include/wx/frame.h +++ b/include/wx/frame.h @@ -190,6 +190,10 @@ protected: // test whether this window makes part of the frame virtual bool IsOneOfBars(const wxWindow *win) const; + virtual bool IsClientAreaChild(const wxWindow *child) const + { + return !IsOneOfBars(child) && wxTopLevelWindow::IsClientAreaChild(child); + } #if wxUSE_MENUS // override to update menu bar position when the frame size changes diff --git a/include/wx/mac/carbon/window.h b/include/wx/mac/carbon/window.h index 097890bf33..7f98c88483 100644 --- a/include/wx/mac/carbon/window.h +++ b/include/wx/mac/carbon/window.h @@ -214,8 +214,13 @@ public: // returns true if the grandchildren need to be clipped to the children's content area // (e.g., splitter windows) virtual bool MacClipGrandChildren() const { return false ; } - bool MacIsWindowScrollbar( const wxWindow* sb ) + bool MacIsWindowScrollbar( const wxWindow* sb ) const { return ((wxWindow*)m_hScrollBar == sb || (wxWindow*)m_vScrollBar == sb) ; } + virtual bool IsClientAreaChild(const wxWindow *child) const + { + return !MacIsWindowScrollbar(child) && + wxWindowBase::IsClientAreaChild(child); + } virtual void MacInstallEventHandler(WXWidget native) ; void MacPostControlCreate(const wxPoint& pos, const wxSize& size) ; diff --git a/include/wx/toplevel.h b/include/wx/toplevel.h index 92fcc6b37f..f10caf9f33 100644 --- a/include/wx/toplevel.h +++ b/include/wx/toplevel.h @@ -20,6 +20,7 @@ #include "wx/nonownedwnd.h" #include "wx/iconbndl.h" +#include "wx/containr.h" // the default names for various classes extern WXDLLEXPORT_DATA(const wxChar) wxFrameNameStr[]; @@ -206,9 +207,6 @@ public: // reverts to the "permanent" default as soon as this temporary default // item loses focus - // used to reset default if pointing to removed child - virtual void RemoveChild(wxWindowBase *child); - // get the default item, temporary or permanent wxWindow *GetDefaultItem() const { return m_winTmpDefault ? m_winTmpDefault : m_winDefault; } @@ -306,6 +304,7 @@ protected: DECLARE_NO_COPY_CLASS(wxTopLevelWindowBase) DECLARE_EVENT_TABLE() + WX_DECLARE_CONTROL_CONTAINER(); }; diff --git a/include/wx/univ/window.h b/include/wx/univ/window.h index fe6a23f7bd..92b17be4a7 100644 --- a/include/wx/univ/window.h +++ b/include/wx/univ/window.h @@ -190,6 +190,16 @@ public: // should we use the standard control colours or not? virtual bool ShouldInheritColours() const { return false; } + virtual bool IsClientAreaChild(const wxWindow *child) const + { +#if wxUSE_SCROLLBAR + if ( child == (wxWindow*)m_scrollbarHorz || + child == (wxWindow*)m_scrollbarVert ) + return false; +#endif + return wxWindowNative::IsClientAreaChild(child); + } + protected: // common part of all ctors void Init(); diff --git a/include/wx/window.h b/include/wx/window.h index 91a1ac180d..80c4b0961e 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -641,6 +641,11 @@ public: virtual void AddChild( wxWindowBase *child ); virtual void RemoveChild( wxWindowBase *child ); + // returns true if the child is in the client area of the window, i.e. is + // not scrollbar, toolbar etc. + virtual bool IsClientAreaChild(const wxWindow *WXUNUSED(child)) const + { return true; } + // looking for windows // ------------------- diff --git a/src/common/containr.cpp b/src/common/containr.cpp index a7de0bd423..16fda35e9d 100644 --- a/src/common/containr.cpp +++ b/src/common/containr.cpp @@ -75,10 +75,8 @@ bool wxControlContainerBase::ShouldAcceptFocus() const wxWindow *child = node->GetData(); node = node->GetNext(); -#ifdef __WXMAC__ - if ( m_winParent->MacIsWindowScrollbar( child ) ) + if ( !m_winParent->IsClientAreaChild(child) ) continue; -#endif if ( child->CanAcceptFocus() ) return false; @@ -658,11 +656,10 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused) wxWindow *child = node->GetData(); node = node->GetNext(); -#ifdef __WXMAC__ - if ( child->GetParent()->MacIsWindowScrollbar( child ) ) + // skip special windows: + if ( !win->IsClientAreaChild(child) ) continue; -#endif - + if ( child->CanAcceptFocusFromKeyboard() && !child->IsTopLevel() ) { #ifdef __WXMSW__ diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp index 0991a598ae..92417acc0e 100644 --- a/src/common/dlgcmn.cpp +++ b/src/common/dlgcmn.cpp @@ -52,12 +52,8 @@ BEGIN_EVENT_TABLE(wxDialogBase, wxTopLevelWindow) EVT_CLOSE(wxDialogBase::OnCloseWindow) EVT_CHAR_HOOK(wxDialogBase::OnCharHook) - - WX_EVENT_TABLE_CONTROL_CONTAINER(wxDialogBase) END_EVENT_TABLE() -WX_DELEGATE_TO_CONTROL_CONTAINER(wxDialogBase, wxTopLevelWindow) - void wxDialogBase::Init() { m_returnCode = 0; @@ -68,8 +64,6 @@ void wxDialogBase::Init() // dialog controls from reaching the parent frame which is usually // undesirable and can lead to unexpected and hard to find bugs SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS); - - WX_INIT_CONTROL_CONTAINER(); } // helper of GetParentForModalDialog() diff --git a/src/common/toplvcmn.cpp b/src/common/toplvcmn.cpp index e72953cf7e..77cbec0582 100644 --- a/src/common/toplvcmn.cpp +++ b/src/common/toplvcmn.cpp @@ -40,8 +40,11 @@ BEGIN_EVENT_TABLE(wxTopLevelWindowBase, wxWindow) EVT_CLOSE(wxTopLevelWindowBase::OnCloseWindow) EVT_SIZE(wxTopLevelWindowBase::OnSize) EVT_WINDOW_DESTROY(wxTopLevelWindowBase::OnChildDestroy) + WX_EVENT_TABLE_CONTROL_CONTAINER(wxTopLevelWindowBase) END_EVENT_TABLE() +WX_DELEGATE_TO_CONTROL_CONTAINER(wxTopLevelWindowBase, wxWindow) + // ============================================================================ // implementation // ============================================================================ @@ -58,10 +61,14 @@ wxTopLevelWindowBase::wxTopLevelWindowBase() m_isShown = false; m_winDefault = NULL; m_winTmpDefault = NULL; + + WX_INIT_CONTROL_CONTAINER(); } wxTopLevelWindowBase::~wxTopLevelWindowBase() { + m_winDefault = m_winTmpDefault = NULL; + // don't let wxTheApp keep any stale pointers to us if ( wxTheApp && wxTheApp->GetTopWindow() == this ) wxTheApp->SetTopWindow(NULL); @@ -412,14 +419,3 @@ void wxTopLevelWindowBase::RequestUserAttention(int WXUNUSED(flags)) // it's probably better than do nothing, isn't it? Raise(); } - -void wxTopLevelWindowBase::RemoveChild(wxWindowBase *child) -{ - if ( child == m_winDefault ) - m_winDefault = NULL; - - if ( child == m_winTmpDefault ) - m_winTmpDefault = NULL; - - wxWindow::RemoveChild(child); -} -- 2.45.2