1c142477cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3c142477cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4c142477cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5c142477cSAndrew Rist * distributed with this work for additional information
6c142477cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7c142477cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8c142477cSAndrew Rist * "License"); you may not use this file except in compliance
9c142477cSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11c142477cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13c142477cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14c142477cSAndrew Rist * software distributed under the License is distributed on an
15c142477cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c142477cSAndrew Rist * KIND, either express or implied. See the License for the
17c142477cSAndrew Rist * specific language governing permissions and limitations
18c142477cSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20c142477cSAndrew Rist *************************************************************/
21c142477cSAndrew Rist
22c142477cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sdext.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "PresenterScrollBar.hxx"
28cdf0e10cSrcweir #include "PresenterBitmapContainer.hxx"
29cdf0e10cSrcweir #include "PresenterCanvasHelper.hxx"
30cdf0e10cSrcweir #include "PresenterGeometryHelper.hxx"
31cdf0e10cSrcweir #include "PresenterPaintManager.hxx"
32cdf0e10cSrcweir #include "PresenterTimer.hxx"
33cdf0e10cSrcweir #include "PresenterUIPainter.hxx"
34cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
35cdf0e10cSrcweir #include <com/sun/star/awt/WindowAttribute.hpp>
36cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp>
37cdf0e10cSrcweir #include <com/sun/star/awt/XToolkit.hpp>
38cdf0e10cSrcweir #include <com/sun/star/rendering/CompositeOperation.hpp>
39cdf0e10cSrcweir #include <com/sun/star/rendering/TexturingMode.hpp>
40cdf0e10cSrcweir #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
41cdf0e10cSrcweir #include <boost/bind.hpp>
42cdf0e10cSrcweir #include <boost/enable_shared_from_this.hpp>
43cdf0e10cSrcweir #include <boost/weak_ptr.hpp>
44cdf0e10cSrcweir #include <math.h>
45cdf0e10cSrcweir
46cdf0e10cSrcweir using namespace ::com::sun::star;
47cdf0e10cSrcweir using namespace ::com::sun::star::uno;
48cdf0e10cSrcweir using ::rtl::OUString;
49cdf0e10cSrcweir
50cdf0e10cSrcweir #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
51cdf0e10cSrcweir
52cdf0e10cSrcweir const static double gnScrollBarGap (10);
53cdf0e10cSrcweir
54cdf0e10cSrcweir namespace sdext { namespace presenter {
55cdf0e10cSrcweir
56cdf0e10cSrcweir //===== PresenterScrollBar::MousePressRepeater ================================
57cdf0e10cSrcweir
58cdf0e10cSrcweir class PresenterScrollBar::MousePressRepeater
59cdf0e10cSrcweir : public ::boost::enable_shared_from_this<MousePressRepeater>
60cdf0e10cSrcweir {
61cdf0e10cSrcweir public:
62cdf0e10cSrcweir MousePressRepeater (const ::rtl::Reference<PresenterScrollBar>& rpScrollBar);
63cdf0e10cSrcweir void Dispose (void);
64cdf0e10cSrcweir void Start (const PresenterScrollBar::Area& reArea);
65cdf0e10cSrcweir void Stop (void);
66cdf0e10cSrcweir void SetMouseArea (const PresenterScrollBar::Area& reArea);
67cdf0e10cSrcweir
68cdf0e10cSrcweir private:
69cdf0e10cSrcweir void Callback (const TimeValue& rCurrentTime);
70cdf0e10cSrcweir void Execute (void);
71cdf0e10cSrcweir
72cdf0e10cSrcweir sal_Int32 mnMousePressRepeaterTaskId;
73cdf0e10cSrcweir ::rtl::Reference<PresenterScrollBar> mpScrollBar;
74cdf0e10cSrcweir PresenterScrollBar::Area meMouseArea;
75cdf0e10cSrcweir };
76cdf0e10cSrcweir
77cdf0e10cSrcweir
78cdf0e10cSrcweir
79cdf0e10cSrcweir
80cdf0e10cSrcweir //===== PresenterScrollBar ====================================================
81cdf0e10cSrcweir
82cdf0e10cSrcweir boost::weak_ptr<PresenterBitmapContainer> PresenterScrollBar::mpSharedBitmaps;
83cdf0e10cSrcweir
PresenterScrollBar(const Reference<XComponentContext> & rxComponentContext,const Reference<awt::XWindow> & rxParentWindow,const::boost::shared_ptr<PresenterPaintManager> & rpPaintManager,const::boost::function<void (double)> & rThumbMotionListener)84cdf0e10cSrcweir PresenterScrollBar::PresenterScrollBar (
85cdf0e10cSrcweir const Reference<XComponentContext>& rxComponentContext,
86cdf0e10cSrcweir const Reference<awt::XWindow>& rxParentWindow,
87cdf0e10cSrcweir const ::boost::shared_ptr<PresenterPaintManager>& rpPaintManager,
88cdf0e10cSrcweir const ::boost::function<void(double)>& rThumbMotionListener)
89cdf0e10cSrcweir : PresenterScrollBarInterfaceBase(m_aMutex),
90cdf0e10cSrcweir mxComponentContext(rxComponentContext),
91cdf0e10cSrcweir mxParentWindow(rxParentWindow),
92cdf0e10cSrcweir mxWindow(),
93cdf0e10cSrcweir mxCanvas(),
94cdf0e10cSrcweir mxPresenterHelper(),
95cdf0e10cSrcweir mpPaintManager(rpPaintManager),
96cdf0e10cSrcweir mnThumbPosition(0),
97cdf0e10cSrcweir mnTotalSize(0),
98cdf0e10cSrcweir mnThumbSize(0),
99cdf0e10cSrcweir mnLineHeight(10),
100cdf0e10cSrcweir maDragAnchor(-1,-1),
101cdf0e10cSrcweir maThumbMotionListener(rThumbMotionListener),
102cdf0e10cSrcweir meButtonDownArea(None),
103cdf0e10cSrcweir meMouseMoveArea(None),
104cdf0e10cSrcweir mbIsNotificationActive(false),
105cdf0e10cSrcweir mpBitmaps(),
106cdf0e10cSrcweir mpPrevButtonDescriptor(),
107cdf0e10cSrcweir mpNextButtonDescriptor(),
108cdf0e10cSrcweir mpPagerStartDescriptor(),
109cdf0e10cSrcweir mpPagerCenterDescriptor(),
110cdf0e10cSrcweir mpPagerEndDescriptor(),
111cdf0e10cSrcweir mpThumbStartDescriptor(),
112cdf0e10cSrcweir mpThumbCenterDescriptor(),
113cdf0e10cSrcweir mpThumbEndDescriptor(),
114cdf0e10cSrcweir mpMousePressRepeater(new MousePressRepeater(this)),
115cdf0e10cSrcweir mpBackgroundBitmap(),
116cdf0e10cSrcweir mpCanvasHelper(new PresenterCanvasHelper())
117cdf0e10cSrcweir {
118cdf0e10cSrcweir try
119cdf0e10cSrcweir {
120cdf0e10cSrcweir Reference<lang::XMultiComponentFactory> xFactory (rxComponentContext->getServiceManager());
121cdf0e10cSrcweir if ( ! xFactory.is())
122cdf0e10cSrcweir throw RuntimeException();
123cdf0e10cSrcweir
124cdf0e10cSrcweir mxPresenterHelper = Reference<drawing::XPresenterHelper>(
125cdf0e10cSrcweir xFactory->createInstanceWithContext(
126cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.comp.Draw.PresenterHelper"),
127cdf0e10cSrcweir rxComponentContext),
128cdf0e10cSrcweir UNO_QUERY_THROW);
129cdf0e10cSrcweir
130cdf0e10cSrcweir if (mxPresenterHelper.is())
131cdf0e10cSrcweir mxWindow = mxPresenterHelper->createWindow(rxParentWindow,
132cdf0e10cSrcweir sal_False,
133cdf0e10cSrcweir sal_False,
134cdf0e10cSrcweir sal_False,
135cdf0e10cSrcweir sal_False);
136cdf0e10cSrcweir
137cdf0e10cSrcweir // Make the background transparent. The slide show paints its own background.
138cdf0e10cSrcweir Reference<awt::XWindowPeer> xPeer (mxWindow, UNO_QUERY_THROW);
139cdf0e10cSrcweir if (xPeer.is())
140cdf0e10cSrcweir {
141cdf0e10cSrcweir xPeer->setBackground(0xff000000);
142cdf0e10cSrcweir }
143cdf0e10cSrcweir
144cdf0e10cSrcweir mxWindow->setVisible(sal_True);
145cdf0e10cSrcweir mxWindow->addWindowListener(this);
146cdf0e10cSrcweir mxWindow->addPaintListener(this);
147cdf0e10cSrcweir mxWindow->addMouseListener(this);
148cdf0e10cSrcweir mxWindow->addMouseMotionListener(this);
149cdf0e10cSrcweir }
150cdf0e10cSrcweir catch (RuntimeException&)
151cdf0e10cSrcweir {
152cdf0e10cSrcweir }
153cdf0e10cSrcweir }
154cdf0e10cSrcweir
155cdf0e10cSrcweir
156cdf0e10cSrcweir
157cdf0e10cSrcweir
~PresenterScrollBar(void)158cdf0e10cSrcweir PresenterScrollBar::~PresenterScrollBar (void)
159cdf0e10cSrcweir {
160cdf0e10cSrcweir }
161cdf0e10cSrcweir
162cdf0e10cSrcweir
163cdf0e10cSrcweir
164cdf0e10cSrcweir
disposing(void)165cdf0e10cSrcweir void SAL_CALL PresenterScrollBar::disposing (void)
166cdf0e10cSrcweir {
167cdf0e10cSrcweir mpMousePressRepeater->Dispose();
168cdf0e10cSrcweir
169cdf0e10cSrcweir if (mxWindow.is())
170cdf0e10cSrcweir {
171cdf0e10cSrcweir mxWindow->removeWindowListener(this);
172cdf0e10cSrcweir mxWindow->removePaintListener(this);
173cdf0e10cSrcweir mxWindow->removeMouseListener(this);
174cdf0e10cSrcweir mxWindow->removeMouseMotionListener(this);
175cdf0e10cSrcweir
176cdf0e10cSrcweir Reference<lang::XComponent> xComponent (mxWindow, UNO_QUERY);
177cdf0e10cSrcweir mxWindow = NULL;
178cdf0e10cSrcweir if (xComponent.is())
179cdf0e10cSrcweir xComponent->dispose();
180cdf0e10cSrcweir }
181cdf0e10cSrcweir
182cdf0e10cSrcweir mpBitmaps.reset();
183cdf0e10cSrcweir }
184cdf0e10cSrcweir
185cdf0e10cSrcweir
186cdf0e10cSrcweir
187cdf0e10cSrcweir
SetVisible(const bool bIsVisible)188cdf0e10cSrcweir void PresenterScrollBar::SetVisible (const bool bIsVisible)
189cdf0e10cSrcweir {
190cdf0e10cSrcweir if (mxWindow.is())
191cdf0e10cSrcweir mxWindow->setVisible(bIsVisible);
192cdf0e10cSrcweir }
193cdf0e10cSrcweir
194cdf0e10cSrcweir
195cdf0e10cSrcweir
196cdf0e10cSrcweir
SetPosSize(const css::geometry::RealRectangle2D & rBox)197cdf0e10cSrcweir void PresenterScrollBar::SetPosSize (const css::geometry::RealRectangle2D& rBox)
198cdf0e10cSrcweir {
199cdf0e10cSrcweir if (mxWindow.is())
200cdf0e10cSrcweir {
201cdf0e10cSrcweir mxWindow->setPosSize(
202cdf0e10cSrcweir sal_Int32(floor(rBox.X1)),
203cdf0e10cSrcweir sal_Int32(ceil(rBox.Y1)),
204cdf0e10cSrcweir sal_Int32(ceil(rBox.X2-rBox.X1)),
205cdf0e10cSrcweir sal_Int32(floor(rBox.Y2-rBox.Y1)),
206cdf0e10cSrcweir awt::PosSize::POSSIZE);
207cdf0e10cSrcweir UpdateBorders();
208cdf0e10cSrcweir }
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir
212cdf0e10cSrcweir
213cdf0e10cSrcweir
SetThumbPosition(double nPosition,const bool bAsynchronousUpdate)214cdf0e10cSrcweir void PresenterScrollBar::SetThumbPosition (
215cdf0e10cSrcweir double nPosition,
216cdf0e10cSrcweir const bool bAsynchronousUpdate)
217cdf0e10cSrcweir {
218cdf0e10cSrcweir SetThumbPosition(nPosition, bAsynchronousUpdate, true, true);
219cdf0e10cSrcweir }
220cdf0e10cSrcweir
221cdf0e10cSrcweir
222cdf0e10cSrcweir
223cdf0e10cSrcweir
SetThumbPosition(double nPosition,const bool bAsynchronousUpdate,const bool bValidate,const bool bNotify)224cdf0e10cSrcweir void PresenterScrollBar::SetThumbPosition (
225cdf0e10cSrcweir double nPosition,
226cdf0e10cSrcweir const bool bAsynchronousUpdate,
227cdf0e10cSrcweir const bool bValidate,
228cdf0e10cSrcweir const bool bNotify)
229cdf0e10cSrcweir {
230cdf0e10cSrcweir if (bValidate)
231cdf0e10cSrcweir nPosition = ValidateThumbPosition(nPosition);
232cdf0e10cSrcweir
233cdf0e10cSrcweir if (nPosition != mnThumbPosition && ! mbIsNotificationActive)
234cdf0e10cSrcweir {
235cdf0e10cSrcweir mnThumbPosition = nPosition;
236cdf0e10cSrcweir
237cdf0e10cSrcweir UpdateBorders();
238cdf0e10cSrcweir Repaint(GetRectangle(Total), bAsynchronousUpdate);
239cdf0e10cSrcweir if (bNotify)
240cdf0e10cSrcweir NotifyThumbPositionChange();
241cdf0e10cSrcweir }
242cdf0e10cSrcweir }
243cdf0e10cSrcweir
244cdf0e10cSrcweir
245cdf0e10cSrcweir
246cdf0e10cSrcweir
GetThumbPosition(void) const247cdf0e10cSrcweir double PresenterScrollBar::GetThumbPosition (void) const
248cdf0e10cSrcweir {
249cdf0e10cSrcweir return mnThumbPosition;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir
252cdf0e10cSrcweir
253cdf0e10cSrcweir
254cdf0e10cSrcweir
SetTotalSize(const double nTotalSize)255cdf0e10cSrcweir void PresenterScrollBar::SetTotalSize (const double nTotalSize)
256cdf0e10cSrcweir {
257cdf0e10cSrcweir if (mnTotalSize != nTotalSize)
258cdf0e10cSrcweir {
259cdf0e10cSrcweir mnTotalSize = nTotalSize + 1;
260cdf0e10cSrcweir UpdateBorders();
261cdf0e10cSrcweir Repaint(GetRectangle(Total), false);
262cdf0e10cSrcweir }
263cdf0e10cSrcweir }
264cdf0e10cSrcweir
265cdf0e10cSrcweir
266cdf0e10cSrcweir
267cdf0e10cSrcweir
GetTotalSize(void) const268cdf0e10cSrcweir double PresenterScrollBar::GetTotalSize (void) const
269cdf0e10cSrcweir {
270cdf0e10cSrcweir return mnTotalSize;
271cdf0e10cSrcweir }
272cdf0e10cSrcweir
273cdf0e10cSrcweir
274cdf0e10cSrcweir
275cdf0e10cSrcweir
SetThumbSize(const double nThumbSize)276cdf0e10cSrcweir void PresenterScrollBar::SetThumbSize (const double nThumbSize)
277cdf0e10cSrcweir {
278cdf0e10cSrcweir OSL_ASSERT(nThumbSize>=0);
279cdf0e10cSrcweir if (mnThumbSize != nThumbSize)
280cdf0e10cSrcweir {
281cdf0e10cSrcweir mnThumbSize = nThumbSize;
282cdf0e10cSrcweir UpdateBorders();
283cdf0e10cSrcweir Repaint(GetRectangle(Total), false);
284cdf0e10cSrcweir }
285cdf0e10cSrcweir }
286cdf0e10cSrcweir
287cdf0e10cSrcweir
288cdf0e10cSrcweir
289cdf0e10cSrcweir
GetThumbSize(void) const290cdf0e10cSrcweir double PresenterScrollBar::GetThumbSize (void) const
291cdf0e10cSrcweir {
292cdf0e10cSrcweir return mnThumbSize;
293cdf0e10cSrcweir }
294cdf0e10cSrcweir
295cdf0e10cSrcweir
296cdf0e10cSrcweir
297cdf0e10cSrcweir
SetLineHeight(const double nLineHeight)298cdf0e10cSrcweir void PresenterScrollBar::SetLineHeight (const double nLineHeight)
299cdf0e10cSrcweir {
300cdf0e10cSrcweir mnLineHeight = nLineHeight;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir
303cdf0e10cSrcweir
304cdf0e10cSrcweir
305cdf0e10cSrcweir
GetLineHeight(void) const306cdf0e10cSrcweir double PresenterScrollBar::GetLineHeight (void) const
307cdf0e10cSrcweir {
308cdf0e10cSrcweir return mnLineHeight;
309cdf0e10cSrcweir }
310cdf0e10cSrcweir
311cdf0e10cSrcweir
312cdf0e10cSrcweir
313cdf0e10cSrcweir
SetCanvas(const Reference<css::rendering::XCanvas> & rxCanvas)314cdf0e10cSrcweir void PresenterScrollBar::SetCanvas (const Reference<css::rendering::XCanvas>& rxCanvas)
315cdf0e10cSrcweir {
316cdf0e10cSrcweir if (mxCanvas != rxCanvas)
317cdf0e10cSrcweir {
318cdf0e10cSrcweir mxCanvas = rxCanvas;
319cdf0e10cSrcweir if (mxCanvas.is())
320cdf0e10cSrcweir {
321cdf0e10cSrcweir if (mpBitmaps.get()==NULL)
322cdf0e10cSrcweir {
323cdf0e10cSrcweir if (mpSharedBitmaps.expired())
324cdf0e10cSrcweir {
325cdf0e10cSrcweir try
326cdf0e10cSrcweir {
327cdf0e10cSrcweir mpBitmaps.reset(new PresenterBitmapContainer(
328cdf0e10cSrcweir OUString::createFromAscii("PresenterScreenSettings/ScrollBar/Bitmaps"),
329cdf0e10cSrcweir ::boost::shared_ptr<PresenterBitmapContainer>(),
330cdf0e10cSrcweir mxComponentContext,
331*79e0a548SAriel Constenla-Haile mxCanvas));
332cdf0e10cSrcweir mpSharedBitmaps = mpBitmaps;
333cdf0e10cSrcweir }
334cdf0e10cSrcweir catch(Exception&)
335cdf0e10cSrcweir {
336cdf0e10cSrcweir OSL_ASSERT(false);
337cdf0e10cSrcweir }
338cdf0e10cSrcweir }
339cdf0e10cSrcweir else
340cdf0e10cSrcweir mpBitmaps = ::boost::shared_ptr<PresenterBitmapContainer>(mpSharedBitmaps);
341cdf0e10cSrcweir UpdateBitmaps();
342cdf0e10cSrcweir UpdateBorders();
343cdf0e10cSrcweir }
344cdf0e10cSrcweir
345cdf0e10cSrcweir Repaint(GetRectangle(Total), false);
346cdf0e10cSrcweir }
347cdf0e10cSrcweir }
348cdf0e10cSrcweir }
349cdf0e10cSrcweir
350cdf0e10cSrcweir
351cdf0e10cSrcweir
352cdf0e10cSrcweir
SetBackground(const SharedBitmapDescriptor & rpBackgroundBitmap)353cdf0e10cSrcweir void PresenterScrollBar::SetBackground (const SharedBitmapDescriptor& rpBackgroundBitmap)
354cdf0e10cSrcweir {
355cdf0e10cSrcweir mpBackgroundBitmap = rpBackgroundBitmap;
356cdf0e10cSrcweir }
357cdf0e10cSrcweir
358cdf0e10cSrcweir
359cdf0e10cSrcweir
CheckValues(void)360cdf0e10cSrcweir void PresenterScrollBar::CheckValues (void)
361cdf0e10cSrcweir {
362cdf0e10cSrcweir mnThumbPosition = ValidateThumbPosition(mnThumbPosition);
363cdf0e10cSrcweir }
364cdf0e10cSrcweir
365cdf0e10cSrcweir
366cdf0e10cSrcweir
367cdf0e10cSrcweir
ValidateThumbPosition(double nPosition)368cdf0e10cSrcweir double PresenterScrollBar::ValidateThumbPosition (double nPosition)
369cdf0e10cSrcweir {
370cdf0e10cSrcweir if (nPosition + mnThumbSize > mnTotalSize)
371cdf0e10cSrcweir nPosition = mnTotalSize - mnThumbSize;
372cdf0e10cSrcweir if (nPosition < 0)
373cdf0e10cSrcweir nPosition = 0;
374cdf0e10cSrcweir return nPosition;
375cdf0e10cSrcweir }
376cdf0e10cSrcweir
377cdf0e10cSrcweir
378cdf0e10cSrcweir
379cdf0e10cSrcweir
Paint(const awt::Rectangle & rUpdateBox,const bool bNoClip)380cdf0e10cSrcweir void PresenterScrollBar::Paint (
381cdf0e10cSrcweir const awt::Rectangle& rUpdateBox,
382cdf0e10cSrcweir const bool bNoClip)
383cdf0e10cSrcweir {
384cdf0e10cSrcweir if ( ! mxCanvas.is() || ! mxWindow.is())
385cdf0e10cSrcweir {
386cdf0e10cSrcweir OSL_ASSERT(mxCanvas.is());
387cdf0e10cSrcweir OSL_ASSERT(mxWindow.is());
388cdf0e10cSrcweir return;
389cdf0e10cSrcweir }
390cdf0e10cSrcweir
391cdf0e10cSrcweir if ( ! bNoClip)
392cdf0e10cSrcweir {
393cdf0e10cSrcweir if (PresenterGeometryHelper::AreRectanglesDisjoint (rUpdateBox, mxWindow->getPosSize()))
394cdf0e10cSrcweir return;
395cdf0e10cSrcweir }
396cdf0e10cSrcweir
397cdf0e10cSrcweir PaintBackground(rUpdateBox);
398cdf0e10cSrcweir PaintComposite(rUpdateBox, PagerUp,
399cdf0e10cSrcweir mpPagerStartDescriptor, mpPagerCenterDescriptor, SharedBitmapDescriptor());
400cdf0e10cSrcweir PaintComposite(rUpdateBox, PagerDown,
401cdf0e10cSrcweir SharedBitmapDescriptor(), mpPagerCenterDescriptor, mpPagerEndDescriptor);
402cdf0e10cSrcweir PaintComposite(rUpdateBox, Thumb,
403cdf0e10cSrcweir mpThumbStartDescriptor, mpThumbCenterDescriptor, mpThumbEndDescriptor);
404cdf0e10cSrcweir PaintBitmap(rUpdateBox, PrevButton, mpPrevButtonDescriptor);
405cdf0e10cSrcweir PaintBitmap(rUpdateBox, NextButton, mpNextButtonDescriptor);
406cdf0e10cSrcweir
407cdf0e10cSrcweir Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
408cdf0e10cSrcweir if (xSpriteCanvas.is())
409cdf0e10cSrcweir xSpriteCanvas->updateScreen(sal_False);
410cdf0e10cSrcweir }
411cdf0e10cSrcweir
412cdf0e10cSrcweir
413cdf0e10cSrcweir
414cdf0e10cSrcweir
415cdf0e10cSrcweir
416cdf0e10cSrcweir
417cdf0e10cSrcweir //----- XWindowListener -------------------------------------------------------
418cdf0e10cSrcweir
windowResized(const css::awt::WindowEvent & rEvent)419cdf0e10cSrcweir void SAL_CALL PresenterScrollBar::windowResized (const css::awt::WindowEvent& rEvent)
420cdf0e10cSrcweir throw (css::uno::RuntimeException)
421cdf0e10cSrcweir {
422cdf0e10cSrcweir (void)rEvent;
423cdf0e10cSrcweir }
424cdf0e10cSrcweir
425cdf0e10cSrcweir
426cdf0e10cSrcweir
427cdf0e10cSrcweir
428cdf0e10cSrcweir
windowMoved(const css::awt::WindowEvent & rEvent)429cdf0e10cSrcweir void SAL_CALL PresenterScrollBar::windowMoved (const css::awt::WindowEvent& rEvent)
430cdf0e10cSrcweir throw (css::uno::RuntimeException)
431cdf0e10cSrcweir {
432cdf0e10cSrcweir (void)rEvent;
433cdf0e10cSrcweir }
434cdf0e10cSrcweir
435cdf0e10cSrcweir
436cdf0e10cSrcweir
437cdf0e10cSrcweir
windowShown(const css::lang::EventObject & rEvent)438cdf0e10cSrcweir void SAL_CALL PresenterScrollBar::windowShown (const css::lang::EventObject& rEvent)
439cdf0e10cSrcweir throw (css::uno::RuntimeException)
440cdf0e10cSrcweir {
441cdf0e10cSrcweir (void)rEvent;
442cdf0e10cSrcweir }
443cdf0e10cSrcweir
444cdf0e10cSrcweir
445cdf0e10cSrcweir
446cdf0e10cSrcweir
windowHidden(const css::lang::EventObject & rEvent)447cdf0e10cSrcweir void SAL_CALL PresenterScrollBar::windowHidden (const css::lang::EventObject& rEvent)
448cdf0e10cSrcweir throw (css::uno::RuntimeException)
449cdf0e10cSrcweir {
450cdf0e10cSrcweir (void)rEvent;
451cdf0e10cSrcweir }
452cdf0e10cSrcweir
453cdf0e10cSrcweir
454cdf0e10cSrcweir
455cdf0e10cSrcweir
456cdf0e10cSrcweir //----- XPaintListener --------------------------------------------------------
457cdf0e10cSrcweir
windowPaint(const css::awt::PaintEvent & rEvent)458cdf0e10cSrcweir void SAL_CALL PresenterScrollBar::windowPaint (const css::awt::PaintEvent& rEvent)
459cdf0e10cSrcweir throw (css::uno::RuntimeException)
460cdf0e10cSrcweir {
461cdf0e10cSrcweir if (mxWindow.is())
462cdf0e10cSrcweir {
463cdf0e10cSrcweir awt::Rectangle aRepaintBox (rEvent.UpdateRect);
464cdf0e10cSrcweir const awt::Rectangle aWindowBox (mxWindow->getPosSize());
465cdf0e10cSrcweir aRepaintBox.X += aWindowBox.X;
466cdf0e10cSrcweir aRepaintBox.Y += aWindowBox.Y;
467cdf0e10cSrcweir Paint(aRepaintBox);
468cdf0e10cSrcweir
469cdf0e10cSrcweir Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
470cdf0e10cSrcweir if (xSpriteCanvas.is())
471cdf0e10cSrcweir xSpriteCanvas->updateScreen(sal_False);
472cdf0e10cSrcweir }
473cdf0e10cSrcweir }
474cdf0e10cSrcweir
475cdf0e10cSrcweir
476cdf0e10cSrcweir
477cdf0e10cSrcweir
478cdf0e10cSrcweir //----- XMouseListener --------------------------------------------------------
479cdf0e10cSrcweir
mousePressed(const css::awt::MouseEvent & rEvent)480cdf0e10cSrcweir void SAL_CALL PresenterScrollBar::mousePressed (const css::awt::MouseEvent& rEvent)
481cdf0e10cSrcweir throw(css::uno::RuntimeException)
482cdf0e10cSrcweir {
483cdf0e10cSrcweir maDragAnchor.X = rEvent.X;
484cdf0e10cSrcweir maDragAnchor.Y = rEvent.Y;
485cdf0e10cSrcweir meButtonDownArea = GetArea(rEvent.X, rEvent.Y);
486cdf0e10cSrcweir
487cdf0e10cSrcweir mpMousePressRepeater->Start(meButtonDownArea);
488cdf0e10cSrcweir }
489cdf0e10cSrcweir
490cdf0e10cSrcweir
491cdf0e10cSrcweir
492cdf0e10cSrcweir
mouseReleased(const css::awt::MouseEvent & rEvent)493cdf0e10cSrcweir void SAL_CALL PresenterScrollBar::mouseReleased (const css::awt::MouseEvent& rEvent)
494cdf0e10cSrcweir throw(css::uno::RuntimeException)
495cdf0e10cSrcweir {
496cdf0e10cSrcweir (void)rEvent;
497cdf0e10cSrcweir
498cdf0e10cSrcweir mpMousePressRepeater->Stop();
499cdf0e10cSrcweir
500cdf0e10cSrcweir if (mxPresenterHelper.is())
501cdf0e10cSrcweir mxPresenterHelper->releaseMouse(mxWindow);
502cdf0e10cSrcweir }
503cdf0e10cSrcweir
504cdf0e10cSrcweir
505cdf0e10cSrcweir
506cdf0e10cSrcweir
mouseEntered(const css::awt::MouseEvent & rEvent)507cdf0e10cSrcweir void SAL_CALL PresenterScrollBar::mouseEntered (const css::awt::MouseEvent& rEvent)
508cdf0e10cSrcweir throw(css::uno::RuntimeException)
509cdf0e10cSrcweir {
510cdf0e10cSrcweir (void)rEvent;
511cdf0e10cSrcweir }
512cdf0e10cSrcweir
513cdf0e10cSrcweir
514cdf0e10cSrcweir
515cdf0e10cSrcweir
mouseExited(const css::awt::MouseEvent & rEvent)516cdf0e10cSrcweir void SAL_CALL PresenterScrollBar::mouseExited (const css::awt::MouseEvent& rEvent)
517cdf0e10cSrcweir throw(css::uno::RuntimeException)
518cdf0e10cSrcweir {
519cdf0e10cSrcweir (void)rEvent;
520cdf0e10cSrcweir if (meMouseMoveArea != None)
521cdf0e10cSrcweir {
522cdf0e10cSrcweir const Area eOldMouseMoveArea (meMouseMoveArea);
523cdf0e10cSrcweir meMouseMoveArea = None;
524cdf0e10cSrcweir Repaint(GetRectangle(eOldMouseMoveArea), true);
525cdf0e10cSrcweir }
526cdf0e10cSrcweir meButtonDownArea = None;
527cdf0e10cSrcweir meMouseMoveArea = None;
528cdf0e10cSrcweir
529cdf0e10cSrcweir mpMousePressRepeater->Stop();
530cdf0e10cSrcweir }
531cdf0e10cSrcweir
532cdf0e10cSrcweir
533cdf0e10cSrcweir
534cdf0e10cSrcweir
535cdf0e10cSrcweir
536cdf0e10cSrcweir //----- XMouseMotionListener --------------------------------------------------
537cdf0e10cSrcweir
mouseMoved(const css::awt::MouseEvent & rEvent)538cdf0e10cSrcweir void SAL_CALL PresenterScrollBar::mouseMoved (const css::awt::MouseEvent& rEvent)
539cdf0e10cSrcweir throw (css::uno::RuntimeException)
540cdf0e10cSrcweir {
541cdf0e10cSrcweir const Area eArea (GetArea(rEvent.X, rEvent.Y));
542cdf0e10cSrcweir if (eArea != meMouseMoveArea)
543cdf0e10cSrcweir {
544cdf0e10cSrcweir const Area eOldMouseMoveArea (meMouseMoveArea);
545cdf0e10cSrcweir meMouseMoveArea = eArea;
546cdf0e10cSrcweir if (eOldMouseMoveArea != None)
547cdf0e10cSrcweir Repaint(GetRectangle(eOldMouseMoveArea), meMouseMoveArea==None);
548cdf0e10cSrcweir if (meMouseMoveArea != None)
549cdf0e10cSrcweir Repaint(GetRectangle(meMouseMoveArea), true);
550cdf0e10cSrcweir }
551cdf0e10cSrcweir mpMousePressRepeater->SetMouseArea(eArea);
552cdf0e10cSrcweir }
553cdf0e10cSrcweir
554cdf0e10cSrcweir
555cdf0e10cSrcweir
556cdf0e10cSrcweir
mouseDragged(const css::awt::MouseEvent & rEvent)557cdf0e10cSrcweir void SAL_CALL PresenterScrollBar::mouseDragged (const css::awt::MouseEvent& rEvent)
558cdf0e10cSrcweir throw (css::uno::RuntimeException)
559cdf0e10cSrcweir {
560cdf0e10cSrcweir if (meButtonDownArea != Thumb)
561cdf0e10cSrcweir return;
562cdf0e10cSrcweir
563cdf0e10cSrcweir mpMousePressRepeater->Stop();
564cdf0e10cSrcweir
565cdf0e10cSrcweir if (mxPresenterHelper.is())
566cdf0e10cSrcweir mxPresenterHelper->captureMouse(mxWindow);
567cdf0e10cSrcweir
568cdf0e10cSrcweir const double nDragDistance (GetDragDistance(rEvent.X,rEvent.Y));
569cdf0e10cSrcweir UpdateDragAnchor(nDragDistance);
570cdf0e10cSrcweir if (nDragDistance != 0)
571cdf0e10cSrcweir {
572cdf0e10cSrcweir SetThumbPosition(mnThumbPosition + nDragDistance, false, true, true);
573cdf0e10cSrcweir }
574cdf0e10cSrcweir }
575cdf0e10cSrcweir
576cdf0e10cSrcweir
577cdf0e10cSrcweir
578cdf0e10cSrcweir
579cdf0e10cSrcweir //----- lang::XEventListener --------------------------------------------------
580cdf0e10cSrcweir
disposing(const css::lang::EventObject & rEvent)581cdf0e10cSrcweir void SAL_CALL PresenterScrollBar::disposing (const css::lang::EventObject& rEvent)
582cdf0e10cSrcweir throw (css::uno::RuntimeException)
583cdf0e10cSrcweir {
584cdf0e10cSrcweir if (rEvent.Source == mxWindow)
585cdf0e10cSrcweir mxWindow = NULL;
586cdf0e10cSrcweir }
587cdf0e10cSrcweir
588cdf0e10cSrcweir
589cdf0e10cSrcweir
590cdf0e10cSrcweir
591cdf0e10cSrcweir //-----------------------------------------------------------------------------
592cdf0e10cSrcweir
GetRectangle(const Area eArea) const593cdf0e10cSrcweir geometry::RealRectangle2D PresenterScrollBar::GetRectangle (const Area eArea) const
594cdf0e10cSrcweir {
595cdf0e10cSrcweir OSL_ASSERT(eArea>=0 && eArea<__AreaCount__);
596cdf0e10cSrcweir
597cdf0e10cSrcweir return maBox[eArea];
598cdf0e10cSrcweir }
599cdf0e10cSrcweir
600cdf0e10cSrcweir
601cdf0e10cSrcweir
602cdf0e10cSrcweir
Repaint(const geometry::RealRectangle2D aBox,const bool bAsynchronousUpdate)603cdf0e10cSrcweir void PresenterScrollBar::Repaint (
604cdf0e10cSrcweir const geometry::RealRectangle2D aBox,
605cdf0e10cSrcweir const bool bAsynchronousUpdate)
606cdf0e10cSrcweir {
607cdf0e10cSrcweir if (mpPaintManager.get() != NULL)
608cdf0e10cSrcweir mpPaintManager->Invalidate(
609cdf0e10cSrcweir mxWindow,
610cdf0e10cSrcweir PresenterGeometryHelper::ConvertRectangle(aBox),
611cdf0e10cSrcweir bAsynchronousUpdate);
612cdf0e10cSrcweir }
613cdf0e10cSrcweir
614cdf0e10cSrcweir
615cdf0e10cSrcweir
616cdf0e10cSrcweir
PaintBackground(const css::awt::Rectangle & rUpdateBox)617cdf0e10cSrcweir void PresenterScrollBar::PaintBackground(
618cdf0e10cSrcweir const css::awt::Rectangle& rUpdateBox)
619cdf0e10cSrcweir {
620cdf0e10cSrcweir if (mpBackgroundBitmap.get() == NULL)
621cdf0e10cSrcweir return;
622cdf0e10cSrcweir
623cdf0e10cSrcweir const awt::Rectangle aWindowBox (mxWindow->getPosSize());
624cdf0e10cSrcweir mpCanvasHelper->Paint(
625cdf0e10cSrcweir mpBackgroundBitmap,
626cdf0e10cSrcweir mxCanvas,
627cdf0e10cSrcweir rUpdateBox,
628cdf0e10cSrcweir aWindowBox,
629cdf0e10cSrcweir awt::Rectangle());
630cdf0e10cSrcweir }
631cdf0e10cSrcweir
632cdf0e10cSrcweir
633cdf0e10cSrcweir
634cdf0e10cSrcweir
PaintBitmap(const css::awt::Rectangle & rUpdateBox,const Area eArea,const SharedBitmapDescriptor & rpBitmaps)635cdf0e10cSrcweir void PresenterScrollBar::PaintBitmap(
636cdf0e10cSrcweir const css::awt::Rectangle& rUpdateBox,
637cdf0e10cSrcweir const Area eArea,
638cdf0e10cSrcweir const SharedBitmapDescriptor& rpBitmaps)
639cdf0e10cSrcweir {
640cdf0e10cSrcweir const geometry::RealRectangle2D aLocalBox (GetRectangle(eArea));
641cdf0e10cSrcweir const awt::Rectangle aWindowBox (mxWindow->getPosSize());
642cdf0e10cSrcweir geometry::RealRectangle2D aBox (aLocalBox);
643cdf0e10cSrcweir aBox.X1 += aWindowBox.X;
644cdf0e10cSrcweir aBox.Y1 += aWindowBox.Y;
645cdf0e10cSrcweir aBox.X2 += aWindowBox.X;
646cdf0e10cSrcweir aBox.Y2 += aWindowBox.Y;
647cdf0e10cSrcweir
648cdf0e10cSrcweir Reference<rendering::XBitmap> xBitmap (GetBitmap(eArea,rpBitmaps));
649cdf0e10cSrcweir
650cdf0e10cSrcweir if (xBitmap.is())
651cdf0e10cSrcweir {
652cdf0e10cSrcweir Reference<rendering::XPolyPolygon2D> xClipPolygon (
653cdf0e10cSrcweir PresenterGeometryHelper::CreatePolygon(
654cdf0e10cSrcweir PresenterGeometryHelper::Intersection(rUpdateBox,
655cdf0e10cSrcweir PresenterGeometryHelper::ConvertRectangle(aBox)),
656cdf0e10cSrcweir mxCanvas->getDevice()));
657cdf0e10cSrcweir
658cdf0e10cSrcweir const rendering::ViewState aViewState (
659cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,0, 0,1,0),
660cdf0e10cSrcweir xClipPolygon);
661cdf0e10cSrcweir
662cdf0e10cSrcweir const geometry::IntegerSize2D aBitmapSize (xBitmap->getSize());
663cdf0e10cSrcweir rendering::RenderState aRenderState (
664cdf0e10cSrcweir geometry::AffineMatrix2D(
665cdf0e10cSrcweir 1,0,aBox.X1 + (aBox.X2-aBox.X1 - aBitmapSize.Width)/2,
666cdf0e10cSrcweir 0,1,aBox.Y1 + (aBox.Y2-aBox.Y1 - aBitmapSize.Height)/2),
667cdf0e10cSrcweir NULL,
668cdf0e10cSrcweir Sequence<double>(4),
669cdf0e10cSrcweir rendering::CompositeOperation::SOURCE);
670cdf0e10cSrcweir
671cdf0e10cSrcweir mxCanvas->drawBitmap(
672cdf0e10cSrcweir xBitmap,
673cdf0e10cSrcweir aViewState,
674cdf0e10cSrcweir aRenderState);
675cdf0e10cSrcweir }
676cdf0e10cSrcweir }
677cdf0e10cSrcweir
678cdf0e10cSrcweir
679cdf0e10cSrcweir
680cdf0e10cSrcweir
NotifyThumbPositionChange(void)681cdf0e10cSrcweir void PresenterScrollBar::NotifyThumbPositionChange (void)
682cdf0e10cSrcweir {
683cdf0e10cSrcweir if ( ! mbIsNotificationActive)
684cdf0e10cSrcweir {
685cdf0e10cSrcweir mbIsNotificationActive = true;
686cdf0e10cSrcweir
687cdf0e10cSrcweir try
688cdf0e10cSrcweir {
689cdf0e10cSrcweir maThumbMotionListener(mnThumbPosition);
690cdf0e10cSrcweir }
691cdf0e10cSrcweir catch (Exception&)
692cdf0e10cSrcweir {
693cdf0e10cSrcweir }
694cdf0e10cSrcweir
695cdf0e10cSrcweir mbIsNotificationActive = false;
696cdf0e10cSrcweir }
697cdf0e10cSrcweir }
698cdf0e10cSrcweir
699cdf0e10cSrcweir
700cdf0e10cSrcweir
701cdf0e10cSrcweir
GetArea(const double nX,const double nY) const702cdf0e10cSrcweir PresenterScrollBar::Area PresenterScrollBar::GetArea (const double nX, const double nY) const
703cdf0e10cSrcweir {
704cdf0e10cSrcweir const geometry::RealPoint2D aPoint(nX, nY);
705cdf0e10cSrcweir
706cdf0e10cSrcweir if (PresenterGeometryHelper::IsInside(GetRectangle(Pager), aPoint))
707cdf0e10cSrcweir {
708cdf0e10cSrcweir if (PresenterGeometryHelper::IsInside(GetRectangle(Thumb), aPoint))
709cdf0e10cSrcweir return Thumb;
710cdf0e10cSrcweir else if (PresenterGeometryHelper::IsInside(GetRectangle(PagerUp), aPoint))
711cdf0e10cSrcweir return PagerUp;
712cdf0e10cSrcweir else if (PresenterGeometryHelper::IsInside(GetRectangle(PagerDown), aPoint))
713cdf0e10cSrcweir return PagerDown;
714cdf0e10cSrcweir }
715cdf0e10cSrcweir else if (PresenterGeometryHelper::IsInside(GetRectangle(PrevButton), aPoint))
716cdf0e10cSrcweir return PrevButton;
717cdf0e10cSrcweir else if (PresenterGeometryHelper::IsInside(GetRectangle(NextButton), aPoint))
718cdf0e10cSrcweir return NextButton;
719cdf0e10cSrcweir
720cdf0e10cSrcweir return None;
721cdf0e10cSrcweir }
722cdf0e10cSrcweir
723cdf0e10cSrcweir
724cdf0e10cSrcweir
725cdf0e10cSrcweir
UpdateWidthOrHeight(sal_Int32 & rSize,const SharedBitmapDescriptor & rpDescriptor)726cdf0e10cSrcweir void PresenterScrollBar::UpdateWidthOrHeight (
727cdf0e10cSrcweir sal_Int32& rSize,
728cdf0e10cSrcweir const SharedBitmapDescriptor& rpDescriptor)
729cdf0e10cSrcweir {
730cdf0e10cSrcweir if (rpDescriptor.get() != NULL)
731cdf0e10cSrcweir {
732cdf0e10cSrcweir Reference<rendering::XBitmap> xBitmap (rpDescriptor->GetNormalBitmap());
733cdf0e10cSrcweir if (xBitmap.is())
734cdf0e10cSrcweir {
735cdf0e10cSrcweir const geometry::IntegerSize2D aBitmapSize (xBitmap->getSize());
736cdf0e10cSrcweir const sal_Int32 nBitmapSize = (sal_Int32)GetMinor(aBitmapSize.Width, aBitmapSize.Height);
737cdf0e10cSrcweir if (nBitmapSize > rSize)
738cdf0e10cSrcweir rSize = nBitmapSize;
739cdf0e10cSrcweir }
740cdf0e10cSrcweir }
741cdf0e10cSrcweir }
742cdf0e10cSrcweir
743cdf0e10cSrcweir
744cdf0e10cSrcweir
745cdf0e10cSrcweir
GetBitmap(const Area eArea,const SharedBitmapDescriptor & rpBitmaps) const746cdf0e10cSrcweir css::uno::Reference<css::rendering::XBitmap> PresenterScrollBar::GetBitmap (
747cdf0e10cSrcweir const Area eArea,
748cdf0e10cSrcweir const SharedBitmapDescriptor& rpBitmaps) const
749cdf0e10cSrcweir {
750cdf0e10cSrcweir if (rpBitmaps.get() == NULL)
751cdf0e10cSrcweir return NULL;
752cdf0e10cSrcweir else
753cdf0e10cSrcweir return rpBitmaps->GetBitmap(GetBitmapMode(eArea));
754cdf0e10cSrcweir }
755cdf0e10cSrcweir
756cdf0e10cSrcweir
757cdf0e10cSrcweir
758cdf0e10cSrcweir
GetBitmapMode(const Area eArea) const759cdf0e10cSrcweir PresenterBitmapContainer::BitmapDescriptor::Mode PresenterScrollBar::GetBitmapMode (
760cdf0e10cSrcweir const Area eArea) const
761cdf0e10cSrcweir {
762cdf0e10cSrcweir if (IsDisabled(eArea))
763cdf0e10cSrcweir return PresenterBitmapContainer::BitmapDescriptor::Disabled;
764cdf0e10cSrcweir else if (eArea == meMouseMoveArea)
765cdf0e10cSrcweir return PresenterBitmapContainer::BitmapDescriptor::MouseOver;
766cdf0e10cSrcweir else
767cdf0e10cSrcweir return PresenterBitmapContainer::BitmapDescriptor::Normal;
768cdf0e10cSrcweir }
769cdf0e10cSrcweir
770cdf0e10cSrcweir
771cdf0e10cSrcweir
772cdf0e10cSrcweir
IsDisabled(const Area eArea) const773cdf0e10cSrcweir bool PresenterScrollBar::IsDisabled (const Area eArea) const
774cdf0e10cSrcweir {
775cdf0e10cSrcweir OSL_ASSERT(eArea>=0 && eArea<__AreaCount__);
776cdf0e10cSrcweir
777cdf0e10cSrcweir return ! maEnabledState[eArea];
778cdf0e10cSrcweir }
779cdf0e10cSrcweir
780cdf0e10cSrcweir
781cdf0e10cSrcweir
782cdf0e10cSrcweir
783cdf0e10cSrcweir //===== PresenterVerticalScrollBar ============================================
784cdf0e10cSrcweir
PresenterVerticalScrollBar(const Reference<XComponentContext> & rxComponentContext,const Reference<awt::XWindow> & rxParentWindow,const::boost::shared_ptr<PresenterPaintManager> & rpPaintManager,const::boost::function<void (double)> & rThumbMotionListener)785cdf0e10cSrcweir PresenterVerticalScrollBar::PresenterVerticalScrollBar (
786cdf0e10cSrcweir const Reference<XComponentContext>& rxComponentContext,
787cdf0e10cSrcweir const Reference<awt::XWindow>& rxParentWindow,
788cdf0e10cSrcweir const ::boost::shared_ptr<PresenterPaintManager>& rpPaintManager,
789cdf0e10cSrcweir const ::boost::function<void(double)>& rThumbMotionListener)
790cdf0e10cSrcweir : PresenterScrollBar(rxComponentContext, rxParentWindow, rpPaintManager, rThumbMotionListener),
791cdf0e10cSrcweir mnScrollBarWidth(0)
792cdf0e10cSrcweir {
793cdf0e10cSrcweir }
794cdf0e10cSrcweir
795cdf0e10cSrcweir
796cdf0e10cSrcweir
797cdf0e10cSrcweir
~PresenterVerticalScrollBar(void)798cdf0e10cSrcweir PresenterVerticalScrollBar::~PresenterVerticalScrollBar (void)
799cdf0e10cSrcweir {
800cdf0e10cSrcweir }
801cdf0e10cSrcweir
802cdf0e10cSrcweir
803cdf0e10cSrcweir
804cdf0e10cSrcweir
GetDragDistance(const sal_Int32 nX,const sal_Int32 nY) const805cdf0e10cSrcweir double PresenterVerticalScrollBar::GetDragDistance (const sal_Int32 nX, const sal_Int32 nY) const
806cdf0e10cSrcweir {
807cdf0e10cSrcweir (void)nX;
808cdf0e10cSrcweir const double nDistance (nY - maDragAnchor.Y);
809cdf0e10cSrcweir if (nDistance == 0)
810cdf0e10cSrcweir return 0;
811cdf0e10cSrcweir else
812cdf0e10cSrcweir {
813cdf0e10cSrcweir const awt::Rectangle aWindowBox (mxWindow->getPosSize());
814cdf0e10cSrcweir const double nBarWidth (aWindowBox.Width);
815cdf0e10cSrcweir const double nPagerHeight (aWindowBox.Height - 2*nBarWidth);
816cdf0e10cSrcweir const double nDragDistance (mnTotalSize / nPagerHeight * nDistance);
817cdf0e10cSrcweir if (nDragDistance + mnThumbPosition < 0)
818cdf0e10cSrcweir return -mnThumbPosition;
819cdf0e10cSrcweir else if (mnThumbPosition + nDragDistance > mnTotalSize-mnThumbSize)
820cdf0e10cSrcweir return mnTotalSize-mnThumbSize-mnThumbPosition;
821cdf0e10cSrcweir else
822cdf0e10cSrcweir return nDragDistance;
823cdf0e10cSrcweir }
824cdf0e10cSrcweir }
825cdf0e10cSrcweir
826cdf0e10cSrcweir
827cdf0e10cSrcweir
828cdf0e10cSrcweir
UpdateDragAnchor(const double nDragDistance)829cdf0e10cSrcweir void PresenterVerticalScrollBar::UpdateDragAnchor (const double nDragDistance)
830cdf0e10cSrcweir {
831cdf0e10cSrcweir const awt::Rectangle aWindowBox (mxWindow->getPosSize());
832cdf0e10cSrcweir const double nBarWidth (aWindowBox.Width);
833cdf0e10cSrcweir const double nPagerHeight (aWindowBox.Height - 2*nBarWidth);
834cdf0e10cSrcweir maDragAnchor.Y += nDragDistance * nPagerHeight / mnTotalSize;
835cdf0e10cSrcweir }
836cdf0e10cSrcweir
837cdf0e10cSrcweir
838cdf0e10cSrcweir
839cdf0e10cSrcweir
GetSize(void) const840cdf0e10cSrcweir sal_Int32 PresenterVerticalScrollBar::GetSize (void) const
841cdf0e10cSrcweir {
842cdf0e10cSrcweir return mnScrollBarWidth;
843cdf0e10cSrcweir }
844cdf0e10cSrcweir
845cdf0e10cSrcweir
846cdf0e10cSrcweir
847cdf0e10cSrcweir
GetPoint(const double nMajor,const double nMinor) const848cdf0e10cSrcweir geometry::RealPoint2D PresenterVerticalScrollBar::GetPoint (
849cdf0e10cSrcweir const double nMajor, const double nMinor) const
850cdf0e10cSrcweir {
851cdf0e10cSrcweir return geometry::RealPoint2D(nMinor, nMajor);
852cdf0e10cSrcweir }
853cdf0e10cSrcweir
854cdf0e10cSrcweir
855cdf0e10cSrcweir
856cdf0e10cSrcweir
GetMajor(const double nX,const double nY) const857cdf0e10cSrcweir double PresenterVerticalScrollBar::GetMajor (const double nX, const double nY) const
858cdf0e10cSrcweir {
859cdf0e10cSrcweir (void)nX;
860cdf0e10cSrcweir return nY;
861cdf0e10cSrcweir }
862cdf0e10cSrcweir
863cdf0e10cSrcweir
864cdf0e10cSrcweir
865cdf0e10cSrcweir
GetMinor(const double nX,const double nY) const866cdf0e10cSrcweir double PresenterVerticalScrollBar::GetMinor (const double nX, const double nY) const
867cdf0e10cSrcweir {
868cdf0e10cSrcweir (void)nY;
869cdf0e10cSrcweir return nX;
870cdf0e10cSrcweir }
871cdf0e10cSrcweir
872cdf0e10cSrcweir
873cdf0e10cSrcweir
874cdf0e10cSrcweir
UpdateBorders(void)875cdf0e10cSrcweir void PresenterVerticalScrollBar::UpdateBorders (void)
876cdf0e10cSrcweir {
877cdf0e10cSrcweir const awt::Rectangle aWindowBox (mxWindow->getPosSize());
878cdf0e10cSrcweir double nBottom = aWindowBox.Height;
879cdf0e10cSrcweir
880cdf0e10cSrcweir if (mpNextButtonDescriptor.get() != NULL)
881cdf0e10cSrcweir {
882cdf0e10cSrcweir Reference<rendering::XBitmap> xBitmap (mpNextButtonDescriptor->GetNormalBitmap());
883cdf0e10cSrcweir if (xBitmap.is())
884cdf0e10cSrcweir {
885cdf0e10cSrcweir geometry::IntegerSize2D aSize (xBitmap->getSize());
886cdf0e10cSrcweir maBox[NextButton] = geometry::RealRectangle2D(
887cdf0e10cSrcweir 0, nBottom - aSize.Height, aWindowBox.Width, nBottom);
888cdf0e10cSrcweir nBottom -= aSize.Height + gnScrollBarGap;
889cdf0e10cSrcweir }
890cdf0e10cSrcweir }
891cdf0e10cSrcweir if (mpPrevButtonDescriptor.get() != NULL)
892cdf0e10cSrcweir {
893cdf0e10cSrcweir Reference<rendering::XBitmap> xBitmap (mpPrevButtonDescriptor->GetNormalBitmap());
894cdf0e10cSrcweir if (xBitmap.is())
895cdf0e10cSrcweir {
896cdf0e10cSrcweir geometry::IntegerSize2D aSize (xBitmap->getSize());
897cdf0e10cSrcweir maBox[PrevButton] = geometry::RealRectangle2D(
898cdf0e10cSrcweir 0, nBottom - aSize.Height, aWindowBox.Width, nBottom);
899cdf0e10cSrcweir nBottom -= aSize.Height + gnScrollBarGap;
900cdf0e10cSrcweir }
901cdf0e10cSrcweir }
902cdf0e10cSrcweir const double nPagerHeight (nBottom);
903cdf0e10cSrcweir maBox[Pager] = geometry::RealRectangle2D(
904cdf0e10cSrcweir 0,0, aWindowBox.Width, nBottom);
905cdf0e10cSrcweir if (mnTotalSize < 1)
906cdf0e10cSrcweir {
907cdf0e10cSrcweir maBox[Thumb] = maBox[Pager];
908cdf0e10cSrcweir
909cdf0e10cSrcweir // Set up the enabled/disabled states.
910cdf0e10cSrcweir maEnabledState[PrevButton] = false;
911cdf0e10cSrcweir maEnabledState[PagerUp] = false;
912cdf0e10cSrcweir maEnabledState[NextButton] = false;
913cdf0e10cSrcweir maEnabledState[PagerDown] = false;
914cdf0e10cSrcweir maEnabledState[Thumb] = false;
915cdf0e10cSrcweir }
916cdf0e10cSrcweir else
917cdf0e10cSrcweir {
918cdf0e10cSrcweir const double nThumbSize = ::std::min(mnThumbSize,mnTotalSize);
919cdf0e10cSrcweir const double nThumbPosition = ::std::min(::std::max(0.0,mnThumbPosition), mnTotalSize - nThumbSize);
920cdf0e10cSrcweir maBox[Thumb] = geometry::RealRectangle2D(
921cdf0e10cSrcweir 0, nThumbPosition / mnTotalSize * nPagerHeight,
922cdf0e10cSrcweir aWindowBox.Width,
923cdf0e10cSrcweir (nThumbPosition+nThumbSize) / mnTotalSize * nPagerHeight);
924cdf0e10cSrcweir
925cdf0e10cSrcweir // Set up the enabled/disabled states.
926cdf0e10cSrcweir maEnabledState[PrevButton] = nThumbPosition>0;
927cdf0e10cSrcweir maEnabledState[PagerUp] = nThumbPosition>0;
928cdf0e10cSrcweir maEnabledState[NextButton] = nThumbPosition+nThumbSize < mnTotalSize;
929cdf0e10cSrcweir maEnabledState[PagerDown] = nThumbPosition+nThumbSize < mnTotalSize;
930cdf0e10cSrcweir maEnabledState[Thumb] = nThumbSize < mnTotalSize;
931cdf0e10cSrcweir }
932cdf0e10cSrcweir maBox[PagerUp] = geometry::RealRectangle2D(
933cdf0e10cSrcweir maBox[Pager].X1, maBox[Pager].Y1, maBox[Pager].X2, maBox[Thumb].Y1-1);
934cdf0e10cSrcweir maBox[PagerDown] = geometry::RealRectangle2D(
935cdf0e10cSrcweir maBox[Pager].X1, maBox[Thumb].Y2+1, maBox[Pager].X2, maBox[Pager].Y2);
936cdf0e10cSrcweir maBox[Total] = PresenterGeometryHelper::Union(
937cdf0e10cSrcweir PresenterGeometryHelper::Union(maBox[PrevButton], maBox[NextButton]),
938cdf0e10cSrcweir maBox[Pager]);
939cdf0e10cSrcweir }
940cdf0e10cSrcweir
941cdf0e10cSrcweir
942cdf0e10cSrcweir
943cdf0e10cSrcweir
UpdateBitmaps(void)944cdf0e10cSrcweir void PresenterVerticalScrollBar::UpdateBitmaps (void)
945cdf0e10cSrcweir {
946cdf0e10cSrcweir if (mpBitmaps.get() != NULL)
947cdf0e10cSrcweir {
948cdf0e10cSrcweir mpPrevButtonDescriptor = mpBitmaps->GetBitmap(A2S("Up"));
949cdf0e10cSrcweir mpNextButtonDescriptor = mpBitmaps->GetBitmap(A2S("Down"));
950cdf0e10cSrcweir mpPagerStartDescriptor = mpBitmaps->GetBitmap(A2S("PagerTop"));
951cdf0e10cSrcweir mpPagerCenterDescriptor = mpBitmaps->GetBitmap(A2S("PagerVertical"));
952cdf0e10cSrcweir mpPagerEndDescriptor = mpBitmaps->GetBitmap(A2S("PagerBottom"));
953cdf0e10cSrcweir mpThumbStartDescriptor = mpBitmaps->GetBitmap(A2S("ThumbTop"));
954cdf0e10cSrcweir mpThumbCenterDescriptor = mpBitmaps->GetBitmap(A2S("ThumbVertical"));
955cdf0e10cSrcweir mpThumbEndDescriptor = mpBitmaps->GetBitmap(A2S("ThumbBottom"));
956cdf0e10cSrcweir
957cdf0e10cSrcweir mnScrollBarWidth = 0;
958cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarWidth, mpPrevButtonDescriptor);
959cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarWidth, mpNextButtonDescriptor);
960cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarWidth, mpPagerStartDescriptor);
961cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarWidth, mpPagerCenterDescriptor);
962cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarWidth, mpPagerEndDescriptor);
963cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarWidth, mpThumbStartDescriptor);
964cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarWidth, mpThumbCenterDescriptor);
965cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarWidth, mpThumbEndDescriptor);
966cdf0e10cSrcweir if (mnScrollBarWidth == 0)
967cdf0e10cSrcweir mnScrollBarWidth = 20;
968cdf0e10cSrcweir }
969cdf0e10cSrcweir }
970cdf0e10cSrcweir
971cdf0e10cSrcweir
972cdf0e10cSrcweir
973cdf0e10cSrcweir
PaintComposite(const css::awt::Rectangle & rUpdateBox,const Area eArea,const SharedBitmapDescriptor & rpStartBitmaps,const SharedBitmapDescriptor & rpCenterBitmaps,const SharedBitmapDescriptor & rpEndBitmaps)974cdf0e10cSrcweir void PresenterVerticalScrollBar::PaintComposite(
975cdf0e10cSrcweir const css::awt::Rectangle& rUpdateBox,
976cdf0e10cSrcweir const Area eArea,
977cdf0e10cSrcweir const SharedBitmapDescriptor& rpStartBitmaps,
978cdf0e10cSrcweir const SharedBitmapDescriptor& rpCenterBitmaps,
979cdf0e10cSrcweir const SharedBitmapDescriptor& rpEndBitmaps)
980cdf0e10cSrcweir {
981cdf0e10cSrcweir const awt::Rectangle aWindowBox (mxWindow->getPosSize());
982cdf0e10cSrcweir geometry::RealRectangle2D aBox (GetRectangle(eArea));
983cdf0e10cSrcweir aBox.X1 += aWindowBox.X;
984cdf0e10cSrcweir aBox.Y1 += aWindowBox.Y;
985cdf0e10cSrcweir aBox.X2 += aWindowBox.X;
986cdf0e10cSrcweir aBox.Y2 += aWindowBox.Y;
987cdf0e10cSrcweir
988cdf0e10cSrcweir // Get bitmaps and sizes.
989cdf0e10cSrcweir
990cdf0e10cSrcweir PresenterUIPainter::PaintVerticalBitmapComposite(
991cdf0e10cSrcweir mxCanvas,
992cdf0e10cSrcweir rUpdateBox,
993cdf0e10cSrcweir (eArea == Thumb
994cdf0e10cSrcweir ? PresenterGeometryHelper::ConvertRectangleWithConstantSize(aBox)
995cdf0e10cSrcweir : PresenterGeometryHelper::ConvertRectangle(aBox)),
996cdf0e10cSrcweir GetBitmap(eArea, rpStartBitmaps),
997cdf0e10cSrcweir GetBitmap(eArea, rpCenterBitmaps),
998cdf0e10cSrcweir GetBitmap(eArea, rpEndBitmaps));
999cdf0e10cSrcweir }
1000cdf0e10cSrcweir
1001cdf0e10cSrcweir
1002cdf0e10cSrcweir
1003cdf0e10cSrcweir
1004cdf0e10cSrcweir //===== PresenterHorizontalScrollBar ============================================
1005cdf0e10cSrcweir
PresenterHorizontalScrollBar(const Reference<XComponentContext> & rxComponentContext,const Reference<awt::XWindow> & rxParentWindow,const::boost::shared_ptr<PresenterPaintManager> & rpPaintManager,const::boost::function<void (double)> & rThumbMotionListener)1006cdf0e10cSrcweir PresenterHorizontalScrollBar::PresenterHorizontalScrollBar (
1007cdf0e10cSrcweir const Reference<XComponentContext>& rxComponentContext,
1008cdf0e10cSrcweir const Reference<awt::XWindow>& rxParentWindow,
1009cdf0e10cSrcweir const ::boost::shared_ptr<PresenterPaintManager>& rpPaintManager,
1010cdf0e10cSrcweir const ::boost::function<void(double)>& rThumbMotionListener)
1011cdf0e10cSrcweir : PresenterScrollBar(rxComponentContext, rxParentWindow, rpPaintManager, rThumbMotionListener),
1012cdf0e10cSrcweir mnScrollBarHeight(0)
1013cdf0e10cSrcweir {
1014cdf0e10cSrcweir }
1015cdf0e10cSrcweir
1016cdf0e10cSrcweir
1017cdf0e10cSrcweir
1018cdf0e10cSrcweir
~PresenterHorizontalScrollBar(void)1019cdf0e10cSrcweir PresenterHorizontalScrollBar::~PresenterHorizontalScrollBar (void)
1020cdf0e10cSrcweir {
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir
1023cdf0e10cSrcweir
1024cdf0e10cSrcweir
1025cdf0e10cSrcweir
GetDragDistance(const sal_Int32 nX,const sal_Int32 nY) const1026cdf0e10cSrcweir double PresenterHorizontalScrollBar::GetDragDistance (const sal_Int32 nX, const sal_Int32 nY) const
1027cdf0e10cSrcweir {
1028cdf0e10cSrcweir (void)nY;
1029cdf0e10cSrcweir const double nDistance (nX - maDragAnchor.X);
1030cdf0e10cSrcweir if (nDistance == 0)
1031cdf0e10cSrcweir return 0;
1032cdf0e10cSrcweir else
1033cdf0e10cSrcweir {
1034cdf0e10cSrcweir const awt::Rectangle aWindowBox (mxWindow->getPosSize());
1035cdf0e10cSrcweir const double nBarHeight (aWindowBox.Height);
1036cdf0e10cSrcweir const double nPagerWidth (aWindowBox.Width - 2*nBarHeight);
1037cdf0e10cSrcweir const double nDragDistance (mnTotalSize / nPagerWidth * nDistance);
1038cdf0e10cSrcweir if (nDragDistance + mnThumbPosition < 0)
1039cdf0e10cSrcweir return -mnThumbPosition;
1040cdf0e10cSrcweir else if (mnThumbPosition + nDragDistance > mnTotalSize-mnThumbSize)
1041cdf0e10cSrcweir return mnTotalSize-mnThumbSize-mnThumbPosition;
1042cdf0e10cSrcweir else
1043cdf0e10cSrcweir return nDragDistance;
1044cdf0e10cSrcweir }
1045cdf0e10cSrcweir }
1046cdf0e10cSrcweir
1047cdf0e10cSrcweir
1048cdf0e10cSrcweir
1049cdf0e10cSrcweir
UpdateDragAnchor(const double nDragDistance)1050cdf0e10cSrcweir void PresenterHorizontalScrollBar::UpdateDragAnchor (const double nDragDistance)
1051cdf0e10cSrcweir {
1052cdf0e10cSrcweir const awt::Rectangle aWindowBox (mxWindow->getPosSize());
1053cdf0e10cSrcweir const double nBarHeight (aWindowBox.Height);
1054cdf0e10cSrcweir const double nPagerWidth (aWindowBox.Width - 2*nBarHeight);
1055cdf0e10cSrcweir maDragAnchor.X += nDragDistance * nPagerWidth / mnTotalSize;
1056cdf0e10cSrcweir }
1057cdf0e10cSrcweir
1058cdf0e10cSrcweir
1059cdf0e10cSrcweir
1060cdf0e10cSrcweir
GetSize(void) const1061cdf0e10cSrcweir sal_Int32 PresenterHorizontalScrollBar::GetSize (void) const
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir return mnScrollBarHeight;
1064cdf0e10cSrcweir }
1065cdf0e10cSrcweir
1066cdf0e10cSrcweir
1067cdf0e10cSrcweir
1068cdf0e10cSrcweir
1069cdf0e10cSrcweir
GetPoint(const double nMajor,const double nMinor) const1070cdf0e10cSrcweir geometry::RealPoint2D PresenterHorizontalScrollBar::GetPoint (
1071cdf0e10cSrcweir const double nMajor, const double nMinor) const
1072cdf0e10cSrcweir {
1073cdf0e10cSrcweir return geometry::RealPoint2D(nMajor, nMinor);
1074cdf0e10cSrcweir }
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir
1077cdf0e10cSrcweir
1078cdf0e10cSrcweir
GetMajor(const double nX,const double nY) const1079cdf0e10cSrcweir double PresenterHorizontalScrollBar::GetMajor (const double nX, const double nY) const
1080cdf0e10cSrcweir {
1081cdf0e10cSrcweir (void)nY;
1082cdf0e10cSrcweir return nX;
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir
1085cdf0e10cSrcweir
1086cdf0e10cSrcweir
1087cdf0e10cSrcweir
GetMinor(const double nX,const double nY) const1088cdf0e10cSrcweir double PresenterHorizontalScrollBar::GetMinor (const double nX, const double nY) const
1089cdf0e10cSrcweir {
1090cdf0e10cSrcweir (void)nX;
1091cdf0e10cSrcweir return nY;
1092cdf0e10cSrcweir }
1093cdf0e10cSrcweir
1094cdf0e10cSrcweir
1095cdf0e10cSrcweir
1096cdf0e10cSrcweir
UpdateBorders(void)1097cdf0e10cSrcweir void PresenterHorizontalScrollBar::UpdateBorders (void)
1098cdf0e10cSrcweir {
1099cdf0e10cSrcweir const awt::Rectangle aWindowBox (mxWindow->getPosSize());
1100cdf0e10cSrcweir double nRight = aWindowBox.Width;
1101cdf0e10cSrcweir const double nGap (2);
1102cdf0e10cSrcweir
1103cdf0e10cSrcweir if (mpNextButtonDescriptor.get() != NULL)
1104cdf0e10cSrcweir {
1105cdf0e10cSrcweir Reference<rendering::XBitmap> xBitmap (mpNextButtonDescriptor->GetNormalBitmap());
1106cdf0e10cSrcweir if (xBitmap.is())
1107cdf0e10cSrcweir {
1108cdf0e10cSrcweir geometry::IntegerSize2D aSize (xBitmap->getSize());
1109cdf0e10cSrcweir maBox[NextButton] = geometry::RealRectangle2D(
1110cdf0e10cSrcweir nRight - aSize.Width,0, nRight, aWindowBox.Height);
1111cdf0e10cSrcweir nRight -= aSize.Width + nGap;
1112cdf0e10cSrcweir }
1113cdf0e10cSrcweir }
1114cdf0e10cSrcweir if (mpPrevButtonDescriptor.get() != NULL)
1115cdf0e10cSrcweir {
1116cdf0e10cSrcweir Reference<rendering::XBitmap> xBitmap (mpPrevButtonDescriptor->GetNormalBitmap());
1117cdf0e10cSrcweir if (xBitmap.is())
1118cdf0e10cSrcweir {
1119cdf0e10cSrcweir geometry::IntegerSize2D aSize (xBitmap->getSize());
1120cdf0e10cSrcweir maBox[PrevButton] = geometry::RealRectangle2D(
1121cdf0e10cSrcweir nRight - aSize.Width,0, nRight, aWindowBox.Height);
1122cdf0e10cSrcweir nRight -= aSize.Width + nGap;
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir }
1125cdf0e10cSrcweir
1126cdf0e10cSrcweir const double nPagerWidth (nRight);
1127cdf0e10cSrcweir maBox[Pager] = geometry::RealRectangle2D(
1128cdf0e10cSrcweir 0,0, nRight, aWindowBox.Height);
1129cdf0e10cSrcweir if (mnTotalSize == 0)
1130cdf0e10cSrcweir {
1131cdf0e10cSrcweir maBox[Thumb] = maBox[Pager];
1132cdf0e10cSrcweir
1133cdf0e10cSrcweir // Set up the enabled/disabled states.
1134cdf0e10cSrcweir maEnabledState[PrevButton] = false;
1135cdf0e10cSrcweir maEnabledState[PagerUp] = false;
1136cdf0e10cSrcweir maEnabledState[NextButton] = false;
1137cdf0e10cSrcweir maEnabledState[PagerDown] = false;
1138cdf0e10cSrcweir maEnabledState[Thumb] = false;
1139cdf0e10cSrcweir }
1140cdf0e10cSrcweir else
1141cdf0e10cSrcweir {
1142cdf0e10cSrcweir const double nThumbSize = ::std::min(mnThumbSize,mnTotalSize);
1143cdf0e10cSrcweir const double nThumbPosition = ::std::min(::std::max(0.0,mnThumbPosition), mnTotalSize - nThumbSize);
1144cdf0e10cSrcweir maBox[Thumb] = geometry::RealRectangle2D(
1145cdf0e10cSrcweir (nThumbPosition) / mnTotalSize * nPagerWidth, 0,
1146cdf0e10cSrcweir (nThumbPosition+nThumbSize) / mnTotalSize * nPagerWidth, aWindowBox.Height);
1147cdf0e10cSrcweir
1148cdf0e10cSrcweir // Set up the enabled/disabled states.
1149cdf0e10cSrcweir maEnabledState[PrevButton] = nThumbPosition>0;
1150cdf0e10cSrcweir maEnabledState[PagerUp] = nThumbPosition>0;
1151cdf0e10cSrcweir maEnabledState[NextButton] = nThumbPosition+nThumbSize < mnTotalSize;
1152cdf0e10cSrcweir maEnabledState[PagerDown] = nThumbPosition+nThumbSize < mnTotalSize;
1153cdf0e10cSrcweir maEnabledState[Thumb] = nThumbSize < mnTotalSize;
1154cdf0e10cSrcweir }
1155cdf0e10cSrcweir maBox[PagerUp] = geometry::RealRectangle2D(
1156cdf0e10cSrcweir maBox[Pager].X1, maBox[Pager].Y1, maBox[Thumb].X1-1, maBox[Pager].Y2);
1157cdf0e10cSrcweir maBox[PagerDown] = geometry::RealRectangle2D(
1158cdf0e10cSrcweir maBox[Thumb].X2+1, maBox[Pager].Y1, maBox[Pager].X2, maBox[Pager].Y2);
1159cdf0e10cSrcweir maBox[Total] = PresenterGeometryHelper::Union(
1160cdf0e10cSrcweir PresenterGeometryHelper::Union(maBox[PrevButton], maBox[NextButton]),
1161cdf0e10cSrcweir maBox[Pager]);
1162cdf0e10cSrcweir }
1163cdf0e10cSrcweir
1164cdf0e10cSrcweir
1165cdf0e10cSrcweir
1166cdf0e10cSrcweir
UpdateBitmaps(void)1167cdf0e10cSrcweir void PresenterHorizontalScrollBar::UpdateBitmaps (void)
1168cdf0e10cSrcweir {
1169cdf0e10cSrcweir if (mpBitmaps.get() != NULL)
1170cdf0e10cSrcweir {
1171cdf0e10cSrcweir mpPrevButtonDescriptor = mpBitmaps->GetBitmap(A2S("Left"));
1172cdf0e10cSrcweir mpNextButtonDescriptor = mpBitmaps->GetBitmap(A2S("Right"));
1173cdf0e10cSrcweir mpPagerStartDescriptor = mpBitmaps->GetBitmap(A2S("PagerLeft"));
1174cdf0e10cSrcweir mpPagerCenterDescriptor = mpBitmaps->GetBitmap(A2S("PagerHorizontal"));
1175cdf0e10cSrcweir mpPagerEndDescriptor = mpBitmaps->GetBitmap(A2S("PagerRight"));
1176cdf0e10cSrcweir mpThumbStartDescriptor = mpBitmaps->GetBitmap(A2S("ThumbLeft"));
1177cdf0e10cSrcweir mpThumbCenterDescriptor = mpBitmaps->GetBitmap(A2S("ThumbHorizontal"));
1178cdf0e10cSrcweir mpThumbEndDescriptor = mpBitmaps->GetBitmap(A2S("ThumbRight"));
1179cdf0e10cSrcweir
1180cdf0e10cSrcweir mnScrollBarHeight = 0;
1181cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarHeight, mpPrevButtonDescriptor);
1182cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarHeight, mpNextButtonDescriptor);
1183cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarHeight, mpPagerStartDescriptor);
1184cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarHeight, mpPagerCenterDescriptor);
1185cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarHeight, mpPagerEndDescriptor);
1186cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarHeight, mpThumbStartDescriptor);
1187cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarHeight, mpThumbCenterDescriptor);
1188cdf0e10cSrcweir UpdateWidthOrHeight(mnScrollBarHeight, mpThumbEndDescriptor);
1189cdf0e10cSrcweir if (mnScrollBarHeight == 0)
1190cdf0e10cSrcweir mnScrollBarHeight = 20;
1191cdf0e10cSrcweir }
1192cdf0e10cSrcweir }
1193cdf0e10cSrcweir
1194cdf0e10cSrcweir
1195cdf0e10cSrcweir
PaintComposite(const css::awt::Rectangle & rUpdateBox,const Area eArea,const SharedBitmapDescriptor & rpStartBitmaps,const SharedBitmapDescriptor & rpCenterBitmaps,const SharedBitmapDescriptor & rpEndBitmaps)1196cdf0e10cSrcweir void PresenterHorizontalScrollBar::PaintComposite(
1197cdf0e10cSrcweir const css::awt::Rectangle& rUpdateBox,
1198cdf0e10cSrcweir const Area eArea,
1199cdf0e10cSrcweir const SharedBitmapDescriptor& rpStartBitmaps,
1200cdf0e10cSrcweir const SharedBitmapDescriptor& rpCenterBitmaps,
1201cdf0e10cSrcweir const SharedBitmapDescriptor& rpEndBitmaps)
1202cdf0e10cSrcweir {
1203cdf0e10cSrcweir const awt::Rectangle aWindowBox (mxWindow->getPosSize());
1204cdf0e10cSrcweir geometry::RealRectangle2D aBox (GetRectangle(eArea));
1205cdf0e10cSrcweir aBox.X1 += aWindowBox.X;
1206cdf0e10cSrcweir aBox.Y1 += aWindowBox.Y;
1207cdf0e10cSrcweir aBox.X2 += aWindowBox.X;
1208cdf0e10cSrcweir aBox.Y2 += aWindowBox.Y;
1209cdf0e10cSrcweir
1210cdf0e10cSrcweir PresenterUIPainter::PaintHorizontalBitmapComposite(
1211cdf0e10cSrcweir mxCanvas,
1212cdf0e10cSrcweir rUpdateBox,
1213cdf0e10cSrcweir PresenterGeometryHelper::ConvertRectangle(aBox),
1214cdf0e10cSrcweir GetBitmap(eArea, rpStartBitmaps),
1215cdf0e10cSrcweir GetBitmap(eArea, rpCenterBitmaps),
1216cdf0e10cSrcweir GetBitmap(eArea, rpEndBitmaps));
1217cdf0e10cSrcweir }
1218cdf0e10cSrcweir
1219cdf0e10cSrcweir
1220cdf0e10cSrcweir
1221cdf0e10cSrcweir
1222cdf0e10cSrcweir //===== PresenterScrollBar::MousePressRepeater ================================
1223cdf0e10cSrcweir
MousePressRepeater(const::rtl::Reference<PresenterScrollBar> & rpScrollBar)1224cdf0e10cSrcweir PresenterScrollBar::MousePressRepeater::MousePressRepeater (
1225cdf0e10cSrcweir const ::rtl::Reference<PresenterScrollBar>& rpScrollBar)
1226cdf0e10cSrcweir : mnMousePressRepeaterTaskId(PresenterTimer::NotAValidTaskId),
1227cdf0e10cSrcweir mpScrollBar(rpScrollBar),
1228cdf0e10cSrcweir meMouseArea(PresenterScrollBar::None)
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir }
1231cdf0e10cSrcweir
1232cdf0e10cSrcweir
1233cdf0e10cSrcweir
1234cdf0e10cSrcweir
Dispose(void)1235cdf0e10cSrcweir void PresenterScrollBar::MousePressRepeater::Dispose (void)
1236cdf0e10cSrcweir {
1237cdf0e10cSrcweir Stop();
1238cdf0e10cSrcweir mpScrollBar = NULL;
1239cdf0e10cSrcweir }
1240cdf0e10cSrcweir
1241cdf0e10cSrcweir
1242cdf0e10cSrcweir
1243cdf0e10cSrcweir
Start(const PresenterScrollBar::Area & reArea)1244cdf0e10cSrcweir void PresenterScrollBar::MousePressRepeater::Start (const PresenterScrollBar::Area& reArea)
1245cdf0e10cSrcweir {
1246cdf0e10cSrcweir meMouseArea = reArea;
1247cdf0e10cSrcweir
1248cdf0e10cSrcweir if (mnMousePressRepeaterTaskId == PresenterTimer::NotAValidTaskId)
1249cdf0e10cSrcweir {
1250cdf0e10cSrcweir // Execute key press operation at least this one time.
1251cdf0e10cSrcweir Execute();
1252cdf0e10cSrcweir
1253cdf0e10cSrcweir // Schedule repeated executions.
1254cdf0e10cSrcweir mnMousePressRepeaterTaskId = PresenterTimer::ScheduleRepeatedTask (
1255cdf0e10cSrcweir ::boost::bind(&PresenterScrollBar::MousePressRepeater::Callback, shared_from_this(), _1),
1256cdf0e10cSrcweir 500000000,
1257cdf0e10cSrcweir 250000000);
1258cdf0e10cSrcweir }
1259cdf0e10cSrcweir else
1260cdf0e10cSrcweir {
1261cdf0e10cSrcweir // There is already an active repeating task.
1262cdf0e10cSrcweir }
1263cdf0e10cSrcweir }
1264cdf0e10cSrcweir
1265cdf0e10cSrcweir
1266cdf0e10cSrcweir
1267cdf0e10cSrcweir
Stop(void)1268cdf0e10cSrcweir void PresenterScrollBar::MousePressRepeater::Stop (void)
1269cdf0e10cSrcweir {
1270cdf0e10cSrcweir if (mnMousePressRepeaterTaskId != PresenterTimer::NotAValidTaskId)
1271cdf0e10cSrcweir {
1272cdf0e10cSrcweir const sal_Int32 nTaskId (mnMousePressRepeaterTaskId);
1273cdf0e10cSrcweir mnMousePressRepeaterTaskId = PresenterTimer::NotAValidTaskId;
1274cdf0e10cSrcweir PresenterTimer::CancelTask(nTaskId);
1275cdf0e10cSrcweir }
1276cdf0e10cSrcweir }
1277cdf0e10cSrcweir
1278cdf0e10cSrcweir
1279cdf0e10cSrcweir
1280cdf0e10cSrcweir
SetMouseArea(const PresenterScrollBar::Area & reArea)1281cdf0e10cSrcweir void PresenterScrollBar::MousePressRepeater::SetMouseArea(const PresenterScrollBar::Area& reArea)
1282cdf0e10cSrcweir {
1283cdf0e10cSrcweir if (meMouseArea != reArea)
1284cdf0e10cSrcweir {
1285cdf0e10cSrcweir if (mnMousePressRepeaterTaskId != PresenterTimer::NotAValidTaskId)
1286cdf0e10cSrcweir {
1287cdf0e10cSrcweir Stop();
1288cdf0e10cSrcweir }
1289cdf0e10cSrcweir }
1290cdf0e10cSrcweir }
1291cdf0e10cSrcweir
1292cdf0e10cSrcweir
1293cdf0e10cSrcweir
1294cdf0e10cSrcweir
Callback(const TimeValue & rCurrentTime)1295cdf0e10cSrcweir void PresenterScrollBar::MousePressRepeater::Callback (const TimeValue& rCurrentTime)
1296cdf0e10cSrcweir {
1297cdf0e10cSrcweir (void)rCurrentTime;
1298cdf0e10cSrcweir
1299cdf0e10cSrcweir if (mpScrollBar.get() == NULL)
1300cdf0e10cSrcweir {
1301cdf0e10cSrcweir Stop();
1302cdf0e10cSrcweir return;
1303cdf0e10cSrcweir }
1304cdf0e10cSrcweir
1305cdf0e10cSrcweir Execute();
1306cdf0e10cSrcweir }
1307cdf0e10cSrcweir
1308cdf0e10cSrcweir
1309cdf0e10cSrcweir
1310cdf0e10cSrcweir
Execute(void)1311cdf0e10cSrcweir void PresenterScrollBar::MousePressRepeater::Execute (void)
1312cdf0e10cSrcweir {
1313cdf0e10cSrcweir const double nThumbPosition (mpScrollBar->GetThumbPosition());
1314cdf0e10cSrcweir switch (meMouseArea)
1315cdf0e10cSrcweir {
1316cdf0e10cSrcweir case PrevButton:
1317cdf0e10cSrcweir mpScrollBar->SetThumbPosition(nThumbPosition - mpScrollBar->GetLineHeight(), true);
1318cdf0e10cSrcweir break;
1319cdf0e10cSrcweir
1320cdf0e10cSrcweir case NextButton:
1321cdf0e10cSrcweir mpScrollBar->SetThumbPosition(nThumbPosition + mpScrollBar->GetLineHeight(), true);
1322cdf0e10cSrcweir break;
1323cdf0e10cSrcweir
1324cdf0e10cSrcweir case PagerUp:
1325cdf0e10cSrcweir mpScrollBar->SetThumbPosition(nThumbPosition - mpScrollBar->GetThumbSize()*0.8, true);
1326cdf0e10cSrcweir break;
1327cdf0e10cSrcweir
1328cdf0e10cSrcweir case PagerDown:
1329cdf0e10cSrcweir mpScrollBar->SetThumbPosition(nThumbPosition + mpScrollBar->GetThumbSize()*0.8, true);
1330cdf0e10cSrcweir break;
1331cdf0e10cSrcweir
1332cdf0e10cSrcweir default:
1333cdf0e10cSrcweir break;
1334cdf0e10cSrcweir }
1335cdf0e10cSrcweir }
1336cdf0e10cSrcweir
1337cdf0e10cSrcweir
1338cdf0e10cSrcweir
1339cdf0e10cSrcweir } } // end of namespace ::sdext::presenter
1340