1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: splitwin.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
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>
44 #include <vcl/svids.hrc>
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
74 SplitWindowItemBits mnBits
;
81 ImplSplitItem
* mpItems
;
82 Wallpaper
* mpWallpaper
;
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
)
121 if ( eAlign
== WINDOWALIGN_TOP
)
128 else if ( eAlign
== WINDOWALIGN_LEFT
)
135 else if ( eAlign
== WINDOWALIGN_BOTTOM
)
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
);
164 Rectangle
aRect( aTmpPoint
, Size( nDX
, nDY
) );
165 aDecoView
.DrawFrame( aRect
, FRAME_DRAW_DOUBLEIN
);
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 ) );
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 ) );
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 ) );
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
)
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
);
326 // -----------------------------------------------------------------------
328 static ImplSplitSet
* ImplFindItem( ImplSplitSet
* pSet
, USHORT nId
, USHORT
& rPos
)
331 USHORT nItems
= pSet
->mnItems
;
332 ImplSplitItem
* pItems
= pSet
->mpItems
;
334 for ( i
= 0; i
< nItems
; i
++ )
336 if ( pItems
[i
].mnId
== nId
)
343 for ( i
= 0; i
< nItems
; i
++ )
345 if ( pItems
[i
].mpSet
)
347 ImplSplitSet
* pFindSet
= ImplFindItem( pItems
[i
].mpSet
, nId
, rPos
);
356 // -----------------------------------------------------------------------
358 static USHORT
ImplFindItem( ImplSplitSet
* pSet
, Window
* pWindow
)
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
;
370 if ( pItems
[i
].mpSet
)
372 USHORT nId
= ImplFindItem( pItems
[i
].mpSet
, pWindow
);
382 // -----------------------------------------------------------------------
384 static USHORT
ImplFindItem( ImplSplitSet
* pSet
, const Point
& rPos
,
385 BOOL bRows
, BOOL bDown
= TRUE
)
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
);
402 aRect
.Bottom() += pSet
->mnSplitSize
;
404 aRect
.Top() -= pSet
->mnSplitSize
;
409 aRect
.Right() += pSet
->mnSplitSize
;
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) );
422 return pItems
[i
].mnId
;
430 // -----------------------------------------------------------------------
432 static void ImplDeleteSet( ImplSplitSet
* pSet
)
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
;
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
)
480 USHORT nItems
= pSet
->mnItems
;
487 long nNewSizeWinSize
;
495 ImplSplitItem
* pItems
= pSet
->mpItems
;
498 // Anzahl sichtbarer Items ermitteln
500 for ( i
= 0; i
< nItems
; i
++ )
502 if ( !(pItems
[i
].mnBits
& SWIB_INVISIBLE
) )
506 // Groessen berechnen
508 nCalcSize
= nSetHeight
;
510 nCalcSize
= nSetWidth
;
511 nCalcSize
-= (nVisItems
-1)*pSet
->mnSplitSize
;
513 if ( pSet
->mbCalcPix
|| (pSet
->mnLastSize
!= nCalcSize
) )
515 long nPercentFactor
= 10;
518 long nRelPercent
= 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
;
529 nAbsSize
+= pItems
[i
].mnSize
;
532 // Relative-Werte auf prozentual mappen (Percent bei uns 10tel Prozent)
533 nPercent
*= nPercentFactor
;
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
;
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;
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;
569 pItems
[i
].mnPixSize
= (nSizeDelta
*pItems
[i
].mnSize
*nPercentFactor
)/nPercent
;
572 pItems
[i
].mnPixSize
= pItems
[i
].mnSize
;
573 nCurSize
+= pItems
[i
].mnPixSize
;
576 pSet
->mbCalcPix
= FALSE
;
577 pSet
->mnLastSize
= nCalcSize
;
580 nSizeDelta
= nCalcSize
-nCurSize
;
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
)) )
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
619 while ( nSizeDelta
&& (nItems
!= nMins
) )
621 // Feststellen, welche Items berechnet werden duerfen
623 while ( !nCalcItems
)
625 for ( i
= 0; i
< nItems
; i
++ )
627 pItems
[i
].mbSubSize
= FALSE
;
630 pItems
[i
].mbSubSize
= TRUE
;
633 if ( !(pItems
[i
].mnBits
& SWIB_INVISIBLE
) )
635 if ( (nSizeDelta
> 0) || pItems
[i
].mnPixSize
)
638 pItems
[i
].mbSubSize
= TRUE
;
641 if ( (j
== 0) && (pItems
[i
].mnBits
& (SWIB_RELATIVESIZE
| SWIB_PERCENTSIZE
)) )
642 pItems
[i
].mbSubSize
= TRUE
;
648 if ( pItems
[i
].mbSubSize
)
655 // Groessen von den einzelnen Items abziehen
656 nErrorSum
= nSizeDelta
% nCalcItems
;
657 nCurSizeDelta
= nSizeDelta
/ nCalcItems
;
659 for ( i
= 0; i
< nItems
; i
++ )
661 if ( pItems
[i
].mnBits
& SWIB_INVISIBLE
)
663 else if ( pItems
[i
].mbSubSize
)
665 pSize
= &(pItems
[i
].mnPixSize
);
677 if ( (*pSize
+nCurSizeDelta
+nTempErr
) <= 0 )
689 *pSize
+= nCurSizeDelta
;
690 nSizeDelta
-= nCurSizeDelta
;
691 if ( nTempErr
&& (*pSize
|| (nTempErr
> 0)) )
694 nSizeDelta
-= nTempErr
;
695 nErrorSum
-= nTempErr
;
705 for ( i
= 0; i
< nItems
; i
++ )
707 if ( !(pItems
[i
].mnBits
& SWIB_INVISIBLE
) )
708 nCurSize
+= pItems
[i
].mnPixSize
;
712 // Maximale Groesse berechnen
717 nMaxPos
= nSetTop
-nSetHeight
;
719 nMaxPos
= nSetTop
+nSetHeight
;
725 nMaxPos
= nSetLeft
-nSetWidth
;
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
)
745 if ( nPos
+pItems
[i
].mnPixSize
> nMaxPos
)
750 nPos
-= pItems
[i
].mnPixSize
;
751 if ( nPos
< nMaxPos
)
758 pItems
[i
].mnWidth
= 0;
759 pItems
[i
].mnHeight
= 0;
760 pItems
[i
].mnSplitSize
= 0;
766 pItems
[i
].mnLeft
= nSetLeft
;
767 pItems
[i
].mnTop
= nPos
;
768 pItems
[i
].mnWidth
= nSetWidth
;
769 pItems
[i
].mnHeight
= pItems
[i
].mnPixSize
;
773 pItems
[i
].mnLeft
= nPos
;
774 pItems
[i
].mnTop
= nSetTop
;
775 pItems
[i
].mnWidth
= pItems
[i
].mnPixSize
;
776 pItems
[i
].mnHeight
= nSetHeight
;
780 pItems
[i
].mnSplitSize
= 0;
783 pItems
[i
].mnSplitSize
= pSet
->mnSplitSize
;
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
;
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
) )
802 nPos
-= pSet
->mnSplitSize
;
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) );
821 for ( i
= 0; i
< nItems
; i
++ )
823 pItems
[i
].mbFixed
= FALSE
;
824 if ( pItems
[i
].mnBits
& SWIB_FIXED
)
825 pItems
[i
].mbFixed
= TRUE
;
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
;
845 // -----------------------------------------------------------------------
847 void SplitWindow::ImplCalcSet2( SplitWindow
* pWindow
, ImplSplitSet
* pSet
, BOOL bHide
,
848 BOOL bRows
, BOOL
/*bDown*/ )
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
) )
868 // Old Rect invalidieren
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
;
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
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
;
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
)
924 ImplCalcSet2( pWindow
, pItems
[i
].mpSet
, bTempHide
,
925 ((pItems
[i
].mnBits
& SWIB_COLSET
) == 0) );
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
);
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
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
)
969 pItems
[i
].mnSize
= (pItems
[i
].mnPixSize
+(nRelSize
/2))/nRelSize
;
971 pItems
[i
].mnSize
= 1;
973 else if ( pItems
[i
].mnBits
& SWIB_PERCENTSIZE
)
976 pItems
[i
].mnSize
= (pItems
[i
].mnPixSize
*100)/nPerSize
;
978 pItems
[i
].mnSize
= 1;
981 pItems
[i
].mnSize
= pItems
[i
].mnPixSize
;
985 // -----------------------------------------------------------------------
987 void SplitWindow::ImplDrawBack( SplitWindow
* pWindow
, const Rectangle
& rRect
,
988 const Wallpaper
* pWall
, const Bitmap
* 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() );
1011 pWindow
->DrawWallpaper( rRect
, *pWall
);
1014 // -----------------------------------------------------------------------
1016 void SplitWindow::ImplDrawBack( SplitWindow
* pWindow
, ImplSplitSet
* pSet
)
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
;
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
)
1067 USHORT nItems
= pSet
->mnItems
;
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
;
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
) );
1107 if ( !bDown
|| (nItemSplitSize
>= nSplitSize
) )
1109 pWindow
->SetLineColor( rStyleSettings
.GetDarkShadowColor() );
1110 pWindow
->DrawLine( Point( nTop
, nPos
), Point( nBottom
, nPos
) );
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
) );
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
)
1164 USHORT nItems
= pSet
->mnItems
;
1170 ImplSplitItem
* pItems
= pSet
->mpItems
;
1183 for ( i
= 0; i
< nItems
-1; i
++ )
1185 if ( pItems
[i
].mnSplitSize
)
1189 nTop
= pItems
[i
].mnLeft
;
1190 nBottom
= pItems
[i
].mnLeft
+pItems
[i
].mnWidth
-1;
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
;
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) );
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
)
1245 if ( pWindow
->mbHorz
)
1247 if ( pWindow
->mbBottomRight
)
1249 nBorder
= pWindow
->mnBottomBorder
;
1254 nBorder
= pWindow
->mnTopBorder
;
1255 nPos
= pWindow
->mnDY
-nBorder
;
1261 if ( pWindow
->mbBottomRight
)
1263 nBorder
= pWindow
->mnRightBorder
;
1268 nBorder
= pWindow
->mnLeftBorder
;
1269 nPos
= pWindow
->mnDX
-nBorder
;
1273 long nSplitSize
= pWindow
->mpMainSet
->mnSplitSize
-2;
1274 if ( pWindow
->mbAutoHide
|| pWindow
->mbFadeOut
)
1275 nSplitSize
+= SPLITWIN_SPLITSIZEEXLN
;
1276 if ( !pWindow
->mbBottomRight
)
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;
1286 if ( pWindow
->mbHorz
)
1287 return SPLIT_VERT
| SPLIT_WINDOW
;
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
)
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
) )
1311 if ( (pThis
->mnSplitTest
& SPLIT_WINDOW
) &&
1312 (pThis
->mbAutoHide
|| pThis
->mbFadeOut
) )
1314 aRect
.Left() += SPLITWIN_SPLITSIZEEXLN
;
1315 aRect
.Right() += SPLITWIN_SPLITSIZEEXLN
;
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
) )
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;
1347 pNewSet
->mnSplitSize
= SPLITWIN_SPLITSIZE
;
1348 pNewSet
->mbCalcPix
= TRUE
;
1350 mpMainSet
= pNewSet
;
1351 mpBaseSet
= pNewSet
;
1362 meAlign
= WINDOWALIGN_TOP
;
1363 mnWinStyle
= nStyle
;
1366 mnMouseModifier
= 0;
1371 mbBottomRight
= FALSE
;
1374 mbInvalidate
= TRUE
;
1378 mbAutoHideIn
= FALSE
;
1379 mbAutoHideDown
= FALSE
;
1380 mbFadeInDown
= FALSE
;
1381 mbFadeOutDown
= FALSE
;
1382 mbAutoHidePressed
= FALSE
;
1383 mbFadeInPressed
= FALSE
;
1384 mbFadeOutPressed
= FALSE
;
1385 mbFadeNoButtonMode
= 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
);
1407 DockingWindow::ImplInit( pParent
, (nStyle
| WB_CLIPCHILDREN
) & ~(WB_BORDER
| WB_SIZEABLE
) );
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
)
1422 else if ( mpMainSet
->mpWallpaper
)
1423 SetBackground( *mpMainSet
->mpWallpaper
);
1426 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
1429 if ( IsControlBackground() )
1430 aColor
= GetControlBackground();
1431 else if ( Window::GetStyle() & WB_3DLOOK
)
1432 aColor
= rStyleSettings
.GetFaceColor();
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
) )
1461 // -----------------------------------------------------------------------
1463 SplitWindow::~SplitWindow()
1466 ImplDeleteSet( mpMainSet
);
1469 // -----------------------------------------------------------------------
1471 void SplitWindow::ImplSetWindowSize( long nDelta
)
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();
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();
1500 aSize
.Width() += nDelta
;
1501 SetPosSizePixel( aPos
, aSize
);
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
1520 if ( mnWinStyle
& WB_SIZEABLE
)
1526 for ( i
= 0; i
< mpMainSet
->mnItems
; i
++ )
1528 if ( mpMainSet
->mpItems
[i
].mnBits
& (SWIB_RELATIVESIZE
| SWIB_PERCENTSIZE
) )
1531 nCalcSize
+= mpMainSet
->mpItems
[i
].mnSize
;
1534 if ( i
== mpMainSet
->mnItems
)
1537 Point aPos
= GetPosPixel();
1540 nCurSize
= aNewSize
.Height()-mnTopBorder
-mnBottomBorder
;
1542 nCurSize
= aNewSize
.Width()-mnLeftBorder
-mnRightBorder
;
1543 nCurSize
-= nSplitSize
;
1544 nCurSize
-= (mpMainSet
->mnItems
-1)*mpMainSet
->mnSplitSize
;
1546 nDelta
= nCalcSize
-nCurSize
;
1550 if ( meAlign
== WINDOWALIGN_TOP
)
1552 aSize
.Height() += nDelta
;
1554 else if ( meAlign
== WINDOWALIGN_BOTTOM
)
1557 aSize
.Height() += nDelta
;
1559 else if ( meAlign
== WINDOWALIGN_LEFT
)
1561 aSize
.Width() += nDelta
;
1563 else // meAlign == WINDOWALIGN_RIGHT
1566 aSize
.Width() += nDelta
;
1574 // -----------------------------------------------------------------------
1576 void SplitWindow::ImplCalcLayout()
1578 if ( !mbCalc
|| !mbRecalc
|| !mpMainSet
->mpItems
)
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
1588 if ( mnWinStyle
& WB_SIZEABLE
)
1594 for ( i
= 0; i
< mpMainSet
->mnItems
; i
++ )
1596 if ( mpMainSet
->mpItems
[i
].mnBits
& (SWIB_RELATIVESIZE
| SWIB_PERCENTSIZE
) )
1599 nCalcSize
+= mpMainSet
->mpItems
[i
].mnSize
;
1602 if ( i
== mpMainSet
->mnItems
)
1605 nCurSize
= mnDY
-mnTopBorder
-mnBottomBorder
;
1607 nCurSize
= mnDX
-mnLeftBorder
-mnRightBorder
;
1608 nCurSize
-= nSplitSize
;
1609 nCurSize
-= (mpMainSet
->mnItems
-1)*mpMainSet
->mnSplitSize
;
1612 ImplSetWindowSize( nCalcSize
-nCurSize
);
1617 if ( (mnDX
<= 0) || (mnDY
<= 0) )
1620 // Groessen/Position vorberechnen
1628 if ( mbBottomRight
)
1629 nT
= mnDY
-mnBottomBorder
;
1636 if ( mbBottomRight
)
1637 nL
= mnDX
-mnRightBorder
;
1642 nW
= mnDX
-mnLeftBorder
-mnRightBorder
;
1643 nH
= mnDY
-mnTopBorder
-mnBottomBorder
;
1644 if ( mnWinStyle
& WB_SIZEABLE
)
1652 // Sets rekursiv berechnen
1653 ImplCalcSet( mpMainSet
, nL
, nT
, nW
, nH
, mbHorz
, !mbBottomRight
);
1654 ImplCalcSet2( this, mpMainSet
, FALSE
, mbHorz
, !mbBottomRight
);
1658 // -----------------------------------------------------------------------
1660 void SplitWindow::ImplUpdate()
1664 if ( IsReallyShown() && IsUpdateMode() && mbRecalc
)
1666 if ( mpMainSet
->mpItems
)
1673 // -----------------------------------------------------------------------
1675 void SplitWindow::ImplUpdateSet( ImplSplitSet
* pSet
)
1677 if ( IsReallyShown() && IsUpdateMode() && mbRecalc
)
1679 // Wenn wir noch berechnen muessen, dann alles invalidieren.
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
) )
1692 if ( pSet
== mpMainSet
)
1694 aRect
.Left() = mnLeftBorder
;
1695 aRect
.Top() = mnTopBorder
;
1696 aRect
.Right() = mnDX
-mnRightBorder
-1;
1697 aRect
.Bottom() = mnDY
-mnBottomBorder
-1;
1701 ImplSplitItem
* pItem
;
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();
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;
1750 nButtonSize
+= SPLITWIN_SPLITSIZEFADE
+1;
1752 nButtonSize
+= SPLITWIN_SPLITSIZEFADE
+1;
1754 nButtonSize
+= SPLITWIN_SPLITSIZEAUTOHIDE
+1;
1757 nCenterEx
+= ((mnDX
-mnLeftBorder
-mnRightBorder
)-nButtonSize
)/2;
1759 nCenterEx
+= ((mnDY
-mnTopBorder
-mnBottomBorder
)-nButtonSize
)/2;
1760 if ( nCenterEx
> 0 )
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;
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;
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
;
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
;
1807 rRect
.Left() -= mnLeftBorder
;
1808 rRect
.Right() += mnRightBorder
;
1813 // -----------------------------------------------------------------------
1815 void SplitWindow::ImplGetAutoHideRect( Rectangle
& rRect
, BOOL bTest
) const
1822 if ( mbFadeIn
|| mbFadeOut
)
1823 nEx
= SPLITWIN_SPLITSIZEFADE
+1;
1824 ImplGetButtonRect( aRect
, nEx
, bTest
&& mbFadeIn
);
1830 // -----------------------------------------------------------------------
1832 void SplitWindow::ImplGetFadeInRect( Rectangle
& rRect
, BOOL bTest
) const
1837 ImplGetButtonRect( aRect
, 0, bTest
);
1842 // -----------------------------------------------------------------------
1844 void SplitWindow::ImplGetFadeOutRect( Rectangle
& rRect
, BOOL
) const
1849 ImplGetButtonRect( aRect
, 0, FALSE
);
1854 // -----------------------------------------------------------------------
1856 void SplitWindow::ImplDrawButtonRect( const Rectangle
& rRect
, long nSize
)
1858 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
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() ) );
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() );
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() );
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() ) );
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() );
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() );
1922 // -----------------------------------------------------------------------
1924 void SplitWindow::ImplDrawAutoHide( BOOL bInPaint
)
1928 Rectangle aTempRect
;
1929 ImplGetAutoHideRect( aTempRect
);
1934 // ImageListe laden, wenn noch nicht vorhanden
1935 ImplSVData
* pSVData
= ImplGetSVData();
1936 ImageList
* pImageList
;
1939 if ( !pSVData
->maCtrlData
.mpSplitHPinImgList
)
1941 ResMgr
* pResMgr
= ImplGetResMgr();
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
;
1954 if ( !pSVData
->maCtrlData
.mpSplitVPinImgList
)
1956 ResMgr
* pResMgr
= ImplGetResMgr();
1957 pSVData
->maCtrlData
.mpSplitVPinImgList
= new ImageList(4);
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
1970 if ( mbAutoHidePressed
)
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) );
1991 nSize
= aImageSize
.Width();
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();
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
);
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() );
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
);
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
);
2069 int width
= (int) (0.5 * rRect
.getWidth() + 0.5);
2070 int i
= rRect
.nLeft
+ (rRect
.getWidth() - width
) / 2;
2072 const int y
= rRect
.nTop
+ 1;
2073 ImplDrawFadeArrow( Point( i
-8, y
), bHorz
, bLeft
);
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
) );
2088 ImplDrawFadeArrow( Point( i
+3, y
), bHorz
, bLeft
);
2092 int height
= (int) (0.5 * rRect
.getHeight() + 0.5);
2093 int i
= rRect
.nTop
+ (rRect
.getHeight() - height
) / 2;
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
) );
2111 ImplDrawFadeArrow( Point( x
, i
+3), bHorz
, bLeft
);
2115 void SplitWindow::ImplDrawFadeIn( BOOL bInPaint
)
2119 Rectangle aTempRect
;
2121 ImplGetFadeInRect( aTempRect
);
2124 if ( meAlign
== WINDOWALIGN_TOP
)
2126 else if ( meAlign
== WINDOWALIGN_BOTTOM
)
2128 else if ( meAlign
== WINDOWALIGN_LEFT
)
2130 else if ( meAlign
== WINDOWALIGN_RIGHT
)
2138 ImplDrawGrip( aTempRect
, (meAlign
== WINDOWALIGN_TOP
) || (meAlign
== WINDOWALIGN_BOTTOM
), bLeft
);
2142 // -----------------------------------------------------------------------
2144 void SplitWindow::ImplDrawFadeOut( BOOL bInPaint
)
2148 Rectangle aTempRect
;
2150 ImplGetFadeOutRect( aTempRect
);
2153 if ( meAlign
== WINDOWALIGN_TOP
)
2155 else if ( meAlign
== WINDOWALIGN_BOTTOM
)
2157 else if ( meAlign
== WINDOWALIGN_LEFT
)
2159 else if ( meAlign
== WINDOWALIGN_RIGHT
)
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
;
2185 mnMouseModifier
= rMEvt
.GetModifier();
2186 if ( !(mnMouseModifier
& KEY_SHIFT
) || (mnSplitPos
+1 >= mpSplitSet
->mnItems
) )
2187 bPropSmaller
= FALSE
;
2189 bPropSmaller
= TRUE
;
2191 // Hier kann noch die maximale Groesse gesetzt werden
2195 nCurMaxSize
= mnMaxSize
;
2198 Size aSize
= GetParent()->GetOutputSizePixel();
2200 nCurMaxSize
= aSize
.Height();
2202 nCurMaxSize
= aSize
.Width();
2205 if ( mpSplitSet
->mpItems
)
2208 if ( (mpSplitSet
== mpMainSet
) && mbBottomRight
)
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
)
2220 maDragRect
.Right() += mpSplitSet
->mnSplitSize
;
2222 maDragRect
.Left() -= mpSplitSet
->mnSplitSize
;
2227 maDragRect
.Bottom() += mpSplitSet
->mnSplitSize
;
2229 maDragRect
.Top() -= mpSplitSet
->mnSplitSize
;
2237 pSplitItem
= &(mpSplitSet
->mpItems
[nTemp
-1]);
2238 if ( pSplitItem
->mbFixed
)
2242 if ( mnSplitTest
& SPLIT_HORZ
)
2245 maDragRect
.Left() -= pSplitItem
->mnPixSize
;
2247 maDragRect
.Right() += pSplitItem
->mnPixSize
;
2252 maDragRect
.Top() -= pSplitItem
->mnPixSize
;
2254 maDragRect
.Bottom() += pSplitItem
->mnPixSize
;
2261 if ( (mpSplitSet
== mpMainSet
) && (mnWinStyle
& WB_SIZEABLE
) && !bPropSmaller
)
2266 maDragRect
.Bottom() += nCurMaxSize
-mnDY
-mnTopBorder
;
2268 maDragRect
.Right() += nCurMaxSize
-mnDX
-mnLeftBorder
;
2273 maDragRect
.Top() -= nCurMaxSize
-mnDY
-mnBottomBorder
;
2275 maDragRect
.Left() -= nCurMaxSize
-mnDX
-mnRightBorder
;
2280 nTemp
= mnSplitPos
+1;
2281 while ( nTemp
< mpSplitSet
->mnItems
)
2283 pSplitItem
= &(mpSplitSet
->mpItems
[nTemp
]);
2284 if ( pSplitItem
->mbFixed
)
2288 if ( mnSplitTest
& SPLIT_HORZ
)
2291 maDragRect
.Right() += pSplitItem
->mnPixSize
;
2293 maDragRect
.Left() -= pSplitItem
->mnPixSize
;
2298 maDragRect
.Bottom() += pSplitItem
->mnPixSize
;
2300 maDragRect
.Top() -= pSplitItem
->mnPixSize
;
2309 maDragRect
.Left() = mnLeftBorder
;
2310 maDragRect
.Top() = mnTopBorder
;
2311 maDragRect
.Right() = mnDX
-mnRightBorder
-1;
2312 maDragRect
.Bottom() = mnDY
-mnBottomBorder
-1;
2315 if ( mbBottomRight
)
2316 maDragRect
.Top() -= nCurMaxSize
-mnDY
-mnBottomBorder
;
2318 maDragRect
.Bottom() += nCurMaxSize
-mnDY
-mnTopBorder
;
2322 if ( mbBottomRight
)
2323 maDragRect
.Left() -= nCurMaxSize
-mnDX
-mnRightBorder
;
2325 maDragRect
.Right() += nCurMaxSize
-mnDX
-mnLeftBorder
;
2331 mbDragFull
= (GetSettings().GetStyleSettings().GetDragFullOptions() & DRAGFULL_OPTION_SPLIT
) != 0;
2333 ImplSplitMousePos( aMousePosPixel
);
2336 ImplDrawSplitTracking( this, aMousePosPixel
);
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
);
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
);
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
);
2427 ImplGetFadeOutRect( aTestRect
, TRUE
);
2428 if ( aTestRect
.IsInside( aMousePosPixel
) )
2430 mbFadeOutDown
= TRUE
;
2431 mbFadeOutPressed
= TRUE
;
2432 ImplDrawFadeOut( FALSE
);
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
;
2452 if ( mbAutoHideDown
|| mbFadeInDown
|| mbFadeOutDown
)
2455 ImplStartSplit( rMEvt
);
2458 // -----------------------------------------------------------------------
2460 void SplitWindow::MouseMove( const MouseEvent
& rMEvt
)
2462 if ( !IsTracking() )
2464 Point aPos
= rMEvt
.GetPosPixel();
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
);
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
);
2517 ImplDrawAutoHide( FALSE
);
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() )
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() )
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
;
2596 ImplSplitMousePos( aMousePosPixel
);
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];
2619 if ( rTEvt
.IsTrackingEnded() )
2622 bSplit
= !rTEvt
.IsTrackingCanceled();
2626 ImplDrawSplitTracking( this, aMousePosPixel
);
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
)
2641 ImplSetWindowSize( nDelta
);
2645 long nNewSize
= mpSplitSet
->mpItems
[mnSplitPos
].mnPixSize
;
2646 if ( (mpSplitSet
== mpMainSet
) && mbBottomRight
)
2650 SplitItem( mpSplitSet
->mpItems
[mnSplitPos
].mnId
, nNewSize
,
2651 bPropSmaller
, bPropGreater
);
2659 mnMStartPos
= mnMSplitPos
;
2663 if ( rTEvt
.IsTrackingEnded() )
2672 mnMouseModifier
= 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();
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
) )
2764 nHelpResId
= SV_HELPTEXT_SPLITFIXED
;
2766 nHelpResId
= SV_HELPTEXT_SPLITFLOATING
;
2770 ImplGetFadeInRect( aHelpRect
, TRUE
);
2771 if ( aHelpRect
.IsInside( aMousePosPixel
) )
2772 nHelpResId
= SV_HELPTEXT_FADEIN
;
2775 ImplGetFadeOutRect( aHelpRect
, TRUE
);
2776 if ( aHelpRect
.IsInside( aMousePosPixel
) )
2777 nHelpResId
= SV_HELPTEXT_FADEOUT
;
2781 // Rechteck ermitteln
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
2793 ResMgr
* pResMgr
= ImplGetResMgr();
2795 aStr
= XubString( ResId( nHelpResId
, *pResMgr
) );
2796 if ( rHEvt
.GetMode() & HELPMODE_BALLOON
)
2797 Help::ShowBalloon( this, aHelpRect
.Center(), aHelpRect
, aStr
);
2799 Help::ShowQuickHelp( this, aHelpRect
, aStr
);
2804 DockingWindow::RequestHelp( rHEvt
);
2807 // -----------------------------------------------------------------------
2809 void SplitWindow::StateChanged( StateChangedType nType
)
2811 if ( nType
== STATE_CHANGE_INITSHOW
)
2813 if ( IsUpdateMode() )
2816 else if ( nType
== STATE_CHANGE_UPDATEMODE
)
2818 if ( IsUpdateMode() && IsReallyShown() )
2821 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
2827 DockingWindow::StateChanged( nType
);
2830 // -----------------------------------------------------------------------
2832 void SplitWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
2834 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
2835 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
2841 DockingWindow::DataChanged( rDCEvt
);
2844 // -----------------------------------------------------------------------
2846 void SplitWindow::InsertItem( USHORT nId
, Window
* pWindow
, long nSize
,
2847 USHORT nPos
, USHORT nSetId
,
2848 SplitWindowItemBits nBits
)
2852 DBG_ASSERT( ImplFindSet( mpMainSet
, nSetId
), "SplitWindow::InsertItem() - Set not exists" );
2853 DBG_ASSERT( !ImplFindItem( mpMainSet
, nId
, nDbgDummy
), "SplitWindow::InsertItem() - Id already exists" );
2856 // Size muss min. 1 sein
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];
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
;
2875 pSet
->mbCalcPix
= TRUE
;
2877 // Item anlegen und erweitern
2878 pItem
= &(pSet
->mpItems
[nPos
]);
2879 memset( pItem
, 0, sizeof( ImplSplitItem
) );
2880 pItem
->mnSize
= nSize
;
2882 pItem
->mnBits
= nBits
;
2886 pItem
->mpWindow
= pWindow
;
2887 pItem
->mpOrgParent
= pWindow
->GetParent();
2889 // Window mit SplitWindow verbinden
2891 pWindow
->SetParent( this );
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
;
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
)
2926 DBG_ASSERT( ImplFindItem( mpMainSet
, nId
, nDbgDummy
), "SplitWindow::MoveItem() - Id not found" );
2927 DBG_ASSERT( ImplFindSet( mpMainSet
, nNewSetId
), "SplitWindow::MoveItem() - Set not exists" );
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
) );
2949 memmove( pSet
->mpItems
+nNewPos
+1, pSet
->mpItems
+nNewPos
,
2950 (nPos
-nNewPos
)*sizeof( ImplSplitItem
) );
2952 memcpy( &(pSet
->mpItems
[nNewPos
]), &aTempItem
, sizeof( aTempItem
) );
2959 if ( nNewPos
>= pNewSet
->mnItems
)
2960 nNewPos
= pNewSet
->mnItems
;
2961 memcpy( &aTempItem
, &(pSet
->mpItems
[nPos
]), sizeof( aTempItem
) );
2963 pSet
->mbCalcPix
= TRUE
;
2964 if ( pSet
->mnItems
)
2966 memmove( pSet
->mpItems
+nPos
, pSet
->mpItems
+nPos
+1,
2967 (pSet
->mnItems
-nPos
)*sizeof( ImplSplitItem
) );
2971 delete[] pSet
->mpItems
;
2972 pSet
->mpItems
= NULL
;
2974 ImplSplitItem
* pNewItems
= new ImplSplitItem
[pNewSet
->mnItems
+1];
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
;
2985 pNewSet
->mbCalcPix
= TRUE
;
2986 memcpy( &(pNewSet
->mpItems
[nNewPos
]), &aTempItem
, sizeof( aTempItem
) );
2991 // -----------------------------------------------------------------------
2993 void SplitWindow::RemoveItem( USHORT nId
, BOOL bHide
)
2997 DBG_ASSERT( ImplFindItem( mpMainSet
, nId
, nDbgDummy
), "SplitWindow::RemoveItem() - Id not found" );
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
3009 ImplDeleteSet( pItem
->mpSet
);
3013 pSet
->mbCalcPix
= TRUE
;
3014 if ( pSet
->mnItems
)
3016 memmove( pSet
->mpItems
+nPos
, pSet
->mpItems
+nPos
+1,
3017 (pSet
->mnItems
-nPos
)*sizeof( ImplSplitItem
) );
3021 delete[] pSet
->mpItems
;
3022 pSet
->mpItems
= NULL
;
3027 // Window erst hier loeschen, um weniger Paints zu haben
3030 // Fenster wieder herstellen
3031 if ( bHide
|| (pOrgParent
!= this) )
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
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
,
3083 ImplSplitSet
* pSet
= ImplFindSet( mpMainSet
, nSetId
);
3087 ImplSetSplitSize( pSet
, nSplitSize
);
3089 pSet
->mnSplitSize
= nSplitSize
;
3094 // -----------------------------------------------------------------------
3096 long SplitWindow::GetSplitSize( USHORT nSetId
) const
3098 ImplSplitSet
* pSet
= ImplFindSet( mpMainSet
, nSetId
);
3100 return pSet
->mnSplitSize
;
3105 // -----------------------------------------------------------------------
3107 void SplitWindow::SetItemBackground( USHORT nSetId
)
3110 SetItemBackground( nSetId
, aWall
);
3113 // -----------------------------------------------------------------------
3115 void SplitWindow::SetItemBackground( USHORT nSetId
, const Wallpaper
& rWallpaper
)
3117 ImplSplitSet
* pSet
= ImplFindSet( mpMainSet
, nSetId
);
3121 BOOL bUpdate
= TRUE
;
3123 if ( rWallpaper
.GetStyle() == WALLPAPER_NULL
)
3125 if ( pSet
->mpWallpaper
)
3127 delete pSet
->mpWallpaper
;
3128 pSet
->mpWallpaper
= NULL
;
3135 // Ab jetzt muss immer invalidiert werden
3136 mbInvalidate
= TRUE
;
3138 if ( !pSet
->mpWallpaper
)
3139 pSet
->mpWallpaper
= new Wallpaper( rWallpaper
);
3141 *(pSet
->mpWallpaper
) = rWallpaper
;
3144 // Beim MainSet koennen wir den Background umsetzen
3145 if ( pSet
== mpMainSet
)
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
);
3168 // -----------------------------------------------------------------------
3170 BOOL
SplitWindow::IsItemBackground( USHORT nSetId
) const
3172 ImplSplitSet
* pSet
= ImplFindSet( mpMainSet
, nSetId
);
3174 if ( pSet
&& pSet
->mpWallpaper
)
3180 // -----------------------------------------------------------------------
3182 void SplitWindow::SetItemBitmap( USHORT nSetId
, const Bitmap
& rBitmap
)
3184 ImplSplitSet
* pSet
= ImplFindSet( mpMainSet
, nSetId
);
3188 BOOL bUpdate
= TRUE
;
3192 if ( pSet
->mpBitmap
)
3194 delete pSet
->mpBitmap
;
3195 pSet
->mpBitmap
= NULL
;
3202 // Ab jetzt muss immer invalidiert werden
3203 mbInvalidate
= TRUE
;
3205 if ( !pSet
->mpBitmap
)
3206 pSet
->mpBitmap
= new Bitmap( rBitmap
);
3208 *(pSet
->mpBitmap
) = rBitmap
;
3211 // Beim MainSet koennen wir den Background umsetzen
3212 if ( pSet
== mpMainSet
)
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
);
3235 // -----------------------------------------------------------------------
3237 void SplitWindow::SplitItem( USHORT nId
, long nNewSize
,
3238 BOOL bPropSmall
, BOOL bPropGreat
)
3248 ImplSplitSet
* pSet
= ImplFindItem( mpBaseSet
, nId
, nPos
);
3249 ImplSplitItem
* pItems
;
3254 nItems
= pSet
->mnItems
;
3255 pItems
= pSet
->mpItems
;
3259 pItems
[nPos
].mnSize
= nNewSize
;
3263 nDelta
= nNewSize
-pItems
[nPos
].mnPixSize
;
3267 // Bereich berechnen, der beim Splitten betroffen sein kann
3270 for ( i
= 0; i
< nItems
; i
++ )
3272 if ( pItems
[i
].mbFixed
)
3281 // Wenn das Fenster sizeable ist, wird das TopSet anders behandelt
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
)) )
3306 else if ( nPos
>= nMax
)
3311 else if ( nPos
&& (nPos
>= pSet
->mnItems
-1) )
3315 BOOL bTemp
= bPropSmall
;
3316 bPropSmall
= bPropGreat
;
3320 // Jetzt die Fenster splitten
3327 nTempDelta
= nDelta
;
3335 pItems
[n
].mnPixSize
++;
3342 while ( nTempDelta
);
3345 pItems
[nPos
+1].mnPixSize
-= nDelta
;
3357 if ( nDelta
&& pItems
[n
-1].mnPixSize
)
3359 pItems
[n
-1].mnPixSize
--;
3374 if ( pItems
[n
-1].mnPixSize
+nDelta
< 0 )
3376 nDelta
+= pItems
[n
-1].mnPixSize
;
3377 pItems
[n
-1].mnPixSize
= 0;
3381 pItems
[n
-1].mnPixSize
+= nDelta
;
3396 nTempDelta
= nDelta
;
3404 pItems
[n
-1].mnPixSize
++;
3411 while ( nTempDelta
);
3414 pItems
[nPos
].mnPixSize
+= nDelta
;
3426 if ( nDelta
&& pItems
[n
].mnPixSize
)
3428 pItems
[n
].mnPixSize
--;
3443 if ( pItems
[n
].mnPixSize
-nDelta
< 0 )
3445 nDelta
-= pItems
[n
].mnPixSize
;
3446 pItems
[n
].mnPixSize
= 0;
3450 pItems
[n
].mnPixSize
-= nDelta
;
3460 // Original-Groessen updaten
3461 ImplCalcLogSize( pItems
, nItems
);
3466 // -----------------------------------------------------------------------
3468 void SplitWindow::SetItemSize( USHORT nId
, long nNewSize
)
3471 ImplSplitSet
* pSet
= ImplFindItem( mpBaseSet
, nId
, nPos
);
3472 ImplSplitItem
* pItem
;
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
;
3488 // -----------------------------------------------------------------------
3490 long SplitWindow::GetItemSize( USHORT nId
) const
3493 ImplSplitSet
* pSet
= ImplFindItem( mpBaseSet
, nId
, nPos
);
3496 return pSet
->mpItems
[nPos
].mnSize
;
3501 // -----------------------------------------------------------------------
3503 long SplitWindow::GetItemSize( USHORT nId
, SplitWindowItemBits nBits
) const
3506 ImplSplitSet
* pSet
= ImplFindItem( mpBaseSet
, nId
, nPos
);
3510 if ( nBits
== pSet
->mpItems
[nPos
].mnBits
)
3511 return pSet
->mpItems
[nPos
].mnSize
;
3514 ((SplitWindow
*)this)->ImplCalcLayout();
3518 ImplSplitItem
* pItems
;
3520 SplitWindowItemBits nTempBits
;
3522 nItems
= pSet
->mnItems
;
3523 pItems
= pSet
->mpItems
;
3524 for ( i
= 0; i
< nItems
; i
++ )
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
)
3539 return (pItems
[nPos
].mnPixSize
+(nRelSize
/2))/nRelSize
;
3543 else if ( nBits
& SWIB_PERCENTSIZE
)
3546 return (pItems
[nPos
].mnPixSize
*100)/nPerSize
;
3551 return pItems
[nPos
].mnPixSize
;
3558 // -----------------------------------------------------------------------
3560 void SplitWindow::SetItemBits( USHORT nId
, SplitWindowItemBits nNewBits
)
3563 ImplSplitSet
* pSet
= ImplFindItem( mpBaseSet
, nId
, nPos
);
3564 ImplSplitItem
* pItem
;
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
;
3582 // -----------------------------------------------------------------------
3584 SplitWindowItemBits
SplitWindow::GetItemBits( USHORT nId
) const
3587 ImplSplitSet
* pSet
= ImplFindItem( mpBaseSet
, nId
, nPos
);
3590 return pSet
->mpItems
[nPos
].mnBits
;
3595 // -----------------------------------------------------------------------
3597 Window
* SplitWindow::GetItemWindow( USHORT nId
) const
3600 ImplSplitSet
* pSet
= ImplFindItem( mpBaseSet
, nId
, nPos
);
3603 return pSet
->mpItems
[nPos
].mpWindow
;
3608 // -----------------------------------------------------------------------
3610 USHORT
SplitWindow::GetSet( USHORT nId
) const
3613 ImplSplitSet
* pSet
= ImplFindItem( mpBaseSet
, nId
, nPos
);
3621 // -----------------------------------------------------------------------
3623 BOOL
SplitWindow::GetSet( USHORT nId
, USHORT
& rSetId
, USHORT
& rPos
) const
3625 ImplSplitSet
* pSet
= ImplFindItem( mpBaseSet
, nId
, rPos
);
3628 rSetId
= pSet
->mnId
;
3635 // -----------------------------------------------------------------------
3637 BOOL
SplitWindow::IsItemValid( USHORT nId
) const
3640 ImplSplitSet
* pSet
= ImplFindItem( mpBaseSet
, nId
, nPos
);
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
;
3671 for ( USHORT i
= 0; i
< pSet
->mnItems
; i
++ )
3673 if ( pSet
->mpItems
[i
].mnId
== nId
)
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
;
3695 // -----------------------------------------------------------------------
3697 USHORT
SplitWindow::GetItemCount( USHORT nSetId
) const
3699 ImplSplitSet
* pSet
= ImplFindSet( mpBaseSet
, nSetId
);
3701 return pSet
->mnItems
;
3706 // -----------------------------------------------------------------------
3708 void SplitWindow::ImplNewAlign()
3713 mbBottomRight
= FALSE
;
3715 else if ( meAlign
== WINDOWALIGN_TOP
)
3718 mbBottomRight
= FALSE
;
3720 else if ( meAlign
== WINDOWALIGN_BOTTOM
)
3723 mbBottomRight
= TRUE
;
3725 else if ( meAlign
== WINDOWALIGN_LEFT
)
3728 mbBottomRight
= FALSE
;
3730 else if ( meAlign
== WINDOWALIGN_RIGHT
)
3733 mbBottomRight
= TRUE
;
3736 if ( mnWinStyle
& WB_BORDER
)
3738 ImplCalcBorder( meAlign
, mbNoAlign
, mnLeftBorder
, mnTopBorder
,
3739 mnRightBorder
, mnBottomBorder
);
3742 if ( IsReallyVisible() && IsUpdateMode() )
3747 // -----------------------------------------------------------------------
3749 void SplitWindow::SetNoAlign( BOOL bNoAlign
)
3751 bNoAlign
= bNoAlign
!= 0;
3752 if ( mbNoAlign
!= bNoAlign
)
3754 mbNoAlign
= bNoAlign
;
3759 // -----------------------------------------------------------------------
3761 void SplitWindow::SetAlign( WindowAlign eNewAlign
)
3763 if ( meAlign
!= eNewAlign
)
3765 meAlign
= eNewAlign
;
3770 // -----------------------------------------------------------------------
3772 Size
SplitWindow::CalcWindowSizePixel( const Size
& rSize
, WindowAlign eAlign
,
3773 WinBits nWinStyle
, BOOL bExtra
)
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;
3791 aSize
.Height() += SPLITWIN_SPLITSIZEEXLN
;
3795 aSize
.Width() += SPLITWIN_SPLITSIZE
-2;
3797 aSize
.Width() += SPLITWIN_SPLITSIZEEXLN
;
3804 // -----------------------------------------------------------------------
3806 void SplitWindow::ShowAutoHideButton( BOOL bShow
)
3812 // -----------------------------------------------------------------------
3814 void SplitWindow::ShowFadeInHideButton( BOOL bShow
)
3820 // -----------------------------------------------------------------------
3822 void SplitWindow::ShowFadeOutButton( BOOL bShow
)
3828 // -----------------------------------------------------------------------
3830 void SplitWindow::SetAutoHideState( BOOL bAutoHide
)
3832 mbAutoHideIn
= bAutoHide
;
3833 if ( IsReallyVisible() )
3836 ImplGetAutoHideRect( aRect
);
3837 Invalidate( aRect
);
3841 // -----------------------------------------------------------------------
3843 long SplitWindow::GetFadeInSize() const
3848 n
= mnTopBorder
+mnBottomBorder
;
3850 n
= mnLeftBorder
+mnRightBorder
;
3852 return n
+SPLITWIN_SPLITSIZE
+SPLITWIN_SPLITSIZEEX
-2;
3855 // -----------------------------------------------------------------------
3857 Rectangle
SplitWindow::GetAutoHideRect() const
3860 ImplGetAutoHideRect( aRect
, TRUE
);
3864 // -----------------------------------------------------------------------
3866 Rectangle
SplitWindow::GetFadeInRect() const
3869 ImplGetFadeInRect( aRect
, TRUE
);
3873 // -----------------------------------------------------------------------
3875 Rectangle
SplitWindow::GetFadeOutRect() const
3878 ImplGetFadeOutRect( aRect
, TRUE
);