#include "Builtins.h" #include #include "MidiData.h" #include #include #include #include #include #include #include class TransposeWindow: public AddOnWindow { public: TransposeWindow(BList *, BMessage *, BLooper *); ~TransposeWindow(); virtual void MessageReceived(BMessage *); private: BTextView *txt; BList *List; BMessage *Message; BLooper *Looper; }; /* * this is the entry point * */ BWindow *Transpose(BList *List, BMessage *Msg, BLooper *Loop) { return new TransposeWindow(List, Msg, Loop); } TransposeWindow::TransposeWindow(BList *list, BMessage *M, BLooper *Loop): BWindow(BRect(100, 100, 300, 180), "Tranpose", B_TITLED_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE) { List = list; Message = M; Looper = Loop; BView *BackGround = new BView(Bounds(), "", B_FOLLOW_ALL, B_WILL_DRAW); BackGround->SetViewColor(216, 216, 216); AddChild(BackGround); BButton *B = new BButton(BRect(150, 40, 190, 55), "", "OK", new BMessage('_ok_')); B->MakeDefault(true); BackGround->AddChild(B); B = new BButton(BRect(10, 40, 90, 55), "", "Cancel", new BMessage('_ca_')); BackGround->AddChild(B); txt = new BTextControl(BRect(10, 10, 190, 25), "", "Transpose by", "0", NULL); BTextView *V = txt->TextView(); for (int i = 0; i < 255; i++) V->DisallowChar(i); for (char *cp = "0123456789-"; *cp; cp++) V->AllowChar(*cp); BackGround->AddChild(txt); } void TransposeWindow::MessageReceived(BMessage *msg) { switch(msg->what) { case '_ca_': { BMessage *m(Message); m->AddInt32("Status", 0); Looper->PostMessage(msg); Quit(); } break; case '_ok_': { const char *cp = txt->Text(); int cnt = 0; cnt = atoi(cp); if (cnt) { for (int32 i = 0; i < List->CountItems(); i++) { Note *N = (Note *)List->ItemAt(i); if (N->GetKind() == 0x90) { N->SetNote(N->GetNote + cnt); } } BMessage *m(Message); m->AddInt32("Status", 1); Looper->PostMessage(msg); Quit(); } break; default: BWindow::MessageReceived(msg); } }