OPTIONSH.CPP
上传用户:aakk678
上传日期:2022-07-09
资源大小:406k
文件大小:5k
源码类别:

界面编程

开发平台:

Visual C++

  1. // optionsh.cpp : implementation file
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1997 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12. #include "stdafx.h"
  13. #include "wordpad.h"
  14. #include "unitspag.h"
  15. #include "docopt.h"
  16. #include "optionsh.h"
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char BASED_CODE THIS_FILE[] = __FILE__;
  20. #endif
  21. /////////////////////////////////////////////////////////////////////////////
  22. // COptionSheet
  23. COptionSheet::COptionSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
  24. : CCSPropertySheet(nIDCaption, pParentWnd, iSelectPage),
  25. pageText(IDS_TEXT_OPTIONS), pageRTF(IDS_RTF_OPTIONS), 
  26. pageWord(IDS_WORD6_OPTIONS), pageWrite(IDS_WRITE_OPTIONS), 
  27. pageEmbedded()
  28. {
  29. units.m_nUnits = theApp.GetUnits();
  30. units.m_bWordSel = theApp.m_bWordSel;
  31. pageText.m_nWordWrap = theApp.GetDocOptions(RD_TEXT).m_nWordWrap;
  32. pageRTF.m_nWordWrap = theApp.GetDocOptions(RD_RICHTEXT).m_nWordWrap;
  33. pageWord.m_nWordWrap = theApp.GetDocOptions(RD_WINWORD6).m_nWordWrap;
  34. pageWrite.m_nWordWrap = theApp.GetDocOptions(RD_WRITE).m_nWordWrap;
  35. pageEmbedded.m_nWordWrap = theApp.GetDocOptions(RD_EMBEDDED).m_nWordWrap;
  36. SetPageButtons(pageText, theApp.GetDockState(RD_TEXT));
  37. SetPageButtons(pageRTF, theApp.GetDockState(RD_RICHTEXT));
  38. SetPageButtons(pageWord, theApp.GetDockState(RD_WINWORD6));
  39. SetPageButtons(pageWrite, theApp.GetDockState(RD_WRITE));
  40. SetPageButtons(pageEmbedded, theApp.GetDockState(RD_EMBEDDED));
  41. SetPageButtons(pageEmbedded, theApp.GetDockState(RD_EMBEDDED, FALSE));
  42. AddPage(&units);
  43. AddPage(&pageText);
  44. AddPage(&pageRTF);
  45. AddPage(&pageWord);
  46. AddPage(&pageWrite);
  47. AddPage(&pageEmbedded);
  48. }
  49. void COptionSheet::SetPageButtons(CDocOptPage& page, CDockState& ds)
  50. {
  51. if (ds.m_arrBarInfo.GetSize() == 0)
  52. {
  53. page.m_bFormatBar = page.m_bRulerBar = TRUE;
  54. page.m_bToolBar = page.m_bStatusBar = TRUE;
  55. }
  56. else
  57. {
  58. for (int i = 0;i < ds.m_arrBarInfo.GetSize(); i++)
  59. {
  60. CControlBarInfo* pInfo = (CControlBarInfo*)ds.m_arrBarInfo[i];
  61. ASSERT(pInfo != NULL);
  62. switch (pInfo->m_nBarID)
  63. {
  64. case ID_VIEW_FORMATBAR:
  65. page.m_bFormatBar = page.m_bFormatBar || pInfo->m_bVisible;
  66. break;
  67. case ID_VIEW_RULER:
  68. page.m_bRulerBar = page.m_bRulerBar || pInfo->m_bVisible;
  69. break;
  70. case ID_VIEW_TOOLBAR:
  71. page.m_bToolBar = page.m_bToolBar || pInfo->m_bVisible;
  72. break;
  73. case ID_VIEW_STATUS_BAR:
  74. page.m_bStatusBar = page.m_bStatusBar || pInfo->m_bVisible;
  75. break;
  76. }
  77. }
  78. }
  79. }
  80. void COptionSheet::SetState(CDocOptPage& page, CDockState& ds)
  81. {
  82. for (int i = 0;i < ds.m_arrBarInfo.GetSize(); i++)
  83. {
  84. CControlBarInfo* pInfo = (CControlBarInfo*)ds.m_arrBarInfo[i];
  85. ASSERT(pInfo != NULL);
  86. switch (pInfo->m_nBarID)
  87. {
  88. case ID_VIEW_FORMATBAR:
  89. pInfo->m_bVisible = page.m_bFormatBar;
  90. break;
  91. case ID_VIEW_RULER:
  92. pInfo->m_bVisible = page.m_bRulerBar;
  93. break;
  94. case ID_VIEW_TOOLBAR:
  95. pInfo->m_bVisible = page.m_bToolBar;
  96. break;
  97. case ID_VIEW_STATUS_BAR:
  98. pInfo->m_bVisible = page.m_bStatusBar;
  99. break;
  100. }
  101. }
  102. }
  103. BEGIN_MESSAGE_MAP(COptionSheet, CCSPropertySheet)
  104. //{{AFX_MSG_MAP(COptionSheet)
  105. ON_WM_CREATE()
  106. //}}AFX_MSG_MAP
  107. END_MESSAGE_MAP()
  108. /////////////////////////////////////////////////////////////////////////////
  109. // COptionSheet message handlers
  110. int COptionSheet::DoModal()
  111. {
  112. int nRes = CCSPropertySheet::DoModal();
  113. if (nRes == IDOK)
  114. {
  115. SetState(pageText, theApp.GetDockState(RD_TEXT));
  116. SetState(pageRTF, theApp.GetDockState(RD_RICHTEXT));
  117. SetState(pageWord, theApp.GetDockState(RD_WINWORD6));
  118. SetState(pageWrite, theApp.GetDockState(RD_WRITE));
  119. SetState(pageEmbedded, theApp.GetDockState(RD_EMBEDDED));
  120. SetState(pageEmbedded, theApp.GetDockState(RD_EMBEDDED, FALSE));
  121. theApp.SetUnits(units.m_nUnits);
  122. theApp.m_bWordSel = units.m_bWordSel;
  123. theApp.GetDocOptions(RD_TEXT).m_nWordWrap = pageText.m_nWordWrap;
  124. theApp.GetDocOptions(RD_RICHTEXT).m_nWordWrap = pageRTF.m_nWordWrap;
  125. theApp.GetDocOptions(RD_WINWORD6).m_nWordWrap = pageWord.m_nWordWrap;
  126. theApp.GetDocOptions(RD_WRITE).m_nWordWrap = pageWrite.m_nWordWrap;
  127. theApp.GetDocOptions(RD_EMBEDDED).m_nWordWrap = pageEmbedded.m_nWordWrap;
  128. }
  129. return nRes;
  130. }
  131. /////////////////////////////////////////////////////////////////////////////
  132. // COptionSheet message handlers