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: SlsSelectionFunction.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_SELECTION_FUNCTION_HXX
32 #define SD_SLIDESORTER_SELECTION_FUNCTION_HXX
34 #include "controller/SlsSlideFunction.hxx"
35 #include "model/SlsSharedPageDescriptor.hxx"
36 #include <tools/list.hxx>
39 class SdSlideViewShell
;
45 namespace sd
{ namespace slidesorter
{
49 namespace sd
{ namespace slidesorter
{ namespace controller
{
51 class SlideSorterController
;
53 class SelectionFunction
54 : public SlideFunction
59 static FunctionReference
Create( SlideSorter
& rSlideSorter
, SfxRequest
& rRequest
);
61 // Mouse- & Key-Events
62 virtual BOOL
KeyInput(const KeyEvent
& rKEvt
);
63 virtual BOOL
MouseMove(const MouseEvent
& rMEvt
);
64 virtual BOOL
MouseButtonUp(const MouseEvent
& rMEvt
);
65 virtual BOOL
MouseButtonDown(const MouseEvent
& rMEvt
);
66 virtual void Paint(const Rectangle
&, ::sd::Window
* );
68 virtual void Activate(); // Function aktivieren
69 virtual void Deactivate(); // Function deaktivieren
71 virtual void ScrollStart();
72 virtual void ScrollEnd();
74 /// Forward to the clipboard manager.
75 virtual void DoCut (void);
77 /// Forward to the clipboard manager.
78 virtual void DoCopy (void);
80 /// Forward to the clipboard manager.
81 virtual void DoPaste (void);
83 /** is called when the current function should be aborted. <p>
84 This is used when a function gets a KEY_ESCAPE but can also
88 true if a active function was aborted
90 virtual bool cancel();
93 SlideSorter
& mrSlideSorter
;
94 SlideSorterController
& mrController
;
97 SlideSorter
& rSlideSorter
,
98 SfxRequest
& rRequest
);
100 virtual ~SelectionFunction();
103 class SubstitutionHandler
;
104 class EventDescriptor
;
105 class InsertionIndicatorHandler
;
107 /// Set in MouseButtonDown this flag indicates that a page has been hit.
110 /// The rectangle of the mouse drag selection.
111 Rectangle maDragSelectionRectangle
;
112 bool mbDragSelection
;
114 /// Box of the insert marker in model coordinates.
115 Rectangle maInsertionMarkerBox
;
117 /** We use this flag to filter out the cases where MouseMotion() is called
118 with a pressed mouse button but without a prior MouseButtonDown()
119 call. This is an indication that the mouse button was pressed over
120 another control, e.g. the view tab bar, and that a re-layout of the
121 controls moved the slide sorter under the mouse.
123 bool mbProcessingMouseButtonDown
;
125 ::std::auto_ptr
<SubstitutionHandler
> mpSubstitutionHandler
;
127 ::std::auto_ptr
<InsertionIndicatorHandler
> mpInsertionIndicatorHandler
;
129 DECL_LINK( DragSlideHdl
, Timer
* );
130 void StartDrag (void);
132 /** Set the selection to exactly the specified page and also set it as
135 void SetCurrentPage (const model::SharedPageDescriptor
& rpDescriptor
);
137 /** When the view on which this selection function is working is the
138 main view then the view is switched to the regular editing view.
140 void SwitchView (const model::SharedPageDescriptor
& rpDescriptor
);
142 /** Make the slide nOffset slides away of the current one the new
143 current slide. When the new index is outside the range of valid
144 page numbers it is clipped to that range.
146 When nOffset is negative then go back. When nOffset if positive go
147 forward. When it is zero then ignore the call.
149 void GotoNextPage (int nOffset
);
151 void ProcessMouseEvent (sal_uInt32 nEventType
, const MouseEvent
& rEvent
);
152 void ProcessKeyEvent (const KeyEvent
& rEvent
);
154 // What follows are a couple of helper methods that are used by
155 // ProcessMouseEvent().
157 /// Select the specified page and set the selection anchor.
158 void SelectHitPage (const model::SharedPageDescriptor
& rpDescriptor
);
159 /// Deselect the specified page.
160 void DeselectHitPage (const model::SharedPageDescriptor
& rpDescriptor
);
161 /// Deselect all pages.
162 void DeselectAllPages (void);
164 /** for a possibly following mouse motion by starting the drag timer
165 that after a short time of pressed but un-moved mouse starts a drag
168 void PrepareMouseMotion (const Point
& aMouseModelPosition
);
170 /** Select all pages between and including the selection anchor and the
173 void RangeSelect (const model::SharedPageDescriptor
& rpDescriptor
);
175 /** Start a rectangle selection at the given position.
177 void StartRectangleSelection (const Point
& aMouseModelPosition
);
179 /** Update the rectangle selection so that the given position becomes
180 the new second point of the selection rectangle.
182 void UpdateRectangleSelection (const Point
& aMouseModelPosition
);
184 /** Select all pages that lie completly in the selection rectangle.
186 void ProcessRectangleSelection (bool bToggleSelection
);
188 /** Hide and clear the insertion indiciator, substitution display and
191 void ClearOverlays (void);
193 /** Compute a numerical code that describes a mouse event and that can
194 be used for fast look up of the appropriate reaction.
196 sal_uInt32
EncodeMouseEvent (
197 const EventDescriptor
& rDescriptor
,
198 const MouseEvent
& rEvent
) const;
200 /** Compute a numerical code that describes a key event and that can
201 be used for fast look up of the appropriate reaction.
203 sal_uInt32
EncodeKeyEvent (
204 const EventDescriptor
& rDescriptor
,
205 const KeyEvent
& rEvent
) const;
207 void EventPreprocessing (const EventDescriptor
& rEvent
);
208 bool EventProcessing (const EventDescriptor
& rEvent
);
209 void EventPostprocessing (const EventDescriptor
& rEvent
);
212 } } } // end of namespace ::sd::slidesorter::controller