File: jcsTree.h

package info (click to toggle)
mriconvert 1%3A2.1.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,488 kB
  • sloc: cpp: 17,029; makefile: 11
file content (93 lines) | stat: -rw-r----- 2,089 bytes parent folder | download | duplicates (5)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/// jcsTree.h
/**
*/

#ifndef JCS_TREE_H
#define JCS_TREE_H

#include <wx/treectrl.h>

#include <string>
#include <map>

class jcsTreeItemData : public wxTreeItemData
{
public:

	jcsTreeItemData(const std::string& uid, int itemType)
	: mUid(uid), mItemType(itemType) {}

	int GetItemType() const { return mItemType; }
	const std::string& GetUid() const { return mUid; }
	const std::string& GetSeriesUid() const { return mSeriesUid; }
	void SetSeriesUid(const std::string& uid) { mSeriesUid = uid; }
	const std::string& GetPrefix() const { return mPrefix; }
	void SetPrefix(const std::string& prefix) { mPrefix = prefix; }

private:

	jcsTreeItemData() {}
	std::string mSeriesUid; // only used for output files
	std::string mPrefix;    // also only for output files
	std::string mUid;
	int mItemType;

};


class jcsTreeCtrl : public wxTreeCtrl
{
public:

	jcsTreeCtrl(wxWindow* parent, wxWindowID id, long style,
	const char* root);

	int GetItemType(const wxTreeItemId& item) const;
	int GetSelectionType() const;
	const std::string GetItemUid(const wxTreeItemId& item) const;
	wxString GetStringSelection() const;
	wxString GetStringSelection(const wxTreeItemId& item) const;
	std::string GetSelectionUid() const;
	wxTreeItemId GetTreeId(std::string uid) const;
	const std::string GetSeriesUid(const wxTreeItemId& item) const;
	const std::string GetPrefix(const wxTreeItemId& item) const;

	bool IsChild(const wxTreeItemId& item, 
	const wxTreeItemId& parent) const;

	void Reset();
	void RemoveBranch(wxTreeItemId branch);
	bool IsMultiple() const;
	int GetSelected(wxArrayTreeItemIds& selecteds) const;

protected:

	//Maps unique id's to tree item id's
	typedef std::map<std::string, wxTreeItemId> jcsTreeMap;
	jcsTreeMap mTreeMap;

private:

	bool HasVisibleRoot();
	void mRemoveFromMap(wxTreeItemId branch);
	void CreateImageList(int size = 16);
	long mStyle;
};

enum {
	dtROOT,
	dtSUBJECT,
	dtSTUDY,
	dtSERIES,
	dtFILE
};


enum {
	folder_icon,
	open_folder_icon,
	file_icon
};

#endif