summaryrefslogtreecommitdiff
path: root/skinengine/src/skin_object.cpp
blob: 322419137866d7b0bafa7088a04494900f606d3d (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include "headers.h"

static int sttParseTextToInt(const TCHAR *str)
{
	if (!str) return 0;
	if (!lstrcmp(str, _T("auto"))) return -1;
	return _ttoi(str);
}

void CSkinObject::LoadFromXml(HXML hXml)
{
	m_width = sttParseTextToInt(xi.getAttrValue(hXml, _T("width")));
	m_height = sttParseTextToInt(xi.getAttrValue(hXml, _T("height")));
}

void CSkinObject::SetParent(ISkinElement *parent)
{
	if (m_parent) m_parent->RemoveChild(this);
	m_parent = parent;
}

void CSkinObject::SetId(const TCHAR *id)
{
	if (m_id) free(m_id);
	m_id = _tcsdup(id);
}

void CSkinObject::SetDataSource(ISkinDataSource *ds)
{
	m_ds = ds;
}

void CSkinObject::Destroy()
{
	delete this;
}

void CSkinObject::Measure(SkinRenderParams *params)
{
	SetRect(&params->rc, 0, 0, m_width, m_height);
}

void CSkinObject::Layout(SkinRenderParams *params)
{
	m_rcPosition = params->rc;
}

bool CSkinObject::IsComplexObject()
{
	return false;
}

ISkinElement *CSkinObject::GetParent()
{
	return m_parent;
}

int CSkinObject::GetChildCount()
{
	return 0;
}

ISkinElement *CSkinObject::GetChild(int index)
{
	return NULL;
}

bool CSkinObject::AppendChild(ISkinElement *child)
{
	return false;
}

bool CSkinObject::InsertChild(ISkinElement *child, int index)
{
	return false;
}

void CSkinObject::RemoveChild(ISkinElement *child)
{
}

void CSkinObject::SetPropText(const TCHAR *key, const TCHAR *value)
{
	m_properties.insert(new Property(key, value));
}

const TCHAR *CSkinObject::GetPropText(const TCHAR *key, const TCHAR *value)
{
	Property search(key, 0);
	if (Property *result = m_properties.find(&search))
		if (result->m_type == Property::Text)
			return result->m_valueText;
	return NULL;
}

void CSkinObject::SetPropInt(const TCHAR *key, int value)
{
	m_properties.insert(new Property(key, value));

	if (!lstrcmp(key, _T("width")))		m_width = value;		else
	if (!lstrcmp(key, _T("height")))	m_height = value;
}

void CSkinObject::SetPropIntText(const TCHAR *key, const TCHAR *value)
{
	SetPropInt(key, sttParseTextToInt(value));
}

int CSkinObject::GetPropInt(const TCHAR *key)
{
	Property search(key, 0);
	if (Property *result = m_properties.find(&search))
		if (result->m_type == Property::Integer)
			return result->m_valueInt;
	return 0;
}