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_CONTROLLER_SLSSELECTIONFUNCTION_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLSSELECTIONFUNCTION_HXX
23 #include "model/SlsSharedPageDescriptor.hxx"
24 #include "controller/SlsFocusManager.hxx"
25 #include "controller/SlsInsertionIndicatorHandler.hxx"
27 #include <svtools/transfer.hxx>
28 #include <boost/noncopyable.hpp>
29 #include <boost/scoped_ptr.hpp>
31 namespace sd
{ namespace slidesorter
{
35 namespace sd
{ namespace slidesorter
{ namespace controller
{
37 class SlideSorterController
;
39 class SelectionFunction
41 private ::boost::noncopyable
46 static rtl::Reference
<FuPoor
> Create( SlideSorter
& rSlideSorter
, SfxRequest
& rRequest
);
48 // Mouse- & Key-Events
49 virtual bool KeyInput(const KeyEvent
& rKEvt
) SAL_OVERRIDE
;
50 virtual bool MouseMove(const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
51 virtual bool MouseButtonUp(const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
52 virtual bool MouseButtonDown(const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
54 virtual void Activate() SAL_OVERRIDE
;
55 virtual void Deactivate() SAL_OVERRIDE
;
57 /// Forward to the clipboard manager.
58 virtual void DoCut() SAL_OVERRIDE
;
60 /// Forward to the clipboard manager.
61 virtual void DoCopy() SAL_OVERRIDE
;
63 /// Forward to the clipboard manager.
64 virtual void DoPaste() SAL_OVERRIDE
;
66 /** is called when the current function should be aborted. <p>
67 This is used when a function gets a KEY_ESCAPE but can also
71 true if a active function was aborted
73 virtual bool cancel() SAL_OVERRIDE
;
76 const AcceptDropEvent
& rEvent
,
77 const sal_Int8 nDragAction
);
79 /** Turn of substitution display and insertion indicator.
81 void NotifyDragFinished();
83 /** Call when drag-and-drop or multi selection is started or stopped in
84 order to update permission of mouse over indication.
86 void UpdateMouseOverIndicationPermission();
88 class EventDescriptor
;
90 friend class ModeHandler
;
98 void SwitchToNormalMode();
99 void SwitchToDragAndDropMode(const Point
& rMousePosition
);
100 void SwitchToMultiSelectionMode (const Point
& rMousePosition
, const sal_uInt32 nEventCode
);
102 void ResetShiftKeySelectionAnchor();
103 /** Special case handling for when the context menu is hidden. This
104 method will reinitialize the current mouse position to prevent the
105 mouse motion during the time the context menu is displayed from
106 being interpreted as drag-and-drop start.
108 void ResetMouseAnchor();
111 SlideSorter
& mrSlideSorter
;
112 SlideSorterController
& mrController
;
115 SlideSorter
& rSlideSorter
,
116 SfxRequest
& rRequest
);
118 virtual ~SelectionFunction();
122 /// The rectangle of the mouse drag selection.
123 Rectangle maDragSelectionRectangle
;
124 bool mbDragSelection
;
126 /// Box of the insert marker in model coordinates.
127 Rectangle maInsertionMarkerBox
;
129 /** We use this flag to filter out the cases where MouseMotion() is called
130 with a pressed mouse button but without a prior MouseButtonDown()
131 call. This is an indication that the mouse button was pressed over
132 another control, e.g. the view tab bar, and that a re-layout of the
133 controls moved the slide sorter under the mouse.
135 bool mbProcessingMouseButtonDown
;
137 /** Remember the slide where the shift key was pressed and started a
138 multiselection via keyboard.
140 sal_Int32 mnShiftKeySelectionAnchor
;
142 /** The selection function can be in one of several mutually
145 ::boost::shared_ptr
<ModeHandler
> mpModeHandler
;
147 /** Make the slide nOffset slides away of the current one the new
148 current slide. When the new index is outside the range of valid
149 page numbers it is clipped to that range.
151 When nOffset is negative then go back. When nOffset if positive go
152 forward. When it is zero then ignore the call.
154 void GotoNextPage (int nOffset
);
156 /** Make the slide with the given index the new current slide.
158 Index of the new current slide. When the new index is outside
159 the range of valid page numbers it is clipped to that range.
161 void GotoPage (int nIndex
);
163 void ProcessMouseEvent (sal_uInt32 nEventType
, const MouseEvent
& rEvent
);
165 // What follows are a couple of helper methods that are used by
166 // ProcessMouseEvent().
168 void ProcessEvent (EventDescriptor
& rEvent
);
171 const FocusManager::FocusMoveDirection eDirection
,
172 const bool bIsShiftDown
,
173 const bool bIsControlDown
);
175 void StopDragAndDrop();
177 void SwitchMode (const ::boost::shared_ptr
<ModeHandler
>& rpHandler
);
180 } } } // end of namespace ::sd::slidesorter::controller
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */