From b654ee9d440654b98632c8bec3091dd02ad8c53c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 13 Feb 2022 10:22:38 -0800 Subject: [PATCH] Debugger: Allow custom draw and generic lists. --- Windows/Debugger/Debugger_Disasm.cpp | 16 +++++++------- Windows/GEDebugger/TabDisplayLists.cpp | 8 +++---- Windows/GEDebugger/TabState.cpp | 4 ++-- Windows/GEDebugger/TabVertices.cpp | 8 +++---- Windows/W32Util/Misc.cpp | 29 ++++++++++++++++++++------ Windows/W32Util/Misc.h | 6 +++++- 6 files changed, 46 insertions(+), 25 deletions(-) diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index a42fe32c32..84ea2f9911 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -361,17 +361,17 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) leftTabs->HandleNotify(lParam); break; case IDC_BREAKPOINTLIST: - breakpointList->HandleNotify(lParam); - break; + SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, breakpointList->HandleNotify(lParam)); + return TRUE; case IDC_THREADLIST: - threadList->HandleNotify(lParam); - break; + SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, threadList->HandleNotify(lParam)); + return TRUE; case IDC_STACKFRAMES: - stackTraceView->HandleNotify(lParam); - break; + SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, stackTraceView->HandleNotify(lParam)); + return TRUE; case IDC_MODULELIST: - moduleList->HandleNotify(lParam); - break; + SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, moduleList->HandleNotify(lParam)); + return TRUE; case IDC_DEBUG_BOTTOMTABS: bottomTabs->HandleNotify(lParam); break; diff --git a/Windows/GEDebugger/TabDisplayLists.cpp b/Windows/GEDebugger/TabDisplayLists.cpp index fd4e615ad2..3a622a0442 100644 --- a/Windows/GEDebugger/TabDisplayLists.cpp +++ b/Windows/GEDebugger/TabDisplayLists.cpp @@ -258,11 +258,11 @@ BOOL TabDisplayLists::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (wParam) { case IDC_GEDBG_LISTS_STACK: - stack->HandleNotify(lParam); - break; + SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, stack->HandleNotify(lParam)); + return TRUE; case IDC_GEDBG_LISTS_ALLLISTS: - allLists->HandleNotify(lParam); - break; + SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, allLists->HandleNotify(lParam)); + return TRUE; } break; diff --git a/Windows/GEDebugger/TabState.cpp b/Windows/GEDebugger/TabState.cpp index 1a67b43b64..0e30def5cb 100644 --- a/Windows/GEDebugger/TabState.cpp +++ b/Windows/GEDebugger/TabState.cpp @@ -1054,8 +1054,8 @@ BOOL TabStateValues::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (wParam) { case IDC_GEDBG_VALUES: - values->HandleNotify(lParam); - break; + SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, values->HandleNotify(lParam)); + return TRUE; } break; } diff --git a/Windows/GEDebugger/TabVertices.cpp b/Windows/GEDebugger/TabVertices.cpp index dbd96c2464..24215e2307 100644 --- a/Windows/GEDebugger/TabVertices.cpp +++ b/Windows/GEDebugger/TabVertices.cpp @@ -355,8 +355,8 @@ BOOL TabVertices::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (wParam) { case IDC_GEDBG_VERTICES: - values->HandleNotify(lParam); - break; + SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, values->HandleNotify(lParam)); + return TRUE; } break; } @@ -652,8 +652,8 @@ BOOL TabMatrices::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (wParam) { case IDC_GEDBG_MATRICES: - values->HandleNotify(lParam); - break; + SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, values->HandleNotify(lParam)); + return TRUE; } break; } diff --git a/Windows/W32Util/Misc.cpp b/Windows/W32Util/Misc.cpp index c2b1002795..02a234eb50 100644 --- a/Windows/W32Util/Misc.cpp +++ b/Windows/W32Util/Misc.cpp @@ -215,8 +215,7 @@ void GenericListControl::SetIconList(int w, int h, const std::vector &ico ListView_SetImageList(handle, (HIMAGELIST)images_, LVSIL_STATE); } -void GenericListControl::HandleNotify(LPARAM lParam) -{ +int GenericListControl::HandleNotify(LPARAM lParam) { LPNMHDR mhdr = (LPNMHDR) lParam; if (mhdr->code == NM_DBLCLK) @@ -224,7 +223,7 @@ void GenericListControl::HandleNotify(LPARAM lParam) LPNMITEMACTIVATE item = (LPNMITEMACTIVATE) lParam; if ((item->iItem != -1 && item->iItem < GetRowCount()) || sendInvalidRows) OnDoubleClick(item->iItem,item->iSubItem); - return; + return 0; } if (mhdr->code == NM_RCLICK) @@ -232,7 +231,23 @@ void GenericListControl::HandleNotify(LPARAM lParam) const LPNMITEMACTIVATE item = (LPNMITEMACTIVATE)lParam; if ((item->iItem != -1 && item->iItem < GetRowCount()) || sendInvalidRows) OnRightClick(item->iItem,item->iSubItem,item->ptAction); - return; + return 0; + } + + if (mhdr->code == NM_CUSTOMDRAW && ListenRowPrePaint()) { + LPNMLVCUSTOMDRAW msg = (LPNMLVCUSTOMDRAW)lParam; + switch (msg->nmcd.dwDrawStage) { + case CDDS_PREPAINT: + return CDRF_NOTIFYITEMDRAW; + + case CDDS_ITEMPREPAINT: + if (OnRowPrePaint((int)msg->nmcd.dwItemSpec, msg)) { + return CDRF_NEWFONT; + } + return CDRF_DODEFAULT; + } + + return CDRF_DODEFAULT; } if (mhdr->code == LVN_GETDISPINFO) @@ -247,7 +262,7 @@ void GenericListControl::HandleNotify(LPARAM lParam) dispInfo->item.pszText = stringBuffer; dispInfo->item.mask |= LVIF_TEXT; - return; + return 0; } // handle checkboxes @@ -263,8 +278,10 @@ void GenericListControl::HandleNotify(LPARAM lParam) OnToggle(item->iItem,newImage == 2); } - return; + return 0; } + + return 0; } void GenericListControl::Update() { diff --git a/Windows/W32Util/Misc.h b/Windows/W32Util/Misc.h index c0ce2c33aa..e3c8630fc0 100644 --- a/Windows/W32Util/Misc.h +++ b/Windows/W32Util/Misc.h @@ -33,6 +33,7 @@ struct GenericListViewDef #define GLVC_CENTERED 1 +typedef struct tagNMLVCUSTOMDRAW *LPNMLVCUSTOMDRAW; // the most significant bit states whether the key is currently down. // simply checking if it's != 0 is not enough, as bit0 is set if @@ -44,7 +45,7 @@ class GenericListControl public: GenericListControl(HWND hwnd, const GenericListViewDef& def); virtual ~GenericListControl(); - void HandleNotify(LPARAM lParam); + int HandleNotify(LPARAM lParam); void Update(); int GetSelectedIndex(); HWND GetHandle() { return handle; }; @@ -62,6 +63,9 @@ protected: virtual void CopyRows(int start, int size); virtual void OnToggle(int item, bool newValue) { }; + virtual bool ListenRowPrePaint() { return false; } + virtual bool OnRowPrePaint(int row, LPNMLVCUSTOMDRAW msg) { return false; } + private: static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); void ProcessUpdate();