Skip to content

Commit

Permalink
Latest HexCtrl adapted.
Browse files Browse the repository at this point in the history
  • Loading branch information
jovibor committed Jan 3, 2025
1 parent 2430ef1 commit 87e442a
Show file tree
Hide file tree
Showing 13 changed files with 712 additions and 461 deletions.
7 changes: 5 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Checks: '*,
-cppcoreguidelines-*,-google-*,-fuchsia-*,-hicpp-*,-cert-*,-clang-*,-llvmlibc-*,-altera-*,
-cppcoreguidelines-*,-google-*,-fuchsia-*,-hicpp-*,-cert-*,-clang-*,-llvmlibc-*,-altera-*,-boost-*,-abseil-*,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-narrowing-conversions,
Expand All @@ -12,8 +12,11 @@ Checks: '*,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
-misc-use-after-move,
-misc-use-internal-linkage,
-modernize-use-trailing-return-type,
-modernize-avoid-c-arrays,
-modernize-use-nodiscard,
-modernize-use-ranges,
-performance-no-int-to-ptr,
-portability-simd-intrinsics,
-readability-avoid-nested-conditional-operator,
Expand All @@ -27,7 +30,7 @@ Checks: '*,
-readability-misleading-indentation,
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-named-parameter,
google-readability-casting'

HeaderFilterRegex: ''
4 changes: 1 addition & 3 deletions Pepper/CPepperDoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
#include <afxcontrolbars.h>
#include "CFileLoader.h"
import Utility;
import libpe;
using namespace libpe;

class CPepperDoc : public CDocument
{
class CPepperDoc : public CDocument {
public:
[[nodiscard]] auto GetFileLoader() -> CFileLoader&;
void SetEditMode(bool fEditMode);
Expand Down
190 changes: 114 additions & 76 deletions Pepper/CViewRightBL.cpp

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions Pepper/CViewRightBL.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@
#include "CPepperDoc.h"
#include "CTreeEx.h"
#include "HexCtrl.h"
#include "ListEx/ListEx.h"

import Utility;

using namespace HEXCTRL;
using namespace LISTEX;
using namespace Utility;

class CViewRightBL : public CView
{
class CViewRightBL : public CView {
private:
[[nodiscard]] auto GetListByID(UINT_PTR uListID) -> CListEx*;
afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
void OnInitialUpdate()override;
BOOL OnCommand(WPARAM wParam, LPARAM lParam)override;
void OnDraw(CDC* pDC)override; // overridden to draw this view
Expand Down Expand Up @@ -63,10 +64,10 @@ class CViewRightBL : public CView
IHexCtrlPtr m_stHexEdit { CreateHexCtrl() };
HEXCREATE m_hcs { };
LISTEXCREATE m_stlcs;
IListExPtr m_listExportFuncs { CreateListEx() };
IListExPtr m_listImportEntry { CreateListEx() };
IListExPtr m_listDelayImportEntry { CreateListEx() };
IListExPtr m_listRelocsEntry { CreateListEx() };
CListEx m_listExportFuncs;
CListEx m_listImportEntry;
CListEx m_listDelayImportEntry;
CListEx m_listRelocsEntry;
CTreeEx m_treeResBottom;
CImageList m_imglTreeRes;
std::vector<std::tuple<long, long, long, EResType>> m_vecResId { }; //Lvl: ROOT, 2, 3 and res type for tree node.
Expand Down
39 changes: 31 additions & 8 deletions Pepper/CViewRightBR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ BEGIN_MESSAGE_MAP(CViewRightBR, CScrollView)
ON_WM_SIZE()
ON_WM_ERASEBKGND()
ON_WM_RBUTTONUP()
ON_WM_DRAWITEM()
ON_WM_MEASUREITEM()
END_MESSAGE_MAP()

void CViewRightBR::OnInitialUpdate()
Expand All @@ -84,7 +86,7 @@ void CViewRightBR::OnInitialUpdate()
}
m_EditBRB.SetFont(&m_fontEditRes);

m_stlcs.pParent = this;
m_stlcs.hWndParent = m_hWnd;
m_stlcs.pColors = &Utility::g_stListColors;
m_stlcs.dwHdrHeight = 35;

Expand All @@ -94,10 +96,10 @@ void CViewRightBR::OnInitialUpdate()
ReleaseDC(pDC);

StringCchCopyW(m_lf.lfFaceName, 9, L"Consolas");
m_stlcs.pListLogFont = &m_lf;
m_stlcs.pLFList = &m_lf;
m_hdrlf.lfWeight = FW_BOLD;
StringCchCopyW(m_hdrlf.lfFaceName, 16, L"Times New Roman");
m_stlcs.pHdrLogFont = &m_hdrlf;
m_stlcs.pLFHdr = &m_hdrlf;

CreateListTLSCallbacks();
}
Expand Down Expand Up @@ -132,8 +134,9 @@ void CViewRightBR::OnUpdate(CView* /*pSender*/, LPARAM lHint, CObject* pHint)
{
CRect rcClient;
GetClientRect(&rcClient);
m_stListTLSCallbacks->SetWindowPos(this, 0, 0, rcClient.Width(), rcClient.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
m_hwndActive = m_stListTLSCallbacks->m_hWnd;
m_stListTLSCallbacks.SetWindowPos(m_hWnd, 0, 0, rcClient.Width(), rcClient.Height(),
SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
m_hwndActive = m_stListTLSCallbacks.GetHWND();
m_pChildFrame->GetSplitRightBot().ShowCol(1);
m_pChildFrame->GetSplitRightBot().SetColumnInfo(0, rcParent.Width() / 2, 0);
}
Expand Down Expand Up @@ -587,12 +590,12 @@ void CViewRightBR::CreateListTLSCallbacks()

m_stlcs.dwStyle = 0;
m_stlcs.uID = IDC_LIST_TLS_CALLBACKS;
m_stListTLSCallbacks->Create(m_stlcs);
m_stListTLSCallbacks->InsertColumn(0, L"TLS Callbacks", LVCFMT_CENTER, 300);
m_stListTLSCallbacks.Create(m_stlcs);
m_stListTLSCallbacks.InsertColumn(0, L"TLS Callbacks", LVCFMT_CENTER, 300);

int listindex { };
for (const auto& iterCallbacks : pTLS->vecTLSCallbacks) {
m_stListTLSCallbacks->InsertItem(listindex++, std::format(L"{:08X}", iterCallbacks).data());
m_stListTLSCallbacks.InsertItem(listindex++, std::format(L"{:08X}", iterCallbacks).data());
}
}

Expand Down Expand Up @@ -1134,6 +1137,26 @@ void CViewRightBR::ResLoadError()
RedrawWindow();
}

void CViewRightBR::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if (nIDCtl == IDC_LIST_TLS_CALLBACKS) {
m_stListTLSCallbacks.DrawItem(lpDrawItemStruct);
return;
}

CView::OnDrawItem(nIDCtl, lpDrawItemStruct);
}

void CViewRightBR::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
if (nIDCtl == IDC_LIST_TLS_CALLBACKS) {
m_stListTLSCallbacks.MeasureItem(lpMeasureItemStruct);
return;
}

CView::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
}

