annotate src/win32/RewindInterval.cpp @ 4:5f6f2134e8ce

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