1/*
2 * Copyright 2004-2018, Axel D��rfler, axeld@pinc-software.de.
3 * All rights reserved. Distributed under the terms of the MIT license.
4 */
5
6
7/*!	Abstract base class for probe windows. It only provides the following
8	functionality:
9		- Access to the basic entry_ref
10		- Common BWindow flags
11		- Stores size in settings on QuitRequested()
12		- Redirects drops to BApplication
13		- Notifies BApplication about closed window
14		- Forwards mouse wheel to the DataView
15		- Contains() checks whether or not the ref/attribute is what this
16		  window contains
17*/
18
19
20#include "ProbeWindow.h"
21
22#include <Application.h>
23#include <View.h>
24
25#include "DiskProbe.h"
26
27
28ProbeWindow::ProbeWindow(BRect rect, entry_ref* ref)
29	:
30	BWindow(rect, ref->name, B_DOCUMENT_WINDOW,
31		B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
32	fRef(*ref)
33{
34}
35
36
37ProbeWindow::~ProbeWindow()
38{
39}
40
41
42void
43ProbeWindow::MessageReceived(BMessage* message)
44{
45	switch (message->what) {
46		case B_MOUSE_WHEEL_CHANGED:
47			if (BView* view = FindView("dataView"))
48				view->MessageReceived(message);
49			break;
50
51		case B_SIMPLE_DATA:
52		{
53			BMessage refsReceived(*message);
54			refsReceived.what = B_REFS_RECEIVED;
55			be_app_messenger.SendMessage(&refsReceived);
56			break;
57		}
58
59		default:
60			BWindow::MessageReceived(message);
61	}
62}
63
64
65bool
66ProbeWindow::QuitRequested()
67{
68	BMessage update(kMsgSettingsChanged);
69	update.AddRect("window_frame", Frame());
70	be_app_messenger.SendMessage(&update);
71
72	be_app_messenger.SendMessage(kMsgWindowClosed);
73	return true;
74}
75
76