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