bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / inc / fupoor.hxx
blob1e79d6a6336b37662439368439644132969dfc51
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_INC_FUPOOR_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_FUPOOR_HXX
23 #include <vcl/timer.hxx>
24 #include <tools/link.hxx>
25 #include <tools/gen.hxx>
26 #include <vcl/vclptr.hxx>
27 #include <svx/svdobj.hxx>
29 #include <helper/simplereferencecomponent.hxx>
31 class SdDrawDocument;
32 class SfxRequest;
33 class CommandEvent;
34 class HelpEvent;
35 class KeyEvent;
36 class MouseEvent;
38 namespace sd {
40 class DrawDocShell;
41 class View;
42 class ViewShell;
43 class Window;
45 /**
46 * Base class for all functions
48 class FuPoor : public SimpleReferenceComponent
50 public:
51 static const int HITPIX = 2; // hit tolerance in pixel
52 static const int HITLOG = 53; // hit tolerance in mm100
53 static const int DRGPIX = 2; // minimal drag move in pixel
54 static const int DRGLOG = 53; // minimal drag move in mm100
57 virtual void DoExecute( SfxRequest& rReq );
59 void SetMouseButtonCode(sal_uInt16 nNew) { if(nNew != mnCode) mnCode = nNew; }
60 sal_uInt16 GetMouseButtonCode() const { return mnCode; }
62 DrawDocShell* GetDocSh() { return mpDocSh; }
64 virtual void DoCut();
65 virtual void DoCopy();
66 virtual void DoPaste();
67 virtual void DoPasteUnformatted();
69 // mouse & key events; return value = sal_True: event has been handled
70 virtual bool KeyInput(const KeyEvent& rKEvt);
71 virtual bool MouseMove(const MouseEvent& );
72 virtual bool MouseButtonUp(const MouseEvent& rMEvt);
74 // moved from inline to *.cxx
75 virtual bool MouseButtonDown(const MouseEvent& rMEvt);
77 virtual bool Command(const CommandEvent& rCEvt);
78 virtual bool RequestHelp(const HelpEvent& rHEvt);
79 virtual void ReceiveRequest(SfxRequest& rReq);
81 virtual void Activate(); ///< activates the function
82 virtual void Deactivate(); ///< deactivates the function
84 void SetWindow(::sd::Window* pWin);
86 virtual void SelectionHasChanged();
88 sal_uInt16 GetSlotID() const { return nSlotId; }
90 void StartDelayToScrollTimer ();
92 virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle);
94 /** is called when the current function should be aborted. <p>
95 This is used when a function gets a KEY_ESCAPE but can also
96 be called directly.
98 @returns true if a active function was aborted
100 virtual bool cancel();
102 // #i33136#
103 /** Decide if the object to be created should be created
104 orthogonal. Default implementation uses nSlotID
105 to decide. May be overridden to use other criteria
106 for this decision
108 @returns true if the to be created object should be orthogonal.
110 virtual bool doConstructOrthogonal() const;
112 protected:
114 @param pViewSh
115 May be NULL.
117 FuPoor (ViewShell* pViewSh,
118 ::sd::Window* pWin,
119 ::sd::View* pView,
120 SdDrawDocument* pDoc,
121 SfxRequest& rReq);
122 virtual ~FuPoor() override;
124 DECL_LINK( DelayHdl, Timer *, void );
126 static void ImpForceQuadratic(::tools::Rectangle& rRect);
128 /** Switch to another layer. The layer to switch to is specified by an
129 offset relative to the active layer. With respect to the layer bar
130 control at the lower left of the document window positive values
131 move to the right and negative values move to the left.
133 <p>Switching the layer is independent of the view's layer mode. The
134 layers are switched even when the layer mode is turned off and the
135 layer control is not visible.</p>
136 @param nOffset
137 If the offset is positive skip that many layers in selecting the
138 next layer. If it is negative then select a previous one. An
139 offset or zero does not change the current layer. If the
140 resulting index lies outside the valid range of indices then it
141 is set to either the minimal or maximal valid index, whichever
142 is nearer.
144 void SwitchLayer (sal_Int32 nOffset);
146 ::sd::View* mpView;
147 ViewShell* mpViewShell;
148 VclPtr< ::sd::Window> mpWindow;
149 DrawDocShell* mpDocSh;
150 SdDrawDocument* mpDoc;
152 sal_uInt16 nSlotId;
154 Timer aScrollTimer; ///< for auto-scrolling
155 DECL_LINK( ScrollHdl, Timer *, void );
156 void ForceScroll(const Point& aPixPos);
158 Timer aDragTimer; ///< for Drag&Drop
159 DECL_LINK(DragHdl, Timer *, void);
160 bool bIsInDragMode;
161 Point aMDPos; ///< position of MouseButtonDown
163 /// Flag to prevent auto-scrolling until one drags from outside into the window
164 bool bNoScrollUntilInside;
166 /// timer to delay scrolling (~ 1 sec) when dragging out of the window
167 Timer aDelayToScrollTimer;
168 bool bScrollable;
169 bool bDelayActive;
170 bool bFirstMouseMove;
172 /// member to hold state of the mouse buttons for creation of own MouseEvents (like in ScrollHdl)
174 private:
175 sal_uInt16 mnCode;
179 } // end of namespace sd
181 #endif // _SD_FUPOOR_HXX
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */