File: component_node.h

package info (click to toggle)
clanlib 0.5.4-1-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 10,320 kB
  • ctags: 10,893
  • sloc: cpp: 76,056; xml: 3,281; sh: 2,961; perl: 1,204; asm: 837; makefile: 775
file content (86 lines) | stat: -rw-r--r-- 1,992 bytes parent folder | download
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

#ifndef header_component_node
#define header_component_node

#ifdef WIN32
#pragma warning(disable : 4786)
#endif

#include <list>
#include <string>
#include <ClanLib/GUI/component_options.h>
class Document;
class CL_ComponentType;

class ComponentNode
{
//!Construction:
private:
	//: Construct node with other node as parent.
	ComponentNode(const std::string &name, const std::string &type, const CL_ComponentOptions &options, ComponentNode *parent);

	//: Construct node with document as parent.
	ComponentNode(const std::string &name, const std::string &type, const CL_ComponentOptions &options, Document *parent);

	//: Destructor.
	~ComponentNode();

//!Attributes:
public:
	//: Options attached to this component.
	const CL_ComponentOptions &get_options() const;

	//: Name of the component, if any.
	const std::string &get_name() const { return name; }

	//: Component type. Eg. "button" or "window".
	const std::string &get_type() const;

	//: List of child components of this component.
	std::list<ComponentNode *> nodes;

	//: Finds and returns the component type object for this
	//: component. If not found, null is returned.
	CL_ComponentType *find_component_type();

	//: Get document the node belongs to.
	Document *get_document();

	ComponentNode *get_parent() { return parent; }

//!Operations:
public:
	//: Change the options for this component.
	void set_options(const CL_ComponentOptions &options);

	//: Change component type.
	void set_type(const std::string &type);

	//: Add child component to node.
	ComponentNode *add_node(const std::string &type);

	//: Remove child component from node.
	void remove_node(ComponentNode *node);

//!Implementation:
private:
	//: Allow construction from document.
	friend Document;

	//: Parent node, if any.
	ComponentNode *parent;

	//: Document owner.
	Document *document;

	//: Component name, if any.
	std::string name;

	//: Component type.
	std::string type;

	//: Component options.
	CL_ComponentOptions options;
};

#endif