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


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


desc
@@


1.1
log
@Initial revision
@
text
@#include "MyListView.h"
#include <PopUpMenu.h>
#include <MenuItem.h>
#include <stdio.h>

#include "TrackList.h"
enum
{
	MENU_DELETE = 'dele',



};


MyListView::MyListView(BRect frame, const char *name, 
		list_view_type type, 
		uint32 resizingMode,
		uint32 flags):
		BListView(frame, name, type, resizingMode, flags)
{
	status_t err;
	BMenuItem *tmp;
	PopUp = new BPopUpMenu("", false, false);
	tmp = new BMenuItem("Delete Track", new BMessage(MENU_DELETE), 0);
	//tmp->SetTarget(this);
	PopUp->AddItem(tmp);
	//err = PopUp->SetTargetForItems(this);
}


MyListView::~MyListView()
{
	if (PopUp)
		delete PopUp;
}



void MyListView::AttachedToWindow(void)
{
	if (PopUp) PopUp->SetTargetForItems((BHandler *)Window());
	BListView::AttachedToWindow();
}

void MyListView::MessageReceived(BMessage *msg)
{
	switch (msg->what)
	{
	case MENU_DELETE:
		msg->PrintToStream();
		break;
	default:
		BListView::MessageReceived(msg);
	
	}
}

void MyListView::MouseDown(BPoint where)
{
	BPoint loc2;
	uint32 buttons;
	int32 index;
	
	GetMouse(&loc2, &buttons);

	index = IndexOf(loc2);
	ConvertToScreen(&loc2);
	
	if ( (buttons & B_SECONDARY_MOUSE_BUTTON) && (index >= 0))
	{
		Select(index);
		
		PopUp->Go(loc2, TRUE, FALSE, TRUE);
	}
	else
		BListView::MouseDown(where);
}
@
