1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlsViewOverlay.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_SLIDESORTER_VIEW_OVERLAY_HXX
32 #define SD_SLIDESORTER_VIEW_OVERLAY_HXX
34 #include "model/SlsSharedPageDescriptor.hxx"
36 #include <basegfx/polygon/b2dpolypolygon.hxx>
37 #include <osl/mutex.hxx>
38 #include <svx/sdr/overlay/overlayobject.hxx>
39 #include <tools/gen.hxx>
41 #include <boost/weak_ptr.hpp>
42 #include <boost/noncopyable.hpp>
48 namespace sd
{ namespace slidesorter
{
52 namespace sd
{ namespace slidesorter
{ namespace model
{
53 class PageEnumeration
;
56 namespace sd
{ namespace slidesorter
{ namespace controller
{
57 class SlideSorterController
;
60 namespace sdr
{ namespace overlay
{
64 namespace sd
{ namespace slidesorter
{ namespace view
{
67 class InsertionIndicatorOverlay
;
68 class PageObjectViewObjectContact
;
69 class SelectionRectangleOverlay
;
70 class SubstitutionOverlay
;
73 /** This base class of slide sorter overlays uses the drawing layer overlay
74 support for the display.
77 : public sdr::overlay::OverlayObject
80 OverlayBase (ViewOverlay
& rViewOverlay
);
81 virtual ~OverlayBase (void);
86 ViewOverlay
& mrViewOverlay
;
88 /** Make sure that the overlay object is registered at the
89 OverlayManager. This registration is done on demand.
91 void EnsureRegistration (void);
97 /** During internal drag and drop the outlines of the selected slides are
98 painted at the mouse position in dashed lines.
100 class SubstitutionOverlay
104 SubstitutionOverlay (ViewOverlay
& rViewOverlay
);
105 virtual ~SubstitutionOverlay (void);
107 /** Setup the substitution display of the given set of selected pages.
108 The given mouse position is remembered so that it later can be
109 returned by GetPosition(). This is a convenience feature.
112 model::PageEnumeration
& rSelection
,
113 const Point
& rPosition
);
115 /** Clear the substitution display. Until the next call of Create() no
116 substution is painted.
120 /** Move the substitution display by the given amount of pixels.
122 void Move (const Point
& rOffset
);
123 void SetPosition (const Point
& rPosition
);
124 Point
GetPosition (void) const;
126 // react on stripe definition change
127 virtual void stripeDefinitionHasChanged();
130 // geometry creation for OverlayObject
131 virtual drawinglayer::primitive2d::Primitive2DSequence
createOverlayObjectPrimitive2DSequence();
135 basegfx::B2DPolyPolygon maShapes
;
141 /** Slides can be selected by drawing a selection rectangle in the slide
142 sorter. When the left mouse button is released all slides that are at
143 least partially in the rectangle are selected.
145 class SelectionRectangleOverlay
149 SelectionRectangleOverlay (ViewOverlay
& rViewOverlay
);
151 void Start (const Point
& rAnchor
);
152 void Update (const Point
& rSecondCorner
);
154 Rectangle
GetSelectionRectangle (void);
156 // react on stripe definition change
157 virtual void stripeDefinitionHasChanged();
160 // geometry creation for OverlayObject
161 virtual drawinglayer::primitive2d::Primitive2DSequence
createOverlayObjectPrimitive2DSequence();
165 Point maSecondCorner
;
171 /** The insertion indicator is painted as a vertical or horizonal bar
172 in the space between slides.
174 class InsertionIndicatorOverlay
178 InsertionIndicatorOverlay (ViewOverlay
& rViewOverlay
);
180 /** Given a position in model coordinates this method calculates the
181 insertion marker both as an index in the document and as a rectangle
182 used for drawing the insertion indicator.
184 void SetPosition (const Point
& rPosition
);
186 sal_Int32
GetInsertionPageIndex (void) const;
189 // geometry creation for OverlayObject
190 virtual drawinglayer::primitive2d::Primitive2DSequence
createOverlayObjectPrimitive2DSequence();
193 sal_Int32 mnInsertionIndex
;
194 Rectangle maBoundingBox
;
196 void SetPositionAndSize (const Rectangle
& rBoundingBox
);
202 /** Paint a frame around the slide preview under the mouse. The actual
203 painting is done by the PageObjectViewObjectContact of the slidesorter.
205 class MouseOverIndicatorOverlay
209 MouseOverIndicatorOverlay (ViewOverlay
& rViewOverlay
);
210 virtual ~MouseOverIndicatorOverlay (void);
212 /** Set the page object for which to paint a mouse over indicator.
214 A value of <NULL/> indicates to not paint the mouse over indicator.
216 void SetSlideUnderMouse (const model::SharedPageDescriptor
& rpDescriptor
);
219 // geometry creation for OverlayObject
220 virtual drawinglayer::primitive2d::Primitive2DSequence
createOverlayObjectPrimitive2DSequence();
223 /** The page under the mouse is stored as weak shared pointer so that
224 model changes can be handled without having the SlideSorterModel
225 inform this class explicitly.
227 ::boost::weak_ptr
<model::PageDescriptor
> mpPageUnderMouse
;
229 view::PageObjectViewObjectContact
* GetViewObjectContact (void) const;
235 /** The view overlay manages and paints some indicators that are painted on
236 top of the regular view content (the page objects). It is separated
237 from the view to allow the indicators to be altered in position and size
238 without repainting the whole view content (inside that the bounding box
239 of the indicator). This is achieved by using the drawing layer overlay
242 The view overlay itself simply gives access to the more specialized
243 classes that handle individual indicators.
249 ViewOverlay (SlideSorter
& rSlideSorter
);
252 SelectionRectangleOverlay
& GetSelectionRectangleOverlay (void);
253 MouseOverIndicatorOverlay
& GetMouseOverIndicatorOverlay (void);
254 InsertionIndicatorOverlay
& GetInsertionIndicatorOverlay (void);
255 SubstitutionOverlay
& GetSubstitutionOverlay (void);
257 SlideSorter
& GetSlideSorter (void) const;
259 sdr::overlay::OverlayManager
* GetOverlayManager (void) const;
262 SlideSorter
& mrSlideSorter
;
263 SelectionRectangleOverlay maSelectionRectangleOverlay
;
264 MouseOverIndicatorOverlay maMouseOverIndicatorOverlay
;
265 InsertionIndicatorOverlay maInsertionIndicatorOverlay
;
266 SubstitutionOverlay maSubstitutionOverlay
;
271 } } } // end of namespace ::sd::slidesorter::view