1 /* 2 * Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>. 3 * Copyright (c) 2009 Philippe Saint-Pierre, stpere@gmail.com 4 * All rights reserved. Distributed under the terms of the MIT license. 5 * 6 * Copyright (c) 1999 Mike Steed. You are free to use and distribute this software 7 * as long as it is accompanied by it's documentation and this copyright notice. 8 * The software comes with no warranty, etc. 9 */ 10 #include "MainWindow.h" 11 12 #include <Application.h> 13 #include <Catalog.h> 14 #include <Node.h> 15 #include <Roster.h> 16 #include <Screen.h> 17 18 #include <LayoutBuilder.h> 19 20 #include "DiskUsage.h" 21 #include "ControlsView.h" 22 23 #undef B_TRANSLATION_CONTEXT 24 #define B_TRANSLATION_CONTEXT "MainWindow" 25 26 MainWindow::MainWindow(BRect pieRect) 27 : 28 BWindow(pieRect, B_TRANSLATE_SYSTEM_NAME("DiskUsage"), B_TITLED_WINDOW, 29 B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE 30 | B_AUTO_UPDATE_SIZE_LIMITS) 31 { 32 fControlsView = new ControlsView(); 33 34 SetLayout(new BGroupLayout(B_VERTICAL)); 35 36 AddChild(BLayoutBuilder::Group<>(B_VERTICAL) 37 .Add(fControlsView) 38 .SetInsets(0, B_USE_WINDOW_SPACING, 0, 0) 39 ); 40 float maxHeight = BScreen(this).Frame().Height() - 12; 41 fControlsView->SetExplicitMaxSize(BSize(maxHeight, maxHeight)); 42 } 43 44 45 MainWindow::~MainWindow() 46 { 47 } 48 49 50 void 51 MainWindow::MessageReceived(BMessage* message) 52 { 53 switch (message->what) { 54 case kBtnCancel: 55 case kBtnRescan: 56 case B_SIMPLE_DATA: 57 case B_REFS_RECEIVED: 58 fControlsView->MessageReceived(message); 59 break; 60 61 default: 62 BWindow::MessageReceived(message); 63 break; 64 } 65 } 66 67 68 bool 69 MainWindow::QuitRequested() 70 { 71 be_app->PostMessage(B_QUIT_REQUESTED); 72 return true; 73 } 74 75 76 // #pragma mark - 77 78 79 void 80 MainWindow::EnableRescan() 81 { 82 fControlsView->EnableRescan(); 83 } 84 85 86 void 87 MainWindow::EnableCancel() 88 { 89 fControlsView->EnableCancel(); 90 } 91 92 93 void 94 MainWindow::ShowInfo(const FileInfo* info) 95 { 96 fControlsView->ShowInfo(info); 97 } 98 99 100 BVolume* 101 MainWindow::FindDeviceFor(dev_t device, bool invoke) 102 { 103 return fControlsView->FindDeviceFor(device, invoke); 104 } 105