PageLookAndBehaviour.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:13k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // PageLookAndBehaviour.cpp : implementation file
  2. //
  3. // This file is a part of the XTREME TOOLKIT PRO MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "ToolBox.h"
  22. #include "PageLookAndBehaviour.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. #if (_MSC_VER <= 1100)
  29. void DDX_Slider(CDataExchange* pDX, int nIDC, int& value)
  30. {
  31. HWND hWndCtrl = pDX->PrepareCtrl(nIDC);
  32. if (pDX->m_bSaveAndValidate)
  33. value = (int) ::SendMessage(hWndCtrl, TBM_GETPOS, 0, 0l);
  34. else
  35. ::SendMessage(hWndCtrl, TBM_SETPOS, TRUE, value);
  36. }
  37. #endif
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CPageLookAndBehaviour property page
  40. CPageLookAndBehaviour::CPageLookAndBehaviour() : CPropertyPage(CPageLookAndBehaviour::IDD)
  41. {
  42. //{{AFX_DATA_INIT(CPageLookAndBehaviour)
  43. m_bLargeIcons = FALSE;
  44. m_bDrawFocusRect = TRUE;
  45. m_bSelectOnFocus = TRUE;
  46. m_bToggleButtons = FALSE;
  47. m_nControlMargins = 0;
  48. m_nGroupInnerMargins = 50;
  49. m_nGroupOuterMargins = 0;
  50. m_nItemsMargins = 0;
  51. m_bDefaultMargins = TRUE;
  52. m_bAllowDrag = TRUE;
  53. m_bShowGroupIcons = FALSE;
  54. m_bSmallGroupIcons = FALSE;
  55. m_bEnableAnimation = FALSE;
  56. //}}AFX_DATA_INIT
  57. }
  58. CPageLookAndBehaviour::~CPageLookAndBehaviour()
  59. {
  60. }
  61. void CPageLookAndBehaviour::DoDataExchange(CDataExchange* pDX)
  62. {
  63. CPropertyPage::DoDataExchange(pDX);
  64. //{{AFX_DATA_MAP(CPageLookAndBehaviour)
  65. DDX_Control(pDX, IDC_COMBO_THEME, m_comboTheme);
  66. DDX_Control(pDX, IDC_COMBO_LAYOUT, m_comboLayout);
  67. DDX_Control(pDX, IDC_COMBO_HOTTRACK, m_comboHotTrack);
  68. DDX_Control(pDX, IDC_COMBO_BEHAVIOUR, m_comboBehaviour);
  69. DDX_Check(pDX, IDC_CHECK_LARGEICONS, m_bLargeIcons);
  70. DDX_Check(pDX, IDC_CHECK_DRAWFOCUSRECT, m_bDrawFocusRect);
  71. DDX_Check(pDX, IDC_CHECK_SELECTONFOCUS, m_bSelectOnFocus);
  72. DDX_Check(pDX, IDC_CHECK_TOGGLEBUTTONS, m_bToggleButtons);
  73. DDX_Slider(pDX, IDC_SLIDER_CONTROL, m_nControlMargins);
  74. DDX_Slider(pDX, IDC_SLIDER_GROUPINNER, m_nGroupInnerMargins);
  75. DDX_Slider(pDX, IDC_SLIDER_GROUPOUTER, m_nGroupOuterMargins);
  76. DDX_Slider(pDX, IDC_SLIDER_ITEMS, m_nItemsMargins);
  77. DDX_Check(pDX, IDC_CHECK_DEFAULTMARGINS, m_bDefaultMargins);
  78. DDX_Check(pDX, IDC_CHECK_ALLOWDRAG, m_bAllowDrag);
  79. DDX_Check(pDX, IDC_CHECK_SHOWGROUPICONS, m_bShowGroupIcons);
  80. DDX_Check(pDX, IDC_CHECK_SMALLGROUPICONS, m_bSmallGroupIcons);
  81. DDX_Check(pDX, IDC_CHECK_ANIMATION, m_bEnableAnimation);
  82. //}}AFX_DATA_MAP
  83. }
  84. BEGIN_MESSAGE_MAP(CPageLookAndBehaviour, CPropertyPage)
  85. //{{AFX_MSG_MAP(CPageLookAndBehaviour)
  86. ON_WM_CREATE()
  87. ON_CBN_SELCHANGE(IDC_COMBO_BEHAVIOUR, OnSelchangeComboBehaviour)
  88. ON_CBN_SELCHANGE(IDC_COMBO_THEME, OnSelchangeComboTheme)
  89. ON_CBN_SELCHANGE(IDC_COMBO_LAYOUT, OnSelchangeComboLayout)
  90. ON_CBN_SELCHANGE(IDC_COMBO_HOTTRACK, OnSelchangeComboHottrack)
  91. ON_BN_CLICKED(IDC_CHECK_LARGEICONS, OnCheckLargeicons)
  92. ON_BN_CLICKED(IDC_CHECK_DRAWFOCUSRECT, OnCheckDrawfocusrect)
  93. ON_BN_CLICKED(IDC_CHECK_SELECTONFOCUS, OnCheckSelectonfocus)
  94. ON_BN_CLICKED(IDC_CHECK_TOGGLEBUTTONS, OnCheckTogglebuttons)
  95. ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_CONTROL, OnReleasedcaptureSliderControl)
  96. ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_GROUPINNER, OnReleasedcaptureSliderGroupinner)
  97. ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_GROUPOUTER, OnReleasedcaptureSliderGroupouter)
  98. ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_ITEMS, OnReleasedcaptureSliderItems)
  99. ON_BN_CLICKED(IDC_CHECK_DEFAULTMARGINS, OnCheckDefaultmargins)
  100. ON_BN_CLICKED(IDC_CHECK_ALLOWDRAG, OnCheckAllowDrag)
  101. ON_BN_CLICKED(IDC_CHECK_ANIMATION, OnCheckAnimation)
  102. ON_BN_CLICKED(IDC_CHECK_SHOWGROUPICONS, OnCheckShowGroupIcons)
  103. ON_BN_CLICKED(IDC_CHECK_SMALLGROUPICONS, OnCheckSmallGroupIcons)
  104. //}}AFX_MSG_MAP
  105. END_MESSAGE_MAP()
  106. /////////////////////////////////////////////////////////////////////////////
  107. // CPageLookAndBehaviour message handlers
  108. int CPageLookAndBehaviour::OnCreate(LPCREATESTRUCT lpCreateStruct)
  109. {
  110. if (CPropertyPage::OnCreate(lpCreateStruct) == -1)
  111. return -1;
  112. return 0;
  113. }
  114. CXTPTaskPanel* CPageLookAndBehaviour::GetTaskPanel()
  115. {
  116. CWnd* pSplitterWnd = GetParentFrame()->GetDlgItem(AFX_IDW_PANE_FIRST);
  117. ASSERT_KINDOF(CSplitterWnd, pSplitterWnd);
  118. return (CXTPTaskPanel*)pSplitterWnd->GetDlgItem(AFX_IDW_PANE_FIRST);
  119. }
  120. BOOL CPageLookAndBehaviour::OnInitDialog()
  121. {
  122. CPropertyPage::OnInitDialog();
  123. m_comboLayout.AddString(_T("xtpTaskItemLayoutDefault"));
  124. m_comboLayout.AddString(_T("xtpTaskItemLayoutImages"));
  125. m_comboLayout.AddString(_T("xtpTaskItemLayoutImagesWithText"));
  126. m_comboLayout.AddString(_T("xtpTaskItemLayoutImagesWithTextBelow"));
  127. m_comboLayout.SetCurSel(0);
  128. m_comboHotTrack.AddString(_T("xtpTaskPanelHighlightDefault"));
  129. m_comboHotTrack.AddString(_T("xtpTaskPanelHighlightText"));
  130. m_comboHotTrack.AddString(_T("xtpTaskPanelHighlightImage"));
  131. m_comboHotTrack.AddString(_T("xtpTaskPanelHighlightItem"));
  132. m_comboHotTrack.AddString(_T("xtpTaskPanelHighlightNone"));
  133. m_comboHotTrack.SetCurSel(0);
  134. m_comboBehaviour.AddString(_T("xtpTaskPanelBehaviourExplorer"));
  135. m_comboBehaviour.AddString(_T("xtpTaskPanelBehaviourList"));
  136. m_comboBehaviour.AddString(_T("xtpTaskPanelBehaviourToolbox"));
  137. m_comboBehaviour.SetCurSel(2);
  138. m_comboTheme.AddString(_T("xtpTaskPanelThemeOffice2000"));
  139. m_comboTheme.AddString(_T("xtpTaskPanelThemeOffice2003"));
  140. m_comboTheme.AddString(_T("xtpTaskPanelThemeNativeWinXP"));
  141. m_comboTheme.AddString(_T("xtpTaskPanelThemeOffice2000Plain"));
  142. m_comboTheme.AddString(_T("xtpTaskPanelThemeOfficeXPPlain"));
  143. m_comboTheme.AddString(_T("xtpTaskPanelThemeOffice2003Plain"));
  144. m_comboTheme.AddString(_T("xtpTaskPanelThemeNativeWinXPPlain"));
  145. m_comboTheme.AddString(_T("xtpTaskPanelThemeToolbox"));
  146. m_comboTheme.AddString(_T("xtpTaskPanelThemeToolboxWhidbey"));
  147. m_comboTheme.AddString(_T("xtpTaskPanelThemeListView"));
  148. m_comboTheme.AddString(_T("xtpTaskPanelThemeListViewOfficeXP"));
  149. m_comboTheme.AddString(_T("xtpTaskPanelThemeListViewOffice2003"));
  150. m_comboTheme.AddString(_T("xtpTaskPanelThemeShortcutBarOffice2003"));
  151. m_comboTheme.AddString(_T("xtpTaskPanelThemeShortcutBarOffice2007"));
  152. m_comboTheme.SetCurSel(7);
  153. GetDlgItem(IDC_CHECK_TOGGLEBUTTONS)->EnableWindow(FALSE);
  154. GetDlgItem(IDC_CHECK_SMALLGROUPICONS)->EnableWindow(FALSE);
  155. return TRUE;  // return TRUE unless you set the focus to a control
  156.               // EXCEPTION: OCX Property Pages should return FALSE
  157. }
  158. void CPageLookAndBehaviour::OnSelchangeComboBehaviour()
  159. {
  160. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  161. pTaskPanel->SetBehaviour((XTPTaskPanelBehaviour)m_comboBehaviour.GetCurSel());
  162. }
  163. void CPageLookAndBehaviour::OnSelchangeComboTheme()
  164. {
  165. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  166. XTPTaskPanelPaintTheme themeCurrent = (XTPTaskPanelPaintTheme) m_comboTheme.GetCurSel();
  167. pTaskPanel->SetTheme(themeCurrent);
  168. pTaskPanel->Reposition();
  169. OnThemeChanged();
  170. CXTPCommandBars* pCommandBars = ((CXTPFrameWnd*)AfxGetMainWnd())->GetCommandBars();
  171. CXTPPaintManager::SetTheme(
  172. themeCurrent == xtpTaskPanelThemeOffice2000? xtpThemeOffice2000:
  173. themeCurrent ==xtpTaskPanelThemeNativeWinXP? xtpThemeNativeWinXP:
  174. themeCurrent ==xtpTaskPanelThemeOffice2000Plain? xtpThemeOffice2000:
  175. themeCurrent ==xtpTaskPanelThemeOfficeXPPlain? xtpThemeOfficeXP:
  176. themeCurrent ==xtpTaskPanelThemeNativeWinXPPlain? xtpThemeNativeWinXP:
  177. themeCurrent ==xtpTaskPanelThemeToolbox? xtpThemeOfficeXP:
  178. themeCurrent ==xtpTaskPanelThemeToolboxWhidbey? xtpThemeOfficeXP:
  179. themeCurrent ==xtpTaskPanelThemeListView? xtpThemeOffice2000:
  180. themeCurrent ==xtpTaskPanelThemeListViewOfficeXP? xtpThemeOfficeXP:
  181. themeCurrent ==xtpTaskPanelThemeShortcutBarOffice2003? xtpThemeOffice2003:
  182. themeCurrent ==xtpTaskPanelThemeShortcutBarOffice2007? xtpThemeRibbon:
  183. xtpThemeOffice2003);
  184. pCommandBars->RedrawCommandBars();
  185. }
  186. void CPageLookAndBehaviour::OnSelchangeComboLayout()
  187. {
  188. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  189. pTaskPanel->SetItemLayout((XTPTaskPanelItemLayout)m_comboLayout.GetCurSel());
  190. }
  191. void CPageLookAndBehaviour::OnSelchangeComboHottrack()
  192. {
  193. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  194. pTaskPanel->SetHotTrackStyle((XTPTaskPanelHotTrackStyle)m_comboHotTrack.GetCurSel());
  195. }
  196. void CPageLookAndBehaviour::OnCheckLargeicons()
  197. {
  198. UpdateData();
  199. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  200. pTaskPanel->SetIconSize(m_bLargeIcons? CSize(32, 32): CSize(16, 16));
  201. }
  202. void CPageLookAndBehaviour::OnCheckDrawfocusrect()
  203. {
  204. UpdateData();
  205. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  206. pTaskPanel->DrawFocusRect(m_bDrawFocusRect);
  207. }
  208. void CPageLookAndBehaviour::OnCheckSelectonfocus()
  209. {
  210. UpdateData();
  211. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  212. pTaskPanel->SetSelectItemOnFocus(m_bSelectOnFocus);
  213. if (m_bSelectOnFocus)
  214. {
  215. m_bToggleButtons = FALSE;
  216. UpdateData(FALSE);
  217. }
  218. GetDlgItem(IDC_CHECK_TOGGLEBUTTONS)->EnableWindow(!m_bSelectOnFocus);
  219. }
  220. void CPageLookAndBehaviour::OnCheckTogglebuttons()
  221. {
  222. UpdateData();
  223. }
  224. void CPageLookAndBehaviour::OnReleasedcaptureSliderControl(NMHDR* /*pNMHDR*/, LRESULT* pResult)
  225. {
  226. UpdateData();
  227. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  228. int nMargin = 0 + m_nControlMargins * 12 / 100;
  229. int nGroupSpacing = 0 + m_nControlMargins * 15 / 100;
  230. pTaskPanel->SetMargins(nMargin, nMargin, nMargin, nMargin, nGroupSpacing);
  231. m_bDefaultMargins = FALSE;
  232. UpdateData(FALSE);
  233. *pResult = 0;
  234. }
  235. void CPageLookAndBehaviour::OnReleasedcaptureSliderGroupinner(NMHDR* /*pNMHDR*/, LRESULT* pResult)
  236. {
  237. UpdateData();
  238. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  239. int nMargin = 0 + m_nGroupInnerMargins * 20 / 100;
  240. pTaskPanel->GetPaintManager()->m_rcGroupInnerMargins.SetRect(nMargin, nMargin, nMargin, nMargin);
  241. pTaskPanel->Reposition();
  242. m_bDefaultMargins = FALSE;
  243. UpdateData(FALSE);
  244. *pResult = 0;
  245. }
  246. void CPageLookAndBehaviour::OnReleasedcaptureSliderGroupouter(NMHDR* /*pNMHDR*/, LRESULT* pResult)
  247. {
  248. UpdateData();
  249. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  250. int nMargin = 0 + m_nGroupOuterMargins * 13 / 100;
  251. pTaskPanel->GetPaintManager()->m_rcGroupOuterMargins.SetRect(nMargin, nMargin, nMargin, nMargin);
  252. pTaskPanel->Reposition();
  253. m_bDefaultMargins = FALSE;
  254. UpdateData(FALSE);
  255. *pResult = 0;
  256. }
  257. void CPageLookAndBehaviour::OnReleasedcaptureSliderItems(NMHDR* /*pNMHDR*/, LRESULT* pResult)
  258. {
  259. UpdateData();
  260. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  261. int nMargin = 3 + m_nItemsMargins * 15 / 100;
  262. pTaskPanel->GetPaintManager()->m_rcItemOuterMargins.SetRect(nMargin, nMargin, nMargin, nMargin);
  263. pTaskPanel->Reposition();
  264. m_bDefaultMargins = FALSE;
  265. UpdateData(FALSE);
  266. *pResult = 0;
  267. }
  268. void CPageLookAndBehaviour::OnThemeChanged()
  269. {
  270. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  271. m_nGroupInnerMargins = 50;
  272. m_nGroupOuterMargins = 0;
  273. m_nItemsMargins = 0;
  274. m_nControlMargins = pTaskPanel->GetPaintManager()->GetControlMargins(pTaskPanel).left * 100 / 12;
  275. UpdateData(FALSE);
  276. }
  277. void CPageLookAndBehaviour::OnCheckDefaultmargins()
  278. {
  279. UpdateData();
  280. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  281. pTaskPanel->SetTheme((XTPTaskPanelPaintTheme)m_comboTheme.GetCurSel());
  282. pTaskPanel->SetMargins(CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT);
  283. pTaskPanel->Reposition();
  284. OnThemeChanged();
  285. m_nControlMargins = pTaskPanel->GetPaintManager()->m_rcControlMargins.left * 100 / 12;
  286. UpdateData(FALSE);
  287. }
  288. void CPageLookAndBehaviour::OnCheckAnimation()
  289. {
  290. UpdateData();
  291. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  292. pTaskPanel->EnableAnimation(m_bEnableAnimation);
  293. }
  294. void CPageLookAndBehaviour::OnCheckAllowDrag()
  295. {
  296. UpdateData();
  297. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  298. pTaskPanel->AllowDrag(m_bAllowDrag);
  299. }
  300. void CPageLookAndBehaviour::OnCheckShowGroupIcons() 
  301. {
  302. UpdateData();
  303. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  304. if (m_bShowGroupIcons)
  305. {
  306. pTaskPanel->GetImageManager()->SetIcon(IDR_MAINFRAME, IDR_MAINFRAME);
  307. }
  308. else
  309. {
  310. pTaskPanel->GetImageManager()->RemoveIcon(IDR_MAINFRAME);
  311. }
  312. pTaskPanel->Reposition();
  313. GetDlgItem(IDC_CHECK_SMALLGROUPICONS)->EnableWindow(m_bShowGroupIcons);
  314. }
  315. void CPageLookAndBehaviour::OnCheckSmallGroupIcons() 
  316. {
  317. UpdateData();
  318. CXTPTaskPanel* pTaskPanel = GetTaskPanel();
  319. pTaskPanel->SetGroupIconSize(m_bSmallGroupIcons? CSize(16, 16): CSize(32, 32));
  320. }