Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / vcl / source / window / commandevent.cxx
blob06e974c9fc6a1cb68c5d66a82f139c5f9a59488d
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 #include <string.h>
22 #include <vcl/commandevent.hxx>
24 CommandExtTextInputData::CommandExtTextInputData( const OUString& rText,
25 const ExtTextInputAttr* pTextAttr, sal_Int32 nCursorPos, sal_uInt16 nCursorFlags,
26 bool bOnlyCursor)
27 : maText(rText)
29 if ( pTextAttr && !maText.isEmpty() )
31 mpTextAttr.reset( new ExtTextInputAttr[maText.getLength()] );
32 memcpy( mpTextAttr.get(), pTextAttr, maText.getLength()*sizeof(ExtTextInputAttr) );
35 mnCursorPos = nCursorPos;
36 mnCursorFlags = nCursorFlags;
37 mbOnlyCursor = bOnlyCursor;
40 CommandExtTextInputData::CommandExtTextInputData( const CommandExtTextInputData& rData ) :
41 maText( rData.maText )
43 if ( rData.mpTextAttr && !maText.isEmpty() )
45 mpTextAttr.reset( new ExtTextInputAttr[maText.getLength()] );
46 memcpy( mpTextAttr.get(), rData.mpTextAttr.get(), maText.getLength()*sizeof(ExtTextInputAttr) );
49 mnCursorPos = rData.mnCursorPos;
50 mnCursorFlags = rData.mnCursorFlags;
51 mbOnlyCursor = rData.mbOnlyCursor;
54 CommandExtTextInputData::~CommandExtTextInputData()
58 CommandWheelData::CommandWheelData()
60 mnDelta = 0;
61 mnNotchDelta = 0;
62 mnLines = 0.0;
63 mnWheelMode = CommandWheelMode::NONE;
64 mnCode = 0;
65 mbHorz = false;
66 mbDeltaIsPixel = false;
69 CommandWheelData::CommandWheelData( long nWheelDelta, long nWheelNotchDelta,
70 double nScrollLines,
71 CommandWheelMode nWheelMode, sal_uInt16 nKeyModifier,
72 bool bHorz, bool bDeltaIsPixel )
74 mnDelta = nWheelDelta;
75 mnNotchDelta = nWheelNotchDelta;
76 mnLines = nScrollLines;
77 mnWheelMode = nWheelMode;
78 mnCode = nKeyModifier;
79 mbHorz = bHorz;
80 mbDeltaIsPixel = bDeltaIsPixel;
83 CommandScrollData::CommandScrollData( long nDeltaX, long nDeltaY )
85 mnDeltaX = nDeltaX;
86 mnDeltaY = nDeltaY;
89 CommandModKeyData::CommandModKeyData( ModKeyFlags nCode, bool bDown )
91 mbDown = bDown;
92 mnCode = nCode;
95 CommandSelectionChangeData::CommandSelectionChangeData( sal_uLong nStart, sal_uLong nEnd )
97 mnStart = nStart;
98 mnEnd = nEnd;
101 CommandEvent::CommandEvent()
103 mpData = nullptr;
104 mnCommand = CommandEventId::NONE;
105 mbMouseEvent = false;
108 CommandEvent::CommandEvent( const Point& rMousePos,
109 CommandEventId nCmd, bool bMEvt, const void* pCmdData ) :
110 maPos( rMousePos )
112 mpData = const_cast<void*>(pCmdData);
113 mnCommand = nCmd;
114 mbMouseEvent = bMEvt;
117 const CommandExtTextInputData* CommandEvent::GetExtTextInputData() const
119 if ( mnCommand == CommandEventId::ExtTextInput )
120 return static_cast<const CommandExtTextInputData*>(mpData);
121 else
122 return nullptr;
125 const CommandWheelData* CommandEvent::GetWheelData() const
127 if ( mnCommand == CommandEventId::Wheel )
128 return static_cast<const CommandWheelData*>(mpData);
129 else
130 return nullptr;
133 const CommandScrollData* CommandEvent::GetAutoScrollData() const
135 if ( mnCommand == CommandEventId::AutoScroll )
136 return static_cast<const CommandScrollData*>(mpData);
137 else
138 return nullptr;
141 const CommandModKeyData* CommandEvent::GetModKeyData() const
143 if( mnCommand == CommandEventId::ModKeyChange )
144 return static_cast<const CommandModKeyData*>(mpData);
145 else
146 return nullptr;
149 const CommandDialogData* CommandEvent::GetDialogData() const
151 if( mnCommand == CommandEventId::ShowDialog )
152 return static_cast<const CommandDialogData*>(mpData);
153 else
154 return nullptr;
157 CommandMediaData* CommandEvent::GetMediaData() const
159 if( mnCommand == CommandEventId::Media )
160 return static_cast<CommandMediaData*>(mpData);
161 else
162 return nullptr;
165 const CommandSelectionChangeData* CommandEvent::GetSelectionChangeData() const
167 if( mnCommand == CommandEventId::SelectionChange )
168 return static_cast<const CommandSelectionChangeData*>(mpData);
169 else
170 return nullptr;
173 const CommandSwipeData* CommandEvent::GetSwipeData() const
175 if( mnCommand == CommandEventId::Swipe )
176 return static_cast<const CommandSwipeData*>(mpData);
177 else
178 return nullptr;
181 const CommandLongPressData* CommandEvent::GetLongPressData() const
183 if( mnCommand == CommandEventId::LongPress )
184 return static_cast<const CommandLongPressData*>(mpData);
185 else
186 return nullptr;
189 const CommandGestureData* CommandEvent::GetGestureData() const
191 if (mnCommand == CommandEventId::Gesture)
192 return static_cast<const CommandGestureData*>(mpData);
193 else
194 return nullptr;
198 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */