xref: /AOO41X/main/vcl/source/window/seleng.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_vcl.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <tools/ref.hxx>
32*cdf0e10cSrcweir #include <vcl/window.hxx>
33*cdf0e10cSrcweir #include <vcl/seleng.hxx>
34*cdf0e10cSrcweir #include <tools/debug.hxx>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir inline sal_Bool SelectionEngine::ShouldDeselect( sal_Bool bModifierKey1 ) const
40*cdf0e10cSrcweir {
41*cdf0e10cSrcweir //	return !( eSelMode == MULTIPLE_SELECTION && bModifierKey1 );
42*cdf0e10cSrcweir 	return eSelMode != MULTIPLE_SELECTION || !bModifierKey1;
43*cdf0e10cSrcweir }
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir // TODO: FunctionSet::SelectAtPoint raus
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir /*************************************************************************
49*cdf0e10cSrcweir |*
50*cdf0e10cSrcweir |*    SelectionEngine::SelectionEngine()
51*cdf0e10cSrcweir |*
52*cdf0e10cSrcweir |*    Beschreibung      SELENG.SDW
53*cdf0e10cSrcweir |*    Ersterstellung    OV 10.10.94
54*cdf0e10cSrcweir |*    Letzte Aenderung  OV 10.10.94
55*cdf0e10cSrcweir |*
56*cdf0e10cSrcweir *************************************************************************/
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir SelectionEngine::SelectionEngine( Window* pWindow, FunctionSet* pFuncSet ) :
59*cdf0e10cSrcweir                     pWin( pWindow )
60*cdf0e10cSrcweir {
61*cdf0e10cSrcweir     eSelMode = SINGLE_SELECTION;
62*cdf0e10cSrcweir     pFunctionSet = pFuncSet;
63*cdf0e10cSrcweir     nFlags = SELENG_EXPANDONMOVE;
64*cdf0e10cSrcweir     nLockedMods = 0;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir     aWTimer.SetTimeoutHdl( LINK( this, SelectionEngine, ImpWatchDog ) );
67*cdf0e10cSrcweir     aWTimer.SetTimeout( SELENG_AUTOREPEAT_INTERVAL );
68*cdf0e10cSrcweir }
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir /*************************************************************************
71*cdf0e10cSrcweir |*
72*cdf0e10cSrcweir |*    SelectionEngine::~SelectionEngine()
73*cdf0e10cSrcweir |*
74*cdf0e10cSrcweir |*    Beschreibung      SELENG.SDW
75*cdf0e10cSrcweir |*    Ersterstellung    OV 10.10.94
76*cdf0e10cSrcweir |*    Letzte Aenderung  OV 10.10.94
77*cdf0e10cSrcweir |*
78*cdf0e10cSrcweir *************************************************************************/
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir SelectionEngine::~SelectionEngine()
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir     aWTimer.Stop();
83*cdf0e10cSrcweir }
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir /*************************************************************************
86*cdf0e10cSrcweir |*
87*cdf0e10cSrcweir |*    SelectionEngine::ImpWatchDog()
88*cdf0e10cSrcweir |*
89*cdf0e10cSrcweir |*    Beschreibung      SELENG.SDW
90*cdf0e10cSrcweir |*    Ersterstellung    OV 10.10.94
91*cdf0e10cSrcweir |*    Letzte Aenderung  OV 10.10.94
92*cdf0e10cSrcweir |*
93*cdf0e10cSrcweir *************************************************************************/
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir IMPL_LINK( SelectionEngine, ImpWatchDog, Timer*, EMPTYARG )
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir     if ( !aArea.IsInside( aLastMove.GetPosPixel() ) )
98*cdf0e10cSrcweir         SelMouseMove( aLastMove );
99*cdf0e10cSrcweir     return 0;
100*cdf0e10cSrcweir }
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir /*************************************************************************
103*cdf0e10cSrcweir |*
104*cdf0e10cSrcweir |*    SelectionEngine::SetSelectionMode()
105*cdf0e10cSrcweir |*
106*cdf0e10cSrcweir |*    Beschreibung      SELENG.SDW
107*cdf0e10cSrcweir |*    Ersterstellung    OV 10.10.94
108*cdf0e10cSrcweir |*    Letzte Aenderung  OV 10.10.94
109*cdf0e10cSrcweir |*
110*cdf0e10cSrcweir *************************************************************************/
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir void SelectionEngine::SetSelectionMode( SelectionMode eMode )
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir     eSelMode = eMode;
115*cdf0e10cSrcweir }
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir /*************************************************************************
118*cdf0e10cSrcweir |*
119*cdf0e10cSrcweir |*    SelectionEngine::ActivateDragMode()
120*cdf0e10cSrcweir |*
121*cdf0e10cSrcweir |*    Beschreibung      SELENG.SDW
122*cdf0e10cSrcweir |*    Ersterstellung    OV 10.10.94
123*cdf0e10cSrcweir |*    Letzte Aenderung  OV 10.10.94
124*cdf0e10cSrcweir |*
125*cdf0e10cSrcweir *************************************************************************/
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir void SelectionEngine::ActivateDragMode()
128*cdf0e10cSrcweir {
129*cdf0e10cSrcweir     DBG_ERRORFILE( "SelectionEngine::ActivateDragMode not implemented" );
130*cdf0e10cSrcweir }
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir /*************************************************************************
133*cdf0e10cSrcweir |*
134*cdf0e10cSrcweir |*    SelectionEngine::CursorPosChanging()
135*cdf0e10cSrcweir |*
136*cdf0e10cSrcweir |*    Beschreibung      SELENG.SDW
137*cdf0e10cSrcweir |*    Ersterstellung    OV 10.10.94
138*cdf0e10cSrcweir |*    Letzte Aenderung  GT 2002-04-04
139*cdf0e10cSrcweir |*
140*cdf0e10cSrcweir *************************************************************************/
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir void SelectionEngine::CursorPosChanging( sal_Bool bShift, sal_Bool bMod1 )
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir     if ( !pFunctionSet )
145*cdf0e10cSrcweir         return;
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir     if ( bShift && eSelMode != SINGLE_SELECTION )
148*cdf0e10cSrcweir     {
149*cdf0e10cSrcweir         if ( IsAddMode() )
150*cdf0e10cSrcweir         {
151*cdf0e10cSrcweir             if ( !(nFlags & SELENG_HAS_ANCH) )
152*cdf0e10cSrcweir             {
153*cdf0e10cSrcweir                 pFunctionSet->CreateAnchor();
154*cdf0e10cSrcweir                 nFlags |= SELENG_HAS_ANCH;
155*cdf0e10cSrcweir             }
156*cdf0e10cSrcweir         }
157*cdf0e10cSrcweir         else
158*cdf0e10cSrcweir         {
159*cdf0e10cSrcweir             if ( !(nFlags & SELENG_HAS_ANCH) )
160*cdf0e10cSrcweir             {
161*cdf0e10cSrcweir                 if( ShouldDeselect( bMod1 ) )
162*cdf0e10cSrcweir                     pFunctionSet->DeselectAll();
163*cdf0e10cSrcweir                 pFunctionSet->CreateAnchor();
164*cdf0e10cSrcweir                 nFlags |= SELENG_HAS_ANCH;
165*cdf0e10cSrcweir             }
166*cdf0e10cSrcweir         }
167*cdf0e10cSrcweir     }
168*cdf0e10cSrcweir     else
169*cdf0e10cSrcweir     {
170*cdf0e10cSrcweir         if ( IsAddMode() )
171*cdf0e10cSrcweir         {
172*cdf0e10cSrcweir             if ( nFlags & SELENG_HAS_ANCH )
173*cdf0e10cSrcweir             {
174*cdf0e10cSrcweir                 // pFunctionSet->CreateCursor();
175*cdf0e10cSrcweir 				pFunctionSet->DestroyAnchor();
176*cdf0e10cSrcweir                 nFlags &= (~SELENG_HAS_ANCH);
177*cdf0e10cSrcweir             }
178*cdf0e10cSrcweir         }
179*cdf0e10cSrcweir         else
180*cdf0e10cSrcweir         {
181*cdf0e10cSrcweir             if( ShouldDeselect( bMod1 ) )
182*cdf0e10cSrcweir                 pFunctionSet->DeselectAll();
183*cdf0e10cSrcweir 			else
184*cdf0e10cSrcweir 				pFunctionSet->DestroyAnchor();
185*cdf0e10cSrcweir             nFlags &= (~SELENG_HAS_ANCH);
186*cdf0e10cSrcweir         }
187*cdf0e10cSrcweir     }
188*cdf0e10cSrcweir }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir /*************************************************************************
191*cdf0e10cSrcweir |*
192*cdf0e10cSrcweir |*    SelectionEngine::SelMouseButtonDown()
193*cdf0e10cSrcweir |*
194*cdf0e10cSrcweir |*    Beschreibung      SELENG.SDW
195*cdf0e10cSrcweir |*    Ersterstellung    OV 10.10.94
196*cdf0e10cSrcweir |*    Letzte Aenderung  OV 07.06.95
197*cdf0e10cSrcweir |*
198*cdf0e10cSrcweir *************************************************************************/
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir sal_Bool SelectionEngine::SelMouseButtonDown( const MouseEvent& rMEvt )
201*cdf0e10cSrcweir {
202*cdf0e10cSrcweir     nFlags &= (~SELENG_CMDEVT);
203*cdf0e10cSrcweir     if ( !pFunctionSet || !pWin || rMEvt.GetClicks() > 1 || rMEvt.IsRight() )
204*cdf0e10cSrcweir         return sal_False;
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir     sal_uInt16 nModifier = rMEvt.GetModifier() | nLockedMods;
207*cdf0e10cSrcweir     if ( nModifier & KEY_MOD2 )
208*cdf0e10cSrcweir         return sal_False;
209*cdf0e10cSrcweir     // in SingleSelection: Control-Taste filtern (damit auch
210*cdf0e10cSrcweir     // mit Ctrl-Click ein D&D gestartet werden kann)
211*cdf0e10cSrcweir     if ( nModifier == KEY_MOD1 && eSelMode == SINGLE_SELECTION )
212*cdf0e10cSrcweir         nModifier = 0;
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir     Point aPos = rMEvt.GetPosPixel();
215*cdf0e10cSrcweir     aLastMove = rMEvt;
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir 	if( !rMEvt.IsRight() )
218*cdf0e10cSrcweir 	{
219*cdf0e10cSrcweir 	    pWin->CaptureMouse();
220*cdf0e10cSrcweir 		nFlags |= SELENG_IN_SEL;
221*cdf0e10cSrcweir 	}
222*cdf0e10cSrcweir 	else
223*cdf0e10cSrcweir 	{
224*cdf0e10cSrcweir 		nModifier = 0;
225*cdf0e10cSrcweir 	}
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir     switch ( nModifier )
228*cdf0e10cSrcweir     {
229*cdf0e10cSrcweir         case 0:     // KEY_NO_KEY
230*cdf0e10cSrcweir         {
231*cdf0e10cSrcweir             sal_Bool bSelAtPoint = pFunctionSet->IsSelectionAtPoint( aPos );
232*cdf0e10cSrcweir             nFlags &= (~SELENG_IN_ADD);
233*cdf0e10cSrcweir             if ( (nFlags & SELENG_DRG_ENAB) && bSelAtPoint )
234*cdf0e10cSrcweir             {
235*cdf0e10cSrcweir                 nFlags |= SELENG_WAIT_UPEVT;
236*cdf0e10cSrcweir                 nFlags &= ~(SELENG_IN_SEL);
237*cdf0e10cSrcweir                 pWin->ReleaseMouse();
238*cdf0e10cSrcweir                 return sal_True;  //auf STARTDRAG-Command-Event warten
239*cdf0e10cSrcweir             }
240*cdf0e10cSrcweir             if ( eSelMode != SINGLE_SELECTION )
241*cdf0e10cSrcweir 			{
242*cdf0e10cSrcweir 				if( !IsAddMode() )
243*cdf0e10cSrcweir 	                pFunctionSet->DeselectAll();
244*cdf0e10cSrcweir 				else
245*cdf0e10cSrcweir 					pFunctionSet->DestroyAnchor();
246*cdf0e10cSrcweir                	nFlags &= (~SELENG_HAS_ANCH); // bHasAnchor = sal_False;
247*cdf0e10cSrcweir 			}
248*cdf0e10cSrcweir             pFunctionSet->SetCursorAtPoint( aPos );
249*cdf0e10cSrcweir             // Sonderbehandlung Single-Selection, damit Select+Drag
250*cdf0e10cSrcweir             // in einem Zug moeglich ist
251*cdf0e10cSrcweir             if (eSelMode == SINGLE_SELECTION && (nFlags & SELENG_DRG_ENAB))
252*cdf0e10cSrcweir                 nFlags |= SELENG_WAIT_UPEVT;
253*cdf0e10cSrcweir             return sal_True;
254*cdf0e10cSrcweir         }
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir         case KEY_SHIFT:
257*cdf0e10cSrcweir             if ( eSelMode == SINGLE_SELECTION )
258*cdf0e10cSrcweir             {
259*cdf0e10cSrcweir                 pWin->ReleaseMouse();
260*cdf0e10cSrcweir                 nFlags &= (~SELENG_IN_SEL);
261*cdf0e10cSrcweir                 return sal_False;
262*cdf0e10cSrcweir             }
263*cdf0e10cSrcweir             if ( nFlags & SELENG_ADD_ALW )
264*cdf0e10cSrcweir                 nFlags |= SELENG_IN_ADD;
265*cdf0e10cSrcweir             else
266*cdf0e10cSrcweir                 nFlags &= (~SELENG_IN_ADD);
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir             if( !(nFlags & SELENG_HAS_ANCH) )
269*cdf0e10cSrcweir             {
270*cdf0e10cSrcweir                 if ( !(nFlags & SELENG_IN_ADD) )
271*cdf0e10cSrcweir                     pFunctionSet->DeselectAll();
272*cdf0e10cSrcweir                 pFunctionSet->CreateAnchor();
273*cdf0e10cSrcweir                 nFlags |= SELENG_HAS_ANCH;
274*cdf0e10cSrcweir             }
275*cdf0e10cSrcweir             pFunctionSet->SetCursorAtPoint( aPos );
276*cdf0e10cSrcweir             return sal_True;
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir         case KEY_MOD1:
279*cdf0e10cSrcweir             // Control nur bei Mehrfachselektion erlaubt
280*cdf0e10cSrcweir             if ( eSelMode != MULTIPLE_SELECTION )
281*cdf0e10cSrcweir             {
282*cdf0e10cSrcweir                 nFlags &= (~SELENG_IN_SEL);
283*cdf0e10cSrcweir                 pWin->ReleaseMouse();
284*cdf0e10cSrcweir                 return sal_True;  // Mausclick verschlucken
285*cdf0e10cSrcweir             }
286*cdf0e10cSrcweir             if ( nFlags & SELENG_HAS_ANCH )
287*cdf0e10cSrcweir             {
288*cdf0e10cSrcweir                 // pFunctionSet->CreateCursor();
289*cdf0e10cSrcweir 				pFunctionSet->DestroyAnchor();
290*cdf0e10cSrcweir                 nFlags &= (~SELENG_HAS_ANCH);
291*cdf0e10cSrcweir             }
292*cdf0e10cSrcweir             if ( pFunctionSet->IsSelectionAtPoint( aPos ) )
293*cdf0e10cSrcweir             {
294*cdf0e10cSrcweir                 pFunctionSet->DeselectAtPoint( aPos );
295*cdf0e10cSrcweir                 pFunctionSet->SetCursorAtPoint( aPos, sal_True );
296*cdf0e10cSrcweir             }
297*cdf0e10cSrcweir             else
298*cdf0e10cSrcweir             {
299*cdf0e10cSrcweir                 pFunctionSet->SetCursorAtPoint( aPos );
300*cdf0e10cSrcweir             }
301*cdf0e10cSrcweir             return sal_True;
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir         case KEY_SHIFT + KEY_MOD1:
304*cdf0e10cSrcweir             if ( eSelMode != MULTIPLE_SELECTION )
305*cdf0e10cSrcweir             {
306*cdf0e10cSrcweir                 pWin->ReleaseMouse();
307*cdf0e10cSrcweir                 nFlags &= (~SELENG_IN_SEL);
308*cdf0e10cSrcweir                 return sal_False;
309*cdf0e10cSrcweir             }
310*cdf0e10cSrcweir             nFlags |= SELENG_IN_ADD; //bIsInAddMode = sal_True;
311*cdf0e10cSrcweir             if ( !(nFlags & SELENG_HAS_ANCH) )
312*cdf0e10cSrcweir             {
313*cdf0e10cSrcweir                 pFunctionSet->CreateAnchor();
314*cdf0e10cSrcweir                 nFlags |= SELENG_HAS_ANCH;
315*cdf0e10cSrcweir             }
316*cdf0e10cSrcweir             pFunctionSet->SetCursorAtPoint( aPos );
317*cdf0e10cSrcweir             return sal_True;
318*cdf0e10cSrcweir     }
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir     return sal_False;
321*cdf0e10cSrcweir }
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir /*************************************************************************
324*cdf0e10cSrcweir |*
325*cdf0e10cSrcweir |*    SelectionEngine::SelMouseButtonUp()
326*cdf0e10cSrcweir |*
327*cdf0e10cSrcweir |*    Beschreibung      SELENG.SDW
328*cdf0e10cSrcweir |*    Ersterstellung    OV 10.10.94
329*cdf0e10cSrcweir |*    Letzte Aenderung  OV 10.10.94
330*cdf0e10cSrcweir |*
331*cdf0e10cSrcweir *************************************************************************/
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir sal_Bool SelectionEngine::SelMouseButtonUp( const MouseEvent& rMEvt )
334*cdf0e10cSrcweir {
335*cdf0e10cSrcweir     aWTimer.Stop();
336*cdf0e10cSrcweir     //DbgOut("Up");
337*cdf0e10cSrcweir     if( !pFunctionSet || !pWin )
338*cdf0e10cSrcweir     {
339*cdf0e10cSrcweir         nFlags &= ~(SELENG_CMDEVT | SELENG_WAIT_UPEVT | SELENG_IN_SEL);
340*cdf0e10cSrcweir         return sal_False;
341*cdf0e10cSrcweir     }
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir 	if( !rMEvt.IsRight() )
344*cdf0e10cSrcweir 	{
345*cdf0e10cSrcweir 	   pWin->ReleaseMouse();
346*cdf0e10cSrcweir 	}
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir     if( (nFlags & SELENG_WAIT_UPEVT) && !(nFlags & SELENG_CMDEVT) &&
349*cdf0e10cSrcweir         eSelMode != SINGLE_SELECTION)
350*cdf0e10cSrcweir     {
351*cdf0e10cSrcweir         // MouseButtonDown in Sel aber kein CommandEvent eingetrudelt
352*cdf0e10cSrcweir         // ==> deselektieren
353*cdf0e10cSrcweir         sal_uInt16 nModifier = aLastMove.GetModifier() | nLockedMods;
354*cdf0e10cSrcweir         if( nModifier == KEY_MOD1 || IsAlwaysAdding() )
355*cdf0e10cSrcweir 		{
356*cdf0e10cSrcweir 			if( !(nModifier & KEY_SHIFT) )
357*cdf0e10cSrcweir 			{
358*cdf0e10cSrcweir 				pFunctionSet->DestroyAnchor();
359*cdf0e10cSrcweir 		        nFlags &= (~SELENG_HAS_ANCH); // nix Anker
360*cdf0e10cSrcweir 			}
361*cdf0e10cSrcweir 			pFunctionSet->DeselectAtPoint( aLastMove.GetPosPixel() );
362*cdf0e10cSrcweir         	nFlags &= (~SELENG_HAS_ANCH); // nix Anker
363*cdf0e10cSrcweir 	        pFunctionSet->SetCursorAtPoint( aLastMove.GetPosPixel(), sal_True );
364*cdf0e10cSrcweir 		}
365*cdf0e10cSrcweir 		else
366*cdf0e10cSrcweir 		{
367*cdf0e10cSrcweir             pFunctionSet->DeselectAll();
368*cdf0e10cSrcweir 	        nFlags &= (~SELENG_HAS_ANCH); // nix Anker
369*cdf0e10cSrcweir         	pFunctionSet->SetCursorAtPoint( aLastMove.GetPosPixel() );
370*cdf0e10cSrcweir 		}
371*cdf0e10cSrcweir     }
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir     nFlags &= ~(SELENG_CMDEVT | SELENG_WAIT_UPEVT | SELENG_IN_SEL);
374*cdf0e10cSrcweir     return sal_True;
375*cdf0e10cSrcweir }
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir /*************************************************************************
378*cdf0e10cSrcweir |*
379*cdf0e10cSrcweir |*    SelectionEngine::SelMouseMove()
380*cdf0e10cSrcweir |*
381*cdf0e10cSrcweir |*    Beschreibung      SELENG.SDW
382*cdf0e10cSrcweir |*    Ersterstellung    OV 10.10.94
383*cdf0e10cSrcweir |*    Letzte Aenderung  OV 10.10.94
384*cdf0e10cSrcweir |*
385*cdf0e10cSrcweir *************************************************************************/
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir sal_Bool SelectionEngine::SelMouseMove( const MouseEvent& rMEvt )
388*cdf0e10cSrcweir {
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir     if ( !pFunctionSet || !(nFlags & SELENG_IN_SEL) ||
391*cdf0e10cSrcweir          (nFlags & (SELENG_CMDEVT | SELENG_WAIT_UPEVT)) )
392*cdf0e10cSrcweir         return sal_False;
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir 	if( !(nFlags & SELENG_EXPANDONMOVE) )
395*cdf0e10cSrcweir 		return sal_False; // auf DragEvent warten!
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir     aLastMove = rMEvt;
398*cdf0e10cSrcweir     // wenn die Maus ausserhalb der Area steht, dann wird die
399*cdf0e10cSrcweir     // Frequenz des SetCursorAtPoint() nur durch den Timer bestimmt
400*cdf0e10cSrcweir     if( aWTimer.IsActive() && !aArea.IsInside( rMEvt.GetPosPixel() ))
401*cdf0e10cSrcweir         return sal_True;
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir     aWTimer.Start();
405*cdf0e10cSrcweir     if ( eSelMode != SINGLE_SELECTION )
406*cdf0e10cSrcweir     {
407*cdf0e10cSrcweir         if ( !(nFlags & SELENG_HAS_ANCH) )
408*cdf0e10cSrcweir         {
409*cdf0e10cSrcweir             pFunctionSet->CreateAnchor();
410*cdf0e10cSrcweir             //DbgOut("Move:Creating anchor");
411*cdf0e10cSrcweir             nFlags |= SELENG_HAS_ANCH;
412*cdf0e10cSrcweir         }
413*cdf0e10cSrcweir     }
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir     //DbgOut("Move:SetCursor");
416*cdf0e10cSrcweir     pFunctionSet->SetCursorAtPoint( rMEvt.GetPosPixel() );
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir     return sal_True;
419*cdf0e10cSrcweir }
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir /*************************************************************************
422*cdf0e10cSrcweir |*
423*cdf0e10cSrcweir |*    SelectionEngine::SetWindow()
424*cdf0e10cSrcweir |*
425*cdf0e10cSrcweir |*    Beschreibung      SELENG.SDW
426*cdf0e10cSrcweir |*    Ersterstellung    OV 10.10.94
427*cdf0e10cSrcweir |*    Letzte Aenderung  OV 10.10.94
428*cdf0e10cSrcweir |*
429*cdf0e10cSrcweir *************************************************************************/
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir void SelectionEngine::SetWindow( Window* pNewWin )
432*cdf0e10cSrcweir {
433*cdf0e10cSrcweir     if( pNewWin != pWin )
434*cdf0e10cSrcweir     {
435*cdf0e10cSrcweir         if ( pWin && (nFlags & SELENG_IN_SEL) )
436*cdf0e10cSrcweir             pWin->ReleaseMouse();
437*cdf0e10cSrcweir         pWin = pNewWin;
438*cdf0e10cSrcweir         if ( pWin && ( nFlags & SELENG_IN_SEL ) )
439*cdf0e10cSrcweir             pWin->CaptureMouse();
440*cdf0e10cSrcweir     }
441*cdf0e10cSrcweir }
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir /*************************************************************************
444*cdf0e10cSrcweir |*
445*cdf0e10cSrcweir |*    SelectionEngine::Reset()
446*cdf0e10cSrcweir |*
447*cdf0e10cSrcweir |*    Beschreibung      SELENG.SDW
448*cdf0e10cSrcweir |*    Ersterstellung    OV 07.07.95
449*cdf0e10cSrcweir |*    Letzte Aenderung  OV 07.07.95
450*cdf0e10cSrcweir |*
451*cdf0e10cSrcweir *************************************************************************/
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir void SelectionEngine::Reset()
454*cdf0e10cSrcweir {
455*cdf0e10cSrcweir     aWTimer.Stop();
456*cdf0e10cSrcweir     if ( nFlags & SELENG_IN_SEL )
457*cdf0e10cSrcweir         pWin->ReleaseMouse();
458*cdf0e10cSrcweir     nFlags &= ~(SELENG_HAS_ANCH | SELENG_IN_SEL);
459*cdf0e10cSrcweir     nLockedMods = 0;
460*cdf0e10cSrcweir }
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir /*************************************************************************
463*cdf0e10cSrcweir |*
464*cdf0e10cSrcweir |*    SelectionEngine::Command()
465*cdf0e10cSrcweir |*
466*cdf0e10cSrcweir |*    Beschreibung      SELENG.SDW
467*cdf0e10cSrcweir |*    Ersterstellung    OV 07.07.95
468*cdf0e10cSrcweir |*    Letzte Aenderung  OV 07.07.95
469*cdf0e10cSrcweir |*
470*cdf0e10cSrcweir *************************************************************************/
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir void SelectionEngine::Command( const CommandEvent& rCEvt )
473*cdf0e10cSrcweir {
474*cdf0e10cSrcweir     // Timer aWTimer ist beim Aufspannen einer Selektion aktiv
475*cdf0e10cSrcweir     if ( !pFunctionSet || !pWin || aWTimer.IsActive() )
476*cdf0e10cSrcweir         return;
477*cdf0e10cSrcweir     aWTimer.Stop();
478*cdf0e10cSrcweir     nFlags |= SELENG_CMDEVT;
479*cdf0e10cSrcweir     if ( rCEvt.GetCommand() == COMMAND_STARTDRAG )
480*cdf0e10cSrcweir     {
481*cdf0e10cSrcweir         if ( nFlags & SELENG_DRG_ENAB )
482*cdf0e10cSrcweir         {
483*cdf0e10cSrcweir             DBG_ASSERT( rCEvt.IsMouseEvent(), "STARTDRAG: Not a MouseEvent" );
484*cdf0e10cSrcweir             if ( pFunctionSet->IsSelectionAtPoint( rCEvt.GetMousePosPixel() ) )
485*cdf0e10cSrcweir             {
486*cdf0e10cSrcweir             	aLastMove = MouseEvent( rCEvt.GetMousePosPixel(),
487*cdf0e10cSrcweir            					aLastMove.GetClicks(), aLastMove.GetMode(),
488*cdf0e10cSrcweir            					aLastMove.GetButtons(), aLastMove.GetModifier() );
489*cdf0e10cSrcweir                 pFunctionSet->BeginDrag();
490*cdf0e10cSrcweir                 nFlags &= ~(SELENG_CMDEVT|SELENG_WAIT_UPEVT|SELENG_IN_SEL);
491*cdf0e10cSrcweir             }
492*cdf0e10cSrcweir             else
493*cdf0e10cSrcweir                 nFlags &= ~SELENG_CMDEVT;
494*cdf0e10cSrcweir         }
495*cdf0e10cSrcweir         else
496*cdf0e10cSrcweir             nFlags &= ~SELENG_CMDEVT;
497*cdf0e10cSrcweir     }
498*cdf0e10cSrcweir }
499