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 : |*
46 : |* Basisklasse fuer alle Funktionen
47 : |*
48 : \************************************************************************/
49 :
50 : class FuPoor : public SimpleReferenceComponent
51 : {
52 : public:
53 : static const int HITPIX = 2; // Hit-Toleranz in Pixel
54 : static const int DRGPIX = 2; // Drag MinMove in Pixel
55 :
56 : TYPEINFO();
57 :
58 : virtual void DoExecute( SfxRequest& rReq );
59 :
60 0 : void SetMouseButtonCode(sal_uInt16 nNew) { if(nNew != mnCode) mnCode = nNew; }
61 0 : sal_uInt16 GetMouseButtonCode() const { return mnCode; }
62 :
63 0 : DrawDocShell* GetDocSh() { return mpDocSh; }
64 : SdDrawDocument* GetDoc() { return mpDoc; }
65 :
66 : virtual void DoCut();
67 : virtual void DoCopy();
68 : virtual void DoPaste();
69 :
70 : // Mouse- & Key-Events; Returnwert=sal_True: Event wurde bearbeitet
71 : virtual sal_Bool KeyInput(const KeyEvent& rKEvt);
72 : virtual sal_Bool MouseMove(const MouseEvent& );
73 : virtual sal_Bool MouseButtonUp(const MouseEvent& rMEvt);
74 :
75 : // moved from inline to *.cxx
76 : virtual sal_Bool MouseButtonDown(const MouseEvent& rMEvt);
77 :
78 : virtual sal_Bool Command(const CommandEvent& rCEvt);
79 : virtual sal_Bool RequestHelp(const HelpEvent& rHEvt);
80 : virtual void Paint(const Rectangle&, ::sd::Window* );
81 : virtual void ReceiveRequest(SfxRequest& rReq);
82 :
83 : virtual void Activate(); // Function aktivieren
84 : virtual void Deactivate(); // Function deaktivieren
85 :
86 0 : void SetWindow(::sd::Window* pWin) { mpWindow = pWin; }
87 :
88 : virtual void SelectionHasChanged();
89 :
90 0 : sal_uInt16 GetSlotID() const { return( nSlotId ); }
91 : sal_uInt16 GetSlotValue() const { return( nSlotValue ); }
92 :
93 : void SetNoScrollUntilInside(sal_Bool bNoScroll = sal_True)
94 : { bNoScrollUntilInside = bNoScroll; }
95 :
96 : void StartDelayToScrollTimer ();
97 :
98 : virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle);
99 :
100 : /** is called when the currenct function should be aborted. <p>
101 : This is used when a function gets a KEY_ESCAPE but can also
102 : be called directly.
103 :
104 : @returns true if a active function was aborted
105 : */
106 : virtual bool cancel();
107 :
108 : // #i33136#
109 : /** Decide if the object to be created should be created
110 : orthogonal. Default implementation uses nSlotID
111 : to decide. May be overloaded to use other criterias
112 : for this decision
113 :
114 : @returns true if the to be created object should be orthogonal.
115 : */
116 : virtual bool doConstructOrthogonal() const;
117 :
118 : protected:
119 : /**
120 : @param pViewSh
121 : May be NULL.
122 : */
123 : FuPoor (ViewShell* pViewSh,
124 : ::sd::Window* pWin,
125 : ::sd::View* pView,
126 : SdDrawDocument* pDoc,
127 : SfxRequest& rReq);
128 : virtual ~FuPoor (void);
129 :
130 : DECL_LINK( DelayHdl, void * );
131 :
132 : void ImpForceQuadratic(Rectangle& rRect);
133 :
134 : /** Switch to another layer. The layer to switch to is specified by an
135 : offset relative to the active layer. With respect to the layer bar
136 : control at the lower left of the document window positive values
137 : move to the right and negative values move to the left.
138 :
139 : <p>Switching the layer is independant of the view's layer mode. The
140 : layers are switched even when the layer mode is turned off and the
141 : layer control is not visible.</p>
142 : @param nOffset
143 : If the offset is positive skip that many layers in selecting the
144 : next layer. If it is negative then select a previous one. An
145 : offset or zero does not change the current layer. If the
146 : resulting index lies outside the valid range of indices then it
147 : is set to either the minimal or maximal valid index, whitchever
148 : is nearer.
149 : */
150 : void SwitchLayer (sal_Int32 nOffset);
151 :
152 : ::sd::View* mpView;
153 : ViewShell* mpViewShell;
154 : ::sd::Window* mpWindow;
155 : DrawDocShell* mpDocSh;
156 : SdDrawDocument* mpDoc;
157 :
158 : sal_uInt16 nSlotId;
159 : sal_uInt16 nSlotValue;
160 :
161 : Dialog* pDialog;
162 :
163 : Timer aScrollTimer; // fuer Autoscrolling
164 : DECL_LINK( ScrollHdl, void * );
165 : void ForceScroll(const Point& aPixPos);
166 :
167 : Timer aDragTimer; // fuer Drag&Drop
168 : DECL_LINK(DragHdl, void *);
169 : sal_Bool bIsInDragMode;
170 : Point aMDPos; // Position von MouseButtonDown
171 :
172 : // Flag, um AutoScrolling zu verhindern, bis von ausserhalb in das
173 : // Fenster hinein gedragt wurde
174 : sal_Bool bNoScrollUntilInside;
175 :
176 : // Timer um das scrolling zu verzoegern, wenn aus dem fenster
177 : // herausgedraggt wird (ca. 1 sec.)
178 : Timer aDelayToScrollTimer; // fuer Verzoegerung bis scroll
179 : sal_Bool bScrollable;
180 : sal_Bool bDelayActive;
181 : sal_Bool bFirstMouseMove;
182 :
183 : // member to hold state of the mouse buttons for creation
184 : // of own MouseEvents (like in ScrollHdl)
185 :
186 : private:
187 : sal_uInt16 mnCode;
188 :
189 : };
190 :
191 : typedef rtl::Reference< FuPoor > FunctionReference;
192 :
193 : } // end of namespace sd
194 :
195 : #endif // _SD_FUPOOR_HXX
196 :
197 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|