1 #include "FormObject.hpp"
2 
FormObject()3 FormObject::FormObject() : _Rect(Rect(Point(10, 10), Size(120, 30))), _HAlign(Ctrl::LEFT),
4 	_VAlign(Ctrl::TOP), _State(FormObject::NONE)
5 {
6 	Name = "Noname";
7 	Set("Variable", "None");
8 	Set("Frame", "Default frame");
9 }
10 
FormObject(const FormObject & other)11 FormObject::FormObject(const FormObject& other)
12 {
13 	*this   = other;
14 	_Rect   = other.GetRect();
15 	_State  = other.GetState();
16 	_HAlign = other.GetHAlign();
17 	_VAlign = other.GetVAlign();
18 }
19 
FormObject(const Rect & r)20 FormObject::FormObject(const Rect& r)
21 	: _Rect(r), _HAlign(Ctrl::LEFT), _VAlign(Ctrl::TOP), _State(FormObject::NONE)
22 {
23 	Name = "Noname";
24 	Set("Variable", "None");
25 	Set("Frame", "Default frame");
26 }
27 
FormObject(int x,int y,int cx,int cy)28 FormObject::FormObject(int x, int y, int cx, int cy) : _Rect(Rect(Point(x, y), Size(cx, cy))),
29 	_HAlign(Ctrl::LEFT), _VAlign(Ctrl::TOP), _State(FormObject::NONE)
30 {
31 	Name = "Noname";
32 	Set("Variable", "None");
33 	Set("Frame", "Default frame");
34 }
35 
Xmlize(XmlIO xml)36 void FormObject::Xmlize(XmlIO xml)
37 {
38 	xml.Attr("x", _Rect.left).Attr("y", _Rect.top);
39 
40 	int cx = _Rect.Width();
41 	int cy = _Rect.Height();
42 
43 	xml.Attr("cx", cx).Attr("cy", cy);
44 
45 	if (xml.IsLoading())
46 	{
47 		_Rect.right = _Rect.left + cx;
48 		_Rect.bottom = _Rect.top + cy;
49 	}
50 
51 	xml.Attr("align", _HAlign).Attr("valign", _VAlign);
52 	XMLConfig::Xmlize(xml);
53 }
54