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 .
20 #ifndef INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_VIEW_SLIDESORTERVIEW_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_VIEW_SLIDESORTERVIEW_HXX
23 #include "SlideSorter.hxx"
24 #include "model/SlsPageDescriptor.hxx"
25 #include "model/SlsSharedPageDescriptor.hxx"
26 #include "view/SlsLayouter.hxx"
27 #include "view/SlsILayerPainter.hxx"
30 #include <sfx2/viewfrm.hxx>
32 #include <tools/gen.hxx>
33 #include <svx/svdmodel.hxx>
34 #include <vcl/region.hxx>
35 #include <vcl/outdev.hxx>
36 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
38 #include <boost/shared_ptr.hpp>
39 #include <boost/noncopyable.hpp>
43 namespace sd
{ namespace slidesorter
{ namespace controller
{
47 namespace sd
{ namespace slidesorter
{ namespace cache
{
51 namespace sd
{ namespace slidesorter
{ namespace model
{
52 class SlideSorterModel
;
55 namespace sd
{ namespace slidesorter
{ namespace view
{
59 class PageObjectPainter
;
60 class SelectionPainter
;
65 public ::boost::noncopyable
70 /** Create a new view for the slide sorter.
72 This reference is simply passed to the base class and not used
76 SlideSorterView (SlideSorter
& rSlideSorter
);
79 virtual ~SlideSorterView();
82 /** Set the general way of layouting the page objects. Note that this
83 method does not trigger any repaints or layouts.
85 bool SetOrientation (const Layouter::Orientation eOrientation
);
86 Layouter::Orientation
GetOrientation() const { return meOrientation
;}
88 void RequestRepaint();
89 void RequestRepaint (const model::SharedPageDescriptor
& rDescriptor
);
90 void RequestRepaint (const Rectangle
& rRepaintBox
);
91 void RequestRepaint (const vcl::Region
& rRepaintRegion
);
93 Rectangle
GetModelArea();
95 /** Return the index of the page that is rendered at the given position.
97 The position is expected to be in pixel coordinates.
99 The returned index is -1 when there is no page object at the
102 sal_Int32
GetPageIndexAtPoint (const Point
& rPosition
) const;
104 view::Layouter
& GetLayouter();
106 virtual void ModelHasChanged() SAL_OVERRIDE
;
108 /** This method is typically called before a model change takes place.
109 All references to model data are released. PostModelChange() has to
110 be called to complete the handling of the model change. When the
111 calls to Pre- and PostModelChange() are very close to each other you
112 may call HandleModelChange() instead.
114 void PreModelChange();
116 /** This method is typically called after a model change took place.
117 References to model data are re-allocated. Call this method only
118 after PreModelChange() has been called.
120 void PostModelChange();
122 /** This method is a convenience function that simply calls
123 PreModelChange() and then PostModelChange().
125 void HandleModelChange();
127 void HandleDrawModeChange();
130 virtual void CompleteRedraw (
131 OutputDevice
* pDevice
,
132 const vcl::Region
& rPaintArea
,
133 sdr::contact::ViewObjectContactRedirector
* pRedirector
= NULL
) SAL_OVERRIDE
;
134 void Paint (OutputDevice
& rDevice
, const Rectangle
& rRepaintArea
);
136 virtual void ConfigurationChanged (
137 utl::ConfigurationBroadcaster
* pBroadcaster
,
138 sal_uInt32 nHint
) SAL_OVERRIDE
;
140 void HandleDataChangeEvent();
143 /** This tells the view that it has to re-determine the visibility of
144 the page objects before painting them the next time.
146 void InvalidatePageObjectVisibilities();
148 /** Return the window to which this view renders its output.
150 // ::boost::shared_ptr<sd::Window> GetWindow() const;
152 ::boost::shared_ptr
<cache::PageCache
> GetPreviewCache();
154 /** Set the bounding box of the insertion marker in model coordinates.
156 It will be painted as a dark rectangle that fills the given box.
158 void SetInsertionMarker (const Rectangle
& rBBox
);
160 /** Specify whether the insertion marker will be painted or not.
162 void SetInsertionMarkerVisibility (bool bVisible
);
164 /** Set the size and position of the selection rectangle.
166 It will be painted as a dashed rectangle.
168 void SetSelectionRectangle (const Rectangle
& rBox
);
170 /** Specify whether the selection rectangle will be painted or not.
172 void SetSelectionRectangleVisibility (bool bVisible
);
174 /** Return the range of currently visible page objects including the
175 first and last one in that range.
177 The returned pair of page object indices is empty when the
178 second index is lower than the first.
180 Pair
GetVisiblePageRange();
182 /** Add a shape to the page. Typically used from inside
185 // void AddSdrObject (SdrObject& rObject);
187 /** Add a listener that is called when the set of visible slides.
189 When this method is called multiple times for the same listener
190 the second and all following calls are ignored. Each listener
193 void AddVisibilityChangeListener (const Link
<>& rListener
);
195 /** Remove a listener that is called when the set of visible slides changes.
197 It is save to pass a listener that was not added or has been
198 removed previously. Such calls are ignored.
200 void RemoveVisibilityChangeListener (const Link
<>& rListener
);
202 /** The page under the mouse is not highlighted in some contexts. Call
203 this method on context changes.
205 void UpdatePageUnderMouse ();
206 void UpdatePageUnderMouse (const Point
& rMousePosition
);
207 void SetPageUnderMouse (const model::SharedPageDescriptor
& rpDescriptor
);
210 const model::SharedPageDescriptor
& rpDescriptor
,
211 const model::PageDescriptor::State eState
,
212 const bool bStateValue
);
214 void UpdateOrientation();
216 ::boost::shared_ptr
<PageObjectPainter
> GetPageObjectPainter();
217 ::boost::shared_ptr
<LayeredDevice
> GetLayeredDevice() const { return mpLayeredDevice
;}
222 DrawLock (SlideSorter
& rSlideSorter
);
224 /** When the DrawLock is disposed then it will not request a repaint
229 view::SlideSorterView
& mrView
;
230 VclPtr
<sd::Window
> mpWindow
;
233 ToolTip
& GetToolTip() const;
235 virtual void DragFinished (sal_Int8 nDropAction
) SAL_OVERRIDE
;
238 virtual void Notify (SfxBroadcaster
& rBroadcaster
, const SfxHint
& rHint
) SAL_OVERRIDE
;
241 SlideSorter
& mrSlideSorter
;
242 model::SlideSorterModel
& mrModel
;
244 ::std::unique_ptr
<Layouter
> mpLayouter
;
245 bool mbPageObjectVisibilitiesValid
;
246 ::boost::shared_ptr
<cache::PageCache
> mpPreviewCache
;
247 ::boost::shared_ptr
<LayeredDevice
> mpLayeredDevice
;
248 Range maVisiblePageRange
;
249 bool mbModelChangedWhileModifyEnabled
;
251 bool mbPreciousFlagUpdatePending
;
252 Layouter::Orientation meOrientation
;
253 ::boost::shared_ptr
<controller::Properties
> mpProperties
;
254 model::SharedPageDescriptor mpPageUnderMouse
;
255 sal_Int32 mnButtonUnderMouse
;
256 ::boost::shared_ptr
<PageObjectPainter
> mpPageObjectPainter
;
257 ::boost::shared_ptr
<SelectionPainter
> mpSelectionPainter
;
258 vcl::Region maRedrawRegion
;
259 SharedILayerPainter mpBackgroundPainter
;
260 ::boost::scoped_ptr
<ToolTip
> mpToolTip
;
261 bool mbIsRearrangePending
;
262 ::std::vector
<Link
<>> maVisibilityChangeListeners
;
264 /** Determine the visibility of all page objects.
266 void DeterminePageObjectVisibilities();
268 void UpdatePreciousFlags();
269 void RequestRearrange();
273 } } } // end of namespace ::sd::slidesorter::view
277 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */