nss: upgrade to release 3.73
[LibreOffice.git] / sfx2 / source / notebookbar / NotebookbarPopup.cxx
blobcba325a43c56d627ac7c80f259216ebba3cf14c7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "NotebookbarPopup.hxx"
11 #include <vcl/IPrioritable.hxx>
12 #include <vcl/layout.hxx>
14 NotebookbarPopup::NotebookbarPopup(const VclPtr<VclHBox>& pParent)
15 : FloatingWindow(pParent, "Popup", "sfx/ui/notebookbarpopup.ui")
16 , m_pParent(pParent)
18 get(m_pBox, "box");
19 m_pBox->SetSizePixel(Size(100, 75));
20 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
21 const BitmapEx& aPersona = rStyleSettings.GetPersonaHeader();
23 if (!aPersona.IsEmpty())
24 m_pBox->SetBackground(Wallpaper(aPersona));
25 else
26 m_pBox->SetBackground(rStyleSettings.GetDialogColor());
29 NotebookbarPopup::~NotebookbarPopup() { disposeOnce(); }
31 VclHBox* NotebookbarPopup::getBox() { return m_pBox.get(); }
33 void NotebookbarPopup::PopupModeEnd()
35 hideSeparators(false);
36 while (m_pBox->GetChildCount())
38 vcl::IPrioritable* pChild = dynamic_cast<vcl::IPrioritable*>(GetChild(0));
39 if (pChild)
40 pChild->HideContent();
42 vcl::Window* pWindow = m_pBox->GetChild(0);
43 pWindow->SetParent(m_pParent);
45 // resize after all children of box are empty
46 if (m_pParent && !m_pBox->GetChildCount())
47 m_pParent->Resize();
50 FloatingWindow::PopupModeEnd();
53 void NotebookbarPopup::hideSeparators(bool bHide)
55 // separator on the beginning
56 vcl::Window* pWindow = m_pBox->GetChild(0);
57 while (pWindow && pWindow->GetType() == WindowType::CONTAINER)
59 pWindow = pWindow->GetChild(0);
61 if (pWindow && pWindow->GetType() == WindowType::FIXEDLINE)
63 if (bHide)
64 pWindow->Hide();
65 else
66 pWindow->Show();
69 // separator on the end
70 pWindow = m_pBox->GetChild(m_pBox->GetChildCount() - 1);
71 while (pWindow && pWindow->GetType() == WindowType::CONTAINER)
73 pWindow = pWindow->GetChild(pWindow->GetChildCount() - 1);
75 if (pWindow && pWindow->GetType() == WindowType::FIXEDLINE)
77 if (bHide)
78 pWindow->Hide();
79 else
80 pWindow->Show();
83 if (bHide)
85 sal_Int32 BoxId = 0;
86 while (BoxId <= m_pBox->GetChildCount() - 1)
88 if (m_pBox->GetChild(BoxId))
90 pWindow = m_pBox->GetChild(BoxId);
91 ApplyBackground(pWindow);
93 BoxId++;
96 else
98 sal_Int32 BoxId = m_pBox->GetChildCount() - 1;
99 while (BoxId >= 0)
101 if (m_pBox->GetChild(BoxId))
103 pWindow = m_pBox->GetChild(BoxId);
104 RemoveBackground(pWindow);
106 BoxId--;
111 void NotebookbarPopup::dispose()
113 PopupModeEnd();
114 m_pBox.disposeAndClear();
115 m_pParent.clear();
117 FloatingWindow::dispose();
120 void NotebookbarPopup::ApplyBackground(vcl::Window* pWindow)
122 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
123 const BitmapEx& aPersona = rStyleSettings.GetPersonaHeader();
125 if (!aPersona.IsEmpty())
126 pWindow->SetBackground(Wallpaper(aPersona));
127 else
128 pWindow->SetBackground(rStyleSettings.GetDialogColor());
130 sal_Int32 nNext = 0;
131 VclPtr<vcl::Window> pChild = pWindow->GetChild(nNext);
132 while (pChild && pWindow->GetType() == WindowType::CONTAINER)
134 ApplyBackground(pChild);
135 nNext++;
136 if (pWindow->GetChild(nNext) && pWindow->GetType() == WindowType::CONTAINER)
137 pChild = pWindow->GetChild(nNext);
138 else
139 break;
143 void NotebookbarPopup::RemoveBackground(vcl::Window* pWindow)
145 pWindow->SetBackground(Wallpaper(COL_TRANSPARENT));
147 sal_Int32 nNext = 0;
148 VclPtr<vcl::Window> pChild = pWindow->GetChild(nNext);
149 while (pChild && pWindow->GetType() == WindowType::CONTAINER)
151 RemoveBackground(pChild);
152 nNext++;
153 if (pWindow->GetChild(nNext) && pWindow->GetType() == WindowType::CONTAINER)
154 pChild = pWindow->GetChild(nNext);
155 else
156 break;
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */