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