Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
5.2 KiB

  1. // optionsh.cpp : implementation file
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 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.GetDocOptions(RD_TEXT));
  37. SetPageButtons(pageRTF, theApp.GetDocOptions(RD_RICHTEXT));
  38. SetPageButtons(pageWord, theApp.GetDocOptions(RD_WINWORD6));
  39. SetPageButtons(pageWrite, theApp.GetDocOptions(RD_WRITE));
  40. SetPageButtons(pageEmbedded, theApp.GetDocOptions(RD_EMBEDDED));
  41. SetPageButtons(pageEmbedded, theApp.GetDocOptions(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, CDocOptions& options, BOOL bPrimary)
  50. {
  51. CDocOptions::CBarState& barstate = options.GetBarState(bPrimary);
  52. page.m_bFormatBar = barstate.m_bFormatBar;
  53. page.m_bRulerBar = barstate.m_bRulerBar;
  54. page.m_bToolBar = barstate.m_bToolBar;
  55. page.m_bStatusBar = barstate.m_bStatusBar;
  56. }
  57. void COptionSheet::SetState(CDocOptPage& page, CDocOptions& options, BOOL bPrimary)
  58. {
  59. CDocOptions::CBarState& barstate = options.GetBarState(bPrimary);
  60. CDockState& ds = options.GetDockState(bPrimary);
  61. barstate.m_bFormatBar = page.m_bFormatBar;
  62. barstate.m_bRulerBar = page.m_bRulerBar;
  63. barstate.m_bToolBar = page.m_bToolBar;
  64. barstate.m_bStatusBar = page.m_bStatusBar;
  65. for (int i = 0;i < ds.m_arrBarInfo.GetSize(); i++)
  66. {
  67. CControlBarInfo* pInfo = (CControlBarInfo*)ds.m_arrBarInfo[i];
  68. ASSERT(pInfo != NULL);
  69. switch (pInfo->m_nBarID)
  70. {
  71. case ID_VIEW_FORMATBAR:
  72. pInfo->m_bVisible = page.m_bFormatBar;
  73. break;
  74. case ID_VIEW_RULER:
  75. pInfo->m_bVisible = page.m_bRulerBar;
  76. break;
  77. case ID_VIEW_TOOLBAR:
  78. pInfo->m_bVisible = page.m_bToolBar;
  79. break;
  80. case ID_VIEW_STATUS_BAR:
  81. pInfo->m_bVisible = page.m_bStatusBar;
  82. break;
  83. }
  84. }
  85. }
  86. const DWORD m_nHelpIDs[] =
  87. {
  88. AFX_IDC_TAB_CONTROL, (DWORD) -1,
  89. 0, 0
  90. };
  91. LONG COptionSheet::OnHelp(WPARAM, LPARAM lParam)
  92. {
  93. ::WinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle,
  94. AfxGetApp()->m_pszHelpFilePath,
  95. HELP_WM_HELP, (DWORD_PTR) m_nHelpIDs);
  96. return 0;
  97. }
  98. LONG COptionSheet::OnHelpContextMenu(WPARAM wParam, LPARAM)
  99. {
  100. ::WinHelp((HWND)wParam, AfxGetApp()->m_pszHelpFilePath,
  101. HELP_CONTEXTMENU, (DWORD_PTR) m_nHelpIDs);
  102. return 0;
  103. }
  104. BEGIN_MESSAGE_MAP(COptionSheet, CCSPropertySheet)
  105. //{{AFX_MSG_MAP(COptionSheet)
  106. ON_WM_CREATE()
  107. ON_MESSAGE(WM_HELP, OnHelp)
  108. ON_MESSAGE(WM_CONTEXTMENU, OnHelpContextMenu)
  109. //}}AFX_MSG_MAP
  110. END_MESSAGE_MAP()
  111. /////////////////////////////////////////////////////////////////////////////
  112. // COptionSheet message handlers
  113. INT_PTR COptionSheet::DoModal()
  114. {
  115. //
  116. // Turn apply button off
  117. //
  118. m_psh.dwFlags |= PSH_NOAPPLYNOW ;
  119. INT_PTR nRes = CCSPropertySheet::DoModal();
  120. if (nRes == IDOK)
  121. {
  122. SetState(pageText, theApp.GetDocOptions(RD_TEXT));
  123. SetState(pageRTF, theApp.GetDocOptions(RD_RICHTEXT));
  124. SetState(pageWord, theApp.GetDocOptions(RD_WINWORD6));
  125. SetState(pageWrite, theApp.GetDocOptions(RD_WRITE));
  126. SetState(pageEmbedded, theApp.GetDocOptions(RD_EMBEDDED));
  127. SetState(pageEmbedded, theApp.GetDocOptions(RD_EMBEDDED), FALSE);
  128. theApp.SetUnits(units.m_nUnits);
  129. theApp.m_bWordSel = units.m_bWordSel;
  130. theApp.GetDocOptions(RD_TEXT).m_nWordWrap = pageText.m_nWordWrap;
  131. theApp.GetDocOptions(RD_RICHTEXT).m_nWordWrap = pageRTF.m_nWordWrap;
  132. theApp.GetDocOptions(RD_WINWORD6).m_nWordWrap = pageWord.m_nWordWrap;
  133. theApp.GetDocOptions(RD_WRITE).m_nWordWrap = pageWrite.m_nWordWrap;
  134. theApp.GetDocOptions(RD_EMBEDDED).m_nWordWrap = pageEmbedded.m_nWordWrap;
  135. }
  136. return nRes;
  137. }
  138. /////////////////////////////////////////////////////////////////////////////
  139. // COptionSheet message handlers