sync master with lastest vba changes
[ooovba.git] / sc / source / ui / formdlg / privsplt.cxx
blobcc3ad2e7f1f8ad85e825f9353f4360c75fbb1a96
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: privsplt.cxx,v $
10 * $Revision: 1.4 $
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 #*------------------------------------------------------------------------
42 #* Klasse: MD_Test
44 #* Funktion: Konstruktor der Klasse ScPrivatSplit
46 #* Input: ---
48 #* Output: ---
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();
61 eScSplit=eSplit;
62 aXMovingRange.Min()=nNewX;
63 aXMovingRange.Max()=nNewX;
64 aYMovingRange.Min()=nNewY;
65 aYMovingRange.Max()=nNewY;
67 aWinPointer=GetPointer();
69 aMovingFlag=FALSE;
70 if(eScSplit==SC_SPLIT_HORZ)
72 aWinPointer=Pointer(POINTER_HSPLIT);
74 else
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.
91 #* Input: ---
93 #* Output: ---
95 #************************************************************************/
97 void ScPrivatSplit::MouseButtonDown( const MouseEvent& rMEvt )
99 Point aPos=LogicToPixel(rMEvt.GetPosPixel());
101 nOldX=(short)aPos.X();
102 nOldY=(short)aPos.Y();
104 CaptureMouse();
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.
117 #* Input: ---
119 #* Output: ---
121 #************************************************************************/
123 void ScPrivatSplit::MouseButtonUp( const MouseEvent& rMEvt )
125 ReleaseMouse();
127 Point aPos=LogicToPixel(rMEvt.GetPosPixel());
128 Point a2Pos=GetPosPixel();
129 Point a3Pos=a2Pos;
131 if(eScSplit==SC_SPLIT_HORZ)
133 nNewX=(short)aPos.X();
134 nDeltaX=nNewX-nOldX;
135 a2Pos.X()+=nDeltaX;
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();
147 else
149 nNewY=(short)aPos.Y();
150 nDeltaY=nNewY-nOldY;
151 a2Pos.Y()+=nDeltaY;
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();
163 SetPosPixel(a2Pos);
164 Invalidate();
165 Update();
166 CtrModified();
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.
179 #* Input: ---
181 #* Output: ---
183 #************************************************************************/
185 void ScPrivatSplit::MouseMove( const MouseEvent& rMEvt )
187 Point aPos=LogicToPixel(rMEvt.GetPosPixel());
188 Point a2Pos=GetPosPixel();
189 Point a3Pos=a2Pos;
190 if(rMEvt.IsLeft())
192 if(eScSplit==SC_SPLIT_HORZ)
194 nNewX=(short)aPos.X();
195 nDeltaX=nNewX-nOldX;
196 a2Pos.X()+=nDeltaX;
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();
209 else
211 nNewY=(short)aPos.Y();
212 nDeltaY=nNewY-nOldY;
213 a2Pos.Y()+=nDeltaY;
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();
226 SetPosPixel(a2Pos);
228 CtrModified();
229 Invalidate();
230 Update();
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
244 #* Output: ---
246 #************************************************************************/
247 void ScPrivatSplit::SetXRange(Range cRgeX)
249 aXMovingRange=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
262 #* Output: ---
264 #************************************************************************/
265 void ScPrivatSplit::SetYRange(Range cRgeY)
267 aYMovingRange=cRgeY;
272 /*************************************************************************
273 #* Member: GetDeltaY Datum:13.10.97
274 #*------------------------------------------------------------------------
276 #* Klasse: ScPrivatSplit
278 #* Funktion: Liefert die relative x-Verschiebung zurueck
280 #* Input: ---
282 #* Output: ---
284 #************************************************************************/
285 short ScPrivatSplit::GetDeltaX()
287 return nDeltaX;
290 /*************************************************************************
291 #* Member: GetDeltaY Datum:13.10.97
292 #*------------------------------------------------------------------------
294 #* Klasse: ScPrivatSplit
296 #* Funktion: Liefert die relative y-Verschiebung zurueck
298 #* Input: ---
300 #* Output: ---
302 #************************************************************************/
303 short ScPrivatSplit::GetDeltaY()
305 return nDeltaY;
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.
317 #* Input: ---
319 #* Output: ---
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();
332 Point a3Pos=a2Pos;
334 if(eScSplit==SC_SPLIT_HORZ)
336 nNewX=(short)aPos.X();
337 nDeltaX=nNewX-nOldX;
338 a2Pos.X()+=nDeltaX;
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();
350 else
352 nNewY=(short)aPos.Y();
353 nDeltaY=nNewY-nOldY;
354 a2Pos.Y()+=nDeltaY;
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();
366 SetPosPixel(a2Pos);
367 Invalidate();
368 Update();
369 CtrModified();
373 void ScPrivatSplit::ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground )
375 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
377 if ( bFont )
379 Font aFont = rStyleSettings.GetAppFont();
380 if ( IsControlFont() )
381 aFont.Merge( GetControlFont() );
382 SetFont( aFont );
385 if ( bFont || bForeground )
387 Color aTextColor = rStyleSettings.GetButtonTextColor();
388 if ( IsControlForeground() )
389 aTextColor = GetControlForeground();
390 SetTextColor( aTextColor );
393 if ( bBackground )
395 SetBackground( rStyleSettings.GetFaceColor());
397 if ( IsBackground() )
399 SetFillColor( GetBackground().GetColor() );
400 SetBackground();
402 Invalidate();
405 // -----------------------------------------------------------------------
407 void ScPrivatSplit::StateChanged( StateChangedType nType )
409 if ( (nType == STATE_CHANGE_ZOOM) ||
410 (nType == STATE_CHANGE_CONTROLFONT) )
412 ImplInitSettings( TRUE, FALSE, FALSE );
413 Invalidate();
415 if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
417 ImplInitSettings( FALSE, TRUE, FALSE );
418 Invalidate();
420 else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
422 ImplInitSettings( FALSE, FALSE, TRUE );
423 Invalidate();
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 );
437 Invalidate();
439 else
440 Window::DataChanged( rDCEvt );