xref: /trunk/main/vcl/source/window/decoview.cxx (revision 1ce07f25dfc815f42a7f16b3ee2e0bd0fc9b6c64)
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 
ImplDrawSymbol(OutputDevice * pDev,const Rectangle & rRect,SymbolType eType)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 
DrawSymbol(const Rectangle & rRect,SymbolType eType,const Color & rColor,sal_uInt16 nStyle)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 Disabled ausgeben
593             mpOutDev->SetFillColor( rStyleSettings.GetShadowColor() );
594         }
595         else
596             mpOutDev->SetFillColor( rColor );
597     }
598 
599     ImplDrawSymbol( mpOutDev, aRect, eType );
600 
601     mpOutDev->SetLineColor( aOldLineColor );
602     mpOutDev->SetFillColor( aOldFillColor );
603     mpOutDev->EnableMapMode( bOldMapMode );
604 }
605 
606 // =======================================================================
607 
DrawFrame(const Rectangle & rRect,const Color & rLeftTopColor,const Color & rRightBottomColor)608 void DecorationView::DrawFrame( const Rectangle& rRect,
609                                 const Color& rLeftTopColor,
610                                 const Color& rRightBottomColor )
611 {
612     Rectangle   aRect           = mpOutDev->LogicToPixel( rRect );
613     Color       aOldLineColor   = mpOutDev->GetLineColor();
614     Color       aOldFillColor   = mpOutDev->GetFillColor();
615     sal_Bool        bOldMapMode     = mpOutDev->IsMapModeEnabled();
616     mpOutDev->EnableMapMode( sal_False );
617     mpOutDev->SetLineColor();
618     mpOutDev->ImplDraw2ColorFrame( aRect, rLeftTopColor, rRightBottomColor );
619     mpOutDev->SetLineColor( aOldLineColor );
620     mpOutDev->SetFillColor( aOldFillColor );
621     mpOutDev->EnableMapMode( bOldMapMode );
622 }
623 
624 // =======================================================================
625 
DrawHighlightFrame(const Rectangle & rRect,sal_uInt16 nStyle)626 void DecorationView::DrawHighlightFrame( const Rectangle& rRect,
627                                          sal_uInt16 nStyle )
628 {
629     const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings();
630     Color aLightColor = rStyleSettings.GetLightColor();
631     Color aShadowColor = rStyleSettings.GetShadowColor();
632 
633     if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ||
634          (mpOutDev->GetOutDevType() == OUTDEV_PRINTER) )
635     {
636         aLightColor = Color( COL_BLACK );
637         aShadowColor = Color( COL_BLACK );
638     }
639     else if ( nStyle & FRAME_HIGHLIGHT_TESTBACKGROUND )
640     {
641         Wallpaper aBackground = mpOutDev->GetBackground();
642         if ( aBackground.IsBitmap() || aBackground.IsGradient() )
643         {
644             aLightColor = rStyleSettings.GetFaceColor();
645             aShadowColor = Color( COL_BLACK );
646         }
647         else
648         {
649             Color aBackColor = aBackground.GetColor();
650             if ( (aLightColor.GetColorError( aBackColor ) < 32) ||
651                  (aShadowColor.GetColorError( aBackColor ) < 32) )
652             {
653                 aLightColor = Color( COL_WHITE );
654                 aShadowColor = Color( COL_BLACK );
655 
656                 if ( aLightColor.GetColorError( aBackColor ) < 32 )
657                     aLightColor.DecreaseLuminance( 64 );
658                 if ( aShadowColor.GetColorError( aBackColor ) < 32 )
659                     aShadowColor.IncreaseLuminance( 64 );
660             }
661         }
662     }
663 
664     if ( (nStyle & FRAME_HIGHLIGHT_STYLE) == FRAME_HIGHLIGHT_IN )
665     {
666         Color aTempColor = aLightColor;
667         aLightColor = aShadowColor;
668         aShadowColor = aTempColor;
669     }
670 
671     DrawFrame( rRect, aLightColor, aShadowColor );
672 }
673 
674 // =======================================================================
675 
ImplDrawDPILineRect(OutputDevice * pDev,Rectangle & rRect,const Color * pColor,sal_Bool bRound=sal_False)676 static void ImplDrawDPILineRect( OutputDevice* pDev, Rectangle& rRect,
677                                  const Color* pColor, sal_Bool bRound = sal_False )
678 {
679     long nLineWidth = pDev->ImplGetDPIX()/300;
680     long nLineHeight = pDev->ImplGetDPIY()/300;
681     if ( !nLineWidth )
682         nLineWidth = 1;
683     if ( !nLineHeight )
684         nLineHeight = 1;
685 
686     if ( pColor )
687     {
688         if ( (nLineWidth == 1) && (nLineHeight == 1) )
689         {
690             pDev->SetLineColor( *pColor );
691             pDev->SetFillColor();
692             if( bRound )
693             {
694                 pDev->DrawLine( Point( rRect.Left()+1, rRect.Top()), Point( rRect.Right()-1, rRect.Top()) );
695                 pDev->DrawLine( Point( rRect.Left()+1, rRect.Bottom()), Point( rRect.Right()-1, rRect.Bottom()) );
696                 pDev->DrawLine( Point( rRect.Left(), rRect.Top()+1), Point( rRect.Left(), rRect.Bottom()-1) );
697                 pDev->DrawLine( Point( rRect.Right(), rRect.Top()+1), Point( rRect.Right(), rRect.Bottom()-1) );
698             }
699             else
700                 pDev->DrawRect( rRect );
701         }
702         else
703         {
704             long nWidth = rRect.GetWidth();
705             long nHeight = rRect.GetHeight();
706             pDev->SetLineColor();
707             pDev->SetFillColor( *pColor );
708             pDev->DrawRect( Rectangle( rRect.TopLeft(), Size( nWidth, nLineHeight ) ) );
709             pDev->DrawRect( Rectangle( rRect.TopLeft(), Size( nLineWidth, nHeight ) ) );
710             pDev->DrawRect( Rectangle( Point( rRect.Left(), rRect.Bottom()-nLineHeight ),
711                                        Size( nWidth, nLineHeight ) ) );
712             pDev->DrawRect( Rectangle( Point( rRect.Right()-nLineWidth, rRect.Top() ),
713                                        Size( nLineWidth, nHeight ) ) );
714         }
715     }
716 
717     rRect.Left()    += nLineWidth;
718     rRect.Top()     += nLineHeight;
719     rRect.Right()   -= nLineWidth;
720     rRect.Bottom()  -= nLineHeight;
721 }
722 
723 // =======================================================================
724 
ImplDrawFrame(OutputDevice * pDev,Rectangle & rRect,const StyleSettings & rStyleSettings,sal_uInt16 nStyle)725 static void ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect,
726                            const StyleSettings& rStyleSettings, sal_uInt16 nStyle )
727 {
728     // mask menu style
729     sal_Bool bMenuStyle = (nStyle & FRAME_DRAW_MENU) ? sal_True : sal_False;
730     nStyle &= ~FRAME_DRAW_MENU;
731 
732     Window *pWin = NULL;
733     if( pDev->GetOutDevType() == OUTDEV_WINDOW )
734         pWin = (Window*) pDev;
735 
736     // UseFlatBorders disables 3D style for all frames except menus
737     // menus may use different border colors (e.g. on XP)
738     // normal frames will be drawn using the shadow color
739     // whereas window frame borders will use black
740     sal_Bool bFlatBorders = ( !bMenuStyle && rStyleSettings.GetUseFlatBorders() );
741 
742     // no flat borders for standard VCL controls (i.e. formcontrols that keep their classic look)
743     // will not affect frame windows (like dropdowns)
744     if( bFlatBorders && pWin && pWin->GetType() == WINDOW_BORDERWINDOW && (pWin != pWin->ImplGetFrameWindow()) )
745     {
746         // check for formcontrol, i.e., a control without NWF enabled
747         Control *pControl = dynamic_cast< Control* >( pWin->GetWindow( WINDOW_CLIENT ) );
748         if( pControl && pControl->IsNativeWidgetEnabled() )
749             bFlatBorders = sal_True;
750         else
751             bFlatBorders = sal_False;
752     }
753 
754     // no round corners for window frame borders
755     sal_Bool bRound = (bFlatBorders && !(nStyle & FRAME_DRAW_WINDOWBORDER));
756 
757     if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ||
758          (pDev->GetOutDevType() == OUTDEV_PRINTER) ||
759          bFlatBorders )
760         nStyle |= FRAME_DRAW_MONO;
761 
762     if ( nStyle & FRAME_DRAW_NODRAW )
763     {
764         sal_uInt16 nValueStyle = bMenuStyle ? nStyle | FRAME_DRAW_MENU : nStyle;
765         if( pWin->GetType() == WINDOW_BORDERWINDOW )
766             nValueStyle |= FRAME_DRAW_BORDERWINDOWBORDER;
767         ImplControlValue aControlValue( nValueStyle );
768         Rectangle aBound, aContent;
769         Rectangle aNatRgn( rRect );
770         if(pWin && pWin->GetNativeControlRegion(CTRL_FRAME, PART_BORDER,
771             aNatRgn, 0, aControlValue, rtl::OUString(), aBound, aContent) )
772         {
773             rRect = aContent;
774         }
775         else if ( nStyle & FRAME_DRAW_MONO )
776             ImplDrawDPILineRect( pDev, rRect, NULL, bRound );
777         else
778         {
779             sal_uInt16 nFrameStyle = nStyle & FRAME_DRAW_STYLE;
780 
781             if ( nFrameStyle == FRAME_DRAW_GROUP )
782             {
783                 rRect.Left()    += 2;
784                 rRect.Top()     += 2;
785                 rRect.Right()   -= 2;
786                 rRect.Bottom()  -= 2;
787             }
788             else if ( (nFrameStyle == FRAME_DRAW_IN) ||
789                       (nFrameStyle == FRAME_DRAW_OUT) )
790             {
791                 rRect.Left()++;
792                 rRect.Top()++;
793                 rRect.Right()--;
794                 rRect.Bottom()--;
795             }
796             else // FRAME_DRAW_DOUBLEIN || FRAME_DRAW_DOUBLEOUT
797             {
798                 rRect.Left()    += 2;
799                 rRect.Top()     += 2;
800                 rRect.Right()   -= 2;
801                 rRect.Bottom()  -= 2;
802             }
803         }
804     }
805     else
806     {
807         if( pWin && pWin->IsNativeControlSupported(CTRL_FRAME, PART_BORDER) )
808         {
809             sal_uInt16 nValueStyle = bMenuStyle ? nStyle | FRAME_DRAW_MENU : nStyle;
810             if( pWin->GetType() == WINDOW_BORDERWINDOW )
811                 nValueStyle |= FRAME_DRAW_BORDERWINDOWBORDER;
812             ImplControlValue aControlValue( nValueStyle );
813             Rectangle aBound, aContent;
814             Rectangle aNatRgn( rRect );
815             if( pWin->GetNativeControlRegion(CTRL_FRAME, PART_BORDER,
816                 aNatRgn, 0, aControlValue, rtl::OUString(), aBound, aContent) )
817             {
818                 if( pWin->DrawNativeControl( CTRL_FRAME, PART_BORDER, aContent, CTRL_STATE_ENABLED,
819                             aControlValue, rtl::OUString()) )
820                 {
821                     rRect = aContent;
822                     return;
823                 }
824             }
825         }
826 
827         if ( nStyle & FRAME_DRAW_MONO )
828         {
829             Color aColor = bRound ? rStyleSettings.GetShadowColor()
830                                   : pDev->GetSettings().GetStyleSettings().GetMonoColor();
831             // when the MonoColor wasn't set, check face color
832             if (
833                 (bRound && aColor.IsDark()) ||
834                 (
835                     (aColor == Color(COL_BLACK)) &&
836                     (pDev->GetSettings().GetStyleSettings().GetFaceColor().IsDark())
837                 )
838                )
839             {
840                 aColor = Color( COL_WHITE );
841             }
842             ImplDrawDPILineRect( pDev, rRect, &aColor, bRound );
843         }
844         else
845         {
846             sal_uInt16 nFrameStyle = nStyle & FRAME_DRAW_STYLE;
847             if ( nFrameStyle == FRAME_DRAW_GROUP )
848             {
849                 pDev->SetFillColor();
850                 pDev->SetLineColor( rStyleSettings.GetLightColor() );
851                 rRect.Top()++;
852                 rRect.Left()++;
853                 pDev->DrawRect( rRect );
854                 rRect.Top()--;
855                 rRect.Left()--;
856                 pDev->SetLineColor( rStyleSettings.GetShadowColor() );
857                 rRect.Right()--;
858                 rRect.Bottom()--;
859                 pDev->DrawRect( rRect );
860                 rRect.Right()++;
861                 rRect.Bottom()++;
862             }
863             else
864             {
865                 pDev->SetLineColor();
866 
867                 if ( (nFrameStyle == FRAME_DRAW_IN) ||
868                      (nFrameStyle == FRAME_DRAW_OUT) )
869                 {
870                     if ( nFrameStyle == FRAME_DRAW_IN )
871                     {
872                         pDev->ImplDraw2ColorFrame( rRect,
873                                                    rStyleSettings.GetShadowColor(),
874                                                    rStyleSettings.GetLightColor() );
875                     }
876                     else
877                     {
878                         pDev->ImplDraw2ColorFrame( rRect,
879                                                    rStyleSettings.GetLightColor(),
880                                                    rStyleSettings.GetShadowColor() );
881                     }
882 
883                     rRect.Left()++;
884                     rRect.Top()++;
885                     rRect.Right()--;
886                     rRect.Bottom()--;
887                 }
888                 else // FRAME_DRAW_DOUBLEIN || FRAME_DRAW_DOUBLEOUT
889                 {
890                     if ( nFrameStyle == FRAME_DRAW_DOUBLEIN )
891                     {
892                         if( bFlatBorders ) // no 3d effect
893                             pDev->ImplDraw2ColorFrame( rRect,
894                                                     rStyleSettings.GetShadowColor(),
895                                                     rStyleSettings.GetShadowColor() );
896                         else
897                             pDev->ImplDraw2ColorFrame( rRect,
898                                                     rStyleSettings.GetShadowColor(),
899                                                     rStyleSettings.GetLightColor() );
900                     }
901                     else
902                     {
903                         if( bMenuStyle )
904                             pDev->ImplDraw2ColorFrame( rRect,
905                                                     rStyleSettings.GetMenuBorderColor(),
906                                                     rStyleSettings.GetDarkShadowColor() );
907                         else
908                             pDev->ImplDraw2ColorFrame( rRect,
909                                                     bFlatBorders ? // no 3d effect
910                                                     rStyleSettings.GetDarkShadowColor() :
911                                                     rStyleSettings.GetLightBorderColor(),
912                                                     rStyleSettings.GetDarkShadowColor() );
913 
914                     }
915 
916                     rRect.Left()++;
917                     rRect.Top()++;
918                     rRect.Right()--;
919                     rRect.Bottom()--;
920 
921                     sal_Bool bDrawn = sal_True;
922                     if ( nFrameStyle == FRAME_DRAW_DOUBLEIN )
923                     {
924                         if( bFlatBorders ) // no 3d effect
925                             pDev->ImplDraw2ColorFrame( rRect,
926                                                     rStyleSettings.GetFaceColor(),
927                                                     rStyleSettings.GetFaceColor() );
928                         else
929                             pDev->ImplDraw2ColorFrame( rRect,
930                                                     rStyleSettings.GetDarkShadowColor(),
931                                                     rStyleSettings.GetLightBorderColor() );
932                     }
933                     else
934                     {
935                         // flat menus have no shadow border
936                         if( !bMenuStyle || !rStyleSettings.GetUseFlatMenues() )
937                             pDev->ImplDraw2ColorFrame( rRect,
938                                                     rStyleSettings.GetLightColor(),
939                                                     rStyleSettings.GetShadowColor() );
940                         else
941                             bDrawn = sal_False;
942                     }
943                     if( bDrawn )
944                     {
945                         rRect.Left()++;
946                         rRect.Top()++;
947                         rRect.Right()--;
948                         rRect.Bottom()--;
949                     }
950                 }
951             }
952         }
953     }
954 }
955 
956 // -----------------------------------------------------------------------
957 
DrawFrame(const Rectangle & rRect,sal_uInt16 nStyle)958 Rectangle DecorationView::DrawFrame( const Rectangle& rRect, sal_uInt16 nStyle )
959 {
960     Rectangle   aRect = rRect;
961     sal_Bool        bOldMap = mpOutDev->IsMapModeEnabled();
962     if ( bOldMap )
963     {
964         aRect = mpOutDev->LogicToPixel( aRect );
965         mpOutDev->EnableMapMode( sal_False );
966     }
967 
968     if ( !rRect.IsEmpty() )
969     {
970         if ( nStyle & FRAME_DRAW_NODRAW )
971              ImplDrawFrame( mpOutDev, aRect, mpOutDev->GetSettings().GetStyleSettings(), nStyle );
972         else
973         {
974              Color maOldLineColor  = mpOutDev->GetLineColor();
975              Color maOldFillColor  = mpOutDev->GetFillColor();
976              ImplDrawFrame( mpOutDev, aRect, mpOutDev->GetSettings().GetStyleSettings(), nStyle );
977              mpOutDev->SetLineColor( maOldLineColor );
978              mpOutDev->SetFillColor( maOldFillColor );
979         }
980     }
981 
982     if ( bOldMap )
983     {
984         mpOutDev->EnableMapMode( bOldMap );
985         aRect = mpOutDev->PixelToLogic( aRect );
986     }
987 
988     return aRect;
989 }
990 
991 // =======================================================================
992 
ImplDrawButton(OutputDevice * pDev,Rectangle & rRect,const StyleSettings & rStyleSettings,sal_uInt16 nStyle)993 static void ImplDrawButton( OutputDevice* pDev, Rectangle& rRect,
994                             const StyleSettings& rStyleSettings, sal_uInt16 nStyle )
995 {
996     Rectangle aFillRect = rRect;
997 
998     if ( nStyle & BUTTON_DRAW_MONO )
999     {
1000         if ( !(nStyle & BUTTON_DRAW_NODRAW) )
1001         {
1002             Color aBlackColor( COL_BLACK );
1003 
1004             if ( nStyle & BUTTON_DRAW_DEFAULT )
1005                 ImplDrawDPILineRect( pDev, aFillRect, &aBlackColor );
1006 
1007             ImplDrawDPILineRect( pDev, aFillRect, &aBlackColor );
1008 
1009             Size aBrdSize( 1, 1 );
1010             if ( pDev->GetOutDevType() == OUTDEV_PRINTER )
1011             {
1012                 MapMode aResMapMode( MAP_100TH_MM );
1013                 aBrdSize = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode );
1014                 if ( !aBrdSize.Width() )
1015                     aBrdSize.Width() = 1;
1016                 if ( !aBrdSize.Height() )
1017                     aBrdSize.Height() = 1;
1018             }
1019             pDev->SetLineColor();
1020             pDev->SetFillColor( aBlackColor );
1021             Rectangle aRect1;
1022             Rectangle aRect2;
1023             aRect1.Left()   = aFillRect.Left();
1024             aRect1.Right()  = aFillRect.Right(),
1025             aRect2.Top()    = aFillRect.Top();
1026             aRect2.Bottom() = aFillRect.Bottom();
1027             if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
1028             {
1029                 aRect1.Top()    = aFillRect.Top();
1030                 aRect1.Bottom() = aBrdSize.Height()-1;
1031                 aRect2.Left()   = aFillRect.Left();
1032                 aRect2.Right()  = aFillRect.Left()+aBrdSize.Width()-1;
1033                 aFillRect.Left() += aBrdSize.Width();
1034                 aFillRect.Top()  += aBrdSize.Height();
1035             }
1036             else
1037             {
1038                 aRect1.Top()    = aFillRect.Bottom()-aBrdSize.Height()+1;
1039                 aRect1.Bottom() = aFillRect.Bottom();
1040                 aRect2.Left()   = aFillRect.Right()-aBrdSize.Width()+1;
1041                 aRect2.Right()  = aFillRect.Right(),
1042                 aFillRect.Right()  -= aBrdSize.Width();
1043                 aFillRect.Bottom() -= aBrdSize.Height();
1044             }
1045             pDev->DrawRect( aRect1 );
1046             pDev->DrawRect( aRect2 );
1047         }
1048     }
1049     else
1050     {
1051         if ( !(nStyle & BUTTON_DRAW_NODRAW) )
1052         {
1053             if ( nStyle & BUTTON_DRAW_DEFAULT )
1054             {
1055                 Color aDefBtnColor = rStyleSettings.GetDarkShadowColor();
1056                 ImplDrawDPILineRect( pDev, aFillRect, &aDefBtnColor );
1057             }
1058         }
1059 
1060         if ( !(nStyle & BUTTON_DRAW_NODRAW) )
1061         {
1062             pDev->SetLineColor();
1063             if ( nStyle & BUTTON_DRAW_NOLEFTLIGHTBORDER )
1064             {
1065                 pDev->SetFillColor( rStyleSettings.GetLightBorderColor() );
1066                 pDev->DrawRect( Rectangle( aFillRect.Left(), aFillRect.Top(),
1067                                            aFillRect.Left(), aFillRect.Bottom() ) );
1068                 aFillRect.Left()++;
1069             }
1070             if ( (nStyle & BUTTON_DRAW_NOTOPLIGHTBORDER) &&
1071                  !(nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED)) )
1072             {
1073                 pDev->SetFillColor( rStyleSettings.GetLightBorderColor() );
1074                 pDev->DrawRect( Rectangle( aFillRect.Left(), aFillRect.Top(),
1075                                            aFillRect.Right(), aFillRect.Top() ) );
1076                 aFillRect.Top()++;
1077             }
1078             if ( (( (nStyle & BUTTON_DRAW_NOBOTTOMSHADOWBORDER) | BUTTON_DRAW_FLAT) == (BUTTON_DRAW_NOBOTTOMSHADOWBORDER | BUTTON_DRAW_FLAT)) &&
1079                  !(nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED | BUTTON_DRAW_HIGHLIGHT)) )
1080             {
1081                 pDev->SetFillColor( rStyleSettings.GetDarkShadowColor() );
1082                 pDev->DrawRect( Rectangle( aFillRect.Left(), aFillRect.Bottom(),
1083                                            aFillRect.Right(), aFillRect.Bottom() ) );
1084                 aFillRect.Bottom()--;
1085             }
1086 
1087             Color aColor1;
1088             Color aColor2;
1089             if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
1090             {
1091                 aColor1 = rStyleSettings.GetDarkShadowColor();
1092                 aColor2 = rStyleSettings.GetLightColor();
1093             }
1094             else
1095             {
1096                 if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER )
1097                     aColor1 = rStyleSettings.GetLightBorderColor();
1098                 else
1099                     aColor1 = rStyleSettings.GetLightColor();
1100                 if ( (nStyle & BUTTON_DRAW_FLATTEST) == BUTTON_DRAW_FLAT )
1101                     aColor2 = rStyleSettings.GetShadowColor();
1102                 else
1103                     aColor2 = rStyleSettings.GetDarkShadowColor();
1104             }
1105             pDev->ImplDraw2ColorFrame( aFillRect, aColor1, aColor2 );
1106             aFillRect.Left()++;
1107             aFillRect.Top()++;
1108             aFillRect.Right()--;
1109             aFillRect.Bottom()--;
1110 
1111             if ( !((nStyle & BUTTON_DRAW_FLATTEST) == BUTTON_DRAW_FLAT) )
1112             {
1113                 if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
1114                 {
1115                     aColor1 = rStyleSettings.GetShadowColor();
1116                     aColor2 = rStyleSettings.GetLightBorderColor();
1117                 }
1118                 else
1119                 {
1120                     if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER )
1121                         aColor1 = rStyleSettings.GetLightColor();
1122                     else
1123                         aColor1 = rStyleSettings.GetLightBorderColor();
1124                     aColor2 = rStyleSettings.GetShadowColor();
1125                 }
1126                 pDev->ImplDraw2ColorFrame( aFillRect, aColor1, aColor2 );
1127                 aFillRect.Left()++;
1128                 aFillRect.Top()++;
1129                 aFillRect.Right()--;
1130                 aFillRect.Bottom()--;
1131             }
1132         }
1133     }
1134 
1135     if ( !(nStyle & (BUTTON_DRAW_NOFILL | BUTTON_DRAW_NODRAW)) )
1136     {
1137         pDev->SetLineColor();
1138         if ( nStyle & BUTTON_DRAW_MONO )
1139         {
1140             // Hack: Auf Druckern wollen wir im Mon oChrom-Modus trotzdem
1141             // erstmal graue Buttons haben
1142             if ( pDev->GetOutDevType() == OUTDEV_PRINTER )
1143                 pDev->SetFillColor( Color( COL_LIGHTGRAY ) );
1144             else
1145                 pDev->SetFillColor( Color( COL_WHITE ) );
1146         }
1147         else
1148         {
1149             if ( nStyle & (BUTTON_DRAW_CHECKED | BUTTON_DRAW_DONTKNOW) )
1150                 pDev->SetFillColor( rStyleSettings.GetCheckedColor() );
1151             else
1152                 pDev->SetFillColor( rStyleSettings.GetFaceColor() );
1153         }
1154         pDev->DrawRect( aFillRect );
1155     }
1156 
1157     // Ein Border freilassen, der jedoch bei Default-Darstellung
1158     // mitbenutzt wird
1159     rRect.Left()++;
1160     rRect.Top()++;
1161     rRect.Right()--;
1162     rRect.Bottom()--;
1163 
1164     if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER )
1165     {
1166         rRect.Left()++;
1167         rRect.Top()++;
1168     }
1169     else if ( nStyle & BUTTON_DRAW_NOLEFTLIGHTBORDER )
1170         rRect.Left()++;
1171 
1172     if ( nStyle & BUTTON_DRAW_PRESSED )
1173     {
1174         if ( (rRect.GetHeight() > 10) && (rRect.GetWidth() > 10) )
1175         {
1176             rRect.Left()    += 4;
1177             rRect.Top()     += 4;
1178             rRect.Right()   -= 1;
1179             rRect.Bottom()  -= 1;
1180         }
1181         else
1182         {
1183             rRect.Left()    += 3;
1184             rRect.Top()     += 3;
1185             rRect.Right()   -= 2;
1186             rRect.Bottom()  -= 2;
1187         }
1188     }
1189     else if ( nStyle & BUTTON_DRAW_CHECKED )
1190     {
1191         rRect.Left()    += 3;
1192         rRect.Top()     += 3;
1193         rRect.Right()   -= 2;
1194         rRect.Bottom()  -= 2;
1195     }
1196     else
1197     {
1198         rRect.Left()    += 2;
1199         rRect.Top()     += 2;
1200         rRect.Right()   -= 3;
1201         rRect.Bottom()  -= 3;
1202     }
1203 }
1204 
1205 // -----------------------------------------------------------------------
1206 
DrawButton(const Rectangle & rRect,sal_uInt16 nStyle)1207 Rectangle DecorationView::DrawButton( const Rectangle& rRect, sal_uInt16 nStyle )
1208 {
1209     Rectangle   aRect = rRect;
1210     sal_Bool        bOldMap = mpOutDev->IsMapModeEnabled();
1211     if ( bOldMap )
1212     {
1213         aRect = mpOutDev->LogicToPixel( aRect );
1214         mpOutDev->EnableMapMode( sal_False );
1215     }
1216 
1217     if ( !rRect.IsEmpty() )
1218     {
1219         const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings();
1220 
1221         if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
1222             nStyle |= BUTTON_DRAW_MONO;
1223 
1224         if ( nStyle & BUTTON_DRAW_NODRAW )
1225              ImplDrawButton( mpOutDev, aRect, rStyleSettings, nStyle );
1226         else
1227         {
1228              Color maOldLineColor  = mpOutDev->GetLineColor();
1229              Color maOldFillColor  = mpOutDev->GetFillColor();
1230              ImplDrawButton( mpOutDev, aRect, rStyleSettings, nStyle );
1231              mpOutDev->SetLineColor( maOldLineColor );
1232              mpOutDev->SetFillColor( maOldFillColor );
1233         }
1234     }
1235 
1236     if ( bOldMap )
1237     {
1238         mpOutDev->EnableMapMode( bOldMap );
1239         aRect = mpOutDev->PixelToLogic( aRect );
1240     }
1241 
1242     return aRect;
1243 }
1244 
1245 // -----------------------------------------------------------------------
1246 
DrawSeparator(const Point & rStart,const Point & rStop,bool bVertical)1247 void DecorationView::DrawSeparator( const Point& rStart, const Point& rStop, bool bVertical )
1248 {
1249     Point aStart( rStart ), aStop( rStop );
1250     const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings();
1251 
1252     mpOutDev->Push( PUSH_LINECOLOR );
1253     if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
1254         mpOutDev->SetLineColor( Color( COL_BLACK ) );
1255     else
1256         mpOutDev->SetLineColor( rStyleSettings.GetShadowColor() );
1257 
1258     mpOutDev->DrawLine( aStart, aStop );
1259     if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
1260     {
1261         mpOutDev->SetLineColor( rStyleSettings.GetLightColor() );
1262         if( bVertical )
1263         {
1264             aStart.X()++;
1265             aStop.X()++;
1266         }
1267         else
1268         {
1269             aStart.Y()++;
1270             aStop.Y()++;
1271         }
1272         mpOutDev->DrawLine( aStart, aStop );
1273     }
1274     mpOutDev->Pop();
1275 }
1276 
1277 /* vim: set noet sw=4 ts=4: */
1278