Options.cpp
上传用户:lqriiqpl
上传日期:2022-07-04
资源大小:258k
文件大小:4k
源码类别:

文件操作

开发平台:

Visual C++

  1. // Options.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "Text2PDF.h"
  5. #include "Options.h"
  6. #include "CommonDef.h"
  7. #include "pdflib.hpp"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // COptions dialog
  15. COptions::COptions(CWnd* pParent /*=NULL*/)
  16. : CDialog(COptions::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(COptions)
  19. m_Bottom = MARGIN_BOTTOM;
  20. m_Left = MARGIN_LEFT;
  21. m_Right = MARGIN_RIGHT;
  22. m_Top = MARGIN_TOP;
  23. m_PageSizePoints = _T("");
  24. m_Launch = FALSE;
  25. //}}AFX_DATA_INIT
  26. }
  27. void COptions::DoDataExchange(CDataExchange* pDX)
  28. {
  29. CDialog::DoDataExchange(pDX);
  30. //{{AFX_DATA_MAP(COptions)
  31. DDX_Control(pDX, IDC_PAGE_SIZE, m_PageSize);
  32. DDX_Control(pDX, IDC_OPEN_MODE, m_OpenMode);
  33. DDX_Control(pDX, IDC_OPEN_ACTION, m_OpenAction);
  34. DDX_Control(pDX, IDC_EFFECT, m_Effect);
  35. DDX_Text(pDX, IDC_BOTTOM, m_Bottom);
  36. DDV_MinMaxFloat(pDX, m_Bottom, 0.f, 100.f);
  37. DDX_Text(pDX, IDC_LEFT, m_Left);
  38. DDV_MinMaxFloat(pDX, m_Left, 0.f, 100.f);
  39. DDX_Text(pDX, IDC_RIGHT, m_Right);
  40. DDV_MinMaxFloat(pDX, m_Right, 0.f, 100.f);
  41. DDX_Text(pDX, IDC_TOP, m_Top);
  42. DDV_MinMaxFloat(pDX, m_Top, 0.f, 100.f);
  43. DDX_Text(pDX, IDC_PAGE_SIZE_POINTS, m_PageSizePoints);
  44. DDX_Check(pDX, IDC_LAUNCH_PDF, m_Launch);
  45. //}}AFX_DATA_MAP
  46. }
  47. BEGIN_MESSAGE_MAP(COptions, CDialog)
  48. //{{AFX_MSG_MAP(COptions)
  49. ON_CBN_SELCHANGE(IDC_PAGE_SIZE, OnSelchangePageSize)
  50. //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52. /////////////////////////////////////////////////////////////////////////////
  53. // COptions message handlers
  54. BOOL COptions::OnInitDialog() 
  55. {
  56. CDialog::OnInitDialog();
  57. m_Bottom=PageSpec.Bottom;
  58. m_Top=PageSpec.Top;
  59. m_Left=PageSpec.Left;
  60. m_Right=PageSpec.Right;
  61. m_Launch=PageSpec.Launch;
  62. m_OpenAction.SetCurSel(PageSpec.OpenAction);
  63. m_OpenMode.SetCurSel(PageSpec.OpenMode);
  64. m_PageSize.SetCurSel(PageSpec.PageSize);
  65. m_Effect.SetCurSel(PageSpec.Effect);
  66. OnSelchangePageSize();
  67. UpdateData(FALSE);
  68. return TRUE;  // return TRUE unless you set the focus to a control
  69.               // EXCEPTION: OCX Property Pages should return FALSE
  70. }
  71. void COptions::SetParameter(struct _PageSpec _pageSpec)
  72. {
  73. PageSpec=_pageSpec;
  74. }
  75. struct _PageSpec COptions::GetParameter()
  76. {
  77. return PageSpec;
  78. }
  79. void COptions::OnOK() 
  80. {
  81. UpdateData(TRUE);
  82. PageSpec.Bottom=m_Bottom;
  83. PageSpec.Left=m_Left;
  84. PageSpec.Right=m_Right;
  85. PageSpec.Top=m_Top;
  86. PageSpec.Launch=m_Launch;
  87. PageSpec.Effect=m_Effect.GetCurSel();
  88. PageSpec.OpenAction=m_OpenAction.GetCurSel();
  89. PageSpec.OpenMode=m_OpenMode.GetCurSel();
  90. PageSpec.PageSize=m_PageSize.GetCurSel();
  91. CDialog::OnOK();
  92. }
  93. void COptions::OnSelchangePageSize() 
  94. {
  95. switch (m_PageSize.GetCurSel())
  96. {
  97. case 0: //A0
  98. m_PageSizePoints.Format(SIZE_POINT_STR, a0_width, a0_height);
  99. break;
  100. case 1: //A1
  101. m_PageSizePoints.Format(SIZE_POINT_STR, a1_width, a1_height);
  102. break;
  103. case 2: //A2
  104. m_PageSizePoints.Format(SIZE_POINT_STR, a2_width, a2_height);
  105. break;
  106. case 3: //A3
  107. m_PageSizePoints.Format(SIZE_POINT_STR, a3_width, a3_height);
  108. break;
  109. case 4: //A4
  110. m_PageSizePoints.Format(SIZE_POINT_STR, a4_width, a4_height);
  111. break;
  112. case 5: //A5
  113. m_PageSizePoints.Format(SIZE_POINT_STR, a5_width, a5_height);
  114. break;
  115. case 6: //A6
  116. m_PageSizePoints.Format(SIZE_POINT_STR, a6_width, a6_height);
  117. break;
  118. case 7: //B5
  119. m_PageSizePoints.Format(SIZE_POINT_STR, b5_width, b5_height);
  120. break;
  121. case 8: //letter
  122. m_PageSizePoints.Format(SIZE_POINT_STR, letter_width, letter_height);
  123. break;
  124. case 9: //legal
  125. m_PageSizePoints.Format(SIZE_POINT_STR, legal_width, legal_height);
  126. break;
  127. case 10: //ledger
  128. m_PageSizePoints.Format(SIZE_POINT_STR, ledger_width, ledger_height);
  129. break;
  130. }
  131. UpdateData(FALSE);
  132. }