[User Interface] Rename CEditNumber to CEditNumber32

This commit is contained in:
zilmar 2017-11-22 07:37:45 +11:00
parent 6fa3be42cd
commit 188d6ae6d1
14 changed files with 95 additions and 79 deletions

View File

@ -19,7 +19,7 @@ LRESULT CAddSymbolDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*l
CenterWindow();
m_AddressEdit.Attach(GetDlgItem(IDC_ADDR_EDIT));
m_AddressEdit.SetDisplayType(CEditNumber::DisplayHex);
m_AddressEdit.SetDisplayType(CEditNumber32::DisplayHex);
m_TypeComboBox.Attach(GetDlgItem(IDC_TYPE_COMBOBOX));
m_NameEdit.Attach(GetDlgItem(IDC_NAME_EDIT));
m_DescriptionEdit.Attach(GetDlgItem(IDC_DESC_EDIT));

View File

@ -30,7 +30,7 @@ private:
uint32_t m_InitAddress;
int m_InitType;
CEditNumber m_AddressEdit;
CEditNumber32 m_AddressEdit;
CComboBox m_TypeComboBox;
CEdit m_NameEdit;
CEdit m_DescriptionEdit;
@ -46,5 +46,5 @@ private:
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
MSG_WM_DESTROY(OnDestroy)
END_MSG_MAP()
END_MSG_MAP()
};

View File

@ -86,11 +86,11 @@ LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA
GetWindowRect(&m_DefaultWindowRect);
// Setup address input
m_AddressEdit.SetDisplayType(CEditNumber::DisplayHex);
m_AddressEdit.SetDisplayType(CEditNumber32::DisplayHex);
m_AddressEdit.SetLimitText(8);
// Setup PC register input
m_PCEdit.SetDisplayType(CEditNumber::DisplayHex);
m_PCEdit.SetDisplayType(CEditNumber32::DisplayHex);
m_PCEdit.SetLimitText(8);
m_bIgnorePCChange = true;

View File

@ -95,10 +95,10 @@ private:
DWORD m_StartAddress;
CRect m_DefaultWindowRect;
CEditNumber m_PCEdit;
CEditNumber32 m_PCEdit;
bool m_bIgnorePCChange;
CEditNumber m_AddressEdit;
CEditNumber32 m_AddressEdit;
bool m_bIgnoreAddrChange;
CCommandList m_CommandList;

View File

@ -31,9 +31,9 @@ LRESULT CDumpMemory::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPa
m_FormatList.Attach(GetDlgItem(IDC_FORMAT));
m_FileName.Attach(GetDlgItem(IDC_FILENAME));
m_StartAddress.SetDisplayType(CEditNumber::DisplayHex);
m_EndAddress.SetDisplayType(CEditNumber::DisplayHex);
m_PC.SetDisplayType(CEditNumber::DisplayHex);
m_StartAddress.SetDisplayType(CEditNumber32::DisplayHex);
m_EndAddress.SetDisplayType(CEditNumber32::DisplayHex);
m_PC.SetDisplayType(CEditNumber32::DisplayHex);
uint32_t startAddress = 0x80000000;
uint32_t endAddress = startAddress + (g_MMU ? g_MMU->RdramSize() : 0x400000);

View File

@ -42,5 +42,5 @@ private:
CComboBox m_FormatList;
CEdit m_FileName;
CEditNumber m_StartAddress, m_EndAddress, m_PC;
CEditNumber32 m_StartAddress, m_EndAddress, m_PC;
};

View File

@ -41,14 +41,14 @@ void CDebugMemorySearch::AddAlignmentOptions(CComboBox & ctrl)
LRESULT CDebugMemorySearch::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
m_PAddrStart.Attach(GetDlgItem(IDC_PADDR_START));
m_PAddrStart.SetDisplayType(CEditNumber::DisplayHex);
m_PAddrStart.SetDisplayType(CEditNumber32::DisplayHex);
m_SearchLen.Attach(GetDlgItem(IDC_ADDR_END));
m_SearchLen.SetDisplayType(CEditNumber::DisplayHex);
m_SearchLen.SetDisplayType(CEditNumber32::DisplayHex);
m_SearchValue.Attach(GetDlgItem(IDC_SEARCH_VALUE));
m_SearchValue.SetDisplayType(CEditNumber::DisplayDec);
m_SearchValue.SetDisplayType(CEditNumber32::DisplayDec);
m_SearchValue.SetValue(0);
m_MaxSearch.Attach(GetDlgItem(IDC_MAX_SEARCH));
m_MaxSearch.SetDisplayType(CEditNumber::DisplayDec);
m_MaxSearch.SetDisplayType(CEditNumber32::DisplayDec);
m_MaxSearch.SetValue(50000);
m_UnknownSize.Attach(GetDlgItem(IDC_UNKNOWN_ALIGN));
AddAlignmentOptions(m_UnknownSize);
@ -97,7 +97,7 @@ LRESULT CDebugMemorySearch::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND hWndC
case IDC_SEARCH_HEX:
{
bool bChecked = (SendMessage(hWndCtl, BM_GETSTATE, 0, 0) & BST_CHECKED) != 0;
m_SearchValue.SetDisplayType(bChecked ? CEditNumber::DisplayHex : CEditNumber::DisplayDec);
m_SearchValue.SetDisplayType(bChecked ? CEditNumber32::DisplayHex : CEditNumber32::DisplayDec);
}
break;
case ID_POPUP_SHOWINMEMORYVIEWER:

View File

@ -54,7 +54,7 @@ private:
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
NOTIFY_HANDLER_EX(IDC_LST_RESULTS, NM_RCLICK, OnResultRClick)
NOTIFY_HANDLER_EX(IDC_LST_RESULTS, NM_DBLCLK, OnResultDblClick)
END_MSG_MAP()
END_MSG_MAP()
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
@ -67,7 +67,7 @@ private:
void EnableJalOptions(bool Enable);
void AddAlignmentOptions(CComboBox & ctrl);
CEditNumber m_PAddrStart, m_SearchLen, m_SearchValue, m_MaxSearch;
CEditNumber32 m_PAddrStart, m_SearchLen, m_SearchValue, m_MaxSearch;
CComboBox m_UnknownOptions, m_ValueSize, m_UnknownSize;
CListViewCtrl m_SearchResults;
SearchResult m_SearchResult;

View File

