fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / formdlg / privsplt.cxx
blobe568ed5f7638ed8ddbc0410bcacfac1fa4532ee4
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"
21 #include <vcl/settings.hxx>
23 /*************************************************************************
24 #* Member: ScPrivatSplit
25 #*------------------------------------------------------------------------
27 #* Klasse: MD_Test
29 #* Funktion: Konstruktor der Klasse ScPrivatSplit
31 #* Input: ---
33 #* Output: ---
35 #************************************************************************/
37 ScPrivatSplit::ScPrivatSplit(vcl::Window* pParent, const ResId& rResId,
38 SC_SPLIT_DIRECTION eSplit)
39 : Control(pParent, rResId)
40 , nDeltaX(0)
41 , nDeltaY(0)
43 Point aPos=GetPosPixel();
44 nOldX=(short)aPos.X();
45 nOldY=(short)aPos.Y();
46 nNewX=(short)aPos.X();
47 nNewY=(short)aPos.Y();
48 eScSplit=eSplit;
49 aXMovingRange.Min()=nNewX;
50 aXMovingRange.Max()=nNewX;
51 aYMovingRange.Min()=nNewY;
52 aYMovingRange.Max()=nNewY;
54 aWinPointer=GetPointer();
56 aMovingFlag=false;
57 if(eScSplit==SC_SPLIT_HORZ)
59 aWinPointer=Pointer(PointerStyle::HSplit);
61 else
63 aWinPointer=Pointer(PointerStyle::VSplit);
65 SetPointer(aWinPointer);
68 /*************************************************************************
69 #* Member: MouseButtonDown
70 #*------------------------------------------------------------------------
72 #* Klasse: ScPrivatSplit
74 #* Funktion: Reagiert auf einen einzelnen Mouse-Event. Nach Aufruf
75 #* werden alle Mauseingaben an dieses Control weitergeleitet.
77 #* Input: ---
79 #* Output: ---
81 #************************************************************************/
83 void ScPrivatSplit::MouseButtonDown( const MouseEvent& rMEvt )
85 Point aPos=LogicToPixel(rMEvt.GetPosPixel());
87 nOldX=(short)aPos.X();
88 nOldY=(short)aPos.Y();
90 CaptureMouse();
93 /*************************************************************************
94 #* Member: MouseButtonUp
95 #*------------------------------------------------------------------------
97 #* Klasse: ScPrivatSplit
99 #* Funktion: Ende einer Benutzeraktion mit der Maus. Es werden
100 #* die aktuelle Maus- Koordinaten ermittelt und fuer
101 #* die Verschiebung des Fensters verwendet.
103 #* Input: ---
105 #* Output: ---
107 #************************************************************************/
109 void ScPrivatSplit::MouseButtonUp( const MouseEvent& rMEvt )
111 ReleaseMouse();
113 Point aPos=LogicToPixel(rMEvt.GetPosPixel());
114 Point a2Pos=GetPosPixel();
115 Point a3Pos=a2Pos;
117 if(eScSplit==SC_SPLIT_HORZ)
119 nNewX=(short)aPos.X();
120 nDeltaX=nNewX-nOldX;
121 a2Pos.X()+=nDeltaX;
122 if(a2Pos.X()<aXMovingRange.Min())
124 nDeltaX=(short)(aXMovingRange.Min()-a3Pos.X());
125 a2Pos.X()=aXMovingRange.Min();
127 else if(a2Pos.X()>aXMovingRange.Max())
129 nDeltaX=(short)(aXMovingRange.Max()-a3Pos.X());
130 a2Pos.X()=aXMovingRange.Max();
133 else
135 nNewY=(short)aPos.Y();
136 nDeltaY=nNewY-nOldY;
137 a2Pos.Y()+=nDeltaY;
138 if(a2Pos.Y()<aYMovingRange.Min())
140 nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
141 a2Pos.Y()=aYMovingRange.Min();
143 else if(a2Pos.Y()>aYMovingRange.Max())
145 nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
146 a2Pos.Y()=aYMovingRange.Max();
149 SetPosPixel(a2Pos);
150 Invalidate();
151 Update();
152 CtrModified();
155 /*************************************************************************
156 #* Member: MouseMove
157 #*------------------------------------------------------------------------
159 #* Klasse: ScPrivatSplit
161 #* Funktion: Reagiert kontinuierlich auf Mausbewegungen. Es werden
162 #* die aktuelle Maus- Koordinaten ermittelt und fuer
163 #* die Verschiebung des Fensters verwendet.
165 #* Input: ---
167 #* Output: ---
169 #************************************************************************/
171 void ScPrivatSplit::MouseMove( const MouseEvent& rMEvt )
173 Point aPos=LogicToPixel(rMEvt.GetPosPixel());
174 Point a2Pos=GetPosPixel();
175 Point a3Pos=a2Pos;
176 if(rMEvt.IsLeft())
178 if(eScSplit==SC_SPLIT_HORZ)
180 nNewX=(short)aPos.X();
181 nDeltaX=nNewX-nOldX;
182 a2Pos.X()+=nDeltaX;
184 if(a2Pos.X()<aXMovingRange.Min())
186 nDeltaX=(short)(aXMovingRange.Min()-a3Pos.X());
187 a2Pos.X()=aXMovingRange.Min();
189 else if(a2Pos.X()>aXMovingRange.Max())
191 nDeltaX=(short)(aXMovingRange.Max()-a3Pos.X());
192 a2Pos.X()=aXMovingRange.Max();
195 else
197 nNewY=(short)aPos.Y();
198 nDeltaY=nNewY-nOldY;
199 a2Pos.Y()+=nDeltaY;
200 if(a2Pos.Y()<aYMovingRange.Min())
202 nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
203 a2Pos.Y()=aYMovingRange.Min();
205 else if(a2Pos.Y()>aYMovingRange.Max())
207 nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
208 a2Pos.Y()=aYMovingRange.Max();
212 SetPosPixel(a2Pos);
214 CtrModified();
215 Invalidate();
216 Update();
220 /*************************************************************************
221 #* Member: SetYRange
222 #*------------------------------------------------------------------------
224 #* Klasse: ScPrivatSplit
226 #* Funktion: Setzt den Range fuer die Y- Verschiebung
228 #* Input: neuer Bereich
230 #* Output: ---
232 #************************************************************************/
233 void ScPrivatSplit::SetYRange(Range cRgeY)
235 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();
338 void ScPrivatSplit::ImplInitSettings( bool bFont, bool bForeground, bool bBackground )
340 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
342 if ( bFont )
344 vcl::Font aFont = rStyleSettings.GetAppFont();
345 if ( IsControlFont() )
346 aFont.Merge( GetControlFont() );
347 SetFont( aFont );
350 if ( bFont || bForeground )
352 Color aTextColor = rStyleSettings.GetButtonTextColor();
353 if ( IsControlForeground() )
354 aTextColor = GetControlForeground();
355 SetTextColor( aTextColor );
358 if ( bBackground )
360 SetBackground( rStyleSettings.GetFaceColor());
362 if ( IsBackground() )
364 SetFillColor( GetBackground().GetColor() );
365 SetBackground();
367 Invalidate();
370 void ScPrivatSplit::StateChanged( StateChangedType nType )
372 if ( (nType == StateChangedType::Zoom) ||
373 (nType == StateChangedType::ControlFont) )
375 ImplInitSettings( true, false, false );
376 Invalidate();
378 if ( nType == StateChangedType::ControlForeground )
380 ImplInitSettings( false, true, false );
381 Invalidate();
383 else if ( nType == StateChangedType::ControlBackground )
385 ImplInitSettings( false, false, true );
386 Invalidate();
389 Control::StateChanged( nType );
392 void ScPrivatSplit::DataChanged( const DataChangedEvent& rDCEvt )
394 if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
395 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
397 ImplInitSettings( true, true, true );
398 Invalidate();
400 else
401 Window::DataChanged( rDCEvt );
404 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */