home *** CD-ROM | disk | FTP | other *** search
/ 3D Games - Real-time Rend…ng & Software Technology / 3D Games - Real-time Rendering & Software Technology.iso / flysdk / frontend / flyEditor / DlgEditValue.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-06  |  2.2 KB  |  105 lines

  1. // DlgEditValue.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "flyeditor.h"
  6. #include "DlgEditValue.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CDlgEditValue dialog
  16.  
  17.  
  18. CDlgEditValue::CDlgEditValue(CWnd* pParent /*=NULL*/)
  19.     : CDialog(CDlgEditValue::IDD, pParent)
  20. {
  21.     //{{AFX_DATA_INIT(CDlgEditValue)
  22.         // NOTE: the ClassWizard will add member initialization here
  23.     //}}AFX_DATA_INIT
  24. }
  25.  
  26.  
  27. void CDlgEditValue::DoDataExchange(CDataExchange* pDX)
  28. {
  29.     CDialog::DoDataExchange(pDX);
  30.     //{{AFX_DATA_MAP(CDlgEditValue)
  31.     DDX_Control(pDX, IDC_EDIT1, m_edit);
  32.     //}}AFX_DATA_MAP
  33. }
  34.  
  35.  
  36. BEGIN_MESSAGE_MAP(CDlgEditValue, CDialog)
  37.     //{{AFX_MSG_MAP(CDlgEditValue)
  38.     ON_EN_KILLFOCUS(IDC_EDIT1, OnKillfocusEdit1)
  39.     //}}AFX_MSG_MAP
  40. END_MESSAGE_MAP()
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CDlgEditValue message handlers
  44.  
  45. void CDlgEditValue::OnKillfocusEdit1() 
  46. {
  47.     m_edit.GetWindowText(value,255);    
  48. }
  49.  
  50. BOOL CDlgEditValue::OnInitDialog() 
  51. {
  52.     CDialog::OnInitDialog();
  53.     
  54.     m_edit.SetWindowText(value);
  55.     
  56.     char str[256]="Edit Value";
  57.     switch(pd->type)
  58.     {
  59.     case 'v':
  60.         strcat(str," (vector)");
  61.         break;
  62.     case 'f':
  63.         strcat(str," (float)");
  64.         break;
  65.     case 'a':
  66.         strcat(str," (angle)");
  67.         break;
  68.     case 'i':
  69.         strcat(str," (int)");
  70.         break;
  71.     case 's':
  72.         strcat(str," (string)");
  73.         break;
  74.     }
  75.  
  76.     return TRUE;  // return TRUE unless you set the focus to a control
  77.                   // EXCEPTION: OCX Property Pages should return FALSE
  78. }
  79.  
  80. void CDlgEditValue::OnOK() 
  81. {
  82.     char buf[256];
  83.     m_edit.GetWindowText(buf,255);
  84.     switch(pd->type)
  85.     {
  86.     case 'v':
  87.         sscanf(buf,"%f %f %f",&((float *)pd->data)[0],&((float *)pd->data)[1],&((float *)pd->data)[2]);
  88.         break;
  89.     case 'f':
  90.         sscanf(buf,"%f",(float *)pd->data);
  91.         break;
  92.     case 'a':
  93.         sscanf(buf,"%f",(float *)pd->data);
  94.         *((float *)pd->data)=(float)cos(*((float *)pd->data)*PiOver180);
  95.         break;
  96.     case 'i':
  97.         sscanf(buf,"%i",(int *)pd->data);
  98.         break;
  99.     case 's':
  100.         strcpy((char *)pd->data,buf);
  101.         break;
  102.     }
  103.     CDialog::OnOK();
  104. }
  105.