Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <string.h>
31 : :
32 : : #include <tools/debug.hxx>
33 : : #include <tools/rcid.h>
34 : :
35 : : #include <vcl/event.hxx>
36 : : #include <vcl/wall.hxx>
37 : : #include <vcl/bitmap.hxx>
38 : : #include <vcl/decoview.hxx>
39 : : #include <vcl/symbol.hxx>
40 : : #include <vcl/image.hxx>
41 : : #include <vcl/help.hxx>
42 : : #include <vcl/splitwin.hxx>
43 : :
44 : : #include <svdata.hxx>
45 : : #include <svids.hrc>
46 : :
47 : : // =======================================================================
48 : :
49 : : // Attention: Must not contain non-PODs because array is enlarged/copied
50 : : // with the use of memmove/memcpy.
51 : : struct ImplSplitItem
52 : : {
53 : : long mnSize;
54 : : long mnPixSize;
55 : : long mnLeft;
56 : : long mnTop;
57 : : long mnWidth;
58 : : long mnHeight;
59 : : long mnSplitPos;
60 : : long mnSplitSize;
61 : : long mnOldSplitPos;
62 : : long mnOldSplitSize;
63 : : long mnOldWidth;
64 : : long mnOldHeight;
65 : : ImplSplitSet* mpSet;
66 : : Window* mpWindow;
67 : : Window* mpOrgParent;
68 : : sal_uInt16 mnId;
69 : : SplitWindowItemBits mnBits;
70 : : sal_Bool mbFixed;
71 : : sal_Bool mbSubSize;
72 : : /// Minimal width or height of the item. -1 means no restriction.
73 : : long mnMinSize;
74 : : /// Maximal width or height of the item. -1 means no restriction.
75 : : long mnMaxSize;
76 : : };
77 : :
78 : : struct ImplSplitSet
79 : : {
80 : : ImplSplitItem* mpItems;
81 : : Wallpaper* mpWallpaper;
82 : : Bitmap* mpBitmap;
83 : : long mnLastSize;
84 : : long mnSplitSize;
85 : : sal_uInt16 mnItems;
86 : : sal_uInt16 mnId;
87 : : sal_Bool mbCalcPix;
88 : : };
89 : :
90 : :
91 : :
92 : : /** Check whether the given size is inside the valid range defined by
93 : : [rItem.mnMinSize,rItem.mnMaxSize]. When it is not inside it then return
94 : : the upper or lower bound, respectively. Otherwise return the given size
95 : : unmodified.
96 : : Note that either mnMinSize and/or mnMaxSize can be -1 in which case the
97 : : size has not lower or upper bound.
98 : : */
99 : : namespace {
100 : 0 : long ValidateSize (const long nSize, const ImplSplitItem &rItem)
101 : : {
102 [ # # ][ # # ]: 0 : if (rItem.mnMinSize>=0 && nSize<rItem.mnMinSize)
103 : 0 : return rItem.mnMinSize;
104 [ # # ][ # # ]: 0 : else if (rItem.mnMaxSize>0 && nSize>rItem.mnMaxSize)
105 : 0 : return rItem.mnMaxSize;
106 : : else
107 : 0 : return nSize;
108 : : }
109 : : }
110 : :
111 : :
112 : : #define SPLITWIN_SPLITSIZE 3
113 : : #define SPLITWIN_SPLITSIZEEX 4
114 : : #define SPLITWIN_SPLITSIZEEXLN 6
115 : : #define SPLITWIN_SPLITSIZEAUTOHIDE 36
116 : : #define SPLITWIN_SPLITSIZEFADE 36
117 : :
118 : : #define SPLIT_HORZ ((sal_uInt16)0x0001)
119 : : #define SPLIT_VERT ((sal_uInt16)0x0002)
120 : : #define SPLIT_WINDOW ((sal_uInt16)0x0004)
121 : : #define SPLIT_NOSPLIT ((sal_uInt16)0x8000)
122 : :
123 : : // =======================================================================
124 : :
125 : 23954 : static void ImplCalcBorder( WindowAlign eAlign, sal_Bool bNoAlign,
126 : : long& rLeft, long& rTop,
127 : : long& rRight, long& rBottom )
128 : : {
129 [ - + ]: 23954 : if ( bNoAlign )
130 : : {
131 : 0 : rLeft = 2;
132 : 0 : rTop = 2;
133 : 0 : rRight = 2;
134 : 0 : rBottom = 2;
135 : : }
136 : : else
137 : : {
138 [ + + + + ]: 23954 : switch ( eAlign )
139 : : {
140 : : case WINDOWALIGN_TOP:
141 : 13688 : rLeft = 2;
142 : 13688 : rTop = 2;
143 : 13688 : rRight = 2;
144 : 13688 : rBottom = 0;
145 : 13688 : break;
146 : : case WINDOWALIGN_LEFT:
147 : 3422 : rLeft = 2;
148 : 3422 : rTop = 2;
149 : 3422 : rRight = 0;
150 : 3422 : rBottom = 2;
151 : 3422 : break;
152 : : case WINDOWALIGN_BOTTOM:
153 : 3422 : rLeft = 2;
154 : 3422 : rTop = 0;
155 : 3422 : rRight = 2;
156 : 3422 : rBottom = 2;
157 : 3422 : break;
158 : : default:
159 : 3422 : rLeft = 0;
160 : 3422 : rTop = 2;
161 : 3422 : rRight = 2;
162 : 3422 : rBottom = 2;
163 : 3422 : break;
164 : : }
165 : : }
166 : 23954 : }
167 : :
168 : : // -----------------------------------------------------------------------
169 : :
170 : 463 : void SplitWindow::ImplDrawBorder( SplitWindow* pWin )
171 : : {
172 : 463 : const StyleSettings& rStyleSettings = pWin->GetSettings().GetStyleSettings();
173 : 463 : long nDX = pWin->mnDX;
174 : 463 : long nDY = pWin->mnDY;
175 : :
176 [ - + ]: 463 : if ( pWin->mbNoAlign )
177 : : {
178 : 0 : DecorationView aDecoView( pWin );
179 : 0 : Point aTmpPoint;
180 [ # # ]: 0 : Rectangle aRect( aTmpPoint, Size( nDX, nDY ) );
181 [ # # ]: 0 : aDecoView.DrawFrame( aRect, FRAME_DRAW_DOUBLEIN );
182 : : }
183 : : else
184 : : {
185 [ + + + + ]: 463 : switch ( pWin->meAlign )
186 : : {
187 : : case WINDOWALIGN_BOTTOM:
188 : 29 : pWin->SetLineColor( rStyleSettings.GetShadowColor() );
189 [ + - ]: 29 : pWin->DrawLine( Point( 0, nDY-2 ), Point( nDX-1, nDY-2 ) );
190 [ + - ]: 29 : pWin->DrawLine( Point( 0, 0 ), Point( 0, nDY-1 ) );
191 [ + - ]: 29 : pWin->DrawLine( Point( nDX-2, 0 ), Point( nDX-2, nDY-3 ) );
192 : :
193 : 29 : pWin->SetLineColor( rStyleSettings.GetLightColor() );
194 [ + - ]: 29 : pWin->DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) );
195 [ + - ]: 29 : pWin->DrawLine( Point( 1, 1 ), Point( 1, nDY-3 ) );
196 [ + - ]: 29 : pWin->DrawLine( Point( nDX-1, 0 ), Point( nDX-1, nDY-1 ) );
197 : 29 : break;
198 : : case WINDOWALIGN_TOP:
199 : 2 : pWin->SetLineColor( rStyleSettings.GetShadowColor() );
200 [ + - ]: 2 : pWin->DrawLine( Point( 0, 0 ), Point( nDX-1, 0 ) );
201 [ + - ]: 2 : pWin->DrawLine( Point( 0, 0 ), Point( 0, nDY-1 ) );
202 [ + - ]: 2 : pWin->DrawLine( Point( nDX-2, 0 ), Point( nDX-2, nDY-1 ) );
203 : :
204 : 2 : pWin->SetLineColor( rStyleSettings.GetLightColor() );
205 [ + - ]: 2 : pWin->DrawLine( Point( 1, 1 ), Point( nDX-3, 1 ) );
206 [ + - ]: 2 : pWin->DrawLine( Point( 1, 1 ), Point( 1, nDY-1 ) );
207 [ + - ]: 2 : pWin->DrawLine( Point( nDX-1, 1 ), Point( nDX-1, nDY-1 ) );
208 : 2 : break;
209 : : case WINDOWALIGN_LEFT:
210 : 225 : pWin->SetLineColor( rStyleSettings.GetShadowColor() );
211 [ + - ]: 225 : pWin->DrawLine( Point( 0, 0 ), Point( nDX-1, 0 ) );
212 [ + - ]: 225 : pWin->DrawLine( Point( 0, 0 ), Point( 0, nDY-1 ) );
213 [ + - ]: 225 : pWin->DrawLine( Point( 0, nDY-2 ), Point( nDX-1, nDY-2 ) );
214 : :
215 : 225 : pWin->SetLineColor( rStyleSettings.GetLightColor() );
216 [ + - ]: 225 : pWin->DrawLine( Point( 1, 1 ), Point( nDX-1, 1 ) );
217 [ + - ]: 225 : pWin->DrawLine( Point( 1, 1 ), Point( 1, nDY-3 ) );
218 [ + - ]: 225 : pWin->DrawLine( Point( 1, nDY-1 ), Point( nDX-1, nDY-1 ) );
219 : 225 : break;
220 : : default:
221 : 207 : pWin->SetLineColor( rStyleSettings.GetShadowColor() );
222 [ + - ]: 207 : pWin->DrawLine( Point( 0, 0 ), Point( nDX-2, 0 ) );
223 [ + - ]: 207 : pWin->DrawLine( Point( nDX-2, 0 ), Point( nDX-2, nDY-3 ) );
224 [ + - ]: 207 : pWin->DrawLine( Point( 0, nDY-2 ), Point( nDX-2, nDY-2 ) );
225 : :
226 : 207 : pWin->SetLineColor( rStyleSettings.GetLightColor() );
227 [ + - ]: 207 : pWin->DrawLine( Point( 0, 1 ), Point( nDX-3, 1 ) );
228 [ + - ]: 207 : pWin->DrawLine( Point( nDX-1, 0 ), Point( nDX-1, nDY-1 ) );
229 [ + - ]: 207 : pWin->DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) );
230 : 207 : break;
231 : : }
232 : : }
233 : 463 : }
234 : :
235 : : // -----------------------------------------------------------------------
236 : :
237 : 463 : void SplitWindow::ImplDrawBorderLine( SplitWindow* pWin )
238 : : {
239 [ - + ][ # # ]: 463 : if ( pWin->mbFadeOut || pWin->mbAutoHide )
240 : : {
241 : 463 : const StyleSettings& rStyleSettings = pWin->GetSettings().GetStyleSettings();
242 : 463 : long nDX = pWin->mnDX;
243 : 463 : long nDY = pWin->mnDY;
244 : :
245 [ + + + + : 463 : switch ( pWin->meAlign )
- ]
246 : : {
247 : : case WINDOWALIGN_LEFT:
248 : 225 : pWin->SetLineColor( rStyleSettings.GetShadowColor() );
249 [ + - ]: 225 : pWin->DrawLine( Point( nDX-SPLITWIN_SPLITSIZEEXLN-1, 0 ), Point( nDX-SPLITWIN_SPLITSIZEEXLN-1, nDY-3 ) );
250 : 225 : pWin->SetLineColor( rStyleSettings.GetLightColor() );
251 [ + - ]: 225 : pWin->DrawLine( Point( nDX-SPLITWIN_SPLITSIZEEXLN, 1 ), Point( nDX-SPLITWIN_SPLITSIZEEXLN, nDY-4 ) );
252 : 225 : break;
253 : : case WINDOWALIGN_RIGHT:
254 : 207 : pWin->SetLineColor( rStyleSettings.GetShadowColor() );
255 [ + - ]: 207 : pWin->DrawLine( Point( SPLITWIN_SPLITSIZEEXLN-1, 0 ), Point( SPLITWIN_SPLITSIZEEXLN-1, nDY-3 ) );
256 : 207 : pWin->SetLineColor( rStyleSettings.GetLightColor() );
257 [ + - ]: 207 : pWin->DrawLine( Point( SPLITWIN_SPLITSIZEEXLN, 1 ), Point( SPLITWIN_SPLITSIZEEXLN, nDY-4 ) );
258 : 207 : break;
259 : : case WINDOWALIGN_TOP:
260 : 2 : pWin->SetLineColor( rStyleSettings.GetShadowColor() );
261 [ + - ]: 2 : pWin->DrawLine( Point( 0, nDY-SPLITWIN_SPLITSIZEEXLN-1 ), Point( nDX-3, nDY-SPLITWIN_SPLITSIZEEXLN-1 ) );
262 : 2 : pWin->SetLineColor( rStyleSettings.GetLightColor() );
263 [ + - ]: 2 : pWin->DrawLine( Point( 1, nDY-SPLITWIN_SPLITSIZEEXLN ), Point( nDX-4, nDY-SPLITWIN_SPLITSIZEEXLN ) );
264 : 2 : break;
265 : : case WINDOWALIGN_BOTTOM:
266 : 29 : pWin->SetLineColor( rStyleSettings.GetShadowColor() );
267 [ + - ]: 29 : pWin->DrawLine( Point( 0, SPLITWIN_SPLITSIZEEXLN-1 ), Point( nDX-3, SPLITWIN_SPLITSIZEEXLN-1 ) );
268 : 29 : pWin->SetLineColor( rStyleSettings.GetLightColor() );
269 [ + - ]: 29 : pWin->DrawLine( Point( 1, SPLITWIN_SPLITSIZEEXLN ), Point( nDX-4, SPLITWIN_SPLITSIZEEXLN ) );
270 : 29 : break;
271 : : }
272 : : }
273 : 463 : }
274 : :
275 : : // -----------------------------------------------------------------------
276 : :
277 : 53456 : static ImplSplitSet* ImplFindSet( ImplSplitSet* pSet, sal_uInt16 nId )
278 : : {
279 [ + + ]: 53456 : if ( pSet->mnId == nId )
280 : 52208 : return pSet;
281 : :
282 : : sal_uInt16 i;
283 : 1248 : sal_uInt16 nItems = pSet->mnItems;
284 : 1248 : ImplSplitItem* pItems = pSet->mpItems;
285 : :
286 [ + - ]: 1248 : for ( i = 0; i < nItems; i++ )
287 : : {
288 [ + - ]: 1248 : if ( pItems[i].mnId == nId )
289 : 1248 : return pItems[i].mpSet;
290 : : }
291 : :
292 [ # # ]: 0 : for ( i = 0; i < nItems; i++ )
293 : : {
294 [ # # ]: 0 : if ( pItems[i].mpSet )
295 : : {
296 : 0 : ImplSplitSet* pFindSet = ImplFindSet( pItems[i].mpSet, nId );
297 [ # # ]: 0 : if ( pFindSet )
298 : 0 : return pFindSet;
299 : : }
300 : : }
301 : :
302 : 53456 : return NULL;
303 : : }
304 : :
305 : : // -----------------------------------------------------------------------
306 : :
307 : 3498 : static ImplSplitSet* ImplFindItem( ImplSplitSet* pSet, sal_uInt16 nId, sal_uInt16& rPos )
308 : : {
309 : : sal_uInt16 i;
310 : 3498 : sal_uInt16 nItems = pSet->mnItems;
311 : 3498 : ImplSplitItem* pItems = pSet->mpItems;
312 : :
313 [ + + ]: 5028 : for ( i = 0; i < nItems; i++ )
314 : : {
315 [ + + ]: 3498 : if ( pItems[i].mnId == nId )
316 : : {
317 : 1968 : rPos = i;
318 : 1968 : return pSet;
319 : : }
320 : : }
321 : :
322 [ + - ]: 1530 : for ( i = 0; i < nItems; i++ )
323 : : {
324 [ + - ]: 1530 : if ( pItems[i].mpSet )
325 : : {
326 : 1530 : ImplSplitSet* pFindSet = ImplFindItem( pItems[i].mpSet, nId, rPos );
327 [ + - ]: 1530 : if ( pFindSet )
328 : 1530 : return pFindSet;
329 : : }
330 : : }
331 : :
332 : 3498 : return NULL;
333 : : }
334 : :
335 : : // -----------------------------------------------------------------------
336 : :
337 : 252 : static sal_uInt16 ImplFindItem( ImplSplitSet* pSet, Window* pWindow )
338 : : {
339 : : sal_uInt16 i;
340 : 252 : sal_uInt16 nItems = pSet->mnItems;
341 : 252 : ImplSplitItem* pItems = pSet->mpItems;
342 : :
343 [ + - ]: 252 : for ( i = 0; i < nItems; i++ )
344 : : {
345 [ + + ]: 252 : if ( pItems[i].mpWindow == pWindow )
346 : 126 : return pItems[i].mnId;
347 : : else
348 : : {
349 [ + - ]: 126 : if ( pItems[i].mpSet )
350 : : {
351 : 126 : sal_uInt16 nId = ImplFindItem( pItems[i].mpSet, pWindow );
352 [ + - ]: 126 : if ( nId )
353 : 126 : return nId;
354 : : }
355 : : }
356 : : }
357 : :
358 : 252 : return 0;
359 : : }
360 : :
361 : : // -----------------------------------------------------------------------
362 : :
363 : 0 : static sal_uInt16 ImplFindItem( ImplSplitSet* pSet, const Point& rPos,
364 : : sal_Bool bRows, sal_Bool bDown = sal_True )
365 : : {
366 : : sal_uInt16 i;
367 : 0 : sal_uInt16 nItems = pSet->mnItems;
368 : 0 : ImplSplitItem* pItems = pSet->mpItems;
369 : :
370 [ # # ]: 0 : for ( i = 0; i < nItems; i++ )
371 : : {
372 [ # # ][ # # ]: 0 : if ( pItems[i].mnWidth && pItems[i].mnHeight )
373 : : {
374 : : // Wegen ICC auftrennen
375 : 0 : Point aPoint( pItems[i].mnLeft, pItems[i].mnTop );
376 : 0 : Size aSize( pItems[i].mnWidth, pItems[i].mnHeight );
377 [ # # ]: 0 : Rectangle aRect( aPoint, aSize );
378 [ # # ]: 0 : if ( bRows )
379 : : {
380 [ # # ]: 0 : if ( bDown )
381 : 0 : aRect.Bottom() += pSet->mnSplitSize;
382 : : else
383 : 0 : aRect.Top() -= pSet->mnSplitSize;
384 : : }
385 : : else
386 : : {
387 [ # # ]: 0 : if ( bDown )
388 : 0 : aRect.Right() += pSet->mnSplitSize;
389 : : else
390 : 0 : aRect.Left() -= pSet->mnSplitSize;
391 : : }
392 : :
393 [ # # ][ # # ]: 0 : if ( aRect.IsInside( rPos ) )
394 : : {
395 [ # # ][ # # ]: 0 : if ( pItems[i].mpSet && pItems[i].mpSet->mpItems )
396 : : {
397 : 0 : return ImplFindItem( pItems[i].mpSet, rPos,
398 [ # # ]: 0 : ((pItems[i].mnBits & SWIB_COLSET) == 0) );
399 : : }
400 : : else
401 : 0 : return pItems[i].mnId;
402 : : }
403 : : }
404 : : }
405 : :
406 : 0 : return 0;
407 : : }
408 : :
409 : : // -----------------------------------------------------------------------
410 : :
411 : 13272 : static void ImplDeleteSet( ImplSplitSet* pSet )
412 : : {
413 : : sal_uInt16 i;
414 : 13272 : sal_uInt16 nItems = pSet->mnItems;
415 : 13272 : ImplSplitItem* pItems = pSet->mpItems;
416 : :
417 [ - + ]: 13272 : for ( i = 0; i < nItems; i++ )
418 : : {
419 [ # # ]: 0 : if ( pItems[i].mpSet )
420 : 0 : ImplDeleteSet( pItems[i].mpSet );
421 : : }
422 : :
423 [ - + ]: 13272 : if ( pSet->mpWallpaper )
424 [ # # ]: 0 : delete pSet->mpWallpaper;
425 : :
426 [ - + ]: 13272 : if ( pSet->mpBitmap )
427 [ # # ]: 0 : delete pSet->mpBitmap;
428 : :
429 [ - + ]: 13272 : delete [] pItems;
430 : 13272 : delete pSet;
431 : 13272 : }
432 : :
433 : : // -----------------------------------------------------------------------
434 : :
435 : 824 : static void ImplCalcSet( ImplSplitSet* pSet,
436 : : long nSetLeft, long nSetTop,
437 : : long nSetWidth, long nSetHeight,
438 : : sal_Bool bRows, sal_Bool bDown = sal_True )
439 : : {
440 [ - + ]: 824 : if ( !pSet->mpItems )
441 : 824 : return;
442 : :
443 : : sal_uInt16 i;
444 : : sal_uInt16 j;
445 : : sal_uInt16 nMins;
446 : : sal_uInt16 nCalcItems;
447 : 824 : sal_uInt16 nItems = pSet->mnItems;
448 : : sal_uInt16 nVisItems;
449 : : sal_uInt16 nAbsItems;
450 : : long nCalcSize;
451 : : long nSizeDelta;
452 : : long nCurSize;
453 : : long nSizeWinSize;
454 : : long nNewSizeWinSize;
455 : : long nTemp;
456 : : long nTempErr;
457 : : long nErrorSum;
458 : : long nCurSizeDelta;
459 : : long nPos;
460 : : long nMaxPos;
461 : : long* pSize;
462 : 824 : ImplSplitItem* pItems = pSet->mpItems;
463 : : sal_Bool bEmpty;
464 : :
465 : : // Anzahl sichtbarer Items ermitteln
466 : 824 : nVisItems = 0;
467 [ + + ]: 1648 : for ( i = 0; i < nItems; i++ )
468 : : {
469 [ + - ]: 824 : if ( !(pItems[i].mnBits & SWIB_INVISIBLE) )
470 : 824 : nVisItems++;
471 : : }
472 : :
473 : : // Groessen berechnen
474 [ + + ]: 824 : if ( bRows )
475 : 412 : nCalcSize = nSetHeight;
476 : : else
477 : 412 : nCalcSize = nSetWidth;
478 : 824 : nCalcSize -= (nVisItems-1)*pSet->mnSplitSize;
479 : 824 : nCurSize = 0;
480 [ + + ][ + + ]: 824 : if ( pSet->mbCalcPix || (pSet->mnLastSize != nCalcSize) )
481 : : {
482 : 724 : long nPercentFactor = 10;
483 : 724 : long nRelCount = 0;
484 : 724 : long nPercent = 0;
485 : 724 : long nRelPercent = 0;
486 : 724 : long nAbsSize = 0;
487 [ + + ]: 1448 : for ( i = 0; i < nItems; i++ )
488 : : {
489 [ + - ]: 724 : if ( !(pItems[i].mnBits & SWIB_INVISIBLE) )
490 : : {
491 [ - + ]: 724 : if ( pItems[i].mnBits & SWIB_RELATIVESIZE )
492 : 0 : nRelCount += pItems[i].mnSize;
493 [ + + ]: 724 : else if ( pItems[i].mnBits & SWIB_PERCENTSIZE )
494 : 412 : nPercent += pItems[i].mnSize;
495 : : else
496 : 312 : nAbsSize += pItems[i].mnSize;
497 : : }
498 : : }
499 : : // Relative-Werte auf prozentual mappen (Percent bei uns 10tel Prozent)
500 : 724 : nPercent *= nPercentFactor;
501 [ - + ]: 724 : if ( nRelCount )
502 : : {
503 : 0 : long nRelPercentBase = 1000;
504 [ # # ][ # # ]: 0 : while ( (nRelCount > nRelPercentBase) && (nPercentFactor < 100000) )
[ # # ]
505 : : {
506 : 0 : nRelPercentBase *= 10;
507 : 0 : nPercentFactor *= 10;
508 : : }
509 [ # # ]: 0 : if ( nPercent < nRelPercentBase )
510 : : {
511 : 0 : nRelPercent = (nRelPercentBase-nPercent)/nRelCount;
512 : 0 : nPercent += nRelPercent*nRelCount;
513 : : }
514 : : else
515 : 0 : nRelPercent = 0;
516 : : }
517 [ + + ]: 724 : if ( !nPercent )
518 : 312 : nPercent = 1;
519 : 724 : nSizeDelta = nCalcSize-nAbsSize;
520 [ + + ]: 1448 : for ( i = 0; i < nItems; i++ )
521 : : {
522 [ - + ]: 724 : if ( pItems[i].mnBits & SWIB_INVISIBLE )
523 : 0 : pItems[i].mnPixSize = 0;
524 [ - + ]: 724 : else if ( pItems[i].mnBits & SWIB_RELATIVESIZE )
525 : : {
526 [ # # ]: 0 : if ( nSizeDelta <= 0 )
527 : 0 : pItems[i].mnPixSize = 0;
528 : : else
529 : 0 : pItems[i].mnPixSize = (nSizeDelta*pItems[i].mnSize*nRelPercent)/nPercent;
530 : : }
531 [ + + ]: 724 : else if ( pItems[i].mnBits & SWIB_PERCENTSIZE )
532 : : {
533 [ - + ]: 412 : if ( nSizeDelta <= 0 )
534 : 0 : pItems[i].mnPixSize = 0;
535 : : else
536 : 412 : pItems[i].mnPixSize = (nSizeDelta*pItems[i].mnSize*nPercentFactor)/nPercent;
537 : : }
538 : : else
539 : 312 : pItems[i].mnPixSize = pItems[i].mnSize;
540 : 724 : nCurSize += pItems[i].mnPixSize;
541 : : }
542 : :
543 : 724 : pSet->mbCalcPix = sal_False;
544 : 724 : pSet->mnLastSize = nCalcSize;
545 : :
546 : : // Fenster einpassen
547 : 724 : nSizeDelta = nCalcSize-nCurSize;
548 [ - + ]: 724 : if ( nSizeDelta )
549 : : {
550 : 0 : nAbsItems = 0;
551 : 0 : nSizeWinSize = 0;
552 : 0 : nNewSizeWinSize = 0;
553 : :
554 : : // Zuerst die absoluten Items relativ resizen
555 [ # # ]: 0 : for ( i = 0; i < nItems; i++ )
556 : : {
557 [ # # ]: 0 : if ( !(pItems[i].mnBits & SWIB_INVISIBLE) )
558 : : {
559 [ # # ]: 0 : if ( !(pItems[i].mnBits & (SWIB_RELATIVESIZE | SWIB_PERCENTSIZE)) )
560 : : {
561 : 0 : nAbsItems++;
562 : 0 : nSizeWinSize += pItems[i].mnPixSize;
563 : : }
564 : : }
565 : : }
566 : : // Rundungsfehler werden hier nicht ausgelichen
567 [ # # ][ # # ]: 0 : if ( (nAbsItems < (sal_uInt16)(Abs( nSizeDelta ))) && nSizeWinSize )
[ # # ]
568 : : {
569 [ # # ]: 0 : for ( i = 0; i < nItems; i++ )
570 : : {
571 [ # # ]: 0 : if ( !(pItems[i].mnBits & SWIB_INVISIBLE) )
572 : : {
573 [ # # ]: 0 : if ( !(pItems[i].mnBits & (SWIB_RELATIVESIZE | SWIB_PERCENTSIZE)) )
574 : : {
575 : 0 : pItems[i].mnPixSize += (nSizeDelta*pItems[i].mnPixSize)/nSizeWinSize;
576 : 0 : nNewSizeWinSize += pItems[i].mnPixSize;
577 : : }
578 : : }
579 : : }
580 : 0 : nSizeDelta -= nNewSizeWinSize-nSizeWinSize;
581 : : }
582 : :
583 : : // Jetzt die Rundunsfehler ausgleichen
584 : 0 : j = 0;
585 : 0 : nMins = 0;
586 [ # # ][ # # ]: 0 : while ( nSizeDelta && (nItems != nMins) )
[ # # ]
587 : : {
588 : : // Feststellen, welche Items berechnet werden duerfen
589 : 0 : nCalcItems = 0;
590 [ # # ]: 0 : while ( !nCalcItems )
591 : : {
592 [ # # ]: 0 : for ( i = 0; i < nItems; i++ )
593 : : {
594 : 0 : pItems[i].mbSubSize = sal_False;
595 : :
596 [ # # ]: 0 : if ( j >= 2 )
597 : 0 : pItems[i].mbSubSize = sal_True;
598 : : else
599 : : {
600 [ # # ]: 0 : if ( !(pItems[i].mnBits & SWIB_INVISIBLE) )
601 : : {
602 [ # # ][ # # ]: 0 : if ( (nSizeDelta > 0) || pItems[i].mnPixSize )
603 : : {
604 [ # # ]: 0 : if ( j >= 1 )
605 : 0 : pItems[i].mbSubSize = sal_True;
606 : : else
607 : : {
608 [ # # ][ # # ]: 0 : if ( (j == 0) && (pItems[i].mnBits & (SWIB_RELATIVESIZE | SWIB_PERCENTSIZE)) )
609 : 0 : pItems[i].mbSubSize = sal_True;
610 : : }
611 : : }
612 : : }
613 : : }
614 : :
615 [ # # ]: 0 : if ( pItems[i].mbSubSize )
616 : 0 : nCalcItems++;
617 : : }
618 : :
619 : 0 : j++;
620 : : }
621 : :
622 : : // Groessen von den einzelnen Items abziehen
623 : 0 : nErrorSum = nSizeDelta % nCalcItems;
624 : 0 : nCurSizeDelta = nSizeDelta / nCalcItems;
625 : 0 : nMins = 0;
626 [ # # ]: 0 : for ( i = 0; i < nItems; i++ )
627 : : {
628 [ # # ]: 0 : if ( pItems[i].mnBits & SWIB_INVISIBLE )
629 : 0 : nMins++;
630 [ # # ]: 0 : else if ( pItems[i].mbSubSize )
631 : : {
632 : 0 : pSize = &(pItems[i].mnPixSize);
633 : :
634 [ # # ]: 0 : if ( nErrorSum )
635 : : {
636 [ # # ]: 0 : if ( nErrorSum < 0 )
637 : 0 : nTempErr = -1;
638 : : else
639 : 0 : nTempErr = 1;
640 : : }
641 : : else
642 : 0 : nTempErr = 0;
643 : :
644 [ # # ]: 0 : if ( (*pSize+nCurSizeDelta+nTempErr) <= 0 )
645 : : {
646 : 0 : nTemp = *pSize;
647 [ # # ]: 0 : if ( nTemp )
648 : : {
649 : 0 : *pSize -= nTemp;
650 : 0 : nSizeDelta += nTemp;
651 : : }
652 : 0 : nMins++;
653 : : }
654 : : else
655 : : {
656 : 0 : *pSize += nCurSizeDelta;
657 : 0 : nSizeDelta -= nCurSizeDelta;
658 [ # # ][ # # ]: 0 : if ( nTempErr && (*pSize || (nTempErr > 0)) )
[ # # ]
659 : : {
660 : 0 : *pSize += nTempErr;
661 : 0 : nSizeDelta -= nTempErr;
662 : 0 : nErrorSum -= nTempErr;
663 : : }
664 : : }
665 : : }
666 : : }
667 : : }
668 : 724 : }
669 : : }
670 : : else
671 : : {
672 [ + + ]: 200 : for ( i = 0; i < nItems; i++ )
673 : : {
674 [ + - ]: 100 : if ( !(pItems[i].mnBits & SWIB_INVISIBLE) )
675 : 100 : nCurSize += pItems[i].mnPixSize;
676 : : }
677 : : }
678 : :
679 : : // Maximale Groesse berechnen
680 [ + + ]: 824 : if ( bRows )
681 : : {
682 : 412 : nPos = nSetTop;
683 [ + + ]: 412 : if ( !bDown )
684 : 34 : nMaxPos = nSetTop-nSetHeight;
685 : : else
686 : 378 : nMaxPos = nSetTop+nSetHeight;
687 : : }
688 : : else
689 : : {
690 : 412 : nPos = nSetLeft;
691 [ + + ]: 412 : if ( !bDown )
692 : 160 : nMaxPos = nSetLeft-nSetWidth;
693 : : else
694 : 252 : nMaxPos = nSetLeft+nSetWidth;
695 : : }
696 : :
697 : : // Fenster anordnen und Werte anpassen
698 [ + + ]: 1648 : for ( i = 0; i < nItems; i++ )
699 : : {
700 : 824 : pItems[i].mnOldSplitPos = pItems[i].mnSplitPos;
701 : 824 : pItems[i].mnOldSplitSize = pItems[i].mnSplitSize;
702 : 824 : pItems[i].mnOldWidth = pItems[i].mnWidth;
703 : 824 : pItems[i].mnOldHeight = pItems[i].mnHeight;
704 : :
705 [ - + ]: 824 : if ( pItems[i].mnBits & SWIB_INVISIBLE )
706 : 0 : bEmpty = sal_True;
707 : : else
708 : : {
709 : 824 : bEmpty = sal_False;
710 [ + + ]: 824 : if ( bDown )
711 : : {
712 [ - + ]: 630 : if ( nPos+pItems[i].mnPixSize > nMaxPos )
713 : 0 : bEmpty = sal_True;
714 : : }
715 : : else
716 : : {
717 : 194 : nPos -= pItems[i].mnPixSize;
718 [ - + ]: 194 : if ( nPos < nMaxPos )
719 : 0 : bEmpty = sal_True;
720 : : }
721 : : }
722 : :
723 [ - + ]: 824 : if ( bEmpty )
724 : : {
725 : 0 : pItems[i].mnWidth = 0;
726 : 0 : pItems[i].mnHeight = 0;
727 : 0 : pItems[i].mnSplitSize = 0;
728 : : }
729 : : else
730 : : {
731 [ + + ]: 824 : if ( bRows )
732 : : {
733 : 412 : pItems[i].mnLeft = nSetLeft;
734 : 412 : pItems[i].mnTop = nPos;
735 : 412 : pItems[i].mnWidth = nSetWidth;
736 : 412 : pItems[i].mnHeight = pItems[i].mnPixSize;
737 : : }
738 : : else
739 : : {
740 : 412 : pItems[i].mnLeft = nPos;
741 : 412 : pItems[i].mnTop = nSetTop;
742 : 412 : pItems[i].mnWidth = pItems[i].mnPixSize;
743 : 412 : pItems[i].mnHeight = nSetHeight;
744 : : }
745 : :
746 [ - + ]: 824 : if ( i > nItems-1 )
747 : 0 : pItems[i].mnSplitSize = 0;
748 : : else
749 : : {
750 : 824 : pItems[i].mnSplitSize = pSet->mnSplitSize;
751 [ + + ]: 824 : if ( bDown )
752 : : {
753 : 630 : pItems[i].mnSplitPos = nPos+pItems[i].mnPixSize;
754 [ + - ]: 630 : if ( pItems[i].mnSplitPos+pItems[i].mnSplitSize > nMaxPos )
755 : 630 : pItems[i].mnSplitSize = nMaxPos-pItems[i].mnSplitPos;
756 : : }
757 : : else
758 : : {
759 : 194 : pItems[i].mnSplitPos = nPos-pSet->mnSplitSize;
760 [ + - ]: 194 : if ( pItems[i].mnSplitPos < nMaxPos )
761 : 194 : pItems[i].mnSplitSize = pItems[i].mnSplitPos+pSet->mnSplitSize-nMaxPos;
762 : : }
763 : : }
764 : : }
765 : :
766 [ + - ]: 824 : if ( !(pItems[i].mnBits & SWIB_INVISIBLE) )
767 : : {
768 [ + + ]: 824 : if ( !bDown )
769 : 194 : nPos -= pSet->mnSplitSize;
770 : : else
771 : 630 : nPos += pItems[i].mnPixSize+pSet->mnSplitSize;
772 : : }
773 : : }
774 : :
775 : : // Sub-Set's berechnen
776 [ + + ]: 1648 : for ( i = 0; i < nItems; i++ )
777 : : {
778 [ + + ][ + - ]: 824 : if ( pItems[i].mpSet && pItems[i].mnWidth && pItems[i].mnHeight )
[ + - ]
779 : : {
780 : 412 : ImplCalcSet( pItems[i].mpSet,
781 : 824 : pItems[i].mnLeft, pItems[i].mnTop,
782 : 824 : pItems[i].mnWidth, pItems[i].mnHeight,
783 : 412 : ((pItems[i].mnBits & SWIB_COLSET) == 0) );
784 : : }
785 : : }
786 : :
787 : : // Fixed setzen
788 [ + + ]: 1648 : for ( i = 0; i < nItems; i++ )
789 : : {
790 : 824 : pItems[i].mbFixed = sal_False;
791 [ - + ]: 824 : if ( pItems[i].mnBits & SWIB_FIXED )
792 : 0 : pItems[i].mbFixed = sal_True;
793 : : else
794 : : {
795 : : // Wenn Child-Set vorhanden, ist dieses Item auch Fixed, wenn
796 : : // ein Child fixed ist
797 [ + + ]: 824 : if ( pItems[i].mpSet )
798 : : {
799 [ + + ]: 824 : for ( j = 0; j < pItems[i].mpSet->mnItems; j++ )
800 : : {
801 [ - + ]: 412 : if ( pItems[i].mpSet->mpItems[j].mbFixed )
802 : : {
803 : 0 : pItems[i].mbFixed = sal_True;
804 : 0 : break;
805 : : }
806 : : }
807 : : }
808 : : }
809 : : }
810 : : }
811 : :
812 : : // -----------------------------------------------------------------------
813 : :
814 : 824 : void SplitWindow::ImplCalcSet2( SplitWindow* pWindow, ImplSplitSet* pSet, sal_Bool bHide,
815 : : sal_Bool bRows, sal_Bool /*bDown*/ )
816 : : {
817 : : sal_uInt16 i;
818 : 824 : sal_uInt16 nItems = pSet->mnItems;
819 : 824 : ImplSplitItem* pItems = pSet->mpItems;
820 : :
821 [ + + ][ + - ]: 824 : if ( pWindow->IsReallyVisible() && pWindow->IsUpdateMode() && pWindow->mbInvalidate )
[ + - ][ + + ]
822 : : {
823 [ + + ]: 572 : for ( i = 0; i < nItems; i++ )
824 : : {
825 [ - + ]: 286 : if ( pItems[i].mnSplitSize )
826 : : {
827 : : // Evt. alles invalidieren oder nur einen kleinen Teil
828 [ # # ][ # # ]: 0 : if ( (pItems[i].mnOldSplitPos != pItems[i].mnSplitPos) ||
[ # # ][ # # ]
829 : 0 : (pItems[i].mnOldSplitSize != pItems[i].mnSplitSize) ||
830 : 0 : (pItems[i].mnOldWidth != pItems[i].mnWidth) ||
831 : 0 : (pItems[i].mnOldHeight != pItems[i].mnHeight) )
832 : : {
833 [ # # ]: 0 : Rectangle aRect;
834 : :
835 : : // Old Rect invalidieren
836 [ # # ]: 0 : if ( bRows )
837 : : {
838 : 0 : aRect.Left() = pItems[i].mnLeft;
839 : 0 : aRect.Right() = pItems[i].mnLeft+pItems[i].mnOldWidth-1;
840 : 0 : aRect.Top() = pItems[i].mnOldSplitPos;
841 : 0 : aRect.Bottom() = aRect.Top() + pItems[i].mnOldSplitSize;
842 : : }
843 : : else
844 : : {
845 : 0 : aRect.Top() = pItems[i].mnTop;
846 : 0 : aRect.Bottom() = pItems[i].mnTop+pItems[i].mnOldHeight-1;
847 : 0 : aRect.Left() = pItems[i].mnOldSplitPos;
848 : 0 : aRect.Right() = aRect.Left() + pItems[i].mnOldSplitSize;
849 : : }
850 [ # # ]: 0 : pWindow->Invalidate( aRect );
851 : : // New Rect invalidieren
852 [ # # ]: 0 : if ( bRows )
853 : : {
854 : 0 : aRect.Left() = pItems[i].mnLeft;
855 : 0 : aRect.Right() = pItems[i].mnLeft+pItems[i].mnWidth-1;
856 : 0 : aRect.Top() = pItems[i].mnSplitPos;
857 : 0 : aRect.Bottom() = aRect.Top() + pItems[i].mnSplitSize;
858 : : }
859 : : else
860 : : {
861 : 0 : aRect.Top() = pItems[i].mnTop;
862 : 0 : aRect.Bottom() = pItems[i].mnTop+pItems[i].mnHeight-1;
863 : 0 : aRect.Left() = pItems[i].mnSplitPos;
864 : 0 : aRect.Right() = aRect.Left() + pItems[i].mnSplitSize;
865 : : }
866 [ # # ]: 0 : pWindow->Invalidate( aRect );
867 : :
868 : : // Leere Sets komplett invalidieren, da diese Flaechen
869 : : // nicht von Fenstern ueberladen werden
870 [ # # ][ # # ]: 0 : if ( pItems[i].mpSet && !pItems[i].mpSet->mpItems )
871 : : {
872 : 0 : aRect.Left() = pItems[i].mnLeft;
873 : 0 : aRect.Top() = pItems[i].mnTop;
874 : 0 : aRect.Right() = pItems[i].mnLeft+pItems[i].mnWidth-1;
875 : 0 : aRect.Bottom() = pItems[i].mnTop+pItems[i].mnHeight-1;
876 [ # # ]: 0 : pWindow->Invalidate( aRect );
877 : : }
878 : : }
879 : : }
880 : : }
881 : : }
882 : :
883 : : // Fenster positionieren
884 [ + + ]: 1648 : for ( i = 0; i < nItems; i++ )
885 : : {
886 [ + + ]: 824 : if ( pItems[i].mpSet )
887 : : {
888 : 412 : sal_Bool bTempHide = bHide;
889 [ + - ][ - + ]: 412 : if ( !pItems[i].mnWidth || !pItems[i].mnHeight )
890 : 0 : bTempHide = sal_True;
891 : 412 : ImplCalcSet2( pWindow, pItems[i].mpSet, bTempHide,
892 : 412 : ((pItems[i].mnBits & SWIB_COLSET) == 0) );
893 : : }
894 : : else
895 : : {
896 [ + - ][ + - ]: 412 : if ( pItems[i].mnWidth && pItems[i].mnHeight && !bHide )
[ + - ]
897 : : {
898 : 412 : Point aPos( pItems[i].mnLeft, pItems[i].mnTop );
899 : 412 : Size aSize( pItems[i].mnWidth, pItems[i].mnHeight );
900 [ + - ]: 412 : pItems[i].mpWindow->SetPosSizePixel( aPos, aSize );
901 : : }
902 : : else
903 : 0 : pItems[i].mpWindow->Hide();
904 : : }
905 : : }
906 : :
907 : : // Fenster anzeigen und Flag zuruecksetzen
908 [ + + ]: 1648 : for ( i = 0; i < nItems; i++ )
909 : : {
910 [ + + ][ + - ]: 824 : if ( pItems[i].mpWindow && pItems[i].mnWidth && pItems[i].mnHeight && !bHide )
[ + - ][ + - ]
911 : 412 : pItems[i].mpWindow->Show();
912 : : }
913 : 824 : }
914 : :
915 : : // -----------------------------------------------------------------------
916 : :
917 : 0 : static void ImplCalcLogSize( ImplSplitItem* pItems, sal_uInt16 nItems )
918 : : {
919 : : // Original-Groessen updaten
920 : : sal_uInt16 i;
921 : 0 : long nRelSize = 0;
922 : 0 : long nPerSize = 0;
923 [ # # ]: 0 : for ( i = 0; i < nItems; i++ )
924 : : {
925 [ # # ]: 0 : if ( pItems[i].mnBits & SWIB_RELATIVESIZE )
926 : 0 : nRelSize += pItems[i].mnPixSize;
927 [ # # ]: 0 : else if ( pItems[i].mnBits & SWIB_PERCENTSIZE )
928 : 0 : nPerSize += pItems[i].mnPixSize;
929 : : }
930 : 0 : nPerSize += nRelSize;
931 [ # # ]: 0 : for ( i = 0; i < nItems; i++ )
932 : : {
933 [ # # ]: 0 : if ( pItems[i].mnBits & SWIB_RELATIVESIZE )
934 : : {
935 [ # # ]: 0 : if ( nRelSize )
936 : 0 : pItems[i].mnSize = (pItems[i].mnPixSize+(nRelSize/2))/nRelSize;
937 : : else
938 : 0 : pItems[i].mnSize = 1;
939 : : }
940 [ # # ]: 0 : else if ( pItems[i].mnBits & SWIB_PERCENTSIZE )
941 : : {
942 [ # # ]: 0 : if ( nPerSize )
943 : 0 : pItems[i].mnSize = (pItems[i].mnPixSize*100)/nPerSize;
944 : : else
945 : 0 : pItems[i].mnSize = 1;
946 : : }
947 : : else
948 : 0 : pItems[i].mnSize = pItems[i].mnPixSize;
949 : : }
950 : 0 : }
951 : :
952 : : // -----------------------------------------------------------------------
953 : :
954 : 0 : void SplitWindow::ImplDrawBack( SplitWindow* pWindow, const Rectangle& rRect,
955 : : const Wallpaper* pWall, const Bitmap* pBitmap )
956 : : {
957 [ # # ]: 0 : if ( pBitmap )
958 : : {
959 : 0 : Point aPos = rRect.TopLeft();
960 [ # # ]: 0 : Size aBmpSize = pBitmap->GetSizePixel();
961 [ # # ]: 0 : pWindow->Push( PUSH_CLIPREGION );
962 [ # # ]: 0 : pWindow->IntersectClipRegion( rRect );
963 [ # # ]: 0 : do
964 : : {
965 : 0 : aPos.X() = rRect.Left();
966 [ # # ]: 0 : do
967 : : {
968 [ # # ]: 0 : pWindow->DrawBitmap( aPos, *pBitmap );
969 : 0 : aPos.X() += aBmpSize.Width();
970 : : }
971 : 0 : while ( aPos.X() < rRect.Right() );
972 : 0 : aPos.Y() += aBmpSize.Height();
973 : : }
974 : 0 : while ( aPos.Y() < rRect.Bottom() );
975 [ # # ]: 0 : pWindow->Pop();
976 : : }
977 : : else
978 : 0 : pWindow->DrawWallpaper( rRect, *pWall );
979 : 0 : }
980 : :
981 : : // -----------------------------------------------------------------------
982 : :
983 : 926 : void SplitWindow::ImplDrawBack( SplitWindow* pWindow, ImplSplitSet* pSet )
984 : : {
985 : : sal_uInt16 i;
986 : 926 : sal_uInt16 nItems = pSet->mnItems;
987 : 926 : ImplSplitItem* pItems = pSet->mpItems;
988 : :
989 : : // Beim Mainset auch den Hintergrund zeichnen
990 [ + + ]: 926 : if ( pSet->mnId == 0 )
991 : : {
992 [ - + ]: 463 : if ( pSet->mpBitmap )
993 : : {
994 : : Rectangle aRect( pWindow->mnLeftBorder,
995 : : pWindow->mnTopBorder,
996 : : pWindow->mnDX-pWindow->mnRightBorder-1,
997 [ # # ]: 0 : pWindow->mnDY-pWindow->mnBottomBorder-1 );
998 [ # # ]: 0 : ImplDrawBack( pWindow, aRect, pSet->mpWallpaper, pSet->mpBitmap );
999 : : }
1000 : : }
1001 : :
1002 [ + + ]: 1852 : for ( i = 0; i < nItems; i++ )
1003 : : {
1004 : 926 : pSet = pItems[i].mpSet;
1005 [ + + ]: 926 : if ( pSet )
1006 : : {
1007 [ + - ][ - + ]: 463 : if ( pSet->mpBitmap || pSet->mpWallpaper )
1008 : : {
1009 : : // Wegen ICC auftrennen
1010 : 0 : Point aPoint( pItems[i].mnLeft, pItems[i].mnTop );
1011 : 0 : Size aSize( pItems[i].mnWidth, pItems[i].mnHeight );
1012 [ # # ]: 0 : Rectangle aRect( aPoint, aSize );
1013 [ # # ]: 0 : ImplDrawBack( pWindow, aRect, pSet->mpWallpaper, pSet->mpBitmap );
1014 : : }
1015 : : }
1016 : : }
1017 : :
1018 [ + + ]: 1852 : for ( i = 0; i < nItems; i++ )
1019 : : {
1020 [ + + ]: 926 : if ( pItems[i].mpSet )
1021 : 463 : ImplDrawBack( pWindow, pItems[i].mpSet );
1022 : : }
1023 : 926 : }
1024 : :
1025 : : // -----------------------------------------------------------------------
1026 : :
1027 : 926 : static void ImplDrawSplit( SplitWindow* pWindow, ImplSplitSet* pSet,
1028 : : sal_Bool bRows, sal_Bool bDown = sal_True )
1029 : : {
1030 [ - + ]: 926 : if ( !pSet->mpItems )
1031 : 926 : return;
1032 : :
1033 : : sal_uInt16 i;
1034 : 926 : sal_uInt16 nItems = pSet->mnItems;
1035 : : long nPos;
1036 : : long nTop;
1037 : : long nBottom;
1038 : 926 : ImplSplitItem* pItems = pSet->mpItems;
1039 : 926 : const StyleSettings& rStyleSettings = pWindow->GetSettings().GetStyleSettings();
1040 : :
1041 : 926 : sal_Bool bFlat = (pWindow->GetStyle() & WB_FLATSPLITDRAW) == WB_FLATSPLITDRAW;
1042 : :
1043 [ - + ]: 926 : for ( i = 0; i < nItems-1; i++ )
1044 : : {
1045 [ # # ]: 0 : if ( pItems[i].mnSplitSize )
1046 : : {
1047 : 0 : nPos = pItems[i].mnSplitPos;
1048 : :
1049 : 0 : long nItemSplitSize = pItems[i].mnSplitSize;
1050 : 0 : long nSplitSize = pSet->mnSplitSize;
1051 [ # # ]: 0 : if ( bRows )
1052 : : {
1053 : 0 : nTop = pItems[i].mnLeft;
1054 : 0 : nBottom = pItems[i].mnLeft+pItems[i].mnWidth-1;
1055 : :
1056 [ # # ]: 0 : if ( bFlat ) nPos--;
1057 : :
1058 [ # # ][ # # ]: 0 : if ( bDown || (nItemSplitSize >= nSplitSize) )
1059 : : {
1060 : 0 : pWindow->SetLineColor( rStyleSettings.GetLightColor() );
1061 [ # # ]: 0 : pWindow->DrawLine( Point( nTop, nPos+1 ), Point( nBottom, nPos+1 ) );
1062 : : }
1063 : 0 : nPos += nSplitSize-2;
1064 [ # # ]: 0 : if ( bFlat ) nPos+=2;
1065 [ # # ][ # # ]: 0 : if ( (!bDown && (nItemSplitSize >= 2)) ||
[ # # ][ # # ]
1066 : : (bDown && (nItemSplitSize >= nSplitSize-1)) )
1067 : : {
1068 : 0 : pWindow->SetLineColor( rStyleSettings.GetShadowColor() );
1069 [ # # ]: 0 : pWindow->DrawLine( Point( nTop, nPos ), Point( nBottom, nPos ) );
1070 : : }
1071 [ # # ]: 0 : if ( !bFlat )
1072 : : {
1073 : 0 : nPos++;
1074 [ # # ][ # # ]: 0 : if ( !bDown || (nItemSplitSize >= nSplitSize) )
1075 : : {
1076 : 0 : pWindow->SetLineColor( rStyleSettings.GetDarkShadowColor() );
1077 [ # # ]: 0 : pWindow->DrawLine( Point( nTop, nPos ), Point( nBottom, nPos ) );
1078 : : }
1079 : : }
1080 : : }
1081 : : else
1082 : : {
1083 : 0 : nTop = pItems[i].mnTop;
1084 : 0 : nBottom = pItems[i].mnTop+pSet->mpItems[i].mnHeight-1;
1085 : :
1086 [ # # ]: 0 : if ( bFlat ) nPos--;
1087 [ # # ][ # # ]: 0 : if ( bDown || (nItemSplitSize >= nSplitSize) )
1088 : : {
1089 : 0 : pWindow->SetLineColor( rStyleSettings.GetLightColor() );
1090 [ # # ]: 0 : pWindow->DrawLine( Point( nPos+1, nTop ), Point( nPos+1, nBottom ) );
1091 : : }
1092 : 0 : nPos += pSet->mnSplitSize-2;
1093 [ # # ]: 0 : if ( bFlat ) nPos+=2;
1094 [ # # ][ # # ]: 0 : if ( (!bDown && (nItemSplitSize >= 2)) ||
[ # # ][ # # ]
1095 : : (bDown && (nItemSplitSize >= nSplitSize-1)) )
1096 : : {
1097 : 0 : pWindow->SetLineColor( rStyleSettings.GetShadowColor() );
1098 [ # # ]: 0 : pWindow->DrawLine( Point( nPos, nTop ), Point( nPos, nBottom ) );
1099 : : }
1100 [ # # ]: 0 : if( !bFlat )
1101 : : {
1102 : 0 : nPos++;
1103 [ # # ][ # # ]: 0 : if ( !bDown || (nItemSplitSize >= nSplitSize) )
1104 : : {
1105 : 0 : pWindow->SetLineColor( rStyleSettings.GetDarkShadowColor() );
1106 [ # # ]: 0 : pWindow->DrawLine( Point( nPos, nTop ), Point( nPos, nBottom ) );
1107 : : }
1108 : : }
1109 : : }
1110 : : }
1111 : : }
1112 : :
1113 [ + + ]: 1852 : for ( i = 0; i < nItems; i++ )
1114 : : {
1115 [ + + ][ + - ]: 926 : if ( pItems[i].mpSet && pItems[i].mnWidth && pItems[i].mnHeight )
[ + - ]
1116 : 463 : ImplDrawSplit( pWindow, pItems[i].mpSet, ((pItems[i].mnBits & SWIB_COLSET) == 0) );
1117 : : }
1118 : : }
1119 : :
1120 : : // -----------------------------------------------------------------------
1121 : :
1122 : 0 : sal_uInt16 SplitWindow::ImplTestSplit( ImplSplitSet* pSet, const Point& rPos,
1123 : : long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos,
1124 : : sal_Bool bRows, sal_Bool /*bDown*/ )
1125 : : {
1126 [ # # ]: 0 : if ( !pSet->mpItems )
1127 : 0 : return 0;
1128 : :
1129 : : sal_uInt16 i;
1130 : : sal_uInt16 nSplitTest;
1131 : 0 : sal_uInt16 nItems = pSet->mnItems;
1132 : : long nMPos1;
1133 : : long nMPos2;
1134 : : long nPos;
1135 : : long nTop;
1136 : : long nBottom;
1137 : 0 : ImplSplitItem* pItems = pSet->mpItems;
1138 : :
1139 [ # # ]: 0 : if ( bRows )
1140 : : {
1141 : 0 : nMPos1 = rPos.X();
1142 : 0 : nMPos2 = rPos.Y();
1143 : : }
1144 : : else
1145 : : {
1146 : 0 : nMPos1 = rPos.Y();
1147 : 0 : nMPos2 = rPos.X();
1148 : : }
1149 : :
1150 [ # # ]: 0 : for ( i = 0; i < nItems-1; i++ )
1151 : : {
1152 [ # # ]: 0 : if ( pItems[i].mnSplitSize )
1153 : : {
1154 [ # # ]: 0 : if ( bRows )
1155 : : {
1156 : 0 : nTop = pItems[i].mnLeft;
1157 : 0 : nBottom = pItems[i].mnLeft+pItems[i].mnWidth-1;
1158 : : }
1159 : : else
1160 : : {
1161 : 0 : nTop = pItems[i].mnTop;
1162 : 0 : nBottom = pItems[i].mnTop+pItems[i].mnHeight-1;
1163 : : }
1164 : 0 : nPos = pItems[i].mnSplitPos;
1165 : :
1166 [ # # ][ # # ]: 0 : if ( (nMPos1 >= nTop) && (nMPos1 <= nBottom) &&
[ # # ][ # # ]
1167 : 0 : (nMPos2 >= nPos) && (nMPos2 <= nPos+pItems[i].mnSplitSize) )
1168 : : {
1169 [ # # ][ # # ]: 0 : if ( !pItems[i].mbFixed && !pItems[i+1].mbFixed )
1170 : : {
1171 : 0 : rMouseOff = nMPos2-nPos;
1172 : 0 : *ppFoundSet = pSet;
1173 : 0 : rFoundPos = i;
1174 [ # # ]: 0 : if ( bRows )
1175 : 0 : return SPLIT_VERT;
1176 : : else
1177 : 0 : return SPLIT_HORZ;
1178 : : }
1179 : : else
1180 : 0 : return SPLIT_NOSPLIT;
1181 : : }
1182 : : }
1183 : : }
1184 : :
1185 [ # # ]: 0 : for ( i = 0; i < nItems; i++ )
1186 : : {
1187 [ # # ]: 0 : if ( pItems[i].mpSet )
1188 : : {
1189 : 0 : nSplitTest = ImplTestSplit( pItems[i].mpSet, rPos,
1190 : : rMouseOff, ppFoundSet, rFoundPos,
1191 : 0 : ((pItems[i].mnBits & SWIB_COLSET) == 0) );
1192 [ # # ]: 0 : if ( nSplitTest )
1193 : 0 : return nSplitTest;
1194 : : }
1195 : : }
1196 : :
1197 : 0 : return 0;
1198 : : }
1199 : :
1200 : : // -----------------------------------------------------------------------
1201 : :
1202 : 0 : sal_uInt16 SplitWindow::ImplTestSplit( SplitWindow* pWindow, const Point& rPos,
1203 : : long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos )
1204 : : {
1205 : : // Resizeable SplitWindow muss anders behandelt werden
1206 [ # # ]: 0 : if ( pWindow->mnWinStyle & WB_SIZEABLE )
1207 : : {
1208 : : long nTPos;
1209 : : long nPos;
1210 : : long nBorder;
1211 : :
1212 [ # # ]: 0 : if ( pWindow->mbHorz )
1213 : : {
1214 [ # # ]: 0 : if ( pWindow->mbBottomRight )
1215 : : {
1216 : 0 : nBorder = pWindow->mnBottomBorder;
1217 : 0 : nPos = 0;
1218 : : }
1219 : : else
1220 : : {
1221 : 0 : nBorder = pWindow->mnTopBorder;
1222 : 0 : nPos = pWindow->mnDY-nBorder;
1223 : : }
1224 : 0 : nTPos = rPos.Y();
1225 : : }
1226 : : else
1227 : : {
1228 [ # # ]: 0 : if ( pWindow->mbBottomRight )
1229 : : {
1230 : 0 : nBorder = pWindow->mnRightBorder;
1231 : 0 : nPos = 0;
1232 : : }
1233 : : else
1234 : : {
1235 : 0 : nBorder = pWindow->mnLeftBorder;
1236 : 0 : nPos = pWindow->mnDX-nBorder;
1237 : : }
1238 : 0 : nTPos = rPos.X();
1239 : : }
1240 : 0 : long nSplitSize = pWindow->mpMainSet->mnSplitSize-2;
1241 [ # # ][ # # ]: 0 : if ( pWindow->mbAutoHide || pWindow->mbFadeOut )
1242 : 0 : nSplitSize += SPLITWIN_SPLITSIZEEXLN;
1243 [ # # ]: 0 : if ( !pWindow->mbBottomRight )
1244 : 0 : nPos -= nSplitSize;
1245 [ # # ][ # # ]: 0 : if ( (nTPos >= nPos) && (nTPos <= nPos+nSplitSize+nBorder) )
1246 : : {
1247 : 0 : rMouseOff = nTPos-nPos;
1248 : 0 : *ppFoundSet = pWindow->mpMainSet;
1249 [ # # ]: 0 : if ( pWindow->mpMainSet->mpItems )
1250 : 0 : rFoundPos = pWindow->mpMainSet->mnItems-1;
1251 : : else
1252 : 0 : rFoundPos = 0;
1253 [ # # ]: 0 : if ( pWindow->mbHorz )
1254 : 0 : return SPLIT_VERT | SPLIT_WINDOW;
1255 : : else
1256 : 0 : return SPLIT_HORZ | SPLIT_WINDOW;
1257 : : }
1258 : : }
1259 : :
1260 : : return ImplTestSplit( pWindow->mpMainSet, rPos, rMouseOff, ppFoundSet, rFoundPos,
1261 : 0 : pWindow->mbHorz, !pWindow->mbBottomRight );
1262 : : }
1263 : :
1264 : : // -----------------------------------------------------------------------
1265 : :
1266 : 0 : void SplitWindow::ImplDrawSplitTracking( SplitWindow* pThis, const Point& rPos )
1267 : : {
1268 [ # # ]: 0 : Rectangle aRect;
1269 : :
1270 [ # # ]: 0 : if ( pThis->mnSplitTest & SPLIT_HORZ )
1271 : : {
1272 : 0 : aRect.Top() = pThis->maDragRect.Top();
1273 : 0 : aRect.Bottom() = pThis->maDragRect.Bottom();
1274 : 0 : aRect.Left() = rPos.X();
1275 : 0 : aRect.Right() = aRect.Left()+pThis->mpSplitSet->mnSplitSize-1;
1276 [ # # ]: 0 : if ( !(pThis->mnWinStyle & WB_NOSPLITDRAW) )
1277 : 0 : aRect.Right()--;
1278 [ # # ][ # # ]: 0 : if ( (pThis->mnSplitTest & SPLIT_WINDOW) &&
[ # # ]
1279 : : (pThis->mbAutoHide || pThis->mbFadeOut) )
1280 : : {
1281 : 0 : aRect.Left() += SPLITWIN_SPLITSIZEEXLN;
1282 : 0 : aRect.Right() += SPLITWIN_SPLITSIZEEXLN;
1283 : : }
1284 : : }
1285 : : else
1286 : : {
1287 : 0 : aRect.Left() = pThis->maDragRect.Left();
1288 : 0 : aRect.Right() = pThis->maDragRect.Right();
1289 : 0 : aRect.Top() = rPos.Y();
1290 : 0 : aRect.Bottom() = aRect.Top()+pThis->mpSplitSet->mnSplitSize-1;
1291 [ # # ]: 0 : if ( !(pThis->mnWinStyle & WB_NOSPLITDRAW) )
1292 : 0 : aRect.Bottom()--;
1293 [ # # ][ # # ]: 0 : if ( (pThis->mnSplitTest & SPLIT_WINDOW) &&
[ # # ]
1294 : : (pThis->mbAutoHide || pThis->mbFadeOut) )
1295 : : {
1296 : 0 : aRect.Top() += SPLITWIN_SPLITSIZEEXLN;
1297 : 0 : aRect.Bottom() += SPLITWIN_SPLITSIZEEXLN;
1298 : : }
1299 : : }
1300 [ # # ]: 0 : pThis->ShowTracking( aRect, SHOWTRACK_SPLIT );
1301 : 0 : }
1302 : :
1303 : : // -----------------------------------------------------------------------
1304 : :
1305 : 13688 : void SplitWindow::ImplInit( Window* pParent, WinBits nStyle )
1306 : : {
1307 : 13688 : ImplSplitSet* pNewSet = new ImplSplitSet;
1308 : 13688 : pNewSet->mpItems = NULL;
1309 : 13688 : pNewSet->mpWallpaper = NULL;
1310 : 13688 : pNewSet->mpBitmap = NULL;
1311 : 13688 : pNewSet->mnLastSize = 0;
1312 : 13688 : pNewSet->mnItems = 0;
1313 : 13688 : pNewSet->mnId = 0;
1314 : 13688 : pNewSet->mnSplitSize = SPLITWIN_SPLITSIZE;
1315 : 13688 : pNewSet->mbCalcPix = sal_True;
1316 : :
1317 : 13688 : mpMainSet = pNewSet;
1318 : 13688 : mpBaseSet = pNewSet;
1319 : 13688 : mpSplitSet = NULL;
1320 : 13688 : mpLastSizes = NULL;
1321 : 13688 : mnDX = 0;
1322 : 13688 : mnDY = 0;
1323 : 13688 : mnLeftBorder = 0;
1324 : 13688 : mnTopBorder = 0;
1325 : 13688 : mnRightBorder = 0;
1326 : 13688 : mnBottomBorder = 0;
1327 : 13688 : mnMaxSize = 0;
1328 : 13688 : mnMouseOff = 0;
1329 : 13688 : meAlign = WINDOWALIGN_TOP;
1330 : 13688 : mnWinStyle = nStyle;
1331 : 13688 : mnSplitTest = 0;
1332 : 13688 : mnSplitPos = 0;
1333 : 13688 : mnMouseModifier = 0;
1334 : 13688 : mnMStartPos = 0;
1335 : 13688 : mnMSplitPos = 0;
1336 : 13688 : mbDragFull = sal_False;
1337 : 13688 : mbHorz = sal_True;
1338 : 13688 : mbBottomRight = sal_False;
1339 : 13688 : mbCalc = sal_False;
1340 : 13688 : mbRecalc = sal_True;
1341 : 13688 : mbInvalidate = sal_True;
1342 : 13688 : mbAutoHide = sal_False;
1343 : 13688 : mbFadeIn = sal_False;
1344 : 13688 : mbFadeOut = sal_False;
1345 : 13688 : mbAutoHideIn = sal_False;
1346 : 13688 : mbAutoHideDown = sal_False;
1347 : 13688 : mbFadeInDown = sal_False;
1348 : 13688 : mbFadeOutDown = sal_False;
1349 : 13688 : mbAutoHidePressed = sal_False;
1350 : 13688 : mbFadeInPressed = sal_False;
1351 : 13688 : mbFadeOutPressed = sal_False;
1352 : 13688 : mbFadeNoButtonMode = sal_False;
1353 : 13688 : mbNoAlign = sal_False;
1354 : :
1355 [ - + ]: 13688 : if ( nStyle & WB_NOSPLITDRAW )
1356 : : {
1357 : 0 : pNewSet->mnSplitSize -= 2;
1358 : 0 : mbInvalidate = sal_False;
1359 : : }
1360 : :
1361 [ + - ]: 13688 : if ( nStyle & WB_BORDER )
1362 : : {
1363 : : ImplCalcBorder( meAlign, mbNoAlign, mnLeftBorder, mnTopBorder,
1364 : 13688 : mnRightBorder, mnBottomBorder );
1365 : : }
1366 : : else
1367 : : {
1368 : 0 : mnLeftBorder = 0;
1369 : 0 : mnTopBorder = 0;
1370 : 0 : mnRightBorder = 0;
1371 : 0 : mnBottomBorder = 0;
1372 : : }
1373 : :
1374 : 13688 : DockingWindow::ImplInit( pParent, (nStyle | WB_CLIPCHILDREN) & ~(WB_BORDER | WB_SIZEABLE) );
1375 : :
1376 : 13688 : ImplInitSettings();
1377 : 13688 : }
1378 : :
1379 : : // -----------------------------------------------------------------------
1380 : :
1381 : 13688 : void SplitWindow::ImplInitSettings()
1382 : : {
1383 : : // Wenn fuer das MainSet eine Bitmap gesetzt wird, dann
1384 : : // brauchen wir nicht mehr den Hintergrund loeschen
1385 : : // Wenn MainSet Wallpaper hat, dann ist das der Hintergrund, ansonsten
1386 : : // sind es die Standard-Farben
1387 [ - + ]: 13688 : if ( mpMainSet->mpBitmap )
1388 : 0 : SetBackground();
1389 [ - + ]: 13688 : else if ( mpMainSet->mpWallpaper )
1390 : 0 : SetBackground( *mpMainSet->mpWallpaper );
1391 : : else
1392 : : {
1393 : 13688 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1394 : :
1395 : 13688 : Color aColor;
1396 [ - + ][ + - ]: 13688 : if ( IsControlBackground() )
1397 [ # # ]: 0 : aColor = GetControlBackground();
1398 [ + - ][ + - ]: 13688 : else if ( Window::GetStyle() & WB_3DLOOK )
1399 : 13688 : aColor = rStyleSettings.GetFaceColor();
1400 : : else
1401 : 0 : aColor = rStyleSettings.GetWindowColor();
1402 [ + - ][ + - ]: 13688 : SetBackground( aColor );
[ + - ]
1403 : : }
1404 : 13688 : }
1405 : :
1406 : : // =======================================================================
1407 : :
1408 : 13688 : SplitWindow::SplitWindow( Window* pParent, WinBits nStyle ) :
1409 [ + - ][ + - ]: 13688 : DockingWindow( WINDOW_SPLITWINDOW )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1410 : : {
1411 [ + - ]: 13688 : ImplInit( pParent, nStyle );
1412 : 13688 : }
1413 : :
1414 : : // -----------------------------------------------------------------------
1415 : :
1416 : 12960 : SplitWindow::~SplitWindow()
1417 : : {
1418 : : // Sets loeschen
1419 [ + - ]: 12960 : ImplDeleteSet( mpMainSet );
1420 : 12960 : mpMainSet = NULL; //NULL for base-class callbacks during dtoring
1421 [ - + ]: 12960 : }
1422 : :
1423 : : // -----------------------------------------------------------------------
1424 : :
1425 : 685 : void SplitWindow::ImplSetWindowSize( long nDelta )
1426 : : {
1427 [ + + ]: 685 : if ( !nDelta )
1428 : 685 : return;
1429 : :
1430 [ + - ]: 273 : Size aSize = GetSizePixel();
1431 [ - + + + ]: 273 : switch ( meAlign )
1432 : : {
1433 : : case WINDOWALIGN_TOP:
1434 : 0 : aSize.Height() += nDelta;
1435 [ # # ]: 0 : SetSizePixel( aSize );
1436 : 0 : break;
1437 : : case WINDOWALIGN_BOTTOM:
1438 : : {
1439 : 34 : maDragRect.Top() += nDelta;
1440 [ + - ]: 34 : Point aPos = GetPosPixel();
1441 : 34 : aPos.Y() -= nDelta;
1442 : 34 : aSize.Height() += nDelta;
1443 [ + - ]: 34 : SetPosSizePixel( aPos, aSize );
1444 : : break;
1445 : : }
1446 : : case WINDOWALIGN_LEFT:
1447 : 103 : aSize.Width() += nDelta;
1448 [ + - ]: 103 : SetSizePixel( aSize );
1449 : 103 : break;
1450 : : case WINDOWALIGN_RIGHT:
1451 : : default:
1452 : : {
1453 : 136 : maDragRect.Left() += nDelta;
1454 [ + - ]: 136 : Point aPos = GetPosPixel();
1455 : 136 : aPos.X() -= nDelta;
1456 : 136 : aSize.Width() += nDelta;
1457 [ + - ]: 136 : SetPosSizePixel( aPos, aSize );
1458 : : break;
1459 : : }
1460 : : }
1461 : :
1462 [ + - ]: 685 : SplitResize();
1463 : : }
1464 : :
1465 : : // -----------------------------------------------------------------------
1466 : :
1467 : 830 : Size SplitWindow::CalcLayoutSizePixel( const Size& aNewSize )
1468 : : {
1469 : 830 : Size aSize( aNewSize );
1470 : 830 : long nSplitSize = mpMainSet->mnSplitSize-2;
1471 : :
1472 [ + - ][ + + ]: 830 : if ( mbAutoHide || mbFadeOut )
1473 : 791 : nSplitSize += SPLITWIN_SPLITSIZEEXLN;
1474 : :
1475 : : // Wenn Fenster sizeable ist, wird die groesse automatisch nach
1476 : : // dem MainSet festgelegt, wenn kein relatives Fenster enthalten
1477 : : // ist
1478 [ + + ]: 830 : if ( mnWinStyle & WB_SIZEABLE )
1479 : : {
1480 : : long nCurSize;
1481 : 791 : long nCalcSize = 0;
1482 : : sal_uInt16 i;
1483 : :
1484 [ + + ]: 1582 : for ( i = 0; i < mpMainSet->mnItems; i++ )
1485 : : {
1486 [ - + ]: 791 : if ( mpMainSet->mpItems[i].mnBits & (SWIB_RELATIVESIZE | SWIB_PERCENTSIZE) )
1487 : 0 : break;
1488 : : else
1489 : 791 : nCalcSize += mpMainSet->mpItems[i].mnSize;
1490 : : }
1491 : :
1492 [ + - ]: 791 : if ( i == mpMainSet->mnItems )
1493 : : {
1494 : 791 : long nDelta = 0;
1495 [ + - ]: 791 : Point aPos = GetPosPixel();
1496 : :
1497 [ + + ]: 791 : if ( mbHorz )
1498 : 58 : nCurSize = aNewSize.Height()-mnTopBorder-mnBottomBorder;
1499 : : else
1500 : 733 : nCurSize = aNewSize.Width()-mnLeftBorder-mnRightBorder;
1501 : 791 : nCurSize -= nSplitSize;
1502 : 791 : nCurSize -= (mpMainSet->mnItems-1)*mpMainSet->mnSplitSize;
1503 : :
1504 : 791 : nDelta = nCalcSize-nCurSize;
1505 [ + + ]: 791 : if ( !nDelta )
1506 : : return aSize;
1507 : :
1508 [ + - + + ]: 39 : switch ( meAlign )
1509 : : {
1510 : : case WINDOWALIGN_TOP:
1511 : 2 : aSize.Height() += nDelta;
1512 : 2 : break;
1513 : : case WINDOWALIGN_BOTTOM:
1514 : 0 : aPos.Y() -= nDelta;
1515 : 0 : aSize.Height() += nDelta;
1516 : 0 : break;
1517 : : case WINDOWALIGN_LEFT:
1518 : 27 : aSize.Width() += nDelta;
1519 : 27 : break;
1520 : : case WINDOWALIGN_RIGHT:
1521 : : default:
1522 : 10 : aPos.X() -= nDelta;
1523 : 10 : aSize.Width() += nDelta;
1524 : 791 : break;
1525 : : }
1526 : : }
1527 : : }
1528 : :
1529 : 830 : return aSize;
1530 : : }
1531 : :
1532 : : // -----------------------------------------------------------------------
1533 : :
1534 : 1204 : void SplitWindow::ImplCalcLayout()
1535 : : {
1536 [ + + ][ + - ]: 1204 : if ( !mbCalc || !mbRecalc || !mpMainSet->mpItems )
[ + + ]
1537 : 519 : return;
1538 : :
1539 : 685 : long nSplitSize = mpMainSet->mnSplitSize-2;
1540 [ + - ][ + - ]: 685 : if ( mbAutoHide || mbFadeOut )
1541 : 685 : nSplitSize += SPLITWIN_SPLITSIZEEXLN;
1542 : :
1543 : : // Wenn Fenster sizeable ist, wird die groesse automatisch nach
1544 : : // dem MainSet festgelegt, wenn kein relatives Fenster enthalten
1545 : : // ist
1546 [ + - ]: 685 : if ( mnWinStyle & WB_SIZEABLE )
1547 : : {
1548 : : long nCurSize;
1549 : 685 : long nCalcSize = 0;
1550 : : sal_uInt16 i;
1551 : :
1552 [ + + ]: 1370 : for ( i = 0; i < mpMainSet->mnItems; i++ )
1553 : : {
1554 [ - + ]: 685 : if ( mpMainSet->mpItems[i].mnBits & (SWIB_RELATIVESIZE | SWIB_PERCENTSIZE) )
1555 : 0 : break;
1556 : : else
1557 : 685 : nCalcSize += mpMainSet->mpItems[i].mnSize;
1558 : : }
1559 : :
1560 [ + - ]: 685 : if ( i == mpMainSet->mnItems )
1561 : : {
1562 [ + + ]: 685 : if ( mbHorz )
1563 : 70 : nCurSize = mnDY-mnTopBorder-mnBottomBorder;
1564 : : else
1565 : 615 : nCurSize = mnDX-mnLeftBorder-mnRightBorder;
1566 : 685 : nCurSize -= nSplitSize;
1567 : 685 : nCurSize -= (mpMainSet->mnItems-1)*mpMainSet->mnSplitSize;
1568 : :
1569 : 685 : mbRecalc = sal_False;
1570 : 685 : ImplSetWindowSize( nCalcSize-nCurSize );
1571 : 685 : mbRecalc = sal_True;
1572 : : }
1573 : : }
1574 : :
1575 [ + + ][ + + ]: 685 : if ( (mnDX <= 0) || (mnDY <= 0) )
1576 : 273 : return;
1577 : :
1578 : : // Groessen/Position vorberechnen
1579 : : long nL;
1580 : : long nT;
1581 : : long nW;
1582 : : long nH;
1583 : :
1584 [ + + ]: 412 : if ( mbHorz )
1585 : : {
1586 [ + + ]: 36 : if ( mbBottomRight )
1587 : 34 : nT = mnDY-mnBottomBorder;
1588 : : else
1589 : 2 : nT = mnTopBorder;
1590 : 36 : nL = mnLeftBorder;
1591 : : }
1592 : : else
1593 : : {
1594 [ + + ]: 376 : if ( mbBottomRight )
1595 : 160 : nL = mnDX-mnRightBorder;
1596 : : else
1597 : 216 : nL = mnLeftBorder;
1598 : 376 : nT = mnTopBorder;
1599 : : }
1600 : 412 : nW = mnDX-mnLeftBorder-mnRightBorder;
1601 : 412 : nH = mnDY-mnTopBorder-mnBottomBorder;
1602 [ + - ]: 412 : if ( mnWinStyle & WB_SIZEABLE )
1603 : : {
1604 [ + + ]: 412 : if ( mbHorz )
1605 : 36 : nH -= nSplitSize;
1606 : : else
1607 : 376 : nW -= nSplitSize;
1608 : : }
1609 : :
1610 : : // Sets rekursiv berechnen
1611 : 412 : ImplCalcSet( mpMainSet, nL, nT, nW, nH, mbHorz, !mbBottomRight );
1612 : 412 : ImplCalcSet2( this, mpMainSet, sal_False, mbHorz, !mbBottomRight );
1613 : 1204 : mbCalc = sal_False;
1614 : : }
1615 : :
1616 : : // -----------------------------------------------------------------------
1617 : :
1618 : 40178 : void SplitWindow::ImplUpdate()
1619 : : {
1620 : 40178 : mbCalc = sal_True;
1621 : :
1622 [ + + ][ + - ]: 40178 : if ( IsReallyShown() && IsUpdateMode() && mbRecalc )
[ + + ][ + + ]
1623 : : {
1624 [ + + ]: 391 : if ( mpMainSet->mpItems )
1625 : 373 : ImplCalcLayout();
1626 : : else
1627 : 18 : Invalidate();
1628 : : }
1629 : 40178 : }
1630 : :
1631 : : // -----------------------------------------------------------------------
1632 : :
1633 : 0 : void SplitWindow::ImplSplitMousePos( Point& rMousePos )
1634 : : {
1635 [ # # ]: 0 : if ( mnSplitTest & SPLIT_HORZ )
1636 : : {
1637 : 0 : rMousePos.X() -= mnMouseOff;
1638 [ # # ]: 0 : if ( rMousePos.X() < maDragRect.Left() )
1639 : 0 : rMousePos.X() = maDragRect.Left();
1640 [ # # ]: 0 : else if ( rMousePos.X()+mpSplitSet->mnSplitSize+1 > maDragRect.Right() )
1641 : 0 : rMousePos.X() = maDragRect.Right()-mpSplitSet->mnSplitSize+1;
1642 : : // Wegen FullDrag in Screen-Koordinaaten merken
1643 : 0 : mnMSplitPos = OutputToScreenPixel( rMousePos ).X();
1644 : : }
1645 : : else
1646 : : {
1647 : 0 : rMousePos.Y() -= mnMouseOff;
1648 [ # # ]: 0 : if ( rMousePos.Y() < maDragRect.Top() )
1649 : 0 : rMousePos.Y() = maDragRect.Top();
1650 [ # # ]: 0 : else if ( rMousePos.Y()+mpSplitSet->mnSplitSize+1 > maDragRect.Bottom() )
1651 : 0 : rMousePos.Y() = maDragRect.Bottom()-mpSplitSet->mnSplitSize+1;
1652 : 0 : mnMSplitPos = OutputToScreenPixel( rMousePos ).Y();
1653 : : }
1654 : 0 : }
1655 : :
1656 : : // -----------------------------------------------------------------------
1657 : :
1658 : 463 : void SplitWindow::ImplGetButtonRect( Rectangle& rRect, long nEx, sal_Bool bTest ) const
1659 : : {
1660 : 463 : long nSplitSize = mpMainSet->mnSplitSize-2;
1661 [ + - ][ - + ]: 463 : if ( mbAutoHide || mbFadeOut || mbFadeIn )
[ # # ]
1662 : 463 : nSplitSize += SPLITWIN_SPLITSIZEEX;
1663 : :
1664 : 463 : long nButtonSize = 0;
1665 [ - + ]: 463 : if ( mbFadeIn )
1666 : 0 : nButtonSize += SPLITWIN_SPLITSIZEFADE+1;
1667 [ + - ]: 463 : if ( mbFadeOut )
1668 : 463 : nButtonSize += SPLITWIN_SPLITSIZEFADE+1;
1669 [ - + ]: 463 : if ( mbAutoHide )
1670 : 0 : nButtonSize += SPLITWIN_SPLITSIZEAUTOHIDE+1;
1671 : 463 : long nCenterEx = 0;
1672 [ + + ]: 463 : if ( mbHorz )
1673 : 31 : nCenterEx += ((mnDX-mnLeftBorder-mnRightBorder)-nButtonSize)/2;
1674 : : else
1675 : 432 : nCenterEx += ((mnDY-mnTopBorder-mnBottomBorder)-nButtonSize)/2;
1676 [ + - ]: 463 : if ( nCenterEx > 0 )
1677 : 463 : nEx += nCenterEx;
1678 : :
1679 [ + + + + : 463 : switch ( meAlign )
- ]
1680 : : {
1681 : : case WINDOWALIGN_TOP:
1682 : 2 : rRect.Left() = mnLeftBorder+nEx;
1683 : 2 : rRect.Top() = mnDY-mnBottomBorder-nSplitSize;
1684 : 2 : rRect.Right() = rRect.Left()+SPLITWIN_SPLITSIZEAUTOHIDE;
1685 : 2 : rRect.Bottom() = mnDY-mnBottomBorder-1;
1686 [ - + ]: 2 : if ( bTest )
1687 : : {
1688 : 0 : rRect.Top() -= mnTopBorder;
1689 : 0 : rRect.Bottom() += mnBottomBorder;
1690 : : }
1691 : 2 : break;
1692 : : case WINDOWALIGN_BOTTOM:
1693 : 29 : rRect.Left() = mnLeftBorder+nEx;
1694 : 29 : rRect.Top() = mnTopBorder;
1695 : 29 : rRect.Right() = rRect.Left()+SPLITWIN_SPLITSIZEAUTOHIDE;
1696 : 29 : rRect.Bottom() = mnTopBorder+nSplitSize-1;
1697 [ - + ]: 29 : if ( bTest )
1698 : : {
1699 : 0 : rRect.Top() -= mnTopBorder;
1700 : 0 : rRect.Bottom() += mnBottomBorder;
1701 : : }
1702 : 29 : break;
1703 : : case WINDOWALIGN_LEFT:
1704 : 225 : rRect.Left() = mnDX-mnRightBorder-nSplitSize;
1705 : 225 : rRect.Top() = mnTopBorder+nEx;
1706 : 225 : rRect.Right() = mnDX-mnRightBorder-1;
1707 : 225 : rRect.Bottom() = rRect.Top()+SPLITWIN_SPLITSIZEAUTOHIDE;
1708 [ - + ]: 225 : if ( bTest )
1709 : : {
1710 : 0 : rRect.Left() -= mnLeftBorder;
1711 : 0 : rRect.Right() += mnRightBorder;
1712 : : }
1713 : 225 : break;
1714 : : case WINDOWALIGN_RIGHT:
1715 : 207 : rRect.Left() = mnLeftBorder;
1716 : 207 : rRect.Top() = mnTopBorder+nEx;
1717 : 207 : rRect.Right() = mnLeftBorder+nSplitSize-1;
1718 : 207 : rRect.Bottom() = rRect.Top()+SPLITWIN_SPLITSIZEAUTOHIDE;
1719 [ - + ]: 207 : if ( bTest )
1720 : : {
1721 : 0 : rRect.Left() -= mnLeftBorder;
1722 : 0 : rRect.Right() += mnRightBorder;
1723 : : }
1724 : 207 : break;
1725 : : }
1726 : 463 : }
1727 : :
1728 : : // -----------------------------------------------------------------------
1729 : :
1730 : 0 : void SplitWindow::ImplGetAutoHideRect( Rectangle& rRect, sal_Bool bTest ) const
1731 : : {
1732 [ # # ]: 0 : Rectangle aRect;
1733 : :
1734 [ # # ]: 0 : if ( mbAutoHide )
1735 : : {
1736 : 0 : long nEx = 0;
1737 [ # # ][ # # ]: 0 : if ( mbFadeIn || mbFadeOut )
1738 : 0 : nEx = SPLITWIN_SPLITSIZEFADE+1;
1739 [ # # ][ # # ]: 0 : ImplGetButtonRect( aRect, nEx, bTest && mbFadeIn );
1740 : : }
1741 : :
1742 : 0 : rRect = aRect;
1743 : 0 : }
1744 : :
1745 : : // -----------------------------------------------------------------------
1746 : :
1747 : 0 : void SplitWindow::ImplGetFadeInRect( Rectangle& rRect, sal_Bool bTest ) const
1748 : : {
1749 [ # # ]: 0 : Rectangle aRect;
1750 : :
1751 [ # # ]: 0 : if ( mbFadeIn )
1752 : 0 : ImplGetButtonRect( aRect, 0, bTest );
1753 : :
1754 : 0 : rRect = aRect;
1755 : 0 : }
1756 : :
1757 : : // -----------------------------------------------------------------------
1758 : :
1759 : 463 : void SplitWindow::ImplGetFadeOutRect( Rectangle& rRect, sal_Bool ) const
1760 : : {
1761 [ + - ]: 463 : Rectangle aRect;
1762 : :
1763 [ + - ]: 463 : if ( mbFadeOut )
1764 : 463 : ImplGetButtonRect( aRect, 0, sal_False );
1765 : :
1766 : 463 : rRect = aRect;
1767 : 463 : }
1768 : :
1769 : : // -----------------------------------------------------------------------
1770 : :
1771 : 0 : void SplitWindow::ImplDrawButtonRect( const Rectangle& rRect, long nSize )
1772 : : {
1773 : 0 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1774 : :
1775 [ # # ]: 0 : if ( mbHorz )
1776 : : {
1777 : 0 : long nLeft = rRect.Left();
1778 : 0 : long nRight = rRect.Right();
1779 : 0 : long nCenter = rRect.Center().Y();
1780 : 0 : long nEx1 = nLeft+((rRect.GetWidth()-nSize)/2)-2;
1781 : 0 : long nEx2 = nEx1+nSize+3;
1782 : 0 : SetLineColor( rStyleSettings.GetLightColor() );
1783 [ # # ]: 0 : DrawLine( Point( rRect.Left(), rRect.Top() ), Point( rRect.Left(), rRect.Bottom() ) );
1784 [ # # ]: 0 : DrawLine( Point( rRect.Left(), rRect.Top() ), Point( rRect.Right(), rRect.Top() ) );
1785 : 0 : SetLineColor( rStyleSettings.GetShadowColor() );
1786 [ # # ]: 0 : DrawLine( Point( rRect.Right(), rRect.Top() ), Point( rRect.Right(), rRect.Bottom() ) );
1787 [ # # ]: 0 : DrawLine( Point( rRect.Left(), rRect.Bottom() ), Point( rRect.Right(), rRect.Bottom() ) );
1788 : 0 : long i = nLeft+2;
1789 [ # # ]: 0 : while ( i < nRight-3 )
1790 : : {
1791 [ # # ][ # # ]: 0 : if ( (i < nEx1) || (i > nEx2 ) )
1792 : : {
1793 [ # # ]: 0 : DrawPixel( Point( i, nCenter-2 ), rStyleSettings.GetLightColor() );
1794 [ # # ]: 0 : DrawPixel( Point( i+1, nCenter-2+1 ), rStyleSettings.GetShadowColor() );
1795 : : }
1796 : 0 : i++;
1797 [ # # ][ # # ]: 0 : if ( (i < nEx1) || ((i > nEx2 ) && (i < nRight-3)) )
[ # # ]
1798 : : {
1799 [ # # ]: 0 : DrawPixel( Point( i, nCenter+2 ), rStyleSettings.GetLightColor() );
1800 [ # # ]: 0 : DrawPixel( Point( i+1, nCenter+2+1 ), rStyleSettings.GetShadowColor() );
1801 : : }
1802 : 0 : i += 2;
1803 : : }
1804 : : }
1805 : : else
1806 : : {
1807 : 0 : long nTop = rRect.Top();
1808 : 0 : long nBottom = rRect.Bottom();
1809 : 0 : long nCenter = rRect.Center().X();
1810 : 0 : long nEx1 = nTop+((rRect.GetHeight()-nSize)/2)-2;
1811 : 0 : long nEx2 = nEx1+nSize+3;
1812 : 0 : SetLineColor( rStyleSettings.GetLightColor() );
1813 [ # # ]: 0 : DrawLine( Point( rRect.Left(), rRect.Top() ), Point( rRect.Right(), rRect.Top() ) );
1814 [ # # ]: 0 : DrawLine( Point( rRect.Left(), rRect.Top() ), Point( rRect.Left(), rRect.Bottom() ) );
1815 : 0 : SetLineColor( rStyleSettings.GetShadowColor() );
1816 [ # # ]: 0 : DrawLine( Point( rRect.Right(), rRect.Top() ), Point( rRect.Right(), rRect.Bottom() ) );
1817 [ # # ]: 0 : DrawLine( Point( rRect.Left(), rRect.Bottom() ), Point( rRect.Right(), rRect.Bottom() ) );
1818 : 0 : long i = nTop+2;
1819 [ # # ]: 0 : while ( i < nBottom-3 )
1820 : : {
1821 [ # # ][ # # ]: 0 : if ( (i < nEx1) || (i > nEx2 ) )
1822 : : {
1823 [ # # ]: 0 : DrawPixel( Point( nCenter-2, i ), rStyleSettings.GetLightColor() );
1824 [ # # ]: 0 : DrawPixel( Point( nCenter-2+1, i+1 ), rStyleSettings.GetShadowColor() );
1825 : : }
1826 : 0 : i++;
1827 [ # # ][ # # ]: 0 : if ( (i < nEx1) || ((i > nEx2 ) && (i < nBottom-3)) )
[ # # ]
1828 : : {
1829 [ # # ]: 0 : DrawPixel( Point( nCenter+2, i ), rStyleSettings.GetLightColor() );
1830 [ # # ]: 0 : DrawPixel( Point( nCenter+2+1, i+1 ), rStyleSettings.GetShadowColor() );
1831 : : }
1832 : 0 : i += 2;
1833 : : }
1834 : : }
1835 : 0 : }
1836 : :
1837 : : // -----------------------------------------------------------------------
1838 : :
1839 : 463 : void SplitWindow::ImplDrawAutoHide( sal_Bool bInPaint )
1840 : : {
1841 [ - + ]: 463 : if ( mbAutoHide )
1842 : : {
1843 [ # # ]: 0 : Rectangle aTempRect;
1844 [ # # ]: 0 : ImplGetAutoHideRect( aTempRect );
1845 : :
1846 [ # # ]: 0 : if ( !bInPaint )
1847 [ # # ]: 0 : Erase( aTempRect );
1848 : :
1849 : : // ImageListe laden, wenn noch nicht vorhanden
1850 [ # # ]: 0 : ImplSVData* pSVData = ImplGetSVData();
1851 : : ImageList* pImageList;
1852 [ # # ]: 0 : if ( mbHorz )
1853 : : {
1854 [ # # ]: 0 : if ( !pSVData->maCtrlData.mpSplitHPinImgList )
1855 : : {
1856 [ # # ]: 0 : ResMgr* pResMgr = ImplGetResMgr();
1857 [ # # ]: 0 : if( pResMgr )
1858 : : {
1859 : 0 : Color aNonAlphaMask( 0x00, 0x00, 0xFF );
1860 [ # # ][ # # ]: 0 : pSVData->maCtrlData.mpSplitHPinImgList = new ImageList(4);
1861 : : pSVData->maCtrlData.mpSplitHPinImgList->InsertFromHorizontalBitmap
1862 [ # # ]: 0 : ( ResId( SV_RESID_BITMAP_SPLITHPIN, *pResMgr ), 4, &aNonAlphaMask );
1863 : : }
1864 : : }
1865 : 0 : pImageList = pSVData->maCtrlData.mpSplitHPinImgList;
1866 : : }
1867 : : else
1868 : : {
1869 [ # # ]: 0 : if ( !pSVData->maCtrlData.mpSplitVPinImgList )
1870 : : {
1871 [ # # ]: 0 : ResMgr* pResMgr = ImplGetResMgr();
1872 [ # # ][ # # ]: 0 : pSVData->maCtrlData.mpSplitVPinImgList = new ImageList(4);
1873 [ # # ]: 0 : if( pResMgr )
1874 : : {
1875 : 0 : Color aNonAlphaMask( 0x00, 0x00, 0xFF );
1876 : : pSVData->maCtrlData.mpSplitVPinImgList->InsertFromHorizontalBitmap
1877 [ # # ]: 0 : ( ResId( SV_RESID_BITMAP_SPLITVPIN, *pResMgr ), 4, &aNonAlphaMask );
1878 : : }
1879 : : }
1880 : 0 : pImageList = pSVData->maCtrlData.mpSplitVPinImgList;
1881 : : }
1882 : :
1883 : : // Image ermitteln und zurueckgeben
1884 : : sal_uInt16 nId;
1885 [ # # ]: 0 : if ( mbAutoHidePressed )
1886 : : {
1887 [ # # ]: 0 : if ( mbAutoHideIn )
1888 : 0 : nId = 3;
1889 : : else
1890 : 0 : nId = 4;
1891 : : }
1892 : : else
1893 : : {
1894 [ # # ]: 0 : if ( mbAutoHideIn )
1895 : 0 : nId = 1;
1896 : : else
1897 : 0 : nId = 2;
1898 : : }
1899 : :
1900 [ # # ]: 0 : Image aImage = pImageList->GetImage( nId );
1901 [ # # ]: 0 : Size aImageSize = aImage.GetSizePixel();
1902 [ # # ]: 0 : Point aPos( aTempRect.Left()+((aTempRect.GetWidth()-aImageSize.Width())/2),
1903 [ # # ]: 0 : aTempRect.Top()+((aTempRect.GetHeight()-aImageSize.Height())/2) );
1904 : : long nSize;
1905 [ # # ]: 0 : if ( mbHorz )
1906 : 0 : nSize = aImageSize.Width();
1907 : : else
1908 : 0 : nSize = aImageSize.Height();
1909 [ # # ]: 0 : ImplDrawButtonRect( aTempRect, nSize );
1910 [ # # ][ # # ]: 0 : DrawImage( aPos, aImage );
1911 : : }
1912 : 463 : }
1913 : :
1914 : : // -----------------------------------------------------------------------
1915 : :
1916 : 926 : void SplitWindow::ImplDrawFadeArrow( const Point& rPt, sal_Bool bHorz, sal_Bool bLeft )
1917 : : {
1918 : 926 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1919 : :
1920 : 926 : int x( rPt.X() );
1921 : 926 : int y( rPt.Y() );
1922 : :
1923 : 926 : Color aCol;
1924 [ + + ]: 926 : if( !bHorz )
1925 : : {
1926 : 864 : int dx = 1;
1927 [ + + ]: 864 : if( bLeft )
1928 : : {
1929 : 450 : x ++;
1930 : 450 : dx = -1;
1931 : : }
1932 : :
1933 : 864 : x++; y++;
1934 : 864 : aCol = Color( COL_WHITE );
1935 [ + - ]: 864 : DrawPixel( Point(x, y), aCol );
1936 [ + - ]: 864 : DrawPixel( Point(x, y+1), aCol );
1937 [ + - ]: 864 : DrawPixel( Point(x, y+2), aCol );
1938 [ + - ]: 864 : DrawPixel( Point(x+dx, y+1), aCol );
1939 : :
1940 : 864 : x--; y--;
1941 : 864 : aCol = rStyleSettings.GetDarkShadowColor();
1942 [ + - ]: 864 : DrawPixel( Point(x, y), rStyleSettings.GetDarkShadowColor() );
1943 [ + - ]: 864 : DrawPixel( Point(x, y+1), rStyleSettings.GetDarkShadowColor() );
1944 [ + - ]: 864 : DrawPixel( Point(x, y+2), rStyleSettings.GetDarkShadowColor() );
1945 [ + - ]: 864 : DrawPixel( Point(x+dx, y+1), rStyleSettings.GetDarkShadowColor() );
1946 : : }
1947 : : else
1948 : : {
1949 : 62 : int dy = 1;
1950 [ + + ]: 62 : if( bLeft )
1951 : : {
1952 : 4 : y ++;
1953 : 4 : dy = -1;
1954 : : }
1955 : :
1956 : 62 : x++; y++;
1957 : 62 : aCol = Color( COL_WHITE );
1958 [ + - ]: 62 : DrawPixel( Point(x, y), aCol );
1959 [ + - ]: 62 : DrawPixel( Point(x+1, y), aCol );
1960 [ + - ]: 62 : DrawPixel( Point(x+2, y), aCol );
1961 [ + - ]: 62 : DrawPixel( Point(x+1, y+dy), aCol );
1962 : :
1963 : 62 : x--; y--;
1964 : 62 : aCol = rStyleSettings.GetDarkShadowColor();
1965 [ + - ]: 62 : DrawPixel( Point(x, y), aCol );
1966 [ + - ]: 62 : DrawPixel( Point(x+1, y), aCol );
1967 [ + - ]: 62 : DrawPixel( Point(x+2, y), aCol );
1968 [ + - ]: 62 : DrawPixel( Point(x+1, y+dy), aCol );
1969 : : }
1970 : 926 : }
1971 : :
1972 : 463 : void SplitWindow::ImplDrawGrip( const Rectangle& rRect, sal_Bool bHorz, sal_Bool bLeft )
1973 : : {
1974 : 463 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1975 : :
1976 [ - + ][ + - ]: 463 : if( rRect.IsInside( GetPointerPosPixel() ) )
1977 : : {
1978 [ # # ][ # # ]: 0 : DrawWallpaper( rRect, Wallpaper( Color( COL_WHITE ) ) );
[ # # ]
1979 : 0 : DrawSelectionBackground( rRect, 2, sal_False, sal_False, sal_False );
1980 : : }
1981 : :
1982 [ + + ]: 463 : if( bHorz )
1983 : : {
1984 : 31 : int width = (int) (0.5 * rRect.getWidth() + 0.5);
1985 : 31 : int i = rRect.nLeft + (rRect.getWidth() - width) / 2;
1986 : 31 : width += i;
1987 : 31 : const int y = rRect.nTop + 1;
1988 [ + - ]: 31 : ImplDrawFadeArrow( Point( i-8, y), bHorz, bLeft );
1989 [ + + ]: 186 : while( i <= width )
1990 : : {
1991 : :
1992 [ + - ]: 155 : DrawPixel( Point(i, y), rStyleSettings.GetDarkShadowColor() );
1993 [ + - ]: 155 : DrawPixel( Point(i+1, y), rStyleSettings.GetShadowColor() );
1994 : :
1995 [ + - ]: 155 : DrawPixel( Point(i, y+1), rStyleSettings.GetShadowColor() );
1996 [ + - ]: 155 : DrawPixel( Point(i+1, y+1), rStyleSettings.GetFaceColor() );
1997 [ + - ]: 155 : DrawPixel( Point(i+2, y+1), Color(COL_WHITE) );
1998 : :
1999 [ + - ]: 155 : DrawPixel( Point(i+1, y+2), Color(COL_WHITE) );
2000 [ + - ]: 155 : DrawPixel( Point(i+2, y+2), Color(COL_WHITE) );
2001 : 155 : i+=4;
2002 : : }
2003 [ + - ]: 31 : ImplDrawFadeArrow( Point( i+3, y), bHorz, bLeft );
2004 : : }
2005 : : else
2006 : : {
2007 : 432 : int height = (int) (0.5 * rRect.getHeight() + 0.5);
2008 : 432 : int i = rRect.nTop + (rRect.getHeight() - height) / 2;
2009 : 432 : height += i;
2010 : 432 : const int x = rRect.nLeft + 1;
2011 [ + - ]: 432 : ImplDrawFadeArrow( Point( x, i-8), bHorz, bLeft );
2012 [ + + ]: 2592 : while( i <= height )
2013 : : {
2014 : :
2015 [ + - ]: 2160 : DrawPixel( Point(x, i), rStyleSettings.GetDarkShadowColor() );
2016 [ + - ]: 2160 : DrawPixel( Point(x+1, i), rStyleSettings.GetShadowColor() );
2017 : :
2018 [ + - ]: 2160 : DrawPixel( Point(x, i+1), rStyleSettings.GetShadowColor() );
2019 [ + - ]: 2160 : DrawPixel( Point(x+1, i+1), rStyleSettings.GetFaceColor() );
2020 [ + - ]: 2160 : DrawPixel( Point(x+2, i+1), Color(COL_WHITE) );
2021 : :
2022 [ + - ]: 2160 : DrawPixel( Point(x+1, i+2), Color(COL_WHITE) );
2023 [ + - ]: 2160 : DrawPixel( Point(x+2, i+2), Color(COL_WHITE) );
2024 : 2160 : i+=4;
2025 : : }
2026 [ + - ]: 432 : ImplDrawFadeArrow( Point( x, i+3), bHorz, bLeft );
2027 : : }
2028 : 463 : }
2029 : :
2030 : 463 : void SplitWindow::ImplDrawFadeIn( sal_Bool bInPaint )
2031 : : {
2032 [ - + ]: 463 : if ( mbFadeIn )
2033 : : {
2034 [ # # ]: 0 : Rectangle aTempRect;
2035 [ # # ]: 0 : ImplGetFadeInRect( aTempRect );
2036 : :
2037 : 0 : sal_Bool bLeft = sal_True;
2038 [ # # ]: 0 : switch ( meAlign )
2039 : : {
2040 : : case WINDOWALIGN_TOP:
2041 : : case WINDOWALIGN_LEFT:
2042 : 0 : bLeft = sal_False;
2043 : 0 : break;
2044 : : case WINDOWALIGN_BOTTOM:
2045 : : case WINDOWALIGN_RIGHT:
2046 : : default:
2047 : 0 : bLeft = sal_True;
2048 : 0 : break;
2049 : : }
2050 : :
2051 [ # # ]: 0 : if ( !bInPaint )
2052 [ # # ]: 0 : Erase( aTempRect );
2053 : :
2054 [ # # ][ # # ]: 0 : ImplDrawGrip( aTempRect, (meAlign == WINDOWALIGN_TOP) || (meAlign == WINDOWALIGN_BOTTOM), bLeft );
[ # # ]
2055 : : }
2056 : 463 : }
2057 : :
2058 : : // -----------------------------------------------------------------------
2059 : :
2060 : 463 : void SplitWindow::ImplDrawFadeOut( sal_Bool bInPaint )
2061 : : {
2062 [ + - ]: 463 : if ( mbFadeOut )
2063 : : {
2064 [ + - ]: 463 : Rectangle aTempRect;
2065 [ + - ]: 463 : ImplGetFadeOutRect( aTempRect );
2066 : :
2067 : 463 : sal_Bool bLeft = sal_True;
2068 [ + + ]: 463 : switch ( meAlign )
2069 : : {
2070 : : case WINDOWALIGN_BOTTOM:
2071 : : case WINDOWALIGN_RIGHT:
2072 : 236 : bLeft = sal_False;
2073 : 236 : break;
2074 : : case WINDOWALIGN_TOP:
2075 : : case WINDOWALIGN_LEFT:
2076 : : default:
2077 : 227 : bLeft = sal_True;
2078 : 227 : break;
2079 : : }
2080 : :
2081 [ - + ]: 463 : if ( !bInPaint )
2082 [ # # ]: 0 : Erase( aTempRect );
2083 : :
2084 [ + + ][ + + ]: 463 : ImplDrawGrip( aTempRect, (meAlign == WINDOWALIGN_TOP) || (meAlign == WINDOWALIGN_BOTTOM), bLeft );
[ + - ]
2085 : : }
2086 : 463 : }
2087 : :
2088 : : // -----------------------------------------------------------------------
2089 : 0 : void SplitWindow::ImplStartSplit( const MouseEvent& rMEvt )
2090 : : {
2091 : 0 : Point aMousePosPixel = rMEvt.GetPosPixel();
2092 [ # # ]: 0 : mnSplitTest = ImplTestSplit( this, aMousePosPixel, mnMouseOff, &mpSplitSet, mnSplitPos );
2093 : :
2094 [ # # ][ # # ]: 0 : if ( mnSplitTest && !(mnSplitTest & SPLIT_NOSPLIT) )
2095 : : {
2096 : : ImplSplitItem* pSplitItem;
2097 : : long nCurMaxSize;
2098 : : sal_uInt16 nTemp;
2099 : : sal_Bool bDown;
2100 : : sal_Bool bPropSmaller;
2101 : :
2102 : 0 : mnMouseModifier = rMEvt.GetModifier();
2103 [ # # ][ # # ]: 0 : if ( !(mnMouseModifier & KEY_SHIFT) || (mnSplitPos+1 >= mpSplitSet->mnItems) )
2104 : 0 : bPropSmaller = sal_False;
2105 : : else
2106 : 0 : bPropSmaller = sal_True;
2107 : :
2108 : : // Hier kann noch die maximale Groesse gesetzt werden
2109 [ # # ]: 0 : StartSplit();
2110 : :
2111 [ # # ]: 0 : if ( mnMaxSize )
2112 : 0 : nCurMaxSize = mnMaxSize;
2113 : : else
2114 : : {
2115 [ # # ]: 0 : Size aSize = GetParent()->GetOutputSizePixel();
2116 [ # # ]: 0 : if ( mbHorz )
2117 : 0 : nCurMaxSize = aSize.Height();
2118 : : else
2119 : 0 : nCurMaxSize = aSize.Width();
2120 : : }
2121 : :
2122 [ # # ]: 0 : if ( mpSplitSet->mpItems )
2123 : : {
2124 : 0 : bDown = sal_True;
2125 [ # # ][ # # ]: 0 : if ( (mpSplitSet == mpMainSet) && mbBottomRight )
2126 : 0 : bDown = sal_False;
2127 : :
2128 : 0 : pSplitItem = &(mpSplitSet->mpItems[mnSplitPos]);
2129 : 0 : maDragRect.Left() = pSplitItem->mnLeft;
2130 : 0 : maDragRect.Top() = pSplitItem->mnTop;
2131 : 0 : maDragRect.Right() = pSplitItem->mnLeft+pSplitItem->mnWidth-1;
2132 : 0 : maDragRect.Bottom() = pSplitItem->mnTop+pSplitItem->mnHeight-1;
2133 : :
2134 [ # # ]: 0 : if ( mnSplitTest & SPLIT_HORZ )
2135 : : {
2136 [ # # ]: 0 : if ( bDown )
2137 : 0 : maDragRect.Right() += mpSplitSet->mnSplitSize;
2138 : : else
2139 : 0 : maDragRect.Left() -= mpSplitSet->mnSplitSize;
2140 : : }
2141 : : else
2142 : : {
2143 [ # # ]: 0 : if ( bDown )
2144 : 0 : maDragRect.Bottom() += mpSplitSet->mnSplitSize;
2145 : : else
2146 : 0 : maDragRect.Top() -= mpSplitSet->mnSplitSize;
2147 : : }
2148 : :
2149 [ # # ]: 0 : if ( mnSplitPos )
2150 : : {
2151 : 0 : nTemp = mnSplitPos;
2152 [ # # ]: 0 : while ( nTemp )
2153 : : {
2154 : 0 : pSplitItem = &(mpSplitSet->mpItems[nTemp-1]);
2155 [ # # ]: 0 : if ( pSplitItem->mbFixed )
2156 : 0 : break;
2157 : : else
2158 : : {
2159 [ # # ]: 0 : if ( mnSplitTest & SPLIT_HORZ )
2160 : : {
2161 [ # # ]: 0 : if ( bDown )
2162 : 0 : maDragRect.Left() -= pSplitItem->mnPixSize;
2163 : : else
2164 : 0 : maDragRect.Right() += pSplitItem->mnPixSize;
2165 : : }
2166 : : else
2167 : : {
2168 [ # # ]: 0 : if ( bDown )
2169 : 0 : maDragRect.Top() -= pSplitItem->mnPixSize;
2170 : : else
2171 : 0 : maDragRect.Bottom() += pSplitItem->mnPixSize;
2172 : : }
2173 : : }
2174 : 0 : nTemp--;
2175 : : }
2176 : : }
2177 : :
2178 [ # # ][ # # ]: 0 : if ( (mpSplitSet == mpMainSet) && (mnWinStyle & WB_SIZEABLE) && !bPropSmaller )
[ # # ]
2179 : : {
2180 [ # # ]: 0 : if ( bDown )
2181 : : {
2182 [ # # ]: 0 : if ( mbHorz )
2183 : 0 : maDragRect.Bottom() += nCurMaxSize-mnDY-mnTopBorder;
2184 : : else
2185 : 0 : maDragRect.Right() += nCurMaxSize-mnDX-mnLeftBorder;
2186 : : }
2187 : : else
2188 : : {
2189 [ # # ]: 0 : if ( mbHorz )
2190 : 0 : maDragRect.Top() -= nCurMaxSize-mnDY-mnBottomBorder;
2191 : : else
2192 : 0 : maDragRect.Left() -= nCurMaxSize-mnDX-mnRightBorder;
2193 : : }
2194 : : }
2195 : : else
2196 : : {
2197 : 0 : nTemp = mnSplitPos+1;
2198 [ # # ]: 0 : while ( nTemp < mpSplitSet->mnItems )
2199 : : {
2200 : 0 : pSplitItem = &(mpSplitSet->mpItems[nTemp]);
2201 [ # # ]: 0 : if ( pSplitItem->mbFixed )
2202 : 0 : break;
2203 : : else
2204 : : {
2205 [ # # ]: 0 : if ( mnSplitTest & SPLIT_HORZ )
2206 : : {
2207 [ # # ]: 0 : if ( bDown )
2208 : 0 : maDragRect.Right() += pSplitItem->mnPixSize;
2209 : : else
2210 : 0 : maDragRect.Left() -= pSplitItem->mnPixSize;
2211 : : }
2212 : : else
2213 : : {
2214 [ # # ]: 0 : if ( bDown )
2215 : 0 : maDragRect.Bottom() += pSplitItem->mnPixSize;
2216 : : else
2217 : 0 : maDragRect.Top() -= pSplitItem->mnPixSize;
2218 : : }
2219 : : }
2220 : 0 : nTemp++;
2221 : : }
2222 : : }
2223 : : }
2224 : : else
2225 : : {
2226 : 0 : maDragRect.Left() = mnLeftBorder;
2227 : 0 : maDragRect.Top() = mnTopBorder;
2228 : 0 : maDragRect.Right() = mnDX-mnRightBorder-1;
2229 : 0 : maDragRect.Bottom() = mnDY-mnBottomBorder-1;
2230 [ # # ]: 0 : if ( mbHorz )
2231 : : {
2232 [ # # ]: 0 : if ( mbBottomRight )
2233 : 0 : maDragRect.Top() -= nCurMaxSize-mnDY-mnBottomBorder;
2234 : : else
2235 : 0 : maDragRect.Bottom() += nCurMaxSize-mnDY-mnTopBorder;
2236 : : }
2237 : : else
2238 : : {
2239 [ # # ]: 0 : if ( mbBottomRight )
2240 : 0 : maDragRect.Left() -= nCurMaxSize-mnDX-mnRightBorder;
2241 : : else
2242 : 0 : maDragRect.Right() += nCurMaxSize-mnDX-mnLeftBorder;
2243 : : }
2244 : : }
2245 : :
2246 [ # # ]: 0 : StartTracking();
2247 : :
2248 : 0 : mbDragFull = (GetSettings().GetStyleSettings().GetDragFullOptions() & DRAGFULL_OPTION_SPLIT) != 0;
2249 : :
2250 [ # # ]: 0 : ImplSplitMousePos( aMousePosPixel );
2251 : :
2252 [ # # ]: 0 : if ( !mbDragFull )
2253 [ # # ]: 0 : ImplDrawSplitTracking( this, aMousePosPixel );
2254 : : else
2255 : : {
2256 : 0 : ImplSplitItem* pItems = mpSplitSet->mpItems;
2257 : 0 : sal_uInt16 nItems = mpSplitSet->mnItems;
2258 [ # # ]: 0 : mpLastSizes = new long[nItems*2];
2259 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < nItems; i++ )
2260 : : {
2261 : 0 : mpLastSizes[i*2] = pItems[i].mnSize;
2262 : 0 : mpLastSizes[i*2+1] = pItems[i].mnPixSize;
2263 : : }
2264 : : }
2265 : 0 : mnMStartPos = mnMSplitPos;
2266 : :
2267 : 0 : PointerStyle eStyle = POINTER_ARROW;
2268 [ # # ]: 0 : if ( mnSplitTest & SPLIT_HORZ )
2269 : 0 : eStyle = POINTER_HSPLIT;
2270 [ # # ]: 0 : else if ( mnSplitTest & SPLIT_VERT )
2271 : 0 : eStyle = POINTER_VSPLIT;
2272 : :
2273 : 0 : Pointer aPtr( eStyle );
2274 [ # # ]: 0 : SetPointer( aPtr );
2275 : : }
2276 : 0 : }
2277 : :
2278 : :
2279 : : // -----------------------------------------------------------------------
2280 : :
2281 : 0 : void SplitWindow::StartSplit()
2282 : : {
2283 : 0 : maStartSplitHdl.Call( this );
2284 : 0 : }
2285 : :
2286 : : // -----------------------------------------------------------------------
2287 : :
2288 : 0 : void SplitWindow::Split()
2289 : : {
2290 : 0 : maSplitHdl.Call( this );
2291 : 0 : }
2292 : :
2293 : : // -----------------------------------------------------------------------
2294 : :
2295 : 0 : void SplitWindow::SplitResize()
2296 : : {
2297 : 0 : maSplitResizeHdl.Call( this );
2298 : 0 : }
2299 : :
2300 : : // -----------------------------------------------------------------------
2301 : :
2302 : 0 : void SplitWindow::AutoHide()
2303 : : {
2304 : 0 : maAutoHideHdl.Call( this );
2305 : 0 : }
2306 : :
2307 : : // -----------------------------------------------------------------------
2308 : :
2309 : 0 : void SplitWindow::FadeIn()
2310 : : {
2311 : 0 : maFadeInHdl.Call( this );
2312 : 0 : }
2313 : :
2314 : : // -----------------------------------------------------------------------
2315 : :
2316 : 0 : void SplitWindow::FadeOut()
2317 : : {
2318 : 0 : maFadeOutHdl.Call( this );
2319 : 0 : }
2320 : :
2321 : : // -----------------------------------------------------------------------
2322 : :
2323 : 0 : void SplitWindow::MouseButtonDown( const MouseEvent& rMEvt )
2324 : : {
2325 [ # # ][ # # ]: 0 : if ( !rMEvt.IsLeft() || rMEvt.IsMod2() )
[ # # ]
2326 : : {
2327 [ # # ]: 0 : DockingWindow::MouseButtonDown( rMEvt );
2328 : : return;
2329 : : }
2330 : :
2331 : 0 : Point aMousePosPixel = rMEvt.GetPosPixel();
2332 [ # # ]: 0 : Rectangle aTestRect;
2333 : :
2334 : 0 : mbFadeNoButtonMode = sal_False;
2335 [ # # ]: 0 : ImplGetAutoHideRect( aTestRect, sal_True );
2336 [ # # ][ # # ]: 0 : if ( aTestRect.IsInside( aMousePosPixel ) )
2337 : : {
2338 : 0 : mbAutoHideDown = sal_True;
2339 : 0 : mbAutoHidePressed = sal_True;
2340 [ # # ]: 0 : ImplDrawAutoHide( sal_False );
2341 : : }
2342 : : else
2343 : : {
2344 [ # # ]: 0 : ImplGetFadeOutRect( aTestRect, sal_True );
2345 [ # # ][ # # ]: 0 : if ( aTestRect.IsInside( aMousePosPixel ) )
2346 : : {
2347 : 0 : mbFadeOutDown = sal_True;
2348 : 0 : mbFadeOutPressed = sal_True;
2349 [ # # ]: 0 : ImplDrawFadeOut( sal_False );
2350 : : }
2351 : : else
2352 : : {
2353 [ # # ]: 0 : ImplGetFadeInRect( aTestRect, sal_True );
2354 [ # # ][ # # ]: 0 : if ( aTestRect.IsInside( aMousePosPixel ) )
2355 : : {
2356 : 0 : mbFadeInDown = sal_True;
2357 : 0 : mbFadeInPressed = sal_True;
2358 [ # # ]: 0 : ImplDrawFadeIn( sal_False );
2359 : : }
2360 [ # # ][ # # ]: 0 : else if ( !aTestRect.IsEmpty() && !(mnWinStyle & WB_SIZEABLE) )
[ # # ][ # # ]
2361 : : {
2362 : 0 : mbFadeNoButtonMode = sal_True;
2363 [ # # ]: 0 : FadeIn();
2364 : : return;
2365 : : }
2366 : : }
2367 : : }
2368 : :
2369 [ # # ][ # # ]: 0 : if ( mbAutoHideDown || mbFadeInDown || mbFadeOutDown )
[ # # ]
2370 [ # # ]: 0 : StartTracking();
2371 : : else
2372 [ # # ]: 0 : ImplStartSplit( rMEvt );
2373 : : }
2374 : :
2375 : : // -----------------------------------------------------------------------
2376 : :
2377 : 0 : void SplitWindow::MouseMove( const MouseEvent& rMEvt )
2378 : : {
2379 [ # # ]: 0 : if ( !IsTracking() )
2380 : : {
2381 : 0 : Point aPos = rMEvt.GetPosPixel();
2382 : : long nTemp;
2383 : : ImplSplitSet* pTempSplitSet;
2384 : : sal_uInt16 nTempSplitPos;
2385 [ # # ]: 0 : sal_uInt16 nSplitTest = ImplTestSplit( this, aPos, nTemp, &pTempSplitSet, nTempSplitPos );
2386 : 0 : PointerStyle eStyle = POINTER_ARROW;
2387 [ # # ]: 0 : Rectangle aAutoHideRect;
2388 [ # # ]: 0 : Rectangle aFadeInRect;
2389 [ # # ]: 0 : Rectangle aFadeOutRect;
2390 : :
2391 [ # # ]: 0 : ImplGetAutoHideRect( aAutoHideRect );
2392 [ # # ]: 0 : ImplGetFadeInRect( aFadeInRect );
2393 [ # # ]: 0 : ImplGetFadeOutRect( aFadeOutRect );
2394 [ # # ][ # # ]: 0 : if ( !aAutoHideRect.IsInside( aPos ) &&
[ # # ][ # # ]
[ # # ]
2395 [ # # ]: 0 : !aFadeInRect.IsInside( aPos ) &&
2396 [ # # ]: 0 : !aFadeOutRect.IsInside( aPos ) )
2397 : : {
2398 [ # # ][ # # ]: 0 : if ( nSplitTest && !(nSplitTest & SPLIT_NOSPLIT) )
2399 : : {
2400 [ # # ]: 0 : if ( nSplitTest & SPLIT_HORZ )
2401 : 0 : eStyle = POINTER_HSPLIT;
2402 [ # # ]: 0 : else if ( nSplitTest & SPLIT_VERT )
2403 : 0 : eStyle = POINTER_VSPLIT;
2404 : : }
2405 : : }
2406 : :
2407 : 0 : Pointer aPtr( eStyle );
2408 [ # # ]: 0 : SetPointer( aPtr );
2409 : : }
2410 : 0 : }
2411 : :
2412 : : // -----------------------------------------------------------------------
2413 : :
2414 : 0 : void SplitWindow::Tracking( const TrackingEvent& rTEvt )
2415 : : {
2416 : 0 : Point aMousePosPixel = rTEvt.GetMouseEvent().GetPosPixel();
2417 : :
2418 [ # # ]: 0 : if ( mbAutoHideDown )
2419 : : {
2420 [ # # ]: 0 : if ( rTEvt.IsTrackingEnded() )
2421 : : {
2422 : 0 : mbAutoHideDown = sal_False;
2423 [ # # ]: 0 : if ( mbAutoHidePressed )
2424 : : {
2425 : 0 : mbAutoHidePressed = sal_False;
2426 : :
2427 [ # # ]: 0 : if ( !rTEvt.IsTrackingCanceled() )
2428 : : {
2429 : 0 : mbAutoHideIn = !mbAutoHideIn;
2430 [ # # ]: 0 : ImplDrawAutoHide( sal_False );
2431 [ # # ]: 0 : AutoHide();
2432 : : }
2433 : : else
2434 [ # # ]: 0 : ImplDrawAutoHide( sal_False );
2435 : : }
2436 : : }
2437 : : else
2438 : : {
2439 [ # # ]: 0 : Rectangle aTestRect;
2440 [ # # ]: 0 : ImplGetAutoHideRect( aTestRect, sal_True );
2441 [ # # ]: 0 : sal_Bool bNewPressed = aTestRect.IsInside( aMousePosPixel );
2442 [ # # ]: 0 : if ( bNewPressed != mbAutoHidePressed )
2443 : : {
2444 : 0 : mbAutoHidePressed = bNewPressed;
2445 [ # # ]: 0 : ImplDrawAutoHide( sal_False );
2446 : : }
2447 : : }
2448 : : }
2449 [ # # ]: 0 : else if ( mbFadeInDown )
2450 : : {
2451 [ # # ]: 0 : if ( rTEvt.IsTrackingEnded() )
2452 : : {
2453 : 0 : mbFadeInDown = sal_False;
2454 [ # # ]: 0 : if ( mbFadeInPressed )
2455 : : {
2456 : 0 : mbFadeInPressed = sal_False;
2457 [ # # ]: 0 : ImplDrawFadeIn( sal_False );
2458 : :
2459 [ # # ]: 0 : if ( !rTEvt.IsTrackingCanceled() )
2460 [ # # ]: 0 : FadeIn();
2461 : : }
2462 : : }
2463 : : else
2464 : : {
2465 [ # # ]: 0 : Rectangle aTestRect;
2466 [ # # ]: 0 : ImplGetFadeInRect( aTestRect, sal_True );
2467 [ # # ]: 0 : sal_Bool bNewPressed = aTestRect.IsInside( aMousePosPixel );
2468 [ # # ]: 0 : if ( bNewPressed != mbFadeInPressed )
2469 : : {
2470 : 0 : mbFadeInPressed = bNewPressed;
2471 [ # # ]: 0 : ImplDrawFadeIn( sal_False );
2472 : : }
2473 : : }
2474 : : }
2475 [ # # ]: 0 : else if ( mbFadeOutDown )
2476 : : {
2477 [ # # ]: 0 : if ( rTEvt.IsTrackingEnded() )
2478 : : {
2479 : 0 : mbFadeOutDown = sal_False;
2480 [ # # ]: 0 : if ( mbFadeOutPressed )
2481 : : {
2482 : 0 : mbFadeOutPressed = sal_False;
2483 [ # # ]: 0 : ImplDrawFadeOut( sal_False );
2484 : :
2485 [ # # ]: 0 : if ( !rTEvt.IsTrackingCanceled() )
2486 [ # # ]: 0 : FadeOut();
2487 : : }
2488 : : }
2489 : : else
2490 : : {
2491 [ # # ]: 0 : Rectangle aTestRect;
2492 [ # # ]: 0 : ImplGetFadeOutRect( aTestRect, sal_True );
2493 [ # # ]: 0 : sal_Bool bNewPressed = aTestRect.IsInside( aMousePosPixel );
2494 [ # # ]: 0 : if ( bNewPressed == sal_False )
2495 : : {
2496 : 0 : mbFadeOutPressed = bNewPressed;
2497 [ # # ]: 0 : ImplDrawFadeOut( sal_False );
2498 : :
2499 : : // We need a mouseevent with a position inside the button for the
2500 : : // ImplStartSplit function!
2501 : 0 : MouseEvent aOrgMEvt = rTEvt.GetMouseEvent();
2502 : 0 : MouseEvent aNewMEvt = MouseEvent( aTestRect.Center(), aOrgMEvt.GetClicks(),
2503 : 0 : aOrgMEvt.GetMode(), aOrgMEvt.GetButtons(),
2504 [ # # ][ # # ]: 0 : aOrgMEvt.GetModifier() );
2505 : :
2506 [ # # ]: 0 : ImplStartSplit( aNewMEvt );
2507 : 0 : mbFadeOutDown = sal_False;
2508 : : }
2509 : : }
2510 : : }
2511 : : else
2512 : : {
2513 [ # # ]: 0 : ImplSplitMousePos( aMousePosPixel );
2514 : 0 : sal_Bool bSplit = sal_True;
2515 [ # # ]: 0 : if ( mbDragFull )
2516 : : {
2517 [ # # ]: 0 : if ( rTEvt.IsTrackingEnded() )
2518 : : {
2519 [ # # ]: 0 : if ( rTEvt.IsTrackingCanceled() )
2520 : : {
2521 : 0 : ImplSplitItem* pItems = mpSplitSet->mpItems;
2522 : 0 : sal_uInt16 nItems = mpSplitSet->mnItems;
2523 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < nItems; i++ )
2524 : : {
2525 : 0 : pItems[i].mnSize = mpLastSizes[i*2];
2526 : 0 : pItems[i].mnPixSize = mpLastSizes[i*2+1];
2527 : : }
2528 [ # # ]: 0 : ImplUpdate();
2529 [ # # ]: 0 : Split();
2530 : : }
2531 : 0 : bSplit = sal_False;
2532 : : }
2533 : : }
2534 : : else
2535 : : {
2536 [ # # ]: 0 : if ( rTEvt.IsTrackingEnded() )
2537 : : {
2538 [ # # ]: 0 : HideTracking();
2539 : 0 : bSplit = !rTEvt.IsTrackingCanceled();
2540 : : }
2541 : : else
2542 : : {
2543 [ # # ]: 0 : ImplDrawSplitTracking( this, aMousePosPixel );
2544 : 0 : bSplit = sal_False;
2545 : : }
2546 : : }
2547 : :
2548 [ # # ]: 0 : if ( bSplit )
2549 : : {
2550 [ # # ]: 0 : sal_Bool bPropSmaller = (mnMouseModifier & KEY_SHIFT) ? sal_True : sal_False;
2551 [ # # ]: 0 : sal_Bool bPropGreater = (mnMouseModifier & KEY_MOD1) ? sal_True : sal_False;
2552 : 0 : long nDelta = mnMSplitPos-mnMStartPos;
2553 : :
2554 [ # # ][ # # ]: 0 : if ( (mnSplitTest & SPLIT_WINDOW) && !mpMainSet->mpItems )
2555 : : {
2556 [ # # ][ # # ]: 0 : if ( (mpSplitSet == mpMainSet) && mbBottomRight )
2557 : 0 : nDelta *= -1;
2558 [ # # ]: 0 : ImplSetWindowSize( nDelta );
2559 : : }
2560 : : else
2561 : : {
2562 : 0 : long nNewSize = mpSplitSet->mpItems[mnSplitPos].mnPixSize;
2563 [ # # ][ # # ]: 0 : if ( (mpSplitSet == mpMainSet) && mbBottomRight )
2564 : 0 : nNewSize -= nDelta;
2565 : : else
2566 : 0 : nNewSize += nDelta;
2567 : 0 : SplitItem( mpSplitSet->mpItems[mnSplitPos].mnId, nNewSize,
2568 [ # # ]: 0 : bPropSmaller, bPropGreater );
2569 : : }
2570 : :
2571 [ # # ]: 0 : Split();
2572 : :
2573 [ # # ]: 0 : if ( mbDragFull )
2574 : : {
2575 [ # # ]: 0 : Update();
2576 : 0 : mnMStartPos = mnMSplitPos;
2577 : : }
2578 : : }
2579 : :
2580 [ # # ]: 0 : if ( rTEvt.IsTrackingEnded() )
2581 : : {
2582 : 0 : delete mpLastSizes;
2583 : 0 : mpLastSizes = NULL;
2584 : 0 : mpSplitSet = NULL;
2585 : 0 : mnMouseOff = 0;
2586 : 0 : mnMStartPos = 0;
2587 : 0 : mnMSplitPos = 0;
2588 : 0 : mnMouseModifier = 0;
2589 : 0 : mnSplitTest = 0;
2590 : 0 : mnSplitPos = 0;
2591 : : }
2592 : : }
2593 : 0 : }
2594 : :
2595 : : // -----------------------------------------------------------------------
2596 : :
2597 : 217 : long SplitWindow::PreNotify( NotifyEvent& rNEvt )
2598 : : {
2599 : 217 : const MouseEvent* pMouseEvt = NULL;
2600 : :
2601 [ - + ][ # # ]: 217 : if( (rNEvt.GetType() == EVENT_MOUSEMOVE) && (pMouseEvt = rNEvt.GetMouseEvent()) != NULL )
[ - + ]
2602 : : {
2603 [ # # ][ # # ]: 0 : if( !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
[ # # ][ # # ]
2604 : : {
2605 : : // trigger redraw if mouse over state has changed
2606 [ # # ]: 0 : Rectangle aFadeInRect;
2607 [ # # ]: 0 : Rectangle aFadeOutRect;
2608 [ # # ]: 0 : ImplGetFadeInRect( aFadeInRect );
2609 [ # # ]: 0 : ImplGetFadeOutRect( aFadeOutRect );
2610 : :
2611 [ # # ][ # # ]: 0 : if ( aFadeInRect.IsInside( GetPointerPosPixel() ) != aFadeInRect.IsInside( GetLastPointerPosPixel() ) )
[ # # ][ # # ]
[ # # ]
2612 [ # # ]: 0 : Invalidate( aFadeInRect );
2613 [ # # ][ # # ]: 0 : if ( aFadeOutRect.IsInside( GetPointerPosPixel() ) != aFadeOutRect.IsInside( GetLastPointerPosPixel() ) )
[ # # ][ # # ]
[ # # ]
2614 [ # # ]: 0 : Invalidate( aFadeOutRect );
2615 : :
2616 [ # # ][ # # ]: 0 : if( pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow() )
[ # # ]
2617 : : {
2618 [ # # ]: 0 : Invalidate( aFadeInRect );
2619 [ # # ]: 0 : Invalidate( aFadeOutRect );
2620 : : }
2621 : : }
2622 : : }
2623 : 217 : return Window::PreNotify( rNEvt );
2624 : : }
2625 : :
2626 : : // -----------------------------------------------------------------------
2627 : :
2628 : 463 : void SplitWindow::Paint( const Rectangle& )
2629 : : {
2630 [ + - ]: 463 : if ( mnWinStyle & WB_BORDER )
2631 : 463 : ImplDrawBorder( this );
2632 : :
2633 : 463 : ImplDrawBorderLine( this );
2634 : 463 : ImplDrawFadeOut( sal_True );
2635 : 463 : ImplDrawFadeIn( sal_True );
2636 : 463 : ImplDrawAutoHide( sal_True );
2637 : :
2638 : : // FrameSet-Hintergruende zeichnen
2639 : 463 : ImplDrawBack( this, mpMainSet );
2640 : :
2641 : : // Splitter zeichnen
2642 [ + - ]: 463 : if ( !(mnWinStyle & WB_NOSPLITDRAW) )
2643 : 463 : ImplDrawSplit( this, mpMainSet, mbHorz, !mbBottomRight );
2644 : 463 : }
2645 : :
2646 : : // -----------------------------------------------------------------------
2647 : :
2648 : 1258 : void SplitWindow::Move()
2649 : : {
2650 : 1258 : DockingWindow::Move();
2651 : 1258 : }
2652 : :
2653 : : // -----------------------------------------------------------------------
2654 : :
2655 : 1288 : void SplitWindow::Resize()
2656 : : {
2657 [ + - ]: 1288 : Size aSize = GetOutputSizePixel();
2658 : 1288 : mnDX = aSize.Width();
2659 : 1288 : mnDY = aSize.Height();
2660 : :
2661 [ + - ]: 1288 : ImplUpdate();
2662 [ + - ]: 1288 : Invalidate();
2663 : 1288 : }
2664 : :
2665 : : // -----------------------------------------------------------------------
2666 : :
2667 : 0 : void SplitWindow::RequestHelp( const HelpEvent& rHEvt )
2668 : : {
2669 : : // no keyboard help for splitwin
2670 [ # # ][ # # ]: 0 : if ( rHEvt.GetMode() & (HELPMODE_BALLOON | HELPMODE_QUICK) && !rHEvt.KeyboardActivated() )
[ # # ]
2671 : : {
2672 [ # # ][ # # ]: 0 : Point aMousePosPixel = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
2673 [ # # ]: 0 : Rectangle aHelpRect;
2674 : 0 : sal_uInt16 nHelpResId = 0;
2675 : :
2676 [ # # ]: 0 : ImplGetAutoHideRect( aHelpRect, sal_True );
2677 [ # # ][ # # ]: 0 : if ( aHelpRect.IsInside( aMousePosPixel ) )
2678 : : {
2679 [ # # ]: 0 : if ( mbAutoHideIn )
2680 : 0 : nHelpResId = SV_HELPTEXT_SPLITFIXED;
2681 : : else
2682 : 0 : nHelpResId = SV_HELPTEXT_SPLITFLOATING;
2683 : : }
2684 : : else
2685 : : {
2686 [ # # ]: 0 : ImplGetFadeInRect( aHelpRect, sal_True );
2687 [ # # ][ # # ]: 0 : if ( aHelpRect.IsInside( aMousePosPixel ) )
2688 : 0 : nHelpResId = SV_HELPTEXT_FADEIN;
2689 : : else
2690 : : {
2691 [ # # ]: 0 : ImplGetFadeOutRect( aHelpRect, sal_True );
2692 [ # # ][ # # ]: 0 : if ( aHelpRect.IsInside( aMousePosPixel ) )
2693 : 0 : nHelpResId = SV_HELPTEXT_FADEOUT;
2694 : : }
2695 : : }
2696 : :
2697 : : // Rechteck ermitteln
2698 [ # # ]: 0 : if ( nHelpResId )
2699 : : {
2700 [ # # ]: 0 : Point aPt = OutputToScreenPixel( aHelpRect.TopLeft() );
2701 : 0 : aHelpRect.Left() = aPt.X();
2702 : 0 : aHelpRect.Top() = aPt.Y();
2703 [ # # ][ # # ]: 0 : aPt = OutputToScreenPixel( aHelpRect.BottomRight() );
2704 : 0 : aHelpRect.Right() = aPt.X();
2705 : 0 : aHelpRect.Bottom() = aPt.Y();
2706 : :
2707 : : // Text ermitteln und anzeigen
2708 [ # # ]: 0 : XubString aStr;
2709 [ # # ]: 0 : ResMgr* pResMgr = ImplGetResMgr();
2710 [ # # ]: 0 : if( pResMgr )
2711 [ # # ][ # # ]: 0 : aStr = ResId( nHelpResId, *pResMgr ).toString();
2712 [ # # ]: 0 : if ( rHEvt.GetMode() & HELPMODE_BALLOON )
2713 [ # # ][ # # ]: 0 : Help::ShowBalloon( this, aHelpRect.Center(), aHelpRect, aStr );
2714 : : else
2715 [ # # ]: 0 : Help::ShowQuickHelp( this, aHelpRect, aStr );
2716 [ # # ]: 0 : return;
2717 : : }
2718 : : }
2719 : :
2720 : 0 : DockingWindow::RequestHelp( rHEvt );
2721 : : }
2722 : :
2723 : : // -----------------------------------------------------------------------
2724 : :
2725 : 6758 : void SplitWindow::StateChanged( StateChangedType nType )
2726 : : {
2727 [ + + - + ]: 6758 : switch ( nType )
2728 : : {
2729 : : case STATE_CHANGE_INITSHOW:
2730 [ + + ]: 624 : if ( IsUpdateMode() )
2731 : 585 : ImplCalcLayout();
2732 : 624 : break;
2733 : : case STATE_CHANGE_UPDATEMODE:
2734 [ + + ][ + + ]: 2182 : if ( IsUpdateMode() && IsReallyShown() )
[ + + ]
2735 : 246 : ImplCalcLayout();
2736 : 2182 : break;
2737 : : case STATE_CHANGE_CONTROLBACKGROUND:
2738 : 0 : ImplInitSettings();
2739 : 0 : Invalidate();
2740 : 0 : break;
2741 : : }
2742 : :
2743 : 6758 : DockingWindow::StateChanged( nType );
2744 : 6758 : }
2745 : :
2746 : : // -----------------------------------------------------------------------
2747 : :
2748 : 48 : void SplitWindow::DataChanged( const DataChangedEvent& rDCEvt )
2749 : : {
2750 [ + - - + ]: 96 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
[ - + ]
2751 : 48 : (rDCEvt.GetFlags() & SETTINGS_STYLE) )
2752 : : {
2753 : 0 : ImplInitSettings();
2754 : 0 : Invalidate();
2755 : : }
2756 : : else
2757 : 48 : DockingWindow::DataChanged( rDCEvt );
2758 : 48 : }
2759 : :
2760 : : // -----------------------------------------------------------------------
2761 : :
2762 : 624 : void SplitWindow::InsertItem( sal_uInt16 nId, Window* pWindow, long nSize,
2763 : : sal_uInt16 nPos, sal_uInt16 nSetId,
2764 : : SplitWindowItemBits nBits )
2765 : : {
2766 : : #ifdef DBG_UTIL
2767 : : sal_uInt16 nDbgDummy;
2768 : : DBG_ASSERT( ImplFindSet( mpMainSet, nSetId ), "SplitWindow::InsertItem() - Set not exists" );
2769 : : DBG_ASSERT( !ImplFindItem( mpMainSet, nId, nDbgDummy ), "SplitWindow::InsertItem() - Id already exists" );
2770 : : #endif
2771 : :
2772 : : // Size has to be at least 1.
2773 [ - + ]: 624 : if ( nSize < 1 )
2774 : 0 : nSize = 1;
2775 : :
2776 : 624 : ImplSplitSet* pSet = ImplFindSet( mpMainSet, nSetId );
2777 : : ImplSplitSet* pNewSet;
2778 : : ImplSplitItem* pItem;
2779 : :
2780 : : // Make room for the new item.
2781 [ - + ]: 624 : if ( nPos > pSet->mnItems )
2782 : 0 : nPos = pSet->mnItems;
2783 : 624 : ImplSplitItem* pNewItems = new ImplSplitItem[pSet->mnItems+1];
2784 [ - + ]: 624 : if ( nPos )
2785 : 0 : memcpy( pNewItems, pSet->mpItems, sizeof( ImplSplitItem )*nPos );
2786 [ - + ]: 624 : if ( nPos < pSet->mnItems )
2787 : 0 : memcpy( pNewItems+nPos+1, pSet->mpItems+nPos, sizeof( ImplSplitItem )*(pSet->mnItems-nPos) );
2788 [ - + ]: 624 : delete[] pSet->mpItems;
2789 : 624 : pSet->mpItems = pNewItems;
2790 : 624 : pSet->mnItems++;
2791 : 624 : pSet->mbCalcPix = sal_True;
2792 : :
2793 : : // Create and initialize item.
2794 : 624 : pItem = &(pSet->mpItems[nPos]);
2795 : 624 : memset( pItem, 0, sizeof( ImplSplitItem ) );
2796 : 624 : pItem->mnSize = nSize;
2797 : 624 : pItem->mnId = nId;
2798 : 624 : pItem->mnBits = nBits;
2799 : 624 : pItem->mnMinSize=-1;
2800 : 624 : pItem->mnMaxSize=-1;
2801 : :
2802 [ + + ]: 624 : if ( pWindow )
2803 : : {
2804 : 312 : pItem->mpWindow = pWindow;
2805 : 312 : pItem->mpOrgParent = pWindow->GetParent();
2806 : :
2807 : : // Attach window to SplitWindow.
2808 : 312 : pWindow->Hide();
2809 : 312 : pWindow->SetParent( this );
2810 : : }
2811 : : else
2812 : : {
2813 : 312 : pNewSet = new ImplSplitSet;
2814 : 312 : pNewSet->mpItems = NULL;
2815 : 312 : pNewSet->mpWallpaper = NULL;
2816 : 312 : pNewSet->mpBitmap = NULL;
2817 : 312 : pNewSet->mnLastSize = 0;
2818 : 312 : pNewSet->mnItems = 0;
2819 : 312 : pNewSet->mnId = nId;
2820 : 312 : pNewSet->mnSplitSize = pSet->mnSplitSize;
2821 : 312 : pNewSet->mbCalcPix = sal_True;
2822 : :
2823 : 312 : pItem->mpSet = pNewSet;
2824 : : }
2825 : :
2826 : 624 : ImplUpdate();
2827 : 624 : }
2828 : :
2829 : : // -----------------------------------------------------------------------
2830 : :
2831 : 312 : void SplitWindow::InsertItem( sal_uInt16 nId, long nSize,
2832 : : sal_uInt16 nPos, sal_uInt16 nSetId,
2833 : : SplitWindowItemBits nBits )
2834 : : {
2835 : 312 : InsertItem( nId, NULL, nSize, nPos, nSetId, nBits );
2836 : 312 : }
2837 : :
2838 : : // -----------------------------------------------------------------------
2839 : :
2840 : 624 : void SplitWindow::RemoveItem( sal_uInt16 nId, sal_Bool bHide )
2841 : : {
2842 : : #ifdef DBG_UTIL
2843 : : sal_uInt16 nDbgDummy;
2844 : : DBG_ASSERT( ImplFindItem( mpMainSet, nId, nDbgDummy ), "SplitWindow::RemoveItem() - Id not found" );
2845 : : #endif
2846 : :
2847 : : // Set suchen
2848 : : sal_uInt16 nPos;
2849 [ + - ]: 624 : ImplSplitSet* pSet = ImplFindItem( mpMainSet, nId, nPos );
2850 : 624 : ImplSplitItem* pItem = &(pSet->mpItems[nPos]);
2851 : 624 : Window* pWindow = pItem->mpWindow;
2852 : 624 : Window* pOrgParent = pItem->mpOrgParent;
2853 : :
2854 : : // Evt. Set loeschen
2855 [ + + ]: 624 : if ( !pWindow )
2856 [ + - ]: 312 : ImplDeleteSet( pItem->mpSet );
2857 : :
2858 : : // Item entfernen
2859 : 624 : pSet->mnItems--;
2860 : 624 : pSet->mbCalcPix = sal_True;
2861 [ - + ]: 624 : if ( pSet->mnItems )
2862 : : {
2863 : 0 : memmove( pSet->mpItems+nPos, pSet->mpItems+nPos+1,
2864 : 0 : (pSet->mnItems-nPos)*sizeof( ImplSplitItem ) );
2865 : : }
2866 : : else
2867 : : {
2868 [ + - ]: 624 : delete[] pSet->mpItems;
2869 : 624 : pSet->mpItems = NULL;
2870 : : }
2871 : :
2872 [ + - ]: 624 : ImplUpdate();
2873 : :
2874 : : // Window erst hier loeschen, um weniger Paints zu haben
2875 [ + + ]: 624 : if ( pWindow )
2876 : : {
2877 : : // Fenster wieder herstellen
2878 [ - + ][ # # ]: 312 : if ( bHide || (pOrgParent != this) )
2879 : : {
2880 [ + - ]: 312 : pWindow->Hide();
2881 [ + - ]: 312 : pWindow->SetParent( pOrgParent );
2882 : : }
2883 : : }
2884 : 624 : }
2885 : :
2886 : : // -----------------------------------------------------------------------
2887 : :
2888 : 0 : void SplitWindow::Clear()
2889 : : {
2890 : : // Alle Sets loeschen
2891 : 0 : ImplDeleteSet( mpMainSet );
2892 : :
2893 : : // Main-Set wieder anlegen
2894 : 0 : mpMainSet = new ImplSplitSet;
2895 : 0 : mpMainSet->mpItems = NULL;
2896 : 0 : mpMainSet->mpWallpaper = NULL;
2897 : 0 : mpMainSet->mpBitmap = NULL;
2898 : 0 : mpMainSet->mnLastSize = 0;
2899 : 0 : mpMainSet->mnItems = 0;
2900 : 0 : mpMainSet->mnId = 0;
2901 : 0 : mpMainSet->mnSplitSize = SPLITWIN_SPLITSIZE;
2902 : 0 : mpMainSet->mbCalcPix = sal_True;
2903 [ # # ]: 0 : if ( mnWinStyle & WB_NOSPLITDRAW )
2904 : 0 : mpMainSet->mnSplitSize -= 2;
2905 : 0 : mpBaseSet = mpMainSet;
2906 : :
2907 : : // Und neu invalidieren
2908 : 0 : ImplUpdate();
2909 : 0 : }
2910 : :
2911 : : // -----------------------------------------------------------------------
2912 : :
2913 : 0 : void SplitWindow::SplitItem( sal_uInt16 nId, long nNewSize,
2914 : : sal_Bool bPropSmall, sal_Bool bPropGreat )
2915 : : {
2916 : : sal_uInt16 nItems;
2917 : : sal_uInt16 nPos;
2918 : : sal_uInt16 nMin;
2919 : : sal_uInt16 nMax;
2920 : : sal_uInt16 i;
2921 : : sal_uInt16 n;
2922 : : long nDelta;
2923 : : long nTempDelta;
2924 [ # # ]: 0 : ImplSplitSet* pSet = ImplFindItem( mpBaseSet, nId, nPos );
2925 : : ImplSplitItem* pItems;
2926 : :
2927 [ # # ]: 0 : if ( !pSet )
2928 : : return;
2929 : :
2930 : 0 : nItems = pSet->mnItems;
2931 : 0 : pItems = pSet->mpItems;
2932 : :
2933 : : // When there is an explicit minimum or maximum size then move nNewSize
2934 : : // into that range (when it is not yet already in it.)
2935 : 0 : nNewSize = ValidateSize(nNewSize, pItems[nPos]);
2936 : :
2937 [ # # ]: 0 : if ( mbCalc )
2938 : : {
2939 : 0 : pItems[nPos].mnSize = nNewSize;
2940 : : return;
2941 : : }
2942 : :
2943 : 0 : nDelta = nNewSize-pItems[nPos].mnPixSize;
2944 [ # # ]: 0 : if ( !nDelta )
2945 : : return;
2946 : :
2947 : : // Bereich berechnen, der beim Splitten betroffen sein kann
2948 : 0 : nMin = 0;
2949 : 0 : nMax = nItems;
2950 [ # # ]: 0 : for ( i = 0; i < nItems; i++ )
2951 : : {
2952 [ # # ]: 0 : if ( pItems[i].mbFixed )
2953 : : {
2954 [ # # ]: 0 : if ( i < nPos )
2955 : 0 : nMin = i+1;
2956 : : else
2957 : 0 : nMax = i;
2958 : : }
2959 : : }
2960 : :
2961 : : // Wenn das Fenster sizeable ist, wird das TopSet anders behandelt
2962 : 0 : sal_Bool bSmall = sal_True;
2963 : 0 : sal_Bool bGreat = sal_True;
2964 [ # # ][ # # ]: 0 : if ( (pSet == mpMainSet) && (mnWinStyle & WB_SIZEABLE) )
2965 : : {
2966 [ # # ]: 0 : if ( nPos < pSet->mnItems-1 )
2967 : : {
2968 [ # # ]: 0 : if ( !((bPropSmall && bPropGreat) ||
2969 : : ((nDelta > 0) && bPropSmall) ||
2970 [ # # ][ # # ]: 0 : ((nDelta < 0) && bPropGreat)) )
[ # # ][ # # ]
[ # # ]
2971 : : {
2972 [ # # ]: 0 : if ( nDelta < 0 )
2973 : 0 : bGreat = sal_False;
2974 : : else
2975 : 0 : bSmall = sal_False;
2976 : : }
2977 : : }
2978 : : else
2979 : : {
2980 [ # # ]: 0 : if ( nDelta < 0 )
2981 : 0 : bGreat = sal_False;
2982 : : else
2983 : 0 : bSmall = sal_False;
2984 : : }
2985 : : }
2986 [ # # ]: 0 : else if ( nPos >= nMax )
2987 : : {
2988 : 0 : bSmall = sal_False;
2989 : 0 : bGreat = sal_False;
2990 : : }
2991 [ # # ][ # # ]: 0 : else if ( nPos && (nPos >= pSet->mnItems-1) )
2992 : : {
2993 : 0 : nPos--;
2994 : 0 : nDelta *= -1;
2995 : 0 : sal_Bool bTemp = bPropSmall;
2996 : 0 : bPropSmall = bPropGreat;
2997 : 0 : bPropGreat = bTemp;
2998 : : }
2999 : :
3000 : : // Jetzt die Fenster splitten
3001 [ # # ]: 0 : if ( nDelta < 0 )
3002 : : {
3003 [ # # ]: 0 : if ( bGreat )
3004 : : {
3005 [ # # ]: 0 : if ( bPropGreat )
3006 : : {
3007 : 0 : nTempDelta = nDelta;
3008 [ # # ]: 0 : do
3009 : : {
3010 : 0 : n = nPos+1;
3011 [ # # ]: 0 : do
3012 : : {
3013 [ # # ]: 0 : if ( nTempDelta )
3014 : : {
3015 : 0 : pItems[n].mnPixSize++;
3016 : 0 : nTempDelta++;
3017 : : }
3018 : 0 : n++;
3019 : : }
3020 : : while ( n < nMax );
3021 : : }
3022 : : while ( nTempDelta );
3023 : : }
3024 : : else
3025 : 0 : pItems[nPos+1].mnPixSize -= nDelta;
3026 : : }
3027 : :
3028 [ # # ]: 0 : if ( bSmall )
3029 : : {
3030 [ # # ]: 0 : if ( bPropSmall )
3031 : : {
3032 [ # # ]: 0 : do
3033 : : {
3034 : 0 : n = nPos+1;
3035 [ # # ]: 0 : do
3036 : : {
3037 [ # # ][ # # ]: 0 : if ( nDelta && pItems[n-1].mnPixSize )
3038 : : {
3039 : 0 : pItems[n-1].mnPixSize--;
3040 : 0 : nDelta++;
3041 : : }
3042 : :
3043 : 0 : n--;
3044 : : }
3045 : : while ( n > nMin );
3046 : : }
3047 : : while ( nDelta );
3048 : : }
3049 : : else
3050 : : {
3051 : 0 : n = nPos+1;
3052 [ # # ]: 0 : do
3053 : : {
3054 [ # # ]: 0 : if ( pItems[n-1].mnPixSize+nDelta < 0 )
3055 : : {
3056 : 0 : nDelta += pItems[n-1].mnPixSize;
3057 : 0 : pItems[n-1].mnPixSize = 0;
3058 : : }
3059 : : else
3060 : : {
3061 : 0 : pItems[n-1].mnPixSize += nDelta;
3062 : 0 : break;
3063 : : }
3064 : 0 : n--;
3065 : : }
3066 : : while ( n > nMin );
3067 : : }
3068 : : }
3069 : : }
3070 : : else
3071 : : {
3072 [ # # ]: 0 : if ( bGreat )
3073 : : {
3074 [ # # ]: 0 : if ( bPropGreat )
3075 : : {
3076 : 0 : nTempDelta = nDelta;
3077 [ # # ]: 0 : do
3078 : : {
3079 : 0 : n = nPos+1;
3080 [ # # ]: 0 : do
3081 : : {
3082 [ # # ]: 0 : if ( nTempDelta )
3083 : : {
3084 : 0 : pItems[n-1].mnPixSize++;
3085 : 0 : nTempDelta--;
3086 : : }
3087 : 0 : n--;
3088 : : }
3089 : : while ( n > nMin );
3090 : : }
3091 : : while ( nTempDelta );
3092 : : }
3093 : : else
3094 : 0 : pItems[nPos].mnPixSize += nDelta;
3095 : : }
3096 : :
3097 [ # # ]: 0 : if ( bSmall )
3098 : : {
3099 [ # # ]: 0 : if ( bPropSmall )
3100 : : {
3101 [ # # ]: 0 : do
3102 : : {
3103 : 0 : n = nPos+1;
3104 [ # # ]: 0 : do
3105 : : {
3106 [ # # ][ # # ]: 0 : if ( nDelta && pItems[n].mnPixSize )
3107 : : {
3108 : 0 : pItems[n].mnPixSize--;
3109 : 0 : nDelta--;
3110 : : }
3111 : :
3112 : 0 : n++;
3113 : : }
3114 : : while ( n < nMax );
3115 : : }
3116 : : while ( nDelta );
3117 : : }
3118 : : else
3119 : : {
3120 : 0 : n = nPos+1;
3121 [ # # ]: 0 : do
3122 : : {
3123 [ # # ]: 0 : if ( pItems[n].mnPixSize-nDelta < 0 )
3124 : : {
3125 : 0 : nDelta -= pItems[n].mnPixSize;
3126 : 0 : pItems[n].mnPixSize = 0;
3127 : : }
3128 : : else
3129 : : {
3130 : 0 : pItems[n].mnPixSize -= nDelta;
3131 : 0 : break;
3132 : : }
3133 : 0 : n++;
3134 : : }
3135 : : while ( n < nMax );
3136 : : }
3137 : : }
3138 : : }
3139 : :
3140 : : // Original-Groessen updaten
3141 : 0 : ImplCalcLogSize( pItems, nItems );
3142 : :
3143 [ # # ]: 0 : ImplUpdate();
3144 : : }
3145 : :
3146 : : // -----------------------------------------------------------------------
3147 : :
3148 : 0 : void SplitWindow::SetItemSize( sal_uInt16 nId, long nNewSize )
3149 : : {
3150 : : sal_uInt16 nPos;
3151 [ # # ]: 0 : ImplSplitSet* pSet = ImplFindItem( mpBaseSet, nId, nPos );
3152 : : ImplSplitItem* pItem;
3153 : :
3154 [ # # ]: 0 : if ( !pSet )
3155 : 0 : return;
3156 : :
3157 : : // Testen, ob sich Groesse aendert
3158 : 0 : pItem = &(pSet->mpItems[nPos]);
3159 [ # # ]: 0 : if ( pItem->mnSize != nNewSize )
3160 : : {
3161 : : // Neue Groesse setzen und neu durchrechnen
3162 : 0 : pItem->mnSize = nNewSize;
3163 : 0 : pSet->mbCalcPix = sal_True;
3164 [ # # ]: 0 : ImplUpdate();
3165 : : }
3166 : : }
3167 : :
3168 : : // -----------------------------------------------------------------------
3169 : :
3170 : 0 : long SplitWindow::GetItemSize( sal_uInt16 nId ) const
3171 : : {
3172 : : sal_uInt16 nPos;
3173 [ # # ]: 0 : ImplSplitSet* pSet = ImplFindItem( mpBaseSet, nId, nPos );
3174 : :
3175 [ # # ]: 0 : if ( pSet )
3176 : 0 : return pSet->mpItems[nPos].mnSize;
3177 : : else
3178 : 0 : return 0;
3179 : : }
3180 : :
3181 : : // -----------------------------------------------------------------------
3182 : :
3183 : 0 : long SplitWindow::GetItemSize( sal_uInt16 nId, SplitWindowItemBits nBits ) const
3184 : : {
3185 : : sal_uInt16 nPos;
3186 [ # # ]: 0 : ImplSplitSet* pSet = ImplFindItem( mpBaseSet, nId, nPos );
3187 : :
3188 [ # # ]: 0 : if ( pSet )
3189 : : {
3190 [ # # ]: 0 : if ( nBits == pSet->mpItems[nPos].mnBits )
3191 : 0 : return pSet->mpItems[nPos].mnSize;
3192 : : else
3193 : : {
3194 [ # # ]: 0 : ((SplitWindow*)this)->ImplCalcLayout();
3195 : :
3196 : 0 : long nRelSize = 0;
3197 : 0 : long nPerSize = 0;
3198 : : ImplSplitItem* pItems;
3199 : : sal_uInt16 nItems;
3200 : : SplitWindowItemBits nTempBits;
3201 : : sal_uInt16 i;
3202 : 0 : nItems = pSet->mnItems;
3203 : 0 : pItems = pSet->mpItems;
3204 [ # # ]: 0 : for ( i = 0; i < nItems; i++ )
3205 : : {
3206 [ # # ]: 0 : if ( i == nPos )
3207 : 0 : nTempBits = nBits;
3208 : : else
3209 : 0 : nTempBits = pItems[i].mnBits;
3210 [ # # ]: 0 : if ( nTempBits & SWIB_RELATIVESIZE )
3211 : 0 : nRelSize += pItems[i].mnPixSize;
3212 [ # # ]: 0 : else if ( nTempBits & SWIB_PERCENTSIZE )
3213 : 0 : nPerSize += pItems[i].mnPixSize;
3214 : : }
3215 : 0 : nPerSize += nRelSize;
3216 [ # # ]: 0 : if ( nBits & SWIB_RELATIVESIZE )
3217 : : {
3218 [ # # ]: 0 : if ( nRelSize )
3219 : 0 : return (pItems[nPos].mnPixSize+(nRelSize/2))/nRelSize;
3220 : : else
3221 : 0 : return 1;
3222 : : }
3223 [ # # ]: 0 : else if ( nBits & SWIB_PERCENTSIZE )
3224 : : {
3225 [ # # ]: 0 : if ( nPerSize )
3226 : 0 : return (pItems[nPos].mnPixSize*100)/nPerSize;
3227 : : else
3228 : 0 : return 1;
3229 : : }
3230 : : else
3231 : 0 : return pItems[nPos].mnPixSize;
3232 : : }
3233 : : }
3234 : : else
3235 : 0 : return 0;
3236 : : }
3237 : :
3238 : :
3239 : :
3240 : :
3241 : 126 : void SplitWindow::SetItemSizeRange (sal_uInt16 nId, const Range aRange)
3242 : : {
3243 : : sal_uInt16 nPos;
3244 [ + - ]: 126 : ImplSplitSet* pSet = ImplFindItem(mpBaseSet, nId, nPos);
3245 : :
3246 [ + - ]: 126 : if (pSet != NULL)
3247 : : {
3248 : 126 : pSet->mpItems[nPos].mnMinSize = aRange.Min();
3249 : 126 : pSet->mpItems[nPos].mnMaxSize = aRange.Max();
3250 : : }
3251 : 126 : }
3252 : :
3253 : : // -----------------------------------------------------------------------
3254 : :
3255 : 438 : sal_uInt16 SplitWindow::GetSet( sal_uInt16 nId ) const
3256 : : {
3257 : : sal_uInt16 nPos;
3258 [ + - ]: 438 : ImplSplitSet* pSet = ImplFindItem( mpBaseSet, nId, nPos );
3259 : :
3260 [ + - ]: 438 : if ( pSet )
3261 : 438 : return pSet->mnId;
3262 : : else
3263 : 438 : return 0;
3264 : : }
3265 : :
3266 : : // -----------------------------------------------------------------------
3267 : :
3268 : 780 : sal_Bool SplitWindow::IsItemValid( sal_uInt16 nId ) const
3269 : : {
3270 : : sal_uInt16 nPos;
3271 [ + - ][ + - ]: 780 : ImplSplitSet* pSet = mpBaseSet ? ImplFindItem(mpBaseSet, nId, nPos) : NULL;
3272 : :
3273 [ + - ]: 780 : if ( pSet )
3274 : 780 : return sal_True;
3275 : : else
3276 : 780 : return sal_False;
3277 : : }
3278 : :
3279 : : // -----------------------------------------------------------------------
3280 : :
3281 : 126 : sal_uInt16 SplitWindow::GetItemId( Window* pWindow ) const
3282 : : {
3283 : 126 : return ImplFindItem( mpBaseSet, pWindow );
3284 : : }
3285 : :
3286 : : // -----------------------------------------------------------------------
3287 : :
3288 : 0 : sal_uInt16 SplitWindow::GetItemId( const Point& rPos ) const
3289 : : {
3290 : 0 : return ImplFindItem( mpBaseSet, rPos, mbHorz, !mbBottomRight );
3291 : : }
3292 : :
3293 : : // -----------------------------------------------------------------------
3294 : :
3295 : 0 : sal_uInt16 SplitWindow::GetItemPos( sal_uInt16 nId, sal_uInt16 nSetId ) const
3296 : : {
3297 : 0 : ImplSplitSet* pSet = ImplFindSet( mpBaseSet, nSetId );
3298 : 0 : sal_uInt16 nPos = SPLITWINDOW_ITEM_NOTFOUND;
3299 : :
3300 [ # # ]: 0 : if ( pSet )
3301 : : {
3302 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < pSet->mnItems; i++ )
3303 : : {
3304 [ # # ]: 0 : if ( pSet->mpItems[i].mnId == nId )
3305 : : {
3306 : 0 : nPos = i;
3307 : 0 : break;
3308 : : }
3309 : : }
3310 : : }
3311 : :
3312 : 0 : return nPos;
3313 : : }
3314 : :
3315 : : // -----------------------------------------------------------------------
3316 : :
3317 : 312 : sal_uInt16 SplitWindow::GetItemId( sal_uInt16 nPos, sal_uInt16 nSetId ) const
3318 : : {
3319 : 312 : ImplSplitSet* pSet = ImplFindSet( mpBaseSet, nSetId );
3320 [ + - ][ + - ]: 312 : if ( pSet && (nPos < pSet->mnItems) )
3321 : 312 : return pSet->mpItems[nPos].mnId;
3322 : : else
3323 : 312 : return 0;
3324 : : }
3325 : :
3326 : : // -----------------------------------------------------------------------
3327 : :
3328 : 52520 : sal_uInt16 SplitWindow::GetItemCount( sal_uInt16 nSetId ) const
3329 : : {
3330 : 52520 : ImplSplitSet* pSet = ImplFindSet( mpBaseSet, nSetId );
3331 [ + - ]: 52520 : if ( pSet )
3332 : 52520 : return pSet->mnItems;
3333 : : else
3334 : 52520 : return 0;
3335 : : }
3336 : :
3337 : : // -----------------------------------------------------------------------
3338 : :
3339 : 10266 : void SplitWindow::ImplNewAlign()
3340 : : {
3341 [ - + ]: 10266 : if ( mbNoAlign )
3342 : : {
3343 : 0 : mbHorz = sal_False;
3344 : 0 : mbBottomRight = sal_False;
3345 : : }
3346 : : else
3347 : : {
3348 [ - + + + : 10266 : switch ( meAlign )
- ]
3349 : : {
3350 : : case WINDOWALIGN_TOP:
3351 : 0 : mbHorz = sal_True;
3352 : 0 : mbBottomRight = sal_False;
3353 : 0 : break;
3354 : : case WINDOWALIGN_BOTTOM:
3355 : 3422 : mbHorz = sal_True;
3356 : 3422 : mbBottomRight = sal_True;
3357 : 3422 : break;
3358 : : case WINDOWALIGN_LEFT:
3359 : 3422 : mbHorz = sal_False;
3360 : 3422 : mbBottomRight = sal_False;
3361 : 3422 : break;
3362 : : case WINDOWALIGN_RIGHT:
3363 : 3422 : mbHorz = sal_False;
3364 : 3422 : mbBottomRight = sal_True;
3365 : 3422 : break;
3366 : : }
3367 : : }
3368 : :
3369 [ + - ]: 10266 : if ( mnWinStyle & WB_BORDER )
3370 : : {
3371 : : ImplCalcBorder( meAlign, mbNoAlign, mnLeftBorder, mnTopBorder,
3372 : 10266 : mnRightBorder, mnBottomBorder );
3373 : : }
3374 : :
3375 [ - + ][ # # ]: 10266 : if ( IsReallyVisible() && IsUpdateMode() )
[ - + ]
3376 : 0 : Invalidate();
3377 : 10266 : ImplUpdate();
3378 : 10266 : }
3379 : :
3380 : : // -----------------------------------------------------------------------
3381 : :
3382 : 13688 : void SplitWindow::SetAlign( WindowAlign eNewAlign )
3383 : : {
3384 [ + + ]: 13688 : if ( meAlign != eNewAlign )
3385 : : {
3386 : 10266 : meAlign = eNewAlign;
3387 : 10266 : ImplNewAlign();
3388 : : }
3389 : 13688 : }
3390 : :
3391 : : // -----------------------------------------------------------------------
3392 : :
3393 : 13688 : void SplitWindow::ShowAutoHideButton( sal_Bool bShow )
3394 : : {
3395 : 13688 : mbAutoHide = bShow;
3396 : 13688 : ImplUpdate();
3397 : 13688 : }
3398 : :
3399 : : // -----------------------------------------------------------------------
3400 : :
3401 : 6844 : void SplitWindow::ShowFadeInHideButton( sal_Bool bShow )
3402 : : {
3403 : 6844 : mbFadeIn = bShow;
3404 : 6844 : ImplUpdate();
3405 : 6844 : }
3406 : :
3407 : : // -----------------------------------------------------------------------
3408 : :
3409 : 6844 : void SplitWindow::ShowFadeOutButton( sal_Bool bShow )
3410 : : {
3411 : 6844 : mbFadeOut = bShow;
3412 : 6844 : ImplUpdate();
3413 : 6844 : }
3414 : :
3415 : : // -----------------------------------------------------------------------
3416 : :
3417 : 13688 : void SplitWindow::SetAutoHideState( sal_Bool bAutoHide )
3418 : : {
3419 : 13688 : mbAutoHideIn = bAutoHide;
3420 [ - + ]: 13688 : if ( IsReallyVisible() )
3421 : : {
3422 [ # # ]: 0 : Rectangle aRect;
3423 [ # # ]: 0 : ImplGetAutoHideRect( aRect );
3424 [ # # ]: 0 : Invalidate( aRect );
3425 : : }
3426 : 13688 : }
3427 : :
3428 : : // -----------------------------------------------------------------------
3429 : :
3430 : 7468 : long SplitWindow::GetFadeInSize() const
3431 : : {
3432 : 7468 : long n = 0;
3433 : :
3434 [ + + ]: 7468 : if ( mbHorz )
3435 : 3494 : n = mnTopBorder+mnBottomBorder;
3436 : : else
3437 : 3974 : n = mnLeftBorder+mnRightBorder;
3438 : :
3439 : 7468 : return n+SPLITWIN_SPLITSIZE+SPLITWIN_SPLITSIZEEX-2;
3440 : : }
3441 : :
3442 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|