LibreOffice Module vcl (master) 1
seleng.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_VCL_SELENG_HXX
21#define INCLUDED_VCL_SELENG_HXX
22
23#include <vcl/dllapi.h>
24#include <vcl/timer.hxx>
25#include <vcl/event.hxx>
26#include <vcl/vclenum.hxx>
28
29class CommandEvent;
30
31namespace vcl {
32 class Window;
33}
34
35// Timerticks
36#define SELENG_DRAGDROP_TIMEOUT 400
37#define SELENG_AUTOREPEAT_INTERVAL 50
38#define SELENG_AUTOREPEAT_INTERVAL_MIN 25
39#define SELENG_AUTOREPEAT_INTERVAL_MAX 300
40
42{
43public:
44 virtual ~FunctionSet() = 0;
45
46 virtual void BeginDrag() = 0;
47
48 virtual void CreateAnchor() = 0; // Anker-Pos := Cursor-Pos
49 virtual void DestroyAnchor() = 0;
50
51 // move cursor, at the same time match cursor position to the selection
52 // starting at anchor. true == Ok
53 virtual void SetCursorAtPoint( const Point& rPointPixel,
54 bool bDontSelectAtCursor = false ) = 0;
55
56 virtual bool IsSelectionAtPoint( const Point& rPointPixel ) = 0;
57 virtual void DeselectAtPoint( const Point& rPointPixel ) = 0;
58 // delete anchor & deselect all
59 virtual void DeselectAll() = 0;
60};
61
62
64 DRG_ENAB = 0x0001,
65 IN_SEL = 0x0002,
66 IN_ADD = 0x0004,
67 ADD_ALW = 0x0008,
68 HAS_ANCH = 0x0020,
69 CMDEVT = 0x0040,
70 WAIT_UPEVT = 0x0080,
71 EXPANDONMOVE = 0x0100,
72};
73namespace o3tl
74{
75 template<> struct typed_flags<SelectionEngineFlags> : is_typed_flags<SelectionEngineFlags, 0x01ef> {};
76}
77
79{
80private:
84 Timer aWTimer; // generate fake mouse moves
88 sal_uInt16 nLockedMods;
90 DECL_DLLPRIVATE_LINK( ImpWatchDog, Timer*, void );
91
92 inline bool ShouldDeselect( bool bModifierKey1 ) const;
93 // determines to deselect or not when Ctrl-key is pressed on CursorPosChanging
94public:
95
97 FunctionSet* pFunctions = nullptr );
99 // Avoid implicitly defined copy constructors/assignments for the
100 // DLLPUBLIC class (they may require forward-declared classes used
101 // internally to be defined in places using SelectionEngine)
106
107 // true: Event was processed by Selection Engine
108 bool SelMouseButtonDown( const MouseEvent& rMEvt );
109 bool SelMouseButtonUp( const MouseEvent& rMEvt );
110 bool SelMouseMove( const MouseEvent& rMEvt );
111 //SelMouseButtonDown captures mouse events, SelMouseButtonUp
112 //releases the capture. If you need to release the mouse
113 //capture after SelMouseButtonDown but before
114 //SelMouseButtonUp, e.g. to allow events to go to a
115 //context menu via "Command" which is delivered after
116 //mouse down but before mouse up, then use this
117 void ReleaseMouse();
118 void CaptureMouse();
119
120 // Keyboard
121 void CursorPosChanging( bool bShift, bool bMod1 );
122
123 // is needed to generate a Move event via a Timer
124 // when the mouse is outside the area
125 void SetVisibleArea( const tools::Rectangle& rNewArea )
126 { aArea = rNewArea; }
127
128 void SetAddMode( bool);
129 bool IsAddMode() const;
130
131 void AddAlways( bool bOn );
132 bool IsAlwaysAdding() const;
133
134 void EnableDrag( bool bOn );
135
136 void SetSelectionMode( SelectionMode eMode );
137 SelectionMode GetSelectionMode() const { return eSelMode; }
138
140 { pFunctionSet = pFuncs; }
141 const FunctionSet* GetFunctionSet() const { return pFunctionSet; }
142
143 const Point& GetMousePosPixel() const
144 { return aLastMove.GetPosPixel(); }
145 const MouseEvent& GetMouseEvent() const { return aLastMove; }
146
147 void SetWindow( vcl::Window*);
148 vcl::Window* GetWindow() const { return pWin; }
149
150 void LockModifiers( sal_uInt16 nModifiers )
151 { nLockedMods = nModifiers; }
152 sal_uInt16 GetLockedModifiers() const { return nLockedMods; }
153
154 bool IsInSelection() const;
155 void Reset();
156
157 bool Command(const CommandEvent& rCEvt);
158
159 bool HasAnchor() const;
160 void SetAnchor( bool bAnchor );
161
162 void SetUpdateInterval( sal_uLong nInterval );
163
164 // is switched on in the Ctor
165 void ExpandSelectionOnMouseMove( bool bExpand = true )
166 {
167 if( bExpand )
169 else
171 }
172};
173
174inline bool SelectionEngine::IsAddMode() const
175{
177 return true;
178 else
179 return false;
180}
181
182inline void SelectionEngine::SetAddMode( bool bNewMode )
183{
184 if ( bNewMode )
186 else
188}
189
190inline void SelectionEngine::EnableDrag( bool bOn )
191{
192 if ( bOn )
194 else
196}
197
198inline void SelectionEngine::AddAlways( bool bOn )
199{
200 if( bOn )
202 else
204}
205
207{
209 return true;
210 else
211 return false;
212}
213
215{
217 return true;
218 else
219 return false;
220}
221
222inline bool SelectionEngine::HasAnchor() const
223{
225 return true;
226 else
227 return false;
228}
229
230inline void SelectionEngine::SetAnchor( bool bAnchor )
231{
232 if ( bAnchor )
234 else
236}
237
238#endif // INCLUDED_VCL_SELENG_HXX
239
240/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void DeselectAtPoint(const Point &rPointPixel)=0
virtual void DestroyAnchor()=0
virtual void SetCursorAtPoint(const Point &rPointPixel, bool bDontSelectAtCursor=false)=0
virtual void CreateAnchor()=0
virtual void BeginDrag()=0
virtual void DeselectAll()=0
virtual bool IsSelectionAtPoint(const Point &rPointPixel)=0
const Point & GetPosPixel() const
Definition: event.hxx:123
void LockModifiers(sal_uInt16 nModifiers)
Definition: seleng.hxx:150
void SetAddMode(bool)
Definition: seleng.hxx:182
Timer aWTimer
Definition: seleng.hxx:84
SelectionMode GetSelectionMode() const
Definition: seleng.hxx:137
const MouseEvent & GetMouseEvent() const
Definition: seleng.hxx:145
bool IsInSelection() const
Definition: seleng.hxx:214
bool IsAddMode() const
Definition: seleng.hxx:174
const Point & GetMousePosPixel() const
Definition: seleng.hxx:143
DECL_DLLPRIVATE_LINK(ImpWatchDog, Timer *, void)
void AddAlways(bool bOn)
Definition: seleng.hxx:198
VclPtr< vcl::Window > pWin
Definition: seleng.hxx:82
tools::Rectangle aArea
Definition: seleng.hxx:83
SelectionEngine(SelectionEngine &&)=delete
sal_uInt16 GetLockedModifiers() const
Definition: seleng.hxx:152
sal_uInt16 nLockedMods
Definition: seleng.hxx:88
SelectionEngineFlags nFlags
Definition: seleng.hxx:89
bool IsAlwaysAdding() const
Definition: seleng.hxx:206
void EnableDrag(bool bOn)
Definition: seleng.hxx:190
vcl::Window * GetWindow() const
Definition: seleng.hxx:148
FunctionSet * pFunctionSet
Definition: seleng.hxx:81
void SetAnchor(bool bAnchor)
Definition: seleng.hxx:230
SelectionEngine & operator=(const SelectionEngine &)=delete
void SetFunctionSet(FunctionSet *pFuncs)
Definition: seleng.hxx:139
void SetVisibleArea(const tools::Rectangle &rNewArea)
Definition: seleng.hxx:125
MouseEvent aLastMove
Definition: seleng.hxx:85
bool HasAnchor() const
Definition: seleng.hxx:222
SelectionMode eSelMode
Definition: seleng.hxx:86
sal_uLong nUpdateInterval
Definition: seleng.hxx:87
const FunctionSet * GetFunctionSet() const
Definition: seleng.hxx:141
void ExpandSelectionOnMouseMove(bool bExpand=true)
Definition: seleng.hxx:165
SelectionEngine & operator=(SelectionEngine &&)=delete
SelectionEngine(const SelectionEngine &)=delete
Definition: timer.hxx:27
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
SelectionEngineFlags
Definition: seleng.hxx:63
sal_uIntPtr sal_uLong
SelectionMode
Definition: vclenum.hxx:26