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