fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / vcl / seleng.hxx
blobf93e74a3ebf48b335ff6ba41a6c97e3ed22c2904
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _SV_SELENG_HXX
21 #define _SV_SELENG_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/timer.hxx>
25 #include <vcl/event.hxx>
27 class Window;
28 class CommandEvent;
30 // Timerticks
31 #define SELENG_DRAGDROP_TIMEOUT 400
32 #define SELENG_AUTOREPEAT_INTERVAL 50
33 #define SELENG_AUTOREPEAT_INTERVAL_MIN 25
34 #define SELENG_AUTOREPEAT_INTERVAL_MAX 300
36 enum SelectionMode { NO_SELECTION, SINGLE_SELECTION, RANGE_SELECTION, MULTIPLE_SELECTION };
38 // ---------------
39 // - FunctionSet -
40 // ---------------
42 class VCL_DLLPUBLIC FunctionSet
44 public:
45 virtual ~FunctionSet() = 0;
47 virtual void BeginDrag() = 0;
49 virtual void CreateAnchor() = 0; // Anker-Pos := Cursor-Pos
50 virtual void DestroyAnchor() = 0;
52 // move cursor, at the same time match cursor position to the selection
53 // starting at anchor. sal_True == Ok
54 virtual sal_Bool SetCursorAtPoint( const Point& rPointPixel,
55 sal_Bool bDontSelectAtCursor = sal_False ) = 0;
57 virtual sal_Bool IsSelectionAtPoint( const Point& rPointPixel ) = 0;
58 virtual void DeselectAtPoint( const Point& rPointPixel ) = 0;
59 // delete anchor & deselect all
60 virtual void DeselectAll() = 0;
63 // -------------------
64 // - SelectionEngine -
65 // -------------------
67 #define SELENG_DRG_ENAB 0x0001
68 #define SELENG_IN_SEL 0x0002
69 #define SELENG_IN_ADD 0x0004
70 #define SELENG_ADD_ALW 0x0008
71 #define SELENG_HAS_ANCH 0x0020
72 #define SELENG_CMDEVT 0x0040
73 #define SELENG_WAIT_UPEVT 0x0080
74 #define SELENG_EXPANDONMOVE 0x0100
76 class VCL_DLLPUBLIC SelectionEngine
78 private:
79 FunctionSet* pFunctionSet;
80 Window* pWin;
81 Rectangle aArea;
82 Timer aWTimer; // generate fake mouse moves
83 MouseEvent aLastMove;
84 SelectionMode eSelMode;
85 sal_uLong nUpdateInterval;
86 // sensitivity of mouse moves during a selection
87 sal_uInt16 nMouseSensitivity;
88 sal_uInt16 nLockedMods;
89 sal_uInt16 nFlags;
90 DECL_DLLPRIVATE_LINK( ImpWatchDog, void* );
92 inline sal_Bool ShouldDeselect( sal_Bool bModifierKey1 ) const;
93 // determines to deselect or not when Ctrl-key is pressed on CursorPosChanging
94 public:
96 SelectionEngine( Window* pWindow,
97 FunctionSet* pFunctions = NULL,
98 sal_uLong nAutoRepeatInterval = SELENG_AUTOREPEAT_INTERVAL );
99 ~SelectionEngine();
101 // sal_True: Event was processed by Selection Engine
102 sal_Bool SelMouseButtonDown( const MouseEvent& rMEvt );
103 sal_Bool SelMouseButtonUp( const MouseEvent& rMEvt );
104 sal_Bool SelMouseMove( const MouseEvent& rMEvt );
106 // Keyboard
107 void CursorPosChanging( sal_Bool bShift, sal_Bool bMod1 );
109 // is needed to generate a Move event via a Timer
110 // when the mouse is outside the area
111 void SetVisibleArea( const Rectangle rNewArea )
112 { aArea = rNewArea; }
113 const Rectangle& GetVisibleArea() const { return aArea; }
115 void SetAddMode( sal_Bool);
116 sal_Bool IsAddMode() const;
118 void AddAlways( sal_Bool bOn );
119 sal_Bool IsAlwaysAdding() const;
121 void EnableDrag( sal_Bool bOn );
123 void SetSelectionMode( SelectionMode eMode );
124 SelectionMode GetSelectionMode() const { return eSelMode; }
126 void SetFunctionSet( FunctionSet* pFuncs )
127 { pFunctionSet = pFuncs; }
128 const FunctionSet* GetFunctionSet() const { return pFunctionSet; }
130 void SetMouseSensitivity( sal_uInt16 nSensitivity )
131 { nMouseSensitivity = nSensitivity; }
132 sal_uInt16 GetMouseSensitivity() const
133 { return nMouseSensitivity; }
135 const Point& GetMousePosPixel() const
136 { return aLastMove.GetPosPixel(); }
137 const MouseEvent& GetMouseEvent() const { return aLastMove; }
139 void SetWindow( Window*);
140 Window* GetWindow() const { return pWin; }
142 void LockModifiers( sal_uInt16 nModifiers )
143 { nLockedMods = nModifiers; }
144 sal_uInt16 GetLockedModifiers() const { return nLockedMods; }
146 sal_Bool IsInSelection() const;
147 void Reset();
149 void Command( const CommandEvent& rCEvt );
151 sal_Bool HasAnchor() const;
152 void SetAnchor( sal_Bool bAnchor );
154 void SetUpdateInterval( sal_uLong nInterval );
156 // wird im Ctor eingeschaltet
157 void ExpandSelectionOnMouseMove( sal_Bool bExpand = sal_True )
159 if( bExpand )
160 nFlags |= SELENG_EXPANDONMOVE;
161 else
162 nFlags &= ~SELENG_EXPANDONMOVE;
166 inline sal_Bool SelectionEngine::IsAddMode() const
168 if ( nFlags & (SELENG_IN_ADD | SELENG_ADD_ALW) )
169 return sal_True;
170 else
171 return sal_False;
174 inline void SelectionEngine::SetAddMode( sal_Bool bNewMode )
176 if ( bNewMode )
177 nFlags |= SELENG_IN_ADD;
178 else
179 nFlags &= (~SELENG_IN_ADD);
182 inline void SelectionEngine::EnableDrag( sal_Bool bOn )
184 if ( bOn )
185 nFlags |= SELENG_DRG_ENAB;
186 else
187 nFlags &= (~SELENG_DRG_ENAB);
190 inline void SelectionEngine::AddAlways( sal_Bool bOn )
192 if( bOn )
193 nFlags |= SELENG_ADD_ALW;
194 else
195 nFlags &= (~SELENG_ADD_ALW);
198 inline sal_Bool SelectionEngine::IsAlwaysAdding() const
200 if ( nFlags & SELENG_ADD_ALW )
201 return sal_True;
202 else
203 return sal_False;
206 inline sal_Bool SelectionEngine::IsInSelection() const
208 if ( nFlags & SELENG_IN_SEL )
209 return sal_True;
210 else
211 return sal_False;
214 inline sal_Bool SelectionEngine::HasAnchor() const
216 if ( nFlags & SELENG_HAS_ANCH )
217 return sal_True;
218 else
219 return sal_False;
222 inline void SelectionEngine::SetAnchor( sal_Bool bAnchor )
224 if ( bAnchor )
225 nFlags |= SELENG_HAS_ANCH;
226 else
227 nFlags &= (~SELENG_HAS_ANCH);
230 #endif // _SV_SELENG_HXX
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */