diff options
Diffstat (limited to 'xml/object.h')
-rw-r--r-- | xml/object.h | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/xml/object.h b/xml/object.h new file mode 100644 index 0000000..8b134a9 --- /dev/null +++ b/xml/object.h @@ -0,0 +1,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 |