auto CViewRightBR::ParceDlgTemplate(std::span<std::byte> spnData)->std::optional<std::wstring>
{
#pragma pack(push, 4) //When refData comes from PE resources it is packed.
Expand Down
11 changes: 5 additions & 6 deletions Pepper/CViewRightBR.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
#include <memory>
#include "CPepperDoc.h"
#include "CChildFrm.h"
#include "ListEx/ListEx.h"
#include <span>

import Utility;
using namespace Utility;
using namespace LISTEX;

class CWndSampleDlg final : public CWnd
{
class CWndSampleDlg final : public CWnd {
public:
void Attach(CImageList* pImgList);
void CreatedForMenu(bool fMenu); //Created for show RT_MENU, not RT_DIALOG.
Expand All @@ -29,9 +27,10 @@ class CWndSampleDlg final : public CWnd
bool m_fMenu { false }; //Dialog is created only for showing RT_MENU.
};

class CViewRightBR final : public CScrollView
{
class CViewRightBR final : public CScrollView {
private:
afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnRButtonUp(UINT nFlags, CPoint pt);
Expand Down Expand Up @@ -70,7 +69,7 @@ class CViewRightBR final : public CScrollView
CWndSampleDlg m_wndSampleDlg;
CMenu m_menuSample;
LISTEXCREATE m_stlcs;
IListExPtr m_stListTLSCallbacks { CreateListEx() };
CListEx m_stListTLSCallbacks;
LOGFONTW m_lf { };
LOGFONTW m_hdrlf { };
EResType m_eResTypeToDraw { };
Expand Down
Loading

0 comments on commit 87e442a

Please sign in to comment.