Skip to content

Commit

Permalink
Panes' dialogs are now switching while switching tabs. Panes' states …
Browse files Browse the repository at this point in the history
…are now saved when app closes.

MainFrame class now has GetHexerView, GetHexCtrl methods.
AFX_WM_CHANGE_ACTIVE_TAB message handler added to the MainFrame.
Many internal reworks. Latest HexCtrl.
  • Loading branch information
jovibor committed Jun 25, 2023
1 parent f4b3de2 commit 9ba6552
Show file tree
Hide file tree
Showing 13 changed files with 402 additions and 142 deletions.
140 changes: 118 additions & 22 deletions Hexer/CAppSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,54 @@
*******************************************************************************/
#include "stdafx.h"
#include "CAppSettings.h"
#include "resource.h"
#include <format>

void CAppSettings::LoadSettings(std::wstring_view wsvKeyName)
{
//Settings.
const std::wstring wstrKeySettings = std::wstring { L"SOFTWARE\\" } + std::wstring { wsvKeyName } + L"\\Settings";
if (CRegKey regSettings; regSettings.Open(HKEY_CURRENT_USER, wstrKeySettings.data()) == ERROR_SUCCESS) {
//SetShowPaneFileProps.

//SetShowPane.
DWORD dwShowPaneFileProps { };
regSettings.QueryDWORDValue(L"ShowPaneFileProps", dwShowPaneFileProps);
SetShowPaneFileProps(dwShowPaneFileProps > 0);
SetShowPane(IDC_PANE_FILEPROPS, dwShowPaneFileProps > 0);

//SetShowPaneDataInterp.
//SetShowPane.
DWORD dwShowPaneDataInterp { };
regSettings.QueryDWORDValue(L"ShowPaneDataInterp", dwShowPaneDataInterp);
SetShowPaneDataInterp(dwShowPaneDataInterp > 0);
SetShowPane(IDC_PANE_DATAINTERP, dwShowPaneDataInterp > 0);

//SetShowPaneTemplMgr.
//SetShowPane.
DWORD dwShowPaneTemplMgr { };
regSettings.QueryDWORDValue(L"ShowPaneTemplMgr", dwShowPaneTemplMgr);
SetShowPaneTemplMgr(dwShowPaneTemplMgr > 0);
SetShowPane(IDC_PANE_TEMPLMGR, dwShowPaneTemplMgr > 0);

//SetPaneActive.
DWORD dwIsPaneActiveFileProps { };
regSettings.QueryDWORDValue(L"IsPaneActiveFileProps", dwIsPaneActiveFileProps);
SetPaneActive(IDC_PANE_FILEPROPS, dwIsPaneActiveFileProps > 0);

//SetPaneActive.
DWORD dwIsPaneActiveDataInterp { };
regSettings.QueryDWORDValue(L"IsPaneActiveDataInterp", dwIsPaneActiveDataInterp);
SetPaneActive(IDC_PANE_DATAINTERP, dwIsPaneActiveDataInterp > 0);

//SetPaneActive.
DWORD dwIsPaneActiveTemplMgr { };
regSettings.QueryDWORDValue(L"IsPaneActiveTemplMgr", dwIsPaneActiveTemplMgr);
SetPaneActive(IDC_PANE_TEMPLMGR, dwIsPaneActiveTemplMgr > 0);

//SetPaneData.
QWORD ullPaneDataTemplMgr { };
regSettings.QueryQWORDValue(L"PaneDataTemplMgr", ullPaneDataTemplMgr);
SetPaneData(IDC_PANE_TEMPLMGR, ullPaneDataTemplMgr);

//SetPaneData.
QWORD ullPaneDataDataInterp { };
regSettings.QueryQWORDValue(L"PaneDataDataInterp", ullPaneDataDataInterp);
SetPaneData(IDC_PANE_DATAINTERP, ullPaneDataDataInterp);
}

//Recent File List.
Expand Down Expand Up @@ -63,10 +90,19 @@ void CAppSettings::SaveSettings(std::wstring_view wsvKeyName)
regSettings.Create(HKEY_CURRENT_USER, wstrKeySettings.data());
}

