LibreOffice Module sdext (master) 1
PresenterScrollBar.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
20#ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERSCROLLBAR_HXX
21#define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERSCROLLBAR_HXX
22
24#include <com/sun/star/awt/XWindow.hpp>
25#include <com/sun/star/drawing/XPresenterHelper.hpp>
26#include <com/sun/star/rendering/XCanvas.hpp>
27#include <com/sun/star/uno/XComponentContext.hpp>
30
31#include <functional>
32#include <memory>
33
34namespace sdext::presenter {
35
36class PresenterCanvasHelper;
37class PresenterPaintManager;
38
39typedef ::cppu::WeakComponentImplHelper <
40 css::awt::XWindowListener,
41 css::awt::XPaintListener,
42 css::awt::XMouseListener,
43 css::awt::XMouseMotionListener
45
49 : private ::cppu::BaseMutex,
51{
52public:
53 virtual ~PresenterScrollBar() override;
56
57 virtual void SAL_CALL disposing() override;
58
59 css::uno::Reference<css::uno::XComponentContext> const&
61
62 void SetVisible (const bool bIsVisible);
63
66 void SetPosSize (const css::geometry::RealRectangle2D& rBox);
67
73 void SetThumbPosition (
74 double nPosition,
75 const bool bAsynchronousRepaint);
76
77 double GetThumbPosition() const { return mnThumbPosition;}
78
81 void SetTotalSize (const double nTotalSize);
82
87 void SetThumbSize (const double nThumbSize);
88 double GetThumbSize() const { return mnThumbSize;}
89
90 void SetLineHeight (const double nLineHeight);
91 double GetLineHeight() const { return mnLineHeight;}
92
95 void SetCanvas (const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
96
97 void SetBackground (const SharedBitmapDescriptor& rpBackgroundBitmap);
98
102 void CheckValues();
103
107 void Paint (
108 const css::awt::Rectangle& rUpdateBox);
109
110 virtual sal_Int32 GetSize() const = 0;
111
112 // XWindowListener
113
114 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent) override;
115
116 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent) override;
117
118 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent) override;
119
120 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent) override;
121
122 // XPaintListener
123
124 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent) override;
125
126 // XMouseListener
127
128 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent) override;
129
130 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent) override;
131
132 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent) override;
133
134 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent) override;
135
136 // XMouseMotionListener
137
138 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent) override;
139
140 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent) override;
141
142 // lang::XEventListener
143 virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent) override;
144
147
148protected:
149 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
150 css::uno::Reference<css::awt::XWindow> mxWindow;
151 css::uno::Reference<css::rendering::XCanvas> mxCanvas;
152 css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper;
153 std::shared_ptr<PresenterPaintManager> mpPaintManager;
158 css::geometry::RealPoint2D maDragAnchor;
159 ::std::function<void (double)> maThumbMotionListener;
162 css::geometry::RealRectangle2D maBox[AreaCount];
164 static std::weak_ptr<PresenterBitmapContainer> mpSharedBitmaps;
165 std::shared_ptr<PresenterBitmapContainer> mpBitmaps;
175
176 css::geometry::RealRectangle2D const & GetRectangle (const Area eArea) const;
177 virtual double GetDragDistance (const sal_Int32 nX, const sal_Int32 nY) const = 0;
178 virtual void UpdateDragAnchor (const double nDragDistance) = 0;
179 virtual double GetMinor (const double nX, const double nY) const = 0;
180 virtual void UpdateBorders() = 0;
181 virtual void UpdateBitmaps() = 0;
182 virtual void PaintComposite(
183 const css::awt::Rectangle& rRepaintBox,
184 const Area eArea,
185 const SharedBitmapDescriptor& rpStartBitmaps,
186 const SharedBitmapDescriptor& rpCenterBitmaps,
187 const SharedBitmapDescriptor& rpEndBitmaps) = 0;
188
190 const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
191 const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
192 std::shared_ptr<PresenterPaintManager> xPaintManager,
193 ::std::function<void (double)> aThumbMotionListener);
194
195 void Repaint (
196 const css::geometry::RealRectangle2D& rBox,
197 const bool bAsynchronous);
198 void PaintBackground (
199 const css::awt::Rectangle& rRepaintBox);
200 void PaintBitmap(
201 const css::awt::Rectangle& rRepaintBox,
202 const Area eArea,
203 const SharedBitmapDescriptor& rpBitmaps);
204 void UpdateWidthOrHeight (sal_Int32& rSize,
205 const SharedBitmapDescriptor& rpDescriptor);
206 css::uno::Reference<css::rendering::XBitmap> GetBitmap (
207 const Area eArea,
208 const SharedBitmapDescriptor& rpBitmaps) const;
210 const Area eArea) const;
211 bool IsDisabled (const Area eArea) const;
212 double ValidateThumbPosition (double nPosition);
213
214private:
215 class MousePressRepeater;
216 std::shared_ptr<MousePressRepeater> mpMousePressRepeater;
218 std::unique_ptr<PresenterCanvasHelper> mpCanvasHelper;
219
220 Area GetArea (const double nX, const double nY) const;
221};
222
226{
227public:
229 const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
230 const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
231 const std::shared_ptr<PresenterPaintManager>& rpPaintManager,
232 const ::std::function<void (double)>& rThumbMotionListener);
233 virtual ~PresenterVerticalScrollBar() override;
234 virtual sal_Int32 GetSize() const override;
235
236protected:
237 virtual double GetDragDistance (const sal_Int32 nX, const sal_Int32 nY) const override;
238 virtual void UpdateDragAnchor (const double nDragDistance) override;
239 virtual double GetMinor (const double nX, const double nY) const override;
240 virtual void UpdateBorders() override;
241 virtual void UpdateBitmaps() override;
242 virtual void PaintComposite(
243 const css::awt::Rectangle& rRepaintBox,
244 const Area eArea,
245 const SharedBitmapDescriptor& rpStartBitmaps,
246 const SharedBitmapDescriptor& rpCenterBitmaps,
247 const SharedBitmapDescriptor& rpEndBitmaps) override;
248
249private:
251};
252
253} // end of namespace ::sdext::presenter
254
255#endif
256
257/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class of horizontal and vertical scroll bars.
virtual void UpdateDragAnchor(const double nDragDistance)=0
std::shared_ptr< PresenterBitmapContainer > mpBitmaps
void SetPosSize(const css::geometry::RealRectangle2D &rBox)
Set the bounding box of the scroll bar.
Area GetArea(const double nX, const double nY) const
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
virtual double GetDragDistance(const sal_Int32 nX, const sal_Int32 nY) const =0
css::uno::Reference< css::awt::XWindow > mxWindow
void SetThumbSize(const double nThumbSize)
Set the size of the movable thumb.
virtual double GetMinor(const double nX, const double nY) const =0
PresenterScrollBar & operator=(const PresenterScrollBar &)=delete
css::geometry::RealRectangle2D const & GetRectangle(const Area eArea) const
void Paint(const css::awt::Rectangle &rUpdateBox)
On some occasions it is necessary to trigger the painting of a scrollbar from the outside.
virtual sal_Int32 GetSize() const =0
std::shared_ptr< MousePressRepeater > mpMousePressRepeater
virtual void SAL_CALL mouseEntered(const css::awt::MouseEvent &rEvent) override
css::uno::Reference< css::rendering::XCanvas > mxCanvas
virtual void SAL_CALL mousePressed(const css::awt::MouseEvent &rEvent) override
virtual void SAL_CALL windowShown(const css::lang::EventObject &rEvent) override
void SetThumbPosition(double nPosition, const bool bAsynchronousRepaint)
Set the position of the movable thumb.
virtual void SAL_CALL windowPaint(const css::awt::PaintEvent &rEvent) override
css::geometry::RealRectangle2D maBox[AreaCount]
static std::weak_ptr< PresenterBitmapContainer > mpSharedBitmaps
std::shared_ptr< PresenterPaintManager > mpPaintManager
void Repaint(const css::geometry::RealRectangle2D &rBox, const bool bAsynchronous)
virtual void SAL_CALL mouseMoved(const css::awt::MouseEvent &rEvent) override
virtual void SAL_CALL mouseExited(const css::awt::MouseEvent &rEvent) override
void UpdateWidthOrHeight(sal_Int32 &rSize, const SharedBitmapDescriptor &rpDescriptor)
std::unique_ptr< PresenterCanvasHelper > mpCanvasHelper
PresenterBitmapContainer::BitmapDescriptor::Mode GetBitmapMode(const Area eArea) const
PresenterScrollBar(const PresenterScrollBar &)=delete
virtual void SAL_CALL windowResized(const css::awt::WindowEvent &rEvent) override
css::uno::Reference< css::uno::XComponentContext > const & GetComponentContext() const
virtual void SAL_CALL windowHidden(const css::lang::EventObject &rEvent) override
css::uno::Reference< css::drawing::XPresenterHelper > mxPresenterHelper
virtual void SAL_CALL windowMoved(const css::awt::WindowEvent &rEvent) override
void SetVisible(const bool bIsVisible)
void PaintBitmap(const css::awt::Rectangle &rRepaintBox, const Area eArea, const SharedBitmapDescriptor &rpBitmaps)
bool IsDisabled(const Area eArea) const
virtual void SAL_CALL mouseReleased(const css::awt::MouseEvent &rEvent) override
PresenterScrollBar(const css::uno::Reference< css::uno::XComponentContext > &rxComponentContext, const css::uno::Reference< css::awt::XWindow > &rxParentWindow, std::shared_ptr< PresenterPaintManager > xPaintManager, ::std::function< void(double)> aThumbMotionListener)
virtual void SAL_CALL mouseDragged(const css::awt::MouseEvent &rEvent) override
SharedBitmapDescriptor mpPagerCenterDescriptor
void SetBackground(const SharedBitmapDescriptor &rpBackgroundBitmap)
double ValidateThumbPosition(double nPosition)
void SetTotalSize(const double nTotalSize)
Set the upper border of the slider range.
::std::function< void(double)> maThumbMotionListener
void SetLineHeight(const double nLineHeight)
css::uno::Reference< css::rendering::XBitmap > GetBitmap(const Area eArea, const SharedBitmapDescriptor &rpBitmaps) const
void CheckValues()
Call this after changing total size or thumb position or size to move the thumb to a valid position.
void SetCanvas(const css::uno::Reference< css::rendering::XCanvas > &rxCanvas)
Set the canvas that is used for painting the scroll bar.
void PaintBackground(const css::awt::Rectangle &rRepaintBox)
virtual void PaintComposite(const css::awt::Rectangle &rRepaintBox, const Area eArea, const SharedBitmapDescriptor &rpStartBitmaps, const SharedBitmapDescriptor &rpCenterBitmaps, const SharedBitmapDescriptor &rpEndBitmaps)=0
SharedBitmapDescriptor mpThumbCenterDescriptor
css::geometry::RealPoint2D maDragAnchor
virtual void SAL_CALL disposing() override
PresenterVerticalScrollBar(const css::uno::Reference< css::uno::XComponentContext > &rxComponentContext, const css::uno::Reference< css::awt::XWindow > &rxParentWindow, const std::shared_ptr< PresenterPaintManager > &rpPaintManager, const ::std::function< void(double)> &rThumbMotionListener)
virtual sal_Int32 GetSize() const override
virtual void PaintComposite(const css::awt::Rectangle &rRepaintBox, const Area eArea, const SharedBitmapDescriptor &rpStartBitmaps, const SharedBitmapDescriptor &rpCenterBitmaps, const SharedBitmapDescriptor &rpEndBitmaps) override
virtual double GetDragDistance(const sal_Int32 nX, const sal_Int32 nY) const override
virtual double GetMinor(const double nX, const double nY) const override
virtual void UpdateDragAnchor(const double nDragDistance) override
::cppu::WeakComponentImplHelper< css::awt::XWindowListener, css::awt::XPaintListener, css::awt::XMouseListener, css::awt::XMouseMotionListener > PresenterScrollBarInterfaceBase
std::shared_ptr< PresenterBitmapContainer::BitmapDescriptor > SharedBitmapDescriptor