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

对话框与窗口

开发平台:

Visual C++

  1. // optionsh.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 "wordpad.h"
  22. #include "unitspag.h"
  23. #include "docopt.h"
  24. #include "optionsh.h"
  25. #ifdef _DEBUG
  26. #undef THIS_FILE
  27. static char BASED_CODE THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. // COptionSheet
  31. COptionSheet::COptionSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
  32. : CCSPropertySheet(nIDCaption, pParentWnd, iSelectPage),
  33. pageText(IDS_TEXT_OPTIONS), pageRTF(IDS_RTF_OPTIONS),
  34. pageWord(IDS_WORD6_OPTIONS), pageWrite(IDS_WRITE_OPTIONS),
  35. pageEmbedded()
  36. {
  37. units.m_nUnits = theApp.GetUnits();
  38. units.m_bWordSel = theApp.m_bWordSel;
  39. pageText.m_nWordWrap = theApp.GetDocOptions(RD_TEXT).m_nWordWrap;
  40. pageRTF.m_nWordWrap = theApp.GetDocOptions(RD_RICHTEXT).m_nWordWrap;
  41. pageWord.m_nWordWrap = theApp.GetDocOptions(RD_WINWORD6).m_nWordWrap;
  42. pageWrite.m_nWordWrap = theApp.GetDocOptions(RD_WRITE).m_nWordWrap;
  43. pageEmbedded.m_nWordWrap = theApp.GetDocOptions(RD_EMBEDDED).m_nWordWrap;
  44. SetPageButtons(pageText, theApp.GetDockState(RD_TEXT));
  45. SetPageButtons(pageRTF, theApp.GetDockState(RD_RICHTEXT));
  46. SetPageButtons(pageWord, theApp.GetDockState(RD_WINWORD6));
  47. SetPageButtons(pageWrite, theApp.GetDockState(RD_WRITE));
  48. SetPageButtons(pageEmbedded, theApp.GetDockState(RD_EMBEDDED));
  49. SetPageButtons(pageEmbedded, theApp.GetDockState(RD_EMBEDDED, FALSE));
  50. AddPage(&units);
  51. AddPage(&pageText);
  52. AddPage(&pageRTF);
  53. AddPage(&pageWord);
  54. AddPage(&pageWrite);
  55. AddPage(&pageEmbedded);
  56. }
  57. void COptionSheet::SetPageButtons(CDocOptPage& page, CDockState& ds)
  58. {
  59. if (ds.m_arrBarInfo.GetSize() == 0)
  60. {
  61. page.m_bFormatBar = page.m_bRulerBar = TRUE;
  62. page.m_bToolBar = page.m_bStatusBar = TRUE;
  63. }
  64. else
  65. {
  66. for (int i = 0;i < ds.m_arrBarInfo.GetSize(); i++)
  67. {
  68. CControlBarInfo* pInfo = (CControlBarInfo*)ds.m_arrBarInfo[i];
  69. ASSERT(pInfo != NULL);
  70. switch (pInfo->m_nBarID)
  71. {
  72. case ID_VIEW_FORMATBAR:
  73. page.m_bFormatBar = page.m_bFormatBar || pInfo->m_bVisible;
  74. break;
  75. case ID_VIEW_RULER:
  76. page.m_bRulerBar = page.m_bRulerBar || pInfo->m_bVisible;
  77. break;
  78. case ID_VIEW_TOOLBAR:
  79. page.m_bToolBar = page.m_bToolBar || pInfo->m_bVisible;
  80. break;
  81. case ID_VIEW_STATUS_BAR:
  82. page.m_bStatusBar = page.m_bStatusBar || pInfo->m_bVisible;
  83. break;
  84. }
  85. }
  86. }
  87. }
  88. void COptionSheet::SetState(CDocOptPage& page, CDockState& ds)
  89. {
  90. for (int i = 0;i < ds.m_arrBarInfo.GetSize(); i++)
  91. {
  92. CControlBarInfo* pInfo = (CControlBarInfo*)ds.m_arrBarInfo[i];
  93. ASSERT(pInfo != NULL);
  94. switch (pInfo->m_nBarID)
  95. {
  96. case ID_VIEW_FORMATBAR:
  97. pInfo->m_bVisible = page.m_bFormatBar;
  98. break;
  99. case ID_VIEW_RULER:
  100. pInfo->m_bVisible = page.m_bRulerBar;
  101. break;
  102. case ID_VIEW_TOOLBAR:
  103. pInfo->m_bVisible = page.m_bToolBar;
  104. break;
  105. case ID_VIEW_STATUS_BAR:
  106. pInfo->m_bVisible = page.m_bStatusBar;
  107. break;
  108. }
  109. }
  110. }
  111. BEGIN_MESSAGE_MAP(COptionSheet, CCSPropertySheet)
  112. //{{AFX_MSG_MAP(COptionSheet)
  113. ON_WM_CREATE()
  114. //}}AFX_MSG_MAP
  115. END_MESSAGE_MAP()
  116. /////////////////////////////////////////////////////////////////////////////
  117. // COptionSheet message handlers
  118. INT_PTR COptionSheet::DoModal()
  119. {
  120. INT_PTR nRes = CCSPropertySheet::DoModal();
  121. if (nRes == IDOK)
  122. {
  123. SetState(pageText, theApp.GetDockState(RD_TEXT));
  124. SetState(pageRTF, theApp.GetDockState(RD_RICHTEXT));
  125. SetState(pageWord, theApp.GetDockState(RD_WINWORD6));
  126. SetState(pageWrite, theApp.GetDockState(RD_WRITE));
  127. SetState(pageEmbedded, theApp.GetDockState(RD_EMBEDDED));
  128. SetState(pageEmbedded, theApp.GetDockState(RD_EMBEDDED, FALSE));
  129. theApp.SetUnits(units.m_nUnits);
  130. theApp.m_bWordSel = units.m_bWordSel;
  131. theApp.GetDocOptions(RD_TEXT).m_nWordWrap = pageText.m_nWordWrap;
  132. theApp.GetDocOptions(RD_RICHTEXT).m_nWordWrap = pageRTF.m_nWordWrap;
  133. theApp.GetDocOptions(RD_WINWORD6).m_nWordWrap = pageWord.m_nWordWrap;
  134. theApp.GetDocOptions(RD_WRITE).m_nWordWrap = pageWrite.m_nWordWrap;
  135. theApp.GetDocOptions(RD_EMBEDDED).m_nWordWrap = pageEmbedded.m_nWordWrap;
  136. }
  137. return nRes;
  138. }
  139. /////////////////////////////////////////////////////////////////////////////
  140. // COptionSheet message handlers