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: SetXRange Datum:14.10.97
236 #*------------------------------------------------------------------------
238 #* Klasse: ScPrivatSplit
240 #* Funktion: Setzt den Range fuer die X- Verschiebung
242 #* Input: neuer Bereich
246 #************************************************************************/
247 void ScPrivatSplit::SetXRange(Range cRgeX
)
252 /*************************************************************************
253 #* Member: SetYRange Datum:14.10.97
254 #*------------------------------------------------------------------------
256 #* Klasse: ScPrivatSplit
258 #* Funktion: Setzt den Range fuer die Y- Verschiebung
260 #* Input: neuer Bereich
264 #************************************************************************/
265 void ScPrivatSplit::SetYRange(Range cRgeY
)
272 /*************************************************************************
273 #* Member: GetDeltaY Datum:13.10.97
274 #*------------------------------------------------------------------------
276 #* Klasse: ScPrivatSplit
278 #* Funktion: Liefert die relative x-Verschiebung zurueck
284 #************************************************************************/
285 short ScPrivatSplit::GetDeltaX()
290 /*************************************************************************
291 #* Member: GetDeltaY Datum:13.10.97
292 #*------------------------------------------------------------------------
294 #* Klasse: ScPrivatSplit
296 #* Funktion: Liefert die relative y-Verschiebung zurueck
302 #************************************************************************/
303 short ScPrivatSplit::GetDeltaY()
308 /*************************************************************************
309 #* Member: CtrModified Datum:13.10.97
310 #*------------------------------------------------------------------------
312 #* Klasse: ScPrivatSplit
314 #* Funktion: Teilt einem installierten Handler mit, dass
315 #* eine Veraenderung eingetreten ist.
321 #************************************************************************/
322 void ScPrivatSplit::CtrModified()
324 aCtrModifiedLink
.Call( this );
327 void ScPrivatSplit::MoveSplitTo(Point aPos
)
329 Point a2Pos
=GetPosPixel();
330 nOldX
=(short)a2Pos
.X();
331 nOldY
=(short)a2Pos
.Y();
334 if(eScSplit
==SC_SPLIT_HORZ
)
336 nNewX
=(short)aPos
.X();
339 if(a2Pos
.X()<aXMovingRange
.Min())
341 nDeltaX
=(short)(aXMovingRange
.Min()-a3Pos
.X());
342 a2Pos
.X()=aXMovingRange
.Min();
344 else if(a2Pos
.X()>aXMovingRange
.Max())
346 nDeltaX
=(short)(aXMovingRange
.Max()-a3Pos
.X());
347 a2Pos
.X()=aXMovingRange
.Max();
352 nNewY
=(short)aPos
.Y();
355 if(a2Pos
.Y()<aYMovingRange
.Min())
357 nDeltaY
=(short)(aYMovingRange
.Min()-a3Pos
.Y());
358 a2Pos
.Y()=aYMovingRange
.Min();
360 else if(a2Pos
.Y()>aYMovingRange
.Max())
362 nDeltaY
=(short)(aYMovingRange
.Max()-a3Pos
.Y());
363 a2Pos
.Y()=aYMovingRange
.Max();
373 void ScPrivatSplit::ImplInitSettings( BOOL bFont
, BOOL bForeground
, BOOL bBackground
)
375 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
379 Font aFont
= rStyleSettings
.GetAppFont();
380 if ( IsControlFont() )
381 aFont
.Merge( GetControlFont() );
385 if ( bFont
|| bForeground
)
387 Color aTextColor
= rStyleSettings
.GetButtonTextColor();
388 if ( IsControlForeground() )
389 aTextColor
= GetControlForeground();
390 SetTextColor( aTextColor
);
395 SetBackground( rStyleSettings
.GetFaceColor());
397 if ( IsBackground() )
399 SetFillColor( GetBackground().GetColor() );
405 // -----------------------------------------------------------------------
407 void ScPrivatSplit::StateChanged( StateChangedType nType
)
409 if ( (nType
== STATE_CHANGE_ZOOM
) ||
410 (nType
== STATE_CHANGE_CONTROLFONT
) )
412 ImplInitSettings( TRUE
, FALSE
, FALSE
);
415 if ( nType
== STATE_CHANGE_CONTROLFOREGROUND
)
417 ImplInitSettings( FALSE
, TRUE
, FALSE
);
420 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
422 ImplInitSettings( FALSE
, FALSE
, TRUE
);
426 Control::StateChanged( nType
);
429 // -----------------------------------------------------------------------
431 void ScPrivatSplit::DataChanged( const DataChangedEvent
& rDCEvt
)
433 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
434 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
436 ImplInitSettings( TRUE
, TRUE
, TRUE
);
440 Window::DataChanged( rDCEvt
);