PageButtons.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:35k
源码类别:

界面编程

开发平台:

Visual C++

  1. // PageButtons.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "profuis_controls.h"
  5. #include "PageButtons.h"
  6. #include "MainDlg.h"
  7. #include <Resources/Resource.h>
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. #define IDC_HAND MAKEINTRESOURCE(32649)
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CPageButtons dialog
  16. CPageButtons::CPageButtons(CWnd* pParent /*=NULL*/)
  17. : CPageBase(CPageButtons::IDD, pParent)
  18. , m_bInitComplete( false )
  19. {
  20. //{{AFX_DATA_INIT(CPageButtons)
  21. //}}AFX_DATA_INIT
  22. }
  23. void CPageButtons::DoDataExchange(CDataExchange* pDX)
  24. {
  25. CPageBase::DoDataExchange(pDX);
  26. //{{AFX_DATA_MAP(CPageButtons)
  27. DDX_Control(pDX, IDC_TEXT_MARGINS_RESET, m_wndTextMarginsReset);
  28. DDX_Control(pDX, IDC_ICON_MARGINS_RESET, m_wndIconMarginsReset);
  29. DDX_Control(pDX, IDC_SPIN_ICON_MARGINS_TOP, m_wndSpinIconMarginsTop);
  30. DDX_Control(pDX, IDC_SPIN_ICON_MARGINS_RIGHT, m_wndSpinIconMarginsRight);
  31. DDX_Control(pDX, IDC_SPIN_ICON_MARGINS_LEFT, m_wndSpinIconMarginsLeft);
  32. DDX_Control(pDX, IDC_SPIN_ICON_MARGINS_BOTTOM, m_wndSpinIconMarginsBottom);
  33. DDX_Control(pDX, IDC_SPIN_TEXT_MARGINS_TOP, m_wndSpinTextMarginsTop);
  34. DDX_Control(pDX, IDC_SPIN_TEXT_MARGINS_RIGHT, m_wndSpinTextMarginsRight);
  35. DDX_Control(pDX, IDC_SPIN_TEXT_MARGINS_LEFT, m_wndSpinTextMarginsLeft);
  36. DDX_Control(pDX, IDC_SPIN_TEXT_MARGINS_BOTTOM, m_wndSpinTextMarginsBottom);
  37. DDX_Control(pDX, IDC_TEXT_MARGINS_TOP, m_wndTextMarginsTop);
  38. DDX_Control(pDX, IDC_TEXT_MARGINS_RIGHT, m_wndTextMarginsRight);
  39. DDX_Control(pDX, IDC_TEXT_MARGINS_LEFT, m_wndTextMarginsLeft);
  40. DDX_Control(pDX, IDC_TEXT_MARGINS_BOTTOM, m_wndTextMarginsBottom);
  41. DDX_Control(pDX, IDC_ICON_MARGINS_TOP, m_wndIconMarginsTop);
  42. DDX_Control(pDX, IDC_ICON_MARGINS_RIGHT, m_wndIconMarginsRight);
  43. DDX_Control(pDX, IDC_ICON_MARGINS_LEFT, m_wndIconMarginsLeft);
  44. DDX_Control(pDX, IDC_ICON_MARGINS_BOTTOM, m_wndIconMarginsBottom);
  45. DDX_Control(pDX, IDC_GROUP_BOX_TEXT_MARGINS, m_wndGroupBoxTextMargins);
  46. DDX_Control(pDX, IDC_GROUP_BOX_ICON_MARGINS, m_wndGroupBoxIconMargins);
  47. DDX_Control(pDX, IDC_STATIC_ICON_ALIGNMENT_VERT, m_wndlabelIconAlignmentVert);
  48. DDX_Control(pDX, IDC_STATIC_ICON_ALIGNMENT_HORZ, m_wndlabelIconAlignmentHorz);
  49. DDX_Control(pDX, IDC_STATIC_TEXT_ALIGNMENT_VERT, m_wndlabelTextAlignmentVert);
  50. DDX_Control(pDX, IDC_STATIC_TEXT_ALIGNMENT_HORZ, m_wndlabelTextAlignmentHorz);
  51. DDX_Control(pDX, IDC_TEXT_ALIGNMENT_VERT, m_wndTextAlignmentVert);
  52. DDX_Control(pDX, IDC_TEXT_ALIGNMENT_HORZ, m_wndTextAlignmentHorz);
  53. DDX_Control(pDX, IDC_ICON_ALIGNMENT_VERT, m_wndIconAlignmentVert);
  54. DDX_Control(pDX, IDC_ICON_ALIGNMENT_HORZ, m_wndIconAlignmentHorz);
  55. DDX_Control(pDX, IDC_GROUP_BOX_TEXT_ALIGNMENT, m_wndGroupBoxTextAlignment);
  56. DDX_Control(pDX, IDC_GROUP_BOX_ICON_ALIGNMENT, m_wndGroupBoxIconAlignment);
  57. DDX_Control(pDX, IDC_RADIO1, m_wndRadio1);
  58. DDX_Control(pDX, IDC_RADIO2, m_wndRadio2);
  59. DDX_Control(pDX, IDC_CHECK_BOX2, m_chkCheckBox2);
  60. DDX_Control(pDX, IDC_CHECK_BOX1, m_chkCheckBox1);
  61. DDX_Control(pDX, IDC_BUTTON_WITH_MENU, m_btnWithMenu);
  62. DDX_Control(pDX, IDC_BUTTON_COLOR2, m_btnColor2);
  63. DDX_Control(pDX, IDC_BUTTON_COLOR1, m_btnColor1);
  64. DDX_Control(pDX, IDC_CHECK_BOX_SHOW_FOCUS_RECT, m_chkCheckBoxShowFocusRect);
  65. DDX_Control(pDX, IDC_TOOLTIP, m_Tooltip);
  66. DDX_Control(pDX, IDC_STATIC_TOOLTIP, m_wndLabelTooltip);
  67. DDX_Control(pDX, IDC_STATIC_SKIN, m_wndLabelSkin);
  68. DDX_Control(pDX, IDC_STATIC_CHECK_BOX, m_wndGroupBoxCheck);
  69. DDX_Control(pDX, IDC_STATIC_CURSOR, m_wndLabelCursor);
  70. DDX_Control(pDX, IDC_SKIN, m_CheckBoxSkin);
  71. DDX_Control(pDX, IDC_PUSH_LIKE_BUTTON, m_btnPushLikeButton);
  72. DDX_Control(pDX, IDC_PUSH_BUTTON, m_btnPushButton);
  73. DDX_Control(pDX, IDC_CURSOR, m_Cursor);
  74. DDX_Control(pDX, IDC_CHECK_TRISTATE, m_chkTriState);
  75. DDX_Control(pDX, IDC_CHECK_BUTTON_SHOW_FOCUS_RECT, m_chkButtonShowFocusRect);
  76. DDX_Control(pDX, IDC_CHECK_BUTTON_ENABLE, m_chkButtonEnable);
  77. DDX_Control(pDX, IDC_CHECK_BOX_ENABLE, m_chkCheckBoxEnable);
  78. DDX_Control(pDX, IDC_CHECK_LEFT_TEXT, m_chkLeftText);
  79. DDX_Control(pDX, IDC_CHECK_SEPARATED_BUTTONS, m_chkSeparatedButtons);
  80. DDX_Control(pDX, IDC_CHECK_FLAT, m_chkFlat);
  81. DDX_Control(pDX, IDC_CHECK_BORDER, m_chkBorders);
  82. //}}AFX_DATA_MAP
  83. }
  84. BEGIN_MESSAGE_MAP(CPageButtons, CPageBase)
  85. //{{AFX_MSG_MAP(CPageButtons)
  86. ON_CBN_SELENDOK(IDC_SKIN, OnSelendokSkin)
  87. ON_CBN_SELENDOK(IDC_CURSOR, OnSelendokCursor)
  88. ON_CBN_SELENDOK(IDC_ICON_ALIGNMENT_HORZ, OnSelendokIconAlignmentHorz)
  89. ON_CBN_SELENDOK(IDC_ICON_ALIGNMENT_VERT, OnSelendokIconAlignmentVert)
  90. ON_CBN_SELENDOK(IDC_TEXT_ALIGNMENT_HORZ, OnSelendokTextAlignmentHorz)
  91. ON_CBN_SELENDOK(IDC_TEXT_ALIGNMENT_VERT, OnSelendokTextAlignmentVert)
  92. ON_BN_CLICKED(IDC_TEXT_MARGINS_RESET, OnTextMarginsReset)
  93. ON_BN_CLICKED(IDC_ICON_MARGINS_RESET, OnIconMarginsReset)
  94. //}}AFX_MSG_MAP
  95. // color popup menu
  96. ON_REGISTERED_MESSAGE(
  97. CExtPopupColorMenuWnd::g_nMsgNotifyColorChangedFinally,
  98. OnColorChangedFinally
  99. )
  100. ON_REGISTERED_MESSAGE(
  101. CExtPopupColorMenuWnd::g_nMsgNotifyCustColor,
  102. OnColorSelectCustom
  103. )
  104. ON_REGISTERED_MESSAGE(CExtPopupMenuWnd::g_nMsgPrepareMenu,OnExtMenuPrepare)
  105. ON_REGISTERED_MESSAGE(CExtPopupMenuWnd::g_nMsgPopupDrawItem,OnDrawPopupMenuItem)
  106. ON_REGISTERED_MESSAGE(CExtPopupMenuWnd::g_nMsgPopupDrawLeftArea,OnDrawPopupLeftArea)
  107. END_MESSAGE_MAP()
  108. /////////////////////////////////////////////////////////////////////////////
  109. // CPageButtons message handlers
  110. BOOL CPageButtons::OnInitDialog() 
  111. {
  112. CPageBase::OnInitDialog();
  113. m_wndTextMarginsReset.SetFlat( TRUE );
  114. m_wndIconMarginsReset.SetFlat( TRUE );
  115. m_wndTextMarginsReset.SetDrawBorder( TRUE );
  116. m_wndIconMarginsReset.SetDrawBorder( TRUE );
  117. m_wndSpinIconMarginsTop.SetRange(0,20);
  118. m_wndSpinIconMarginsRight.SetRange(0,20);
  119. m_wndSpinIconMarginsLeft.SetRange(0,20);
  120. m_wndSpinIconMarginsBottom.SetRange(0,20);
  121. m_wndSpinTextMarginsTop.SetRange(0,20);
  122. m_wndSpinTextMarginsRight.SetRange(0,20);
  123. m_wndSpinTextMarginsLeft.SetRange(0,20);
  124. m_wndSpinTextMarginsBottom.SetRange(0,20);
  125. SetDlgItemInt( IDC_TEXT_MARGINS_TOP, 3 );
  126. SetDlgItemInt( IDC_TEXT_MARGINS_RIGHT, 3 );
  127. SetDlgItemInt( IDC_TEXT_MARGINS_LEFT, 3 );
  128. SetDlgItemInt( IDC_TEXT_MARGINS_BOTTOM, 3 );
  129. SetDlgItemInt( IDC_ICON_MARGINS_TOP, 3 );
  130. SetDlgItemInt( IDC_ICON_MARGINS_RIGHT, 3 );
  131. SetDlgItemInt( IDC_ICON_MARGINS_LEFT, 3 );
  132. SetDlgItemInt( IDC_ICON_MARGINS_BOTTOM, 3 );
  133. CString sTooltip( _T("Tooltip") );
  134. m_Tooltip.SetWindowText( sTooltip );
  135. m_btnPushButton.SetTooltipText( LPCTSTR(sTooltip) );
  136. m_btnPushButton.m_icon.AssignFromHICON(
  137. (HICON) ::LoadImage(
  138. ::AfxGetInstanceHandle(),
  139. MAKEINTRESOURCE(IDI_NOTEPAD),
  140. IMAGE_ICON,
  141. 48,
  142. 48,
  143. 0
  144. ),
  145. false
  146. );
  147. HICON hIconIn = (HICON)
  148. ::LoadImage(
  149. ::AfxGetInstanceHandle(),
  150. MAKEINTRESOURCE(IDI_ICON_IN),
  151. IMAGE_ICON,
  152. 32,
  153. 32,
  154. 0
  155. );
  156. m_btnWithMenu.m_icon.m_bmpHover.AssignFromHICON( hIconIn );
  157. ::DeleteObject( hIconIn );
  158. HICON hIconOut = (HICON)
  159. ::LoadImage(
  160. ::AfxGetInstanceHandle(),
  161. MAKEINTRESOURCE(IDI_ICON_OUT),
  162. IMAGE_ICON,
  163. 32,
  164. 32,
  165. 0
  166. );
  167. m_btnWithMenu.m_icon.m_bmpNormal.AssignFromHICON( hIconOut );
  168. ::DeleteObject( hIconOut );
  169. m_btnWithMenu.m_icon.m_dwFlags |= __EXT_ICON_PERSISTENT_BITMAP_HOVER;
  170. m_btnPushLikeButton.m_icon.AssignFromHICON(
  171. (HICON) ::LoadImage(
  172. ::AfxGetInstanceHandle(),
  173. MAKEINTRESOURCE(IDI_LED_OFF),
  174. IMAGE_ICON,
  175. 16,
  176. 16,
  177. 0
  178. ),
  179. false
  180. );
  181. CheckDlgButton( IDC_CHECK_BUTTON_ENABLE, BST_CHECKED );
  182. CheckDlgButton( IDC_CHECK_BOX_ENABLE, BST_CHECKED );
  183. m_btnColor1.m_lParamCookie = LPARAM(IDC_BUTTON_COLOR1);
  184. m_btnColor1.m_nMenuLeftAreaWidth = 30;
  185. m_btnColor2.m_lParamCookie = LPARAM(IDC_BUTTON_COLOR2);
  186. m_btnWithMenu.m_dwMenuOpt |= TPMX_OWNERDRAW_FIXED;
  187. CMenu _menu;
  188. VERIFY(
  189. _menu.LoadMenu(IDR_POPUP_MENU)
  190. );
  191. m_btnWithMenu.m_menu.Attach(
  192. _menu.Detach()
  193. );
  194. m_bInitComplete = true;
  195. int nIndex = -1, nInitSel = -1;
  196. //////////////////////////////////////////////////////////////////////////
  197. nInitSel = nIndex = m_wndTextAlignmentHorz.AddString( _T("Default") );
  198. m_wndTextAlignmentHorz.SetItemData( nIndex, CExtPaintManager::__ALIGN_HORIZ_CENTER );
  199. nIndex = m_wndTextAlignmentHorz.AddString( _T("Left") );
  200. m_wndTextAlignmentHorz.SetItemData( nIndex, CExtPaintManager::__ALIGN_HORIZ_LEFT );
  201. nIndex = m_wndTextAlignmentHorz.AddString( _T("Right") );
  202. m_wndTextAlignmentHorz.SetItemData( nIndex, CExtPaintManager::__ALIGN_HORIZ_RIGHT );
  203. nIndex = m_wndTextAlignmentHorz.AddString( _T("Center") );
  204. m_wndTextAlignmentHorz.SetItemData( nIndex, CExtPaintManager::__ALIGN_HORIZ_CENTER );
  205. m_wndTextAlignmentHorz.SetCurSel( nInitSel );
  206. nInitSel = nIndex = m_wndIconAlignmentHorz.AddString( _T("Default") );
  207. m_wndIconAlignmentHorz.SetItemData( nIndex, CExtPaintManager::__ALIGN_HORIZ_LEFT );
  208. nIndex = m_wndIconAlignmentHorz.AddString( _T("Left") );
  209. m_wndIconAlignmentHorz.SetItemData( nIndex, CExtPaintManager::__ALIGN_HORIZ_LEFT );
  210. nIndex = m_wndIconAlignmentHorz.AddString( _T("Right") );
  211. m_wndIconAlignmentHorz.SetItemData( nIndex, CExtPaintManager::__ALIGN_HORIZ_RIGHT );
  212. nIndex = m_wndIconAlignmentHorz.AddString( _T("Center") );
  213. m_wndIconAlignmentHorz.SetItemData( nIndex, CExtPaintManager::__ALIGN_HORIZ_CENTER );
  214. m_wndIconAlignmentHorz.SetCurSel( nInitSel );
  215. nInitSel = nIndex = m_wndTextAlignmentVert.AddString( _T("Default") );
  216. m_wndTextAlignmentVert.SetItemData( nIndex, CExtPaintManager::__ALIGN_VERT_CENTER );
  217. nIndex = m_wndTextAlignmentVert.AddString( _T("Top") );
  218. m_wndTextAlignmentVert.SetItemData( nIndex, CExtPaintManager::__ALIGN_VERT_TOP );
  219. nIndex = m_wndTextAlignmentVert.AddString( _T("Bottom") );
  220. m_wndTextAlignmentVert.SetItemData( nIndex, CExtPaintManager::__ALIGN_VERT_BOTTOM );
  221. nIndex = m_wndTextAlignmentVert.AddString( _T("Center") );
  222. m_wndTextAlignmentVert.SetItemData( nIndex, CExtPaintManager::__ALIGN_VERT_CENTER );
  223. m_wndTextAlignmentVert.SetCurSel( nInitSel );
  224. nInitSel = nIndex = m_wndIconAlignmentVert.AddString( _T("Default") );
  225. m_wndIconAlignmentVert.SetItemData( nIndex, CExtPaintManager::__ALIGN_VERT_CENTER );
  226. nIndex = m_wndIconAlignmentVert.AddString( _T("Top") );
  227. m_wndIconAlignmentVert.SetItemData( nIndex, CExtPaintManager::__ALIGN_VERT_TOP );
  228. nIndex = m_wndIconAlignmentVert.AddString( _T("Bottom") );
  229. m_wndIconAlignmentVert.SetItemData( nIndex, CExtPaintManager::__ALIGN_VERT_BOTTOM );
  230. nIndex = m_wndIconAlignmentVert.AddString( _T("Center") );
  231. m_wndIconAlignmentVert.SetItemData( nIndex, CExtPaintManager::__ALIGN_VERT_CENTER );
  232. m_wndIconAlignmentVert.SetCurSel( nInitSel );
  233. //////////////////////////////////////////////////////////////////////////
  234. nInitSel = nIndex = m_CheckBoxSkin.AddString( _T("Standard") );
  235. m_CheckBoxSkin.SetItemData( nIndex, 0 );
  236. nIndex = m_CheckBoxSkin.AddString( _T("XP") );
  237. m_CheckBoxSkin.SetItemData( nIndex, IDB_BOX_IMAGES_XP );
  238. nIndex = m_CheckBoxSkin.AddString( _T("XP Blue") );
  239. m_CheckBoxSkin.SetItemData( nIndex, IDB_BOX_IMAGES_XP_BLUE );
  240. nIndex = m_CheckBoxSkin.AddString( _T("XP Cross") );
  241. m_CheckBoxSkin.SetItemData( nIndex, IDB_BOX_IMAGES_XP_CROSS );
  242. m_CheckBoxSkin.SetCurSel( nInitSel );
  243. nInitSel = nIndex = m_Cursor.AddString( _T("Default") );
  244. m_Cursor.SetItemData( nIndex, 0 );
  245. nIndex = m_Cursor.AddString( _T("Hand") );
  246. m_Cursor.SetItemData( nIndex, (DWORD)IDC_HAND);
  247. nIndex = m_Cursor.AddString( _T("Cross") );
  248. m_Cursor.SetItemData( nIndex, (DWORD)IDC_CROSS);
  249. nIndex = m_Cursor.AddString( _T("UpArrow") );
  250. m_Cursor.SetItemData( nIndex, (DWORD)IDC_UPARROW);
  251. nIndex = m_Cursor.AddString( _T("Wait") );
  252. m_Cursor.SetItemData( nIndex, (DWORD)IDC_WAIT);
  253. nIndex = m_Cursor.AddString( _T("SizeAll") );
  254. m_Cursor.SetItemData( nIndex, (DWORD)IDC_SIZEALL);
  255. m_Cursor.SetCurSel( nInitSel );
  256. OnCmdMsg( IDC_CHECK_BUTTON_ENABLE, CN_COMMAND, NULL, NULL );
  257. OnCmdMsg( IDC_CHECK_FLAT, CN_COMMAND, NULL, NULL );
  258. OnCmdMsg( IDC_CHECK_BORDER, CN_COMMAND, NULL, NULL );
  259. OnCmdMsg( IDC_CHECK_BUTTON_SHOW_FOCUS_RECT, CN_COMMAND, NULL, NULL );
  260. OnCmdMsg( IDC_CHECK_SEPARATED_BUTTONS, CN_COMMAND, NULL, NULL );
  261. OnCmdMsg( IDC_CHECK_BOX_ENABLE, CN_COMMAND, NULL, NULL );
  262. OnCmdMsg( IDC_CHECK_TRISTATE, CN_COMMAND, NULL, NULL );
  263. OnCmdMsg( IDC_CHECK_LEFT_TEXT, CN_COMMAND, NULL, NULL );
  264. OnCmdMsg( IDC_CHECK_BOX_SHOW_FOCUS_RECT, CN_COMMAND, NULL, NULL );
  265. return TRUE;  // return TRUE unless you set the focus to a control
  266.               // EXCEPTION: OCX Property Pages should return FALSE
  267. }
  268. //////////////////////////////////////////////////////////////////////////
  269. BOOL CPageButtons::OnCmdMsg(UINT nID, INT nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
  270. {
  271. if( !m_bInitComplete ){
  272. return CPageBase::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  273. }
  274. if( nCode == EN_CHANGE )
  275. {
  276. switch( nID )
  277. {
  278. case IDC_TOOLTIP:
  279. {
  280. CString sTooltip;
  281. m_Tooltip.GetWindowText( sTooltip );
  282. m_btnPushButton.SetTooltipText( LPCTSTR(sTooltip) );
  283. }
  284. break;
  285. case IDC_TEXT_MARGINS_TOP:
  286. case IDC_TEXT_MARGINS_RIGHT:
  287. case IDC_TEXT_MARGINS_LEFT:
  288. case IDC_TEXT_MARGINS_BOTTOM:
  289. {
  290. UINT nValTop = GetDlgItemInt( IDC_TEXT_MARGINS_TOP );
  291. UINT nValRight = GetDlgItemInt( IDC_TEXT_MARGINS_RIGHT );
  292. UINT nValLeft = GetDlgItemInt( IDC_TEXT_MARGINS_LEFT );
  293. UINT nValBottom = GetDlgItemInt( IDC_TEXT_MARGINS_BOTTOM );
  294. m_btnPushButton.SetTextMargins(
  295. nValLeft,
  296. nValTop,
  297. nValRight,
  298. nValBottom
  299. );
  300. }
  301. break;
  302. case IDC_ICON_MARGINS_TOP:
  303. case IDC_ICON_MARGINS_RIGHT:
  304. case IDC_ICON_MARGINS_LEFT:
  305. case IDC_ICON_MARGINS_BOTTOM:
  306. {
  307. UINT nValTop = GetDlgItemInt( IDC_ICON_MARGINS_TOP );
  308. UINT nValRight = GetDlgItemInt( IDC_ICON_MARGINS_RIGHT );
  309. UINT nValLeft = GetDlgItemInt( IDC_ICON_MARGINS_LEFT );
  310. UINT nValBottom = GetDlgItemInt( IDC_ICON_MARGINS_BOTTOM );
  311. m_btnPushButton.SetIconMargins(
  312. nValLeft,
  313. nValTop,
  314. nValRight,
  315. nValBottom
  316. );
  317. }
  318. break;
  319. default:
  320. return CPageBase::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  321. }
  322. return TRUE;
  323. }
  324. if( nCode == CN_UPDATE_COMMAND_UI
  325. && ( nID == IDC_MENU_ITEM_RARELY1
  326. || nID == IDC_MENU_ITEM_RARELY2
  327. || nID == IDC_MENU_ITEM_RARELY3 )
  328. )
  329. {
  330. CCmdUI * pCmdUI = (CCmdUI *)pExtra;
  331. ASSERT( pCmdUI != NULL );
  332. pCmdUI->Enable();
  333. return TRUE;
  334. }
  335. if( nCode == CN_COMMAND )
  336. {
  337. BOOL bChecked = FALSE;
  338. switch( nID )
  339. {
  340. case IDC_CHECK_BUTTON_ENABLE:
  341. bChecked = IsDlgButtonChecked( nID );
  342. m_btnPushButton.EnableWindow( bChecked );
  343. m_btnPushLikeButton.EnableWindow( bChecked );
  344. m_btnWithMenu.EnableWindow( bChecked );
  345. m_btnColor1.EnableWindow( bChecked );
  346. m_btnColor2.EnableWindow( bChecked );
  347. break;
  348. case IDC_CHECK_FLAT:
  349. bChecked = IsDlgButtonChecked( nID );
  350. m_btnPushButton.SetFlat( bChecked );
  351. m_btnPushLikeButton.SetFlat( bChecked );
  352. m_btnWithMenu.SetFlat( bChecked );
  353. m_btnColor1.SetFlat( bChecked );
  354. m_btnColor2.SetFlat( bChecked );
  355. break;
  356. case IDC_CHECK_BORDER:
  357. bChecked = IsDlgButtonChecked( nID );
  358. m_btnPushButton.SetDrawBorder( bChecked );
  359. m_btnPushLikeButton.SetDrawBorder( bChecked );
  360. m_btnWithMenu.SetDrawBorder( bChecked );
  361. m_btnColor1.SetDrawBorder( bChecked );
  362. m_btnColor2.SetDrawBorder( bChecked );
  363. break;
  364. case IDC_PUSH_LIKE_BUTTON:
  365. m_btnPushLikeButton.m_icon.AssignFromHICON(
  366. (HICON) ::LoadImage(
  367. ::AfxGetInstanceHandle(),
  368. IsDlgButtonChecked( nID )
  369. ? MAKEINTRESOURCE(IDI_LED_ON)
  370. : MAKEINTRESOURCE(IDI_LED_OFF),
  371. IMAGE_ICON,
  372. 16,
  373. 16,
  374. 0
  375. ),
  376. false
  377. );
  378. break;
  379. case IDC_CHECK_BUTTON_SHOW_FOCUS_RECT:
  380. bChecked = IsDlgButtonChecked( nID );
  381. m_btnPushButton.SetDrawFocusRect( bChecked );
  382. m_btnPushLikeButton.SetDrawFocusRect( bChecked );
  383. m_btnWithMenu.SetDrawFocusRect( bChecked );
  384. m_btnColor1.SetDrawFocusRect( bChecked );
  385. m_btnColor2.SetDrawFocusRect( bChecked );
  386. break;
  387. case IDC_CHECK_SEPARATED_BUTTONS:
  388. bChecked = IsDlgButtonChecked( nID );
  389. m_btnWithMenu.SetSeparatedDropDown( bChecked );
  390. m_btnColor1.SetSeparatedDropDown( bChecked );
  391. m_btnColor2.SetSeparatedDropDown( bChecked );
  392. break;
  393. case IDC_CHECK_BOX_ENABLE:
  394. m_chkCheckBox1.EnableWindow( IsDlgButtonChecked( nID ) );
  395. m_chkCheckBox2.EnableWindow( IsDlgButtonChecked( nID ) );
  396. m_wndRadio1.EnableWindow( IsDlgButtonChecked( nID ) );
  397. m_wndRadio2.EnableWindow( IsDlgButtonChecked( nID ) );
  398. break;
  399. case IDC_CHECK_TRISTATE:
  400. if( IsDlgButtonChecked( nID ) ){
  401. m_chkCheckBox1.SetButtonStyle( BS_AUTO3STATE );
  402. m_chkCheckBox2.SetButtonStyle( BS_AUTO3STATE );
  403. }else{
  404. m_chkCheckBox1.SetButtonStyle( BS_AUTOCHECKBOX );
  405. m_chkCheckBox2.SetButtonStyle( BS_AUTOCHECKBOX );
  406. }
  407. m_chkCheckBox1.Invalidate();
  408. m_chkCheckBox2.Invalidate();
  409. break;
  410. case IDC_CHECK_LEFT_TEXT:
  411. if( IsDlgButtonChecked( nID ) ){
  412. m_chkCheckBox1.ModifyStyle( 0, BS_LEFTTEXT );
  413. m_chkCheckBox2.ModifyStyle( 0, BS_LEFTTEXT );
  414. m_wndRadio1.ModifyStyle( 0, BS_LEFTTEXT );
  415. m_wndRadio2.ModifyStyle( 0, BS_LEFTTEXT );
  416. }else{
  417. m_chkCheckBox1.ModifyStyle( BS_LEFTTEXT, 0 );
  418. m_chkCheckBox2.ModifyStyle( BS_LEFTTEXT, 0 );
  419. m_wndRadio1.ModifyStyle( BS_LEFTTEXT, 0 );
  420. m_wndRadio2.ModifyStyle( BS_LEFTTEXT, 0 );
  421. }
  422. m_chkCheckBox1.Invalidate();
  423. m_chkCheckBox2.Invalidate();
  424. m_wndRadio1.Invalidate();
  425. m_wndRadio2.Invalidate();
  426. break;
  427. case IDC_CHECK_BOX_SHOW_FOCUS_RECT:
  428. bChecked = IsDlgButtonChecked( nID );
  429. m_chkCheckBox1.SetDrawFocusRect( bChecked );
  430. m_chkCheckBox2.SetDrawFocusRect( bChecked );
  431. m_wndRadio1.SetDrawFocusRect( bChecked );
  432. m_wndRadio2.SetDrawFocusRect( bChecked );
  433. break;
  434. default:
  435. return CPageBase::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  436. }
  437. return TRUE;
  438. }
  439. return CPageBase::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  440. }
  441. //////////////////////////////////////////////////////////////////////////
  442. LRESULT CPageButtons::OnColorChangedFinally(WPARAM wParam, LPARAM lParam)
  443. {
  444. switch( lParam )
  445. {
  446. case IDC_BUTTON_COLOR1:
  447. case IDC_BUTTON_COLOR2:
  448. case ID_COLOR_CTRL_8X5:
  449. case ID_COLOR_CTRL_8X2:
  450. case ID_COLOR_CTRL_GRAYSCALE:
  451. case ID_COLOR_CTRL_HLS:
  452. {
  453. COLORREF clrColorCtrl = COLORREF(wParam);
  454. if( clrColorCtrl == COLORREF(-1) )
  455. AfxMessageBox(_T("Default Color"));
  456. else
  457. {
  458. CString sColor;
  459. sColor.Format(
  460. _T( "RGB color is 0x%02X%02X%02X" ),
  461. INT( GetRValue(clrColorCtrl) ),
  462. INT( GetGValue(clrColorCtrl) ),
  463. INT( GetBValue(clrColorCtrl) )
  464. );
  465. AfxMessageBox( sColor );
  466. }
  467. }
  468. break;
  469. default:
  470. break;
  471. } // switch( lParam )
  472. return 0;
  473. }
  474. //////////////////////////////////////////////////////////////////////////
  475. LRESULT CPageButtons::OnColorSelectCustom(WPARAM wParam, LPARAM lParam)
  476. {
  477. wParam;
  478. if( lParam == ID_COLOR_CTRL_8X5
  479. || lParam == ID_COLOR_CTRL_8X2
  480. || lParam == ID_COLOR_CTRL_GRAYSCALE
  481. || lParam == ID_COLOR_CTRL_HLS
  482. )
  483. {
  484. COLORREF clrNew;
  485. CExtColorDlg dlgColor;
  486. dlgColor.m_strSection = _T("ColorDialog");
  487. dlgColor.m_strEntryDialogPosition = _T("Position");
  488. dlgColor.m_strEntryColorModelSelection = _T("ColorModel");
  489. if( dlgColor.DoModal() != IDOK )
  490. return 0;
  491. clrNew = dlgColor.m_clrNew;
  492. OnColorChangedFinally( (WPARAM)clrNew, lParam );
  493. }
  494. return 0;
  495. }
  496. //////////////////////////////////////////////////////////////////////////
  497. LRESULT CPageButtons::OnDrawPopupLeftArea(WPARAM wParam, LPARAM lParam)
  498. {
  499. wParam;
  500. CExtPopupMenuWnd::DRAWLEFTAREADATA * pDrawLeftAreaData =
  501. reinterpret_cast < CExtPopupMenuWnd::DRAWLEFTAREADATA * > ( lParam );
  502. ASSERT( pDrawLeftAreaData != NULL );
  503. // get draw DC
  504. CDC & dc = *( (CDC *) *pDrawLeftAreaData );
  505. CRect rcItem = LPCRECT(*pDrawLeftAreaData);
  506. CExtPaintManager::stat_PaintGradientRect(
  507. dc,
  508. &rcItem,
  509. dc.GetNearestColor( RGB( 0, 0, 0 ) ),
  510. dc.GetNearestColor( RGB( 100, 100, 255 ) ),
  511. true
  512. );
  513. LOGFONT lf;
  514. ::memset(&lf,0,sizeof(LOGFONT));
  515. g_PaintManager->m_FontNormalVertX.GetLogFont( &lf );
  516. lf.lfHeight = -18;
  517. lf.lfWidth = 0;
  518. lf.lfWeight = 900;
  519. __EXT_MFC_STRCPY( lf.lfFaceName, LF_FACESIZE, _T("Times New Roman") );
  520. CFont font;
  521. VERIFY(
  522. font.CreateFontIndirect(&lf)
  523. );
  524. CFont * pOldFont = dc.SelectObject( &font );
  525. INT nOldBkMode = dc.SetBkMode( TRANSPARENT );
  526. COLORREF clrOldText = dc.SetTextColor( RGB( 0, 0, 0 ) );
  527. static CString sTitle( _T("Prof-UIS") );
  528. CPoint ptText( rcItem.left+4, rcItem.bottom-5 );
  529. dc.DrawState(
  530. ptText, rcItem.Size(), (LPCTSTR)sTitle,
  531. DSS_NORMAL,  TRUE, 0, (CBrush*)NULL
  532. );
  533. dc.SetTextColor( RGB( 255, 255, 255 ) );
  534. ptText.Offset( -1, -2 );
  535. dc.DrawState(
  536. ptText, rcItem.Size(), (LPCTSTR)sTitle,
  537. DSS_NORMAL,  TRUE, 0, (CBrush*)NULL
  538. );
  539. const int nIconMetric = 24;
  540. HICON hIcon = (HICON)
  541. ::LoadImage(
  542. ::AfxGetInstanceHandle(),
  543. MAKEINTRESOURCE(IDI_ICON_FOR_POPUP_MENU),
  544. IMAGE_ICON,
  545. nIconMetric,
  546. nIconMetric,
  547. 0
  548. );
  549. if( hIcon != NULL )
  550. {
  551. int nOffset = (rcItem.Width() - nIconMetric) / 2;
  552. VERIFY(
  553. ::DrawIconEx(
  554. dc.GetSafeHdc(),
  555. rcItem.left + nOffset,
  556. rcItem.top + nOffset,
  557. hIcon,
  558. nIconMetric,
  559. nIconMetric,
  560. 0,
  561. (HBRUSH)NULL,
  562. DI_NORMAL
  563. )
  564. );
  565. VERIFY( DestroyIcon( hIcon ) );
  566. }
  567. dc.SetBkMode( nOldBkMode );
  568. dc.SetTextColor( clrOldText );
  569. dc.SelectObject( pOldFont );
  570. return !0;
  571. }
  572. //////////////////////////////////////////////////////////////////////////
  573. LRESULT CPageButtons::OnDrawPopupMenuItem(WPARAM wParam, LPARAM lParam)
  574. {
  575. wParam;
  576. CExtPopupMenuWnd::DRAWITEMDATA * pDrawItemData =
  577. reinterpret_cast < CExtPopupMenuWnd::DRAWITEMDATA * > ( lParam );
  578. ASSERT( pDrawItemData != NULL );
  579. UINT nCmdID = pDrawItemData->GetCmdID();
  580. if( nCmdID != ID_OWNERDRAW_ITEM )
  581. return 0; // default painting
  582. // paint default menu item background
  583. pDrawItemData->PaintDefaultBk();
  584. // paint some staff in a little bit rect
  585. CRect rcItem = LPCRECT(*pDrawItemData);
  586. rcItem.DeflateRect( 10, 1, 10, 4 );
  587. LPCTSTR sItemText = __EXT_MFC_SAFE_LPCTSTR( *pDrawItemData );
  588. INT nItemTextLen = INT( _tcslen( sItemText ) );
  589. // get draw DC
  590. CDC & dc = *( (CDC *) *pDrawItemData );
  591. CExtWndShadow _shadow;
  592. _shadow.Paint(
  593. NULL,
  594. dc, rcItem, CRect(0,0,0,0), CRect(0,0,0,0),
  595. 3,
  596. CExtWndShadow::DEF_BRIGHTNESS_MIN,
  597. CExtWndShadow::DEF_BRIGHTNESS_MAX,
  598. false
  599. );
  600. CExtPaintManager::stat_PaintGradientRect(
  601. dc,
  602. &rcItem,
  603. dc.GetNearestColor( RGB( 255, 0, 0 ) ),
  604. dc.GetNearestColor( RGB( 0, 0, 255 ) ),
  605. false
  606. );
  607. INT nOldBkMode = dc.SetBkMode( TRANSPARENT );
  608. COLORREF clrOldText = dc.SetTextColor( RGB( 0, 0, 0 ) );
  609. CFont * pOldFont = dc.SelectObject( &g_PaintManager->m_FontBold );
  610. rcItem.OffsetRect( 2, 1 );
  611. dc.DrawText(
  612. sItemText, nItemTextLen, &rcItem, 
  613. DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_END_ELLIPSIS
  614. );
  615. clrOldText = dc.SetTextColor( RGB( 255, 255, 255 ) );
  616. rcItem.OffsetRect( -2, -1 );
  617. dc.DrawText(
  618. sItemText, nItemTextLen, &rcItem, 
  619. DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_END_ELLIPSIS
  620. );
  621. dc.SelectObject( pOldFont );
  622. dc.SetBkMode( nOldBkMode );
  623. dc.SetTextColor( clrOldText );
  624. return !0;
  625. }
  626. //////////////////////////////////////////////////////////////////////////
  627. LRESULT CPageButtons::OnExtMenuPrepare(WPARAM wParam, LPARAM lParam)
  628. {
  629. lParam;
  630. CExtPopupMenuWnd::MsgPrepareMenuData_t * pData =
  631. reinterpret_cast
  632. < CExtPopupMenuWnd::MsgPrepareMenuData_t * >
  633. ( wParam );
  634. ASSERT( pData != NULL );
  635. CExtPopupMenuWnd * pPopup = pData->m_pPopup;
  636. ASSERT( pPopup != NULL );
  637. INT nReplacePos =
  638. pPopup->ItemFindPosForCmdID( ID_COLOR_CTRL_8X5 );
  639. if( nReplacePos >= 0 )
  640. {
  641. CExtPopupColorMenuWnd * pColorPopup = new CExtPopupColorMenuWnd;
  642. pColorPopup->m_lParamCookie = LPARAM( ID_COLOR_CTRL_8X5 );
  643. pColorPopup->m_hWndNotifyColorChanged = GetSafeHwnd();
  644. pColorPopup->m_clrDefault = COLORREF(-1);
  645. VERIFY(
  646. pPopup->ItemInsertSpecPopup(
  647. pColorPopup,
  648. nReplacePos + 1,
  649. pPopup->ItemGetText(nReplacePos),
  650. pPopup->ItemGetIcon(nReplacePos)
  651. )
  652. );
  653. pPopup->ItemSetDisplayed( nReplacePos + 1, true );
  654. VERIFY( pPopup->ItemRemove(nReplacePos) );
  655. } // if( nReplacePos >= 0 )
  656. nReplacePos =
  657. pPopup->ItemFindPosForCmdID( ID_COLOR_CTRL_8X2 );
  658. if( nReplacePos >= 0 )
  659. {
  660. CExtPopupColorMenuWnd * pColorPopup = new CExtPopupColorMenuWnd;
  661. pColorPopup->m_lParamCookie = LPARAM( ID_COLOR_CTRL_8X2 );
  662. pColorPopup->m_hWndNotifyColorChanged = GetSafeHwnd();
  663. pColorPopup->m_clrDefault = COLORREF(-1);
  664. pColorPopup->SetColors8x2();
  665. VERIFY(
  666. pPopup->ItemInsertSpecPopup(
  667. pColorPopup,
  668. nReplacePos + 1,
  669. pPopup->ItemGetText(nReplacePos),
  670. pPopup->ItemGetIcon(nReplacePos)
  671. )
  672. );
  673. pPopup->ItemSetDisplayed( nReplacePos + 1, true );
  674. VERIFY( pPopup->ItemRemove(nReplacePos) );
  675. } // if( nReplacePos >= 0 )
  676. nReplacePos =
  677. pPopup->ItemFindPosForCmdID( ID_COLOR_CTRL_GRAYSCALE );
  678. if( nReplacePos >= 0 )
  679. {
  680. CExtPopupColorMenuWnd * pColorPopup = new CExtPopupColorMenuWnd;
  681. pColorPopup->m_lParamCookie = LPARAM( ID_COLOR_CTRL_GRAYSCALE );
  682. pColorPopup->m_hWndNotifyColorChanged = GetSafeHwnd();
  683. pColorPopup->m_clrDefault = COLORREF(-1);
  684. pColorPopup->RemoveAllColors();
  685. int nGrayColors = 16;
  686. pColorPopup->SetColorsInRow( nGrayColors );
  687. pColorPopup->m_sizeColorItemCell.cy *= 2;
  688. for( int nColorIndex = 0; nColorIndex < nGrayColors; nColorIndex++ )
  689. {
  690. double f = double( nColorIndex ) / double( nGrayColors - 1 );
  691. COLORREF clr = CExtBitmap::stat_HLStoRGB( 0.0, f, 0.0 );
  692. int n = GetRValue(clr);
  693. CExtSafeString str;
  694. str.Format(
  695. _T("#%02X%02X%02X"),
  696. n,
  697. n,
  698. n
  699. );
  700. pColorPopup->AddColor(
  701. new CExtPopupColorMenuWnd::COLORREF_TABLE_ENTRY(
  702. 0,
  703. clr,
  704. str
  705. )
  706. );
  707. }
  708. VERIFY(
  709. pPopup->ItemInsertSpecPopup(
  710. pColorPopup,
  711. nReplacePos + 1,
  712. pPopup->ItemGetText(nReplacePos),
  713. pPopup->ItemGetIcon(nReplacePos)
  714. )
  715. );
  716. pPopup->ItemSetDisplayed( nReplacePos + 1, true );
  717. VERIFY( pPopup->ItemRemove(nReplacePos) );
  718. } // if( nReplacePos >= 0 )
  719. nReplacePos =
  720. pPopup->ItemFindPosForCmdID( ID_COLOR_CTRL_HLS );
  721. if( nReplacePos >= 0 )
  722. {
  723. CExtPopupColorMenuWnd * pColorPopup = new CExtPopupColorMenuWnd;
  724. pColorPopup->m_lParamCookie = LPARAM( ID_COLOR_CTRL_HLS );
  725. pColorPopup->m_hWndNotifyColorChanged = GetSafeHwnd();
  726. pColorPopup->m_clrDefault = COLORREF(-1);
  727. pColorPopup->RemoveAllColors();
  728. int nStepsHue = 12;
  729. int nStepsSat = 8;
  730. pColorPopup->m_sizeColorItemCell.cx = 14;
  731. pColorPopup->m_sizeColorItemCell.cy = 12;
  732. pColorPopup->m_sizeColorItemSpaces.cx = 1;
  733. pColorPopup->m_sizeColorItemSpaces.cy = 1;
  734. pColorPopup->SetColorsInRow( nStepsHue );
  735. for( int nSat = 0; nSat < nStepsSat; nSat++ )
  736. {
  737. double fSat = 1.0 - double( nSat ) / double( nStepsSat );
  738. for( int nHue = 0; nHue < nStepsHue; nHue++ )
  739. {
  740. double fHue = double( nHue ) / double( nStepsHue );
  741. COLORREF clr = CExtBitmap::stat_HLStoRGB( fHue, 0.5, fSat );
  742. CExtSafeString str;
  743. str.Format(
  744. _T("#%02X%02X%02X"),
  745. GetRValue(clr),
  746. GetGValue(clr),
  747. GetBValue(clr)
  748. );
  749. pColorPopup->AddColor(
  750. new CExtPopupColorMenuWnd::COLORREF_TABLE_ENTRY(
  751. 0,
  752. clr,
  753. str
  754. )
  755. );
  756. }
  757. }
  758. VERIFY(
  759. pPopup->ItemInsertSpecPopup(
  760. pColorPopup,
  761. nReplacePos + 1,
  762. pPopup->ItemGetText(nReplacePos),
  763. pPopup->ItemGetIcon(nReplacePos)
  764. )
  765. );
  766. pPopup->ItemSetDisplayed( nReplacePos + 1, true );
  767. VERIFY( pPopup->ItemRemove(nReplacePos) );
  768. } // if( nReplacePos >= 0 )
  769. #if (!defined __EXT_MFC_NO_DATE_PICKER)
  770. nReplacePos =
  771. pPopup->ItemFindPosForCmdID(ID_DATE_PICKER_CTRL);
  772. if( nReplacePos >= 0 )
  773. {
  774. CExtPopupControlMenuWnd::g_bControlMenuWithShadows = true;
  775. CExtPopupDatePickerMenuWnd * pDatePickerPopup = new CExtPopupDatePickerMenuWnd;
  776. VERIFY(
  777. pPopup->ItemInsertSpecPopup(
  778. pDatePickerPopup,
  779. nReplacePos + 1,
  780. pPopup->ItemGetText(nReplacePos),
  781. pPopup->ItemGetIcon(nReplacePos)
  782. )
  783. );
  784. pPopup->ItemSetDisplayed( nReplacePos + 1, true );
  785. VERIFY( pPopup->ItemRemove(nReplacePos) );
  786. } // if( nReplacePos >= 0 )
  787. #endif // #if (!defined __EXT_MFC_NO_DATE_PICKER)
  788. nReplacePos = pPopup->ItemFindPosForCmdID( ID_PALETTE_MENU );
  789. if( nReplacePos >= 0 )
  790. {
  791. pPopup->ItemRemove( nReplacePos );
  792. CExtPopupMenuWnd * pPalettePopup = new CExtPopupMenuWnd;
  793. pPopup->ItemInsertSpecPopup(
  794. pPalettePopup,
  795. nReplacePos,
  796. g_CmdManager->CmdGetPtr(
  797. g_CmdManager->ProfileNameFromWnd( m_hWnd ),
  798. ID_PALETTE_MENU
  799. )->m_sMenuText
  800. );
  801. pPalettePopup->TrackFlagsSet(
  802. pPalettePopup->TrackFlagsGet()
  803. | TPMX_PALETTE
  804. );
  805. pPalettePopup->ItemInsertCommand(
  806. 1,
  807. -1,
  808. _T("Palette 6 x 2:")
  809. );
  810. INT nLastPos = pPalettePopup->ItemGetCount() - 1;
  811. pPalettePopup->ItemEnabledSet( nLastPos, false );
  812. pPalettePopup->ItemEnabledAppearanceSet( nLastPos );
  813. pPalettePopup->ItemBoldSet( nLastPos );
  814. pPalettePopup->ItemPaletteRowWrapSet( nLastPos );
  815. CExtBitmap _bmp;
  816. VERIFY( _bmp.LoadBMP_Resource( MAKEINTRESOURCE(IDB_PAINT_PALETTE) ) );
  817. INT nRow, nColumn;
  818. static const INT nRowCountPaint = 2, nColumnCountPaint = 6;
  819. static const COLORREF clrTransparentPaint = RGB(255,0,255);
  820. static const CSize _sizeBitmapPartPaint(16,16);
  821. for( nRow = 0; nRow < nRowCountPaint; nRow ++ )
  822. {
  823. for( nColumn = 0; nColumn < nColumnCountPaint; nColumn ++ )
  824. {
  825. CPoint ptBitmapOffset(
  826. nRow * nColumnCountPaint * _sizeBitmapPartPaint.cx
  827. + nColumn * _sizeBitmapPartPaint.cx,
  828. 0
  829. );
  830. CRect rcBitmapPart(
  831. ptBitmapOffset,
  832. _sizeBitmapPartPaint
  833. );
  834. CExtCmdIcon _icon;
  835. _icon.m_bmpNormal.FromBitmap(
  836. _bmp,
  837. &rcBitmapPart
  838. );
  839. ASSERT( ! _icon.IsEmpty() );
  840. _icon.m_bmpNormal.AlphaColor( clrTransparentPaint, RGB(0,0,0), 0 );
  841. pPalettePopup->ItemInsertCommand(
  842. 3 + nRow*nColumnCountPaint + nColumn,
  843. -1,
  844. NULL,
  845. NULL,
  846. _icon
  847. );
  848. if( nColumn == (nColumnCountPaint-1) )
  849. pPalettePopup->ItemPaletteRowWrapSet(
  850. pPalettePopup->ItemGetCount() - 1
  851. );
  852. } // for( nColumn = 0; nColumn < nColumnCountPaint; nColumn ++ )
  853. } // for( nRow = 0; nRow < nRowCountPaint; nRow ++ )
  854. pPalettePopup->ItemInsert();
  855. pPalettePopup->ItemInsertCommand(
  856. 2,
  857. -1,
  858. _T("Palette 6 x 7:")
  859. );
  860. nLastPos = pPalettePopup->ItemGetCount() - 1;
  861. pPalettePopup->ItemEnabledSet( nLastPos, false );
  862. pPalettePopup->ItemEnabledAppearanceSet( nLastPos );
  863. pPalettePopup->ItemBoldSet( nLastPos );
  864. pPalettePopup->ItemPaletteRowWrapSet( nLastPos );
  865. VERIFY( _bmp.LoadBMP_Resource( MAKEINTRESOURCE(IDB_EXT_CUSTOM_TB_IMAGES) ) );
  866. static const INT nRowCountCustom = 7, nColumnCountCustom = 6;
  867. static const COLORREF clrTransparentCustom = RGB(255,0,255);
  868. static const CSize _sizeBitmapPartCustom(16,16);
  869. for( nRow = 0; nRow < nRowCountCustom; nRow ++ )
  870. {
  871. for( nColumn = 0; nColumn < nColumnCountCustom; nColumn ++ )
  872. {
  873. CPoint ptBitmapOffset(
  874. nRow * nColumnCountCustom * _sizeBitmapPartCustom.cx
  875. + nColumn * _sizeBitmapPartCustom.cx,
  876. 0
  877. );
  878. CRect rcBitmapPart(
  879. ptBitmapOffset,
  880. _sizeBitmapPartCustom
  881. );
  882. CExtCmdIcon _icon;
  883. _icon.m_bmpNormal.FromBitmap(
  884. _bmp,
  885. &rcBitmapPart
  886. );
  887. ASSERT( ! _icon.IsEmpty() );
  888. _icon.m_bmpNormal.AlphaColor( clrTransparentCustom, RGB(0,0,0), 0 );
  889. pPalettePopup->ItemInsertCommand(
  890. 3 + nRow*nColumnCountCustom + nColumn,
  891. -1,
  892. NULL,
  893. NULL,
  894. _icon
  895. );
  896. if( nColumn == (nColumnCountCustom-1) )
  897. pPalettePopup->ItemPaletteRowWrapSet(
  898. pPalettePopup->ItemGetCount() - 1
  899. );
  900. } // for( nColumn = 0; nColumn < nColumnCountCustom; nColumn ++ )
  901. } // for( nRow = 0; nRow < nRowCountCustom; nRow ++ )
  902. } // if( nReplacePos >= 0 )
  903. return TRUE;
  904. }
  905. //////////////////////////////////////////////////////////////////////////
  906. void CPageButtons::OnSelendokSkin() 
  907. {
  908. int nCurSel = m_CheckBoxSkin.GetCurSel();
  909. int nBitmapResource = int( m_CheckBoxSkin.GetItemData( nCurSel ) );
  910. m_chkCheckBox2.m_nBitmapResource 
  911. = m_chkCheckBox1.m_nBitmapResource 
  912. = nBitmapResource;
  913. if( nBitmapResource == IDB_BOX_IMAGES_XP )
  914. {
  915. m_wndRadio1.m_nBitmapResource 
  916. = m_wndRadio2.m_nBitmapResource 
  917. = IDB_RADIO_BOX_IMAGES_XP;
  918. }
  919. else if( nBitmapResource == IDB_BOX_IMAGES_XP_CROSS )
  920. {
  921. m_wndRadio1.m_nBitmapResource 
  922. = m_wndRadio2.m_nBitmapResource 
  923. = IDB_RADIO_BOX_IMAGES_XP_CROSS;
  924. }
  925. else if( nBitmapResource == IDB_BOX_IMAGES_XP_BLUE )
  926. {
  927. m_wndRadio1.m_nBitmapResource 
  928. = m_wndRadio2.m_nBitmapResource 
  929. = IDB_RADIO_BOX_IMAGES_XP_BLUE;
  930. }
  931. else
  932. {
  933. m_wndRadio1.m_nBitmapResource 
  934. = m_wndRadio2.m_nBitmapResource 
  935. = m_chkCheckBox1.m_nBitmapResource
  936. = m_chkCheckBox2.m_nBitmapResource
  937. = 0;
  938. }
  939. m_chkCheckBox1.Invalidate();
  940. m_chkCheckBox2.Invalidate();
  941. m_wndRadio1.Invalidate();
  942. m_wndRadio2.Invalidate();
  943. }
  944. //////////////////////////////////////////////////////////////////////////
  945. void CPageButtons::OnSelendokCursor() 
  946. {
  947. int nCurSel = m_Cursor.GetCurSel();
  948. int nCursorType = int( m_Cursor.GetItemData( nCurSel ) );
  949. if( nCursorType == 0 )
  950. nCursorType = -1;
  951. m_btnPushButton.SetBtnCursor( nCursorType );
  952. }
  953. void CPageButtons::OnSelendokIconAlignmentHorz() 
  954. {
  955. INT nCurSel = m_wndIconAlignmentHorz.GetCurSel();
  956. DWORD dwStyle = DWORD( m_wndIconAlignmentHorz.GetItemData( nCurSel ) );
  957. INT nIconAlignment = m_btnPushButton.GetIconAlignment();
  958. ASSERT( nIconAlignment >= 0 );
  959. nIconAlignment &= ~CExtPaintManager::__ALIGN_HORIZ_MASK;
  960. nIconAlignment |= dwStyle;
  961. m_btnPushButton.SetIconAlignment( nIconAlignment );
  962. }
  963. void CPageButtons::OnSelendokIconAlignmentVert() 
  964. {
  965. INT nCurSel = m_wndIconAlignmentVert.GetCurSel();
  966. DWORD dwStyle = DWORD( m_wndIconAlignmentVert.GetItemData( nCurSel ) );
  967. INT nIconAlignment = m_btnPushButton.GetIconAlignment();
  968. ASSERT( nIconAlignment >= 0 );
  969. nIconAlignment &= ~CExtPaintManager::__ALIGN_VERT_MASK;
  970. nIconAlignment |= dwStyle;
  971. m_btnPushButton.SetIconAlignment( nIconAlignment );
  972. }
  973. void CPageButtons::OnSelendokTextAlignmentHorz() 
  974. {
  975. INT nCurSel = m_wndTextAlignmentHorz.GetCurSel();
  976. DWORD dwStyle = (DWORD)m_wndTextAlignmentHorz.GetItemData( nCurSel );
  977. INT nTextAlignment = m_btnPushButton.GetTextAlignment();
  978. ASSERT( nTextAlignment >= 0 );
  979. nTextAlignment &= ~CExtPaintManager::__ALIGN_HORIZ_MASK;
  980. nTextAlignment |= dwStyle;
  981. m_btnPushButton.SetTextAlignment( nTextAlignment );
  982. }
  983. void CPageButtons::OnSelendokTextAlignmentVert() 
  984. {
  985. INT nCurSel = m_wndTextAlignmentVert.GetCurSel();
  986. DWORD dwStyle = DWORD( m_wndTextAlignmentVert.GetItemData( nCurSel ) );
  987. INT nTextAlignment = m_btnPushButton.GetTextAlignment();
  988. ASSERT( nTextAlignment >= 0 );
  989. nTextAlignment &= ~CExtPaintManager::__ALIGN_VERT_MASK;
  990. nTextAlignment |= dwStyle;
  991. m_btnPushButton.SetTextAlignment( nTextAlignment );
  992. }
  993. void CPageButtons::OnTextMarginsReset() 
  994. {
  995. SetDlgItemInt( IDC_TEXT_MARGINS_TOP, 3 );
  996. SetDlgItemInt( IDC_TEXT_MARGINS_RIGHT, 3 );
  997. SetDlgItemInt( IDC_TEXT_MARGINS_LEFT, 3 );
  998. SetDlgItemInt( IDC_TEXT_MARGINS_BOTTOM, 3 );
  999. }
  1000. void CPageButtons::OnIconMarginsReset() 
  1001. {
  1002. SetDlgItemInt( IDC_ICON_MARGINS_TOP, 3 );
  1003. SetDlgItemInt( IDC_ICON_MARGINS_RIGHT, 3 );
  1004. SetDlgItemInt( IDC_ICON_MARGINS_LEFT, 3 );
  1005. SetDlgItemInt( IDC_ICON_MARGINS_BOTTOM, 3 );
  1006. }