LibreOffice Module sfx2 (master) 1
DeckTitleBar.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 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
22
23#include <utility>
24#include <vcl/bitmapex.hxx>
25#include <vcl/customweld.hxx>
26#include <vcl/outdev.hxx>
27#include <vcl/ptrstyle.hxx>
28
29#ifdef DEBUG
30#include <sfx2/sidebar/Tools.hxx>
31#endif
32
33namespace sfx2::sidebar {
34
36{
37private:
39public:
40 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
41 {
44 }
45
46 virtual void StyleUpdated() override
47 {
48 maGrip = BitmapEx("sfx2/res/grip.png");
49 Size aGripSize(maGrip.GetSizePixel());
50 set_size_request(aGripSize.Width(), aGripSize.Height());
52 }
53
54 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/) override
55 {
57 rRenderContext.Erase();
58 rRenderContext.DrawBitmapEx(Point(0, 0), maGrip);
59 }
60};
61
62DeckTitleBar::DeckTitleBar (const OUString& rsTitle,
63 weld::Builder& rBuilder,
64 std::function<void()> aCloserAction)
65 : TitleBar(rBuilder, Theme::Color_DeckTitleBarBackground)
66 , mxGripWidget(new GripWidget)
67 , mxGripWeld(new weld::CustomWeld(rBuilder, "grip", *mxGripWidget))
68 , mxLabel(rBuilder.weld_label("label"))
69 , maCloserAction(std::move(aCloserAction))
70 , mbIsCloserVisible(false)
71{
72 mxLabel->set_label(rsTitle);
73 mxGripWidget->SetPointer(PointerStyle::Move);
74
76 SetCloserVisible(true);
77}
78
80{
81}
82
84{
85 int x, y, width, height;
86 if (mxGripWidget->GetDrawingArea()->get_extents_relative_to(*mxTitlebar, x, y, width, height))
87 return tools::Rectangle(Point(x, y), Size(width, height));
88 return tools::Rectangle();
89}
90
91void DeckTitleBar::SetTitle(const OUString& rsTitle)
92{
93 mxLabel->set_label(rsTitle);
94}
95
96OUString DeckTitleBar::GetTitle() const
97{
98 return mxLabel->get_label();
99}
100
101void DeckTitleBar::SetCloserVisible (const bool bIsCloserVisible)
102{
103 if (mbIsCloserVisible == bIsCloserVisible)
104 return;
105
106 mbIsCloserVisible = bIsCloserVisible;
107
108 mxToolBox->set_visible(mbIsCloserVisible);
109}
110
112{
113 if (maCloserAction)
115}
116
118{
119 mxToolBox->set_item_icon_name("button", "sfx2/res/closedoc.png");
121}
122
123} // end of namespace sfx2::sidebar
124
125/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::rtl::Reference< TimeLabel > mxLabel
const Size & GetSizePixel() const
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
void SetBackground()
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void SetCloserVisible(const bool bIsCloserVisible)
virtual void HandleToolBoxItemClick() override
virtual void DataChanged() override
std::unique_ptr< GripWidget > mxGripWidget
virtual void SetTitle(const OUString &rsTitle) override
const std::function< void()> maCloserAction
virtual ~DeckTitleBar() override
DeckTitleBar(const OUString &rsTitle, weld::Builder &rBuilder, std::function< void()> aCloserAction)
virtual OUString GetTitle() const override
tools::Rectangle GetDragArea() const
std::unique_ptr< weld::Label > mxLabel
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
virtual void StyleUpdated() override
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Simple collection of colors, gradients, fonts that define the look of the sidebar and its controls.
Definition: Theme.hxx:44
static Color GetColor(const ThemeItem eItem)
Definition: Theme.cxx:49
@ Color_DeckTitleBarBackground
Definition: Theme.hxx:58
virtual void DataChanged()
Definition: TitleBar.cxx:43
std::unique_ptr< weld::Box > mxTitlebar
Definition: TitleBar.hxx:55
std::unique_ptr< weld::Toolbar > mxToolBox
Definition: TitleBar.hxx:57
void set_size_request(int nWidth, int nHeight)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
float y
float x