LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/vcl/source/window - splitwin.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 817 1746 46.8 %
Date: 2013-07-09 Functions: 52 80 65.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10