Skip to content

Commit

Permalink
Getters for splitters to CChildFrame.
Browse files Browse the repository at this point in the history
Code cleaning.
  • Loading branch information
jovibor committed Apr 27, 2023
1 parent 11fc0f9 commit 2d5b596
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 60 deletions.
15 changes: 15 additions & 0 deletions Pepper/CChildFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,21 @@ void CChildFrame::OnDestroy()
--reinterpret_cast<CMainFrame*>(AfxGetMainWnd())->GetChildFramesCount();
}

auto CChildFrame::GetSplitRight()->CSplitterEx&
{
return m_stSplitterRight;
}

auto CChildFrame::GetSplitRightTop()->CSplitterEx&
{
return m_stSplitterRightTop;
}

auto CChildFrame::GetSplitRightBot()->CSplitterEx&
{
return m_stSplitterRightBottom;
}

BOOL CChildFrame::OnEraseBkgnd(CDC* pDC)
{
return CMDIChildWndEx::OnEraseBkgnd(pDC);
Expand Down
18 changes: 9 additions & 9 deletions Pepper/CChildFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@
#pragma once
#include "CSplitterEx.h"

import Utility;
using namespace util;

class CChildFrame : public CMDIChildWndEx
{
public:
CSplitterEx m_stSplitterMain;
CSplitterEx m_stSplitterRight;
CSplitterEx m_stSplitterRightTop;
CSplitterEx m_stSplitterRightBottom;
[[nodiscard]] auto GetSplitRight() -> CSplitterEx&;
[[nodiscard]] auto GetSplitRightTop() -> CSplitterEx&;
[[nodiscard]] auto GetSplitRightBot() -> CSplitterEx&;
private:
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnClose();
Expand All @@ -28,8 +24,12 @@ class CChildFrame : public CMDIChildWndEx
DECLARE_MESSAGE_MAP();
DECLARE_DYNCREATE(CChildFrame);
private:
bool m_fSplitterCreated { false };
bool m_fClosing { false }; //Indicates that tab is closing now.
CSplitterEx m_stSplitterMain;
CSplitterEx m_stSplitterRight;
CSplitterEx m_stSplitterRightTop;
CSplitterEx m_stSplitterRightBottom;
UINT m_cx { };
UINT m_cy { };
bool m_fSplitterCreated { false };
bool m_fClosing { false }; //Indicates that tab is closing now.
};
10 changes: 5 additions & 5 deletions Pepper/CFileLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ class CFileLoader : public CWnd
IHexCtrl* pHexCtrl { };
bool fWhole { };
};
bool m_fLoaded { false };
bool m_fModified { false };
bool m_fWritable { false };
static constexpr DWORD m_dwStyle { WS_POPUP | WS_OVERLAPPEDWINDOW };
static constexpr DWORD m_dwExStyle { WS_EX_APPWINDOW }; //To force to the taskbar.
CPepperDoc* m_pMainDoc { };
IHexCtrlPtr m_pHex { HEXCTRL::CreateHexCtrl() };
HEXCREATE m_hcs;
HEXDATA m_hds;
const DWORD m_dwStyle { WS_POPUP | WS_OVERLAPPEDWINDOW };
const DWORD m_dwExStyle { WS_EX_APPWINDOW }; //To force to the taskbar.
LARGE_INTEGER m_stFileSize { }; //Size of the loaded PE file.
HANDLE m_hFile { };
HANDLE m_hMapObject { }; //Returned by CreateFileMappingW.
LPVOID m_lpBase { };
std::vector<HEXTODATACHECK> m_vecCheck;
bool m_fLoaded { false };
bool m_fModified { false };
bool m_fWritable { false };
};
2 changes: 1 addition & 1 deletion Pepper/CMainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <afxcontrolbars.h>

import Utility;
using namespace util;
using namespace Util;

