Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <vcl/settings.hxx>
30 : : #include <vcl/outdev.hxx>
31 : : #include <vcl/decoview.hxx>
32 : : #include <vcl/window.hxx>
33 : : #include <vcl/ctrl.hxx>
34 : :
35 : : // =======================================================================
36 : :
37 : : #define BUTTON_DRAW_FLATTEST (BUTTON_DRAW_FLAT | \
38 : : BUTTON_DRAW_PRESSED | \
39 : : BUTTON_DRAW_CHECKED | \
40 : : BUTTON_DRAW_HIGHLIGHT)
41 : :
42 : : // =======================================================================
43 : :
44 : : namespace {
45 : :
46 : 28690 : long AdjustRectToSquare( Rectangle &rRect )
47 : : {
48 : 28690 : const long nWidth = rRect.GetWidth();
49 : 28690 : const long nHeight = rRect.GetHeight();
50 : 28690 : long nSide = Min( nWidth, nHeight );
51 : :
52 [ + + ][ + - ]: 28690 : if ( nSide && !(nSide & 1) )
53 : : {
54 : : // we prefer an odd size
55 : 24635 : --nSide;
56 : : }
57 : :
58 : : // Make the rectangle a square
59 [ + - ]: 28690 : rRect.SetSize( Size( nSide, nSide ) );
60 : :
61 : : // and place it at the center of the original rectangle
62 : 28690 : rRect.Move( (nWidth-nSide)/2, (nHeight-nSide)/2 );
63 : :
64 : 28690 : return nSide;
65 : : }
66 : :
67 : 28690 : void ImplDrawSymbol( OutputDevice* pDev, Rectangle nRect, const SymbolType eType )
68 : : {
69 [ + - ]: 28690 : const long nSide = AdjustRectToSquare( nRect );
70 : :
71 [ + - ]: 28690 : if ( !nSide ) return;
72 [ - + ]: 28690 : if ( nSide==1 )
73 : : {
74 [ # # ]: 0 : pDev->DrawPixel( Point( nRect.Left(), nRect.Top() ) );
75 : : return;
76 : : }
77 : :
78 : : // Precalculate some values
79 : 28690 : const long n2 = nSide/2;
80 : 28690 : const long n4 = (n2+1)/2;
81 : 28690 : const long n8 = (n4+1)/2;
82 [ + - ]: 28690 : const Point aCenter = nRect.Center();
83 : :
84 [ - - - - : 28690 : switch ( eType )
+ + + + +
+ - - - -
- - - - -
- + - - -
- - - ]
85 : : {
86 : : case SYMBOL_ARROW_UP:
87 [ # # ]: 0 : pDev->DrawPixel( Point( aCenter.X(), nRect.Top() ) );
88 [ # # ]: 0 : for ( long i=1; i <= n2; ++i )
89 : : {
90 : 0 : ++nRect.Top();
91 : 0 : pDev->DrawLine( Point( aCenter.X()-i, nRect.Top() ),
92 [ # # ]: 0 : Point( aCenter.X()+i, nRect.Top() ) );
93 : : }
94 : 0 : pDev->DrawRect( Rectangle( aCenter.X()-n8, nRect.Top()+1,
95 [ # # ][ # # ]: 0 : aCenter.X()+n8, nRect.Bottom() ) );
96 : 0 : break;
97 : :
98 : : case SYMBOL_ARROW_DOWN:
99 [ # # ]: 0 : pDev->DrawPixel( Point( aCenter.X(), nRect.Bottom() ) );
100 [ # # ]: 0 : for ( long i=1; i <= n2; ++i )
101 : : {
102 : 0 : --nRect.Bottom();
103 : 0 : pDev->DrawLine( Point( aCenter.X()-i, nRect.Bottom() ),
104 [ # # ]: 0 : Point( aCenter.X()+i, nRect.Bottom() ) );
105 : : }
106 : 0 : pDev->DrawRect( Rectangle( aCenter.X()-n8, nRect.Top(),
107 [ # # ][ # # ]: 0 : aCenter.X()+n8, nRect.Bottom()-1 ) );
108 : 0 : break;
109 : :
110 : : case SYMBOL_ARROW_LEFT:
111 [ # # ]: 0 : pDev->DrawPixel( Point( nRect.Left(), aCenter.Y() ) );
112 [ # # ]: 0 : for ( long i=1; i <= n2; ++i )
113 : : {
114 : 0 : ++nRect.Left();
115 : 0 : pDev->DrawLine( Point( nRect.Left(), aCenter.Y()-i ),
116 [ # # ]: 0 : Point( nRect.Left(), aCenter.Y()+i ) );
117 : : }
118 : 0 : pDev->DrawRect( Rectangle( nRect.Left()+1, aCenter.Y()-n8,
119 [ # # ][ # # ]: 0 : nRect.Right(), aCenter.Y()+n8 ) );
120 : 0 : break;
121 : :
122 : : case SYMBOL_ARROW_RIGHT:
123 [ # # ]: 0 : pDev->DrawPixel( Point( nRect.Right(), aCenter.Y() ) );
124 [ # # ]: 0 : for ( long i=1; i <= n2; ++i )
125 : : {
126 : 0 : --nRect.Right();
127 : 0 : pDev->DrawLine( Point( nRect.Right(), aCenter.Y()-i ),
128 [ # # ]: 0 : Point( nRect.Right(), aCenter.Y()+i ) );
129 : : }
130 : 0 : pDev->DrawRect( Rectangle( nRect.Left(), aCenter.Y()-n8,
131 [ # # ][ # # ]: 0 : nRect.Right()-1, aCenter.Y()+n8 ) );
132 : 0 : break;
133 : :
134 : :
135 : : case SYMBOL_SPIN_UP:
136 : 5798 : nRect.Top() += n4;
137 [ + - ]: 5798 : pDev->DrawPixel( Point( aCenter.X(), nRect.Top() ) );
138 [ + + ]: 22838 : for ( long i=1; i <= n2; ++i )
139 : : {
140 : 17040 : ++nRect.Top();
141 : 17040 : pDev->DrawLine( Point( aCenter.X()-i, nRect.Top() ),
142 [ + - ]: 34080 : Point( aCenter.X()+i, nRect.Top() ) );
143 : : }
144 : 5798 : break;
145 : :
146 : : case SYMBOL_SPIN_DOWN:
147 : 9637 : nRect.Bottom() -= n4;
148 [ + - ]: 9637 : pDev->DrawPixel( Point( aCenter.X(), nRect.Bottom() ) );
149 [ + + ]: 38419 : for ( long i=1; i <= n2; ++i )
150 : : {
151 : 28782 : --nRect.Bottom();
152 : 28782 : pDev->DrawLine( Point( aCenter.X()-i, nRect.Bottom() ),
153 [ + - ]: 57564 : Point( aCenter.X()+i, nRect.Bottom() ) );
154 : : }
155 : 9637 : break;
156 : :
157 : : case SYMBOL_SPIN_LEFT:
158 : : case SYMBOL_FIRST:
159 : : case SYMBOL_PREV:
160 : : case SYMBOL_REVERSEPLAY:
161 : 5853 : nRect.Left() += n4;
162 [ + + ]: 5853 : if ( eType==SYMBOL_FIRST )
163 : : {
164 : 812 : pDev->DrawLine( Point( nRect.Left(), nRect.Top() ),
165 [ + - ]: 1624 : Point( nRect.Left(), nRect.Bottom() ) );
166 : 812 : ++nRect.Left();
167 : : }
168 [ + - ]: 5853 : pDev->DrawPixel( Point( nRect.Left(), aCenter.Y() ) );
169 [ + + ]: 24256 : for ( long i=1; i <= n2; ++i )
170 : : {
171 : 18403 : ++nRect.Left();
172 : 18403 : pDev->DrawLine( Point( nRect.Left(), aCenter.Y()-i ),
173 [ + - ]: 36806 : Point( nRect.Left(), aCenter.Y()+i ) );
174 : : }
175 : 5853 : break;
176 : :
177 : : case SYMBOL_SPIN_RIGHT:
178 : : case SYMBOL_LAST:
179 : : case SYMBOL_NEXT:
180 : : case SYMBOL_PLAY:
181 : 4027 : nRect.Right() -= n4;
182 [ + + ]: 4027 : if ( eType==SYMBOL_LAST )
183 : : {
184 : 837 : pDev->DrawLine( Point( nRect.Right(), nRect.Top() ),
185 [ + - ]: 1674 : Point( nRect.Right(), nRect.Bottom() ) );
186 : 837 : --nRect.Right();
187 : : }
188 [ + - ]: 4027 : pDev->DrawPixel( Point( nRect.Right(), aCenter.Y() ) );
189 [ + + ]: 16500 : for ( long i=1; i <= n2; ++i )
190 : : {
191 : 12473 : --nRect.Right();
192 : 12473 : pDev->DrawLine( Point( nRect.Right(), aCenter.Y()-i ),
193 [ + - ]: 24946 : Point( nRect.Right(), aCenter.Y()+i ) );
194 : : }
195 : 4027 : break;
196 : :
197 : : case SYMBOL_PAGEUP:
198 [ + - ]: 1676 : pDev->DrawPixel( Point( aCenter.X(), nRect.Top() ) );
199 [ + - ]: 1676 : pDev->DrawPixel( Point( aCenter.X(), nRect.Top()+n2 ) );
200 [ + + ]: 6704 : for ( long i=1; i < n2; ++i )
201 : : {
202 : 5028 : ++nRect.Top();
203 : 5028 : pDev->DrawLine( Point( aCenter.X()-i, nRect.Top() ),
204 [ + - ]: 10056 : Point( aCenter.X()+i, nRect.Top() ) );
205 : 5028 : pDev->DrawLine( Point( aCenter.X()-i, nRect.Top()+n2 ),
206 [ + - ]: 10056 : Point( aCenter.X()+i, nRect.Top()+n2 ) );
207 : : }
208 : 1676 : break;
209 : :
210 : : case SYMBOL_PAGEDOWN:
211 [ + - ]: 1683 : pDev->DrawPixel( Point( aCenter.X(), nRect.Bottom() ) );
212 [ + - ]: 1683 : pDev->DrawPixel( Point( aCenter.X(), nRect.Bottom()-n2 ) );
213 [ + + ]: 6732 : for ( long i=1; i < n2; ++i )
214 : : {
215 : 5049 : --nRect.Bottom();
216 : 5049 : pDev->DrawLine( Point( aCenter.X()-i, nRect.Bottom() ),
217 [ + - ]: 10098 : Point( aCenter.X()+i, nRect.Bottom() ) );
218 : 5049 : pDev->DrawLine( Point( aCenter.X()-i, nRect.Bottom()-n2 ),
219 [ + - ]: 10098 : Point( aCenter.X()+i, nRect.Bottom()-n2 ) );
220 : : }
221 : 1683 : break;
222 : :
223 : : case SYMBOL_RADIOCHECKMARK:
224 : : case SYMBOL_RECORD:
225 : : {
226 : : // Midpoint circle algorithm
227 : 0 : long x = 0;
228 : 0 : long y = n2;
229 : 0 : long p = 1 - n2;
230 : : // Draw central line
231 : 0 : pDev->DrawLine( Point( aCenter.X(), aCenter.Y()-y ),
232 [ # # ]: 0 : Point( aCenter.X(), aCenter.Y()+y ) );
233 [ # # ]: 0 : while ( x<y )
234 : : {
235 [ # # ]: 0 : if ( p>=0 )
236 : : {
237 : : // Draw vertical lines close to sides
238 : 0 : pDev->DrawLine( Point( aCenter.X()+y, aCenter.Y()-x ),
239 [ # # ]: 0 : Point( aCenter.X()+y, aCenter.Y()+x ) );
240 : 0 : pDev->DrawLine( Point( aCenter.X()-y, aCenter.Y()-x ),
241 [ # # ]: 0 : Point( aCenter.X()-y, aCenter.Y()+x ) );
242 : 0 : --y;
243 : 0 : p -= 2*y;
244 : : }
245 : 0 : ++x;
246 : 0 : p += 2*x+1;
247 : : // Draw vertical lines close to center
248 : 0 : pDev->DrawLine( Point( aCenter.X()-x, aCenter.Y()-y ),
249 [ # # ]: 0 : Point( aCenter.X()-x, aCenter.Y()+y ) );
250 : 0 : pDev->DrawLine( Point( aCenter.X()+x, aCenter.Y()-y ),
251 [ # # ]: 0 : Point( aCenter.X()+x, aCenter.Y()+y ) );
252 : : }
253 : : }
254 : 0 : break;
255 : :
256 : : case SYMBOL_STOP:
257 [ # # ]: 0 : pDev->DrawRect( nRect );
258 : 0 : break;
259 : :
260 : : case SYMBOL_PAUSE:
261 : 0 : pDev->DrawRect( Rectangle ( nRect.Left(), nRect.Top(),
262 [ # # ][ # # ]: 0 : aCenter.X()-n8, nRect.Bottom() ) );
263 : 0 : pDev->DrawRect( Rectangle ( aCenter.X()+n8, nRect.Top(),
264 [ # # ][ # # ]: 0 : nRect.Right(), nRect.Bottom() ) );
265 : 0 : break;
266 : :
267 : : case SYMBOL_WINDSTART:
268 : 0 : pDev->DrawLine( Point( nRect.Left(), aCenter.Y()-n2+1 ),
269 [ # # ]: 0 : Point( nRect.Left(), aCenter.Y()+n2-1 ) );
270 : 0 : ++nRect.Left();
271 : : // Intentional fall-through
272 : : case SYMBOL_WINDBACKWARD:
273 [ # # ]: 0 : pDev->DrawPixel( Point( nRect.Left(), aCenter.Y() ) );
274 [ # # ]: 0 : pDev->DrawPixel( Point( nRect.Left()+n2, aCenter.Y() ) );
275 [ # # ]: 0 : for ( long i=1; i < n2; ++i )
276 : : {
277 : 0 : ++nRect.Left();
278 : 0 : pDev->DrawLine( Point( nRect.Left(), aCenter.Y()-i ),
279 [ # # ]: 0 : Point( nRect.Left(), aCenter.Y()+i ) );
280 : 0 : pDev->DrawLine( Point( nRect.Left()+n2, aCenter.Y()-i ),
281 [ # # ]: 0 : Point( nRect.Left()+n2, aCenter.Y()+i ) );
282 : : }
283 : 0 : break;
284 : :
285 : : case SYMBOL_WINDEND:
286 : 0 : pDev->DrawLine( Point( nRect.Right(), aCenter.Y()-n2+1 ),
287 [ # # ]: 0 : Point( nRect.Right(), aCenter.Y()+n2-1 ) );
288 : 0 : --nRect.Right();
289 : : // Intentional fall-through
290 : : case SYMBOL_WINDFORWARD:
291 [ # # ]: 0 : pDev->DrawPixel( Point( nRect.Right(), aCenter.Y() ) );
292 [ # # ]: 0 : pDev->DrawPixel( Point( nRect.Right()-n2, aCenter.Y() ) );
293 [ # # ]: 0 : for ( long i=1; i < n2; ++i )
294 : : {
295 : 0 : --nRect.Right();
296 : 0 : pDev->DrawLine( Point( nRect.Right(), aCenter.Y()-i ),
297 [ # # ]: 0 : Point( nRect.Right(), aCenter.Y()+i ) );
298 : 0 : pDev->DrawLine( Point( nRect.Right()-n2, aCenter.Y()-i ),
299 [ # # ]: 0 : Point( nRect.Right()-n2, aCenter.Y()+i ) );
300 : : }
301 : 0 : break;
302 : :
303 : : case SYMBOL_CLOSE:
304 : 0 : pDev->DrawLine( Point( nRect.Left(), nRect.Top() ),
305 [ # # ]: 0 : Point( nRect.Right(), nRect.Bottom() ) );
306 : 0 : pDev->DrawLine( Point( nRect.Left(), nRect.Bottom() ),
307 [ # # ]: 0 : Point( nRect.Right(), nRect.Top() ) );
308 [ # # ]: 0 : for ( long i=1; i<n8; ++i )
309 : : {
310 : 0 : pDev->DrawLine( Point( nRect.Left()+i, nRect.Top() ),
311 [ # # ]: 0 : Point( nRect.Right(), nRect.Bottom()-i ) );
312 : 0 : pDev->DrawLine( Point( nRect.Left(), nRect.Top()+i ),
313 [ # # ]: 0 : Point( nRect.Right()-i, nRect.Bottom() ) );
314 : 0 : pDev->DrawLine( Point( nRect.Left()+i, nRect.Bottom() ),
315 [ # # ]: 0 : Point( nRect.Right(), nRect.Top()+i ) );
316 : 0 : pDev->DrawLine( Point( nRect.Left(), nRect.Bottom()-i ),
317 [ # # ]: 0 : Point( nRect.Right()-i, nRect.Top() ) );
318 : : }
319 : 0 : break;
320 : :
321 : : case SYMBOL_ROLLDOWN:
322 : 0 : pDev->DrawLine( Point( nRect.Left(), nRect.Top() ),
323 [ # # ]: 0 : Point( nRect.Left(), nRect.Bottom() ) );
324 : 0 : pDev->DrawLine( Point( nRect.Right(), nRect.Top() ),
325 [ # # ]: 0 : Point( nRect.Right(), nRect.Bottom() ) );
326 : 0 : pDev->DrawLine( Point( nRect.Left(), nRect.Bottom() ),
327 [ # # ]: 0 : Point( nRect.Right(), nRect.Bottom() ) );
328 : : // Intentional fall-through
329 : : case SYMBOL_ROLLUP:
330 : 0 : pDev->DrawRect( Rectangle( nRect.Left(), nRect.Top(),
331 [ # # ][ # # ]: 0 : nRect.Right(), nRect.Top()+n8 ) );
332 : 0 : break;
333 : :
334 : : case SYMBOL_CHECKMARK:
335 : : {
336 : 16 : long n3 = nSide/3;
337 : 16 : nRect.Top() -= n3/2;
338 : 16 : nRect.Bottom() -= n3/2;
339 : : // #106953# never mirror checkmarks
340 [ - + ][ # # ]: 16 : if ( pDev->ImplHasMirroredGraphics() && pDev->IsRTLEnabled() )
[ - + ][ + - ]
341 : : {
342 : : // Draw a mirrored checkmark so that it looks "normal" in a
343 : : // mirrored graphics device (double mirroring!)
344 : 0 : pDev->DrawLine( Point( nRect.Right(), nRect.Bottom()-n3 ),
345 [ # # ]: 0 : Point( nRect.Right()-n3, nRect.Bottom() ) );
346 : 0 : pDev->DrawLine( Point( nRect.Right()-n3, nRect.Bottom() ),
347 [ # # ]: 0 : Point( nRect.Left(), nRect.Top()+n3 ) );
348 : 0 : ++nRect.Top();
349 : 0 : ++nRect.Bottom();
350 : 0 : pDev->DrawLine( Point( nRect.Right(), nRect.Bottom()-n3 ),
351 [ # # ]: 0 : Point( nRect.Right()-n3, nRect.Bottom() ) );
352 : 0 : pDev->DrawLine( Point( nRect.Right()-n3, nRect.Bottom() ),
353 [ # # ]: 0 : Point( nRect.Left(), nRect.Top()+n3 ) );
354 : : }
355 : : else
356 : : {
357 : 16 : pDev->DrawLine( Point( nRect.Left(), nRect.Bottom()-n3 ),
358 [ + - ]: 32 : Point( nRect.Left()+n3, nRect.Bottom() ) );
359 : 16 : pDev->DrawLine( Point( nRect.Left()+n3, nRect.Bottom() ),
360 [ + - ]: 32 : Point( nRect.Right(), nRect.Top()+n3 ) );
361 : 16 : ++nRect.Top();
362 : 16 : ++nRect.Bottom();
363 : 16 : pDev->DrawLine( Point( nRect.Left(), nRect.Bottom()-n3 ),
364 [ + - ]: 32 : Point( nRect.Left()+n3, nRect.Bottom() ) );
365 : 16 : pDev->DrawLine( Point( nRect.Left()+n3, nRect.Bottom() ),
366 [ + - ]: 32 : Point( nRect.Right(), nRect.Top()+n3 ) );
367 : : }
368 : : }
369 : 16 : break;
370 : :
371 : : case SYMBOL_SPIN_UPDOWN:
372 [ # # ]: 0 : pDev->DrawPixel( Point( aCenter.X(), nRect.Top() ) );
373 [ # # ]: 0 : pDev->DrawPixel( Point( aCenter.X(), nRect.Bottom() ) );
374 [ # # ]: 0 : for ( long i=1; i < n2; ++i )
375 : : {
376 : 0 : ++nRect.Top();
377 : 0 : --nRect.Bottom();
378 : 0 : pDev->DrawLine( Point( aCenter.X()-i, nRect.Top() ),
379 [ # # ]: 0 : Point( aCenter.X()+i, nRect.Top() ) );
380 : 0 : pDev->DrawLine( Point( aCenter.X()-i, nRect.Bottom() ),
381 [ # # ]: 0 : Point( aCenter.X()+i, nRect.Bottom() ) );
382 : : }
383 : 0 : break;
384 : :
385 : : case SYMBOL_FLOAT:
386 : 0 : nRect.Right() -= n4;
387 : 0 : nRect.Top() += n4+1;
388 : 0 : pDev->DrawRect( Rectangle( nRect.Left(), nRect.Top(),
389 [ # # ][ # # ]: 0 : nRect.Right(), nRect.Top()+n8 ) );
390 : 0 : pDev->DrawLine( Point( nRect.Left(), nRect.Top()+n8 ),
391 [ # # ]: 0 : Point( nRect.Left(), nRect.Bottom() ) );
392 : 0 : pDev->DrawLine( Point( nRect.Left(), nRect.Bottom() ),
393 [ # # ]: 0 : Point( nRect.Right(), nRect.Bottom() ) );
394 : 0 : pDev->DrawLine( Point( nRect.Right(), nRect.Top()+n8 ),
395 [ # # ]: 0 : Point( nRect.Right(), nRect.Bottom() ) );
396 : 0 : nRect.Right() += n4;
397 : 0 : nRect.Top() -= n4+1;
398 : 0 : nRect.Left() += n4;
399 : 0 : nRect.Bottom() -= n4+1;
400 : 0 : pDev->DrawRect( Rectangle( nRect.Left(), nRect.Top(),
401 [ # # ][ # # ]: 0 : nRect.Right(), nRect.Top()+n8 ) );
402 : 0 : pDev->DrawLine( Point( nRect.Left(), nRect.Top()+n8 ),
403 [ # # ]: 0 : Point( nRect.Left(), nRect.Bottom() ) );
404 : 0 : pDev->DrawLine( Point( nRect.Left(), nRect.Bottom() ),
405 [ # # ]: 0 : Point( nRect.Right(), nRect.Bottom() ) );
406 : 0 : pDev->DrawLine( Point( nRect.Right(), nRect.Top()+n8 ),
407 [ # # ]: 0 : Point( nRect.Right(), nRect.Bottom() ) );
408 : 0 : break;
409 : :
410 : : case SYMBOL_DOCK:
411 : 0 : pDev->DrawLine( Point( nRect.Left(), nRect.Top() ),
412 [ # # ]: 0 : Point( nRect.Right(), nRect.Top() ) );
413 : 0 : pDev->DrawLine( Point( nRect.Left(), nRect.Top() ),
414 [ # # ]: 0 : Point( nRect.Left(), nRect.Bottom() ) );
415 : 0 : pDev->DrawLine( Point( nRect.Left(), nRect.Bottom() ),
416 [ # # ]: 0 : Point( nRect.Right(), nRect.Bottom() ) );
417 : 0 : pDev->DrawLine( Point( nRect.Right(), nRect.Top() ),
418 [ # # ]: 0 : Point( nRect.Right(), nRect.Bottom() ) );
419 : 0 : break;
420 : :
421 : : case SYMBOL_HIDE:
422 : 0 : pDev->DrawRect( Rectangle( nRect.Left()+n8, nRect.Bottom()-n8,
423 [ # # ][ # # ]: 0 : nRect.Right()-n8, nRect.Bottom() ) );
424 : 0 : break;
425 : :
426 : : case SYMBOL_PLUS:
427 : 0 : pDev->DrawRect( Rectangle( nRect.Left(), aCenter.Y()-n8,
428 [ # # ][ # # ]: 0 : nRect.Right(), aCenter.Y()+n8 ) );
429 : 0 : pDev->DrawRect( Rectangle( aCenter.X()-n8, nRect.Top(),
430 [ # # ][ # # ]: 0 : aCenter.X()+n8, nRect.Bottom() ) );
431 : 28690 : break;
432 : : }
433 : : }
434 : :
435 : :
436 : 1712 : void ImplDrawDPILineRect( OutputDevice *const pDev, Rectangle& rRect,
437 : : const Color *const pColor, const bool bRound = false )
438 : : {
439 : 1712 : long nLineWidth = pDev->ImplGetDPIX()/300;
440 : 1712 : long nLineHeight = pDev->ImplGetDPIY()/300;
441 [ + - ]: 1712 : if ( !nLineWidth )
442 : 1712 : nLineWidth = 1;
443 [ + - ]: 1712 : if ( !nLineHeight )
444 : 1712 : nLineHeight = 1;
445 : :
446 [ + + ]: 1712 : if ( pColor )
447 : : {
448 [ + - ][ + - ]: 1125 : if ( (nLineWidth == 1) && (nLineHeight == 1) )
449 : : {
450 : 1125 : pDev->SetLineColor( *pColor );
451 [ - + ]: 2250 : if( bRound )
452 : : {
453 [ # # ]: 0 : pDev->DrawLine( Point( rRect.Left()+1, rRect.Top()), Point( rRect.Right()-1, rRect.Top()) );
454 [ # # ]: 0 : pDev->DrawLine( Point( rRect.Left()+1, rRect.Bottom()), Point( rRect.Right()-1, rRect.Bottom()) );
455 [ # # ]: 0 : pDev->DrawLine( Point( rRect.Left(), rRect.Top()+1), Point( rRect.Left(), rRect.Bottom()-1) );
456 [ # # ]: 0 : pDev->DrawLine( Point( rRect.Right(), rRect.Top()+1), Point( rRect.Right(), rRect.Bottom()-1) );
457 : : }
458 : : else
459 : : {
460 : 1125 : pDev->SetFillColor();
461 : 1125 : pDev->DrawRect( rRect );
462 : : }
463 : : }
464 : : else
465 : : {
466 : 0 : const long nWidth = rRect.GetWidth();
467 : 0 : const long nHeight = rRect.GetHeight();
468 : 0 : pDev->SetLineColor();
469 : 0 : pDev->SetFillColor( *pColor );
470 [ # # ][ # # ]: 0 : pDev->DrawRect( Rectangle( rRect.TopLeft(), Size( nWidth, nLineHeight ) ) );
471 [ # # ][ # # ]: 0 : pDev->DrawRect( Rectangle( rRect.TopLeft(), Size( nLineWidth, nHeight ) ) );
472 : 0 : pDev->DrawRect( Rectangle( Point( rRect.Left(), rRect.Bottom()-nLineHeight ),
473 [ # # ][ # # ]: 0 : Size( nWidth, nLineHeight ) ) );
474 : 0 : pDev->DrawRect( Rectangle( Point( rRect.Right()-nLineWidth, rRect.Top() ),
475 [ # # ][ # # ]: 1125 : Size( nLineWidth, nHeight ) ) );
476 : : }
477 : : }
478 : :
479 : 1712 : rRect.Left() += nLineWidth;
480 : 1712 : rRect.Top() += nLineHeight;
481 : 1712 : rRect.Right() -= nLineWidth;
482 : 1712 : rRect.Bottom() -= nLineHeight;
483 : 1712 : }
484 : :
485 : :
486 : 72941 : void ImplDraw2ColorFrame( OutputDevice *const pDev, Rectangle& rRect,
487 : : const Color& rLeftTopColor, const Color& rRightBottomColor )
488 : : {
489 : 72941 : pDev->SetLineColor( rLeftTopColor );
490 [ + - ]: 72941 : pDev->DrawLine( rRect.TopLeft(), rRect.BottomLeft() );
491 [ + - ]: 72941 : pDev->DrawLine( rRect.TopLeft(), rRect.TopRight() );
492 : 72941 : pDev->SetLineColor( rRightBottomColor );
493 [ + - ][ + - ]: 72941 : pDev->DrawLine( rRect.BottomLeft(), rRect.BottomRight() );
494 [ + - ][ + - ]: 72941 : pDev->DrawLine( rRect.TopRight(), rRect.BottomRight() );
495 : :
496 : : // reduce drawing area
497 : 72941 : ++rRect.Left();
498 : 72941 : ++rRect.Top();
499 : 72941 : --rRect.Right();
500 : 72941 : --rRect.Bottom();
501 : 72941 : }
502 : :
503 : :
504 : 28545 : void ImplDrawButton( OutputDevice *const pDev, Rectangle aFillRect,
505 : : const sal_uInt16 nStyle )
506 : : {
507 : 28545 : const StyleSettings& rStyleSettings = pDev->GetSettings().GetStyleSettings();
508 : :
509 [ - + ]: 57090 : if ( (nStyle & BUTTON_DRAW_MONO) ||
[ + - - + ]
510 : 28545 : (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
511 : : {
512 : 0 : const Color aBlackColor( COL_BLACK );
513 : :
514 [ # # ]: 0 : if ( nStyle & BUTTON_DRAW_DEFAULT )
515 : : {
516 : : // default selection shows a wider border
517 [ # # ]: 0 : ImplDrawDPILineRect( pDev, aFillRect, &aBlackColor );
518 : : }
519 : :
520 [ # # ]: 0 : ImplDrawDPILineRect( pDev, aFillRect, &aBlackColor );
521 : :
522 : 0 : Size aBrdSize( 1, 1 );
523 [ # # ]: 0 : if ( pDev->GetOutDevType() == OUTDEV_PRINTER )
524 : : {
525 [ # # ][ # # ]: 0 : aBrdSize = pDev->LogicToPixel( Size( 20, 20 ), MapMode(MAP_100TH_MM) );
[ # # ]
526 [ # # ]: 0 : if ( !aBrdSize.Width() )
527 : 0 : aBrdSize.Width() = 1;
528 [ # # ]: 0 : if ( !aBrdSize.Height() )
529 : 0 : aBrdSize.Height() = 1;
530 : : }
531 : :
532 [ # # ]: 0 : pDev->SetLineColor();
533 [ # # ]: 0 : pDev->SetFillColor( aBlackColor );
534 : 0 : const Rectangle aOrigFillRect(aFillRect);
535 [ # # ]: 0 : if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
536 : : {
537 : : // shrink fill rect
538 : 0 : aFillRect.Left() += aBrdSize.Width();
539 : 0 : aFillRect.Top() += aBrdSize.Height();
540 : : // draw top and left borders (aOrigFillRect-aFillRect)
541 : : pDev->DrawRect( Rectangle( aOrigFillRect.Left(), aOrigFillRect.Top(),
542 [ # # ][ # # ]: 0 : aOrigFillRect.Right(), aFillRect.Top()-1 ) );
543 : : pDev->DrawRect( Rectangle( aOrigFillRect.Left(), aOrigFillRect.Top(),
544 [ # # ][ # # ]: 0 : aFillRect.Left()-1, aOrigFillRect.Bottom() ) );
545 : : }
546 : : else
547 : : {
548 : : // shrink fill rect
549 : 0 : aFillRect.Right() -= aBrdSize.Width();
550 : 0 : aFillRect.Bottom() -= aBrdSize.Height();
551 : : // draw bottom and right borders (aOrigFillRect-aFillRect)
552 : 0 : pDev->DrawRect( Rectangle( aOrigFillRect.Left(), aFillRect.Bottom()+1,
553 [ # # ][ # # ]: 0 : aOrigFillRect.Right(), aOrigFillRect.Bottom() ) );
554 : 0 : pDev->DrawRect( Rectangle( aFillRect.Right()+1, aOrigFillRect.Top(),
555 [ # # ][ # # ]: 0 : aOrigFillRect.Right(), aOrigFillRect.Bottom() ) );
556 : : }
557 : :
558 [ # # ]: 0 : if ( !(nStyle & BUTTON_DRAW_NOFILL) )
559 : : {
560 : : // Hack: Auf Druckern wollen wir im MonoChrom-Modus trotzdem
561 : : // erstmal graue Buttons haben
562 [ # # ]: 0 : if ( pDev->GetOutDevType() == OUTDEV_PRINTER )
563 [ # # ]: 0 : pDev->SetFillColor( Color( COL_LIGHTGRAY ) );
564 : : else
565 [ # # ]: 0 : pDev->SetFillColor( Color( COL_WHITE ) );
566 [ # # ]: 0 : pDev->DrawRect( aFillRect );
567 : : }
568 : : }
569 : : else
570 : : {
571 [ + + ]: 28545 : if ( nStyle & BUTTON_DRAW_DEFAULT )
572 : : {
573 : 6 : const Color aDefBtnColor = rStyleSettings.GetDarkShadowColor();
574 [ + - ]: 6 : ImplDrawDPILineRect( pDev, aFillRect, &aDefBtnColor );
575 : : }
576 : :
577 [ + + ]: 28545 : if ( nStyle & BUTTON_DRAW_NOLEFTLIGHTBORDER )
578 : : {
579 [ + - ]: 1214 : pDev->SetLineColor( rStyleSettings.GetLightBorderColor() );
580 : 1214 : pDev->DrawLine( Point( aFillRect.Left(), aFillRect.Top() ),
581 [ + - ]: 2428 : Point( aFillRect.Left(), aFillRect.Bottom() ) );
582 : 1214 : ++aFillRect.Left();
583 : : }
584 : :
585 : 28545 : Color aColor1;
586 : 28545 : Color aColor2;
587 [ + + ]: 28545 : if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
588 : : {
589 : 4 : aColor1 = rStyleSettings.GetDarkShadowColor();
590 : 4 : aColor2 = rStyleSettings.GetLightColor();
591 : : }
592 : : else
593 : : {
594 [ + + ]: 28541 : if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER )
595 : 21979 : aColor1 = rStyleSettings.GetLightBorderColor();
596 : : else
597 : 6562 : aColor1 = rStyleSettings.GetLightColor();
598 [ - + ]: 28541 : if ( (nStyle & BUTTON_DRAW_FLATTEST) == BUTTON_DRAW_FLAT )
599 : 0 : aColor2 = rStyleSettings.GetShadowColor();
600 : : else
601 : 28541 : aColor2 = rStyleSettings.GetDarkShadowColor();
602 : : }
603 : :
604 [ + - ]: 28545 : ImplDraw2ColorFrame( pDev, aFillRect, aColor1, aColor2 );
605 : :
606 [ + - ]: 28545 : if ( !((nStyle & BUTTON_DRAW_FLATTEST) == BUTTON_DRAW_FLAT) )
607 : : {
608 [ + + ]: 28545 : if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) )
609 : : {
610 : 4 : aColor1 = rStyleSettings.GetShadowColor();
611 : 4 : aColor2 = rStyleSettings.GetLightBorderColor();
612 : : }
613 : : else
614 : : {
615 [ + + ]: 28541 : if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER )
616 : 21979 : aColor1 = rStyleSettings.GetLightColor();
617 : : else
618 : 6562 : aColor1 = rStyleSettings.GetLightBorderColor();
619 : 28541 : aColor2 = rStyleSettings.GetShadowColor();
620 : : }
621 [ + - ]: 28545 : ImplDraw2ColorFrame( pDev, aFillRect, aColor1, aColor2 );
622 : : }
623 : :
624 [ + - ]: 28545 : if ( !(nStyle & BUTTON_DRAW_NOFILL) )
625 : : {
626 [ + - ]: 28545 : pDev->SetLineColor();
627 [ - + ]: 28545 : if ( nStyle & (BUTTON_DRAW_CHECKED | BUTTON_DRAW_DONTKNOW) )
628 [ # # ]: 0 : pDev->SetFillColor( rStyleSettings.GetCheckedColor() );
629 : : else
630 [ + - ]: 28545 : pDev->SetFillColor( rStyleSettings.GetFaceColor() );
631 [ + - ]: 28545 : pDev->DrawRect( aFillRect );
632 : : }
633 : : }
634 : 28545 : }
635 : :
636 : 35188 : void ImplDrawFrame( OutputDevice *const pDev, Rectangle& rRect,
637 : : const StyleSettings& rStyleSettings, sal_uInt16 nStyle )
638 : : {
639 [ + - ]: 35188 : Window *const pWin = (pDev->GetOutDevType()==OUTDEV_WINDOW) ? (Window*) pDev : NULL;
640 : :
641 : 35188 : const bool bMenuStyle = nStyle & FRAME_DRAW_MENU;
642 : :
643 : : // UseFlatBorders disables 3D style for all frames except menus
644 : : // menus may use different border colors (eg on XP)
645 : : // normal frames will be drawn using the shadow color
646 : : // whereas window frame borders will use black
647 [ + + ][ - + ]: 35188 : bool bFlatBorders = !bMenuStyle && rStyleSettings.GetUseFlatBorders();
648 : :
649 : : // no flat borders for standard VCL controls (ie formcontrols that keep their classic look)
650 : : // will not affect frame windows (like dropdowns)
651 [ - + ][ # # ]: 35188 : if( bFlatBorders && pWin && pWin->GetType() == WINDOW_BORDERWINDOW && (pWin != pWin->ImplGetFrameWindow()) )
[ # # ][ # # ]
[ - + ]
652 : : {
653 : : // check for formcontrol, i.e., a control without NWF enabled
654 [ # # ]: 0 : Control *const pControl = dynamic_cast< Control* >( pWin->GetWindow( WINDOW_CLIENT ) );
655 [ # # ][ # # ]: 0 : if( !pControl || !pControl->IsNativeWidgetEnabled() )
[ # # ]
656 : 0 : bFlatBorders = false;
657 : : }
658 : :
659 : 35188 : const bool bNoDraw = nStyle & FRAME_DRAW_NODRAW;
660 : :
661 [ + - + - ]: 70376 : if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ||
[ - + ][ - + ]
662 : 35188 : (pDev->GetOutDevType() == OUTDEV_PRINTER) ||
663 : : bFlatBorders )
664 : 0 : nStyle |= FRAME_DRAW_MONO;
665 : :
666 [ + - ]: 70376 : if( (nStyle & FRAME_DRAW_STYLE) != FRAME_DRAW_NWF &&
[ + - - + ]
[ - + ]
667 : 35188 : pWin && pWin->IsNativeControlSupported(CTRL_FRAME, PART_BORDER) )
668 : : {
669 : : ImplControlValue aControlValue( nStyle |
670 [ # # ]: 0 : (pWin->GetType()==WINDOW_BORDERWINDOW ?
671 [ # # ]: 0 : FRAME_DRAW_BORDERWINDOWBORDER : 0) );
672 [ # # ][ # # ]: 0 : Rectangle aBound, aContent;
673 : 0 : Rectangle aNatRgn( rRect );
674 [ # # ]: 0 : if( pWin->GetNativeControlRegion(CTRL_FRAME, PART_BORDER,
675 [ # # ]: 0 : aNatRgn, 0, aControlValue, rtl::OUString(), aBound, aContent) )
676 : : {
677 : : // if bNoDraw is true then don't call the drawing routine
678 : : // but just update the target rectangle
679 [ # # ][ # # ]: 0 : if( bNoDraw ||
[ # # ]
680 : : pWin->DrawNativeControl( CTRL_FRAME, PART_BORDER, aContent, CTRL_STATE_ENABLED,
681 [ # # ][ # # ]: 0 : aControlValue, rtl::OUString()) )
[ # # ]
682 : : {
683 : 0 : rRect = aContent;
684 : 35188 : return;
685 : : }
686 [ # # ][ # # ]: 0 : }
687 : : }
688 : :
689 [ + + ]: 35188 : if ( nStyle & FRAME_DRAW_MONO )
690 : : {
691 : : // no round corners for window frame borders
692 [ - + ][ # # ]: 1706 : const bool bRound = bFlatBorders && !(nStyle & FRAME_DRAW_WINDOWBORDER);
693 : :
694 [ + + ]: 1706 : if ( bNoDraw )
695 : : {
696 : 587 : ImplDrawDPILineRect( pDev, rRect, NULL, bRound );
697 : : }
698 : : else
699 : : {
700 : : Color aColor = bRound ? rStyleSettings.GetShadowColor()
701 [ - + ]: 1119 : : pDev->GetSettings().GetStyleSettings().GetMonoColor();
702 : : // when the MonoColor wasn't set, check face color
703 [ - + ]: 4476 : if (
[ # # + - ]
[ - + ][ - + ]
704 [ # # ]: 0 : (bRound && aColor.IsDark()) ||
705 : : (
706 [ + - ][ # # ]: 2238 : (aColor == Color(COL_BLACK)) &&
707 [ + - ]: 1119 : pDev->GetSettings().GetStyleSettings().GetFaceColor().IsDark()
708 : : )
709 : : )
710 : : {
711 : 0 : aColor = Color( COL_WHITE );
712 : : }
713 [ + - ]: 1119 : ImplDrawDPILineRect( pDev, rRect, &aColor, bRound );
714 : : }
715 : : }
716 : : else
717 : : {
718 [ + + ]: 33482 : if ( bNoDraw )
719 : : {
720 [ + + - - ]: 25239 : switch ( nStyle & FRAME_DRAW_STYLE )
721 : : {
722 : : case FRAME_DRAW_IN:
723 : : case FRAME_DRAW_OUT:
724 : 68 : ++rRect.Left();
725 : 68 : ++rRect.Top();
726 : 68 : --rRect.Right();
727 : 68 : --rRect.Bottom();
728 : 68 : break;
729 : :
730 : : case FRAME_DRAW_GROUP:
731 : : case FRAME_DRAW_DOUBLEIN:
732 : : case FRAME_DRAW_DOUBLEOUT:
733 : 25171 : rRect.Left() += 2;
734 : 25171 : rRect.Top() += 2;
735 : 25171 : rRect.Right() -= 2;
736 : 25171 : rRect.Bottom() -= 2;
737 : 25171 : break;
738 : :
739 : : case FRAME_DRAW_NWF:
740 : : // enough space for the native rendering
741 : 0 : rRect.Left() += 4;
742 : 0 : rRect.Top() += 4;
743 : 0 : rRect.Right() -= 4;
744 : 0 : rRect.Bottom() -= 4;
745 : 25239 : break;
746 : : }
747 : : }
748 : : else
749 : : {
750 [ - + - + : 8243 : switch ( nStyle & FRAME_DRAW_STYLE )
+ - - ]
751 : : {
752 : : case FRAME_DRAW_GROUP:
753 : 0 : pDev->SetFillColor();
754 : 0 : pDev->SetLineColor( rStyleSettings.GetLightColor() );
755 : 0 : pDev->DrawRect( Rectangle( rRect.Left()+1, rRect.Top()+1,
756 [ # # ]: 0 : rRect.Right(), rRect.Bottom() ) );
757 : 0 : pDev->SetLineColor( rStyleSettings.GetShadowColor() );
758 : 0 : pDev->DrawRect( Rectangle( rRect.Left(), rRect.Top(),
759 [ # # ]: 0 : rRect.Right()-1, rRect.Bottom()-1 ) );
760 : :
761 : : // adjust target rectangle
762 : 0 : rRect.Left() += 2;
763 : 0 : rRect.Top() += 2;
764 : 0 : rRect.Right() -= 2;
765 : 0 : rRect.Bottom() -= 2;
766 : 0 : break;
767 : :
768 : : case FRAME_DRAW_IN:
769 : : ImplDraw2ColorFrame( pDev, rRect,
770 : 635 : rStyleSettings.GetShadowColor(),
771 : 1270 : rStyleSettings.GetLightColor() );
772 : 635 : break;
773 : :
774 : : case FRAME_DRAW_OUT:
775 : : ImplDraw2ColorFrame( pDev, rRect,
776 : 0 : rStyleSettings.GetLightColor(),
777 : 0 : rStyleSettings.GetShadowColor() );
778 : 0 : break;
779 : :
780 : : case FRAME_DRAW_DOUBLEIN:
781 [ - + ]: 7588 : if( bFlatBorders )
782 : : {
783 : : // no 3d effect
784 : : ImplDraw2ColorFrame( pDev, rRect,
785 : 0 : rStyleSettings.GetShadowColor(),
786 : 0 : rStyleSettings.GetShadowColor() );
787 : : ImplDraw2ColorFrame( pDev, rRect,
788 : 0 : rStyleSettings.GetFaceColor(),
789 : 0 : rStyleSettings.GetFaceColor() );
790 : : }
791 : : else
792 : : {
793 : : ImplDraw2ColorFrame( pDev, rRect,
794 : 7588 : rStyleSettings.GetShadowColor(),
795 : 15176 : rStyleSettings.GetLightColor() );
796 : : ImplDraw2ColorFrame( pDev, rRect,
797 : 7588 : rStyleSettings.GetDarkShadowColor(),
798 : 15176 : rStyleSettings.GetLightBorderColor() );
799 : : }
800 : 7588 : break;
801 : :
802 : : case FRAME_DRAW_DOUBLEOUT:
803 [ + + ]: 20 : if( bMenuStyle )
804 : : {
805 : : ImplDraw2ColorFrame( pDev, rRect,
806 : 14 : rStyleSettings.GetMenuBorderColor(),
807 : 28 : rStyleSettings.GetDarkShadowColor() );
808 [ + - ]: 14 : if ( !rStyleSettings.GetUseFlatMenues() )
809 : : {
810 : : ImplDraw2ColorFrame( pDev, rRect,
811 : 14 : rStyleSettings.GetLightColor(),
812 : 28 : rStyleSettings.GetShadowColor() );
813 : : }
814 : : }
815 : : else
816 : : {
817 : : ImplDraw2ColorFrame( pDev, rRect,
818 : : bFlatBorders ? // no 3d effect
819 : : rStyleSettings.GetDarkShadowColor() :
820 : : rStyleSettings.GetLightBorderColor(),
821 [ - + ]: 6 : rStyleSettings.GetDarkShadowColor() );
822 : : ImplDraw2ColorFrame( pDev, rRect,
823 : 6 : rStyleSettings.GetLightColor(),
824 : 12 : rStyleSettings.GetShadowColor() );
825 : : }
826 : 20 : break;
827 : :
828 : : case FRAME_DRAW_NWF:
829 : : // no rendering, just enough space for the native rendering
830 : 0 : rRect.Left() += 4;
831 : 0 : rRect.Top() += 4;
832 : 0 : rRect.Right() -= 4;
833 : 0 : rRect.Bottom() -= 4;
834 : 0 : break;
835 : : }
836 : : }
837 : : }
838 : : }
839 : :
840 : : }
841 : :
842 : :
843 : : // -----------------------------------------------------------------------
844 : :
845 : 21742 : void DecorationView::DrawSymbol( const Rectangle& rRect, SymbolType eType,
846 : : const Color& rColor, sal_uInt16 nStyle )
847 : : {
848 : 21742 : const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings();
849 [ + - ]: 21742 : const Rectangle aRect = mpOutDev->LogicToPixel( rRect );
850 : 21742 : const Color aOldLineColor = mpOutDev->GetLineColor();
851 : 21742 : const Color aOldFillColor = mpOutDev->GetFillColor();
852 : 21742 : const bool bOldMapMode = mpOutDev->IsMapModeEnabled();
853 : 21742 : Color nColor(rColor);
854 [ + - ]: 21742 : mpOutDev->EnableMapMode( sal_False );
855 : :
856 [ + - - + ]: 43484 : if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ||
[ - + ]
857 : 21742 : (mpOutDev->GetOutDevType() == OUTDEV_PRINTER) )
858 : 0 : nStyle |= BUTTON_DRAW_MONO;
859 : :
860 [ - + ]: 21742 : if ( nStyle & SYMBOL_DRAW_MONO )
861 : : {
862 : : // Monochrome: set color to black if enabled, to gray if disabled
863 [ # # ]: 0 : nColor = Color( ( nStyle & SYMBOL_DRAW_DISABLE ) ? COL_GRAY : COL_BLACK );
864 : : }
865 : : else
866 : : {
867 [ + + ]: 21742 : if ( nStyle & SYMBOL_DRAW_DISABLE )
868 : : {
869 : : // Draw shifted and brighter symbol for embossed look
870 [ + - ]: 6948 : mpOutDev->SetLineColor( rStyleSettings.GetLightColor() );
871 [ + - ]: 6948 : mpOutDev->SetFillColor( rStyleSettings.GetLightColor() );
872 [ + - ][ + - ]: 6948 : ImplDrawSymbol( mpOutDev, aRect + Point(1, 1) , eType );
873 : 6948 : nColor = rStyleSettings.GetShadowColor();
874 : : }
875 : : }
876 : :
877 : : // Set selected color and draw the symbol
878 [ + - ]: 21742 : mpOutDev->SetLineColor( nColor );
879 [ + - ]: 21742 : mpOutDev->SetFillColor( nColor );
880 [ + - ]: 21742 : ImplDrawSymbol( mpOutDev, aRect, eType );
881 : :
882 : : // Restore previous settings
883 [ + - ]: 21742 : mpOutDev->SetLineColor( aOldLineColor );
884 [ + - ]: 21742 : mpOutDev->SetFillColor( aOldFillColor );
885 [ + - ]: 21742 : mpOutDev->EnableMapMode( bOldMapMode );
886 : 21742 : }
887 : :
888 : : // =======================================================================
889 : :
890 : 0 : void DecorationView::DrawFrame( const Rectangle& rRect,
891 : : const Color& rLeftTopColor,
892 : : const Color& rRightBottomColor )
893 : : {
894 [ # # ]: 0 : Rectangle aRect = mpOutDev->LogicToPixel( rRect );
895 : 0 : const Color aOldLineColor = mpOutDev->GetLineColor();
896 : 0 : const bool bOldMapMode = mpOutDev->IsMapModeEnabled();
897 [ # # ]: 0 : mpOutDev->EnableMapMode( false );
898 [ # # ]: 0 : ImplDraw2ColorFrame( mpOutDev, aRect, rLeftTopColor, rRightBottomColor );
899 [ # # ]: 0 : mpOutDev->SetLineColor( aOldLineColor );
900 [ # # ]: 0 : mpOutDev->EnableMapMode( bOldMapMode );
901 : 0 : }
902 : :
903 : : // =======================================================================
904 : :
905 : 0 : void DecorationView::DrawHighlightFrame( const Rectangle& rRect,
906 : : sal_uInt16 nStyle )
907 : : {
908 : 0 : const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings();
909 : 0 : Color aLightColor = rStyleSettings.GetLightColor();
910 : 0 : Color aShadowColor = rStyleSettings.GetShadowColor();
911 : :
912 [ # # ]: 0 : if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ||
[ # # # # ]
913 : 0 : (mpOutDev->GetOutDevType() == OUTDEV_PRINTER) )
914 : : {
915 : 0 : aLightColor = Color( COL_BLACK );
916 : 0 : aShadowColor = Color( COL_BLACK );
917 : : }
918 [ # # ]: 0 : else if ( nStyle & FRAME_HIGHLIGHT_TESTBACKGROUND )
919 : : {
920 [ # # ]: 0 : Wallpaper aBackground = mpOutDev->GetBackground();
921 [ # # ][ # # ]: 0 : if ( aBackground.IsBitmap() || aBackground.IsGradient() )
[ # # ][ # # ]
[ # # ]
922 : : {
923 : 0 : aLightColor = rStyleSettings.GetFaceColor();
924 : 0 : aShadowColor = Color( COL_BLACK );
925 : : }
926 : : else
927 : : {
928 [ # # ]: 0 : Color aBackColor = aBackground.GetColor();
929 [ # # ][ # # ]: 0 : if ( (aLightColor.GetColorError( aBackColor ) < 32) ||
[ # # ][ # # ]
930 [ # # ]: 0 : (aShadowColor.GetColorError( aBackColor ) < 32) )
931 : : {
932 : 0 : aLightColor = Color( COL_WHITE );
933 : 0 : aShadowColor = Color( COL_BLACK );
934 : :
935 [ # # ][ # # ]: 0 : if ( aLightColor.GetColorError( aBackColor ) < 32 )
936 [ # # ]: 0 : aLightColor.DecreaseLuminance( 64 );
937 [ # # ][ # # ]: 0 : if ( aShadowColor.GetColorError( aBackColor ) < 32 )
938 [ # # ]: 0 : aShadowColor.IncreaseLuminance( 64 );
939 : : }
940 [ # # ]: 0 : }
941 : : }
942 : :
943 [ # # ]: 0 : if ( (nStyle & FRAME_HIGHLIGHT_STYLE) == FRAME_HIGHLIGHT_IN )
944 : : {
945 : 0 : Color aTempColor = aLightColor;
946 : 0 : aLightColor = aShadowColor;
947 : 0 : aShadowColor = aTempColor;
948 : : }
949 : :
950 [ # # ]: 0 : DrawFrame( rRect, aLightColor, aShadowColor );
951 : 0 : }
952 : :
953 : : // =======================================================================
954 : :
955 : 35195 : Rectangle DecorationView::DrawFrame( const Rectangle& rRect, sal_uInt16 nStyle )
956 : : {
957 : 35195 : Rectangle aRect = rRect;
958 : 35195 : sal_Bool bOldMap = mpOutDev->IsMapModeEnabled();
959 [ - + ]: 35195 : if ( bOldMap )
960 : : {
961 : 0 : aRect = mpOutDev->LogicToPixel( aRect );
962 : 0 : mpOutDev->EnableMapMode( sal_False );
963 : : }
964 : :
965 [ + + ]: 35195 : if ( !rRect.IsEmpty() )
966 : : {
967 [ + + ]: 35188 : if ( nStyle & FRAME_DRAW_NODRAW )
968 : 25826 : ImplDrawFrame( mpOutDev, aRect, mpOutDev->GetSettings().GetStyleSettings(), nStyle );
969 : : else
970 : : {
971 : 9362 : Color maOldLineColor = mpOutDev->GetLineColor();
972 : 9362 : Color maOldFillColor = mpOutDev->GetFillColor();
973 [ + - ]: 9362 : ImplDrawFrame( mpOutDev, aRect, mpOutDev->GetSettings().GetStyleSettings(), nStyle );
974 [ + - ]: 9362 : mpOutDev->SetLineColor( maOldLineColor );
975 [ + - ]: 9362 : mpOutDev->SetFillColor( maOldFillColor );
976 : : }
977 : : }
978 : :
979 [ - + ]: 35195 : if ( bOldMap )
980 : : {
981 : 0 : mpOutDev->EnableMapMode( bOldMap );
982 : 0 : aRect = mpOutDev->PixelToLogic( aRect );
983 : : }
984 : :
985 : 35195 : return aRect;
986 : : }
987 : :
988 : : // =======================================================================
989 : :
990 : 28745 : Rectangle DecorationView::DrawButton( const Rectangle& rRect, sal_uInt16 nStyle )
991 : : {
992 [ + - ][ + + ]: 28745 : if ( rRect.IsEmpty() )
993 : : {
994 : 200 : return rRect;
995 : : }
996 : :
997 : 28545 : Rectangle aRect = rRect;
998 : 28545 : const bool bOldMap = mpOutDev->IsMapModeEnabled();
999 : :
1000 [ - + ]: 28545 : if ( bOldMap )
1001 : : {
1002 [ # # ]: 0 : aRect = mpOutDev->LogicToPixel( aRect );
1003 [ # # ]: 0 : mpOutDev->EnableMapMode( false );
1004 : : }
1005 : :
1006 : 28545 : const Color maOldLineColor = mpOutDev->GetLineColor();
1007 : 28545 : const Color maOldFillColor = mpOutDev->GetFillColor();
1008 [ + - ]: 28545 : ImplDrawButton( mpOutDev, aRect, nStyle );
1009 [ + - ]: 28545 : mpOutDev->SetLineColor( maOldLineColor );
1010 [ + - ]: 28545 : mpOutDev->SetFillColor( maOldFillColor );
1011 : :
1012 : : // Ein Border freilassen, der jedoch bei Default-Darstellung
1013 : : // mitbenutzt wird
1014 : 28545 : ++aRect.Left();
1015 : 28545 : ++aRect.Top();
1016 : 28545 : --aRect.Right();
1017 : 28545 : --aRect.Bottom();
1018 : :
1019 [ + + ]: 28545 : if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER )
1020 : : {
1021 : 21983 : ++aRect.Left();
1022 : 21983 : ++aRect.Top();
1023 : : }
1024 [ + + ]: 6562 : else if ( nStyle & BUTTON_DRAW_NOLEFTLIGHTBORDER )
1025 : : {
1026 : 1214 : ++aRect.Left();
1027 : : }
1028 : :
1029 [ + + ]: 28545 : if ( nStyle & BUTTON_DRAW_PRESSED )
1030 : : {
1031 [ + - ][ + - ]: 4 : if ( (aRect.GetHeight() > 10) && (aRect.GetWidth() > 10) )
[ + - ][ + - ]
[ + - ]
1032 : : {
1033 : 4 : aRect.Left() += 4;
1034 : 4 : aRect.Top() += 4;
1035 : 4 : aRect.Right() -= 1;
1036 : 4 : aRect.Bottom() -= 1;
1037 : : }
1038 : : else
1039 : : {
1040 : 0 : aRect.Left() += 3;
1041 : 0 : aRect.Top() += 3;
1042 : 0 : aRect.Right() -= 2;
1043 : 0 : aRect.Bottom() -= 2;
1044 : : }
1045 : : }
1046 [ - + ]: 28541 : else if ( nStyle & BUTTON_DRAW_CHECKED )
1047 : : {
1048 : 0 : aRect.Left() += 3;
1049 : 0 : aRect.Top() += 3;
1050 : 0 : aRect.Right() -= 2;
1051 : 0 : aRect.Bottom() -= 2;
1052 : : }
1053 : : else
1054 : : {
1055 : 28541 : aRect.Left() += 2;
1056 : 28541 : aRect.Top() += 2;
1057 : 28541 : aRect.Right() -= 3;
1058 : 28541 : aRect.Bottom() -= 3;
1059 : : }
1060 : :
1061 [ - + ]: 28545 : if ( bOldMap )
1062 : : {
1063 [ # # ]: 0 : mpOutDev->EnableMapMode( bOldMap );
1064 [ # # ]: 0 : aRect = mpOutDev->PixelToLogic( aRect );
1065 : : }
1066 : :
1067 : 28745 : return aRect;
1068 : : }
1069 : :
1070 : : // -----------------------------------------------------------------------
1071 : :
1072 : 21111 : void DecorationView::DrawSeparator( const Point& rStart, const Point& rStop, bool bVertical )
1073 : : {
1074 : 21111 : Point aStart( rStart ), aStop( rStop );
1075 : 21111 : const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings();
1076 [ + - ]: 21111 : Window *const pWin = (mpOutDev->GetOutDevType()==OUTDEV_WINDOW) ? (Window*) mpOutDev: NULL;
1077 [ + - ]: 21111 : if(pWin)
1078 : : {
1079 [ + + ]: 21111 : ControlPart nPart = ( bVertical ? PART_SEPARATOR_VERT : PART_SEPARATOR_HORZ );
1080 [ + - ]: 21111 : bool nativeSupported = pWin->IsNativeControlSupported( CTRL_FIXEDLINE, nPart );
1081 : 21111 : ImplControlValue aValue;
1082 : 21111 : ControlState nState = 0;
1083 [ + - ]: 21111 : Rectangle aRect(rStart,rStop);
1084 [ - + ][ # # ]: 21111 : if(nativeSupported && pWin->DrawNativeControl(CTRL_FIXEDLINE,nPart,aRect,nState,aValue,rtl::OUString()))
[ # # ][ - + ]
[ - + ][ # # ]
1085 [ + - ][ + - ]: 42222 : return;
1086 : : }
1087 : :
1088 [ + - ]: 21111 : mpOutDev->Push( PUSH_LINECOLOR );
1089 [ - + ]: 21111 : if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
1090 [ # # ]: 0 : mpOutDev->SetLineColor( Color( COL_BLACK ) );
1091 : : else
1092 [ + - ]: 21111 : mpOutDev->SetLineColor( rStyleSettings.GetShadowColor() );
1093 : :
1094 [ + - ]: 21111 : mpOutDev->DrawLine( aStart, aStop );
1095 [ + - ]: 21111 : if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
1096 : : {
1097 [ + - ]: 21111 : mpOutDev->SetLineColor( rStyleSettings.GetLightColor() );
1098 [ + + ]: 21111 : if( bVertical )
1099 : : {
1100 : 21047 : aStart.X()++;
1101 : 21047 : aStop.X()++;
1102 : : }
1103 : : else
1104 : : {
1105 : 64 : aStart.Y()++;
1106 : 64 : aStop.Y()++;
1107 : : }
1108 [ + - ]: 21111 : mpOutDev->DrawLine( aStart, aStop );
1109 : : }
1110 [ + - ]: 21111 : mpOutDev->Pop();
1111 : : }
1112 : :
1113 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|