1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #*------------------------------------------------------------------------
29 #* Funktion: Konstruktor der Klasse ScPrivatSplit
35 #************************************************************************/
37 ScPrivatSplit::ScPrivatSplit(vcl::Window
* pParent
, const ResId
& rResId
)
38 : Control(pParent
, rResId
)
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();
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.
71 #************************************************************************/
73 void ScPrivatSplit::MouseButtonDown( const MouseEvent
& rMEvt
)
75 Point aPos
=LogicToPixel(rMEvt
.GetPosPixel());
77 nOldX
=(short)aPos
.X();
78 nOldY
=(short)aPos
.Y();
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.
97 #************************************************************************/
99 void ScPrivatSplit::MouseButtonUp( const MouseEvent
& rMEvt
)
103 Point aPos
=LogicToPixel(rMEvt
.GetPosPixel());
104 Point a2Pos
=GetPosPixel();
107 nNewY
=(short)aPos
.Y();
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();
127 /*************************************************************************
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.
141 #************************************************************************/
143 void ScPrivatSplit::MouseMove( const MouseEvent
& rMEvt
)
145 Point aPos
=LogicToPixel(rMEvt
.GetPosPixel());
146 Point a2Pos
=GetPosPixel();
150 nNewY
=(short)aPos
.Y();
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();
172 /*************************************************************************
174 #*------------------------------------------------------------------------
176 #* Klasse: ScPrivatSplit
178 #* Funktion: Setzt den Range fuer die Y- Verschiebung
180 #* Input: neuer Bereich
184 #************************************************************************/
185 void ScPrivatSplit::SetYRange(Range cRgeY
)
190 /*************************************************************************
192 #*------------------------------------------------------------------------
194 #* Klasse: ScPrivatSplit
196 #* Funktion: Liefert die relative y-Verschiebung zurueck
202 #************************************************************************/
203 short ScPrivatSplit::GetDeltaY()
208 /*************************************************************************
209 #* Member: CtrModified
210 #*------------------------------------------------------------------------
212 #* Klasse: ScPrivatSplit
214 #* Funktion: Teilt einem installierten Handler mit, dass
215 #* eine Veraenderung eingetreten ist.
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();
234 nNewY
=(short)aPos
.Y();
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();
254 void ScPrivatSplit::ImplInitSettings( bool bFont
, bool bForeground
, bool bBackground
)
256 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
260 vcl::Font aFont
= rStyleSettings
.GetAppFont();
261 if ( IsControlFont() )
262 aFont
.Merge( GetControlFont() );
266 if ( bFont
|| bForeground
)
268 Color aTextColor
= rStyleSettings
.GetButtonTextColor();
269 if ( IsControlForeground() )
270 aTextColor
= GetControlForeground();
271 SetTextColor( aTextColor
);
276 SetBackground( rStyleSettings
.GetFaceColor());
278 if ( IsBackground() )
280 SetFillColor( GetBackground().GetColor() );
286 void ScPrivatSplit::StateChanged( StateChangedType nType
)
288 if ( (nType
== StateChangedType::Zoom
) ||
289 (nType
== StateChangedType::ControlFont
) )
291 ImplInitSettings( true, false, false );
294 if ( nType
== StateChangedType::ControlForeground
)
296 ImplInitSettings( false, true, false );
299 else if ( nType
== StateChangedType::ControlBackground
)
301 ImplInitSettings( false, false, true );
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 );
317 Window::DataChanged( rDCEvt
);
320 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */