diff --git a/HexCtrl/HexCtrl.h b/HexCtrl/HexCtrl.h index 7c55b7e..8618d11 100644 --- a/HexCtrl/HexCtrl.h +++ b/HexCtrl/HexCtrl.h @@ -132,11 +132,11 @@ namespace HEXCTRL { * HEXBKM: Bookmarks main struct. * ********************************************************************************************/ struct HEXBKM { - VecSpan vecSpan { }; //Vector of offsets and sizes. - std::wstring wstrDesc { }; //Bookmark description. - ULONGLONG ullID { }; //Bookmark ID, assigned internally by framework. - ULONGLONG ullData { }; //User defined custom data. - HEXCOLOR stClr { }; //Bookmark bk/text color. + VecSpan vecSpan; //Vector of offsets and sizes. + std::wstring wstrDesc; //Bookmark description. + ULONGLONG ullID { }; //Bookmark ID, assigned internally by framework. + ULONGLONG ullData { }; //User defined custom data. + HEXCOLOR stClr { }; //Bookmark bk/text color. }; using PHEXBKM = HEXBKM*; @@ -216,12 +216,12 @@ namespace HEXCTRL { //Template's field main struct. struct HEXTEMPLFIELD { - std::wstring wstrName { }; //Field name. - std::wstring wstrDescr { }; //Field description. + std::wstring wstrName; //Field name. + std::wstring wstrDescr; //Field description. int iOffset { }; //Field offset relative to the Template's beginning. int iSize { }; //Field size. HEXCOLOR stClr { }; //Field Bk and Text color. - HexVecFields vecNested { }; //Vector for nested fields. + HexVecFields vecNested; //Vector for nested fields. PCHEXTEMPLFIELD pFieldParent { }; //Parent field, in case of nested. EHexFieldType eType { }; //Field type. std::uint8_t uTypeID { }; //Field type ID if, it's a custom type. diff --git a/HexCtrl/dep/ListEx/CListEx.cpp b/HexCtrl/dep/ListEx/CListEx.cpp index 1cdf458..e562fa2 100644 --- a/HexCtrl/dep/ListEx/CListEx.cpp +++ b/HexCtrl/dep/ListEx/CListEx.cpp @@ -66,12 +66,12 @@ namespace HEXCTRL::LISTEX::INTERNAL { COLORREF m_clrHglInactive { }; COLORREF m_clrHglActive { }; DWORD m_dwHeaderHeight { 19 }; //Standard (default) height. - std::unordered_map m_umapColors { }; //Colors for columns. - std::unordered_map m_umapIcons { }; //Icons for columns. - std::unordered_map m_umapHidden { }; //Hidden columns. - std::unordered_map m_umapSortable { }; //Is column sortable. - std::unordered_map m_umapEditable { }; //Columns that can be in-place edited. - std::unordered_map m_umapDataAlign { }; //Column's data align mode. + std::unordered_map m_umapColors; //Colors for columns. + std::unordered_map m_umapIcons; //Icons for columns. + std::unordered_map m_umapHidden; //Hidden columns. + std::unordered_map m_umapSortable; //Is column sortable. + std::unordered_map m_umapEditable; //Columns that can be in-place edited. + std::unordered_map m_umapDataAlign; //Column's data align mode. UINT m_uSortColumn { 0 }; //ColumnID to draw sorting triangle at. 0 is to avoid triangle before first clicking. bool m_fSortable { false }; //List-is-sortable global flog. Need to draw sortable triangle or not? bool m_fSortAscending { }; //Sorting type. @@ -703,13 +703,13 @@ namespace HEXCTRL::LISTEX::INTERNAL { CPen m_penGrid; //Pen for list lines between cells. CWnd m_wndCellTT; //Cells tool-tip window. CWnd m_wndLinkTT; //Links tool-tip window. - CWnd m_wndRowTT { }; //Tooltip window for row in m_fHighLatency mode. + CWnd m_wndRowTT; //Tooltip window for row in m_fHighLatency mode. TTTOOLINFOW m_ttiCell { }; //Cells tool-tip info struct. TTTOOLINFOW m_ttiLink { }; //Links tool-tip info struct. TTTOOLINFOW m_ttiHL { }; //High latency tooltip info struct. - std::chrono::steady_clock::time_point m_tmTT { }; //Start time of the any tooltip. - std::wstring m_wstrTextTT { }; //Tool-tip current text. - std::wstring m_wstrCaptionTT { }; //Tool-tip current caption. + std::chrono::steady_clock::time_point m_tmTT; //Start time of the tooltip. + std::wstring m_wstrTextTT; //Tool-tip current text. + std::wstring m_wstrCaptionTT; //Tool-tip current caption. LVHITTESTINFO m_htiCurrCell { }; //Cells hit struct for tool-tip. LVHITTESTINFO m_htiCurrLink { }; //Links hit struct for tool-tip. LVHITTESTINFO m_htiEdit { }; //Hit struct for in-place editing. @@ -723,14 +723,14 @@ namespace HEXCTRL::LISTEX::INTERNAL { int m_iLOGPIXELSY { }; //GetDeviceCaps(LOGPIXELSY) constant. PFNLVCOMPARE m_pfnCompare { }; //Pointer to a user provided compare func. EListExSortMode m_eDefSortMode { EListExSortMode::SORT_LEX }; //Default sorting mode. - CRect m_rcLinkCurr { }; //Current link's rect; - std::unordered_map> m_umapCellTt { }; //Cell's tooltips. - std::unordered_map> m_umapCellData { }; //Cell's custom data. - std::unordered_map> m_umapCellColor { }; //Cell's colors. - std::unordered_map m_umapRowColor { }; //Row colors. - std::unordered_map> m_umapCellIcon { }; //Cell's icon. - std::unordered_map m_umapColumnColor { }; //Column colors. - std::unordered_map m_umapColumnSortMode { }; //Column sorting mode. + CRect m_rcLinkCurr; //Current link's rect; + std::unordered_map> m_umapCellTt; //Cell's tooltips. + std::unordered_map> m_umapCellData; //Cell's custom data. + std::unordered_map> m_umapCellColor; //Cell's colors. + std::unordered_map m_umapRowColor; //Row colors. + std::unordered_map> m_umapCellIcon; //Cell's icon. + std::unordered_map m_umapColumnColor; //Column colors. + std::unordered_map m_umapColumnSortMode; //Column sorting mode. bool m_fCreated { false }; //Is created. bool m_fHighLatency { }; //High latency flag. bool m_fSortable { false }; //Is list sortable. @@ -740,7 +740,6 @@ namespace HEXCTRL::LISTEX::INTERNAL { bool m_fVirtual { false }; //Whether list is virtual (LVS_OWNERDATA) or not. bool m_fCellTTActive { false }; //Is cell's tool-tip shown atm. bool m_fLinkTTActive { false }; //Is link's tool-tip shown atm. - bool m_fTTHiding { false }; //Flag is set when Tooltip window is hiding. bool m_fLDownAtLink { false }; //Left mouse down on link. bool m_fHLFlag { }; //High latency Vscroll flag. }; @@ -748,7 +747,7 @@ namespace HEXCTRL::LISTEX::INTERNAL { //Colors for the row/column. struct CListEx::SCOLROWCLR { LISTEXCOLOR clr { }; //Colors - std::chrono::high_resolution_clock::time_point time { }; //Time when added. + std::chrono::high_resolution_clock::time_point time; //Time when added. }; //Text and links in the cell. @@ -757,13 +756,13 @@ namespace HEXCTRL::LISTEX::INTERNAL { ITEMDATA(std::wstring_view wsvText, std::wstring_view wsvLink, std::wstring_view wsvTitle, CRect rect, bool fLink = false, bool fTitle = false) : wstrText(wsvText), wstrLink(wsvLink), wstrTitle(wsvTitle), rect(rect), fLink(fLink), fTitle(fTitle) {} - std::wstring wstrText { }; //Visible text. - std::wstring wstrLink { }; //Text within link tag. - std::wstring wstrTitle { }; //Text within title <...title="textFromHere"> tag. - CRect rect { }; //Rect text belongs to. - int iIconIndex { -1 }; //Icon index in the image list, if any. - bool fLink { false }; //Is it just a text (wsvLink is empty) or text with link? - bool fTitle { false }; //Is it link with custom title (wsvTitle is not empty)? + std::wstring wstrText; //Visible text. + std::wstring wstrLink; //Text within link tag. + std::wstring wstrTitle; //Text within title <...title="textFromHere"> tag. + CRect rect; //Rect text belongs to. + int iIconIndex { -1 }; //Icon index in the image list, if any. + bool fLink { false }; //Is it just a text (wsvLink is empty) or text with link? + bool fTitle { false }; //Is it link with custom title (wsvTitle is not empty)? }; //List tooltips. @@ -846,7 +845,6 @@ bool CListEx::Create(const LISTEXCREATE& lcs) //The TTF_TRACK flag should not be used with the TTS_BALLOON tooltips, because in this case //the balloon will always be positioned _below_ provided coordinates. m_ttiCell.uFlags = lcs.dwTTStyleCell & TTS_BALLOON ? 0 : TTF_TRACK; - m_ttiCell.uId = 0x01; m_wndCellTT.SendMessageW(TTM_ADDTOOLW, 0, reinterpret_cast(&m_ttiCell)); m_wndCellTT.SendMessageW(TTM_SETMAXTIPWIDTH, 0, static_cast(400)); //to allow use of newline \n. if (m_stColors.clrTooltipText != 0xFFFFFFFFUL || m_stColors.clrTooltipBk != 0xFFFFFFFFUL) { @@ -866,7 +864,6 @@ bool CListEx::Create(const LISTEXCREATE& lcs) m_ttiLink.cbSize = sizeof(TTTOOLINFOW); m_ttiLink.uFlags = lcs.dwTTStyleLink & TTS_BALLOON ? 0 : TTF_TRACK; - m_ttiLink.uId = 0x02; m_wndLinkTT.SendMessageW(TTM_ADDTOOLW, 0, reinterpret_cast(&m_ttiLink)); m_wndLinkTT.SendMessageW(TTM_SETMAXTIPWIDTH, 0, static_cast(400)); //to allow use of newline \n. @@ -878,7 +875,6 @@ bool CListEx::Create(const LISTEXCREATE& lcs) } m_ttiHL.cbSize = sizeof(TTTOOLINFOW); m_ttiHL.uFlags = TTF_TRACK; - m_ttiHL.uId = 0x03; m_wndRowTT.SendMessageW(TTM_ADDTOOLW, 0, reinterpret_cast(&m_ttiHL)); } @@ -1636,12 +1632,11 @@ int CListEx::GetIcon(int iItem, int iSubItem)const GetParent()->SendMessageW(WM_NOTIFY, static_cast(uCtrlID), reinterpret_cast(&lii)); return lii.iIconIndex; //By default it's -1, meaning no icon. } - else { - const auto ID = MapIndexToID(iItem); - if (const auto it = m_umapCellIcon.find(ID); it != m_umapCellIcon.end()) { - if (const auto itInner = it->second.find(iSubItem); itInner != it->second.end()) { - return itInner->second; - } + + const auto ID = MapIndexToID(iItem); + if (const auto it = m_umapCellIcon.find(ID); it != m_umapCellIcon.end()) { + if (const auto itInner = it->second.find(iSubItem); itInner != it->second.end()) { + return itInner->second; } } @@ -1742,7 +1737,8 @@ void CListEx::OnLButtonDblClk(UINT nFlags, CPoint point) m_htiEdit.pt = point; SubItemHitTest(&m_htiEdit); if (m_htiEdit.iItem < 0 || m_htiEdit.iSubItem < 0 || !GetHeaderCtrl().IsColumnEditable(m_htiEdit.iSubItem)) { - return CMFCListCtrl::OnLButtonDblClk(nFlags, point); + CMFCListCtrl::OnLButtonDblClk(nFlags, point); + return; } const auto uCtrlId = static_cast(GetDlgCtrlID()); @@ -1752,7 +1748,8 @@ void CListEx::OnLButtonDblClk(UINT nFlags, CPoint point) GetParent()->SendMessageW(WM_NOTIFY, static_cast(uCtrlId), reinterpret_cast(&ldi)); if (!ldi.fAllowEdit) { //User explicitly declined to display edit-box. - return CMFCListCtrl::OnLButtonDblClk(nFlags, point); + CMFCListCtrl::OnLButtonDblClk(nFlags, point); + return; } //Get Column data alignment. @@ -1860,28 +1857,22 @@ void CListEx::OnMouseMove(UINT /*nFlags*/, CPoint pt) static const auto hCurArrow = static_cast(LoadImageW(nullptr, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED)); static const auto hCurHand = static_cast(LoadImageW(nullptr, IDC_HAND, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED)); - //When tootlip is hiding (on timer event) it sends WM_MOUSEMOVE message to the underlying window. - //This flag/check is to prevent handling of this message, otherwise timers will rerun. - if (m_fTTHiding) { - m_fTTHiding = false; - return; - } - LVHITTESTINFO hti { pt }; SubItemHitTest(&hti); bool fLinkRect { false }; //Cursor at link's rect area? if (hti.iItem >= 0 && hti.iSubItem >= 0) { - const auto vecText = ParseItemData(hti.iItem, hti.iSubItem); - if (const auto iterFind = std::find_if(vecText.begin(), vecText.end(), [&](const ITEMDATA& item) { - return item.fLink && item.rect.PtInRect(pt); }); iterFind != vecText.end()) { + auto vecText = ParseItemData(hti.iItem, hti.iSubItem); //Non const to allow std::move(itLink->wstrLink). + auto itLink = std::find_if(vecText.begin(), vecText.end(), //Non const to allow std::move(itLink->wstrLink). + [&](const ITEMDATA& item) { return item.fLink && item.rect.PtInRect(pt); }); + if (itLink != vecText.end()) { fLinkRect = true; - if (m_fLinkTooltip && !m_fLDownAtLink && m_rcLinkCurr != iterFind->rect) { + if (m_fLinkTooltip && !m_fLDownAtLink && m_rcLinkCurr != itLink->rect) { TTLinkShow(false); m_fLinkTTActive = true; - m_rcLinkCurr = iterFind->rect; + m_rcLinkCurr = itLink->rect; m_htiCurrLink.iItem = hti.iItem; m_htiCurrLink.iSubItem = hti.iSubItem; - m_wstrTextTT = iterFind->fTitle ? std::move(iterFind->wstrTitle) : std::move(iterFind->wstrLink); + m_wstrTextTT = itLink->fTitle ? std::move(itLink->wstrTitle) : std::move(itLink->wstrLink); m_ttiLink.lpszText = m_wstrTextTT.data(); if (m_dwTTShowDelay > 0) { SetTimer(m_uIDTLinkTTActivate, m_dwTTShowDelay, nullptr); //Activate link's tooltip after delay. @@ -2327,7 +2318,6 @@ void CListEx::TTCellShow(bool fShow, bool fTimer) } m_fCellTTActive = false; - m_fTTHiding = true; m_wndCellTT.SendMessageW(TTM_TRACKACTIVATE, FALSE, reinterpret_cast(&m_ttiCell)); } } @@ -2353,7 +2343,6 @@ void CListEx::TTLinkShow(bool fShow, bool fTimer) } m_fLinkTTActive = false; - m_fTTHiding = true; m_wndLinkTT.SendMessageW(TTM_TRACKACTIVATE, FALSE, reinterpret_cast(&m_ttiLink)); } } diff --git a/HexCtrl/src/CHexCtrl.cpp b/HexCtrl/src/CHexCtrl.cpp index 974afaf..a6c5a0e 100644 --- a/HexCtrl/src/CHexCtrl.cpp +++ b/HexCtrl/src/CHexCtrl.cpp @@ -216,28 +216,18 @@ bool CHexCtrl::Create(const HEXCREATE& hcs) } } - m_wndTTBkm.CreateEx(WS_EX_TOPMOST, TOOLTIPS_CLASSW, nullptr, TTS_NOPREFIX | TTS_ALWAYSTIP, + m_wndTTMain.CreateEx(WS_EX_TOPMOST, TOOLTIPS_CLASSW, nullptr, TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, m_hWnd, nullptr); - m_stToolInfoBkm.cbSize = sizeof(TTTOOLINFOW); - m_stToolInfoBkm.uFlags = TTF_TRACK; - m_stToolInfoBkm.uId = m_uIDTTBkm; - m_wndTTBkm.SendMessageW(TTM_ADDTOOLW, 0, reinterpret_cast(&m_stToolInfoBkm)); - m_wndTTBkm.SendMessageW(TTM_SETMAXTIPWIDTH, 0, static_cast(400)); //To allow the use of a newline \n. - - m_wndTTTempl.CreateEx(WS_EX_TOPMOST, TOOLTIPS_CLASSW, nullptr, TTS_NOPREFIX | TTS_ALWAYSTIP, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, m_hWnd, nullptr); - m_stToolInfoTempl.cbSize = sizeof(TTTOOLINFOW); - m_stToolInfoTempl.uFlags = TTF_TRACK; - m_stToolInfoTempl.uId = m_uIDTTTempl; - m_wndTTTempl.SendMessageW(TTM_ADDTOOLW, 0, reinterpret_cast(&m_stToolInfoTempl)); - m_wndTTTempl.SendMessageW(TTM_SETMAXTIPWIDTH, 0, static_cast(400)); //To allow the use of a newline \n. + m_ttiMain.cbSize = sizeof(TTTOOLINFOW); + m_ttiMain.uFlags = TTF_TRACK; + m_wndTTMain.SendMessageW(TTM_ADDTOOLW, 0, reinterpret_cast(&m_ttiMain)); + m_wndTTMain.SendMessageW(TTM_SETMAXTIPWIDTH, 0, static_cast(400)); //To allow the use of a newline \n. m_wndTTOffset.CreateEx(WS_EX_TOPMOST, TOOLTIPS_CLASSW, nullptr, TTS_NOANIMATE | TTS_NOFADE | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, m_hWnd, nullptr); - m_stToolInfoOffset.cbSize = sizeof(TTTOOLINFOW); - m_stToolInfoOffset.uFlags = TTF_TRACK; - m_stToolInfoOffset.uId = 0x03UL; - m_wndTTOffset.SendMessageW(TTM_ADDTOOLW, 0, reinterpret_cast(&m_stToolInfoOffset)); + m_ttiOffset.cbSize = sizeof(TTTOOLINFOW); + m_ttiOffset.uFlags = TTF_TRACK; + m_wndTTOffset.SendMessageW(TTM_ADDTOOLW, 0, reinterpret_cast(&m_ttiOffset)); m_wndTTOffset.SendMessageW(TTM_SETMAXTIPWIDTH, 0, static_cast(400)); //To allow the use of a newline \n. if (hcs.pColors != nullptr) { @@ -1315,7 +1305,8 @@ void CHexCtrl::ModifyData(const HEXMODIFY& hms) break; }; - return ModifyData(hmsRepeat); + ModifyData(hmsRepeat); + return; } constexpr auto lmbOper = [](std::byte* pData, const HEXMODIFY& hms, [[maybe_unused]] SpanCByte) { @@ -3509,7 +3500,7 @@ auto CHexCtrl::CopyPrintScreen()const->std::wstring const auto ullSelSize = m_pSelection->GetSelSize(); const auto dwCapacity = GetCapacity(); - std::wstring wstrRet { }; + std::wstring wstrRet; wstrRet.reserve(static_cast(ullSelSize) * 4); wstrRet = L"Offset"; wstrRet.insert(0, (static_cast(m_dwOffsetDigits) - wstrRet.size()) / 2, ' '); @@ -5503,51 +5494,29 @@ void CHexCtrl::TextChunkPoint(ULONGLONG ullOffset, int& iCx, int& iCy)const (ullScrollV - (ullScrollV % m_sizeFontMain.cy))); } -void CHexCtrl::TTBkmShow(bool fShow, bool fTimer) +void CHexCtrl::TTMainShow(bool fShow, bool fTimer) { if (fShow) { m_tmTT = std::chrono::high_resolution_clock::now(); POINT pt; GetCursorPos(&pt); - m_wndTTBkm.SendMessageW(TTM_TRACKPOSITION, 0, static_cast(MAKELONG(pt.x + 3, pt.y - 20))); - m_wndTTBkm.SendMessageW(TTM_UPDATETIPTEXTW, 0, reinterpret_cast(&m_stToolInfoBkm)); - m_wndTTBkm.SendMessageW(TTM_TRACKACTIVATE, static_cast(TRUE), reinterpret_cast(&m_stToolInfoBkm)); - SetTimer(m_uIDTTBkm, 300, nullptr); + m_wndTTMain.SendMessageW(TTM_TRACKPOSITION, 0, static_cast(MAKELONG(pt.x + 3, pt.y - 20))); + m_wndTTMain.SendMessageW(TTM_UPDATETIPTEXTW, 0, reinterpret_cast(&m_ttiMain)); + m_wndTTMain.SendMessageW(TTM_TRACKACTIVATE, static_cast(TRUE), reinterpret_cast(&m_ttiMain)); + SetTimer(m_uIDTTTMain, 300, nullptr); } else { - KillTimer(m_uIDTTBkm); + KillTimer(m_uIDTTTMain); //When hiding tooltip by timer we not nullify the pointer. //Otherwise tooltip will be shown again after mouse movement, //even if cursor didn't leave current bkm area. if (!fTimer) { m_pBkmTTCurr = nullptr; - } - - m_fTTHiding = true; - m_wndTTBkm.SendMessageW(TTM_TRACKACTIVATE, FALSE, reinterpret_cast(&m_stToolInfoBkm)); - } -} - -void CHexCtrl::TTTemplShow(bool fShow, bool fTimer) -{ - if (fShow) { - m_tmTT = std::chrono::high_resolution_clock::now(); - POINT pt; - GetCursorPos(&pt); - m_wndTTTempl.SendMessageW(TTM_TRACKPOSITION, 0, static_cast(MAKELONG(pt.x + 3, pt.y - 20))); - m_wndTTTempl.SendMessageW(TTM_UPDATETIPTEXTW, 0, reinterpret_cast(&m_stToolInfoTempl)); - m_wndTTTempl.SendMessageW(TTM_TRACKACTIVATE, static_cast(TRUE), reinterpret_cast(&m_stToolInfoTempl)); - SetTimer(m_uIDTTTempl, 300, nullptr); - } - else { - KillTimer(m_uIDTTTempl); - if (!fTimer) { m_pTFieldTTCurr = nullptr; } - m_fTTHiding = true; - m_wndTTTempl.SendMessageW(TTM_TRACKACTIVATE, FALSE, reinterpret_cast(&m_stToolInfoTempl)); + m_wndTTMain.SendMessageW(TTM_TRACKACTIVATE, FALSE, reinterpret_cast(&m_ttiMain)); } } @@ -5557,13 +5526,13 @@ void CHexCtrl::TTOffsetShow(bool fShow) CPoint ptScreen; GetCursorPos(&ptScreen); auto wstrOffset = (IsOffsetAsHex() ? L"Offset: 0x" : L"Offset: ") + OffsetToWstr(GetTopLine() * GetCapacity()); - m_stToolInfoOffset.lpszText = wstrOffset.data(); + m_ttiOffset.lpszText = wstrOffset.data(); m_wndTTOffset.SendMessageW(TTM_TRACKPOSITION, 0, static_cast(MAKELONG(ptScreen.x - 5, ptScreen.y - 20))); - m_wndTTOffset.SendMessageW(TTM_UPDATETIPTEXTW, 0, reinterpret_cast(&m_stToolInfoOffset)); - m_stToolInfoOffset.lpszText = nullptr; + m_wndTTOffset.SendMessageW(TTM_UPDATETIPTEXTW, 0, reinterpret_cast(&m_ttiOffset)); + m_ttiOffset.lpszText = nullptr; } - m_wndTTOffset.SendMessageW(TTM_TRACKACTIVATE, static_cast(fShow), reinterpret_cast(&m_stToolInfoOffset)); + m_wndTTOffset.SendMessageW(TTM_TRACKACTIVATE, static_cast(fShow), reinterpret_cast(&m_ttiOffset)); } void CHexCtrl::Undo() @@ -5931,13 +5900,6 @@ void CHexCtrl::OnLButtonUp(UINT nFlags, CPoint point) void CHexCtrl::OnMouseMove(UINT nFlags, CPoint point) { - //When tootlip is hiding (on timer event) it sends WM_MOUSEMOVE message to the underlying window. - //This flag/check is to prevent handling of this message, otherwise timers will rerun. - if (m_fTTHiding) { - m_fTTHiding = false; - return; - }; - const auto optHit = HitTest(point); if (m_fLMousePressed) { @@ -6042,12 +6004,12 @@ void CHexCtrl::OnMouseMove(UINT nFlags, CPoint point) CPoint ptScreen = point; ClientToScreen(&ptScreen); ptScreen.Offset(3, 3); - m_stToolInfoBkm.lpszText = pBkm->wstrDesc.data(); - TTBkmShow(true); + m_ttiMain.lpszText = pBkm->wstrDesc.data(); + TTMainShow(true); } } else if (m_pBkmTTCurr != nullptr) { - TTBkmShow(false); + TTMainShow(false); } else if (const auto pField = m_pDlgTemplMgr->HitTest(optHit->ullOffset); m_pDlgTemplMgr->IsTooltips() && pField != nullptr) { @@ -6056,21 +6018,18 @@ void CHexCtrl::OnMouseMove(UINT nFlags, CPoint point) CPoint ptScreen = point; ClientToScreen(&ptScreen); ptScreen.Offset(3, 3); - m_stToolInfoTempl.lpszText = const_cast(pField->wstrName.data()); - TTTemplShow(true); + m_ttiMain.lpszText = const_cast(pField->wstrName.data()); + TTMainShow(true); } } - else if (m_pTFieldTTCurr != nullptr) { - TTTemplShow(false); + else if (m_pTFieldTTCurr != nullptr || m_pBkmTTCurr != nullptr) { + TTMainShow(false); } } else { - if (m_pBkmTTCurr != nullptr) { //If there is already bkm tooltip shown, but cursor is outside of data chunks. - TTBkmShow(false); - } - - if (m_pTFieldTTCurr != nullptr) { //If there is already Template's field tooltip shown. - TTTemplShow(false); + //If there is already tooltip shown, but cursor is outside of data chunks. + if (m_pBkmTTCurr != nullptr || m_pTFieldTTCurr != nullptr) { + TTMainShow(false); } } @@ -6200,24 +6159,16 @@ void CHexCtrl::OnTimer(UINT_PTR nIDEvent) ClientToScreen(rcClient); CPoint ptCursor; GetCursorPos(&ptCursor); - const auto msElapsed = std::chrono::duration(std::chrono::high_resolution_clock::now() - m_tmTT).count(); switch (nIDEvent) { - case m_uIDTTBkm: - //Checking if cursor has left client rect, or more than dbSecToShow seconds have passed since toolip is shown. - if (!rcClient.PtInRect(ptCursor)) { - TTBkmShow(false); - } - else if (msElapsed >= dbSecToShow) { - TTBkmShow(false, true); - } - break; - case m_uIDTTTempl: - if (!rcClient.PtInRect(ptCursor)) { - TTTemplShow(false); + case m_uIDTTTMain: + if (!rcClient.PtInRect(ptCursor)) { //Check if cursor has left client rect, + TTMainShow(false); } - else if (msElapsed >= dbSecToShow) { - TTTemplShow(false, true); + else if (const auto msElapsed = std::chrono::duration + (std::chrono::high_resolution_clock::now() - m_tmTT).count(); + msElapsed >= dbSecToShow) { //or more than dbSecToShow ms have passed since toolip was shown. + TTMainShow(false, true); } break; default: diff --git a/HexCtrl/src/CHexCtrl.h b/HexCtrl/src/CHexCtrl.h index 4142f99..5928e47 100644 --- a/HexCtrl/src/CHexCtrl.h +++ b/HexCtrl/src/CHexCtrl.h @@ -178,8 +178,7 @@ namespace HEXCTRL::INTERNAL { void SetFontSize(long lSize); //Set current font size. void SnapshotUndo(const VecSpan& vecSpan); //Takes currently modifiable data snapshot. void TextChunkPoint(ULONGLONG ullOffset, int& iCx, int& iCy)const; //Point of the text chunk. - void TTBkmShow(bool fShow, bool fTimer = false); //Tooltip for bookmark show/hide. - void TTTemplShow(bool fShow, bool fTimer = false); //Tooltip for templates show/hide. + void TTMainShow(bool fShow, bool fTimer = false); //Main tooltip show/hide. void TTOffsetShow(bool fShow); //Tooltip Offset show/hide. void Undo(); @@ -213,8 +212,7 @@ namespace HEXCTRL::INTERNAL { private: static constexpr auto m_pwszHexChars { L"0123456789ABCDEF" }; //Hex digits wchars for fast lookup. static constexpr auto m_pwszClassName { L"HexCtrl" }; //HexCtrl Window Class name. - static constexpr auto m_uIDTTBkm { 0x01UL }; //Tooltip ID for Bookmarks. - static constexpr auto m_uIDTTTempl { 0x02UL }; //Tooltip ID for Templates. + static constexpr auto m_uIDTTTMain { 0x01UL }; //Timer ID for default tooltip. static constexpr auto m_iIndentBottomLine { 1 }; //Bottom line indent from window's bottom. static constexpr auto m_iFirstHorzLinePx { 0 }; //First horizontal line indent. static constexpr auto m_iFirstVertLinePx { 0 }; //First vertical line indent. @@ -230,17 +228,15 @@ namespace HEXCTRL::INTERNAL { const std::unique_ptr m_pSelection { std::make_unique() }; //Selection class. const std::unique_ptr m_pScrollV { std::make_unique() }; //Vertical scroll bar. const std::unique_ptr m_pScrollH { std::make_unique() }; //Horizontal scroll bar. - SpanByte m_spnData { }; //Main data span. + SpanByte m_spnData; //Main data span. HEXCOLORS m_stColors; //All HexCtrl colors. IHexVirtData* m_pHexVirtData { }; //Data handler pointer for Virtual mode. IHexVirtColors* m_pHexVirtColors { }; //Pointer for custom colors class. - TTTOOLINFOW m_stToolInfoBkm { }; //Tooltip info for Bookmarks. - TTTOOLINFOW m_stToolInfoTempl { }; //Tooltip info for Templates. - TTTOOLINFOW m_stToolInfoOffset { }; //Tooltip info for Offset. - std::chrono::steady_clock::time_point m_tmTT { }; //Start time of the tooltip. - CWnd m_wndTTBkm { }; //Tooltip window for bookmarks description. - CWnd m_wndTTTempl { }; //Tooltip window for Templates' fields. - CWnd m_wndTTOffset { }; //Tooltip window for Offset in m_fHighLatency mode. + CWnd m_wndTTMain; //Main tooltip window. + CWnd m_wndTTOffset; //Tooltip window for Offset in m_fHighLatency mode. + TTTOOLINFOW m_ttiMain { }; //Main tooltip info. + TTTOOLINFOW m_ttiOffset { }; //Tooltip info for Offset. + std::chrono::steady_clock::time_point m_tmTT; //Start time of the tooltip. PHEXBKM m_pBkmTTCurr { }; //Currently shown bookmark's tooltip; PCHEXTEMPLFIELD m_pTFieldTTCurr { }; //Currently shown Template field's tooltip; CFont m_fontMain; //Main Hex chunks font. @@ -287,16 +283,16 @@ namespace HEXCTRL::INTERNAL { int m_iFourthVertLinePx { }; //Fourth vert line indent. int m_iCodePage { -1 }; //Current code-page for Text area. -1 for default. int m_iLOGPIXELSY { }; //GetDeviceCaps(LOGPIXELSY) constant. - std::wstring m_wstrCapacity { }; //Top Capacity string. - std::wstring m_wstrInfoBar { }; //Info bar text. - std::wstring m_wstrPageName { }; //Name of the sector/page. - std::wstring m_wstrTextTitle { }; //Text area title. + std::wstring m_wstrCapacity; //Top Capacity string. + std::wstring m_wstrInfoBar; //Info bar text. + std::wstring m_wstrPageName; //Name of the sector/page. + std::wstring m_wstrTextTitle; //Text area title. std::vector>> m_vecUndo; //Undo data. std::vector>> m_vecRedo; //Redo data. std::vector < std::unique_ptr < std::remove_pointer::type, - decltype([](const HBITMAP hBmp) { DeleteObject(hBmp); }) >> m_vecHBITMAP { }; //Icons for the Menu. - std::vector m_vecKeyBind { };//Vector of key bindings. - std::vector m_vecCharsWidth { }; //Vector of chars widths. + decltype([](const HBITMAP hBmp) { DeleteObject(hBmp); }) >> m_vecHBITMAP; //Icons for the Menu. + std::vector m_vecKeyBind; //Vector of key bindings. + std::vector m_vecCharsWidth; //Vector of chars widths. wchar_t m_wchUnprintable { L'.' }; //Replacement char for unprintable characters. wchar_t m_wchDateSepar { L'/' }; //Date separator. bool m_fCreated { false }; //Is control created or not yet. @@ -312,6 +308,5 @@ namespace HEXCTRL::INTERNAL { bool m_fKeyDownAtm { false }; //Whether a key is pressed at the moment. bool m_fRedraw { true }; //Should WM_PAINT be handled or not. bool m_fScrollLines { false }; //Page scroll in "Screen * m_flScrollRatio" or in lines. - bool m_fTTHiding { false }; //Flag is set when any Tooltip window is hiding. }; } \ No newline at end of file diff --git a/HexCtrl/src/Dialogs/CHexDlgBkmMgr.h b/HexCtrl/src/Dialogs/CHexDlgBkmMgr.h index f38d6a1..fe8a462 100644 --- a/HexCtrl/src/Dialogs/CHexDlgBkmMgr.h +++ b/HexCtrl/src/Dialogs/CHexDlgBkmMgr.h @@ -62,9 +62,9 @@ namespace HEXCTRL::INTERNAL { IHexCtrl* m_pHexCtrl { }; IHexBookmarks* m_pVirtual { }; LISTEX::IListExPtr m_pList { LISTEX::CreateListEx() }; - LONGLONG m_llIndexCurr { }; //Current bookmark's position index, to move next/prev. - std::uint64_t m_u64Flags { }; //Data from SetDlgProperties. CMenu m_menuList; - CButton m_btnHex; //Check-box "Hex numbers". + CButton m_btnHex; //Check-box "Hex numbers". + LONGLONG m_llIndexCurr { }; //Current bookmark's position index, to move next/prev. + std::uint64_t m_u64Flags { }; //Data from SetDlgProperties. }; } \ No newline at end of file diff --git a/HexCtrl/src/Dialogs/CHexDlgCallback.h b/HexCtrl/src/Dialogs/CHexDlgCallback.h index d4860f5..3f91149 100644 --- a/HexCtrl/src/Dialogs/CHexDlgCallback.h +++ b/HexCtrl/src/Dialogs/CHexDlgCallback.h @@ -28,14 +28,14 @@ namespace HEXCTRL::INTERNAL { static constexpr UINT_PTR m_uTimerCancelCheck { 0x1 }; static constexpr auto m_iElapse { 100 }; //Milliseconds for the timer. CProgressCtrl m_stProgBar; - std::wstring m_wstrOperName { }; - std::wstring m_wstrCountName { }; //Count name (e.g. Found, Replaced, etc...). + std::wstring m_wstrOperName; + std::wstring m_wstrCountName; //Count name (e.g. Found, Replaced, etc...). ULONGLONG m_ullProgBarMin { }; - ULONGLONG m_ullProgBarPrev { }; //Previous timer tick progress. + ULONGLONG m_ullProgBarPrev { }; //Previous timer tick progress. ULONGLONG m_ullProgBarCurr { }; ULONGLONG m_ullProgBarMax { }; - ULONGLONG m_ullThousandth { }; //One thousandth part. - ULONGLONG m_ullCount { }; //Count of found/replaced items. + ULONGLONG m_ullThousandth { }; //One thousandth part. + ULONGLONG m_ullCount { }; //Count of found/replaced items. bool m_fCancel { false }; }; } \ No newline at end of file diff --git a/HexCtrl/src/Dialogs/CHexDlgCodepage.h b/HexCtrl/src/Dialogs/CHexDlgCodepage.h index 8d498e0..220c544 100644 --- a/HexCtrl/src/Dialogs/CHexDlgCodepage.h +++ b/HexCtrl/src/Dialogs/CHexDlgCodepage.h @@ -35,13 +35,13 @@ namespace HEXCTRL::INTERNAL { private: struct CODEPAGE { int iCPID { }; - std::wstring wstrName { }; + std::wstring wstrName; UINT uMaxChars { }; }; inline static CHexDlgCodepage* m_pThis { }; IHexCtrl* m_pHexCtrl { }; LISTEX::IListExPtr m_pListMain { LISTEX::CreateListEx() }; - std::vector m_vecCodePage { }; + std::vector m_vecCodePage; std::uint64_t m_u64Flags { }; //Data from SetDlgProperties. }; } \ No newline at end of file diff --git a/HexCtrl/src/Dialogs/CHexDlgDataInterp.h b/HexCtrl/src/Dialogs/CHexDlgDataInterp.h index 9490575..534e580 100644 --- a/HexCtrl/src/Dialogs/CHexDlgDataInterp.h +++ b/HexCtrl/src/Dialogs/CHexDlgDataInterp.h @@ -102,12 +102,12 @@ namespace HEXCTRL::INTERNAL { std::vector m_vecGrid; IHexCtrl* m_pHexCtrl { }; CHexPropGridCtrl m_gridCtrl; - CButton m_btnHex; //Check-box "Hex numbers". - CButton m_btnBE; //Check-box "Big endian". + CButton m_btnHex; //Check-box "Hex numbers". + CButton m_btnBE; //Check-box "Big endian". ULONGLONG m_ullOffset { }; - DWORD m_dwHglDataSize { }; //Size of the data to highlight in the HexCtrl. - DWORD m_dwDateFormat { }; //Date format. std::uint64_t m_u64Flags { }; //Data from SetDlgProperties. - wchar_t m_wchDateSepar { }; //Date separator. + DWORD m_dwHglDataSize { }; //Size of the data to highlight in the HexCtrl. + DWORD m_dwDateFormat { }; //Date format. + wchar_t m_wchDateSepar { }; //Date separator. }; } \ No newline at end of file diff --git a/HexCtrl/src/Dialogs/CHexDlgGoTo.h b/HexCtrl/src/Dialogs/CHexDlgGoTo.h index 71d235b..101730a 100644 --- a/HexCtrl/src/Dialogs/CHexDlgGoTo.h +++ b/HexCtrl/src/Dialogs/CHexDlgGoTo.h @@ -33,8 +33,8 @@ namespace HEXCTRL::INTERNAL { DECLARE_MESSAGE_MAP(); private: IHexCtrl* m_pHexCtrl { }; - std::uint64_t m_u64Flags { }; //Data from SetDlgProperties. CComboBox m_comboMode; - bool m_fRepeat { false }; //Is repeat available. + std::uint64_t m_u64Flags { }; //Data from SetDlgProperties. + bool m_fRepeat { false }; //Is repeat available. }; } \ No newline at end of file diff --git a/HexCtrl/src/Dialogs/CHexDlgSearch.h b/HexCtrl/src/Dialogs/CHexDlgSearch.h index 52e8f97..1964364 100644 --- a/HexCtrl/src/Dialogs/CHexDlgSearch.h +++ b/HexCtrl/src/Dialogs/CHexDlgSearch.h @@ -152,42 +152,42 @@ namespace HEXCTRL::INTERNAL { IHexCtrl* m_pHexCtrl { }; ESearchMode m_eSearchMode { }; LISTEX::IListExPtr m_pListMain { LISTEX::CreateListEx() }; - CMenu m_menuList; //Menu for the list control. - CComboBox m_comboFind; //Combo box "Search". - CComboBox m_comboReplace; //Combo box "Replace". - CComboBox m_comboMode; //Combo box "Search mode". - CComboBox m_comboType; //Combo box "Search type". - CButton m_btnSel; //Check box "In selection". - CButton m_btnWC; //Check box "Wildcard". - CButton m_btnInv; //Check box "Inverted". - CButton m_btnBE; //Check box "Big-endian". - CButton m_btnMC; //Check box "Match case". - CEdit m_editStartFrom; //Edit box "Start from". - CEdit m_editStep; //Edit box "Step". - CEdit m_editRngBegin; //Edit box "Range begin". - CEdit m_editRngEnd; //Edit box "Range end". - CEdit m_editLimit; //Edit box "Limit search hits". - ULONGLONG m_ullStartFrom { }; //"Start form" search offset. + CMenu m_menuList; //Menu for the list control. + CComboBox m_comboFind; //Combo box "Search". + CComboBox m_comboReplace; //Combo box "Replace". + CComboBox m_comboMode; //Combo box "Search mode". + CComboBox m_comboType; //Combo box "Search type". + CButton m_btnSel; //Check box "In selection". + CButton m_btnWC; //Check box "Wildcard". + CButton m_btnInv; //Check box "Inverted". + CButton m_btnBE; //Check box "Big-endian". + CButton m_btnMC; //Check box "Match case". + CEdit m_editStartFrom; //Edit box "Start from". + CEdit m_editStep; //Edit box "Step". + CEdit m_editRngBegin; //Edit box "Range begin". + CEdit m_editRngEnd; //Edit box "Range end". + CEdit m_editLimit; //Edit box "Limit search hits". + ULONGLONG m_ullStartFrom { }; //"Start form" search offset. ULONGLONG m_ullRngBegin { }; ULONGLONG m_ullRngEnd { }; - ULONGLONG m_ullStep { 1 }; //Search step (default is 1 byte). - std::uint64_t m_u64Flags { }; //Data from SetDlgProperties. - DWORD m_dwCount { }; //How many, or what index number. - DWORD m_dwReplaced { }; //Replaced amount; - DWORD m_dwLimit { 10000 }; //Maximum found search occurences. - int m_iWrap { }; //Wrap direction: -1 = Beginning, 1 = End. - VecSearchResult m_vecSearchRes; //Search results. + ULONGLONG m_ullStep { 1 }; //Search step (default is 1 byte). + std::uint64_t m_u64Flags { }; //Data from SetDlgProperties. + DWORD m_dwCount { }; //How many, or what index number. + DWORD m_dwReplaced { }; //Replaced amount; + DWORD m_dwLimit { 10000 }; //Maximum found search occurences. + int m_iWrap { }; //Wrap direction: -1 = Beginning, 1 = End. + VecSearchResult m_vecSearchRes; //Search results. std::vector m_vecSearchData; //Data to search for. std::vector m_vecReplaceData; //Data to replace with. - std::wstring m_wstrSearch; //Text from "Search" box. - std::wstring m_wstrReplace; //Text from "Replace with..." box. - bool m_fForward { }; //Search direction, Forward/Backward. - bool m_fSecondMatch { false }; //First or subsequent match. - bool m_fFound { false }; //Found or not. - bool m_fDoCount { true }; //Do we count matches or just print "Found". - bool m_fReplace { false }; //Find or Find and Replace with...? - bool m_fAll { false }; //Find/Replace one by one, or all? - bool m_fSearchNext { false }; //Search through Next/Prev menu. + std::wstring m_wstrSearch; //Text from "Search" box. + std::wstring m_wstrReplace; //Text from "Replace with..." box. + bool m_fForward { }; //Search direction, Forward/Backward. + bool m_fSecondMatch { false }; //First or subsequent match. + bool m_fFound { false }; //Found or not. + bool m_fDoCount { true }; //Do we count matches or just print "Found". + bool m_fReplace { false }; //Find or Find and Replace with...? + bool m_fAll { false }; //Find/Replace one by one, or all? + bool m_fSearchNext { false }; //Search through Next/Prev menu. bool m_fFreshSearch { true }; }; } \ No newline at end of file diff --git a/HexCtrl/src/Dialogs/CHexDlgTemplMgr.cpp b/HexCtrl/src/Dialogs/CHexDlgTemplMgr.cpp index a49a513..6472a19 100644 --- a/HexCtrl/src/Dialogs/CHexDlgTemplMgr.cpp +++ b/HexCtrl/src/Dialogs/CHexDlgTemplMgr.cpp @@ -1832,8 +1832,8 @@ void CHexDlgTemplMgr::UnloadTemplate(int iTemplateID) void CHexDlgTemplMgr::UpdateStaticText() { - std::wstring wstrOffset { }; - std::wstring wstrSize { }; + std::wstring wstrOffset; + std::wstring wstrSize; if (m_pAppliedCurr != nullptr) { //If m_pAppliedCurr == nullptr set empty text. wstrOffset = std::vformat(IsShowAsHex() ? L"0x{:X}" : L"{}", std::make_wformat_args(m_pAppliedCurr->ullOffset)); diff --git a/HexCtrl/src/Dialogs/CHexDlgTemplMgr.h b/HexCtrl/src/Dialogs/CHexDlgTemplMgr.h index a4ae556..7f34c39 100644 --- a/HexCtrl/src/Dialogs/CHexDlgTemplMgr.h +++ b/HexCtrl/src/Dialogs/CHexDlgTemplMgr.h @@ -131,25 +131,25 @@ namespace HEXCTRL::INTERNAL { IHexCtrl* m_pHexCtrl { }; std::vector> m_vecTemplates; //Loaded Templates. std::vector> m_vecTemplatesAppl; //Currently Applied Templates. - CComboBox m_comboTemplates; //Currently available templates list. - CEdit m_editOffset; //"Offset" edit box. - CButton m_btnMin; //Check-box min-max. - CButton m_btnShowTT; //Check-box "Show tooltips". - CButton m_btnHglSel; //Check-box "Highlight selected". - CButton m_btnHex; //Check-box "Hex numbers". - CButton m_btnSwapEndian; //Check-box "Swap endian". - CWnd m_wndStaticOffset; //Static text "Template offset:". - CWnd m_wndStaticSize; //Static text Template size:". - HBITMAP m_hBITMAPMin { }; //Bitmap for the min checkbox. - HBITMAP m_hBITMAPMax { }; //Bitmap for the max checkbox. + CComboBox m_comboTemplates; //Currently available templates list. + CEdit m_editOffset; //"Offset" edit box. + CButton m_btnMin; //Check-box min-max. + CButton m_btnShowTT; //Check-box "Show tooltips". + CButton m_btnHglSel; //Check-box "Highlight selected". + CButton m_btnHex; //Check-box "Hex numbers". + CButton m_btnSwapEndian; //Check-box "Swap endian". + CWnd m_wndStaticOffset; //Static text "Template offset:". + CWnd m_wndStaticSize; //Static text Template size:". + HBITMAP m_hBITMAPMin { }; //Bitmap for the min checkbox. + HBITMAP m_hBITMAPMax { }; //Bitmap for the max checkbox. LISTEX::IListExPtr m_pListApplied { LISTEX::CreateListEx() }; CTreeCtrl m_treeApplied; - CMenu m_menuTree; //Menu for the tree control. - CMenu m_menuHdr; //Menu for the list header. + CMenu m_menuTree; //Menu for the tree control. + CMenu m_menuHdr; //Menu for the list header. PCTEMPLAPPLIED m_pAppliedCurr { }; //Currently selected template in the applied Tree. PCVecFields m_pVecFieldsCurr { }; //Currently selected Fields vector. HTREEITEM m_hTreeCurrParent { }; //Currently selected Tree node's parent. - std::uint64_t m_u64Flags { }; //Data from SetDlgProperties. + std::uint64_t m_u64Flags { }; //Data from SetDlgProperties. DWORD m_dwDateFormat { }; //Date format. int m_iDynLayoutMinY { }; //For DynamicLayout::SetMinSize. wchar_t m_wchDateSepar { }; //Date separator.