summaryrefslogtreecommitdiff
path: root/Source/Core/DebuggerWX/src/BreakpointWindow.cpp
blob: fbcf1ad4bd9450c8519ef7709ba69cb4ca212f48 (plain)
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//__________________________________________________________________________________________________
// F|RES and ector 2003-2008
//

#include "Debugger.h"
#include "BreakPointWindow.h"
#include "BreakpointView.h"

#include "wx/mstream.h"

extern "C" {
#include "../resources/toolbar_add_breakpoint.c"
#include "../resources/toolbar_add_memorycheck.c"
#include "../resources/toolbar_delete.c"
}

static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT;

BEGIN_EVENT_TABLE(CBreakPointWindow, wxFrame)
	EVT_CLOSE(CBreakPointWindow::OnClose)
	EVT_MENU(IDM_DELETE, CBreakPointWindow::OnDelete)
	EVT_MENU(IDM_ADD_BREAKPOINT, CBreakPointWindow::OnAddBreakPoint)
	EVT_MENU(IDM_ADD_MEMORYCHECK, CBreakPointWindow::OnAddMemoryCheck)
END_EVENT_TABLE()


#define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name, sizeof(name))
inline wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length)
{
	wxMemoryInputStream is(data, length);
	return(wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1));
}


CBreakPointWindow::CBreakPointWindow(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
	: wxFrame(parent, id, title, position, size, style)
	, m_BreakPointListView(NULL)
{
	InitBitmaps();

	CreateGUIControls();

	// Create the toolbar
	RecreateToolbar();

}


CBreakPointWindow::~CBreakPointWindow()
{}


void 
CBreakPointWindow::CreateGUIControls()
{
	SetTitle(wxT("Breakpoints"));
	SetIcon(wxNullIcon);
	SetSize(8, 8, 400, 370);
	Center();

	m_BreakPointListView = new CBreakPointView(this, ID_BPS, wxDefaultPosition, GetSize(),
			wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL | wxLC_SORT_ASCENDING);

	NotifyUpdate();
}


void
CBreakPointWindow::PopulateToolbar(wxToolBar* toolBar)
{
	int w = m_Bitmaps[Toolbar_Delete].GetWidth(),
		h = m_Bitmaps[Toolbar_Delete].GetHeight();

	toolBar->SetToolBitmapSize(wxSize(w, h));
	toolBar->AddTool(IDM_DELETE, _T("Delete"), m_Bitmaps[Toolbar_Delete], _T("Refresh"));
	toolBar->AddSeparator();
	toolBar->AddTool(IDM_ADD_BREAKPOINT,    _T("BP"),    m_Bitmaps[Toolbar_Add_BreakPoint], _T("Open file..."));
	toolBar->AddTool(IDM_ADD_MEMORYCHECK, _T("MemCheck"), m_Bitmaps[Toolbar_Add_Memcheck], _T("Refresh"));

	// after adding the buttons to the toolbar, must call Realize() to reflect
	// the changes
	toolBar->Realize();
}


void
CBreakPointWindow::RecreateToolbar()
{
	// delete and recreate the toolbar
	wxToolBarBase* toolBar = GetToolBar();
	long style = toolBar ? toolBar->GetWindowStyle() : TOOLBAR_STYLE;

	delete toolBar;
	SetToolBar(NULL);

	style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_BOTTOM | wxTB_RIGHT | wxTB_HORZ_LAYOUT | wxTB_TOP);
	wxToolBar* theToolBar = CreateToolBar(style, ID_TOOLBAR);

	PopulateToolbar(theToolBar);
	SetToolBar(theToolBar);
}


void
CBreakPointWindow::InitBitmaps()
{
	// load orignal size 48x48
	m_Bitmaps[Toolbar_Delete] = wxGetBitmapFromMemory(toolbar_delete_png);
	m_Bitmaps[Toolbar_Add_BreakPoint] = wxGetBitmapFromMemory(toolbar_add_breakpoint_png);
	m_Bitmaps[Toolbar_Add_Memcheck] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);

	// scale to 24x24 for toolbar
	for (size_t n = Toolbar_Delete; n < WXSIZEOF(m_Bitmaps); n++)
	{
		m_Bitmaps[n] = wxBitmap(m_Bitmaps[n].ConvertToImage().Scale(16, 16));
	}
}


void 
CBreakPointWindow::OnClose(wxCloseEvent& /*event*/)
{
	Hide();
}


void CBreakPointWindow::NotifyUpdate()
{
	if (m_BreakPointListView != NULL)
	{
		m_BreakPointListView->Update();
	}
}


void 
CBreakPointWindow::OnDelete(wxCommandEvent& event)
{
	if (m_BreakPointListView)
	{
		m_BreakPointListView->DeleteCurrentSelection();
	}
}


void 
CBreakPointWindow::OnAddBreakPoint(wxCommandEvent& event)
{

}


void 
CBreakPointWindow::OnAddMemoryCheck(wxCommandEvent& event)
{

}