Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2692 lines
98 KiB

  1. //
  2. // cuischem.cpp
  3. // = UIF scheme implementation =
  4. //
  5. #include "private.h"
  6. #include "cuischem.h"
  7. #include "cuisys.h"
  8. #include "cmydc.h"
  9. #include "cuiutil.h"
  10. #include "math.h"
  11. //
  12. // gloval variables
  13. //
  14. static class CUIFColorTableSys *v_pColTableSys = NULL;
  15. static class CUIFColorTableOff10 *v_pColTableOfc10 = NULL;
  16. /*=============================================================================*/
  17. /* */
  18. /* C U I F C O L O R T A B L E */
  19. /* */
  20. /*=============================================================================*/
  21. typedef enum _SYSCOLOR
  22. {
  23. SYSCOLOR_3DFACE,
  24. SYSCOLOR_3DSHAODW,
  25. SYSCOLOR_ACTIVEBORDER,
  26. SYSCOLOR_ACTIVECAPTION,
  27. SYSCOLOR_BTNFACE,
  28. SYSCOLOR_BTNSHADOW,
  29. SYSCOLOR_BTNTEXT,
  30. SYSCOLOR_CAPTIONTEXT,
  31. SYSCOLOR_GRAYTEXT,
  32. SYSCOLOR_HIGHLIGHT,
  33. SYSCOLOR_HIGHLIGHTTEXT,
  34. SYSCOLOR_INACTIVECAPTION,
  35. SYSCOLOR_INACTIVECAPTIONTEXT,
  36. SYSCOLOR_MENUTEXT,
  37. SYSCOLOR_WINDOW,
  38. SYSCOLOR_WINDOWTEXT,
  39. SYSCOLOR_MAX /* must be last */
  40. } SYSCOLOR;
  41. typedef enum _OFC10COLOR
  42. {
  43. OFC10COLOR_BKGDTB, // msocbvcrCBBkgd
  44. OFC10COLOR_BKGDMENU, // msocbvcrCBMenuBkgd
  45. OFC10COLOR_BKGDWP, // msocbvcrWPBkgd
  46. OFC10COLOR_MENUBARSHORT, // msocbvcrCBMenuIconBkgd
  47. OFC10COLOR_MENUBARLONG, // msocbvcrCBMenuIconBkgdDropped
  48. OFC10COLOR_MOUSEOVERBKGND, // msocbvcrCBCtlBkgdMouseOver
  49. OFC10COLOR_MOUSEOVERBORDER, // msocbvcrCBCtlBdrMouseOver
  50. OFC10COLOR_MOUSEOVERTEXT, // msocbvcrCBCtlTextMouseOver
  51. OFC10COLOR_MOUSEDOWNBKGND, // msocbvcrCBCtlBkgdMouseDown
  52. OFC10COLOR_MOUSEDOWNBORDER, // msocbvcrCBCtlBdrMouseDown
  53. OFC10COLOR_MOUSEDOWNTEXT, // msocbvcrCBCtlTextMouseDown
  54. OFC10COLOR_CTRLBKGD, // msocbvcrCBCtlBkgd
  55. OFC10COLOR_CTRLTEXT, // msocbvcrCBCtlText
  56. OFC10COLOR_CTRLTEXTDISABLED, // msocbvcrCBCtlTextDisabled
  57. OFC10COLOR_CTRLIMAGESHADOW, // REVIEW: KOJIW: office calcs shadow color from bkgnd (not constant color)
  58. OFC10COLOR_CTRLBKGDSELECTED, // msocbvcrCBCtlBkgdSelected
  59. OFC10COLOR_CTRLBORDERSELECTED, // msocbvcrCBCtlBdrSelected
  60. // OFC10COLOR_CTRLDBRDISABLED, //
  61. OFC10COLOR_BDROUTERMENU, // msocbvcrCBMenuBdrOuter
  62. OFC10COLOR_BDRINNERMENU, // msocbvcrCBMenuBdrInner
  63. OFC10COLOR_BDROUTERFLOATTB, // msocbvcrCBBdrOuterFloating
  64. OFC10COLOR_BDRINNERFLOATTB, // msocbvcrCBBdrInnerFloating
  65. OFC10COLOR_BDROUTERFLOATWP, // msocbvcrWPBdrOuterFloating
  66. OFC10COLOR_BDRINNERFLOATWP, // msocbvcrWPBdrInnerFloating
  67. OFC10COLOR_CAPTIONBKGDTB, // msocbvcrCBTitleBkgd
  68. OFC10COLOR_CAPTIONTEXTTB, // msocbvcrCBTitleText
  69. OFC10COLOR_ACTIVECAPTIONBKGDWP, // msocbvcrWPTitleBkgdActive
  70. OFC10COLOR_ACTIVECAPTIONTEXTWP, // msocbvcrWPTitleTextActive
  71. OFC10COLOR_INACTIVECAPTIONBKGDWP, // msocbvcrWPTitleBkgdInactive
  72. OFC10COLOR_INACTIVECAPTIONTEXTWP, // msocbvcrWPTitleTextInactive
  73. OFC10COLOR_SPLITTERLINE, // msocbvcrCBSplitterLine
  74. OFC10COLOR_DRAGHANDLE, // msocbvcrCBDragHandle
  75. OFC10COLOR_MENUCTRLTEXT, // msocbvcrCBMenuCtlText
  76. OFC10COLOR_MAX /* must be last */
  77. } OFC10COLOR;
  78. /*============================================================================*/
  79. /*
  80. Contrast Increasing Code
  81. */
  82. /*============================================================================*/
  83. typedef double CIC_NUM;
  84. // Sizes of color channels in weighted RGB space.
  85. #define MAX_RED 195
  86. #define MAX_GREEN 390
  87. #define MAX_BLUE 65
  88. /*
  89. A note on "dMinContrast":
  90. 0 contrast means the two colors are the same.
  91. Black and White have a contrast of roughly 442, which is the maximum contrast
  92. two colors can have.
  93. The most you can request to have between two colors is 221, since if
  94. one color is 50% grey, the furthest you can be from it is 221 away
  95. (at white or black).
  96. */
  97. #define MIN_TEXT_CONTRAST 180
  98. #define MIN_ICON_CONTRAST 90
  99. struct COLORCONTRAST
  100. {
  101. OFC10COLOR colLocked; // will not be changed by CIC
  102. OFC10COLOR colMoveable; // might be changed by CIC
  103. CIC_NUM cMinContrast; // minimum contrast required between locked and moveable
  104. BOOL fConsiderDarkness; // take into consideration the effects of dark colors
  105. };
  106. static const COLORCONTRAST vrgContrast[] =
  107. {
  108. // Locked Moveable Contrast Darkness
  109. OFC10COLOR_BKGDTB, OFC10COLOR_CTRLTEXT, MIN_TEXT_CONTRAST, TRUE,
  110. OFC10COLOR_BKGDTB, OFC10COLOR_CTRLTEXTDISABLED, 80, TRUE,
  111. OFC10COLOR_BKGDTB, OFC10COLOR_MOUSEOVERBKGND, 50, TRUE,
  112. OFC10COLOR_BKGDTB, OFC10COLOR_MOUSEOVERBORDER, 100, TRUE,
  113. OFC10COLOR_BKGDTB, OFC10COLOR_CTRLBKGDSELECTED, 5, TRUE, // TODO DMORTON - need larger value
  114. // OFC10COLOR_BKGDTB, OFC10COLOR_MOUSEOVERSELECTED, 30, TRUE,
  115. // OFC10COLOR_MOUSEOVERSELECTED, OFC10COLOR_MOUSEOVERSELECTEDBORDER,100, TRUE,
  116. OFC10COLOR_MOUSEOVERBKGND, OFC10COLOR_MOUSEOVERTEXT, MIN_TEXT_CONTRAST, TRUE,
  117. OFC10COLOR_BKGDTB, OFC10COLOR_MOUSEDOWNBKGND, 30, TRUE,
  118. OFC10COLOR_MOUSEDOWNBKGND, OFC10COLOR_MOUSEDOWNTEXT, MIN_TEXT_CONTRAST, TRUE,
  119. OFC10COLOR_BKGDMENU, OFC10COLOR_MENUCTRLTEXT, MIN_TEXT_CONTRAST, TRUE,
  120. // OFC10COLOR_BKGDMENU, OFC10COLOR_MENUCTRLTEXTDISABLED, 80, TRUE,
  121. // OFC10COLOR_BKGDMENU, OFC10COLOR_MENUCTRLBORDER, 100, TRUE,
  122. OFC10COLOR_CAPTIONBKGDTB , OFC10COLOR_CAPTIONTEXTTB, MIN_TEXT_CONTRAST, TRUE,
  123. OFC10COLOR_BKGDMENU, OFC10COLOR_DRAGHANDLE, 85, TRUE,
  124. };
  125. //
  126. // CUIFColorTableBase
  127. //
  128. class CUIFColorTable
  129. {
  130. public:
  131. CUIFColorTable( void )
  132. {
  133. }
  134. virtual ~CUIFColorTable( void )
  135. {
  136. DoneColor();
  137. DoneBrush();
  138. }
  139. void Initialize( void )
  140. {
  141. InitColor();
  142. InitBrush();
  143. }
  144. void Update( void )
  145. {
  146. DoneColor();
  147. DoneBrush();
  148. InitColor();
  149. InitBrush();
  150. }
  151. protected:
  152. virtual void InitColor( void ) {}
  153. virtual void DoneColor( void ) {}
  154. virtual void InitBrush( void ) {}
  155. virtual void DoneBrush( void ) {}
  156. };
  157. //
  158. // CUIFColorTableSys
  159. //
  160. class CUIFColorTableSys : public CUIFColorTable
  161. {
  162. public:
  163. CUIFColorTableSys( void ) : CUIFColorTable()
  164. {
  165. }
  166. virtual ~CUIFColorTableSys( void )
  167. {
  168. DoneColor();
  169. DoneBrush();
  170. }
  171. __inline COLORREF GetColor( SYSCOLOR iColor )
  172. {
  173. return m_rgColor[ iColor ];
  174. }
  175. __inline HBRUSH GetBrush( SYSCOLOR iColor )
  176. {
  177. if (!m_rgBrush[iColor])
  178. m_rgBrush[iColor] = CreateSolidBrush( m_rgColor[iColor] );
  179. return m_rgBrush[ iColor ];
  180. }
  181. protected:
  182. COLORREF m_rgColor[ SYSCOLOR_MAX ];
  183. HBRUSH m_rgBrush[ SYSCOLOR_MAX ];
  184. virtual void InitColor( void )
  185. {
  186. m_rgColor[ SYSCOLOR_3DFACE ] = GetSysColor( COLOR_3DFACE );
  187. m_rgColor[ SYSCOLOR_3DSHAODW ] = GetSysColor( COLOR_3DSHADOW );
  188. m_rgColor[ SYSCOLOR_ACTIVEBORDER ] = GetSysColor( COLOR_ACTIVEBORDER );
  189. m_rgColor[ SYSCOLOR_ACTIVECAPTION ] = GetSysColor( COLOR_ACTIVECAPTION );
  190. m_rgColor[ SYSCOLOR_BTNFACE ] = GetSysColor( COLOR_BTNFACE );
  191. m_rgColor[ SYSCOLOR_BTNSHADOW ] = GetSysColor( COLOR_BTNSHADOW );
  192. m_rgColor[ SYSCOLOR_BTNTEXT ] = GetSysColor( COLOR_BTNTEXT );
  193. m_rgColor[ SYSCOLOR_CAPTIONTEXT ] = GetSysColor( COLOR_CAPTIONTEXT );
  194. m_rgColor[ SYSCOLOR_GRAYTEXT ] = GetSysColor( COLOR_GRAYTEXT );
  195. m_rgColor[ SYSCOLOR_HIGHLIGHT ] = GetSysColor( COLOR_HIGHLIGHT );
  196. m_rgColor[ SYSCOLOR_HIGHLIGHTTEXT ] = GetSysColor( COLOR_HIGHLIGHTTEXT );
  197. m_rgColor[ SYSCOLOR_INACTIVECAPTION ] = GetSysColor( COLOR_INACTIVECAPTION );
  198. m_rgColor[ SYSCOLOR_INACTIVECAPTIONTEXT ] = GetSysColor( COLOR_INACTIVECAPTIONTEXT );
  199. m_rgColor[ SYSCOLOR_MENUTEXT ] = GetSysColor( COLOR_MENUTEXT );
  200. m_rgColor[ SYSCOLOR_WINDOW ] = GetSysColor( COLOR_WINDOW );
  201. m_rgColor[ SYSCOLOR_WINDOWTEXT ] = GetSysColor( COLOR_WINDOWTEXT );
  202. m_rgColor[ SYSCOLOR_3DSHAODW ] = GetSysColor( COLOR_3DSHADOW );
  203. }
  204. virtual void DoneColor( void )
  205. {
  206. }
  207. virtual void InitBrush( void )
  208. {
  209. for (int i = 0; i < SYSCOLOR_MAX; i++) {
  210. m_rgBrush[i] = NULL;
  211. }
  212. }
  213. virtual void DoneBrush( void )
  214. {
  215. for (int i = 0; i < SYSCOLOR_MAX; i++) {
  216. if (m_rgBrush[i]) {
  217. DeleteObject( m_rgBrush[i] );
  218. m_rgBrush[i] = NULL;
  219. }
  220. }
  221. }
  222. };
  223. //
  224. // CUIFColorTableOff10
  225. //
  226. class CUIFColorTableOff10 : public CUIFColorTable
  227. {
  228. public:
  229. CUIFColorTableOff10( void ) : CUIFColorTable()
  230. {
  231. }
  232. virtual ~CUIFColorTableOff10( void )
  233. {
  234. DoneColor();
  235. DoneBrush();
  236. }
  237. __inline COLORREF GetColor( OFC10COLOR iColor )
  238. {
  239. return m_rgColor[ iColor ];
  240. }
  241. __inline HBRUSH GetBrush( OFC10COLOR iColor )
  242. {
  243. if (!m_rgBrush[iColor])
  244. m_rgBrush[iColor] = CreateSolidBrush( m_rgColor[iColor] );
  245. return m_rgBrush[ iColor ];
  246. }
  247. protected:
  248. COLORREF m_rgColor[ OFC10COLOR_MAX ];
  249. HBRUSH m_rgBrush[ OFC10COLOR_MAX ];
  250. virtual void InitColor( void )
  251. {
  252. if (UIFIsLowColor() || UIFIsHighContrast()) {
  253. if (UIFIsHighContrast()) {
  254. // high contrast setting
  255. m_rgColor[ OFC10COLOR_MENUBARLONG ] = col( COLOR_BTNFACE );
  256. m_rgColor[ OFC10COLOR_MOUSEOVERBKGND ] = col( COLOR_HIGHLIGHT );
  257. m_rgColor[ OFC10COLOR_MOUSEOVERBORDER ] = col( COLOR_MENUTEXT );
  258. m_rgColor[ OFC10COLOR_MOUSEOVERTEXT ] = col( COLOR_HIGHLIGHTTEXT);
  259. m_rgColor[ OFC10COLOR_CTRLBKGDSELECTED ] = col( COLOR_HIGHLIGHT );
  260. m_rgColor[ OFC10COLOR_CTRLBORDERSELECTED ] = col( COLOR_MENUTEXT );
  261. }
  262. else {
  263. // low color setting
  264. m_rgColor[ OFC10COLOR_MENUBARLONG ] = col( COLOR_BTNSHADOW );
  265. m_rgColor[ OFC10COLOR_MOUSEOVERBKGND ] = col( COLOR_WINDOW );
  266. m_rgColor[ OFC10COLOR_MOUSEOVERBORDER ] = col( COLOR_HIGHLIGHT );
  267. m_rgColor[ OFC10COLOR_MOUSEOVERTEXT ] = col( COLOR_WINDOWTEXT );
  268. m_rgColor[ OFC10COLOR_CTRLBKGDSELECTED ] = col( COLOR_WINDOW );
  269. m_rgColor[ OFC10COLOR_CTRLBORDERSELECTED ] = col( COLOR_HIGHLIGHT );
  270. }
  271. // common setting
  272. m_rgColor[ OFC10COLOR_BKGDTB ] = col( COLOR_BTNFACE );
  273. m_rgColor[ OFC10COLOR_BKGDMENU ] = col( COLOR_WINDOW );
  274. m_rgColor[ OFC10COLOR_BKGDWP ] = col( COLOR_WINDOW );
  275. m_rgColor[ OFC10COLOR_MENUBARSHORT ] = col( COLOR_BTNFACE );
  276. m_rgColor[ OFC10COLOR_MOUSEDOWNBKGND ] = col( COLOR_HIGHLIGHT);
  277. m_rgColor[ OFC10COLOR_MOUSEDOWNBORDER ] = col( COLOR_HIGHLIGHT );
  278. m_rgColor[ OFC10COLOR_MOUSEDOWNTEXT ] = col( COLOR_HIGHLIGHTTEXT);
  279. m_rgColor[ OFC10COLOR_CTRLBKGD ] = col( COLOR_BTNFACE );
  280. m_rgColor[ OFC10COLOR_CTRLTEXT ] = col( COLOR_BTNTEXT );
  281. m_rgColor[ OFC10COLOR_CTRLTEXTDISABLED ] = col( COLOR_BTNSHADOW );
  282. m_rgColor[ OFC10COLOR_CTRLIMAGESHADOW ] = col( COLOR_BTNFACE );
  283. m_rgColor[ OFC10COLOR_BDROUTERMENU ] = col( COLOR_BTNTEXT );
  284. m_rgColor[ OFC10COLOR_BDRINNERMENU ] = col( COLOR_WINDOW );
  285. m_rgColor[ OFC10COLOR_BDROUTERFLOATTB ] = col( COLOR_BTNSHADOW );
  286. m_rgColor[ OFC10COLOR_BDRINNERFLOATTB ] = col( COLOR_BTNFACE );
  287. m_rgColor[ OFC10COLOR_BDROUTERFLOATWP ] = col( COLOR_BTNSHADOW );
  288. m_rgColor[ OFC10COLOR_BDRINNERFLOATWP ] = col( COLOR_BTNFACE );
  289. m_rgColor[ OFC10COLOR_CAPTIONBKGDTB ] = col( COLOR_BTNSHADOW );
  290. m_rgColor[ OFC10COLOR_CAPTIONTEXTTB ] = col( COLOR_CAPTIONTEXT );
  291. m_rgColor[ OFC10COLOR_ACTIVECAPTIONBKGDWP ] = col( COLOR_HIGHLIGHT );
  292. m_rgColor[ OFC10COLOR_ACTIVECAPTIONTEXTWP ] = col( COLOR_HIGHLIGHTTEXT );
  293. m_rgColor[ OFC10COLOR_INACTIVECAPTIONBKGDWP ] = col( COLOR_BTNFACE );
  294. m_rgColor[ OFC10COLOR_INACTIVECAPTIONTEXTWP ] = col( COLOR_BTNTEXT );
  295. m_rgColor[ OFC10COLOR_SPLITTERLINE ] = col( COLOR_BTNSHADOW );
  296. m_rgColor[ OFC10COLOR_DRAGHANDLE ] = col( COLOR_BTNTEXT );
  297. m_rgColor[ OFC10COLOR_SPLITTERLINE ] = col( COLOR_BTNSHADOW );
  298. m_rgColor[ OFC10COLOR_MENUCTRLTEXT ] = col( COLOR_WINDOWTEXT );
  299. }
  300. else {
  301. m_rgColor[ OFC10COLOR_BKGDTB ] = col( 835, col( COLOR_BTNFACE ), 165, col( COLOR_WINDOW ) );
  302. m_rgColor[ OFC10COLOR_BKGDMENU ] = col( 15, col( COLOR_BTNFACE ), 85, col( COLOR_WINDOW ) );
  303. m_rgColor[ OFC10COLOR_BKGDWP ] = col( 15, col( COLOR_BTNFACE ), 85, col( COLOR_WINDOW ) );
  304. m_rgColor[ OFC10COLOR_MENUBARSHORT ] = col(835, col( COLOR_BTNFACE ), 165, col( COLOR_WINDOW ) );
  305. m_rgColor[ OFC10COLOR_MENUBARLONG ] = col( 90, col( COLOR_BTNFACE ), 10, col( COLOR_BTNSHADOW ) );
  306. m_rgColor[ OFC10COLOR_MOUSEOVERBKGND ] = col( 30, col( COLOR_HIGHLIGHT ), 70, col( COLOR_WINDOW ) );
  307. m_rgColor[ OFC10COLOR_MOUSEOVERBORDER ] = col( COLOR_HIGHLIGHT );
  308. m_rgColor[ OFC10COLOR_MOUSEOVERTEXT ] = col( COLOR_MENUTEXT );
  309. m_rgColor[ OFC10COLOR_MOUSEDOWNBKGND ] = col( 50, col( COLOR_HIGHLIGHT ), 50, col( COLOR_WINDOW ) );
  310. m_rgColor[ OFC10COLOR_MOUSEDOWNBORDER ] = col( COLOR_HIGHLIGHT );
  311. m_rgColor[ OFC10COLOR_MOUSEDOWNTEXT ] = col( COLOR_HIGHLIGHTTEXT );
  312. m_rgColor[ OFC10COLOR_CTRLBKGD ] = m_rgColor[ OFC10COLOR_BKGDTB ];
  313. m_rgColor[ OFC10COLOR_CTRLTEXT ] = col( COLOR_BTNTEXT );
  314. m_rgColor[ OFC10COLOR_CTRLTEXTDISABLED ] = col( 90, col( COLOR_BTNSHADOW ), 10, col( COLOR_WINDOW ) );
  315. m_rgColor[ OFC10COLOR_CTRLBKGDSELECTED ] = col( 10, col( COLOR_HIGHLIGHT ), 50, m_rgColor[ OFC10COLOR_CTRLBKGD], 40, col( COLOR_WINDOW));
  316. m_rgColor[ OFC10COLOR_CTRLIMAGESHADOW ] = col( 75, m_rgColor[ OFC10COLOR_MOUSEOVERBKGND ], 25, RGB( 0x00, 0x00, 0x00 ) ); // REVIEW: KOJIW: bkgnd s always OFC10COLOR_MOUSEOVERBKGND???
  317. m_rgColor[ OFC10COLOR_CTRLBORDERSELECTED ] = col( COLOR_HIGHLIGHT );
  318. m_rgColor[ OFC10COLOR_BDROUTERMENU ] = col( 20, col( COLOR_BTNTEXT ), 80, col( COLOR_BTNSHADOW ) );
  319. m_rgColor[ OFC10COLOR_BDRINNERMENU ] = m_rgColor[ OFC10COLOR_BKGDMENU ];
  320. m_rgColor[ OFC10COLOR_BDROUTERFLOATTB ] = col( 15, col( COLOR_BTNTEXT ), 85, col( COLOR_BTNSHADOW ) );
  321. m_rgColor[ OFC10COLOR_BDRINNERFLOATTB ] = m_rgColor[ OFC10COLOR_BKGDTB ];
  322. m_rgColor[ OFC10COLOR_BDROUTERFLOATWP ] = col( COLOR_BTNSHADOW );
  323. m_rgColor[ OFC10COLOR_BDRINNERFLOATWP ] = m_rgColor[ OFC10COLOR_BKGDWP ];
  324. m_rgColor[ OFC10COLOR_CAPTIONBKGDTB ] = col( COLOR_BTNSHADOW );
  325. m_rgColor[ OFC10COLOR_CAPTIONTEXTTB ] = col( COLOR_CAPTIONTEXT );
  326. m_rgColor[ OFC10COLOR_ACTIVECAPTIONBKGDWP ] = m_rgColor[ OFC10COLOR_MOUSEOVERBKGND ];
  327. m_rgColor[ OFC10COLOR_ACTIVECAPTIONTEXTWP ] = m_rgColor[ OFC10COLOR_MOUSEOVERTEXT ];
  328. m_rgColor[ OFC10COLOR_INACTIVECAPTIONBKGDWP ] = col( COLOR_BTNFACE );
  329. m_rgColor[ OFC10COLOR_INACTIVECAPTIONTEXTWP ] = col( COLOR_BTNTEXT );
  330. m_rgColor[ OFC10COLOR_SPLITTERLINE ] = col( 70, col( COLOR_BTNSHADOW ), 30, col( COLOR_WINDOW ) );
  331. m_rgColor[ OFC10COLOR_DRAGHANDLE ] = col( 75, col( COLOR_BTNSHADOW ), 25, col( COLOR_WINDOW ) );
  332. m_rgColor[ OFC10COLOR_MENUCTRLTEXT ] = col( COLOR_WINDOWTEXT );
  333. CbvFixContrastProblems();
  334. }
  335. }
  336. virtual void DoneColor( void )
  337. {
  338. }
  339. virtual void InitBrush( void )
  340. {
  341. for (int i = 0; i < OFC10COLOR_MAX; i++) {
  342. m_rgBrush[i] = NULL;
  343. }
  344. }
  345. virtual void DoneBrush( void )
  346. {
  347. for (int i = 0; i < OFC10COLOR_MAX; i++) {
  348. if (m_rgBrush[i]) {
  349. DeleteObject( m_rgBrush[i] );
  350. m_rgBrush[i] = NULL;
  351. }
  352. }
  353. }
  354. __inline COLORREF col( int iColor )
  355. {
  356. return GetSysColor( iColor );
  357. }
  358. COLORREF col( int r1, COLORREF col1, int r2, COLORREF col2 )
  359. {
  360. int sum = r1 + r2;
  361. Assert( sum == 10 || sum == 100 || sum == 1000 );
  362. int r = (r1 * GetRValue(col1) + r2 * GetRValue(col2) + sum/2) / sum;
  363. int g = (r1 * GetGValue(col1) + r2 * GetGValue(col2) + sum/2) / sum;
  364. int b = (r1 * GetBValue(col1) + r2 * GetBValue(col2) + sum/2) / sum;
  365. return RGB( r, g, b );
  366. }
  367. COLORREF col( int r1, COLORREF col1, int r2, COLORREF col2 , int r3, COLORREF col3)
  368. {
  369. int sum = r1 + r2 + r3;
  370. Assert( sum == 10 || sum == 100 || sum == 1000 );
  371. int r = (r1 * GetRValue(col1) + r2 * GetRValue(col2) + r3 * GetRValue(col3) + sum/3) / sum;
  372. int g = (r1 * GetGValue(col1) + r2 * GetGValue(col2) + r3 * GetGValue(col3) + sum/3) / sum;
  373. int b = (r1 * GetBValue(col1) + r2 * GetBValue(col2) + r3 * GetBValue(col3) + sum/3) / sum;
  374. return RGB( r, g, b );
  375. }
  376. /*---------------------------------------------------------------------------
  377. CCbvScaleContrastForDarkness
  378. As colors become darker, their contrast descreases, even if their
  379. distance apart stays fixed.
  380. ie. in the grayscale, 0 and 50 are the same distance apart as 205 and 255,
  381. but monitors/eyes see less difference between 0 and 50, than 205 and 255.
  382. This function increases the dContrast value, based on a dDarkness.
  383. This operation assumes the parameters are in the weighted RGB color space
  384. (the color space that the CIC uses), ie. 220 is middle of the road.
  385. ----------------------------------------------------------------- DMORTON -*/
  386. CIC_NUM CCbvScaleContrastForDarkness(CIC_NUM dContrast, CIC_NUM dDarkness)
  387. {
  388. return (2 - (min(dDarkness, 220)) / 220) * dContrast;
  389. }
  390. /*---------------------------------------------------------------------------
  391. CCbvGetContrastSquared
  392. As a speed improvement, whenever you don't need the real contrast, but
  393. instead can make due with the contrast squared, call this function
  394. and avoid the expensive sqrt call thats in CCbvGetContrast.
  395. ----------------------------------------------------------------- DMORTON -*/
  396. CIC_NUM CCbvGetContrastSquared(COLORREF cr1, COLORREF cr2)
  397. {
  398. // Transform the delta vector into weighted RGB color space
  399. CIC_NUM dRedD = (CIC_NUM)(GetRValue(cr1) - GetRValue(cr2)) * MAX_RED / 255;
  400. CIC_NUM dGreenD = (CIC_NUM)(GetGValue(cr1) - GetGValue(cr2)) * MAX_GREEN / 255;
  401. CIC_NUM dBlueD = (CIC_NUM)(GetBValue(cr1) - GetBValue(cr2)) * MAX_BLUE / 255;
  402. // Calculate its magnitude squared
  403. return(dRedD * dRedD + dGreenD * dGreenD + dBlueD * dBlueD);
  404. }
  405. /*---------------------------------------------------------------------------
  406. CCbvGetContrast
  407. Determines the contrast between cr1 and cr2.
  408. As the incoming parameters are COLORREFs, they must be in the
  409. normal RGB space.
  410. However, the result is given in the more usefull weighted RGB space.
  411. ----------------------------------------------------------------- DMORTON -*/
  412. CIC_NUM CCbvGetContrast(COLORREF cr1, COLORREF cr2)
  413. {
  414. // Calculate its magnitude - watch out for negative values
  415. return((CIC_NUM)sqrt((double)CCbvGetContrastSquared(cr1, cr2)));
  416. }
  417. /*---------------------------------------------------------------------------
  418. FCbvEnoughContrast
  419. Determines if crLocked and crMoveable meet the minimum contrast requirement,
  420. which is specified by dMinContrast.
  421. fDarkness will invoke consideration of how dark colors have less contrast,
  422. if its TRUE. crLocked will be used to determine how dark the colors are.
  423. ----------------------------------------------------------------- DMORTON -*/
  424. BOOL FCbvEnoughContrast(COLORREF crLocked, COLORREF crMoveable,
  425. CIC_NUM dMinContrast, BOOL fDarkness)
  426. {
  427. if (fDarkness)
  428. {
  429. // TODO DMORTON - how expensive is this CCbvGetContrast call?
  430. // Isn't it doing a square root?
  431. dMinContrast = CCbvScaleContrastForDarkness(dMinContrast,
  432. CCbvGetContrast(crLocked, RGB(0, 0, 0)));
  433. }
  434. // Its much faster to square dMinContrast, then it is to square root
  435. // the calculated contrast.
  436. return(CCbvGetContrastSquared(crLocked, crMoveable) >
  437. dMinContrast * dMinContrast);
  438. }
  439. /*---------------------------------------------------------------------------
  440. CbvIncreaseContrast
  441. Attempts to seperate crMoveable, from crLocked, so that their resulting
  442. contrast is at least cMinContrast.
  443. Its stupid to call this function if the colors already have this minimum
  444. contrast, so that case is asserted.
  445. ----------------------------------------------------------------- DMORTON -*/
  446. void CbvIncreaseContrast(COLORREF crLocked, COLORREF *pcrMoveable,
  447. CIC_NUM cMinContrast)
  448. {
  449. CIC_NUM cLockedI = CCbvGetContrast(crLocked, RGB(0, 0, 0));
  450. CIC_NUM cMoveableI = CCbvGetContrast(*pcrMoveable, RGB(0, 0, 0));
  451. // Scale up dMinContrast if cLockedI is close to black, since we have
  452. // a hard time seeing differences in dark shades
  453. CIC_NUM cContrast = CCbvScaleContrastForDarkness(cMinContrast, cLockedI);
  454. BOOL fTowardsWhite;
  455. if (cMoveableI > cLockedI) // we want to move towards white
  456. {
  457. if (cLockedI < 442 - cContrast) // TODO DMORTON: is this a valid way of checking available distance to white?
  458. {
  459. fTowardsWhite = TRUE; // There is room towards white
  460. }
  461. else
  462. {
  463. fTowardsWhite = FALSE; // There is no room towards white, try black
  464. }
  465. }
  466. else // we want to move towards black
  467. {
  468. if (cLockedI > cContrast)
  469. {
  470. fTowardsWhite = FALSE; // There is room towards black
  471. }
  472. else
  473. {
  474. fTowardsWhite = TRUE; // There is no room towards black, try white
  475. }
  476. }
  477. // Convert to weighted color space
  478. CIC_NUM cRedL = GetRValue(crLocked) * (CIC_NUM) MAX_RED / 255;
  479. CIC_NUM cGreenL = GetGValue(crLocked) * (CIC_NUM) MAX_GREEN / 255;
  480. CIC_NUM cBlueL = GetBValue(crLocked) * (CIC_NUM) MAX_BLUE / 255;
  481. CIC_NUM cRedM = GetRValue(*pcrMoveable) * (CIC_NUM) MAX_RED / 255;
  482. CIC_NUM cGreenM = GetGValue(*pcrMoveable) * (CIC_NUM) MAX_GREEN / 255;
  483. CIC_NUM cBlueM = GetBValue(*pcrMoveable) * (CIC_NUM) MAX_BLUE / 255;
  484. if (fTowardsWhite)
  485. {
  486. // Convert everything so white is the origin
  487. cRedM = MAX_RED - cRedM;
  488. cGreenM = MAX_GREEN - cGreenM;
  489. cBlueM = MAX_BLUE - cBlueM;
  490. cRedL = MAX_RED - cRedL;
  491. cGreenL = MAX_GREEN - cGreenL;
  492. cBlueL = MAX_BLUE - cBlueL;
  493. }
  494. // Calculate the magnitude of the moveable color
  495. CIC_NUM cMagMove = (CIC_NUM)sqrt(cRedM * cRedM + cGreenM * cGreenM + cBlueM * cBlueM);
  496. // we don't want some floating point snafu to cause us
  497. // to go negative, or be zero
  498. cMagMove = max(0.001f, cMagMove);
  499. // Dot product the locked color and the moveable color
  500. CIC_NUM cLockDotMove = cRedL * cRedM + cGreenL * cGreenM + cBlueL * cBlueM;
  501. // Take the projection of the locked color onto the moveable color
  502. CIC_NUM cLockProjected = (cLockDotMove) / cMagMove;
  503. CIC_NUM cScale = cLockProjected / cMagMove;
  504. CIC_NUM cRedTemp = cScale * cRedM - cRedL;
  505. CIC_NUM cGreenTemp = cScale * cGreenM - cGreenL;
  506. CIC_NUM cBlueTemp = cScale * cBlueM - cBlueL;
  507. // Calculate the last side of the triangle,
  508. // this is simply r^2 = a^2 + b^2, solving for b.
  509. CIC_NUM cN = (CIC_NUM)sqrt(cContrast * cContrast -
  510. (cRedTemp * cRedTemp + cGreenTemp * cGreenTemp +
  511. cBlueTemp * cBlueTemp));
  512. CIC_NUM cNewMagMove = cLockProjected - cN;
  513. // Scale the unit moveable vector
  514. cRedM = cRedM * cNewMagMove / cMagMove;
  515. cGreenM = cGreenM * cNewMagMove / cMagMove;
  516. cBlueM = cBlueM * cNewMagMove / cMagMove;
  517. if (fTowardsWhite)
  518. {
  519. // Convert everything back again
  520. cRedM = MAX_RED - cRedM;
  521. cGreenM = MAX_GREEN - cGreenM;
  522. cBlueM = MAX_BLUE - cBlueM;
  523. }
  524. cRedM = min(MAX_RED, max(0, cRedM));
  525. cGreenM = min(MAX_GREEN, max(0, cGreenM));
  526. cBlueM = min(MAX_BLUE, max(0, cBlueM));
  527. // Convert back to normal RGB color space
  528. int cR = (int)(cRedM * 255 / MAX_RED + 0.5);
  529. int cG = (int)(cGreenM * 255 / MAX_GREEN + 0.5);
  530. int cB = (int)(cBlueM * 255 / MAX_BLUE + 0.5);
  531. cR = max(0, min(255, cR));
  532. cG = max(0, min(255, cG));
  533. cB = max(0, min(255, cB));
  534. *pcrMoveable = RGB(cR, cG, cB);
  535. }
  536. /*---------------------------------------------------------------------------
  537. CbvDecreaseContrast
  538. Attempts to pull crMoveable towards crLocked, so that their resulting
  539. contrast is at most cMaxContrast.
  540. Its stupid to call this function if the colors already have this maximum
  541. contrast, so that case is asserted.
  542. ----------------------------------------------------------------- DMORTON -*/
  543. void CbvDecreaseContrast(COLORREF crLocked, COLORREF *pcrMoveable, CIC_NUM cMaxContrast)
  544. {
  545. CIC_NUM cLockedI = CCbvGetContrast(crLocked, RGB(0, 0, 0));
  546. // Scale up dMaxContrast if cLockedI is close to black, since we have
  547. // a hard time seeing differences in dark shades
  548. CIC_NUM dContrast = CCbvScaleContrastForDarkness(cMaxContrast, cLockedI);
  549. CIC_NUM cRedL = GetRValue(crLocked) * (CIC_NUM) MAX_RED / 255;
  550. CIC_NUM cGreenL = GetGValue(crLocked) * (CIC_NUM) MAX_GREEN / 255;
  551. CIC_NUM cBlueL = GetBValue(crLocked) * (CIC_NUM) MAX_BLUE / 255;
  552. CIC_NUM cRedM = GetRValue(*pcrMoveable) * (CIC_NUM) MAX_RED / 255;
  553. CIC_NUM cGreenM = GetGValue(*pcrMoveable) * (CIC_NUM) MAX_GREEN / 255;
  554. CIC_NUM cBlueM = GetBValue(*pcrMoveable) * (CIC_NUM) MAX_BLUE / 255;
  555. CIC_NUM cRedDelta = cRedL - cRedM;
  556. CIC_NUM cGreenDelta = cGreenL - cGreenM;
  557. CIC_NUM cBlueDelta = cBlueL - cBlueM;
  558. // Add to moveable a fraction of delta, to get it closer to locked.
  559. CIC_NUM dMagDelta = (CIC_NUM)sqrt(cRedDelta * cRedDelta + cGreenDelta * cGreenDelta
  560. + cBlueDelta * cBlueDelta);
  561. CIC_NUM dScale = (dMagDelta - dContrast) / dMagDelta;
  562. cRedM += cRedDelta * dScale;
  563. cGreenM += cGreenDelta * dScale;
  564. cBlueM += cBlueDelta * dScale;
  565. cRedM = min(MAX_RED, max(0, cRedM));
  566. cGreenM = min(MAX_GREEN, max(0, cGreenM));
  567. cBlueM = min(MAX_BLUE, max(0, cBlueM));
  568. // Transform back into normal RGB space...
  569. int cR = (int)(cRedM * 255 / MAX_RED + 0.5);
  570. int cG = (int)(cGreenM * 255 / MAX_GREEN + 0.5);
  571. int cB = (int)(cBlueM * 255 / MAX_BLUE + 0.5);
  572. cR = max(0, min(255, cR));
  573. cG = max(0, min(255, cG));
  574. cB = max(0, min(255, cB));
  575. *pcrMoveable = RGB(cR, cG, cB);
  576. }
  577. /*---------------------------------------------------------------------------
  578. CbvFixContrastProblems
  579. Goes through all crucial combinations of colors, ensuring that minimum
  580. and maximum contrasts are in place.
  581. ----------------------------------------------------------------- DMORTON -*/
  582. void CbvFixContrastProblems()
  583. {
  584. #if 0
  585. if (FCbvEnoughContrast(m_rgColor[OFC10COLOR_MAINMENUBKGD],
  586. m_rgColor[OFC10COLOR_BKGDTB], 35, TRUE))
  587. {
  588. CbvDecreaseContrast(m_rgColor[OFC10COLOR_MAINMENUBKGD],
  589. &(m_rgColor[OFC10COLOR_BKGDTB]), 35);
  590. }
  591. #else
  592. if (FCbvEnoughContrast(col(COLOR_BTNFACE),
  593. m_rgColor[OFC10COLOR_BKGDTB], 35, TRUE))
  594. {
  595. CbvDecreaseContrast(col(COLOR_BTNFACE),
  596. &(m_rgColor[OFC10COLOR_BKGDTB]), 35);
  597. }
  598. #endif
  599. int i;
  600. for(i = 0; i < sizeof(vrgContrast) / sizeof(vrgContrast[0]); i++)
  601. {
  602. if (!FCbvEnoughContrast(m_rgColor[vrgContrast[i].colLocked],
  603. m_rgColor[vrgContrast[i].colMoveable],
  604. vrgContrast[i].cMinContrast,
  605. vrgContrast[i].fConsiderDarkness))
  606. {
  607. CbvIncreaseContrast(m_rgColor[vrgContrast[i].colLocked],
  608. &(m_rgColor[vrgContrast[i].colMoveable]),
  609. vrgContrast[i].cMinContrast);
  610. }
  611. }
  612. }
  613. };
  614. /*=============================================================================*/
  615. /* */
  616. /* C U I F S C H E M E D E F */
  617. /* */
  618. /*=============================================================================*/
  619. static SYSCOLOR v_rgSysCol[ UIFCOLOR_MAX ] =
  620. {
  621. SYSCOLOR_3DFACE, /* UIFCOLOR_MENUBKGND */
  622. SYSCOLOR_3DFACE, /* UIFCOLOR_MENUBARSHORT */
  623. SYSCOLOR_3DFACE, /* UIFCOLOR_MENUBARLONG */
  624. SYSCOLOR_HIGHLIGHT, /* UIFCOLOR_MOUSEOVERBKGND */
  625. SYSCOLOR_HIGHLIGHT, /* UIFCOLOR_MOUSEOVERBORDER */
  626. SYSCOLOR_HIGHLIGHTTEXT, /* UIFCOLOR_MOUSEOVERTEXT */
  627. SYSCOLOR_HIGHLIGHT, /* UIFCOLOR_MOUSEDOWNBKGND */
  628. SYSCOLOR_HIGHLIGHT, /* UIFCOLOR_MOUSEDOWNBORDER */
  629. SYSCOLOR_HIGHLIGHTTEXT, /* UIFCOLOR_MOUSEDOWNTEXT */
  630. SYSCOLOR_3DFACE, /* UIFCOLOR_CTRLBKGND */
  631. SYSCOLOR_BTNTEXT, /* UIFCOLOR_CTRLTEXT */
  632. SYSCOLOR_GRAYTEXT, /* UIFCOLOR_CTRLTEXTDISABLED */
  633. SYSCOLOR_3DSHAODW, /* UIFCOLOR_CTRLIMAGESHADOW */
  634. SYSCOLOR_HIGHLIGHT, /* UIFCOLOR_CTRLBKGNDSELECTED */
  635. SYSCOLOR_ACTIVEBORDER, /* UIFCOLOR_BORDEROUTER */
  636. SYSCOLOR_3DFACE, /* UIFCOLOR_BORDERINNER */
  637. SYSCOLOR_ACTIVECAPTION, /* UIFCOLOR_ACTIVECAPTIONBKGND */
  638. SYSCOLOR_CAPTIONTEXT, /* UIFCOLOR_ACTIVECAPTIONTEXT */
  639. SYSCOLOR_INACTIVECAPTION, /* UIFCOLOR_INACTIVECAPTIONBKGND */
  640. SYSCOLOR_INACTIVECAPTIONTEXT, /* UIFCOLOR_INACTIVECAPTIONTEXT */
  641. SYSCOLOR_BTNSHADOW, /* UIFCOLOR_SPLITTERLINE */
  642. SYSCOLOR_BTNTEXT, /* UIFCOLOR_DRAGHANDLE */
  643. SYSCOLOR_3DFACE, /* UIFCOLOR_WINDOW */
  644. };
  645. //
  646. // CUIFSchemeDef
  647. // = UI object default scheme =
  648. //
  649. class CUIFSchemeDef : public CUIFScheme
  650. {
  651. public:
  652. CUIFSchemeDef( UIFSCHEME scheme )
  653. {
  654. m_scheme = scheme;
  655. }
  656. virtual ~CUIFSchemeDef( void )
  657. {
  658. }
  659. //
  660. // CUIFScheme methods
  661. //
  662. /* G E T T Y P E */
  663. /*------------------------------------------------------------------------------
  664. Get scheme type
  665. ------------------------------------------------------------------------------*/
  666. virtual UIFSCHEME GetType( void )
  667. {
  668. return m_scheme;
  669. }
  670. /* G E T C O L O R */
  671. /*------------------------------------------------------------------------------
  672. Get scheme color
  673. ------------------------------------------------------------------------------*/
  674. virtual COLORREF GetColor( UIFCOLOR iCol )
  675. {
  676. return v_pColTableSys->GetColor( v_rgSysCol[ iCol ] );
  677. }
  678. /* G E T B R U S H */
  679. /*------------------------------------------------------------------------------
  680. Get scheme brush
  681. ------------------------------------------------------------------------------*/
  682. virtual HBRUSH GetBrush( UIFCOLOR iCol )
  683. {
  684. return v_pColTableSys->GetBrush( v_rgSysCol[ iCol ] );
  685. }
  686. /* C Y M E N U I T E M */
  687. /*------------------------------------------------------------------------------
  688. Get menu item height
  689. ------------------------------------------------------------------------------*/
  690. virtual int CyMenuItem( int cyMenuText )
  691. {
  692. return cyMenuText + 2;
  693. }
  694. /* C X S I Z E F R A M E */
  695. /*------------------------------------------------------------------------------
  696. Get size frame width
  697. ------------------------------------------------------------------------------*/
  698. virtual int CxSizeFrame( void )
  699. {
  700. return GetSystemMetrics( SM_CXSIZEFRAME );
  701. }
  702. /* C Y S I Z E F R A M E */
  703. /*------------------------------------------------------------------------------
  704. Get size frame height
  705. ------------------------------------------------------------------------------*/
  706. virtual int CySizeFrame( void )
  707. {
  708. return GetSystemMetrics( SM_CYSIZEFRAME );
  709. }
  710. /* C X W N D B O R D E R */
  711. /*------------------------------------------------------------------------------
  712. Get window border width
  713. ------------------------------------------------------------------------------*/
  714. virtual int CxWndBorder( void )
  715. {
  716. return 1;
  717. }
  718. /* C Y W N D B O R D E R */
  719. /*------------------------------------------------------------------------------
  720. Get window border height
  721. ------------------------------------------------------------------------------*/
  722. virtual int CyWndBorder( void )
  723. {
  724. return 1;
  725. }
  726. /* F I L L R E C T */
  727. /*------------------------------------------------------------------------------
  728. Fill rect by shceme color
  729. ------------------------------------------------------------------------------*/
  730. virtual void FillRect( HDC hDC, const RECT *prc, UIFCOLOR iCol )
  731. {
  732. ::FillRect( hDC, prc, GetBrush( iCol ) );
  733. }
  734. /* F R A M E R E C T */
  735. /*------------------------------------------------------------------------------
  736. Frame rect by scheme color
  737. ------------------------------------------------------------------------------*/
  738. virtual void FrameRect( HDC hDC, const RECT *prc, UIFCOLOR iCol )
  739. {
  740. ::FrameRect( hDC, prc, GetBrush( iCol ) );
  741. }
  742. /* D R A W S E L E C T I O N R E C T */
  743. /*------------------------------------------------------------------------------
  744. Draw selection rect
  745. ------------------------------------------------------------------------------*/
  746. virtual void DrawSelectionRect( HDC hDC, const RECT *prc, BOOL fMouseDown )
  747. {
  748. Assert( prc != NULL );
  749. ::FillRect( hDC, prc, GetBrush( UIFCOLOR_MOUSEDOWNBKGND ) );
  750. }
  751. /* G E T C T R L F A C E O F F S E T */
  752. /*------------------------------------------------------------------------------
  753. Get offcet of control face from status
  754. ------------------------------------------------------------------------------*/
  755. virtual void GetCtrlFaceOffset( DWORD dwFlag, DWORD dwState, SIZE *poffset )
  756. {
  757. int cxyOffset = 0;
  758. Assert( PtrToInt(poffset) );
  759. if ((dwState & UIFDCS_SELECTED) == UIFDCS_SELECTED) {
  760. cxyOffset = (dwFlag & UIFDCF_RAISEDONSELECT) ? -1 :
  761. (dwFlag & UIFDCF_SUNKENONSELECT) ? +1 : 0;
  762. }
  763. else if ((dwState & UIFDCS_MOUSEDOWN) == UIFDCS_MOUSEDOWN) {
  764. cxyOffset = (dwFlag & UIFDCF_RAISEDONMOUSEDOWN) ? -1 :
  765. (dwFlag & UIFDCF_SUNKENONMOUSEDOWN) ? +1 : 0;
  766. }
  767. else if ((dwState & UIFDCS_MOUSEOVER) == UIFDCS_MOUSEOVER) {
  768. cxyOffset = (dwFlag & UIFDCF_RAISEDONMOUSEOVER) ? -1 :
  769. (dwFlag & UIFDCF_SUNKENONMOUSEOVER) ? +1 : 0;
  770. }
  771. else {
  772. cxyOffset = (dwFlag & UIFDCF_RAISEDONNORMAL) ? -1 :
  773. (dwFlag & UIFDCF_RAISEDONNORMAL) ? +1 : 0;
  774. }
  775. poffset->cx = cxyOffset;
  776. poffset->cy = cxyOffset;
  777. }
  778. /* D R A W C T R L B K G D */
  779. /*------------------------------------------------------------------------------
  780. Paint control background
  781. ------------------------------------------------------------------------------*/
  782. virtual void DrawCtrlBkgd( HDC hDC, const RECT *prc, DWORD dwFlag, DWORD dwState )
  783. {
  784. Assert( prc != NULL );
  785. ::FillRect( hDC, prc, GetBrush( UIFCOLOR_CTRLBKGND ) );
  786. #ifndef UNDER_CE
  787. if (((dwState & UIFDCS_SELECTED) != 0) && ((dwState & UIFDCS_MOUSEDOWN) == 0)) {
  788. RECT rc = *prc;
  789. HBRUSH hBrush;
  790. COLORREF colTextOld;
  791. COLORREF colBackOld;
  792. hBrush = CreateDitherBrush();
  793. if (hBrush)
  794. {
  795. colTextOld = SetTextColor( hDC, GetSysColor(COLOR_3DFACE) );
  796. colBackOld = SetBkColor( hDC, GetSysColor(COLOR_3DHILIGHT) );
  797. InflateRect( &rc, -2, -2 );
  798. ::FillRect( hDC, &rc, hBrush );
  799. SetTextColor( hDC, colTextOld );
  800. SetBkColor( hDC, colBackOld );
  801. DeleteObject( hBrush );
  802. }
  803. }
  804. #endif /* !UNDER_CE */
  805. }
  806. /* D R A W C T R L E D G E */
  807. /*------------------------------------------------------------------------------
  808. Paint control edge
  809. ------------------------------------------------------------------------------*/
  810. virtual void DrawCtrlEdge( HDC hDC, const RECT *prc, DWORD dwFlag, DWORD dwState )
  811. {
  812. UINT uiEdge = 0;
  813. if ((dwState & UIFDCS_SELECTED) == UIFDCS_SELECTED) {
  814. uiEdge = (dwFlag & UIFDCF_RAISEDONSELECT) ? BDR_RAISEDINNER :
  815. (dwFlag & UIFDCF_SUNKENONSELECT) ? BDR_SUNKENOUTER : 0;
  816. }
  817. else if ((dwState & UIFDCS_MOUSEDOWN) == UIFDCS_MOUSEDOWN) {
  818. uiEdge = (dwFlag & UIFDCF_RAISEDONMOUSEDOWN) ? BDR_RAISEDINNER :
  819. (dwFlag & UIFDCF_SUNKENONMOUSEDOWN) ? BDR_SUNKENOUTER : 0;
  820. }
  821. else if ((dwState & UIFDCS_MOUSEOVER) == UIFDCS_MOUSEOVER) {
  822. uiEdge = (dwFlag & UIFDCF_RAISEDONMOUSEOVER) ? BDR_RAISEDINNER :
  823. (dwFlag & UIFDCF_SUNKENONMOUSEOVER) ? BDR_SUNKENOUTER : 0;
  824. }
  825. else {
  826. uiEdge = (dwFlag & UIFDCF_RAISEDONNORMAL) ? BDR_RAISEDINNER :
  827. (dwFlag & UIFDCF_RAISEDONNORMAL) ? BDR_SUNKENOUTER : 0;
  828. }
  829. if (uiEdge != 0) {
  830. RECT rcT = *prc;
  831. DrawEdge( hDC, &rcT, uiEdge, BF_RECT );
  832. }
  833. }
  834. /* D R A W C T R L T E X T */
  835. /*------------------------------------------------------------------------------
  836. Paint control text
  837. ------------------------------------------------------------------------------*/
  838. virtual void DrawCtrlText( HDC hDC, const RECT *prc, LPCWSTR pwch, int cwch, DWORD dwState , BOOL fVertical)
  839. {
  840. RECT rc;
  841. COLORREF colTextOld = GetTextColor( hDC );
  842. int iBkModeOld = SetBkMode( hDC, TRANSPARENT );
  843. Assert( prc != NULL );
  844. Assert( pwch != NULL );
  845. rc = *prc;
  846. if (cwch == -1) {
  847. cwch = StrLenW(pwch);
  848. }
  849. if (dwState & UIFDCS_DISABLED) {
  850. OffsetRect( &rc, +1, +1 );
  851. SetTextColor( hDC, GetSysColor(COLOR_3DHIGHLIGHT) ); // TODO: KojiW
  852. CUIExtTextOut( hDC,
  853. fVertical ? rc.right : rc.left,
  854. rc.top,
  855. ETO_CLIPPED,
  856. &rc,
  857. pwch,
  858. cwch,
  859. NULL );
  860. OffsetRect( &rc, -1, -1 );
  861. }
  862. SetTextColor( hDC, GetSysColor(COLOR_BTNTEXT) ); // TODO: KojiW
  863. CUIExtTextOut( hDC,
  864. fVertical ? rc.right : rc.left,
  865. rc.top,
  866. ETO_CLIPPED,
  867. &rc,
  868. pwch,
  869. cwch,
  870. NULL );
  871. SetTextColor( hDC, colTextOld );
  872. SetBkMode( hDC, iBkModeOld );
  873. }
  874. /* D R A W C T R L I C O N */
  875. /*------------------------------------------------------------------------------
  876. Paint control icon
  877. ------------------------------------------------------------------------------*/
  878. virtual void DrawCtrlIcon( HDC hDC, const RECT *prc, HICON hIcon, DWORD dwState , SIZE *psizeIcon)
  879. {
  880. Assert( prc != NULL );
  881. if (IsRTLLayout())
  882. {
  883. HBITMAP hbmp;
  884. HBITMAP hbmpMask;
  885. if (CUIGetIconBitmaps(hIcon, &hbmp, &hbmpMask, psizeIcon))
  886. {
  887. DrawCtrlBitmap( hDC, prc, hbmp, hbmpMask, dwState );
  888. DeleteObject(hbmp);
  889. DeleteObject(hbmpMask);
  890. }
  891. }
  892. else
  893. {
  894. CUIDrawState( hDC,
  895. NULL,
  896. NULL,
  897. (LPARAM)hIcon,
  898. 0,
  899. prc->left,
  900. prc->top,
  901. 0,
  902. 0,
  903. DST_ICON | ((dwState & UIFDCS_DISABLED) ? (DSS_DISABLED | DSS_MONO) : 0) );
  904. }
  905. }
  906. /* D R A W C T R L B I T M A P */
  907. /*------------------------------------------------------------------------------
  908. Paint control bitmap
  909. ------------------------------------------------------------------------------*/
  910. virtual void DrawCtrlBitmap( HDC hDC, const RECT *prc, HBITMAP hBmp, HBITMAP hBmpMask, DWORD dwState )
  911. {
  912. Assert( prc != NULL );
  913. if (IsRTLLayout())
  914. {
  915. hBmp = CUIMirrorBitmap(hBmp, GetBrush(UIFCOLOR_CTRLBKGND));
  916. hBmpMask = CUIMirrorBitmap(hBmpMask, (HBRUSH)GetStockObject(BLACK_BRUSH));
  917. }
  918. if (!hBmpMask)
  919. {
  920. CUIDrawState( hDC,
  921. NULL,
  922. NULL,
  923. (LPARAM)hBmp,
  924. 0,
  925. prc->left,
  926. prc->top,
  927. prc->right - prc->left,
  928. prc->bottom - prc->top,
  929. DST_BITMAP | ((dwState & UIFDCS_DISABLED) ? (DSS_DISABLED | DSS_MONO) : 0) );
  930. }
  931. else
  932. {
  933. HBITMAP hBmpTmp;
  934. HBRUSH hbr;
  935. BOOL fDeleteHBR = FALSE;
  936. if (dwState & UIFDCS_DISABLED) {
  937. hBmpTmp = CreateDisabledBitmap(prc,
  938. hBmpMask,
  939. GetBrush(UIFCOLOR_CTRLBKGND),
  940. GetBrush(UIFCOLOR_CTRLTEXTDISABLED ), TRUE);
  941. }
  942. else
  943. {
  944. if (((dwState & UIFDCS_SELECTED) != 0) && ((dwState & UIFDCS_MOUSEDOWN) == 0))
  945. {
  946. hbr = CreateDitherBrush();
  947. fDeleteHBR = TRUE;
  948. }
  949. // else if (dwState & UIFDCS_SELECTED)
  950. // hbr = (HBRUSH)(COLOR_3DHIGHLIGHT + 1);
  951. else
  952. hbr = (HBRUSH)(COLOR_3DFACE + 1);
  953. hBmpTmp = CreateMaskBmp(prc, hBmp, hBmpMask, hbr,
  954. GetSysColor(COLOR_3DFACE),
  955. GetSysColor(COLOR_3DHILIGHT));
  956. #if 0
  957. CBitmapDC hdcTmp;
  958. CBitmapDC hdcSrc((HDC)hdcTmp);
  959. CBitmapDC hdcMask((HDC)hdcTmp);
  960. CBitmapDC hdcDst((HDC)hdcTmp);
  961. hdcSrc.SetBitmap(hBmp);
  962. hdcMask.SetBitmap(hBmpMask);
  963. hdcDst.SetBitmap(hBmpTmp);
  964. BitBlt(hdcTmp, 0, 30, 30, 30, hdcSrc, 0, 0, SRCCOPY);
  965. BitBlt(hdcTmp, 30, 30, 30, 30, hdcMask, 0, 0, SRCCOPY);
  966. BitBlt(hdcTmp, 60, 30, 30, 30, hdcDst, 0, 0, SRCCOPY);
  967. hdcSrc.GetBitmapAndKeep();
  968. hdcMask.GetBitmapAndKeep();
  969. hdcDst.GetBitmapAndKeep();
  970. #endif
  971. }
  972. if (hBmpTmp)
  973. {
  974. CUIDrawState( hDC,
  975. NULL,
  976. NULL,
  977. (LPARAM)hBmpTmp,
  978. 0,
  979. prc->left,
  980. prc->top,
  981. prc->right - prc->left,
  982. prc->bottom - prc->top,
  983. DST_BITMAP);
  984. DeleteObject(hBmpTmp);
  985. }
  986. if (fDeleteHBR)
  987. DeleteObject(hbr );
  988. }
  989. if (IsRTLLayout())
  990. {
  991. DeleteObject(hBmp);
  992. DeleteObject(hBmpMask);
  993. }
  994. }
  995. /* D R A W M E N U B I T M A P */
  996. /*------------------------------------------------------------------------------
  997. Paint menu bitmap
  998. ------------------------------------------------------------------------------*/
  999. virtual void DrawMenuBitmap( HDC hDC, const RECT *prc, HBITMAP hBmp, HBITMAP hBmpMask, DWORD dwState )
  1000. {
  1001. DrawCtrlBitmap( hDC, prc, hBmp, hBmpMask, dwState );
  1002. }
  1003. /* D R A W M E N U S E P A R A T O R
  1004. /*------------------------------------------------------------------------------
  1005. Paint menu separator
  1006. ------------------------------------------------------------------------------*/
  1007. virtual void DrawMenuSeparator( HDC hDC, const RECT *prc)
  1008. {
  1009. RECT rc;
  1010. rc = *prc;
  1011. rc.bottom = rc.top + (rc.bottom - rc.top) / 2;
  1012. ::FillRect(hDC, &rc, (HBRUSH)(COLOR_3DSHADOW + 1));
  1013. rc = *prc;
  1014. rc.top = rc.top + (rc.bottom - rc.top) / 2;
  1015. ::FillRect(hDC, &rc, (HBRUSH)(COLOR_3DHIGHLIGHT + 1));
  1016. }
  1017. /* D R A W F R A M E C T R L B K G D */
  1018. /*------------------------------------------------------------------------------
  1019. Paint frame control background
  1020. ------------------------------------------------------------------------------*/
  1021. virtual void DrawFrameCtrlBkgd( HDC hDC, const RECT *prc, DWORD dwFlag, DWORD dwState )
  1022. {
  1023. DrawCtrlBkgd( hDC, prc, dwFlag, dwState );
  1024. }
  1025. /* D R A W F R A M E C T R L E D G E */
  1026. /*------------------------------------------------------------------------------
  1027. Paint frame control edge
  1028. ------------------------------------------------------------------------------*/
  1029. virtual void DrawFrameCtrlEdge( HDC hDC, const RECT *prc, DWORD dwFlag, DWORD dwState )
  1030. {
  1031. DrawCtrlEdge( hDC, prc, dwFlag, dwState );
  1032. }
  1033. /* D R A W F R A M E C T R L I C O N */
  1034. /*------------------------------------------------------------------------------
  1035. Paint frame control icon
  1036. ------------------------------------------------------------------------------*/
  1037. virtual void DrawFrameCtrlIcon( HDC hDC, const RECT *prc, HICON hIcon, DWORD dwState , SIZE *psizeIcon)
  1038. {
  1039. DrawCtrlIcon( hDC, prc, hIcon, dwState , psizeIcon);
  1040. }
  1041. /* D R A W F R A M E C T R L B I T M A P */
  1042. /*------------------------------------------------------------------------------
  1043. Paint frame control bitmap
  1044. ------------------------------------------------------------------------------*/
  1045. virtual void DrawFrameCtrlBitmap( HDC hDC, const RECT *prc, HBITMAP hBmp, HBITMAP hBmpMask, DWORD dwState )
  1046. {
  1047. DrawCtrlBitmap( hDC, prc, hBmp, hBmpMask, dwState );
  1048. }
  1049. /* D R A W W N D F R A M E */
  1050. /*------------------------------------------------------------------------------
  1051. ------------------------------------------------------------------------------*/
  1052. virtual void DrawWndFrame( HDC hDC, const RECT *prc, DWORD dwFlag, int cxFrame, int cyFrame )
  1053. {
  1054. RECT rc = *prc;
  1055. switch (dwFlag) {
  1056. default:
  1057. case UIFDWF_THIN: {
  1058. FrameRect( hDC, &rc, UIFCOLOR_BORDEROUTER );
  1059. break;
  1060. }
  1061. case UIFDWF_THICK:
  1062. case UIFDWF_ROUNDTHICK: {
  1063. DrawEdge( hDC, &rc, EDGE_RAISED, BF_RECT );
  1064. break;
  1065. }
  1066. }
  1067. }
  1068. /* D R A W D R A G H A N D L E */
  1069. /*------------------------------------------------------------------------------
  1070. ------------------------------------------------------------------------------*/
  1071. virtual void DrawDragHandle( HDC hDC, const RECT *prc, BOOL fVertical)
  1072. {
  1073. RECT rc;
  1074. if (!fVertical)
  1075. {
  1076. ::SetRect(&rc,
  1077. prc->left + 1,
  1078. prc->top,
  1079. prc->left + 4,
  1080. prc->bottom);
  1081. }
  1082. else
  1083. {
  1084. ::SetRect(&rc,
  1085. prc->left,
  1086. prc->top + 1,
  1087. prc->right,
  1088. prc->top + 4);
  1089. }
  1090. DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT);
  1091. }
  1092. /* D R A W S E P A R A T O R */
  1093. /*------------------------------------------------------------------------------
  1094. ------------------------------------------------------------------------------*/
  1095. virtual void DrawSeparator( HDC hDC, const RECT *prc, BOOL fVertical)
  1096. {
  1097. CSolidPen hpenL;
  1098. CSolidPen hpenS;
  1099. HPEN hpenOld = NULL;
  1100. if (!hpenL.Init(GetSysColor(COLOR_3DHILIGHT)))
  1101. return;
  1102. if (!hpenS.Init(GetSysColor(COLOR_3DSHADOW)))
  1103. return;
  1104. if (!fVertical)
  1105. {
  1106. hpenOld = (HPEN)SelectObject(hDC, (HPEN)hpenS);
  1107. MoveToEx(hDC, prc->left + 1, prc->top, NULL);
  1108. LineTo(hDC, prc->left + 1, prc->bottom);
  1109. SelectObject(hDC, (HPEN)hpenL);
  1110. MoveToEx(hDC, prc->left + 2, prc->top, NULL);
  1111. LineTo(hDC, prc->left + 2, prc->bottom);
  1112. }
  1113. else
  1114. {
  1115. hpenOld = (HPEN)SelectObject(hDC, (HPEN)hpenS);
  1116. MoveToEx(hDC, prc->left , prc->top + 1, NULL);
  1117. LineTo(hDC, prc->right, prc->top + 1);
  1118. SelectObject(hDC, (HPEN)hpenL);
  1119. MoveToEx(hDC, prc->left , prc->top + 2, NULL);
  1120. LineTo(hDC, prc->right, prc->top + 2);
  1121. }
  1122. SelectObject(hDC, hpenOld);
  1123. }
  1124. protected:
  1125. UIFSCHEME m_scheme;
  1126. };
  1127. /*=============================================================================*/
  1128. /* */
  1129. /* C U I F S C H E M E O F F 1 0 L O O K */
  1130. /* */
  1131. /*=============================================================================*/
  1132. static OFC10COLOR v_rgO10ColMenu[ UIFCOLOR_MAX ] =
  1133. {
  1134. OFC10COLOR_BKGDMENU, /* UIFCOLOR_MENUBKGND */
  1135. OFC10COLOR_MENUBARSHORT, /* UIFCOLOR_MENUBARSHORT */
  1136. OFC10COLOR_MENUBARLONG, /* UIFCOLOR_MENUBARLONG */
  1137. OFC10COLOR_MOUSEOVERBKGND, /* UIFCOLOR_MOUSEOVERBKGND */
  1138. OFC10COLOR_MOUSEOVERBORDER, /* UIFCOLOR_MOUSEOVERBORDER */
  1139. OFC10COLOR_MOUSEOVERTEXT, /* UIFCOLOR_MOUSEOVERTEXT */
  1140. OFC10COLOR_MOUSEDOWNBKGND, /* UIFCOLOR_MOUSEDOWNBKGND */
  1141. OFC10COLOR_MOUSEDOWNBORDER, /* UIFCOLOR_MOUSEDOWNBORDER */
  1142. OFC10COLOR_MOUSEDOWNTEXT, /* UIFCOLOR_MOUSEDOWNTEXT */
  1143. OFC10COLOR_CTRLBKGD, /* UIFCOLOR_CTRLBKGND */
  1144. OFC10COLOR_MENUCTRLTEXT, /* UIFCOLOR_CTRLTEXT */
  1145. OFC10COLOR_CTRLTEXTDISABLED, /* UIFCOLOR_CTRLTEXTDISABLED */
  1146. OFC10COLOR_CTRLIMAGESHADOW, /* UIFCOLOR_CTRLIMAGESHADOW */
  1147. OFC10COLOR_MOUSEOVERBKGND, /* UIFCOLOR_CTRLBKGNDSELECTED */
  1148. OFC10COLOR_BDROUTERMENU, /* UIFCOLOR_BORDEROUTER */
  1149. OFC10COLOR_BDRINNERMENU, /* UIFCOLOR_BORDERINNER */
  1150. OFC10COLOR_ACTIVECAPTIONBKGDWP, /* UIFCOLOR_ACTIVECAPTIONBKGND */ // TEMP assign
  1151. OFC10COLOR_ACTIVECAPTIONTEXTWP, /* UIFCOLOR_ACTIVECAPTIONTEXT */ // TEMP assign
  1152. OFC10COLOR_INACTIVECAPTIONBKGDWP, /* UIFCOLOR_INACTIVECAPTIONBKGND */ // TEMP assign
  1153. OFC10COLOR_INACTIVECAPTIONTEXTWP, /* UIFCOLOR_INACTIVECAPTIONTEXT */ // TEMP assign
  1154. OFC10COLOR_SPLITTERLINE, /* UIFCOLOR_SPLITTERLINE */
  1155. OFC10COLOR_DRAGHANDLE, /* UIFCOLOR_DRAGHANDLE */
  1156. // virtual colors
  1157. OFC10COLOR_BKGDMENU, /* UIFCOLOR_WINDOW */
  1158. };
  1159. static OFC10COLOR v_rgO10ColToolbar[ UIFCOLOR_MAX ] =
  1160. {
  1161. OFC10COLOR_BKGDMENU, /* UIFCOLOR_MENUBKGND */
  1162. OFC10COLOR_MENUBARSHORT, /* UIFCOLOR_MENUBARSHORT */
  1163. OFC10COLOR_MENUBARLONG, /* UIFCOLOR_MENUBARLONG */
  1164. OFC10COLOR_MOUSEOVERBKGND, /* UIFCOLOR_MOUSEOVERBKGND */
  1165. OFC10COLOR_MOUSEOVERBORDER, /* UIFCOLOR_MOUSEOVERBORDER */
  1166. OFC10COLOR_MOUSEOVERTEXT, /* UIFCOLOR_MOUSEOVERTEXT */
  1167. OFC10COLOR_MOUSEDOWNBKGND, /* UIFCOLOR_MOUSEDOWNBKGND */
  1168. OFC10COLOR_MOUSEDOWNBORDER, /* UIFCOLOR_MOUSEDOWNBORDER */
  1169. OFC10COLOR_MOUSEDOWNTEXT, /* UIFCOLOR_MOUSEDOWNTEXT */
  1170. OFC10COLOR_CTRLBKGD, /* UIFCOLOR_CTRLBKGND */
  1171. OFC10COLOR_CTRLTEXT, /* UIFCOLOR_CTRLTEXT */
  1172. OFC10COLOR_CTRLTEXTDISABLED, /* UIFCOLOR_CTRLTEXTDISABLED */
  1173. OFC10COLOR_CTRLIMAGESHADOW, /* UIFCOLOR_CTRLIMAGESHADOW */
  1174. OFC10COLOR_CTRLBKGDSELECTED, /* UIFCOLOR_CTRLBKGNDSELECTED */
  1175. OFC10COLOR_BDROUTERFLOATTB, /* UIFCOLOR_BORDEROUTER */
  1176. OFC10COLOR_BDRINNERFLOATTB, /* UIFCOLOR_BORDERINNER */
  1177. OFC10COLOR_CAPTIONBKGDTB, /* UIFCOLOR_ACTIVECAPTIONBKGND */
  1178. OFC10COLOR_CAPTIONTEXTTB, /* UIFCOLOR_ACTIVECAPTIONTEXT */
  1179. OFC10COLOR_CAPTIONBKGDTB, /* UIFCOLOR_INACTIVECAPTIONBKGND */
  1180. OFC10COLOR_CAPTIONTEXTTB, /* UIFCOLOR_INACTIVECAPTIONTEXT */
  1181. OFC10COLOR_SPLITTERLINE, /* UIFCOLOR_SPLITTERLINE */
  1182. OFC10COLOR_DRAGHANDLE, /* UIFCOLOR_DRAGHANDLE */
  1183. // virtual colors
  1184. OFC10COLOR_BKGDTB, /* UIFCOLOR_WINDOW */
  1185. };
  1186. static OFC10COLOR v_rgO10ColWorkPane[ UIFCOLOR_MAX ] =
  1187. {
  1188. OFC10COLOR_BKGDMENU, /* UIFCOLOR_MENUBKGND */
  1189. OFC10COLOR_MENUBARSHORT, /* UIFCOLOR_MENUBARSHORT */
  1190. OFC10COLOR_MENUBARLONG, /* UIFCOLOR_MENUBARLONG */
  1191. OFC10COLOR_MOUSEOVERBKGND, /* UIFCOLOR_MOUSEOVERBKGND */
  1192. OFC10COLOR_MOUSEOVERBORDER, /* UIFCOLOR_MOUSEOVERBORDER */
  1193. OFC10COLOR_MOUSEOVERTEXT, /* UIFCOLOR_MOUSEOVERTEXT */
  1194. OFC10COLOR_MOUSEDOWNBKGND, /* UIFCOLOR_MOUSEDOWNBKGND */
  1195. OFC10COLOR_MOUSEDOWNBORDER, /* UIFCOLOR_MOUSEDOWNBORDER */
  1196. OFC10COLOR_MOUSEDOWNTEXT, /* UIFCOLOR_MOUSEDOWNTEXT */
  1197. OFC10COLOR_CTRLBKGD, /* UIFCOLOR_CTRLBKGND */
  1198. OFC10COLOR_CTRLTEXT, /* UIFCOLOR_CTRLTEXT */
  1199. OFC10COLOR_CTRLTEXTDISABLED, /* UIFCOLOR_CTRLTEXTDISABLED */
  1200. OFC10COLOR_CTRLIMAGESHADOW, /* UIFCOLOR_CTRLIMAGESHADOW */
  1201. OFC10COLOR_CTRLBKGDSELECTED, /* UIFCOLOR_CTRLBKGNDSELECTED */
  1202. OFC10COLOR_BDROUTERFLOATWP, /* UIFCOLOR_BORDEROUTER */
  1203. OFC10COLOR_BDRINNERFLOATWP, /* UIFCOLOR_BORDERINNER */
  1204. OFC10COLOR_ACTIVECAPTIONBKGDWP, /* UIFCOLOR_ACTIVECAPTIONBKGND */
  1205. OFC10COLOR_ACTIVECAPTIONTEXTWP, /* UIFCOLOR_ACTIVECAPTIONTEXT */
  1206. OFC10COLOR_INACTIVECAPTIONBKGDWP, /* UIFCOLOR_INACTIVECAPTIONBKGND */
  1207. OFC10COLOR_INACTIVECAPTIONTEXTWP, /* UIFCOLOR_INACTIVECAPTIONTEXT */
  1208. OFC10COLOR_SPLITTERLINE, /* UIFCOLOR_SPLITTERLINE */
  1209. OFC10COLOR_DRAGHANDLE, /* UIFCOLOR_DRAGHANDLE */
  1210. // virtual colors
  1211. OFC10COLOR_BKGDWP, /* UIFCOLOR_WINDOW */
  1212. };
  1213. //
  1214. // CUIFSchemeOff10
  1215. //
  1216. class CUIFSchemeOff10 : public CUIFScheme
  1217. {
  1218. public:
  1219. CUIFSchemeOff10( UIFSCHEME scheme )
  1220. {
  1221. m_scheme = scheme;
  1222. // find color map table
  1223. switch (m_scheme) {
  1224. default:
  1225. case UIFSCHEME_OFC10MENU: {
  1226. m_pcoldef = v_rgO10ColMenu;
  1227. break;
  1228. }
  1229. case UIFSCHEME_OFC10TOOLBAR: {
  1230. m_pcoldef = v_rgO10ColToolbar;
  1231. break;
  1232. }
  1233. case UIFSCHEME_OFC10WORKPANE: {
  1234. m_pcoldef = v_rgO10ColWorkPane;
  1235. break;
  1236. }
  1237. }
  1238. }
  1239. virtual ~CUIFSchemeOff10( void )
  1240. {
  1241. }
  1242. //
  1243. // CUIFScheme method
  1244. //
  1245. /* G E T T Y P E */
  1246. /*------------------------------------------------------------------------------
  1247. Get scheme type
  1248. ------------------------------------------------------------------------------*/
  1249. virtual UIFSCHEME GetType( void )
  1250. {
  1251. return m_scheme;
  1252. }
  1253. /* G E T C O L O R */
  1254. /*------------------------------------------------------------------------------
  1255. Get scheme color
  1256. ------------------------------------------------------------------------------*/
  1257. virtual COLORREF GetColor( UIFCOLOR iCol )
  1258. {
  1259. return v_pColTableOfc10->GetColor( m_pcoldef[ iCol ] );
  1260. }
  1261. /* G E T B R U S H */
  1262. /*------------------------------------------------------------------------------
  1263. Get scheme brush
  1264. ------------------------------------------------------------------------------*/
  1265. virtual HBRUSH GetBrush( UIFCOLOR iCol )
  1266. {
  1267. return v_pColTableOfc10->GetBrush( m_pcoldef[ iCol ] );
  1268. }
  1269. /* C Y M E N U I T E M */
  1270. /*------------------------------------------------------------------------------
  1271. Get menu item height
  1272. ------------------------------------------------------------------------------*/
  1273. virtual int CyMenuItem( int cyMenuText )
  1274. {
  1275. return cyMenuText + 4;
  1276. }
  1277. /* C X S I Z E F R A M E */
  1278. /*------------------------------------------------------------------------------
  1279. Get size frame width
  1280. ------------------------------------------------------------------------------*/
  1281. virtual int CxSizeFrame( void )
  1282. {
  1283. return max( 3, GetSystemMetrics( SM_CXSIZEFRAME ) - 2 );
  1284. }
  1285. /* C Y S I Z E F R A M E */
  1286. /*------------------------------------------------------------------------------
  1287. Get size frame height
  1288. ------------------------------------------------------------------------------*/
  1289. virtual int CySizeFrame( void )
  1290. {
  1291. return max( 3, GetSystemMetrics( SM_CYSIZEFRAME ) - 2 );
  1292. }
  1293. /* C X W N D B O R D E R */
  1294. /*------------------------------------------------------------------------------
  1295. Get window border width
  1296. ------------------------------------------------------------------------------*/
  1297. virtual int CxWndBorder( void )
  1298. {
  1299. return 1;
  1300. }
  1301. /* C Y W N D B O R D E R */
  1302. /*------------------------------------------------------------------------------
  1303. Get window border height
  1304. ------------------------------------------------------------------------------*/
  1305. virtual int CyWndBorder( void )
  1306. {
  1307. return 1;
  1308. }
  1309. /* F I L L R E C T */
  1310. /*------------------------------------------------------------------------------
  1311. Fill rect by scheme color
  1312. ------------------------------------------------------------------------------*/
  1313. virtual void FillRect( HDC hDC, const RECT *prc, UIFCOLOR iCol )
  1314. {
  1315. ::FillRect( hDC, prc, GetBrush( iCol ) );
  1316. }
  1317. /* F R A M E R E C T */
  1318. /*------------------------------------------------------------------------------
  1319. Frame rect by scheme color
  1320. ------------------------------------------------------------------------------*/
  1321. virtual void FrameRect( HDC hDC, const RECT *prc, UIFCOLOR iCol )
  1322. {
  1323. ::FrameRect( hDC, prc, GetBrush( iCol ) );
  1324. }
  1325. /* D R A W S E L E C T I O N R E C T */
  1326. /*------------------------------------------------------------------------------
  1327. Draw selection rect
  1328. ------------------------------------------------------------------------------*/
  1329. virtual void DrawSelectionRect( HDC hDC, const RECT *prc, BOOL fMouseDown )
  1330. {
  1331. Assert( prc != NULL );
  1332. if (fMouseDown) {
  1333. ::FillRect( hDC, prc, GetBrush( UIFCOLOR_MOUSEDOWNBKGND ) );
  1334. ::FrameRect( hDC, prc, GetBrush( UIFCOLOR_MOUSEDOWNBORDER ) );
  1335. }
  1336. else {
  1337. ::FillRect( hDC, prc, GetBrush( UIFCOLOR_MOUSEOVERBKGND ) );
  1338. ::FrameRect( hDC, prc, GetBrush( UIFCOLOR_MOUSEOVERBORDER ) );
  1339. }
  1340. }
  1341. /* G E T C T R L F A C E O F F S E T */
  1342. /*------------------------------------------------------------------------------
  1343. Get offcet of control face from status
  1344. ------------------------------------------------------------------------------*/
  1345. virtual void GetCtrlFaceOffset( DWORD dwFlag, DWORD dwState, SIZE *poffset )
  1346. {
  1347. Assert( poffset != NULL );
  1348. poffset->cx = 0;
  1349. poffset->cy = 0;
  1350. }
  1351. /* D R A W C T R L B K G D */
  1352. /*------------------------------------------------------------------------------
  1353. get background color
  1354. ------------------------------------------------------------------------------*/
  1355. virtual UIFCOLOR GetBkgdCol( DWORD dwState )
  1356. {
  1357. UIFCOLOR col = UIFCOLOR_MAX; /* invalid */
  1358. if ((dwState & UIFDCS_DISABLED) == 0) { /* enabled */
  1359. if ((dwState & UIFDCS_MOUSEOVERSELECTED) == UIFDCS_MOUSEOVERSELECTED) {
  1360. col = UIFCOLOR_MOUSEDOWNBKGND; /* frame: 100% */
  1361. }
  1362. else if ((dwState & UIFDCS_MOUSEDOWN) == UIFDCS_MOUSEDOWN) {
  1363. col = UIFCOLOR_MOUSEDOWNBKGND; /* frame: 100% */
  1364. }
  1365. else if ((dwState & UIFDCS_MOUSEOVER) == UIFDCS_MOUSEOVER) {
  1366. col = UIFCOLOR_MOUSEOVERBKGND; /* frame: 65% */
  1367. }
  1368. else if ((dwState & UIFDCS_SELECTED) == UIFDCS_SELECTED) {
  1369. col = UIFCOLOR_CTRLBKGNDSELECTED; /* frame: 65% */
  1370. }
  1371. else {
  1372. col = UIFCOLOR_WINDOW;
  1373. }
  1374. }
  1375. else { /* disabled */
  1376. col = UIFCOLOR_WINDOW;
  1377. }
  1378. return col;
  1379. }
  1380. /* D R A W C T R L B K G D */
  1381. /*------------------------------------------------------------------------------
  1382. Paint control background
  1383. ------------------------------------------------------------------------------*/
  1384. virtual void DrawCtrlBkgd( HDC hDC, const RECT *prc, DWORD dwFlag, DWORD dwState )
  1385. {
  1386. Assert( prc != NULL );
  1387. UIFCOLOR col = GetBkgdCol(dwState);
  1388. if (col != UIFCOLOR_MAX) {
  1389. FillRect( hDC, prc, col );
  1390. }
  1391. }
  1392. /* D R A W C T R L E D G E */
  1393. /*------------------------------------------------------------------------------
  1394. Paint control edge
  1395. ------------------------------------------------------------------------------*/
  1396. virtual void DrawCtrlEdge( HDC hDC, const RECT *prc, DWORD dwFlag, DWORD dwState )
  1397. {
  1398. UIFCOLOR col = UIFCOLOR_MAX; /* invalid color */
  1399. if ((dwState & UIFDCS_DISABLED) == 0) { /* enabled */
  1400. if ((dwState & UIFDCS_MOUSEOVERSELECTED) == UIFDCS_MOUSEOVERSELECTED) {
  1401. col = UIFCOLOR_MOUSEDOWNBORDER; /* frame: 100% */
  1402. }
  1403. else if ((dwState & UIFDCS_MOUSEDOWN) == UIFDCS_MOUSEDOWN) {
  1404. col = UIFCOLOR_MOUSEDOWNBORDER; /* frame: 100% */
  1405. }
  1406. else if ((dwState & UIFDCS_MOUSEOVER) == UIFDCS_MOUSEOVER) {
  1407. col = UIFCOLOR_MOUSEOVERBORDER; /* frame: 65% */
  1408. }
  1409. else if ((dwState & UIFDCS_SELECTED) == UIFDCS_SELECTED) {
  1410. col = UIFCOLOR_MOUSEOVERBORDER; /* frame: 65% */
  1411. }
  1412. }
  1413. else { /* disabled */
  1414. if ((dwState & UIFDCS_MOUSEOVERSELECTED) == UIFDCS_MOUSEOVERSELECTED) {
  1415. col = UIFCOLOR_MOUSEDOWNBORDER; /* frame: 100% */ // REVIEW: KOJIW: correct?
  1416. }
  1417. else if ((dwState & UIFDCS_MOUSEDOWN) == UIFDCS_MOUSEDOWN) {
  1418. col = UIFCOLOR_CTRLTEXTDISABLED;
  1419. }
  1420. else if ((dwState & UIFDCS_MOUSEOVER) == UIFDCS_MOUSEOVER) {
  1421. col = UIFCOLOR_MOUSEDOWNBORDER; /* frame: 100% */ // REVIEW: KOJIW: correct?
  1422. }
  1423. else if ((dwState & UIFDCS_SELECTED) == UIFDCS_SELECTED) {
  1424. col = UIFCOLOR_CTRLTEXTDISABLED; // ????
  1425. }
  1426. }
  1427. if (col != UIFCOLOR_MAX) {
  1428. FrameRect( hDC, prc, col );
  1429. }
  1430. }
  1431. /* D R A W C T R L T E X T */
  1432. /*------------------------------------------------------------------------------
  1433. Paint control text
  1434. ------------------------------------------------------------------------------*/
  1435. virtual void DrawCtrlText( HDC hDC, const RECT *prc, LPCWSTR pwch, int cwch, DWORD dwState , BOOL fVertical)
  1436. {
  1437. COLORREF colTextOld = GetTextColor( hDC );
  1438. int iBkModeOld = SetBkMode( hDC, TRANSPARENT );
  1439. Assert( prc != NULL );
  1440. Assert( pwch != NULL );
  1441. if (cwch == -1) {
  1442. cwch = StrLenW(pwch);
  1443. }
  1444. if ((dwState & UIFDCS_MOUSEOVERSELECTED) == UIFDCS_MOUSEOVERSELECTED) {
  1445. SetTextColor( hDC, GetColor(UIFCOLOR_MOUSEDOWNTEXT) );
  1446. } else if (dwState & UIFDCS_DISABLED) {
  1447. SetTextColor( hDC, GetColor(UIFCOLOR_CTRLTEXTDISABLED) );
  1448. } else if (dwState & UIFDCS_MOUSEOVER) {
  1449. SetTextColor( hDC, GetColor(UIFCOLOR_MOUSEOVERTEXT) );
  1450. } else if (dwState & UIFDCS_MOUSEDOWN) {
  1451. SetTextColor( hDC, GetColor(UIFCOLOR_MOUSEDOWNTEXT) );
  1452. } else {
  1453. SetTextColor( hDC, GetColor(UIFCOLOR_CTRLTEXT) );
  1454. }
  1455. CUIExtTextOut( hDC,
  1456. fVertical ? prc->right : prc->left,
  1457. prc->top,
  1458. ETO_CLIPPED,
  1459. prc,
  1460. pwch,
  1461. cwch,
  1462. NULL );
  1463. SetTextColor( hDC, colTextOld );
  1464. SetBkMode( hDC, iBkModeOld );
  1465. }
  1466. /* D R A W C T R L I C O N */
  1467. /*------------------------------------------------------------------------------
  1468. Paint control icon
  1469. ------------------------------------------------------------------------------*/
  1470. virtual void DrawCtrlIcon( HDC hDC, const RECT *prc, HICON hIcon, DWORD dwState , SIZE *psizeIcon)
  1471. {
  1472. #if 1
  1473. HBITMAP hbmp;
  1474. HBITMAP hbmpMask;
  1475. if (CUIGetIconBitmaps(hIcon, &hbmp, &hbmpMask, psizeIcon))
  1476. {
  1477. DrawCtrlBitmap( hDC, prc, hbmp, hbmpMask, dwState );
  1478. DeleteObject(hbmp);
  1479. DeleteObject(hbmpMask);
  1480. }
  1481. #else
  1482. Assert( prc != NULL );
  1483. if (((dwState & UIFDCS_MOUSEOVER) == UIFDCS_MOUSEOVER) &&
  1484. ((dwState & UIFDCS_SELECTED) == 0) &&
  1485. ((dwState & UIFDCS_DISABLED) == 0)) {
  1486. // draw shadow
  1487. CUIDrawState( hDC,
  1488. GetBrush( UIFCOLOR_CTRLIMAGESHADOW ),
  1489. NULL,
  1490. (LPARAM)hIcon,
  1491. 0,
  1492. prc->left + 1,
  1493. prc->top + 1,
  1494. 0,
  1495. 0,
  1496. DST_ICON | DSS_MONO );
  1497. CUIDrawState( hDC,
  1498. NULL,
  1499. NULL,
  1500. (LPARAM)hIcon,
  1501. 0,
  1502. prc->left - 1,
  1503. prc->top - 1,
  1504. 0,
  1505. 0,
  1506. DST_ICON );
  1507. }
  1508. else {
  1509. if (dwState & UIFDCS_DISABLED)
  1510. {
  1511. HICON hIconSm = NULL;
  1512. if (hIcon)
  1513. hIconSm = (HICON)CopyImage(hIcon, IMAGE_ICON, 16, 16, 0);
  1514. if (hIconSm)
  1515. {
  1516. CUIDrawState( hDC,
  1517. NULL,
  1518. NULL,
  1519. (LPARAM)hIconSm,
  1520. 0,
  1521. prc->left,
  1522. prc->top,
  1523. prc->right - prc->left,
  1524. prc->bottom - prc->top,
  1525. DST_ICON | (DSS_DISABLED | DSS_MONO));
  1526. }
  1527. else
  1528. {
  1529. CUIDrawState( hDC,
  1530. NULL,
  1531. NULL,
  1532. (LPARAM)hIcon,
  1533. 0,
  1534. prc->left,
  1535. prc->top,
  1536. 0,
  1537. 0,
  1538. DST_ICON | (DSS_DISABLED | DSS_MONO));
  1539. }
  1540. if (hIconSm)
  1541. DestroyIcon(hIconSm);
  1542. }
  1543. else
  1544. {
  1545. CUIDrawState( hDC,
  1546. NULL,
  1547. NULL,
  1548. (LPARAM)hIcon,
  1549. 0,
  1550. prc->left,
  1551. prc->top,
  1552. 0,
  1553. 0,
  1554. DST_ICON);
  1555. }
  1556. }
  1557. #endif
  1558. }
  1559. /* D R A W C T R L B I T M A P */
  1560. /*------------------------------------------------------------------------------
  1561. Paint control bitmap
  1562. ------------------------------------------------------------------------------*/
  1563. virtual void DrawCtrlBitmap( HDC hDC, const RECT *prc, HBITMAP hBmp, HBITMAP hBmpMask, DWORD dwState )
  1564. {
  1565. Assert( prc != NULL );
  1566. if (IsRTLLayout())
  1567. {
  1568. hBmp = CUIMirrorBitmap(hBmp, GetBrush(GetBkgdCol(dwState)));
  1569. hBmpMask = CUIMirrorBitmap(hBmpMask, (HBRUSH)GetStockObject(BLACK_BRUSH));
  1570. }
  1571. if (((dwState & UIFDCS_MOUSEOVER) == UIFDCS_MOUSEOVER) &&
  1572. ((dwState & UIFDCS_SELECTED) == 0) &&
  1573. ((dwState & UIFDCS_DISABLED) == 0)) {
  1574. if (!hBmpMask)
  1575. {
  1576. // draw shadow
  1577. CUIDrawState( hDC,
  1578. GetBrush( UIFCOLOR_CTRLIMAGESHADOW ),
  1579. NULL,
  1580. (LPARAM)hBmp,
  1581. 0,
  1582. prc->left + 1,
  1583. prc->top + 1,
  1584. prc->right - prc->left,
  1585. prc->bottom - prc->top,
  1586. DST_BITMAP | DSS_MONO );
  1587. CUIDrawState( hDC,
  1588. NULL,
  1589. NULL,
  1590. (LPARAM)hBmp,
  1591. 0,
  1592. prc->left - 1,
  1593. prc->top - 1,
  1594. prc->right - prc->left,
  1595. prc->bottom - prc->top,
  1596. DST_BITMAP );
  1597. }
  1598. else
  1599. {
  1600. HBITMAP hBmpTmp;
  1601. UIFCOLOR col = GetBkgdCol(dwState);
  1602. RECT rcNew = *prc;
  1603. //
  1604. // adjust rect of shadow for RTL layout.
  1605. //
  1606. if (IsRTLLayout())
  1607. {
  1608. rcNew.left++;
  1609. rcNew.top++;
  1610. }
  1611. hBmpTmp = CreateShadowMaskBmp(&rcNew,
  1612. hBmp,
  1613. hBmpMask,
  1614. (HBRUSH)GetBrush(col),
  1615. GetBrush( UIFCOLOR_CTRLIMAGESHADOW));
  1616. if (hBmpTmp)
  1617. {
  1618. CUIDrawState( hDC,
  1619. NULL,
  1620. NULL,
  1621. (LPARAM)hBmpTmp,
  1622. 0,
  1623. rcNew.left,
  1624. rcNew.top,
  1625. rcNew.right - rcNew.left,
  1626. rcNew.bottom - rcNew.top,
  1627. DST_BITMAP );
  1628. DeleteObject(hBmpTmp);
  1629. }
  1630. }
  1631. }
  1632. else {
  1633. if (!hBmpMask)
  1634. {
  1635. CUIDrawState( hDC,
  1636. NULL,
  1637. NULL,
  1638. (LPARAM)hBmp,
  1639. 0,
  1640. prc->left,
  1641. prc->top,
  1642. prc->right - prc->left,
  1643. prc->bottom - prc->top,
  1644. DST_BITMAP | ((dwState & UIFDCS_DISABLED) ? (DSS_DISABLED | DSS_MONO) : 0) );
  1645. }
  1646. else
  1647. {
  1648. HBITMAP hBmpTmp;
  1649. UIFCOLOR col = GetBkgdCol(dwState);
  1650. if (dwState & UIFDCS_DISABLED)
  1651. hBmpTmp = CreateDisabledBitmap(prc,
  1652. hBmpMask,
  1653. GetBrush(col),
  1654. GetBrush(UIFCOLOR_CTRLTEXTDISABLED),
  1655. FALSE);
  1656. else
  1657. hBmpTmp = CreateMaskBmp(prc,
  1658. hBmp,
  1659. hBmpMask,
  1660. (HBRUSH)GetBrush(col), 0, 0);
  1661. CUIDrawState( hDC,
  1662. NULL,
  1663. NULL,
  1664. (LPARAM)hBmpTmp,
  1665. 0,
  1666. prc->left,
  1667. prc->top,
  1668. prc->right - prc->left,
  1669. prc->bottom - prc->top,
  1670. DST_BITMAP);
  1671. // DST_BITMAP | ((dwState & UIFDCS_DISABLED) ? (DSS_DISABLED | DSS_MONO) : 0) );
  1672. DeleteObject(hBmpTmp);
  1673. }
  1674. }
  1675. if (IsRTLLayout())
  1676. {
  1677. DeleteObject(hBmp);
  1678. DeleteObject(hBmpMask);
  1679. }
  1680. }
  1681. /* D R A W M E N U B I T M A P */
  1682. /*------------------------------------------------------------------------------
  1683. Paint menu bitmap
  1684. ------------------------------------------------------------------------------*/
  1685. virtual void DrawMenuBitmap( HDC hDC, const RECT *prc, HBITMAP hBmp, HBITMAP hBmpMask, DWORD dwState )
  1686. {
  1687. Assert( prc != NULL );
  1688. if (IsRTLLayout())
  1689. {
  1690. // hBmp = CUIMirrorBitmap(hBmp, GetBrush(UIFCOLOR_CTRLBKGND));
  1691. UIFCOLOR col;
  1692. if (dwState & UIFDCS_SELECTED)
  1693. // col = UIFCOLOR_CTRLIMAGESHADOW;
  1694. col = UIFCOLOR_MOUSEOVERBKGND;
  1695. else
  1696. col = UIFCOLOR_CTRLBKGND;
  1697. hBmp = CUIMirrorBitmap(hBmp, GetBrush(col));
  1698. hBmpMask = CUIMirrorBitmap(hBmpMask, (HBRUSH)GetStockObject(BLACK_BRUSH));
  1699. }
  1700. if (((dwState & UIFDCS_MOUSEOVER) == UIFDCS_MOUSEOVER) && ((dwState & UIFDCS_SELECTED) == 0)) {
  1701. if (!hBmpMask)
  1702. {
  1703. // draw shadow
  1704. CUIDrawState( hDC,
  1705. GetBrush( UIFCOLOR_CTRLIMAGESHADOW ),
  1706. NULL,
  1707. (LPARAM)hBmp,
  1708. 0,
  1709. prc->left + 1,
  1710. prc->top + 1,
  1711. prc->right - prc->left,
  1712. prc->bottom - prc->top,
  1713. DST_BITMAP | DSS_MONO );
  1714. CUIDrawState( hDC,
  1715. NULL,
  1716. NULL,
  1717. (LPARAM)hBmp,
  1718. 0,
  1719. prc->left - 1,
  1720. prc->top - 1,
  1721. prc->right - prc->left,
  1722. prc->bottom - prc->top,
  1723. DST_BITMAP );
  1724. }
  1725. else
  1726. {
  1727. HBITMAP hBmpTmp;
  1728. UIFCOLOR col = GetBkgdCol(dwState);
  1729. RECT rcNew = *prc;
  1730. hBmpTmp = CreateShadowMaskBmp(&rcNew,
  1731. hBmp,
  1732. hBmpMask,
  1733. (HBRUSH)GetBrush(col),
  1734. GetBrush( UIFCOLOR_CTRLIMAGESHADOW));
  1735. if (hBmpTmp)
  1736. {
  1737. CUIDrawState( hDC,
  1738. NULL,
  1739. NULL,
  1740. (LPARAM)hBmpTmp,
  1741. 0,
  1742. rcNew.left,
  1743. rcNew.top,
  1744. rcNew.right - rcNew.left,
  1745. rcNew.bottom - rcNew.top,
  1746. DST_BITMAP );
  1747. DeleteObject(hBmpTmp);
  1748. }
  1749. }
  1750. }
  1751. else {
  1752. if (!hBmpMask)
  1753. {
  1754. CUIDrawState( hDC,
  1755. NULL,
  1756. NULL,
  1757. (LPARAM)hBmp,
  1758. 0,
  1759. prc->left,
  1760. prc->top,
  1761. prc->right - prc->left,
  1762. prc->bottom - prc->top,
  1763. DST_BITMAP );
  1764. }
  1765. else
  1766. {
  1767. HBITMAP hBmpTmp;
  1768. UIFCOLOR col;
  1769. if (dwState & UIFDCS_SELECTED)
  1770. // col = UIFCOLOR_CTRLIMAGESHADOW;
  1771. col = UIFCOLOR_MOUSEOVERBKGND;
  1772. else
  1773. col = UIFCOLOR_CTRLBKGND;
  1774. hBmpTmp = CreateMaskBmp(prc,
  1775. hBmp,
  1776. hBmpMask,
  1777. (HBRUSH)GetBrush(col), 0, 0);
  1778. CUIDrawState( hDC,
  1779. NULL,
  1780. NULL,
  1781. (LPARAM)hBmpTmp,
  1782. 0,
  1783. prc->left,
  1784. prc->top,
  1785. prc->right - prc->left,
  1786. prc->bottom - prc->top,
  1787. DST_BITMAP );
  1788. DeleteObject(hBmpTmp);
  1789. }
  1790. }
  1791. if (IsRTLLayout())
  1792. {
  1793. DeleteObject(hBmp);
  1794. DeleteObject(hBmpMask);
  1795. }
  1796. }
  1797. /* D R A W M E N U S E P A R A T O R
  1798. /*------------------------------------------------------------------------------
  1799. Paint menu separator
  1800. ------------------------------------------------------------------------------*/
  1801. virtual void DrawMenuSeparator( HDC hDC, const RECT *prc)
  1802. {
  1803. ::FillRect(hDC, prc, GetBrush(UIFCOLOR_CTRLBKGND));
  1804. }
  1805. /* G E T F R A M E B K G D C O L */
  1806. /*------------------------------------------------------------------------------
  1807. get background color of frame control
  1808. ------------------------------------------------------------------------------*/
  1809. virtual UIFCOLOR GetFrameBkgdCol( DWORD dwState )
  1810. {
  1811. UIFCOLOR col = UIFCOLOR_MAX; /* invalid */
  1812. if ((dwState & UIFDCS_DISABLED) == 0) { /* enabled */
  1813. if ((dwState & UIFDCS_MOUSEOVERSELECTED) == UIFDCS_MOUSEOVERSELECTED) {
  1814. col = UIFCOLOR_MOUSEDOWNBKGND; /* frame: 100% */
  1815. }
  1816. else if ((dwState & UIFDCS_MOUSEDOWN) == UIFDCS_MOUSEDOWN) {
  1817. col = UIFCOLOR_MOUSEDOWNBKGND; /* frame: 100% */
  1818. }
  1819. else if ((dwState & UIFDCS_MOUSEOVER) == UIFDCS_MOUSEOVER) {
  1820. col = UIFCOLOR_MOUSEOVERBKGND; /* frame: 65% */
  1821. }
  1822. else if ((dwState & UIFDCS_SELECTED) == UIFDCS_SELECTED) {
  1823. col = UIFCOLOR_MOUSEOVERBKGND; /* frame: 65% */
  1824. }
  1825. else if ((dwState & UIFDCS_ACTIVE) == UIFDCS_ACTIVE) {
  1826. col = UIFCOLOR_ACTIVECAPTIONBKGND;
  1827. }
  1828. else {
  1829. col = UIFCOLOR_INACTIVECAPTIONBKGND;
  1830. }
  1831. }
  1832. else { /* disabled */
  1833. if ((dwState & UIFDCS_ACTIVE) == UIFDCS_ACTIVE) {
  1834. col = UIFCOLOR_ACTIVECAPTIONBKGND;
  1835. }
  1836. else {
  1837. col = UIFCOLOR_INACTIVECAPTIONBKGND;
  1838. }
  1839. }
  1840. return col;
  1841. }
  1842. /* D R A W F R A M E C T R L B K G D */
  1843. /*------------------------------------------------------------------------------
  1844. Paint frame control background
  1845. ------------------------------------------------------------------------------*/
  1846. virtual void DrawFrameCtrlBkgd( HDC hDC, const RECT *prc, DWORD dwFlag, DWORD dwState )
  1847. {
  1848. Assert( prc != NULL );
  1849. UIFCOLOR col = GetFrameBkgdCol(dwState);
  1850. if (col != UIFCOLOR_MAX) {
  1851. FillRect( hDC, prc, col );
  1852. }
  1853. }
  1854. /* D R A W F R A M E C T R L E D G E */
  1855. /*------------------------------------------------------------------------------
  1856. Paint frame control edge
  1857. ------------------------------------------------------------------------------*/
  1858. virtual void DrawFrameCtrlEdge( HDC hDC, const RECT *prc, DWORD dwFlag, DWORD dwState )
  1859. {
  1860. DrawCtrlEdge( hDC, prc, dwFlag, dwState );
  1861. }
  1862. /* D R A W F R A M E C T R L I C O N */
  1863. /*------------------------------------------------------------------------------
  1864. Paint frame control icon
  1865. ------------------------------------------------------------------------------*/
  1866. virtual void DrawFrameCtrlIcon( HDC hDC, const RECT *prc, HICON hIcon, DWORD dwState , SIZE *psizeIcon)
  1867. {
  1868. HBITMAP hbmp;
  1869. HBITMAP hbmpMask;
  1870. if (CUIGetIconBitmaps(hIcon, &hbmp, &hbmpMask, psizeIcon))
  1871. {
  1872. DrawCtrlBitmap( hDC, prc, hbmp, hbmpMask, dwState );
  1873. DeleteObject(hbmp);
  1874. DeleteObject(hbmpMask);
  1875. }
  1876. }
  1877. /* D R A W F R A M E C T R L B I T M A P */
  1878. /*------------------------------------------------------------------------------
  1879. Paint frame control bitmap
  1880. ------------------------------------------------------------------------------*/
  1881. virtual void DrawFrameCtrlBitmap( HDC hDC, const RECT *prc, HBITMAP hBmp, HBITMAP hBmpMask, DWORD dwState )
  1882. {
  1883. if (!hBmpMask) {
  1884. CUIDrawState( hDC,
  1885. NULL,
  1886. NULL,
  1887. (LPARAM)hBmp,
  1888. 0,
  1889. prc->left,
  1890. prc->top,
  1891. prc->right - prc->left,
  1892. prc->bottom - prc->top,
  1893. DST_BITMAP | ((dwState & UIFDCS_DISABLED) ? (DSS_DISABLED | DSS_MONO) : 0) );
  1894. }
  1895. else {
  1896. HBITMAP hBmpTmp;
  1897. UIFCOLOR col = GetFrameBkgdCol(dwState);
  1898. if (dwState & UIFDCS_DISABLED) {
  1899. hBmpTmp = CreateDisabledBitmap(prc,
  1900. hBmpMask,
  1901. (HBRUSH)GetBrush(col),
  1902. GetBrush( UIFCOLOR_CTRLIMAGESHADOW ), FALSE);
  1903. }
  1904. else {
  1905. HDC hDCMem;
  1906. HDC hDCTmp;
  1907. HDC hDCMono;
  1908. HBITMAP hBmpMono;
  1909. HBITMAP hBmpMemOld;
  1910. HBITMAP hBmpTmpOld;
  1911. HBITMAP hBmpMonoOld;
  1912. LONG width = prc->right - prc->left;
  1913. LONG height = prc->bottom - prc->top;
  1914. RECT rc;
  1915. UIFCOLOR colText;
  1916. SetRect( &rc, 0, 0, width, height );
  1917. if ((dwState & UIFDCS_MOUSEOVERSELECTED) == UIFDCS_MOUSEOVERSELECTED) {
  1918. colText = UIFCOLOR_MOUSEDOWNTEXT; /* frame: 100% */
  1919. }
  1920. else if ((dwState & UIFDCS_MOUSEDOWN) == UIFDCS_MOUSEDOWN) {
  1921. colText = UIFCOLOR_MOUSEDOWNTEXT; /* frame: 100% */
  1922. }
  1923. else if ((dwState & UIFDCS_MOUSEOVER) == UIFDCS_MOUSEOVER) {
  1924. colText = UIFCOLOR_MOUSEOVERTEXT; /* frame: 65% */
  1925. }
  1926. else if ((dwState & UIFDCS_SELECTED) == UIFDCS_SELECTED) {
  1927. colText = UIFCOLOR_MOUSEOVERTEXT; /* frame: 65% */
  1928. }
  1929. else {
  1930. colText = UIFCOLOR_CTRLTEXT;
  1931. }
  1932. // create destination bitmap
  1933. hDCTmp = CreateCompatibleDC( hDC );
  1934. hBmpTmp = CreateCompatibleBitmap( hDC, width, height );
  1935. hBmpTmpOld = (HBITMAP)SelectObject( hDCTmp, hBmpTmp );
  1936. // create work DC
  1937. hDCMem = CreateCompatibleDC( hDC );
  1938. // paint background
  1939. FillRect( hDCTmp, &rc, col );
  1940. // step1. apply mask
  1941. hBmpMemOld = (HBITMAP)SelectObject( hDCMem, hBmpMask );
  1942. BitBlt( hDCTmp, 0, 0, width, height, hDCMem, 0, 0, SRCAND );
  1943. // step2. fill color on mask
  1944. HBRUSH hBrushOld = (HBRUSH)SelectObject( hDCTmp, GetBrush( colText ) );
  1945. BitBlt( hDCTmp, 0, 0, width, height, hDCMem, 0, 0, 0x00BA0B09 /* DPSnao */ );
  1946. SelectObject( hDCTmp, hBrushOld );
  1947. // step3. create image mask
  1948. SelectObject( hDCMem, hBmp );
  1949. hDCMono = CreateCompatibleDC( hDC );
  1950. hBmpMono = CreateBitmap( width, height, 1, 1, NULL );
  1951. hBmpMonoOld = (HBITMAP)SelectObject( hDCMono, hBmpMono );
  1952. SetBkColor( hDCMem, RGB( 0, 0, 0 ) );
  1953. BitBlt( hDCMono, 0, 0, width, height, hDCMem, 0, 0, SRCCOPY );
  1954. // step4. apply image mask
  1955. SetBkColor( hDCTmp, RGB( 255, 255, 255 ) );
  1956. SetTextColor( hDCTmp, RGB( 0, 0, 0 ) );
  1957. BitBlt( hDCTmp, 0, 0, width, height, hDCMono, 0, 0, SRCAND );
  1958. SelectObject( hDCMono, hBmpMonoOld );
  1959. DeleteObject( hBmpMono );
  1960. DeleteDC( hDCMono );
  1961. // step5. apply image
  1962. BitBlt( hDCTmp, 0, 0, width, height, hDCMem, 0, 0, SRCINVERT );
  1963. // dispose work DC
  1964. DeleteDC( hDCMem );
  1965. //
  1966. SelectObject( hDCTmp, hBmpTmpOld );
  1967. DeleteDC( hDCTmp );
  1968. }
  1969. CUIDrawState( hDC,
  1970. NULL,
  1971. NULL,
  1972. (LPARAM)hBmpTmp,
  1973. 0,
  1974. prc->left,
  1975. prc->top,
  1976. prc->right - prc->left,
  1977. prc->bottom - prc->top,
  1978. DST_BITMAP);
  1979. DeleteObject(hBmpTmp);
  1980. }
  1981. }
  1982. /* D R A W W N D F R A M E */
  1983. /*------------------------------------------------------------------------------
  1984. ------------------------------------------------------------------------------*/
  1985. virtual void DrawWndFrame( HDC hDC, const RECT *prc, DWORD dwFlag, int cxFrame, int cyFrame )
  1986. {
  1987. RECT rc;
  1988. int cxFrameOuter;
  1989. int cyFrameOuter;
  1990. int cxFrameInner;
  1991. int cyFrameInner;
  1992. switch (dwFlag) {
  1993. default:
  1994. case UIFDWF_THIN: {
  1995. cxFrameOuter = cxFrame;
  1996. cyFrameOuter = cyFrame;
  1997. cxFrameInner = 0;
  1998. cyFrameInner = 0;
  1999. break;
  2000. }
  2001. case UIFDWF_THICK:
  2002. case UIFDWF_ROUNDTHICK: {
  2003. cxFrameOuter = cxFrame - 1;
  2004. cyFrameOuter = cyFrame - 1;
  2005. cxFrameInner = 1;
  2006. cyFrameInner = 1;
  2007. break;
  2008. }
  2009. }
  2010. // left
  2011. rc = *prc;
  2012. rc.right = rc.left + cxFrameOuter;
  2013. FillRect( hDC, &rc, UIFCOLOR_BORDEROUTER );
  2014. if (cxFrameInner != 0) {
  2015. rc.left = rc.left + cxFrameOuter;
  2016. rc.right = rc.left + cxFrameInner;
  2017. rc.top = rc.top + cyFrameOuter;
  2018. rc.bottom = rc.bottom - cyFrameOuter;
  2019. FillRect( hDC, &rc, UIFCOLOR_BORDERINNER );
  2020. }
  2021. // right
  2022. rc = *prc;
  2023. rc.left = rc.right - cxFrameOuter;
  2024. FillRect( hDC, &rc, UIFCOLOR_BORDEROUTER );
  2025. if (cxFrameInner != 0) {
  2026. rc.left = rc.right - cxFrame;
  2027. rc.right = rc.left + cxFrameInner;
  2028. rc.top = rc.top + cyFrameOuter;
  2029. rc.bottom = rc.bottom - cyFrameOuter;
  2030. FillRect( hDC, &rc, UIFCOLOR_BORDERINNER );
  2031. }
  2032. // top
  2033. rc = *prc;
  2034. rc.bottom = rc.top + cyFrameOuter;
  2035. FillRect( hDC, &rc, UIFCOLOR_BORDEROUTER );
  2036. if (cyFrameInner != 0) {
  2037. rc.top = rc.top + cyFrameOuter;
  2038. rc.bottom = rc.top + cyFrameInner;
  2039. rc.left = rc.left + cxFrameOuter;
  2040. rc.right = rc.right - cxFrameOuter;
  2041. FillRect( hDC, &rc, UIFCOLOR_BORDERINNER );
  2042. }
  2043. // bottom
  2044. rc = *prc;
  2045. rc.top = rc.bottom - cyFrameOuter;
  2046. FillRect( hDC, &rc, UIFCOLOR_BORDEROUTER );
  2047. if (cyFrameInner != 0) {
  2048. rc.top = rc.bottom - cyFrame;
  2049. rc.bottom = rc.top + cyFrameInner;
  2050. rc.left = rc.left + cxFrameOuter;
  2051. rc.right = rc.right - cxFrameOuter;
  2052. FillRect( hDC, &rc, UIFCOLOR_BORDERINNER );
  2053. }
  2054. // rounded corner
  2055. if (dwFlag & UIFDWF_ROUNDTHICK) {
  2056. rc = *prc;
  2057. rc.left = rc.left + cxFrameOuter;
  2058. rc.top = rc.top + cyFrameOuter;
  2059. rc.right = rc.left + 1;
  2060. rc.bottom = rc.top + 1;
  2061. FillRect( hDC, &rc, UIFCOLOR_BORDEROUTER );
  2062. rc = *prc;
  2063. rc.left = rc.right - (cxFrameOuter + 1);
  2064. rc.top = rc.top + cyFrameOuter;
  2065. rc.right = rc.left + 1;
  2066. rc.bottom = rc.top + 1;
  2067. FillRect( hDC, &rc, UIFCOLOR_BORDEROUTER );
  2068. }
  2069. }
  2070. /* D R A W D R A G H A N D L E */
  2071. /*------------------------------------------------------------------------------
  2072. ------------------------------------------------------------------------------*/
  2073. virtual void DrawDragHandle( HDC hDC, const RECT *prc, BOOL fVertical)
  2074. {
  2075. CSolidPen hpen;
  2076. hpen.Init(GetColor(UIFCOLOR_DRAGHANDLE));
  2077. HPEN hpenOld = (HPEN)SelectObject(hDC, hpen);
  2078. if (!fVertical)
  2079. {
  2080. int x0, x1, y;
  2081. y = prc->top + 2;
  2082. x0 = prc->left + 2;
  2083. x1 = prc->right;
  2084. for (;y < prc->bottom - 1; y+=2)
  2085. {
  2086. MoveToEx(hDC, x0, y, NULL);
  2087. LineTo(hDC, x1, y);
  2088. }
  2089. }
  2090. else
  2091. {
  2092. int y0, y1, x;
  2093. x = prc->left + 2;
  2094. y0 = prc->top + 2;
  2095. y1 = prc->bottom;
  2096. for (;x < prc->right - 1; x+=2)
  2097. {
  2098. MoveToEx(hDC, x, y0, NULL);
  2099. LineTo(hDC, x, y1);
  2100. }
  2101. }
  2102. SelectObject(hDC, hpenOld);
  2103. }
  2104. /* D R A W S E P A R A T O R */
  2105. /*------------------------------------------------------------------------------
  2106. ------------------------------------------------------------------------------*/
  2107. virtual void DrawSeparator( HDC hDC, const RECT *prc, BOOL fVertical)
  2108. {
  2109. CSolidPen hpenL;
  2110. HPEN hpenOld = NULL;
  2111. if (!hpenL.Init(GetColor(UIFCOLOR_CTRLIMAGESHADOW)))
  2112. return;
  2113. if (!fVertical)
  2114. {
  2115. hpenOld = (HPEN)SelectObject(hDC, (HPEN)hpenL);
  2116. MoveToEx(hDC, prc->left + 1, prc->top + 1, NULL);
  2117. LineTo(hDC, prc->left + 1, prc->bottom - 1);
  2118. }
  2119. else
  2120. {
  2121. hpenOld = (HPEN)SelectObject(hDC, (HPEN)hpenL);
  2122. MoveToEx(hDC, prc->left + 1, prc->top + 1, NULL);
  2123. LineTo(hDC, prc->right - 1, prc->top + 1);
  2124. }
  2125. SelectObject(hDC, hpenOld);
  2126. }
  2127. protected:
  2128. UIFSCHEME m_scheme;
  2129. OFC10COLOR *m_pcoldef;
  2130. };
  2131. /*=============================================================================*/
  2132. /* */
  2133. /* E X P O R T E D F U N C T I O N S */
  2134. /* */
  2135. /*=============================================================================*/
  2136. /* I N I T U I F S C H E M E */
  2137. /*------------------------------------------------------------------------------
  2138. ------------------------------------------------------------------------------*/
  2139. void InitUIFScheme( void )
  2140. {
  2141. // create color tables
  2142. v_pColTableSys = new CUIFColorTableSys();
  2143. if (v_pColTableSys)
  2144. v_pColTableSys->Initialize();
  2145. v_pColTableOfc10 = new CUIFColorTableOff10();
  2146. if (v_pColTableOfc10)
  2147. v_pColTableOfc10->Initialize();
  2148. }
  2149. /* D O N E U I F S C H E M E */
  2150. /*------------------------------------------------------------------------------
  2151. ------------------------------------------------------------------------------*/
  2152. void DoneUIFScheme( void )
  2153. {
  2154. if (v_pColTableSys != NULL) {
  2155. delete v_pColTableSys;
  2156. v_pColTableSys = NULL;
  2157. }
  2158. if (v_pColTableOfc10 != NULL) {
  2159. delete v_pColTableOfc10;
  2160. v_pColTableOfc10 = NULL;
  2161. }
  2162. }
  2163. /* U P D A T E U I F S C H E M E */
  2164. /*------------------------------------------------------------------------------
  2165. ------------------------------------------------------------------------------*/
  2166. void UpdateUIFScheme( void )
  2167. {
  2168. if (v_pColTableSys != NULL) {
  2169. v_pColTableSys->Update();
  2170. }
  2171. if (v_pColTableOfc10 != NULL) {
  2172. v_pColTableOfc10->Update();
  2173. }
  2174. }
  2175. /* C R E A T E U I F S C H E M E */
  2176. /*------------------------------------------------------------------------------
  2177. ------------------------------------------------------------------------------*/
  2178. CUIFScheme *CreateUIFScheme( UIFSCHEME scheme )
  2179. {
  2180. CUIFScheme *pScheme = NULL;
  2181. switch (scheme) {
  2182. default:
  2183. case UIFSCHEME_DEFAULT: {
  2184. pScheme = new CUIFSchemeDef( scheme );
  2185. break;
  2186. }
  2187. case UIFSCHEME_OFC10MENU: {
  2188. pScheme = new CUIFSchemeOff10( scheme );
  2189. break;
  2190. }
  2191. case UIFSCHEME_OFC10TOOLBAR: {
  2192. pScheme = new CUIFSchemeOff10( scheme );
  2193. break;
  2194. }
  2195. case UIFSCHEME_OFC10WORKPANE: {
  2196. pScheme = new CUIFSchemeOff10( scheme );
  2197. break;
  2198. }
  2199. }
  2200. Assert( pScheme != NULL );
  2201. return pScheme;
  2202. }