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 :
32 : namespace sfx2 { namespace sidebar {
33 :
34 : static const sal_Int32 gaLeftGripPadding (3);
35 : static const sal_Int32 gaRightGripPadding (3);
36 :
37 :
38 0 : DeckTitleBar::DeckTitleBar (
39 : const ::rtl::OUString& rsTitle,
40 : Window* pParentWindow,
41 : const ::boost::function<void(void)>& rCloserAction)
42 : : TitleBar(rsTitle, pParentWindow, GetBackgroundPaint()),
43 : mnCloserItemIndex(1),
44 : maCloserAction(rCloserAction),
45 0 : mbIsCloserVisible(false)
46 : {
47 : OSL_ASSERT(pParentWindow != NULL);
48 :
49 0 : if (maCloserAction)
50 0 : SetCloserVisible(true);
51 :
52 : #ifdef DEBUG
53 : SetText(OUString("DeckTitleBar"));
54 : #endif
55 0 : }
56 :
57 :
58 :
59 :
60 0 : DeckTitleBar::~DeckTitleBar (void)
61 : {
62 0 : }
63 :
64 :
65 :
66 :
67 0 : void DeckTitleBar::SetCloserVisible (const bool bIsCloserVisible)
68 : {
69 0 : if (mbIsCloserVisible != bIsCloserVisible)
70 : {
71 0 : mbIsCloserVisible = bIsCloserVisible;
72 :
73 0 : if (mbIsCloserVisible)
74 : {
75 : maToolBox.InsertItem(
76 : mnCloserItemIndex,
77 0 : Theme::GetImage(Theme::Image_Closer));
78 : maToolBox.SetQuickHelpText(
79 : mnCloserItemIndex,
80 0 : SFX2_RESSTR(SFX_STR_SIDEBAR_CLOSE_DECK));
81 : }
82 : else
83 : maToolBox.RemoveItem(
84 0 : maToolBox.GetItemPos(mnCloserItemIndex));
85 : }
86 0 : }
87 :
88 :
89 :
90 :
91 0 : Rectangle DeckTitleBar::GetTitleArea (const Rectangle& rTitleBarBox)
92 : {
93 0 : Image aGripImage (Theme::GetImage(Theme::Image_Grip));
94 : return Rectangle(
95 0 : aGripImage.GetSizePixel().Width() + gaLeftGripPadding + gaRightGripPadding,
96 : rTitleBarBox.Top(),
97 : rTitleBarBox.Right(),
98 0 : rTitleBarBox.Bottom());
99 : }
100 :
101 :
102 :
103 :
104 0 : void DeckTitleBar::PaintDecoration (const Rectangle& rTitleBarBox)
105 : {
106 : (void)rTitleBarBox;
107 0 : }
108 :
109 :
110 :
111 :
112 0 : sidebar::Paint DeckTitleBar::GetBackgroundPaint (void)
113 : {
114 0 : return Theme::GetPaint(Theme::Paint_DeckTitleBarBackground);
115 : }
116 :
117 :
118 :
119 :
120 0 : Color DeckTitleBar::GetTextColor (void)
121 : {
122 0 : return Theme::GetColor(Theme::Color_DeckTitleFont);
123 : }
124 :
125 :
126 :
127 :
128 0 : void DeckTitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex)
129 : {
130 0 : if (nItemIndex == mnCloserItemIndex)
131 0 : if (maCloserAction)
132 0 : maCloserAction();
133 0 : }
134 :
135 :
136 :
137 :
138 0 : cssu::Reference<css::accessibility::XAccessible> DeckTitleBar::CreateAccessible (void)
139 : {
140 0 : const ::rtl::OUString sAccessibleName(msTitle);
141 0 : SetAccessibleName(sAccessibleName);
142 0 : SetAccessibleDescription(sAccessibleName);
143 0 : return TitleBar::CreateAccessible();
144 : }
145 :
146 :
147 :
148 :
149 0 : void DeckTitleBar::DataChanged (const DataChangedEvent& rEvent)
150 : {
151 : maToolBox.SetItemImage(
152 : mnCloserItemIndex,
153 0 : Theme::GetImage(Theme::Image_Closer));
154 0 : TitleBar::DataChanged(rEvent);
155 0 : }
156 :
157 :
158 : } } // end of namespace sfx2::sidebar
159 :
160 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|