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
MainWindow(BRect pieRect)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
~MainWindow()45f75a7bf5SStephan Aßmus MainWindow::~MainWindow()
46f75a7bf5SStephan Aßmus {
47f75a7bf5SStephan Aßmus }
48f75a7bf5SStephan Aßmus
49f75a7bf5SStephan Aßmus
50f75a7bf5SStephan Aßmus void
MessageReceived(BMessage * message)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 default:
62f75a7bf5SStephan Aßmus BWindow::MessageReceived(message);
63f75a7bf5SStephan Aßmus break;
64f75a7bf5SStephan Aßmus }
65f75a7bf5SStephan Aßmus }
66f75a7bf5SStephan Aßmus
67f75a7bf5SStephan Aßmus
68f75a7bf5SStephan Aßmus bool
QuitRequested()69f75a7bf5SStephan Aßmus MainWindow::QuitRequested()
70f75a7bf5SStephan Aßmus {
71f75a7bf5SStephan Aßmus be_app->PostMessage(B_QUIT_REQUESTED);
72f75a7bf5SStephan Aßmus return true;
73f75a7bf5SStephan Aßmus }
74f75a7bf5SStephan Aßmus
75f75a7bf5SStephan Aßmus
76f75a7bf5SStephan Aßmus // #pragma mark -
77f75a7bf5SStephan Aßmus
78f75a7bf5SStephan Aßmus
79f75a7bf5SStephan Aßmus void
EnableRescan()80*3e52a3d5SPhilippe Saint-Pierre MainWindow::EnableRescan()
81f75a7bf5SStephan Aßmus {
82*3e52a3d5SPhilippe Saint-Pierre fControlsView->EnableRescan();
83*3e52a3d5SPhilippe Saint-Pierre }
84*3e52a3d5SPhilippe Saint-Pierre
85*3e52a3d5SPhilippe Saint-Pierre
86*3e52a3d5SPhilippe Saint-Pierre void
EnableCancel()87*3e52a3d5SPhilippe Saint-Pierre MainWindow::EnableCancel()
88*3e52a3d5SPhilippe Saint-Pierre {
89*3e52a3d5SPhilippe Saint-Pierre fControlsView->EnableCancel();
90f75a7bf5SStephan Aßmus }
91f75a7bf5SStephan Aßmus
92f75a7bf5SStephan Aßmus
93f75a7bf5SStephan Aßmus void
ShowInfo(const FileInfo * info)94dde4ac43SPhilippe Saint-Pierre MainWindow::ShowInfo(const FileInfo* info)
95f75a7bf5SStephan Aßmus {
96dde4ac43SPhilippe Saint-Pierre fControlsView->ShowInfo(info);
97f75a7bf5SStephan Aßmus }
98f75a7bf5SStephan Aßmus
99f75a7bf5SStephan Aßmus
100f75a7bf5SStephan Aßmus BVolume*
FindDeviceFor(dev_t device,bool invoke)101f75a7bf5SStephan Aßmus MainWindow::FindDeviceFor(dev_t device, bool invoke)
102f75a7bf5SStephan Aßmus {
103f75a7bf5SStephan Aßmus return fControlsView->FindDeviceFor(device, invoke);
104f75a7bf5SStephan Aßmus }
105