@ -631,13 +631,13 @@ void CRegisterTabs::SetColorsEnabled(bool bColorsEnabled)
m_bColorsEnabled = bColorsEnabled;
}
void CRegisterTabs::InitRegisterEdit(CWindow& tab, CEditNumber& edit, WORD ctrlId)
void CRegisterTabs::InitRegisterEdit(CWindow& tab, CEditNumber32& edit, WORD ctrlId)
{
edit.Attach(tab.GetDlgItem(ctrlId));
edit.SetDisplayType(CEditNumber::DisplayHex);
edit.SetDisplayType(CEditNumber32::DisplayHex);
}
void CRegisterTabs::InitRegisterEdits(CWindow& tab, CEditNumber* edits, const WORD* ctrlIds, uint32_t ctrlIdsCount)
void CRegisterTabs::InitRegisterEdits(CWindow& tab, CEditNumber32* edits, const WORD* ctrlIds, uint32_t ctrlIdsCount)
{
for (int i = 0, n = ctrlIdsCount; i < n; i++)
{
@ -658,12 +658,12 @@ void CRegisterTabs::InitRegisterEdits64(CWindow& tab, CEditReg64* edits, const W
}
}
void CRegisterTabs::ZeroRegisterEdit(CEditNumber& edit)
void CRegisterTabs::ZeroRegisterEdit(CEditNumber32& edit)
{
edit.SetValue(0, false, true);
}
void CRegisterTabs::ZeroRegisterEdits(CEditNumber* edits, uint32_t ctrlIdsCount)
void CRegisterTabs::ZeroRegisterEdits(CEditNumber32* edits, uint32_t ctrlIdsCount)
{
for (int i = 0, n = ctrlIdsCount; i < n; i++)
{

View File

@ -200,43 +200,43 @@ private:
CEditReg64 m_LOEdit;
CWindow m_FPRTab;
CEditNumber m_FPREdits[sizeof(FPREditIds) / sizeof(FPREditIds[0])];
CEditNumber m_FCSREdit;
CEditNumber32 m_FPREdits[sizeof(FPREditIds) / sizeof(FPREditIds[0])];
CEditNumber32 m_FCSREdit;
CWindow m_COP0Tab;
CEditNumber m_COP0Edits[sizeof(COP0EditIds) / sizeof(COP0EditIds[0])];
CEditNumber32 m_COP0Edits[sizeof(COP0EditIds) / sizeof(COP0EditIds[0])];
CStatic m_CauseTip;
CWindow m_RDRAMTab;
CEditNumber m_RDRAMEdits[sizeof(RDRAMEditIds) / sizeof(RDRAMEditIds[0])];
CEditNumber32 m_RDRAMEdits[sizeof(RDRAMEditIds) / sizeof(RDRAMEditIds[0])];
CWindow m_SPTab;
CEditNumber m_SPEdits[sizeof(SPEditIds) / sizeof(SPEditIds[0])];
CEditNumber m_SPPCEdit;
CEditNumber32 m_SPEdits[sizeof(SPEditIds) / sizeof(SPEditIds[0])];
CEditNumber32 m_SPPCEdit;
CWindow m_DPCTab;
CEditNumber m_DPCEdits[sizeof(DPCEditIds) / sizeof(DPCEditIds[0])];
CEditNumber32 m_DPCEdits[sizeof(DPCEditIds) / sizeof(DPCEditIds[0])];
CWindow m_MITab;
CEditNumber m_MIEdits[sizeof(MIEditIds) / sizeof(MIEditIds[0])];
CEditNumber32 m_MIEdits[sizeof(MIEditIds) / sizeof(MIEditIds[0])];
CWindow m_VITab;
CEditNumber m_VIEdits[sizeof(VIEditIds) / sizeof(VIEditIds[0])];
CEditNumber32 m_VIEdits[sizeof(VIEditIds) / sizeof(VIEditIds[0])];
CWindow m_AITab;
CEditNumber m_AIEdits[sizeof(AIEditIds) / sizeof(AIEditIds[0])];
CEditNumber32 m_AIEdits[sizeof(AIEditIds) / sizeof(AIEditIds[0])];
CWindow m_PITab;
CEditNumber m_PIEdits[sizeof(PIEditIds) / sizeof(PIEditIds[0])];
CEditNumber32 m_PIEdits[sizeof(PIEditIds) / sizeof(PIEditIds[0])];
CWindow m_RITab;
CEditNumber m_RIEdits[sizeof(RIEditIds) / sizeof(RIEditIds[0])];
CEditNumber32 m_RIEdits[sizeof(RIEditIds) / sizeof(RIEditIds[0])];
CWindow m_SITab;
CEditNumber m_SIEdits[sizeof(SIEditIds) / sizeof(SIEditIds[0])];
CEditNumber32 m_SIEdits[sizeof(SIEditIds) / sizeof(SIEditIds[0])];
CWindow m_DDTab;
CEditNumber m_DDEdits[sizeof(DDEditIds) / sizeof(DDEditIds[0])];
CEditNumber32 m_DDEdits[sizeof(DDEditIds) / sizeof(DDEditIds[0])];
static void RegisterChanged(HWND hDlg, TAB_ID srcTabId, WPARAM wParam);
@ -244,12 +244,12 @@ 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);
static void InitRegisterEdits(CWindow& tab, CEditNumber* edits, const WORD* ctrlIds, uint32_t ctrlIdsCount);
static void InitRegisterEdit(CWindow& tab, CEditNumber32& edit, WORD ctrlId);
static void InitRegisterEdits(CWindow& tab, CEditNumber32* edits, const WORD* ctrlIds, uint32_t ctrlIdsCount);
static void InitRegisterEdit64(CWindow& tab, CEditReg64& edit, WORD ctrlId);
static void InitRegisterEdits64(CWindow& tab, CEditReg64* edits, const WORD* ctrlIds, uint32_t ctrlIdsCount);
static void ZeroRegisterEdit(CEditNumber& edit);
static void ZeroRegisterEdits(CEditNumber* edits, uint32_t ctrlIdsCount);
static void ZeroRegisterEdit(CEditNumber32& edit);
static void ZeroRegisterEdits(CEditNumber32* edits, uint32_t ctrlIdsCount);
static void ZeroRegisterEdit64(CEditReg64& edit);
static void ZeroRegisterEdits64(CEditReg64* edits, uint32_t ctrlIdsCount);

View File

@ -58,7 +58,7 @@ LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM
}
m_MemAddr.Attach(GetDlgItem(IDC_ADDR_EDIT));
m_MemAddr.SetDisplayType(CEditNumber::DisplayHex);
m_MemAddr.SetDisplayType(CEditNumber32::DisplayHex);
m_MemAddr.SetValue(0x80000000, false, true);
SendDlgItemMessage(IDC_CHK_VADDR, BM_SETCHECK, BST_CHECKED, 0);

View File

@ -66,7 +66,7 @@ private:
void InterceptMouseWheel(WPARAM wParam, LPARAM lParam);
CEditNumber m_MemAddr;
CEditNumber32 m_MemAddr;
CListCtrl * m_MemoryList;
CAddSymbolDlg m_AddSymbolDlg;
CStatic m_SymInfo;

View File

@ -9,17 +9,18 @@
* *
****************************************************************************/
#include "stdafx.h"
#include "EditNumber32.h"
CEditNumber::CEditNumber(void) :
CEditNumber32::CEditNumber32(void) :
m_DisplayType(DisplayDec)
{
}
CEditNumber::~CEditNumber(void)
CEditNumber32::~CEditNumber32(void)
{
}
bool CEditNumber::IsHexConvertableText(LPTSTR _text)
bool CEditNumber32::IsHexConvertableText(LPTSTR _text)
{
int start, end;
GetSel(start, end);
@ -35,9 +36,11 @@ bool CEditNumber::IsHexConvertableText(LPTSTR _text)
if (second == 'X' || second == 'x')
{
if (end <= 1)
{
bPaste = false;
}
}
if (!bPaste) return bPaste;
if (!bPaste) { return bPaste; }
//Check
unsigned int i = 0;
if (strlen(_text) >= 2)
@ -45,11 +48,17 @@ bool CEditNumber::IsHexConvertableText(LPTSTR _text)
if (_text[0] == '0' && (_text[1] == 'x' || _text[1] == 'X'))
{
if ((second == 'x' || second == 'X') && (!(start == 0 && end >= 2)))
{
bPaste = false;
}
else if (start > 0)
{
bPaste = false;
}
else
{
i += 2;
}
}
}
if (!bPaste) return bPaste;
@ -62,9 +71,13 @@ bool CEditNumber::IsHexConvertableText(LPTSTR _text)
if ((_text[0] == 'x' || _text[0] == 'X'))
{
if (head != '0'&&start == 0)
{
bPaste = false;
}
else if (!(start == 1 && end >= 1 && head == '0'))
{
bPaste = false;
}
}
}
if (!bPaste) return bPaste;
@ -80,14 +93,14 @@ bool CEditNumber::IsHexConvertableText(LPTSTR _text)
return bPaste;
}
void CEditNumber::FormatClipboard()
void CEditNumber32::FormatClipboard()
{
LPTSTR lptstr, lptstrCopy;
HGLOBAL hglb;
if (!this->OpenClipboard())
return;
if (!IsClipboardFormatAvailable(CF_TEXT))
if (!this->OpenClipboard() || !IsClipboardFormatAvailable(CF_TEXT))
{
return;
}
hglb = GetClipboardData(CF_TEXT);
if (hglb != NULL)
{
@ -95,12 +108,15 @@ void CEditNumber::FormatClipboard()
for (unsigned int i = 0; i < strlen(lptstr); i++)
{
if (lptstr[i] != 'X'&&lptstr[i] != 'x')
{
lptstr[i] = (char)toupper(lptstr[i]);
}
if (lptstr[i] == 'X')
{
lptstr[i] = 'x';
}
}
hglb = GlobalAlloc(GMEM_MOVEABLE,
(strlen(lptstr) + 1) * sizeof(TCHAR));
hglb = GlobalAlloc(GMEM_MOVEABLE, (strlen(lptstr) + 1) * sizeof(TCHAR));
if (hglb == NULL)
{
CloseClipboard();
@ -115,13 +131,13 @@ void CEditNumber::FormatClipboard()
}
}
LRESULT CEditNumber::OnValidateValue(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
LRESULT CEditNumber32::OnValidateValue(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
bHandled = true;
return true;
}
LRESULT CEditNumber::OnPaste(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
LRESULT CEditNumber32::OnPaste(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
//Paste
bHandled = false;
@ -156,7 +172,7 @@ LRESULT CEditNumber::OnPaste(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/
return true;
}
LRESULT CEditNumber::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
LRESULT CEditNumber32::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
int start, end;
GetSel(start, end);
@ -244,24 +260,24 @@ LRESULT CEditNumber::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
return false;
}
BOOL CEditNumber::Attach(HWND hWndNew)
BOOL CEditNumber32::Attach(HWND hWndNew)
{
return SubclassWindow(hWndNew);
}
BOOL CEditNumber::AttachToDlgItem(HWND parent, UINT dlgID)
BOOL CEditNumber32::AttachToDlgItem(HWND parent, UINT dlgID)
{
return SubclassWindow(::GetDlgItem(parent, dlgID));
}
void CEditNumber::SetDisplayType(DisplayType Type)
void CEditNumber32::SetDisplayType(DisplayType Type)
{
DWORD lCurrentValue = GetValue();
m_DisplayType = Type;
SetValue(lCurrentValue);
}
DWORD CEditNumber::GetValue(void)
uint32_t CEditNumber32::GetValue(void)
{
char text[200];
GetWindowText(text, sizeof(text));
@ -280,7 +296,8 @@ DWORD CEditNumber::GetValue(void)
for (size_t i = Start; i < Finish; i++)
{
Value = (Value << 4);
switch (text[i]) {
switch (text[i])
{
case '0': break;
case '1': Value += 1; break;
case '2': Value += 2; break;
@ -311,14 +328,15 @@ DWORD CEditNumber::GetValue(void)
return Value;
}
void CEditNumber::SetValue(DWORD Value, bool ShowHexIdent, bool ZeroExtend)
void CEditNumber32::SetValue(uint32_t Value, bool ShowHexIdent, bool ZeroExtend)
{
char text[200];
if (m_DisplayType == DisplayDec)
{
sprintf(text, "%d", Value);
}
else {
else
{
sprintf(text, "%s%0*X", ShowHexIdent ? "0x" : "", ZeroExtend ? 8 : 0, Value);
}
SetWindowText(text);

View File

@ -11,10 +11,9 @@
#pragma once
#include <wtl/atlctrls.h>
#include <stdio.h>
class CEditNumber :
public CWindowImpl<CEditNumber, CEdit>
class CEditNumber32 :
public CWindowImpl<CEditNumber32, CEdit>
{
public:
enum DisplayType
@ -23,6 +22,15 @@ public:
DisplayDec,
};
CEditNumber32(void);
virtual ~CEditNumber32(void);
BOOL Attach(HWND hWndNew);
BOOL AttachToDlgItem(HWND parent, UINT dlgID);
void SetDisplayType(DisplayType Type);
uint32_t GetValue(void);
void SetValue(uint32_t Value, bool ShowHexIdent = true, bool ZeroExtend = false);
protected:
enum
{
@ -31,7 +39,7 @@ protected:
DisplayType m_DisplayType;
BEGIN_MSG_MAP(CEditNumber)
BEGIN_MSG_MAP(CEditNumber32)
MESSAGE_HANDLER(WM_CHAR, OnKeyDown)
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
MESSAGE_HANDLER(WM_PASTE, OnPaste)
@ -41,17 +49,7 @@ protected:
bool IsHexConvertableText(LPTSTR _text);
void FormatClipboard();
LRESULT OnValidateValue(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled);
LRESULT OnPaste(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled);
LRESULT OnValidateValue(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnPaste(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
public:
CEditNumber(void);
virtual ~CEditNumber(void);
BOOL Attach(HWND hWndNew);
BOOL AttachToDlgItem(HWND parent, UINT dlgID);
void SetDisplayType(DisplayType Type);
DWORD GetValue(void);
void SetValue(DWORD Value, bool ShowHexIdent = true, bool ZeroExtend = false);
};