LibreOffice Module sc (master)  1
tbzoomsliderctrl.hxx
Go to the documentation of this file.
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/customweld.hxx>
22 #include <vcl/window.hxx>
23 #include <svl/poolitem.hxx>
25 #include <sfx2/tbxctrl.hxx>
26 
27 namespace com::sun::star::frame { class XDispatchProvider; }
28 
29 class SvxZoomSliderItem;
30 
32 {
33 public:
35  ScZoomSliderControl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx );
36  virtual ~ScZoomSliderControl() override;
37 
38  virtual void StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) override;
39  virtual VclPtr<InterimItemWindow> CreateItemWindow( vcl::Window *pParent ) override;
40 };
41 
43 {
44 private:
45  sal_uInt16 mnCurrentZoom;
46  sal_uInt16 mnMinZoom;
47  sal_uInt16 mnMaxZoom;
48  std::vector< tools::Long > maSnappingPointOffsets;
49  std::vector< sal_uInt16 > maSnappingPointZooms;
54  css::uno::Reference<css::frame::XDispatchProvider> m_xDispatchProvider;
55 
56  sal_uInt16 Offset2Zoom(tools::Long nOffset) const;
57  tools::Long Zoom2Offset(sal_uInt16 nZoom) const;
58 
59  void DoPaint(vcl::RenderContext& rRenderContext);
60 public:
61  ScZoomSlider(const css::uno::Reference<css::frame::XDispatchProvider>& rDispatchProvider,
62  sal_uInt16 nCurrentZoom);
63 
64  void UpdateFromItem(const SvxZoomSliderItem* pZoomSliderItem);
65 
66  virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
67  virtual bool MouseMove( const MouseEvent& rMEvt ) override;
68  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
69 };
70 
71 class ScZoomSliderWnd final : public InterimItemWindow
72 {
73 private:
74  std::unique_ptr<ScZoomSlider> mxWidget;
75  std::unique_ptr<weld::CustomWeld> mxWeld;
76 
77 public:
78  ScZoomSliderWnd(vcl::Window* pParent, const css::uno::Reference<css::frame::XDispatchProvider>& rDispatchProvider,
79  sal_uInt16 nCurrentZoom);
80  virtual ~ScZoomSliderWnd() override;
81  virtual void dispose() override;
82  void UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem );
83 };
84 
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::CustomWeld > mxWeld
void DoPaint(vcl::RenderContext &rRenderContext)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
virtual ~ScZoomSliderWnd() override
long Long
sal_Int16 nId
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchProvider
tools::Long Zoom2Offset(sal_uInt16 nZoom) const
std::vector< tools::Long > maSnappingPointOffsets
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
virtual bool MouseMove(const MouseEvent &rMEvt) override
std::vector< sal_uInt16 > maSnappingPointZooms
ScZoomSliderWnd(vcl::Window *pParent, const css::uno::Reference< css::frame::XDispatchProvider > &rDispatchProvider, sal_uInt16 nCurrentZoom)
ScZoomSliderControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
std::unique_ptr< ScZoomSlider > mxWidget
virtual void dispose() override
ScZoomSlider(const css::uno::Reference< css::frame::XDispatchProvider > &rDispatchProvider, sal_uInt16 nCurrentZoom)
virtual ~ScZoomSliderControl() override
sal_uInt16 Offset2Zoom(tools::Long nOffset) const
SfxItemState
void UpdateFromItem(const SvxZoomSliderItem *pZoomSliderItem)
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
sal_uInt16 mnMaxZoom
sal_uInt16 mnCurrentZoom
void UpdateFromItem(const SvxZoomSliderItem *pZoomSliderItem)
sal_uInt16 mnMinZoom