@@ -32,7 +32,7 @@ BreakpointWindow::BreakpointWindow(DebuggerWindow2& parent, const wxPoint& main_
3232
3333 wxBoxSizer* main_sizer = new wxBoxSizer (wxVERTICAL);
3434
35- m_breakpoints = new wxListView (this , wxID_ANY);
35+ m_breakpoints = new wxListView (this , wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL );
3636 m_breakpoints->EnableCheckBoxes (true );
3737
3838 wxListItem col0;
@@ -162,18 +162,20 @@ void BreakpointWindow::OnBreakpointToggled(wxListEvent& event)
162162void BreakpointWindow::OnLeftDClick (wxMouseEvent& event)
163163{
164164 const auto position = event.GetPosition ();
165- const sint32 index = (position.y / m_breakpoints->GetCharHeight ()) - 2 ;
166- if (index < 0 || index >= m_breakpoints->GetItemCount ())
165+ int flags = 0 ;
166+ const long index = m_breakpoints->HitTest (position, flags);
167+
168+ if (index == wxNOT_FOUND)
167169 return ;
168-
170+
169171 sint32 x = position.x ;
170172 const auto enabled_width = m_breakpoints->GetColumnWidth (ColumnEnabled);
171173 if (x <= enabled_width)
172174 return ;
173175
174176 x -= enabled_width;
175177 const auto address_width = m_breakpoints->GetColumnWidth (ColumnAddress);
176- if (x <= address_width)
178+ if (x <= address_width)
177179 {
178180 const auto item = m_breakpoints->GetItemText (index, ColumnAddress);
179181 const auto address = std::stoul (item.ToStdString (), nullptr , 16 );
@@ -183,13 +185,13 @@ void BreakpointWindow::OnLeftDClick(wxMouseEvent& event)
183185 }
184186
185187 x -= address_width;
186- const auto type_width = m_breakpoints->GetColumnWidth (ColumnType);
188+ const auto type_width = m_breakpoints->GetColumnWidth (ColumnType);
187189 if (x <= type_width)
188190 return ;
189191
190192 x -= type_width;
191193 const auto comment_width = m_breakpoints->GetColumnWidth (ColumnComment);
192- if (x <= comment_width)
194+ if (x <= comment_width)
193195 {
194196 if (index >= debuggerState.breakpoints .size ())
195197 return ;
@@ -213,9 +215,9 @@ void BreakpointWindow::OnLeftDClick(wxMouseEvent& event)
213215
214216void BreakpointWindow::OnRightDown (wxMouseEvent& event)
215217{
216- const auto position = event. GetPosition () ;
217- const sint32 index = (position. y / m_breakpoints->GetCharHeight ()) - 2 ;
218- if (index < 0 || index >= m_breakpoints->GetItemCount ())
218+ int flags = 0 ;
219+ const long index = m_breakpoints->HitTest (event. GetPosition (), flags) ;
220+ if (index == wxNOT_FOUND || index < 0 || index >= m_breakpoints->GetItemCount ())
219221 {
220222 wxMenu menu;
221223 menu.Append (MENU_ID_CREATE_CODE_BP_EXECUTION, _ (" Create execution breakpoint" ));
@@ -244,19 +246,16 @@ void BreakpointWindow::OnContextMenuClickSelected(wxCommandEvent& evt)
244246 if (evt.GetId () == MENU_ID_DELETE_BP)
245247 {
246248 long sel = m_breakpoints->GetFirstSelected ();
247- if (sel != wxNOT_FOUND)
248- {
249- if (sel >= debuggerState.breakpoints .size ())
250- return ;
249+ if (sel == wxNOT_FOUND || sel < 0 || sel >= m_breakpoints->GetItemCount ())
250+ return ;
251251
252- auto it = debuggerState.breakpoints .begin ();
253- std::advance (it, sel);
252+ auto it = debuggerState.breakpoints .begin ();
253+ std::advance (it, sel);
254254
255- debugger_deleteBreakpoint (*it);
255+ debugger_deleteBreakpoint (*it);
256256
257- wxCommandEvent evt (wxEVT_BREAKPOINT_CHANGE);
258- wxPostEvent (this ->m_parent , evt);
259- }
257+ wxCommandEvent evt (wxEVT_BREAKPOINT_CHANGE);
258+ wxPostEvent (this ->m_parent , evt);
260259 }
261260}
262261
0 commit comments