LCOV - code coverage report
Current view: top level - vcl/source/window - decoview.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 290 619 46.8 %
Date: 2014-04-11 Functions: 10 12 83.3 %
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 <vcl/settings.hxx>
      21             : #include <vcl/outdev.hxx>
      22             : #include <vcl/decoview.hxx>
      23             : #include <vcl/window.hxx>
      24             : #include <vcl/ctrl.hxx>
      25             : 
      26             : #define BUTTON_DRAW_FLATTEST    (BUTTON_DRAW_FLAT |             \
      27             :                                  BUTTON_DRAW_PRESSED |          \
      28             :                                  BUTTON_DRAW_CHECKED |          \
      29             :                                  BUTTON_DRAW_HIGHLIGHT)
      30             : 
      31             : namespace {
      32             : 
      33       31251 : long AdjustRectToSquare( Rectangle &rRect )
      34             : {
      35       31251 :     const long nWidth = rRect.GetWidth();
      36       31251 :     const long nHeight = rRect.GetHeight();
      37       31251 :     long nSide = std::min( nWidth, nHeight );
      38             : 
      39       31251 :     if ( nSide && !(nSide & 1) )
      40             :     {
      41             :         // we prefer an odd size
      42       30760 :         --nSide;
      43             :     }
      44             : 
      45             :     // Make the rectangle a square
      46       31251 :     rRect.SetSize( Size( nSide, nSide ) );
      47             : 
      48             :     // and place it at the center of the original rectangle
      49       31251 :     rRect.Move( (nWidth-nSide)/2, (nHeight-nSide)/2 );
      50             : 
      51       31251 :     return nSide;
      52             : }
      53             : 
      54       31251 : void ImplDrawSymbol( OutputDevice* pDev, Rectangle nRect, const SymbolType eType  )
      55             : {
      56       31251 :     const long nSide = AdjustRectToSquare( nRect );
      57             : 
      58       31251 :     if ( !nSide ) return;
      59       31251 :     if ( nSide==1 )
      60             :     {
      61           0 :         pDev->DrawPixel( Point( nRect.Left(), nRect.Top() ) );
      62           0 :         return;
      63             :     }
      64             : 
      65             :     // Precalculate some values
      66       31251 :     const long n2 = nSide/2;
      67       31251 :     const long n4 = (n2+1)/2;
      68       31251 :     const long n8 = (n4+1)/2;
      69       31251 :     const Point aCenter = nRect.Center();
      70             : 
      71       31251 :     switch ( eType )
      72             :     {
      73             :         case SYMBOL_ARROW_UP:
      74           0 :             pDev->DrawPixel( Point( aCenter.X(), nRect.Top() ) );
      75           0 :             for ( long i=1; i <= n2; ++i )
      76             :             {
      77           0 :                 ++nRect.Top();
      78           0 :                 pDev->DrawLine( Point( aCenter.X()-i, nRect.Top() ),
      79           0 :                                 Point( aCenter.X()+i, nRect.Top() ) );
      80             :             }
      81           0 :             pDev->DrawRect( Rectangle( aCenter.X()-n8, nRect.Top()+1,
      82           0 :                                        aCenter.X()+n8, nRect.Bottom() ) );
      83           0 :             break;
      84             : 
      85             :         case SYMBOL_ARROW_DOWN:
      86           0 :             pDev->DrawPixel( Point( aCenter.X(), nRect.Bottom() ) );
      87           0 :             for ( long i=1; i <= n2; ++i )
      88             :             {
      89           0 :                 --nRect.Bottom();
      90           0 :                 pDev->DrawLine( Point( aCenter.X()-i, nRect.Bottom() ),
      91           0 :                                 Point( aCenter.X()+i, nRect.Bottom() ) );
      92             :             }
      93           0 :             pDev->DrawRect( Rectangle( aCenter.X()-n8, nRect.Top(),
      94           0 :                                        aCenter.X()+n8, nRect.Bottom()-1 ) );
      95           0 :             break;
      96             : 
      97             :         case SYMBOL_ARROW_LEFT:
      98           0 :             pDev->DrawPixel( Point( nRect.Left(), aCenter.Y() ) );
      99           0 :             for ( long i=1; i <= n2; ++i )
     100             :             {
     101           0 :                 ++nRect.Left();
     102           0 :                 pDev->DrawLine( Point( nRect.Left(), aCenter.Y()-i ),
     103           0 :                                 Point( nRect.Left(), aCenter.Y()+i ) );
     104             :             }
     105           0 :             pDev->DrawRect( Rectangle( nRect.Left()+1, aCenter.Y()-n8,
     106           0 :                                        nRect.Right(), aCenter.Y()+n8 ) );
     107           0 :             break;
     108             : 
     109             :         case SYMBOL_ARROW_RIGHT:
     110           0 :             pDev->DrawPixel( Point( nRect.Right(), aCenter.Y() ) );
     111           0 :             for ( long i=1; i <= n2; ++i )
     112             :             {
     113           0 :                 --nRect.Right();
     114           0 :                 pDev->DrawLine( Point( nRect.Right(), aCenter.Y()-i ),
     115           0 :                                 Point( nRect.Right(), aCenter.Y()+i ) );
     116             :             }
     117           0 :             pDev->DrawRect( Rectangle( nRect.Left(), aCenter.Y()-n8,
     118           0 :                                        nRect.Right()-1, aCenter.Y()+n8 ) );
     119           0 :             break;
     120             : 
     121             :         case SYMBOL_SPIN_UP:
     122        8951 :             nRect.Top() += n4;
     123        8951 :             pDev->DrawPixel( Point( aCenter.X(), nRect.Top() ) );
     124       35800 :             for ( long i=1; i <= n2; ++i )
     125             :             {
     126       26849 :                 ++nRect.Top();
     127       53698 :                 pDev->DrawLine( Point( aCenter.X()-i, nRect.Top() ),
     128       80547 :                                 Point( aCenter.X()+i, nRect.Top() ) );
     129             :             }
     130        8951 :             break;
     131             : 
     132             :         case SYMBOL_SPIN_DOWN:
     133        9207 :             nRect.Bottom() -= n4;
     134        9207 :             pDev->DrawPixel( Point( aCenter.X(), nRect.Bottom() ) );
     135       37029 :             for ( long i=1; i <= n2; ++i )
     136             :             {
     137       27822 :                 --nRect.Bottom();
     138       55644 :                 pDev->DrawLine( Point( aCenter.X()-i, nRect.Bottom() ),
     139       83466 :                                 Point( aCenter.X()+i, nRect.Bottom() ) );
     140             :             }
     141        9207 :             break;
     142             : 
     143             :         case SYMBOL_SPIN_LEFT:
     144             :         case SYMBOL_FIRST:
     145             :         case SYMBOL_PREV:
     146             :         case SYMBOL_REVERSEPLAY:
     147        8358 :             nRect.Left() += n4;
     148        8358 :             if ( eType==SYMBOL_FIRST )
     149             :             {
     150         780 :                 pDev->DrawLine( Point( nRect.Left(), nRect.Top() ),
     151        1170 :                                 Point( nRect.Left(), nRect.Bottom() ) );
     152         390 :                 ++nRect.Left();
     153             :             }
     154        8358 :             pDev->DrawPixel( Point( nRect.Left(), aCenter.Y() ) );
     155       33768 :             for ( long i=1; i <= n2; ++i )
     156             :             {
     157       25410 :                 ++nRect.Left();
     158       50820 :                 pDev->DrawLine( Point( nRect.Left(), aCenter.Y()-i ),
     159       76230 :                                 Point( nRect.Left(), aCenter.Y()+i ) );
     160             :             }
     161        8358 :             break;
     162             : 
     163             :         case SYMBOL_SPIN_RIGHT:
     164             :         case SYMBOL_LAST:
     165             :         case SYMBOL_NEXT:
     166             :         case SYMBOL_PLAY:
     167        4727 :             nRect.Right() -= n4;
     168        4727 :             if ( eType==SYMBOL_LAST )
     169             :             {
     170         800 :                 pDev->DrawLine( Point( nRect.Right(), nRect.Top() ),
     171        1200 :                                 Point( nRect.Right(), nRect.Bottom() ) );
     172         400 :                 --nRect.Right();
     173             :             }
     174        4727 :             pDev->DrawPixel( Point( nRect.Right(), aCenter.Y() ) );
     175       19058 :             for ( long i=1; i <= n2; ++i )
     176             :             {
     177       14331 :                 --nRect.Right();
     178       28662 :                 pDev->DrawLine( Point( nRect.Right(), aCenter.Y()-i ),
     179       42993 :                                 Point( nRect.Right(), aCenter.Y()+i ) );
     180             :             }
     181        4727 :             break;
     182             : 
     183             :         case SYMBOL_PAGEUP:
     184           0 :             pDev->DrawPixel( Point( aCenter.X(), nRect.Top() ) );
     185           0 :             pDev->DrawPixel( Point( aCenter.X(), nRect.Top()+n2 ) );
     186           0 :             for ( long i=1; i < n2; ++i )
     187             :             {
     188           0 :                 ++nRect.Top();
     189           0 :                 pDev->DrawLine( Point( aCenter.X()-i, nRect.Top() ),
     190           0 :                                 Point( aCenter.X()+i, nRect.Top() ) );
     191           0 :                 pDev->DrawLine( Point( aCenter.X()-i, nRect.Top()+n2 ),
     192           0 :                                 Point( aCenter.X()+i, nRect.Top()+n2 ) );
     193             :             }
     194           0 :             break;
     195             : 
     196             :         case SYMBOL_PAGEDOWN:
     197           0 :             pDev->DrawPixel( Point( aCenter.X(), nRect.Bottom() ) );
     198           0 :             pDev->DrawPixel( Point( aCenter.X(), nRect.Bottom()-n2 ) );
     199           0 :             for ( long i=1; i < n2; ++i )
     200             :             {
     201           0 :                 --nRect.Bottom();
     202           0 :                 pDev->DrawLine( Point( aCenter.X()-i, nRect.Bottom() ),
     203           0 :                                 Point( aCenter.X()+i, nRect.Bottom() ) );
     204           0 :                 pDev->DrawLine( Point( aCenter.X()-i, nRect.Bottom()-n2 ),
     205           0 :                                 Point( aCenter.X()+i, nRect.Bottom()-n2 ) );
     206             :             }
     207           0 :             break;
     208             : 
     209             :         case SYMBOL_RADIOCHECKMARK:
     210             :         case SYMBOL_RECORD:
     211             :             {
     212             :                 // Midpoint circle algorithm
     213           0 :                 long x = 0;
     214           0 :                 long y = n2;
     215           0 :                 long p = 1 - n2;
     216             :                 // Draw central line
     217           0 :                 pDev->DrawLine( Point( aCenter.X(), aCenter.Y()-y ),
     218           0 :                                 Point( aCenter.X(), aCenter.Y()+y ) );
     219           0 :                 while ( x<y )
     220             :                 {
     221           0 :                     if ( p>=0 )
     222             :                     {
     223             :                         // Draw vertical lines close to sides
     224           0 :                         pDev->DrawLine( Point( aCenter.X()+y, aCenter.Y()-x ),
     225           0 :                                         Point( aCenter.X()+y, aCenter.Y()+x ) );
     226           0 :                         pDev->DrawLine( Point( aCenter.X()-y, aCenter.Y()-x ),
     227           0 :                                         Point( aCenter.X()-y, aCenter.Y()+x ) );
     228           0 :                         --y;
     229           0 :                         p -= 2*y;
     230             :                     }
     231           0 :                     ++x;
     232           0 :                     p += 2*x+1;
     233             :                     // Draw vertical lines close to center
     234           0 :                     pDev->DrawLine( Point( aCenter.X()-x, aCenter.Y()-y ),
     235           0 :                                     Point( aCenter.X()-x, aCenter.Y()+y ) );
     236           0 :                     pDev->DrawLine( Point( aCenter.X()+x, aCenter.Y()-y ),
     237           0 :                                     Point( aCenter.X()+x, aCenter.Y()+y ) );
     238             :                 }
     239             :             }
     240           0 :             break;
     241             : 
     242             :         case SYMBOL_STOP:
     243           0 :             pDev->DrawRect( nRect );
     244           0 :             break;
     245             : 
     246             :         case SYMBOL_PAUSE:
     247           0 :             pDev->DrawRect( Rectangle ( nRect.Left(), nRect.Top(),
     248           0 :                                         aCenter.X()-n8, nRect.Bottom() ) );
     249           0 :             pDev->DrawRect( Rectangle ( aCenter.X()+n8, nRect.Top(),
     250           0 :                                         nRect.Right(), nRect.Bottom() ) );
     251           0 :             break;
     252             : 
     253             :         case SYMBOL_WINDSTART:
     254           0 :             pDev->DrawLine( Point( nRect.Left(), aCenter.Y()-n2+1 ),
     255           0 :                             Point( nRect.Left(), aCenter.Y()+n2-1 ) );
     256           0 :             ++nRect.Left();
     257             :             // Intentional fall-through
     258             :         case SYMBOL_WINDBACKWARD:
     259           0 :             pDev->DrawPixel( Point( nRect.Left(), aCenter.Y() ) );
     260           0 :             pDev->DrawPixel( Point( nRect.Left()+n2, aCenter.Y() ) );
     261           0 :             for ( long i=1; i < n2; ++i )
     262             :             {
     263           0 :                 ++nRect.Left();
     264           0 :                 pDev->DrawLine( Point( nRect.Left(), aCenter.Y()-i ),
     265           0 :                                 Point( nRect.Left(), aCenter.Y()+i ) );
     266           0 :                 pDev->DrawLine( Point( nRect.Left()+n2, aCenter.Y()-i ),
     267           0 :                                 Point( nRect.Left()+n2, aCenter.Y()+i ) );
     268             :             }
     269           0 :             break;
     270             : 
     271             :         case SYMBOL_WINDEND:
     272           0 :             pDev->DrawLine( Point( nRect.Right(), aCenter.Y()-n2+1 ),
     273           0 :                             Point( nRect.Right(), aCenter.Y()+n2-1 ) );
     274           0 :             --nRect.Right();
     275             :             // Intentional fall-through
     276             :         case SYMBOL_WINDFORWARD:
     277           0 :             pDev->DrawPixel( Point( nRect.Right(), aCenter.Y() ) );
     278           0 :             pDev->DrawPixel( Point( nRect.Right()-n2, aCenter.Y() ) );
     279           0 :             for ( long i=1; i < n2; ++i )
     280             :             {
     281           0 :                 --nRect.Right();
     282           0 :                 pDev->DrawLine( Point( nRect.Right(), aCenter.Y()-i ),
     283           0 :                                 Point( nRect.Right(), aCenter.Y()+i ) );
     284           0 :                 pDev->DrawLine( Point( nRect.Right()-n2, aCenter.Y()-i ),
     285           0 :                                 Point( nRect.Right()-n2, aCenter.Y()+i ) );
     286             :             }
     287           0 :             break;
     288             : 
     289             :         case SYMBOL_CLOSE:
     290           0 :             pDev->DrawLine( Point( nRect.Left(), nRect.Top() ),
     291           0 :                             Point( nRect.Right(), nRect.Bottom() ) );
     292           0 :             pDev->DrawLine( Point( nRect.Left(), nRect.Bottom() ),
     293           0 :                             Point( nRect.Right(), nRect.Top() ) );
     294           0 :             for ( long i=1; i<n8; ++i )
     295             :             {
     296           0 :                 pDev->DrawLine( Point( nRect.Left()+i, nRect.Top() ),
     297           0 :                                 Point( nRect.Right(), nRect.Bottom()-i ) );
     298           0 :                 pDev->DrawLine( Point( nRect.Left(), nRect.Top()+i ),
     299           0 :                                 Point( nRect.Right()-i, nRect.Bottom() ) );
     300           0 :                 pDev->DrawLine( Point( nRect.Left()+i, nRect.Bottom() ),
     301           0 :                                 Point( nRect.Right(), nRect.Top()+i ) );
     302           0 :                 pDev->DrawLine( Point( nRect.Left(), nRect.Bottom()-i ),
     303           0 :                                 Point( nRect.Right()-i, nRect.Top() ) );
     304             :             }
     305           0 :             break;
     306             : 
     307             :         case SYMBOL_ROLLDOWN:
     308           0 :             pDev->DrawLine( Point( nRect.Left(), nRect.Top() ),
     309           0 :                             Point( nRect.Left(), nRect.Bottom() ) );
     310           0 :             pDev->DrawLine( Point( nRect.Right(), nRect.Top() ),
     311           0 :                             Point( nRect.Right(), nRect.Bottom() ) );
     312           0 :             pDev->DrawLine( Point( nRect.Left(), nRect.Bottom() ),
     313           0 :                             Point( nRect.Right(), nRect.Bottom() ) );
     314             :             // Intentional fall-through
     315             :         case SYMBOL_ROLLUP:
     316           0 :             pDev->DrawRect( Rectangle( nRect.Left(), nRect.Top(),
     317           0 :                                        nRect.Right(), nRect.Top()+n8 ) );
     318           0 :             break;
     319             : 
     320             :         case SYMBOL_CHECKMARK:
     321             :             {
     322           8 :                 long n3 = nSide/3;
     323           8 :                 nRect.Top() -= n3/2;
     324           8 :                 nRect.Bottom() -= n3/2;
     325             :                 // #106953# never mirror checkmarks
     326           8 :                 if ( pDev->HasMirroredGraphics() && pDev->IsRTLEnabled() )
     327             :                 {
     328             :                     // Draw a mirrored checkmark so that it looks "normal" in a
     329             :                     // mirrored graphics device (double mirroring!)
     330           0 :                     pDev->DrawLine( Point( nRect.Right(), nRect.Bottom()-n3 ),
     331           0 :                                     Point( nRect.Right()-n3, nRect.Bottom() ) );
     332           0 :                     pDev->DrawLine( Point( nRect.Right()-n3, nRect.Bottom() ),
     333           0 :                                     Point( nRect.Left(), nRect.Top()+n3 ) );
     334           0 :                     ++nRect.Top();
     335           0 :                     ++nRect.Bottom();
     336           0 :                     pDev->DrawLine( Point( nRect.Right(), nRect.Bottom()-n3 ),
     337           0 :                                     Point( nRect.Right()-n3, nRect.Bottom() ) );
     338           0 :                     pDev->DrawLine( Point( nRect.Right()-n3, nRect.Bottom() ),
     339           0 :                                     Point( nRect.Left(), nRect.Top()+n3 ) );
     340             :                 }
     341             :                 else
     342             :                 {
     343          16 :                     pDev->DrawLine( Point( nRect.Left(), nRect.Bottom()-n3 ),
     344          24 :                                     Point( nRect.Left()+n3, nRect.Bottom() ) );
     345          16 :                     pDev->DrawLine( Point( nRect.Left()+n3, nRect.Bottom() ),
     346          24 :                                     Point( nRect.Right(), nRect.Top()+n3 ) );
     347           8 :                     ++nRect.Top();
     348           8 :                     ++nRect.Bottom();
     349          16 :                     pDev->DrawLine( Point( nRect.Left(), nRect.Bottom()-n3 ),
     350          24 :                                     Point( nRect.Left()+n3, nRect.Bottom() ) );
     351          16 :                     pDev->DrawLine( Point( nRect.Left()+n3, nRect.Bottom() ),
     352          24 :                                     Point( nRect.Right(), nRect.Top()+n3 ) );
     353             :                 }
     354             :             }
     355           8 :             break;
     356             : 
     357             :         case SYMBOL_SPIN_UPDOWN:
     358           0 :             pDev->DrawPixel( Point( aCenter.X(), nRect.Top() ) );
     359           0 :             pDev->DrawPixel( Point( aCenter.X(), nRect.Bottom() ) );
     360           0 :             for ( long i=1; i < n2; ++i )
     361             :             {
     362           0 :                 ++nRect.Top();
     363           0 :                 --nRect.Bottom();
     364           0 :                 pDev->DrawLine( Point( aCenter.X()-i, nRect.Top() ),
     365           0 :                                 Point( aCenter.X()+i, nRect.Top() ) );
     366           0 :                 pDev->DrawLine( Point( aCenter.X()-i, nRect.Bottom() ),
     367           0 :                                 Point( aCenter.X()+i, nRect.Bottom() ) );
     368             :             }
     369           0 :             break;
     370             : 
     371             :         case SYMBOL_FLOAT:
     372           0 :             nRect.Right() -= n4;
     373           0 :             nRect.Top() += n4+1;
     374           0 :             pDev->DrawRect( Rectangle( nRect.Left(), nRect.Top(),
     375           0 :                                        nRect.Right(), nRect.Top()+n8 ) );
     376           0 :             pDev->DrawLine( Point( nRect.Left(), nRect.Top()+n8 ),
     377           0 :                             Point( nRect.Left(), nRect.Bottom() ) );
     378           0 :             pDev->DrawLine( Point( nRect.Left(), nRect.Bottom() ),
     379           0 :                             Point( nRect.Right(), nRect.Bottom() ) );
     380           0 :             pDev->DrawLine( Point( nRect.Right(), nRect.Top()+n8 ),
     381           0 :                             Point( nRect.Right(), nRect.Bottom() ) );
     382           0 :             nRect.Right() += n4;
     383           0 :             nRect.Top() -= n4+1;
     384           0 :             nRect.Left() += n4;
     385           0 :             nRect.Bottom() -= n4+1;
     386           0 :             pDev->DrawRect( Rectangle( nRect.Left(), nRect.Top(),
     387           0 :                                        nRect.Right(), nRect.Top()+n8 ) );
     388           0 :             pDev->DrawLine( Point( nRect.Left(), nRect.Top()+n8 ),
     389           0 :                             Point( nRect.Left(), nRect.Bottom() ) );
     390           0 :             pDev->DrawLine( Point( nRect.Left(), nRect.Bottom() ),
     391           0 :                             Point( nRect.Right(), nRect.Bottom() ) );
     392           0 :             pDev->DrawLine( Point( nRect.Right(), nRect.Top()+n8 ),
     393           0 :                             Point( nRect.Right(), nRect.Bottom() ) );
     394           0 :             break;
     395             : 
     396             :         case SYMBOL_DOCK:
     397           0 :             pDev->DrawLine( Point( nRect.Left(), nRect.Top() ),
     398           0 :                             Point( nRect.Right(), nRect.Top() ) );
     399           0 :             pDev->DrawLine( Point( nRect.Left(), nRect.Top() ),
     400           0 :                             Point( nRect.Left(), nRect.Bottom() ) );
     401           0 :             pDev->DrawLine( Point( nRect.Left(), nRect.Bottom() ),
     402           0 :                             Point( nRect.Right(), nRect.Bottom() ) );
     403           0 :             pDev->DrawLine( Point( nRect.Right(), nRect.Top() ),
     404           0 :                             Point( nRect.Right(), nRect.Bottom() ) );
     405           0 :             break;
     406             : 
     407             :         case SYMBOL_HIDE:
     408           0 :             pDev->DrawRect( Rectangle( nRect.Left()+n8, nRect.Bottom()-n8,
     409           0 :                                        nRect.Right()-n8, nRect.Bottom() ) );
     410           0 :             break;
     411             : 
     412             :         case SYMBOL_PLUS:
     413           0 :             pDev->DrawRect( Rectangle( nRect.Left(), aCenter.Y()-n8,
     414           0 :                                        nRect.Right(), aCenter.Y()+n8 ) );
     415           0 :             pDev->DrawRect( Rectangle( aCenter.X()-n8, nRect.Top(),
     416           0 :                                        aCenter.X()+n8, nRect.Bottom() ) );
     417           0 :             break;
     418             :     }
     419             : }
     420             : 
     421        1259 : void ImplDrawDPILineRect( OutputDevice *const pDev, Rectangle& rRect,
     422             :                           const Color *const pColor, const bool bRound = false )
     423             : {
     424        1259 :     long nLineWidth = pDev->ImplGetDPIX()/300;
     425        1259 :     long nLineHeight = pDev->ImplGetDPIY()/300;
     426        1259 :     if ( !nLineWidth )
     427        1259 :         nLineWidth = 1;
     428        1259 :     if ( !nLineHeight )
     429        1259 :         nLineHeight = 1;
     430             : 
     431        1259 :     if ( pColor )
     432             :     {
     433         820 :         if ( (nLineWidth == 1) && (nLineHeight == 1) )
     434             :         {
     435         820 :             pDev->SetLineColor( *pColor );
     436        1640 :             if( bRound )
     437             :             {
     438           0 :                 pDev->DrawLine( Point( rRect.Left()+1, rRect.Top()), Point( rRect.Right()-1, rRect.Top()) );
     439           0 :                 pDev->DrawLine( Point( rRect.Left()+1, rRect.Bottom()), Point( rRect.Right()-1, rRect.Bottom()) );
     440           0 :                 pDev->DrawLine( Point( rRect.Left(), rRect.Top()+1), Point( rRect.Left(), rRect.Bottom()-1) );
     441           0 :                 pDev->DrawLine( Point( rRect.Right(), rRect.Top()+1), Point( rRect.Right(), rRect.Bottom()-1) );
     442             :             }
     443             :             else
     444             :             {
     445         820 :                 pDev->SetFillColor();
     446         820 :                 pDev->DrawRect( rRect );
     447             :             }
     448             :         }
     449             :         else
     450             :         {
     451           0 :             const long nWidth = rRect.GetWidth();
     452           0 :             const long nHeight = rRect.GetHeight();
     453           0 :             pDev->SetLineColor();
     454           0 :             pDev->SetFillColor( *pColor );
     455           0 :             pDev->DrawRect( Rectangle( rRect.TopLeft(), Size( nWidth, nLineHeight ) ) );
     456           0 :             pDev->DrawRect( Rectangle( rRect.TopLeft(), Size( nLineWidth, nHeight ) ) );
     457           0 :             pDev->DrawRect( Rectangle( Point( rRect.Left(), rRect.Bottom()-nLineHeight ),
     458           0 :                                        Size( nWidth, nLineHeight ) ) );
     459           0 :             pDev->DrawRect( Rectangle( Point( rRect.Right()-nLineWidth, rRect.Top() ),
     460           0 :                                        Size( nLineWidth, nHeight ) ) );
     461             :         }
     462             :     }
     463             : 
     464        1259 :     rRect.Left()   += nLineWidth;
     465        1259 :     rRect.Top()    += nLineHeight;
     466        1259 :     rRect.Right()  -= nLineWidth;
     467        1259 :     rRect.Bottom() -= nLineHeight;
     468        1259 : }
     469             : 
     470       73595 : void ImplDraw2ColorFrame( OutputDevice *const pDev, Rectangle& rRect,
     471             :                           const Color& rLeftTopColor, const Color& rRightBottomColor )
     472             : {
     473       73595 :     pDev->SetLineColor( rLeftTopColor );
     474       73595 :     pDev->DrawLine( rRect.TopLeft(), rRect.BottomLeft() );
     475       73595 :     pDev->DrawLine( rRect.TopLeft(), rRect.TopRight() );
     476       73595 :     pDev->SetLineColor( rRightBottomColor );
     477       73595 :     pDev->DrawLine( rRect.BottomLeft(), rRect.BottomRight() );
     478       73595 :     pDev->DrawLine( rRect.TopRight(), rRect.BottomRight() );
     479             : 
     480             :     // reduce drawing area
     481       73595 :     ++rRect.Left();
     482       73595 :     ++rRect.Top();
     483       73595 :     --rRect.Right();
     484       73595 :     --rRect.Bottom();
     485       73595 : }
     486             : 
     487       30537 : void ImplDrawButton( OutputDevice *const pDev, Rectangle aFillRect,
     488             :                      const sal_uInt16 nStyle )
     489             : {
     490       30537 :     const StyleSettings& rStyleSettings = pDev->GetSettings().GetStyleSettings();
     491             : 
     492       61074 :     if ( (nStyle & BUTTON_DRAW_MONO) ||
     493       30537 :          (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
     494             :     {
     495           0 :         const Color aBlackColor( COL_BLACK );
     496             : 
     497           0 :         if ( nStyle & BUTTON_DRAW_DEFAULT )
     498             :         {
     499             :             // default selection shows a wider border
     500           0 :             ImplDrawDPILineRect( pDev, aFillRect, &aBlackColor );
     501             :         }
     502             : 
     503           0 :         ImplDrawDPILineRect( pDev, aFillRect, &aBlackColor );
     504             : 
     505           0 :         Size aBrdSize( 1, 1 );
     506           0 :         if ( pDev->GetOutDevType() == OUTDEV_PRINTER )
     507             :         {
     508           0 :             aBrdSize = pDev->LogicToPixel( Size( 20, 20 ), MapMode(MAP_100TH_MM) );
     509           0 :             if ( !aBrdSize.Width() )
     510           0 :                 aBrdSize.Width() = 1;
     511           0 :             if ( !aBrdSize.Height() )
     512           0 :                 aBrdSize.Height() = 1;
     513             :         }
     514             : 
     515           0 :         pDev->SetLineColor();
     516           0 :         pDev->SetFillColor( aBlackColor );
     517           0 :         const Rectangle aOrigFillRect(aFillRect);
     518           0 :         if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
     519             :         {
     520             :             // shrink fill rect
     521           0 :             aFillRect.Left() += aBrdSize.Width();
     522           0 :             aFillRect.Top()  += aBrdSize.Height();
     523             :             // draw top and left borders (aOrigFillRect-aFillRect)
     524             :             pDev->DrawRect( Rectangle( aOrigFillRect.Left(), aOrigFillRect.Top(),
     525           0 :                                        aOrigFillRect.Right(), aFillRect.Top()-1 ) );
     526             :             pDev->DrawRect( Rectangle( aOrigFillRect.Left(), aOrigFillRect.Top(),
     527           0 :                                        aFillRect.Left()-1, aOrigFillRect.Bottom() ) );
     528             :         }
     529             :         else
     530             :         {
     531             :             // shrink fill rect
     532           0 :             aFillRect.Right()  -= aBrdSize.Width();
     533           0 :             aFillRect.Bottom() -= aBrdSize.Height();
     534             :             // draw bottom and right borders (aOrigFillRect-aFillRect)
     535           0 :             pDev->DrawRect( Rectangle( aOrigFillRect.Left(), aFillRect.Bottom()+1,
     536           0 :                                        aOrigFillRect.Right(), aOrigFillRect.Bottom() ) );
     537           0 :             pDev->DrawRect( Rectangle( aFillRect.Right()+1, aOrigFillRect.Top(),
     538           0 :                                        aOrigFillRect.Right(), aOrigFillRect.Bottom() ) );
     539             :         }
     540             : 
     541           0 :         if ( !(nStyle & BUTTON_DRAW_NOFILL) )
     542             :         {
     543             :             // Hack: in monochrome mode on printers we like to have grey buttons
     544           0 :             if ( pDev->GetOutDevType() == OUTDEV_PRINTER )
     545           0 :                 pDev->SetFillColor( Color( COL_LIGHTGRAY ) );
     546             :             else
     547           0 :                 pDev->SetFillColor( Color( COL_WHITE ) );
     548           0 :             pDev->DrawRect( aFillRect );
     549             :         }
     550             :     }
     551             :     else
     552             :     {
     553       30537 :         if ( nStyle & BUTTON_DRAW_DEFAULT )
     554             :         {
     555           2 :             const Color aDefBtnColor = rStyleSettings.GetDarkShadowColor();
     556           2 :             ImplDrawDPILineRect( pDev, aFillRect, &aDefBtnColor );
     557             :         }
     558             : 
     559       30537 :         if ( nStyle & BUTTON_DRAW_NOLEFTLIGHTBORDER )
     560             :         {
     561         828 :             pDev->SetLineColor( rStyleSettings.GetLightBorderColor() );
     562        1656 :             pDev->DrawLine( Point( aFillRect.Left(), aFillRect.Top() ),
     563        2484 :                             Point( aFillRect.Left(), aFillRect.Bottom() ) );
     564         828 :             ++aFillRect.Left();
     565             :         }
     566             : 
     567       30537 :         Color aColor1;
     568       30537 :         Color aColor2;
     569       30537 :         if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
     570             :         {
     571           4 :             aColor1 = rStyleSettings.GetDarkShadowColor();
     572           4 :             aColor2 = rStyleSettings.GetLightColor();
     573             :         }
     574             :         else
     575             :         {
     576       30533 :             if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER )
     577       29379 :                 aColor1 = rStyleSettings.GetLightBorderColor();
     578             :             else
     579        1154 :                 aColor1 = rStyleSettings.GetLightColor();
     580       30533 :             if ( (nStyle & BUTTON_DRAW_FLATTEST) == BUTTON_DRAW_FLAT )
     581           0 :                 aColor2 = rStyleSettings.GetShadowColor();
     582             :             else
     583       30533 :                 aColor2 = rStyleSettings.GetDarkShadowColor();
     584             :         }
     585             : 
     586       30537 :         ImplDraw2ColorFrame( pDev, aFillRect, aColor1, aColor2 );
     587             : 
     588       30537 :         if ( !((nStyle & BUTTON_DRAW_FLATTEST) == BUTTON_DRAW_FLAT) )
     589             :         {
     590       30537 :             if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
     591             :             {
     592           4 :                 aColor1 = rStyleSettings.GetShadowColor();
     593           4 :                 aColor2 = rStyleSettings.GetLightBorderColor();
     594             :             }
     595             :             else
     596             :             {
     597       30533 :                 if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER )
     598       29379 :                     aColor1 = rStyleSettings.GetLightColor();
     599             :                 else
     600        1154 :                     aColor1 = rStyleSettings.GetLightBorderColor();
     601       30533 :                 aColor2 = rStyleSettings.GetShadowColor();
     602             :             }
     603       30537 :             ImplDraw2ColorFrame( pDev, aFillRect, aColor1, aColor2 );
     604             :         }
     605             : 
     606       30537 :         if ( !(nStyle & BUTTON_DRAW_NOFILL) )
     607             :         {
     608       30537 :             pDev->SetLineColor();
     609       30537 :             if ( nStyle & (BUTTON_DRAW_CHECKED | BUTTON_DRAW_DONTKNOW) )
     610           1 :                 pDev->SetFillColor( rStyleSettings.GetCheckedColor() );
     611             :             else
     612       30536 :                 pDev->SetFillColor( rStyleSettings.GetFaceColor() );
     613       30537 :             pDev->DrawRect( aFillRect );
     614             :         }
     615             :     }
     616       30537 : }
     617             : 
     618       28724 : void ImplDrawFrame( OutputDevice *const pDev, Rectangle& rRect,
     619             :                     const StyleSettings& rStyleSettings, sal_uInt16 nStyle )
     620             : {
     621       28724 :     Window *const pWin = (pDev->GetOutDevType()==OUTDEV_WINDOW) ? (Window*) pDev : NULL;
     622             : 
     623       28724 :     const bool bMenuStyle = nStyle & FRAME_DRAW_MENU;
     624             : 
     625             :     // UseFlatBorders disables 3D style for all frames except menus
     626             :     // menus may use different border colors (eg on XP)
     627             :     // normal frames will be drawn using the shadow color
     628             :     // whereas window frame borders will use black
     629       28724 :     bool bFlatBorders = !bMenuStyle && rStyleSettings.GetUseFlatBorders();
     630             : 
     631             :     // no flat borders for standard VCL controls (ie formcontrols that keep their classic look)
     632             :     // will not affect frame windows (like dropdowns)
     633       28724 :     if( bFlatBorders && pWin && pWin->GetType() == WINDOW_BORDERWINDOW && (pWin != pWin->ImplGetFrameWindow()) )
     634             :     {
     635             :         // check for formcontrol, i.e., a control without NWF enabled
     636           0 :         Control *const pControl = dynamic_cast< Control* >( pWin->GetWindow( WINDOW_CLIENT ) );
     637           0 :         if( !pControl || !pControl->IsNativeWidgetEnabled() )
     638           0 :             bFlatBorders = false;
     639             :     }
     640             : 
     641       28724 :     const bool bNoDraw = nStyle & FRAME_DRAW_NODRAW;
     642             : 
     643       86172 :     if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ||
     644       57448 :          (pDev->GetOutDevType() == OUTDEV_PRINTER) ||
     645             :          bFlatBorders )
     646           0 :         nStyle |= FRAME_DRAW_MONO;
     647             : 
     648       86172 :     if( (nStyle & FRAME_DRAW_STYLE) != FRAME_DRAW_NWF &&
     649       57448 :         pWin && pWin->IsNativeControlSupported(CTRL_FRAME, PART_BORDER) )
     650             :     {
     651           0 :         ImplControlValue aControlValue( nStyle |
     652           0 :                                         (pWin->GetType()==WINDOW_BORDERWINDOW ?
     653           0 :                                         FRAME_DRAW_BORDERWINDOWBORDER : 0) );
     654           0 :         Rectangle aBound, aContent;
     655           0 :         Rectangle aNatRgn( rRect );
     656           0 :         if( pWin->GetNativeControlRegion(CTRL_FRAME, PART_BORDER,
     657           0 :             aNatRgn, 0, aControlValue, OUString(), aBound, aContent) )
     658             :         {
     659             :             // if bNoDraw is true then don't call the drawing routine
     660             :             // but just update the target rectangle
     661           0 :             if( bNoDraw ||
     662             :                 pWin->DrawNativeControl( CTRL_FRAME, PART_BORDER, aContent, CTRL_STATE_ENABLED,
     663           0 :                                          aControlValue, OUString()) )
     664             :             {
     665           0 :                 rRect = aContent;
     666       28724 :                 return;
     667             :             }
     668           0 :         }
     669             :     }
     670             : 
     671       28724 :     if ( nStyle & FRAME_DRAW_MONO )
     672             :     {
     673             :         // no round corners for window frame borders
     674        1257 :         const bool bRound = bFlatBorders && !(nStyle & FRAME_DRAW_WINDOWBORDER);
     675             : 
     676        1257 :         if ( bNoDraw )
     677             :         {
     678         439 :             ImplDrawDPILineRect( pDev, rRect, NULL, bRound );
     679             :         }
     680             :         else
     681             :         {
     682             :             Color aColor = bRound ? rStyleSettings.GetShadowColor()
     683         818 :                                   : pDev->GetSettings().GetStyleSettings().GetMonoColor();
     684             :             // when the MonoColor wasn't set, check face color
     685        1636 :             if (
     686        2454 :                 (bRound && aColor.IsDark()) ||
     687             :                 (
     688        4080 :                   (aColor == Color(COL_BLACK)) &&
     689         808 :                   pDev->GetSettings().GetStyleSettings().GetFaceColor().IsDark()
     690             :                 )
     691             :                )
     692             :             {
     693           0 :                 aColor = Color( COL_WHITE );
     694             :             }
     695         818 :             ImplDrawDPILineRect( pDev, rRect, &aColor, bRound );
     696             :         }
     697             :     }
     698             :     else
     699             :     {
     700       27467 :         if ( bNoDraw )
     701             :         {
     702       20168 :             switch ( nStyle & FRAME_DRAW_STYLE )
     703             :             {
     704             :                 case FRAME_DRAW_IN:
     705             :                 case FRAME_DRAW_OUT:
     706          34 :                     ++rRect.Left();
     707          34 :                     ++rRect.Top();
     708          34 :                     --rRect.Right();
     709          34 :                     --rRect.Bottom();
     710          34 :                     break;
     711             : 
     712             :                 case FRAME_DRAW_GROUP:
     713             :                 case FRAME_DRAW_DOUBLEIN:
     714             :                 case FRAME_DRAW_DOUBLEOUT:
     715       20134 :                     rRect.Left()   += 2;
     716       20134 :                     rRect.Top()    += 2;
     717       20134 :                     rRect.Right()  -= 2;
     718       20134 :                     rRect.Bottom() -= 2;
     719       20134 :                     break;
     720             : 
     721             :                 case FRAME_DRAW_NWF:
     722             :                     // enough space for the native rendering
     723           0 :                     rRect.Left() += 4;
     724           0 :                     rRect.Top() += 4;
     725           0 :                     rRect.Right() -= 4;
     726           0 :                     rRect.Bottom() -= 4;
     727           0 :                     break;
     728             :             }
     729             :         }
     730             :         else
     731             :         {
     732        7299 :             switch ( nStyle & FRAME_DRAW_STYLE )
     733             :             {
     734             :                 case FRAME_DRAW_GROUP:
     735           0 :                     pDev->SetFillColor();
     736           0 :                     pDev->SetLineColor( rStyleSettings.GetLightColor() );
     737           0 :                     pDev->DrawRect( Rectangle( rRect.Left()+1, rRect.Top()+1,
     738           0 :                                             rRect.Right(), rRect.Bottom() ) );
     739           0 :                     pDev->SetLineColor( rStyleSettings.GetShadowColor() );
     740           0 :                     pDev->DrawRect( Rectangle( rRect.Left(), rRect.Top(),
     741           0 :                                             rRect.Right()-1, rRect.Bottom()-1 ) );
     742             : 
     743             :                     // adjust target rectangle
     744           0 :                     rRect.Left()   += 2;
     745           0 :                     rRect.Top()    += 2;
     746           0 :                     rRect.Right()  -= 2;
     747           0 :                     rRect.Bottom() -= 2;
     748           0 :                     break;
     749             : 
     750             :                 case FRAME_DRAW_IN:
     751             :                     ImplDraw2ColorFrame( pDev, rRect,
     752        2077 :                                          rStyleSettings.GetShadowColor(),
     753        4154 :                                          rStyleSettings.GetLightColor() );
     754        2077 :                     break;
     755             : 
     756             :                 case FRAME_DRAW_OUT:
     757             :                     ImplDraw2ColorFrame( pDev, rRect,
     758           0 :                                          rStyleSettings.GetLightColor(),
     759           0 :                                          rStyleSettings.GetShadowColor() );
     760           0 :                     break;
     761             : 
     762             :                 case FRAME_DRAW_DOUBLEIN:
     763        5212 :                     if( bFlatBorders )
     764             :                     {
     765             :                         // no 3d effect
     766             :                         ImplDraw2ColorFrame( pDev, rRect,
     767           0 :                                              rStyleSettings.GetShadowColor(),
     768           0 :                                              rStyleSettings.GetShadowColor() );
     769             :                         ImplDraw2ColorFrame( pDev, rRect,
     770           0 :                                              rStyleSettings.GetFaceColor(),
     771           0 :                                              rStyleSettings.GetFaceColor() );
     772             :                     }
     773             :                     else
     774             :                     {
     775             :                         ImplDraw2ColorFrame( pDev, rRect,
     776        5212 :                                              rStyleSettings.GetShadowColor(),
     777       10424 :                                              rStyleSettings.GetLightColor() );
     778             :                         ImplDraw2ColorFrame( pDev, rRect,
     779        5212 :                                              rStyleSettings.GetDarkShadowColor(),
     780       10424 :                                              rStyleSettings.GetLightBorderColor() );
     781             :                     }
     782        5212 :                     break;
     783             : 
     784             :                 case FRAME_DRAW_DOUBLEOUT:
     785          10 :                     if( bMenuStyle )
     786             :                     {
     787             :                         ImplDraw2ColorFrame( pDev, rRect,
     788           7 :                                              rStyleSettings.GetMenuBorderColor(),
     789          14 :                                              rStyleSettings.GetDarkShadowColor() );
     790           7 :                         if ( !rStyleSettings.GetUseFlatMenus() )
     791             :                         {
     792             :                             ImplDraw2ColorFrame( pDev, rRect,
     793           7 :                                                  rStyleSettings.GetLightColor(),
     794          14 :                                                  rStyleSettings.GetShadowColor() );
     795             :                         }
     796             :                     }
     797             :                     else
     798             :                     {
     799             :                         ImplDraw2ColorFrame( pDev, rRect,
     800             :                                              bFlatBorders ? // no 3d effect
     801             :                                              rStyleSettings.GetDarkShadowColor() :
     802             :                                              rStyleSettings.GetLightBorderColor(),
     803           3 :                                              rStyleSettings.GetDarkShadowColor() );
     804             :                         ImplDraw2ColorFrame( pDev, rRect,
     805           3 :                                              rStyleSettings.GetLightColor(),
     806           6 :                                              rStyleSettings.GetShadowColor() );
     807             :                     }
     808          10 :                     break;
     809             : 
     810             :                 case FRAME_DRAW_NWF:
     811             :                     // no rendering, just enough space for the native rendering
     812           0 :                     rRect.Left() += 4;
     813           0 :                     rRect.Top() += 4;
     814           0 :                     rRect.Right() -= 4;
     815           0 :                     rRect.Bottom() -= 4;
     816           0 :                     break;
     817             :             }
     818             :         }
     819             :     }
     820             : }
     821             : 
     822             : }
     823             : 
     824       22240 : void DecorationView::DrawSymbol( const Rectangle& rRect, SymbolType eType,
     825             :                                  const Color& rColor, sal_uInt16 nStyle )
     826             : {
     827       22240 :     const StyleSettings&    rStyleSettings  = mpOutDev->GetSettings().GetStyleSettings();
     828       22240 :     const Rectangle         aRect           = mpOutDev->LogicToPixel( rRect );
     829       22240 :     const Color             aOldLineColor   = mpOutDev->GetLineColor();
     830       22240 :     const Color             aOldFillColor   = mpOutDev->GetFillColor();
     831       22240 :     const bool              bOldMapMode     = mpOutDev->IsMapModeEnabled();
     832       22240 :     Color                   nColor(rColor);
     833       22240 :     mpOutDev->EnableMapMode( false );
     834             : 
     835       44480 :     if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ||
     836       22240 :          (mpOutDev->GetOutDevType() == OUTDEV_PRINTER) )
     837           0 :         nStyle |= BUTTON_DRAW_MONO;
     838             : 
     839       22240 :     if ( nStyle & SYMBOL_DRAW_MONO )
     840             :     {
     841             :         // Monochrome: set color to black if enabled, to gray if disabled
     842           0 :         nColor = Color( ( nStyle & SYMBOL_DRAW_DISABLE ) ? COL_GRAY : COL_BLACK );
     843             :     }
     844             :     else
     845             :     {
     846       22240 :         if ( nStyle & SYMBOL_DRAW_DISABLE )
     847             :         {
     848             :             // Draw shifted and brighter symbol for embossed look
     849        9011 :             mpOutDev->SetLineColor( rStyleSettings.GetLightColor() );
     850        9011 :             mpOutDev->SetFillColor( rStyleSettings.GetLightColor() );
     851        9011 :             ImplDrawSymbol( mpOutDev, aRect + Point(1, 1) , eType );
     852        9011 :             nColor = rStyleSettings.GetShadowColor();
     853             :         }
     854             :     }
     855             : 
     856             :     // Set selected color and draw the symbol
     857       22240 :     mpOutDev->SetLineColor( nColor );
     858       22240 :     mpOutDev->SetFillColor( nColor );
     859       22240 :     ImplDrawSymbol( mpOutDev, aRect, eType );
     860             : 
     861             :     // Restore previous settings
     862       22240 :     mpOutDev->SetLineColor( aOldLineColor );
     863       22240 :     mpOutDev->SetFillColor( aOldFillColor );
     864       22240 :     mpOutDev->EnableMapMode( bOldMapMode );
     865       22240 : }
     866             : 
     867           0 : void DecorationView::DrawFrame( const Rectangle& rRect,
     868             :                                 const Color& rLeftTopColor,
     869             :                                 const Color& rRightBottomColor )
     870             : {
     871           0 :     Rectangle   aRect         = mpOutDev->LogicToPixel( rRect );
     872           0 :     const Color aOldLineColor = mpOutDev->GetLineColor();
     873           0 :     const bool  bOldMapMode   = mpOutDev->IsMapModeEnabled();
     874           0 :     mpOutDev->EnableMapMode( false );
     875           0 :     ImplDraw2ColorFrame( mpOutDev, aRect, rLeftTopColor, rRightBottomColor );
     876           0 :     mpOutDev->SetLineColor( aOldLineColor );
     877           0 :     mpOutDev->EnableMapMode( bOldMapMode );
     878           0 : }
     879             : 
     880           0 : void DecorationView::DrawHighlightFrame( const Rectangle& rRect,
     881             :                                          sal_uInt16 nStyle )
     882             : {
     883           0 :     const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings();
     884           0 :     Color aLightColor = rStyleSettings.GetLightColor();
     885           0 :     Color aShadowColor = rStyleSettings.GetShadowColor();
     886             : 
     887           0 :     if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ||
     888           0 :          (mpOutDev->GetOutDevType() == OUTDEV_PRINTER) )
     889             :     {
     890           0 :         aLightColor = Color( COL_BLACK );
     891           0 :         aShadowColor = Color( COL_BLACK );
     892             :     }
     893           0 :     else if ( nStyle & FRAME_HIGHLIGHT_TESTBACKGROUND )
     894             :     {
     895           0 :         Wallpaper aBackground = mpOutDev->GetBackground();
     896           0 :         if ( aBackground.IsBitmap() || aBackground.IsGradient() )
     897             :         {
     898           0 :             aLightColor = rStyleSettings.GetFaceColor();
     899           0 :             aShadowColor = Color( COL_BLACK );
     900             :         }
     901             :         else
     902             :         {
     903           0 :             Color aBackColor = aBackground.GetColor();
     904           0 :             if ( (aLightColor.GetColorError( aBackColor ) < 32) ||
     905           0 :                  (aShadowColor.GetColorError( aBackColor ) < 32) )
     906             :             {
     907           0 :                 aLightColor = Color( COL_WHITE );
     908           0 :                 aShadowColor = Color( COL_BLACK );
     909             : 
     910           0 :                 if ( aLightColor.GetColorError( aBackColor ) < 32 )
     911           0 :                     aLightColor.DecreaseLuminance( 64 );
     912           0 :                 if ( aShadowColor.GetColorError( aBackColor ) < 32 )
     913           0 :                     aShadowColor.IncreaseLuminance( 64 );
     914             :             }
     915           0 :         }
     916             :     }
     917             : 
     918           0 :     if ( (nStyle & FRAME_HIGHLIGHT_STYLE) == FRAME_HIGHLIGHT_IN )
     919             :     {
     920           0 :         Color aTempColor = aLightColor;
     921           0 :         aLightColor = aShadowColor;
     922           0 :         aShadowColor = aTempColor;
     923             :     }
     924             : 
     925           0 :     DrawFrame( rRect, aLightColor, aShadowColor );
     926           0 : }
     927             : 
     928       28725 : Rectangle DecorationView::DrawFrame( const Rectangle& rRect, sal_uInt16 nStyle )
     929             : {
     930       28725 :     Rectangle   aRect = rRect;
     931       28725 :     bool        bOldMap = mpOutDev->IsMapModeEnabled();
     932       28725 :     if ( bOldMap )
     933             :     {
     934           0 :         aRect = mpOutDev->LogicToPixel( aRect );
     935           0 :         mpOutDev->EnableMapMode( false );
     936             :     }
     937             : 
     938       28725 :     if ( !rRect.IsEmpty() )
     939             :     {
     940       28724 :         if ( nStyle & FRAME_DRAW_NODRAW )
     941       20607 :              ImplDrawFrame( mpOutDev, aRect, mpOutDev->GetSettings().GetStyleSettings(), nStyle );
     942             :         else
     943             :         {
     944        8117 :              Color maOldLineColor  = mpOutDev->GetLineColor();
     945        8117 :              Color maOldFillColor  = mpOutDev->GetFillColor();
     946        8117 :              ImplDrawFrame( mpOutDev, aRect, mpOutDev->GetSettings().GetStyleSettings(), nStyle );
     947        8117 :              mpOutDev->SetLineColor( maOldLineColor );
     948        8117 :              mpOutDev->SetFillColor( maOldFillColor );
     949             :         }
     950             :     }
     951             : 
     952       28725 :     if ( bOldMap )
     953             :     {
     954           0 :         mpOutDev->EnableMapMode( bOldMap );
     955           0 :         aRect = mpOutDev->PixelToLogic( aRect );
     956             :     }
     957             : 
     958       28725 :     return aRect;
     959             : }
     960             : 
     961       30667 : Rectangle DecorationView::DrawButton( const Rectangle& rRect, sal_uInt16 nStyle )
     962             : {
     963       30667 :     if ( rRect.IsEmpty() )
     964             :     {
     965         130 :         return rRect;
     966             :     }
     967             : 
     968       30537 :     Rectangle aRect = rRect;
     969       30537 :     const bool bOldMap = mpOutDev->IsMapModeEnabled();
     970             : 
     971       30537 :     if ( bOldMap )
     972             :     {
     973           0 :         aRect = mpOutDev->LogicToPixel( aRect );
     974           0 :         mpOutDev->EnableMapMode( false );
     975             :     }
     976             : 
     977       30537 :     const Color maOldLineColor = mpOutDev->GetLineColor();
     978       30537 :     const Color maOldFillColor = mpOutDev->GetFillColor();
     979       30537 :     ImplDrawButton( mpOutDev, aRect, nStyle );
     980       30537 :     mpOutDev->SetLineColor( maOldLineColor );
     981       30537 :     mpOutDev->SetFillColor( maOldFillColor );
     982             : 
     983             :     // keep border free, altough it is used at default representation
     984       30537 :     ++aRect.Left();
     985       30537 :     ++aRect.Top();
     986       30537 :     --aRect.Right();
     987       30537 :     --aRect.Bottom();
     988             : 
     989       30537 :     if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER )
     990             :     {
     991       29382 :         ++aRect.Left();
     992       29382 :         ++aRect.Top();
     993             :     }
     994        1155 :     else if ( nStyle & BUTTON_DRAW_NOLEFTLIGHTBORDER )
     995             :     {
     996         828 :         ++aRect.Left();
     997             :     }
     998             : 
     999       30537 :     if ( nStyle & BUTTON_DRAW_PRESSED )
    1000             :     {
    1001           3 :         if ( (aRect.GetHeight() > 10) && (aRect.GetWidth() > 10) )
    1002             :         {
    1003           3 :             aRect.Left()   += 4;
    1004           3 :             aRect.Top()    += 4;
    1005           3 :             aRect.Right()  -= 1;
    1006           3 :             aRect.Bottom() -= 1;
    1007             :         }
    1008             :         else
    1009             :         {
    1010           0 :             aRect.Left()   += 3;
    1011           0 :             aRect.Top()    += 3;
    1012           0 :             aRect.Right()  -= 2;
    1013           0 :             aRect.Bottom() -= 2;
    1014             :         }
    1015             :     }
    1016       30534 :     else if ( nStyle & BUTTON_DRAW_CHECKED )
    1017             :     {
    1018           1 :         aRect.Left()   += 3;
    1019           1 :         aRect.Top()    += 3;
    1020           1 :         aRect.Right()  -= 2;
    1021           1 :         aRect.Bottom() -= 2;
    1022             :     }
    1023             :     else
    1024             :     {
    1025       30533 :         aRect.Left()   += 2;
    1026       30533 :         aRect.Top()    += 2;
    1027       30533 :         aRect.Right()  -= 3;
    1028       30533 :         aRect.Bottom() -= 3;
    1029             :     }
    1030             : 
    1031       30537 :     if ( bOldMap )
    1032             :     {
    1033           0 :         mpOutDev->EnableMapMode( bOldMap );
    1034           0 :         aRect = mpOutDev->PixelToLogic( aRect );
    1035             :     }
    1036             : 
    1037       30537 :     return aRect;
    1038             : }
    1039             : 
    1040       13187 : void DecorationView::DrawSeparator( const Point& rStart, const Point& rStop, bool bVertical )
    1041             : {
    1042       13187 :     Point aStart( rStart ), aStop( rStop );
    1043       13187 :     const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings();
    1044       13187 :     Window *const pWin = (mpOutDev->GetOutDevType()==OUTDEV_WINDOW) ? (Window*) mpOutDev: NULL;
    1045       13187 :     if(pWin)
    1046             :     {
    1047       13187 :         ControlPart nPart = ( bVertical ? PART_SEPARATOR_VERT : PART_SEPARATOR_HORZ );
    1048       13187 :         bool nativeSupported = pWin->IsNativeControlSupported( CTRL_FIXEDLINE, nPart );
    1049       13187 :         ImplControlValue    aValue;
    1050       13187 :         ControlState        nState = 0;
    1051       13187 :         Rectangle aRect(rStart,rStop);
    1052       13187 :         if(nativeSupported && pWin->DrawNativeControl(CTRL_FIXEDLINE,nPart,aRect,nState,aValue,OUString()))
    1053       13187 :             return;
    1054             :     }
    1055             : 
    1056       13187 :     mpOutDev->Push( PUSH_LINECOLOR );
    1057       13187 :     if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
    1058           0 :         mpOutDev->SetLineColor( Color( COL_BLACK ) );
    1059             :     else
    1060       13187 :         mpOutDev->SetLineColor( rStyleSettings.GetShadowColor() );
    1061             : 
    1062       13187 :     mpOutDev->DrawLine( aStart, aStop );
    1063       13187 :     if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
    1064             :     {
    1065       13187 :         mpOutDev->SetLineColor( rStyleSettings.GetLightColor() );
    1066       13187 :         if( bVertical )
    1067             :         {
    1068       13167 :             aStart.X()++;
    1069       13167 :             aStop.X()++;
    1070             :         }
    1071             :         else
    1072             :         {
    1073          20 :             aStart.Y()++;
    1074          20 :             aStop.Y()++;
    1075             :         }
    1076       13187 :         mpOutDev->DrawLine( aStart, aStop );
    1077             :     }
    1078       13187 :     mpOutDev->Pop();
    1079             : }
    1080             : 
    1081             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10