summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/debugger/win/logwininfo.cpp
blob: 88b6022aa9a8c0318268d4187130a28ff1c1669e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// license:BSD-3-Clause
// copyright-holders:Aaron Giles, Vas Crabb
//============================================================
//
//  logwininfo.c - Win32 debug window handling
//
//============================================================

#include "emu.h"
#include "logwininfo.h"

#include "debugviewinfo.h"
#include "logviewinfo.h"


logwin_info::logwin_info(debugger_windows_interface &debugger) :
	debugwin_info(debugger, false, std::string("Errorlog: ").append(debugger.machine().system().type.fullname()).append(" [").append(debugger.machine().system().name).append("]").c_str(), nullptr)
{
	if (!window())
		return;

	m_views[0].reset(new logview_info(debugger, *this, window()));
	if ((m_views[0] == nullptr) || !m_views[0]->is_valid())
	{
		m_views[0].reset();
		return;
	}

	// create the log menu
	HMENU const logmenu = CreatePopupMenu();
	AppendMenu(logmenu, MF_ENABLED, ID_CLEAR_LOG, TEXT("Clear"));
	AppendMenu(GetMenu(window()), MF_ENABLED | MF_POPUP, (UINT_PTR)logmenu, TEXT("Log"));

	// compute a client rect
	RECT bounds;
	bounds.top = bounds.left = 0;
	bounds.right = m_views[0]->maxwidth() + (2 * EDGE_WIDTH);
	bounds.bottom = 200;
	AdjustWindowRectEx(&bounds, DEBUG_WINDOW_STYLE, FALSE, DEBUG_WINDOW_STYLE_EX);

	// clamp the min/max size
	set_maxwidth(bounds.right - bounds.left);

	// position the window at the bottom-right
	SetWindowPos(window(), HWND_TOP, 100, 100, bounds.right - bounds.left, bounds.bottom - bounds.top, SWP_SHOWWINDOW);

	// recompute the children
	debugwin_info::recompute_children();
}


logwin_info::~logwin_info()
{
}

bool logwin_info::handle_command(WPARAM wparam, LPARAM lparam)
{
	if ((HIWORD(wparam) == 0) && (LOWORD(wparam) == ID_CLEAR_LOG))
	{
		downcast<logview_info *>(m_views[0].get())->clear();
		machine().debug_view().update_all(DVT_LOG);
		return true;
	}
	return debugwin_info::handle_command(wparam, lparam);
}