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 23*546208a5SOliver Tappe #undef B_TRANSLATION_CONTEXT 24*546208a5SOliver 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) 38dde4ac43SPhilippe Saint-Pierre .SetInsets(5, 5, 5, 5) 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) { 54f75a7bf5SStephan Aßmus case kBtnRescan: 55dde4ac43SPhilippe Saint-Pierre fControlsView->MessageReceived(message); 56dde4ac43SPhilippe Saint-Pierre break; 57dde4ac43SPhilippe Saint-Pierre case B_SIMPLE_DATA: 58f75a7bf5SStephan Aßmus case B_REFS_RECEIVED: 59dde4ac43SPhilippe Saint-Pierre fControlsView->MessageReceived(message); 60f75a7bf5SStephan Aßmus break; 61f75a7bf5SStephan Aßmus 62f75a7bf5SStephan Aßmus case kBtnHelp: 63973f8e21SSiarzhuk Zharski if (helpFileWasFound) 64973f8e21SSiarzhuk Zharski be_roster->Launch(&helpFileRef); 65f75a7bf5SStephan Aßmus break; 66f75a7bf5SStephan Aßmus 67f75a7bf5SStephan Aßmus default: 68f75a7bf5SStephan Aßmus BWindow::MessageReceived(message); 69f75a7bf5SStephan Aßmus break; 70f75a7bf5SStephan Aßmus } 71f75a7bf5SStephan Aßmus } 72f75a7bf5SStephan Aßmus 73f75a7bf5SStephan Aßmus 74f75a7bf5SStephan Aßmus bool 75f75a7bf5SStephan Aßmus MainWindow::QuitRequested() 76f75a7bf5SStephan Aßmus { 77f75a7bf5SStephan Aßmus be_app->PostMessage(B_QUIT_REQUESTED); 78f75a7bf5SStephan Aßmus return true; 79f75a7bf5SStephan Aßmus } 80f75a7bf5SStephan Aßmus 81f75a7bf5SStephan Aßmus 82f75a7bf5SStephan Aßmus // #pragma mark - 83f75a7bf5SStephan Aßmus 84f75a7bf5SStephan Aßmus 85f75a7bf5SStephan Aßmus void 86dde4ac43SPhilippe Saint-Pierre MainWindow::SetRescanEnabled(bool enabled) 87f75a7bf5SStephan Aßmus { 88dde4ac43SPhilippe Saint-Pierre fControlsView->SetRescanEnabled(enabled); 89f75a7bf5SStephan Aßmus } 90f75a7bf5SStephan Aßmus 91f75a7bf5SStephan Aßmus 92f75a7bf5SStephan Aßmus void 93dde4ac43SPhilippe Saint-Pierre MainWindow::ShowInfo(const FileInfo* info) 94f75a7bf5SStephan Aßmus { 95dde4ac43SPhilippe Saint-Pierre fControlsView->ShowInfo(info); 96f75a7bf5SStephan Aßmus } 97f75a7bf5SStephan Aßmus 98f75a7bf5SStephan Aßmus 99f75a7bf5SStephan Aßmus BVolume* 100f75a7bf5SStephan Aßmus MainWindow::FindDeviceFor(dev_t device, bool invoke) 101f75a7bf5SStephan Aßmus { 102f75a7bf5SStephan Aßmus return fControlsView->FindDeviceFor(device, invoke); 103f75a7bf5SStephan Aßmus } 104