class CMainFrame : public CMDIFrameWndEx
{
Expand Down
4 changes: 2 additions & 2 deletions Pepper/CPepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ BOOL CAboutDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();

const auto wstrVerPepper = std::format(L"Pepper: PE32/PE32+ Binaries Analyzer v{}.{}.{}", util::PEPPER_VERSION_MAJOR,
util::PEPPER_VERSION_MINOR, util::PEPPER_VERSION_PATCH);
const auto wstrVerPepper = std::format(L"Pepper: PE32/PE32+ Binaries Analyzer v{}.{}.{}", Util::PEPPER_VERSION_MAJOR,
Util::PEPPER_VERSION_MINOR, Util::PEPPER_VERSION_PATCH);
GetDlgItem(IDC_LINK_PEPPER)->SetWindowTextW(wstrVerPepper.data());
const auto wstrVerLibpe = std::format(L"libpe: PE32/PE32+ Binaries Parsing Library v{}.{}.{}",
libpe::LIBPE_VERSION_MAJOR, libpe::LIBPE_VERSION_MINOR, libpe::LIBPE_VERSION_PATCH);
Expand Down
2 changes: 1 addition & 1 deletion Pepper/CPepperDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <format>

import Utility;
using namespace util;
using namespace Util;

IMPLEMENT_DYNCREATE(CPepperDoc, CDocument)

Expand Down
4 changes: 2 additions & 2 deletions Pepper/CPepperDoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CPepperDoc : public CDocument
[[nodiscard]] auto GetFileLoader() -> CFileLoader&;
void SetEditMode(bool fEditMode);
[[nodiscard]] bool IsEditMode() { return m_fEditMode; }
[[nodiscard]] auto GetFileInfo() -> util::PEFILEINFO&;
[[nodiscard]] auto GetFileInfo() -> Util::PEFILEINFO&;
[[nodiscard]] auto GetOffsetFromVA(ULONGLONG ullVA) -> DWORD;
[[nodiscard]] auto GetOffsetFromRVA(ULONGLONG ullRVA) -> DWORD;
[[nodiscard]] auto GetDOSHeader() -> std::optional<IMAGE_DOS_HEADER>&;
Expand Down Expand Up @@ -71,7 +71,7 @@ class CPepperDoc : public CDocument
std::optional<PEBOUNDIMPORT_VEC> m_optBoundImp;
std::optional<PEDELAYIMPORT_VEC> m_optDelayImp;
std::optional<PECOMDESCRIPTOR> m_optComDescr;
util::PEFILEINFO m_stFileInfo;
Util::PEFILEINFO m_stFileInfo;
bool m_fEditMode { false };
bool m_fHasCur { false };
bool m_fHasIco { false };
Expand Down
6 changes: 2 additions & 4 deletions Pepper/CTreeEx.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@

class CTreeEx : public CTreeCtrl
{
DECLARE_DYNAMIC(CTreeEx);
CTreeEx() = default;
virtual ~CTreeEx() = default;
protected:
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
DECLARE_MESSAGE_MAP();
DECLARE_DYNAMIC(CTreeEx);
};
2 changes: 1 addition & 1 deletion Pepper/CViewLeft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "res/resource.h"

import Utility;
using namespace util;
using namespace Util;

IMPLEMENT_DYNCREATE(CViewLeft, CView)

Expand Down
1 change: 1 addition & 0 deletions Pepper/CViewRightBL.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Utility;

using namespace HEXCTRL;
using namespace LISTEX;
using namespace Util;

class CViewRightBL : public CView
{
Expand Down
31 changes: 16 additions & 15 deletions Pepper/CViewRightBR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,30 +139,30 @@ void CViewRightBR::OnUpdate(CView* /*pSender*/, LPARAM lHint, CObject* pHint)
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_pChildFrame->m_stSplitterRightBottom.ShowCol(1);
m_pChildFrame->m_stSplitterRightBottom.SetColumnInfo(0, rcParent.Width() / 2, 0);
m_pChildFrame->GetSplitRightBot().ShowCol(1);
m_pChildFrame->GetSplitRightBot().SetColumnInfo(0, rcParent.Width() / 2, 0);
}
break;
case IDC_TREE_RESOURCE:
m_pChildFrame->m_stSplitterRightBottom.ShowCol(1);
m_pChildFrame->m_stSplitterRightBottom.SetColumnInfo(0, rcParent.Width() / 3, 0);
m_pChildFrame->GetSplitRightBot().ShowCol(1);
m_pChildFrame->GetSplitRightBot().SetColumnInfo(0, rcParent.Width() / 3, 0);
break;
case IDC_SHOW_RESOURCE_RBR:
m_pResData = reinterpret_cast<PERESFLAT*>(pHint);
ShowResource(m_pResData);
m_pChildFrame->m_stSplitterRightBottom.ShowCol(1);
m_pChildFrame->m_stSplitterRightBottom.SetColumnInfo(0, rcParent.Width() / 3, 0);
m_pChildFrame->GetSplitRightBot().ShowCol(1);
m_pChildFrame->GetSplitRightBot().SetColumnInfo(0, rcParent.Width() / 3, 0);
break;
case IDC_LIST_DEBUG_ENTRY:
CreateDebugEntry(HIWORD(lHint));
m_pChildFrame->m_stSplitterRightBottom.ShowCol(1);
m_pChildFrame->m_stSplitterRightBottom.SetColumnInfo(0, rcParent.Width() / 2, 0);
m_pChildFrame->GetSplitRightBot().ShowCol(1);
m_pChildFrame->GetSplitRightBot().SetColumnInfo(0, rcParent.Width() / 2, 0);
break;
default:
m_pChildFrame->m_stSplitterRightBottom.HideCol(1);
m_pChildFrame->GetSplitRightBot().HideCol(1);
}

