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