summaryrefslogtreecommitdiff
path: root/src/mir_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/mir_core')
-rw-r--r--src/mir_core/src/CCtrlCombo.cpp17
-rw-r--r--src/mir_core/src/CCtrlListView.cpp31
-rw-r--r--src/mir_core/src/mir_core.def3
-rw-r--r--src/mir_core/src/mir_core64.def3
4 files changed, 54 insertions, 0 deletions
diff --git a/src/mir_core/src/CCtrlCombo.cpp b/src/mir_core/src/CCtrlCombo.cpp
index 39e82949f6..a7abf1d707 100644
--- a/src/mir_core/src/CCtrlCombo.cpp
+++ b/src/mir_core/src/CCtrlCombo.cpp
@@ -76,6 +76,23 @@ void CCtrlCombo::OnReset()
SetInt(LoadInt());
}
+// selects line with userdata passed
+int CCtrlCombo::SelectData(LPARAM data)
+{
+ int ret = -1, nCount = GetCount();
+
+ for (int i = 0; i < nCount; i++)
+ if (GetItemData(i) == data) {
+ ret = i;
+ break;
+ }
+
+ return SetCurSel(ret);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Windows API
+
int CCtrlCombo::AddString(const wchar_t *text, LPARAM data)
{
int iItem = SendMessage(m_hwnd, CB_ADDSTRING, 0, (LPARAM)text);
diff --git a/src/mir_core/src/CCtrlListView.cpp b/src/mir_core/src/CCtrlListView.cpp
index ec0995e4d2..9ef8687bc6 100644
--- a/src/mir_core/src/CCtrlListView.cpp
+++ b/src/mir_core/src/CCtrlListView.cpp
@@ -75,6 +75,37 @@ BOOL CCtrlListView::OnNotify(int, NMHDR *pnmh)
return FALSE;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static int CALLBACK LVMoveSortProc(LPARAM l1, LPARAM l2, LPARAM param)
+{
+ int result = l1 - l2;
+ int newItem = HIWORD(param);
+ int oldItem = LOWORD(param);
+ if (newItem > oldItem)
+ return (l1 == oldItem && l2 <= newItem) ? 1 : result;
+
+ return (l2 == oldItem && l1 >= newItem) ? 1 : result;
+}
+
+int CCtrlListView::MoveItem(int idx, int direction)
+{
+ if ((direction > 0 && idx >= GetItemCount() - 1) || (direction < 0 && idx <= 0))
+ return idx;
+
+ if (idx < 0)
+ idx = GetNextItem(-1, LVNI_FOCUSED);
+ SortItemsEx(&LVMoveSortProc, MAKELONG(idx, idx + direction));
+ return idx + direction;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void CCtrlListView::SetCurSel(int idx)
+{
+ SetItemState(idx, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
+}
+
// additional api
HIMAGELIST CCtrlListView::CreateImageList(int iImageList)
{
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index 3441b0543f..a895c2f6c6 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1501,3 +1501,6 @@ TimeZone_GetSystemTime @1692
?GetCaretPos@CCtrlListBox@@MBEXAAUCContextMenuPos@@@Z @1724 NONAME
?GetCaretPos@CCtrlListView@@MBEXAAUCContextMenuPos@@@Z @1725 NONAME
?GetCaretPos@CCtrlTreeView@@MBEXAAUCContextMenuPos@@@Z @1726 NONAME
+?MoveItem@CCtrlListView@@QAEHHH@Z @1727 NONAME
+?SelectData@CCtrlCombo@@QAEHJ@Z @1728 NONAME
+?SetCurSel@CCtrlListView@@QAEXH@Z @1729 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index 392cfa2cda..9e6cf832e4 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1501,3 +1501,6 @@ TimeZone_GetSystemTime @1692
?GetCaretPos@CCtrlListBox@@MEBAXAEAUCContextMenuPos@@@Z @1724 NONAME
?GetCaretPos@CCtrlListView@@MEBAXAEAUCContextMenuPos@@@Z @1725 NONAME
?GetCaretPos@CCtrlTreeView@@MEBAXAEAUCContextMenuPos@@@Z @1726 NONAME
+?MoveItem@CCtrlListView@@QEAAHHH@Z @1727 NONAME
+?SelectData@CCtrlCombo@@QEAAH_J@Z @1728 NONAME
+?SetCurSel@CCtrlListView@@QEAAXH@Z @1729 NONAME