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()
90 ::sal_uInt16 SAL_CALL
StatusbarItem::getItemId()
95 ::sal_uInt32 SAL_CALL
StatusbarItem::getWidth()
97 SolarMutexGuard aGuard
;
99 return m_pStatusBar
->GetItemWidth( m_nId
);
101 return ::sal_uInt32(0);
104 ::sal_uInt16 SAL_CALL
StatusbarItem::getStyle()
106 std::unique_lock
aGuard( m_aMutex
);
110 ::sal_Int32 SAL_CALL
StatusbarItem::getOffset()
112 SolarMutexGuard aGuard
;
114 return m_pStatusBar
->GetItemOffset( m_nId
);
119 css::awt::Rectangle SAL_CALL
StatusbarItem::getItemRect()
121 SolarMutexGuard aGuard
;
122 css::awt::Rectangle aAWTRect
;
125 tools::Rectangle aRect
= m_pStatusBar
->GetItemRect( m_nId
);
126 return css::awt::Rectangle( aRect
.Left(),
135 OUString SAL_CALL
StatusbarItem::getText()
137 SolarMutexGuard aGuard
;
139 return m_pStatusBar
->GetItemText( m_nId
);
144 void SAL_CALL
StatusbarItem::setText( const OUString
& rText
)
146 SolarMutexGuard aGuard
;
148 m_pStatusBar
->SetItemText( m_nId
, rText
);
151 OUString SAL_CALL
StatusbarItem::getHelpText()
153 SolarMutexGuard aGuard
;
155 return m_pStatusBar
->GetHelpText( m_nId
);
160 void SAL_CALL
StatusbarItem::setHelpText( const OUString
& rHelpText
)
162 SolarMutexGuard aGuard
;
164 m_pStatusBar
->SetHelpText( m_nId
, rHelpText
);
167 OUString SAL_CALL
StatusbarItem::getQuickHelpText()
169 SolarMutexGuard aGuard
;
171 return m_pStatusBar
->GetHelpText( m_nId
);
176 void SAL_CALL
StatusbarItem::setQuickHelpText( const OUString
& rQuickHelpText
)
178 SolarMutexGuard aGuard
;
180 m_pStatusBar
->SetQuickHelpText( m_nId
, rQuickHelpText
);
183 OUString SAL_CALL
StatusbarItem::getAccessibleName()
185 SolarMutexGuard aGuard
;
187 return m_pStatusBar
->GetAccessibleName( m_nId
);
192 void SAL_CALL
StatusbarItem::setAccessibleName( const OUString
& rAccessibleName
)
194 SolarMutexGuard aGuard
;
196 m_pStatusBar
->SetAccessibleName( m_nId
, rAccessibleName
);
199 sal_Bool SAL_CALL
StatusbarItem::getVisible()
201 SolarMutexGuard aGuard
;
203 return m_pStatusBar
->IsItemVisible( m_nId
);
208 void SAL_CALL
StatusbarItem::setVisible( sal_Bool bVisible
)
210 SolarMutexGuard aGuard
;
214 if ( bool(bVisible
) != m_pStatusBar
->IsItemVisible( m_nId
) )
217 m_pStatusBar
->ShowItem( m_nId
);
219 m_pStatusBar
->HideItem( m_nId
);
223 void SAL_CALL
StatusbarItem::repaint( )
225 SolarMutexGuard aGuard
;
228 m_pStatusBar
->RedrawItem( m_nId
);
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */