diff src/win32/RewindInterval.cpp @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/RewindInterval.cpp	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,96 @@
     1.4 +// RewindInterval.cpp : implementation file
     1.5 +//
     1.6 +
     1.7 +#include "stdafx.h"
     1.8 +#include <cmath>
     1.9 +#include "resource.h"
    1.10 +#include "RewindInterval.h"
    1.11 +#include "VBA.h"
    1.12 +
    1.13 +/////////////////////////////////////////////////////////////////////////////
    1.14 +// RewindInterval dialog
    1.15 +
    1.16 +RewindInterval::RewindInterval(float interval, int slots, CWnd*pParent /*=NULL*/)
    1.17 +	: CDialog(RewindInterval::IDD, pParent)
    1.18 +{
    1.19 +	//{{AFX_DATA_INIT(RewindInterval)
    1.20 +	// NOTE: the ClassWizard will add member initialization here
    1.21 +	//}}AFX_DATA_INIT
    1.22 +	this->interval = interval;
    1.23 +	this->slots    = slots;
    1.24 +}
    1.25 +
    1.26 +void RewindInterval::DoDataExchange(CDataExchange*pDX)
    1.27 +{
    1.28 +	CDialog::DoDataExchange(pDX);
    1.29 +	//{{AFX_DATA_MAP(RewindInterval)
    1.30 +	DDX_Control(pDX, IDC_INTERVAL, m_interval);
    1.31 +	DDX_Control(pDX, IDC_REWINDSLOTS, m_slots);
    1.32 +	//}}AFX_DATA_MAP
    1.33 +}
    1.34 +
    1.35 +BEGIN_MESSAGE_MAP(RewindInterval, CDialog)
    1.36 +//{{AFX_MSG_MAP(RewindInterval)
    1.37 +ON_BN_CLICKED(ID_CANCEL, OnCancel)
    1.38 +ON_BN_CLICKED(ID_OK, OnOk)
    1.39 +//}}AFX_MSG_MAP
    1.40 +END_MESSAGE_MAP()
    1.41 +
    1.42 +/////////////////////////////////////////////////////////////////////////////
    1.43 +// RewindInterval message handlers
    1.44 +
    1.45 +void RewindInterval::OnCancel()
    1.46 +{
    1.47 +	EndDialog(-1);
    1.48 +}
    1.49 +
    1.50 +void RewindInterval::OnOk()
    1.51 +{
    1.52 +	CString buffer, buffer2;
    1.53 +
    1.54 +	m_interval.GetWindowText(buffer);
    1.55 +	m_slots.GetWindowText(buffer2);
    1.56 +
    1.57 +	float interval = (float)atof(buffer);
    1.58 +	int   slots    = atoi(buffer2);
    1.59 +
    1.60 +	if (interval >= 0 && (int)interval <= 600)
    1.61 +	{
    1.62 +		if (slots >= 0 && slots <= MAX_REWIND_SLOTS)
    1.63 +		{
    1.64 +			int iInterval = (int)(interval*6.0f + 0.5f);
    1.65 +			if (interval > 0 && iInterval == 0)
    1.66 +				iInterval = 1;
    1.67 +			EndDialog(iInterval | (slots << 16));
    1.68 +			theApp.winAccelMgr.UpdateMenu(theApp.menu);
    1.69 +		}
    1.70 +		else
    1.71 +			systemMessage(IDS_INVALID_INTERVAL_VALUE,
    1.72 +			              "Invalid rewind slot amount. Please enter a number "
    1.73 +			              "between 0 and 128 slots");
    1.74 +	}
    1.75 +	else
    1.76 +		systemMessage(IDS_INVALID_INTERVAL_VALUE,
    1.77 +		              "Invalid rewind interval value. Please enter a number "
    1.78 +		              "between 0 and 600 seconds");
    1.79 +}
    1.80 +
    1.81 +BOOL RewindInterval::OnInitDialog()
    1.82 +{
    1.83 +	CDialog::OnInitDialog();
    1.84 +
    1.85 +	m_interval.LimitText(5);
    1.86 +	m_slots.LimitText(3);
    1.87 +
    1.88 +	CString buffer, buffer2;
    1.89 +	buffer.Format("%.1f", interval);
    1.90 +	m_interval.SetWindowText(buffer);
    1.91 +	buffer2.Format("%d", slots);
    1.92 +	m_slots.SetWindowText(buffer2);
    1.93 +
    1.94 +	CenterWindow();
    1.95 +
    1.96 +	return TRUE; // return TRUE unless you set the focus to a control
    1.97 +	             // EXCEPTION: OCX Property Pages should return FALSE
    1.98 +}
    1.99 +