//SetShowPane*.
regSettings.SetDWORDValue(L"ShowPaneFileProps", GetShowPaneFileProps());
regSettings.SetDWORDValue(L"ShowPaneDataInterp", GetShowPaneDataInterp());
regSettings.SetDWORDValue(L"ShowPaneTemplMgr", GetShowPaneTemplMgr());
//SetShowPane.
regSettings.SetDWORDValue(L"ShowPaneFileProps", GetShowPane(IDC_PANE_FILEPROPS));
regSettings.SetDWORDValue(L"ShowPaneDataInterp", GetShowPane(IDC_PANE_DATAINTERP));
regSettings.SetDWORDValue(L"ShowPaneTemplMgr", GetShowPane(IDC_PANE_TEMPLMGR));

//SetPaneActive.
regSettings.SetDWORDValue(L"IsPaneActiveFileProps", GetPaneActive(IDC_PANE_FILEPROPS));
regSettings.SetDWORDValue(L"IsPaneActiveDataInterp", GetPaneActive(IDC_PANE_DATAINTERP));
regSettings.SetDWORDValue(L"IsPaneActiveTemplMgr", GetPaneActive(IDC_PANE_TEMPLMGR));

//SetPaneData
regSettings.SetQWORDValue(L"PaneDataDataInterp", GetPaneData(IDC_PANE_DATAINTERP));
regSettings.SetQWORDValue(L"PaneDataTemplMgr", GetPaneData(IDC_PANE_TEMPLMGR));

//Recent File List.
CRegKey regRFL;
Expand All @@ -80,37 +116,97 @@ void CAppSettings::SaveSettings(std::wstring_view wsvKeyName)
}
}

bool CAppSettings::GetShowPaneFileProps()const
auto CAppSettings::GetPaneData(UINT uPaneID)const->std::uint64_t
{
return m_fShowPaneFileProps;
switch (uPaneID) {
case IDC_PANE_FILEPROPS:
return m_ullPaneDataFileProps;
case IDC_PANE_DATAINTERP:
return m_ullPaneDataDataInterp;
case IDC_PANE_TEMPLMGR:
return m_ullPaneDataTemplMgr;
default:
return { };
}
}

bool CAppSettings::GetShowPaneDataInterp()const
bool CAppSettings::GetPaneActive(UINT uPaneID)const
{
return m_fShowPaneDataInterp;
switch (uPaneID) {
case IDC_PANE_FILEPROPS:
return m_fPaneActiveFileProps;
case IDC_PANE_DATAINTERP:
return m_fPaneActiveDataInterp;
case IDC_PANE_TEMPLMGR:
return m_fPaneActiveTemplMgr;
default:
return { };
}
}

bool CAppSettings::GetShowPaneTemplMgr()const
bool CAppSettings::GetShowPane(UINT uPaneID)const
{
return m_fShowPaneTemplMgr;
switch (uPaneID) {
case IDC_PANE_FILEPROPS:
return m_fShowPaneFileProps;
case IDC_PANE_DATAINTERP:
return m_fShowPaneDataInterp;
case IDC_PANE_TEMPLMGR:
return m_fShowPaneTemplMgr;
default:
return { };
}
}

auto CAppSettings::GetRFL()->std::vector<std::wstring>&
{
return m_vecRFL;
}

void CAppSettings::SetShowPaneFileProps(bool fShow)
void CAppSettings::SetPaneData(UINT uPaneID, std::uint64_t ullData)
{
m_fShowPaneFileProps = fShow;
switch (uPaneID) {
case IDC_PANE_FILEPROPS:
m_ullPaneDataFileProps = ullData;
break;
case IDC_PANE_DATAINTERP:
m_ullPaneDataDataInterp = ullData;
break;
case IDC_PANE_TEMPLMGR:
m_ullPaneDataTemplMgr = ullData;
break;
default:
return;
}
}

void CAppSettings::SetShowPaneDataInterp(bool fShow)
void CAppSettings::SetPaneActive(UINT uPaneID, bool fActive)
{
m_fShowPaneDataInterp = fShow;
switch (uPaneID) {
case IDC_PANE_FILEPROPS:
m_fPaneActiveFileProps = fActive;
case IDC_PANE_DATAINTERP:
m_fPaneActiveDataInterp = fActive;
case IDC_PANE_TEMPLMGR:
m_fPaneActiveTemplMgr = fActive;
default:
return;
}
}

void CAppSettings::SetShowPaneTemplMgr(bool fShow)
void CAppSettings::SetShowPane(UINT uPaneID, bool fShow)
{
m_fShowPaneTemplMgr = fShow;
switch (uPaneID) {
case IDC_PANE_FILEPROPS:
m_fShowPaneFileProps = fShow;
break;
case IDC_PANE_DATAINTERP:
m_fShowPaneDataInterp = fShow;
break;
case IDC_PANE_TEMPLMGR:
m_fShowPaneTemplMgr = fShow;
break;
default:
return;
}
}
25 changes: 16 additions & 9 deletions Hexer/CAppSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,25 @@ class CAppSettings final
CAppSettings(CAppSettings&&) = delete;
void operator=(const CAppSettings&) = delete;
~CAppSettings() = default;

void LoadSettings(std::wstring_view wsvKeyName);
void SaveSettings(std::wstring_view wsvKeyName);
[[nodiscard]] bool GetShowPaneFileProps()const;
[[nodiscard]] bool GetShowPaneDataInterp()const;
[[nodiscard]] bool GetShowPaneTemplMgr()const;
[[nodiscard]] auto GetPaneData(UINT uPaneID)const->std::uint64_t;
[[nodiscard]] bool GetPaneActive(UINT uPaneID)const;
[[nodiscard]] bool GetShowPane(UINT uPaneID)const;
[[nodiscard]] auto GetRFL() -> std::vector<std::wstring>&;
void SetShowPaneFileProps(bool fShow);
void SetShowPaneDataInterp(bool fShow);
void SetShowPaneTemplMgr(bool fShow);
void SetPaneData(UINT uPaneID, std::uint64_t ullData);
void SetPaneActive(UINT uPaneID, bool fActive);
void SetShowPane(UINT uPaneID, bool fShow);
private:
std::vector<std::wstring> m_vecRFL;
bool m_fShowPaneFileProps { }; //Show "File Properties" pane on the first frame opened?
bool m_fShowPaneDataInterp { }; //Show "Data Interpreter" pane on the first frame opened?
bool m_fShowPaneTemplMgr { }; //Show "Template Manager" pane on the first frame opened?
std::uint64_t m_ullPaneDataFileProps { };
std::uint64_t m_ullPaneDataTemplMgr { };
std::uint64_t m_ullPaneDataDataInterp { };
bool m_fShowPaneFileProps { }; //Show "File Properties" pane on the first frame opened?
bool m_fShowPaneDataInterp { }; //Show "Data Interpreter" pane on the first frame opened?
bool m_fShowPaneTemplMgr { }; //Show "Template Manager" pane on the first frame opened?
bool m_fPaneActiveFileProps { }; //Is Pane active "File Properties"?
bool m_fPaneActiveDataInterp { }; //Is Pane active "Data Interpreter"?
bool m_fPaneActiveTemplMgr { }; //Is Pane active "Template Manager"?
};
10 changes: 10 additions & 0 deletions Hexer/CChildFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWndEx)
ON_WM_MDIACTIVATE()
END_MESSAGE_MAP()

auto CChildFrame::GetHexerView()const->CHexerView*
{
return m_pHexerView;
}

void CChildFrame::SetHexerView(CHexerView* pView)
{
m_pHexerView = pView;
}

void CChildFrame::OnClose()
{
m_fClosing = true;
Expand Down
5 changes: 5 additions & 0 deletions Hexer/CChildFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
*******************************************************************************/
#pragma once

class CHexerView;
class CChildFrame final : public CMDIChildWndEx
{
public:
[[nodiscard]] auto GetHexerView()const->CHexerView*;
void SetHexerView(CHexerView* pView);
private:
afx_msg void OnClose();
BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)override;
Expand All @@ -16,5 +20,6 @@ class CChildFrame final : public CMDIChildWndEx
DECLARE_DYNCREATE(CChildFrame);
DECLARE_MESSAGE_MAP();
private:
CHexerView* m_pHexerView { };
bool m_fClosing { false }; //Indicates that the tab is closing now.
};
Loading

0 comments on commit 9ba6552

Please sign in to comment.