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

对话框与窗口

开发平台:

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 "CommandBarIcons.h"
  22. #include "AlphaIconsPage.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CAlphaIconsPage dialog
  30. CAlphaIconsPage::CAlphaIconsPage(CWnd* pParent /*=NULL*/)
  31. : CPropertiesTabPage(CAlphaIconsPage::IDD, pParent)
  32. {
  33. //{{AFX_DATA_INIT(CAlphaIconsPage)
  34. m_bFaded = FALSE;
  35. m_bShadow = FALSE;
  36. m_bLargeImages = FALSE;
  37. m_bResample = FALSE;
  38. //}}AFX_DATA_INIT
  39. }
  40. void CAlphaIconsPage::UpdateContent()
  41. {
  42. XTP_COMMANDBARS_ICONSINFO* pIconsInfo = XTPPaintManager()->GetIconsInfo();
  43. m_bFaded = pIconsInfo->bUseFadedIcons;
  44. m_bShadow = pIconsInfo->bIconsWithShadow;
  45. CXTPFrameWnd* pFrame = (CXTPFrameWnd*)AfxGetMainWnd();
  46. CXTPCommandBars* pCommandBars = pFrame->GetCommandBars();
  47. ASSERT(pCommandBars);
  48. CXTPCommandBarsOptions* pOptions = pCommandBars->GetCommandBarsOptions();
  49. m_bLargeImages = pOptions->bLargeIcons;
  50. UpdateData(FALSE);
  51. }
  52. void CAlphaIconsPage::DoDataExchange(CDataExchange* pDX)
  53. {
  54. CDialog::DoDataExchange(pDX);
  55. //{{AFX_DATA_MAP(CAlphaIconsPage)
  56. DDX_Check(pDX, IDC_CHECK_FADED, m_bFaded);
  57. DDX_Check(pDX, IDC_CHECK_SHADOW, m_bShadow);
  58. DDX_Check(pDX, IDC_CHECK_LARGEIMAGES, m_bLargeImages);
  59. DDX_Check(pDX, IDC_CHECK_RESAMPLE, m_bResample);
  60. //}}AFX_DATA_MAP
  61. }
  62. BEGIN_MESSAGE_MAP(CAlphaIconsPage, CDialog)
  63. //{{AFX_MSG_MAP(CAlphaIconsPage)
  64. ON_BN_CLICKED(IDC_CHECK_FADED, OnCheckFaded)
  65. ON_BN_CLICKED(IDC_CHECK_SHADOW, OnCheckShadow)
  66. ON_BN_CLICKED(IDC_CHECK_LARGEIMAGES, OnCheckLargeimages)
  67. ON_BN_CLICKED(IDC_CHECK_RESAMPLE, OnCheckResample)
  68. //}}AFX_MSG_MAP
  69. END_MESSAGE_MAP()
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CAlphaIconsPage message handlers
  72. void CAlphaIconsPage::RedrawCommandBars()
  73. {
  74. CXTPFrameWnd* pFrame = (CXTPFrameWnd*)AfxGetMainWnd();
  75. pFrame->RecalcLayout(FALSE);
  76. pFrame->GetCommandBars()->RedrawCommandBars();
  77. pFrame->RedrawWindow();
  78. }
  79. void CAlphaIconsPage::OnCheckFaded()
  80. {
  81. UpdateData();
  82. XTP_COMMANDBARS_ICONSINFO* pIconsInfo = XTPPaintManager()->GetIconsInfo();
  83. pIconsInfo->bUseFadedIcons = m_bFaded;
  84. RedrawCommandBars();
  85. }
  86. void CAlphaIconsPage::OnCheckShadow()
  87. {
  88. UpdateData();
  89. XTP_COMMANDBARS_ICONSINFO* pIconsInfo = XTPPaintManager()->GetIconsInfo();
  90. pIconsInfo->bIconsWithShadow = m_bShadow;
  91. RedrawCommandBars();
  92. }
  93. void CAlphaIconsPage::OnCheckDisabled()
  94. {
  95. UpdateData();
  96. XTP_COMMANDBARS_ICONSINFO* pIconsInfo = XTPPaintManager()->GetIconsInfo();
  97. pIconsInfo->bUseDisabledIcons = m_bDisabled;
  98. RedrawCommandBars();
  99. }
  100. void CAlphaIconsPage::OnCancel()
  101. {
  102. }
  103. void CAlphaIconsPage::OnActivate()
  104. {
  105. CXTPFrameWnd* pFrame = (CXTPFrameWnd*)AfxGetMainWnd();
  106. CXTPCommandBars* pCommandBars = pFrame->GetCommandBars();
  107. ASSERT(pCommandBars);
  108. CXTPToolBar* pToolBar = pCommandBars->GetAt(1);
  109. ASSERT(pToolBar->GetTitle() == _T("Standard"));
  110. XTPImageManager()->RemoveAll();
  111. pToolBar->LoadToolBar(IDR_ICONS_MENU_32);
  112. XTP_COMMANDBARS_ICONSINFO* pIconsInfo = XTPPaintManager()->GetIconsInfo();
  113. pIconsInfo->bUseDisabledIcons = TRUE;
  114. CXTPCommandBarsOptions* pOptions = pCommandBars->GetCommandBarsOptions();
  115. pOptions->szIcons = CSize(16, 16);
  116. pOptions->szLargeIcons = CSize (42, 35);
  117. pOptions->bLargeIcons = FALSE;
  118. XTPImageManager()->SetIcons(IDR_ICONS_TOOLBAR_32);
  119. if (!XTPImageManager()->IsAlphaIconsSupported())
  120. {
  121. m_bResample = TRUE;
  122. GetDlgItem(IDC_CHECK_RESAMPLE)->EnableWindow(FALSE);
  123. UpdateData(FALSE);
  124. }
  125. ResampleImages();
  126. UpdateContent();
  127. }
  128. void CAlphaIconsPage::ResampleImages()
  129. {
  130. if (m_bResample)
  131. {
  132. CBitmap bmpResample;
  133. bmpResample.Attach(CXTPImageManager::ResampleAlphaLayer(IDR_ICONS_MENU_32, RGB(0, 0xFF, 0)));
  134. XTPImageManager()->SetIcons(IDR_ICONS_MENU_32, bmpResample);
  135. bmpResample.DeleteObject();
  136. bmpResample.Attach(CXTPImageManager::ResampleAlphaLayer(IDR_ICONS_TOOLBAR_32, RGB(0, 0xFF, 0)));
  137. XTPImageManager()->SetIcons(IDR_ICONS_TOOLBAR_32, bmpResample);
  138. } else
  139. {
  140. XTPImageManager()->SetIcons(IDR_ICONS_MENU_32);
  141. XTPImageManager()->SetIcons(IDR_ICONS_TOOLBAR_32);
  142. }
  143. RedrawCommandBars();
  144. }
  145. void CAlphaIconsPage::OnCheckResample()
  146. {
  147. UpdateData();
  148. ResampleImages();
  149. }
  150. void CAlphaIconsPage::OnCheckLargeimages()
  151. {
  152. UpdateData();
  153. CXTPFrameWnd* pFrame = (CXTPFrameWnd*)AfxGetMainWnd();
  154. CXTPCommandBars* pCommandBars = pFrame->GetCommandBars();
  155. ASSERT(pCommandBars);
  156. CXTPCommandBarsOptions* pOptions = pCommandBars->GetCommandBarsOptions();
  157. // Set global icon's size
  158. pOptions->bLargeIcons = m_bLargeImages;
  159. RedrawCommandBars();
  160. }