Fix scope error with newer GCC.
[spiralsynthmodular.git] / SettingsWindow.C
blobb694afef74c4fd5c74f5efd9f8e7e18fb0feae18
1 /*  SpiralSynthModular
2  *  Copyleft (C) 2002 David Griffiths <dave@pawfal.org>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 #include <stdio.h>
20 #include <FL/Fl_Box.H>
21 #include <FL/Fl_Pixmap.H>
23 #include "SettingsWindow.h"
24 #include "SpiralSound/SpiralInfo.h"
25 #include "GUI/options.xpm"
27 SettingsWindow::SettingsWindow() :
28 Fl_Double_Window(250,275,"SSM Options"),
29 m_App(NULL)
31         color(SpiralInfo::GUICOL_Tool);
32         box(FL_FLAT_BOX);
34         Fl_Pixmap *Icon = new Fl_Pixmap(options_xpm);
35         Fl_Box *IconBox = new Fl_Box(25,30,50,50,"");
36         IconBox->image(Icon);
38         Fl_Box *TextBox = new Fl_Box(180,10,50,20,"SpiralSynth Modular");
39         TextBox->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE);
40         TextBox = new Fl_Box(180,30,50,20,"Constructed by Dave Griffiths");
41         TextBox->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE);
42         TextBox->labelsize(10);
43         TextBox = new Fl_Box(192,40,50,20,"dave@@pawfal.org");
44         TextBox->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE);
45         TextBox->labelsize(10);
46         TextBox = new Fl_Box(180,50,50,20,"www.pawfal.org");
47         TextBox->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE);
48         TextBox->labelsize(10);
49         TextBox = new Fl_Box(180,63,50,20,"We are the music makers");
50         TextBox->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE);
51         TextBox->labelsize(10);
52         TextBox = new Fl_Box(180,73,50,20,"We are the dreamers of dreams");
53         TextBox->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE);
54         TextBox->labelsize(10);
57         Fl_Group *OptionsGrp = new Fl_Group(5,95,240,150,"");
58         OptionsGrp->box(FL_FLAT_BOX);
59         OptionsGrp->color(SpiralInfo::GUICOL_Button);
61         m_Options = new Fl_Pack(5,115,230,100,"Settings");
62         m_Options->color(SpiralInfo::GUICOL_Button);
63         OptionsGrp->add(m_Options);
65         Fl_Box *Name;
66         Fl_Pack *Line;
68         char BufferSize[256];
69         sprintf(BufferSize,"%d",SpiralInfo::BUFSIZE);
71         char FragmentSize[256];
72         sprintf(FragmentSize,"%d",SpiralInfo::FRAGSIZE);
74         char FragmentCount[256];
75         sprintf(FragmentCount,"%d",SpiralInfo::FRAGCOUNT);
77         char Samplerate[256];
78         sprintf(Samplerate,"%d",SpiralInfo::SAMPLERATE);
80         char OutputDevice[256];
81         sprintf(OutputDevice,"%s",SpiralInfo::OUTPUTFILE.c_str());
83         char MidiDevice[256];
84         sprintf(MidiDevice,"%s",SpiralInfo::MIDIFILE.c_str());
86         Line = new Fl_Pack(0,0,100,20,"");
87         Line->type(FL_HORIZONTAL);
88         Name = new Fl_Box(55,0,150,20,"Buffer Size");
89         Name->labelsize(10);
90         Name->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
91         Line->add(Name);
92         m_BufferSize = new Fl_Int_Input(0,0,80,20,"");
93         m_BufferSize->value(BufferSize);
94         Line->add(m_BufferSize);
95         Line->end();
96         m_Options->add(Line);
98         Line = new Fl_Pack(0,0,100,20,"");
99         Line->type(FL_HORIZONTAL);
100         Name = new Fl_Box(55,0,150,20,"Fragment Size");
101         Name->labelsize(10);
102         Name->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
103         Line->add(Name);
104         m_FragmentSize = new Fl_Int_Input(0,0,80,20,"");
105         m_FragmentSize->value(FragmentSize);
106         Line->add(m_FragmentSize);
107         Line->end();
108         m_Options->add(Line);
110         Line = new Fl_Pack(0,0,100,20,"");
111         Line->type(FL_HORIZONTAL);
112         Name = new Fl_Box(55,0,150,20,"Fragment Count (-1 = auto)");
113         Name->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
114         Name->labelsize(10);
115         Line->add(Name);
116         m_FragmentCount = new Fl_Int_Input(0,0,80,20,"");
117         m_FragmentCount->value(FragmentCount);
118         Line->add(m_FragmentCount);
119         Line->end();
120         m_Options->add(Line);
122         Line = new Fl_Pack(0,0,100,20,"");
123         Line->type(FL_HORIZONTAL);
124         Name = new Fl_Box(55,0,150,20,"SampleRate");
125         Name->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
126         Name->labelsize(10);
127         Line->add(Name);
128         m_Samplerate = new Fl_Int_Input(0,0,80,20,"");
129         m_Samplerate->value(Samplerate);
130         Line->add(m_Samplerate);
131         Line->end();
132         m_Options->add(Line);
134         Line = new Fl_Pack(0,0,100,20,"");
135         Line->type(FL_HORIZONTAL);
136         Name = new Fl_Box(55,0,150,20,"Output Device");
137         Name->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
138         Name->labelsize(10);
139         Line->add(Name);
140         m_OutputDevice = new Fl_Input(0,0,80,20,"");
141         m_OutputDevice->value(OutputDevice);
142         Line->add(m_OutputDevice);
143         Line->end();
144         m_Options->add(Line);
146         Line = new Fl_Pack(0,0,100,20,"");
147         Line->type(FL_HORIZONTAL);
148         Name = new Fl_Box(55,0,150,20,"Midi Device");
149         Name->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
150         Name->labelsize(10);
151         Line->add(Name);
152         m_MidiDevice = new Fl_Input(0,0,80,20,"");
153         m_MidiDevice->value(MidiDevice);
154         Line->add(m_MidiDevice);
155         Line->end();
156         m_Options->add(Line);
158         m_Options->end();
160         m_Save = new Fl_Button(140,250,50,20,"Save");
161         m_Save->labelsize(10);
162         m_Save->tooltip("Save these settings");
163         m_Save->callback((Fl_Callback*)cb_Save);
164         add(m_Save);
166         m_Apply = new Fl_Button(195,250,50,20,"Apply");
167         m_Apply->labelsize(10);
168         m_Apply->tooltip("Some plugins may request to save data first");
169         m_Apply->callback((Fl_Callback*)cb_Apply);
170         add(m_Apply);
172         end();
175 SettingsWindow::~SettingsWindow()
179 inline void SettingsWindow::cb_Apply_i(Fl_Button* o, void* v)
181         SpiralInfo::BUFSIZE=(int)atof(m_BufferSize->value());
182         SpiralInfo::FRAGSIZE=(int)atof(m_FragmentSize->value());
183         SpiralInfo::FRAGCOUNT=(int)atof(m_FragmentCount->value());
184         SpiralInfo::SAMPLERATE=(int)atof(m_Samplerate->value());
185         SpiralInfo::OUTPUTFILE=m_OutputDevice->value();
186         SpiralInfo::MIDIFILE=m_MidiDevice->value();
188         assert(m_App);
189         if (m_App)
190         {
191                 m_App->UpdateHostInfo();
192         }
194 void SettingsWindow::cb_Apply(Fl_Button* o, void* v)
195 { ((SettingsWindow*)(o->parent()))->cb_Apply_i(o,v); }
197 inline void SettingsWindow::cb_Save_i(Fl_Button* o, void* v)
199         SpiralInfo::BUFSIZE=(int)atof(m_BufferSize->value());
200         SpiralInfo::FRAGSIZE=(int)atof(m_FragmentSize->value());
201         SpiralInfo::FRAGCOUNT=(int)atof(m_FragmentCount->value());
202         SpiralInfo::SAMPLERATE=(int)atof(m_Samplerate->value());
203         SpiralInfo::OUTPUTFILE=m_OutputDevice->value();
204         SpiralInfo::MIDIFILE=m_MidiDevice->value();
205         SpiralInfo::Get()->SavePrefs();
207 void SettingsWindow::cb_Save(Fl_Button* o, void* v)
208 { ((SettingsWindow*)(o->parent()))->cb_Save_i(o,v); }