From a47d5c329823c5a2fb1c24525201b032c0cc1efc Mon Sep 17 00:00:00 2001 From: zilmar Date: Fri, 20 Oct 2017 19:57:21 +1100 Subject: [PATCH] [Debugger] Change how font work --- .../N64System/Debugger/Debugger-Commands.cpp | 24 ++++++-- .../N64System/Debugger/Debugger-Commands.h | 5 +- .../Debugger/Debugger-RegisterTabs.cpp | 56 ++++++++----------- .../Debugger/Debugger-RegisterTabs.h | 8 +-- 4 files changed, 46 insertions(+), 47 deletions(-) diff --git a/Source/Project64/N64System/Debugger/Debugger-Commands.cpp b/Source/Project64/N64System/Debugger/Debugger-Commands.cpp index 31631422c..afd781213 100644 --- a/Source/Project64/N64System/Debugger/Debugger-Commands.cpp +++ b/Source/Project64/N64System/Debugger/Debugger-Commands.cpp @@ -31,6 +31,8 @@ CToolTipDialog() m_StartAddress = 0x80000000; m_Breakpoints = m_Debugger->Breakpoints(); m_bEditing = false; + m_CommandListRows = 39; + m_RowHeight = 13; } CDebugCommandsView::~CDebugCommandsView(void) @@ -57,8 +59,6 @@ LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA DlgResize_Init(false, true); DlgToolTip_Init(); - m_CommandListRows = 39; - CheckCPUType(); GetWindowRect(&m_DefaultWindowRect); @@ -871,7 +871,19 @@ LRESULT CDebugCommandsView::OnMeasureItem(UINT uMsg, WPARAM wParam, LPARAM lPara if (wParam == IDC_CMD_LIST) { MEASUREITEMSTRUCT* lpMeasureItem = (MEASUREITEMSTRUCT*)lParam; - lpMeasureItem->itemHeight = CCommandList::ROW_HEIGHT; + HWND hCmdList = GetDlgItem(IDC_CMD_LIST); + HWND hHeader = ListView_GetHeader(hCmdList); + RECT header_rc = { 0 }, control_rc = { 0 }; + if (::GetClientRect(hHeader, &header_rc) && GetClientRect(&control_rc)) + { + int height = (control_rc.bottom - control_rc.top) - (header_rc.bottom - header_rc.top); + m_RowHeight = height / m_CommandListRows; + } + else + { + m_RowHeight = 13; + } + lpMeasureItem->itemHeight = m_RowHeight; } return FALSE; } @@ -928,8 +940,8 @@ void CDebugCommandsView::DrawBranchArrows(HDC listDC) int begX = baseX - arrow.startMargin * 3; int endX = baseX - arrow.endMargin * 3; - int begY = baseY + arrow.startPos * CCommandList::ROW_HEIGHT; - int endY = baseY + arrow.endPos * CCommandList::ROW_HEIGHT; + int begY = baseY + arrow.startPos * m_RowHeight; + int endY = baseY + arrow.endPos * m_RowHeight; bool bEndVisible = true; @@ -1405,7 +1417,7 @@ LRESULT CDebugCommandsView::OnSizing(UINT uMsg, WPARAM wParam, LPARAM lParam, BO int rowsHeight = listRect.Height() - headRect.Height(); - int nRows = (rowsHeight / CCommandList::ROW_HEIGHT); + int nRows = (rowsHeight / m_RowHeight); if (m_CommandListRows != nRows) { diff --git a/Source/Project64/N64System/Debugger/Debugger-Commands.h b/Source/Project64/N64System/Debugger/Debugger-Commands.h index fc8b4112f..d90473285 100644 --- a/Source/Project64/N64System/Debugger/Debugger-Commands.h +++ b/Source/Project64/N64System/Debugger/Debugger-Commands.h @@ -29,10 +29,6 @@ public: COL_SYMBOL }; - enum { - ROW_HEIGHT = 13, - }; - void Attach(HWND hWndNew) { CListViewCtrl::Attach(hWndNew); @@ -143,6 +139,7 @@ private: OPCODE& m_SelectedOpCode = m_SelectedOpInfo.m_OpCode; uint32_t m_FollowAddress; + uint32_t m_RowHeight; typedef struct { uint32_t address; diff --git a/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.cpp b/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.cpp index 61bf302e5..59b673b92 100644 --- a/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.cpp +++ b/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.cpp @@ -19,14 +19,6 @@ bool CRegisterTabs::m_bColorsEnabled = false; void CRegisterTabs::Attach(HWND hWndNew) { CTabCtrl::Attach(hWndNew); - LOGFONT lf; - GetObject((HFONT)GetCurrentObject(GetDC(), OBJ_FONT), sizeof(LOGFONT), &lf); - - HFONT monoFont = CreateFont(lf.lfHeight * -1, 0, 0, 0, - FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, - OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, - CLEARTYPE_QUALITY, FF_DONTCARE, "Consolas" - ); m_GPRTab = AddTab("GPR", IDD_Debugger_RegGPR, TabProcGPR); m_FPRTab = AddTab("FPR", IDD_Debugger_RegFPR, TabProcFPR); @@ -42,36 +34,36 @@ void CRegisterTabs::Attach(HWND hWndNew) m_SITab = AddTab("SI", IDD_Debugger_RegSI, TabProcDefault); m_DDTab = AddTab("DD", IDD_Debugger_RegDD, TabProcDefault); - InitRegisterEdits64(m_GPRTab, m_GPREdits, GPREditIds, monoFont); - InitRegisterEdit64(m_GPRTab, m_HIEdit, IDC_HI_EDIT, monoFont); - InitRegisterEdit64(m_GPRTab, m_LOEdit, IDC_LO_EDIT, monoFont); + InitRegisterEdits64(m_GPRTab, m_GPREdits, GPREditIds); + InitRegisterEdit64(m_GPRTab, m_HIEdit, IDC_HI_EDIT); + InitRegisterEdit64(m_GPRTab, m_LOEdit, IDC_LO_EDIT); - InitRegisterEdits(m_FPRTab, m_FPREdits, FPREditIds, monoFont); - InitRegisterEdit(m_FPRTab, m_FCSREdit, IDC_FCSR_EDIT, monoFont); + InitRegisterEdits(m_FPRTab, m_FPREdits, FPREditIds); + InitRegisterEdit(m_FPRTab, m_FCSREdit, IDC_FCSR_EDIT); - InitRegisterEdits(m_COP0Tab, m_COP0Edits, COP0EditIds, monoFont); + InitRegisterEdits(m_COP0Tab, m_COP0Edits, COP0EditIds); m_CauseTip.Attach(m_COP0Tab.GetDlgItem(IDC_CAUSE_TIP)); - InitRegisterEdits(m_RDRAMTab, m_RDRAMEdits, RDRAMEditIds, monoFont); + InitRegisterEdits(m_RDRAMTab, m_RDRAMEdits, RDRAMEditIds); - InitRegisterEdits(m_SPTab, m_SPEdits, SPEditIds, monoFont); - InitRegisterEdit(m_SPTab, m_SPPCEdit, IDC_SP_PC_EDIT, monoFont); + InitRegisterEdits(m_SPTab, m_SPEdits, SPEditIds); + InitRegisterEdit(m_SPTab, m_SPPCEdit, IDC_SP_PC_EDIT); - InitRegisterEdits(m_DPCTab, m_DPCEdits, DPCEditIds, monoFont); + InitRegisterEdits(m_DPCTab, m_DPCEdits, DPCEditIds); - InitRegisterEdits(m_MITab, m_MIEdits, MIEditIds, monoFont); + InitRegisterEdits(m_MITab, m_MIEdits, MIEditIds); - InitRegisterEdits(m_VITab, m_VIEdits, VIEditIds, monoFont); + InitRegisterEdits(m_VITab, m_VIEdits, VIEditIds); - InitRegisterEdits(m_AITab, m_AIEdits, AIEditIds, monoFont); + InitRegisterEdits(m_AITab, m_AIEdits, AIEditIds); - InitRegisterEdits(m_PITab, m_PIEdits, PIEditIds, monoFont); + InitRegisterEdits(m_PITab, m_PIEdits, PIEditIds); - InitRegisterEdits(m_RITab, m_RIEdits, RIEditIds, monoFont); + InitRegisterEdits(m_RITab, m_RIEdits, RIEditIds); - InitRegisterEdits(m_SITab, m_SIEdits, SIEditIds, monoFont); + InitRegisterEdits(m_SITab, m_SIEdits, SIEditIds); - InitRegisterEdits(m_DDTab, m_DDEdits, DDEditIds, monoFont); + InitRegisterEdits(m_DDTab, m_DDEdits, DDEditIds); SetColorsEnabled(false); RefreshEdits(); @@ -668,32 +660,30 @@ void CRegisterTabs::SetColorsEnabled(bool bColorsEnabled) m_bColorsEnabled = bColorsEnabled; } -void CRegisterTabs::InitRegisterEdit(CWindow& tab, CEditNumber& edit, WORD ctrlId, HFONT font) +void CRegisterTabs::InitRegisterEdit(CWindow& tab, CEditNumber& edit, WORD ctrlId) { edit.Attach(tab.GetDlgItem(ctrlId)); edit.SetDisplayType(CEditNumber::DisplayHex); - edit.SetFont(font); } -void CRegisterTabs::InitRegisterEdits(CWindow& tab, CEditNumber* edits, const DWORD* ctrlIds, HFONT font) +void CRegisterTabs::InitRegisterEdits(CWindow& tab, CEditNumber* edits, const DWORD* ctrlIds) { for (int i = 0; i < ctrlIds[i] != 0; i++) { - InitRegisterEdit(tab, edits[i], ctrlIds[i], font); + InitRegisterEdit(tab, edits[i], ctrlIds[i]); } } -void CRegisterTabs::InitRegisterEdit64(CWindow& tab, CEditReg64& edit, WORD ctrlId, HFONT font) +void CRegisterTabs::InitRegisterEdit64(CWindow& tab, CEditReg64& edit, WORD ctrlId) { edit.Attach(tab.GetDlgItem(ctrlId)); - edit.SetFont(font); } -void CRegisterTabs::InitRegisterEdits64(CWindow& tab, CEditReg64* edits, const DWORD* ctrlIds, HFONT font) +void CRegisterTabs::InitRegisterEdits64(CWindow& tab, CEditReg64* edits, const DWORD* ctrlIds) { for (int i = 0; i < ctrlIds[i] != 0; i++) { - InitRegisterEdit64(tab, edits[i], ctrlIds[i], font); + InitRegisterEdit64(tab, edits[i], ctrlIds[i]); } } diff --git a/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.h b/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.h index cf8e48c7a..f9cd5a68c 100644 --- a/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.h +++ b/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.h @@ -261,10 +261,10 @@ private: static INT_PTR CALLBACK TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); static INT_PTR CALLBACK TabProcFPR(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); - static void InitRegisterEdit(CWindow& tab, CEditNumber& edit, WORD ctrlId, HFONT font); - static void InitRegisterEdits(CWindow& tab, CEditNumber* edits, const DWORD* ctrlIds, HFONT font); - static void InitRegisterEdit64(CWindow& tab, CEditReg64& edit, WORD ctrlId, HFONT font); - static void InitRegisterEdits64(CWindow& tab, CEditReg64* edits, const DWORD* ctrlIds, HFONT font); + static void InitRegisterEdit(CWindow& tab, CEditNumber& edit, WORD ctrlId); + static void InitRegisterEdits(CWindow& tab, CEditNumber* edits, const DWORD* ctrlIds); + static void InitRegisterEdit64(CWindow& tab, CEditReg64& edit, WORD ctrlId); + static void InitRegisterEdits64(CWindow& tab, CEditReg64* edits, const DWORD* ctrlIds); static void ZeroRegisterEdit(CEditNumber& edit); static void ZeroRegisterEdits(CEditNumber* edits, const DWORD* ctrlIds); static void ZeroRegisterEdit64(CEditReg64& edit);