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 "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")
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
));
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));
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())
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
)
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
)
86 while (BoxId
<= m_pBox
->GetChildCount() - 1)
88 if (m_pBox
->GetChild(BoxId
))
90 pWindow
= m_pBox
->GetChild(BoxId
);
91 ApplyBackground(pWindow
);
98 sal_Int32 BoxId
= m_pBox
->GetChildCount() - 1;
101 if (m_pBox
->GetChild(BoxId
))
103 pWindow
= m_pBox
->GetChild(BoxId
);
104 RemoveBackground(pWindow
);
111 void NotebookbarPopup::dispose()
114 m_pBox
.disposeAndClear();
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
));
128 pWindow
->SetBackground(rStyleSettings
.GetDialogColor());
131 VclPtr
<vcl::Window
> pChild
= pWindow
->GetChild(nNext
);
132 while (pChild
&& pWindow
->GetType() == WindowType::CONTAINER
)
134 ApplyBackground(pChild
);
136 if (pWindow
->GetChild(nNext
) && pWindow
->GetType() == WindowType::CONTAINER
)
137 pChild
= pWindow
->GetChild(nNext
);
143 void NotebookbarPopup::RemoveBackground(vcl::Window
* pWindow
)
145 pWindow
->SetBackground(Wallpaper(COL_TRANSPARENT
));
148 VclPtr
<vcl::Window
> pChild
= pWindow
->GetChild(nNext
);
149 while (pChild
&& pWindow
->GetType() == WindowType::CONTAINER
)
151 RemoveBackground(pChild
);
153 if (pWindow
->GetChild(nNext
) && pWindow
->GetType() == WindowType::CONTAINER
)
154 pChild
= pWindow
->GetChild(nNext
);
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */