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