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 .
19 #include <tools/debug.hxx>
21 #include <svl/eitem.hxx>
22 #include <vcl/event.hxx>
23 #include <vcl/image.hxx>
24 #include <vcl/status.hxx>
27 #include <bitmaps.hlst>
28 #include <scresid.hxx>
29 #include <strings.hrc>
31 SFX_IMPL_STATUSBAR_CONTROL(ScAutoCalculateControl
, SfxBoolItem
);
33 ScAutoCalculateControl::ScAutoCalculateControl(sal_uInt16 _nSlotId
, sal_uInt16 _nId
,
35 : SfxStatusBarControl(_nSlotId
, _nId
, rStb
)
40 ScAutoCalculateControl::~ScAutoCalculateControl() {}
42 void ScAutoCalculateControl::StateChangedAtStatusBarControl(sal_uInt16
, SfxItemState eState
,
43 const SfxPoolItem
* pState
)
45 if (eState
!= SfxItemState::DEFAULT
|| SfxItemState::DISABLED
== eState
)
48 auto pItem
= static_cast<const SfxBoolItem
*>(pState
);
51 SAL_WARN("sc", "Item wasn't a SfxBoolItem");
54 m_bIsActive
= pItem
->GetValue();
56 GetStatusBar().SetQuickHelpText(GetId(), m_bIsActive
? "" : ScResId(STR_AUTOCALC_OFF
));
57 GetStatusBar().Invalidate();
60 void ScAutoCalculateControl::Paint(const UserDrawEvent
& rUsrEvt
)
62 vcl::RenderContext
* pDev
= rUsrEvt
.GetRenderContext();
63 tools::Rectangle
aRect(rUsrEvt
.GetRect());
68 const Image
aImage(StockImage::Yes
, RID_BMP_CALCULATOR_RED
);
70 Point aPt
= aRect
.TopLeft();
71 aPt
+= Point((aRect
.GetSize().getWidth() - aImage
.GetSizePixel().getWidth()) / 2,
72 (aRect
.GetSize().getHeight() - aImage
.GetSizePixel().getHeight()) / 2);
74 pDev
->DrawImage(aPt
, aImage
);
78 void ScAutoCalculateControl::Click()
81 SfxStatusBarControl::Click(); // exec FID_AUTO_CALC and toggle AutoCalc on
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */