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 6 * and Producers) 7 */ 8 #include <Catalog.h> 9 #include <Entry.h> 10 #include <Locale.h> 11 12 #include "SoundListView.h" 13 14 15 #undef B_TRANSLATION_CONTEXT 16 #define B_TRANSLATION_CONTEXT "SoundListView" 17 18 19 SoundListView::SoundListView( 20 const BRect & area, 21 const char * name, 22 uint32 resize) : 23 BListView(area, name, B_SINGLE_SELECTION_LIST, resize) 24 { 25 } 26 27 28 SoundListView::~SoundListView() 29 { 30 } 31 32 33 void 34 SoundListView::Draw(BRect updateRect) 35 { 36 if (IsEmpty()) { 37 SetHighColor(235,235,235); 38 FillRect(Bounds()); 39 40 SetHighColor(0,0,0); 41 BFont font(be_bold_font); 42 font.SetSize(12.0); 43 SetFont(&font); 44 font_height height; 45 font.GetHeight(&height); 46 float width = font.StringWidth(B_TRANSLATE("Drop files here")); 47 48 BPoint pt; 49 pt.x = (Bounds().Width() - width) / 2; 50 pt.y = (Bounds().Height() + height.ascent + height.descent)/ 2; 51 DrawString(B_TRANSLATE("Drop files here"), pt); 52 } 53 BListView::Draw(updateRect); 54 } 55 56 57 void 58 SoundListView::AttachedToWindow() 59 { 60 BListView::AttachedToWindow(); 61 SetViewColor(255,255,255); 62 } 63 64 65 SoundListItem::SoundListItem( 66 const BEntry & entry, 67 bool isTemp) 68 : BStringItem(""), 69 fEntry(entry), 70 fIsTemp(isTemp) 71 { 72 char name[256]; 73 fEntry.GetName(name); 74 SetText(name); 75 } 76 77 78 SoundListItem::~SoundListItem() 79 { 80 } 81