Translated using Weblate (Chinese (Simplified))
[cygwin-setup.git] / ListView.h
blob6a1be0b58decb86e4788f5102904414361ef463e
1 /*
2 * Copyright (c) 2016 Jon Turney
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
14 #ifndef SETUP_LISTVIEW_H
15 #define SETUP_LISTVIEW_H
17 #include "ActionList.h"
18 #include "win32.h"
19 #include <commctrl.h>
20 #include <vector>
22 // ---------------------------------------------------------------------------
23 // interface to class ListView
25 // ListView Common Control
26 // ---------------------------------------------------------------------------
28 struct ModifierKeys
30 enum { Shift = 0x01, Control = 0x02, Alt = 0x04 };
31 static int get(); // get bitmask of currently pressed keys
34 class ListViewLine
36 public:
37 enum class State { collapsed, expanded, nothing=-1 };
38 enum Action { None = 0x00, Direct = 0x01, PopUp = 0x02, NextRow = 0x04 };
40 virtual ~ListViewLine() {};
41 virtual const std::wstring get_text(int col) const = 0;
42 virtual State get_state() const = 0;
43 virtual const std::string get_tooltip(int col) const = 0;
44 virtual int get_indent() const = 0;
45 virtual ActionList *get_actions(int col) const = 0;
46 virtual int do_action(int col, int id) = 0;
47 virtual int do_default_action(int col) = 0;
48 virtual int map_key_to_action(WORD vkey, int modkeys, int & col_num,
49 int & action_id) const = 0;
52 typedef std::vector<ListViewLine *> ListViewContents;
54 class ListView
56 public:
57 enum class ControlType
59 text,
60 checkbox,
61 popup,
64 class Header
66 public:
67 unsigned int text; // resource id of header text
68 int fmt;
69 ControlType type;
70 int width;
71 int hdr_width;
73 typedef Header *HeaderList;
75 void init(HWND parent, int id, HeaderList headers);
77 void noteColumnWidthStart();
78 template <typename T>
79 void noteColumnWidth(int col_num, const T& string);
80 void noteColumnWidthEnd();
81 void resizeColumns(void);
83 void setContents(ListViewContents *contents, bool tree = false);
84 void setEmptyText(unsigned int text);
86 bool OnNotify (NMHDR *pNmHdr, LRESULT *pResult);
88 private:
89 HWND hWndParent;
90 HWND hWndListView;
91 HWND hWndTip;
92 HDC dc;
93 HIMAGELIST hImgList;
94 HIMAGELIST hEmptyImgList;
96 ListViewContents *contents;
97 HeaderList headers;
98 std::wstring empty_list_text;
99 int iRow_track;
100 int iCol_track;
102 void initColumns(HeaderList hl);
103 void empty(void);
104 int popup_menu(int iRow, int iCol, POINT p);
107 #endif /* SETUP_LISTVIEW_H */