1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
23 #include <vcl/commandevent.hxx>
25 CommandExtTextInputData::CommandExtTextInputData( OUString aText
,
26 const ExtTextInputAttr
* pTextAttr
, sal_Int32 nCursorPos
, sal_uInt16 nCursorFlags
,
28 : maText(std::move(aText
))
30 if ( pTextAttr
&& !maText
.isEmpty() )
32 mpTextAttr
.reset( new ExtTextInputAttr
[maText
.getLength()] );
33 memcpy( mpTextAttr
.get(), pTextAttr
, maText
.getLength()*sizeof(ExtTextInputAttr
) );
36 mnCursorPos
= nCursorPos
;
37 mnCursorFlags
= nCursorFlags
;
38 mbOnlyCursor
= bOnlyCursor
;
41 CommandExtTextInputData::CommandExtTextInputData( const CommandExtTextInputData
& rData
) :
42 maText( rData
.maText
)
44 if ( rData
.mpTextAttr
&& !maText
.isEmpty() )
46 mpTextAttr
.reset( new ExtTextInputAttr
[maText
.getLength()] );
47 memcpy( mpTextAttr
.get(), rData
.mpTextAttr
.get(), maText
.getLength()*sizeof(ExtTextInputAttr
) );
50 mnCursorPos
= rData
.mnCursorPos
;
51 mnCursorFlags
= rData
.mnCursorFlags
;
52 mbOnlyCursor
= rData
.mbOnlyCursor
;
55 CommandExtTextInputData::~CommandExtTextInputData()
59 CommandWheelData::CommandWheelData()
64 mnWheelMode
= CommandWheelMode::NONE
;
67 mbDeltaIsPixel
= false;
70 CommandWheelData::CommandWheelData( tools::Long nWheelDelta
, tools::Long nWheelNotchDelta
,
72 CommandWheelMode nWheelMode
, sal_uInt16 nKeyModifier
,
73 bool bHorz
, bool bDeltaIsPixel
)
75 mnDelta
= nWheelDelta
;
76 mnNotchDelta
= nWheelNotchDelta
;
77 mnLines
= nScrollLines
;
78 mnWheelMode
= nWheelMode
;
79 mnCode
= nKeyModifier
;
81 mbDeltaIsPixel
= bDeltaIsPixel
;
84 CommandScrollData::CommandScrollData( tools::Long nDeltaX
, tools::Long nDeltaY
)
90 CommandModKeyData::CommandModKeyData( ModKeyFlags nCode
, bool bDown
)
96 CommandSelectionChangeData::CommandSelectionChangeData( sal_uLong nStart
, sal_uLong nEnd
)
102 CommandEvent::CommandEvent()
105 mnCommand
= CommandEventId::NONE
;
106 mbMouseEvent
= false;
109 CommandEvent::CommandEvent( const Point
& rMousePos
,
110 CommandEventId nCmd
, bool bMEvt
, const void* pCmdData
) :
113 mpData
= const_cast<void*>(pCmdData
);
115 mbMouseEvent
= bMEvt
;
118 const CommandExtTextInputData
* CommandEvent::GetExtTextInputData() const
120 if ( mnCommand
== CommandEventId::ExtTextInput
)
121 return static_cast<const CommandExtTextInputData
*>(mpData
);
126 const CommandWheelData
* CommandEvent::GetWheelData() const
128 if ( mnCommand
== CommandEventId::Wheel
)
129 return static_cast<const CommandWheelData
*>(mpData
);
134 const CommandScrollData
* CommandEvent::GetAutoScrollData() const
136 if ( mnCommand
== CommandEventId::AutoScroll
)
137 return static_cast<const CommandScrollData
*>(mpData
);
142 const CommandModKeyData
* CommandEvent::GetModKeyData() const
144 if( mnCommand
== CommandEventId::ModKeyChange
)
145 return static_cast<const CommandModKeyData
*>(mpData
);
150 const CommandDialogData
* CommandEvent::GetDialogData() const
152 if( mnCommand
== CommandEventId::ShowDialog
)
153 return static_cast<const CommandDialogData
*>(mpData
);
158 CommandMediaData
* CommandEvent::GetMediaData() const
160 if( mnCommand
== CommandEventId::Media
)
161 return static_cast<CommandMediaData
*>(mpData
);
166 const CommandSelectionChangeData
* CommandEvent::GetSelectionChangeData() const
168 if( mnCommand
== CommandEventId::SelectionChange
)
169 return static_cast<const CommandSelectionChangeData
*>(mpData
);
174 const CommandGestureSwipeData
* CommandEvent::GetGestureSwipeData() const
176 if( mnCommand
== CommandEventId::GestureSwipe
)
177 return static_cast<const CommandGestureSwipeData
*>(mpData
);
182 const CommandGestureLongPressData
* CommandEvent::GetLongPressData() const
184 if( mnCommand
== CommandEventId::GestureLongPress
)
185 return static_cast<const CommandGestureLongPressData
*>(mpData
);
190 const CommandGesturePanData
* CommandEvent::GetGesturePanData() const
192 if (mnCommand
== CommandEventId::GesturePan
)
193 return static_cast<const CommandGesturePanData
*>(mpData
);
198 const CommandGestureZoomData
* CommandEvent::GetGestureZoomData() const
200 if (mnCommand
== CommandEventId::GestureZoom
)
201 return static_cast<const CommandGestureZoomData
*>(mpData
);
206 const CommandGestureRotateData
* CommandEvent::GetGestureRotateData() const
208 if (mnCommand
== CommandEventId::GestureRotate
)
209 return static_cast<const CommandGestureRotateData
*>(mpData
);
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */