1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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 <svx/labelitemwindow.hxx>
11 #include <vcl/svapp.hxx>
13 LabelItemWindow::LabelItemWindow(vcl::Window
* pParent
, const OUString
& rLabel
)
14 : InterimItemWindow(pParent
, u
"svx/ui/labelbox.ui"_ustr
, u
"LabelBox"_ustr
)
15 , m_xBox(m_xBuilder
->weld_box(u
"LabelBox"_ustr
))
16 , m_xLabel(m_xBuilder
->weld_label(u
"label"_ustr
))
17 , m_xImage(m_xBuilder
->weld_image(u
"image"_ustr
))
19 InitControlBase(m_xLabel
.get());
21 m_xLabel
->set_label(rLabel
);
23 m_xImage
->set_size_request(24, 24); // vcl/res/infobar.png is 32x32 - too large here
27 m_xLabel
->set_toolbar_background();
30 void LabelItemWindow::SetOptimalSize()
32 Size
aSize(m_xBox
->get_preferred_size());
33 aSize
.AdjustWidth(12);
38 void LabelItemWindow::set_label(const OUString
& rLabel
, const LabelItemWindowType eType
)
40 // hide temporarily, to trigger a11y announcement for SHOWING event for
41 // the label with NOTIFICATION a11y role when label gets shown again below
42 if (!rLabel
.isEmpty())
43 m_xLabel
->set_visible(false);
45 m_xLabel
->set_label(rLabel
);
46 if ((eType
== LabelItemWindowType::Text
) || rLabel
.isEmpty())
49 m_xLabel
->set_font_color(COL_AUTO
);
50 m_xBox
->set_background(COL_AUTO
);
52 else if (eType
== LabelItemWindowType::Info
)
55 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
56 if (rStyleSettings
.GetDialogColor().IsDark())
57 m_xBox
->set_background(Color(0x00, 0x56, 0x80));
59 m_xBox
->set_background(Color(0xBD, 0xE5, 0xF8)); // same as InfobarType::INFO
61 m_xLabel
->set_visible(
62 true); // always show and not just if !rLabel.isEmpty() to not make the chevron appear
65 OUString
LabelItemWindow::get_label() const { return m_xLabel
->get_label(); }
67 void LabelItemWindow::dispose()
72 InterimItemWindow::dispose();
75 LabelItemWindow::~LabelItemWindow() { disposeOnce(); }
77 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */