Skip to content

Commit

Permalink
Docs. Latest ListEx.
Browse files Browse the repository at this point in the history
StrToNum removed as a git submodule, added as a standalone.
Code cleaning.
  • Loading branch information
jovibor committed Jun 18, 2024
1 parent 6ac55a0 commit 0f9e7ab
Show file tree
Hide file tree
Showing 18 changed files with 2,002 additions and 127 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

22 changes: 11 additions & 11 deletions HexCtrl/HexCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ namespace HEXCTRL {
virtual bool Create(const HEXCREATE& hcs) = 0; //Main initialization method.
virtual bool CreateDialogCtrl(UINT uCtrlID, HWND hWndParent) = 0; //Сreates custom dialog control.
virtual void Destroy() = 0; //Deleter.
virtual void ExecuteCmd(EHexCmd eCmd) = 0; //Execute a command within the control.
virtual void ExecuteCmd(EHexCmd eCmd) = 0; //Execute a command within HexCtrl.
[[nodiscard]] virtual auto GetActualWidth()const->int = 0; //Working area actual width.
[[nodiscard]] virtual auto GetBookmarks()const->IHexBookmarks* = 0; //Get Bookmarks interface.
[[nodiscard]] virtual auto GetCacheSize()const->DWORD = 0; //Returns VirtualData mode cache size.
Expand All @@ -404,7 +404,7 @@ namespace HEXCTRL {
[[nodiscard]] virtual auto GetCharsExtraSpace()const->DWORD = 0; //Get extra space between chars, in pixels.
[[nodiscard]] virtual auto GetCodepage()const->int = 0; //Get current codepage ID.
[[nodiscard]] virtual auto GetColors()const->const HEXCOLORS & = 0; //All current colors.
[[nodiscard]] virtual auto GetData(HEXSPAN hss)const->SpanByte = 0; //Get pointer to data offset, no matter what mode the control works in.
[[nodiscard]] virtual auto GetData(HEXSPAN hss)const->SpanByte = 0; //Get pointer to data offset, no matter what mode HexCtrl works in.
[[nodiscard]] virtual auto GetDataSize()const->ULONGLONG = 0; //Get currently set data size.
[[nodiscard]] virtual auto GetDateInfo()const->std::tuple<DWORD, wchar_t> = 0; //Get date format and separator info.
[[nodiscard]] virtual auto GetDlgItemHandle(EHexWnd eWnd, EHexDlgItem eItem)const->HWND = 0; //Dialogs' items.
Expand All @@ -420,29 +420,29 @@ namespace HEXCTRL {
[[nodiscard]] virtual auto GetTemplates()const->IHexTemplates* = 0; //Get Templates interface.
[[nodiscard]] virtual auto GetUnprintableChar()const->wchar_t = 0; //Get unprintable replacement character.
[[nodiscard]] virtual auto GetWndHandle(EHexWnd eWnd, bool fCreate = true)const->HWND = 0; //Get HWND of internal window/dialogs.
virtual void GoToOffset(ULONGLONG ullOffset, int iRelPos = 0) = 0; //Go (scroll) to a given offset.
virtual void GoToOffset(ULONGLONG ullOffset, int iPosAt = 0) = 0; //Go to the given offset.
[[nodiscard]] virtual bool HasSelection()const = 0; //Does currently have any selection or not.
[[nodiscard]] virtual auto HitTest(POINT pt, bool fScreen = true)const->std::optional<HEXHITTEST> = 0; //HitTest given point.
[[nodiscard]] virtual bool IsCmdAvail(EHexCmd eCmd)const = 0; //Is given Cmd currently available (can be executed)?
[[nodiscard]] virtual bool IsCreated()const = 0; //Shows whether control is created or not.
[[nodiscard]] virtual bool IsDataSet()const = 0; //Shows whether a data was set to the control or not.
[[nodiscard]] virtual bool IsCreated()const = 0; //Shows whether HexCtrl is created or not.
[[nodiscard]] virtual bool IsDataSet()const = 0; //Shows whether a data was set to HexCtrl or not.
[[nodiscard]] virtual bool IsInfoBar()const = 0; //Is InfoBar visible?
[[nodiscard]] virtual bool IsMutable()const = 0; //Is edit mode enabled or not.
[[nodiscard]] virtual bool IsOffsetAsHex()const = 0; //Is "Offset" currently shown as Hex or as Decimal.
[[nodiscard]] virtual bool IsMutable()const = 0; //Is data mutable or not.
[[nodiscard]] virtual bool IsOffsetAsHex()const = 0; //Are offsets shown as Hex or as Decimal.
[[nodiscard]] virtual auto IsOffsetVisible(ULONGLONG ullOffset)const->HEXVISION = 0; //Ensures that the given offset is visible.
[[nodiscard]] virtual bool IsVirtual()const = 0; //Is working in VirtualData or default mode.
virtual void ModifyData(const HEXMODIFY& hms) = 0; //Main routine to modify data in IsMutable()==true mode.
virtual void Redraw() = 0; //Redraw the control's window.
virtual void SetCapacity(DWORD dwCapacity) = 0; //Set the control's current capacity.
virtual void Redraw() = 0; //Redraw HexCtrl's window.
virtual void SetCapacity(DWORD dwCapacity) = 0; //Set current capacity.
virtual void SetCaretPos(ULONGLONG ullOffset, bool fHighLow = true, bool fRedraw = true) = 0; //Set the caret position.
virtual void SetCharsExtraSpace(DWORD dwSpace) = 0; //Extra space to add between chars, in pixels.
virtual void SetCodepage(int iCodepage) = 0; //Codepage for text area.
virtual void SetColors(const HEXCOLORS& hcs) = 0; //Set all the control's colors.
virtual void SetColors(const HEXCOLORS& hcs) = 0; //Set HexCtrl's colors.
virtual bool SetConfig(std::wstring_view wsvPath) = 0; //Set configuration file, or "" for defaults.
virtual void SetData(const HEXDATA& hds) = 0; //Main method for setting data to display (and edit).
virtual void SetDateInfo(DWORD dwFormat, wchar_t wchSepar) = 0; //Set date format and date separator.
virtual void SetDlgProperties(EHexWnd eWnd, std::uint64_t u64Flags) = 0; //Properties for the internal dialogs.
virtual void SetFont(const LOGFONTW& lf) = 0; //Set the control's new font. This font has to be monospaced.
virtual void SetFont(const LOGFONTW& lf) = 0; //Set HexCtrl's font, this font has to be monospaced.
virtual void SetGroupSize(DWORD dwSize) = 0; //Set data grouping size.
virtual void SetMutable(bool fEnable) = 0; //Enable or disable mutable/editable mode.
virtual void SetOffsetMode(bool fHex) = 0; //Set offset being shown as Hex or as Decimal.
Expand Down
80 changes: 31 additions & 49 deletions HexCtrl/dep/ListEx/CListEx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
namespace HEXCTRL::LISTEX::INTERNAL {
class CListExHdr final : public CMFCHeaderCtrl {
public:
explicit CListExHdr();
~CListExHdr()final = default;
void DeleteColumn(int iIndex);
[[nodiscard]] UINT GetHiddenCount()const;
[[nodiscard]] int GetColumnDataAlign(int iIndex)const;
Expand Down Expand Up @@ -57,9 +55,6 @@ namespace HEXCTRL::LISTEX::INTERNAL {
DECLARE_MESSAGE_MAP();
private:
CFont m_fontHdr;
CPen m_penGrid;
CPen m_penLight;
CPen m_penShadow;
COLORREF m_clrBkNWA { }; //Bk of non working area.
COLORREF m_clrText { };
COLORREF m_clrBk { };
Expand All @@ -85,7 +80,7 @@ namespace HEXCTRL::LISTEX::INTERNAL {

//Header column icons.
struct CListExHdr::SHDRICON {
LISTEXHDRICON stIcon { }; //Icon data struct.
LISTEXHDRICON stIcon; //Icon data struct.
bool fLMPressed { false }; //Left mouse button pressed atm.
};

Expand All @@ -108,13 +103,6 @@ BEGIN_MESSAGE_MAP(CListExHdr, CMFCHeaderCtrl)
ON_WM_RBUTTONDOWN()
END_MESSAGE_MAP()

CListExHdr::CListExHdr()
{
m_penGrid.CreatePen(PS_SOLID, 2, RGB(220, 220, 220));
m_penLight.CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT));
m_penShadow.CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
}

void CListExHdr::DeleteColumn(int iIndex)
{
if (const auto ID = ColumnIndexToID(iIndex); ID > 0) {
Expand Down Expand Up @@ -354,18 +342,6 @@ int CListExHdr::ColumnIDToIndex(UINT uID)const
return -1;
}

void CListExHdr::OnDestroy()
{
CMFCHeaderCtrl::OnDestroy();

m_umapColors.clear();
m_umapIcons.clear();
m_umapHidden.clear();
m_umapSortable.clear();
m_umapEditable.clear();
m_umapDataAlign.clear();
}

auto CListExHdr::GetHdrColor(UINT ID)const->const CListExHdr::SHDRCOLOR*
{
if (const auto it = m_umapColors.find(ID); it != m_umapColors.end()) {
Expand Down Expand Up @@ -406,7 +382,19 @@ bool CListExHdr::IsEditable(UINT ID)const
return iter != m_umapEditable.end() && iter->second;
}

void CListExHdr::OnDrawItem(CDC* pDC, int iItem, CRect rcOrig, BOOL bIsPressed, BOOL bIsHighlighted)
void CListExHdr::OnDestroy()
{
CMFCHeaderCtrl::OnDestroy();

m_umapColors.clear();
m_umapIcons.clear();
m_umapHidden.clear();
m_umapSortable.clear();
m_umapEditable.clear();
m_umapDataAlign.clear();
}

void CListExHdr::OnDrawItem(CDC* pDC, int iItem, const CRect rcOrig, BOOL bIsPressed, BOOL bIsHighlighted)
{
//Non working area after last column. Or if column is resized to zero width.
if (iItem < 0 || rcOrig.IsRectEmpty()) {
Expand All @@ -418,8 +406,8 @@ void CListExHdr::OnDrawItem(CDC* pDC, int iItem, CRect rcOrig, BOOL bIsPressed,
auto& rDC = memDC.GetDC();
const auto ID = ColumnIndexToID(iItem);
const auto pClr = GetHdrColor(ID);
const COLORREF clrText { pClr != nullptr ? pClr->clrText : m_clrText };
const COLORREF clrBk { bIsHighlighted ? (bIsPressed ? m_clrHglActive : m_clrHglInactive)
const auto clrText { pClr != nullptr ? pClr->clrText : m_clrText };
const auto clrBk { bIsHighlighted ? (bIsPressed ? m_clrHglActive : m_clrHglInactive)
: (pClr != nullptr ? pClr->clrBk : m_clrBk) };

rDC.FillSolidRect(rcOrig, clrBk);
Expand Down Expand Up @@ -474,30 +462,24 @@ void CListExHdr::OnDrawItem(CDC* pDC, int iItem, CRect rcOrig, BOOL bIsPressed,

//Draw sortable triangle (arrow).
if (m_fSortable && IsSortable(ID) && ID == m_uSortColumn) {
rDC.SelectObject(m_penLight);
const auto iOffset = rcOrig.Height() / 4;

if (m_fSortAscending) {
//Draw the UP arrow.
rDC.MoveTo(rcOrig.right - 2 * iOffset, iOffset);
rDC.LineTo(rcOrig.right - iOffset, rcOrig.bottom - iOffset - 1);
rDC.LineTo(rcOrig.right - 3 * iOffset - 2, rcOrig.bottom - iOffset - 1);
rDC.SelectObject(m_penShadow);
rDC.MoveTo(rcOrig.right - 3 * iOffset - 1, rcOrig.bottom - iOffset - 1);
rDC.LineTo(rcOrig.right - 2 * iOffset, iOffset - 1);
static const CPen penArrow(PS_SOLID, 1, RGB(90, 90, 90));
static const CBrush brFill(GetSysColor(COLOR_3DFACE));
rDC.SelectObject(penArrow);
rDC.SelectObject(brFill);
if (m_fSortAscending) { //Draw the UP arrow.
const POINT arrPt[] { { rcOrig.right - 10, 3 },
{ rcOrig.right - 15, 8 }, { rcOrig.right - 5, 8 } };
rDC.Polygon(arrPt, 3);
}
else {
//Draw the DOWN arrow.
rDC.MoveTo(rcOrig.right - iOffset - 1, iOffset);
rDC.LineTo(rcOrig.right - 2 * iOffset - 1, rcOrig.bottom - iOffset);
rDC.SelectObject(m_penShadow);
rDC.MoveTo(rcOrig.right - 2 * iOffset - 2, rcOrig.bottom - iOffset);
rDC.LineTo(rcOrig.right - 3 * iOffset - 1, iOffset);
rDC.LineTo(rcOrig.right - iOffset - 1, iOffset);
else { //Draw the DOWN arrow.
const POINT arrPt[] { { rcOrig.right - 10, 8 },
{ rcOrig.right - 15, 3 }, { rcOrig.right - 5, 3 } };
rDC.Polygon(arrPt, 3);
}
}

rDC.SelectObject(m_penGrid);
static const CPen penGrid(PS_SOLID, 2, GetSysColor(COLOR_3DFACE));
rDC.SelectObject(penGrid);
rDC.MoveTo(rcOrig.TopLeft());
rDC.LineTo(rcOrig.left, rcOrig.bottom);
if (iItem == GetItemCount() - 1) { //Last item.
Expand All @@ -506,7 +488,7 @@ void CListExHdr::OnDrawItem(CDC* pDC, int iItem, CRect rcOrig, BOOL bIsPressed,
}
}

LRESULT CListExHdr::OnLayout(WPARAM /*wParam*/, LPARAM lParam)
auto CListExHdr::OnLayout(WPARAM /*wParam*/, LPARAM lParam)->LRESULT
{
CMFCHeaderCtrl::DefWindowProcW(HDM_LAYOUT, 0, lParam);

Expand Down
6 changes: 3 additions & 3 deletions HexCtrl/dep/ListEx/ListEx.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace HEXCTRL::LISTEX {
NMHDR hdr { };
int iItem { };
int iSubItem { };
LISTEXCOLOR stClr { };
LISTEXCOLOR stClr;
};
using PLISTEXCOLORINFO = LISTEXCOLORINFO*;

Expand Down Expand Up @@ -71,7 +71,7 @@ namespace HEXCTRL::LISTEX {
NMHDR hdr { };
int iItem { };
int iSubItem { };
LISTEXTTDATA stData { };
LISTEXTTDATA stData;
};
using PLISTEXTTINFO = LISTEXTTINFO*;

Expand Down Expand Up @@ -117,7 +117,7 @@ namespace HEXCTRL::LISTEX {
PCLISTEXCOLORS pColors { }; //ListEx colors.
const LOGFONTW* pListLogFont { }; //ListEx font.
const LOGFONTW* pHdrLogFont { }; //Header font.
CRect rect { }; //Initial rect.
CRect rect; //Initial rect.
UINT uID { }; //ListEx control ID.
DWORD dwStyle { }; //ListEx window styles.
DWORD dwExStyle { }; //Extended window styles.
Expand Down
1 change: 0 additions & 1 deletion HexCtrl/dep/StrToNum
Submodule StrToNum deleted from 2d02d4
Loading

0 comments on commit 0f9e7ab

Please sign in to comment.