fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sc / source / ui / formdlg / privsplt.cxx
blob1ac5f183a1917a0b36b30cafe0316bc546638bfb
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 "privsplt.hxx"
22 /*************************************************************************
23 #* Member: ScPrivatSplit
24 #*------------------------------------------------------------------------
26 #* Klasse: MD_Test
28 #* Funktion: Konstruktor der Klasse ScPrivatSplit
30 #* Input: ---
32 #* Output: ---
34 #************************************************************************/
36 ScPrivatSplit::ScPrivatSplit( Window* pParent, const ResId& rResId,
37 SC_SPLIT_DIRECTION eSplit):
38 Control( pParent, rResId )
40 Point aPos=GetPosPixel();
41 nOldX=(short)aPos.X();
42 nOldY=(short)aPos.Y();
43 nNewX=(short)aPos.X();
44 nNewY=(short)aPos.Y();
45 eScSplit=eSplit;
46 aXMovingRange.Min()=nNewX;
47 aXMovingRange.Max()=nNewX;
48 aYMovingRange.Min()=nNewY;
49 aYMovingRange.Max()=nNewY;
51 aWinPointer=GetPointer();
53 aMovingFlag=false;
54 if(eScSplit==SC_SPLIT_HORZ)
56 aWinPointer=Pointer(POINTER_HSPLIT);
58 else
60 aWinPointer=Pointer(POINTER_VSPLIT);
62 SetPointer(aWinPointer);
66 /*************************************************************************
67 #* Member: MouseButtonDown
68 #*------------------------------------------------------------------------
70 #* Klasse: ScPrivatSplit
72 #* Funktion: Reagiert auf einen einzelnen Mouse-Event. Nach Aufruf
73 #* werden alle Mauseingaben an dieses Control weitergeleitet.
75 #* Input: ---
77 #* Output: ---
79 #************************************************************************/
81 void ScPrivatSplit::MouseButtonDown( const MouseEvent& rMEvt )
83 Point aPos=LogicToPixel(rMEvt.GetPosPixel());
85 nOldX=(short)aPos.X();
86 nOldY=(short)aPos.Y();
88 CaptureMouse();
91 /*************************************************************************
92 #* Member: MouseButtonUp
93 #*------------------------------------------------------------------------
95 #* Klasse: ScPrivatSplit
97 #* Funktion: Ende einer Benutzeraktion mit der Maus. Es werden
98 #* die aktuelle Maus- Koordinaten ermittelt und fuer
99 #* die Verschiebung des Fensters verwendet.
101 #* Input: ---
103 #* Output: ---
105 #************************************************************************/
107 void ScPrivatSplit::MouseButtonUp( const MouseEvent& rMEvt )
109 ReleaseMouse();
111 Point aPos=LogicToPixel(rMEvt.GetPosPixel());
112 Point a2Pos=GetPosPixel();
113 Point a3Pos=a2Pos;
115 if(eScSplit==SC_SPLIT_HORZ)
117 nNewX=(short)aPos.X();
118 nDeltaX=nNewX-nOldX;
119 a2Pos.X()+=nDeltaX;
120 if(a2Pos.X()<aXMovingRange.Min())
122 nDeltaX=(short)(aXMovingRange.Min()-a3Pos.X());
123 a2Pos.X()=aXMovingRange.Min();
125 else if(a2Pos.X()>aXMovingRange.Max())
127 nDeltaX=(short)(aXMovingRange.Max()-a3Pos.X());
128 a2Pos.X()=aXMovingRange.Max();
131 else
133 nNewY=(short)aPos.Y();
134 nDeltaY=nNewY-nOldY;
135 a2Pos.Y()+=nDeltaY;
136 if(a2Pos.Y()<aYMovingRange.Min())
138 nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
139 a2Pos.Y()=aYMovingRange.Min();
141 else if(a2Pos.Y()>aYMovingRange.Max())
143 nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
144 a2Pos.Y()=aYMovingRange.Max();
147 SetPosPixel(a2Pos);
148 Invalidate();
149 Update();
150 CtrModified();
153 /*************************************************************************
154 #* Member: MouseMove
155 #*------------------------------------------------------------------------
157 #* Klasse: ScPrivatSplit
159 #* Funktion: Reagiert kontinuierlich auf Mausbewegungen. Es werden
160 #* die aktuelle Maus- Koordinaten ermittelt und fuer
161 #* die Verschiebung des Fensters verwendet.
163 #* Input: ---
165 #* Output: ---
167 #************************************************************************/
169 void ScPrivatSplit::MouseMove( const MouseEvent& rMEvt )
171 Point aPos=LogicToPixel(rMEvt.GetPosPixel());
172 Point a2Pos=GetPosPixel();
173 Point a3Pos=a2Pos;
174 if(rMEvt.IsLeft())
176 if(eScSplit==SC_SPLIT_HORZ)
178 nNewX=(short)aPos.X();
179 nDeltaX=nNewX-nOldX;
180 a2Pos.X()+=nDeltaX;
182 if(a2Pos.X()<aXMovingRange.Min())
184 nDeltaX=(short)(aXMovingRange.Min()-a3Pos.X());
185 a2Pos.X()=aXMovingRange.Min();
187 else if(a2Pos.X()>aXMovingRange.Max())
189 nDeltaX=(short)(aXMovingRange.Max()-a3Pos.X());
190 a2Pos.X()=aXMovingRange.Max();
193 else
195 nNewY=(short)aPos.Y();
196 nDeltaY=nNewY-nOldY;
197 a2Pos.Y()+=nDeltaY;
198 if(a2Pos.Y()<aYMovingRange.Min())
200 nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
201 a2Pos.Y()=aYMovingRange.Min();
203 else if(a2Pos.Y()>aYMovingRange.Max())
205 nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
206 a2Pos.Y()=aYMovingRange.Max();
210 SetPosPixel(a2Pos);
212 CtrModified();
213 Invalidate();
214 Update();
218 /*************************************************************************
219 #* Member: SetYRange
220 #*------------------------------------------------------------------------
222 #* Klasse: ScPrivatSplit
224 #* Funktion: Setzt den Range fuer die Y- Verschiebung
226 #* Input: neuer Bereich
228 #* Output: ---
230 #************************************************************************/
231 void ScPrivatSplit::SetYRange(Range cRgeY)
233 aYMovingRange=cRgeY;
238 /*************************************************************************
239 #* Member: GetDeltaY
240 #*------------------------------------------------------------------------
242 #* Klasse: ScPrivatSplit
244 #* Funktion: Liefert die relative x-Verschiebung zurueck
246 #* Input: ---
248 #* Output: ---
250 #************************************************************************/
251 short ScPrivatSplit::GetDeltaX()
253 return nDeltaX;
256 /*************************************************************************
257 #* Member: GetDeltaY
258 #*------------------------------------------------------------------------
260 #* Klasse: ScPrivatSplit
262 #* Funktion: Liefert die relative y-Verschiebung zurueck
264 #* Input: ---
266 #* Output: ---
268 #************************************************************************/
269 short ScPrivatSplit::GetDeltaY()
271 return nDeltaY;
274 /*************************************************************************
275 #* Member: CtrModified
276 #*------------------------------------------------------------------------
278 #* Klasse: ScPrivatSplit
280 #* Funktion: Teilt einem installierten Handler mit, dass
281 #* eine Veraenderung eingetreten ist.
283 #* Input: ---
285 #* Output: ---
287 #************************************************************************/
288 void ScPrivatSplit::CtrModified()
290 aCtrModifiedLink.Call( this );
293 void ScPrivatSplit::MoveSplitTo(Point aPos)
295 Point a2Pos=GetPosPixel();
296 nOldX=(short)a2Pos.X();
297 nOldY=(short)a2Pos.Y();
298 Point a3Pos=a2Pos;
300 if(eScSplit==SC_SPLIT_HORZ)
302 nNewX=(short)aPos.X();
303 nDeltaX=nNewX-nOldX;
304 a2Pos.X()+=nDeltaX;
305 if(a2Pos.X()<aXMovingRange.Min())
307 nDeltaX=(short)(aXMovingRange.Min()-a3Pos.X());
308 a2Pos.X()=aXMovingRange.Min();
310 else if(a2Pos.X()>aXMovingRange.Max())
312 nDeltaX=(short)(aXMovingRange.Max()-a3Pos.X());
313 a2Pos.X()=aXMovingRange.Max();
316 else
318 nNewY=(short)aPos.Y();
319 nDeltaY=nNewY-nOldY;
320 a2Pos.Y()+=nDeltaY;
321 if(a2Pos.Y()<aYMovingRange.Min())
323 nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
324 a2Pos.Y()=aYMovingRange.Min();
326 else if(a2Pos.Y()>aYMovingRange.Max())
328 nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
329 a2Pos.Y()=aYMovingRange.Max();
332 SetPosPixel(a2Pos);
333 Invalidate();
334 Update();
335 CtrModified();
339 void ScPrivatSplit::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
341 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
343 if ( bFont )
345 Font aFont = rStyleSettings.GetAppFont();
346 if ( IsControlFont() )
347 aFont.Merge( GetControlFont() );
348 SetFont( aFont );
351 if ( bFont || bForeground )
353 Color aTextColor = rStyleSettings.GetButtonTextColor();
354 if ( IsControlForeground() )
355 aTextColor = GetControlForeground();
356 SetTextColor( aTextColor );
359 if ( bBackground )
361 SetBackground( rStyleSettings.GetFaceColor());
363 if ( IsBackground() )
365 SetFillColor( GetBackground().GetColor() );
366 SetBackground();
368 Invalidate();
371 // -----------------------------------------------------------------------
373 void ScPrivatSplit::StateChanged( StateChangedType nType )
375 if ( (nType == STATE_CHANGE_ZOOM) ||
376 (nType == STATE_CHANGE_CONTROLFONT) )
378 ImplInitSettings( sal_True, false, false );
379 Invalidate();
381 if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
383 ImplInitSettings( false, sal_True, false );
384 Invalidate();
386 else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
388 ImplInitSettings( false, false, sal_True );
389 Invalidate();
392 Control::StateChanged( nType );
395 // -----------------------------------------------------------------------
397 void ScPrivatSplit::DataChanged( const DataChangedEvent& rDCEvt )
399 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
400 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
402 ImplInitSettings( sal_True, sal_True, sal_True );
403 Invalidate();
405 else
406 Window::DataChanged( rDCEvt );
410 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */