summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/debugger/win/debugwininfo.h
blob: 51acc70018f0f090c920966763b9fcb8e527b8d5 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// license:BSD-3-Clause
// copyright-holders:Aaron Giles, Vas Crabb
//============================================================
//
//  debugwininfo.h - Win32 debug window handling
//
//============================================================

#ifndef __DEBUG_WIN_DEBUG_WIN_INFO_H__
#define __DEBUG_WIN_DEBUG_WIN_INFO_H__

#include "debugwin.h"

#include "debugbaseinfo.h"

#include "emu.h"


class debugwin_info : protected debugbase_info
{
public:
	template<class U> friend class simple_list;

	debugwin_info(debugger_windows_interface &debugger, bool is_main_console, LPCSTR title, WNDPROC handler);
	virtual ~debugwin_info();

	bool is_valid() const { return m_wnd != NULL; }
	debugwin_info *next() const { return m_next; }

	void set_ignore_char_lparam(LPARAM value) { m_ignore_char_lparam = value >> 16; }
	bool check_ignore_char_lparam(LPARAM value)
	{
		if (m_ignore_char_lparam == (value >> 16))
		{
			m_ignore_char_lparam = 0;
			return false;
		}
		else
		{
			return true;
		}
	}

	void show() { smart_show_window(m_wnd, true); }
	void hide() { smart_show_window(m_wnd, false); }
	void set_foreground() { SetForegroundWindow(m_wnd); }
	void destroy();

	virtual bool set_default_focus();
	void prev_view(debugview_info *curview);
	void next_view(debugview_info *curview);
	virtual bool restore_field(HWND wnd) { return false; }

	virtual bool handle_key(WPARAM wparam, LPARAM lparam);

protected:
	static DWORD const  DEBUG_WINDOW_STYLE = (WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN) & (~WS_MINIMIZEBOX & ~WS_MAXIMIZEBOX);
	static DWORD const  DEBUG_WINDOW_STYLE_EX = 0;

	static int const    MAX_VIEWS = 4;
	static int const    EDGE_WIDTH = 3;

	enum
	{
		ID_NEW_MEMORY_WND = 1,
		ID_NEW_DISASM_WND,
		ID_NEW_LOG_WND,
		ID_NEW_POINTS_WND,
		ID_RUN,
		ID_RUN_AND_HIDE,
		ID_RUN_VBLANK,
		ID_RUN_IRQ,
		ID_NEXT_CPU,
		ID_STEP,
		ID_STEP_OVER,
		ID_STEP_OUT,
		ID_HARD_RESET,
		ID_SOFT_RESET,
		ID_EXIT,

		ID_1_BYTE_CHUNKS,
		ID_2_BYTE_CHUNKS,
		ID_4_BYTE_CHUNKS,
		ID_8_BYTE_CHUNKS,
		ID_LOGICAL_ADDRESSES,
		ID_PHYSICAL_ADDRESSES,
		ID_REVERSE_VIEW,
		ID_INCREASE_MEM_WIDTH,
		ID_DECREASE_MEM_WIDTH,

		ID_TOGGLE_BREAKPOINT,
		ID_DISABLE_BREAKPOINT,
		ID_RUN_TO_CURSOR,
		ID_SHOW_RAW,
		ID_SHOW_ENCRYPTED,
		ID_SHOW_COMMENTS,

		ID_SHOW_BREAKPOINTS,
		ID_SHOW_WATCHPOINTS,

		ID_DEVICE_OPTIONS   // always keep this at the end
	};

	bool is_main_console() const { return m_is_main_console; }
	HWND window() const { return m_wnd; }
	UINT32 minwidth() const { return m_minwidth; }
	UINT32 maxwidth() const { return m_maxwidth; }
	void set_minwidth(UINT32 value) { m_minwidth = value; }
	void set_maxwidth(UINT32 value) { m_maxwidth = value; }

	virtual void recompute_children();
	virtual void update_menu() { }
	virtual bool handle_command(WPARAM wparam, LPARAM lparam);
	virtual void draw_contents(HDC dc);
	void draw_border(HDC dc, RECT &bounds);
	void draw_border(HDC dc, HWND child);

	auto_pointer<debugview_info>    m_views[MAX_VIEWS];

private:
	LRESULT window_proc(UINT message, WPARAM wparam, LPARAM lparam);

	HMENU create_standard_menubar();

	static LRESULT CALLBACK static_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam);

	static void register_window_class();

	bool const      m_is_main_console;

	debugwin_info   *m_next;
	HWND            m_wnd;
	WNDPROC const   m_handler;

	UINT32          m_minwidth, m_maxwidth;
	UINT32          m_minheight, m_maxheight;

	UINT16          m_ignore_char_lparam;

	static bool     s_window_class_registered;
};

#endif