157e2f323SJérôme Duval /*
257e2f323SJérôme Duval * Copyright 2005, Jérôme Duval. All rights reserved.
357e2f323SJérôme Duval * Distributed under the terms of the MIT License.
457e2f323SJérôme Duval *
53ee96407SJérôme Duval * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers
63ee96407SJérôme Duval * and Producers)
757e2f323SJérôme Duval */
83ee96407SJérôme Duval #include <Catalog.h>
957e2f323SJérôme Duval #include <Entry.h>
103ee96407SJérôme Duval #include <Locale.h>
1157e2f323SJérôme Duval
1257e2f323SJérôme Duval #include "SoundListView.h"
1357e2f323SJérôme Duval
1457e2f323SJérôme Duval
15546208a5SOliver Tappe #undef B_TRANSLATION_CONTEXT
16546208a5SOliver Tappe #define B_TRANSLATION_CONTEXT "SoundListView"
173ee96407SJérôme Duval
183ee96407SJérôme Duval
SoundListView(const BRect & area,const char * name,uint32 resize)1957e2f323SJérôme Duval SoundListView::SoundListView(
2057e2f323SJérôme Duval const BRect & area,
2157e2f323SJérôme Duval const char * name,
2257e2f323SJérôme Duval uint32 resize) :
2357e2f323SJérôme Duval BListView(area, name, B_SINGLE_SELECTION_LIST, resize)
2457e2f323SJérôme Duval {
2557e2f323SJérôme Duval }
2657e2f323SJérôme Duval
278e32a27eSPhilippe Saint-Pierre
~SoundListView()2857e2f323SJérôme Duval SoundListView::~SoundListView()
2957e2f323SJérôme Duval {
3057e2f323SJérôme Duval }
3157e2f323SJérôme Duval
328e32a27eSPhilippe Saint-Pierre
3357e2f323SJérôme Duval void
Draw(BRect updateRect)3457e2f323SJérôme Duval SoundListView::Draw(BRect updateRect)
3557e2f323SJérôme Duval {
3657e2f323SJérôme Duval if (IsEmpty()) {
37*b271ff3fSPhilippe Saint-Pierre SetLowColor(ViewColor());
38*b271ff3fSPhilippe Saint-Pierre FillRect(Bounds(), B_SOLID_LOW);
3957e2f323SJérôme Duval
40*b271ff3fSPhilippe Saint-Pierre SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
4157e2f323SJérôme Duval BFont font(be_bold_font);
4257e2f323SJérôme Duval SetFont(&font);
4357e2f323SJérôme Duval font_height height;
4457e2f323SJérôme Duval font.GetHeight(&height);
453ee96407SJérôme Duval float width = font.StringWidth(B_TRANSLATE("Drop files here"));
4657e2f323SJérôme Duval
4757e2f323SJérôme Duval BPoint pt;
4857e2f323SJérôme Duval pt.x = (Bounds().Width() - width) / 2;
4957e2f323SJérôme Duval pt.y = (Bounds().Height() + height.ascent + height.descent)/ 2;
503ee96407SJérôme Duval DrawString(B_TRANSLATE("Drop files here"), pt);
5157e2f323SJérôme Duval }
5257e2f323SJérôme Duval BListView::Draw(updateRect);
5357e2f323SJérôme Duval }
5457e2f323SJérôme Duval
5557e2f323SJérôme Duval
5657e2f323SJérôme Duval void
AttachedToWindow()5757e2f323SJérôme Duval SoundListView::AttachedToWindow()
5857e2f323SJérôme Duval {
5957e2f323SJérôme Duval BListView::AttachedToWindow();
60*b271ff3fSPhilippe Saint-Pierre SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
61*b271ff3fSPhilippe Saint-Pierre B_LIGHTEN_1_TINT));
6257e2f323SJérôme Duval }
6357e2f323SJérôme Duval
6457e2f323SJérôme Duval
SoundListItem(const BEntry & entry,bool isTemp)6557e2f323SJérôme Duval SoundListItem::SoundListItem(
6657e2f323SJérôme Duval const BEntry & entry,
6757e2f323SJérôme Duval bool isTemp)
6857e2f323SJérôme Duval : BStringItem(""),
6957e2f323SJérôme Duval fEntry(entry),
7057e2f323SJérôme Duval fIsTemp(isTemp)
7157e2f323SJérôme Duval {
7257e2f323SJérôme Duval char name[256];
7357e2f323SJérôme Duval fEntry.GetName(name);
7457e2f323SJérôme Duval SetText(name);
7557e2f323SJérôme Duval }
7657e2f323SJérôme Duval
778e32a27eSPhilippe Saint-Pierre
~SoundListItem()7857e2f323SJérôme Duval SoundListItem::~SoundListItem()
7957e2f323SJérôme Duval {
8057e2f323SJérôme Duval }
81