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 <Box.h> 12 #include <Button.h> 13 #include <StringView.h> 14 #include <Volume.h> 15 #include <Path.h> 16 17 #include <LayoutBuilder.h> 18 19 #include "Common.h" 20 #include "MainWindow.h" 21 #include "PieView.h" 22 #include "StatusView.h" 23 24 #include "VolumeView.h" 25 26 const float kMinWinSize = 275.0; 27 28 VolumeView::VolumeView(const char* name, BVolume* volume) 29 : BView(name, B_WILL_DRAW) 30 { 31 SetLayout(new BGroupLayout(B_HORIZONTAL)); 32 fPieView = new PieView(volume); 33 34 fPieView->SetExplicitMinSize(BSize(kMinWinSize, kMinWinSize)); 35 36 fStatusView = new StatusView(); 37 38 AddChild(BLayoutBuilder::Group<>(B_VERTICAL) 39 .Add(fPieView) 40 .Add(fStatusView) 41 ); 42 } 43 44 45 VolumeView::~VolumeView() 46 { 47 } 48 49 50 void 51 VolumeView::SetRescanEnabled(bool enabled) 52 { 53 fStatusView->SetRescanEnabled(enabled); 54 } 55 56 57 void 58 VolumeView::SetPath(BPath path) 59 { 60 fPieView->SetPath(path); 61 fStatusView->SetBtnLabel(kStrRescan); 62 } 63 64 65 void 66 VolumeView::MessageReceived(BMessage* msg) 67 { 68 msg->PrintToStream(); 69 switch(msg->what) { 70 case kBtnRescan: 71 fPieView->MessageReceived(msg); 72 fStatusView->SetBtnLabel(kStrRescan); 73 break; 74 75 default: 76 BView::MessageReceived(msg); 77 } 78 } 79 80 81 void 82 VolumeView::ShowInfo(const FileInfo* info) 83 { 84 fStatusView->ShowInfo(info); 85 } 86