Skip to content

Commit

Permalink
IsInfoBar renamed to HasInfoBar.
Browse files Browse the repository at this point in the history
Latest ListEx.
  • Loading branch information
jovibor committed Feb 13, 2025
1 parent 41477ab commit 8d6e483
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 38 deletions.
3 changes: 1 addition & 2 deletions HexCtrl/HexCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,12 @@ namespace HEXCTRL {
[[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 iPosAt = 0) = 0; //Go to the given offset.
[[nodiscard]] virtual bool HasInfoBar()const = 0; //Is InfoBar currently visible?
[[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 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 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.
Expand Down Expand Up @@ -495,7 +495,6 @@ namespace HEXCTRL {
constexpr auto HEXCTRL_MSG_SETGROUPSIZE { 0x0110U }; //Data grouping size has changed.
constexpr auto HEXCTRL_MSG_SETSELECTION { 0x0111U }; //Selection has been made.


/**************************************************************************
* Flags for the internal dialogs, used with the SetDlgProperties method. *
**************************************************************************/
Expand Down
32 changes: 13 additions & 19 deletions HexCtrl/dep/ListEx/ListEx.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -1379,12 +1379,7 @@ bool CListEx::Create(const LISTEXCREATE& lcs)

void CListEx::CreateDialogCtrl(UINT uCtrlID, HWND hWndParent)
{
LISTEXCREATE lcs;
lcs.hWndParent = hWndParent;
lcs.uID = uCtrlID;
lcs.fDialogCtrl = true;

Create(lcs);
Create({ .hWndParent { hWndParent }, .uID { uCtrlID }, .fDialogCtrl { true } });
}

bool CListEx::DeleteAllItems()
Expand Down Expand Up @@ -2116,9 +2111,10 @@ int CALLBACK CListEx::DefCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lPar
break;
case EListExSortMode::SORT_NUMERIC:
{
LONGLONG llData1 { }, llData2 { };
StrToInt64ExW(wstrItem1.data(), STIF_SUPPORT_HEX, &llData1);
StrToInt64ExW(wstrItem2.data(), STIF_SUPPORT_HEX, &llData2);
LONGLONG llData1 { };
LONGLONG llData2 { };
::StrToInt64ExW(wstrItem1.data(), STIF_SUPPORT_HEX, &llData1);
::StrToInt64ExW(wstrItem2.data(), STIF_SUPPORT_HEX, &llData2);
iCompare = llData1 != llData2 ? (llData1 - llData2 < 0 ? -1 : 1) : 0;
}
break;
Expand Down Expand Up @@ -2478,9 +2474,9 @@ auto CListEx::OnMouseWheel(const MSG& msg)->LRESULT

auto CListEx::OnMouseMove(const MSG& msg)->LRESULT
{
static const auto hCurArrow = static_cast<HCURSOR>(LoadImageW(nullptr, IDC_ARROW, IMAGE_CURSOR, 0, 0,
static const auto hCurArrow = static_cast<HCURSOR>(::LoadImageW(nullptr, IDC_ARROW, IMAGE_CURSOR, 0, 0,
LR_DEFAULTSIZE | LR_SHARED));
static const auto hCurHand = static_cast<HCURSOR>(LoadImageW(nullptr, IDC_HAND, IMAGE_CURSOR, 0, 0,
static const auto hCurHand = static_cast<HCURSOR>(::LoadImageW(nullptr, IDC_HAND, IMAGE_CURSOR, 0, 0,
LR_DEFAULTSIZE | LR_SHARED));
const POINT pt { .x { GET_X_LPARAM(msg.lParam) }, .y { GET_Y_LPARAM(msg.lParam) } };

Expand Down Expand Up @@ -2639,7 +2635,7 @@ auto CListEx::OnPaint()->LRESULT
::GetClipBox(dcMem, rcClient);
dcMem.FillSolidRect(rcClient, m_stColors.clrNWABk);

return DefSubclassProc(m_hWnd, WM_PAINT, reinterpret_cast<WPARAM>(dcMem.GetHDC()), 0);
return ::DefSubclassProc(m_hWnd, WM_PAINT, reinterpret_cast<WPARAM>(dcMem.GetHDC()), 0);
}

auto CListEx::OnTimer(const MSG& msg)->LRESULT
Expand All @@ -2652,7 +2648,7 @@ auto CListEx::OnTimer(const MSG& msg)->LRESULT

POINT ptCur;
::GetCursorPos(&ptCur);
POINT ptCurClient = ptCur;
POINT ptCurClient { ptCur };
::ScreenToClient(m_hWnd, &ptCurClient);
LVHITTESTINFO hitInfo { .pt { ptCurClient } };
HitTest(&hitInfo);
Expand Down Expand Up @@ -2721,9 +2717,7 @@ auto CListEx::OnVScroll(const MSG& msg)->LRESULT
}
else {
m_fHLFlag = true;
SCROLLINFO si { };
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_ALL;
SCROLLINFO si { .cbSize { sizeof(SCROLLINFO) }, .fMask { SIF_ALL } };
::GetScrollInfo(m_hWnd, SB_VERT, &si);
m_uHLItem = si.nTrackPos; //si.nTrackPos is in fact a row number.
TTHLShow(true, m_uHLItem);
Expand Down Expand Up @@ -2763,7 +2757,7 @@ auto CListEx::ParseItemData(int iItem, int iSubitem)->std::vector<CListEx::ITEMD

std::size_t nPosCurr { 0 }; //Current position in the parsed string.
wnd::CRect rcTextCurr; //Current rect.
const auto hDC = GetDC(m_hWnd);
const auto hDC = ::GetDC(m_hWnd);

while (nPosCurr != std::wstring_view::npos) {
static constexpr std::wstring_view wsvTagLink { L"<link=" };
Expand Down Expand Up @@ -2855,7 +2849,7 @@ auto CListEx::ParseItemData(int iItem, int iSubitem)->std::vector<CListEx::ITEMD
nPosCurr = std::wstring_view::npos;
}
}
ReleaseDC(m_hWnd, hDC);
::ReleaseDC(m_hWnd, hDC);

//Depending on column's data alignment we adjust rects coords to render properly.
switch (GetHeader().GetColumnDataAlign(iSubitem)) {
Expand Down Expand Up @@ -2913,7 +2907,7 @@ void CListEx::RecalcMeasure()const
{
//To get WM_MEASUREITEM after changing the font.
wnd::CRect rc;
GetWindowRect(m_hWnd, rc);
::GetWindowRect(m_hWnd, rc);
const WINDOWPOS wp { .hwnd { m_hWnd }, .cx { rc.Width() }, .cy { rc.Height() },
.flags { SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER } };
::SendMessageW(m_hWnd, WM_WINDOWPOSCHANGED, 0, reinterpret_cast<LPARAM>(&wp));
Expand Down
20 changes: 10 additions & 10 deletions HexCtrl/src/CHexCtrl.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,12 @@ namespace HEXCTRL::INTERNAL {
[[nodiscard]] auto GetUnprintableChar()const->wchar_t override;
[[nodiscard]] auto GetWndHandle(EHexWnd eWnd, bool fCreate)const->HWND override;
void GoToOffset(ULONGLONG ullOffset, int iPosAt = 0)override;
[[nodiscard]] bool HasInfoBar()const override;
[[nodiscard]] bool HasSelection()const override;
[[nodiscard]] auto HitTest(POINT pt, bool fScreen)const->std::optional<HEXHITTEST> override;
[[nodiscard]] bool IsCmdAvail(EHexCmd eCmd)const override;
[[nodiscard]] bool IsCreated()const override;
[[nodiscard]] bool IsDataSet()const override;
[[nodiscard]] bool IsInfoBar()const override;
[[nodiscard]] bool IsMutable()const override;
[[nodiscard]] bool IsOffsetAsHex()const override;
[[nodiscard]] auto IsOffsetVisible(ULONGLONG ullOffset)const->HEXVISION override;
Expand Down Expand Up @@ -1293,6 +1293,13 @@ void CHexCtrl::GoToOffset(ULONGLONG ullOffset, int iPosAt)
}
}

bool CHexCtrl::HasInfoBar()const
{
if (!IsCreated()) { ut::DBG_REPORT_NOT_CREATED(); return false; }

return m_fInfoBar;
}

bool CHexCtrl::HasSelection()const
{
if (!IsCreated()) { ut::DBG_REPORT_NOT_CREATED(); return false; }
Expand Down Expand Up @@ -1418,13 +1425,6 @@ bool CHexCtrl::IsDataSet()const
return m_fDataSet;
}

bool CHexCtrl::IsInfoBar()const
{
if (!IsCreated()) { ut::DBG_REPORT_NOT_CREATED(); return false; }

return m_fInfoBar;
}

bool CHexCtrl::IsMutable()const
{
if (!IsCreated()) { ut::DBG_REPORT_NOT_CREATED(); return false; }
Expand Down Expand Up @@ -3133,7 +3133,7 @@ void CHexCtrl::DrawWindow(HDC hDC)const

void CHexCtrl::DrawInfoBar(HDC hDC)const
{
if (!IsInfoBar())
if (!HasInfoBar())
return;

struct POLYINFODATA { //InfoBar text, colors, and vertical lines.
Expand Down Expand Up @@ -4497,7 +4497,7 @@ void CHexCtrl::RecalcAll(HDC hDC, LPCRECT pRC)
m_sizeFontInfo.cx = tm.tmAveCharWidth;
m_sizeFontInfo.cy = tm.tmHeight + tm.tmExternalLeading;

if (IsInfoBar()) {
if (HasInfoBar()) {
m_iHeightInfoBarPx = m_sizeFontInfo.cy;
m_iHeightInfoBarPx += m_iHeightInfoBarPx / 3;
}
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
* [GetUnprintableChar](#getunprintablechar)
* [GetWndHandle](#getwndhandle)
* [GoToOffset](#gotooffset)
* [HasInfoBar](#hasinfobar)
* [HasSelection](#hasselection)
* [HitTest](#hittest)
* [IsCmdAvail](#iscmdavail)
* [IsCreated](#iscreated)
* [IsDataSet](#isdataset)
* [IsInfoBar](#isinfobar)
* [IsMutable](#ismutable)
* [IsOffsetAsHex](#isoffsetashex)
* [IsOffsetVisible](#isoffsetvisible)
Expand Down Expand Up @@ -536,6 +536,12 @@ Go to the given offset. The second argument `iPosAt` can take three values:
* &nbsp; `0` - offset will appear in the center
* &nbsp; `1` - offset will appear at the bottom line

### [](#)HasInfoBar
```cpp
[[nodiscard]] bool HasInfoBar()const;
```
Shows whether bottom info bar currently visible or not.

### [](#)HasSelection
```cpp
[[nodiscard]] bool HasSelection()const;
Expand Down Expand Up @@ -566,12 +572,6 @@ Shows whether **HexCtrl** is created or not.
```
Shows whether a data was set to **HexCtrl** or not

### [](#)IsInfoBar
```cpp
[[nodiscard]] bool IsInfoBar()const;
```
Shows whether the bottom Info bar is visible at the moment or not.

### [](#)IsMutable
```cpp
[[nodiscard]] bool IsMutable()const;
Expand Down

0 comments on commit 8d6e483

Please sign in to comment.