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

对话框与窗口

开发平台:

Visual C++

  1. // PropertiesView.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 "TabbedView.h"
  22. #include "PropertiesView.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CPropertiesView
  30. IMPLEMENT_DYNCREATE(CPropertiesView, CFormView)
  31. CPropertiesView::CPropertiesView()
  32. : CFormView(CPropertiesView::IDD)
  33. {
  34. //{{AFX_DATA_INIT(CPropertiesView)
  35. // NOTE: the ClassWizard will add member initialization here
  36. //}}AFX_DATA_INIT
  37. m_nAppearance = -1;
  38. m_nColor = -1;
  39. m_nLayout = -1;
  40. m_nPosition = -1;
  41. m_bLunaColors = FALSE;
  42. m_bOneNoteColors = FALSE;
  43. }
  44. CPropertiesView::~CPropertiesView()
  45. {
  46. }
  47. void CPropertiesView::DoDataExchange(CDataExchange* pDX)
  48. {
  49. CFormView::DoDataExchange(pDX);
  50. //{{AFX_DATA_MAP(CPropertiesView)
  51. // NOTE: the ClassWizard will add DDX and DDV calls here
  52. //}}AFX_DATA_MAP
  53. DDX_Control(pDX, IDC_COMBO_APPEARANCE, m_comboAppearance);
  54. DDX_Control(pDX, IDC_COMBO_POSITION, m_comboPosition);
  55. DDX_Control(pDX, IDC_COMBO_COLOR, m_comboColor);
  56. DDX_CBIndex(pDX, IDC_COMBO_APPEARANCE, m_nAppearance);
  57. DDX_CBIndex(pDX, IDC_COMBO_COLOR, m_nColor);
  58. DDX_CBIndex(pDX, IDC_COMBO_LAYOUT, m_nLayout);
  59. DDX_CBIndex(pDX, IDC_COMBO_POSITION, m_nPosition);
  60. DDX_Check(pDX, IDC_CHECK_LUNA_COLORS, m_bLunaColors);
  61. DDX_Check(pDX, IDC_CHECK_ONENOTE_COLORS, m_bOneNoteColors);
  62. }
  63. BEGIN_MESSAGE_MAP(CPropertiesView, CFormView)
  64. //{{AFX_MSG_MAP(CPropertiesView)
  65. // NOTE - the ClassWizard will add and remove mapping macros here.
  66. //}}AFX_MSG_MAP
  67. ON_CBN_SELCHANGE(IDC_COMBO_COLOR, OnSelchangeComboColor)
  68. ON_CBN_SELCHANGE(IDC_COMBO_POSITION, OnSelchangeComboPosition)
  69. ON_CBN_SELCHANGE(IDC_COMBO_APPEARANCE, OnSelchangeComboAppearance)
  70. ON_BN_CLICKED(IDC_CHECK_LUNA_COLORS, OnCheckLunaColors)
  71. ON_BN_CLICKED(IDC_CHECK_ONENOTE_COLORS, OnCheckOnenoteColors)
  72. ON_CBN_SELCHANGE(IDC_COMBO_LAYOUT, OnSelchangeComboLayout)
  73. END_MESSAGE_MAP()
  74. /////////////////////////////////////////////////////////////////////////////
  75. // CPropertiesView diagnostics
  76. #ifdef _DEBUG
  77. void CPropertiesView::AssertValid() const
  78. {
  79. CFormView::AssertValid();
  80. }
  81. void CPropertiesView::Dump(CDumpContext& dc) const
  82. {
  83. CFormView::Dump(dc);
  84. }
  85. #endif //_DEBUG
  86. /////////////////////////////////////////////////////////////////////////////
  87. // CPropertiesView message handlers
  88. void CPropertiesView::OnInitialUpdate()
  89. {
  90. CFormView::OnInitialUpdate();
  91. SetScrollSizes(MM_TEXT, CSize(0)); // Disable Scroll Bars;
  92. Update();
  93. m_comboPosition.SetItemData(0, xtpTabPositionTop);
  94. m_comboPosition.SetItemData(1, xtpTabPositionLeft);
  95. m_comboPosition.SetItemData(2, xtpTabPositionBottom);
  96. m_comboPosition.SetItemData(3, xtpTabPositionRight);
  97. }
  98. CXTPTabPaintManager* CPropertiesView::GetPaintManager()
  99. {
  100. return ((CXTPTabControl*)GetParent())->GetPaintManager();
  101. }
  102. void CPropertiesView::Reposition()
  103. {
  104. ((CXTPTabControl*)GetParent())->Reposition();
  105. }
  106. void CPropertiesView::OnSelchangeComboColor()
  107. {
  108. UpdateData();
  109. XTPTabColorStyle color = (XTPTabColorStyle)m_comboColor.GetItemData(m_nColor);
  110. GetPaintManager()->SetColor(color);
  111. UpdateControls();
  112. Reposition();
  113. }
  114. void CPropertiesView::Update()
  115. {
  116. m_nAppearance = GetPaintManager()->GetAppearance();
  117. m_nColor = 1;
  118. m_nLayout = GetPaintManager()->GetLayout();
  119. m_nPosition = GetPaintManager()->GetPosition();
  120. m_bLunaColors = !GetPaintManager()->IsLunaColorsDisabled();
  121. m_bOneNoteColors = GetPaintManager()->m_bOneNoteColors;
  122. UpdateData(FALSE);
  123. UpdateControls();
  124. }
  125. void CPropertiesView::OnSelchangeComboPosition()
  126. {
  127. UpdateData();
  128. XTPTabPosition position = (XTPTabPosition)m_comboPosition.GetItemData(m_nPosition);
  129. GetPaintManager()->SetPosition(position);
  130. Reposition();
  131. }
  132. void CPropertiesView::OnSelchangeComboAppearance()
  133. {
  134. UpdateData();
  135. GetPaintManager()->SetAppearance((XTPTabAppearanceStyle)m_nAppearance);
  136. UpdateControls();
  137. Reposition();
  138. }
  139. void CPropertiesView::OnSelchangeComboLayout()
  140. {
  141. UpdateData();
  142. GetPaintManager()->SetLayout((XTPTabLayoutStyle)m_nLayout);
  143. Reposition();
  144. }
  145. void CPropertiesView::UpdateControls()
  146. {
  147. const struct
  148. {
  149. int nColorSet;
  150. LPCTSTR strColorSet;
  151. }
  152. colors[] =
  153. {
  154. xtpTabColorDefault, _T("xtpTabColorDefault"),
  155. xtpTabColorVisualStudio, _T("xtpTabColorVisualStudio"),
  156. xtpTabColorOffice2003, _T("xtpTabColorOffice2003"),
  157. xtpTabColorWinXP, _T("xtpTabColorWinXP")
  158. };
  159. int nSupported = GetPaintManager()->GetAppearanceSet()->GetSupportedColorSets();
  160. m_comboColor.ResetContent();
  161. for (int i = 0; i < 4; i++)
  162. {
  163. if (nSupported & colors[i].nColorSet)
  164. {
  165. int nItem = m_comboColor.AddString(colors[i].strColorSet);
  166. m_comboColor.SetItemData(nItem, colors[i].nColorSet);
  167. if (GetPaintManager()->GetColor() == colors[i].nColorSet)
  168. {
  169. m_nColor = nItem;
  170. m_comboColor.SetCurSel(nItem);
  171. }
  172. }
  173. }
  174. GetDlgItem(IDC_CHECK_LUNA_COLORS)->EnableWindow(m_comboColor.GetItemData(m_nColor) == xtpTabColorOffice2003);
  175. GetDlgItem(IDC_CHECK_ONENOTE_COLORS)->EnableWindow(m_comboColor.GetItemData(m_nColor) != xtpTabColorWinXP);
  176. }
  177. void CPropertiesView::OnCheckLunaColors()
  178. {
  179. UpdateData();
  180. GetPaintManager()->DisableLunaColors(!m_bLunaColors);
  181. Reposition();
  182. }
  183. void CPropertiesView::OnCheckOnenoteColors()
  184. {
  185. UpdateData();
  186. GetPaintManager()->SetOneNoteColors(m_bOneNoteColors);
  187. Reposition();
  188. }