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 .
21 #include <vcl/customweld.hxx>
22 #include <vcl/image.hxx>
23 #include <vcl/window.hxx>
24 #include <svl/poolitem.hxx>
25 #include <vcl/InterimItemWindow.hxx>
26 #include <sfx2/tbxctrl.hxx>
28 namespace com::sun::star::frame
{ class XDispatchProvider
; }
30 class SvxZoomSliderItem
;
32 class ScZoomSliderControl
: public SfxToolBoxControl
35 SFX_DECL_TOOLBOX_CONTROL();
36 ScZoomSliderControl( sal_uInt16 nSlotId
, ToolBoxItemId nId
, ToolBox
& rTbx
);
37 virtual ~ScZoomSliderControl() override
;
39 virtual void StateChangedAtToolBoxControl( sal_uInt16 nSID
, SfxItemState eState
, const SfxPoolItem
* pState
) override
;
40 virtual VclPtr
<InterimItemWindow
> CreateItemWindow( vcl::Window
*pParent
) override
;
43 class ScZoomSlider final
: public weld::CustomWidgetController
46 sal_uInt16 mnSliderLength
;
47 sal_uInt16 mnCurrentZoom
;
50 std::vector
< tools::Long
> maSnappingPointOffsets
;
51 std::vector
< sal_uInt16
> maSnappingPointZooms
;
53 Image maIncreaseButton
;
54 Image maDecreaseButton
;
56 css::uno::Reference
<css::frame::XDispatchProvider
> m_xDispatchProvider
;
58 sal_uInt16
Offset2Zoom(tools::Long nOffset
) const;
59 tools::Long
Zoom2Offset(sal_uInt16 nZoom
) const;
61 void DoPaint(vcl::RenderContext
& rRenderContext
);
63 ScZoomSlider(css::uno::Reference
<css::frame::XDispatchProvider
> xDispatchProvider
,
64 sal_uInt16 nCurrentZoom
);
66 void UpdateFromItem(const SvxZoomSliderItem
* pZoomSliderItem
);
68 void SetSliderLength(sal_uInt16 nLength
) { mnSliderLength
= nLength
; }
69 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
;
75 class ScZoomSliderWnd final
: public InterimItemWindow
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
;
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
);
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */