Line data Source code
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 :
20 : #include "DeckTitleBar.hxx"
21 : #include <sfx2/sidebar/Theme.hxx>
22 : #include <sfx2/sfxresid.hxx>
23 : #include "Sidebar.hrc"
24 :
25 : #include <vcl/image.hxx>
26 :
27 : #ifdef DEBUG
28 : #include <sfx2/sidebar/Tools.hxx>
29 : #endif
30 :
31 : namespace sfx2 { namespace sidebar {
32 :
33 : namespace
34 : {
35 : static const sal_Int32 gaLeftGripPadding (3);
36 : static const sal_Int32 gaRightGripPadding (3);
37 : }
38 :
39 3156 : DeckTitleBar::DeckTitleBar (const OUString& rsTitle,
40 : vcl::Window* pParentWindow,
41 : const std::function<void()>& rCloserAction)
42 : : TitleBar(rsTitle, pParentWindow, GetBackgroundPaint())
43 : , mnCloserItemIndex(1)
44 : , maCloserAction(rCloserAction)
45 3156 : , mbIsCloserVisible(false)
46 : {
47 : OSL_ASSERT(pParentWindow != NULL);
48 :
49 3156 : if (maCloserAction)
50 3156 : SetCloserVisible(true);
51 :
52 : #ifdef DEBUG
53 : SetText(OUString("DeckTitleBar"));
54 : #endif
55 3156 : }
56 :
57 6765 : void DeckTitleBar::SetCloserVisible (const bool bIsCloserVisible)
58 : {
59 6765 : if (mbIsCloserVisible != bIsCloserVisible)
60 : {
61 3156 : mbIsCloserVisible = bIsCloserVisible;
62 :
63 3156 : if (mbIsCloserVisible)
64 : {
65 3156 : maToolBox->InsertItem(mnCloserItemIndex,
66 6312 : Theme::GetImage(Theme::Image_Closer));
67 3156 : maToolBox->SetQuickHelpText(mnCloserItemIndex,
68 6312 : SFX2_RESSTR(SFX_STR_SIDEBAR_CLOSE_DECK));
69 : }
70 : else
71 0 : maToolBox->RemoveItem(maToolBox->GetItemPos(mnCloserItemIndex));
72 : }
73 6765 : }
74 :
75 144 : Rectangle DeckTitleBar::GetTitleArea (const Rectangle& rTitleBarBox)
76 : {
77 144 : Image aGripImage (Theme::GetImage(Theme::Image_Grip));
78 : return Rectangle(
79 288 : aGripImage.GetSizePixel().Width() + gaLeftGripPadding + gaRightGripPadding,
80 : rTitleBarBox.Top(),
81 : rTitleBarBox.Right(),
82 432 : rTitleBarBox.Bottom());
83 : }
84 :
85 144 : void DeckTitleBar::PaintDecoration(vcl::RenderContext& /*rRenderContext*/, const Rectangle& /*rTitleBarBox*/)
86 : {
87 144 : }
88 :
89 3159 : sidebar::Paint DeckTitleBar::GetBackgroundPaint()
90 : {
91 3159 : return Theme::GetPaint(Theme::Paint_DeckTitleBarBackground);
92 : }
93 :
94 0 : Color DeckTitleBar::GetTextColor()
95 : {
96 0 : return Theme::GetColor(Theme::Color_DeckTitleFont);
97 : }
98 :
99 0 : void DeckTitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex)
100 : {
101 0 : if (nItemIndex == mnCloserItemIndex && maCloserAction)
102 0 : maCloserAction();
103 0 : }
104 :
105 0 : css::uno::Reference<css::accessibility::XAccessible> DeckTitleBar::CreateAccessible()
106 : {
107 0 : const OUString sAccessibleName(msTitle);
108 0 : SetAccessibleName(sAccessibleName);
109 0 : SetAccessibleDescription(sAccessibleName);
110 0 : return TitleBar::CreateAccessible();
111 : }
112 :
113 3 : void DeckTitleBar::DataChanged (const DataChangedEvent& rEvent)
114 : {
115 3 : maToolBox->SetItemImage(
116 : mnCloserItemIndex,
117 6 : Theme::GetImage(Theme::Image_Closer));
118 3 : TitleBar::DataChanged(rEvent);
119 3 : }
120 :
121 648 : } } // end of namespace sfx2::sidebar
122 :
123 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|