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

对话框与窗口

开发平台:

Visual C++

  1. // AlphaIconsPage.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 "resource.h"
  22. #include "TabClientPage.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CTabManagerPage dialog
  30. CTabManagerPage::CTabManagerPage()
  31. : CPropertyPage(CTabManagerPage::IDD)
  32. {
  33. //{{AFX_DATA_INIT(CTabManagerPage)
  34. m_nAppearance = xtpTabAppearancePropertyPage2003;
  35. m_nColor = -1;
  36. m_nLayout = -1;
  37. m_nPosition = -1;
  38. m_bFillBackground = FALSE;
  39. m_bBoldSelected = TRUE;
  40. m_bLunaColors = TRUE;
  41. m_bOneNoteColors = TRUE;
  42. m_bHotTracking = FALSE;
  43. m_bShowIcons = FALSE;
  44. m_nArrows = -1;
  45. m_nClose = -1;
  46. m_bShowStaticFrame = FALSE;
  47. m_nClientFrame = -1;
  48. m_bAllowReorder = TRUE;
  49. m_bMultiRowFixedSelection = FALSE;
  50. m_bMultiRowJustified = FALSE;
  51. //}}AFX_DATA_INIT
  52. m_bShowIcons = TRUE;
  53. }
  54. void CTabManagerPage::DoDataExchange(CDataExchange* pDX)
  55. {
  56. CPropertyPage::DoDataExchange(pDX);
  57. //{{AFX_DATA_MAP(CTabManagerPage)
  58. DDX_Control(pDX, IDC_COMBO_APPEARANCE, m_comboAppearance);
  59. DDX_Control(pDX, IDC_COMBO_POSITION, m_comboPosition);
  60. DDX_Control(pDX, IDC_COMBO_COLOR, m_comboColor);
  61. DDX_CBIndex(pDX, IDC_COMBO_APPEARANCE, m_nAppearance);
  62. DDX_CBIndex(pDX, IDC_COMBO_COLOR, m_nColor);
  63. DDX_CBIndex(pDX, IDC_COMBO_LAYOUT, m_nLayout);
  64. DDX_CBIndex(pDX, IDC_COMBO_POSITION, m_nPosition);
  65. DDX_Check(pDX, IDC_CHECK_BOLD_SELECTED, m_bBoldSelected);
  66. DDX_Check(pDX, IDC_CHECK_LUNA_COLORS, m_bLunaColors);
  67. DDX_Check(pDX, IDC_CHECK_ONENOTE_COLORS, m_bOneNoteColors);
  68. DDX_Check(pDX, IDC_CHECK_HOTTRACKING, m_bHotTracking);
  69. DDX_Check(pDX, IDC_CHECK_ICONS, m_bShowIcons);
  70. DDX_Check(pDX, IDC_CHECK_ALLOW_REORDER, m_bAllowReorder);
  71. DDX_Check(pDX, IDC_CHECK_MULTIROWFIXEDSELECTION, m_bMultiRowFixedSelection);
  72. DDX_Check(pDX, IDC_CHECK_MULTIROWJUSTIFIED, m_bMultiRowJustified);
  73. DDX_Check(pDX, IDC_CHECK_FILLBACKGROUND, m_bFillBackground);
  74. //}}AFX_DATA_MAP
  75. }
  76. BEGIN_MESSAGE_MAP(CTabManagerPage, CPropertyPage)
  77. //{{AFX_MSG_MAP(CTabManagerPage)
  78. ON_CBN_SELCHANGE(IDC_COMBO_COLOR, OnSelchangeComboColor)
  79. ON_CBN_SELCHANGE(IDC_COMBO_POSITION, OnSelchangeComboPosition)
  80. ON_CBN_SELCHANGE(IDC_COMBO_APPEARANCE, OnSelchangeComboAppearance)
  81. ON_BN_CLICKED(IDC_CHECK_BOLD_SELECTED, OnCheckBoldSelected)
  82. ON_BN_CLICKED(IDC_CHECK_LUNA_COLORS, OnCheckLunaColors)
  83. ON_BN_CLICKED(IDC_CHECK_ONENOTE_COLORS, OnCheckOnenoteColors)
  84. ON_BN_CLICKED(IDC_CHECK_HOTTRACKING, OnCheckHottracking)
  85. ON_BN_CLICKED(IDC_CHECK_ICONS, OnCheckIcons)
  86. ON_CBN_SELCHANGE(IDC_COMBO_LAYOUT, OnSelchangeComboLayout)
  87. ON_CBN_SELCHANGE(IDC_COMBO_ARROWS, OnSelchangeComboArrows)
  88. ON_CBN_SELCHANGE(IDC_COMBO_CLOSE, OnSelchangeComboClose)
  89. ON_BN_CLICKED(IDC_CHECK_STATIC_FRAME, OnCheckStaticFrame)
  90. ON_CBN_SELCHANGE(IDC_COMBO_CLIENT_FRAME, OnSelchangeComboClientFrame)
  91. ON_BN_CLICKED(IDC_CHECK_MULTIROWFIXEDSELECTION, OnCheckFixedSelection)
  92. ON_BN_CLICKED(IDC_CHECK_ALLOW_REORDER, OnCheckAllowReorder)
  93. ON_BN_CLICKED(IDC_CHECK_MULTIROWJUSTIFIED, OnCheckJustified)
  94. ON_BN_CLICKED(IDC_CHECK_FILLBACKGROUND, OnCheckBackground)
  95. //}}AFX_MSG_MAP
  96. END_MESSAGE_MAP()
  97. /////////////////////////////////////////////////////////////////////////////
  98. // CTabManagerPage message handlers
  99. BOOL CTabManagerPage::OnInitDialog()
  100. {
  101. CPropertyPage::OnInitDialog();
  102. // Initialize OneNote style tabs.
  103. //GetPaintManager()->SetAppearance((XTPTabAppearanceStyle)m_nAppearance);
  104. //GetPaintManager()->DisableLunaColors(!m_bLunaColors);
  105. //GetPaintManager()->SetOneNoteColors(m_bOneNoteColors);
  106. Update();
  107. m_comboPosition.SetItemData(0, xtpTabPositionTop);
  108. m_comboPosition.SetItemData(1, xtpTabPositionLeft);
  109. m_comboPosition.SetItemData(2, xtpTabPositionBottom);
  110. m_comboPosition.SetItemData(3, xtpTabPositionRight);
  111. return TRUE;  // return TRUE  unless you set the focus to a control
  112. }
  113. void CTabManagerPage::Update()
  114. {
  115. m_nAppearance = GetPaintManager()->GetAppearance();
  116. m_nColor = 1;
  117. m_bFillBackground = GetPaintManager()->m_bFillBackground;
  118. m_nLayout = GetPaintManager()->GetLayout();
  119. m_nPosition = GetPaintManager()->GetPosition();
  120. m_bBoldSelected = GetPaintManager()->m_bBoldSelected;
  121. m_bLunaColors = !GetPaintManager()->IsLunaColorsDisabled();
  122. m_bOneNoteColors = GetPaintManager()->m_bOneNoteColors;
  123. m_bHotTracking = GetPaintManager()->m_bHotTracking;
  124. m_bShowStaticFrame = GetPaintManager()->m_bStaticFrame;
  125. CXTPTabManager* pManager = GetManager();
  126. if (pManager)
  127. {
  128. m_nArrows = pManager->FindNavigateButton(xtpTabNavigateButtonLeft)->GetFlags();
  129. m_nClose = pManager->FindNavigateButton(xtpTabNavigateButtonClose)->GetFlags();
  130. }
  131. m_nClientFrame = GetPaintManager()->m_clientFrame;
  132. m_bMultiRowFixedSelection = GetPaintManager()->m_bMultiRowFixedSelection;
  133. m_bMultiRowJustified = GetPaintManager()->m_bMultiRowJustified;
  134. UpdateData(FALSE);
  135. UpdateControls();
  136. }
  137. void CTabManagerPage::OnCancel()
  138. {
  139. }
  140. void CTabManagerPage::OnSelchangeComboColor()
  141. {
  142. UpdateData();
  143. XTPTabColorStyle color = (XTPTabColorStyle)m_comboColor.GetItemData(m_nColor);
  144. GetPaintManager()->SetColor(color);
  145. UpdateControls();
  146. Reposition();
  147. }
  148. void CTabManagerPage::OnSelchangeComboPosition()
  149. {
  150. UpdateData();
  151. XTPTabPosition position = (XTPTabPosition)m_comboPosition.GetItemData(m_nPosition);
  152. GetPaintManager()->SetPosition(position);
  153. Reposition();
  154. }
  155. void CTabManagerPage::OnSelchangeComboAppearance()
  156. {
  157. UpdateData();
  158. GetPaintManager()->SetAppearance((XTPTabAppearanceStyle)m_nAppearance);
  159. UpdateControls();
  160. Reposition();
  161. }
  162. void CTabManagerPage::OnSelchangeComboLayout()
  163. {
  164. UpdateData();
  165. GetPaintManager()->SetLayout((XTPTabLayoutStyle)m_nLayout);
  166. UpdateControls();
  167. Reposition();
  168. }
  169. void CTabManagerPage::OnSelchangeComboArrows()
  170. {
  171. UpdateData();
  172. CXTPTabManager* pManager = GetManager();
  173. if (pManager)
  174. {
  175. pManager->FindNavigateButton(xtpTabNavigateButtonLeft)->SetFlags((XTPTabNavigateButtonFlags)m_nArrows);
  176. pManager->FindNavigateButton(xtpTabNavigateButtonRight)->SetFlags((XTPTabNavigateButtonFlags)m_nArrows);
  177. }
  178. Reposition();
  179. }
  180. void CTabManagerPage::OnSelchangeComboClose()
  181. {
  182. UpdateData();
  183. CXTPTabManager* pManager = GetManager();
  184. if (pManager)
  185. {
  186. pManager->FindNavigateButton(xtpTabNavigateButtonClose)->SetFlags((XTPTabNavigateButtonFlags)m_nClose);
  187. }
  188. Reposition();
  189. }
  190. void CTabManagerPage::OnSelchangeComboClientFrame()
  191. {
  192. UpdateData();
  193. GetPaintManager()->m_clientFrame = (XTPTabClientFrame)m_nClientFrame;
  194. Reposition();
  195. }
  196. void CTabManagerPage::UpdateControls()
  197. {
  198. const struct
  199. {
  200. int nColorSet;
  201. LPCTSTR strColorSet;
  202. }
  203. colors[] =
  204. {
  205. xtpTabColorDefault, _T("xtpTabColorDefault"),
  206. xtpTabColorVisualStudio, _T("xtpTabColorVisualStudio"),
  207. xtpTabColorOffice2003, _T("xtpTabColorOffice2003"),
  208. xtpTabColorWinXP, _T("xtpTabColorWinXP"),
  209. xtpTabColorWhidbey, _T("xtpTabColorWhidbey")
  210. };
  211. int nSupported = GetPaintManager()->GetAppearanceSet()->GetSupportedColorSets();
  212. m_comboColor.ResetContent();
  213. for (int i = 0; i < 5; i++)
  214. {
  215. if (nSupported & colors[i].nColorSet)
  216. {
  217. int nItem = m_comboColor.AddString(colors[i].strColorSet);
  218. m_comboColor.SetItemData(nItem, colors[i].nColorSet);
  219. if (GetPaintManager()->GetColor() == colors[i].nColorSet)
  220. {
  221. m_nColor = nItem;
  222. m_comboColor.SetCurSel(nItem);
  223. }
  224. }
  225. }
  226. GetDlgItem(IDC_CHECK_LUNA_COLORS)->EnableWindow((m_comboColor.GetItemData(m_nColor) & (xtpTabColorOffice2003|xtpTabColorWhidbey)) != 0);
  227. GetDlgItem(IDC_CHECK_ONENOTE_COLORS)->EnableWindow(m_comboColor.GetItemData(m_nColor) != xtpTabColorWinXP);
  228. GetDlgItem(IDC_CHECK_MULTIROWFIXEDSELECTION)->EnableWindow(m_nLayout == xtpTabLayoutMultiRow);
  229. GetDlgItem(IDC_CHECK_MULTIROWJUSTIFIED)->EnableWindow(m_nLayout == xtpTabLayoutMultiRow);
  230. }
  231. void CTabManagerPage::OnCheckBoldSelected()
  232. {
  233. UpdateData();
  234. GetPaintManager()->m_bBoldSelected = m_bBoldSelected;
  235. Reposition();
  236. }
  237. void CTabManagerPage::OnCheckLunaColors()
  238. {
  239. UpdateData();
  240. GetPaintManager()->DisableLunaColors(!m_bLunaColors);
  241. Reposition();
  242. }
  243. void CTabManagerPage::OnCheckOnenoteColors()
  244. {
  245. UpdateData();
  246. GetPaintManager()->SetOneNoteColors(m_bOneNoteColors);
  247. Reposition();
  248. }
  249. void CTabManagerPage::OnCheckHottracking()
  250. {
  251. UpdateData();
  252. GetPaintManager()->m_bHotTracking = m_bHotTracking;
  253. Reposition();
  254. }
  255. void CTabManagerPage::OnCheckIcons()
  256. {
  257. UpdateData();
  258. GetPaintManager()->m_bShowIcons = m_bShowIcons;
  259. Reposition();
  260. }
  261. void CTabManagerPage::OnCheckStaticFrame()
  262. {
  263. UpdateData();
  264. GetPaintManager()->m_bStaticFrame = m_bShowStaticFrame;
  265. Reposition();
  266. }
  267. void CTabManagerPage::OnCheckAllowReorder()
  268. {
  269. UpdateData();
  270. if (GetManager())
  271. GetManager()->SetAllowReorder(m_bAllowReorder);
  272. }
  273. void CTabManagerPage::OnCheckFixedSelection() 
  274. {
  275. UpdateData();
  276. GetPaintManager()->m_bMultiRowFixedSelection = m_bMultiRowFixedSelection;
  277. Reposition();
  278. }
  279. void CTabManagerPage::OnCheckBackground()
  280. {
  281. UpdateData();
  282. GetPaintManager()->m_bFillBackground = m_bFillBackground;
  283. Reposition();
  284. }
  285. void CTabManagerPage::OnCheckJustified() 
  286. {
  287. UpdateData();
  288. GetPaintManager()->m_bMultiRowJustified = m_bMultiRowJustified;
  289. Reposition();
  290. }
  291. //////////////////////////////////////////////////////////////////////////
  292. // CTabControlPage
  293. CTabControlPage::CTabControlPage()
  294. {
  295. m_bShowIcons = FALSE;
  296. m_bAllowReorder = FALSE;
  297. }
  298. CXTPTabManager* CTabControlPage::GetManager()
  299. {
  300. CXTPMDIFrameWnd* pFrame = (CXTPMDIFrameWnd*)AfxGetMainWnd();
  301. CXTPCommandBars* pCommandBars = pFrame->GetCommandBars();
  302. CXTPTabToolBar* pToolBar = (CXTPTabToolBar*)pCommandBars->GetToolBar(IDR_MAINFRAME);
  303. return pToolBar;
  304. }