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

Generated by: LCOV version 1.10