summaryrefslogtreecommitdiff
path: root/xml/object.h
blob: 8b134a94e025441cad8e52955e24181797c3211f (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
 *  $Id: object.h,v 1.4 2004/12/08 17:13:26 lordjaxom Exp $
 */

#ifndef VDR_TEXT2SKIN_XML_OBJECT_H
#define VDR_TEXT2SKIN_XML_OBJECT_H

#include "xml/string.h"
#include "xml/function.h"
#include <vdr/osd.h>
#include <vector>
#include <string>
#include <map>

class cxDisplay;
class cxSkin;

struct txPoint {
	int x, y;
	txPoint(int _x = 0, int _y = 0) { x = _x; y = _y; }
};

struct txSize {
	int w, h;
	txSize(int _w = 0, int _h = 0) { w = _w; h = _h; }
};

struct txWindow {
	txPoint pos1;
	txPoint pos2;
	int bpp;
	txWindow(int _x1 = 0, int _y1 = 0, int _x2 = -1, int _y2 = -1, int _bpp=4): 
			pos1(_x1, _y2), pos2(_x2, _y2), bpp(_bpp) {}
};

class cxObjects;

class cxObject {
	friend class cText2SkinRender;
	friend bool xStartElem(const std::string &name, std::map<std::string,std::string> &attrs);
	friend bool xCharData(const std::string &text);
	friend bool xEndElem(const std::string &name);

	/* Skin Editor */
	friend class VSkinnerItem;

public:
	enum eType {
		image,
		text,
		rectangle,
		ellipse,
		slope,
		progress,
		scrolltext,
		scrollbar,
		block,
		list,
		item,
#define __COUNT_OBJECT__ (item + 1)
	};
	
private:
	eType          mType;
	txPoint        mPos1;
	txPoint        mPos2;
	int            mAlpha;
	int            mArc;
	std::string    mFg;
	std::string    mBg;
	std::string    mMark;
	std::string    mActive;
	std::string    mKeep;
	cxString       mPath;
	cxString       mText;
	eTextAlignment mAlign;
	cxFunction    *mCondition;
	cxString       mCurrent;
	cxString       mTotal;
	const cFont   *mFont;
	cxObjects     *mObjects; // used for block objects such as <list>
	cxDisplay     *mDisplay;
	cxSkin        *mSkin;

public:
	cxObject(cxDisplay *parent);
	cxObject(const cxObject &Src);
	~cxObject();

	bool ParseType     (const std::string &Text);
	bool ParseCondition(const std::string &Text);
	bool ParseAlignment(const std::string &Text);
	bool ParseFontFace (const std::string &Text);

	void               SetIndex(uint Index, int Tab);

	eType              Type(void)            const { return mType; }
	cxFunction        *Condition(void)       const { return mCondition; }
	int                Alpha(void)           const { return mAlpha; }
	eTextAlignment     Align(void)           const { return mAlign; }
	int                Arc(void)             const { return mArc; }
	std::string        Path(void)            const { return mPath.Evaluate(); }
	std::string        Text(void)            const { return mText.Evaluate(); }
	int                Current(void)         const { return mCurrent.Evaluate(); }
	int                Total(void)           const { return mTotal.Evaluate(); }
	const cFont       *Font(void)            const { return mFont; }
	cxDisplay         *Display(void)         const { return mDisplay; }
	cxSkin            *Skin(void)            const { return mSkin; }

	const std::string &TypeName(void)        const;
	txPoint            Pos(void)             const;
	txSize             Size(void)            const;
	const tColor      *Fg(void)              const;
	const tColor      *Bg(void)              const;
	const tColor      *Mark(void)            const;
	const tColor      *Active(void)          const;
	const tColor      *Keep(void)            const;

	uint               Objects(void)         const;
	const cxObject    *GetObject(uint Index) const;
};

inline void cxObject::SetIndex(uint Index, int Tab)
{
	mText.SetIndex(Index, Tab);
	mPath.SetIndex(Index, Tab);
	if (mCondition != NULL)
		mCondition->SetIndex(Index, Tab);
}

class cxObjects: public std::vector<cxObject*> {
public:
	cxObjects(void);
	~cxObjects();
};

// recursive dependancy
inline uint cxObject::Objects(void) const
{
	return mObjects ? mObjects->size() : 0;
}

inline const cxObject *cxObject::GetObject(uint Index) const
{
	return mObjects ? (*mObjects)[Index] : NULL;
}

#endif // VDR_TEXT2SKIN_XML_OBJECT_H