1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: decoview.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
33 #include <vcl/settings.hxx>
34 #include <tools/poly.hxx>
35 #include <vcl/outdev.hxx>
36 #include <vcl/bmpacc.hxx>
37 #include <vcl/decoview.hxx>
38 #include <vcl/window.hxx>
39 #include <vcl/ctrl.hxx>
41 // =======================================================================
43 #define BUTTON_DRAW_FLATTEST (BUTTON_DRAW_FLAT | \
44 BUTTON_DRAW_PRESSED | \
45 BUTTON_DRAW_CHECKED | \
46 BUTTON_DRAW_HIGHLIGHT)
48 // =======================================================================
50 void ImplDrawOS2Symbol( OutputDevice
* pDev
, const Rectangle
& rRect
,
51 USHORT nStyle
, BOOL bClose
)
53 DecorationView
aView( pDev
);
54 const StyleSettings
& rStyleSettings
= pDev
->GetSettings().GetStyleSettings();
55 Rectangle aRect
= rRect
;
61 if ( nStyle
& (BUTTON_DRAW_PRESSED
| BUTTON_DRAW_CHECKED
) )
63 aColor1
= rStyleSettings
.GetShadowColor();
64 aColor2
= rStyleSettings
.GetLightColor();
68 aColor1
= rStyleSettings
.GetLightColor();
69 aColor2
= rStyleSettings
.GetShadowColor();
71 aView
.DrawFrame( aRect
, aColor1
, aColor2
);
78 if ( nStyle
& (BUTTON_DRAW_PRESSED
| BUTTON_DRAW_CHECKED
) )
79 pDev
->SetLineColor( rStyleSettings
.GetLightColor() );
81 pDev
->SetLineColor( rStyleSettings
.GetShadowColor() );
84 pDev
->DrawLine( aRect
.TopLeft(), Point( aRect
.Left(), aRect
.Bottom()-2 ) );
85 pDev
->DrawLine( aRect
.TopLeft(), Point( aRect
.Right()-2, aRect
.Top() ) );
86 pDev
->DrawLine( Point( aRect
.Left()+2, aRect
.Bottom()-1 ),
87 Point( aRect
.Right()-1, aRect
.Top()+2 ) );
91 pDev
->DrawLine( aRect
.TopLeft(), aRect
.BottomLeft() );
92 pDev
->DrawLine( aRect
.TopLeft(), Point( aRect
.Right()-1, aRect
.Top() ) );
95 if ( nStyle
& (BUTTON_DRAW_PRESSED
| BUTTON_DRAW_CHECKED
) )
96 pDev
->SetLineColor( rStyleSettings
.GetShadowColor() );
98 pDev
->SetLineColor( rStyleSettings
.GetLightColor() );
101 pDev
->DrawLine( Point( aRect
.Right(), aRect
.Top()+2 ), aRect
.BottomRight() );
102 pDev
->DrawLine( Point( aRect
.Left()+2, aRect
.Bottom() ), aRect
.BottomRight() );
103 pDev
->DrawLine( Point( aRect
.Right()-2, aRect
.Top()+1 ),
104 Point( aRect
.Left()+1, aRect
.Bottom()-2 ) );
108 pDev
->DrawLine( aRect
.TopRight(), aRect
.BottomRight() );
109 pDev
->DrawLine( Point( aRect
.Left()+1, aRect
.Bottom() ), aRect
.BottomRight() );
113 // =======================================================================
115 static void ImplDrawSymbol( OutputDevice
* pDev
, const Rectangle
& rRect
,
118 // Groessen vorberechnen
119 long nMin
= Min( rRect
.GetWidth(), rRect
.GetHeight() );
124 Point aCenter
= rRect
.Center();
125 long nCenterX
= aCenter
.X();
126 long nCenterY
= aCenter
.Y();
138 case SYMBOL_ARROW_UP
:
140 if ( !(nMin
& 0x01) )
147 pDev
->DrawRect( Rectangle( nCenterX
, nTop
, nCenterX
, nBottom
) );
153 pDev
->DrawRect( Rectangle( nTemp
, nTop
, nTemp
, nBottom
) );
155 pDev
->DrawRect( Rectangle( nTemp
, nTop
, nTemp
, nBottom
) );
158 pDev
->DrawRect( Rectangle( nCenterX
-n4
, nBottom
,
159 nCenterX
+n4
, nBottom
+n2
) );
163 case SYMBOL_ARROW_DOWN
:
165 if ( !(nMin
& 0x01) )
171 nBottom
= nCenterY
+n2
;
172 pDev
->DrawRect( Rectangle( nCenterX
, nTop
, nCenterX
, nBottom
) );
178 pDev
->DrawRect( Rectangle( nTemp
, nTop
, nTemp
, nBottom
) );
180 pDev
->DrawRect( Rectangle( nTemp
, nTop
, nTemp
, nBottom
) );
183 pDev
->DrawRect( Rectangle( nCenterX
-n4
, nTop
-n2
,
184 nCenterX
+n4
, nTop
) );
188 case SYMBOL_ARROW_LEFT
:
190 if ( !(nMin
& 0x01) )
197 pDev
->DrawRect( Rectangle( nLeft
, nCenterY
, nRight
, nCenterY
) );
203 pDev
->DrawRect( Rectangle( nLeft
, nTemp
, nRight
, nTemp
) );
205 pDev
->DrawRect( Rectangle( nLeft
, nTemp
, nRight
, nTemp
) );
208 pDev
->DrawRect( Rectangle( nRight
, nCenterY
-n4
,
209 nRight
+n2
, nCenterY
+n4
) );
213 case SYMBOL_ARROW_RIGHT
:
215 if ( !(nMin
& 0x01) )
221 nRight
= nCenterX
+n2
;
222 pDev
->DrawRect( Rectangle( nLeft
, nCenterY
, nRight
, nCenterY
) );
228 pDev
->DrawRect( Rectangle( nLeft
, nTemp
, nRight
, nTemp
) );
230 pDev
->DrawRect( Rectangle( nLeft
, nTemp
, nRight
, nTemp
) );
233 pDev
->DrawRect( Rectangle( nLeft
-n2
, nCenterY
-n4
,
234 nLeft
, nCenterY
+n4
) );
241 if ( !(nMin
& 0x01) )
245 pDev
->DrawRect( Rectangle( nCenterX
, nTop
, nCenterX
, nBottom
) );
251 pDev
->DrawRect( Rectangle( nTemp
, nTop
, nTemp
, nBottom
) );
253 pDev
->DrawRect( Rectangle( nTemp
, nTop
, nTemp
, nBottom
) );
259 case SYMBOL_SPIN_DOWN
:
261 if ( !(nMin
& 0x01) )
265 pDev
->DrawRect( Rectangle( nCenterX
, nTop
, nCenterX
, nBottom
) );
271 pDev
->DrawRect( Rectangle( nTemp
, nTop
, nTemp
, nBottom
) );
273 pDev
->DrawRect( Rectangle( nTemp
, nTop
, nTemp
, nBottom
) );
279 case SYMBOL_SPIN_LEFT
:
282 case SYMBOL_REVERSEPLAY
:
284 if ( !(nMin
& 0x01) )
287 if ( eType
== SYMBOL_FIRST
)
290 pDev
->DrawRect( Rectangle( nLeft
, nCenterY
, nRight
, nCenterY
) );
296 pDev
->DrawRect( Rectangle( nLeft
, nTemp
, nRight
, nTemp
) );
298 pDev
->DrawRect( Rectangle( nLeft
, nTemp
, nRight
, nTemp
) );
301 if ( eType
== SYMBOL_FIRST
)
303 pDev
->DrawRect( Rectangle( nCenterX
-n4
-1, nCenterY
-n2
,
304 nCenterX
-n4
-1, nCenterY
+n2
) );
309 case SYMBOL_SPIN_RIGHT
:
314 if ( !(nMin
& 0x01) )
317 if ( eType
== SYMBOL_LAST
)
320 pDev
->DrawRect( Rectangle( nLeft
, nCenterY
, nRight
, nCenterY
) );
326 pDev
->DrawRect( Rectangle( nLeft
, nTemp
, nRight
, nTemp
) );
328 pDev
->DrawRect( Rectangle( nLeft
, nTemp
, nRight
, nTemp
) );
331 if ( eType
== SYMBOL_LAST
)
333 pDev
->DrawRect( Rectangle( nCenterX
+n4
+1, nCenterY
-n2
,
334 nCenterX
+n4
+1, nCenterY
+n2
) );
340 case SYMBOL_PAGEDOWN
:
342 if ( !( nSize
& 0x01 ))
344 // An even rectangle size means we have to use a smaller size for
345 // our arrows as we want to use one pixel for the spearhead! Otherwise
346 // it will be clipped!
353 nBottom
= nCenterY
-1;
354 pDev
->DrawRect( Rectangle( nCenterX
, nTop
, nCenterX
, nBottom
) );
355 pDev
->DrawRect( Rectangle( nCenterX
, nTop
+n2
+1, nCenterX
, nBottom
+n2
+1 ) );
359 ( eType
== SYMBOL_PAGEUP
) ? nTop
++ : nBottom
--;
361 pDev
->DrawRect( Rectangle( nTemp
, nTop
, nTemp
, nBottom
) );
362 pDev
->DrawRect( Rectangle( nTemp
, nTop
+n2
+1, nTemp
, nBottom
+n2
+1 ) );
364 pDev
->DrawRect( Rectangle( nTemp
, nTop
, nTemp
, nBottom
) );
365 pDev
->DrawRect( Rectangle( nTemp
, nTop
+n2
+1, nTemp
, nBottom
+n2
+1 ) );
371 case SYMBOL_RADIOCHECKMARK
:
374 const long nExt
= ( n2
<< 1 ) + 1;
375 Bitmap
aBmp( Size( nExt
, nExt
), 1 );
376 BitmapWriteAccess
* pWAcc
= aBmp
.AcquireWriteAccess();
380 const Color
aWhite( COL_WHITE
);
381 const Color
aBlack( COL_BLACK
);
383 pWAcc
->Erase( aWhite
);
384 pWAcc
->SetLineColor( aBlack
);
385 pWAcc
->SetFillColor( aBlack
);
386 pWAcc
->DrawPolygon( Polygon( Point( n2
, n2
), n2
, n2
) );
387 aBmp
.ReleaseAccess( pWAcc
);
388 pDev
->DrawMask( Point( nCenterX
- n2
, nCenterY
- n2
), aBmp
, pDev
->GetFillColor() );
391 pDev
->DrawPolygon( Polygon( Point( nCenterX
, nCenterY
), n2
, n2
) );
398 nRight
= nCenterX
+n2
;
400 nBottom
= nCenterY
+n2
;
401 pDev
->DrawRect( Rectangle( nLeft
, nTop
, nRight
, nBottom
) );
408 nRight
= nCenterX
+n2
-1;
410 nBottom
= nCenterY
+n2
;
411 pDev
->DrawRect( Rectangle( nLeft
, nTop
, nCenterX
-2, nBottom
) );
412 pDev
->DrawRect( Rectangle( nCenterX
+1, nTop
, nRight
, nBottom
) );
416 case SYMBOL_WINDSTART
:
417 case SYMBOL_WINDBACKWARD
:
419 nLeft
= nCenterX
-n2
+1;
421 pDev
->DrawRect( Rectangle( nLeft
, nCenterY
, nRight
, nCenterY
) );
422 pDev
->DrawRect( Rectangle( nLeft
+n2
, nCenterY
, nRight
+n2
, nCenterY
) );
428 pDev
->DrawRect( Rectangle( nLeft
, nTemp
, nRight
, nTemp
) );
429 pDev
->DrawRect( Rectangle( nLeft
+n2
, nTemp
, nRight
+n2
, nTemp
) );
431 pDev
->DrawRect( Rectangle( nLeft
, nTemp
, nRight
, nTemp
) );
432 pDev
->DrawRect( Rectangle( nLeft
+n2
, nTemp
, nRight
+n2
, nTemp
) );
435 if ( eType
== SYMBOL_WINDSTART
)
437 pDev
->DrawRect( Rectangle( nCenterX
-n2
, nCenterY
-n2
,
438 nCenterX
-n2
, nCenterY
+n2
) );
444 case SYMBOL_WINDFORWARD
:
448 pDev
->DrawRect( Rectangle( nLeft
, nCenterY
, nRight
, nCenterY
) );
449 pDev
->DrawRect( Rectangle( nLeft
+n2
, nCenterY
, nRight
+n2
, nCenterY
) );
455 pDev
->DrawRect( Rectangle( nLeft
, nTemp
, nRight
, nTemp
) );
456 pDev
->DrawRect( Rectangle( nLeft
+n2
, nTemp
, nRight
+n2
, nTemp
) );
458 pDev
->DrawRect( Rectangle( nLeft
, nTemp
, nRight
, nTemp
) );
459 pDev
->DrawRect( Rectangle( nLeft
+n2
, nTemp
, nRight
+n2
, nTemp
) );
462 if ( eType
== SYMBOL_WINDEND
)
464 pDev
->DrawRect( Rectangle( nCenterX
+n2
, nCenterY
-n2
,
465 nCenterX
+n2
, nCenterY
+n2
) );
472 Size
aRectSize( 2, 1 );
474 aRectSize
.Width() = 1;
475 else if ( nMin
> 20 )
476 aRectSize
.Width() = nMin
/10;
477 nLeft
= nCenterX
-n2
+1;
478 nTop
= nCenterY
-n2
+1;
479 nBottom
= nCenterY
-n2
+nMin
-aRectSize
.Width()+1;
481 while ( i
< nMin
-aRectSize
.Width()+1 )
483 pDev
->DrawRect( Rectangle( Point( nLeft
+i
, nTop
+i
), aRectSize
) );
484 pDev
->DrawRect( Rectangle( Point( nLeft
+i
, nBottom
-i
), aRectSize
) );
491 case SYMBOL_ROLLDOWN
:
493 Rectangle
aRect( nCenterX
-n2
, nCenterY
-n2
,
494 nCenterX
+n2
, nCenterY
-n2
+1 );
495 pDev
->DrawRect( aRect
);
496 if ( eType
== SYMBOL_ROLLDOWN
)
498 Rectangle aTempRect
= aRect
;
499 aTempRect
.Bottom() = nCenterY
+n2
;
500 aTempRect
.Right() = aRect
.Left();
501 pDev
->DrawRect( aTempRect
);
502 aTempRect
.Left() = aRect
.Right();
503 aTempRect
.Right() = aRect
.Right();
504 pDev
->DrawRect( aTempRect
);
505 aTempRect
.Top() = aTempRect
.Bottom();
506 aTempRect
.Left() = aRect
.Left();
507 pDev
->DrawRect( aTempRect
);
511 case SYMBOL_CHECKMARK
:
513 // #106953# never mirror checkmarks
514 BOOL bRTL
= pDev
->ImplHasMirroredGraphics() && pDev
->IsRTLEnabled();
515 Point
aPos1( bRTL
? rRect
.Right() : rRect
.Left(),
516 rRect
.Bottom() - rRect
.GetHeight() / 3 );
517 Point
aPos2( bRTL
? rRect
.Right() - rRect
.GetWidth()/3 : rRect
.Left() + rRect
.GetWidth()/3,
519 Point
aPos3( bRTL
? rRect
.TopLeft() : rRect
.TopRight() );
520 Size
aRectSize( 1, 2 );
521 long nStepsY
= aPos2
.Y()-aPos1
.Y();
525 for ( n
= 0; n
<= nStepsY
; n
++ )
529 pDev
->DrawRect( Rectangle( Point( nX
, nY
++ ), aRectSize
) );
533 nStepsY
= aPos2
.Y()-aPos3
.Y();
536 for ( n
= 0; n
<= nStepsY
; n
++ )
539 if ( --nX
< rRect
.Left() )
541 pDev
->DrawRect( Rectangle( Point( nX
, nY
-- ), aRectSize
) );
543 if ( ++nX
> rRect
.Right() )
549 case SYMBOL_SPIN_UPDOWN
:
551 nTop
= nCenterY
-n2
-1;
553 pDev
->DrawRect( Rectangle( nCenterX
, nTop
, nCenterX
, nBottom
) );
559 pDev
->DrawRect( Rectangle( nTemp
, nTop
, nTemp
, nBottom
) );
561 pDev
->DrawRect( Rectangle( nTemp
, nTop
, nTemp
, nBottom
) );
566 pDev
->DrawRect( Rectangle( nCenterX
, nTop
, nCenterX
, nBottom
) );
572 pDev
->DrawRect( Rectangle( nTemp
, nTop
, nTemp
, nBottom
) );
574 pDev
->DrawRect( Rectangle( nTemp
, nTop
, nTemp
, nBottom
) );
583 Rectangle
aRect( nCenterX
-n2
, nCenterY
-n2
+3,
584 nCenterX
+n2
-2, nCenterY
-n2
+4 );
585 pDev
->DrawRect( aRect
);
586 Rectangle aTempRect
= aRect
;
587 aTempRect
.Bottom() = nCenterY
+n2
;
588 aTempRect
.Right() = aRect
.Left();
589 pDev
->DrawRect( aTempRect
);
590 aTempRect
.Left() = aRect
.Right();
591 aTempRect
.Right() = aRect
.Right();
592 pDev
->DrawRect( aTempRect
);
593 aTempRect
.Top() = aTempRect
.Bottom();
594 aTempRect
.Left() = aRect
.Left();
595 pDev
->DrawRect( aTempRect
);
596 aRect
= Rectangle( nCenterX
-n2
+2, nCenterY
-n2
,
597 nCenterX
+n2
, nCenterY
-n2
+1 );
598 pDev
->DrawRect( aRect
);
600 aTempRect
.Bottom() = nCenterY
+n2
-3;
601 aTempRect
.Right() = aRect
.Left();
602 pDev
->DrawRect( aTempRect
);
603 aTempRect
.Left() = aRect
.Right();
604 aTempRect
.Right() = aRect
.Right();
605 pDev
->DrawRect( aTempRect
);
606 aTempRect
.Top() = aTempRect
.Bottom();
607 aTempRect
.Left() = aRect
.Left();
608 pDev
->DrawRect( aTempRect
);
613 Rectangle
aRect( nCenterX
-n2
, nCenterY
-n2
,
614 nCenterX
+n2
, nCenterY
-n2
);
615 pDev
->DrawRect( aRect
);
616 Rectangle aTempRect
= aRect
;
617 aTempRect
.Bottom() = nCenterY
+n2
;
618 aTempRect
.Right() = aRect
.Left();
619 pDev
->DrawRect( aTempRect
);
620 aTempRect
.Left() = aRect
.Right();
621 aTempRect
.Right() = aRect
.Right();
622 pDev
->DrawRect( aTempRect
);
623 aTempRect
.Top() = aTempRect
.Bottom();
624 aTempRect
.Left() = aRect
.Left();
625 pDev
->DrawRect( aTempRect
);
630 long nExtra
= nMin
/ 8;
631 Rectangle
aRect( nCenterX
-n2
+nExtra
, nCenterY
+n2
-1,
632 nCenterX
+n2
-nExtra
, nCenterY
+n2
);
633 pDev
->DrawRect( aRect
);
637 case SYMBOL_OS2CLOSE
:
639 Rectangle
aRect( nCenterX
-n2
, nCenterY
-n2
,
640 nCenterX
+n2
, nCenterY
+n2
);
641 ImplDrawOS2Symbol( pDev
, aRect
, 0, TRUE
);
645 case SYMBOL_OS2FLOAT
:
647 Rectangle
aRect( nCenterX
-n2
+4, nCenterY
-n2
+4,
648 nCenterX
+n2
-4, nCenterY
+n2
-3 );
649 ImplDrawOS2Symbol( pDev
, aRect
, 0, FALSE
);
650 DecorationView
aDecoView( pDev
);
651 Rectangle
aRect2( nCenterX
-n2
, nCenterY
-n2
,
652 nCenterX
-n2
+2, nCenterY
+n2
);
653 aDecoView
.DrawFrame( aRect2
,
654 pDev
->GetSettings().GetStyleSettings().GetLightColor(),
655 pDev
->GetSettings().GetStyleSettings().GetShadowColor() );
656 Rectangle
aRect3( nCenterX
+n2
-2, nCenterY
-n2
,
657 nCenterX
+n2
, nCenterY
+n2
);
658 aDecoView
.DrawFrame( aRect3
,
659 pDev
->GetSettings().GetStyleSettings().GetLightColor(),
660 pDev
->GetSettings().GetStyleSettings().GetShadowColor() );
666 Rectangle
aRect( nCenterX
-n2
+3, nCenterY
-n2
+3,
667 nCenterX
+n2
-3, nCenterY
+n2
-3 );
668 ImplDrawOS2Symbol( pDev
, aRect
, 0, FALSE
);
674 // -----------------------------------------------------------------------
676 void DecorationView::DrawSymbol( const Rectangle
& rRect
, SymbolType eType
,
677 const Color
& rColor
, USHORT nStyle
)
679 const StyleSettings
& rStyleSettings
= mpOutDev
->GetSettings().GetStyleSettings();
680 Rectangle aRect
= mpOutDev
->LogicToPixel( rRect
);
681 Color aOldLineColor
= mpOutDev
->GetLineColor();
682 Color aOldFillColor
= mpOutDev
->GetFillColor();
683 BOOL bOldMapMode
= mpOutDev
->IsMapModeEnabled();
684 mpOutDev
->SetLineColor();
685 mpOutDev
->SetFillColor( rColor
);
686 mpOutDev
->EnableMapMode( FALSE
);
688 if ( (rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) ||
689 (mpOutDev
->GetOutDevType() == OUTDEV_PRINTER
) )
690 nStyle
|= BUTTON_DRAW_MONO
;
692 if ( nStyle
& SYMBOL_DRAW_MONO
)
694 if ( nStyle
& SYMBOL_DRAW_DISABLE
)
695 mpOutDev
->SetFillColor( Color( COL_GRAY
) );
697 mpOutDev
->SetFillColor( Color( COL_BLACK
) );
701 if ( nStyle
& SYMBOL_DRAW_DISABLE
)
703 // Als Embosed ausgeben
704 mpOutDev
->SetFillColor( rStyleSettings
.GetLightColor() );
705 Rectangle aTempRect
= aRect
;
706 aTempRect
.Move( 1, 1 );
707 ImplDrawSymbol( mpOutDev
, aTempRect
, eType
);
708 mpOutDev
->SetFillColor( rStyleSettings
.GetShadowColor() );
711 mpOutDev
->SetFillColor( rColor
);
714 ImplDrawSymbol( mpOutDev
, aRect
, eType
);
716 mpOutDev
->SetLineColor( aOldLineColor
);
717 mpOutDev
->SetFillColor( aOldFillColor
);
718 mpOutDev
->EnableMapMode( bOldMapMode
);
721 // =======================================================================
723 void DecorationView::DrawFrame( const Rectangle
& rRect
,
724 const Color
& rLeftTopColor
,
725 const Color
& rRightBottomColor
)
727 Rectangle aRect
= mpOutDev
->LogicToPixel( rRect
);
728 Color aOldLineColor
= mpOutDev
->GetLineColor();
729 Color aOldFillColor
= mpOutDev
->GetFillColor();
730 BOOL bOldMapMode
= mpOutDev
->IsMapModeEnabled();
731 mpOutDev
->EnableMapMode( FALSE
);
732 mpOutDev
->SetLineColor();
733 mpOutDev
->ImplDraw2ColorFrame( aRect
, rLeftTopColor
, rRightBottomColor
);
734 mpOutDev
->SetLineColor( aOldLineColor
);
735 mpOutDev
->SetFillColor( aOldFillColor
);
736 mpOutDev
->EnableMapMode( bOldMapMode
);
739 // =======================================================================
741 void DecorationView::DrawHighlightFrame( const Rectangle
& rRect
,
744 const StyleSettings
& rStyleSettings
= mpOutDev
->GetSettings().GetStyleSettings();
745 Color aLightColor
= rStyleSettings
.GetLightColor();
746 Color aShadowColor
= rStyleSettings
.GetShadowColor();
748 if ( (rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) ||
749 (mpOutDev
->GetOutDevType() == OUTDEV_PRINTER
) )
751 aLightColor
= Color( COL_BLACK
);
752 aShadowColor
= Color( COL_BLACK
);
754 else if ( nStyle
& FRAME_HIGHLIGHT_TESTBACKGROUND
)
756 Wallpaper aBackground
= mpOutDev
->GetBackground();
757 if ( aBackground
.IsBitmap() || aBackground
.IsGradient() )
759 aLightColor
= rStyleSettings
.GetFaceColor();
760 aShadowColor
= Color( COL_BLACK
);
764 Color aBackColor
= aBackground
.GetColor();
765 if ( (aLightColor
.GetColorError( aBackColor
) < 32) ||
766 (aShadowColor
.GetColorError( aBackColor
) < 32) )
768 aLightColor
= Color( COL_WHITE
);
769 aShadowColor
= Color( COL_BLACK
);
771 if ( aLightColor
.GetColorError( aBackColor
) < 32 )
772 aLightColor
.DecreaseLuminance( 64 );
773 if ( aShadowColor
.GetColorError( aBackColor
) < 32 )
774 aShadowColor
.IncreaseLuminance( 64 );
779 if ( (nStyle
& FRAME_HIGHLIGHT_STYLE
) == FRAME_HIGHLIGHT_IN
)
781 Color aTempColor
= aLightColor
;
782 aLightColor
= aShadowColor
;
783 aShadowColor
= aTempColor
;
786 DrawFrame( rRect
, aLightColor
, aShadowColor
);
789 // =======================================================================
791 static void ImplDrawDPILineRect( OutputDevice
* pDev
, Rectangle
& rRect
,
792 const Color
* pColor
, BOOL bRound
= FALSE
)
794 long nLineWidth
= pDev
->ImplGetDPIX()/300;
795 long nLineHeight
= pDev
->ImplGetDPIY()/300;
803 if ( (nLineWidth
== 1) && (nLineHeight
== 1) )
805 pDev
->SetLineColor( *pColor
);
806 pDev
->SetFillColor();
809 pDev
->DrawLine( Point( rRect
.Left()+1, rRect
.Top()), Point( rRect
.Right()-1, rRect
.Top()) );
810 pDev
->DrawLine( Point( rRect
.Left()+1, rRect
.Bottom()), Point( rRect
.Right()-1, rRect
.Bottom()) );
811 pDev
->DrawLine( Point( rRect
.Left(), rRect
.Top()+1), Point( rRect
.Left(), rRect
.Bottom()-1) );
812 pDev
->DrawLine( Point( rRect
.Right(), rRect
.Top()+1), Point( rRect
.Right(), rRect
.Bottom()-1) );
815 pDev
->DrawRect( rRect
);
819 long nWidth
= rRect
.GetWidth();
820 long nHeight
= rRect
.GetHeight();
821 pDev
->SetLineColor();
822 pDev
->SetFillColor( *pColor
);
823 pDev
->DrawRect( Rectangle( rRect
.TopLeft(), Size( nWidth
, nLineHeight
) ) );
824 pDev
->DrawRect( Rectangle( rRect
.TopLeft(), Size( nLineWidth
, nHeight
) ) );
825 pDev
->DrawRect( Rectangle( Point( rRect
.Left(), rRect
.Bottom()-nLineHeight
),
826 Size( nWidth
, nLineHeight
) ) );
827 pDev
->DrawRect( Rectangle( Point( rRect
.Right()-nLineWidth
, rRect
.Top() ),
828 Size( nLineWidth
, nHeight
) ) );
832 rRect
.Left() += nLineWidth
;
833 rRect
.Top() += nLineHeight
;
834 rRect
.Right() -= nLineWidth
;
835 rRect
.Bottom() -= nLineHeight
;
838 // =======================================================================
840 static void ImplDrawFrame( OutputDevice
* pDev
, Rectangle
& rRect
,
841 const StyleSettings
& rStyleSettings
, USHORT nStyle
)
844 BOOL bMenuStyle
= (nStyle
& FRAME_DRAW_MENU
) ? TRUE
: FALSE
;
845 nStyle
&= ~FRAME_DRAW_MENU
;
848 if( pDev
->GetOutDevType() == OUTDEV_WINDOW
)
849 pWin
= (Window
*) pDev
;
851 // UseFlatBorders disables 3D style for all frames except menus
852 // menus may use different border colors (eg on XP)
853 // normal frames will be drawn using the shadow color
854 // whereas window frame borders will use black
855 BOOL bFlatBorders
= ( !bMenuStyle
&& rStyleSettings
.GetUseFlatBorders() );
857 // no flat borders for standard VCL controls (ie formcontrols that keep their classic look)
858 // will not affect frame windows (like dropdowns)
859 if( bFlatBorders
&& pWin
&& pWin
->GetType() == WINDOW_BORDERWINDOW
&& (pWin
!= pWin
->ImplGetFrameWindow()) )
861 // check for formcontrol, i.e., a control without NWF enabled
862 Control
*pControl
= dynamic_cast< Control
* >( pWin
->GetWindow( WINDOW_CLIENT
) );
863 if( pControl
&& pControl
->IsNativeWidgetEnabled() )
866 bFlatBorders
= FALSE
;
869 // no round corners for window frame borders
870 BOOL bRound
= (bFlatBorders
&& !(nStyle
& FRAME_DRAW_WINDOWBORDER
));
872 if ( (rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) ||
873 (pDev
->GetOutDevType() == OUTDEV_PRINTER
) ||
875 nStyle
|= FRAME_DRAW_MONO
;
877 if ( nStyle
& FRAME_DRAW_NODRAW
)
879 USHORT nValueStyle
= bMenuStyle
? nStyle
| FRAME_DRAW_MENU
: nStyle
;
880 if( pWin
->GetType() == WINDOW_BORDERWINDOW
)
881 nValueStyle
|= FRAME_DRAW_BORDERWINDOWBORDER
;
882 ImplControlValue
aControlValue( nValueStyle
);
883 Region aBound
, aContent
;
884 Region
aNatRgn( rRect
);
885 if(pWin
&& pWin
->GetNativeControlRegion(CTRL_FRAME
, PART_BORDER
,
886 aNatRgn
, 0, aControlValue
, rtl::OUString(), aBound
, aContent
) )
888 rRect
= aContent
.GetBoundRect();
890 else if ( nStyle
& FRAME_DRAW_MONO
)
891 ImplDrawDPILineRect( pDev
, rRect
, NULL
, bRound
);
894 USHORT nFrameStyle
= nStyle
& FRAME_DRAW_STYLE
;
896 if ( nFrameStyle
== FRAME_DRAW_GROUP
)
903 else if ( (nFrameStyle
== FRAME_DRAW_IN
) ||
904 (nFrameStyle
== FRAME_DRAW_OUT
) )
911 else // FRAME_DRAW_DOUBLEIN || FRAME_DRAW_DOUBLEOUT
922 if( pWin
&& pWin
->IsNativeControlSupported(CTRL_FRAME
, PART_BORDER
) )
924 USHORT nValueStyle
= bMenuStyle
? nStyle
| FRAME_DRAW_MENU
: nStyle
;
925 if( pWin
->GetType() == WINDOW_BORDERWINDOW
)
926 nValueStyle
|= FRAME_DRAW_BORDERWINDOWBORDER
;
927 ImplControlValue
aControlValue( nValueStyle
);
928 Region aBound
, aContent
;
929 Region
aNatRgn( rRect
);
930 if( pWin
->GetNativeControlRegion(CTRL_FRAME
, PART_BORDER
,
931 aNatRgn
, 0, aControlValue
, rtl::OUString(), aBound
, aContent
) )
933 if( pWin
->DrawNativeControl( CTRL_FRAME
, PART_BORDER
, aContent
, CTRL_STATE_ENABLED
,
934 aControlValue
, rtl::OUString()) )
936 rRect
= aContent
.GetBoundRect();
942 if ( nStyle
& FRAME_DRAW_MONO
)
944 Color aColor
= bRound
? rStyleSettings
.GetShadowColor()
945 : pDev
->GetSettings().GetStyleSettings().GetMonoColor();
946 // when the MonoColor wasn't set, check face color
948 (bRound
&& aColor
.IsDark()) ||
950 (aColor
== Color(COL_BLACK
)) &&
951 (pDev
->GetSettings().GetStyleSettings().GetFaceColor().IsDark())
955 aColor
= Color( COL_WHITE
);
957 ImplDrawDPILineRect( pDev
, rRect
, &aColor
, bRound
);
961 USHORT nFrameStyle
= nStyle
& FRAME_DRAW_STYLE
;
962 if ( nFrameStyle
== FRAME_DRAW_GROUP
)
964 pDev
->SetFillColor();
965 pDev
->SetLineColor( rStyleSettings
.GetLightColor() );
968 pDev
->DrawRect( rRect
);
971 pDev
->SetLineColor( rStyleSettings
.GetShadowColor() );
974 pDev
->DrawRect( rRect
);
980 pDev
->SetLineColor();
982 if ( (nFrameStyle
== FRAME_DRAW_IN
) ||
983 (nFrameStyle
== FRAME_DRAW_OUT
) )
985 if ( nFrameStyle
== FRAME_DRAW_IN
)
987 pDev
->ImplDraw2ColorFrame( rRect
,
988 rStyleSettings
.GetShadowColor(),
989 rStyleSettings
.GetLightColor() );
993 pDev
->ImplDraw2ColorFrame( rRect
,
994 rStyleSettings
.GetLightColor(),
995 rStyleSettings
.GetShadowColor() );
1003 else // FRAME_DRAW_DOUBLEIN || FRAME_DRAW_DOUBLEOUT
1005 if ( nFrameStyle
== FRAME_DRAW_DOUBLEIN
)
1007 if( bFlatBorders
) // no 3d effect
1008 pDev
->ImplDraw2ColorFrame( rRect
,
1009 rStyleSettings
.GetShadowColor(),
1010 rStyleSettings
.GetShadowColor() );
1012 pDev
->ImplDraw2ColorFrame( rRect
,
1013 rStyleSettings
.GetShadowColor(),
1014 rStyleSettings
.GetLightColor() );
1019 pDev
->ImplDraw2ColorFrame( rRect
,
1020 rStyleSettings
.GetMenuBorderColor(),
1021 rStyleSettings
.GetDarkShadowColor() );
1023 pDev
->ImplDraw2ColorFrame( rRect
,
1024 bFlatBorders
? // no 3d effect
1025 rStyleSettings
.GetDarkShadowColor() :
1026 rStyleSettings
.GetLightBorderColor(),
1027 rStyleSettings
.GetDarkShadowColor() );
1037 if ( nFrameStyle
== FRAME_DRAW_DOUBLEIN
)
1039 if( bFlatBorders
) // no 3d effect
1040 pDev
->ImplDraw2ColorFrame( rRect
,
1041 rStyleSettings
.GetFaceColor(),
1042 rStyleSettings
.GetFaceColor() );
1044 pDev
->ImplDraw2ColorFrame( rRect
,
1045 rStyleSettings
.GetDarkShadowColor(),
1046 rStyleSettings
.GetLightBorderColor() );
1050 // flat menues have no shadow border
1051 if( !bMenuStyle
|| !rStyleSettings
.GetUseFlatMenues() )
1052 pDev
->ImplDraw2ColorFrame( rRect
,
1053 rStyleSettings
.GetLightColor(),
1054 rStyleSettings
.GetShadowColor() );
1071 // -----------------------------------------------------------------------
1073 Rectangle
DecorationView::DrawFrame( const Rectangle
& rRect
, USHORT nStyle
)
1075 Rectangle aRect
= rRect
;
1076 BOOL bOldMap
= mpOutDev
->IsMapModeEnabled();
1079 aRect
= mpOutDev
->LogicToPixel( aRect
);
1080 mpOutDev
->EnableMapMode( FALSE
);
1083 if ( !rRect
.IsEmpty() )
1085 if ( nStyle
& FRAME_DRAW_NODRAW
)
1086 ImplDrawFrame( mpOutDev
, aRect
, mpOutDev
->GetSettings().GetStyleSettings(), nStyle
);
1089 Color maOldLineColor
= mpOutDev
->GetLineColor();
1090 Color maOldFillColor
= mpOutDev
->GetFillColor();
1091 ImplDrawFrame( mpOutDev
, aRect
, mpOutDev
->GetSettings().GetStyleSettings(), nStyle
);
1092 mpOutDev
->SetLineColor( maOldLineColor
);
1093 mpOutDev
->SetFillColor( maOldFillColor
);
1099 mpOutDev
->EnableMapMode( bOldMap
);
1100 aRect
= mpOutDev
->PixelToLogic( aRect
);
1106 // =======================================================================
1108 static void ImplDrawButton( OutputDevice
* pDev
, Rectangle
& rRect
,
1109 const StyleSettings
& rStyleSettings
, USHORT nStyle
)
1111 Rectangle aFillRect
= rRect
;
1113 if ( nStyle
& BUTTON_DRAW_MONO
)
1115 if ( !(nStyle
& BUTTON_DRAW_NODRAW
) )
1117 Color
aBlackColor( COL_BLACK
);
1119 if ( nStyle
& BUTTON_DRAW_DEFAULT
)
1120 ImplDrawDPILineRect( pDev
, aFillRect
, &aBlackColor
);
1122 ImplDrawDPILineRect( pDev
, aFillRect
, &aBlackColor
);
1124 Size
aBrdSize( 1, 1 );
1125 if ( pDev
->GetOutDevType() == OUTDEV_PRINTER
)
1127 MapMode
aResMapMode( MAP_100TH_MM
);
1128 aBrdSize
= pDev
->LogicToPixel( Size( 20, 20 ), aResMapMode
);
1129 if ( !aBrdSize
.Width() )
1130 aBrdSize
.Width() = 1;
1131 if ( !aBrdSize
.Height() )
1132 aBrdSize
.Height() = 1;
1134 pDev
->SetLineColor();
1135 pDev
->SetFillColor( aBlackColor
);
1138 aRect1
.Left() = aFillRect
.Left();
1139 aRect1
.Right() = aFillRect
.Right(),
1140 aRect2
.Top() = aFillRect
.Top();
1141 aRect2
.Bottom() = aFillRect
.Bottom();
1142 if ( nStyle
& (BUTTON_DRAW_PRESSED
| BUTTON_DRAW_CHECKED
) )
1144 aRect1
.Top() = aFillRect
.Top();
1145 aRect1
.Bottom() = aBrdSize
.Height()-1;
1146 aRect2
.Left() = aFillRect
.Left();
1147 aRect2
.Right() = aFillRect
.Left()+aBrdSize
.Width()-1;
1148 aFillRect
.Left() += aBrdSize
.Width();
1149 aFillRect
.Top() += aBrdSize
.Height();
1153 aRect1
.Top() = aFillRect
.Bottom()-aBrdSize
.Height()+1;
1154 aRect1
.Bottom() = aFillRect
.Bottom();
1155 aRect2
.Left() = aFillRect
.Right()-aBrdSize
.Width()+1;
1156 aRect2
.Right() = aFillRect
.Right(),
1157 aFillRect
.Right() -= aBrdSize
.Width();
1158 aFillRect
.Bottom() -= aBrdSize
.Height();
1160 pDev
->DrawRect( aRect1
);
1161 pDev
->DrawRect( aRect2
);
1166 if ( !(nStyle
& BUTTON_DRAW_NODRAW
) )
1168 if ( nStyle
& BUTTON_DRAW_DEFAULT
)
1170 Color aDefBtnColor
= rStyleSettings
.GetDarkShadowColor();
1171 ImplDrawDPILineRect( pDev
, aFillRect
, &aDefBtnColor
);
1175 if ( !(nStyle
& BUTTON_DRAW_NODRAW
) )
1177 pDev
->SetLineColor();
1178 if ( nStyle
& BUTTON_DRAW_NOLEFTLIGHTBORDER
)
1180 pDev
->SetFillColor( rStyleSettings
.GetLightBorderColor() );
1181 pDev
->DrawRect( Rectangle( aFillRect
.Left(), aFillRect
.Top(),
1182 aFillRect
.Left(), aFillRect
.Bottom() ) );
1185 if ( (nStyle
& BUTTON_DRAW_NOTOPLIGHTBORDER
) &&
1186 !(nStyle
& (BUTTON_DRAW_PRESSED
| BUTTON_DRAW_CHECKED
)) )
1188 pDev
->SetFillColor( rStyleSettings
.GetLightBorderColor() );
1189 pDev
->DrawRect( Rectangle( aFillRect
.Left(), aFillRect
.Top(),
1190 aFillRect
.Right(), aFillRect
.Top() ) );
1193 if ( (( (nStyle
& BUTTON_DRAW_NOBOTTOMSHADOWBORDER
) | BUTTON_DRAW_FLAT
) == (BUTTON_DRAW_NOBOTTOMSHADOWBORDER
| BUTTON_DRAW_FLAT
)) &&
1194 !(nStyle
& (BUTTON_DRAW_PRESSED
| BUTTON_DRAW_CHECKED
| BUTTON_DRAW_HIGHLIGHT
)) )
1196 pDev
->SetFillColor( rStyleSettings
.GetDarkShadowColor() );
1197 pDev
->DrawRect( Rectangle( aFillRect
.Left(), aFillRect
.Bottom(),
1198 aFillRect
.Right(), aFillRect
.Bottom() ) );
1199 aFillRect
.Bottom()--;
1204 if ( nStyle
& (BUTTON_DRAW_PRESSED
| BUTTON_DRAW_CHECKED
) )
1206 aColor1
= rStyleSettings
.GetDarkShadowColor();
1207 aColor2
= rStyleSettings
.GetLightColor();
1211 if ( nStyle
& BUTTON_DRAW_NOLIGHTBORDER
)
1212 aColor1
= rStyleSettings
.GetLightBorderColor();
1214 aColor1
= rStyleSettings
.GetLightColor();
1215 if ( (nStyle
& BUTTON_DRAW_FLATTEST
) == BUTTON_DRAW_FLAT
)
1216 aColor2
= rStyleSettings
.GetShadowColor();
1218 aColor2
= rStyleSettings
.GetDarkShadowColor();
1220 pDev
->ImplDraw2ColorFrame( aFillRect
, aColor1
, aColor2
);
1223 aFillRect
.Right()--;
1224 aFillRect
.Bottom()--;
1226 if ( !((nStyle
& BUTTON_DRAW_FLATTEST
) == BUTTON_DRAW_FLAT
) )
1228 if ( nStyle
& (BUTTON_DRAW_PRESSED
| BUTTON_DRAW_CHECKED
) )
1230 aColor1
= rStyleSettings
.GetShadowColor();
1231 aColor2
= rStyleSettings
.GetLightBorderColor();
1235 if ( nStyle
& BUTTON_DRAW_NOLIGHTBORDER
)
1236 aColor1
= rStyleSettings
.GetLightColor();
1238 aColor1
= rStyleSettings
.GetLightBorderColor();
1239 aColor2
= rStyleSettings
.GetShadowColor();
1241 pDev
->ImplDraw2ColorFrame( aFillRect
, aColor1
, aColor2
);
1244 aFillRect
.Right()--;
1245 aFillRect
.Bottom()--;
1250 if ( !(nStyle
& (BUTTON_DRAW_NOFILL
| BUTTON_DRAW_NODRAW
)) )
1252 pDev
->SetLineColor();
1253 if ( nStyle
& BUTTON_DRAW_MONO
)
1255 // Hack: Auf Druckern wollen wir im MonoChrom-Modus trotzdem
1256 // erstmal graue Buttons haben
1257 if ( pDev
->GetOutDevType() == OUTDEV_PRINTER
)
1258 pDev
->SetFillColor( Color( COL_LIGHTGRAY
) );
1260 pDev
->SetFillColor( Color( COL_WHITE
) );
1264 if ( nStyle
& (BUTTON_DRAW_CHECKED
| BUTTON_DRAW_DONTKNOW
) )
1265 pDev
->SetFillColor( rStyleSettings
.GetCheckedColor() );
1267 pDev
->SetFillColor( rStyleSettings
.GetFaceColor() );
1269 pDev
->DrawRect( aFillRect
);
1272 // Ein Border freilassen, der jedoch bei Default-Darstellung
1279 if ( nStyle
& BUTTON_DRAW_NOLIGHTBORDER
)
1284 else if ( nStyle
& BUTTON_DRAW_NOLEFTLIGHTBORDER
)
1287 if ( nStyle
& BUTTON_DRAW_PRESSED
)
1289 if ( (rRect
.GetHeight() > 10) && (rRect
.GetWidth() > 10) )
1294 rRect
.Bottom() -= 1;
1301 rRect
.Bottom() -= 2;
1304 else if ( nStyle
& BUTTON_DRAW_CHECKED
)
1309 rRect
.Bottom() -= 2;
1316 rRect
.Bottom() -= 3;
1320 // -----------------------------------------------------------------------
1322 Rectangle
DecorationView::DrawButton( const Rectangle
& rRect
, USHORT nStyle
)
1324 Rectangle aRect
= rRect
;
1325 BOOL bOldMap
= mpOutDev
->IsMapModeEnabled();
1328 aRect
= mpOutDev
->LogicToPixel( aRect
);
1329 mpOutDev
->EnableMapMode( FALSE
);
1332 if ( !rRect
.IsEmpty() )
1334 const StyleSettings
& rStyleSettings
= mpOutDev
->GetSettings().GetStyleSettings();
1336 if ( rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
)
1337 nStyle
|= BUTTON_DRAW_MONO
;
1339 if ( nStyle
& BUTTON_DRAW_NODRAW
)
1340 ImplDrawButton( mpOutDev
, aRect
, rStyleSettings
, nStyle
);
1343 Color maOldLineColor
= mpOutDev
->GetLineColor();
1344 Color maOldFillColor
= mpOutDev
->GetFillColor();
1345 ImplDrawButton( mpOutDev
, aRect
, rStyleSettings
, nStyle
);
1346 mpOutDev
->SetLineColor( maOldLineColor
);
1347 mpOutDev
->SetFillColor( maOldFillColor
);
1353 mpOutDev
->EnableMapMode( bOldMap
);
1354 aRect
= mpOutDev
->PixelToLogic( aRect
);