/src/libreoffice/sc/source/ui/inc/tbzoomsliderctrl.hxx
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 | | #pragma once |
20 | | |
21 | | #include <vcl/image.hxx> |
22 | | #include <vcl/weld/customweld.hxx> |
23 | | #include <vcl/window.hxx> |
24 | | #include <svl/poolitem.hxx> |
25 | | #include <vcl/InterimItemWindow.hxx> |
26 | | #include <sfx2/tbxctrl.hxx> |
27 | | |
28 | | namespace com::sun::star::frame { class XDispatchProvider; } |
29 | | |
30 | | class SvxZoomSliderItem; |
31 | | |
32 | | class ScZoomSliderControl : public SfxToolBoxControl |
33 | | { |
34 | | public: |
35 | | SFX_DECL_TOOLBOX_CONTROL(); |
36 | | ScZoomSliderControl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ); |
37 | | virtual ~ScZoomSliderControl() override; |
38 | | |
39 | | virtual void StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) override; |
40 | | virtual VclPtr<InterimItemWindow> CreateItemWindow( vcl::Window *pParent ) override; |
41 | | }; |
42 | | |
43 | | class ScZoomSlider final : public weld::CustomWidgetController |
44 | | { |
45 | | private: |
46 | | sal_uInt16 mnSliderLength; |
47 | | sal_uInt16 mnCurrentZoom; |
48 | | sal_uInt16 mnMinZoom; |
49 | | sal_uInt16 mnMaxZoom; |
50 | | std::vector< tools::Long > maSnappingPointOffsets; |
51 | | std::vector< sal_uInt16 > maSnappingPointZooms; |
52 | | Image maSliderButton; |
53 | | Image maIncreaseButton; |
54 | | Image maDecreaseButton; |
55 | | bool mbOmitPaint; |
56 | | css::uno::Reference<css::frame::XDispatchProvider> m_xDispatchProvider; |
57 | | |
58 | | sal_uInt16 Offset2Zoom(tools::Long nOffset) const; |
59 | | tools::Long Zoom2Offset(sal_uInt16 nZoom) const; |
60 | | |
61 | | void DoPaint(vcl::RenderContext& rRenderContext); |
62 | | public: |
63 | | ScZoomSlider(css::uno::Reference<css::frame::XDispatchProvider> xDispatchProvider, |
64 | | sal_uInt16 nCurrentZoom); |
65 | | |
66 | | void UpdateFromItem(const SvxZoomSliderItem* pZoomSliderItem); |
67 | | |
68 | 0 | void SetSliderLength(sal_uInt16 nLength) { mnSliderLength = nLength; } |
69 | 0 | sal_uInt16 GetSliderLength() const { return mnSliderLength; } |
70 | | virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; |
71 | | virtual bool MouseMove( const MouseEvent& rMEvt ) override; |
72 | | virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; |
73 | | }; |
74 | | |
75 | | class ScZoomSliderWnd final : public InterimItemWindow |
76 | | { |
77 | | private: |
78 | | std::unique_ptr<ScZoomSlider> mxWidget; |
79 | | std::unique_ptr<weld::Label> mxPercentage; |
80 | | std::unique_ptr<weld::Label> mxLabel; |
81 | | std::unique_ptr<weld::CustomWeld> mxWeld; |
82 | | |
83 | | public: |
84 | | ScZoomSliderWnd(vcl::Window* pParent, const css::uno::Reference<css::frame::XDispatchProvider>& rDispatchProvider, |
85 | | sal_uInt16 nCurrentZoom); |
86 | | virtual ~ScZoomSliderWnd() override; |
87 | | virtual void dispose() override; |
88 | | void UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem ); |
89 | | }; |
90 | | |
91 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |