-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathtreeview.hpp
64 lines (48 loc) · 1.42 KB
/
treeview.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once
#include "native.hpp"
#include "widget.hpp"
#include <vector>
namespace firefly
{
typedef std::function<void(bool)> treeview_function_t;
enum class tree_level
{
root,
parent,
child
};
struct treeview_param
{
HTREEITEM tree_item;
bool is_editable;
bool has_checkbox;
treeview_function_t on_check_function;
};
class treeview : public widget
{
void initialize();
public:
treeview(window& parent_window);
treeview(widget& parent_widget);
~treeview();
HTREEITEM add_item(std::string const& caption, tree_level level, bool is_editable = false, bool has_checkbox = false, treeview_function_t on_check_function = [](bool) -> void { });
bool remove_item(HTREEITEM tree_item);
bool clear_items();
void create(rectangle& rect = rectangle(), bool has_checkboxes = false);
private:
bool delete_item(HTREEITEM tree_item);
bool has_children(HTREEITEM tree_item);
void traverse_all_nodes(HTREEITEM tree_item, std::vector<std::pair<HTREEITEM, int>>& treeview_nodes, int level = 0, std::function<bool(HTREEITEM)> validate_func = [](HTREEITEM) -> bool { return true; });
private:
void set_default_message_handlers();
LRESULT try_custom_draw_item(NMTVCUSTOMDRAW* custom_draw);
private:
bool has_checkboxes;
HFONT root_font;
HTREEITEM prev_tree_item;
HTREEITEM prev_root_item;
HTREEITEM prev_child_item;
HBITMAP collapsed_button_image;
HBITMAP collapsible_button_image;
};
}