Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / ui / formdlg / privsplt.cxx
blob72adb6dd0335da2d0bc8f7011840b578b755d1e8
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 : Control(pParent, rResId)
39 , nDeltaY(0)
41 Point aPos=GetPosPixel();
42 nOldX=(short)aPos.X();
43 nOldY=(short)aPos.Y();
44 nNewX=(short)aPos.X();
45 nNewY=(short)aPos.Y();
46 aXMovingRange.Min()=nNewX;
47 aXMovingRange.Max()=nNewX;
48 aYMovingRange.Min()=nNewY;
49 aYMovingRange.Max()=nNewY;
51 aWinPointer=GetPointer();
53 aMovingFlag=false;
54 aWinPointer=Pointer(PointerStyle::VSplit);
55 SetPointer(aWinPointer);
58 /*************************************************************************
59 #* Member: MouseButtonDown
60 #*------------------------------------------------------------------------
62 #* Klasse: ScPrivatSplit
64 #* Funktion: Reagiert auf einen einzelnen Mouse-Event. Nach Aufruf
65 #* werden alle Mauseingaben an dieses Control weitergeleitet.
67 #* Input: ---
69 #* Output: ---
71 #************************************************************************/
73 void ScPrivatSplit::MouseButtonDown( const MouseEvent& rMEvt )
75 Point aPos=LogicToPixel(rMEvt.GetPosPixel());
77 nOldX=(short)aPos.X();
78 nOldY=(short)aPos.Y();
80 CaptureMouse();
83 /*************************************************************************
84 #* Member: MouseButtonUp
85 #*------------------------------------------------------------------------
87 #* Klasse: ScPrivatSplit
89 #* Funktion: Ende einer Benutzeraktion mit der Maus. Es werden
90 #* die aktuelle Maus- Koordinaten ermittelt und fuer
91 #* die Verschiebung des Fensters verwendet.
93 #* Input: ---
95 #* Output: ---
97 #************************************************************************/
99 void ScPrivatSplit::MouseButtonUp( const MouseEvent& rMEvt )
101 ReleaseMouse();
103 Point aPos=LogicToPixel(rMEvt.GetPosPixel());
104 Point a2Pos=GetPosPixel();
105 Point a3Pos=a2Pos;
107 nNewY=(short)aPos.Y();
108 nDeltaY=nNewY-nOldY;
109 a2Pos.Y()+=nDeltaY;
110 if(a2Pos.Y()<aYMovingRange.Min())
112 nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
113 a2Pos.Y()=aYMovingRange.Min();
115 else if(a2Pos.Y()>aYMovingRange.Max())
117 nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
118 a2Pos.Y()=aYMovingRange.Max();
121 SetPosPixel(a2Pos);
122 Invalidate();
123 Update();
124 CtrModified();
127 /*************************************************************************
128 #* Member: MouseMove
129 #*------------------------------------------------------------------------
131 #* Klasse: ScPrivatSplit
133 #* Funktion: Reagiert kontinuierlich auf Mausbewegungen. Es werden
134 #* die aktuelle Maus- Koordinaten ermittelt und fuer
135 #* die Verschiebung des Fensters verwendet.
137 #* Input: ---
139 #* Output: ---
141 #************************************************************************/
143 void ScPrivatSplit::MouseMove( const MouseEvent& rMEvt )
145 Point aPos=LogicToPixel(rMEvt.GetPosPixel());
146 Point a2Pos=GetPosPixel();
147 Point a3Pos=a2Pos;
148 if(rMEvt.IsLeft())
150 nNewY=(short)aPos.Y();
151 nDeltaY=nNewY-nOldY;
152 a2Pos.Y()+=nDeltaY;
153 if(a2Pos.Y()<aYMovingRange.Min())
155 nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
156 a2Pos.Y()=aYMovingRange.Min();
158 else if(a2Pos.Y()>aYMovingRange.Max())
160 nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
161 a2Pos.Y()=aYMovingRange.Max();
164 SetPosPixel(a2Pos);
166 CtrModified();
167 Invalidate();
168 Update();
172 /*************************************************************************
173 #* Member: SetYRange
174 #*------------------------------------------------------------------------
176 #* Klasse: ScPrivatSplit
178 #* Funktion: Setzt den Range fuer die Y- Verschiebung
180 #* Input: neuer Bereich
182 #* Output: ---
184 #************************************************************************/
185 void ScPrivatSplit::SetYRange(Range cRgeY)
187 aYMovingRange=cRgeY;
190 /*************************************************************************
191 #* Member: GetDeltaY
192 #*------------------------------------------------------------------------
194 #* Klasse: ScPrivatSplit
196 #* Funktion: Liefert die relative y-Verschiebung zurueck
198 #* Input: ---
200 #* Output: ---
202 #************************************************************************/
203 short ScPrivatSplit::GetDeltaY()
205 return nDeltaY;
208 /*************************************************************************
209 #* Member: CtrModified
210 #*------------------------------------------------------------------------
212 #* Klasse: ScPrivatSplit
214 #* Funktion: Teilt einem installierten Handler mit, dass
215 #* eine Veraenderung eingetreten ist.
217 #* Input: ---
219 #* Output: ---
221 #************************************************************************/
222 void ScPrivatSplit::CtrModified()
224 aCtrModifiedLink.Call( *this );
227 void ScPrivatSplit::MoveSplitTo(Point aPos)
229 Point a2Pos=GetPosPixel();
230 nOldX=(short)a2Pos.X();
231 nOldY=(short)a2Pos.Y();
232 Point a3Pos=a2Pos;
234 nNewY=(short)aPos.Y();
235 nDeltaY=nNewY-nOldY;
236 a2Pos.Y()+=nDeltaY;
237 if(a2Pos.Y()<aYMovingRange.Min())
239 nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
240 a2Pos.Y()=aYMovingRange.Min();
242 else if(a2Pos.Y()>aYMovingRange.Max())
244 nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
245 a2Pos.Y()=aYMovingRange.Max();
248 SetPosPixel(a2Pos);
249 Invalidate();
250 Update();
251 CtrModified();
254 void ScPrivatSplit::ImplInitSettings( bool bFont, bool bForeground, bool bBackground )
256 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
258 if ( bFont )
260 vcl::Font aFont = rStyleSettings.GetAppFont();
261 if ( IsControlFont() )
262 aFont.Merge( GetControlFont() );
263 SetFont( aFont );
266 if ( bFont || bForeground )
268 Color aTextColor = rStyleSettings.GetButtonTextColor();
269 if ( IsControlForeground() )
270 aTextColor = GetControlForeground();
271 SetTextColor( aTextColor );
274 if ( bBackground )
276 SetBackground( rStyleSettings.GetFaceColor());
278 if ( IsBackground() )
280 SetFillColor( GetBackground().GetColor() );
281 SetBackground();
283 Invalidate();
286 void ScPrivatSplit::StateChanged( StateChangedType nType )
288 if ( (nType == StateChangedType::Zoom) ||
289 (nType == StateChangedType::ControlFont) )
291 ImplInitSettings( true, false, false );
292 Invalidate();
294 if ( nType == StateChangedType::ControlForeground )
296 ImplInitSettings( false, true, false );
297 Invalidate();
299 else if ( nType == StateChangedType::ControlBackground )
301 ImplInitSettings( false, false, true );
302 Invalidate();
305 Control::StateChanged( nType );
308 void ScPrivatSplit::DataChanged( const DataChangedEvent& rDCEvt )
310 if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
311 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
313 ImplInitSettings( true, true, true );
314 Invalidate();
316 else
317 Window::DataChanged( rDCEvt );
320 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */