PageRenderTime 74ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/vcl/source/window/decoview.cxx

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