head	1.1;
access;
symbols;
locks
	baron:1.1; strict;
comment	@// @;


1.1
date	99.04.17.15.31.26;	author baron;	state Exp;
branches;
next	;


desc
@@


1.1
log
@Initial revision
@
text
@/*
 * $Id$
 *
 *
 * Copyright 1999 Kelvin W Sherlock
 *
 *
 * Class to display the events in a track
 *
 */

#include "TrackWindow.h"
#include <ListView.h>
#include <View.h>
#include <ScrollView.h>
#include <String.h>
#include <Application.h>
#include <stdio.h>

#define LIST_INVOCATION 'sele'
#define SUBWINDOW_CLOSE 'cclo'

TrackWindow::TrackWindow(TrackList * T, BHandler *hand):
	BWindow(BRect(200, 200, 600, 500), "", B_DOCUMENT_WINDOW, 0),
	handler(hand)
	//quitOnce(0)
{
BString S;
BRect r(Bounds());

	data = T;

	S = "";
	if (data) S = data->GetName();

	if (!S.Length())
	{
		S = "Untitled Track #";
		S << (uint32) data->GetTrackNumber();
	}
	
	SetTitle(S.String());
	
	
	r.right -= 14;	//width of scroller
	LV = new BListView(r, "", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL);
	
	LV->SetInvocationMessage(new BMessage(LIST_INVOCATION));
	
	SV = new BScrollView("", LV, B_FOLLOW_ALL, 0, false, true);
	
	AddChild(SV);
	
	if (data) LV->AddList(data);
	LV->DeselectAll();
	
	Show();
	LV->DeselectAll();
}

TrackWindow::~TrackWindow()
{
}

bool TrackWindow::QuitRequested(void)
{
BMessage *msg;

	//if (quitOnce) return true;
	
	//quitOnce++;
	
	printf("quit requested\n");

	msg = new BMessage(SUBWINDOW_CLOSE);
	msg->AddPointer("subwindow", this);
	//PostMessage(msg, handler);
	DispatchMessage(msg, handler);
	delete msg;

	return false;
}

void TrackWindow::Quit(void)
{
	Lock();
	//{
		printf("quit\n");
		LV->DeselectAll();
		SV->RemoveSelf();
		LV->RemoveSelf();
		delete SV;
		delete LV;

		BWindow::Quit();
	//}
}

void TrackWindow::MessageReceived(BMessage *msg)
{

	BWindow::MessageReceived(msg);
}@
