/*
   winLAME - a frontend for the LAME encoding engine
   Copyright (c) 2000-2005 Michael Fink

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

   $Id: wlWmaOutputSettingsPage.cpp,v 1.3 2005/09/27 18:30:10 vividos Exp $

*/
/*! \file wlWmaOutputSettingsPage.cpp

   \brief contains implementation of the Wma output settings page

*/

// needed includes
#include "stdafx.h"
#include "wlWmaOutputSettingsPage.h"

// debug helper
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//! suggested bitrate values
static int wlWmaBitrates[] =
{
   32,48,64,80,96,128,160,192,256,320
};

static int wlWmaVBRQuality[] =
{
   10,25,50,75,90,98,100
};

// wlWmaOutputSettingsPage methods

LRESULT wlWmaOutputSettingsPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
   // subclass bevel lines
   bevel1.SubclassWindow(GetDlgItem(IDC_WMA_BEVEL1));

   bitrateSpin.SubclassWindow(GetDlgItem(IDC_WMA_SPIN_BITRATE));
   bitrateSpin.SetBuddy(GetDlgItem(IDC_WMA_EDIT_BITRATE));
   bitrateSpin.SetFixedValues(wlWmaBitrates, sizeof(wlWmaBitrates)/sizeof(wlWmaBitrates[0]));

   qualitySpin.SubclassWindow(GetDlgItem(IDC_WMA_SPIN_QUALITY));
   qualitySpin.SetBuddy(GetDlgItem(IDC_WMA_EDIT_QUALITY));
   qualitySpin.SetFixedValues(wlWmaVBRQuality, sizeof(wlWmaVBRQuality)/sizeof(wlWmaVBRQuality[0]));

   return 1;  // let the system set the focus
}

void wlWmaOutputSettingsPage::OnEnterPage()
{
   // get settings manager
   wlSettingsManager &mgr = pui->getUISettings().settings_manager;
   
   // set output bitrate
   SetDlgItemInt(IDC_WMA_EDIT_BITRATE,mgr.queryValueInt(wlWmaBitrate),FALSE);
   SetDlgItemInt(IDC_WMA_EDIT_QUALITY,mgr.queryValueInt(wlWmaQuality),FALSE);

   // bitrate mode radio buttons
   int value = mgr.queryValueInt(wlWmaBitrateMode);
   DDX_Radio(IDC_WMA_RADIO_BRMODE1,value,DDX_LOAD);
}

bool wlWmaOutputSettingsPage::OnLeavePage()
{
   // get settings manager
   wlSettingsManager &mgr = pui->getUISettings().settings_manager;

   mgr.setValue(wlWmaBitrate,(int)GetDlgItemInt(IDC_WMA_EDIT_BITRATE,NULL,FALSE));
   mgr.setValue(wlWmaQuality,(int)GetDlgItemInt(IDC_WMA_EDIT_QUALITY,NULL,FALSE));

   int value=0;
   DDX_Radio(IDC_WMA_RADIO_BRMODE1,value,DDX_SAVE);
   mgr.setValue(wlWmaBitrateMode,value);

   return true;
}
