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

对话框与窗口

开发平台:

Visual C++

  1. // PropertiesPane.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 "GUI_VisualStudio.h"
  22. #include "PropertiesPane.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CPropertiesPane
  30. CPropertiesPane::CPropertiesPane()
  31. {
  32. }
  33. CPropertiesPane::~CPropertiesPane()
  34. {
  35. }
  36. BEGIN_MESSAGE_MAP(CPropertiesPane, CWnd)
  37. //{{AFX_MSG_MAP(CPropertiesPane)
  38. ON_WM_CREATE()
  39. ON_WM_SIZE()
  40. //}}AFX_MSG_MAP
  41. ON_COMMAND(ID_PANEPROPERTIES_CATEGORIZED, OnPanePropertiesCategorized)
  42. ON_UPDATE_COMMAND_UI(ID_PANEPROPERTIES_CATEGORIZED, OnUpdatePanePropertiesCategorized)
  43. ON_COMMAND(ID_PANEPROPERTIES_ALPHABETIC, OnPanePropertiesAlphabetic)
  44. ON_UPDATE_COMMAND_UI(ID_PANEPROPERTIES_ALPHABETIC, OnUpdatePanePropertiesAlphabetic)
  45. ON_WM_SETFOCUS()
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CPropertiesPane message handlers
  49. int CPropertiesPane::OnCreate(LPCREATESTRUCT lpCreateStruct)
  50. {
  51. if (CWnd::OnCreate(lpCreateStruct) == -1)
  52. return -1;
  53. VERIFY(m_wndToolBar.CreateToolBar(WS_TABSTOP|WS_VISIBLE|WS_CHILD|CBRS_TOOLTIPS, this));
  54. VERIFY(m_wndToolBar.LoadToolBar(IDR_PANE_PROPERTIES));
  55. if (m_wndPropertyGrid.GetSafeHwnd() == 0)
  56. {
  57. m_wndPropertyGrid.Create( CRect(0, 0, 0, 0), this, 0 );
  58. m_wndPropertyGrid.SetOwner(this);
  59. m_wndPropertyGrid.SetTheme(xtpGridThemeWhidbey);
  60. CFont font;
  61. font.CreatePointFont(60, _T("Marlett"));
  62. LOGFONT lf;
  63. font.GetLogFont(&lf);
  64. // create document settings category.
  65. CXTPPropertyGridItem* pSettings        = m_wndPropertyGrid.AddCategory(_T("Document Settings"));
  66. // add child items to category.
  67. CXTPPropertyGridItem* pItemSaveOnClose = pSettings->AddChildItem(new CXTPPropertyGridItemBool(_T("SaveOnClose"), TRUE));
  68. pSettings->AddChildItem(new CXTPPropertyGridItemFont(_T("WindowFont"), lf));
  69. pSettings->AddChildItem(new CXTPPropertyGridItemSize(_T("WindowSize"), CSize(100, 100)));
  70. pSettings->Expand();
  71. pItemSaveOnClose->Select();
  72. // create global settings category.
  73. CXTPPropertyGridItem* pGlobals      = m_wndPropertyGrid.AddCategory(_T("Global Settings"));
  74. // add child items to category.
  75. CXTPPropertyGridItem* pItemGreeting = pGlobals->AddChildItem(new CXTPPropertyGridItem(_T("Greeting Text"), _T("Welcome to your application!")));
  76. pGlobals->AddChildItem(new CXTPPropertyGridItemNumber(_T("ItemsInMRUList"), 4));
  77. CXTPPropertyGridItem* pItemRate     = pGlobals->AddChildItem(new CXTPPropertyGridItemNumber(_T("MaxRepeatRate"), 10));
  78. pGlobals->AddChildItem(new CXTPPropertyGridItemColor(_T("ToolbarColor"), RGB(255, 192,128)));
  79. pItemGreeting->SetReadOnly(TRUE);
  80. pItemRate->SetDescription(_T("The rate in milliseconds that the text will repeat."));
  81. // create version category.
  82. CXTPPropertyGridItem* pVersion      = m_wndPropertyGrid.AddCategory(_T("Version"));
  83. // add child items to category.
  84. CXTPPropertyGridItem* pItemVersion  = pVersion->AddChildItem(new CXTPPropertyGridItem(_T("AppVersion"), _T("1.0")));
  85. CXTPPropertyGridItem* pItemLanguage = pVersion->AddChildItem(new CXTPPropertyGridItem(_T("Language"), _T("English (United States)")));
  86. pItemVersion->SetReadOnly(TRUE);
  87. pVersion->Expand();
  88. CXTPPropertyGridItemConstraints* pList = pItemLanguage->GetConstraints();
  89. pList->AddConstraint(_T("Neutral"));
  90. pList->AddConstraint(_T("Arabic"));
  91. pList->AddConstraint(_T("German"));
  92. pList->AddConstraint(_T("Chinese(Taiwan)"));
  93. pList->AddConstraint(_T("English (United Kingdom)"));
  94. pList->AddConstraint(_T("English (United States)"));
  95. pList->AddConstraint(_T("France"));
  96. pList->AddConstraint(_T("Russian"));
  97. pItemLanguage->SetFlags(xtpGridItemHasComboButton | xtpGridItemHasEdit);
  98. // create custom items category.
  99. CXTPPropertyGridItem* pCustom   = m_wndPropertyGrid.AddCategory(_T("Custom Items"));
  100. // add multi level tree node.
  101. CXTPPropertyGridItem* pItemOne    = pCustom->AddChildItem(new CXTPPropertyGridItem(_T("First Level"), _T("")));
  102. CXTPPropertyGridItem* pItemTwo    = pItemOne->AddChildItem(new CXTPPropertyGridItem(_T("Second Level"), _T("")));
  103. CXTPPropertyGridItem* pItemThird     = pItemTwo->AddChildItem(new CXTPPropertyGridItem(_T("Third Level"), _T("")));
  104. pItemThird->AddChildItem(new CXTPPropertyGridItem(_T("Fourth Level 1"), _T("")));
  105. pItemThird->AddChildItem(new CXTPPropertyGridItem(_T("Fourth Level 2"), _T("")));
  106. m_wndPropertyGrid.HighlightChangedItems(TRUE);
  107. }
  108. return 0;
  109. }
  110. void CPropertiesPane::OnSize(UINT nType, int cx, int cy)
  111. {
  112. CWnd::OnSize(nType, cx, cy);
  113. int nTop = 0;
  114. if (m_wndToolBar.GetSafeHwnd())
  115. {
  116. CSize sz = m_wndToolBar.CalcDockingLayout(cx, /*LM_HIDEWRAP|*/ LM_HORZDOCK|LM_HORZ | LM_COMMIT);
  117. m_wndToolBar.MoveWindow(0, nTop, cx, sz.cy);
  118. m_wndToolBar.Invalidate(FALSE);
  119. nTop += sz.cy;
  120. }
  121. if (m_wndPropertyGrid.GetSafeHwnd())
  122. {
  123. m_wndPropertyGrid.MoveWindow(0, nTop, cx, cy - nTop);
  124. m_wndPropertyGrid.Invalidate(FALSE);
  125. }
  126. }
  127. void CPropertiesPane::OnPanePropertiesCategorized()
  128. {
  129. m_wndPropertyGrid.SetPropertySort(xtpGridSortCategorized);
  130. }
  131. void CPropertiesPane::OnUpdatePanePropertiesCategorized(CCmdUI* pCmdUI)
  132. {
  133. pCmdUI->SetCheck(m_wndPropertyGrid.GetPropertySort() == xtpGridSortCategorized);
  134. }
  135. void CPropertiesPane::OnPanePropertiesAlphabetic()
  136. {
  137. m_wndPropertyGrid.SetPropertySort(xtpGridSortAlphabetical);
  138. }
  139. void CPropertiesPane::OnUpdatePanePropertiesAlphabetic(CCmdUI* pCmdUI)
  140. {
  141. pCmdUI->SetCheck(m_wndPropertyGrid.GetPropertySort() == xtpGridSortAlphabetical);
  142. }
  143. void CPropertiesPane::OnSetFocus(CWnd* /*pOldWnd*/)
  144. {
  145. m_wndPropertyGrid.SetFocus();
  146. }