xref: /haiku/src/apps/soundrecorder/SoundListView.cpp (revision 9760dcae2038d47442f4658c2575844c6cf92c40)
1 /*
2  * Copyright 2005, Jérôme Duval. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers and Producers)
6  */
7 #include <Entry.h>
8 
9 #include "SoundListView.h"
10 
11 
12 SoundListView::SoundListView(
13 	const BRect & area,
14 	const char * name,
15 	uint32 resize) :
16 	BListView(area, name, B_SINGLE_SELECTION_LIST, resize)
17 {
18 }
19 
20 
21 SoundListView::~SoundListView()
22 {
23 }
24 
25 
26 void
27 SoundListView::Draw(BRect updateRect)
28 {
29 	if (IsEmpty()) {
30 		SetHighColor(235,235,235);
31 		FillRect(Bounds());
32 
33 		SetHighColor(0,0,0);
34 		BFont font(be_bold_font);
35 		font.SetSize(12.0);
36 		SetFont(&font);
37 		font_height height;
38 		font.GetHeight(&height);
39 		float width = font.StringWidth("Drop files here");
40 
41 		BPoint pt;
42 		pt.x = (Bounds().Width() - width) / 2;
43 		pt.y = (Bounds().Height() + height.ascent + height.descent)/ 2;
44 		DrawString("Drop files here", pt);
45 	}
46 	BListView::Draw(updateRect);
47 }
48 
49 
50 void
51 SoundListView::AttachedToWindow()
52 {
53 	BListView::AttachedToWindow();
54 	SetViewColor(255,255,255);
55 }
56 
57 
58 SoundListItem::SoundListItem(
59 	const BEntry & entry,
60 	bool isTemp)
61 	: BStringItem(""),
62 		fEntry(entry),
63 		fIsTemp(isTemp)
64 {
65 	char name[256];
66 	fEntry.GetName(name);
67 	SetText(name);
68 }
69 
70 
71 SoundListItem::~SoundListItem()
72 {
73 }
74