From: Vadim Zeitlin Date: Sun, 3 Jun 2012 19:17:03 +0000 (+0000) Subject: Add wxRibbonControl::GetAncestorRibbonBar() helper. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/07c7226468720dc9ad09db54154e67984588568e?hp=017dc06b502c041c112a3948e6c5f65000a86d94 Add wxRibbonControl::GetAncestorRibbonBar() helper. New method allowing to find the ribbon bar containing the given window. See #14283. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71641 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/ribbon/control.h b/include/wx/ribbon/control.h index f0f3d12089..9fd1b92a1d 100644 --- a/include/wx/ribbon/control.h +++ b/include/wx/ribbon/control.h @@ -19,6 +19,7 @@ #include "wx/control.h" #include "wx/dynarray.h" +class wxRibbonBar; class wxRibbonArtProvider; class WXDLLIMPEXP_RIBBON wxRibbonControl : public wxControl @@ -55,6 +56,8 @@ public: virtual bool Realize(); bool Realise() {return Realize();} + virtual wxRibbonBar* GetAncestorRibbonBar()const; + // Finds the best width and height given the parent's width and height virtual wxSize GetBestSizeForParentSize(const wxSize& WXUNUSED(parentSize)) const { return GetBestSize(); } diff --git a/interface/wx/ribbon/control.h b/interface/wx/ribbon/control.h index 4a79b47354..88e0c85ee0 100644 --- a/interface/wx/ribbon/control.h +++ b/interface/wx/ribbon/control.h @@ -148,6 +148,15 @@ public: */ bool Realise(); + /** + Get the first ancestor which is a wxRibbonBar (or derived) or NULL + if not having such parent. + + @since 2.9.4 + */ + virtual wxRibbonBar* GetAncestorRibbonBar()const; + + /** Finds the best width and height given the parent's width and height. Used to implement the wxRIBBON_PANEL_FLEXIBLE panel style. diff --git a/src/ribbon/control.cpp b/src/ribbon/control.cpp index d80449445e..9867ecf7d2 100644 --- a/src/ribbon/control.cpp +++ b/src/ribbon/control.cpp @@ -18,6 +18,7 @@ #if wxUSE_RIBBON #include "wx/ribbon/control.h" +#include "wx/ribbon/bar.h" #ifndef WX_PRECOMP #endif @@ -109,4 +110,16 @@ bool wxRibbonControl::Realize() return true; } +wxRibbonBar* wxRibbonControl::GetAncestorRibbonBar()const +{ + for ( wxWindow* win = GetParent(); win; win = win->GetParent() ) + { + wxRibbonBar* bar = wxDynamicCast(win, wxRibbonBar); + if ( bar ) + return bar; + } + + return NULL; +} + #endif // wxUSE_RIBBON