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 case kBtnHelp: 62 if (helpFileWasFound) 63 be_roster->Launch(&helpFileRef); 64 break; 65 66 default: 67 BWindow::MessageReceived(message); 68 break; 69 } 70 } 71 72 73 bool 74 MainWindow::QuitRequested() 75 { 76 be_app->PostMessage(B_QUIT_REQUESTED); 77 return true; 78 } 79 80 81 // #pragma mark - 82 83 84 void 85 MainWindow::EnableRescan() 86 { 87 fControlsView->EnableRescan(); 88 } 89 90 91 void 92 MainWindow::EnableCancel() 93 { 94 fControlsView->EnableCancel(); 95 } 96 97 98 void 99 MainWindow::ShowInfo(const FileInfo* info) 100 { 101 fControlsView->ShowInfo(info); 102 } 103 104 105 BVolume* 106 MainWindow::FindDeviceFor(dev_t device, bool invoke) 107 { 108 return fControlsView->FindDeviceFor(device, invoke); 109 } 110