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
14 #ifndef SETUP_LISTVIEW_H
15 #define SETUP_LISTVIEW_H
17 #include "ActionList.h"
22 // ---------------------------------------------------------------------------
23 // interface to class ListView
25 // ListView Common Control
26 // ---------------------------------------------------------------------------
30 enum { Shift
= 0x01, Control
= 0x02, Alt
= 0x04 };
31 static int get(); // get bitmask of currently pressed keys
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
;
57 enum class ControlType
67 unsigned int text
; // resource id of header text
73 typedef Header
*HeaderList
;
75 void init(HWND parent
, int id
, HeaderList headers
);
77 void noteColumnWidthStart();
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
);
94 HIMAGELIST hEmptyImgList
;
96 ListViewContents
*contents
;
98 std::wstring empty_list_text
;
102 void initColumns(HeaderList hl
);
104 int popup_menu(int iRow
, int iCol
, POINT p
);
107 #endif /* SETUP_LISTVIEW_H */