InputDevDlg.cpp
gehe zur Dokumentation dieser Datei
00001 
00024 #if defined(__GNUG__) && !defined(__APPLE__)
00025 #pragma implementation "InputDevDlg.h"
00026 #endif
00027 
00028 // For compilers that support precompilation, includes "wx/wx.h".
00029 #include "wx/wxprec.h"
00030 
00031 #ifdef __BORLANDC__
00032 #pragma hdrstop
00033 #endif
00034 
00035 #ifndef WX_PRECOMP
00036 #include "wx/wx.h"
00037 #endif
00038 
00041 
00042 #include "InputDevDlg.h"
00043 
00048 IMPLEMENT_DYNAMIC_CLASS( InputDevDlg, InputDevDlgBase )
00049 
00050 BEGIN_EVENT_TABLE( InputDevDlg, InputDevDlgBase )
00051         EVT_CHOICE( XRCID("DeviceChoice"), InputDevDlg::OnChoiceSelected )
00052         EVT_BUTTON( ::wxID_REMOVE, InputDevDlg::OnRemoveClick )
00053         EVT_FILEPICKER_CHANGED(XRCID ("MidiFilePicker"), 
00054                                InputDevDlg::OnFileChanged)
00055         EVT_FILEPICKER_CHANGED(XRCID ("GuidoFilePicker"), 
00056                                InputDevDlg::OnFileChanged)
00057 END_EVENT_TABLE()
00058 
00062 /* \todo: find out, how we can reuse a file Picker for different file types */
00063 
00064 InputDevDlg::InputDevDlg( wxWindow* parent):InputDevDlgBase(parent)
00065 {
00066         DeviceChoice->Clear();
00067         DeviceChoice->Append(_("MIDI Device"),new TypeData(DTMidiPort));
00068         DeviceChoice->Append(_("MIDI file"),new TypeData(DTMidiFile));
00069         DeviceChoice->Append(_("GUIDO file"),new TypeData(DTGis));
00070 
00071         TypeBox = DeviceChoice->GetContainingSizer();
00072         PortBox = PortChoice->GetContainingSizer();
00073         MidiFileBox = MidiFilePicker->GetContainingSizer();
00074         DEBUGLOG (_T ("MidiFilePicker Growable: %d"), MidiFilePicker->IsPickerCtrlGrowable());
00075         if (MidiFilePicker->HasTextCtrl()) {
00076                 DEBUGLOG (_T ("MidiFileTextCtrl Growable: %d"), 
00077                           MidiFilePicker->IsTextCtrlGrowable());
00078                 MidiFilePicker->SetTextCtrlGrowable(true);
00079                 DEBUGLOG (_T ("MidiFileTextCtrl Growable: %d"), 
00080                           MidiFilePicker->IsTextCtrlGrowable());
00081         }
00082         GuidoFileBox = GuidoFilePicker->GetContainingSizer();
00083 
00084 //      GetSizer()->Fit(this);
00085 //      GetSizer()->SetSizeHints(this);
00086 //      Centre();
00087 }
00088 
00093 bool InputDevDlg::ShowToolTips()
00094 {
00095         return TRUE;
00096 }
00097 
00102 wxBitmap InputDevDlg::GetBitmapResource( const wxString& name )
00103 {
00104         // Bitmap retrieval
00106         return wxNullBitmap;
00108 }
00109 
00114 wxIcon InputDevDlg::GetIconResource( const wxString& name )
00115 {
00116         // Icon retrieval
00118         return wxNullIcon;
00120 }
00121 
00126 void InputDevDlg::OnChoiceSelected( wxCommandEvent& event )
00127 {
00128         int i = DeviceChoice->GetSelection();
00129         TypeData * data =(TypeData *)DeviceChoice->GetClientObject(i);
00130         UpdateLayout(*data);
00131         event.Skip();
00132 }
00133 
00134 void InputDevDlg::UpdateLayout(DevType type)
00135 {
00136         if (type == DTNotSet) {
00137                 if (FindType (type) == wxNOT_FOUND)
00138                         DeviceChoice->Insert (_ ("Choose device type"),
00139                                               0,
00140                                               new TypeData (type));
00141         } else {
00142                 int notset = FindType (DTNotSet);
00143                 if (notset != wxNOT_FOUND) {
00144                         DeviceChoice->Delete (notset);
00145                 }
00146 
00147                 if (type == DTUnknown) {
00148                         if (FindType (type) == wxNOT_FOUND)
00149                                 DeviceChoice->Insert (_ ("Unknown device type"),
00150                                                       0,
00151                                                       new TypeData (type));
00152                 }
00153         }
00154         int Type = FindType (type);
00155         DeviceChoice -> SetSelection (Type);
00156 
00157         DEBUGLOG(_T("%d"),type);
00158         wxSizer * sizer = GetSizer();
00159 
00160         DEBUGLOG(_T("%d"),DTMidiPort);
00161         sizer->Show(PortBox, type == DTMidiPort, true);
00162         DEBUGLOG(_T("%d"),DTMidiFile);
00163         sizer->Show(MidiFileBox, (type == DTMidiFile), true);
00164         DEBUGLOG(_T("%d"),DTGis);
00165         sizer->Show(GuidoFileBox, (type == DTGis) , true);
00166 
00167 //      Layout();
00168 //      GetSizer()->SetSizeHints(this);
00169         Fit();
00170 }
00171 
00172 
00177 void InputDevDlg::OnRemoveClick( wxCommandEvent& event )
00178 {
00179         EndModal(::wxID_REMOVE);
00180 }
00181 
00182 void InputDevDlg::OnFileChanged ( wxFileDirPickerEvent & event ) 
00183 {
00184         DEBUGLOG (_T ("Path changed: %s"),event.GetPath().c_str());
00185         Fit();
00186 }
00187 
00188 
00189 int InputDevDlg::FindType (DevType t)
00190 {
00191         TypeData * Data;
00192         for (unsigned int i = 0; i < DeviceChoice->GetCount(); i++) {
00193                 DEBUGLOG (_T ("Choice #%d of %d"),i, DeviceChoice->GetCount());
00194                 Data = (TypeData *)DeviceChoice->GetClientObject(i);
00195                 if (Data) {
00196                         if (*Data == t) return i;
00197                 }
00198         }
00199         return wxNOT_FOUND;
00200 }
00201 
00202 

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