1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <uielement/statusbaritem.hxx>
22 #include <vcl/status.hxx>
23 #include <vcl/svapp.hxx>
25 #include <com/sun/star/ui/ItemStyle.hpp>
27 using namespace com::sun::star::ui
;
34 sal_uInt16
impl_convertItemBitsToItemStyle( StatusBarItemBits nItemBits
)
36 sal_uInt16
nStyle( 0 );
38 if ( nItemBits
& StatusBarItemBits::Right
)
39 nStyle
|= ItemStyle::ALIGN_RIGHT
;
40 else if ( nItemBits
& StatusBarItemBits::Left
)
41 nStyle
|= ItemStyle::ALIGN_LEFT
;
43 nStyle
|= ItemStyle::ALIGN_CENTER
;
45 if ( nItemBits
& StatusBarItemBits::Flat
)
46 nStyle
|= ItemStyle::DRAW_FLAT
;
47 else if ( nItemBits
& StatusBarItemBits::Out
)
48 nStyle
|= ItemStyle::DRAW_OUT3D
;
50 nStyle
|= ItemStyle::DRAW_IN3D
;
52 if ( nItemBits
& StatusBarItemBits::AutoSize
)
53 nStyle
|= ItemStyle::AUTO_SIZE
;
55 if ( nItemBits
& StatusBarItemBits::UserDraw
)
56 nStyle
|= ItemStyle::OWNER_DRAW
;
62 StatusbarItem::StatusbarItem(
63 StatusBar
*pStatusBar
,
66 : m_pStatusBar( pStatusBar
)
69 , m_aCommand(std::move( aCommand
))
72 m_nStyle
= impl_convertItemBitsToItemStyle(
73 m_pStatusBar
->GetItemBits( m_nId
) );
76 StatusbarItem::~StatusbarItem()
80 void StatusbarItem::disposing(std::unique_lock
<std::mutex
>&)
82 m_pStatusBar
= nullptr;
85 OUString SAL_CALL
StatusbarItem::getCommand()
87 std::unique_lock
aGuard( m_aMutex
);
91 ::sal_uInt16 SAL_CALL
StatusbarItem::getItemId()
93 std::unique_lock
aGuard( m_aMutex
);
97 ::sal_uInt32 SAL_CALL
StatusbarItem::getWidth()
99 SolarMutexGuard aGuard
;
101 return m_pStatusBar
->GetItemWidth( m_nId
);
103 return ::sal_uInt32(0);
106 ::sal_uInt16 SAL_CALL
StatusbarItem::getStyle()
108 std::unique_lock
aGuard( m_aMutex
);
112 ::sal_Int32 SAL_CALL
StatusbarItem::getOffset()
114 SolarMutexGuard aGuard
;
116 return m_pStatusBar
->GetItemOffset( m_nId
);
121 css::awt::Rectangle SAL_CALL
StatusbarItem::getItemRect()
123 SolarMutexGuard aGuard
;
124 css::awt::Rectangle aAWTRect
;
127 tools::Rectangle aRect
= m_pStatusBar
->GetItemRect( m_nId
);
128 return css::awt::Rectangle( aRect
.Left(),
137 OUString SAL_CALL
StatusbarItem::getText()
139 SolarMutexGuard aGuard
;
141 return m_pStatusBar
->GetItemText( m_nId
);
146 void SAL_CALL
StatusbarItem::setText( const OUString
& rText
)
148 SolarMutexGuard aGuard
;
150 m_pStatusBar
->SetItemText( m_nId
, rText
);
153 OUString SAL_CALL
StatusbarItem::getHelpText()
155 SolarMutexGuard aGuard
;
157 return m_pStatusBar
->GetHelpText( m_nId
);
162 void SAL_CALL
StatusbarItem::setHelpText( const OUString
& rHelpText
)
164 SolarMutexGuard aGuard
;
166 m_pStatusBar
->SetHelpText( m_nId
, rHelpText
);
169 OUString SAL_CALL
StatusbarItem::getQuickHelpText()
171 SolarMutexGuard aGuard
;
173 return m_pStatusBar
->GetHelpText( m_nId
);
178 void SAL_CALL
StatusbarItem::setQuickHelpText( const OUString
& rQuickHelpText
)
180 SolarMutexGuard aGuard
;
182 m_pStatusBar
->SetQuickHelpText( m_nId
, rQuickHelpText
);
185 OUString SAL_CALL
StatusbarItem::getAccessibleName()
187 SolarMutexGuard aGuard
;
189 return m_pStatusBar
->GetAccessibleName( m_nId
);
194 void SAL_CALL
StatusbarItem::setAccessibleName( const OUString
& rAccessibleName
)
196 SolarMutexGuard aGuard
;
198 m_pStatusBar
->SetAccessibleName( m_nId
, rAccessibleName
);
201 sal_Bool SAL_CALL
StatusbarItem::getVisible()
203 SolarMutexGuard aGuard
;
205 return m_pStatusBar
->IsItemVisible( m_nId
);
210 void SAL_CALL
StatusbarItem::setVisible( sal_Bool bVisible
)
212 SolarMutexGuard aGuard
;
216 if ( bool(bVisible
) != m_pStatusBar
->IsItemVisible( m_nId
) )
219 m_pStatusBar
->ShowItem( m_nId
);
221 m_pStatusBar
->HideItem( m_nId
);
225 void SAL_CALL
StatusbarItem::repaint( )
227 SolarMutexGuard aGuard
;
230 m_pStatusBar
->RedrawItem( m_nId
);
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */