
#define	STRICT

#include "foo_dsp_ssrc.h"
#include "Config.h"

const int	List_SampleRate[]=
{11025, 22050, 24000, 32000, 44100, 48000, 88200, 96000, 176400, 192000};

const WCHAR*	List_Quality[]=
{L"Low", L"Normal", L"High", L"Top", L"Ultra"};

DialogOption::DialogOption(HWND hParentWnd, PARAM_GLOBAL* _ParamGlobal) :
	SDialog(hParentWnd, IDD_CONFIG)
{
	ParamGlobal = _ParamGlobal;
}

DialogOption::~DialogOption(void)
{
	delete SampleRate;
	delete Quality;
}

bool
DialogOption::WmInitDialog(Org_Mes* OrgMes, HWND hwnd, LONG lInitParam)
{
	OrgMes->ExecMessage = true;
	SDialog::WmInitDialog(OrgMes, hwnd, lInitParam);

	SampleRate = new SComboBox(this, IDC_SAMPLE_RATE);
	Quality = new SComboBox(this, IDC_QUALITY);

	for(int Idx = 0; Idx < 10; Idx++) {
		WCHAR	StrSampleRate[8];

		_itow(List_SampleRate[Idx], StrSampleRate, 10);
		SampleRate->AddString(StrSampleRate);
	}

	SetDlgItemInt(IDC_SAMPLE_RATE, ParamGlobal->srate);

	for(int Idx = 0; Idx < 5; Idx++) {
		Quality->AddString(List_Quality[Idx]);
	}

	Quality->SetCurSel(ParamGlobal->quality);

	return true;
}

void
DialogOption::CmOk(void)
{
	int		NewSampleRate = GetDlgItemInt(IDC_SAMPLE_RATE);

	if(NewSampleRate < 6000) {
		NewSampleRate = 6000;
	} else if(NewSampleRate > 192000) {
		NewSampleRate = 192000;
	}

	ParamGlobal->srate = NewSampleRate;

	ParamGlobal->quality = Quality->GetCurSel();

	SDialog::CmOk();
}

