view src/win32/RewindInterval.cpp @ 2:3549bbe597ed

adding makefile.am
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:47 -0600
parents f9f4f1b99eed
children
line wrap: on
line source
1 // RewindInterval.cpp : implementation file
2 //
4 #include "stdafx.h"
5 #include <cmath>
6 #include "resource.h"
7 #include "RewindInterval.h"
8 #include "VBA.h"
10 /////////////////////////////////////////////////////////////////////////////
11 // RewindInterval dialog
13 RewindInterval::RewindInterval(float interval, int slots, CWnd*pParent /*=NULL*/)
14 : CDialog(RewindInterval::IDD, pParent)
15 {
16 //{{AFX_DATA_INIT(RewindInterval)
17 // NOTE: the ClassWizard will add member initialization here
18 //}}AFX_DATA_INIT
19 this->interval = interval;
20 this->slots = slots;
21 }
23 void RewindInterval::DoDataExchange(CDataExchange*pDX)
24 {
25 CDialog::DoDataExchange(pDX);
26 //{{AFX_DATA_MAP(RewindInterval)
27 DDX_Control(pDX, IDC_INTERVAL, m_interval);
28 DDX_Control(pDX, IDC_REWINDSLOTS, m_slots);
29 //}}AFX_DATA_MAP
30 }
32 BEGIN_MESSAGE_MAP(RewindInterval, CDialog)
33 //{{AFX_MSG_MAP(RewindInterval)
34 ON_BN_CLICKED(ID_CANCEL, OnCancel)
35 ON_BN_CLICKED(ID_OK, OnOk)
36 //}}AFX_MSG_MAP
37 END_MESSAGE_MAP()
39 /////////////////////////////////////////////////////////////////////////////
40 // RewindInterval message handlers
42 void RewindInterval::OnCancel()
43 {
44 EndDialog(-1);
45 }
47 void RewindInterval::OnOk()
48 {
49 CString buffer, buffer2;
51 m_interval.GetWindowText(buffer);
52 m_slots.GetWindowText(buffer2);
54 float interval = (float)atof(buffer);
55 int slots = atoi(buffer2);
57 if (interval >= 0 && (int)interval <= 600)
58 {
59 if (slots >= 0 && slots <= MAX_REWIND_SLOTS)
60 {
61 int iInterval = (int)(interval*6.0f + 0.5f);
62 if (interval > 0 && iInterval == 0)
63 iInterval = 1;
64 EndDialog(iInterval | (slots << 16));
65 theApp.winAccelMgr.UpdateMenu(theApp.menu);
66 }
67 else
68 systemMessage(IDS_INVALID_INTERVAL_VALUE,
69 "Invalid rewind slot amount. Please enter a number "
70 "between 0 and 128 slots");
71 }
72 else
73 systemMessage(IDS_INVALID_INTERVAL_VALUE,
74 "Invalid rewind interval value. Please enter a number "
75 "between 0 and 600 seconds");
76 }
78 BOOL RewindInterval::OnInitDialog()
79 {
80 CDialog::OnInitDialog();
82 m_interval.LimitText(5);
83 m_slots.LimitText(3);
85 CString buffer, buffer2;
86 buffer.Format("%.1f", interval);
87 m_interval.SetWindowText(buffer);
88 buffer2.Format("%d", slots);
89 m_slots.SetWindowText(buffer2);
91 CenterWindow();
93 return TRUE; // return TRUE unless you set the focus to a control
94 // EXCEPTION: OCX Property Pages should return FALSE
95 }