Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef SD_FU_POOR_HXX
21 : #define SD_FU_POOR_HXX
22 :
23 : #include <tools/rtti.hxx>
24 : #include <vcl/timer.hxx>
25 : #include <tools/link.hxx>
26 : #include <tools/gen.hxx>
27 : #include <vcl/event.hxx>
28 : #include <rtl/ref.hxx>
29 :
30 : #include "helper/simplereferencecomponent.hxx"
31 :
32 : class SdDrawDocument;
33 : class SfxRequest;
34 : class Dialog;
35 : class SdrObject;
36 :
37 : namespace sd {
38 :
39 : class DrawDocShell;
40 : class View;
41 : class ViewShell;
42 : class Window;
43 :
44 : /**
45 : * Base class for all functions
46 : */
47 : class FuPoor : public SimpleReferenceComponent
48 : {
49 : public:
50 : static const int HITPIX = 2; // Hit-Toleranz in Pixel
51 : static const int DRGPIX = 2; // Drag MinMove in Pixel
52 :
53 : TYPEINFO();
54 :
55 : virtual void DoExecute( SfxRequest& rReq );
56 :
57 0 : void SetMouseButtonCode(sal_uInt16 nNew) { if(nNew != mnCode) mnCode = nNew; }
58 0 : sal_uInt16 GetMouseButtonCode() const { return mnCode; }
59 :
60 0 : DrawDocShell* GetDocSh() { return mpDocSh; }
61 : SdDrawDocument* GetDoc() { return mpDoc; }
62 :
63 : virtual void DoCut();
64 : virtual void DoCopy();
65 : virtual void DoPaste();
66 :
67 : // Mouse- & Key-Events; Returnwert=sal_True: Event wurde bearbeitet
68 : virtual sal_Bool KeyInput(const KeyEvent& rKEvt);
69 : virtual sal_Bool MouseMove(const MouseEvent& );
70 : virtual sal_Bool MouseButtonUp(const MouseEvent& rMEvt);
71 :
72 : // moved from inline to *.cxx
73 : virtual sal_Bool MouseButtonDown(const MouseEvent& rMEvt);
74 :
75 : virtual sal_Bool Command(const CommandEvent& rCEvt);
76 : virtual sal_Bool RequestHelp(const HelpEvent& rHEvt);
77 : virtual void Paint(const Rectangle&, ::sd::Window* );
78 : virtual void ReceiveRequest(SfxRequest& rReq);
79 :
80 : virtual void Activate(); ///< activates the function
81 : virtual void Deactivate(); ///< deactivates the function
82 :
83 376 : void SetWindow(::sd::Window* pWin) { mpWindow = pWin; }
84 :
85 : virtual void SelectionHasChanged();
86 :
87 6888 : sal_uInt16 GetSlotID() const { return( nSlotId ); }
88 : sal_uInt16 GetSlotValue() const { return( nSlotValue ); }
89 :
90 : void SetNoScrollUntilInside(sal_Bool bNoScroll = sal_True)
91 : { bNoScrollUntilInside = bNoScroll; }
92 :
93 : void StartDelayToScrollTimer ();
94 :
95 : virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle);
96 :
97 : /** is called when the currenct function should be aborted. <p>
98 : This is used when a function gets a KEY_ESCAPE but can also
99 : be called directly.
100 :
101 : @returns true if a active function was aborted
102 : */
103 : virtual bool cancel();
104 :
105 : // #i33136#
106 : /** Decide if the object to be created should be created
107 : orthogonal. Default implementation uses nSlotID
108 : to decide. May be overloaded to use other criterias
109 : for this decision
110 :
111 : @returns true if the to be created object should be orthogonal.
112 : */
113 : virtual bool doConstructOrthogonal() const;
114 :
115 : protected:
116 : /**
117 : @param pViewSh
118 : May be NULL.
119 : */
120 : FuPoor (ViewShell* pViewSh,
121 : ::sd::Window* pWin,
122 : ::sd::View* pView,
123 : SdDrawDocument* pDoc,
124 : SfxRequest& rReq);
125 : virtual ~FuPoor (void);
126 :
127 : DECL_LINK( DelayHdl, void * );
128 :
129 : void ImpForceQuadratic(Rectangle& rRect);
130 :
131 : /** Switch to another layer. The layer to switch to is specified by an
132 : offset relative to the active layer. With respect to the layer bar
133 : control at the lower left of the document window positive values
134 : move to the right and negative values move to the left.
135 :
136 : <p>Switching the layer is independent of the view's layer mode. The
137 : layers are switched even when the layer mode is turned off and the
138 : layer control is not visible.</p>
139 : @param nOffset
140 : If the offset is positive skip that many layers in selecting the
141 : next layer. If it is negative then select a previous one. An
142 : offset or zero does not change the current layer. If the
143 : resulting index lies outside the valid range of indices then it
144 : is set to either the minimal or maximal valid index, whitchever
145 : is nearer.
146 : */
147 : void SwitchLayer (sal_Int32 nOffset);
148 :
149 : ::sd::View* mpView;
150 : ViewShell* mpViewShell;
151 : ::sd::Window* mpWindow;
152 : DrawDocShell* mpDocSh;
153 : SdDrawDocument* mpDoc;
154 :
155 : sal_uInt16 nSlotId;
156 : sal_uInt16 nSlotValue;
157 :
158 : Dialog* pDialog;
159 :
160 : Timer aScrollTimer; ///< for auto-scrolling
161 : DECL_LINK( ScrollHdl, void * );
162 : void ForceScroll(const Point& aPixPos);
163 :
164 : Timer aDragTimer; ///< for Drag&Drop
165 : DECL_LINK(DragHdl, void *);
166 : sal_Bool bIsInDragMode;
167 : Point aMDPos; ///< position of MouseButtonDown
168 :
169 : /// Flag to prevent auto-scrolling until one drags from outside into the window
170 : sal_Bool bNoScrollUntilInside;
171 :
172 : /// timer to delay scrolling (~ 1 sec) when dragging out of the window
173 : Timer aDelayToScrollTimer;
174 : sal_Bool bScrollable;
175 : sal_Bool bDelayActive;
176 : sal_Bool bFirstMouseMove;
177 :
178 : /// member to hold state of the mouse buttons for creation of own MouseEvents (like in ScrollHdl)
179 :
180 : private:
181 : sal_uInt16 mnCode;
182 :
183 : };
184 :
185 : typedef rtl::Reference< FuPoor > FunctionReference;
186 :
187 : } // end of namespace sd
188 :
189 : #endif // _SD_FUPOOR_HXX
190 :
191 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|