diff options
-rw-r--r-- | sfx2/source/notebookbar/PriorityHBox.cxx | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/sfx2/source/notebookbar/PriorityHBox.cxx b/sfx2/source/notebookbar/PriorityHBox.cxx index df854701370b..be9c16062615 100644 --- a/sfx2/source/notebookbar/PriorityHBox.cxx +++ b/sfx2/source/notebookbar/PriorityHBox.cxx @@ -55,8 +55,31 @@ public: disposeOnce(); } + void Initialize() + { + m_bInitialized = true; + + GetChildrenWithPriorities(); + SetSizeFromParent(); + } + + void SetSizeFromParent() + { + vcl::Window* pParent = GetParent(); + if (pParent) + { + Size aParentSize = pParent->GetSizePixel(); + SetSizePixel(Size(aParentSize.getWidth(), aParentSize.getHeight())); + } + } + virtual Size calculateRequisition() const override { + if (!m_bInitialized) + { + return VclHBox::calculateRequisition(); + } + sal_uInt16 nVisibleChildren = 0; Size aSize; @@ -90,6 +113,13 @@ public: virtual void Resize() override { + SetSizeFromParent(); + + if (!m_bInitialized) + { + return VclHBox::Resize(); + } + long nWidth = GetSizePixel().Width(); long nCurrentWidth = VclHBox::calculateRequisition().getWidth(); @@ -132,18 +162,7 @@ public: virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override { if (!m_bInitialized && SfxViewFrame::Current()) - { - m_bInitialized = true; - - GetChildrenWithPriorities(); - - SystemWindow* pSystemWindow = SfxViewFrame::Current()->GetFrame().GetSystemWindow(); - if (pSystemWindow) - { - long nWidth = pSystemWindow->GetSizePixel().Width(); - SetSizePixel(Size(nWidth, GetSizePixel().Height())); - } - } + Initialize(); VclHBox::Paint(rRenderContext, rRect); } @@ -160,6 +179,9 @@ public: m_aSortedChilds.push_back(pPrioritable); } + if (!m_aSortedChilds.size()) + m_bInitialized = false; + std::sort(m_aSortedChilds.begin(), m_aSortedChilds.end(), lcl_comparePriority); } }; |