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

对话框与窗口

开发平台:

Visual C++

  1. // DialogPropertyPages.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 "commandbarsdesigner.h"
  22. #include "DialogPropertyPages.h"
  23. #include "EmbeddedFrame.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CDialogPropertyPages dialog
  31. LPCTSTR lpThemes[] = { _T("xtpThemeOffice2000"), _T("xtpThemeOfficeXP"), _T("xtpThemeOffice2003") , 
  32. _T("xtpThemeNativeWinXP"), _T("xtpThemeWhidbey"), _T("xtpThemeOffice2007"), _T("xtpThemeRibbon"), _T("xtpThemeVisualStudio2008") };
  33. CDialogPropertyPages::CDialogPropertyPages(CXTPCommandBars* pCommandBars, CWnd* pParent /*=NULL*/)
  34. : CDialog(CDialogPropertyPages::IDD, pParent)
  35. {
  36. m_pCommandBars = pCommandBars;
  37. //{{AFX_DATA_INIT(CDialogPropertyPages)
  38. // NOTE: the ClassWizard will add member initialization here
  39. //}}AFX_DATA_INIT
  40. CXTPCommandBarsOptions* pOptions = pCommandBars->GetCommandBarsOptions();
  41. m_AlwaysShowFullMenus = pOptions->bAlwaysShowFullMenus;
  42. m_bLargeIcons = pOptions->bLargeIcons;
  43. m_bShowFullAfterDelay = pOptions->bShowFullAfterDelay;
  44. m_bToolBarAccelTips = pOptions->bToolBarAccelTips;
  45. m_bToolBarScreenTips = pOptions->bToolBarScreenTips;
  46. m_szIcons = pOptions->szIcons;
  47. m_szLargeIcons = pOptions->szLargeIcons;
  48. m_szPopupIcons = pOptions->szPopupIcons;
  49. m_bShowExpandButtonAlways = pOptions->bShowExpandButtonAlways;
  50. m_bSyncFloatingBars = pOptions->bSyncFloatingBars;
  51. m_bDblClickFloat = pOptions->bDblClickFloat;
  52. m_bShowTextBelowIcons = pOptions->bShowTextBelowIcons;
  53. m_bAltDragCustomization = pOptions->bAltDragCustomization;
  54. m_bAutoHideUnusedPopups = pOptions->bAutoHideUnusedPopups;
  55. m_nAnimationType = pOptions->animationType;
  56. m_nKeyboardCuesShow = pOptions->GetShowKeyboardCues();
  57. m_nKeyboardCuesUse = pOptions->keyboardCuesUse;
  58. XTP_COMMANDBARS_ICONSINFO* pIconsInfo = pCommandBars->GetPaintManager()->GetIconsInfo();
  59. m_bIconsWithShadow = pIconsInfo->bIconsWithShadow;
  60. m_bUseDisabledIcons = pIconsInfo->bUseDisabledIcons;
  61. m_bUseFadedIcons = pIconsInfo->bUseFadedIcons;
  62. m_theme = ((CEmbeddedFrame*)pCommandBars->GetSite())->m_theme;
  63. m_bCustomizable = ((CEmbeddedFrame*)pCommandBars->GetSite())->m_bCustomizable;
  64. m_pSelected = NULL;
  65. }
  66. void CDialogPropertyPages::DoDataExchange(CDataExchange* pDX)
  67. {
  68. CDialog::DoDataExchange(pDX);
  69. //{{AFX_DATA_MAP(CDialogPropertyPages)
  70. // NOTE: the ClassWizard will add DDX and DDV calls here
  71. //}}AFX_DATA_MAP
  72. }
  73. BEGIN_MESSAGE_MAP(CDialogPropertyPages, CDialog)
  74. //{{AFX_MSG_MAP(CDialogPropertyPages)
  75. ON_NOTIFY(TVN_GETDISPINFO, IDC_LIST_OPTIONS, OnGetdispinfoListOptions)
  76. ON_NOTIFY(TVN_SELCHANGED, IDC_LIST_OPTIONS, OnSelchangedListOptions)
  77. ON_NOTIFY(TVN_ITEMEXPANDED, IDC_LIST_OPTIONS, OnExpandedListOptions)
  78. //}}AFX_MSG_MAP
  79. ON_MESSAGE(XTPWM_PROPERTYGRID_NOTIFY, OnGridNotify)
  80. END_MESSAGE_MAP()
  81. /////////////////////////////////////////////////////////////////////////////
  82. // CDialogPropertyPages message handlers
  83. BOOL CDialogPropertyPages::OnInitDialog()
  84. {
  85. CDialog::OnInitDialog();
  86. m_wndList.SubclassDlgItem(IDC_LIST_OPTIONS, this);
  87. GetDlgItem(IDC_WORKSPACE)->GetWindowRect(m_rcWorkspace);
  88. ScreenToClient(m_rcWorkspace);
  89. HTREEITEM hItem = m_wndList.InsertItem(_T("Configuration Properties"), I_IMAGECALLBACK , I_IMAGECALLBACK );
  90. HTREEITEM hItemGeneral = m_wndList.InsertItem(_T("General"), I_IMAGECALLBACK, I_IMAGECALLBACK, hItem);
  91. HTREEITEM hItemPaint = m_wndList.InsertItem(_T("Paint Manager"), I_IMAGECALLBACK, I_IMAGECALLBACK, hItem);
  92. CreateGridGeneral();
  93. CreateGridPaint();
  94. m_wndList.SetItemData(hItemGeneral, (DWORD_PTR)&m_wndGridGeneral);
  95. m_wndList.SetItemData(hItemPaint, (DWORD_PTR)&m_wndGridPaint);
  96. m_wndGridPaint.ShowWindow(SW_HIDE);
  97. m_wndList.Expand(hItem, TVE_EXPAND);
  98. m_wndList.SelectItem(hItemGeneral);
  99. m_pSelected = &m_wndGridGeneral;
  100. return TRUE;  // return TRUE unless you set the focus to a control
  101.               // EXCEPTION: OCX Property Pages should return FALSE
  102. }
  103. void CDialogPropertyPages::CreateGridGeneral()
  104. {
  105. m_wndGridGeneral.Create(m_rcWorkspace, this, 1000);
  106. m_wndGridGeneral.SetTheme(xtpGridThemeWhidbey);
  107. CXTPPropertyGridItem* pCategoryOptions = m_wndGridGeneral.AddCategory(_T("Options"));
  108. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemBool(_T("Customizable"), m_bCustomizable, &m_bCustomizable));
  109. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemBool(_T("Always Show Full Menus"), m_AlwaysShowFullMenus, &m_AlwaysShowFullMenus));
  110. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemBool(_T("Show Full Menus After Delay"), m_bShowFullAfterDelay, &m_bShowFullAfterDelay));
  111. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemBool(_T("Show ScreenTips on Toolbars"), m_bToolBarScreenTips, &m_bToolBarScreenTips));
  112. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemBool(_T("Show Shortcut Keys in ScreenTips"), m_bToolBarAccelTips, &m_bToolBarAccelTips));
  113. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemBool(_T("Show Expand Buttons Always"), m_bShowExpandButtonAlways, &m_bShowExpandButtonAlways));
  114. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemBool(_T("Large Icons"), m_bLargeIcons, &m_bLargeIcons));
  115. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemSize(_T("Icons Size"), m_szIcons, &m_szIcons));
  116. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemSize(_T("Large Icons Size"), m_szLargeIcons, &m_szLargeIcons));
  117. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemSize(_T("Popup Icons Size"), m_szPopupIcons, &m_szPopupIcons));
  118. CXTPPropertyGridItem* pItemAnimation = pCategoryOptions->AddChildItem(new CXTPPropertyGridItemEnum(_T("Menu Animation"), m_nAnimationType, (int*)&m_nAnimationType));
  119. pItemAnimation->GetConstraints()->AddConstraint(_T("xtpAnimateWindowsDefault"), xtpAnimateWindowsDefault);
  120. pItemAnimation->GetConstraints()->AddConstraint(_T("xtpAnimateRandom"), xtpAnimateRandom);
  121. pItemAnimation->GetConstraints()->AddConstraint(_T("xtpAnimateUnfold"), xtpAnimateUnfold);
  122. pItemAnimation->GetConstraints()->AddConstraint(_T("xtpAnimateSlide"), xtpAnimateSlide);
  123. pItemAnimation->GetConstraints()->AddConstraint(_T("xtpAnimateFade"), xtpAnimateFade);
  124. pItemAnimation->GetConstraints()->AddConstraint(_T("xtpAnimateNone"), xtpAnimateNone);
  125. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemBool(_T("Sync Floating Toolbars"), m_bSyncFloatingBars, &m_bSyncFloatingBars));
  126. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemBool(_T("Float Toolbars by DblClick "), m_bDblClickFloat, &m_bDblClickFloat));
  127. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemBool(_T("Show Text Below Icons"), m_bShowTextBelowIcons, &m_bShowTextBelowIcons));
  128. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemBool(_T("AltDrag Customization"), m_bAltDragCustomization, &m_bAltDragCustomization));
  129. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemBool(_T("Auto Hide Unused Popups"), m_bAutoHideUnusedPopups, &m_bAutoHideUnusedPopups));
  130. CXTPPropertyGridItem* pItemKeyboardCuesShow = pCategoryOptions->AddChildItem(new CXTPPropertyGridItemEnum(_T("Show Keyboard Cues"), m_nKeyboardCuesShow, (int*)&m_nKeyboardCuesShow));
  131. pItemKeyboardCuesShow->GetConstraints()->AddConstraint(_T("xtpKeyboardCuesShowAlways"), xtpKeyboardCuesShowAlways);
  132. pItemKeyboardCuesShow->GetConstraints()->AddConstraint(_T("xtpKeyboardCuesShowNever"), xtpKeyboardCuesShowNever);
  133. pItemKeyboardCuesShow->GetConstraints()->AddConstraint(_T("xtpKeyboardCuesShowWindowsDefault"), xtpKeyboardCuesShowWindowsDefault);
  134. CXTPPropertyGridItem* pItemKeyboardCuesUse = pCategoryOptions->AddChildItem(new CXTPPropertyGridItemEnum(_T("Use Keyboard Cues"), m_nKeyboardCuesUse, (int*)&m_nKeyboardCuesUse));
  135. pItemKeyboardCuesUse->GetConstraints()->AddConstraint(_T("xtpKeyboardCuesUseMenuOnly"), xtpKeyboardCuesUseMenuOnly);
  136. pItemKeyboardCuesUse->GetConstraints()->AddConstraint(_T("xtpKeyboardCuesUseAll"), xtpKeyboardCuesUseAll);
  137. pItemKeyboardCuesUse->GetConstraints()->AddConstraint(_T("xtpKeyboardCuesUseNone"), xtpKeyboardCuesUseNone);
  138. pCategoryOptions->Expand();
  139.   m_wndGridGeneral.SetWindowPos(&m_wndList, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_HIDEWINDOW);
  140. }
  141. void CDialogPropertyPages::CreateGridPaint()
  142. {
  143. m_wndGridPaint.Create(m_rcWorkspace, this, 1001);
  144. m_wndGridPaint.SetTheme(xtpGridThemeWhidbey);
  145. CXTPPropertyGridItem* pCategoryOptions = m_wndGridPaint.AddCategory(_T("Options"));
  146. CXTPPropertyGridItem* pItemTheme = pCategoryOptions->AddChildItem(new CXTPPropertyGridItemEnum(ID_GRID_ITEM_THEME, m_theme, (int*)&m_theme));
  147. CXTPPropertyGridItemConstraints* pConstrants = pItemTheme->GetConstraints();
  148. for (int i = 0; i < _countof(lpThemes); i++)
  149. pConstrants->AddConstraint(lpThemes[i], i);
  150. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemBool(ID_GRID_ITEM_ICONS_SHADOW, m_bIconsWithShadow, &m_bIconsWithShadow));
  151. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemBool(_T("Generate disabled icons"), m_bUseDisabledIcons, &m_bUseDisabledIcons));
  152. pCategoryOptions->AddChildItem(new CXTPPropertyGridItemBool(ID_GRID_ITEM_ICONS_FADED, m_bUseFadedIcons, &m_bUseFadedIcons));
  153. pCategoryOptions->Expand();
  154. m_wndGridPaint.SetWindowPos(&m_wndList, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_HIDEWINDOW);
  155. }
  156. void CDialogPropertyPages::OnGetdispinfoListOptions(NMHDR* pNMHDR, LRESULT* pResult)
  157. {
  158. TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
  159. if (pTVDispInfo->item.mask & (TVIF_SELECTEDIMAGE | TVIF_IMAGE))
  160. {
  161. //UINT nState = m_wndList.GetItemState(pTVDispInfo->item.hItem, TVIF_STATE);
  162. //pTVDispInfo->item.iSelectedImage = pTVDispInfo->item.iImage = nState & TVIS_EXPANDED? 3: 2;
  163. if (m_wndList.GetChildItem(pTVDispInfo->item.hItem) != NULL)
  164. {
  165. UINT nState = m_wndList.GetItemState(pTVDispInfo->item.hItem, TVIF_STATE);
  166. pTVDispInfo->item.iSelectedImage = pTVDispInfo->item.iImage = nState & TVIS_EXPANDED? 3: 2;
  167. }
  168. else
  169. {
  170. pTVDispInfo->item.iSelectedImage = pTVDispInfo->item.iImage =
  171. (m_pSelected == (CWnd*)pTVDispInfo->item.lParam? 0: 1);
  172. }
  173. }
  174. *pResult = 0;
  175. }
  176. void CDialogPropertyPages::OnExpandedListOptions(NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/)
  177. {
  178. m_wndList.Invalidate(TRUE);
  179. }
  180. void CDialogPropertyPages::OnSelchangedListOptions(NMHDR* pNMHDR, LRESULT* pResult)
  181. {
  182. NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
  183. if (pNMTreeView->itemNew.lParam == 0)
  184. return;
  185. if (pNMTreeView->itemNew.hItem)
  186. {
  187. CWnd* pPage = (CWnd*)pNMTreeView->itemNew.lParam;
  188. if (pPage != m_pSelected)
  189. {
  190. ASSERT(pPage);
  191. ASSERT_KINDOF(CXTPPropertyGrid, pPage);
  192. pPage->ShowWindow(SW_SHOW);
  193. pPage->EnableWindow();
  194. pPage->ModifyStyle(0, WS_TABSTOP);
  195. if (m_pSelected)
  196. {
  197. m_pSelected->ShowWindow(SW_HIDE);
  198. }
  199. m_pSelected = pPage;
  200. m_wndList.Invalidate(TRUE);
  201. }
  202. }
  203. *pResult = 0;
  204. }
  205. void CDialogPropertyPages::OnOK()
  206. {
  207. CXTPCommandBarsOptions* pOptions = m_pCommandBars->GetCommandBarsOptions();
  208. pOptions->bAlwaysShowFullMenus = m_AlwaysShowFullMenus;
  209. pOptions->bLargeIcons = m_bLargeIcons;
  210. pOptions->bShowFullAfterDelay = m_bShowFullAfterDelay;
  211. pOptions->bToolBarAccelTips = m_bToolBarAccelTips;
  212. pOptions->bToolBarScreenTips = m_bToolBarScreenTips;
  213. pOptions->szIcons = m_szIcons;
  214. pOptions->szLargeIcons = m_szLargeIcons;
  215. pOptions->szPopupIcons = m_szPopupIcons;
  216. pOptions->bShowExpandButtonAlways = m_bShowExpandButtonAlways;
  217. pOptions->bSyncFloatingBars = m_bSyncFloatingBars;
  218. pOptions->bDblClickFloat = m_bDblClickFloat;
  219. pOptions->bShowTextBelowIcons = m_bShowTextBelowIcons;
  220. pOptions->bAltDragCustomization = m_bAltDragCustomization;
  221. pOptions->bAutoHideUnusedPopups = m_bAutoHideUnusedPopups;
  222. pOptions->animationType = m_nAnimationType;
  223. pOptions->ShowKeyboardCues(m_nKeyboardCuesShow);
  224. pOptions->keyboardCuesUse = m_nKeyboardCuesUse;
  225. ((CEmbeddedFrame*)m_pCommandBars->GetSite())->SetTheme(m_theme);
  226. ((CEmbeddedFrame*)m_pCommandBars->GetSite())->m_bCustomizable = m_bCustomizable;
  227. XTP_COMMANDBARS_ICONSINFO* pIconsInfo = m_pCommandBars->GetPaintManager()->GetIconsInfo();
  228. pIconsInfo->bIconsWithShadow = m_bIconsWithShadow;
  229. pIconsInfo->bUseDisabledIcons = m_bUseDisabledIcons;
  230. pIconsInfo->bUseFadedIcons = m_bUseFadedIcons;
  231. m_pCommandBars->RedrawCommandBars();
  232. m_pCommandBars->RecalcFrameLayout();
  233. CDialog::OnOK();
  234. }
  235. BOOL CDialogPropertyPages::PreTranslateMessage(MSG* pMsg)
  236. {
  237. return CDialog::PreTranslateMessage(pMsg);
  238. }
  239. LRESULT CDialogPropertyPages::OnGridNotify(WPARAM wParam, LPARAM lParam)
  240. {
  241. if (wParam == XTP_PGN_ITEMVALUE_CHANGED)
  242. {
  243. CXTPPropertyGridItem* pItem = (CXTPPropertyGridItem*)lParam;
  244. switch (pItem->GetID())
  245. {
  246. case ID_GRID_ITEM_THEME:
  247. {
  248. CString strTheme = pItem->GetValue();
  249. for (int i = 0; i < _countof(lpThemes); i++)
  250. if (strTheme == lpThemes[i])
  251. {
  252. switch (i)
  253. {
  254. case xtpThemeOfficeXP:
  255. ((CXTPPropertyGridItemBool*)m_wndGridPaint.FindItem(ID_GRID_ITEM_ICONS_SHADOW))->SetBool(TRUE);
  256. ((CXTPPropertyGridItemBool*)m_wndGridPaint.FindItem(ID_GRID_ITEM_ICONS_FADED))->SetBool(TRUE);
  257. break;
  258. case xtpThemeNativeWinXP:
  259. ((CXTPPropertyGridItemBool*)m_wndGridPaint.FindItem(ID_GRID_ITEM_ICONS_SHADOW))->SetBool(FALSE);
  260. ((CXTPPropertyGridItemBool*)m_wndGridPaint.FindItem(ID_GRID_ITEM_ICONS_FADED))->SetBool(TRUE);
  261. break;
  262. default:
  263. ((CXTPPropertyGridItemBool*)m_wndGridPaint.FindItem(ID_GRID_ITEM_ICONS_SHADOW))->SetBool(FALSE);
  264. ((CXTPPropertyGridItemBool*)m_wndGridPaint.FindItem(ID_GRID_ITEM_ICONS_FADED))->SetBool(FALSE);
  265. break;
  266. }
  267. break;
  268. }
  269. }
  270. }
  271. }
  272. return FALSE;
  273. }