/src/libreoffice/sc/source/ui/app/acctrl.cxx
Line | Count | Source |
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 | | #include <tools/debug.hxx> |
20 | | |
21 | | #include <svl/eitem.hxx> |
22 | | #include <vcl/event.hxx> |
23 | | #include <vcl/image.hxx> |
24 | | #include <vcl/status.hxx> |
25 | | |
26 | | #include <acctrl.hxx> |
27 | | #include <bitmaps.hlst> |
28 | | #include <scresid.hxx> |
29 | | #include <strings.hrc> |
30 | | |
31 | | SFX_IMPL_STATUSBAR_CONTROL(ScAutoCalculateControl, SfxBoolItem); |
32 | | |
33 | | ScAutoCalculateControl::ScAutoCalculateControl(sal_uInt16 _nSlotId, sal_uInt16 _nId, |
34 | | StatusBar& rStb) |
35 | 0 | : SfxStatusBarControl(_nSlotId, _nId, rStb) |
36 | 0 | , m_bIsActive(false) |
37 | 0 | { |
38 | 0 | } |
39 | | |
40 | 0 | ScAutoCalculateControl::~ScAutoCalculateControl() {} |
41 | | |
42 | | void ScAutoCalculateControl::StateChangedAtStatusBarControl(sal_uInt16, SfxItemState eState, |
43 | | const SfxPoolItem* pState) |
44 | 0 | { |
45 | 0 | if (eState != SfxItemState::DEFAULT || SfxItemState::DISABLED == eState) |
46 | 0 | return; |
47 | | |
48 | 0 | auto pItem = static_cast<const SfxBoolItem*>(pState); |
49 | 0 | if (!pItem) |
50 | 0 | { |
51 | 0 | SAL_WARN("sc", "Item wasn't a SfxBoolItem"); |
52 | 0 | return; |
53 | 0 | } |
54 | 0 | m_bIsActive = pItem->GetValue(); |
55 | |
|
56 | 0 | GetStatusBar().SetQuickHelpText(GetId(), m_bIsActive ? "" : ScResId(STR_AUTOCALC_OFF)); |
57 | 0 | GetStatusBar().Invalidate(); |
58 | 0 | } |
59 | | |
60 | | void ScAutoCalculateControl::Paint(const UserDrawEvent& rUsrEvt) |
61 | 0 | { |
62 | 0 | vcl::RenderContext* pDev = rUsrEvt.GetRenderContext(); |
63 | 0 | tools::Rectangle aRect(rUsrEvt.GetRect()); |
64 | 0 | pDev->Erase(); |
65 | |
|
66 | 0 | if (!m_bIsActive) |
67 | 0 | { |
68 | 0 | const Image aImage(StockImage::Yes, RID_BMP_CALCULATOR_RED); |
69 | |
|
70 | 0 | Point aPt = aRect.TopLeft(); |
71 | 0 | aPt += Point((aRect.GetSize().getWidth() - aImage.GetSizePixel().getWidth()) / 2, |
72 | 0 | (aRect.GetSize().getHeight() - aImage.GetSizePixel().getHeight()) / 2); |
73 | |
|
74 | 0 | pDev->DrawImage(aPt, aImage); |
75 | 0 | } |
76 | 0 | } |
77 | | |
78 | | void ScAutoCalculateControl::Click() |
79 | 0 | { |
80 | 0 | if (!m_bIsActive) |
81 | 0 | SfxStatusBarControl::Click(); // exec FID_AUTO_CALC and toggle AutoCalc on |
82 | 0 | } |
83 | | |
84 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |