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.

168 lines
4.5 KiB

  1. // formatpa.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 "formatpa.h"
  15. #include "ddxm.h"
  16. #include "helpids.h"
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char BASED_CODE THIS_FILE[] = __FILE__;
  20. #endif
  21. const DWORD CFormatParaDlg::m_nHelpIDs[] =
  22. {
  23. IDC_EDIT_LEFT, IDH_WORDPAD_INDENT_LEFT,
  24. IDC_EDIT_RIGHT, IDH_WORDPAD_INDENT_RIGHT,
  25. IDC_EDIT_FIRST_LINE, IDH_WORDPAD_INDENT_FIRST,
  26. IDC_BOX, (DWORD) -1,
  27. IDC_COMBO_ALIGNMENT, IDH_WORDPAD_ALIGN,
  28. IDC_TEXT_ALIGNMENT, IDH_WORDPAD_ALIGN,
  29. 0, 0
  30. };
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CFormatParaDlg dialog
  33. CFormatParaDlg::CFormatParaDlg(PARAFORMAT& pf, CWnd* pParent /*=NULL*/)
  34. : CCSDialog(CFormatParaDlg::IDD, pParent)
  35. {
  36. m_pf = pf;
  37. if (m_pf.dwMask & PFM_ALIGNMENT)
  38. {
  39. if (m_pf.wAlignment & PFA_LEFT && m_pf.wAlignment & PFA_RIGHT)
  40. m_nAlignment = 2;
  41. else
  42. m_nAlignment = (m_pf.wAlignment & PFA_LEFT) ? 0 : 1;
  43. }
  44. else
  45. m_nAlignment = -1;
  46. //{{AFX_DATA_INIT(CFormatParaDlg)
  47. m_nFirst = 0;
  48. m_nLeft = 0;
  49. m_nRight = 0;
  50. //}}AFX_DATA_INIT
  51. }
  52. void CFormatParaDlg::DoDataExchange(CDataExchange* pDX)
  53. {
  54. CCSDialog::DoDataExchange(pDX);
  55. //{{AFX_DATA_MAP(CFormatParaDlg)
  56. DDX_CBIndex(pDX, IDC_COMBO_ALIGNMENT, m_nAlignment);
  57. DDX_Twips(pDX, IDC_EDIT_FIRST_LINE, m_nFirst);
  58. DDV_MinMaxTwips(pDX, m_nFirst, -31680, 31680);
  59. DDX_Twips(pDX, IDC_EDIT_LEFT, m_nLeft);
  60. DDV_MinMaxTwips(pDX, m_nLeft, -31680, 31680);
  61. DDX_Twips(pDX, IDC_EDIT_RIGHT, m_nRight);
  62. DDV_MinMaxTwips(pDX, m_nRight, -31680, 31680);
  63. //}}AFX_DATA_MAP
  64. }
  65. BEGIN_MESSAGE_MAP(CFormatParaDlg, CCSDialog)
  66. //{{AFX_MSG_MAP(CFormatParaDlg)
  67. //}}AFX_MSG_MAP
  68. END_MESSAGE_MAP()
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CFormatParaDlg message handlers
  71. void CFormatParaDlg::OnOK()
  72. {
  73. CCSDialog::OnOK();
  74. m_pf.dwMask = 0;
  75. if (m_nAlignment >= 0)
  76. {
  77. ASSERT(m_nAlignment < 3);
  78. m_pf.dwMask |= PFM_ALIGNMENT;
  79. m_pf.wAlignment = (WORD)((m_nAlignment == 0) ? PFA_LEFT :
  80. (m_nAlignment == 1) ? PFA_RIGHT : PFA_CENTER);
  81. }
  82. //in case we have RTL Reading order, we need to reverse the sides indent.
  83. if ( m_pf.wEffects & PFE_RTLPARA )
  84. {
  85. if (m_nLeft != DDXM_BLANK)
  86. m_pf.dwMask |= PFM_RIGHTINDENT;
  87. if (m_nRight != DDXM_BLANK && m_nFirst != DDXM_BLANK)
  88. m_pf.dwMask |= PFM_STARTINDENT;
  89. if (m_nFirst != DDXM_BLANK)
  90. m_pf.dwMask |= PFM_OFFSET;
  91. m_pf.dxRightIndent = m_nLeft;
  92. m_pf.dxOffset = -m_nFirst;
  93. m_pf.dxStartIndent = m_nRight + m_nFirst;
  94. }
  95. else
  96. {
  97. if (m_nRight != DDXM_BLANK)
  98. m_pf.dwMask |= PFM_RIGHTINDENT;
  99. if (m_nLeft != DDXM_BLANK && m_nFirst != DDXM_BLANK)
  100. m_pf.dwMask |= PFM_STARTINDENT;
  101. if (m_nFirst != DDXM_BLANK)
  102. m_pf.dwMask |= PFM_OFFSET;
  103. m_pf.dxRightIndent = m_nRight;
  104. m_pf.dxOffset = -m_nFirst;
  105. m_pf.dxStartIndent = m_nLeft + m_nFirst;
  106. }
  107. }
  108. BOOL CFormatParaDlg::OnInitDialog()
  109. {
  110. CComboBox* pBox = (CComboBox*)GetDlgItem(IDC_COMBO_ALIGNMENT);
  111. CString str;
  112. str.LoadString(IDS_LEFT);
  113. pBox->AddString(str);
  114. str.LoadString(IDS_RIGHT);
  115. pBox->AddString(str);
  116. str.LoadString(IDS_CENTER);
  117. pBox->AddString(str);
  118. if (m_nWordWrap == 0)
  119. {
  120. GetDlgItem(IDC_COMBO_ALIGNMENT)->EnableWindow(FALSE);
  121. GetDlgItem(IDC_TEXT_ALIGNMENT)->EnableWindow(FALSE);
  122. }
  123. if ( m_pf.wEffects & PFE_RTLPARA )
  124. {
  125. m_nLeft = (m_pf.dwMask & PFM_RIGHTINDENT) ? m_pf.dxRightIndent : DDXM_BLANK;
  126. if (m_pf.dwMask & PFM_OFFSET)
  127. {
  128. m_nFirst = -m_pf.dxOffset;
  129. m_nRight = (m_pf.dwMask & PFM_STARTINDENT) ?
  130. m_pf.dxStartIndent + m_pf.dxOffset : DDXM_BLANK;
  131. }
  132. else
  133. m_nRight = m_nFirst = DDXM_BLANK;
  134. }
  135. else
  136. {
  137. m_nRight = (m_pf.dwMask & PFM_RIGHTINDENT) ? m_pf.dxRightIndent : DDXM_BLANK;
  138. if (m_pf.dwMask & PFM_OFFSET)
  139. {
  140. m_nFirst = -m_pf.dxOffset;
  141. m_nLeft = (m_pf.dwMask & PFM_STARTINDENT) ?
  142. m_pf.dxStartIndent + m_pf.dxOffset : DDXM_BLANK;
  143. }
  144. else
  145. m_nLeft = m_nFirst = DDXM_BLANK;
  146. }
  147. CCSDialog::OnInitDialog();
  148. return TRUE; // return TRUE unless you set the focus to a control
  149. // EXCEPTION: OCX Property Pages should return FALSE
  150. }