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