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

对话框与窗口

开发平台:

Visual C++

  1. // XTPCustomizeOptionsPage.cpp : implementation of the CXTPCustomizeOptionsPage class.
  2. //
  3. // This file is a part of the XTREME COMMANDBARS 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 "Resource.h"
  22. #include "Common/XTPResourceManager.h"
  23. #include "Common/XTPDrawHelpers.h"
  24. #include "XTPCustomizeOptionsPage.h"
  25. #include "XTPCustomizeSheet.h"
  26. #include "XTPToolBar.h"
  27. #include "XTPCommandBars.h"
  28. #ifdef _DEBUG
  29. #define new DEBUG_NEW
  30. #undef THIS_FILE
  31. static char THIS_FILE[] = __FILE__;
  32. #endif
  33. //////////////////////////////////////////////////////////////////////////
  34. // CXTPGroupLine
  35. CXTPGroupLine::CXTPGroupLine()
  36. {
  37. m_themeButton.OpenThemeData(0, L"BUTTON");
  38. }
  39. BEGIN_MESSAGE_MAP(CXTPGroupLine, CStatic)
  40. ON_WM_PAINT()
  41. END_MESSAGE_MAP()
  42. void CXTPGroupLine::OnPaint()
  43. {
  44. CPaintDC dc(this); // device context for painting
  45. COLORREF clrText = GetSysColor(COLOR_BTNTEXT);
  46. if (m_themeButton.IsAppThemeReady() &&
  47. FAILED(m_themeButton.GetThemeColor(BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &clrText)))
  48. {
  49. clrText = GetSysColor(COLOR_BTNTEXT);
  50. }
  51. BOOL bRightToLeft = GetExStyle() & WS_EX_RTLREADING;
  52. CString strText;
  53. GetWindowText(strText);
  54. CXTPClientRect rc(this);
  55. CXTPFontDC font(&dc, GetFont());
  56. dc.SetBkMode(TRANSPARENT);
  57. dc.SetTextColor(clrText);
  58. dc.DrawText(strText, rc, DT_SINGLELINE | DT_VCENTER |
  59. (bRightToLeft ? DT_RIGHT | DT_RTLREADING: DT_LEFT));
  60. CRect rcLine(0, rc.top, 0, rc.bottom);
  61. dc.DrawText(strText, rcLine, DT_SINGLELINE | DT_VCENTER | DT_CALCRECT);
  62. if (bRightToLeft)
  63. rcLine.SetRect(rc.left, rc.top, rc.right -  + rcLine.Width() - 6, rc.bottom);
  64. else
  65. rcLine.SetRect(rc.left + rcLine.Width() + 6, rc.top, rc.right, rc.bottom);
  66. COLORREF clrLine = GetSysColor(COLOR_3DSHADOW);
  67. if (m_themeButton.IsAppThemeReady() &&
  68. SUCCEEDED(m_themeButton.GetThemeColor(BP_GROUPBOX, GBS_NORMAL, TMT_BORDERCOLORHINT, &clrLine)))
  69. {
  70. dc.FillSolidRect(rcLine.left, rcLine.CenterPoint().y, rcLine.Width(), 1, clrLine);
  71. }
  72. else
  73. {
  74. dc.FillSolidRect(rcLine.left, rcLine.CenterPoint().y, rcLine.Width(), 1, GetSysColor(COLOR_3DSHADOW));
  75. dc.FillSolidRect(rcLine.left, rcLine.CenterPoint().y + 1, rcLine.Width(), 1, GetSysColor(COLOR_3DHIGHLIGHT));
  76. }
  77. }
  78. /////////////////////////////////////////////////////////////////////////////
  79. // CXTPCustomizeOptionsPage property page
  80. CXTPCustomizeOptionsPage::CXTPCustomizeOptionsPage(CXTPCustomizeSheet* pSheet) : CPropertyPage(CXTPCustomizeOptionsPage::IDD)
  81. {
  82. CXTPCommandBars* pCommandBars = pSheet->GetCommandBars();
  83. CXTPCommandBarsOptions* pOptions = pCommandBars->GetCommandBarsOptions();
  84. m_bAlwaysShowFullMenus = pOptions->bAlwaysShowFullMenus;
  85. m_bShowFullAfterDelay = pOptions->bShowFullAfterDelay;
  86. m_bLargeIcons = pOptions->bLargeIcons;
  87. m_bToolBarScreenTips = pOptions->bToolBarScreenTips;
  88. m_bToolBarAccelTips = pOptions->bToolBarAccelTips;
  89. m_nAnimationType = pOptions->animationType;
  90. //{{AFX_DATA_INIT(CXTPCustomizeOptionsPage)
  91. //}}AFX_DATA_INIT
  92. m_pSheet = pSheet;
  93. //RevertResourceContext();
  94. }
  95. CXTPCustomizeOptionsPage::~CXTPCustomizeOptionsPage()
  96. {
  97. }
  98. CXTPCommandBars* CXTPCustomizeOptionsPage::GetCommandBars() const
  99. {
  100. ASSERT(m_pSheet && m_pSheet->GetCommandBars());
  101. return m_pSheet ? m_pSheet->GetCommandBars() : NULL;
  102. }
  103. void CXTPCustomizeOptionsPage::DoDataExchange(CDataExchange* pDX)
  104. {
  105. CPropertyPage::DoDataExchange(pDX);
  106. DDX_Control(pDX, XTP_IDC_COMBO_ANIMATION, m_comboAnimationType);
  107. DDX_CBIndex(pDX, XTP_IDC_COMBO_ANIMATION, m_nAnimationType);
  108. //{{AFX_DATA_MAP(CXTPCustomizeOptionsPage)
  109. DDX_Check(pDX, XTP_IDC_CHECK_FULL_MENUS, m_bAlwaysShowFullMenus);
  110. DDX_Check(pDX, XTP_IDC_CHECK_AFTERDELAY, m_bShowFullAfterDelay);
  111. DDX_Check(pDX, XTP_IDC_CHECK_LARGEICONS, m_bLargeIcons);
  112. DDX_Check(pDX, XTP_IDC_CHECK_SCREENTTIPS, m_bToolBarScreenTips);
  113. DDX_Check(pDX, XTP_IDC_CHECK_SHORTCUTS, m_bToolBarAccelTips);
  114. //}}AFX_DATA_MAP
  115. }
  116. BEGIN_MESSAGE_MAP(CXTPCustomizeOptionsPage, CPropertyPage)
  117. //{{AFX_MSG_MAP(CXTPCustomizeOptionsPage)
  118. ON_BN_CLICKED(XTP_IDC_CHECK_FULL_MENUS, OnCheckFullMenus)
  119. ON_BN_CLICKED(XTP_IDC_CHECK_AFTERDELAY, OnCheckAfterdelay)
  120. ON_BN_CLICKED(XTP_IDC_CHECK_LARGEICONS, OnCheckLargeicons)
  121. ON_BN_CLICKED(XTP_IDC_CHECK_SCREENTTIPS, OnCheckScreenttips)
  122. ON_BN_CLICKED(XTP_IDC_CHECK_SHORTCUTS, OnCheckShortcuts)
  123. ON_BN_CLICKED(XTP_IDC_BUTTON_RESETDATA, OnResetData)
  124. ON_CBN_SELCHANGE(XTP_IDC_COMBO_ANIMATION, OnAnimationChanged)
  125. //}}AFX_MSG_MAP
  126. END_MESSAGE_MAP()
  127. /////////////////////////////////////////////////////////////////////////////
  128. // CXTPCustomizeOptionsPage message handlers
  129. void CXTPCustomizeOptionsPage::AddComboString(UINT nIDResource)
  130. {
  131. CString str;
  132. XTPResourceManager()->LoadString(&str, nIDResource);
  133. m_comboAnimationType.AddString(str);
  134. }
  135. BOOL CXTPCustomizeOptionsPage::OnInitDialog()
  136. {
  137. CPropertyPage::OnInitDialog();
  138. GetDlgItem(XTP_IDC_CHECK_AFTERDELAY)->EnableWindow(!m_bAlwaysShowFullMenus);
  139. GetDlgItem(XTP_IDC_CHECK_SHORTCUTS)->EnableWindow(m_bToolBarScreenTips);
  140. if (GetDlgItem(XTP_IDC_GROUP_PERSONALIZED))
  141. m_wndPersonalizedGroup.SubclassDlgItem(XTP_IDC_GROUP_PERSONALIZED, this);
  142. if (GetDlgItem(XTP_IDC_GROUP_OTHER))
  143. m_wndOtherGroup.SubclassDlgItem(XTP_IDC_GROUP_OTHER, this);
  144. // Add strings to animation combo box.
  145. AddComboString(XTP_IDS_ANIMATION_SYSDEF);
  146. AddComboString(XTP_IDS_ANIMATION_RANDOM);
  147. AddComboString(XTP_IDS_ANIMATION_UNFOLD);
  148. AddComboString(XTP_IDS_ANIMATION_SLIDE);
  149. AddComboString(XTP_IDS_ANIMATION_FADE);
  150. AddComboString(XTP_IDS_ANIMATION_NONE);
  151. // Ensure combo selection is made.
  152. UpdateData(FALSE);
  153. return TRUE;
  154. }
  155. void CXTPCustomizeOptionsPage::OnCheckFullMenus()
  156. {
  157. UpdateData();
  158. GetDlgItem(XTP_IDC_CHECK_AFTERDELAY)->EnableWindow(!m_bAlwaysShowFullMenus);
  159. GetCommandBars()->GetCommandBarsOptions()->bAlwaysShowFullMenus = m_bAlwaysShowFullMenus;
  160. }
  161. void CXTPCustomizeOptionsPage::OnAnimationChanged()
  162. {
  163. UpdateData();
  164. if (m_nAnimationType != CB_ERR)
  165. {
  166. GetCommandBars()->GetCommandBarsOptions()->animationType = (XTPAnimationType)m_nAnimationType;
  167. }
  168. }
  169. void CXTPCustomizeOptionsPage::OnCheckAfterdelay()
  170. {
  171. UpdateData();
  172. GetCommandBars()->GetCommandBarsOptions()->bShowFullAfterDelay = m_bShowFullAfterDelay;
  173. }
  174. void CXTPCustomizeOptionsPage::OnCheckLargeicons()
  175. {
  176. UpdateData();
  177. CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars();
  178. pCommandBars->GetCommandBarsOptions()->bLargeIcons = m_bLargeIcons;
  179. pCommandBars->RedrawCommandBars();
  180. }
  181. void CXTPCustomizeOptionsPage::OnCheckScreenttips()
  182. {
  183. UpdateData();
  184. GetDlgItem(XTP_IDC_CHECK_SHORTCUTS)->EnableWindow(m_bToolBarScreenTips);
  185. GetCommandBars()->GetCommandBarsOptions()->bToolBarScreenTips = m_bToolBarScreenTips;
  186. }
  187. void CXTPCustomizeOptionsPage::OnCheckShortcuts()
  188. {
  189. UpdateData();
  190. GetCommandBars()->GetCommandBarsOptions()->bToolBarAccelTips = m_bToolBarAccelTips;
  191. }
  192. void CXTPCustomizeOptionsPage::OnResetData()
  193. {
  194. CString strPrompt;
  195. VERIFY(XTPResourceManager()->LoadString(&strPrompt, XTP_IDS_CONFIRM_RESETDATA));
  196. if (m_pSheet->MessageBox(strPrompt, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) == IDYES)
  197. {
  198. GetCommandBars()->ResetUsageData();
  199. }
  200. }