/*
   winLAME - a frontend for the LAME encoding engine
   Copyright (c) 2000-2006 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: wlOggVorbisSettingsPage.h,v 1.14 2009/11/02 19:54:26 vividos Exp $

*/
/*! \file wlOggVorbisSettingsPage.h

   \brief contains the settings page for the ogg vorbis encoder

*/
/*! \ingroup userinterface */
/*! @{ */

// prevent multiple including
#ifndef __wloggvorbissettingspage_h_
#define __wloggvorbissettingspage_h_

// needed includes
#include "resource.h"
#include "wlPageBase.h"
#include "wlCommonStuff.h"


//! ogg vorbis settings page class

class wlOggVorbisSettingsPage: public wlPageBase
{
public:
   //! ctor
   wlOggVorbisSettingsPage()
   {
      IDD = IDD_DLG_OGGVORBIS;
      captionID = IDS_DLG_CAP_OGGVORBIS;
      descID = IDS_DLG_DESC_OGGVORBIS;
      helpID = IDS_HTML_OGGVORBIS;
   }

   // message map
BEGIN_MSG_MAP(wlOggVorbisSettingsPage)
   MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
   COMMAND_HANDLER(IDC_OGGV_RADIO_BRMODE1, BN_CLICKED, OnSetBitrateMode)
   COMMAND_HANDLER(IDC_OGGV_RADIO_BRMODE2, BN_CLICKED, OnSetBitrateMode)
   COMMAND_HANDLER(IDC_OGGV_RADIO_BRMODE3, BN_CLICKED, OnSetBitrateMode)
   COMMAND_HANDLER(IDC_OGGV_RADIO_BRMODE4, BN_CLICKED, OnSetBitrateMode)
   COMMAND_HANDLER(IDC_OGGV_EDIT_NOM_BITRATE, EN_CHANGE, OnChangeEditNominalBitrate)
   MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
   REFLECT_NOTIFICATIONS()
END_MSG_MAP()
// Handler prototypes:
//  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
//  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
//  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

   //! inits the page
   LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

   //! called when the bitrate mode changes
   LRESULT OnSetBitrateMode(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
   {
      // look which radio button was activated
      int pos;
      DDX_Radio(IDC_OGGV_RADIO_BRMODE1,pos,DDX_SAVE);
      UpdateBitrateMode(pos);

      return 0;
   }

   //! called when the text of the "nominal bitrate" edit control changes
   LRESULT OnChangeEditNominalBitrate(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

   //! called when slider is moved
   LRESULT OnHScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
   {
      // check if the vbr quality slider was moved
      if ((HWND)lParam == GetDlgItem(IDC_OGGV_SLIDER_QUALITY))
         UpdateQuality();
      else
         if ((HWND)lParam == GetDlgItem(IDC_OGGV_SPIN_QUICK_QUALITY))
            OnQuickQualitySpin(HIWORD(wParam), LOWORD(wParam));
      return 0;
   }

   //! updates controls when bitrate mode changes
   void UpdateBitrateMode(int pos,bool init=false);

   //! updates quality value
   void UpdateQuality();

   //! user clicked on quick quality spin control
   void OnQuickQualitySpin(WORD wCount, WORD wType);

   // virtual functions from wlPageBase

   // called on entering the page
   virtual void OnEnterPage();

   // called on leaving the page
   virtual bool OnLeavePage();

protected:
   wlFixedValueSpinButtonCtrl bitrateNominalSpin;  //!< nominal bitrate spin button control
   wlFixedValueSpinButtonCtrl bitrateMinSpin;      //!< min bitrate spin button control
   wlFixedValueSpinButtonCtrl bitrateMaxSpin;      //!< max bitrate spin button control
   wlBevelLine bevel1; //!< bevel line
   wlBevelLine bevel2; //!< bevel line
};


//@}

#endif
