vfs: check userland buffers before reading them.
[haiku.git] / src / apps / diskusage / VolumeView.cpp
blob06c139871536791ae509993e8a46b76c6b7b32ba
1 /*
2 * Copyright (c) 2010 Philippe Saint-Pierre, stpere@gmail.com
3 * All rights reserved. Distributed under the terms of the MIT license.
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 */
11 #include <Catalog.h>
12 #include <Box.h>
13 #include <Button.h>
14 #include <StringView.h>
15 #include <Volume.h>
16 #include <Path.h>
18 #include <LayoutBuilder.h>
20 #include "DiskUsage.h"
21 #include "MainWindow.h"
22 #include "PieView.h"
23 #include "StatusView.h"
25 #include "VolumeView.h"
27 #undef B_TRANSLATION_CONTEXT
28 #define B_TRANSLATION_CONTEXT "Volume View"
30 const float kMinWinSize = 275.0;
32 VolumeView::VolumeView(const char* name, BVolume* volume)
33 : BView(name, B_WILL_DRAW)
35 SetLayout(new BGroupLayout(B_HORIZONTAL));
36 fPieView = new PieView(volume);
38 fPieView->SetExplicitMinSize(BSize(kMinWinSize, kMinWinSize));
40 fStatusView = new StatusView();
42 AddChild(BLayoutBuilder::Group<>(B_VERTICAL, 2)
43 .Add(fPieView)
44 .Add(fStatusView)
49 VolumeView::~VolumeView()
54 void
55 VolumeView::EnableRescan()
57 fStatusView->EnableRescan();
61 void
62 VolumeView::EnableCancel()
64 fStatusView->EnableCancel();
68 void
69 VolumeView::SetPath(BPath path)
71 fPieView->SetPath(path);
72 EnableRescan();
76 void
77 VolumeView::MessageReceived(BMessage* msg)
79 switch(msg->what) {
80 case kBtnCancel:
81 case kBtnRescan:
82 fPieView->MessageReceived(msg);
83 break;
85 default:
86 BView::MessageReceived(msg);
91 void
92 VolumeView::ShowInfo(const FileInfo* info)
94 fStatusView->ShowInfo(info);