This commit is contained in:
Jean-Philip Desjardins 2017-05-15 01:07:33 -04:00
parent f656879a42
commit 1db03fc7a6
2 changed files with 17 additions and 49 deletions

View File

@ -1,43 +1,25 @@
#include <stdio.h>
#include "FunctionsView.h"
#include "layout/HorizontalLayout.h"
#include "layout/LayoutStretch.h"
#include "win32/LayoutWindow.h"
#include "win32/InputBox.h"
#include "string_cast.h"
#include "PtrMacro.h"
#include "string_format.h"
#define CLSNAME _T("FunctionsView")
#define DEFAULT_GROUPID (1)
#define DEFAULT_GROUPNAME _T("Global")
#define SCALE(x) MulDiv(x, ydpi, 96)
CFunctionsView::CFunctionsView(HWND hParent)
: m_context(nullptr)
, m_biosDebugInfoProvider(nullptr)
CFunctionsView::CFunctionsView(HWND hParent)
{
if(!DoesWindowClassExist(CLSNAME))
{
WNDCLASSEX wc;
memset(&wc, 0, sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wc.hInstance = GetModuleHandle(NULL);
wc.lpszClassName = CLSNAME;
wc.lpfnWndProc = CWindow::WndProc;
RegisterClassEx(&wc);
}
unsigned long windowStyle = WS_CLIPCHILDREN | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX;
#ifndef FUNCTIONSVIEW_STANDALONE
windowStyle |= WS_CHILD;
#endif
int ydpi = GetDeviceCaps(GetDC(NULL), LOGPIXELSY);
Create(NULL, CLSNAME, _T("Functions"), windowStyle, Framework::Win32::CRect(0, 0, SCALE(320), SCALE(240)), hParent, NULL);
Create(NULL, Framework::Win32::CDefaultWndClass().GetName(), _T("Functions"), windowStyle,
Framework::Win32::CRect(0, 0, SCALE(320), SCALE(240)), hParent, NULL);
SetClassPtr();
m_pList = new Framework::Win32::CListView(m_hWnd, Framework::Win32::CRect(0, 0, 0, 0), LVS_REPORT | LVS_SINGLESEL | LVS_SORTASCENDING | LVS_SHOWSELALWAYS);
@ -66,11 +48,6 @@ CFunctionsView::CFunctionsView(HWND hParent)
RefreshLayout();
}
CFunctionsView::~CFunctionsView()
{
}
void CFunctionsView::Refresh()
{
RefreshList();
@ -229,10 +206,8 @@ void CFunctionsView::InitializeModuleGrouper()
m_pList->RemoveAllGroups();
m_pList->EnableGroupView(true);
m_pList->InsertGroup(DEFAULT_GROUPNAME, DEFAULT_GROUPID);
for(auto moduleIterator(std::begin(m_modules));
std::end(m_modules) != moduleIterator; moduleIterator++)
for(const auto& module : m_modules)
{
const auto& module(*moduleIterator);
m_pList->InsertGroup(
string_cast<std::tstring>(module.name.c_str()).c_str(),
module.begin);
@ -241,10 +216,8 @@ void CFunctionsView::InitializeModuleGrouper()
uint32 CFunctionsView::GetFunctionGroupId(uint32 address)
{
for(auto moduleIterator(std::begin(m_modules));
std::end(m_modules) != moduleIterator; moduleIterator++)
for(const auto& module : m_modules)
{
const auto& module(*moduleIterator);
if(address >= module.begin && address < module.end) return module.begin;
}
return DEFAULT_GROUPID;
@ -284,7 +257,7 @@ void CFunctionsView::OnNewClick()
Framework::Win32::CInputBox inputBox(_T("New Function"), _T("New Function Name:"), _T(""));
const TCHAR* sValue = inputBox.GetValue(m_hWnd);
if(sValue == NULL) return;
_tcsncpy(sNameX, sValue, 255);
_tcsncpy(sNameX, sValue, 255);
}
{
@ -368,8 +341,6 @@ void CFunctionsView::OnImportClick()
RefreshList();
OnFunctionsStateChange();
printf("FunctionsView: Symbolic information found and loaded.\r\n");
}
void CFunctionsView::OnDeleteClick()

View File

@ -1,5 +1,4 @@
#ifndef _FUNCTIONSVIEW_H_
#define _FUNCTIONSVIEW_H_
#pragma once
#include <boost/signals2.hpp>
#include <functional>
@ -11,17 +10,17 @@
#include "../BiosDebugInfoProvider.h"
#include "../ELF.h"
class CFunctionsView :
class CFunctionsView :
#ifdef FUNCTIONSVIEW_STANDALONE
public Framework::Win32::CWindow,
#else
public Framework::Win32::CMDIChild,
public Framework::Win32::CMDIChild,
#endif
public boost::signals2::trackable
{
public:
CFunctionsView(HWND);
virtual ~CFunctionsView();
virtual ~CFunctionsView() = default;
void SetContext(CMIPS*, CBiosDebugInfoProvider*);
void Refresh();
@ -49,19 +48,17 @@ private:
void OnDeleteClick();
void OnImportClick();
Framework::Win32::CListView* m_pList;
Framework::Win32::CButton* m_pNew;
Framework::Win32::CButton* m_pRename;
Framework::Win32::CButton* m_pDelete;
Framework::Win32::CButton* m_pImport;
Framework::Win32::CListView* m_pList = nullptr;
Framework::Win32::CButton* m_pNew = nullptr;
Framework::Win32::CButton* m_pRename = nullptr;
Framework::Win32::CButton* m_pDelete = nullptr;
Framework::Win32::CButton* m_pImport = nullptr;
Framework::FlatLayoutPtr m_pLayout;
boost::signals2::connection m_functionTagsChangeConnection;
CMIPS* m_context;
CMIPS* m_context = nullptr;
BiosDebugModuleInfoArray m_modules;
CBiosDebugInfoProvider* m_biosDebugInfoProvider;
CBiosDebugInfoProvider* m_biosDebugInfoProvider = nullptr;
};
#endif