m_pChildFrame->m_stSplitterRightBottom.RecalcLayout();
m_pChildFrame->GetSplitRightBot().RecalcLayout();
}

BOOL CViewRightBR::OnCommand(WPARAM wParam, LPARAM lParam)
Expand All @@ -177,6 +177,8 @@ BOOL CViewRightBR::OnCommand(WPARAM wParam, LPARAM lParam)

void CViewRightBR::OnDraw(CDC* pDC)
{
constexpr auto clrBkIcons { RGB(230, 230, 230) };

CRect rcClipBox;
pDC->GetClipBox(rcClipBox);
const auto sizeScroll = GetTotalSize();
Expand All @@ -198,12 +200,12 @@ void CViewRightBR::OnDraw(CDC* pDC)
case RTYPE_CURSOR:
case RTYPE_BITMAP:
case RTYPE_ICON:
pDC->FillSolidRect(rcClipBox, m_clrBkIcons);
pDC->FillSolidRect(rcClipBox, clrBkIcons);
m_stImgRes.Draw(pDC, 0, { x, y }, ILD_NORMAL);
break;
case RTYPE_GROUP_CURSOR:
case RTYPE_GROUP_ICON:
pDC->FillSolidRect(rcClipBox, m_clrBkIcons);
pDC->FillSolidRect(rcClipBox, clrBkIcons);
for (const auto& iter : m_vecImgRes) {
IMAGEINFO imgInfo;
iter->GetImageInfo(0, &imgInfo);
Expand All @@ -218,7 +220,7 @@ void CViewRightBR::OnDraw(CDC* pDC)
}
break;
case RTYPE_PNG:
pDC->FillSolidRect(rcClipBox, m_clrBkIcons);
pDC->FillSolidRect(rcClipBox, clrBkIcons);
m_imgPng.AlphaBlend(pDC->m_hDC, x, y, m_iImgResWidth, m_iImgResHeight, 0, 0, m_iImgResWidth, m_iImgResHeight);
break;
case RES_LOAD_ERROR:
Expand Down Expand Up @@ -595,8 +597,7 @@ void CViewRightBR::CreateListTLSCallbacks()

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

Expand Down
5 changes: 2 additions & 3 deletions Pepper/CViewRightBR.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <span>

import Utility;
using namespace util;
using namespace Util;
using namespace LISTEX;

class CWndSampleDlg final : public CWnd
Expand Down Expand Up @@ -60,6 +60,7 @@ class CViewRightBR final : public CScrollView
DECLARE_MESSAGE_MAP();
DECLARE_DYNCREATE(CViewRightBR);
private:
static constexpr auto m_clrBkImgList { RGB(250, 250, 250) };
HWND m_hwndActive { };
CChildFrame* m_pChildFrame { };
CPepperDoc* m_pMainDoc { };
Expand All @@ -72,8 +73,6 @@ class CViewRightBR final : public CScrollView
IListExPtr m_stListTLSCallbacks { CreateListEx() };
LOGFONTW m_lf { };
LOGFONTW m_hdrlf { };
COLORREF m_clrBkIcons { RGB(230, 230, 230) };
COLORREF m_clrBkImgList { RGB(250, 250, 250) };
EResType m_eResTypeToDraw { };
int m_iImgResWidth { }; //Width of the whole image to draw.
int m_iImgResHeight { }; //Height of the whole image to draw.
Expand Down
8 changes: 4 additions & 4 deletions Pepper/CViewRightTL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ void CViewRightTL::OnInitialUpdate()
else {
m_wstrFileType = L"File type: unknown";
}
m_wstrPepperVersion = std::format(L"Pepper v{}.{}.{}", util::PEPPER_VERSION_MAJOR,
util::PEPPER_VERSION_MINOR, util::PEPPER_VERSION_PATCH);
m_wstrPepperVersion = std::format(L"Pepper v{}.{}.{}", Util::PEPPER_VERSION_MAJOR,
Util::PEPPER_VERSION_MINOR, Util::PEPPER_VERSION_PATCH);

m_stlcs.stColor.clrTooltipText = RGB(255, 255, 255);
m_stlcs.stColor.clrTooltipBk = RGB(0, 132, 132);
Expand Down Expand Up @@ -193,8 +193,8 @@ void CViewRightTL::OnUpdate(CView* /*pSender*/, LPARAM lHint, CObject* /*pHint*/
m_pwndActive->SetWindowPos(this, 0, 0, rcClient.Width(), rcClient.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
}

fShowRow ? m_pChildFrame->m_stSplitterRight.ShowRow(1) : m_pChildFrame->m_stSplitterRight.HideRow(1);
m_pChildFrame->m_stSplitterRight.RecalcLayout();
fShowRow ? m_pChildFrame->GetSplitRight().ShowRow(1) : m_pChildFrame->GetSplitRight().HideRow(1);
m_pChildFrame->GetSplitRight().RecalcLayout();
}

void CViewRightTL::OnDraw(CDC* pDC)
Expand Down
1 change: 1 addition & 0 deletions Pepper/CViewRightTL.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Utility;

using namespace LISTEX;
using namespace HEXCTRL;
using namespace Util;

class CViewRightTL : public CView
{
Expand Down
13 changes: 7 additions & 6 deletions Pepper/CViewRightTR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "CViewRightTR.h"

import Utility;
using namespace Util;

IMPLEMENT_DYNCREATE(CViewRightTR, CView)

Expand Down Expand Up @@ -59,14 +60,14 @@ void CViewRightTR::OnUpdate(CView* /*pSender*/, LPARAM lHint, CObject* pHint)
::ShowWindow(m_hwndActive, SW_HIDE);
m_stHexEdit->ClearData();
m_hwndActive = m_stHexEdit->GetWindowHandle(EHexWnd::WND_MAIN);
m_pChildFrame->m_stSplitterRightTop.ShowCol(1);
m_pChildFrame->m_stSplitterRightTop.SetColumnInfo(0, rcParent.Width() / 3, 0);
m_pChildFrame->GetSplitRightTop().ShowCol(1);
m_pChildFrame->GetSplitRightTop().SetColumnInfo(0, rcParent.Width() / 3, 0);
::SetWindowPos(m_hwndActive, m_hWnd, 0, 0, rcClient.Width(), rcClient.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
break;
case IDC_HEX_RIGHT_TR:
CreateHexResources(reinterpret_cast<PIMAGE_RESOURCE_DATA_ENTRY>(pHint));
m_pChildFrame->m_stSplitterRightTop.ShowCol(1);
m_pChildFrame->m_stSplitterRightTop.SetColumnInfo(0, rcParent.Width() / 3, 0);
m_pChildFrame->GetSplitRightTop().ShowCol(1);
m_pChildFrame->GetSplitRightTop().SetColumnInfo(0, rcParent.Width() / 3, 0);
break;
case ID_DOC_EDITMODE:
OnDocEditMode();
Expand All @@ -75,11 +76,11 @@ void CViewRightTR::OnUpdate(CView* /*pSender*/, LPARAM lHint, CObject* pHint)
if (m_hwndActive) {
::ShowWindow(m_hwndActive, SW_HIDE);
}
m_pChildFrame->m_stSplitterRightTop.HideCol(1);
m_pChildFrame->GetSplitRightTop().HideCol(1);
break;
}

m_pChildFrame->m_stSplitterRightTop.RecalcLayout();
m_pChildFrame->GetSplitRightTop().RecalcLayout();
}

void CViewRightTR::OnDraw(CDC* /*pDC*/)
Expand Down
Loading

0 comments on commit 2d5b596

Please sign in to comment.