MutRouteWnd.cpp
gehe zur Dokumentation dieser Datei
00001 
00024 
00025 // Name:        MutApp.cpp
00026 // Purpose:     Mutabor Application
00027 // Author:      R. Kraufle
00028 // Modified by:
00029 // Created:     12.08.05
00030 // Copyright:   (c) R. Kraufle
00031 // Licence:     wxWindows license
00033 
00034 // ---------------------------------------------------------------------------
00035 // headers
00036 // ---------------------------------------------------------------------------
00037 
00038 // For compilers that support precompilation, includes "wx/wx.h".
00039 #include "wx/wxprec.h"
00040 
00041 #ifdef __BORLANDC__
00042 #pragma hdrstop
00043 #endif
00044 
00045 #ifndef WX_PRECOMP
00046 #include "wx/wx.h"
00047 //    #include "wx/mdi.h"
00048 #endif
00049 
00050 #include "Defs.h"
00051 #include <stdio.h>
00052 #include "wx/list.h"
00053 #include "wx/ffile.h"
00054 
00055 #include "Runtime.h"
00056 //#include "edevice.h"
00057 //#include "Help.rh"
00058 #include "mhDefs.h"
00059 #include "MutRouteWnd.h"
00060 #include "InputDevDlg.h"
00061 //#include "InputFilterDlg.h"
00062 #include "BoxDlg.h"
00063 //#include "OutputFilterDlg.h"
00064 #include "OutputDevDlg.h"
00065 #include "NewInputDeviceShape.h"
00066 #include "NewBoxShape.h"
00067 #include "NewOutputDeviceShape.h"
00068 #include "DebugRoute.h"
00069 #include "RouteCompat.h"
00070 
00071 #ifndef RTMIDI
00072 #ifndef MMSYSTEM_H
00073 #define MMSYSTEM_H
00074 //  #define WINVER 0x030a
00075 #include <mmsystem.h>
00076 #endif
00077 #endif
00078 
00079 //#include "Mutabor.rh"
00080 #include "Device.h"
00081 #include "MidiKern.h"
00082 
00083 //#if !defined(__WXMSW__)
00084 #include "Icon/DevUnknown.xpm"
00085 #include "Icon/DevMidiPort.xpm"
00086 #include "Icon/DevMidiFile.xpm"
00087 #include "Icon/DevGMN.xpm"
00088 #include "Icon/NewPlop.xpm"
00089 #include "Icon/PlayPlop.xpm"
00090 #include "Icon/PausePlop.xpm"
00091 #include "Icon/ErrorPlop.xpm"
00092 #include "Icon/AddStop.xpm"
00093 #include "Icon/AddPlay.xpm"
00094 #include "Icon/AddPause.xpm"
00095 #include "Icon/AddStopDis.xpm"
00096 //#endif
00097 
00098 #ifdef RTMIDI
00099 #include "RtMidi.h"
00100 
00101 extern RtMidiOut *rtmidiout;
00102 
00103 extern RtMidiIn *rtmidiin;
00104 
00105 #endif
00106 
00107 #define xd 32 // Devicelogo
00108 #define yd 32
00109 
00110 #define xb 24 // Box
00111 #define yb 24
00112 
00113 #define ydt 4 // Text
00114 #define yt 16
00115 
00116 #define yh 12 // Headline
00117 
00118 #define yr (yd+ydt+yt+yz) // Route
00119 
00120 #define BACKGROUND *wxLIGHT_GREY // Background color
00121 
00122 #define RT_INDEVICE  0
00123 #define RT_INFILTER  1
00124 #define RT_BOX       2
00125 #define RT_OUTFILTER 3
00126 #define RT_OUTDEVICE 4
00127 #define RT_PLAYBUTTON 5
00128 #define RT_STOPBUTTON 6
00129 
00130 #define FILENAMELENGTH 200
00131 #define POINT_IN(p, x1, y1, xl, yl)                             \
00132         (x1 <= p.x && p.x < x1+xl && y1 < p.y && p.y < y1+yl)
00133 
00134 DevType IsDT;  // Info f¸r Inputfilter
00135 
00136 extern int curBox;
00137 
00138 /*wx
00139   void RightButtonMenu(TWindow *win, TPoint &point);
00140 */
00141 // help functions ---------------------------------------------------
00142 
00143 #define max(a, b) ((a) < (b) ? (b) : (a))
00144 
00145 int GetTextWidth(wxDC& dc, const wxString &s)
00146 {
00147         wxCoord w, h;
00148         dc.GetTextExtent(s, &w, &h);
00149         return w;
00150 }
00151 
00152 /* lieber nicht wg. unicode
00153    int GetTextWidth(wxDC& dc, char *s)
00154    {
00155    wxString s1 = muT(s);
00156    return GetTextWidth(dc, s1);
00157    }*/
00158 
00159 // TextPin
00160 void TextPin(wxDC &dc, int xm, int y, int xl, const wxString &s, char withBox)
00161 {
00162         if ( withBox )
00163                 dc.DrawRectangle(xm-xl/2, y, xl, yt);
00164 
00165         wxString s1 = s;
00166 
00167         int w = GetTextWidth(dc, s1);
00168 
00169         while ( s1.Length() > 3 ) {
00170                 if ( (w = GetTextWidth(dc, s1)) < xl )
00171                         break;
00172 
00173                 s1 = s1.Mid(4).Prepend(_("..."));
00174         }
00175 
00176         dc.SetBackgroundMode(wxTRANSPARENT);
00177         dc.DrawText(s1, xm - w/2, y + 2);
00178         dc.SetBackgroundMode(wxSOLID);
00179 }
00180 
00181 /* Lieber nicht (unicode)
00182    void TextPin(wxDC &dc, int xm, int y, int xl, char *s, char withBox)
00183    {
00184    wxString s1 = muT(s);
00185    TextPin(dc, xm, y, xl, s1, withBox);
00186    }*/
00187 
00188 // von - bis als string
00189 wxString sRange(int from, int to)
00190 {
00191         if ( from == to )
00192                 return wxString::Format(_T("%d"), from);
00193         else if ( from < to )
00194                 return wxString::Format(_("%d -- %d"), from, to);
00195 
00196         return _("--");
00197 }
00198 
00199 // Box
00200 
00201 
00202 void PrintBox(wxDC &dc, int xm, int ym, int nr, char active, int x3)
00203 {
00204         if ( nr == -2 )
00205                 return;
00206 
00207         wxString s(_T("x"));
00208         if ( nr >= 0 )
00209                 s.Printf(_T("%d"), nr);
00210         wxBrush Brush = wxBrush(BoxColor(nr));
00211         dc.SetBrush(Brush);
00212 
00213         if ( !active ) {
00214                 int xv = (x3+xb+2*xz) / 4, yv = (yb+yr) / 4;
00215                 dc.SetPen(wxPen(BACKGROUND, 1));
00216                 dc.DrawLine(xm, ym, xm-xv, ym);
00217                 dc.SetPen(*wxBLACK_PEN);
00218                 dc.DrawLine(xm-xv, ym, xm-xv, ym+yv);
00219                 dc.DrawLine(xm-xv, ym+yv, xm+xv, ym+yv);
00220                 dc.DrawLine(xm+xv, ym+yv, xm+xv, ym);
00221         } else
00222                 dc.SetPen(wxPen(*wxBLACK, 2));
00223 
00224         dc.DrawRectangle(xm-xb/2, ym-yb/2, xb, yb);
00225         dc.SetPen(wxNullPen);
00226         dc.SetBrush(wxNullBrush);
00227         wxCoord w, h;
00228         dc.GetTextExtent(s, &w, &h);
00229         dc.SetBackgroundMode(wxTRANSPARENT);
00230         dc.DrawText(s, xm - w/2, ym-h/2);
00231         dc.SetBackgroundMode(wxSOLID);
00232 }
00233 
00234 /*
00235 // TNRadioButton - notifying radio button ---------------------------
00236 class TNRadioButton : public TRadioButton
00237 {
00238 public:
00239 TNRadioButton(TWindow* parent, int resourceId, TGroupBox *group, TModule* module = 0)
00240 : TRadioButton(parent, resourceId, group, module) {};
00241 protected:
00242 void BNClicked()
00243 {
00244 TRadioButton::BNClicked();
00245 Parent->SendMessage(WM_COMMAND, CM_UPDATE);
00246 }
00247 DECLARE_RESPONSE_TABLE(TNRadioButton);
00248 };
00249 
00250 DEFINE_RESPONSE_TABLE1(TNRadioButton, TRadioButton)
00251 EV_NOTIFY_AT_CHILD (BN_CLICKED, BNClicked),
00252 END_RESPONSE_TABLE;
00253 
00254 // TNComboBox - notifying combo box ---------------------------------
00255 class TNComboBox : public TComboBox
00256 {
00257 public:
00258 TNComboBox(TWindow* parent, int ResourceId, uint textLen = 0, TModule* module = 0)
00259 : TComboBox(parent, ResourceId, textLen, module) {}
00260 protected:
00261 void EvPaint()
00262 {
00263 TComboBox::EvPaint();
00264 Parent->SendMessage(WM_COMMAND, CM_UPDATE);
00265 }
00266 DECLARE_RESPONSE_TABLE(TNComboBox);
00267 };
00268 
00269 DEFINE_RESPONSE_TABLE1(TNComboBox, TComboBox)
00270 EV_WM_PAINT,
00271 END_RESPONSE_TABLE;
00272 
00273 // TNEdit - notifying edit filed ---------------------------------
00274 class TNEdit : public TEdit
00275 {
00276 public:
00277 TNEdit(TWindow* parent, int ResourceId, uint textLen = 0, TModule* module = 0)
00278 : TEdit(parent, ResourceId, textLen, module) {}
00279 protected:
00280 void EvPaint()
00281 {
00282 TEdit::EvPaint();
00283 Parent->SendMessage(WM_COMMAND, CM_UPDATE);
00284 }
00285 DECLARE_RESPONSE_TABLE(TNEdit);
00286 };
00287 
00288 DEFINE_RESPONSE_TABLE1(TNEdit, TEdit)
00289 EV_WM_PAINT,
00290 END_RESPONSE_TABLE;
00291 
00292 // TRouteDialog - little popup dialogs ------------------------------
00293 
00294 class TRouteDialog : public TGraySetupDialog
00295 {
00296 public:
00297 TRouteDialog(TWindow* parent, int kind, void *buf, int helpNr, int x, int y);
00298 virtual void SetupWindow();
00299 void UpDate();
00300 void CmSearch();
00301 protected:
00302 int Kind;
00303 TGroupBox *TGB1, *TGB2;
00304 TNRadioButton *R1, *R2, *R3, *R4, *R5;
00305 TEdit *E1, *E2;
00306 TComboBox *C1, *C2;
00307 TButton *B1;
00308 TStatic *S1;
00309 TCheckBox *CB1;
00310 DECLARE_RESPONSE_TABLE(TRouteDialog);
00311 };
00312 
00313 DEFINE_RESPONSE_TABLE1(TRouteDialog, TGraySetupDialog)
00314 EV_COMMAND(CM_UPDATE, UpDate),
00315 EV_COMMAND(IDR_BUTTON01, CmSearch),
00316 END_RESPONSE_TABLE;
00317 
00318 TResId RouteDialogId[5] = { IDD_R0, IDD_R1, IDD_R2, IDD_R3, IDD_R0 };
00319 
00320 TRouteDialog::TRouteDialog(TWindow* parent, int kind, void *buf, int helpNr, int x, int y)
00321 : TGraySetupDialog(parent, RouteDialogId[kind], buf, helpNr, x, y)
00322 {
00323 Kind = kind;
00324 switch ( kind )
00325 {
00326 case 0:
00327 case 4:
00328 TGB1 = new TGroupBox(this, IDR_GROUPBOX01);
00329 TGB2 = new TGroupBox(this, IDR_GROUPBOX02);
00330 C1 = new TNComboBox(this, IDR_COMBOBOX01);
00331 E1 = new TEdit(this, IDR_EDIT01, FILENAMELENGTH);
00332 C2 = new TComboBox(this, IDR_COMBOBOX02);
00333 E2 = new TEdit(this, IDR_EDIT02, 4);
00334 B1 = new TButton(this, IDR_BUTTON01);
00335 S1 = new TStatic(this, IDR_STATIC1);
00336 break;
00337 case 1:
00338 TGB1 = new TGroupBox(this, IDR_GROUPBOX11);
00339 TGB2 = new TGroupBox(this, IDR_GROUPBOX12);
00340 R1 = new TNRadioButton(this, IDR_RADIOBUTTON11, TGB1);
00341 R2 = new TNRadioButton(this, IDR_RADIOBUTTON12, TGB1);
00342 R3 = new TNRadioButton(this, IDR_RADIOBUTTON13, TGB1);
00343 R4 = new TNRadioButton(this, IDR_RADIOBUTTON14, TGB1);
00344 E1 = new TEdit(this, IDR_EDIT11, 4);
00345 E2 = new TEdit(this, IDR_EDIT12, 4);
00346 break;
00347 case 2:
00348 TGB1 = new TGroupBox(this, IDR_GROUPBOX21);
00349 TGB2 = new TGroupBox(this, IDR_GROUPBOX22);
00350 R1 = new TNRadioButton(this, IDR_RADIOBUTTON21, TGB1);
00351 R2 = new TNRadioButton(this, IDR_RADIOBUTTON22, TGB1);
00352 R3 = new TNRadioButton(this, IDR_RADIOBUTTON23, TGB1);
00353 E1 = new TEdit(this, IDR_EDIT21, 4);
00354 E1->SetValidator(new TRangeValidator(0, 255));
00355 R4 = new TNRadioButton(this, IDR_RADIOBUTTON24, TGB2);
00356 R5 = new TNRadioButton(this, IDR_RADIOBUTTON25, TGB2);
00357 break;
00358 case 3:
00359 E1 = new TNEdit(this, IDR_EDIT31, 4);
00360 E1->SetValidator(new TRangeValidator(0, 15));
00361 E2 = new TNEdit(this, IDR_EDIT32, 4);
00362 E2->SetValidator(new TRangeValidator(0, 15));
00363 CB1 = new TCheckBox(this, IDR_CHECKBOX31);
00364 break;
00365 }
00366 }
00367 
00368 void TRouteDialog::SetupWindow()
00369 {
00370 TGraySetupDialog::SetupWindow();
00371 if ( Kind == 4 )
00372 SetCaption("Output device");
00373 if ( Kind == 1)
00374 if ( IsDT == DTGis )
00375 R3->SetCaption("box tag");
00376 else
00377 R4->SetCaption((IsDT == DTMidiFile) ? "track" : "key range");
00378 UpDate();
00379 }
00380 
00381 void TRouteDialog::CmSearch()
00382 {
00383 TOpenSaveDialog::TData *FileData =
00384 ( C1->GetSelIndex() == 1 ) ? &MidiFileData : &GmnFileData;
00385 E1->GetLine(FileData->FileName,  FILENAMELENGTH, 0);
00386 FileData->Flags = OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_EXPLORER;
00387 if ( !Kind )
00388 FileData->Flags |= OFN_FILEMUSTEXIST;
00389 if (TFileOpenDialog(this, *FileData).Execute() == IDOK)
00390 {
00391 E1->DeleteLine(0);
00392 E1->Insert(FileData->FileName);
00393 }
00394 }
00395 
00396 #define SHOW(val) \
00397 Show((val) ? SW_SHOWNA : SW_HIDE)
00398 void TRouteDialog::UpDate()
00399 {
00400 char *TGB2Captions[3] = { "Device name", "Midi file name", "GUIDO file name" };
00401 int sel;
00402 switch ( Kind )
00403 {
00404 case 0:
00405 case 4:
00406 sel = C1->GetSelIndex(); // 0 = MIDIPORT
00407 TGB2->SetCaption(TGB2Captions[sel]);
00408 E1->SHOW(sel);
00409 B1->SHOW(sel);
00410 C2->SHOW(!sel);
00411 S1->SHOW(sel != 2 && Kind == 4);
00412 E2->SHOW(sel != 2 && Kind == 4);
00413 break;
00414 case 1:
00415 E1->EnableWindow( R1->GetCheck() != BF_CHECKED && R2->GetCheck() != BF_CHECKED);
00416 E2->EnableWindow( R1->GetCheck() != BF_CHECKED && R2->GetCheck() != BF_CHECKED);
00417 //R4->SHOW(IsDT != DTMidiPort);
00418 break;
00419 case 2:
00420 E1->EnableWindow( R1->GetCheck() == BF_CHECKED );
00421 R4->EnableWindow( R3->GetCheck() != BF_CHECKED );
00422 R5->EnableWindow( R3->GetCheck() != BF_CHECKED );
00423 break;
00424 case 3:
00425 char s1[20], s2[20];
00426 E1->GetText(s1, 19); E2->GetText(s2, 19);
00427 CB1->EnableWindow( atoi(s1) <= DRUMCHANNEL && DRUMCHANNEL <= atoi(s2));
00428 break;
00429 }
00430 }
00431 
00432 // TRouteWin --------------------------------------------------------
00433 */
00434 
00435 BEGIN_EVENT_TABLE(MutRouteWnd, wxScrolledWindow)
00436 //      EVT_SIZE(MutRouteWnd::OnSize)
00437 //      EVT_LEFT_DOWN(MutRouteWnd::OnLeftDown)
00438 //      EVT_LEFT_DCLICK(MutRouteWnd::OnLeftDClick)
00439 END_EVENT_TABLE()
00440 
00441 /*DEFINE_RESPONSE_TABLE1(TRouteWin, TWindow)
00442   EV_WM_CHAR,
00443   EV_WM_SIZE,
00444   EV_WM_LBUTTONDOWN,
00445   EV_WM_LBUTTONDBLCLK,
00446   EV_WM_RBUTTONDOWN,
00447   END_RESPONSE_TABLE;
00448 
00449   TFont RouteFont(8, 0, 0, 0, FW_NORMAL,
00450   false, false, false, 1, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
00451   DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "MS Sans Serif");
00452 */
00453 
00454 wxFont RouteFont(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
00455 
00456 void testdialog();
00457 
00458 
00459 MutRouteWnd::MurFileDataType MutRouteWnd::MurFileData;
00460 
00461 MutRouteWnd::MutRouteWnd(wxWindow *parent, const wxPoint& pos, const wxSize& size)
00462         : wxScrolledWindow(parent, wxID_ANY, pos, size, 
00463                            wxVSCROLL|wxHSCROLL|wxTAB_TRAVERSAL, wxT("Route"))
00464 {
00465         /*  TWindow::Attr.Style |= WS_GROUP | WS_CLIPCHILDREN|
00466             WS_CLIPSIBLINGS | WS_VSCROLL | WS_HSCROLL | WS_BORDER;
00467             Scroller = new TScroller(this, 1, 1, 0, 0);
00468             Attr.AccelTable = IDA_ROUTE;*/
00469         DevIcon[DTUnknown] = new ICON(devunknown);
00470         DevIcon[DTMidiPort] = new ICON(devmidiport);
00471         DevIcon[DTMidiFile] = new ICON(devmidifile);
00472         DevIcon[DTGis] = new ICON(devgmn);
00473         ConIcon[0] = new wxBitmap(AddStop_xpm);//, wxBITMAP_TYPE_XPM);
00474         ConIcon[1] = new wxBitmap(AddPlay_xpm);//, wxBITMAP_TYPE_XPM);
00475         ConIcon[2] = new wxBitmap(AddPause_xpm);//, wxBITMAP_TYPE_XPM);
00476         ConIcon[3] = new wxBitmap(AddStopDis_xpm);//, wxBITMAP_TYPE_XPM);
00477         PlopIcon[0] = new ICON(newplop);
00478         PlopIcon[1] = new ICON(playplop);
00479         PlopIcon[2] = new ICON(pauseplop);
00480         PlopIcon[3] = new ICON(errorplop);
00481         spacey = 8;
00482         spacex = 20;
00483         x1 = 80;
00484         x2 = 80;
00485         x3 = 30;
00486         x4 = 80;
00487         x5 = 80;
00488         SetBackgroundColour(BACKGROUND);
00489         //testdialog();
00490 
00491 
00492         DEBUGLOG (other, _T("this is window %p"),this);
00493         SetSizer(new wxFlexGridSizer(3,0,50));
00494         SetScrollRate(1, 1);
00495 
00496         initMutIconShapes();
00497         InitShapes();
00498 }
00499 
00500 void MutRouteWnd::InitShapes()
00501 {
00502         wxASSERT(GetSizer());
00503         wxSizerFlags flags;
00504         flags.Align(wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL);
00505         flags.Proportion(1);
00506         flags.TripleBorder();
00507         
00508         wxASSERT(InputDevices.empty());
00509         MutInputDeviceShape * newin = new MutNewInputDeviceShape(this,wxID_ANY);
00510         GetSizer()->Add(newin, flags);
00511         InputDevices.Append(newin);
00512         
00513         wxASSERT(Boxes.empty());
00514         MutBoxShape * boxShape = new NewMutBoxShape(this,wxID_ANY);
00515         GetSizer()->Add(boxShape, flags);
00516         Boxes.Append(boxShape);
00517 
00518         wxASSERT(OutputDevices.empty());
00519         MutOutputDeviceShape * newout = new MutNewOutputDeviceShape(this,wxID_ANY);
00520         GetSizer()->Add(newout, flags);
00521         OutputDevices.Append(newout);
00522 
00523         createInputDevices(flags);
00524         createBoxes(flags);
00525         createOutputDevices(flags);
00526         FitInside();
00527 
00528         PRINTSIZER(GetSizer());
00529         DebugCheckRoutes();
00530 }
00531 
00532 void MutRouteWnd::InitDevices() 
00533 {
00534   createInputDevices(MutInputDeviceShape::GetSizerFlags());
00535   createBoxes(MutBoxShape::GetSizerFlags());
00536   createOutputDevices(MutOutputDeviceShape::GetSizerFlags());
00537         FitInside();
00538 
00539         PRINTSIZER(GetSizer());
00540         DebugCheckRoutes();  
00541 }
00542 
00543 void MutRouteWnd::ClearDevices()
00544 {
00545   ClearInputDevices();
00546   ClearBoxes();
00547   ClearOutputDevices();
00548 }
00549 
00550 void MutRouteWnd::createInputDevices(wxSizerFlags flags)
00551 
00552 {
00553         MutInputDeviceShape::SetSizerFlags(flags);
00554         InputSizer = new wxGridSizer(1);
00555 
00556         GetSizer()->Add(InputSizer, 0, wxEXPAND);
00557   
00558         for (InDevice *In = InDevice::GetDeviceList(); In; In = In->GetNext()) {
00559                 wxASSERT (In != In -> GetNext());
00560                 DEBUGLOG (other, _T("In the loop %p -> %p"), In, In->GetNext());
00561                 MutInputDeviceShape * newin = MutInputDeviceShape::CreateShape(this,wxID_ANY, In);
00562                 wxASSERT(newin);
00563                 InputSizer->Add(newin, flags);
00564                 InputDevices.Append(newin);
00565         }
00566 }
00567 
00568 void MutRouteWnd::ClearInputDevices()
00569 {
00570   InputDevices.Clear();
00571   InputSizer->Clear(true);
00572 }
00573 
00574 void MutRouteWnd::createBoxes(wxSizerFlags flags)
00575 {
00576         MutBoxShape::SetSizerFlags(flags);
00577         BoxSizer = new wxGridSizer (1);                 
00578         MutBoxShape * boxShape;
00579 
00580 
00581         for (int i = 0; i< MAX_BOX; i++) {
00582                 BoxPTRs[i] = NULL;
00583         }
00584 
00585         GetSizer()->Add(BoxSizer, 0, wxEXPAND);
00586 
00587         for (MutDeviceShapeList::iterator iter = InputDevices.begin();
00588              iter != InputDevices.end(); ++iter) {
00589 
00590                 MutInputDeviceShape * device = dynamic_cast<MutInputDeviceShape*>(*iter);
00591                 wxASSERT(device);
00592                 if (!device) continue;
00593 
00594                 Route * Route = device->getRoutes();
00595                 while (Route) {
00596                         wxASSERT(0<= Route->Box && Route->Box < MAX_BOX);
00597                         if (!BoxPTRs[Route->Box]) {
00598                                 DEBUGLOG (other, _T("Creating box"));
00599                                 BoxPTRs[Route->Box] = boxShape = 
00600                                         new MutBoxShape(this,wxID_ANY, Route->Box);
00601                                 DEBUGLOG (other, _T("Box shape: %p"),boxShape);
00602                                 wxASSERT(boxShape);
00603                                 if (!boxShape) continue;
00604                                 AddBox(boxShape, flags);
00605                         } else {
00606                                 boxShape = BoxPTRs[Route->Box];
00607                                 wxASSERT(wxDynamicCast(boxShape,MutBoxShape));
00608                         }
00609 
00610                         DEBUGLOG (other, _T("Adding Route to Box %p on window %p"),boxShape,this);
00611                         MutBoxChannelShape * channel =
00612                                 boxShape->AddChannel(Route);
00613                         channel->SetInput(device);
00614 
00615                         Route = Route->GetNext();
00616                 }
00617         }
00618         
00619         // Adding routes without input device
00620         Route * route = Route::GetRouteList();
00621         while (route) {
00622                 wxASSERT(0<= route->Box && route->Box < MAX_BOX);
00623                 
00624                 bool found = false;
00625                 
00626                 wxSizerItemList & list = BoxSizer->GetChildren();
00627                 for (wxSizerItemList::const_iterator i = list.begin(); i != list.end(); i++) {
00628                         MutBoxShape * box = static_cast<MutBoxShape * > ((*i)->GetWindow());
00629                         wxASSERT(dynamic_cast<MutBoxShape *> ((*i)->GetWindow()));
00630                         if (box && box->HasChannel(route)) {
00631                                 found = true;
00632                                 break;
00633                         }
00634                 }
00635                 if (found) {
00636                         route = route -> GetGlobalNext();
00637                         continue;
00638                 }
00639                 
00640                 if (!BoxPTRs[route->Box]) {
00641                         DEBUGLOG (other, _T("Creating box"));
00642                         BoxPTRs[route->Box] = boxShape = 
00643                         new MutBoxShape(this,wxID_ANY, route->Box);
00644                         DEBUGLOG (other, _T("Box shape: %p"),boxShape);
00645                         wxASSERT(boxShape);
00646                         if (!boxShape) continue;
00647                         AddBox(boxShape, flags);
00648                 } else {
00649                         boxShape = BoxPTRs[route->Box];
00650                         wxASSERT(wxDynamicCast(boxShape,MutBoxShape));
00651                 }
00652                 
00653                 DEBUGLOG (other, _T("Adding Route to Box %p on window %p"),boxShape,this);
00654                 boxShape->AddChannel(route);
00655                 
00656                 route = route->GetGlobalNext();
00657         }
00658         
00659 }
00660 void MutRouteWnd::ClearBoxes()
00661 {
00662   Boxes.Clear();
00663   BoxSizer->Clear(true);
00664 }
00665 
00666 
00667 void MutRouteWnd::createOutputDevices(wxSizerFlags flags)
00668 
00669 {
00670         MutOutputDeviceShape::SetSizerFlags(flags);
00671         OutputSizer = new wxGridSizer (1);
00672         
00673         GetSizer()->Add(OutputSizer, 0, wxEXPAND | wxALL,0);
00674 
00675         for (OutDevice *Out = OutDevice::GetDeviceList(); Out; Out = Out->GetNext()) {
00676                 MutOutputDeviceShape * newout =  MutOutputDeviceShape::CreateShape(this,wxID_ANY,Out);
00677 
00678                 OutputSizer->Add(newout, flags);
00679                 OutputDevices.Append(newout);
00680 
00681                 for (MutBoxShapeList::iterator i = Boxes.begin(); i != Boxes.end(); i++) {
00682                         MutBoxShape * box = *i;
00683       
00684                         box->AddPossibleOutput(newout);
00685                 }
00686 
00687         }
00688 }
00689 void MutRouteWnd::ClearOutputDevices()
00690 {
00691   OutputDevices.Clear();
00692   OutputSizer->Clear(true);
00693 }
00694 
00695 
00696 // Route laden, speichern
00697 
00698 void MutRouteWnd::CmRouteLoad(wxCommandEvent& event)
00699 {
00700         // it's our task
00701         event.Skip(false);
00702         
00703         wxString filename = FileNameDialog(wxGetApp().GetTopWindow(),
00704                                            event.GetId());
00705         
00706         if (!filename) return;
00707         
00708         MurFileData.name.Assign(filename);
00709         
00710         wxFFile file(filename);
00711         if (!file.IsOpened()) {
00712                 wxLogError(_("File '%s' couldn't be loaded"),filename.c_str());
00713                 return;
00714         }
00715         wxString text;
00716         if (! file.ReadAll(&text, MurFileData.autoConverter)) {
00717                 wxLogError(_("File '%s' could be opened, but not loaded."),
00718                            filename.c_str());
00719                 return;
00720         }
00721         
00722         // Activate the Route window
00723         wxGetApp().CmRoutes(event);
00724         MutFrame * frame = 
00725           dynamic_cast<MutFrame*>(wxWindow::FindWindowById(WK_ROUTE));
00726         wxWindowList & list = frame->GetChildren();
00727         MutRouteWnd * routewnd=NULL;
00728         for (wxWindowList::iterator i = list.begin();i!= list.end();i++) {
00729                 routewnd = dynamic_cast<MutRouteWnd *> (*i);
00730                 if (routewnd) break;
00731         }
00732         wxASSERT(routewnd);
00733         if (routewnd) {
00734           routewnd->ClearDevices();
00735         }
00736         
00737         compat30::LoadRoutes(text);
00738         
00739         if (routewnd) {
00740           routewnd->InitDevices();
00741         }
00742         
00743         wxCommandEvent ev(wxEVT_COMMAND_MENU_SELECTED,CM_ROUTES);
00744         wxGetApp().ProcessEvent(ev);
00745 }
00746 
00747 void MutRouteWnd::CmRouteSave(wxCommandEvent& event)
00748 {
00749         DEBUGLOGTYPE(other,MutFrame,_T(""));
00750         event.Skip(false);
00751         
00752         if (!MurFileData.name.IsOk() ) {
00753                 CmRouteSaveAs(event);
00754                 return;
00755         }
00756         
00757         /* not applicable, since the file might not yet exsist
00758          if (!MurFileData.name.IsFileWritable()) {
00759          wxLogError(_("Cannot write to routes file '%s'."), 
00760          MurFileData.name.GetFullPath().c_str());
00761          return;
00762          }
00763          */
00764         
00765         wxFFile file(MurFileData.name.GetFullPath(), _T("w"));
00766         
00767         if (!file.IsOpened()) {
00768                 wxLogError(_("Cannot open routes file '%s' for writing."),
00769                            MurFileData.name.GetFullPath().c_str());
00770                 return;
00771         }
00772         
00773         wxString RouteConfig;
00774         
00775         compat30::SaveRoutes(RouteConfig);
00776         
00777         if (file.Write(_T("# Mutabor 3.x routes configuration\n"),
00778                        MurFileData.autoConverter))
00779                 if (file.Write(RouteConfig, MurFileData.autoConverter)) {
00780                         file.Close();
00781                         return;
00782                 }
00783         
00784         wxLogError(_("Error writing file '%s'."),
00785                    
00786                    MurFileData.name.GetFullPath().c_str());
00787         file.Close();
00788 }
00789 
00790 void MutRouteWnd::CmRouteSaveAs(wxCommandEvent& event)
00791 {
00792         DEBUGLOGTYPE(other,MutFrame,_T(""));
00793         
00794         // it's our task
00795         event.Skip(false);
00796         
00797         wxString filename = FileNameDialog(wxGetApp().GetTopWindow(),
00798                                            event.GetId(),
00799                                            MurFileData.name.GetFullPath());
00800         
00801         if (!filename) return;
00802         
00803         MurFileData.name.Assign(filename);
00804         
00805         if (!MurFileData.name.IsOk()) {
00806                 wxLogError(_("The string '%s' is not a valid file name."),
00807                            filename.c_str());
00808                 return;
00809         }
00810         
00811         CmRouteSave(event);
00812 }
00813 
00814 
00815 /*
00816   void TRouteWin::SetupWindow()
00817   {
00818   TWindow::SetupWindow();
00819   SetWindowFont(HFONT(RouteFont), false);
00820 //  NewInstrument();
00821 }
00822 
00823 bool TRouteWin::CanClose()
00824 {
00825 WriteRoutes(&RouteConfig);
00826 return true;
00827 }
00828 
00829 // Reaktion auf Computertastatur
00830 
00831 void TRouteWin::EvChar(uint key, uint repeatCount, uint flags)
00832 {
00833 TWindow::EvChar(key, repeatCount, flags);
00834 if ( LogicOn )
00835 {
00836 if ( 'A' <= key && key <= 'z' || key == VK_TAB
00837 || key == VK_UP || key == VK_DOWN
00838 || key == VK_LEFT || key == VK_RIGHT )
00839 {
00840 pubTaste = key;
00841 if ( IsOpen(WK_LOGIC, curBox) )
00842 GetWinAttr(WK_LOGIC, curBox)->Win->SendMessage(WM_COMMAND, CM_TASTE);
00843 else
00844 KeyboardAnalyseSimple(curBox, key);
00845 }
00846 }
00847 }
00848 */
00849 
00850 
00851 
00852 void MutRouteWnd::OnDraw(wxDC& dc)
00853 {
00854         wxScrolledWindow::OnDraw(dc);
00855         PRINTSIZER(GetSizer());
00856         dc.SetDeviceOrigin(0,0);
00857         wxASSERT(BoxSizer);
00858         wxSizerItemList & list = BoxSizer->GetChildren();
00859         for (wxSizerItemList::const_iterator i = list.begin(); i != list.end(); i++) {
00860                 MutBoxShape * box = static_cast<MutBoxShape * > ((*i)->GetWindow());
00861                 wxASSERT(dynamic_cast<MutBoxShape *> ((*i)->GetWindow()));
00862                 if (box)
00863                         box->DrawLines(dc);
00864         }
00865 
00866         return;
00867 
00868 #if 0
00869         // x1 und x5 berechnen
00870         wxSize R = GetClientSize();
00871         int t1 = 50;
00872         int t5 = 50;
00873 
00874         for (EDevice *In = InEDevices; In; In = In->Next) {
00875                 t1 = max(t1, GetTextWidth(dc, In->Name));
00876 
00877                 for (ERoute *R = In->Routes; R; R = R->Next)
00878                         if ( R->Out )
00879                                 t5 = max(t5, GetTextWidth(dc, R->Out->Name));
00880         }
00881 
00882         x1 = max((int)(R.GetWidth() - 10*xz - 30 - 80 - 80) / 2, 50);
00883 
00884         x5 = x1;
00885 
00886         if ( x1 < t1 || x5 < t5 ) {
00887                 int s = x5+x1;
00888                 x1 = s*t1/(t1+t5);
00889                 x5 = s*t5/(t1+t5);
00890         }
00891 
00892         // Mittelpunkte
00893         int y = yh + yz+yd/2;
00894 
00895         int z1 = xz+x1/2;
00896 
00897         int z2 = 3*xz+x1+x2/2;
00898 
00899         int z3 = 5*xz+x1+x2+x3/2;
00900 
00901         int z4 = 7*xz+x1+x2+x3+x4/2;
00902 
00903         int z5 = 9*xz+x1+x2+x3+x4+x5/2;
00904 
00905         int z1t = z1;  // f¸r Textplop
00906 
00907         if ( z1-xd/2-20 < 2 )
00908                 z1 = xd/2+22; // evtl. verschieben wegen Play-Plops
00909 
00910         wxString s;
00911 
00912         dc.SetFont(RouteFont);
00913         dc.SetBackgroundMode(wxSOLID);
00914         wxPen GrayPen(wxColour(0xee, 0xee, 0xee), 1);
00915 
00916         for (REUSE(EDevice*) In = InEDevices; In; In = In->Next) {
00917 
00918                 // first line segment
00919                 dc.SetPen(*wxBLACK_PEN);
00920                 dc.SetBrush(*wxWHITE_BRUSH);
00921                 dc.DrawLine(z1, y, 2*xz+x1, y);
00922 
00923                 // InDevice
00924                 dc.DrawIcon(*DevIcon[In->DT], z1-xd/2, y-yd/2);
00925 
00926                 // InDevice Name
00927                 TextPin(dc, z1t, y+yd/2+ydt, x1, In->Name, 0);
00928 
00929                 // Mode
00930 
00931                 if ( LogicOn ) {
00932                         if ( In->Mode == -1 )
00933                                 dc.DrawIcon(*PlopIcon[0], z1, y-20);
00934                         else if ( In->Mode == 3 )
00935                                 dc.DrawIcon(*PlopIcon[3], z1, y-20);
00936                         else if ( In->DT >= DTMidiFile ) {
00937                                 /*TODO                          memDC.SelectObject(*ConIcon[(In->Mode == 1) ? 2 : 1]);
00938                                   dc.BitBlt(z1-xd/2-20, y-16, 14, 14, memDC, 0, 0, SRCCOPY);
00939                                   memDC.SelectObject(*ConIcon[(In->Mode) ? 0 : 3]);
00940                                   dc.BitBlt(z1-xd/2-20, y+2, 14, 14, memDC, 0, 0, SRCCOPY);
00941                                   if ( In->Mode > 0 )
00942                                   dc.DrawIcon(z1, y-20, *PlopIcon[In->Mode]);*/
00943                                 dc.DrawBitmap(*ConIcon[(In->Mode == 1) ? 2 : 1],
00944                                               z1-xd/2-20, y-16, false);
00945                                 dc.DrawBitmap(*ConIcon[(In->Mode) ? 0 : 3],
00946                                               z1-xd/2-20, y+2, false);
00947 
00948                                 if ( In->Mode > 0 )
00949                                         dc.DrawIcon(*PlopIcon[In->Mode], z1, y-20);
00950                         }
00951                 }
00952 
00953                 // Routes
00954                 int n = In->nRoutes(), yl = 0;
00955 
00956                 if ( n > 1 )
00957                         yl = (n-1)*yr;
00958 
00959                 dc.DrawLine(2*xz+x1, y, 2*xz+x1, y+yl);
00960 
00961                 for (ERoute *R = In->Routes; R; R = R->Next) {
00962                         // Line
00963                         dc.DrawLine(2*xz+x1, y, z5, y);
00964 
00965                         // Filter
00966 
00967                         switch ( R->Type ) {
00968 
00969                         case RTall:
00970                                 s = _("all");
00971 
00972                                 break;
00973 
00974                         case RTelse:
00975                                 s = _("else");
00976 
00977                                 break;
00978 
00979                         case RTchannel:
00980                                 if ( In->DT == DTGis )
00981                                         s = wxString::Format(_("box: %s"), sRange(R->IFrom, R->ITo).c_str());
00982                                 else
00983                                         s = wxString::Format(_("channel: %s"),
00984                                                              sRange(R->IFrom, R->ITo).c_str());
00985 
00986                                 break;
00987 
00988                         case RTstaff:
00989                                 if ( In->DT == DTGis)
00990                                         s = wxString::Format(_("staff: %s"), sRange(R->IFrom, R->ITo).c_str());
00991                                 else if ( In->DT == DTMidiPort )
00992                                         s = wxString::Format(_("keys: %s"), sRange(R->IFrom, R->ITo).c_str());
00993                                 else
00994                                         s = wxString::Format(_("track: %s"), sRange(R->IFrom, R->ITo).c_str());
00995 
00996                                 break;
00997                         }
00998 
00999                         TextPin(dc, z2, y-yt/2, x2, s, 1);
01000 
01001                         // Box
01002                         PrintBox(dc, z3, y, R->Box, R->Active, x3);
01003                         dc.SetPen(*wxBLACK_PEN); // reset Pen
01004 
01005                         // Filter
01006 
01007                         if ( R->OFrom != -1 && R->Out && R->Out->DT != DTGis ) {
01008                                 s = wxString::Format(_("channel: %s"),
01009                                                      sRange(R->OFrom, R->OTo).c_str());
01010                                 dc.SetPen(*wxBLACK_PEN);
01011                                 dc.SetBrush(*wxWHITE_BRUSH);
01012                                 TextPin(dc, z4, y-yt/2, x4, s, 1);
01013                         }
01014 
01015                         // OutDevice
01016                         if ( R->Out ) {
01017                                 dc.DrawIcon(*DevIcon[R->Out->DT], z5-xd/2, y-yd/2);
01018                                 TextPin(dc, z5, y+yd/2+ydt, x5, R->Out->Name, 0);
01019                         }
01020 
01021                         y+=yr;
01022                 }
01023 
01024                 //    if ( In->Routes ) {
01025                 dc.SetPen(GrayPen);
01026 
01027                 dc.SetBrush(*wxTRANSPARENT_BRUSH);
01028 
01029                 dc.DrawRectangle(z2-x2/2, y-yt/2-26, x2, yt-26);
01030 
01031                 //}
01032                 if ( !n )
01033                         y += yr;
01034 
01035                 y += yz;
01036         }
01037 
01038         dc.SetPen(GrayPen);
01039 
01040         dc.SetBrush(*wxTRANSPARENT_BRUSH);
01041         dc.DrawRectangle(z1-xd/2, y-yd/2, xd, yd);
01042         SetVirtualSize(CalcXl(), CalcYl());
01043 #endif
01044 }
01045 
01046 
01047 /*
01048 void MutRouteWnd::OnSize(wxSizeEvent& event)
01049 {
01050         //  wxShapeCanvas::OnSize
01051 
01052         Refresh();
01053         SetVirtualSize(CalcXl(), CalcYl());
01054         event.Skip();
01055 }
01056 */
01057 
01058 
01059 /*
01060   void TRouteWin::RePaint()
01061   {
01062   TRect R = GetClientRect();
01063   Scroller->SetRange((CalcXl() - R.right) / Scroller->XUnit, (CalcYl()-R.bottom) / Scroller->YUnit);
01064   CorrectScroller();
01065   Invalidate();
01066   PostMessage(WM_PAINT);
01067   }
01068 
01069   void TRouteWin::CorrectScroller()
01070   {
01071   TWindow *Win = GetWindowPtr(GetFocus());
01072   int xw = Win->Attr.X, yw = Win->Attr.Y;
01073   int xl = Attr.W, yl = Attr.H;
01074   int dx = 0, dy = 0;
01075   /wx*  // rechte untere Ecke im Bild ???
01076   if ( xw + MUTTAGX > xl ) dx = xw + MUTTAGX - xl;
01077   if ( yw + MUTTAGY > yl ) dy = yw + MUTTAGY - yl;
01078   // linke obere Ecke im Bild ??? (dominierend)
01079   if ( xw < 0 ) dx = xw;
01080   if ( yw < 0 ) dy = yw;
01081   Scroller->ScrollBy(dx / Scroller->XUnit, dy / Scroller->YUnit); *wx/
01082   }
01083 
01084   /wx*
01085 // keyboardanalyse, Fenster aufr‰umen, Logiken lesen und anzeigen
01086 void TRouteWin::UpDate(int thekey, bool isLogicKey)
01087 {
01088 // Analyse zuerst
01089 keyboard_analyse(thekey, isLogicKey);
01090 curTaste[curInstr][isLogicKey] = thekey;
01091 TWindow *ToFocus = NULL;
01092 if ( isLogicKey )
01093 curTaste[curInstr][0] = 0;
01094 // alte TMutTag-s lˆschen
01095 ChildBroadcastMessage(WM_CLOSE);
01096 // neue erstellen
01097 char isLogic, s[100], s1[100], key, isOpen;
01098 TWindow *aWin;
01099 nTags = 0;
01100 if ( GetMutTag(isLogic, s, s1, key, true) )
01101 do
01102 {
01103 nTags++;
01104 if ( (isOpen = (key == curTaste[curInstr][isLogic])) != 0 )
01105 if ( isLogic )
01106 {
01107 SetString(&(curLogic[curInstr]), s);
01108 if ( !s1[0] )
01109 if ( !curTS[curInstr] )
01110 sprintf(s1, "(INITIAL)");
01111 else if ( curTS[curInstr][0] != '[' )
01112 sprintf(s1, "[%s]", curTS[curInstr]);
01113 else strcpy(s1, curTS[curInstr]);
01114 SetString(&(curTS[curInstr]), s1);
01115 }
01116 else
01117 SetString(&(curTS[curInstr]), s);
01118 aWin = new TMutTag(this, isLogic, isOpen,       10, 10, key, s, GetModule());
01119 if ( isOpen ) ToFocus = aWin;
01120 }
01121 while ( GetMutTag(isLogic, s, s1, key, false) );
01122 // neue TMutTag-s aktivieren
01123 CreateChildren();
01124 // Fokus setzen
01125 if ( !ToFocus )
01126 ToFocus = GetFirstChild();
01127 ToFocus->SetFocus();
01128 // Tags anordnen
01129 SendMessage(WM_SIZE);
01130 SetFocusPos();
01131 Parent->SendMessage(WM_COMMAND, CM_SBREFRESH);
01132 MutWinOk = true;
01133 }
01134 
01135 // Reaktion auf neues aktuelles Instrument
01136 void TRouteWin::NewInstrument()
01137 {
01138 // Titel setzen
01139 sprintf(sHelp, "Logic: %s - Instrument %d", CompiledFile,
01140 curInstr + 1);
01141 Parent->SetCaption(sHelp);
01142 // Tags updaten
01143 UpDate(0, true);
01144 }            *wx/
01145 */
01146 #if 0
01147 int MutRouteWnd::CalcYl()
01148 {
01149         int yl = yh+yz;
01150 
01151         for (EDevice *In = InEDevices; In; In = In->Next) {
01152                 yl += yr+yz;
01153                 int n = In->nRoutes();
01154 
01155                 if ( n > 1 )
01156                         yl += (n-1)*yr;
01157         }
01158 
01159         return yl+yr;
01160 }
01161 
01162 bool MutRouteWnd::CheckPoint(wxPoint point, EDevice **in, ERoute **r, int &token, bool &needNew)
01163 {
01164         int y = yh + yz, ya, n;
01165         int z1 = xz+x1/2;
01166         int z2 = 3*xz+x1+x2/2;
01167         int z3 = 5*xz+x1+x2+x3/2;
01168         int z4 = 7*xz+x1+x2+x3+x4/2;
01169         int z5 = 9*xz+x1+x2+x3+x4+x5/2;
01170 
01171         if ( z1-xd/2-20 < 2 )
01172                 z1 = xd/2+22; // evtl. verschieben wegen Play-Plops
01173 
01174         // get Device
01175         if ( point.y < y && z1-x1/2 <= point.x && point.x <= z1+x1/2 ) {
01176                 *in = InEDevices;
01177                 token = RT_INDEVICE;
01178                 needNew = TRUE;
01179                 return 1;
01180         }
01181 
01182         if ( point.y < y )
01183                 return 0;
01184 
01185         for (*in = InEDevices; *in; *in = (*in)->Next) {
01186                 ya = yr+yz;
01187                 n = (*in)->nRoutes();
01188 
01189                 if ( n > 1 )
01190                         ya += (n-1)*yr;
01191 
01192                 if ( point.y < y+ya )
01193                         break;
01194 
01195                 y += ya;
01196         }
01197 
01198         if ( !*in && z1-x1/2 <= point.x && point.x <= z1+x1/2 ) {
01199                 token = RT_INDEVICE;
01200                 needNew = TRUE;
01201                 return 1;
01202         }
01203 
01204         if ( !*in )
01205                 return 0;
01206 
01207         // recalc to "middle-y"
01208         y += yd/2;
01209 
01210         n = (point.y-y+yr-yb/2-1)/yr; // number of route
01211 
01212         ya = y+n*yr;                  // y of Route
01213 
01214         *r = (*in)->GetRoute(n);
01215 
01216         // check for indevice
01217         token = RT_INDEVICE;
01218 
01219         needNew = FALSE;
01220 
01221 //  if ( POINT_IN(point, z1-xd/2, y-yd/2, xd, yd) ||
01222 //    POINT_IN(point, z1-x1/2, y+yd/2+ydt, x1, yt) )
01223         if ( LogicOn && POINT_IN(point, z1-xd/2-20, y-16, 14, 14) ) {
01224                 token = RT_PLAYBUTTON;
01225                 return 1;
01226         }
01227 
01228         if ( LogicOn && POINT_IN(point, z1-xd/2-20, y+2, 14, 14) ) {
01229                 token = RT_STOPBUTTON;
01230                 return 1;
01231         }
01232 
01233         if ( POINT_IN(point, z1-x1/2, y-yd/2, x1, yd+ydt+yt) )
01234                 return 1;
01235 
01236         if ( z1-x1/2 <= point.x && point.x <= z1+x1/2 ) {
01237                 *in = (*in)->Next;
01238                 needNew = TRUE;
01239                 return 1;
01240         }
01241 
01242         // check for in-filter
01243         token = RT_INFILTER;
01244 
01245         if ( POINT_IN(point, z2-x2/2, ya-yt/2, x2, yt) )
01246                 return 1;
01247 
01248         if ( z2-x2/2 <= point.x && point.x <= z2+x2/2 ) {
01249                 needNew = TRUE;
01250                 return 1;
01251         }
01252 
01253         // check for box
01254         token = RT_BOX;
01255 
01256         if ( POINT_IN(point, z3-xb/2, ya-yb/2, xb, yb) )
01257                 return 1;
01258 
01259         // check for out-filter
01260         token = RT_OUTFILTER;
01261 
01262         if ( POINT_IN(point, z4-x4/2, ya-yt/2, x4, yt) )
01263                 return 1;
01264 
01265         // check for outdevice
01266         token = RT_OUTDEVICE;
01267 
01268         if ( POINT_IN(point, z5-xd/2, ya-yd/2, xd, yd) ||
01269              POINT_IN(point, z5-x5/2, ya+yd/2+ydt, x5, yt) )
01270                 return 1;
01271 
01272         return 0;
01273 }
01274 #endif
01275 #if 0
01276 void MutRouteWnd::OnLeftDown(wxMouseEvent &event)
01277 {
01278         EDevice *In=0;
01279         ERoute *R=0;
01280         bool NeedNew;
01281         int Token;
01282         // Punkt auf absolute Fensterkoordinaten umrechnen
01283         wxPoint rp;
01284         CalcUnscrolledPosition(event.GetX(), event.GetY(), &rp.x, &rp.y);
01285         // Box erwischt ?
01286 
01287         if ( !CheckPoint(rp, &In, &R, Token, NeedNew) )
01288                 return;
01289 
01290         if ( !R || NeedNew )
01291                 return;
01292 
01293         if ( R->Box >= 0 ) {
01294                 wxCommandEvent event1(wxEVT_COMMAND_MENU_SELECTED, CM_BOX);
01295                 event1.SetId(R->Box);
01296                 GetParent()->ProcessEvent(event1);
01297         }
01298 
01299         if ( In->DT < DTMidiPort )
01300                 return;
01301 
01302         if ( Token == RT_PLAYBUTTON ) {
01303                 if ( In->Mode == MutaborDevicePlay ) // Pause
01304                         In->Mode = MutaborDevicePause;
01305                 else                 // Play
01306                         In->Mode = MutaborDevicePlay;
01307 
01308                 InDeviceAction(In->Nr, In->Mode);
01309 
01310                 //RePaint();
01311                 Refresh(); // Reicht das auch?
01312         }
01313 
01314         if ( Token == RT_STOPBUTTON ) {
01315                 if ( In->Mode != MutaborDeviceStop ) {
01316                         In->Mode = MutaborDeviceStop;
01317                         InDeviceAction(In->Nr, In->Mode);
01318                         //RePaint();
01319                         Refresh(); // Reicht das auch?
01320                 }
01321         }
01322 }
01323 #endif
01324 
01325 #if 0 
01326 void MutRouteWnd::OnLeftDClick(wxMouseEvent &event)
01327 {
01328         EDevice *In=NULL;
01329         ERoute *R=NULL, **R1 = NULL;
01330         bool NeedNew;
01331         int Token, Res = wxID_CANCEL;
01332         wxPoint rp;
01333 
01334         CalcUnscrolledPosition(event.GetX(), event.GetY(), &rp.x, &rp.y);
01335 
01336         if ( !CheckPoint(rp, &In, &R, Token, NeedNew) )
01337                 return;
01338 
01339         if ( !R && Token > RT_INFILTER )
01340                 return;
01341 
01342         int nMidi;
01343 
01344         /*if ( LogicOn )
01345           {
01346           wxMessageBox(_("Stop the logics, before you edit the routes!"), _("Not yet!") , wxOK | wxICON_STOP);
01347           return;
01348           }*/
01349 
01350         switch ( Token ) {
01351 
01352         case RT_INDEVICE: {     // evtl. neues Device anlegen
01353 
01354                 if ( NeedNew ) {
01355                         In = NewDevice(&InEDevices, DTUnknown, wxEmptyString, 0, 0, In);
01356                         Refresh();//RePaint();
01357                 }
01358 
01359                 InputDevDlg in(this);
01360 
01361                 // ComboBoxen f¸llen
01362 #ifdef RTMIDI
01363                 nMidi = rtmidiin->getPortCount();
01364 
01365                 if ( nMidi )  {
01366 #ifdef __WXMSW__
01367                         wxString portName;
01368 #else
01369                         std::string portName;
01370 #endif
01371 
01372                         for (int i = 0; i < nMidi; i++) {
01373                                 try {
01374                                         portName = rtmidiin->getPortName(i);
01375 #ifdef __WXMSW__
01376                                         in.AppendPortChoice(portName);
01377 #else
01378                                         in.AppendPortChoice(muT(portName.c_str()));
01379 #endif
01380                                 } catch (RtError &error) {
01381                                         error.printMessage();
01382                                         break;
01383                                 }
01384                         }
01385                 } else
01386                         in.AppendPortChoice(_("no device"));
01387 
01388 #else
01389                 /*    nMidi = midiInGetNumDevs();
01390                       if ( nMidi )
01391                       {
01392                       for (int i = 0; i < nMidi; i++)
01393                       {
01394                       MIDIINCAPS miin;
01395                       midiInGetDevCaps(i, &miin, sizeof(MIDIINCAPS));
01396                       DataR0.Device.AddString(miin.szPname);
01397                       }
01398                       }
01399                       else
01400                       DataR0.Device.AddString("no device");*/
01401 #endif
01402                 in.SetType(DTUnknown);
01403 
01404                 in.SetMidiDevice(0);
01405 
01406                 in.SetMidiFile(wxEmptyString);
01407 
01408                 in.SetGUIDOFile(wxEmptyString);
01409 
01410                 // fill with datas
01411                 DevType type = DTUnknown;
01412 
01413                 in.SetType( In->DT );
01414 
01415                 switch ( In->DT ) {
01416 
01417                 case DTGis:
01418                         in.SetGUIDOFile(In->Name);
01419 
01420                         break;
01421 
01422                 case DTMidiPort:
01423                         in.SetMidiDevice(In->DevId);
01424 
01425                         break;
01426 
01427                 case DTMidiFile:
01428                         in.SetMidiFile(In->Name);
01429 
01430                         break;
01431 
01432                 case DTNotSet:
01433                         wxLogWarning(_("Unexpected value: DTNotSet"));
01434 
01435                         break;
01436 
01437                 case DTUnknown:
01438                         break;
01439 
01440                 default:
01441                         wxLogError(_("Unexpected device type: %d"), In->DT);
01442                 }
01443 
01444                 Res = in.ShowModal();
01445 
01446                 if ( Res == wxID_OK ) {
01447                         DEBUGLOG (other, _T("Got value %d"),in.GetType());
01448                         type = in.GetType();
01449 
01450                         switch (type) {
01451 
01452                         case DTMidiPort:
01453                                 NewDevice(&InEDevices,
01454                                           DTMidiPort,
01455                                           in.GetPortString(in.GetMidiDevice()),
01456                                           in.GetMidiDevice(), In, In);
01457 
01458                                 break;
01459 
01460                         case DTMidiFile:
01461                                 NewDevice(&InEDevices, DTMidiFile, in.GetMidiFile(), 0, In, In);
01462 
01463                                 break;
01464 
01465                         case DTGis:
01466                                 NewDevice(&InEDevices, DTGis, in.GetGUIDOFile(), 0, In, In);
01467 
01468                                 break;
01469 
01470                         case DTNotSet:
01471 
01472                         case DTUnknown:
01473                                 break;
01474 
01475                         default:
01476                                 wxLogWarning(_("Unexpected value: %d"),type);
01477                         }
01478                 } else if ( Res == wxID_REMOVE || (NeedNew && Res == wxCANCEL) )
01479                         NewDevice(&InEDevices, DTNotSet, wxEmptyString, 0, In, 0);
01480 
01481                 break;
01482         }
01483 
01484         case RT_INFILTER: {
01485                 // evtl. neue Route anlegen
01486 
01487                 if ( !R )
01488                         NeedNew = TRUE;
01489 
01490                 if ( NeedNew ) {
01491                         // als Adresse ermitteln
01492 
01493                         for (R1 = &In->Routes; *R1; R1 = &((*R1)->Next))
01494                                 if ( *R1 == R )
01495                                         break;
01496 
01497                         R = new ERoute(RTall, 0, 0, -2, 0, 0, 0, 15);
01498 
01499                         R->Next = *R1;
01500 
01501                         *R1 = R;
01502 
01503                         Refresh();//RePaint();
01504                 }
01505 
01506                 //
01507                 IsDT = In->DT;
01508 
01509                 InputFilterDlg dlg(this, In->DT);
01510 
01511                 dlg.SetType(R->Type);
01512 
01513                 dlg.SetFrom(R->IFrom);
01514 
01515                 dlg.SetTo(R->ITo);
01516 
01517                 dlg.UpdateLayout(R->Type);
01518 
01519                 Res = dlg.ShowModal();
01520 
01521                 if ( Res == wxID_OK ) {
01522                         R->Type = (RouteType)dlg.GetType();
01523                         R->IFrom = dlg.GetFrom();
01524                         R->ITo = dlg.GetTo();
01525                 } else if ( Res == wxID_REMOVE || (NeedNew && Res == wxID_CANCEL) )
01526                         for (R1 = &(In->Routes); *R1; R1 = &((*R1)->Next))
01527                                 if ( *R1 == R ) {
01528                                         *R1 = R->Next;
01529                                         R->Next = 0;
01530                                         break;
01531                                 }
01532 
01533                 break;
01534         }
01535 
01536         case RT_BOX: {
01537                 BoxDlg dlg(this);
01538                 // fill with datas
01539                 dlg.SetBoxNr(0);
01540                 int Type = 0;
01541 
01542                 if ( R->Box == NoBox )
01543                         Type = 2;
01544                 else if ( R->Box == GmnBox )
01545                         Type = 1;
01546                 else {
01547                         Type = 0;
01548                         dlg.SetBoxNr(R->Box);
01549                 }
01550 
01551                 dlg.SetBoxType(Type);
01552 
01553                 dlg.ctrlBox1->SetValue(Type == 0);
01554                 dlg.ctrlBox2->SetValue(Type == 1);
01555                 dlg.ctrlBox3->SetValue(Type == 2);
01556                 dlg.SetMode(!R->Active);
01557                 dlg.UpdateLayout(Type);
01558                 Res = dlg.ShowModal();
01559 
01560                 if ( Res == wxID_OK ) {
01561                         switch ( dlg.GetBoxType() ) {
01562 
01563                         case 0:
01564                                 R->Box = dlg.GetBoxNr();
01565 
01566                                 break;
01567 
01568                         case 1:
01569                                 R->Box = GmnBox;
01570 
01571                                 break;
01572 
01573                         case 2:
01574                                 R->Box = NoBox;
01575 
01576                                 break;
01577                         }
01578 
01579                         R->Active = !dlg.GetMode();
01580                 }
01581 
01582                 break;
01583         }
01584 
01585         case RT_OUTFILTER: {
01586                 OutputFilterDlg dlg(this);
01587                 dlg.SetFrom(R->OFrom);
01588                 dlg.SetTo(R->OTo);
01589                 dlg.SetAvoidDrumChannel(R->ONoDrum);
01590                 Res = dlg.ShowModal();
01591 
01592                 if ( Res == wxID_OK ) {
01593                         R->OFrom = dlg.GetFrom();
01594                         R->OTo = dlg.GetTo();
01595                         R->ONoDrum = dlg.GetAvoidDrumChannel();
01596                 }
01597 
01598                 break;
01599         }
01600 
01601         case RT_OUTDEVICE:
01602                 EDevice *Out = R->Out;
01603 
01604                 // evtl. neues Device anlegen
01605                 if ( !Out ) {
01606                         Out = NewDevice(&OutEDevices, DTUnknown, wxEmptyString, 0, 0, 0);
01607                         R->Out = Out;
01608                         Refresh(); //RePaint();
01609                         NeedNew = TRUE;
01610                 }
01611 
01612                 // ComboBoxen f¸llen
01613                 OutputDevDlg out(this);
01614 
01615 #ifdef RTMIDI
01616                 nMidi = rtmidiout->getPortCount();
01617 
01618                 if ( nMidi ) {
01619 #ifdef __WXMSW__
01620                         wxString portName;
01621 #else
01622                         std::string portName;
01623 #endif
01624 
01625                         for (int i = 0; i < nMidi; i++)  {
01626                                 try {
01627                                         portName = rtmidiout->getPortName(i);
01628 #ifdef __WXMSW__
01629                                         out.ctrlMidiDevice->Append(portName);
01630 #else
01631                                         out.ctrlMidiDevice->Append(muT(portName.c_str()));
01632 #endif
01633                                 } catch (RtError &error) {
01634                                         error.printMessage();
01635                                         break;
01636                                 }
01637                         }
01638                 } else
01639                         out.ctrlMidiDevice->Append(_("no device"));
01640 
01641 #else
01642                 nMidi = midiOutGetNumDevs();
01643 
01644                 if ( nMidi ) {
01645                         for (int i = 0; i < nMidi; i++) {
01646                                 MIDIOUTCAPS miout;
01647                                 midiOutGetDevCaps(i, &miout, sizeof(MIDIOUTCAPS));
01648                                 DataR0.Device.AddString(miout.szPname);
01649                         }
01650                 } else
01651                         DataR0.Device.AddString("no device");
01652 
01653 #endif
01654                 out.SetType(0);
01655 
01656                 out.SetMidiDevice(0);
01657 
01658                 out.SetMidiDeviceBending(2);
01659 
01660                 out.SetMidiFile(wxEmptyString);
01661 
01662                 out.SetMidiFileBending(2);
01663 
01664                 out.SetGUIDOFile(wxEmptyString);
01665 
01666                 // fill with datas
01667                 int type = 0;
01668 
01669                 switch ( Out->DT ) {
01670 
01671                 case DTGis:
01672                         out.SetType(type = 2);
01673 
01674                         out.SetGUIDOFile(Out->Name);
01675 
01676                         break;
01677 
01678                 case DTMidiPort:
01679                         out.SetMidiDevice(Out->DevId);
01680 
01681                         out.SetMidiDeviceBending(Out->BendingRange);
01682 
01683                         break;
01684 
01685                 case DTMidiFile:
01686                         out.SetType(type = 1);
01687 
01688                         out.SetMidiFile(Out->Name);
01689 
01690                         out.SetMidiFileBending(Out->BendingRange);
01691 
01692                         break;
01693 
01694                 case DTNotSet:
01695                         wxLogWarning(_("Unexpected value: DTNotSet"));
01696 
01697                         break;
01698 
01699                 case DTUnknown:
01700                         break;
01701 
01702                 default:
01703                         wxLogError(_("Unexpected device type: %d"), Out->DT);
01704                 }
01705 
01706                 out.UpdateLayout(type);
01707 
01708                 Res = out.ShowModal();
01709 
01710                 if ( Res == wxID_OK ) {
01711                         int type = out.GetType();
01712 
01713                         if ( type == 0 ) {
01714                                 Out = NewDevice(&OutEDevices,
01715                                                 DTMidiPort,
01716                                                 out.ctrlMidiDevice->GetString(out.GetMidiDevice()),
01717                                                 out.GetMidiDevice(), Out, Out);
01718                                 Out->BendingRange = out.GetMidiDeviceBending();
01719                         } else if ( type == 1 ) {
01720                                 Out = NewDevice(&OutEDevices,
01721                                                 DTMidiFile,
01722                                                 out.GetMidiFile(),
01723                                                 0, Out, Out);
01724                                 Out->BendingRange = out.GetMidiFileBending();
01725                         } else
01726                                 Out = NewDevice(&OutEDevices, DTGis, out.GetGUIDOFile(), 0, Out, Out);
01727                 } else if ( Res == wxID_REMOVE || (NeedNew && Res == wxCANCEL) )
01728                         Out = 0; // NewDevice(&OutEDevices, DTNotSet, "", 0, Out, 0);  nicht lˆschen, kˆnnte ja noch eine andere Route verwenden
01729 
01730                 R->Out = Out;
01731 
01732                 break;
01733         }
01734 
01735         // evtl. neu zeichnen
01736         if ( Res == wxID_OK || Res == wxID_REMOVE || NeedNew )
01737                 Refresh();//RePaint();
01738 }
01739 #endif
01740 
01741 /*
01742   void TRouteWin::EvRButtonDown(uint, TPoint& point)
01743   {
01744   if ( LogicOn )
01745   RightButtonMenu(this, point);
01746   }
01747 */
01748 
01749 

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