home *** CD-ROM | disk | FTP | other *** search
/ PC Elektro 3 / PC-Elektro-3-cd1.bin / KBan 2.0 / KBANSRC.LZH / SRC / PROG / VIEW / APTPIN.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-23  |  2.5 KB  |  106 lines

  1. // the implementation of class CAptChgPinDialog
  2. // Copyright (C) 1997 Kazutaka Hirata <khirata@jove.acs.unt.edu>
  3.  
  4. #include "../stdafx.h"
  5.  
  6. #include "aptpin.h"
  7.  
  8. BEGIN_MESSAGE_MAP(CAptChgPinDialog, CAptCommonDialog)
  9. END_MESSAGE_MAP()
  10.  
  11. CEdit& CAptChgPinDialog::ctlWidth(void)
  12. {
  13.   return *(CEdit*)GetDlgItem(IDC_WIDTH);
  14. }
  15.  
  16. CEdit& CAptChgPinDialog::ctlHeight(void)
  17. {
  18.   return *(CEdit*)GetDlgItem(IDC_HEIGHT);
  19. }
  20.  
  21. CEdit& CAptChgPinDialog::ctlDrill(void)
  22. {
  23.   return *(CEdit*)GetDlgItem(IDC_DRILL);
  24. }
  25.  
  26. void CAptChgPinDialog::SetAll(const APERTURE& apt)
  27. {
  28.   CheckRadioButton(IDC_ROUND, IDC_RECTANGLE, IDC_ROUND + apt.type());
  29.   SetTextInt(&ctlWidth (), apt.width ());
  30.   SetTextInt(&ctlHeight(), apt.height());
  31.   SetTextInt(&ctlDrill (), apt.drill ());
  32. }
  33.  
  34. CAptChgPinDialog::CAptChgPinDialog(
  35.   CWnd* pParentWnd,
  36.   const APT_TABLE& apt_table,
  37.   const APT_TABLE& apt_table_purged,
  38.   const APERTURE& prev
  39. )
  40.   : CAptCommonDialog(pParentWnd, IDD_APTCHG_PIN, apt_table, apt_table_purged, prev),
  41.     m_width         (1),
  42.     m_height        (1),
  43.     m_drill         (1)
  44. {
  45. }
  46.  
  47. BOOL CAptChgPinDialog::OnInitDialog(void)
  48. {
  49.   CDialog::OnInitDialog();
  50.  
  51.   ctlWidth ().LimitText(5);
  52.   ctlHeight().LimitText(5);
  53.   ctlDrill ().LimitText(5);
  54.  
  55.   RegisterAllItems();
  56.   if(m_apt_table.size() != 0) {
  57.     SetAll(m_apt_table[m_index]);
  58.     ctlExisting().SetCurSel(m_index);
  59.   }
  60.  
  61.   return TRUE;
  62. }
  63.  
  64. void CAptChgPinDialog::OnOK(void)
  65. {
  66.   CDialog::OnOK();
  67.   if((m_type == APERTURE::APT_ROUND )
  68.   || (m_type == APERTURE::APT_SQUARE)) {
  69.     m_height = 0;
  70.   }
  71.   m_aperture.set_all(m_type,
  72.     unit_change_micron2kban(m_width),
  73.     unit_change_micron2kban(m_height),
  74.     unit_change_micron2kban(m_drill)
  75.   );
  76.   if(!m_apt_table.is_included(m_aperture)) {
  77.     m_apt_table.push_back(m_aperture);
  78.     m_apt_table.sort();
  79.   }
  80. }
  81.  
  82. void CAptChgPinDialog::DoDataExchange(CDataExchange* pDX)
  83. {
  84.   CDialog::DoDataExchange(pDX);
  85.   DDX_Radio    (pDX, IDC_ROUND, m_type);
  86.   DDX_Text     (pDX, IDC_WIDTH, m_width);
  87.   DDV_MinMaxInt(pDX, m_width, 1, 10000);
  88.   DDX_Text     (pDX, IDC_HEIGHT, m_height);
  89.   DDV_MinMaxInt(pDX, m_height, 0, 10000);
  90.   DDX_Text     (pDX, IDC_DRILL, m_drill);
  91.   DDV_MinMaxInt(pDX, m_drill, 0, 10000);
  92.   DDX_LBIndex  (pDX, IDC_EXISTING, m_index);
  93. }
  94.  
  95. void CAptChgPinDialog::AddAperture(const APERTURE& apt)
  96. {
  97.   char str[50];
  98.   sprintf(str, "%-9s %4d:%4d,%4d",
  99.     apt.type_name(),
  100.     apt.width(),
  101.     apt.height(),
  102.     apt.drill()
  103.   );
  104.   ctlExisting().AddString(str);
  105. }
  106.