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 SoundListView::~SoundListView() 21 { 22 } 23 24 void 25 SoundListView::Draw(BRect updateRect) 26 { 27 if (IsEmpty()) { 28 SetHighColor(235,235,235); 29 FillRect(Bounds()); 30 31 SetHighColor(0,0,0); 32 BFont font(be_bold_font); 33 font.SetSize(12.0); 34 SetFont(&font); 35 font_height height; 36 font.GetHeight(&height); 37 float width = font.StringWidth("Drop Files Here"); 38 39 BPoint pt; 40 pt.x = (Bounds().Width() - width) / 2; 41 pt.y = (Bounds().Height() + height.ascent + height.descent)/ 2; 42 DrawString("Drop Files Here", pt); 43 } 44 BListView::Draw(updateRect); 45 } 46 47 48 void 49 SoundListView::AttachedToWindow() 50 { 51 BListView::AttachedToWindow(); 52 SetViewColor(255,255,255); 53 } 54 55 56 SoundListItem::SoundListItem( 57 const BEntry & entry, 58 bool isTemp) 59 : BStringItem(""), 60 fEntry(entry), 61 fIsTemp(isTemp) 62 { 63 char name[256]; 64 fEntry.GetName(name); 65 SetText(name); 66 } 67 68 SoundListItem::~SoundListItem() 69 { 70 } 71