summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-04-29 13:04:44 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-04-29 13:04:44 +0300
commit5394d950df535693ae1cf85ef3cc049810f1f23b (patch)
tree802fca10469411c63537f6ae5e1b4bc657af48c0 /src
parent518a066dd786632852dc12de8bb0a3bd217f8f5d (diff)
more const qualifiers
Diffstat (limited to 'src')
-rw-r--r--src/mir_core/src/CCtrlBase.cpp4
-rw-r--r--src/mir_core/src/CCtrlClc.cpp2
-rw-r--r--src/mir_core/src/CCtrlListBox.cpp15
-rw-r--r--src/mir_core/src/CCtrlListView.cpp32
-rw-r--r--src/mir_core/src/CCtrlTreeView.cpp38
-rw-r--r--src/mir_core/src/CDlgBase.cpp4
-rw-r--r--src/mir_core/src/mir_core.def8
-rw-r--r--src/mir_core/src/mir_core64.def8
8 files changed, 73 insertions, 38 deletions
diff --git a/src/mir_core/src/CCtrlBase.cpp b/src/mir_core/src/CCtrlBase.cpp
index 4cb2bcdb40..800e8c693d 100644
--- a/src/mir_core/src/CCtrlBase.cpp
+++ b/src/mir_core/src/CCtrlBase.cpp
@@ -181,7 +181,9 @@ void CCtrlBase::GetCaretPos(CContextMenuPos &pos) const
{
pos.pCtrl = this;
pos.iCurr = -1;
- GetCursorPos(&pos.pt);
+
+ if (pos.pt.x == 0 && pos.pt.y == 0)
+ GetCursorPos(&pos.pt);
}
LRESULT CCtrlBase::CustomWndProc(UINT, WPARAM, LPARAM)
diff --git a/src/mir_core/src/CCtrlClc.cpp b/src/mir_core/src/CCtrlClc.cpp
index da007afe25..b5b439cdb7 100644
--- a/src/mir_core/src/CCtrlClc.cpp
+++ b/src/mir_core/src/CCtrlClc.cpp
@@ -130,7 +130,7 @@ HANDLE CCtrlClc::GetSelection() const
{ return (HANDLE)SendMessage(m_hwnd, CLM_GETSELECTION, 0, 0);
}
-HANDLE CCtrlClc::HitTest(int x, int y, DWORD *hitTest)
+HANDLE CCtrlClc::HitTest(int x, int y, DWORD *hitTest) const
{ return (HANDLE)SendMessage(m_hwnd, CLM_HITTEST, (WPARAM)hitTest, MAKELPARAM(x,y));
}
diff --git a/src/mir_core/src/CCtrlListBox.cpp b/src/mir_core/src/CCtrlListBox.cpp
index a4cbc3e796..34980c05a3 100644
--- a/src/mir_core/src/CCtrlListBox.cpp
+++ b/src/mir_core/src/CCtrlListBox.cpp
@@ -42,12 +42,15 @@ BOOL CCtrlListBox::OnCommand(HWND, WORD, WORD idCode)
void CCtrlListBox::GetCaretPos(CContextMenuPos &pos) const
{
pos.pCtrl = this;
- pos.iCurr = GetCurSel();
- if (pos.iCurr != -1) {
- RECT rc;
- GetItemRect(pos.iCurr, &rc);
- pos.pt.x = rc.left;
- pos.pt.y = rc.top;
+ if (pos.pt.x == 0 && pos.pt.y == 0) {
+ pos.iCurr = GetCurSel();
+ if (pos.iCurr != -1) {
+ RECT rc;
+ GetItemRect(pos.iCurr, &rc);
+ pos.pt.x = rc.left;
+ pos.pt.y = rc.top;
+ }
+ else CSuper::GetCaretPos(pos);
}
else CSuper::GetCaretPos(pos);
}
diff --git a/src/mir_core/src/CCtrlListView.cpp b/src/mir_core/src/CCtrlListView.cpp
index 090925d80e..0156aeab6e 100644
--- a/src/mir_core/src/CCtrlListView.cpp
+++ b/src/mir_core/src/CCtrlListView.cpp
@@ -152,14 +152,28 @@ LPARAM CCtrlListView::GetItemData(int iItem) const
void CCtrlListView::GetCaretPos(CContextMenuPos &pos) const
{
pos.pCtrl = this;
- pos.iCurr = GetSelectionMark();
- if (pos.iCurr != -1) {
- RECT rc;
- GetItemRect(pos.iCurr, &rc, TRUE);
- pos.pt.x = rc.left;
- pos.pt.y = rc.top;
+
+ // position is empty, let's fill it using selection
+ if (pos.pt.x == 0 && pos.pt.y == 0) {
+ pos.iCurr = GetSelectionMark();
+ if (pos.iCurr != -1) {
+ RECT rc;
+ GetItemRect(pos.iCurr, &rc, TRUE);
+ pos.pt.x = rc.left;
+ pos.pt.y = rc.top;
+ return;
+ }
+ }
+ // position is present, let's calculate current item
+ else {
+ LVHITTESTINFO hti;
+ hti.pt = pos.pt;
+ if (SubItemHitTest(&hti) != -1) {
+ pos.iCurr = hti.iItem;
+ return;
+ }
}
- else CSuper::GetCaretPos(pos);
+ CSuper::GetCaretPos(pos);
}
// classic api
@@ -337,7 +351,7 @@ void CCtrlListView::GetWorkAreas(INT nWorkAreas, LPRECT lprc) const
BOOL CCtrlListView::HasGroup(int dwGroupId)
{ return ListView_HasGroup(m_hwnd, dwGroupId);
}
-int CCtrlListView::HitTest(LPLVHITTESTINFO pinfo)
+int CCtrlListView::HitTest(LPLVHITTESTINFO pinfo) const
{ return ListView_HitTest(m_hwnd, pinfo);
}
int CCtrlListView::InsertColumn(int iCol, const LPLVCOLUMN pcol)
@@ -496,7 +510,7 @@ BOOL CCtrlListView::SortItems(PFNLVCOMPARE pfnCompare, LPARAM lParamSort)
BOOL CCtrlListView::SortItemsEx(PFNLVCOMPARE pfnCompare, LPARAM lParamSort)
{ return ListView_SortItemsEx(m_hwnd, pfnCompare, lParamSort);
}
-INT CCtrlListView::SubItemHitTest(LPLVHITTESTINFO pInfo)
+INT CCtrlListView::SubItemHitTest(LPLVHITTESTINFO pInfo) const
{ return ListView_SubItemHitTest(m_hwnd, pInfo);
}
BOOL CCtrlListView::Update(int iItem)
diff --git a/src/mir_core/src/CCtrlTreeView.cpp b/src/mir_core/src/CCtrlTreeView.cpp
index 565e5aee83..3edabcd61a 100644
--- a/src/mir_core/src/CCtrlTreeView.cpp
+++ b/src/mir_core/src/CCtrlTreeView.cpp
@@ -550,17 +550,33 @@ void CCtrlTreeView::Select(LIST<_TREEITEM> &selected)
void CCtrlTreeView::GetCaretPos(CContextMenuPos &pos) const
{
- HTREEITEM hItem = GetSelection();
- if (hItem != nullptr) {
- pos.pCtrl = this;
- pos.iCurr = (INT_PTR)hItem;
-
- RECT rc;
- GetItemRect(hItem, &rc, TRUE);
- pos.pt.x = rc.left;
- pos.pt.y = rc.top;
+ pos.pCtrl = this;
+
+ // position is empty, let's fill it using selection
+ if (pos.pt.x == 0 && pos.pt.y == 0) {
+ HTREEITEM hItem = GetSelection();
+ if (hItem != nullptr) {
+ pos.pCtrl = this;
+ pos.iCurr = (INT_PTR)hItem;
+
+ RECT rc;
+ GetItemRect(hItem, &rc, TRUE);
+ pos.pt.x = rc.left;
+ pos.pt.y = rc.top;
+ return;
+ }
}
- else CSuper::GetCaretPos(pos);
+ // position is present, let's calculate current item
+ else {
+ TVHITTESTINFO hti;
+ hti.pt = pos.pt;
+ if (HitTest(&hti) && (hti.flags & TVHT_ONITEM)) {
+ pos.hItem = hti.hItem;
+ return;
+ }
+ }
+
+ CSuper::GetCaretPos(pos);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -709,7 +725,7 @@ unsigned CCtrlTreeView::GetVisibleCount() const
{ return TreeView_GetVisibleCount(m_hwnd);
}
-HTREEITEM CCtrlTreeView::HitTest(TVHITTESTINFO *hti)
+HTREEITEM CCtrlTreeView::HitTest(TVHITTESTINFO *hti) const
{ return TreeView_HitTest(m_hwnd, hti);
}
diff --git a/src/mir_core/src/CDlgBase.cpp b/src/mir_core/src/CDlgBase.cpp
index 2b588dffc2..de23eec3d9 100644
--- a/src/mir_core/src/CDlgBase.cpp
+++ b/src/mir_core/src/CDlgBase.cpp
@@ -351,12 +351,12 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
case WM_CONTEXTMENU:
if (CCtrlBase *ctrl = FindControl(HWND(wParam))) {
- CContextMenuPos pos;
- ctrl->GetCaretPos(pos);
+ CContextMenuPos pos = {};
if (lParam != -1) {
pos.pt.x = GET_X_LPARAM(lParam);
pos.pt.y = GET_Y_LPARAM(lParam);
}
+ ctrl->GetCaretPos(pos);
ctrl->OnBuildMenu(&pos);
}
break;
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index dc0233e891..3441b0543f 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -697,9 +697,9 @@ mir_wstrcmpi @280
?GlobalDlgResizer@CDlgBase@@CAHPAUHWND__@@JPAUUTILRESIZECONTROL@@@Z @885 NONAME
?GlobalSubclassWndProc@CCtrlBase@@CGJPAUHWND__@@IIJ@Z @886 NONAME
?HasGroup@CCtrlListView@@QAEHH@Z @887 NONAME
-?HitTest@CCtrlClc@@QAEPAXHHPAK@Z @888 NONAME
-?HitTest@CCtrlListView@@QAEHPAUtagLVHITTESTINFO@@@Z @889 NONAME
-?HitTest@CCtrlTreeView@@QAEPAU_TREEITEM@@PAUtagTVHITTESTINFO@@@Z @890 NONAME
+?HitTest@CCtrlClc@@QBEPAXHHPAK@Z @888 NONAME
+?HitTest@CCtrlListView@@QBEHPAUtagLVHITTESTINFO@@@Z @889 NONAME
+?HitTest@CCtrlTreeView@@QBEPAU_TREEITEM@@PAUtagTVHITTESTINFO@@@Z @890 NONAME
?InsertColumn@CCtrlListView@@QAEHHQAUtagLVCOLUMNW@@@Z @891 NONAME
?InsertGroup@CCtrlListView@@QAEHHPAUtagLVGROUP@@@Z @892 NONAME
?InsertGroupSorted@CCtrlListView@@QAEXPAUtagLVINSERTGROUPSORTED@@@Z @893 NONAME
@@ -857,7 +857,7 @@ mir_wstrcmpi @280
?SortGroups@CCtrlListView@@QAEHP6GHHHPAX@Z0@Z @1056 NONAME
?SortItems@CCtrlListView@@QAEHP6GHJJJ@ZJ@Z @1057 NONAME
?SortItemsEx@CCtrlListView@@QAEHP6GHJJJ@ZJ@Z @1058 NONAME
-?SubItemHitTest@CCtrlListView@@QAEHPAUtagLVHITTESTINFO@@@Z @1059 NONAME
+?SubItemHitTest@CCtrlListView@@QBEHPAUtagLVHITTESTINFO@@@Z @1059 NONAME
?Subclass@CCtrlBase@@IAEXXZ @1060 NONAME
?ThemeDialogBackground@CDlgBase@@IAEXH@Z @1061 NONAME
?TranslateItem@CCtrlTreeView@@QAEXPAU_TREEITEM@@@Z @1062 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index f7eea3fc43..392cfa2cda 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -697,9 +697,9 @@ mir_wstrcmpi @280
?GlobalDlgResizer@CDlgBase@@CAHPEAUHWND__@@_JPEAUUTILRESIZECONTROL@@@Z @885 NONAME
?GlobalSubclassWndProc@CCtrlBase@@CA_JPEAUHWND__@@I_K_J@Z @886 NONAME
?HasGroup@CCtrlListView@@QEAAHH@Z @887 NONAME
-?HitTest@CCtrlClc@@QEAAPEAXHHPEAK@Z @888 NONAME
-?HitTest@CCtrlListView@@QEAAHPEAUtagLVHITTESTINFO@@@Z @889 NONAME
-?HitTest@CCtrlTreeView@@QEAAPEAU_TREEITEM@@PEAUtagTVHITTESTINFO@@@Z @890 NONAME
+?HitTest@CCtrlClc@@QEBAPEAXHHPEAK@Z @888 NONAME
+?HitTest@CCtrlListView@@QEBAHPEAUtagLVHITTESTINFO@@@Z @889 NONAME
+?HitTest@CCtrlTreeView@@QEBAPEAU_TREEITEM@@PEAUtagTVHITTESTINFO@@@Z @890 NONAME
?InsertColumn@CCtrlListView@@QEAAHHQEAUtagLVCOLUMNW@@@Z @891 NONAME
?InsertGroup@CCtrlListView@@QEAAHHPEAUtagLVGROUP@@@Z @892 NONAME
?InsertGroupSorted@CCtrlListView@@QEAAXPEAUtagLVINSERTGROUPSORTED@@@Z @893 NONAME
@@ -857,7 +857,7 @@ mir_wstrcmpi @280
?SortGroups@CCtrlListView@@QEAAHP6AHHHPEAX@Z0@Z @1056 NONAME
?SortItems@CCtrlListView@@QEAAHP6AH_J00@Z0@Z @1057 NONAME
?SortItemsEx@CCtrlListView@@QEAAHP6AH_J00@Z0@Z @1058 NONAME
-?SubItemHitTest@CCtrlListView@@QEAAHPEAUtagLVHITTESTINFO@@@Z @1059 NONAME
+?SubItemHitTest@CCtrlListView@@QEBAHPEAUtagLVHITTESTINFO@@@Z @1059 NONAME
?Subclass@CCtrlBase@@IEAAXXZ @1060 NONAME
?ThemeDialogBackground@CDlgBase@@IEAAXH@Z @1061 NONAME
?TranslateItem@CCtrlTreeView@@QEAAXPEAU_TREEITEM@@@Z @1062 NONAME