OutputMidiFileDeviceShape.cpp
gehe zur Dokumentation dieser Datei
00001 // -*-C++ -*-
00070 #include "OutputMidiFileDeviceShape.h"
00071 #include "DevMidF.h"
00072 #include <limits>
00073 
00074 class MidiFileOutputFilterPanel : public MidiFileOutputFilterPanelBase {
00075 public:
00076         MidiFileOutputFilterPanel(wxWindow * parent):MidiFileOutputFilterPanelBase(parent) {}
00080         void SetFromChannel(int current, int min, int max) {
00081                 from_channel->SetRange(min,max);
00082                 from_channel->SetValue(current);
00083         }
00084         int GetFromChannel() const
00085         {
00086                 return from_channel->GetValue();
00087         }
00088         
00089         void SetToChannel(int current, int min, int max) {
00090                 to_channel->SetRange(min,max);
00091                 to_channel->SetValue(current);
00092         }
00093         int GetToChannel() const
00094         {
00095                 return to_channel->GetValue();
00096         }
00097         
00098         void SetAvoidDrumChannel(bool avoid) {
00099                 avoid_drum_channel->SetValue(avoid);
00100         }
00101         bool GetAvoidDrumChannel() const
00102         {
00103                 return avoid_drum_channel->GetValue();
00104         }
00105 };
00106 
00107 
00108 
00109 void MutOutputMidiFileDeviceShape::InitializeDialog(OutputDevDlg * out) const
00110 {
00111         wxASSERT(device);
00112         wxASSERT(device->GetType() == DTMidiFile);
00113         wxASSERT(out);
00114         OutMidiFile * d = static_cast<OutMidiFile *>(device);
00115         out -> SetType(DTMidiFile);
00116         out -> SetMidiFile(d->GetName());
00117         out -> SetMidiFileBendingRange (d -> GetBendingRange());
00118 }
00119 
00120 bool MutOutputMidiFileDeviceShape::readDialog (OutputDevDlg * out)
00121 {
00122         wxASSERT(device);
00123         wxASSERT(device->GetType() == DTMidiFile);
00124         wxASSERT(out);
00125         wxASSERT (out -> GetType() == DTMidiFile);
00126         wxASSERT(dynamic_cast<OutMidiFile *> (device));
00127         OutMidiFile * d = static_cast<OutMidiFile *>(device);
00128         d->SetName (out -> GetMidiFile());
00129         d->SetBendingRange (out -> GetMidiFileBendingRange());
00130         SetLabel (device->GetName());
00131         return true;
00132 }
00133 
00134 wxPanel * MutOutputMidiFileDeviceShape::GetOutputFilterPanel(wxWindow * parent, 
00135                                                          Route * route) const
00136 {
00137         const int maxint = std::numeric_limits<int>().max();
00138         MidiFileOutputFilterPanel * panel = new MidiFileOutputFilterPanel(parent);
00139         if (!panel) return NULL;
00140         OutMidiFile * dev = dynamic_cast<OutMidiFile *> (device);
00141         const int maxchannel = dev?dev->GetMaxChannel():maxint;
00142         const int minchannel = dev?dev->GetMinChannel():0;
00143         if (!route) {
00144                 panel->SetFromChannel(minchannel, minchannel, maxchannel);
00145                 panel->SetToChannel(maxchannel, minchannel, maxchannel);
00146                 panel->SetAvoidDrumChannel(true);
00147                 return panel;
00148         }
00149         panel->SetFromChannel(route->OFrom, minchannel, maxchannel);
00150         panel->SetToChannel(route->OTo, minchannel, maxchannel);
00151         panel->SetAvoidDrumChannel(route->ONoDrum);
00152         return panel;
00153 }
00154 
00155 void MutOutputMidiFileDeviceShape::ReadOutputFilterPanel(wxWindow * panel, Route * route)
00156 {
00157         wxASSERT(route);
00158         MidiFileOutputFilterPanel * pan = dynamic_cast<MidiFileOutputFilterPanel *> (panel);
00159         if (!pan) {
00160                 UNREACHABLEC;
00161                 return;
00162         }
00163         
00164         route->SetOutputFrom(pan->GetFromChannel());
00165         route->SetOutputTo(pan->GetToChannel());
00166         route->OutputAvoidDrumChannel(pan->GetAvoidDrumChannel());
00167 }
00168 
00169 
00170 
00171 IMPLEMENT_DYNAMIC_CLASS(MutOutputMidiFileDeviceShape, MutOutputDeviceShape)
00172 
00173 /*
00174  * \}
00175  */

Erzeugt am Sun Aug 21 2011 10:51:55 für Mutabor von doxygen 1.7.4