bump product version to 7.6.3.2-android
[LibreOffice.git] / vcl / source / control / NotebookbarPopup.cxx
blob3cc21815ab8402a3b4d3a354c4a1792f4860e706
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 <vcl/bitmapex.hxx>
11 #include <vcl/builder.hxx>
12 #include <vcl/layout.hxx>
13 #include <IPrioritable.hxx>
14 #include <NotebookbarPopup.hxx>
16 NotebookbarPopup::NotebookbarPopup(const VclPtr<VclHBox>& pParent)
17 : FloatingWindow(pParent, "Popup", "sfx/ui/notebookbarpopup.ui")
18 , m_pParent(pParent)
20 m_pUIBuilder->get(m_pBox, "box");
21 m_pBox->SetSizePixel(Size(100, 75));
22 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
23 const BitmapEx& aPersona = rStyleSettings.GetPersonaHeader();
25 if (!aPersona.IsEmpty())
26 m_pBox->SetBackground(Wallpaper(aPersona));
27 else
28 m_pBox->SetBackground(rStyleSettings.GetDialogColor());
31 NotebookbarPopup::~NotebookbarPopup() { disposeOnce(); }
33 VclHBox* NotebookbarPopup::getBox() { return m_pBox.get(); }
35 void NotebookbarPopup::PopupModeEnd()
37 hideSeparators(false);
38 while (m_pBox->GetChildCount())
40 vcl::IPrioritable* pChild = dynamic_cast<vcl::IPrioritable*>(GetChild(0));
41 if (pChild)
42 pChild->HideContent();
44 vcl::Window* pWindow = m_pBox->GetChild(0);
45 pWindow->SetParent(m_pParent);
47 // resize after all children of box are empty
48 if (m_pParent && !m_pBox->GetChildCount())
49 m_pParent->Resize();
52 FloatingWindow::PopupModeEnd();
55 void NotebookbarPopup::hideSeparators(bool bHide)
57 // separator on the beginning
58 vcl::Window* pWindow = m_pBox->GetChild(0);
59 while (pWindow && pWindow->GetType() == WindowType::CONTAINER)
61 pWindow = pWindow->GetChild(0);
63 if (pWindow && pWindow->GetType() == WindowType::FIXEDLINE)
65 if (bHide)
66 pWindow->Hide();
67 else
68 pWindow->Show();
71 // separator on the end
72 pWindow = m_pBox->GetChild(m_pBox->GetChildCount() - 1);
73 while (pWindow && pWindow->GetType() == WindowType::CONTAINER)
75 pWindow = pWindow->GetChild(pWindow->GetChildCount() - 1);
77 if (pWindow && pWindow->GetType() == WindowType::FIXEDLINE)
79 if (bHide)
80 pWindow->Hide();
81 else
82 pWindow->Show();
85 if (bHide)
87 sal_Int32 BoxId = 0;
88 while (BoxId <= m_pBox->GetChildCount() - 1)
90 if (m_pBox->GetChild(BoxId))
92 pWindow = m_pBox->GetChild(BoxId);
93 ApplyBackground(pWindow);
95 BoxId++;
98 else
100 sal_Int32 BoxId = m_pBox->GetChildCount() - 1;
101 while (BoxId >= 0)
103 if (m_pBox->GetChild(BoxId))
105 pWindow = m_pBox->GetChild(BoxId);
106 RemoveBackground(pWindow);
108 BoxId--;
113 void NotebookbarPopup::dispose()
115 PopupModeEnd();
116 m_pBox.disposeAndClear();
117 m_pParent.clear();
119 FloatingWindow::dispose();
122 void NotebookbarPopup::ApplyBackground(vcl::Window* pWindow)
124 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
125 const BitmapEx& aPersona = rStyleSettings.GetPersonaHeader();
127 if (!aPersona.IsEmpty())
128 pWindow->SetBackground(Wallpaper(aPersona));
129 else
130 pWindow->SetBackground(rStyleSettings.GetDialogColor());
132 sal_Int32 nNext = 0;
133 VclPtr<vcl::Window> pChild = pWindow->GetChild(nNext);
134 while (pChild && pWindow->GetType() == WindowType::CONTAINER)
136 ApplyBackground(pChild);
137 nNext++;
138 if (pWindow->GetChild(nNext) && pWindow->GetType() == WindowType::CONTAINER)
139 pChild = pWindow->GetChild(nNext);
140 else
141 break;
145 void NotebookbarPopup::RemoveBackground(vcl::Window* pWindow)
147 pWindow->SetBackground(Wallpaper(COL_TRANSPARENT));
149 sal_Int32 nNext = 0;
150 VclPtr<vcl::Window> pChild = pWindow->GetChild(nNext);
151 while (pChild && pWindow->GetType() == WindowType::CONTAINER)
153 RemoveBackground(pChild);
154 nNext++;
155 if (pWindow->GetChild(nNext) && pWindow->GetType() == WindowType::CONTAINER)
156 pChild = pWindow->GetChild(nNext);
157 else
158 break;
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */