gehe zur Dokumentation dieser Datei00001
00025
00026 #include "wx/wxprec.h"
00027
00028 #ifdef __BORLANDC__
00029 #pragma hdrstop
00030 #endif
00031
00032 #ifndef WX_PRECOMP
00033 #include "wx/wx.h"
00034 #endif
00035
00036
00037 #include "InputDevDlg.h"
00038
00043 IMPLEMENT_DYNAMIC_CLASS( InputDevDlg, InputDevDlgBase )
00044
00045 BEGIN_EVENT_TABLE( InputDevDlg, InputDevDlgBase )
00046 EVT_CHOICE( XRCID("DeviceChoice"), InputDevDlg::OnChoiceSelected )
00047 EVT_BUTTON( ::wxID_REMOVE, InputDevDlg::OnRemoveClick )
00048 EVT_FILEPICKER_CHANGED(XRCID ("MidiFilePicker"),
00049 InputDevDlg::OnFileChanged)
00050 EVT_FILEPICKER_CHANGED(XRCID ("GuidoFilePicker"),
00051 InputDevDlg::OnFileChanged)
00052 END_EVENT_TABLE()
00053
00057
00058
00059 InputDevDlg::InputDevDlg( wxWindow* parent):InputDevDlgBase(parent)
00060 {
00061 DeviceChoice->Clear();
00062 DeviceChoice->Append(_("MIDI Device"),new TypeData(DTMidiPort));
00063 DeviceChoice->Append(_("MIDI file"),new TypeData(DTMidiFile));
00064 DeviceChoice->Append(_("GUIDO file"),new TypeData(DTGis));
00065
00066 TypeBox = DeviceChoice->GetContainingSizer();
00067 PortBox = PortChoice->GetContainingSizer();
00068 MidiFileBox = MidiFilePicker->GetContainingSizer();
00069 DEBUGLOG (other,_T ("MidiFilePicker Growable: %d"), MidiFilePicker->IsPickerCtrlGrowable());
00070 if (MidiFilePicker->HasTextCtrl()) {
00071 DEBUGLOG (other,_T ("MidiFileTextCtrl Growable: %d"),
00072 MidiFilePicker->IsTextCtrlGrowable());
00073 MidiFilePicker->SetTextCtrlGrowable(true);
00074 DEBUGLOG (other,_T ("MidiFileTextCtrl Growable: %d"),
00075 MidiFilePicker->IsTextCtrlGrowable());
00076 }
00077 GuidoFileBox = GuidoFilePicker->GetContainingSizer();
00078
00079
00080
00081
00082 }
00083
00088 bool InputDevDlg::ShowToolTips()
00089 {
00090 return TRUE;
00091 }
00092
00097 wxBitmap InputDevDlg::GetBitmapResource( const wxString& name )
00098 {
00099
00100 return wxNullBitmap;
00101 }
00102
00107 wxIcon InputDevDlg::GetIconResource( const wxString& name )
00108 {
00109
00110 return wxNullIcon;
00111 }
00112
00117 void InputDevDlg::OnChoiceSelected( wxCommandEvent& event )
00118 {
00119 UpdateLayout(GetType());
00120 event.Skip();
00121 }
00122
00123 void InputDevDlg::UpdateLayout(DevType type)
00124 {
00125 if (type == DTNotSet) {
00126 if (FindType (type) == wxNOT_FOUND)
00127 DeviceChoice->Insert (_ ("Choose device type"),
00128 0,
00129 new TypeData (type));
00130 } else {
00131 int notset = FindType (DTNotSet);
00132 if (notset != wxNOT_FOUND) {
00133 DeviceChoice->Delete (notset);
00134 }
00135
00136 if (type == DTUnknown) {
00137 if (FindType (type) == wxNOT_FOUND)
00138 DeviceChoice->Insert (_ ("Unknown device type"),
00139 0,
00140 new TypeData (type));
00141 }
00142 }
00143 int Type = FindType (type);
00144 DeviceChoice -> SetSelection (Type);
00145
00146 DEBUGLOG (other, _T("%d"),type);
00147 wxSizer * sizer = GetSizer();
00148
00149 DEBUGLOG (other, _T("%d"),DTMidiPort);
00150 sizer->Show(PortBox, type == DTMidiPort, true);
00151 DEBUGLOG (other, _T("%d"),DTMidiFile);
00152 sizer->Show(MidiFileBox, (type == DTMidiFile), true);
00153 DEBUGLOG (other, _T("%d"),DTGis);
00154 sizer->Show(GuidoFileBox, (type == DTGis) , true);
00155
00156
00157
00158 Layout();
00159 GetSizer()->SetSizeHints(this);
00160 Fit();
00161 }
00162
00163
00168 void InputDevDlg::OnRemoveClick( wxCommandEvent& event )
00169 {
00170 EndModal(::wxID_REMOVE);
00171 }
00172
00173 void InputDevDlg::OnFileChanged ( wxFileDirPickerEvent & event )
00174 {
00175 DEBUGLOG (other,_T ("Path changed: %s"),event.GetPath().c_str());
00176 GetSizer()->SetSizeHints(this);
00177 Fit();
00178 }
00179
00180
00181 int InputDevDlg::FindType (DevType t)
00182 {
00183 TypeData * Data;
00184 for (unsigned int i = 0; i < DeviceChoice->GetCount(); i++) {
00185 DEBUGLOG (other,_T ("Choice #%d of %d"),i, DeviceChoice->GetCount());
00186 Data = (TypeData *)DeviceChoice->GetClientObject(i);
00187 if (Data) {
00188 if (*Data == t) return i;
00189 }
00190 }
00191 return wxNOT_FOUND;
00192 }
00193
00194