tdf#164393 Change themes UI as per UX feedback
[LibreOffice.git] / vcl / source / window / commandevent.cxx
blob83c21826e7c36700803f473dbb592eeb33f11baf
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 <utility>
23 #include <vcl/commandevent.hxx>
25 CommandExtTextInputData::CommandExtTextInputData( OUString aText,
26 const ExtTextInputAttr* pTextAttr, sal_Int32 nCursorPos, sal_uInt16 nCursorFlags,
27 bool bOnlyCursor)
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()
61 mnDelta = 0;
62 mnNotchDelta = 0;
63 mnLines = 0.0;
64 mnWheelMode = CommandWheelMode::NONE;
65 mnCode = 0;
66 mbHorz = false;
67 mbDeltaIsPixel = false;
70 CommandWheelData::CommandWheelData( tools::Long nWheelDelta, tools::Long nWheelNotchDelta,
71 double nScrollLines,
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;
80 mbHorz = bHorz;
81 mbDeltaIsPixel = bDeltaIsPixel;
84 CommandScrollData::CommandScrollData( tools::Long nDeltaX, tools::Long nDeltaY )
86 mnDeltaX = nDeltaX;
87 mnDeltaY = nDeltaY;
90 CommandModKeyData::CommandModKeyData( ModKeyFlags nCode, bool bDown )
92 mbDown = bDown;
93 mnCode = nCode;
96 CommandSelectionChangeData::CommandSelectionChangeData( sal_uLong nStart, sal_uLong nEnd )
98 mnStart = nStart;
99 mnEnd = nEnd;
102 CommandEvent::CommandEvent()
104 mpData = nullptr;
105 mnCommand = CommandEventId::NONE;
106 mbMouseEvent = false;
109 CommandEvent::CommandEvent( const Point& rMousePos,
110 CommandEventId nCmd, bool bMEvt, const void* pCmdData ) :
111 maPos( rMousePos )
113 mpData = const_cast<void*>(pCmdData);
114 mnCommand = nCmd;
115 mbMouseEvent = bMEvt;
118 const CommandExtTextInputData* CommandEvent::GetExtTextInputData() const
120 if ( mnCommand == CommandEventId::ExtTextInput )
121 return static_cast<const CommandExtTextInputData*>(mpData);
122 else
123 return nullptr;
126 const CommandWheelData* CommandEvent::GetWheelData() const
128 if ( mnCommand == CommandEventId::Wheel )
129 return static_cast<const CommandWheelData*>(mpData);
130 else
131 return nullptr;
134 const CommandScrollData* CommandEvent::GetAutoScrollData() const
136 if ( mnCommand == CommandEventId::AutoScroll )
137 return static_cast<const CommandScrollData*>(mpData);
138 else
139 return nullptr;
142 const CommandModKeyData* CommandEvent::GetModKeyData() const
144 if( mnCommand == CommandEventId::ModKeyChange )
145 return static_cast<const CommandModKeyData*>(mpData);
146 else
147 return nullptr;
150 const CommandDialogData* CommandEvent::GetDialogData() const
152 if( mnCommand == CommandEventId::ShowDialog )
153 return static_cast<const CommandDialogData*>(mpData);
154 else
155 return nullptr;
158 CommandMediaData* CommandEvent::GetMediaData() const
160 if( mnCommand == CommandEventId::Media )
161 return static_cast<CommandMediaData*>(mpData);
162 else
163 return nullptr;
166 const CommandSelectionChangeData* CommandEvent::GetSelectionChangeData() const
168 if( mnCommand == CommandEventId::SelectionChange )
169 return static_cast<const CommandSelectionChangeData*>(mpData);
170 else
171 return nullptr;
174 const CommandGestureSwipeData* CommandEvent::GetGestureSwipeData() const
176 if( mnCommand == CommandEventId::GestureSwipe )
177 return static_cast<const CommandGestureSwipeData*>(mpData);
178 else
179 return nullptr;
182 const CommandGestureLongPressData* CommandEvent::GetLongPressData() const
184 if( mnCommand == CommandEventId::GestureLongPress )
185 return static_cast<const CommandGestureLongPressData*>(mpData);
186 else
187 return nullptr;
190 const CommandGesturePanData* CommandEvent::GetGesturePanData() const
192 if (mnCommand == CommandEventId::GesturePan)
193 return static_cast<const CommandGesturePanData*>(mpData);
194 else
195 return nullptr;
198 const CommandGestureZoomData* CommandEvent::GetGestureZoomData() const
200 if (mnCommand == CommandEventId::GestureZoom)
201 return static_cast<const CommandGestureZoomData*>(mpData);
202 else
203 return nullptr;
206 const CommandGestureRotateData* CommandEvent::GetGestureRotateData() const
208 if (mnCommand == CommandEventId::GestureRotate)
209 return static_cast<const CommandGestureRotateData*>(mpData);
210 else
211 return nullptr;
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */