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>
21 #include <vcl/status.hxx>
22 #include <vcl/svapp.hxx>
24 #include <com/sun/star/ui/ItemStyle.hpp>
26 using namespace com::sun::star::ui
;
29 using com::sun::star::uno::RuntimeException
;
36 static sal_uInt16
impl_convertItemBitsToItemStyle( sal_Int16 nItemBits
)
38 sal_uInt16
nStyle( 0 );
40 if ( ( nItemBits
& SIB_RIGHT
) == SIB_RIGHT
)
41 nStyle
|= ItemStyle::ALIGN_RIGHT
;
42 else if ( ( nItemBits
& SIB_LEFT
) == SIB_LEFT
)
43 nStyle
|= ItemStyle::ALIGN_LEFT
;
45 nStyle
|= ItemStyle::ALIGN_CENTER
;
47 if ( ( nItemBits
& SIB_FLAT
) == SIB_FLAT
)
48 nStyle
|= ItemStyle::DRAW_FLAT
;
49 else if ( ( nItemBits
& SIB_OUT
) == SIB_OUT
)
50 nStyle
|= ItemStyle::DRAW_OUT3D
;
52 nStyle
|= ItemStyle::DRAW_IN3D
;
54 if ( ( nItemBits
& SIB_AUTOSIZE
) == SIB_AUTOSIZE
)
55 nStyle
|= ItemStyle::AUTO_SIZE
;
57 if ( ( nItemBits
& SIB_USERDRAW
) == SIB_USERDRAW
)
58 nStyle
|= ItemStyle::OWNER_DRAW
;
64 StatusbarItem::StatusbarItem(
65 StatusBar
*pStatusBar
,
66 AddonStatusbarItemData
*pItemData
,
68 const rtl::OUString
& aCommand
)
69 : StatusbarItem_Base( m_aMutex
)
70 , m_pStatusBar( pStatusBar
)
71 , m_pItemData( pItemData
)
74 , m_aCommand( aCommand
)
77 m_nStyle
= impl_convertItemBitsToItemStyle(
78 m_pStatusBar
->GetItemBits( m_nId
) );
81 StatusbarItem::~StatusbarItem()
85 void SAL_CALL
StatusbarItem::disposing()
87 osl::MutexGuard
aGuard( m_aMutex
);
92 OUString SAL_CALL
StatusbarItem::getCommand()
93 throw (RuntimeException
, std::exception
)
95 osl::MutexGuard
aGuard( m_aMutex
);
99 ::sal_uInt16 SAL_CALL
StatusbarItem::getItemId()
100 throw (RuntimeException
, std::exception
)
102 osl::MutexGuard
aGuard( m_aMutex
);
106 ::sal_uInt32 SAL_CALL
StatusbarItem::getWidth()
107 throw (RuntimeException
, std::exception
)
109 SolarMutexGuard aGuard
;
111 return m_pStatusBar
->GetItemWidth( m_nId
);
113 return ::sal_uInt32(0);
116 ::sal_uInt16 SAL_CALL
StatusbarItem::getStyle()
117 throw (RuntimeException
, std::exception
)
119 osl::MutexGuard
aGuard( m_aMutex
);
123 ::sal_Int32 SAL_CALL
StatusbarItem::getOffset()
124 throw (RuntimeException
, std::exception
)
126 SolarMutexGuard aGuard
;
128 return m_pStatusBar
->GetItemOffset( m_nId
);
130 return ::sal_Int32(0);
133 ::com::sun::star::awt::Rectangle SAL_CALL
StatusbarItem::getItemRect()
134 throw (RuntimeException
, std::exception
)
136 SolarMutexGuard aGuard
;
137 ::com::sun::star::awt::Rectangle aAWTRect
;
140 Rectangle aRect
= m_pStatusBar
->GetItemRect( m_nId
);
141 return ::com::sun::star::awt::Rectangle( aRect
.Left(),
150 OUString SAL_CALL
StatusbarItem::getText()
151 throw (RuntimeException
, std::exception
)
153 SolarMutexGuard aGuard
;
155 return m_pStatusBar
->GetItemText( m_nId
);
160 void SAL_CALL
StatusbarItem::setText( const OUString
& rText
)
161 throw (RuntimeException
, std::exception
)
163 SolarMutexGuard aGuard
;
165 m_pStatusBar
->SetItemText( m_nId
, rText
);;
168 OUString SAL_CALL
StatusbarItem::getHelpText()
169 throw (RuntimeException
, std::exception
)
171 SolarMutexGuard aGuard
;
173 return m_pStatusBar
->GetHelpText( m_nId
);
178 void SAL_CALL
StatusbarItem::setHelpText( const OUString
& rHelpText
)
179 throw (RuntimeException
, std::exception
)
181 SolarMutexGuard aGuard
;
183 m_pStatusBar
->SetHelpText( m_nId
, rHelpText
);;
186 OUString SAL_CALL
StatusbarItem::getQuickHelpText()
187 throw (RuntimeException
, std::exception
)
189 SolarMutexGuard aGuard
;
191 return m_pStatusBar
->GetHelpText( m_nId
);
196 void SAL_CALL
StatusbarItem::setQuickHelpText( const OUString
& rQuickHelpText
)
197 throw (RuntimeException
, std::exception
)
199 SolarMutexGuard aGuard
;
201 m_pStatusBar
->SetQuickHelpText( m_nId
, rQuickHelpText
);
204 OUString SAL_CALL
StatusbarItem::getAccessibleName()
205 throw (RuntimeException
, std::exception
)
207 SolarMutexGuard aGuard
;
209 return m_pStatusBar
->GetAccessibleName( m_nId
);
214 void SAL_CALL
StatusbarItem::setAccessibleName( const OUString
& rAccessibleName
)
215 throw (RuntimeException
, std::exception
)
217 SolarMutexGuard aGuard
;
219 m_pStatusBar
->SetAccessibleName( m_nId
, rAccessibleName
);
222 sal_Bool SAL_CALL
StatusbarItem::getVisible()
223 throw (RuntimeException
, std::exception
)
225 SolarMutexGuard aGuard
;
227 return m_pStatusBar
->IsItemVisible( m_nId
);
232 void SAL_CALL
StatusbarItem::setVisible( sal_Bool bVisible
)
233 throw (RuntimeException
, std::exception
)
235 SolarMutexGuard aGuard
;
239 if ( bool(bVisible
) != m_pStatusBar
->IsItemVisible( m_nId
) )
242 m_pStatusBar
->ShowItem( m_nId
);
244 m_pStatusBar
->HideItem( m_nId
);
248 void SAL_CALL
StatusbarItem::repaint( )
249 throw (RuntimeException
, std::exception
)
251 SolarMutexGuard aGuard
;
254 m_pStatusBar
->RedrawItem( m_nId
);
260 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */