xref: /trunk/main/vcl/source/window/decoview.cxx (revision d5e8c6bf9be44690bd4016967c75f0f611324980)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_vcl.hxx"
24 #include <vcl/settings.hxx>
25 #include <tools/poly.hxx>
26 #include <vcl/outdev.hxx>
27 #include <vcl/bmpacc.hxx>
28 #include <vcl/decoview.hxx>
29 #include <vcl/window.hxx>
30 #include <vcl/ctrl.hxx>
31 
32 // =======================================================================
33 
34 #define BUTTON_DRAW_FLATTEST    (BUTTON_DRAW_FLAT |         \
35                                  BUTTON_DRAW_PRESSED |      \
36                                  BUTTON_DRAW_CHECKED |      \
37                                  BUTTON_DRAW_HIGHLIGHT)
38 
39 // =======================================================================
40 
41 static void ImplDrawSymbol( OutputDevice* pDev, const Rectangle& rRect,
42                             SymbolType eType  )
43 {
44     // Größen vorberechnen
45     long    nMin    = Min( rRect.GetWidth(), rRect.GetHeight() );
46     long    nSize   = nMin;
47 
48     if ( nMin & 0x01 )
49         nMin--;
50     Point   aCenter = rRect.Center();
51     long    nCenterX = aCenter.X();
52     long    nCenterY = aCenter.Y();
53     long    n2 = nMin / 2;
54     long    n4 = nMin / 4;
55     long    nLeft;
56     long    nTop;
57     long    nRight;
58     long    nBottom;
59     long    nTemp;
60     long    i;
61 
62     switch ( eType )
63     {
64         case SYMBOL_ARROW_UP:
65             {
66             if ( !(nMin & 0x01) )
67             {
68                 n2--;
69                 n4--;
70             }
71             nTop = nCenterY-n2;
72             nBottom = nCenterY;
73             pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) );
74             i = 1;
75             while ( i <= n2 )
76             {
77                 nTop++;
78                 nTemp = nCenterX-i;
79                 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
80                 nTemp = nCenterX+i;
81                 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
82                 i++;
83             }
84             pDev->DrawRect( Rectangle( nCenterX-n4, nBottom,
85                                        nCenterX+n4, nBottom+n2 ) );
86             }
87             break;
88 
89         case SYMBOL_ARROW_DOWN:
90             {
91             if ( !(nMin & 0x01) )
92             {
93                 n2--;
94                 n4--;
95             }
96             nTop = nCenterY;
97             nBottom = nCenterY+n2;
98             pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) );
99             i = 1;
100             while ( i <= n2 )
101             {
102                 nBottom--;
103                 nTemp = nCenterX-i;
104                 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
105                 nTemp = nCenterX+i;
106                 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
107                 i++;
108             }
109             pDev->DrawRect( Rectangle( nCenterX-n4, nTop-n2,
110                                        nCenterX+n4, nTop ) );
111             }
112             break;
113 
114         case SYMBOL_ARROW_LEFT:
115             {
116             if ( !(nMin & 0x01) )
117             {
118                 n2--;
119                 n4--;
120             }
121             nLeft = nCenterX-n2;
122             nRight = nCenterX;
123             pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) );
124             i = 1;
125             while ( i <= n2 )
126             {
127                 nLeft++;
128                 nTemp = nCenterY-i;
129                 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
130                 nTemp = nCenterY+i;
131                 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
132                 i++;
133             }
134             pDev->DrawRect( Rectangle( nRight, nCenterY-n4,
135                                        nRight+n2, nCenterY+n4 ) );
136             }
137             break;
138 
139         case SYMBOL_ARROW_RIGHT:
140             {
141             if ( !(nMin & 0x01) )
142             {
143                 n2--;
144                 n4--;
145             }
146             nLeft = nCenterX;
147             nRight = nCenterX+n2;
148             pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) );
149             i = 1;
150             while ( i <= n2 )
151             {
152                 nRight--;
153                 nTemp = nCenterY-i;
154                 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
155                 nTemp = nCenterY+i;
156                 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
157                 i++;
158             }
159             pDev->DrawRect( Rectangle( nLeft-n2, nCenterY-n4,
160                                        nLeft, nCenterY+n4 ) );
161             }
162             break;
163 
164         case SYMBOL_SPIN_UP:
165             {
166             if ( !(nMin & 0x01) )
167                 n2--;
168             nTop = nCenterY-n4;
169             nBottom = nTop+n2;
170             pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) );
171             i = 1;
172             while ( i <= n2 )
173             {
174                 nTop++;
175                 nTemp = nCenterX-i;
176                 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
177                 nTemp = nCenterX+i;
178                 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
179                 i++;
180             }
181             }
182             break;
183 
184         case SYMBOL_SPIN_DOWN:
185             {
186             if ( !(nMin & 0x01) )
187                 n2--;
188             nTop = nCenterY-n4;
189             nBottom = nTop+n2;
190             pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) );
191             i = 1;
192             while ( i <= n2 )
193             {
194                 nBottom--;
195                 nTemp = nCenterX-i;
196                 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
197                 nTemp = nCenterX+i;
198                 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
199                 i++;
200             }
201             }
202             break;
203 
204         case SYMBOL_SPIN_LEFT:
205         case SYMBOL_FIRST:
206         case SYMBOL_PREV:
207         case SYMBOL_REVERSEPLAY:
208             {
209             if ( !(nMin & 0x01) )
210                 n2--;
211             nLeft = nCenterX-n4;
212             if ( eType == SYMBOL_FIRST )
213                 nLeft++;
214             nRight = nLeft+n2;
215             pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) );
216             i = 1;
217             while ( i <= n2 )
218             {
219                 nLeft++;
220                 nTemp = nCenterY-i;
221                 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
222                 nTemp = nCenterY+i;
223                 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
224                 i++;
225             }
226             if ( eType == SYMBOL_FIRST )
227             {
228                 pDev->DrawRect( Rectangle( nCenterX-n4-1, nCenterY-n2,
229                                            nCenterX-n4-1, nCenterY+n2 ) );
230             }
231             }
232             break;
233 
234         case SYMBOL_SPIN_RIGHT:
235         case SYMBOL_LAST:
236         case SYMBOL_NEXT:
237         case SYMBOL_PLAY:
238             {
239             if ( !(nMin & 0x01) )
240                 n2--;
241             nLeft = nCenterX-n4;
242             if ( eType == SYMBOL_LAST )
243                 nLeft--;
244             nRight = nLeft+n2;
245             pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) );
246             i = 1;
247             while ( i <= n2 )
248             {
249                 nRight--;
250                 nTemp = nCenterY-i;
251                 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
252                 nTemp = nCenterY+i;
253                 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
254                 i++;
255             }
256             if ( eType == SYMBOL_LAST )
257             {
258                 pDev->DrawRect( Rectangle( nCenterX+n4+1, nCenterY-n2,
259                                            nCenterX+n4+1, nCenterY+n2 ) );
260             }
261             }
262             break;
263 
264         case SYMBOL_PAGEUP:
265         case SYMBOL_PAGEDOWN:
266         {
267             if ( !( nSize & 0x01 ))
268             {
269                 // An even rectangle size means we have to use a smaller size for
270                 // our arrows as we want to use one pixel for the spearhead! Otherwise
271                 // it will be clipped!
272                 nCenterX++;
273                 n2 = ( nMin-1 ) / 2;
274                 n4 = ( nMin-1 ) / 4;
275             }
276 
277             nTop = nCenterY-n2;
278             nBottom = nCenterY-1;
279             pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) );
280             pDev->DrawRect( Rectangle( nCenterX, nTop+n2+1, nCenterX, nBottom+n2+1 ) );
281             i = 1;
282             while ( i < n2 )
283             {
284                 ( eType == SYMBOL_PAGEUP ) ? nTop++ : nBottom--;
285                 nTemp = nCenterX-i;
286                 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
287                 pDev->DrawRect( Rectangle( nTemp, nTop+n2+1, nTemp, nBottom+n2+1 ) );
288                 nTemp = nCenterX+i;
289                 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
290                 pDev->DrawRect( Rectangle( nTemp, nTop+n2+1, nTemp, nBottom+n2+1 ) );
291                 i++;
292             }
293         }
294         break;
295 
296         case SYMBOL_RADIOCHECKMARK:
297         case SYMBOL_RECORD:
298         {
299             const long          nExt = ( n2 << 1 ) + 1;
300             Bitmap              aBmp( Size( nExt, nExt ), 1 );
301             BitmapWriteAccess*  pWAcc = aBmp.AcquireWriteAccess();
302 
303             if( pWAcc )
304             {
305                 const Color aWhite( COL_WHITE );
306                 const Color aBlack( COL_BLACK );
307 
308                 pWAcc->Erase( aWhite );
309                 pWAcc->SetLineColor( aBlack );
310                 pWAcc->SetFillColor( aBlack );
311                 pWAcc->DrawPolygon( Polygon( Point( n2, n2 ), n2, n2 ) );
312                 aBmp.ReleaseAccess( pWAcc );
313                 pDev->DrawMask( Point( nCenterX - n2, nCenterY - n2 ), aBmp, pDev->GetFillColor() );
314             }
315             else
316                 pDev->DrawPolygon( Polygon( Point( nCenterX, nCenterY ), n2, n2 ) );
317         }
318         break;
319 
320         case SYMBOL_STOP:
321             {
322             nLeft = nCenterX-n2;
323             nRight = nCenterX+n2;
324             nTop = nCenterY-n2;
325             nBottom = nCenterY+n2;
326             pDev->DrawRect( Rectangle( nLeft, nTop, nRight, nBottom ) );
327             }
328             break;
329 
330         case SYMBOL_PAUSE:
331             {
332             nLeft = nCenterX-n2;
333             nRight = nCenterX+n2-1;
334             nTop = nCenterY-n2;
335             nBottom = nCenterY+n2;
336             pDev->DrawRect( Rectangle( nLeft, nTop, nCenterX-2, nBottom ) );
337             pDev->DrawRect( Rectangle( nCenterX+1, nTop, nRight, nBottom ) );
338             }
339             break;
340 
341         case SYMBOL_WINDSTART:
342         case SYMBOL_WINDBACKWARD:
343             {
344             nLeft = nCenterX-n2+1;
345             nRight = nCenterX;
346             pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) );
347             pDev->DrawRect( Rectangle( nLeft+n2, nCenterY, nRight+n2, nCenterY ) );
348             i = 1;
349             while ( i < n2 )
350             {
351                 nLeft++;
352                 nTemp = nCenterY-i;
353                 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
354                 pDev->DrawRect( Rectangle( nLeft+n2, nTemp, nRight+n2, nTemp ) );
355                 nTemp = nCenterY+i;
356                 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
357                 pDev->DrawRect( Rectangle( nLeft+n2, nTemp, nRight+n2, nTemp ) );
358                 i++;
359             }
360             if ( eType == SYMBOL_WINDSTART )
361             {
362                 pDev->DrawRect( Rectangle( nCenterX-n2, nCenterY-n2,
363                                            nCenterX-n2, nCenterY+n2 ) );
364             }
365             }
366             break;
367 
368         case SYMBOL_WINDEND:
369         case SYMBOL_WINDFORWARD:
370             {
371             nLeft = nCenterX-n2;
372             nRight = nCenterX-1;
373             pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) );
374             pDev->DrawRect( Rectangle( nLeft+n2, nCenterY, nRight+n2, nCenterY ) );
375             i = 1;
376             while ( i < n2 )
377             {
378                 nRight--;
379                 nTemp = nCenterY-i;
380                 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
381                 pDev->DrawRect( Rectangle( nLeft+n2, nTemp, nRight+n2, nTemp ) );
382                 nTemp = nCenterY+i;
383                 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
384                 pDev->DrawRect( Rectangle( nLeft+n2, nTemp, nRight+n2, nTemp ) );
385                 i++;
386             }
387             if ( eType == SYMBOL_WINDEND )
388             {
389                 pDev->DrawRect( Rectangle( nCenterX+n2, nCenterY-n2,
390                                            nCenterX+n2, nCenterY+n2 ) );
391             }
392             }
393             break;
394 
395         case SYMBOL_CLOSE:
396             {
397             Size aRectSize( 2, 1 );
398             if ( nMin < 8 )
399                 aRectSize.Width() = 1;
400             else if ( nMin > 20 )
401                 aRectSize.Width() = nMin/10;
402             nLeft   = nCenterX-n2+1;
403             nTop    = nCenterY-n2+1;
404             nBottom = nCenterY-n2+nMin-aRectSize.Width()+1;
405             i = 0;
406             while ( i < nMin-aRectSize.Width()+1 )
407             {
408                 pDev->DrawRect( Rectangle( Point( nLeft+i, nTop+i ), aRectSize ) );
409                 pDev->DrawRect( Rectangle( Point( nLeft+i, nBottom-i ), aRectSize ) );
410                 i++;
411             }
412             }
413             break;
414 
415         case SYMBOL_ROLLUP:
416         case SYMBOL_ROLLDOWN:
417             {
418             Rectangle aRect( nCenterX-n2, nCenterY-n2,
419                              nCenterX+n2, nCenterY-n2+1 );
420             pDev->DrawRect( aRect );
421             if ( eType == SYMBOL_ROLLDOWN )
422             {
423                 Rectangle aTempRect = aRect;
424                 aTempRect.Bottom() = nCenterY+n2;
425                 aTempRect.Right() = aRect.Left();
426                 pDev->DrawRect( aTempRect );
427                 aTempRect.Left() = aRect.Right();
428                 aTempRect.Right() = aRect.Right();
429                 pDev->DrawRect( aTempRect );
430                 aTempRect.Top() = aTempRect.Bottom();
431                 aTempRect.Left() = aRect.Left();
432                 pDev->DrawRect( aTempRect );
433             }
434             }
435             break;
436         case SYMBOL_CHECKMARK:
437             {
438                 // #106953# never mirror checkmarks
439                 sal_Bool bRTL = pDev->ImplHasMirroredGraphics() && pDev->IsRTLEnabled();
440                 Point aPos1( bRTL ? rRect.Right() : rRect.Left(),
441                     rRect.Bottom() - rRect.GetHeight() / 3 );
442                 Point aPos2( bRTL ? rRect.Right() - rRect.GetWidth()/3 : rRect.Left() + rRect.GetWidth()/3,
443                     rRect.Bottom() );
444                 Point aPos3( bRTL ? rRect.TopLeft() : rRect.TopRight() );
445                 Size aRectSize( 1, 2 );
446                 long nStepsY = aPos2.Y()-aPos1.Y();
447                 long nX = aPos1.X();
448                 long nY = aPos1.Y();
449                 long n;
450                 for ( n = 0; n <= nStepsY; n++ )
451                 {
452                     if( bRTL )
453                         nX--;
454                     pDev->DrawRect( Rectangle( Point( nX, nY++ ), aRectSize ) );
455                     if( !bRTL )
456                         nX++;
457                 }
458                 nStepsY = aPos2.Y()-aPos3.Y();
459                 nX = aPos2.X();
460                 nY = aPos2.Y();
461                 for ( n = 0; n <= nStepsY; n++ )
462                 {
463                     if( bRTL )
464                         if ( --nX < rRect.Left() )
465                             break;
466                     pDev->DrawRect( Rectangle( Point( nX, nY-- ), aRectSize ) );
467                     if( !bRTL )
468                         if ( ++nX > rRect.Right() )
469                             break;
470                 }
471             }
472             break;
473 
474         case SYMBOL_SPIN_UPDOWN:
475             {
476             nTop = nCenterY-n2-1;
477             nBottom = nTop+n2;
478             pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) );
479             i = 1;
480             while ( i <= n2 )
481             {
482                 nTop++;
483                 nTemp = nCenterX-i;
484                 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
485                 nTemp = nCenterX+i;
486                 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
487                 i++;
488             }
489             nTop = nCenterY+1;
490             nBottom = nTop+n2;
491             pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) );
492             i = 1;
493             while ( i <= n2 )
494             {
495                 nBottom--;
496                 nTemp = nCenterX-i;
497                 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
498                 nTemp = nCenterX+i;
499                 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
500                 i++;
501             }
502             }
503             break;
504 
505         case SYMBOL_FLOAT:
506             {
507             Rectangle aRect( nCenterX-n2, nCenterY-n2+3,
508                              nCenterX+n2-2, nCenterY-n2+4 );
509             pDev->DrawRect( aRect );
510             Rectangle aTempRect = aRect;
511             aTempRect.Bottom() = nCenterY+n2;
512             aTempRect.Right() = aRect.Left();
513             pDev->DrawRect( aTempRect );
514             aTempRect.Left() = aRect.Right();
515             aTempRect.Right() = aRect.Right();
516             pDev->DrawRect( aTempRect );
517             aTempRect.Top() = aTempRect.Bottom();
518             aTempRect.Left() = aRect.Left();
519             pDev->DrawRect( aTempRect );
520             aRect = Rectangle( nCenterX-n2+2, nCenterY-n2,
521                              nCenterX+n2, nCenterY-n2+1 );
522             pDev->DrawRect( aRect );
523             aTempRect = aRect;
524             aTempRect.Bottom() = nCenterY+n2-3;
525             aTempRect.Right() = aRect.Left();
526             pDev->DrawRect( aTempRect );
527             aTempRect.Left() = aRect.Right();
528             aTempRect.Right() = aRect.Right();
529             pDev->DrawRect( aTempRect );
530             aTempRect.Top() = aTempRect.Bottom();
531             aTempRect.Left() = aRect.Left();
532             pDev->DrawRect( aTempRect );
533             }
534             break;
535         case SYMBOL_DOCK:
536             {
537             Rectangle aRect( nCenterX-n2, nCenterY-n2,
538                              nCenterX+n2, nCenterY-n2 );
539             pDev->DrawRect( aRect );
540             Rectangle aTempRect = aRect;
541             aTempRect.Bottom() = nCenterY+n2;
542             aTempRect.Right() = aRect.Left();
543             pDev->DrawRect( aTempRect );
544             aTempRect.Left() = aRect.Right();
545             aTempRect.Right() = aRect.Right();
546             pDev->DrawRect( aTempRect );
547             aTempRect.Top() = aTempRect.Bottom();
548             aTempRect.Left() = aRect.Left();
549             pDev->DrawRect( aTempRect );
550             }
551             break;
552         case SYMBOL_HIDE:
553             {
554             long nExtra = nMin / 8;
555             Rectangle aRect( nCenterX-n2+nExtra, nCenterY+n2-1,
556                              nCenterX+n2-nExtra, nCenterY+n2 );
557             pDev->DrawRect( aRect );
558             }
559             break;
560     }
561 }
562 
563 // -----------------------------------------------------------------------
564 
565 void DecorationView::DrawSymbol( const Rectangle& rRect, SymbolType eType,
566                                  const Color& rColor, sal_uInt16 nStyle )
567 {
568     const StyleSettings&    rStyleSettings  = mpOutDev->GetSettings().GetStyleSettings();
569     Rectangle               aRect           = mpOutDev->LogicToPixel( rRect );
570     Color                   aOldLineColor   = mpOutDev->GetLineColor();
571     Color                   aOldFillColor   = mpOutDev->GetFillColor();
572     sal_Bool                    bOldMapMode     = mpOutDev->IsMapModeEnabled();
573     mpOutDev->SetLineColor();
574     mpOutDev->SetFillColor( rColor );
575     mpOutDev->EnableMapMode( sal_False );
576 
577     if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ||
578          (mpOutDev->GetOutDevType() == OUTDEV_PRINTER) )
579         nStyle |= BUTTON_DRAW_MONO;
580 
581     if ( nStyle & SYMBOL_DRAW_MONO )
582     {
583         if ( nStyle & SYMBOL_DRAW_DISABLE )
584             mpOutDev->SetFillColor( Color( COL_GRAY ) );
585         else
586             mpOutDev->SetFillColor( Color( COL_BLACK ) );
587     }
588     else
589     {
590         if ( nStyle & SYMBOL_DRAW_DISABLE )
591         {
592             // Als Embosed ausgeben
593             mpOutDev->SetFillColor( rStyleSettings.GetLightColor() );
594             Rectangle aTempRect = aRect;
595             aTempRect.Move( 0, 0 );
596             ImplDrawSymbol( mpOutDev, aTempRect, eType );
597             mpOutDev->SetFillColor( rStyleSettings.GetShadowColor() );
598         }
599         else
600             mpOutDev->SetFillColor( rColor );
601     }
602 
603     ImplDrawSymbol( mpOutDev, aRect, eType );
604 
605     mpOutDev->SetLineColor( aOldLineColor );
606     mpOutDev->SetFillColor( aOldFillColor );
607     mpOutDev->EnableMapMode( bOldMapMode );
608 }
609 
610 // =======================================================================
611 
612 void DecorationView::DrawFrame( const Rectangle& rRect,
613                                 const Color& rLeftTopColor,
614                                 const Color& rRightBottomColor )
615 {
616     Rectangle   aRect           = mpOutDev->LogicToPixel( rRect );
617     Color       aOldLineColor   = mpOutDev->GetLineColor();
618     Color       aOldFillColor   = mpOutDev->GetFillColor();
619     sal_Bool        bOldMapMode     = mpOutDev->IsMapModeEnabled();
620     mpOutDev->EnableMapMode( sal_False );
621     mpOutDev->SetLineColor();
622     mpOutDev->ImplDraw2ColorFrame( aRect, rLeftTopColor, rRightBottomColor );
623     mpOutDev->SetLineColor( aOldLineColor );
624     mpOutDev->SetFillColor( aOldFillColor );
625     mpOutDev->EnableMapMode( bOldMapMode );
626 }
627 
628 // =======================================================================
629 
630 void DecorationView::DrawHighlightFrame( const Rectangle& rRect,
631                                          sal_uInt16 nStyle )
632 {
633     const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings();
634     Color aLightColor = rStyleSettings.GetLightColor();
635     Color aShadowColor = rStyleSettings.GetShadowColor();
636 
637     if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ||
638          (mpOutDev->GetOutDevType() == OUTDEV_PRINTER) )
639     {
640         aLightColor = Color( COL_BLACK );
641         aShadowColor = Color( COL_BLACK );
642     }
643     else if ( nStyle & FRAME_HIGHLIGHT_TESTBACKGROUND )
644     {
645         Wallpaper aBackground = mpOutDev->GetBackground();
646         if ( aBackground.IsBitmap() || aBackground.IsGradient() )
647         {
648             aLightColor = rStyleSettings.GetFaceColor();
649             aShadowColor = Color( COL_BLACK );
650         }
651         else
652         {
653             Color aBackColor = aBackground.GetColor();
654             if ( (aLightColor.GetColorError( aBackColor ) < 32) ||
655                  (aShadowColor.GetColorError( aBackColor ) < 32) )
656             {
657                 aLightColor = Color( COL_WHITE );
658                 aShadowColor = Color( COL_BLACK );
659 
660                 if ( aLightColor.GetColorError( aBackColor ) < 32 )
661                     aLightColor.DecreaseLuminance( 64 );
662                 if ( aShadowColor.GetColorError( aBackColor ) < 32 )
663                     aShadowColor.IncreaseLuminance( 64 );
664             }
665         }
666     }
667 
668     if ( (nStyle & FRAME_HIGHLIGHT_STYLE) == FRAME_HIGHLIGHT_IN )
669     {
670         Color aTempColor = aLightColor;
671         aLightColor = aShadowColor;
672         aShadowColor = aTempColor;
673     }
674 
675     DrawFrame( rRect, aLightColor, aShadowColor );
676 }
677 
678 // =======================================================================
679 
680 static void ImplDrawDPILineRect( OutputDevice* pDev, Rectangle& rRect,
681                                  const Color* pColor, sal_Bool bRound = sal_False )
682 {
683     long nLineWidth = pDev->ImplGetDPIX()/300;
684     long nLineHeight = pDev->ImplGetDPIY()/300;
685     if ( !nLineWidth )
686         nLineWidth = 1;
687     if ( !nLineHeight )
688         nLineHeight = 1;
689 
690     if ( pColor )
691     {
692         if ( (nLineWidth == 1) && (nLineHeight == 1) )
693         {
694             pDev->SetLineColor( *pColor );
695             pDev->SetFillColor();
696             if( bRound )
697             {
698                 pDev->DrawLine( Point( rRect.Left()+1, rRect.Top()), Point( rRect.Right()-1, rRect.Top()) );
699                 pDev->DrawLine( Point( rRect.Left()+1, rRect.Bottom()), Point( rRect.Right()-1, rRect.Bottom()) );
700                 pDev->DrawLine( Point( rRect.Left(), rRect.Top()+1), Point( rRect.Left(), rRect.Bottom()-1) );
701                 pDev->DrawLine( Point( rRect.Right(), rRect.Top()+1), Point( rRect.Right(), rRect.Bottom()-1) );
702             }
703             else
704                 pDev->DrawRect( rRect );
705         }
706         else
707         {
708             long nWidth = rRect.GetWidth();
709             long nHeight = rRect.GetHeight();
710             pDev->SetLineColor();
711             pDev->SetFillColor( *pColor );
712             pDev->DrawRect( Rectangle( rRect.TopLeft(), Size( nWidth, nLineHeight ) ) );
713             pDev->DrawRect( Rectangle( rRect.TopLeft(), Size( nLineWidth, nHeight ) ) );
714             pDev->DrawRect( Rectangle( Point( rRect.Left(), rRect.Bottom()-nLineHeight ),
715                                        Size( nWidth, nLineHeight ) ) );
716             pDev->DrawRect( Rectangle( Point( rRect.Right()-nLineWidth, rRect.Top() ),
717                                        Size( nLineWidth, nHeight ) ) );
718         }
719     }
720 
721     rRect.Left()    += nLineWidth;
722     rRect.Top()     += nLineHeight;
723     rRect.Right()   -= nLineWidth;
724     rRect.Bottom()  -= nLineHeight;
725 }
726 
727 // =======================================================================
728 
729 static void ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect,
730                            const StyleSettings& rStyleSettings, sal_uInt16 nStyle )
731 {
732     // mask menu style
733     sal_Bool bMenuStyle = (nStyle & FRAME_DRAW_MENU) ? sal_True : sal_False;
734     nStyle &= ~FRAME_DRAW_MENU;
735 
736     Window *pWin = NULL;
737     if( pDev->GetOutDevType() == OUTDEV_WINDOW )
738         pWin = (Window*) pDev;
739 
740     // UseFlatBorders disables 3D style for all frames except menus
741     // menus may use different border colors (e.g. on XP)
742     // normal frames will be drawn using the shadow color
743     // whereas window frame borders will use black
744     sal_Bool bFlatBorders = ( !bMenuStyle && rStyleSettings.GetUseFlatBorders() );
745 
746     // no flat borders for standard VCL controls (i.e. formcontrols that keep their classic look)
747     // will not affect frame windows (like dropdowns)
748     if( bFlatBorders && pWin && pWin->GetType() == WINDOW_BORDERWINDOW && (pWin != pWin->ImplGetFrameWindow()) )
749     {
750         // check for formcontrol, i.e., a control without NWF enabled
751         Control *pControl = dynamic_cast< Control* >( pWin->GetWindow( WINDOW_CLIENT ) );
752         if( pControl && pControl->IsNativeWidgetEnabled() )
753             bFlatBorders = sal_True;
754         else
755             bFlatBorders = sal_False;
756     }
757 
758     // no round corners for window frame borders
759     sal_Bool bRound = (bFlatBorders && !(nStyle & FRAME_DRAW_WINDOWBORDER));
760 
761     if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ||
762          (pDev->GetOutDevType() == OUTDEV_PRINTER) ||
763          bFlatBorders )
764         nStyle |= FRAME_DRAW_MONO;
765 
766     if ( nStyle & FRAME_DRAW_NODRAW )
767     {
768         sal_uInt16 nValueStyle = bMenuStyle ? nStyle | FRAME_DRAW_MENU : nStyle;
769         if( pWin->GetType() == WINDOW_BORDERWINDOW )
770             nValueStyle |= FRAME_DRAW_BORDERWINDOWBORDER;
771         ImplControlValue aControlValue( nValueStyle );
772         Rectangle aBound, aContent;
773         Rectangle aNatRgn( rRect );
774         if(pWin && pWin->GetNativeControlRegion(CTRL_FRAME, PART_BORDER,
775             aNatRgn, 0, aControlValue, rtl::OUString(), aBound, aContent) )
776         {
777             rRect = aContent;
778         }
779         else if ( nStyle & FRAME_DRAW_MONO )
780             ImplDrawDPILineRect( pDev, rRect, NULL, bRound );
781         else
782         {
783             sal_uInt16 nFrameStyle = nStyle & FRAME_DRAW_STYLE;
784 
785             if ( nFrameStyle == FRAME_DRAW_GROUP )
786             {
787                 rRect.Left()    += 2;
788                 rRect.Top()     += 2;
789                 rRect.Right()   -= 2;
790                 rRect.Bottom()  -= 2;
791             }
792             else if ( (nFrameStyle == FRAME_DRAW_IN) ||
793                       (nFrameStyle == FRAME_DRAW_OUT) )
794             {
795                 rRect.Left()++;
796                 rRect.Top()++;
797                 rRect.Right()--;
798                 rRect.Bottom()--;
799             }
800             else // FRAME_DRAW_DOUBLEIN || FRAME_DRAW_DOUBLEOUT
801             {
802                 rRect.Left()    += 2;
803                 rRect.Top()     += 2;
804                 rRect.Right()   -= 2;
805                 rRect.Bottom()  -= 2;
806             }
807         }
808     }
809     else
810     {
811         if( pWin && pWin->IsNativeControlSupported(CTRL_FRAME, PART_BORDER) )
812         {
813             sal_uInt16 nValueStyle = bMenuStyle ? nStyle | FRAME_DRAW_MENU : nStyle;
814             if( pWin->GetType() == WINDOW_BORDERWINDOW )
815                 nValueStyle |= FRAME_DRAW_BORDERWINDOWBORDER;
816             ImplControlValue aControlValue( nValueStyle );
817             Rectangle aBound, aContent;
818             Rectangle aNatRgn( rRect );
819             if( pWin->GetNativeControlRegion(CTRL_FRAME, PART_BORDER,
820                 aNatRgn, 0, aControlValue, rtl::OUString(), aBound, aContent) )
821             {
822                 if( pWin->DrawNativeControl( CTRL_FRAME, PART_BORDER, aContent, CTRL_STATE_ENABLED,
823                             aControlValue, rtl::OUString()) )
824                 {
825                     rRect = aContent;
826                     return;
827                 }
828             }
829         }
830 
831         if ( nStyle & FRAME_DRAW_MONO )
832         {
833             Color aColor = bRound ? rStyleSettings.GetShadowColor()
834                                   : pDev->GetSettings().GetStyleSettings().GetMonoColor();
835             // when the MonoColor wasn't set, check face color
836             if (
837                 (bRound && aColor.IsDark()) ||
838                 (
839                     (aColor == Color(COL_BLACK)) &&
840                     (pDev->GetSettings().GetStyleSettings().GetFaceColor().IsDark())
841                 )
842                )
843             {
844                 aColor = Color( COL_WHITE );
845             }
846             ImplDrawDPILineRect( pDev, rRect, &aColor, bRound );
847         }
848         else
849         {
850             sal_uInt16 nFrameStyle = nStyle & FRAME_DRAW_STYLE;
851             if ( nFrameStyle == FRAME_DRAW_GROUP )
852             {
853                 pDev->SetFillColor();
854                 pDev->SetLineColor( rStyleSettings.GetLightColor() );
855                 rRect.Top()++;
856                 rRect.Left()++;
857                 pDev->DrawRect( rRect );
858                 rRect.Top()--;
859                 rRect.Left()--;
860                 pDev->SetLineColor( rStyleSettings.GetShadowColor() );
861                 rRect.Right()--;
862                 rRect.Bottom()--;
863                 pDev->DrawRect( rRect );
864                 rRect.Right()++;
865                 rRect.Bottom()++;
866             }
867             else
868             {
869                 pDev->SetLineColor();
870 
871                 if ( (nFrameStyle == FRAME_DRAW_IN) ||
872                      (nFrameStyle == FRAME_DRAW_OUT) )
873                 {
874                     if ( nFrameStyle == FRAME_DRAW_IN )
875                     {
876                         pDev->ImplDraw2ColorFrame( rRect,
877                                                    rStyleSettings.GetShadowColor(),
878                                                    rStyleSettings.GetLightColor() );
879                     }
880                     else
881                     {
882                         pDev->ImplDraw2ColorFrame( rRect,
883                                                    rStyleSettings.GetLightColor(),
884                                                    rStyleSettings.GetShadowColor() );
885                     }
886 
887                     rRect.Left()++;
888                     rRect.Top()++;
889                     rRect.Right()--;
890                     rRect.Bottom()--;
891                 }
892                 else // FRAME_DRAW_DOUBLEIN || FRAME_DRAW_DOUBLEOUT
893                 {
894                     if ( nFrameStyle == FRAME_DRAW_DOUBLEIN )
895                     {
896                         if( bFlatBorders ) // no 3d effect
897                             pDev->ImplDraw2ColorFrame( rRect,
898                                                     rStyleSettings.GetShadowColor(),
899                                                     rStyleSettings.GetShadowColor() );
900                         else
901                             pDev->ImplDraw2ColorFrame( rRect,
902                                                     rStyleSettings.GetShadowColor(),
903                                                     rStyleSettings.GetLightColor() );
904                     }
905                     else
906                     {
907                         if( bMenuStyle )
908                             pDev->ImplDraw2ColorFrame( rRect,
909                                                     rStyleSettings.GetMenuBorderColor(),
910                                                     rStyleSettings.GetDarkShadowColor() );
911                         else
912                             pDev->ImplDraw2ColorFrame( rRect,
913                                                     bFlatBorders ? // no 3d effect
914                                                     rStyleSettings.GetDarkShadowColor() :
915                                                     rStyleSettings.GetLightBorderColor(),
916                                                     rStyleSettings.GetDarkShadowColor() );
917 
918                     }
919 
920                     rRect.Left()++;
921                     rRect.Top()++;
922                     rRect.Right()--;
923                     rRect.Bottom()--;
924 
925                     sal_Bool bDrawn = sal_True;
926                     if ( nFrameStyle == FRAME_DRAW_DOUBLEIN )
927                     {
928                         if( bFlatBorders ) // no 3d effect
929                             pDev->ImplDraw2ColorFrame( rRect,
930                                                     rStyleSettings.GetFaceColor(),
931                                                     rStyleSettings.GetFaceColor() );
932                         else
933                             pDev->ImplDraw2ColorFrame( rRect,
934                                                     rStyleSettings.GetDarkShadowColor(),
935                                                     rStyleSettings.GetLightBorderColor() );
936                     }
937                     else
938                     {
939                         // flat menus have no shadow border
940                         if( !bMenuStyle || !rStyleSettings.GetUseFlatMenues() )
941                             pDev->ImplDraw2ColorFrame( rRect,
942                                                     rStyleSettings.GetLightColor(),
943                                                     rStyleSettings.GetShadowColor() );
944                         else
945                             bDrawn = sal_False;
946                     }
947                     if( bDrawn )
948                     {
949                         rRect.Left()++;
950                         rRect.Top()++;
951                         rRect.Right()--;
952                         rRect.Bottom()--;
953                     }
954                 }
955             }
956         }
957     }
958 }
959 
960 // -----------------------------------------------------------------------
961 
962 Rectangle DecorationView::DrawFrame( const Rectangle& rRect, sal_uInt16 nStyle )
963 {
964     Rectangle   aRect = rRect;
965     sal_Bool        bOldMap = mpOutDev->IsMapModeEnabled();
966     if ( bOldMap )
967     {
968         aRect = mpOutDev->LogicToPixel( aRect );
969         mpOutDev->EnableMapMode( sal_False );
970     }
971 
972     if ( !rRect.IsEmpty() )
973     {
974         if ( nStyle & FRAME_DRAW_NODRAW )
975              ImplDrawFrame( mpOutDev, aRect, mpOutDev->GetSettings().GetStyleSettings(), nStyle );
976         else
977         {
978              Color maOldLineColor  = mpOutDev->GetLineColor();
979              Color maOldFillColor  = mpOutDev->GetFillColor();
980              ImplDrawFrame( mpOutDev, aRect, mpOutDev->GetSettings().GetStyleSettings(), nStyle );
981              mpOutDev->SetLineColor( maOldLineColor );
982              mpOutDev->SetFillColor( maOldFillColor );
983         }
984     }
985 
986     if ( bOldMap )
987     {
988         mpOutDev->EnableMapMode( bOldMap );
989         aRect = mpOutDev->PixelToLogic( aRect );
990     }
991 
992     return aRect;
993 }
994 
995 // =======================================================================
996 
997 static void ImplDrawButton( OutputDevice* pDev, Rectangle& rRect,
998                             const StyleSettings& rStyleSettings, sal_uInt16 nStyle )
999 {
1000     Rectangle aFillRect = rRect;
1001 
1002     if ( nStyle & BUTTON_DRAW_MONO )
1003     {
1004         if ( !(nStyle & BUTTON_DRAW_NODRAW) )
1005         {
1006             Color aBlackColor( COL_BLACK );
1007 
1008             if ( nStyle & BUTTON_DRAW_DEFAULT )
1009                 ImplDrawDPILineRect( pDev, aFillRect, &aBlackColor );
1010 
1011             ImplDrawDPILineRect( pDev, aFillRect, &aBlackColor );
1012 
1013             Size aBrdSize( 1, 1 );
1014             if ( pDev->GetOutDevType() == OUTDEV_PRINTER )
1015             {
1016                 MapMode aResMapMode( MAP_100TH_MM );
1017                 aBrdSize = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode );
1018                 if ( !aBrdSize.Width() )
1019                     aBrdSize.Width() = 1;
1020                 if ( !aBrdSize.Height() )
1021                     aBrdSize.Height() = 1;
1022             }
1023             pDev->SetLineColor();
1024             pDev->SetFillColor( aBlackColor );
1025             Rectangle aRect1;
1026             Rectangle aRect2;
1027             aRect1.Left()   = aFillRect.Left();
1028             aRect1.Right()  = aFillRect.Right(),
1029             aRect2.Top()    = aFillRect.Top();
1030             aRect2.Bottom() = aFillRect.Bottom();
1031             if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
1032             {
1033                 aRect1.Top()    = aFillRect.Top();
1034                 aRect1.Bottom() = aBrdSize.Height()-1;
1035                 aRect2.Left()   = aFillRect.Left();
1036                 aRect2.Right()  = aFillRect.Left()+aBrdSize.Width()-1;
1037                 aFillRect.Left() += aBrdSize.Width();
1038                 aFillRect.Top()  += aBrdSize.Height();
1039             }
1040             else
1041             {
1042                 aRect1.Top()    = aFillRect.Bottom()-aBrdSize.Height()+1;
1043                 aRect1.Bottom() = aFillRect.Bottom();
1044                 aRect2.Left()   = aFillRect.Right()-aBrdSize.Width()+1;
1045                 aRect2.Right()  = aFillRect.Right(),
1046                 aFillRect.Right()  -= aBrdSize.Width();
1047                 aFillRect.Bottom() -= aBrdSize.Height();
1048             }
1049             pDev->DrawRect( aRect1 );
1050             pDev->DrawRect( aRect2 );
1051         }
1052     }
1053     else
1054     {
1055         if ( !(nStyle & BUTTON_DRAW_NODRAW) )
1056         {
1057             if ( nStyle & BUTTON_DRAW_DEFAULT )
1058             {
1059                 Color aDefBtnColor = rStyleSettings.GetDarkShadowColor();
1060                 ImplDrawDPILineRect( pDev, aFillRect, &aDefBtnColor );
1061             }
1062         }
1063 
1064         if ( !(nStyle & BUTTON_DRAW_NODRAW) )
1065         {
1066             pDev->SetLineColor();
1067             if ( nStyle & BUTTON_DRAW_NOLEFTLIGHTBORDER )
1068             {
1069                 pDev->SetFillColor( rStyleSettings.GetLightBorderColor() );
1070                 pDev->DrawRect( Rectangle( aFillRect.Left(), aFillRect.Top(),
1071                                            aFillRect.Left(), aFillRect.Bottom() ) );
1072                 aFillRect.Left()++;
1073             }
1074             if ( (nStyle & BUTTON_DRAW_NOTOPLIGHTBORDER) &&
1075                  !(nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED)) )
1076             {
1077                 pDev->SetFillColor( rStyleSettings.GetLightBorderColor() );
1078                 pDev->DrawRect( Rectangle( aFillRect.Left(), aFillRect.Top(),
1079                                            aFillRect.Right(), aFillRect.Top() ) );
1080                 aFillRect.Top()++;
1081             }
1082             if ( (( (nStyle & BUTTON_DRAW_NOBOTTOMSHADOWBORDER) | BUTTON_DRAW_FLAT) == (BUTTON_DRAW_NOBOTTOMSHADOWBORDER | BUTTON_DRAW_FLAT)) &&
1083                  !(nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED | BUTTON_DRAW_HIGHLIGHT)) )
1084             {
1085                 pDev->SetFillColor( rStyleSettings.GetDarkShadowColor() );
1086                 pDev->DrawRect( Rectangle( aFillRect.Left(), aFillRect.Bottom(),
1087                                            aFillRect.Right(), aFillRect.Bottom() ) );
1088                 aFillRect.Bottom()--;
1089             }
1090 
1091             Color aColor1;
1092             Color aColor2;
1093             if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
1094             {
1095                 aColor1 = rStyleSettings.GetDarkShadowColor();
1096                 aColor2 = rStyleSettings.GetLightColor();
1097             }
1098             else
1099             {
1100                 if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER )
1101                     aColor1 = rStyleSettings.GetLightBorderColor();
1102                 else
1103                     aColor1 = rStyleSettings.GetLightColor();
1104                 if ( (nStyle & BUTTON_DRAW_FLATTEST) == BUTTON_DRAW_FLAT )
1105                     aColor2 = rStyleSettings.GetShadowColor();
1106                 else
1107                     aColor2 = rStyleSettings.GetDarkShadowColor();
1108             }
1109             pDev->ImplDraw2ColorFrame( aFillRect, aColor1, aColor2 );
1110             aFillRect.Left()++;
1111             aFillRect.Top()++;
1112             aFillRect.Right()--;
1113             aFillRect.Bottom()--;
1114 
1115             if ( !((nStyle & BUTTON_DRAW_FLATTEST) == BUTTON_DRAW_FLAT) )
1116             {
1117                 if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
1118                 {
1119                     aColor1 = rStyleSettings.GetShadowColor();
1120                     aColor2 = rStyleSettings.GetLightBorderColor();
1121                 }
1122                 else
1123                 {
1124                     if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER )
1125                         aColor1 = rStyleSettings.GetLightColor();
1126                     else
1127                         aColor1 = rStyleSettings.GetLightBorderColor();
1128                     aColor2 = rStyleSettings.GetShadowColor();
1129                 }
1130                 pDev->ImplDraw2ColorFrame( aFillRect, aColor1, aColor2 );
1131                 aFillRect.Left()++;
1132                 aFillRect.Top()++;
1133                 aFillRect.Right()--;
1134                 aFillRect.Bottom()--;
1135             }
1136         }
1137     }
1138 
1139     if ( !(nStyle & (BUTTON_DRAW_NOFILL | BUTTON_DRAW_NODRAW)) )
1140     {
1141         pDev->SetLineColor();
1142         if ( nStyle & BUTTON_DRAW_MONO )
1143         {
1144             // Hack: Auf Druckern wollen wir im Mon oChrom-Modus trotzdem
1145             // erstmal graue Buttons haben
1146             if ( pDev->GetOutDevType() == OUTDEV_PRINTER )
1147                 pDev->SetFillColor( Color( COL_LIGHTGRAY ) );
1148             else
1149                 pDev->SetFillColor( Color( COL_WHITE ) );
1150         }
1151         else
1152         {
1153             if ( nStyle & (BUTTON_DRAW_CHECKED | BUTTON_DRAW_DONTKNOW) )
1154                 pDev->SetFillColor( rStyleSettings.GetCheckedColor() );
1155             else
1156                 pDev->SetFillColor( rStyleSettings.GetFaceColor() );
1157         }
1158         pDev->DrawRect( aFillRect );
1159     }
1160 
1161     // Ein Border freilassen, der jedoch bei Default-Darstellung
1162     // mitbenutzt wird
1163     rRect.Left()++;
1164     rRect.Top()++;
1165     rRect.Right()--;
1166     rRect.Bottom()--;
1167 
1168     if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER )
1169     {
1170         rRect.Left()++;
1171         rRect.Top()++;
1172     }
1173     else if ( nStyle & BUTTON_DRAW_NOLEFTLIGHTBORDER )
1174         rRect.Left()++;
1175 
1176     if ( nStyle & BUTTON_DRAW_PRESSED )
1177     {
1178         if ( (rRect.GetHeight() > 10) && (rRect.GetWidth() > 10) )
1179         {
1180             rRect.Left()    += 4;
1181             rRect.Top()     += 4;
1182             rRect.Right()   -= 1;
1183             rRect.Bottom()  -= 1;
1184         }
1185         else
1186         {
1187             rRect.Left()    += 3;
1188             rRect.Top()     += 3;
1189             rRect.Right()   -= 2;
1190             rRect.Bottom()  -= 2;
1191         }
1192     }
1193     else if ( nStyle & BUTTON_DRAW_CHECKED )
1194     {
1195         rRect.Left()    += 3;
1196         rRect.Top()     += 3;
1197         rRect.Right()   -= 2;
1198         rRect.Bottom()  -= 2;
1199     }
1200     else
1201     {
1202         rRect.Left()    += 2;
1203         rRect.Top()     += 2;
1204         rRect.Right()   -= 3;
1205         rRect.Bottom()  -= 3;
1206     }
1207 }
1208 
1209 // -----------------------------------------------------------------------
1210 
1211 Rectangle DecorationView::DrawButton( const Rectangle& rRect, sal_uInt16 nStyle )
1212 {
1213     Rectangle   aRect = rRect;
1214     sal_Bool        bOldMap = mpOutDev->IsMapModeEnabled();
1215     if ( bOldMap )
1216     {
1217         aRect = mpOutDev->LogicToPixel( aRect );
1218         mpOutDev->EnableMapMode( sal_False );
1219     }
1220 
1221     if ( !rRect.IsEmpty() )
1222     {
1223         const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings();
1224 
1225         if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
1226             nStyle |= BUTTON_DRAW_MONO;
1227 
1228         if ( nStyle & BUTTON_DRAW_NODRAW )
1229              ImplDrawButton( mpOutDev, aRect, rStyleSettings, nStyle );
1230         else
1231         {
1232              Color maOldLineColor  = mpOutDev->GetLineColor();
1233              Color maOldFillColor  = mpOutDev->GetFillColor();
1234              ImplDrawButton( mpOutDev, aRect, rStyleSettings, nStyle );
1235              mpOutDev->SetLineColor( maOldLineColor );
1236              mpOutDev->SetFillColor( maOldFillColor );
1237         }
1238     }
1239 
1240     if ( bOldMap )
1241     {
1242         mpOutDev->EnableMapMode( bOldMap );
1243         aRect = mpOutDev->PixelToLogic( aRect );
1244     }
1245 
1246     return aRect;
1247 }
1248 
1249 // -----------------------------------------------------------------------
1250 
1251 void DecorationView::DrawSeparator( const Point& rStart, const Point& rStop, bool bVertical )
1252 {
1253     Point aStart( rStart ), aStop( rStop );
1254     const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings();
1255 
1256     mpOutDev->Push( PUSH_LINECOLOR );
1257     if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
1258         mpOutDev->SetLineColor( Color( COL_BLACK ) );
1259     else
1260         mpOutDev->SetLineColor( rStyleSettings.GetShadowColor() );
1261 
1262     mpOutDev->DrawLine( aStart, aStop );
1263     if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
1264     {
1265         mpOutDev->SetLineColor( rStyleSettings.GetLightColor() );
1266         if( bVertical )
1267         {
1268             aStart.X()++;
1269             aStop.X()++;
1270         }
1271         else
1272         {
1273             aStart.Y()++;
1274             aStop.Y()++;
1275         }
1276         mpOutDev->DrawLine( aStart, aStop );
1277     }
1278     mpOutDev->Pop();
1279 }
1280 
1281 /* vim: set noet sw=4 ts=4: */
1282