update dev300-m58
[ooovba.git] / vcl / source / window / decoview.cxx
blobf869eed5a16c6f4f672bc4d14b0e2e199ecb0ca9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: decoview.cxx,v $
10 * $Revision: 1.18 $
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;
56 Color aColor1;
57 Color aColor2;
59 pDev->SetFillColor();
61 if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
63 aColor1 = rStyleSettings.GetShadowColor();
64 aColor2 = rStyleSettings.GetLightColor();
66 else
68 aColor1 = rStyleSettings.GetLightColor();
69 aColor2 = rStyleSettings.GetShadowColor();
71 aView.DrawFrame( aRect, aColor1, aColor2 );
73 aRect.Left() += 2;
74 aRect.Top() += 2;
75 aRect.Right() -= 2;
76 aRect.Bottom() -= 2;
78 if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
79 pDev->SetLineColor( rStyleSettings.GetLightColor() );
80 else
81 pDev->SetLineColor( rStyleSettings.GetShadowColor() );
82 if ( bClose )
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 ) );
89 else
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() );
97 else
98 pDev->SetLineColor( rStyleSettings.GetLightColor() );
99 if ( bClose )
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 ) );
106 else
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,
116 SymbolType eType )
118 // Groessen vorberechnen
119 long nMin = Min( rRect.GetWidth(), rRect.GetHeight() );
120 long nSize = nMin;
122 if ( nMin & 0x01 )
123 nMin--;
124 Point aCenter = rRect.Center();
125 long nCenterX = aCenter.X();
126 long nCenterY = aCenter.Y();
127 long n2 = nMin / 2;
128 long n4 = nMin / 4;
129 long nLeft;
130 long nTop;
131 long nRight;
132 long nBottom;
133 long nTemp;
134 long i;
136 switch ( eType )
138 case SYMBOL_ARROW_UP:
140 if ( !(nMin & 0x01) )
142 n2--;
143 n4--;
145 nTop = nCenterY-n2;
146 nBottom = nCenterY;
147 pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) );
148 i = 1;
149 while ( i <= n2 )
151 nTop++;
152 nTemp = nCenterX-i;
153 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
154 nTemp = nCenterX+i;
155 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
156 i++;
158 pDev->DrawRect( Rectangle( nCenterX-n4, nBottom,
159 nCenterX+n4, nBottom+n2 ) );
161 break;
163 case SYMBOL_ARROW_DOWN:
165 if ( !(nMin & 0x01) )
167 n2--;
168 n4--;
170 nTop = nCenterY;
171 nBottom = nCenterY+n2;
172 pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) );
173 i = 1;
174 while ( i <= n2 )
176 nBottom--;
177 nTemp = nCenterX-i;
178 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
179 nTemp = nCenterX+i;
180 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
181 i++;
183 pDev->DrawRect( Rectangle( nCenterX-n4, nTop-n2,
184 nCenterX+n4, nTop ) );
186 break;
188 case SYMBOL_ARROW_LEFT:
190 if ( !(nMin & 0x01) )
192 n2--;
193 n4--;
195 nLeft = nCenterX-n2;
196 nRight = nCenterX;
197 pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) );
198 i = 1;
199 while ( i <= n2 )
201 nLeft++;
202 nTemp = nCenterY-i;
203 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
204 nTemp = nCenterY+i;
205 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
206 i++;
208 pDev->DrawRect( Rectangle( nRight, nCenterY-n4,
209 nRight+n2, nCenterY+n4 ) );
211 break;
213 case SYMBOL_ARROW_RIGHT:
215 if ( !(nMin & 0x01) )
217 n2--;
218 n4--;
220 nLeft = nCenterX;
221 nRight = nCenterX+n2;
222 pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) );
223 i = 1;
224 while ( i <= n2 )
226 nRight--;
227 nTemp = nCenterY-i;
228 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
229 nTemp = nCenterY+i;
230 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
231 i++;
233 pDev->DrawRect( Rectangle( nLeft-n2, nCenterY-n4,
234 nLeft, nCenterY+n4 ) );
236 break;
239 case SYMBOL_SPIN_UP:
241 if ( !(nMin & 0x01) )
242 n2--;
243 nTop = nCenterY-n4;
244 nBottom = nTop+n2;
245 pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) );
246 i = 1;
247 while ( i <= n2 )
249 nTop++;
250 nTemp = nCenterX-i;
251 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
252 nTemp = nCenterX+i;
253 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
254 i++;
257 break;
259 case SYMBOL_SPIN_DOWN:
261 if ( !(nMin & 0x01) )
262 n2--;
263 nTop = nCenterY-n4;
264 nBottom = nTop+n2;
265 pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) );
266 i = 1;
267 while ( i <= n2 )
269 nBottom--;
270 nTemp = nCenterX-i;
271 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
272 nTemp = nCenterX+i;
273 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
274 i++;
277 break;
279 case SYMBOL_SPIN_LEFT:
280 case SYMBOL_FIRST:
281 case SYMBOL_PREV:
282 case SYMBOL_REVERSEPLAY:
284 if ( !(nMin & 0x01) )
285 n2--;
286 nLeft = nCenterX-n4;
287 if ( eType == SYMBOL_FIRST )
288 nLeft++;
289 nRight = nLeft+n2;
290 pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) );
291 i = 1;
292 while ( i <= n2 )
294 nLeft++;
295 nTemp = nCenterY-i;
296 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
297 nTemp = nCenterY+i;
298 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
299 i++;
301 if ( eType == SYMBOL_FIRST )
303 pDev->DrawRect( Rectangle( nCenterX-n4-1, nCenterY-n2,
304 nCenterX-n4-1, nCenterY+n2 ) );
307 break;
309 case SYMBOL_SPIN_RIGHT:
310 case SYMBOL_LAST:
311 case SYMBOL_NEXT:
312 case SYMBOL_PLAY:
314 if ( !(nMin & 0x01) )
315 n2--;
316 nLeft = nCenterX-n4;
317 if ( eType == SYMBOL_LAST )
318 nLeft--;
319 nRight = nLeft+n2;
320 pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) );
321 i = 1;
322 while ( i <= n2 )
324 nRight--;
325 nTemp = nCenterY-i;
326 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
327 nTemp = nCenterY+i;
328 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
329 i++;
331 if ( eType == SYMBOL_LAST )
333 pDev->DrawRect( Rectangle( nCenterX+n4+1, nCenterY-n2,
334 nCenterX+n4+1, nCenterY+n2 ) );
337 break;
339 case SYMBOL_PAGEUP:
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!
347 nCenterX++;
348 n2 = ( nMin-1 ) / 2;
349 n4 = ( nMin-1 ) / 4;
352 nTop = nCenterY-n2;
353 nBottom = nCenterY-1;
354 pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) );
355 pDev->DrawRect( Rectangle( nCenterX, nTop+n2+1, nCenterX, nBottom+n2+1 ) );
356 i = 1;
357 while ( i < n2 )
359 ( eType == SYMBOL_PAGEUP ) ? nTop++ : nBottom--;
360 nTemp = nCenterX-i;
361 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
362 pDev->DrawRect( Rectangle( nTemp, nTop+n2+1, nTemp, nBottom+n2+1 ) );
363 nTemp = nCenterX+i;
364 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
365 pDev->DrawRect( Rectangle( nTemp, nTop+n2+1, nTemp, nBottom+n2+1 ) );
366 i++;
369 break;
371 case SYMBOL_RADIOCHECKMARK:
372 case SYMBOL_RECORD:
374 const long nExt = ( n2 << 1 ) + 1;
375 Bitmap aBmp( Size( nExt, nExt ), 1 );
376 BitmapWriteAccess* pWAcc = aBmp.AcquireWriteAccess();
378 if( pWAcc )
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() );
390 else
391 pDev->DrawPolygon( Polygon( Point( nCenterX, nCenterY ), n2, n2 ) );
393 break;
395 case SYMBOL_STOP:
397 nLeft = nCenterX-n2;
398 nRight = nCenterX+n2;
399 nTop = nCenterY-n2;
400 nBottom = nCenterY+n2;
401 pDev->DrawRect( Rectangle( nLeft, nTop, nRight, nBottom ) );
403 break;
405 case SYMBOL_PAUSE:
407 nLeft = nCenterX-n2;
408 nRight = nCenterX+n2-1;
409 nTop = nCenterY-n2;
410 nBottom = nCenterY+n2;
411 pDev->DrawRect( Rectangle( nLeft, nTop, nCenterX-2, nBottom ) );
412 pDev->DrawRect( Rectangle( nCenterX+1, nTop, nRight, nBottom ) );
414 break;
416 case SYMBOL_WINDSTART:
417 case SYMBOL_WINDBACKWARD:
419 nLeft = nCenterX-n2+1;
420 nRight = nCenterX;
421 pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) );
422 pDev->DrawRect( Rectangle( nLeft+n2, nCenterY, nRight+n2, nCenterY ) );
423 i = 1;
424 while ( i < n2 )
426 nLeft++;
427 nTemp = nCenterY-i;
428 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
429 pDev->DrawRect( Rectangle( nLeft+n2, nTemp, nRight+n2, nTemp ) );
430 nTemp = nCenterY+i;
431 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
432 pDev->DrawRect( Rectangle( nLeft+n2, nTemp, nRight+n2, nTemp ) );
433 i++;
435 if ( eType == SYMBOL_WINDSTART )
437 pDev->DrawRect( Rectangle( nCenterX-n2, nCenterY-n2,
438 nCenterX-n2, nCenterY+n2 ) );
441 break;
443 case SYMBOL_WINDEND:
444 case SYMBOL_WINDFORWARD:
446 nLeft = nCenterX-n2;
447 nRight = nCenterX-1;
448 pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) );
449 pDev->DrawRect( Rectangle( nLeft+n2, nCenterY, nRight+n2, nCenterY ) );
450 i = 1;
451 while ( i < n2 )
453 nRight--;
454 nTemp = nCenterY-i;
455 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
456 pDev->DrawRect( Rectangle( nLeft+n2, nTemp, nRight+n2, nTemp ) );
457 nTemp = nCenterY+i;
458 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) );
459 pDev->DrawRect( Rectangle( nLeft+n2, nTemp, nRight+n2, nTemp ) );
460 i++;
462 if ( eType == SYMBOL_WINDEND )
464 pDev->DrawRect( Rectangle( nCenterX+n2, nCenterY-n2,
465 nCenterX+n2, nCenterY+n2 ) );
468 break;
470 case SYMBOL_CLOSE:
472 Size aRectSize( 2, 1 );
473 if ( nMin < 8 )
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;
480 i = 0;
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 ) );
485 i++;
488 break;
490 case SYMBOL_ROLLUP:
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 );
510 break;
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,
518 rRect.Bottom() );
519 Point aPos3( bRTL ? rRect.TopLeft() : rRect.TopRight() );
520 Size aRectSize( 1, 2 );
521 long nStepsY = aPos2.Y()-aPos1.Y();
522 long nX = aPos1.X();
523 long nY = aPos1.Y();
524 long n;
525 for ( n = 0; n <= nStepsY; n++ )
527 if( bRTL )
528 nX--;
529 pDev->DrawRect( Rectangle( Point( nX, nY++ ), aRectSize ) );
530 if( !bRTL )
531 nX++;
533 nStepsY = aPos2.Y()-aPos3.Y();
534 nX = aPos2.X();
535 nY = aPos2.Y();
536 for ( n = 0; n <= nStepsY; n++ )
538 if( bRTL )
539 if ( --nX < rRect.Left() )
540 break;
541 pDev->DrawRect( Rectangle( Point( nX, nY-- ), aRectSize ) );
542 if( !bRTL )
543 if ( ++nX > rRect.Right() )
544 break;
547 break;
549 case SYMBOL_SPIN_UPDOWN:
551 nTop = nCenterY-n2-1;
552 nBottom = nTop+n2;
553 pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) );
554 i = 1;
555 while ( i <= n2 )
557 nTop++;
558 nTemp = nCenterX-i;
559 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
560 nTemp = nCenterX+i;
561 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
562 i++;
564 nTop = nCenterY+1;
565 nBottom = nTop+n2;
566 pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) );
567 i = 1;
568 while ( i <= n2 )
570 nBottom--;
571 nTemp = nCenterX-i;
572 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
573 nTemp = nCenterX+i;
574 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) );
575 i++;
578 break;
581 case SYMBOL_FLOAT:
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 );
599 aTempRect = 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 );
610 break;
611 case SYMBOL_DOCK:
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 );
627 break;
628 case SYMBOL_HIDE:
630 long nExtra = nMin / 8;
631 Rectangle aRect( nCenterX-n2+nExtra, nCenterY+n2-1,
632 nCenterX+n2-nExtra, nCenterY+n2 );
633 pDev->DrawRect( aRect );
635 break;
637 case SYMBOL_OS2CLOSE:
639 Rectangle aRect( nCenterX-n2, nCenterY-n2,
640 nCenterX+n2, nCenterY+n2 );
641 ImplDrawOS2Symbol( pDev, aRect, 0, TRUE );
643 break;
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() );
662 break;
664 case SYMBOL_OS2HIDE:
666 Rectangle aRect( nCenterX-n2+3, nCenterY-n2+3,
667 nCenterX+n2-3, nCenterY+n2-3 );
668 ImplDrawOS2Symbol( pDev, aRect, 0, FALSE );
670 break;
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 ) );
696 else
697 mpOutDev->SetFillColor( Color( COL_BLACK ) );
699 else
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() );
710 else
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,
742 USHORT nStyle )
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 );
762 else
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;
796 if ( !nLineWidth )
797 nLineWidth = 1;
798 if ( !nLineHeight )
799 nLineHeight = 1;
801 if ( pColor )
803 if ( (nLineWidth == 1) && (nLineHeight == 1) )
805 pDev->SetLineColor( *pColor );
806 pDev->SetFillColor();
807 if( bRound )
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) );
814 else
815 pDev->DrawRect( rRect );
817 else
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 )
843 // mask menu style
844 BOOL bMenuStyle = (nStyle & FRAME_DRAW_MENU) ? TRUE : FALSE;
845 nStyle &= ~FRAME_DRAW_MENU;
847 Window *pWin = NULL;
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() )
864 bFlatBorders = TRUE;
865 else
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) ||
874 bFlatBorders )
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 );
892 else
894 USHORT nFrameStyle = nStyle & FRAME_DRAW_STYLE;
896 if ( nFrameStyle == FRAME_DRAW_GROUP )
898 rRect.Left() += 2;
899 rRect.Top() += 2;
900 rRect.Right() -= 2;
901 rRect.Bottom() -= 2;
903 else if ( (nFrameStyle == FRAME_DRAW_IN) ||
904 (nFrameStyle == FRAME_DRAW_OUT) )
906 rRect.Left()++;
907 rRect.Top()++;
908 rRect.Right()--;
909 rRect.Bottom()--;
911 else // FRAME_DRAW_DOUBLEIN || FRAME_DRAW_DOUBLEOUT
913 rRect.Left() += 2;
914 rRect.Top() += 2;
915 rRect.Right() -= 2;
916 rRect.Bottom() -= 2;
920 else
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();
937 return;
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
947 if (
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 );
959 else
961 USHORT nFrameStyle = nStyle & FRAME_DRAW_STYLE;
962 if ( nFrameStyle == FRAME_DRAW_GROUP )
964 pDev->SetFillColor();
965 pDev->SetLineColor( rStyleSettings.GetLightColor() );
966 rRect.Top()++;
967 rRect.Left()++;
968 pDev->DrawRect( rRect );
969 rRect.Top()--;
970 rRect.Left()--;
971 pDev->SetLineColor( rStyleSettings.GetShadowColor() );
972 rRect.Right()--;
973 rRect.Bottom()--;
974 pDev->DrawRect( rRect );
975 rRect.Right()++;
976 rRect.Bottom()++;
978 else
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() );
991 else
993 pDev->ImplDraw2ColorFrame( rRect,
994 rStyleSettings.GetLightColor(),
995 rStyleSettings.GetShadowColor() );
998 rRect.Left()++;
999 rRect.Top()++;
1000 rRect.Right()--;
1001 rRect.Bottom()--;
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() );
1011 else
1012 pDev->ImplDraw2ColorFrame( rRect,
1013 rStyleSettings.GetShadowColor(),
1014 rStyleSettings.GetLightColor() );
1016 else
1018 if( bMenuStyle )
1019 pDev->ImplDraw2ColorFrame( rRect,
1020 rStyleSettings.GetMenuBorderColor(),
1021 rStyleSettings.GetDarkShadowColor() );
1022 else
1023 pDev->ImplDraw2ColorFrame( rRect,
1024 bFlatBorders ? // no 3d effect
1025 rStyleSettings.GetDarkShadowColor() :
1026 rStyleSettings.GetLightBorderColor(),
1027 rStyleSettings.GetDarkShadowColor() );
1031 rRect.Left()++;
1032 rRect.Top()++;
1033 rRect.Right()--;
1034 rRect.Bottom()--;
1036 BOOL bDrawn = TRUE;
1037 if ( nFrameStyle == FRAME_DRAW_DOUBLEIN )
1039 if( bFlatBorders ) // no 3d effect
1040 pDev->ImplDraw2ColorFrame( rRect,
1041 rStyleSettings.GetFaceColor(),
1042 rStyleSettings.GetFaceColor() );
1043 else
1044 pDev->ImplDraw2ColorFrame( rRect,
1045 rStyleSettings.GetDarkShadowColor(),
1046 rStyleSettings.GetLightBorderColor() );
1048 else
1050 // flat menues have no shadow border
1051 if( !bMenuStyle || !rStyleSettings.GetUseFlatMenues() )
1052 pDev->ImplDraw2ColorFrame( rRect,
1053 rStyleSettings.GetLightColor(),
1054 rStyleSettings.GetShadowColor() );
1055 else
1056 bDrawn = FALSE;
1058 if( bDrawn )
1060 rRect.Left()++;
1061 rRect.Top()++;
1062 rRect.Right()--;
1063 rRect.Bottom()--;
1071 // -----------------------------------------------------------------------
1073 Rectangle DecorationView::DrawFrame( const Rectangle& rRect, USHORT nStyle )
1075 Rectangle aRect = rRect;
1076 BOOL bOldMap = mpOutDev->IsMapModeEnabled();
1077 if ( bOldMap )
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 );
1087 else
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 );
1097 if ( bOldMap )
1099 mpOutDev->EnableMapMode( bOldMap );
1100 aRect = mpOutDev->PixelToLogic( aRect );
1103 return 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 );
1136 Rectangle aRect1;
1137 Rectangle aRect2;
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();
1151 else
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 );
1164 else
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() ) );
1183 aFillRect.Left()++;
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() ) );
1191 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()--;
1202 Color aColor1;
1203 Color aColor2;
1204 if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
1206 aColor1 = rStyleSettings.GetDarkShadowColor();
1207 aColor2 = rStyleSettings.GetLightColor();
1209 else
1211 if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER )
1212 aColor1 = rStyleSettings.GetLightBorderColor();
1213 else
1214 aColor1 = rStyleSettings.GetLightColor();
1215 if ( (nStyle & BUTTON_DRAW_FLATTEST) == BUTTON_DRAW_FLAT )
1216 aColor2 = rStyleSettings.GetShadowColor();
1217 else
1218 aColor2 = rStyleSettings.GetDarkShadowColor();
1220 pDev->ImplDraw2ColorFrame( aFillRect, aColor1, aColor2 );
1221 aFillRect.Left()++;
1222 aFillRect.Top()++;
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();
1233 else
1235 if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER )
1236 aColor1 = rStyleSettings.GetLightColor();
1237 else
1238 aColor1 = rStyleSettings.GetLightBorderColor();
1239 aColor2 = rStyleSettings.GetShadowColor();
1241 pDev->ImplDraw2ColorFrame( aFillRect, aColor1, aColor2 );
1242 aFillRect.Left()++;
1243 aFillRect.Top()++;
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 ) );
1259 else
1260 pDev->SetFillColor( Color( COL_WHITE ) );
1262 else
1264 if ( nStyle & (BUTTON_DRAW_CHECKED | BUTTON_DRAW_DONTKNOW) )
1265 pDev->SetFillColor( rStyleSettings.GetCheckedColor() );
1266 else
1267 pDev->SetFillColor( rStyleSettings.GetFaceColor() );
1269 pDev->DrawRect( aFillRect );
1272 // Ein Border freilassen, der jedoch bei Default-Darstellung
1273 // mitbenutzt wird
1274 rRect.Left()++;
1275 rRect.Top()++;
1276 rRect.Right()--;
1277 rRect.Bottom()--;
1279 if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER )
1281 rRect.Left()++;
1282 rRect.Top()++;
1284 else if ( nStyle & BUTTON_DRAW_NOLEFTLIGHTBORDER )
1285 rRect.Left()++;
1287 if ( nStyle & BUTTON_DRAW_PRESSED )
1289 if ( (rRect.GetHeight() > 10) && (rRect.GetWidth() > 10) )
1291 rRect.Left() += 4;
1292 rRect.Top() += 4;
1293 rRect.Right() -= 1;
1294 rRect.Bottom() -= 1;
1296 else
1298 rRect.Left() += 3;
1299 rRect.Top() += 3;
1300 rRect.Right() -= 2;
1301 rRect.Bottom() -= 2;
1304 else if ( nStyle & BUTTON_DRAW_CHECKED )
1306 rRect.Left() += 3;
1307 rRect.Top() += 3;
1308 rRect.Right() -= 2;
1309 rRect.Bottom() -= 2;
1311 else
1313 rRect.Left() += 2;
1314 rRect.Top() += 2;
1315 rRect.Right() -= 3;
1316 rRect.Bottom() -= 3;
1320 // -----------------------------------------------------------------------
1322 Rectangle DecorationView::DrawButton( const Rectangle& rRect, USHORT nStyle )
1324 Rectangle aRect = rRect;
1325 BOOL bOldMap = mpOutDev->IsMapModeEnabled();
1326 if ( bOldMap )
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 );
1341 else
1343 Color maOldLineColor = mpOutDev->GetLineColor();
1344 Color maOldFillColor = mpOutDev->GetFillColor();
1345 ImplDrawButton( mpOutDev, aRect, rStyleSettings, nStyle );
1346 mpOutDev->SetLineColor( maOldLineColor );
1347 mpOutDev->SetFillColor( maOldFillColor );
1351 if ( bOldMap )
1353 mpOutDev->EnableMapMode( bOldMap );
1354 aRect = mpOutDev->PixelToLogic( aRect );
1357 return aRect;