Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SD_FU_POOR_HXX
30 : : #define SD_FU_POOR_HXX
31 : :
32 : : #include <tools/rtti.hxx>
33 : : #include <vcl/timer.hxx>
34 : : #include <tools/link.hxx>
35 : : #include <tools/gen.hxx>
36 : : #include <vcl/event.hxx>
37 : : #include <rtl/ref.hxx>
38 : :
39 : : #include "helper/simplereferencecomponent.hxx"
40 : :
41 : : class SdDrawDocument;
42 : : class SfxRequest;
43 : : class Dialog;
44 : : class SdrObject;
45 : :
46 : : namespace sd {
47 : :
48 : : class DrawDocShell;
49 : : class View;
50 : : class ViewShell;
51 : : class Window;
52 : :
53 : : /*************************************************************************
54 : : |*
55 : : |* Basisklasse fuer alle Funktionen
56 : : |*
57 : : \************************************************************************/
58 : :
59 : : class FuPoor : public SimpleReferenceComponent
60 : : {
61 : : public:
62 : : static const int HITPIX = 2; // Hit-Toleranz in Pixel
63 : : static const int DRGPIX = 2; // Drag MinMove in Pixel
64 : :
65 : : TYPEINFO();
66 : :
67 : : virtual void DoExecute( SfxRequest& rReq );
68 : :
69 [ # # ]: 0 : void SetMouseButtonCode(sal_uInt16 nNew) { if(nNew != mnCode) mnCode = nNew; }
70 : 0 : sal_uInt16 GetMouseButtonCode() const { return mnCode; }
71 : :
72 : 0 : DrawDocShell* GetDocSh() { return mpDocSh; }
73 : : SdDrawDocument* GetDoc() { return mpDoc; }
74 : :
75 : : virtual void DoCut();
76 : : virtual void DoCopy();
77 : : virtual void DoPaste();
78 : :
79 : : // Mouse- & Key-Events; Returnwert=sal_True: Event wurde bearbeitet
80 : : virtual sal_Bool KeyInput(const KeyEvent& rKEvt);
81 : : virtual sal_Bool MouseMove(const MouseEvent& );
82 : : virtual sal_Bool MouseButtonUp(const MouseEvent& rMEvt);
83 : :
84 : : // moved from inline to *.cxx
85 : : virtual sal_Bool MouseButtonDown(const MouseEvent& rMEvt);
86 : :
87 : : virtual sal_Bool Command(const CommandEvent& rCEvt);
88 : : virtual sal_Bool RequestHelp(const HelpEvent& rHEvt);
89 : : virtual void Paint(const Rectangle&, ::sd::Window* );
90 : : virtual void ReceiveRequest(SfxRequest& rReq);
91 : :
92 : : virtual void Activate(); // Function aktivieren
93 : : virtual void Deactivate(); // Function deaktivieren
94 : :
95 : 766 : void SetWindow(::sd::Window* pWin) { mpWindow = pWin; }
96 : :
97 : : virtual void SelectionHasChanged();
98 : :
99 : 13446 : sal_uInt16 GetSlotID() const { return( nSlotId ); }
100 : : sal_uInt16 GetSlotValue() const { return( nSlotValue ); }
101 : :
102 : : void SetNoScrollUntilInside(sal_Bool bNoScroll = sal_True)
103 : : { bNoScrollUntilInside = bNoScroll; }
104 : :
105 : : void StartDelayToScrollTimer ();
106 : :
107 : : virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle);
108 : :
109 : : /** is called when the currenct function should be aborted. <p>
110 : : This is used when a function gets a KEY_ESCAPE but can also
111 : : be called directly.
112 : :
113 : : @returns true if a active function was aborted
114 : : */
115 : : virtual bool cancel();
116 : :
117 : : // #i33136#
118 : : /** Decide if the object to be created should be created
119 : : orthogonal. Default implementation uses nSlotID
120 : : to decide. May be overloaded to use other criterias
121 : : for this decision
122 : :
123 : : @returns true if the to be created object should be orthogonal.
124 : : */
125 : : virtual bool doConstructOrthogonal() const;
126 : :
127 : : protected:
128 : : /**
129 : : @param pViewSh
130 : : May be NULL.
131 : : */
132 : : FuPoor (ViewShell* pViewSh,
133 : : ::sd::Window* pWin,
134 : : ::sd::View* pView,
135 : : SdDrawDocument* pDoc,
136 : : SfxRequest& rReq);
137 : : virtual ~FuPoor (void);
138 : :
139 : : DECL_LINK( DelayHdl, void * );
140 : :
141 : : void ImpForceQuadratic(Rectangle& rRect);
142 : :
143 : : /** Switch to another layer. The layer to switch to is specified by an
144 : : offset relative to the active layer. With respect to the layer bar
145 : : control at the lower left of the document window positive values
146 : : move to the right and negative values move to the left.
147 : :
148 : : <p>Switching the layer is independant of the view's layer mode. The
149 : : layers are switched even when the layer mode is turned off and the
150 : : layer control is not visible.</p>
151 : : @param nOffset
152 : : If the offset is positive skip that many layers in selecting the
153 : : next layer. If it is negative then select a previous one. An
154 : : offset or zero does not change the current layer. If the
155 : : resulting index lies outside the valid range of indices then it
156 : : is set to either the minimal or maximal valid index, whitchever
157 : : is nearer.
158 : : */
159 : : void SwitchLayer (sal_Int32 nOffset);
160 : :
161 : : ::sd::View* mpView;
162 : : ViewShell* mpViewShell;
163 : : ::sd::Window* mpWindow;
164 : : DrawDocShell* mpDocSh;
165 : : SdDrawDocument* mpDoc;
166 : :
167 : : sal_uInt16 nSlotId;
168 : : sal_uInt16 nSlotValue;
169 : :
170 : : Dialog* pDialog;
171 : :
172 : : Timer aScrollTimer; // fuer Autoscrolling
173 : : DECL_LINK( ScrollHdl, void * );
174 : : void ForceScroll(const Point& aPixPos);
175 : :
176 : : Timer aDragTimer; // fuer Drag&Drop
177 : : DECL_LINK(DragHdl, void *);
178 : : sal_Bool bIsInDragMode;
179 : : Point aMDPos; // Position von MouseButtonDown
180 : :
181 : : // Flag, um AutoScrolling zu verhindern, bis von ausserhalb in das
182 : : // Fenster hinein gedragt wurde
183 : : sal_Bool bNoScrollUntilInside;
184 : :
185 : : // Timer um das scrolling zu verzoegern, wenn aus dem fenster
186 : : // herausgedraggt wird (ca. 1 sec.)
187 : : Timer aDelayToScrollTimer; // fuer Verzoegerung bis scroll
188 : : sal_Bool bScrollable;
189 : : sal_Bool bDelayActive;
190 : : sal_Bool bFirstMouseMove;
191 : :
192 : : // member to hold state of the mouse buttons for creation
193 : : // of own MouseEvents (like in ScrollHdl)
194 : :
195 : : private:
196 : : sal_uInt16 mnCode;
197 : :
198 : : };
199 : :
200 : : typedef rtl::Reference< FuPoor > FunctionReference;
201 : :
202 : : } // end of namespace sd
203 : :
204 : : #endif // _SD_FUPOOR_HXX
205 : :
206 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|