1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: privsplt.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 #include "privsplt.hxx"
38 /*************************************************************************
39 #* Member: ScPrivatSplit Datum:13.10.97
40 #*------------------------------------------------------------------------
44 #* Funktion: Konstruktor der Klasse ScPrivatSplit
50 #************************************************************************/
52 ScPrivatSplit::ScPrivatSplit( Window
* pParent
, const ResId
& rResId
,
53 SC_SPLIT_DIRECTION eSplit
):
54 Control( pParent
, rResId
)
56 Point aPos
=GetPosPixel();
57 nOldX
=(short)aPos
.X();
58 nOldY
=(short)aPos
.Y();
59 nNewX
=(short)aPos
.X();
60 nNewY
=(short)aPos
.Y();
62 aXMovingRange
.Min()=nNewX
;
63 aXMovingRange
.Max()=nNewX
;
64 aYMovingRange
.Min()=nNewY
;
65 aYMovingRange
.Max()=nNewY
;
67 aWinPointer
=GetPointer();
70 if(eScSplit
==SC_SPLIT_HORZ
)
72 aWinPointer
=Pointer(POINTER_HSPLIT
);
76 aWinPointer
=Pointer(POINTER_VSPLIT
);
78 SetPointer(aWinPointer
);
82 /*************************************************************************
83 #* Member: MouseButtonDown Datum:13.10.97
84 #*------------------------------------------------------------------------
86 #* Klasse: ScPrivatSplit
88 #* Funktion: Reagiert auf einen einzelnen Mouse-Event. Nach Aufruf
89 #* werden alle Mauseingaben an dieses Control weitergeleitet.
95 #************************************************************************/
97 void ScPrivatSplit::MouseButtonDown( const MouseEvent
& rMEvt
)
99 Point aPos
=LogicToPixel(rMEvt
.GetPosPixel());
101 nOldX
=(short)aPos
.X();
102 nOldY
=(short)aPos
.Y();
107 /*************************************************************************
108 #* Member: MouseButtonUp Datum:13.10.97
109 #*------------------------------------------------------------------------
111 #* Klasse: ScPrivatSplit
113 #* Funktion: Ende einer Benutzeraktion mit der Maus. Es werden
114 #* die aktuelle Maus- Koordinaten ermittelt und fuer
115 #* die Verschiebung des Fensters verwendet.
121 #************************************************************************/
123 void ScPrivatSplit::MouseButtonUp( const MouseEvent
& rMEvt
)
127 Point aPos
=LogicToPixel(rMEvt
.GetPosPixel());
128 Point a2Pos
=GetPosPixel();
131 if(eScSplit
==SC_SPLIT_HORZ
)
133 nNewX
=(short)aPos
.X();
136 if(a2Pos
.X()<aXMovingRange
.Min())
138 nDeltaX
=(short)(aXMovingRange
.Min()-a3Pos
.X());
139 a2Pos
.X()=aXMovingRange
.Min();
141 else if(a2Pos
.X()>aXMovingRange
.Max())
143 nDeltaX
=(short)(aXMovingRange
.Max()-a3Pos
.X());
144 a2Pos
.X()=aXMovingRange
.Max();
149 nNewY
=(short)aPos
.Y();
152 if(a2Pos
.Y()<aYMovingRange
.Min())
154 nDeltaY
=(short)(aYMovingRange
.Min()-a3Pos
.Y());
155 a2Pos
.Y()=aYMovingRange
.Min();
157 else if(a2Pos
.Y()>aYMovingRange
.Max())
159 nDeltaY
=(short)(aYMovingRange
.Max()-a3Pos
.Y());
160 a2Pos
.Y()=aYMovingRange
.Max();
169 /*************************************************************************
170 #* Member: MouseMove Datum:13.10.97
171 #*------------------------------------------------------------------------
173 #* Klasse: ScPrivatSplit
175 #* Funktion: Reagiert kontinuierlich auf Mausbewegungen. Es werden
176 #* die aktuelle Maus- Koordinaten ermittelt und fuer
177 #* die Verschiebung des Fensters verwendet.
183 #************************************************************************/
185 void ScPrivatSplit::MouseMove( const MouseEvent
& rMEvt
)
187 Point aPos
=LogicToPixel(rMEvt
.GetPosPixel());
188 Point a2Pos
=GetPosPixel();
192 if(eScSplit
==SC_SPLIT_HORZ
)
194 nNewX
=(short)aPos
.X();
198 if(a2Pos
.X()<aXMovingRange
.Min())
200 nDeltaX
=(short)(aXMovingRange
.Min()-a3Pos
.X());
201 a2Pos
.X()=aXMovingRange
.Min();
203 else if(a2Pos
.X()>aXMovingRange
.Max())
205 nDeltaX
=(short)(aXMovingRange
.Max()-a3Pos
.X());
206 a2Pos
.X()=aXMovingRange
.Max();
211 nNewY
=(short)aPos
.Y();
214 if(a2Pos
.Y()<aYMovingRange
.Min())
216 nDeltaY
=(short)(aYMovingRange
.Min()-a3Pos
.Y());
217 a2Pos
.Y()=aYMovingRange
.Min();
219 else if(a2Pos
.Y()>aYMovingRange
.Max())
221 nDeltaY
=(short)(aYMovingRange
.Max()-a3Pos
.Y());
222 a2Pos
.Y()=aYMovingRange
.Max();
234 /*************************************************************************
235 #* Member: SetYRange Datum:14.10.97
236 #*------------------------------------------------------------------------
238 #* Klasse: ScPrivatSplit
240 #* Funktion: Setzt den Range fuer die Y- Verschiebung
242 #* Input: neuer Bereich
246 #************************************************************************/
247 void ScPrivatSplit::SetYRange(Range cRgeY
)
254 /*************************************************************************
255 #* Member: GetDeltaY Datum:13.10.97
256 #*------------------------------------------------------------------------
258 #* Klasse: ScPrivatSplit
260 #* Funktion: Liefert die relative x-Verschiebung zurueck
266 #************************************************************************/
267 short ScPrivatSplit::GetDeltaX()
272 /*************************************************************************
273 #* Member: GetDeltaY Datum:13.10.97
274 #*------------------------------------------------------------------------
276 #* Klasse: ScPrivatSplit
278 #* Funktion: Liefert die relative y-Verschiebung zurueck
284 #************************************************************************/
285 short ScPrivatSplit::GetDeltaY()
290 /*************************************************************************
291 #* Member: CtrModified Datum:13.10.97
292 #*------------------------------------------------------------------------
294 #* Klasse: ScPrivatSplit
296 #* Funktion: Teilt einem installierten Handler mit, dass
297 #* eine Veraenderung eingetreten ist.
303 #************************************************************************/
304 void ScPrivatSplit::CtrModified()
306 aCtrModifiedLink
.Call( this );
309 void ScPrivatSplit::MoveSplitTo(Point aPos
)
311 Point a2Pos
=GetPosPixel();
312 nOldX
=(short)a2Pos
.X();
313 nOldY
=(short)a2Pos
.Y();
316 if(eScSplit
==SC_SPLIT_HORZ
)
318 nNewX
=(short)aPos
.X();
321 if(a2Pos
.X()<aXMovingRange
.Min())
323 nDeltaX
=(short)(aXMovingRange
.Min()-a3Pos
.X());
324 a2Pos
.X()=aXMovingRange
.Min();
326 else if(a2Pos
.X()>aXMovingRange
.Max())
328 nDeltaX
=(short)(aXMovingRange
.Max()-a3Pos
.X());
329 a2Pos
.X()=aXMovingRange
.Max();
334 nNewY
=(short)aPos
.Y();
337 if(a2Pos
.Y()<aYMovingRange
.Min())
339 nDeltaY
=(short)(aYMovingRange
.Min()-a3Pos
.Y());
340 a2Pos
.Y()=aYMovingRange
.Min();
342 else if(a2Pos
.Y()>aYMovingRange
.Max())
344 nDeltaY
=(short)(aYMovingRange
.Max()-a3Pos
.Y());
345 a2Pos
.Y()=aYMovingRange
.Max();
355 void ScPrivatSplit::ImplInitSettings( BOOL bFont
, BOOL bForeground
, BOOL bBackground
)
357 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
361 Font aFont
= rStyleSettings
.GetAppFont();
362 if ( IsControlFont() )
363 aFont
.Merge( GetControlFont() );
367 if ( bFont
|| bForeground
)
369 Color aTextColor
= rStyleSettings
.GetButtonTextColor();
370 if ( IsControlForeground() )
371 aTextColor
= GetControlForeground();
372 SetTextColor( aTextColor
);
377 SetBackground( rStyleSettings
.GetFaceColor());
379 if ( IsBackground() )
381 SetFillColor( GetBackground().GetColor() );
387 // -----------------------------------------------------------------------
389 void ScPrivatSplit::StateChanged( StateChangedType nType
)
391 if ( (nType
== STATE_CHANGE_ZOOM
) ||
392 (nType
== STATE_CHANGE_CONTROLFONT
) )
394 ImplInitSettings( TRUE
, FALSE
, FALSE
);
397 if ( nType
== STATE_CHANGE_CONTROLFOREGROUND
)
399 ImplInitSettings( FALSE
, TRUE
, FALSE
);
402 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
404 ImplInitSettings( FALSE
, FALSE
, TRUE
);
408 Control::StateChanged( nType
);
411 // -----------------------------------------------------------------------
413 void ScPrivatSplit::DataChanged( const DataChangedEvent
& rDCEvt
)
415 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
416 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
418 ImplInitSettings( TRUE
, TRUE
, TRUE
);
422 Window::DataChanged( rDCEvt
);