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