1/*
2 * Copyright (c) 2010 Philippe Saint-Pierre, stpere@gmail.com
3 * All rights reserved. Distributed under the terms of the MIT license.
4 *
5 * Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
6 * as long as it is accompanied by it's documentation and this copyright notice.
7 * The software comes with no warranty, etc.
8 */
9
10
11#include <Catalog.h>
12#include <Box.h>
13#include <Button.h>
14#include <StringView.h>
15#include <Volume.h>
16#include <Path.h>
17
18#include <LayoutBuilder.h>
19
20#include "DiskUsage.h"
21#include "MainWindow.h"
22#include "PieView.h"
23#include "StatusView.h"
24
25#include "VolumeView.h"
26
27#undef B_TRANSLATION_CONTEXT
28#define B_TRANSLATION_CONTEXT "Volume View"
29
30const float kMinWinSize = 275.0;
31
32VolumeView::VolumeView(const char* name, BVolume* volume)
33	: BView(name, B_WILL_DRAW)
34{
35	SetLayout(new BGroupLayout(B_HORIZONTAL));
36	fPieView = new PieView(volume);
37
38	fPieView->SetExplicitMinSize(BSize(kMinWinSize, kMinWinSize));
39
40	fStatusView = new StatusView();
41
42	AddChild(BLayoutBuilder::Group<>(B_VERTICAL, 2)
43		.Add(fPieView)
44		.Add(fStatusView)
45	);
46}
47
48
49VolumeView::~VolumeView()
50{
51}
52
53
54void
55VolumeView::EnableRescan()
56{
57	fStatusView->EnableRescan();
58}
59
60
61void
62VolumeView::EnableCancel()
63{
64	fStatusView->EnableCancel();
65}
66
67
68void
69VolumeView::SetPath(BPath path)
70{
71	fPieView->SetPath(path);
72	EnableRescan();
73}
74
75
76void
77VolumeView::MessageReceived(BMessage* msg)
78{
79	switch(msg->what) {
80		case kBtnCancel:
81		case kBtnRescan:
82			fPieView->MessageReceived(msg);
83			break;
84
85		default:
86			BView::MessageReceived(msg);
87	}
88}
89
90
91void
92VolumeView::ShowInfo(const FileInfo* info)
93{
94	fStatusView->ShowInfo(info);
95}
96