xref: /haiku/src/apps/diskusage/VolumeView.cpp (revision 204dee708a999d5a71d0cb9497650ee7cef85d0a)
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 
30 const float kMinWinSize = 275.0;
31 
32 VolumeView::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 
49 VolumeView::~VolumeView()
50 {
51 }
52 
53 
54 void
55 VolumeView::EnableRescan()
56 {
57 	fStatusView->EnableRescan();
58 }
59 
60 
61 void
62 VolumeView::EnableCancel()
63 {
64 	fStatusView->EnableCancel();
65 }
66 
67 
68 void
69 VolumeView::SetPath(BPath path)
70 {
71 	fPieView->SetPath(path);
72 	EnableRescan();
73 }
74 
75 
76 void
77 VolumeView::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 
91 void
92 VolumeView::ShowInfo(const FileInfo* info)
93 {
94 	fStatusView->ShowInfo(info);
95 }
96