LibreOffice Module vcl (master) 1
NotebookbarPopup.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 */
9
10#include <vcl/bitmapex.hxx>
11#include <vcl/builder.hxx>
12#include <vcl/layout.hxx>
13#include <IPrioritable.hxx>
14#include <NotebookbarPopup.hxx>
15
17 : FloatingWindow(pParent, "Popup", "sfx/ui/notebookbarpopup.ui")
18 , m_pParent(pParent)
19{
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();
24
25 if (!aPersona.IsEmpty())
26 m_pBox->SetBackground(Wallpaper(aPersona));
27 else
28 m_pBox->SetBackground(rStyleSettings.GetDialogColor());
29}
30
32
34
36{
37 hideSeparators(false);
38 while (m_pBox->GetChildCount())
39 {
40 vcl::IPrioritable* pChild = dynamic_cast<vcl::IPrioritable*>(GetChild(0));
41 if (pChild)
42 pChild->HideContent();
43
44 vcl::Window* pWindow = m_pBox->GetChild(0);
45 pWindow->SetParent(m_pParent);
46
47 // resize after all children of box are empty
49 m_pParent->Resize();
50 }
51
53}
54
56{
57 // separator on the beginning
58 vcl::Window* pWindow = m_pBox->GetChild(0);
59 while (pWindow && pWindow->GetType() == WindowType::CONTAINER)
60 {
61 pWindow = pWindow->GetChild(0);
62 }
63 if (pWindow && pWindow->GetType() == WindowType::FIXEDLINE)
64 {
65 if (bHide)
66 pWindow->Hide();
67 else
68 pWindow->Show();
69 }
70
71 // separator on the end
72 pWindow = m_pBox->GetChild(m_pBox->GetChildCount() - 1);
73 while (pWindow && pWindow->GetType() == WindowType::CONTAINER)
74 {
75 pWindow = pWindow->GetChild(pWindow->GetChildCount() - 1);
76 }
77 if (pWindow && pWindow->GetType() == WindowType::FIXEDLINE)
78 {
79 if (bHide)
80 pWindow->Hide();
81 else
82 pWindow->Show();
83 }
84
85 if (bHide)
86 {
87 sal_Int32 BoxId = 0;
88 while (BoxId <= m_pBox->GetChildCount() - 1)
89 {
90 if (m_pBox->GetChild(BoxId))
91 {
92 pWindow = m_pBox->GetChild(BoxId);
93 ApplyBackground(pWindow);
94 }
95 BoxId++;
96 }
97 }
98 else
99 {
100 sal_Int32 BoxId = m_pBox->GetChildCount() - 1;
101 while (BoxId >= 0)
102 {
103 if (m_pBox->GetChild(BoxId))
104 {
105 pWindow = m_pBox->GetChild(BoxId);
106 RemoveBackground(pWindow);
107 }
108 BoxId--;
109 }
110 }
111}
112
114{
115 PopupModeEnd();
118
120}
121
123{
124 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
125 const BitmapEx& aPersona = rStyleSettings.GetPersonaHeader();
126
127 if (!aPersona.IsEmpty())
128 pWindow->SetBackground(Wallpaper(aPersona));
129 else
130 pWindow->SetBackground(rStyleSettings.GetDialogColor());
131
132 sal_Int32 nNext = 0;
133 VclPtr<vcl::Window> pChild = pWindow->GetChild(nNext);
134 while (pChild && pWindow->GetType() == WindowType::CONTAINER)
135 {
136 ApplyBackground(pChild);
137 nNext++;
138 if (pWindow->GetChild(nNext) && pWindow->GetType() == WindowType::CONTAINER)
139 pChild = pWindow->GetChild(nNext);
140 else
141 break;
142 }
143}
144
146{
148
149 sal_Int32 nNext = 0;
150 VclPtr<vcl::Window> pChild = pWindow->GetChild(nNext);
151 while (pChild && pWindow->GetType() == WindowType::CONTAINER)
152 {
153 RemoveBackground(pChild);
154 nNext++;
155 if (pWindow->GetChild(nNext) && pWindow->GetType() == WindowType::CONTAINER)
156 pChild = pWindow->GetChild(nNext);
157 else
158 break;
159 }
160}
161/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const StyleSettings & GetStyleSettings() const
bool IsEmpty() const
Definition: BitmapEx.cxx:186
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: floatwin.cxx:204
virtual void PopupModeEnd()
Definition: floatwin.cxx:751
ScopedVclPtr< VclHBox > m_pParent
void RemoveBackground(vcl::Window *pWindow)
void hideSeparators(bool bHide)
virtual void PopupModeEnd() override
NotebookbarPopup(const VclPtr< VclHBox > &pParent)
VclPtr< VclHBox > m_pBox
void ApplyBackground(vcl::Window *pWindow)
void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
virtual ~NotebookbarPopup() override
BitmapEx const & GetPersonaHeader() const
const Color & GetDialogColor() const
virtual void SetSizePixel(const Size &rAllocation) override
Definition: layout.cxx:197
void disposeAndClear()
Definition: vclptr.hxx:200
void clear()
Definition: vclptr.hxx:190
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
sal_uInt16 GetChildCount() const
Definition: stacking.cxx:1002
WindowType GetType() const
Definition: window2.cxx:1000
void SetParent(vcl::Window *pNewParent)
Definition: stacking.cxx:832
const AllSettings & GetSettings() const
Definition: window3.cxx:129
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2187
void Hide()
Definition: window.hxx:879
vcl::Window * GetChild(sal_uInt16 nChild) const
Definition: stacking.cxx:1018
void SetBackground()
Definition: window3.cxx:100
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)