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