aboutsummaryrefslogtreecommitdiff
path: root/CPP/Windows/Control/ListView.h
diff options
context:
space:
mode:
authorIgor Pavlov <87184205+ip7z@users.noreply.github.com>2021-12-27 00:00:00 +0000
committerIgor Pavlov <87184205+ip7z@users.noreply.github.com>2022-03-18 15:35:13 +0500
commitf19f813537c7aea1c20749c914e756b54a9c3cf5 (patch)
tree816ba62ca7c0fa19f2eb46d9e9d6f7dd7c3a744d /CPP/Windows/Control/ListView.h
parent98e06a519b63b81986abe76d28887f6984a7732b (diff)
download7zip-21.07.tar.gz
7zip-21.07.tar.bz2
7zip-21.07.zip
'21.07'21.07
Diffstat (limited to 'CPP/Windows/Control/ListView.h')
-rw-r--r--CPP/Windows/Control/ListView.h147
1 files changed, 147 insertions, 0 deletions
diff --git a/CPP/Windows/Control/ListView.h b/CPP/Windows/Control/ListView.h
new file mode 100644
index 0000000..a13b104
--- /dev/null
+++ b/CPP/Windows/Control/ListView.h
@@ -0,0 +1,147 @@
1// Windows/Control/ListView.h
2
3#ifndef __WINDOWS_CONTROL_LISTVIEW_H
4#define __WINDOWS_CONTROL_LISTVIEW_H
5
6#include "../../Common/MyWindows.h"
7
8#include <CommCtrl.h>
9
10#include "../Window.h"
11
12namespace NWindows {
13namespace NControl {
14
15class CListView: public NWindows::CWindow
16{
17public:
18 bool CreateEx(DWORD exStyle, DWORD style,
19 int x, int y, int width, int height,
20 HWND parentWindow, HMENU idOrHMenu,
21 HINSTANCE instance, LPVOID createParam);
22
23 void SetUnicodeFormat()
24 {
25 #ifndef UNDER_CE
26 ListView_SetUnicodeFormat(_window, TRUE);
27 #endif
28 }
29
30 bool DeleteAllItems() { return BOOLToBool(ListView_DeleteAllItems(_window)); }
31 bool DeleteColumn(int columnIndex) { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
32
33 int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo) { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
34 int InsertColumn(int columnIndex, LPCTSTR text, int width);
35 bool SetColumnOrderArray(int count, const int *columns)
36 { return BOOLToBool(ListView_SetColumnOrderArray(_window, count, (int *)(void *)columns)); }
37
38 /*
39 int GetNumColumns()
40 {
41 HWND header = ListView_GetHeader(_window);
42 if (!header)
43 return -1;
44 return Header_GetItemCount(header);
45 }
46 */
47
48 int InsertItem(const LVITEM* item) { return ListView_InsertItem(_window, item); }
49 int InsertItem(int index, LPCTSTR text);
50 bool SetItem(const LVITEM* item) { return BOOLToBool(ListView_SetItem(_window, item)); }
51 int SetSubItem(int index, int subIndex, LPCTSTR text);
52
53 #ifndef _UNICODE
54
55 int InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo) { return (int)SendMsg(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
56 int InsertColumn(int columnIndex, LPCWSTR text, int width);
57 int InsertItem(const LV_ITEMW* item) { return (int)SendMsg(LVM_INSERTITEMW, 0, (LPARAM)item); }
58 int InsertItem(int index, LPCWSTR text);
59 bool SetItem(const LV_ITEMW* item) { return BOOLToBool((BOOL)SendMsg(LVM_SETITEMW, 0, (LPARAM)item)); }
60 int SetSubItem(int index, int subIndex, LPCWSTR text);
61
62 #endif
63
64 bool DeleteItem(int itemIndex) { return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); }
65
66 UINT GetSelectedCount() const { return ListView_GetSelectedCount(_window); }
67 int GetItemCount() const { return ListView_GetItemCount(_window); }
68
69 INT GetSelectionMark() const { return ListView_GetSelectionMark(_window); }
70
71 void SetItemCount(int numItems) { ListView_SetItemCount(_window, numItems); }
72 void SetItemCountEx(int numItems, DWORD flags) { ListView_SetItemCountEx(_window, numItems, flags); }
73
74 int GetNextItem(int startIndex, UINT flags) const { return ListView_GetNextItem(_window, startIndex, flags); }
75 int GetNextSelectedItem(int startIndex) const { return GetNextItem(startIndex, LVNI_SELECTED); }
76 int GetFocusedItem() const { return GetNextItem(-1, LVNI_FOCUSED); }
77
78 bool GetItem(LVITEM* item) const { return BOOLToBool(ListView_GetItem(_window, item)); }
79 bool GetItemParam(int itemIndex, LPARAM &param) const;
80 void GetItemText(int itemIndex, int subItemIndex, LPTSTR text, int textSizeMax) const
81 { ListView_GetItemText(_window, itemIndex, subItemIndex, text, textSizeMax); }
82 bool SortItems(PFNLVCOMPARE compareFunction, LPARAM dataParam)
83 { return BOOLToBool(ListView_SortItems(_window, compareFunction, dataParam)); }
84
85 void SetItemState(int index, UINT state, UINT mask) { ListView_SetItemState(_window, index, state, mask); }
86 void SetItemState_Selected(int index, bool select) { SetItemState(index, select ? LVIS_SELECTED : 0, LVIS_SELECTED); }
87 void SetItemState_Selected(int index) { SetItemState(index, LVIS_SELECTED, LVIS_SELECTED); }
88 void SelectAll() { SetItemState_Selected(-1); }
89 void SetItemState_FocusedSelected(int index) { SetItemState(index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); }
90 UINT GetItemState(int index, UINT mask) const { return ListView_GetItemState(_window, index, mask); }
91 bool IsItemSelected(int index) const { return GetItemState(index, LVIS_SELECTED) == LVIS_SELECTED; }
92
93 bool GetColumn(int columnIndex, LVCOLUMN* columnInfo) const
94 { return BOOLToBool(ListView_GetColumn(_window, columnIndex, columnInfo)); }
95
96 HIMAGELIST SetImageList(HIMAGELIST imageList, int imageListType)
97 { return ListView_SetImageList(_window, imageList, imageListType); }
98
99 // version 4.70: NT5 | (NT4 + ie3) | w98 | (w95 + ie3)
100 DWORD GetExtendedListViewStyle() { return ListView_GetExtendedListViewStyle(_window); }
101 void SetExtendedListViewStyle(DWORD exStyle) { ListView_SetExtendedListViewStyle(_window, exStyle); }
102 void SetExtendedListViewStyle(DWORD exMask, DWORD exStyle) { ListView_SetExtendedListViewStyleEx(_window, exMask, exStyle); }
103
104 void SetCheckState(UINT index, bool checkState) { ListView_SetCheckState(_window, index, BoolToBOOL(checkState)); }
105 bool GetCheckState(UINT index) { return BOOLToBool(ListView_GetCheckState(_window, index)); }
106
107 bool EnsureVisible(int index, bool partialOK) { return BOOLToBool(ListView_EnsureVisible(_window, index, BoolToBOOL(partialOK))); }
108
109 bool GetItemRect(int index, RECT *rect, int code) { return BOOLToBool(ListView_GetItemRect(_window, index, rect, code)); }
110
111 HWND GetEditControl() { return ListView_GetEditControl(_window) ; }
112 HWND EditLabel(int itemIndex) { return ListView_EditLabel(_window, itemIndex) ; }
113
114 bool RedrawItems(int firstIndex, int lastIndex) { return BOOLToBool(ListView_RedrawItems(_window, firstIndex, lastIndex)); }
115 bool RedrawAllItems()
116 {
117 if (GetItemCount() > 0)
118 return RedrawItems(0, GetItemCount() - 1);
119 return true;
120 }
121 bool RedrawItem(int index) { return RedrawItems(index, index); }
122
123 int HitTest(LPLVHITTESTINFO info) { return ListView_HitTest(_window, info); }
124 COLORREF GetBkColor() { return ListView_GetBkColor(_window); }
125 bool SetColumnWidth(int iCol, int cx) { return BOOLToBool(ListView_SetColumnWidth(_window, iCol, cx)); }
126 bool SetColumnWidthAuto(int iCol) { return SetColumnWidth(iCol, LVSCW_AUTOSIZE); }
127};
128
129class CListView2: public CListView
130{
131 WNDPROC _origWindowProc;
132public:
133 void SetWindowProc();
134 virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
135};
136
137/*
138class CListView3: public CListView2
139{
140public:
141 virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
142};
143*/
144
145}}
146
147#endif