update dev300-m58
[ooovba.git] / vcl / source / window / splitwin.cxx
blobcf427938d0509ecd913e854ad83eed4053cb54f2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: splitwin.cxx,v $
10 * $Revision: 1.20 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #include <string.h>
35 #include <tools/list.hxx>
36 #include <tools/debug.hxx>
37 #include <tools/rcid.h>
38 #include <vcl/event.hxx>
39 #include <vcl/wall.hxx>
40 #include <vcl/bitmap.hxx>
41 #include <vcl/decoview.hxx>
42 #include <vcl/symbol.hxx>
43 #ifndef _SV_SVIDS_HRC
44 #include <vcl/svids.hrc>
45 #endif
46 #include <vcl/image.hxx>
47 #include <vcl/svdata.hxx>
48 #include <vcl/help.hxx>
49 #include <vcl/splitwin.hxx>
53 // =======================================================================
55 // Achtung: Darf keine Objekte enthalten, da mit memmove/memcpy gearbeitet wird
56 struct ImplSplitItem
58 long mnSize;
59 long mnPixSize;
60 long mnLeft;
61 long mnTop;
62 long mnWidth;
63 long mnHeight;
64 long mnSplitPos;
65 long mnSplitSize;
66 long mnOldSplitPos;
67 long mnOldSplitSize;
68 long mnOldWidth;
69 long mnOldHeight;
70 ImplSplitSet* mpSet;
71 Window* mpWindow;
72 Window* mpOrgParent;
73 USHORT mnId;
74 SplitWindowItemBits mnBits;
75 BOOL mbFixed;
76 BOOL mbSubSize;
79 struct ImplSplitSet
81 ImplSplitItem* mpItems;
82 Wallpaper* mpWallpaper;
83 Bitmap* mpBitmap;
84 long mnLastSize;
85 long mnSplitSize;
86 USHORT mnItems;
87 USHORT mnId;
88 BOOL mbCalcPix;
91 #define SPLITWIN_SPLITSIZE 3
92 #define SPLITWIN_SPLITSIZEEX 4
93 #define SPLITWIN_SPLITSIZEEXLN 6
94 #define SPLITWIN_SPLITSIZEAUTOHIDE 36
95 #define SPLITWIN_SPLITSIZEFADE 36
97 #define SPLIT_HORZ ((USHORT)0x0001)
98 #define SPLIT_VERT ((USHORT)0x0002)
99 #define SPLIT_WINDOW ((USHORT)0x0004)
100 #define SPLIT_NOSPLIT ((USHORT)0x8000)
102 // -----------------------------------------------------------------------
104 DECLARE_LIST( ImplSplitList, SplitWindow* )
106 // =======================================================================
108 static void ImplCalcBorder( WindowAlign eAlign, BOOL bNoAlign,
109 long& rLeft, long& rTop,
110 long& rRight, long& rBottom )
112 if ( bNoAlign )
114 rLeft = 2;
115 rTop = 2;
116 rRight = 2;
117 rBottom = 2;
119 else
121 if ( eAlign == WINDOWALIGN_TOP )
123 rLeft = 2;
124 rTop = 2;
125 rRight = 2;
126 rBottom = 0;
128 else if ( eAlign == WINDOWALIGN_LEFT )
130 rLeft = 2;
131 rTop = 2;
132 rRight = 0;
133 rBottom = 2;
135 else if ( eAlign == WINDOWALIGN_BOTTOM )
137 rLeft = 2;
138 rTop = 0;
139 rRight = 2;
140 rBottom = 2;
142 else
144 rLeft = 0;
145 rTop = 2;
146 rRight = 2;
147 rBottom = 2;
152 // -----------------------------------------------------------------------
154 void SplitWindow::ImplDrawBorder( SplitWindow* pWin )
156 const StyleSettings& rStyleSettings = pWin->GetSettings().GetStyleSettings();
157 long nDX = pWin->mnDX;
158 long nDY = pWin->mnDY;
160 if ( pWin->mbNoAlign )
162 DecorationView aDecoView( pWin );
163 Point aTmpPoint;
164 Rectangle aRect( aTmpPoint, Size( nDX, nDY ) );
165 aDecoView.DrawFrame( aRect, FRAME_DRAW_DOUBLEIN );
167 else
169 if ( pWin->meAlign == WINDOWALIGN_BOTTOM )
171 pWin->SetLineColor( rStyleSettings.GetShadowColor() );
172 pWin->DrawLine( Point( 0, nDY-2 ), Point( nDX-1, nDY-2 ) );
173 pWin->SetLineColor( rStyleSettings.GetLightColor() );
174 pWin->DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) );
176 else
178 pWin->SetLineColor( rStyleSettings.GetShadowColor() );
179 pWin->DrawLine( Point( 0, 0 ), Point( nDX-1, 0 ) );
180 pWin->SetLineColor( rStyleSettings.GetLightColor() );
181 pWin->DrawLine( Point( 0, 1 ), Point( nDX-1, 1 ) );
182 if ( (pWin->meAlign == WINDOWALIGN_LEFT) || (pWin->meAlign == WINDOWALIGN_RIGHT) )
184 if ( pWin->meAlign == WINDOWALIGN_LEFT )
186 pWin->SetLineColor( rStyleSettings.GetShadowColor() );
187 pWin->DrawLine( Point( 0, 0 ), Point( 0, nDY-1 ) );
188 pWin->DrawLine( Point( 0, nDY-2 ), Point( nDX-1, nDY-2 ) );
189 pWin->SetLineColor( rStyleSettings.GetLightColor() );
190 pWin->DrawLine( Point( 1, 1 ), Point( 1, nDY-3 ) );
191 pWin->DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) );
193 else
195 pWin->SetLineColor( rStyleSettings.GetShadowColor() );
196 pWin->DrawLine( Point( nDX-2, 0 ), Point( nDX-2, nDY-3 ) );
197 pWin->DrawLine( Point( 0, nDY-2 ), Point( nDX-2, nDY-2 ) );
198 pWin->SetLineColor( rStyleSettings.GetLightColor() );
199 pWin->DrawLine( Point( nDX-1, 0 ), Point( nDX-1, nDY-1 ) );
200 pWin->DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) );
204 if ( pWin->meAlign == WINDOWALIGN_BOTTOM )
206 pWin->SetLineColor( rStyleSettings.GetShadowColor() );
207 pWin->DrawLine( Point( 0, nDY-2 ), Point( nDX-1, nDY-2 ) );
208 pWin->DrawLine( Point( 0, 0 ), Point( 0, nDY-1 ) );
209 pWin->DrawLine( Point( nDX-2, 0 ), Point( nDX-2, nDY-3 ) );
211 pWin->SetLineColor( rStyleSettings.GetLightColor() );
212 pWin->DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) );
213 pWin->DrawLine( Point( 1, 1 ), Point( 1, nDY-3 ) );
214 pWin->DrawLine( Point( nDX-1, 0 ), Point( nDX-1, nDY-1 ) );
216 else if ( pWin->meAlign == WINDOWALIGN_TOP )
218 pWin->SetLineColor( rStyleSettings.GetShadowColor() );
219 pWin->DrawLine( Point( 0, 0 ), Point( nDX-1, 0 ) );
220 pWin->DrawLine( Point( 0, 0 ), Point( 0, nDY-1 ) );
221 pWin->DrawLine( Point( nDX-2, 0 ), Point( nDX-2, nDY-1 ) );
223 pWin->SetLineColor( rStyleSettings.GetLightColor() );
224 pWin->DrawLine( Point( 1, 1 ), Point( nDX-3, 1 ) );
225 pWin->DrawLine( Point( 1, 1 ), Point( 1, nDY-1 ) );
226 pWin->DrawLine( Point( nDX-1, 1 ), Point( nDX-1, nDY-1 ) );
228 else if ( pWin->meAlign == WINDOWALIGN_LEFT )
230 pWin->SetLineColor( rStyleSettings.GetShadowColor() );
231 pWin->DrawLine( Point( 0, 0 ), Point( nDX-1, 0 ) );
232 pWin->DrawLine( Point( 0, 0 ), Point( 0, nDY-1 ) );
233 pWin->DrawLine( Point( 0, nDY-2 ), Point( nDX-1, nDY-2 ) );
235 pWin->SetLineColor( rStyleSettings.GetLightColor() );
236 pWin->DrawLine( Point( 1, 1 ), Point( nDX-1, 1 ) );
237 pWin->DrawLine( Point( 1, 1 ), Point( 1, nDY-3 ) );
238 pWin->DrawLine( Point( 1, nDY-1 ), Point( nDX-1, nDY-1 ) );
240 else
242 pWin->SetLineColor( rStyleSettings.GetShadowColor() );
243 pWin->DrawLine( Point( 0, 0 ), Point( nDX-2, 0 ) );
244 pWin->DrawLine( Point( nDX-2, 0 ), Point( nDX-2, nDY-3 ) );
245 pWin->DrawLine( Point( 0, nDY-2 ), Point( nDX-2, nDY-2 ) );
247 pWin->SetLineColor( rStyleSettings.GetLightColor() );
248 pWin->DrawLine( Point( 0, 1 ), Point( nDX-3, 1 ) );
249 pWin->DrawLine( Point( nDX-1, 0 ), Point( nDX-1, nDY-1 ) );
250 pWin->DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) );
255 // -----------------------------------------------------------------------
257 void SplitWindow::ImplDrawBorderLine( SplitWindow* pWin )
259 if ( pWin->mbFadeOut || pWin->mbAutoHide )
261 const StyleSettings& rStyleSettings = pWin->GetSettings().GetStyleSettings();
262 long nDX = pWin->mnDX;
263 long nDY = pWin->mnDY;
265 if ( pWin->meAlign == WINDOWALIGN_LEFT )
267 pWin->SetLineColor( rStyleSettings.GetShadowColor() );
268 pWin->DrawLine( Point( nDX-SPLITWIN_SPLITSIZEEXLN-1, 0 ), Point( nDX-SPLITWIN_SPLITSIZEEXLN-1, nDY-3 ) );
269 pWin->SetLineColor( rStyleSettings.GetLightColor() );
270 pWin->DrawLine( Point( nDX-SPLITWIN_SPLITSIZEEXLN, 1 ), Point( nDX-SPLITWIN_SPLITSIZEEXLN, nDY-4 ) );
272 else if ( pWin->meAlign == WINDOWALIGN_RIGHT )
274 pWin->SetLineColor( rStyleSettings.GetShadowColor() );
275 pWin->DrawLine( Point( SPLITWIN_SPLITSIZEEXLN-1, 0 ), Point( SPLITWIN_SPLITSIZEEXLN-1, nDY-3 ) );
276 pWin->SetLineColor( rStyleSettings.GetLightColor() );
277 pWin->DrawLine( Point( SPLITWIN_SPLITSIZEEXLN, 1 ), Point( SPLITWIN_SPLITSIZEEXLN, nDY-4 ) );
279 else if ( pWin->meAlign == WINDOWALIGN_TOP )
281 pWin->SetLineColor( rStyleSettings.GetShadowColor() );
282 pWin->DrawLine( Point( 0, nDY-SPLITWIN_SPLITSIZEEXLN-1 ), Point( nDX-3, nDY-SPLITWIN_SPLITSIZEEXLN-1 ) );
283 pWin->SetLineColor( rStyleSettings.GetLightColor() );
284 pWin->DrawLine( Point( 1, nDY-SPLITWIN_SPLITSIZEEXLN ), Point( nDX-4, nDY-SPLITWIN_SPLITSIZEEXLN ) );
286 else if ( pWin->meAlign == WINDOWALIGN_BOTTOM )
288 pWin->SetLineColor( rStyleSettings.GetShadowColor() );
289 pWin->DrawLine( Point( 0, SPLITWIN_SPLITSIZEEXLN-1 ), Point( nDX-3, SPLITWIN_SPLITSIZEEXLN-1 ) );
290 pWin->SetLineColor( rStyleSettings.GetLightColor() );
291 pWin->DrawLine( Point( 1, SPLITWIN_SPLITSIZEEXLN ), Point( nDX-4, SPLITWIN_SPLITSIZEEXLN ) );
296 // -----------------------------------------------------------------------
298 static ImplSplitSet* ImplFindSet( ImplSplitSet* pSet, USHORT nId )
300 if ( pSet->mnId == nId )
301 return pSet;
303 USHORT i;
304 USHORT nItems = pSet->mnItems;
305 ImplSplitItem* pItems = pSet->mpItems;
307 for ( i = 0; i < nItems; i++ )
309 if ( pItems[i].mnId == nId )
310 return pItems[i].mpSet;
313 for ( i = 0; i < nItems; i++ )
315 if ( pItems[i].mpSet )
317 ImplSplitSet* pFindSet = ImplFindSet( pItems[i].mpSet, nId );
318 if ( pFindSet )
319 return pFindSet;
323 return NULL;
326 // -----------------------------------------------------------------------
328 static ImplSplitSet* ImplFindItem( ImplSplitSet* pSet, USHORT nId, USHORT& rPos )
330 USHORT i;
331 USHORT nItems = pSet->mnItems;
332 ImplSplitItem* pItems = pSet->mpItems;
334 for ( i = 0; i < nItems; i++ )
336 if ( pItems[i].mnId == nId )
338 rPos = i;
339 return pSet;
343 for ( i = 0; i < nItems; i++ )
345 if ( pItems[i].mpSet )
347 ImplSplitSet* pFindSet = ImplFindItem( pItems[i].mpSet, nId, rPos );
348 if ( pFindSet )
349 return pFindSet;
353 return NULL;
356 // -----------------------------------------------------------------------
358 static USHORT ImplFindItem( ImplSplitSet* pSet, Window* pWindow )
360 USHORT i;
361 USHORT nItems = pSet->mnItems;
362 ImplSplitItem* pItems = pSet->mpItems;
364 for ( i = 0; i < nItems; i++ )
366 if ( pItems[i].mpWindow == pWindow )
367 return pItems[i].mnId;
368 else
370 if ( pItems[i].mpSet )
372 USHORT nId = ImplFindItem( pItems[i].mpSet, pWindow );
373 if ( nId )
374 return nId;
379 return 0;
382 // -----------------------------------------------------------------------
384 static USHORT ImplFindItem( ImplSplitSet* pSet, const Point& rPos,
385 BOOL bRows, BOOL bDown = TRUE )
387 USHORT i;
388 USHORT nItems = pSet->mnItems;
389 ImplSplitItem* pItems = pSet->mpItems;
391 for ( i = 0; i < nItems; i++ )
393 if ( pItems[i].mnWidth && pItems[i].mnHeight )
395 // Wegen ICC auftrennen
396 Point aPoint( pItems[i].mnLeft, pItems[i].mnTop );
397 Size aSize( pItems[i].mnWidth, pItems[i].mnHeight );
398 Rectangle aRect( aPoint, aSize );
399 if ( bRows )
401 if ( bDown )
402 aRect.Bottom() += pSet->mnSplitSize;
403 else
404 aRect.Top() -= pSet->mnSplitSize;
406 else
408 if ( bDown )
409 aRect.Right() += pSet->mnSplitSize;
410 else
411 aRect.Left() -= pSet->mnSplitSize;
414 if ( aRect.IsInside( rPos ) )
416 if ( pItems[i].mpSet && pItems[i].mpSet->mpItems )
418 return ImplFindItem( pItems[i].mpSet, rPos,
419 ((pItems[i].mnBits & SWIB_COLSET) == 0) );
421 else
422 return pItems[i].mnId;
427 return 0;
430 // -----------------------------------------------------------------------
432 static void ImplDeleteSet( ImplSplitSet* pSet )
434 USHORT i;
435 USHORT nItems = pSet->mnItems;
436 ImplSplitItem* pItems = pSet->mpItems;
438 for ( i = 0; i < nItems; i++ )
440 if ( pItems[i].mpSet )
441 ImplDeleteSet( pItems[i].mpSet );
444 if ( pSet->mpWallpaper )
445 delete pSet->mpWallpaper;
447 if ( pSet->mpBitmap )
448 delete pSet->mpBitmap;
450 delete [] pItems;
451 delete pSet;
454 // -----------------------------------------------------------------------
456 static void ImplSetSplitSize( ImplSplitSet* pSet, long nNewSize )
458 pSet->mnSplitSize = nNewSize;
459 for ( USHORT i = 0; i < pSet->mnItems; i++ )
461 if ( pSet->mpItems[i].mpSet )
462 ImplSetSplitSize( pSet->mpItems[i].mpSet, nNewSize );
466 // -----------------------------------------------------------------------
468 static void ImplCalcSet( ImplSplitSet* pSet,
469 long nSetLeft, long nSetTop,
470 long nSetWidth, long nSetHeight,
471 BOOL bRows, BOOL bDown = TRUE )
473 if ( !pSet->mpItems )
474 return;
476 USHORT i;
477 USHORT j;
478 USHORT nMins;
479 USHORT nCalcItems;
480 USHORT nItems = pSet->mnItems;
481 USHORT nVisItems;
482 USHORT nAbsItems;
483 long nCalcSize;
484 long nSizeDelta;
485 long nCurSize;
486 long nSizeWinSize;
487 long nNewSizeWinSize;
488 long nTemp;
489 long nTempErr;
490 long nErrorSum;
491 long nCurSizeDelta;
492 long nPos;
493 long nMaxPos;
494 long* pSize;
495 ImplSplitItem* pItems = pSet->mpItems;
496 BOOL bEmpty;
498 // Anzahl sichtbarer Items ermitteln
499 nVisItems = 0;
500 for ( i = 0; i < nItems; i++ )
502 if ( !(pItems[i].mnBits & SWIB_INVISIBLE) )
503 nVisItems++;
506 // Groessen berechnen
507 if ( bRows )
508 nCalcSize = nSetHeight;
509 else
510 nCalcSize = nSetWidth;
511 nCalcSize -= (nVisItems-1)*pSet->mnSplitSize;
512 nCurSize = 0;
513 if ( pSet->mbCalcPix || (pSet->mnLastSize != nCalcSize) )
515 long nPercentFactor = 10;
516 long nRelCount = 0;
517 long nPercent = 0;
518 long nRelPercent = 0;
519 long nAbsSize = 0;
520 for ( i = 0; i < nItems; i++ )
522 if ( !(pItems[i].mnBits & SWIB_INVISIBLE) )
524 if ( pItems[i].mnBits & SWIB_RELATIVESIZE )
525 nRelCount += pItems[i].mnSize;
526 else if ( pItems[i].mnBits & SWIB_PERCENTSIZE )
527 nPercent += pItems[i].mnSize;
528 else
529 nAbsSize += pItems[i].mnSize;
532 // Relative-Werte auf prozentual mappen (Percent bei uns 10tel Prozent)
533 nPercent *= nPercentFactor;
534 if ( nRelCount )
536 long nRelPercentBase = 1000;
537 while ( (nRelCount > nRelPercentBase) && (nPercentFactor < 100000) )
539 nRelPercentBase *= 10;
540 nPercentFactor *= 10;
542 if ( nPercent < nRelPercentBase )
544 nRelPercent = (nRelPercentBase-nPercent)/nRelCount;
545 nPercent += nRelPercent*nRelCount;
547 else
548 nRelPercent = 0;
550 if ( !nPercent )
551 nPercent = 1;
552 nSizeDelta = nCalcSize-nAbsSize;
553 for ( i = 0; i < nItems; i++ )
555 if ( pItems[i].mnBits & SWIB_INVISIBLE )
556 pItems[i].mnPixSize = 0;
557 else if ( pItems[i].mnBits & SWIB_RELATIVESIZE )
559 if ( nSizeDelta <= 0 )
560 pItems[i].mnPixSize = 0;
561 else
562 pItems[i].mnPixSize = (nSizeDelta*pItems[i].mnSize*nRelPercent)/nPercent;
564 else if ( pItems[i].mnBits & SWIB_PERCENTSIZE )
566 if ( nSizeDelta <= 0 )
567 pItems[i].mnPixSize = 0;
568 else
569 pItems[i].mnPixSize = (nSizeDelta*pItems[i].mnSize*nPercentFactor)/nPercent;
571 else
572 pItems[i].mnPixSize = pItems[i].mnSize;
573 nCurSize += pItems[i].mnPixSize;
576 pSet->mbCalcPix = FALSE;
577 pSet->mnLastSize = nCalcSize;
579 // Fenster einpassen
580 nSizeDelta = nCalcSize-nCurSize;
581 if ( nSizeDelta )
583 nAbsItems = 0;
584 nSizeWinSize = 0;
585 nNewSizeWinSize = 0;
587 // Zuerst die absoluten Items relativ resizen
588 for ( i = 0; i < nItems; i++ )
590 if ( !(pItems[i].mnBits & SWIB_INVISIBLE) )
592 if ( !(pItems[i].mnBits & (SWIB_RELATIVESIZE | SWIB_PERCENTSIZE)) )
594 nAbsItems++;
595 nSizeWinSize += pItems[i].mnPixSize;
599 // Rundungsfehler werden hier nicht ausgelichen
600 if ( (nAbsItems < (USHORT)(Abs( nSizeDelta ))) && nSizeWinSize )
602 for ( i = 0; i < nItems; i++ )
604 if ( !(pItems[i].mnBits & SWIB_INVISIBLE) )
606 if ( !(pItems[i].mnBits & (SWIB_RELATIVESIZE | SWIB_PERCENTSIZE)) )
608 pItems[i].mnPixSize += (nSizeDelta*pItems[i].mnPixSize)/nSizeWinSize;
609 nNewSizeWinSize += pItems[i].mnPixSize;
613 nSizeDelta -= nNewSizeWinSize-nSizeWinSize;
616 // Jetzt die Rundunsfehler ausgleichen
617 j = 0;
618 nMins = 0;
619 while ( nSizeDelta && (nItems != nMins) )
621 // Feststellen, welche Items berechnet werden duerfen
622 nCalcItems = 0;
623 while ( !nCalcItems )
625 for ( i = 0; i < nItems; i++ )
627 pItems[i].mbSubSize = FALSE;
629 if ( j >= 2 )
630 pItems[i].mbSubSize = TRUE;
631 else
633 if ( !(pItems[i].mnBits & SWIB_INVISIBLE) )
635 if ( (nSizeDelta > 0) || pItems[i].mnPixSize )
637 if ( j >= 1 )
638 pItems[i].mbSubSize = TRUE;
639 else
641 if ( (j == 0) && (pItems[i].mnBits & (SWIB_RELATIVESIZE | SWIB_PERCENTSIZE)) )
642 pItems[i].mbSubSize = TRUE;
648 if ( pItems[i].mbSubSize )
649 nCalcItems++;
652 j++;
655 // Groessen von den einzelnen Items abziehen
656 nErrorSum = nSizeDelta % nCalcItems;
657 nCurSizeDelta = nSizeDelta / nCalcItems;
658 nMins = 0;
659 for ( i = 0; i < nItems; i++ )
661 if ( pItems[i].mnBits & SWIB_INVISIBLE )
662 nMins++;
663 else if ( pItems[i].mbSubSize )
665 pSize = &(pItems[i].mnPixSize);
667 if ( nErrorSum )
669 if ( nErrorSum < 0 )
670 nTempErr = -1;
671 else
672 nTempErr = 1;
674 else
675 nTempErr = 0;
677 if ( (*pSize+nCurSizeDelta+nTempErr) <= 0 )
679 nTemp = *pSize;
680 if ( nTemp )
682 *pSize -= nTemp;
683 nSizeDelta += nTemp;
685 nMins++;
687 else
689 *pSize += nCurSizeDelta;
690 nSizeDelta -= nCurSizeDelta;
691 if ( nTempErr && (*pSize || (nTempErr > 0)) )
693 *pSize += nTempErr;
694 nSizeDelta -= nTempErr;
695 nErrorSum -= nTempErr;
703 else
705 for ( i = 0; i < nItems; i++ )
707 if ( !(pItems[i].mnBits & SWIB_INVISIBLE) )
708 nCurSize += pItems[i].mnPixSize;
712 // Maximale Groesse berechnen
713 if ( bRows )
715 nPos = nSetTop;
716 if ( !bDown )
717 nMaxPos = nSetTop-nSetHeight;
718 else
719 nMaxPos = nSetTop+nSetHeight;
721 else
723 nPos = nSetLeft;
724 if ( !bDown )
725 nMaxPos = nSetLeft-nSetWidth;
726 else
727 nMaxPos = nSetLeft+nSetWidth;
730 // Fenster anordnen und Werte anpassen
731 for ( i = 0; i < nItems; i++ )
733 pItems[i].mnOldSplitPos = pItems[i].mnSplitPos;
734 pItems[i].mnOldSplitSize = pItems[i].mnSplitSize;
735 pItems[i].mnOldWidth = pItems[i].mnWidth;
736 pItems[i].mnOldHeight = pItems[i].mnHeight;
738 if ( pItems[i].mnBits & SWIB_INVISIBLE )
739 bEmpty = TRUE;
740 else
742 bEmpty = FALSE;
743 if ( bDown )
745 if ( nPos+pItems[i].mnPixSize > nMaxPos )
746 bEmpty = TRUE;
748 else
750 nPos -= pItems[i].mnPixSize;
751 if ( nPos < nMaxPos )
752 bEmpty = TRUE;
756 if ( bEmpty )
758 pItems[i].mnWidth = 0;
759 pItems[i].mnHeight = 0;
760 pItems[i].mnSplitSize = 0;
762 else
764 if ( bRows )
766 pItems[i].mnLeft = nSetLeft;
767 pItems[i].mnTop = nPos;
768 pItems[i].mnWidth = nSetWidth;
769 pItems[i].mnHeight = pItems[i].mnPixSize;
771 else
773 pItems[i].mnLeft = nPos;
774 pItems[i].mnTop = nSetTop;
775 pItems[i].mnWidth = pItems[i].mnPixSize;
776 pItems[i].mnHeight = nSetHeight;
779 if ( i > nItems-1 )
780 pItems[i].mnSplitSize = 0;
781 else
783 pItems[i].mnSplitSize = pSet->mnSplitSize;
784 if ( bDown )
786 pItems[i].mnSplitPos = nPos+pItems[i].mnPixSize;
787 if ( pItems[i].mnSplitPos+pItems[i].mnSplitSize > nMaxPos )
788 pItems[i].mnSplitSize = nMaxPos-pItems[i].mnSplitPos;
790 else
792 pItems[i].mnSplitPos = nPos-pSet->mnSplitSize;
793 if ( pItems[i].mnSplitPos < nMaxPos )
794 pItems[i].mnSplitSize = pItems[i].mnSplitPos+pSet->mnSplitSize-nMaxPos;
799 if ( !(pItems[i].mnBits & SWIB_INVISIBLE) )
801 if ( !bDown )
802 nPos -= pSet->mnSplitSize;
803 else
804 nPos += pItems[i].mnPixSize+pSet->mnSplitSize;
808 // Sub-Set's berechnen
809 for ( i = 0; i < nItems; i++ )
811 if ( pItems[i].mpSet && pItems[i].mnWidth && pItems[i].mnHeight )
813 ImplCalcSet( pItems[i].mpSet,
814 pItems[i].mnLeft, pItems[i].mnTop,
815 pItems[i].mnWidth, pItems[i].mnHeight,
816 ((pItems[i].mnBits & SWIB_COLSET) == 0) );
820 // Fixed setzen
821 for ( i = 0; i < nItems; i++ )
823 pItems[i].mbFixed = FALSE;
824 if ( pItems[i].mnBits & SWIB_FIXED )
825 pItems[i].mbFixed = TRUE;
826 else
828 // Wenn Child-Set vorhanden, ist dieses Item auch Fixed, wenn
829 // ein Child fixed ist
830 if ( pItems[i].mpSet )
832 for ( j = 0; j < pItems[i].mpSet->mnItems; j++ )
834 if ( pItems[i].mpSet->mpItems[j].mbFixed )
836 pItems[i].mbFixed = TRUE;
837 break;
845 // -----------------------------------------------------------------------
847 void SplitWindow::ImplCalcSet2( SplitWindow* pWindow, ImplSplitSet* pSet, BOOL bHide,
848 BOOL bRows, BOOL /*bDown*/ )
850 USHORT i;
851 USHORT nItems = pSet->mnItems;
852 ImplSplitItem* pItems = pSet->mpItems;
854 if ( pWindow->IsReallyVisible() && pWindow->IsUpdateMode() && pWindow->mbInvalidate )
856 for ( i = 0; i < nItems; i++ )
858 if ( pItems[i].mnSplitSize )
860 // Evt. alles invalidieren oder nur einen kleinen Teil
861 if ( (pItems[i].mnOldSplitPos != pItems[i].mnSplitPos) ||
862 (pItems[i].mnOldSplitSize != pItems[i].mnSplitSize) ||
863 (pItems[i].mnOldWidth != pItems[i].mnWidth) ||
864 (pItems[i].mnOldHeight != pItems[i].mnHeight) )
866 Rectangle aRect;
868 // Old Rect invalidieren
869 if ( bRows )
871 aRect.Left() = pItems[i].mnLeft;
872 aRect.Right() = pItems[i].mnLeft+pItems[i].mnOldWidth-1;
873 aRect.Top() = pItems[i].mnOldSplitPos;
874 aRect.Bottom() = aRect.Top() + pItems[i].mnOldSplitSize;
876 else
878 aRect.Top() = pItems[i].mnTop;
879 aRect.Bottom() = pItems[i].mnTop+pItems[i].mnOldHeight-1;
880 aRect.Left() = pItems[i].mnOldSplitPos;
881 aRect.Right() = aRect.Left() + pItems[i].mnOldSplitSize;
883 pWindow->Invalidate( aRect );
884 // New Rect invalidieren
885 if ( bRows )
887 aRect.Left() = pItems[i].mnLeft;
888 aRect.Right() = pItems[i].mnLeft+pItems[i].mnWidth-1;
889 aRect.Top() = pItems[i].mnSplitPos;
890 aRect.Bottom() = aRect.Top() + pItems[i].mnSplitSize;
892 else
894 aRect.Top() = pItems[i].mnTop;
895 aRect.Bottom() = pItems[i].mnTop+pItems[i].mnHeight-1;
896 aRect.Left() = pItems[i].mnSplitPos;
897 aRect.Right() = aRect.Left() + pItems[i].mnSplitSize;
899 pWindow->Invalidate( aRect );
901 // Leere Sets komplett invalidieren, da diese Flaechen
902 // nicht von Fenstern ueberladen werden
903 if ( pItems[i].mpSet && !pItems[i].mpSet->mpItems )
905 aRect.Left() = pItems[i].mnLeft;
906 aRect.Top() = pItems[i].mnTop;
907 aRect.Right() = pItems[i].mnLeft+pItems[i].mnWidth-1;
908 aRect.Bottom() = pItems[i].mnTop+pItems[i].mnHeight-1;
909 pWindow->Invalidate( aRect );
916 // Fenster positionieren
917 for ( i = 0; i < nItems; i++ )
919 if ( pItems[i].mpSet )
921 BOOL bTempHide = bHide;
922 if ( !pItems[i].mnWidth || !pItems[i].mnHeight )
923 bTempHide = TRUE;
924 ImplCalcSet2( pWindow, pItems[i].mpSet, bTempHide,
925 ((pItems[i].mnBits & SWIB_COLSET) == 0) );
927 else
929 if ( pItems[i].mnWidth && pItems[i].mnHeight && !bHide )
931 Point aPos( pItems[i].mnLeft, pItems[i].mnTop );
932 Size aSize( pItems[i].mnWidth, pItems[i].mnHeight );
933 pItems[i].mpWindow->SetPosSizePixel( aPos, aSize );
935 else
936 pItems[i].mpWindow->Hide();
940 // Fenster anzeigen und Flag zuruecksetzen
941 for ( i = 0; i < nItems; i++ )
943 if ( pItems[i].mpWindow && pItems[i].mnWidth && pItems[i].mnHeight && !bHide )
944 pItems[i].mpWindow->Show();
948 // -----------------------------------------------------------------------
950 static void ImplCalcLogSize( ImplSplitItem* pItems, USHORT nItems )
952 // Original-Groessen updaten
953 USHORT i;
954 long nRelSize = 0;
955 long nPerSize = 0;
956 for ( i = 0; i < nItems; i++ )
958 if ( pItems[i].mnBits & SWIB_RELATIVESIZE )
959 nRelSize += pItems[i].mnPixSize;
960 else if ( pItems[i].mnBits & SWIB_PERCENTSIZE )
961 nPerSize += pItems[i].mnPixSize;
963 nPerSize += nRelSize;
964 for ( i = 0; i < nItems; i++ )
966 if ( pItems[i].mnBits & SWIB_RELATIVESIZE )
968 if ( nRelSize )
969 pItems[i].mnSize = (pItems[i].mnPixSize+(nRelSize/2))/nRelSize;
970 else
971 pItems[i].mnSize = 1;
973 else if ( pItems[i].mnBits & SWIB_PERCENTSIZE )
975 if ( nPerSize )
976 pItems[i].mnSize = (pItems[i].mnPixSize*100)/nPerSize;
977 else
978 pItems[i].mnSize = 1;
980 else
981 pItems[i].mnSize = pItems[i].mnPixSize;
985 // -----------------------------------------------------------------------
987 void SplitWindow::ImplDrawBack( SplitWindow* pWindow, const Rectangle& rRect,
988 const Wallpaper* pWall, const Bitmap* pBitmap )
990 if ( pBitmap )
992 Point aPos = rRect.TopLeft();
993 Size aBmpSize = pBitmap->GetSizePixel();
994 pWindow->Push( PUSH_CLIPREGION );
995 pWindow->IntersectClipRegion( rRect );
998 aPos.X() = rRect.Left();
1001 pWindow->DrawBitmap( aPos, *pBitmap );
1002 aPos.X() += aBmpSize.Width();
1004 while ( aPos.X() < rRect.Right() );
1005 aPos.Y() += aBmpSize.Height();
1007 while ( aPos.Y() < rRect.Bottom() );
1008 pWindow->Pop();
1010 else
1011 pWindow->DrawWallpaper( rRect, *pWall );
1014 // -----------------------------------------------------------------------
1016 void SplitWindow::ImplDrawBack( SplitWindow* pWindow, ImplSplitSet* pSet )
1018 USHORT i;
1019 USHORT nItems = pSet->mnItems;
1020 ImplSplitItem* pItems = pSet->mpItems;
1022 // Beim Mainset auch den Hintergrund zeichnen
1023 if ( pSet->mnId == 0 )
1025 if ( pSet->mpBitmap )
1027 Rectangle aRect( pWindow->mnLeftBorder,
1028 pWindow->mnTopBorder,
1029 pWindow->mnDX-pWindow->mnRightBorder-1,
1030 pWindow->mnDY-pWindow->mnBottomBorder-1 );
1031 ImplDrawBack( pWindow, aRect, pSet->mpWallpaper, pSet->mpBitmap );
1035 for ( i = 0; i < nItems; i++ )
1037 pSet = pItems[i].mpSet;
1038 if ( pSet )
1040 if ( pSet->mpBitmap || pSet->mpWallpaper )
1042 // Wegen ICC auftrennen
1043 Point aPoint( pItems[i].mnLeft, pItems[i].mnTop );
1044 Size aSize( pItems[i].mnWidth, pItems[i].mnHeight );
1045 Rectangle aRect( aPoint, aSize );
1046 ImplDrawBack( pWindow, aRect, pSet->mpWallpaper, pSet->mpBitmap );
1051 for ( i = 0; i < nItems; i++ )
1053 if ( pItems[i].mpSet )
1054 ImplDrawBack( pWindow, pItems[i].mpSet );
1058 // -----------------------------------------------------------------------
1060 static void ImplDrawSplit( SplitWindow* pWindow, ImplSplitSet* pSet,
1061 BOOL bRows, BOOL bDown = TRUE )
1063 if ( !pSet->mpItems )
1064 return;
1066 USHORT i;
1067 USHORT nItems = pSet->mnItems;
1068 long nPos;
1069 long nTop;
1070 long nBottom;
1071 ImplSplitItem* pItems = pSet->mpItems;
1072 const StyleSettings& rStyleSettings = pWindow->GetSettings().GetStyleSettings();
1074 BOOL bFlat = (pWindow->GetStyle() & WB_FLATSPLITDRAW) == WB_FLATSPLITDRAW;
1076 for ( i = 0; i < nItems-1; i++ )
1078 if ( pItems[i].mnSplitSize )
1080 nPos = pItems[i].mnSplitPos;
1082 long nItemSplitSize = pItems[i].mnSplitSize;
1083 long nSplitSize = pSet->mnSplitSize;
1084 if ( bRows )
1086 nTop = pItems[i].mnLeft;
1087 nBottom = pItems[i].mnLeft+pItems[i].mnWidth-1;
1089 if ( bFlat ) nPos--;
1091 if ( bDown || (nItemSplitSize >= nSplitSize) )
1093 pWindow->SetLineColor( rStyleSettings.GetLightColor() );
1094 pWindow->DrawLine( Point( nTop, nPos+1 ), Point( nBottom, nPos+1 ) );
1096 nPos += nSplitSize-2;
1097 if ( bFlat ) nPos+=2;
1098 if ( (!bDown && (nItemSplitSize >= 2)) ||
1099 (bDown && (nItemSplitSize >= nSplitSize-1)) )
1101 pWindow->SetLineColor( rStyleSettings.GetShadowColor() );
1102 pWindow->DrawLine( Point( nTop, nPos ), Point( nBottom, nPos ) );
1104 if ( !bFlat )
1106 nPos++;
1107 if ( !bDown || (nItemSplitSize >= nSplitSize) )
1109 pWindow->SetLineColor( rStyleSettings.GetDarkShadowColor() );
1110 pWindow->DrawLine( Point( nTop, nPos ), Point( nBottom, nPos ) );
1114 else
1116 nTop = pItems[i].mnTop;
1117 nBottom = pItems[i].mnTop+pSet->mpItems[i].mnHeight-1;
1119 if ( bFlat ) nPos--;
1120 if ( bDown || (nItemSplitSize >= nSplitSize) )
1122 pWindow->SetLineColor( rStyleSettings.GetLightColor() );
1123 pWindow->DrawLine( Point( nPos+1, nTop ), Point( nPos+1, nBottom ) );
1125 nPos += pSet->mnSplitSize-2;
1126 if ( bFlat ) nPos+=2;
1127 if ( (!bDown && (nItemSplitSize >= 2)) ||
1128 (bDown && (nItemSplitSize >= nSplitSize-1)) )
1130 pWindow->SetLineColor( rStyleSettings.GetShadowColor() );
1131 pWindow->DrawLine( Point( nPos, nTop ), Point( nPos, nBottom ) );
1133 if( !bFlat )
1135 nPos++;
1136 if ( !bDown || (nItemSplitSize >= nSplitSize) )
1138 pWindow->SetLineColor( rStyleSettings.GetDarkShadowColor() );
1139 pWindow->DrawLine( Point( nPos, nTop ), Point( nPos, nBottom ) );
1146 for ( i = 0; i < nItems; i++ )
1148 if ( pItems[i].mpSet && pItems[i].mnWidth && pItems[i].mnHeight )
1149 ImplDrawSplit( pWindow, pItems[i].mpSet, ((pItems[i].mnBits & SWIB_COLSET) == 0) );
1153 // -----------------------------------------------------------------------
1155 USHORT SplitWindow::ImplTestSplit( ImplSplitSet* pSet, const Point& rPos,
1156 long& rMouseOff, ImplSplitSet** ppFoundSet, USHORT& rFoundPos,
1157 BOOL bRows, BOOL /*bDown*/ )
1159 if ( !pSet->mpItems )
1160 return 0;
1162 USHORT i;
1163 USHORT nSplitTest;
1164 USHORT nItems = pSet->mnItems;
1165 long nMPos1;
1166 long nMPos2;
1167 long nPos;
1168 long nTop;
1169 long nBottom;
1170 ImplSplitItem* pItems = pSet->mpItems;
1172 if ( bRows )
1174 nMPos1 = rPos.X();
1175 nMPos2 = rPos.Y();
1177 else
1179 nMPos1 = rPos.Y();
1180 nMPos2 = rPos.X();
1183 for ( i = 0; i < nItems-1; i++ )
1185 if ( pItems[i].mnSplitSize )
1187 if ( bRows )
1189 nTop = pItems[i].mnLeft;
1190 nBottom = pItems[i].mnLeft+pItems[i].mnWidth-1;
1192 else
1194 nTop = pItems[i].mnTop;
1195 nBottom = pItems[i].mnTop+pItems[i].mnHeight-1;
1197 nPos = pItems[i].mnSplitPos;
1199 if ( (nMPos1 >= nTop) && (nMPos1 <= nBottom) &&
1200 (nMPos2 >= nPos) && (nMPos2 <= nPos+pItems[i].mnSplitSize) )
1202 if ( !pItems[i].mbFixed && !pItems[i+1].mbFixed )
1204 rMouseOff = nMPos2-nPos;
1205 *ppFoundSet = pSet;
1206 rFoundPos = i;
1207 if ( bRows )
1208 return SPLIT_VERT;
1209 else
1210 return SPLIT_HORZ;
1212 else
1213 return SPLIT_NOSPLIT;
1218 for ( i = 0; i < nItems; i++ )
1220 if ( pItems[i].mpSet )
1222 nSplitTest = ImplTestSplit( pItems[i].mpSet, rPos,
1223 rMouseOff, ppFoundSet, rFoundPos,
1224 ((pItems[i].mnBits & SWIB_COLSET) == 0) );
1225 if ( nSplitTest )
1226 return nSplitTest;
1230 return 0;
1233 // -----------------------------------------------------------------------
1235 USHORT SplitWindow::ImplTestSplit( SplitWindow* pWindow, const Point& rPos,
1236 long& rMouseOff, ImplSplitSet** ppFoundSet, USHORT& rFoundPos )
1238 // Resizeable SplitWindow muss anders behandelt werden
1239 if ( pWindow->mnWinStyle & WB_SIZEABLE )
1241 long nTPos;
1242 long nPos;
1243 long nBorder;
1245 if ( pWindow->mbHorz )
1247 if ( pWindow->mbBottomRight )
1249 nBorder = pWindow->mnBottomBorder;
1250 nPos = 0;
1252 else
1254 nBorder = pWindow->mnTopBorder;
1255 nPos = pWindow->mnDY-nBorder;
1257 nTPos = rPos.Y();
1259 else
1261 if ( pWindow->mbBottomRight )
1263 nBorder = pWindow->mnRightBorder;
1264 nPos = 0;
1266 else
1268 nBorder = pWindow->mnLeftBorder;
1269 nPos = pWindow->mnDX-nBorder;
1271 nTPos = rPos.X();
1273 long nSplitSize = pWindow->mpMainSet->mnSplitSize-2;
1274 if ( pWindow->mbAutoHide || pWindow->mbFadeOut )
1275 nSplitSize += SPLITWIN_SPLITSIZEEXLN;
1276 if ( !pWindow->mbBottomRight )
1277 nPos -= nSplitSize;
1278 if ( (nTPos >= nPos) && (nTPos <= nPos+nSplitSize+nBorder) )
1280 rMouseOff = nTPos-nPos;
1281 *ppFoundSet = pWindow->mpMainSet;
1282 if ( pWindow->mpMainSet->mpItems )
1283 rFoundPos = pWindow->mpMainSet->mnItems-1;
1284 else
1285 rFoundPos = 0;
1286 if ( pWindow->mbHorz )
1287 return SPLIT_VERT | SPLIT_WINDOW;
1288 else
1289 return SPLIT_HORZ | SPLIT_WINDOW;
1293 return ImplTestSplit( pWindow->mpMainSet, rPos, rMouseOff, ppFoundSet, rFoundPos,
1294 pWindow->mbHorz, !pWindow->mbBottomRight );
1297 // -----------------------------------------------------------------------
1299 void SplitWindow::ImplDrawSplitTracking( SplitWindow* pThis, const Point& rPos )
1301 Rectangle aRect;
1303 if ( pThis->mnSplitTest & SPLIT_HORZ )
1305 aRect.Top() = pThis->maDragRect.Top();
1306 aRect.Bottom() = pThis->maDragRect.Bottom();
1307 aRect.Left() = rPos.X();
1308 aRect.Right() = aRect.Left()+pThis->mpSplitSet->mnSplitSize-1;
1309 if ( !(pThis->mnWinStyle & WB_NOSPLITDRAW) )
1310 aRect.Right()--;
1311 if ( (pThis->mnSplitTest & SPLIT_WINDOW) &&
1312 (pThis->mbAutoHide || pThis->mbFadeOut) )
1314 aRect.Left() += SPLITWIN_SPLITSIZEEXLN;
1315 aRect.Right() += SPLITWIN_SPLITSIZEEXLN;
1318 else
1320 aRect.Left() = pThis->maDragRect.Left();
1321 aRect.Right() = pThis->maDragRect.Right();
1322 aRect.Top() = rPos.Y();
1323 aRect.Bottom() = aRect.Top()+pThis->mpSplitSet->mnSplitSize-1;
1324 if ( !(pThis->mnWinStyle & WB_NOSPLITDRAW) )
1325 aRect.Bottom()--;
1326 if ( (pThis->mnSplitTest & SPLIT_WINDOW) &&
1327 (pThis->mbAutoHide || pThis->mbFadeOut) )
1329 aRect.Top() += SPLITWIN_SPLITSIZEEXLN;
1330 aRect.Bottom() += SPLITWIN_SPLITSIZEEXLN;
1333 pThis->ShowTracking( aRect, SHOWTRACK_SPLIT );
1336 // -----------------------------------------------------------------------
1338 void SplitWindow::ImplInit( Window* pParent, WinBits nStyle )
1340 ImplSplitSet* pNewSet = new ImplSplitSet;
1341 pNewSet->mpItems = NULL;
1342 pNewSet->mpWallpaper = NULL;
1343 pNewSet->mpBitmap = NULL;
1344 pNewSet->mnLastSize = 0;
1345 pNewSet->mnItems = 0;
1346 pNewSet->mnId = 0;
1347 pNewSet->mnSplitSize = SPLITWIN_SPLITSIZE;
1348 pNewSet->mbCalcPix = TRUE;
1350 mpMainSet = pNewSet;
1351 mpBaseSet = pNewSet;
1352 mpSplitSet = NULL;
1353 mpLastSizes = NULL;
1354 mnDX = 0;
1355 mnDY = 0;
1356 mnLeftBorder = 0;
1357 mnTopBorder = 0;
1358 mnRightBorder = 0;
1359 mnBottomBorder = 0;
1360 mnMaxSize = 0;
1361 mnMouseOff = 0;
1362 meAlign = WINDOWALIGN_TOP;
1363 mnWinStyle = nStyle;
1364 mnSplitTest = 0;
1365 mnSplitPos = 0;
1366 mnMouseModifier = 0;
1367 mnMStartPos = 0;
1368 mnMSplitPos = 0;
1369 mbDragFull = FALSE;
1370 mbHorz = TRUE;
1371 mbBottomRight = FALSE;
1372 mbCalc = FALSE;
1373 mbRecalc = TRUE;
1374 mbInvalidate = TRUE;
1375 mbAutoHide = FALSE;
1376 mbFadeIn = FALSE;
1377 mbFadeOut = FALSE;
1378 mbAutoHideIn = FALSE;
1379 mbAutoHideDown = FALSE;
1380 mbFadeInDown = FALSE;
1381 mbFadeOutDown = FALSE;
1382 mbAutoHidePressed = FALSE;
1383 mbFadeInPressed = FALSE;
1384 mbFadeOutPressed = FALSE;
1385 mbFadeNoButtonMode = FALSE;
1386 mbNoAlign = FALSE;
1388 if ( nStyle & WB_NOSPLITDRAW )
1390 pNewSet->mnSplitSize -= 2;
1391 mbInvalidate = FALSE;
1394 if ( nStyle & WB_BORDER )
1396 ImplCalcBorder( meAlign, mbNoAlign, mnLeftBorder, mnTopBorder,
1397 mnRightBorder, mnBottomBorder );
1399 else
1401 mnLeftBorder = 0;
1402 mnTopBorder = 0;
1403 mnRightBorder = 0;
1404 mnBottomBorder = 0;
1407 DockingWindow::ImplInit( pParent, (nStyle | WB_CLIPCHILDREN) & ~(WB_BORDER | WB_SIZEABLE) );
1409 ImplInitSettings();
1412 // -----------------------------------------------------------------------
1414 void SplitWindow::ImplInitSettings()
1416 // Wenn fuer das MainSet eine Bitmap gesetzt wird, dann
1417 // brauchen wir nicht mehr den Hintergrund loeschen
1418 // Wenn MainSet Wallpaper hat, dann ist das der Hintergrund, ansonsten
1419 // sind es die Standard-Farben
1420 if ( mpMainSet->mpBitmap )
1421 SetBackground();
1422 else if ( mpMainSet->mpWallpaper )
1423 SetBackground( *mpMainSet->mpWallpaper );
1424 else
1426 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1428 Color aColor;
1429 if ( IsControlBackground() )
1430 aColor = GetControlBackground();
1431 else if ( Window::GetStyle() & WB_3DLOOK )
1432 aColor = rStyleSettings.GetFaceColor();
1433 else
1434 aColor = rStyleSettings.GetWindowColor();
1435 SetBackground( aColor );
1439 // =======================================================================
1441 SplitWindow::SplitWindow( Window* pParent, WinBits nStyle ) :
1442 DockingWindow( WINDOW_SPLITWINDOW )
1444 ImplInit( pParent, nStyle );
1447 // -----------------------------------------------------------------------
1449 SplitWindow::SplitWindow( Window* pParent, const ResId& rResId ) :
1450 DockingWindow( WINDOW_SPLITWINDOW )
1452 rResId.SetRT( RSC_SPLITWINDOW );
1453 WinBits nStyle = ImplInitRes( rResId );
1454 ImplInit( pParent, nStyle );
1455 ImplLoadRes( rResId );
1457 if ( !(nStyle & WB_HIDE) )
1458 Show();
1461 // -----------------------------------------------------------------------
1463 SplitWindow::~SplitWindow()
1465 // Sets loeschen
1466 ImplDeleteSet( mpMainSet );
1469 // -----------------------------------------------------------------------
1471 void SplitWindow::ImplSetWindowSize( long nDelta )
1473 if ( !nDelta )
1474 return;
1476 Size aSize = GetSizePixel();
1477 if ( meAlign == WINDOWALIGN_TOP )
1479 aSize.Height() += nDelta;
1480 SetSizePixel( aSize );
1482 else if ( meAlign == WINDOWALIGN_BOTTOM )
1484 maDragRect.Top() += nDelta;
1485 Point aPos = GetPosPixel();
1486 aPos.Y() -= nDelta;
1487 aSize.Height() += nDelta;
1488 SetPosSizePixel( aPos, aSize );
1490 else if ( meAlign == WINDOWALIGN_LEFT )
1492 aSize.Width() += nDelta;
1493 SetSizePixel( aSize );
1495 else // meAlign == WINDOWALIGN_RIGHT
1497 maDragRect.Left() += nDelta;
1498 Point aPos = GetPosPixel();
1499 aPos.X() -= nDelta;
1500 aSize.Width() += nDelta;
1501 SetPosSizePixel( aPos, aSize );
1504 SplitResize();
1507 // -----------------------------------------------------------------------
1509 Size SplitWindow::CalcLayoutSizePixel( const Size& aNewSize )
1511 Size aSize( aNewSize );
1512 long nSplitSize = mpMainSet->mnSplitSize-2;
1514 if ( mbAutoHide || mbFadeOut )
1515 nSplitSize += SPLITWIN_SPLITSIZEEXLN;
1517 // Wenn Fenster sizeable ist, wird die groesse automatisch nach
1518 // dem MainSet festgelegt, wenn kein relatives Fenster enthalten
1519 // ist
1520 if ( mnWinStyle & WB_SIZEABLE )
1522 long nCurSize;
1523 long nCalcSize = 0;
1524 USHORT i;
1526 for ( i = 0; i < mpMainSet->mnItems; i++ )
1528 if ( mpMainSet->mpItems[i].mnBits & (SWIB_RELATIVESIZE | SWIB_PERCENTSIZE) )
1529 break;
1530 else
1531 nCalcSize += mpMainSet->mpItems[i].mnSize;
1534 if ( i == mpMainSet->mnItems )
1536 long nDelta = 0;
1537 Point aPos = GetPosPixel();
1539 if ( mbHorz )
1540 nCurSize = aNewSize.Height()-mnTopBorder-mnBottomBorder;
1541 else
1542 nCurSize = aNewSize.Width()-mnLeftBorder-mnRightBorder;
1543 nCurSize -= nSplitSize;
1544 nCurSize -= (mpMainSet->mnItems-1)*mpMainSet->mnSplitSize;
1546 nDelta = nCalcSize-nCurSize;
1547 if ( !nDelta )
1548 return aSize;
1550 if ( meAlign == WINDOWALIGN_TOP )
1552 aSize.Height() += nDelta;
1554 else if ( meAlign == WINDOWALIGN_BOTTOM )
1556 aPos.Y() -= nDelta;
1557 aSize.Height() += nDelta;
1559 else if ( meAlign == WINDOWALIGN_LEFT )
1561 aSize.Width() += nDelta;
1563 else // meAlign == WINDOWALIGN_RIGHT
1565 aPos.X() -= nDelta;
1566 aSize.Width() += nDelta;
1571 return aSize;
1574 // -----------------------------------------------------------------------
1576 void SplitWindow::ImplCalcLayout()
1578 if ( !mbCalc || !mbRecalc || !mpMainSet->mpItems )
1579 return;
1581 long nSplitSize = mpMainSet->mnSplitSize-2;
1582 if ( mbAutoHide || mbFadeOut )
1583 nSplitSize += SPLITWIN_SPLITSIZEEXLN;
1585 // Wenn Fenster sizeable ist, wird die groesse automatisch nach
1586 // dem MainSet festgelegt, wenn kein relatives Fenster enthalten
1587 // ist
1588 if ( mnWinStyle & WB_SIZEABLE )
1590 long nCurSize;
1591 long nCalcSize = 0;
1592 USHORT i;
1594 for ( i = 0; i < mpMainSet->mnItems; i++ )
1596 if ( mpMainSet->mpItems[i].mnBits & (SWIB_RELATIVESIZE | SWIB_PERCENTSIZE) )
1597 break;
1598 else
1599 nCalcSize += mpMainSet->mpItems[i].mnSize;
1602 if ( i == mpMainSet->mnItems )
1604 if ( mbHorz )
1605 nCurSize = mnDY-mnTopBorder-mnBottomBorder;
1606 else
1607 nCurSize = mnDX-mnLeftBorder-mnRightBorder;
1608 nCurSize -= nSplitSize;
1609 nCurSize -= (mpMainSet->mnItems-1)*mpMainSet->mnSplitSize;
1611 mbRecalc = FALSE;
1612 ImplSetWindowSize( nCalcSize-nCurSize );
1613 mbRecalc = TRUE;
1617 if ( (mnDX <= 0) || (mnDY <= 0) )
1618 return;
1620 // Groessen/Position vorberechnen
1621 long nL;
1622 long nT;
1623 long nW;
1624 long nH;
1626 if ( mbHorz )
1628 if ( mbBottomRight )
1629 nT = mnDY-mnBottomBorder;
1630 else
1631 nT = mnTopBorder;
1632 nL = mnLeftBorder;
1634 else
1636 if ( mbBottomRight )
1637 nL = mnDX-mnRightBorder;
1638 else
1639 nL = mnLeftBorder;
1640 nT = mnTopBorder;
1642 nW = mnDX-mnLeftBorder-mnRightBorder;
1643 nH = mnDY-mnTopBorder-mnBottomBorder;
1644 if ( mnWinStyle & WB_SIZEABLE )
1646 if ( mbHorz )
1647 nH -= nSplitSize;
1648 else
1649 nW -= nSplitSize;
1652 // Sets rekursiv berechnen
1653 ImplCalcSet( mpMainSet, nL, nT, nW, nH, mbHorz, !mbBottomRight );
1654 ImplCalcSet2( this, mpMainSet, FALSE, mbHorz, !mbBottomRight );
1655 mbCalc = FALSE;
1658 // -----------------------------------------------------------------------
1660 void SplitWindow::ImplUpdate()
1662 mbCalc = TRUE;
1664 if ( IsReallyShown() && IsUpdateMode() && mbRecalc )
1666 if ( mpMainSet->mpItems )
1667 ImplCalcLayout();
1668 else
1669 Invalidate();
1673 // -----------------------------------------------------------------------
1675 void SplitWindow::ImplUpdateSet( ImplSplitSet* pSet )
1677 if ( IsReallyShown() && IsUpdateMode() && mbRecalc )
1679 // Wenn wir noch berechnen muessen, dann alles invalidieren.
1680 if ( mbCalc )
1682 // Wenn nicht NOSPLITDRAW gesetzt ist, koennen wir uns das
1683 // invalidieren sparen, da bei ImplCalcSet2() die freien flaechen
1684 // sowieso invalidiert werden
1685 if ( !mpMainSet->mpItems || (mnWinStyle & WB_NOSPLITDRAW) )
1686 pSet = mpMainSet;
1687 else
1688 return;
1691 Rectangle aRect;
1692 if ( pSet == mpMainSet )
1694 aRect.Left() = mnLeftBorder;
1695 aRect.Top() = mnTopBorder;
1696 aRect.Right() = mnDX-mnRightBorder-1;
1697 aRect.Bottom() = mnDY-mnBottomBorder-1;
1699 else
1701 ImplSplitItem* pItem;
1702 USHORT nPos;
1704 pSet = ImplFindItem( mpMainSet, pSet->mnId, nPos );
1705 pItem = &(pSet->mpItems[nPos]);
1706 aRect.Left() = pItem->mnLeft;
1707 aRect.Top() = pItem->mnTop;
1708 aRect.Right() = aRect.Left()+pItem->mnWidth;
1709 aRect.Bottom() = aRect.Top()+pItem->mnHeight;
1711 Invalidate( aRect );
1715 // -----------------------------------------------------------------------
1717 void SplitWindow::ImplSplitMousePos( Point& rMousePos )
1719 if ( mnSplitTest & SPLIT_HORZ )
1721 rMousePos.X() -= mnMouseOff;
1722 if ( rMousePos.X() < maDragRect.Left() )
1723 rMousePos.X() = maDragRect.Left();
1724 else if ( rMousePos.X()+mpSplitSet->mnSplitSize+1 > maDragRect.Right() )
1725 rMousePos.X() = maDragRect.Right()-mpSplitSet->mnSplitSize+1;
1726 // Wegen FullDrag in Screen-Koordinaaten merken
1727 mnMSplitPos = OutputToScreenPixel( rMousePos ).X();
1729 else
1731 rMousePos.Y() -= mnMouseOff;
1732 if ( rMousePos.Y() < maDragRect.Top() )
1733 rMousePos.Y() = maDragRect.Top();
1734 else if ( rMousePos.Y()+mpSplitSet->mnSplitSize+1 > maDragRect.Bottom() )
1735 rMousePos.Y() = maDragRect.Bottom()-mpSplitSet->mnSplitSize+1;
1736 mnMSplitPos = OutputToScreenPixel( rMousePos ).Y();
1740 // -----------------------------------------------------------------------
1742 void SplitWindow::ImplGetButtonRect( Rectangle& rRect, long nEx, BOOL bTest ) const
1744 long nSplitSize = mpMainSet->mnSplitSize-2;
1745 if ( mbAutoHide || mbFadeOut || mbFadeIn )
1746 nSplitSize += SPLITWIN_SPLITSIZEEX;
1748 long nButtonSize = 0;
1749 if ( mbFadeIn )
1750 nButtonSize += SPLITWIN_SPLITSIZEFADE+1;
1751 if ( mbFadeOut )
1752 nButtonSize += SPLITWIN_SPLITSIZEFADE+1;
1753 if ( mbAutoHide )
1754 nButtonSize += SPLITWIN_SPLITSIZEAUTOHIDE+1;
1755 long nCenterEx = 0;
1756 if ( mbHorz )
1757 nCenterEx += ((mnDX-mnLeftBorder-mnRightBorder)-nButtonSize)/2;
1758 else
1759 nCenterEx += ((mnDY-mnTopBorder-mnBottomBorder)-nButtonSize)/2;
1760 if ( nCenterEx > 0 )
1761 nEx += nCenterEx;
1763 if ( meAlign == WINDOWALIGN_TOP )
1765 rRect.Left() = mnLeftBorder+nEx;
1766 rRect.Top() = mnDY-mnBottomBorder-nSplitSize;
1767 rRect.Right() = rRect.Left()+SPLITWIN_SPLITSIZEAUTOHIDE;
1768 rRect.Bottom() = mnDY-mnBottomBorder-1;
1769 if ( bTest )
1771 rRect.Top() -= mnTopBorder;
1772 rRect.Bottom() += mnBottomBorder;
1775 else if ( meAlign == WINDOWALIGN_BOTTOM )
1777 rRect.Left() = mnLeftBorder+nEx;
1778 rRect.Top() = mnTopBorder;
1779 rRect.Right() = rRect.Left()+SPLITWIN_SPLITSIZEAUTOHIDE;
1780 rRect.Bottom() = mnTopBorder+nSplitSize-1;
1781 if ( bTest )
1783 rRect.Top() -= mnTopBorder;
1784 rRect.Bottom() += mnBottomBorder;
1787 else if ( meAlign == WINDOWALIGN_LEFT )
1789 rRect.Left() = mnDX-mnRightBorder-nSplitSize;
1790 rRect.Top() = mnTopBorder+nEx;
1791 rRect.Right() = mnDX-mnRightBorder-1;
1792 rRect.Bottom() = rRect.Top()+SPLITWIN_SPLITSIZEAUTOHIDE;
1793 if ( bTest )
1795 rRect.Left() -= mnLeftBorder;
1796 rRect.Right() += mnRightBorder;
1799 else if ( meAlign == WINDOWALIGN_RIGHT )
1801 rRect.Left() = mnLeftBorder;
1802 rRect.Top() = mnTopBorder+nEx;
1803 rRect.Right() = mnLeftBorder+nSplitSize-1;
1804 rRect.Bottom() = rRect.Top()+SPLITWIN_SPLITSIZEAUTOHIDE;
1805 if ( bTest )
1807 rRect.Left() -= mnLeftBorder;
1808 rRect.Right() += mnRightBorder;
1813 // -----------------------------------------------------------------------
1815 void SplitWindow::ImplGetAutoHideRect( Rectangle& rRect, BOOL bTest ) const
1817 Rectangle aRect;
1819 if ( mbAutoHide )
1821 long nEx = 0;
1822 if ( mbFadeIn || mbFadeOut )
1823 nEx = SPLITWIN_SPLITSIZEFADE+1;
1824 ImplGetButtonRect( aRect, nEx, bTest && mbFadeIn );
1827 rRect = aRect;
1830 // -----------------------------------------------------------------------
1832 void SplitWindow::ImplGetFadeInRect( Rectangle& rRect, BOOL bTest ) const
1834 Rectangle aRect;
1836 if ( mbFadeIn )
1837 ImplGetButtonRect( aRect, 0, bTest );
1839 rRect = aRect;
1842 // -----------------------------------------------------------------------
1844 void SplitWindow::ImplGetFadeOutRect( Rectangle& rRect, BOOL ) const
1846 Rectangle aRect;
1848 if ( mbFadeOut )
1849 ImplGetButtonRect( aRect, 0, FALSE );
1851 rRect = aRect;
1854 // -----------------------------------------------------------------------
1856 void SplitWindow::ImplDrawButtonRect( const Rectangle& rRect, long nSize )
1858 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1860 if ( mbHorz )
1862 long nLeft = rRect.Left();
1863 long nRight = rRect.Right();
1864 long nCenter = rRect.Center().Y();
1865 long nEx1 = nLeft+((rRect.GetWidth()-nSize)/2)-2;
1866 long nEx2 = nEx1+nSize+3;
1867 SetLineColor( rStyleSettings.GetLightColor() );
1868 DrawLine( Point( rRect.Left(), rRect.Top() ), Point( rRect.Left(), rRect.Bottom() ) );
1869 DrawLine( Point( rRect.Left(), rRect.Top() ), Point( rRect.Right(), rRect.Top() ) );
1870 SetLineColor( rStyleSettings.GetShadowColor() );
1871 DrawLine( Point( rRect.Right(), rRect.Top() ), Point( rRect.Right(), rRect.Bottom() ) );
1872 DrawLine( Point( rRect.Left(), rRect.Bottom() ), Point( rRect.Right(), rRect.Bottom() ) );
1873 long i = nLeft+2;
1874 while ( i < nRight-3 )
1876 if ( (i < nEx1) || (i > nEx2 ) )
1878 DrawPixel( Point( i, nCenter-2 ), rStyleSettings.GetLightColor() );
1879 DrawPixel( Point( i+1, nCenter-2+1 ), rStyleSettings.GetShadowColor() );
1881 i++;
1882 if ( (i < nEx1) || ((i > nEx2 ) && (i < nRight-3)) )
1884 DrawPixel( Point( i, nCenter+2 ), rStyleSettings.GetLightColor() );
1885 DrawPixel( Point( i+1, nCenter+2+1 ), rStyleSettings.GetShadowColor() );
1887 i += 2;
1890 else
1892 long nTop = rRect.Top();
1893 long nBottom = rRect.Bottom();
1894 long nCenter = rRect.Center().X();
1895 long nEx1 = nTop+((rRect.GetHeight()-nSize)/2)-2;
1896 long nEx2 = nEx1+nSize+3;
1897 SetLineColor( rStyleSettings.GetLightColor() );
1898 DrawLine( Point( rRect.Left(), rRect.Top() ), Point( rRect.Right(), rRect.Top() ) );
1899 DrawLine( Point( rRect.Left(), rRect.Top() ), Point( rRect.Left(), rRect.Bottom() ) );
1900 SetLineColor( rStyleSettings.GetShadowColor() );
1901 DrawLine( Point( rRect.Right(), rRect.Top() ), Point( rRect.Right(), rRect.Bottom() ) );
1902 DrawLine( Point( rRect.Left(), rRect.Bottom() ), Point( rRect.Right(), rRect.Bottom() ) );
1903 long i = nTop+2;
1904 while ( i < nBottom-3 )
1906 if ( (i < nEx1) || (i > nEx2 ) )
1908 DrawPixel( Point( nCenter-2, i ), rStyleSettings.GetLightColor() );
1909 DrawPixel( Point( nCenter-2+1, i+1 ), rStyleSettings.GetShadowColor() );
1911 i++;
1912 if ( (i < nEx1) || ((i > nEx2 ) && (i < nBottom-3)) )
1914 DrawPixel( Point( nCenter+2, i ), rStyleSettings.GetLightColor() );
1915 DrawPixel( Point( nCenter+2+1, i+1 ), rStyleSettings.GetShadowColor() );
1917 i += 2;
1922 // -----------------------------------------------------------------------
1924 void SplitWindow::ImplDrawAutoHide( BOOL bInPaint )
1926 if ( mbAutoHide )
1928 Rectangle aTempRect;
1929 ImplGetAutoHideRect( aTempRect );
1931 if ( !bInPaint )
1932 Erase( aTempRect );
1934 // ImageListe laden, wenn noch nicht vorhanden
1935 ImplSVData* pSVData = ImplGetSVData();
1936 ImageList* pImageList;
1937 if ( mbHorz )
1939 if ( !pSVData->maCtrlData.mpSplitHPinImgList )
1941 ResMgr* pResMgr = ImplGetResMgr();
1942 if( pResMgr )
1944 Color aNonAlphaMask( 0x00, 0x00, 0xFF );
1945 pSVData->maCtrlData.mpSplitHPinImgList = new ImageList(4);
1946 pSVData->maCtrlData.mpSplitHPinImgList->InsertFromHorizontalBitmap
1947 ( ResId( SV_RESID_BITMAP_SPLITHPIN, *pResMgr ), 4, &aNonAlphaMask );
1950 pImageList = pSVData->maCtrlData.mpSplitHPinImgList;
1952 else
1954 if ( !pSVData->maCtrlData.mpSplitVPinImgList )
1956 ResMgr* pResMgr = ImplGetResMgr();
1957 pSVData->maCtrlData.mpSplitVPinImgList = new ImageList(4);
1958 if( pResMgr )
1960 Color aNonAlphaMask( 0x00, 0x00, 0xFF );
1961 pSVData->maCtrlData.mpSplitVPinImgList->InsertFromHorizontalBitmap
1962 ( ResId( SV_RESID_BITMAP_SPLITVPIN, *pResMgr ), 4, &aNonAlphaMask );
1965 pImageList = pSVData->maCtrlData.mpSplitVPinImgList;
1968 // Image ermitteln und zurueckgeben
1969 USHORT nId;
1970 if ( mbAutoHidePressed )
1972 if ( mbAutoHideIn )
1973 nId = 3;
1974 else
1975 nId = 4;
1977 else
1979 if ( mbAutoHideIn )
1980 nId = 1;
1981 else
1982 nId = 2;
1985 Image aImage = pImageList->GetImage( nId );
1986 Size aImageSize = aImage.GetSizePixel();
1987 Point aPos( aTempRect.Left()+((aTempRect.GetWidth()-aImageSize.Width())/2),
1988 aTempRect.Top()+((aTempRect.GetHeight()-aImageSize.Height())/2) );
1989 long nSize;
1990 if ( mbHorz )
1991 nSize = aImageSize.Width();
1992 else
1993 nSize = aImageSize.Height();
1994 ImplDrawButtonRect( aTempRect, nSize );
1995 DrawImage( aPos, aImage );
1999 // -----------------------------------------------------------------------
2001 void SplitWindow::ImplDrawFadeArrow( const Point& rPt, BOOL bHorz, BOOL bLeft )
2003 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
2005 int x( rPt.X() );
2006 int y( rPt.Y() );
2008 Color aCol;
2009 if( !bHorz )
2011 int dx = 1;
2012 if( bLeft )
2014 x ++;
2015 dx = -1;
2018 x++; y++;
2019 aCol = Color( COL_WHITE );
2020 DrawPixel( Point(x, y), aCol );
2021 DrawPixel( Point(x, y+1), aCol );
2022 DrawPixel( Point(x, y+2), aCol );
2023 DrawPixel( Point(x+dx, y+1), aCol );
2025 x--; y--;
2026 aCol = rStyleSettings.GetDarkShadowColor();
2027 DrawPixel( Point(x, y), rStyleSettings.GetDarkShadowColor() );
2028 DrawPixel( Point(x, y+1), rStyleSettings.GetDarkShadowColor() );
2029 DrawPixel( Point(x, y+2), rStyleSettings.GetDarkShadowColor() );
2030 DrawPixel( Point(x+dx, y+1), rStyleSettings.GetDarkShadowColor() );
2032 else
2034 int dy = 1;
2035 if( bLeft )
2037 y ++;
2038 dy = -1;
2041 x++; y++;
2042 aCol = Color( COL_WHITE );
2043 DrawPixel( Point(x, y), aCol );
2044 DrawPixel( Point(x+1, y), aCol );
2045 DrawPixel( Point(x+2, y), aCol );
2046 DrawPixel( Point(x+1, y+dy), aCol );
2048 x--; y--;
2049 aCol = rStyleSettings.GetDarkShadowColor();
2050 DrawPixel( Point(x, y), aCol );
2051 DrawPixel( Point(x+1, y), aCol );
2052 DrawPixel( Point(x+2, y), aCol );
2053 DrawPixel( Point(x+1, y+dy), aCol );
2057 void SplitWindow::ImplDrawGrip( const Rectangle& rRect, BOOL bHorz, BOOL bLeft )
2059 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
2061 if( rRect.IsInside( GetPointerPosPixel() ) )
2063 DrawWallpaper( rRect, Wallpaper( Color( COL_WHITE ) ) );
2064 DrawSelectionBackground( rRect, 2, FALSE, FALSE, FALSE );
2067 if( bHorz )
2069 int width = (int) (0.5 * rRect.getWidth() + 0.5);
2070 int i = rRect.nLeft + (rRect.getWidth() - width) / 2;
2071 width += i;
2072 const int y = rRect.nTop + 1;
2073 ImplDrawFadeArrow( Point( i-8, y), bHorz, bLeft );
2074 while( i <= width )
2077 DrawPixel( Point(i, y), rStyleSettings.GetDarkShadowColor() );
2078 DrawPixel( Point(i+1, y), rStyleSettings.GetShadowColor() );
2080 DrawPixel( Point(i, y+1), rStyleSettings.GetShadowColor() );
2081 DrawPixel( Point(i+1, y+1), rStyleSettings.GetFaceColor() );
2082 DrawPixel( Point(i+2, y+1), Color(COL_WHITE) );
2084 DrawPixel( Point(i+1, y+2), Color(COL_WHITE) );
2085 DrawPixel( Point(i+2, y+2), Color(COL_WHITE) );
2086 i+=4;
2088 ImplDrawFadeArrow( Point( i+3, y), bHorz, bLeft );
2090 else
2092 int height = (int) (0.5 * rRect.getHeight() + 0.5);
2093 int i = rRect.nTop + (rRect.getHeight() - height) / 2;
2094 height += i;
2095 const int x = rRect.nLeft + 1;
2096 ImplDrawFadeArrow( Point( x, i-8), bHorz, bLeft );
2097 while( i <= height )
2100 DrawPixel( Point(x, i), rStyleSettings.GetDarkShadowColor() );
2101 DrawPixel( Point(x+1, i), rStyleSettings.GetShadowColor() );
2103 DrawPixel( Point(x, i+1), rStyleSettings.GetShadowColor() );
2104 DrawPixel( Point(x+1, i+1), rStyleSettings.GetFaceColor() );
2105 DrawPixel( Point(x+2, i+1), Color(COL_WHITE) );
2107 DrawPixel( Point(x+1, i+2), Color(COL_WHITE) );
2108 DrawPixel( Point(x+2, i+2), Color(COL_WHITE) );
2109 i+=4;
2111 ImplDrawFadeArrow( Point( x, i+3), bHorz, bLeft );
2115 void SplitWindow::ImplDrawFadeIn( BOOL bInPaint )
2117 if ( mbFadeIn )
2119 Rectangle aTempRect;
2120 Image aImage;
2121 ImplGetFadeInRect( aTempRect );
2123 BOOL bLeft;
2124 if ( meAlign == WINDOWALIGN_TOP )
2125 bLeft = FALSE;
2126 else if ( meAlign == WINDOWALIGN_BOTTOM )
2127 bLeft = TRUE;
2128 else if ( meAlign == WINDOWALIGN_LEFT )
2129 bLeft = FALSE;
2130 else if ( meAlign == WINDOWALIGN_RIGHT )
2131 bLeft = TRUE;
2132 else
2133 bLeft = TRUE;
2135 if ( !bInPaint )
2136 Erase( aTempRect );
2138 ImplDrawGrip( aTempRect, (meAlign == WINDOWALIGN_TOP) || (meAlign == WINDOWALIGN_BOTTOM), bLeft );
2142 // -----------------------------------------------------------------------
2144 void SplitWindow::ImplDrawFadeOut( BOOL bInPaint )
2146 if ( mbFadeOut )
2148 Rectangle aTempRect;
2149 Image aImage;
2150 ImplGetFadeOutRect( aTempRect );
2152 BOOL bLeft;
2153 if ( meAlign == WINDOWALIGN_TOP )
2154 bLeft = TRUE;
2155 else if ( meAlign == WINDOWALIGN_BOTTOM )
2156 bLeft = FALSE;
2157 else if ( meAlign == WINDOWALIGN_LEFT )
2158 bLeft = TRUE;
2159 else if ( meAlign == WINDOWALIGN_RIGHT )
2160 bLeft = FALSE;
2161 else
2162 bLeft = TRUE;
2164 if ( !bInPaint )
2165 Erase( aTempRect );
2167 ImplDrawGrip( aTempRect, (meAlign == WINDOWALIGN_TOP) || (meAlign == WINDOWALIGN_BOTTOM), bLeft );
2171 // -----------------------------------------------------------------------
2172 void SplitWindow::ImplStartSplit( const MouseEvent& rMEvt )
2174 Point aMousePosPixel = rMEvt.GetPosPixel();
2175 mnSplitTest = ImplTestSplit( this, aMousePosPixel, mnMouseOff, &mpSplitSet, mnSplitPos );
2177 if ( mnSplitTest && !(mnSplitTest & SPLIT_NOSPLIT) )
2179 ImplSplitItem* pSplitItem;
2180 long nCurMaxSize;
2181 USHORT nTemp;
2182 BOOL bDown;
2183 BOOL bPropSmaller;
2185 mnMouseModifier = rMEvt.GetModifier();
2186 if ( !(mnMouseModifier & KEY_SHIFT) || (mnSplitPos+1 >= mpSplitSet->mnItems) )
2187 bPropSmaller = FALSE;
2188 else
2189 bPropSmaller = TRUE;
2191 // Hier kann noch die maximale Groesse gesetzt werden
2192 StartSplit();
2194 if ( mnMaxSize )
2195 nCurMaxSize = mnMaxSize;
2196 else
2198 Size aSize = GetParent()->GetOutputSizePixel();
2199 if ( mbHorz )
2200 nCurMaxSize = aSize.Height();
2201 else
2202 nCurMaxSize = aSize.Width();
2205 if ( mpSplitSet->mpItems )
2207 bDown = TRUE;
2208 if ( (mpSplitSet == mpMainSet) && mbBottomRight )
2209 bDown = FALSE;
2211 pSplitItem = &(mpSplitSet->mpItems[mnSplitPos]);
2212 maDragRect.Left() = pSplitItem->mnLeft;
2213 maDragRect.Top() = pSplitItem->mnTop;
2214 maDragRect.Right() = pSplitItem->mnLeft+pSplitItem->mnWidth-1;
2215 maDragRect.Bottom() = pSplitItem->mnTop+pSplitItem->mnHeight-1;
2217 if ( mnSplitTest & SPLIT_HORZ )
2219 if ( bDown )
2220 maDragRect.Right() += mpSplitSet->mnSplitSize;
2221 else
2222 maDragRect.Left() -= mpSplitSet->mnSplitSize;
2224 else
2226 if ( bDown )
2227 maDragRect.Bottom() += mpSplitSet->mnSplitSize;
2228 else
2229 maDragRect.Top() -= mpSplitSet->mnSplitSize;
2232 if ( mnSplitPos )
2234 nTemp = mnSplitPos;
2235 while ( nTemp )
2237 pSplitItem = &(mpSplitSet->mpItems[nTemp-1]);
2238 if ( pSplitItem->mbFixed )
2239 break;
2240 else
2242 if ( mnSplitTest & SPLIT_HORZ )
2244 if ( bDown )
2245 maDragRect.Left() -= pSplitItem->mnPixSize;
2246 else
2247 maDragRect.Right() += pSplitItem->mnPixSize;
2249 else
2251 if ( bDown )
2252 maDragRect.Top() -= pSplitItem->mnPixSize;
2253 else
2254 maDragRect.Bottom() += pSplitItem->mnPixSize;
2257 nTemp--;
2261 if ( (mpSplitSet == mpMainSet) && (mnWinStyle & WB_SIZEABLE) && !bPropSmaller )
2263 if ( bDown )
2265 if ( mbHorz )
2266 maDragRect.Bottom() += nCurMaxSize-mnDY-mnTopBorder;
2267 else
2268 maDragRect.Right() += nCurMaxSize-mnDX-mnLeftBorder;
2270 else
2272 if ( mbHorz )
2273 maDragRect.Top() -= nCurMaxSize-mnDY-mnBottomBorder;
2274 else
2275 maDragRect.Left() -= nCurMaxSize-mnDX-mnRightBorder;
2278 else
2280 nTemp = mnSplitPos+1;
2281 while ( nTemp < mpSplitSet->mnItems )
2283 pSplitItem = &(mpSplitSet->mpItems[nTemp]);
2284 if ( pSplitItem->mbFixed )
2285 break;
2286 else
2288 if ( mnSplitTest & SPLIT_HORZ )
2290 if ( bDown )
2291 maDragRect.Right() += pSplitItem->mnPixSize;
2292 else
2293 maDragRect.Left() -= pSplitItem->mnPixSize;
2295 else
2297 if ( bDown )
2298 maDragRect.Bottom() += pSplitItem->mnPixSize;
2299 else
2300 maDragRect.Top() -= pSplitItem->mnPixSize;
2303 nTemp++;
2307 else
2309 maDragRect.Left() = mnLeftBorder;
2310 maDragRect.Top() = mnTopBorder;
2311 maDragRect.Right() = mnDX-mnRightBorder-1;
2312 maDragRect.Bottom() = mnDY-mnBottomBorder-1;
2313 if ( mbHorz )
2315 if ( mbBottomRight )
2316 maDragRect.Top() -= nCurMaxSize-mnDY-mnBottomBorder;
2317 else
2318 maDragRect.Bottom() += nCurMaxSize-mnDY-mnTopBorder;
2320 else
2322 if ( mbBottomRight )
2323 maDragRect.Left() -= nCurMaxSize-mnDX-mnRightBorder;
2324 else
2325 maDragRect.Right() += nCurMaxSize-mnDX-mnLeftBorder;
2329 StartTracking();
2331 mbDragFull = (GetSettings().GetStyleSettings().GetDragFullOptions() & DRAGFULL_OPTION_SPLIT) != 0;
2333 ImplSplitMousePos( aMousePosPixel );
2335 if ( !mbDragFull )
2336 ImplDrawSplitTracking( this, aMousePosPixel );
2337 else
2339 ImplSplitItem* pItems = mpSplitSet->mpItems;
2340 USHORT nItems = mpSplitSet->mnItems;
2341 mpLastSizes = new long[nItems*2];
2342 for ( USHORT i = 0; i < nItems; i++ )
2344 mpLastSizes[i*2] = pItems[i].mnSize;
2345 mpLastSizes[i*2+1] = pItems[i].mnPixSize;
2348 mnMStartPos = mnMSplitPos;
2350 PointerStyle eStyle = POINTER_ARROW;
2351 if ( mnSplitTest & SPLIT_HORZ )
2352 eStyle = POINTER_HSPLIT;
2353 else if ( mnSplitTest & SPLIT_VERT )
2354 eStyle = POINTER_VSPLIT;
2356 Pointer aPtr( eStyle );
2357 SetPointer( aPtr );
2362 // -----------------------------------------------------------------------
2364 void SplitWindow::StartSplit()
2366 maStartSplitHdl.Call( this );
2369 // -----------------------------------------------------------------------
2371 void SplitWindow::Split()
2373 maSplitHdl.Call( this );
2376 // -----------------------------------------------------------------------
2378 void SplitWindow::SplitResize()
2380 maSplitResizeHdl.Call( this );
2383 // -----------------------------------------------------------------------
2385 void SplitWindow::AutoHide()
2387 maAutoHideHdl.Call( this );
2390 // -----------------------------------------------------------------------
2392 void SplitWindow::FadeIn()
2394 maFadeInHdl.Call( this );
2397 // -----------------------------------------------------------------------
2399 void SplitWindow::FadeOut()
2401 maFadeOutHdl.Call( this );
2404 // -----------------------------------------------------------------------
2406 void SplitWindow::MouseButtonDown( const MouseEvent& rMEvt )
2408 if ( !rMEvt.IsLeft() || rMEvt.IsMod2() )
2410 DockingWindow::MouseButtonDown( rMEvt );
2411 return;
2414 Point aMousePosPixel = rMEvt.GetPosPixel();
2415 Rectangle aTestRect;
2417 mbFadeNoButtonMode = FALSE;
2418 ImplGetAutoHideRect( aTestRect, TRUE );
2419 if ( aTestRect.IsInside( aMousePosPixel ) )
2421 mbAutoHideDown = TRUE;
2422 mbAutoHidePressed = TRUE;
2423 ImplDrawAutoHide( FALSE );
2425 else
2427 ImplGetFadeOutRect( aTestRect, TRUE );
2428 if ( aTestRect.IsInside( aMousePosPixel ) )
2430 mbFadeOutDown = TRUE;
2431 mbFadeOutPressed = TRUE;
2432 ImplDrawFadeOut( FALSE );
2434 else
2436 ImplGetFadeInRect( aTestRect, TRUE );
2437 if ( aTestRect.IsInside( aMousePosPixel ) )
2439 mbFadeInDown = TRUE;
2440 mbFadeInPressed = TRUE;
2441 ImplDrawFadeIn( FALSE );
2443 else if ( !aTestRect.IsEmpty() && !(mnWinStyle & WB_SIZEABLE) )
2445 mbFadeNoButtonMode = TRUE;
2446 FadeIn();
2447 return;
2452 if ( mbAutoHideDown || mbFadeInDown || mbFadeOutDown )
2453 StartTracking();
2454 else
2455 ImplStartSplit( rMEvt );
2458 // -----------------------------------------------------------------------
2460 void SplitWindow::MouseMove( const MouseEvent& rMEvt )
2462 if ( !IsTracking() )
2464 Point aPos = rMEvt.GetPosPixel();
2465 long nTemp;
2466 ImplSplitSet* pTempSplitSet;
2467 USHORT nTempSplitPos;
2468 USHORT nSplitTest = ImplTestSplit( this, aPos, nTemp, &pTempSplitSet, nTempSplitPos );
2469 PointerStyle eStyle = POINTER_ARROW;
2470 Rectangle aAutoHideRect;
2471 Rectangle aFadeInRect;
2472 Rectangle aFadeOutRect;
2474 ImplGetAutoHideRect( aAutoHideRect );
2475 ImplGetFadeInRect( aFadeInRect );
2476 ImplGetFadeOutRect( aFadeOutRect );
2477 if ( !aAutoHideRect.IsInside( aPos ) &&
2478 !aFadeInRect.IsInside( aPos ) &&
2479 !aFadeOutRect.IsInside( aPos ) )
2481 if ( nSplitTest && !(nSplitTest & SPLIT_NOSPLIT) )
2483 if ( nSplitTest & SPLIT_HORZ )
2484 eStyle = POINTER_HSPLIT;
2485 else if ( nSplitTest & SPLIT_VERT )
2486 eStyle = POINTER_VSPLIT;
2490 Pointer aPtr( eStyle );
2491 SetPointer( aPtr );
2495 // -----------------------------------------------------------------------
2497 void SplitWindow::Tracking( const TrackingEvent& rTEvt )
2499 Point aMousePosPixel = rTEvt.GetMouseEvent().GetPosPixel();
2501 if ( mbAutoHideDown )
2503 if ( rTEvt.IsTrackingEnded() )
2505 mbAutoHideDown = FALSE;
2506 if ( mbAutoHidePressed )
2508 mbAutoHidePressed = FALSE;
2510 if ( !rTEvt.IsTrackingCanceled() )
2512 mbAutoHideIn = !mbAutoHideIn;
2513 ImplDrawAutoHide( FALSE );
2514 AutoHide();
2516 else
2517 ImplDrawAutoHide( FALSE );
2520 else
2522 Rectangle aTestRect;
2523 ImplGetAutoHideRect( aTestRect, TRUE );
2524 BOOL bNewPressed = aTestRect.IsInside( aMousePosPixel );
2525 if ( bNewPressed != mbAutoHidePressed )
2527 mbAutoHidePressed = bNewPressed;
2528 ImplDrawAutoHide( FALSE );
2532 else if ( mbFadeInDown )
2534 if ( rTEvt.IsTrackingEnded() )
2536 mbFadeInDown = FALSE;
2537 if ( mbFadeInPressed )
2539 mbFadeInPressed = FALSE;
2540 ImplDrawFadeIn( FALSE );
2542 if ( !rTEvt.IsTrackingCanceled() )
2543 FadeIn();
2546 else
2548 Rectangle aTestRect;
2549 ImplGetFadeInRect( aTestRect, TRUE );
2550 BOOL bNewPressed = aTestRect.IsInside( aMousePosPixel );
2551 if ( bNewPressed != mbFadeInPressed )
2553 mbFadeInPressed = bNewPressed;
2554 ImplDrawFadeIn( FALSE );
2558 else if ( mbFadeOutDown )
2560 if ( rTEvt.IsTrackingEnded() )
2562 mbFadeOutDown = FALSE;
2563 if ( mbFadeOutPressed )
2565 mbFadeOutPressed = FALSE;
2566 ImplDrawFadeOut( FALSE );
2568 if ( !rTEvt.IsTrackingCanceled() )
2569 FadeOut();
2572 else
2574 Rectangle aTestRect;
2575 ImplGetFadeOutRect( aTestRect, TRUE );
2576 BOOL bNewPressed = aTestRect.IsInside( aMousePosPixel );
2577 if ( bNewPressed == FALSE )
2579 mbFadeOutPressed = bNewPressed;
2580 ImplDrawFadeOut( FALSE );
2582 // We need a mouseevent with a position inside the button for the
2583 // ImplStartSplit function!
2584 MouseEvent aOrgMEvt = rTEvt.GetMouseEvent();
2585 MouseEvent aNewMEvt = MouseEvent( aTestRect.Center(), aOrgMEvt.GetClicks(),
2586 aOrgMEvt.GetMode(), aOrgMEvt.GetButtons(),
2587 aOrgMEvt.GetModifier() );
2589 ImplStartSplit( aNewMEvt );
2590 mbFadeOutDown = FALSE;
2594 else
2596 ImplSplitMousePos( aMousePosPixel );
2597 BOOL bSplit = TRUE;
2598 if ( mbDragFull )
2600 if ( rTEvt.IsTrackingEnded() )
2602 if ( rTEvt.IsTrackingCanceled() )
2604 ImplSplitItem* pItems = mpSplitSet->mpItems;
2605 USHORT nItems = mpSplitSet->mnItems;
2606 for ( USHORT i = 0; i < nItems; i++ )
2608 pItems[i].mnSize = mpLastSizes[i*2];
2609 pItems[i].mnPixSize = mpLastSizes[i*2+1];
2611 ImplUpdate();
2612 Split();
2614 bSplit = FALSE;
2617 else
2619 if ( rTEvt.IsTrackingEnded() )
2621 HideTracking();
2622 bSplit = !rTEvt.IsTrackingCanceled();
2624 else
2626 ImplDrawSplitTracking( this, aMousePosPixel );
2627 bSplit = FALSE;
2631 if ( bSplit )
2633 BOOL bPropSmaller = (mnMouseModifier & KEY_SHIFT) ? TRUE : FALSE;
2634 BOOL bPropGreater = (mnMouseModifier & KEY_MOD1) ? TRUE : FALSE;
2635 long nDelta = mnMSplitPos-mnMStartPos;
2637 if ( (mnSplitTest & SPLIT_WINDOW) && !mpMainSet->mpItems )
2639 if ( (mpSplitSet == mpMainSet) && mbBottomRight )
2640 nDelta *= -1;
2641 ImplSetWindowSize( nDelta );
2643 else
2645 long nNewSize = mpSplitSet->mpItems[mnSplitPos].mnPixSize;
2646 if ( (mpSplitSet == mpMainSet) && mbBottomRight )
2647 nNewSize -= nDelta;
2648 else
2649 nNewSize += nDelta;
2650 SplitItem( mpSplitSet->mpItems[mnSplitPos].mnId, nNewSize,
2651 bPropSmaller, bPropGreater );
2654 Split();
2656 if ( mbDragFull )
2658 Update();
2659 mnMStartPos = mnMSplitPos;
2663 if ( rTEvt.IsTrackingEnded() )
2665 if ( mpLastSizes )
2666 delete mpLastSizes;
2667 mpLastSizes = NULL;
2668 mpSplitSet = NULL;
2669 mnMouseOff = 0;
2670 mnMStartPos = 0;
2671 mnMSplitPos = 0;
2672 mnMouseModifier = 0;
2673 mnSplitTest = 0;
2674 mnSplitPos = 0;
2679 // -----------------------------------------------------------------------
2681 long SplitWindow::PreNotify( NotifyEvent& rNEvt )
2683 const MouseEvent* pMouseEvt = NULL;
2685 if( (rNEvt.GetType() == EVENT_MOUSEMOVE) && (pMouseEvt = rNEvt.GetMouseEvent()) != NULL )
2687 if( !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
2689 // trigger redraw if mouse over state has changed
2690 Rectangle aFadeInRect;
2691 Rectangle aFadeOutRect;
2692 ImplGetFadeInRect( aFadeInRect );
2693 ImplGetFadeOutRect( aFadeOutRect );
2695 if ( aFadeInRect.IsInside( GetPointerPosPixel() ) != aFadeInRect.IsInside( GetLastPointerPosPixel() ) )
2696 Invalidate( aFadeInRect );
2697 if ( aFadeOutRect.IsInside( GetPointerPosPixel() ) != aFadeOutRect.IsInside( GetLastPointerPosPixel() ) )
2698 Invalidate( aFadeOutRect );
2700 if( pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow() )
2702 Invalidate( aFadeInRect );
2703 Invalidate( aFadeOutRect );
2707 return Window::PreNotify( rNEvt );
2710 // -----------------------------------------------------------------------
2712 void SplitWindow::Paint( const Rectangle& )
2714 if ( mnWinStyle & WB_BORDER )
2715 ImplDrawBorder( this );
2717 ImplDrawBorderLine( this );
2718 ImplDrawFadeOut( TRUE );
2719 ImplDrawFadeIn( TRUE );
2720 ImplDrawAutoHide( TRUE );
2722 // FrameSet-Hintergruende zeichnen
2723 ImplDrawBack( this, mpMainSet );
2725 // Splitter zeichnen
2726 if ( !(mnWinStyle & WB_NOSPLITDRAW) )
2727 ImplDrawSplit( this, mpMainSet, mbHorz, !mbBottomRight );
2730 // -----------------------------------------------------------------------
2732 void SplitWindow::Move()
2734 DockingWindow::Move();
2737 // -----------------------------------------------------------------------
2739 void SplitWindow::Resize()
2741 Size aSize = GetOutputSizePixel();
2742 mnDX = aSize.Width();
2743 mnDY = aSize.Height();
2745 ImplUpdate();
2746 Invalidate();
2749 // -----------------------------------------------------------------------
2751 void SplitWindow::RequestHelp( const HelpEvent& rHEvt )
2753 // no keyboard help for splitwin
2754 if ( rHEvt.GetMode() & (HELPMODE_BALLOON | HELPMODE_QUICK) && !rHEvt.KeyboardActivated() )
2756 Point aMousePosPixel = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
2757 Rectangle aHelpRect;
2758 USHORT nHelpResId = 0;
2760 ImplGetAutoHideRect( aHelpRect, TRUE );
2761 if ( aHelpRect.IsInside( aMousePosPixel ) )
2763 if ( mbAutoHideIn )
2764 nHelpResId = SV_HELPTEXT_SPLITFIXED;
2765 else
2766 nHelpResId = SV_HELPTEXT_SPLITFLOATING;
2768 else
2770 ImplGetFadeInRect( aHelpRect, TRUE );
2771 if ( aHelpRect.IsInside( aMousePosPixel ) )
2772 nHelpResId = SV_HELPTEXT_FADEIN;
2773 else
2775 ImplGetFadeOutRect( aHelpRect, TRUE );
2776 if ( aHelpRect.IsInside( aMousePosPixel ) )
2777 nHelpResId = SV_HELPTEXT_FADEOUT;
2781 // Rechteck ermitteln
2782 if ( nHelpResId )
2784 Point aPt = OutputToScreenPixel( aHelpRect.TopLeft() );
2785 aHelpRect.Left() = aPt.X();
2786 aHelpRect.Top() = aPt.Y();
2787 aPt = OutputToScreenPixel( aHelpRect.BottomRight() );
2788 aHelpRect.Right() = aPt.X();
2789 aHelpRect.Bottom() = aPt.Y();
2791 // Text ermitteln und anzeigen
2792 XubString aStr;
2793 ResMgr* pResMgr = ImplGetResMgr();
2794 if( pResMgr )
2795 aStr = XubString( ResId( nHelpResId, *pResMgr ) );
2796 if ( rHEvt.GetMode() & HELPMODE_BALLOON )
2797 Help::ShowBalloon( this, aHelpRect.Center(), aHelpRect, aStr );
2798 else
2799 Help::ShowQuickHelp( this, aHelpRect, aStr );
2800 return;
2804 DockingWindow::RequestHelp( rHEvt );
2807 // -----------------------------------------------------------------------
2809 void SplitWindow::StateChanged( StateChangedType nType )
2811 if ( nType == STATE_CHANGE_INITSHOW )
2813 if ( IsUpdateMode() )
2814 ImplCalcLayout();
2816 else if ( nType == STATE_CHANGE_UPDATEMODE )
2818 if ( IsUpdateMode() && IsReallyShown() )
2819 ImplCalcLayout();
2821 else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
2823 ImplInitSettings();
2824 Invalidate();
2827 DockingWindow::StateChanged( nType );
2830 // -----------------------------------------------------------------------
2832 void SplitWindow::DataChanged( const DataChangedEvent& rDCEvt )
2834 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
2835 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
2837 ImplInitSettings();
2838 Invalidate();
2840 else
2841 DockingWindow::DataChanged( rDCEvt );
2844 // -----------------------------------------------------------------------
2846 void SplitWindow::InsertItem( USHORT nId, Window* pWindow, long nSize,
2847 USHORT nPos, USHORT nSetId,
2848 SplitWindowItemBits nBits )
2850 #ifdef DBG_UTIL
2851 USHORT nDbgDummy;
2852 DBG_ASSERT( ImplFindSet( mpMainSet, nSetId ), "SplitWindow::InsertItem() - Set not exists" );
2853 DBG_ASSERT( !ImplFindItem( mpMainSet, nId, nDbgDummy ), "SplitWindow::InsertItem() - Id already exists" );
2854 #endif
2856 // Size muss min. 1 sein
2857 if ( nSize < 1 )
2858 nSize = 1;
2860 ImplSplitSet* pSet = ImplFindSet( mpMainSet, nSetId );
2861 ImplSplitSet* pNewSet;
2862 ImplSplitItem* pItem;
2864 // Platz fuer neues Item schaffen
2865 if ( nPos > pSet->mnItems )
2866 nPos = pSet->mnItems;
2867 ImplSplitItem* pNewItems = new ImplSplitItem[pSet->mnItems+1];
2868 if ( nPos )
2869 memcpy( pNewItems, pSet->mpItems, sizeof( ImplSplitItem )*nPos );
2870 if ( nPos < pSet->mnItems )
2871 memcpy( pNewItems+nPos+1, pSet->mpItems+nPos, sizeof( ImplSplitItem )*(pSet->mnItems-nPos) );
2872 delete[] pSet->mpItems;
2873 pSet->mpItems = pNewItems;
2874 pSet->mnItems++;
2875 pSet->mbCalcPix = TRUE;
2877 // Item anlegen und erweitern
2878 pItem = &(pSet->mpItems[nPos]);
2879 memset( pItem, 0, sizeof( ImplSplitItem ) );
2880 pItem->mnSize = nSize;
2881 pItem->mnId = nId;
2882 pItem->mnBits = nBits;
2884 if ( pWindow )
2886 pItem->mpWindow = pWindow;
2887 pItem->mpOrgParent = pWindow->GetParent();
2889 // Window mit SplitWindow verbinden
2890 pWindow->Hide();
2891 pWindow->SetParent( this );
2893 else
2895 pNewSet = new ImplSplitSet;
2896 pNewSet->mpItems = NULL;
2897 pNewSet->mpWallpaper = NULL;
2898 pNewSet->mpBitmap = NULL;
2899 pNewSet->mnLastSize = 0;
2900 pNewSet->mnItems = 0;
2901 pNewSet->mnId = nId;
2902 pNewSet->mnSplitSize = pSet->mnSplitSize;
2903 pNewSet->mbCalcPix = TRUE;
2905 pItem->mpSet = pNewSet;
2908 ImplUpdate();
2911 // -----------------------------------------------------------------------
2913 void SplitWindow::InsertItem( USHORT nId, long nSize,
2914 USHORT nPos, USHORT nSetId,
2915 SplitWindowItemBits nBits )
2917 InsertItem( nId, NULL, nSize, nPos, nSetId, nBits );
2920 // -----------------------------------------------------------------------
2922 void SplitWindow::MoveItem( USHORT nId, USHORT nNewPos, USHORT nNewSetId )
2924 #ifdef DBG_UTIL
2925 USHORT nDbgDummy;
2926 DBG_ASSERT( ImplFindItem( mpMainSet, nId, nDbgDummy ), "SplitWindow::MoveItem() - Id not found" );
2927 DBG_ASSERT( ImplFindSet( mpMainSet, nNewSetId ), "SplitWindow::MoveItem() - Set not exists" );
2928 #endif
2930 USHORT nPos;
2931 ImplSplitSet* pNewSet = ImplFindSet( mpMainSet, nNewSetId );
2932 ImplSplitSet* pSet = ImplFindItem( mpMainSet, nId, nPos );
2933 ImplSplitItem aTempItem;
2935 if ( pNewSet == pSet )
2937 if ( nNewPos >= pNewSet->mnItems )
2938 nNewPos = pNewSet->mnItems-1;
2939 if ( nPos != nNewPos )
2941 memcpy( &aTempItem, &(pSet->mpItems[nPos]), sizeof( aTempItem ) );
2942 if ( nPos < nNewPos )
2944 memmove( pSet->mpItems+nPos, pSet->mpItems+nPos+1,
2945 (nNewPos-nPos)*sizeof( ImplSplitItem ) );
2947 else
2949 memmove( pSet->mpItems+nNewPos+1, pSet->mpItems+nNewPos,
2950 (nPos-nNewPos)*sizeof( ImplSplitItem ) );
2952 memcpy( &(pSet->mpItems[nNewPos]), &aTempItem, sizeof( aTempItem ) );
2954 ImplUpdate();
2957 else
2959 if ( nNewPos >= pNewSet->mnItems )
2960 nNewPos = pNewSet->mnItems;
2961 memcpy( &aTempItem, &(pSet->mpItems[nPos]), sizeof( aTempItem ) );
2962 pSet->mnItems--;
2963 pSet->mbCalcPix = TRUE;
2964 if ( pSet->mnItems )
2966 memmove( pSet->mpItems+nPos, pSet->mpItems+nPos+1,
2967 (pSet->mnItems-nPos)*sizeof( ImplSplitItem ) );
2969 else
2971 delete[] pSet->mpItems;
2972 pSet->mpItems = NULL;
2974 ImplSplitItem* pNewItems = new ImplSplitItem[pNewSet->mnItems+1];
2975 if ( nNewPos )
2976 memcpy( pNewItems, pNewSet->mpItems, sizeof( ImplSplitItem )*nNewPos );
2977 if ( nNewPos < pNewSet->mnItems )
2979 memcpy( pNewItems+nNewPos+1, pNewSet->mpItems+nNewPos,
2980 sizeof( ImplSplitItem )*(pNewSet->mnItems-nNewPos) );
2982 delete[] pNewSet->mpItems;
2983 pNewSet->mpItems = pNewItems;
2984 pNewSet->mnItems++;
2985 pNewSet->mbCalcPix = TRUE;
2986 memcpy( &(pNewSet->mpItems[nNewPos]), &aTempItem, sizeof( aTempItem ) );
2987 ImplUpdate();
2991 // -----------------------------------------------------------------------
2993 void SplitWindow::RemoveItem( USHORT nId, BOOL bHide )
2995 #ifdef DBG_UTIL
2996 USHORT nDbgDummy;
2997 DBG_ASSERT( ImplFindItem( mpMainSet, nId, nDbgDummy ), "SplitWindow::RemoveItem() - Id not found" );
2998 #endif
3000 // Set suchen
3001 USHORT nPos;
3002 ImplSplitSet* pSet = ImplFindItem( mpMainSet, nId, nPos );
3003 ImplSplitItem* pItem = &(pSet->mpItems[nPos]);
3004 Window* pWindow = pItem->mpWindow;
3005 Window* pOrgParent = pItem->mpOrgParent;
3007 // Evt. Set loeschen
3008 if ( !pWindow )
3009 ImplDeleteSet( pItem->mpSet );
3011 // Item entfernen
3012 pSet->mnItems--;
3013 pSet->mbCalcPix = TRUE;
3014 if ( pSet->mnItems )
3016 memmove( pSet->mpItems+nPos, pSet->mpItems+nPos+1,
3017 (pSet->mnItems-nPos)*sizeof( ImplSplitItem ) );
3019 else
3021 delete[] pSet->mpItems;
3022 pSet->mpItems = NULL;
3025 ImplUpdate();
3027 // Window erst hier loeschen, um weniger Paints zu haben
3028 if ( pWindow )
3030 // Fenster wieder herstellen
3031 if ( bHide || (pOrgParent != this) )
3033 pWindow->Hide();
3034 pWindow->SetParent( pOrgParent );
3039 // -----------------------------------------------------------------------
3041 void SplitWindow::Clear()
3043 // Alle Sets loeschen
3044 ImplDeleteSet( mpMainSet );
3046 // Main-Set wieder anlegen
3047 mpMainSet = new ImplSplitSet;
3048 mpMainSet->mpItems = NULL;
3049 mpMainSet->mpWallpaper = NULL;
3050 mpMainSet->mpBitmap = NULL;
3051 mpMainSet->mnLastSize = 0;
3052 mpMainSet->mnItems = 0;
3053 mpMainSet->mnId = 0;
3054 mpMainSet->mnSplitSize = SPLITWIN_SPLITSIZE;
3055 mpMainSet->mbCalcPix = TRUE;
3056 if ( mnWinStyle & WB_NOSPLITDRAW )
3057 mpMainSet->mnSplitSize -= 2;
3058 mpBaseSet = mpMainSet;
3060 // Und neu invalidieren
3061 ImplUpdate();
3064 // -----------------------------------------------------------------------
3066 void SplitWindow::SetBaseSet( USHORT nSetId )
3068 mpBaseSet = ImplFindSet( mpMainSet, nSetId );
3071 // -----------------------------------------------------------------------
3073 USHORT SplitWindow::GetBaseSet() const
3075 return mpBaseSet->mnId;
3078 // -----------------------------------------------------------------------
3080 void SplitWindow::SetSplitSize( USHORT nSetId, long nSplitSize,
3081 BOOL bWithChilds )
3083 ImplSplitSet* pSet = ImplFindSet( mpMainSet, nSetId );
3084 if ( pSet )
3086 if ( bWithChilds )
3087 ImplSetSplitSize( pSet, nSplitSize );
3088 else
3089 pSet->mnSplitSize = nSplitSize;
3091 ImplUpdate();
3094 // -----------------------------------------------------------------------
3096 long SplitWindow::GetSplitSize( USHORT nSetId ) const
3098 ImplSplitSet* pSet = ImplFindSet( mpMainSet, nSetId );
3099 if ( pSet )
3100 return pSet->mnSplitSize;
3101 else
3102 return 0;
3105 // -----------------------------------------------------------------------
3107 void SplitWindow::SetItemBackground( USHORT nSetId )
3109 Wallpaper aWall;
3110 SetItemBackground( nSetId, aWall );
3113 // -----------------------------------------------------------------------
3115 void SplitWindow::SetItemBackground( USHORT nSetId, const Wallpaper& rWallpaper )
3117 ImplSplitSet* pSet = ImplFindSet( mpMainSet, nSetId );
3119 if ( pSet )
3121 BOOL bUpdate = TRUE;
3123 if ( rWallpaper.GetStyle() == WALLPAPER_NULL )
3125 if ( pSet->mpWallpaper )
3127 delete pSet->mpWallpaper;
3128 pSet->mpWallpaper = NULL;
3130 else
3131 bUpdate = FALSE;
3133 else
3135 // Ab jetzt muss immer invalidiert werden
3136 mbInvalidate = TRUE;
3138 if ( !pSet->mpWallpaper )
3139 pSet->mpWallpaper = new Wallpaper( rWallpaper );
3140 else
3141 *(pSet->mpWallpaper) = rWallpaper;
3144 // Beim MainSet koennen wir den Background umsetzen
3145 if ( pSet == mpMainSet )
3146 ImplInitSettings();
3148 if ( bUpdate )
3149 ImplUpdateSet( pSet );
3153 // -----------------------------------------------------------------------
3155 Wallpaper SplitWindow::GetItemBackground( USHORT nSetId ) const
3157 ImplSplitSet* pSet = ImplFindSet( mpMainSet, nSetId );
3159 if ( pSet && pSet->mpWallpaper )
3160 return *(pSet->mpWallpaper);
3161 else
3163 Wallpaper aWall;
3164 return aWall;
3168 // -----------------------------------------------------------------------
3170 BOOL SplitWindow::IsItemBackground( USHORT nSetId ) const
3172 ImplSplitSet* pSet = ImplFindSet( mpMainSet, nSetId );
3174 if ( pSet && pSet->mpWallpaper )
3175 return TRUE;
3176 else
3177 return FALSE;
3180 // -----------------------------------------------------------------------
3182 void SplitWindow::SetItemBitmap( USHORT nSetId, const Bitmap& rBitmap )
3184 ImplSplitSet* pSet = ImplFindSet( mpMainSet, nSetId );
3186 if ( pSet )
3188 BOOL bUpdate = TRUE;
3190 if ( !rBitmap )
3192 if ( pSet->mpBitmap )
3194 delete pSet->mpBitmap;
3195 pSet->mpBitmap = NULL;
3197 else
3198 bUpdate = FALSE;
3200 else
3202 // Ab jetzt muss immer invalidiert werden
3203 mbInvalidate = TRUE;
3205 if ( !pSet->mpBitmap )
3206 pSet->mpBitmap = new Bitmap( rBitmap );
3207 else
3208 *(pSet->mpBitmap) = rBitmap;
3211 // Beim MainSet koennen wir den Background umsetzen
3212 if ( pSet == mpMainSet )
3213 ImplInitSettings();
3215 if ( bUpdate )
3216 ImplUpdateSet( pSet );
3220 // -----------------------------------------------------------------------
3222 Bitmap SplitWindow::GetItemBitmap( USHORT nSetId ) const
3224 ImplSplitSet* pSet = ImplFindSet( mpMainSet, nSetId );
3226 if ( pSet && pSet->mpBitmap )
3227 return *(pSet->mpBitmap);
3228 else
3230 Bitmap aBitmap;
3231 return aBitmap;
3235 // -----------------------------------------------------------------------
3237 void SplitWindow::SplitItem( USHORT nId, long nNewSize,
3238 BOOL bPropSmall, BOOL bPropGreat )
3240 USHORT nItems;
3241 USHORT nPos;
3242 USHORT nMin;
3243 USHORT nMax;
3244 USHORT i;
3245 USHORT n;
3246 long nDelta;
3247 long nTempDelta;
3248 ImplSplitSet* pSet = ImplFindItem( mpBaseSet, nId, nPos );
3249 ImplSplitItem* pItems;
3251 if ( !pSet )
3252 return;
3254 nItems = pSet->mnItems;
3255 pItems = pSet->mpItems;
3257 if ( mbCalc )
3259 pItems[nPos].mnSize = nNewSize;
3260 return;
3263 nDelta = nNewSize-pItems[nPos].mnPixSize;
3264 if ( !nDelta )
3265 return;
3267 // Bereich berechnen, der beim Splitten betroffen sein kann
3268 nMin = 0;
3269 nMax = nItems;
3270 for ( i = 0; i < nItems; i++ )
3272 if ( pItems[i].mbFixed )
3274 if ( i < nPos )
3275 nMin = i+1;
3276 else
3277 nMax = i;
3281 // Wenn das Fenster sizeable ist, wird das TopSet anders behandelt
3282 BOOL bSmall = TRUE;
3283 BOOL bGreat = TRUE;
3284 if ( (pSet == mpMainSet) && (mnWinStyle & WB_SIZEABLE) )
3286 if ( nPos < pSet->mnItems-1 )
3288 if ( !((bPropSmall && bPropGreat) ||
3289 ((nDelta > 0) && bPropSmall) ||
3290 ((nDelta < 0) && bPropGreat)) )
3292 if ( nDelta < 0 )
3293 bGreat = FALSE;
3294 else
3295 bSmall = FALSE;
3298 else
3300 if ( nDelta < 0 )
3301 bGreat = FALSE;
3302 else
3303 bSmall = FALSE;
3306 else if ( nPos >= nMax )
3308 bSmall = FALSE;
3309 bGreat = FALSE;
3311 else if ( nPos && (nPos >= pSet->mnItems-1) )
3313 nPos--;
3314 nDelta *= -1;
3315 BOOL bTemp = bPropSmall;
3316 bPropSmall = bPropGreat;
3317 bPropGreat = bTemp;
3320 // Jetzt die Fenster splitten
3321 if ( nDelta < 0 )
3323 if ( bGreat )
3325 if ( bPropGreat )
3327 nTempDelta = nDelta;
3330 n = nPos+1;
3333 if ( nTempDelta )
3335 pItems[n].mnPixSize++;
3336 nTempDelta++;
3338 n++;
3340 while ( n < nMax );
3342 while ( nTempDelta );
3344 else
3345 pItems[nPos+1].mnPixSize -= nDelta;
3348 if ( bSmall )
3350 if ( bPropSmall )
3354 n = nPos+1;
3357 if ( nDelta && pItems[n-1].mnPixSize )
3359 pItems[n-1].mnPixSize--;
3360 nDelta++;
3363 n--;
3365 while ( n > nMin );
3367 while ( nDelta );
3369 else
3371 n = nPos+1;
3374 if ( pItems[n-1].mnPixSize+nDelta < 0 )
3376 nDelta += pItems[n-1].mnPixSize;
3377 pItems[n-1].mnPixSize = 0;
3379 else
3381 pItems[n-1].mnPixSize += nDelta;
3382 break;
3384 n--;
3386 while ( n > nMin );
3390 else
3392 if ( bGreat )
3394 if ( bPropGreat )
3396 nTempDelta = nDelta;
3399 n = nPos+1;
3402 if ( nTempDelta )
3404 pItems[n-1].mnPixSize++;
3405 nTempDelta--;
3407 n--;
3409 while ( n > nMin );
3411 while ( nTempDelta );
3413 else
3414 pItems[nPos].mnPixSize += nDelta;
3417 if ( bSmall )
3419 if ( bPropSmall )
3423 n = nPos+1;
3426 if ( nDelta && pItems[n].mnPixSize )
3428 pItems[n].mnPixSize--;
3429 nDelta--;
3432 n++;
3434 while ( n < nMax );
3436 while ( nDelta );
3438 else
3440 n = nPos+1;
3443 if ( pItems[n].mnPixSize-nDelta < 0 )
3445 nDelta -= pItems[n].mnPixSize;
3446 pItems[n].mnPixSize = 0;
3448 else
3450 pItems[n].mnPixSize -= nDelta;
3451 break;
3453 n++;
3455 while ( n < nMax );
3460 // Original-Groessen updaten
3461 ImplCalcLogSize( pItems, nItems );
3463 ImplUpdate();
3466 // -----------------------------------------------------------------------
3468 void SplitWindow::SetItemSize( USHORT nId, long nNewSize )
3470 USHORT nPos;
3471 ImplSplitSet* pSet = ImplFindItem( mpBaseSet, nId, nPos );
3472 ImplSplitItem* pItem;
3474 if ( !pSet )
3475 return;
3477 // Testen, ob sich Groesse aendert
3478 pItem = &(pSet->mpItems[nPos]);
3479 if ( pItem->mnSize != nNewSize )
3481 // Neue Groesse setzen und neu durchrechnen
3482 pItem->mnSize = nNewSize;
3483 pSet->mbCalcPix = TRUE;
3484 ImplUpdate();
3488 // -----------------------------------------------------------------------
3490 long SplitWindow::GetItemSize( USHORT nId ) const
3492 USHORT nPos;
3493 ImplSplitSet* pSet = ImplFindItem( mpBaseSet, nId, nPos );
3495 if ( pSet )
3496 return pSet->mpItems[nPos].mnSize;
3497 else
3498 return 0;
3501 // -----------------------------------------------------------------------
3503 long SplitWindow::GetItemSize( USHORT nId, SplitWindowItemBits nBits ) const
3505 USHORT nPos;
3506 ImplSplitSet* pSet = ImplFindItem( mpBaseSet, nId, nPos );
3508 if ( pSet )
3510 if ( nBits == pSet->mpItems[nPos].mnBits )
3511 return pSet->mpItems[nPos].mnSize;
3512 else
3514 ((SplitWindow*)this)->ImplCalcLayout();
3516 long nRelSize = 0;
3517 long nPerSize = 0;
3518 ImplSplitItem* pItems;
3519 USHORT nItems;
3520 SplitWindowItemBits nTempBits;
3521 USHORT i;
3522 nItems = pSet->mnItems;
3523 pItems = pSet->mpItems;
3524 for ( i = 0; i < nItems; i++ )
3526 if ( i == nPos )
3527 nTempBits = nBits;
3528 else
3529 nTempBits = pItems[i].mnBits;
3530 if ( nTempBits & SWIB_RELATIVESIZE )
3531 nRelSize += pItems[i].mnPixSize;
3532 else if ( nTempBits & SWIB_PERCENTSIZE )
3533 nPerSize += pItems[i].mnPixSize;
3535 nPerSize += nRelSize;
3536 if ( nBits & SWIB_RELATIVESIZE )
3538 if ( nRelSize )
3539 return (pItems[nPos].mnPixSize+(nRelSize/2))/nRelSize;
3540 else
3541 return 1;
3543 else if ( nBits & SWIB_PERCENTSIZE )
3545 if ( nPerSize )
3546 return (pItems[nPos].mnPixSize*100)/nPerSize;
3547 else
3548 return 1;
3550 else
3551 return pItems[nPos].mnPixSize;
3554 else
3555 return 0;
3558 // -----------------------------------------------------------------------
3560 void SplitWindow::SetItemBits( USHORT nId, SplitWindowItemBits nNewBits )
3562 USHORT nPos;
3563 ImplSplitSet* pSet = ImplFindItem( mpBaseSet, nId, nPos );
3564 ImplSplitItem* pItem;
3566 if ( !pSet )
3567 return;
3569 pItem = &(pSet->mpItems[nPos]);
3570 if ( pItem->mpWindow )
3571 nNewBits &= ~SWIB_COLSET;
3573 if ( pItem->mnBits != nNewBits )
3575 // Neue Bits setzen und neu durchrechnen
3576 pItem->mnBits = nNewBits;
3577 pSet->mbCalcPix = TRUE;
3578 ImplUpdate();
3582 // -----------------------------------------------------------------------
3584 SplitWindowItemBits SplitWindow::GetItemBits( USHORT nId ) const
3586 USHORT nPos;
3587 ImplSplitSet* pSet = ImplFindItem( mpBaseSet, nId, nPos );
3589 if ( pSet )
3590 return pSet->mpItems[nPos].mnBits;
3591 else
3592 return 0;
3595 // -----------------------------------------------------------------------
3597 Window* SplitWindow::GetItemWindow( USHORT nId ) const
3599 USHORT nPos;
3600 ImplSplitSet* pSet = ImplFindItem( mpBaseSet, nId, nPos );
3602 if ( pSet )
3603 return pSet->mpItems[nPos].mpWindow;
3604 else
3605 return NULL;
3608 // -----------------------------------------------------------------------
3610 USHORT SplitWindow::GetSet( USHORT nId ) const
3612 USHORT nPos;
3613 ImplSplitSet* pSet = ImplFindItem( mpBaseSet, nId, nPos );
3615 if ( pSet )
3616 return pSet->mnId;
3617 else
3618 return 0;
3621 // -----------------------------------------------------------------------
3623 BOOL SplitWindow::GetSet( USHORT nId, USHORT& rSetId, USHORT& rPos ) const
3625 ImplSplitSet* pSet = ImplFindItem( mpBaseSet, nId, rPos );
3626 if ( pSet )
3628 rSetId = pSet->mnId;
3629 return TRUE;
3631 else
3632 return FALSE;
3635 // -----------------------------------------------------------------------
3637 BOOL SplitWindow::IsItemValid( USHORT nId ) const
3639 USHORT nPos;
3640 ImplSplitSet* pSet = ImplFindItem( mpBaseSet, nId, nPos );
3642 if ( pSet )
3643 return TRUE;
3644 else
3645 return FALSE;
3648 // -----------------------------------------------------------------------
3650 USHORT SplitWindow::GetItemId( Window* pWindow ) const
3652 return ImplFindItem( mpBaseSet, pWindow );
3655 // -----------------------------------------------------------------------
3657 USHORT SplitWindow::GetItemId( const Point& rPos ) const
3659 return ImplFindItem( mpBaseSet, rPos, mbHorz, !mbBottomRight );
3662 // -----------------------------------------------------------------------
3664 USHORT SplitWindow::GetItemPos( USHORT nId, USHORT nSetId ) const
3666 ImplSplitSet* pSet = ImplFindSet( mpBaseSet, nSetId );
3667 USHORT nPos = SPLITWINDOW_ITEM_NOTFOUND;
3669 if ( pSet )
3671 for ( USHORT i = 0; i < pSet->mnItems; i++ )
3673 if ( pSet->mpItems[i].mnId == nId )
3675 nPos = i;
3676 break;
3681 return nPos;
3684 // -----------------------------------------------------------------------
3686 USHORT SplitWindow::GetItemId( USHORT nPos, USHORT nSetId ) const
3688 ImplSplitSet* pSet = ImplFindSet( mpBaseSet, nSetId );
3689 if ( pSet && (nPos < pSet->mnItems) )
3690 return pSet->mpItems[nPos].mnId;
3691 else
3692 return 0;
3695 // -----------------------------------------------------------------------
3697 USHORT SplitWindow::GetItemCount( USHORT nSetId ) const
3699 ImplSplitSet* pSet = ImplFindSet( mpBaseSet, nSetId );
3700 if ( pSet )
3701 return pSet->mnItems;
3702 else
3703 return 0;
3706 // -----------------------------------------------------------------------
3708 void SplitWindow::ImplNewAlign()
3710 if ( mbNoAlign )
3712 mbHorz = FALSE;
3713 mbBottomRight = FALSE;
3715 else if ( meAlign == WINDOWALIGN_TOP )
3717 mbHorz = TRUE;
3718 mbBottomRight = FALSE;
3720 else if ( meAlign == WINDOWALIGN_BOTTOM )
3722 mbHorz = TRUE;
3723 mbBottomRight = TRUE;
3725 else if ( meAlign == WINDOWALIGN_LEFT )
3727 mbHorz = FALSE;
3728 mbBottomRight = FALSE;
3730 else if ( meAlign == WINDOWALIGN_RIGHT )
3732 mbHorz = FALSE;
3733 mbBottomRight = TRUE;
3736 if ( mnWinStyle & WB_BORDER )
3738 ImplCalcBorder( meAlign, mbNoAlign, mnLeftBorder, mnTopBorder,
3739 mnRightBorder, mnBottomBorder );
3742 if ( IsReallyVisible() && IsUpdateMode() )
3743 Invalidate();
3744 ImplUpdate();
3747 // -----------------------------------------------------------------------
3749 void SplitWindow::SetNoAlign( BOOL bNoAlign )
3751 bNoAlign = bNoAlign != 0;
3752 if ( mbNoAlign != bNoAlign )
3754 mbNoAlign = bNoAlign;
3755 ImplNewAlign();
3759 // -----------------------------------------------------------------------
3761 void SplitWindow::SetAlign( WindowAlign eNewAlign )
3763 if ( meAlign != eNewAlign )
3765 meAlign = eNewAlign;
3766 ImplNewAlign();
3770 // -----------------------------------------------------------------------
3772 Size SplitWindow::CalcWindowSizePixel( const Size& rSize, WindowAlign eAlign,
3773 WinBits nWinStyle, BOOL bExtra )
3775 long nLeft;
3776 long nTop;
3777 long nRight;
3778 long nBottom;
3779 Size aSize = rSize;
3781 ImplCalcBorder( eAlign, FALSE, nLeft, nTop, nRight, nBottom );
3782 aSize.Width() += nLeft+nRight;
3783 aSize.Height() += nTop+nBottom;
3785 if ( nWinStyle & WB_SIZEABLE )
3787 if ( (eAlign == WINDOWALIGN_TOP) || (eAlign == WINDOWALIGN_BOTTOM) )
3789 aSize.Height() += SPLITWIN_SPLITSIZE-2;
3790 if ( bExtra )
3791 aSize.Height() += SPLITWIN_SPLITSIZEEXLN;
3793 else
3795 aSize.Width() += SPLITWIN_SPLITSIZE-2;
3796 if ( bExtra )
3797 aSize.Width() += SPLITWIN_SPLITSIZEEXLN;
3801 return aSize;
3804 // -----------------------------------------------------------------------
3806 void SplitWindow::ShowAutoHideButton( BOOL bShow )
3808 mbAutoHide = bShow;
3809 ImplUpdate();
3812 // -----------------------------------------------------------------------
3814 void SplitWindow::ShowFadeInHideButton( BOOL bShow )
3816 mbFadeIn = bShow;
3817 ImplUpdate();
3820 // -----------------------------------------------------------------------
3822 void SplitWindow::ShowFadeOutButton( BOOL bShow )
3824 mbFadeOut = bShow;
3825 ImplUpdate();
3828 // -----------------------------------------------------------------------
3830 void SplitWindow::SetAutoHideState( BOOL bAutoHide )
3832 mbAutoHideIn = bAutoHide;
3833 if ( IsReallyVisible() )
3835 Rectangle aRect;
3836 ImplGetAutoHideRect( aRect );
3837 Invalidate( aRect );
3841 // -----------------------------------------------------------------------
3843 long SplitWindow::GetFadeInSize() const
3845 long n = 0;
3847 if ( mbHorz )
3848 n = mnTopBorder+mnBottomBorder;
3849 else
3850 n = mnLeftBorder+mnRightBorder;
3852 return n+SPLITWIN_SPLITSIZE+SPLITWIN_SPLITSIZEEX-2;
3855 // -----------------------------------------------------------------------
3857 Rectangle SplitWindow::GetAutoHideRect() const
3859 Rectangle aRect;
3860 ImplGetAutoHideRect( aRect, TRUE );
3861 return aRect;
3864 // -----------------------------------------------------------------------
3866 Rectangle SplitWindow::GetFadeInRect() const
3868 Rectangle aRect;
3869 ImplGetFadeInRect( aRect, TRUE );
3870 return aRect;
3873 // -----------------------------------------------------------------------
3875 Rectangle SplitWindow::GetFadeOutRect() const
3877 Rectangle aRect;
3878 ImplGetFadeOutRect( aRect, TRUE );
3879 return aRect;