]> cygwin.com Git - cygwin-apps/setup.git/blame - ListView.h
Suppress bogus free-nonheap-object warning in iniparse.cc
[cygwin-apps/setup.git] / ListView.h
CommitLineData
ce9f6dd0
JT
1/*
2 * Copyright (c) 2016 Jon Turney
3 *
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.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 */
13
14#ifndef SETUP_LISTVIEW_H
15#define SETUP_LISTVIEW_H
16
4018914c 17#include "ActionList.h"
ce9f6dd0 18#include "win32.h"
68487c7c 19#include <commctrl.h>
ce9f6dd0
JT
20#include <vector>
21
22// ---------------------------------------------------------------------------
23// interface to class ListView
24//
25// ListView Common Control
26// ---------------------------------------------------------------------------
27
28class ListViewLine
29{
30 public:
db1c5abc
JT
31 enum class State { collapsed, expanded, nothing=-1 };
32
ce9f6dd0 33 virtual ~ListViewLine() {};
f34a20e7 34 virtual const std::wstring get_text(int col) const = 0;
db1c5abc 35 virtual State get_state() const = 0;
800274fd 36 virtual const std::string get_tooltip(int col) const = 0;
68487c7c 37 virtual int get_indent() const = 0;
4018914c
JT
38 virtual ActionList *get_actions(int col) const = 0;
39 virtual int do_action(int col, int id) = 0;
76dc99c1 40 virtual int do_default_action(int col) = 0;
22e01f51 41 virtual bool map_key_to_action(WORD vkey, int *col_num, int *action_id) const = 0;
ce9f6dd0
JT
42};
43
44typedef std::vector<ListViewLine *> ListViewContents;
45
46class ListView
47{
48 public:
61183f15
JT
49 enum class ControlType
50 {
51 text,
52 checkbox,
4018914c 53 popup,
61183f15
JT
54 };
55
ce9f6dd0
JT
56 class Header
57 {
58 public:
6ddcf16b 59 unsigned int text; // resource id of header text
ce9f6dd0 60 int fmt;
61183f15 61 ControlType type;
ce9f6dd0
JT
62 int width;
63 int hdr_width;
64 };
65 typedef Header *HeaderList;
66
67 void init(HWND parent, int id, HeaderList headers);
68
69 void noteColumnWidthStart();
35ee780b
JT
70 template <typename T>
71 void noteColumnWidth(int col_num, const T& string);
ce9f6dd0
JT
72 void noteColumnWidthEnd();
73 void resizeColumns(void);
74
68487c7c 75 void setContents(ListViewContents *contents, bool tree = false);
7f85e280 76 void setEmptyText(unsigned int text);
ce9f6dd0
JT
77
78 bool OnNotify (NMHDR *pNmHdr, LRESULT *pResult);
79
80 private:
81 HWND hWndParent;
82 HWND hWndListView;
800274fd 83 HWND hWndTip;
ce9f6dd0 84 HDC dc;
68487c7c
JT
85 HIMAGELIST hImgList;
86 HIMAGELIST hEmptyImgList;
87
ce9f6dd0
JT
88 ListViewContents *contents;
89 HeaderList headers;
7f85e280 90 std::wstring empty_list_text;
800274fd
JT
91 int iRow_track;
92 int iCol_track;
ce9f6dd0
JT
93
94 void initColumns(HeaderList hl);
95 void empty(void);
4018914c 96 int popup_menu(int iRow, int iCol, POINT p);
ce9f6dd0
JT
97};
98
99#endif /* SETUP_LISTVIEW_H */
This page took 0.065346 seconds and 5 git commands to generate.