1 /*
2  * Copyright (C) 2002 - David W. Durham
3  *
4  * This file is part of ReZound, an audio editing application.
5  *
6  * ReZound is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published
8  * by the Free Software Foundation; either version 2 of the License,
9  * or (at your option) any later version.
10  *
11  * ReZound is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
19  */
20 
21 #include "CRezSaveParametersDialog.h"
22 
23 #include <stdexcept>
24 #include <istring>
25 
26 #include "../backend/CActionParameters.h"
27 
28 FXDEFMAP(CRezSaveParametersDialog) CRezSaveParametersDialogMap[]=
29 {
30 //	Message_Type			ID								Message_Handler
31 	//FXMAPFUNC(SEL_CHANGED,		CRezSaveParametersDialog::ID_SAMPLE_FORMAT_COMBOBOX,	CRezSaveParametersDialog::onSampleFormatComboBox),
32 };
33 
34 
FXIMPLEMENT(CRezSaveParametersDialog,CActionParamDialog,CRezSaveParametersDialogMap,ARRAYNUMBER (CRezSaveParametersDialogMap))35 FXIMPLEMENT(CRezSaveParametersDialog,CActionParamDialog,CRezSaveParametersDialogMap,ARRAYNUMBER(CRezSaveParametersDialogMap))
36 
37 CRezSaveParametersDialog::CRezSaveParametersDialog(FXWindow *mainWindow) :
38 	CActionParamDialog(mainWindow)
39 {
40 	setTitle(N_("ReZound Save Parameters"));
41 
42 	FXPacker *p=newVertPanel(NULL);
43 		vector<string> sampleFormats;
44 			sampleFormats.push_back(_("8 Bit Integer"));
45 			sampleFormats.push_back(_("16 Bit Integer"));
46 			sampleFormats.push_back(_("24 Bit Integer"));
47 			sampleFormats.push_back(_("32 Bit Integer"));
48 			sampleFormats.push_back(_("32 Bit Float"));
49 		FXComboTextParamValue *sampleFormat=addComboTextEntry(p,N_("Sample Format"),sampleFormats,CActionParamDialog::cpvtAsInteger,"");
50 }
51 
indexToSampleFormat(int index)52 static AudioEncodingTypes indexToSampleFormat(int index)
53 {
54 	switch(index)
55 	{
56 	case 0: return aetPCMSigned8BitInteger;
57 	case 1: return aetPCMSigned16BitInteger;
58 	case 2: return aetPCMSigned24BitInteger;
59 	case 3: return aetPCMSigned32BitInteger;
60 	case 4: return aetPCM32BitFloat;
61 	default: throw runtime_error(string(__func__)+" -- internal error -- unhandled index: "+istring(index));
62 	}
63 }
64 
sampleFormatToIndex(AudioEncodingTypes fmt)65 static int sampleFormatToIndex(AudioEncodingTypes fmt)
66 {
67 	switch(fmt)
68 	{
69 	case aetPCMSigned8BitInteger: return 0;
70 	case aetPCMSigned16BitInteger: return 1;
71 	case aetPCMSigned24BitInteger: return 2;
72 	case aetPCMSigned32BitInteger: return 3;
73 	case aetPCM32BitFloat: return 4;
74 	default: throw runtime_error(string(__func__)+" -- internal error -- unhandled format: "+istring(fmt));
75 	}
76 }
77 
show(AFrontendHooks::RezSaveParameters & parameters)78 bool CRezSaveParametersDialog::show(AFrontendHooks::RezSaveParameters &parameters)
79 {
80 	CActionParameters actionParameters(NULL);
81 
82 	// set from defaults
83 	getComboText("Sample Format")->setCurrentItem(sampleFormatToIndex(parameters.audioEncodingType));
84 
85 	if(CActionParamDialog::show(NULL,&actionParameters))
86 	{
87 		parameters.audioEncodingType=indexToSampleFormat(actionParameters.getValue<unsigned>("Sample Format"));
88 		return true;
89 	}
90 	else
91 		return false;
92 }
93 
94