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
, u
"Popup"_ustr
, u
"sfx/ui/notebookbarpopup.ui"_ustr
)
20 m_pBox
= m_pUIBuilder
->get
<VclHBox
>(u
"box");
21 m_pBox
->SetSizePixel(Size(100, 75));
22 m_pBox
->SetBackground(GetSettings().GetStyleSettings().GetDialogColor());
25 NotebookbarPopup::~NotebookbarPopup() { disposeOnce(); }
27 VclHBox
* NotebookbarPopup::getBox() { return m_pBox
.get(); }
29 void NotebookbarPopup::PopupModeEnd()
31 hideSeparators(false);
32 while (m_pBox
->GetChildCount())
34 vcl::IPrioritable
* pChild
= dynamic_cast<vcl::IPrioritable
*>(GetChild(0));
36 pChild
->HideContent();
38 vcl::Window
* pWindow
= m_pBox
->GetChild(0);
39 pWindow
->SetParent(m_pParent
);
41 // resize after all children of box are empty
42 if (m_pParent
&& !m_pBox
->GetChildCount())
46 FloatingWindow::PopupModeEnd();
49 void NotebookbarPopup::hideSeparators(bool bHide
)
51 // separator on the beginning
52 vcl::Window
* pWindow
= m_pBox
->GetChild(0);
53 while (pWindow
&& pWindow
->GetType() == WindowType::CONTAINER
)
55 pWindow
= pWindow
->GetChild(0);
57 if (pWindow
&& pWindow
->GetType() == WindowType::FIXEDLINE
)
65 // separator on the end
66 pWindow
= m_pBox
->GetChild(m_pBox
->GetChildCount() - 1);
67 while (pWindow
&& pWindow
->GetType() == WindowType::CONTAINER
)
69 pWindow
= pWindow
->GetChild(pWindow
->GetChildCount() - 1);
71 if (pWindow
&& pWindow
->GetType() == WindowType::FIXEDLINE
)
82 while (BoxId
<= m_pBox
->GetChildCount() - 1)
84 if (m_pBox
->GetChild(BoxId
))
86 pWindow
= m_pBox
->GetChild(BoxId
);
87 ApplyBackground(pWindow
);
94 sal_Int32 BoxId
= m_pBox
->GetChildCount() - 1;
97 if (m_pBox
->GetChild(BoxId
))
99 pWindow
= m_pBox
->GetChild(BoxId
);
100 RemoveBackground(pWindow
);
107 void NotebookbarPopup::dispose()
110 m_pBox
.disposeAndClear();
113 FloatingWindow::dispose();
116 void NotebookbarPopup::ApplyBackground(vcl::Window
* pWindow
)
118 pWindow
->SetBackground(GetSettings().GetStyleSettings().GetDialogColor());
121 VclPtr
<vcl::Window
> pChild
= pWindow
->GetChild(nNext
);
122 while (pChild
&& pWindow
->GetType() == WindowType::CONTAINER
)
124 ApplyBackground(pChild
);
126 if (pWindow
->GetChild(nNext
) && pWindow
->GetType() == WindowType::CONTAINER
)
127 pChild
= pWindow
->GetChild(nNext
);
133 void NotebookbarPopup::RemoveBackground(vcl::Window
* pWindow
)
135 pWindow
->SetBackground(Wallpaper(COL_TRANSPARENT
));
138 VclPtr
<vcl::Window
> pChild
= pWindow
->GetChild(nNext
);
139 while (pChild
&& pWindow
->GetType() == WindowType::CONTAINER
)
141 RemoveBackground(pChild
);
143 if (pWindow
->GetChild(nNext
) && pWindow
->GetType() == WindowType::CONTAINER
)
144 pChild
= pWindow
->GetChild(nNext
);
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */