[Debugger] Change how font work

This commit is contained in:
zilmar 2017-10-20 19:57:21 +11:00
parent b5c8a0f4c5
commit a47d5c3298
4 changed files with 46 additions and 47 deletions

View File

@ -31,6 +31,8 @@ CToolTipDialog<CDebugCommandsView>()
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)
{

View File

@ -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;

View File

@ -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]);
}
}

View File

@ -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);