1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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")
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
));
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));
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())
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
)
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
)
88 while (BoxId
<= m_pBox
->GetChildCount() - 1)
90 if (m_pBox
->GetChild(BoxId
))
92 pWindow
= m_pBox
->GetChild(BoxId
);
93 ApplyBackground(pWindow
);
100 sal_Int32 BoxId
= m_pBox
->GetChildCount() - 1;
103 if (m_pBox
->GetChild(BoxId
))
105 pWindow
= m_pBox
->GetChild(BoxId
);
106 RemoveBackground(pWindow
);
113 void NotebookbarPopup::dispose()
116 m_pBox
.disposeAndClear();
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
));
130 pWindow
->SetBackground(rStyleSettings
.GetDialogColor());
133 VclPtr
<vcl::Window
> pChild
= pWindow
->GetChild(nNext
);
134 while (pChild
&& pWindow
->GetType() == WindowType::CONTAINER
)
136 ApplyBackground(pChild
);
138 if (pWindow
->GetChild(nNext
) && pWindow
->GetType() == WindowType::CONTAINER
)
139 pChild
= pWindow
->GetChild(nNext
);
145 void NotebookbarPopup::RemoveBackground(vcl::Window
* pWindow
)
147 pWindow
->SetBackground(Wallpaper(COL_TRANSPARENT
));
150 VclPtr
<vcl::Window
> pChild
= pWindow
->GetChild(nNext
);
151 while (pChild
&& pWindow
->GetType() == WindowType::CONTAINER
)
153 RemoveBackground(pChild
);
155 if (pWindow
->GetChild(nNext
) && pWindow
->GetType() == WindowType::CONTAINER
)
156 pChild
= pWindow
->GetChild(nNext
);
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */