1370b324cSopenharmony_ci// Windows/Control/ListView.h
2370b324cSopenharmony_ci
3370b324cSopenharmony_ci#ifndef ZIP7_INC_WINDOWS_CONTROL_LISTVIEW_H
4370b324cSopenharmony_ci#define ZIP7_INC_WINDOWS_CONTROL_LISTVIEW_H
5370b324cSopenharmony_ci
6370b324cSopenharmony_ci#include "../../Common/MyWindows.h"
7370b324cSopenharmony_ci
8370b324cSopenharmony_ci#include <CommCtrl.h>
9370b324cSopenharmony_ci
10370b324cSopenharmony_ci#include "../Window.h"
11370b324cSopenharmony_ci
12370b324cSopenharmony_cinamespace NWindows {
13370b324cSopenharmony_cinamespace NControl {
14370b324cSopenharmony_ci
15370b324cSopenharmony_ciclass CListView: public NWindows::CWindow
16370b324cSopenharmony_ci{
17370b324cSopenharmony_cipublic:
18370b324cSopenharmony_ci  bool CreateEx(DWORD exStyle, DWORD style,
19370b324cSopenharmony_ci      int x, int y, int width, int height,
20370b324cSopenharmony_ci      HWND parentWindow, HMENU idOrHMenu,
21370b324cSopenharmony_ci      HINSTANCE instance, LPVOID createParam);
22370b324cSopenharmony_ci
23370b324cSopenharmony_ci  void SetUnicodeFormat()
24370b324cSopenharmony_ci  {
25370b324cSopenharmony_ci    #ifndef UNDER_CE
26370b324cSopenharmony_ci    ListView_SetUnicodeFormat(_window, TRUE);
27370b324cSopenharmony_ci    #endif
28370b324cSopenharmony_ci  }
29370b324cSopenharmony_ci
30370b324cSopenharmony_ci  bool DeleteAllItems() { return BOOLToBool(ListView_DeleteAllItems(_window)); }
31370b324cSopenharmony_ci  bool DeleteColumn(unsigned columnIndex) { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
32370b324cSopenharmony_ci
33370b324cSopenharmony_ci  int InsertColumn(unsigned columnIndex, const LVCOLUMN *columnInfo) { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
34370b324cSopenharmony_ci  int InsertColumn(unsigned columnIndex, LPCTSTR text, int width);
35370b324cSopenharmony_ci  bool SetColumnOrderArray(unsigned count, const int *columns)
36370b324cSopenharmony_ci    { return BOOLToBool(ListView_SetColumnOrderArray(_window, count, (int *)(void *)columns)); }
37370b324cSopenharmony_ci
38370b324cSopenharmony_ci  /*
39370b324cSopenharmony_ci  int GetNumColumns()
40370b324cSopenharmony_ci  {
41370b324cSopenharmony_ci    HWND header = ListView_GetHeader(_window);
42370b324cSopenharmony_ci    if (!header)
43370b324cSopenharmony_ci      return -1;
44370b324cSopenharmony_ci    return Header_GetItemCount(header);
45370b324cSopenharmony_ci  }
46370b324cSopenharmony_ci  */
47370b324cSopenharmony_ci
48370b324cSopenharmony_ci  int InsertItem(const LVITEM* item) { return ListView_InsertItem(_window, item); }
49370b324cSopenharmony_ci  int InsertItem(unsigned index, LPCTSTR text);
50370b324cSopenharmony_ci  bool SetItem(const LVITEM* item) { return BOOLToBool(ListView_SetItem(_window, item)); }
51370b324cSopenharmony_ci  int SetSubItem(unsigned index, unsigned subIndex, LPCTSTR text);
52370b324cSopenharmony_ci
53370b324cSopenharmony_ci  #ifndef _UNICODE
54370b324cSopenharmony_ci
55370b324cSopenharmony_ci  int InsertColumn(unsigned columnIndex, const LVCOLUMNW *columnInfo) { return (int)SendMsg(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
56370b324cSopenharmony_ci  int InsertColumn(unsigned columnIndex, LPCWSTR text, int width);
57370b324cSopenharmony_ci  int InsertItem(const LV_ITEMW* item) { return (int)SendMsg(LVM_INSERTITEMW, 0, (LPARAM)item); }
58370b324cSopenharmony_ci  int InsertItem(unsigned index, LPCWSTR text);
59370b324cSopenharmony_ci  bool SetItem(const LV_ITEMW* item) { return BOOLToBool((BOOL)SendMsg(LVM_SETITEMW, 0, (LPARAM)item)); }
60370b324cSopenharmony_ci  int SetSubItem(unsigned index, unsigned subIndex, LPCWSTR text);
61370b324cSopenharmony_ci
62370b324cSopenharmony_ci  #endif
63370b324cSopenharmony_ci
64370b324cSopenharmony_ci  bool DeleteItem(unsigned itemIndex) { return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); }
65370b324cSopenharmony_ci
66370b324cSopenharmony_ci  UINT GetSelectedCount() const { return ListView_GetSelectedCount(_window); }
67370b324cSopenharmony_ci  int GetItemCount() const { return ListView_GetItemCount(_window); }
68370b324cSopenharmony_ci
69370b324cSopenharmony_ci  INT GetSelectionMark() const { return ListView_GetSelectionMark(_window); }
70370b324cSopenharmony_ci
71370b324cSopenharmony_ci  void SetItemCount(unsigned numItems) { ListView_SetItemCount(_window, numItems); }
72370b324cSopenharmony_ci  void SetItemCountEx(unsigned numItems, DWORD flags) {  ListView_SetItemCountEx(_window, numItems, flags); }
73370b324cSopenharmony_ci
74370b324cSopenharmony_ci  /* startIndex : The index of the item with which to begin the search,
75370b324cSopenharmony_ci     or -1 to find the first item that matches the specified flags.
76370b324cSopenharmony_ci     The specified item itself is excluded from the search. */
77370b324cSopenharmony_ci  int GetNextItem(int startIndex, UINT flags) const { return ListView_GetNextItem(_window, startIndex, flags); }
78370b324cSopenharmony_ci  int GetNextSelectedItem(int startIndex) const { return GetNextItem(startIndex, LVNI_SELECTED); }
79370b324cSopenharmony_ci  int GetFocusedItem() const { return GetNextItem(-1, LVNI_FOCUSED); }
80370b324cSopenharmony_ci
81370b324cSopenharmony_ci  bool GetItem(LVITEM* item) const { return BOOLToBool(ListView_GetItem(_window, item)); }
82370b324cSopenharmony_ci  bool GetItemParam(unsigned itemIndex, LPARAM &param) const;
83370b324cSopenharmony_ci  /*
84370b324cSopenharmony_ci  void GetItemText(unsigned itemIndex, unsigned subItemIndex, LPTSTR text, unsigned textSizeMax) const
85370b324cSopenharmony_ci    { ListView_GetItemText(_window, itemIndex, subItemIndex, text, textSizeMax) }
86370b324cSopenharmony_ci  */
87370b324cSopenharmony_ci  bool SortItems(PFNLVCOMPARE compareFunction, LPARAM dataParam)
88370b324cSopenharmony_ci    { return BOOLToBool(ListView_SortItems(_window, compareFunction, dataParam)); }
89370b324cSopenharmony_ci
90370b324cSopenharmony_ci  // If (index == -1), then the state change is applied to all items.
91370b324cSopenharmony_ci  void SetItemState(int index, UINT state, UINT mask) { ListView_SetItemState(_window, index, state, mask) }
92370b324cSopenharmony_ci  void SetItemState_Selected(int index, bool select) { SetItemState(index, select ? LVIS_SELECTED : 0, LVIS_SELECTED); }
93370b324cSopenharmony_ci  void SetItemState_Selected(int index) { SetItemState(index, LVIS_SELECTED, LVIS_SELECTED); }
94370b324cSopenharmony_ci  void SelectAll() { SetItemState_Selected(-1); }
95370b324cSopenharmony_ci  void SetItemState_FocusedSelected(int index) { SetItemState(index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); }
96370b324cSopenharmony_ci  UINT GetItemState(int index, UINT mask) const { return ListView_GetItemState(_window, index, mask); }
97370b324cSopenharmony_ci  bool IsItemSelected(int index) const { return GetItemState(index, LVIS_SELECTED) == LVIS_SELECTED; }
98370b324cSopenharmony_ci
99370b324cSopenharmony_ci  bool GetColumn(unsigned columnIndex, LVCOLUMN* columnInfo) const
100370b324cSopenharmony_ci    { return BOOLToBool(ListView_GetColumn(_window, columnIndex, columnInfo)); }
101370b324cSopenharmony_ci
102370b324cSopenharmony_ci  HIMAGELIST SetImageList(HIMAGELIST imageList, int imageListType)
103370b324cSopenharmony_ci    { return ListView_SetImageList(_window, imageList, imageListType); }
104370b324cSopenharmony_ci
105370b324cSopenharmony_ci  // version 4.70: NT5 | (NT4 + ie3) | w98 | (w95 + ie3)
106370b324cSopenharmony_ci  DWORD GetExtendedListViewStyle() { return ListView_GetExtendedListViewStyle(_window); }
107370b324cSopenharmony_ci  void SetExtendedListViewStyle(DWORD exStyle) { ListView_SetExtendedListViewStyle(_window, exStyle); }
108370b324cSopenharmony_ci  void SetExtendedListViewStyle(DWORD exMask, DWORD exStyle) { ListView_SetExtendedListViewStyleEx(_window, exMask, exStyle); }
109370b324cSopenharmony_ci
110370b324cSopenharmony_ci  void SetCheckState(UINT index, bool checkState) { ListView_SetCheckState(_window, index, BoolToBOOL(checkState)) }
111370b324cSopenharmony_ci  bool GetCheckState(UINT index) { return BOOLToBool(ListView_GetCheckState(_window, index)); }
112370b324cSopenharmony_ci
113370b324cSopenharmony_ci  bool EnsureVisible(int index, bool partialOK) { return BOOLToBool(ListView_EnsureVisible(_window, index, BoolToBOOL(partialOK))); }
114370b324cSopenharmony_ci
115370b324cSopenharmony_ci  bool GetItemRect(int index, RECT *rect, int code) { return BOOLToBool(ListView_GetItemRect(_window, index, rect, code)); }
116370b324cSopenharmony_ci
117370b324cSopenharmony_ci  HWND GetEditControl() { return ListView_GetEditControl(_window) ; }
118370b324cSopenharmony_ci  HWND EditLabel(int itemIndex) { return ListView_EditLabel(_window, itemIndex) ; }
119370b324cSopenharmony_ci
120370b324cSopenharmony_ci  bool RedrawItems(int firstIndex, int lastIndex) { return BOOLToBool(ListView_RedrawItems(_window, firstIndex, lastIndex)); }
121370b324cSopenharmony_ci  bool RedrawAllItems()
122370b324cSopenharmony_ci  {
123370b324cSopenharmony_ci    if (GetItemCount() > 0)
124370b324cSopenharmony_ci      return RedrawItems(0, GetItemCount() - 1);
125370b324cSopenharmony_ci    return true;
126370b324cSopenharmony_ci  }
127370b324cSopenharmony_ci  bool RedrawItem(int index) { return RedrawItems(index, index); }
128370b324cSopenharmony_ci
129370b324cSopenharmony_ci  int HitTest(LPLVHITTESTINFO info) { return ListView_HitTest(_window, info); }
130370b324cSopenharmony_ci  COLORREF GetBkColor() { return ListView_GetBkColor(_window); }
131370b324cSopenharmony_ci  bool SetColumnWidth(int iCol, int cx) { return BOOLToBool(ListView_SetColumnWidth(_window, iCol, cx)); }
132370b324cSopenharmony_ci  bool SetColumnWidthAuto(int iCol) { return SetColumnWidth(iCol, LVSCW_AUTOSIZE); }
133370b324cSopenharmony_ci};
134370b324cSopenharmony_ci
135370b324cSopenharmony_ciclass CListView2: public CListView
136370b324cSopenharmony_ci{
137370b324cSopenharmony_ci  WNDPROC _origWindowProc;
138370b324cSopenharmony_ci  // ~CListView2() ZIP7_eq_delete;
139370b324cSopenharmony_cipublic:
140370b324cSopenharmony_ci  virtual ~CListView2() {}
141370b324cSopenharmony_ci  CListView2() {}
142370b324cSopenharmony_ci  void SetWindowProc();
143370b324cSopenharmony_ci  virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
144370b324cSopenharmony_ci};
145370b324cSopenharmony_ci
146370b324cSopenharmony_ci/*
147370b324cSopenharmony_ciclass CListView3: public CListView2
148370b324cSopenharmony_ci{
149370b324cSopenharmony_cipublic:
150370b324cSopenharmony_ci  virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
151370b324cSopenharmony_ci};
152370b324cSopenharmony_ci*/
153370b324cSopenharmony_ci
154370b324cSopenharmony_ci}}
155370b324cSopenharmony_ci
156370b324cSopenharmony_ci#endif
157