/* * Copyright 1999 Kelvin W Sherlock * * $Id: TrackList.cpp,v 1.1 1999/04/17 15:31:04 baron Exp baron $ */ #include #include #include #include #include #include "TrackList.h" #include "TrackWindow.h" TrackList::TrackList(int cnt): BListItem(), BList(cnt), numEvents(0), trackName(""), instrumentName(""), theWindow(NULL) { theWindow = NULL; } TrackList::~TrackList() { } void TrackList::SetName(const char *str) { trackName = str; } void TrackList::SetName(const BString& b) { trackName = b; } const char *TrackList::GetName(void) const { return trackName.String(); } const char *TrackList::GetInstrument(void) const { return instrumentName.String(); } void TrackList::SetInstrument(const BString& b) { instrumentName = b; } void TrackList::SetTrackNumber(int n) { trackNumber = n; } int TrackList::GetTrackNumber(void) const { return trackNumber; } void TrackList::DrawItem(BView *owner, BRect rect, bool DrawEveryThing) { BString buffer; if (DrawEveryThing || IsSelected()) { rgb_color color; if (IsSelected()) owner->SetHighColor(216,216,216); else owner->SetHighColor(owner->ViewColor()); owner->FillRect(rect); } // draw the track number owner->SetHighColor(0,0,0); //black owner->MovePenTo(rect.left+4, rect.bottom-2); buffer = ""; buffer << (uint32) trackNumber; owner->DrawString(buffer.String()); // Draw the track name owner->MovePenTo(rect.left+54, rect.bottom-2); owner->DrawString(trackName.String()); // Draw the instrument name owner->MovePenTo(rect.left+204, rect.bottom-2); owner->DrawString(instrumentName.String()); // Draw the # of events owner->MovePenTo(rect.left+354, rect.bottom-2); buffer = ""; buffer << (uint32) CountItems(); owner->DrawString(buffer.String()); } #define SUBWINDOW_CLOSE 'cclo' void TrackList::MessageReceived(BMessage *msg) { switch (msg->what) { case SUBWINDOW_CLOSE: printf("subwindow!\n"); { status_t err; BWindow *W; err = msg->FindPointer("subwindow", 0, (void **)&W); if (err == B_OK) { if (W == theWindow) { theWindow = NULL; printf("closing it...\n"); W->Lock(); printf("1\n"); W->Hide(); printf("2\n"); W->Quit(); } else printf("Unmatched window!!!\n"); } else printf("error getting message\n"); } break; default: printf("not close!\n"); BHandler::MessageReceived(msg); } } void TrackList::EditWindow(void) { //WTF is this wrong sometimes???? printf ("EditWindow!\n"); printf("%x\n", theWindow); if (theWindow) { theWindow->Lock(); while(theWindow->IsHidden()) theWindow->Show(); theWindow->Unlock(); theWindow->Activate(); } else { printf("creating a new window\n"); theWindow = new TrackWindow(this, this); } } void TrackList::QuitWindow(void) { if (theWindow) { theWindow->Lock(); theWindow->Hide(); theWindow->Quit(); theWindow = NULL; } }