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 SetLowColor(ViewColor()); 38 FillRect(Bounds(), B_SOLID_LOW); 39 40 SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); 41 BFont font(be_bold_font); 42 SetFont(&font); 43 font_height height; 44 font.GetHeight(&height); 45 float width = font.StringWidth(B_TRANSLATE("Drop files here")); 46 47 BPoint pt; 48 pt.x = (Bounds().Width() - width) / 2; 49 pt.y = (Bounds().Height() + height.ascent + height.descent)/ 2; 50 DrawString(B_TRANSLATE("Drop files here"), pt); 51 } 52 BListView::Draw(updateRect); 53 } 54 55 56 void 57 SoundListView::AttachedToWindow() 58 { 59 BListView::AttachedToWindow(); 60 SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), 61 B_LIGHTEN_1_TINT)); 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