diff options
Diffstat (limited to 'xml')
-rw-r--r-- | xml/object.c | 112 | ||||
-rw-r--r-- | xml/object.h | 52 | ||||
-rw-r--r-- | xml/parser.c | 12 | ||||
-rw-r--r-- | xml/skin.c | 17 | ||||
-rw-r--r-- | xml/skin.h | 33 | ||||
-rw-r--r-- | xml/string.c | 3 | ||||
-rw-r--r-- | xml/string.h | 4 | ||||
-rw-r--r-- | xml/type.h | 1 | ||||
-rw-r--r-- | xml/xml.c | 2 |
9 files changed, 104 insertions, 132 deletions
diff --git a/xml/object.c b/xml/object.c index eae47e5..ec69fe7 100644 --- a/xml/object.c +++ b/xml/object.c @@ -16,7 +16,7 @@ cxObject::cxObject(cxDisplay *Parent): mType((eType)__COUNT_OBJECT__), mPos1(0, 0), mPos2(-1, -1), - mVirtSize(-1,-1), + mVirtSize(-1, -1), mAlpha(255), mColors(0), mArc(0), @@ -135,7 +135,7 @@ bool cxObject::ParseFontFace(const std::string &Text) void cxObject::SetListIndex(uint Index, int Tab) { - Tab = Tab>=0 ? Tab : -1; + Tab = (Tab >= 0 ? Tab : -1); mListIndex = 1 + Index * cSkinDisplayMenu::MaxTabs + Tab; mText.SetListIndex(Index, Tab); mPath.SetListIndex(Index, Tab); @@ -155,46 +155,45 @@ const cFont *cxObject::Font(void) const if ((font = cText2SkinFont::Load(SkinPath() + "/" + mSkin->Name(), mFontFace, mFontSize, mFontWidth)) != NULL) return font; - - if ((font = cText2SkinFont::Load(SkinPath() + "/fonts", mFontFace, mFontSize, mFontWidth)) - != NULL) + + if ((font = cText2SkinFont::Load(SkinPath() + "/fonts", mFontFace, mFontSize, mFontWidth)) != NULL) return font; - + return cFont::GetFont(fontOsd); } -txPoint cxObject::Pos(const txPoint &BaseOffset, const txSize &BaseSize, const txSize &VirtSize) const +txPoint cxObject::Pos(const txPoint &BaseOffset, const txSize &BaseSize, const txSize &VirtSize) const { txPoint bOffset = BaseOffset.x < 0 ? mSkin->BaseOffset() : BaseOffset; txSize bSize = BaseSize.w < 0 ? mSkin->BaseSize() : BaseSize; - double scale_x = VirtSize.w>0 ? (double)BaseSize.w / VirtSize.w : 1.0, - scale_y = VirtSize.h>0 ? (double)BaseSize.h / VirtSize.h : 1.0; + double scale_x = VirtSize.w > 0 ? (double)BaseSize.w / VirtSize.w : 1.0, + scale_y = VirtSize.h > 0 ? (double)BaseSize.h / VirtSize.h : 1.0; int x1 = mPos1.x < 0 ? (int)((mPos1.x + 1) * scale_x - 1) : (int)(mPos1.x * scale_x); int y1 = mPos1.y < 0 ? (int)((mPos1.y + 1) * scale_x - 1) : (int)(mPos1.y * scale_y); - return txPoint(bOffset.x + (x1 < 0 ? bSize.w + x1 : x1), - bOffset.y + (y1 < 0 ? bSize.h + y1 : y1)); + return txPoint(bOffset.x + (x1 < 0 ? bSize.w + x1 : x1), + bOffset.y + (y1 < 0 ? bSize.h + y1 : y1)); } -txSize cxObject::Size(const txPoint &BaseOffset, const txSize &BaseSize, const txSize &VirtSize) const +txSize cxObject::Size(const txPoint &BaseOffset, const txSize &BaseSize, const txSize &VirtSize) const { //txPoint bOffset = BaseOffset.x < 0 ? mSkin->BaseOffset() : BaseOffset; txSize bSize = BaseSize.w < 0 ? mSkin->BaseSize() : BaseSize; - double scale_x = VirtSize.w>0 ? (double)BaseSize.w / VirtSize.w : 1.0, - scale_y = VirtSize.h>0 ? (double)BaseSize.h / VirtSize.h : 1.0; + double scale_x = VirtSize.w > 0 ? (double)BaseSize.w / VirtSize.w : 1.0, + scale_y = VirtSize.h > 0 ? (double)BaseSize.h / VirtSize.h : 1.0; int x1 = mPos1.x < 0 ? (int)((mPos1.x + 1) * scale_x - 1) : (int)(mPos1.x * scale_x); int y1 = mPos1.y < 0 ? (int)((mPos1.y + 1) * scale_x - 1) : (int)(mPos1.y * scale_y); int x2 = mPos2.x < 0 ? (int)((mPos2.x + 1) * scale_x - 1) : (int)(mPos2.x * scale_x); int y2 = mPos2.y < 0 ? (int)((mPos2.y + 1) * scale_x - 1) : (int)(mPos2.y * scale_y); - txPoint p1(x1 < 0 ? bSize.w + x1 : x1, - y1 < 0 ? bSize.h + y1 : y1); - txPoint p2(x2 < 0 ? bSize.w + x2 : x2, - y2 < 0 ? bSize.h + y2 : y2); + txPoint p1(x1 < 0 ? bSize.w + x1 : x1, + y1 < 0 ? bSize.h + y1 : y1); + txPoint p2(x2 < 0 ? bSize.w + x2 : x2, + y2 < 0 ? bSize.h + y2 : y2); return txSize(p2.x - p1.x + 1, p2.y - p1.y + 1); } @@ -211,7 +210,7 @@ const tColor *cxObject::Bg(void) const return cText2SkinRender::ItemColor(mBg, Bg) ? &Bg : NULL; } -const tColor *cxObject::Bl(void) const +const tColor *cxObject::Bl(void) const { static tColor Bl; return cText2SkinRender::ItemColor(mBl, Bl) ? &Bl : NULL; @@ -252,16 +251,10 @@ cxObjects::~cxObjects() } - - - - - - /////////////////////////////////////////////////////////////////////////////// // ---------- class cxRefresh ---------------------------------------------- // -cxRefresh::cxRefresh( cxObject *Object ): +cxRefresh::cxRefresh(cxObject *Object): mRefreshType(0xFF), mText(NULL), mChanged(NULL), @@ -282,15 +275,15 @@ bool cxRefresh::Dirty(uint dirty, uint &updatein, bool force, uint now) uint nexttime = mObject->State().nexttime; bool to = force || mForce || - mObject->Type() == cxObject::block || mObject->Type() == cxObject::list; + mObject->Type() == cxObject::block || mObject->Type() == cxObject::list; bool changed = force || mForce; - if( now>0 && nexttime>0 ) { + if (now > 0 && nexttime > 0) { // timeout was set - if( now >= nexttime ) { + if (now >= nexttime) // timeout has expired to = true; - } else { + else { // time left -> set new update interval uint nextin = nexttime - now; if (updatein == 0 || nextin < updatein) @@ -298,72 +291,69 @@ bool cxRefresh::Dirty(uint dirty, uint &updatein, bool force, uint now) } } - // Objaect has changed since last redraw - if( mChanged != NULL ) { + // Object has changed since last redraw + if (mChanged != NULL) { mEval = mChanged->Evaluate(); - if( mEval != mLastEval ) { + if (mEval != mLastEval) changed = true; - } } // refresh - if( (mRefreshType & dirty & ~(1<<timeout) & ~(1<<update)) ) { - if( changed ) mLastEval = mEval; + if ((mRefreshType & dirty & ~(1<<timeout) & ~(1<<update))) { + if (changed) + mLastEval = mEval; return true; } // timeout - if( (mRefreshType & dirty & (1<<timeout)) && to ) { - if( changed ) mLastEval = mEval; + if ((mRefreshType & dirty & (1<<timeout)) && to) { + if (changed) + mLastEval = mEval; return true; } - + // update - if( (mRefreshType & dirty & (1<<update)) && changed ) { - mLastEval = mEval; + if ((mRefreshType & dirty & (1<<update)) && changed) { + mLastEval = mEval; return true; } - return false; + return false; } - - - - bool cxRefresh::Parse(const std::string &Text) { - uint refresh=0; - bool force=false, full=false; + uint refresh = 0; + bool force = false, full = false; - if( Text.find("all") != std::string::npos ) + if (Text.find("all") != std::string::npos) refresh |= (1<<all); - if( Text.find("timeout") != std::string::npos ) + if (Text.find("timeout") != std::string::npos) refresh |= (1<<timeout); - if( Text.find("update") != std::string::npos ) + if (Text.find("update") != std::string::npos) refresh |= (1<<update); - //if( Text.find("message") =! std::string::npos ) + //if (Text.find("message") != std::string::npos) // refresh |= (1<<list); - if( Text.find("list") != std::string::npos ) + if (Text.find("list") != std::string::npos) refresh |= (1<<list); - if( Text.find("scroll") != std::string::npos ) + if (Text.find("scroll") != std::string::npos) refresh |= (1<<scroll); - if( Text.find("allways") != std::string::npos ) + if (Text.find("allways") != std::string::npos) refresh |= 0xFF; - if( Text.find("full") != std::string::npos ) + if (Text.find("full") != std::string::npos) full = true; - if( Text.find("force") != std::string::npos ) + if (Text.find("force") != std::string::npos) force = true; - if( refresh == 0) + if (refresh == 0) return false; mForce = force; @@ -375,13 +365,13 @@ bool cxRefresh::Parse(const std::string &Text) bool cxRefresh::ParseChanged(const std::string &Text) { - if( mObject == NULL ) + if (mObject == NULL) return false; - if(mText == NULL) + if (mText == NULL) mText = new cxString(mObject, false); - if ( mText->Parse(Text) ) { + if (mText->Parse(Text)) { mChanged = mText; return true; } diff --git a/xml/object.h b/xml/object.h index aad82a5..18600fe 100644 --- a/xml/object.h +++ b/xml/object.h @@ -33,11 +33,6 @@ struct txWindow { pos1(_x1, _y2), pos2(_x2, _y2), bpp(_bpp) {} }; - - - - - // state information for marquee, blink, scroll struct txState { bool scrolling; @@ -48,14 +43,6 @@ struct txState { txState(void): scrolling(false), offset(0), direction(1), nexttime(0) {} }; - - - - - - - - class cxObject; class cxRefresh { @@ -63,39 +50,33 @@ class cxRefresh { public: enum eRefreshType { - all, // complete redraw of the screen - timeout, // redraw due to a timeout - //message, // a message was set or removed - update, // update of the osd elements - scroll, // a scroll event - list, // list items or the current item have changed + all, // complete redraw of the screen + timeout, // redraw due to a timeout + //message, // a message was set or removed + update, // update of the osd elements + scroll, // a scroll event + list, // list items or the current item have changed }; cxRefresh(cxObject *Object); ~cxRefresh(); - bool Dirty(uint dirty, uint &updatein, bool force=false, uint now=0 ); - bool Full(void) const { return mFull; } + bool Dirty(uint dirty, uint &updatein, bool force = false, uint now = 0); + bool Full(void) const { return mFull; } uint Type(void) const { return mRefreshType; } bool Parse(const std::string &Text); bool ParseChanged(const std::string &Text); - cxRefresh &operator=(const cxRefresh &b); + cxRefresh &operator=(const cxRefresh &b); private: uint mRefreshType; cxType mLastEval; - cxType mEval; + cxType mEval; cxString *mText; cxString *mChanged; cxObject *mObject; bool mForce, mFull; }; - - - - - - class cxObjects; class cxObject { @@ -124,7 +105,7 @@ public: item, #define __COUNT_OBJECT__ (item + 1) }; - + private: cxDisplay *mDisplay; cxSkin *mSkin; @@ -159,8 +140,7 @@ private: // state information for marquee, blink, scroll uint mListIndex; typedef std::map<uint,txState> tStates; - tStates mStates; - + tStates mStates; public: cxObject(cxDisplay *parent); @@ -191,10 +171,10 @@ public: txState &State(void) { return mStates[mListIndex]; } const std::string &TypeName(void) const; - txPoint Pos(const txPoint &BaseOffset=txPoint(-1,-1), const txSize &BaseSize=txSize(-1,-1), - const txSize &VirtSize=txSize(-1,-1) ) const; - txSize Size(const txPoint &BaseOffset=txPoint(-1,-1), const txSize &BaseSize=txSize(-1,-1), - const txSize &VirtSize=txSize(-1,-1)) const; + txPoint Pos(const txPoint &BaseOffset = txPoint(-1, -1), const txSize &BaseSize = txSize(-1, -1), + const txSize &VirtSize = txSize(-1, -1)) const; + txSize Size(const txPoint &BaseOffset = txPoint(-1, -1), const txSize &BaseSize = txSize(-1, -1), + const txSize &VirtSize = txSize(-1, -1)) const; const cFont *Font(void) const; const tColor *Fg(void) const; const tColor *Bg(void) const; diff --git a/xml/parser.c b/xml/parser.c index 158724a..fe93602 100644 --- a/xml/parser.c +++ b/xml/parser.c @@ -103,7 +103,7 @@ bool xStartElem(const std::string &name, std::map<std::string,std::string> &attr display = new cxDisplay(skin); ATTRIB_MAN_FUNC ("id", display->ParseType); ATTRIB_OPT_FUNC ("refresh", display->mRefreshDefault.Parse); - } + } else TAG_ERR_REMAIN("skin"); } @@ -130,7 +130,7 @@ bool xStartElem(const std::string &name, std::map<std::string,std::string> &attr else { object = new cxObject(display); if (object->ParseType(name)) { - if(parents.size() > 0) + if (parents.size() > 0) object->mRefresh = parents.back()->mRefresh; else object->mRefresh = display->mRefreshDefault; @@ -197,9 +197,11 @@ bool xStartElem(const std::string &name, std::map<std::string,std::string> &attr else if (name == "item") { ATTRIB_MAN_NUMBER("height", object->mPos2.y); --object->mPos2.y; - } else if (name == "block" || name == "list") { - ATTRIB_OPT_NUMBER("w", object->mVirtSize.w); - ATTRIB_OPT_NUMBER("h", object->mVirtSize.h); + } + else if (name == "block" + || name == "list") { + ATTRIB_OPT_NUMBER("w", object->mVirtSize.w); + ATTRIB_OPT_NUMBER("h", object->mVirtSize.h); } } else TAG_ERR_REMAIN(context[context.size() - 1].c_str()); @@ -18,31 +18,28 @@ cxVersion::cxVersion(int ma, int min): bool cxVersion::Parse(const std::string &Text) { int dot = Text.find("."); - std::string ma(Text, 0, dot), min(Text, dot+1); + std::string ma(Text, 0, dot), min(Text, dot + 1); char *e = NULL; - const char *t = NULL; - long l=0; + const char *t = NULL; + long l = 0; t = ma.c_str(); l = strtol(t, &e, 10); - if (e ==t || *e != '\0') { + if (e == t || *e != '\0') return false; - } else { + else mMajor = l; - } t = min.c_str(); l = strtol(t, &e, 10); - if (e ==t || *e != '\0') { + if (e == t || *e != '\0') return false; - } else { + else mMinor = l; - } return true; } - cxSkin::cxSkin(const std::string &Name, cText2SkinI18n *I18n, cText2SkinTheme *Theme): mName(Name), mI18n(I18n), @@ -15,37 +15,38 @@ class cText2SkinI18n; class cText2SkinTheme; - class cxVersion { public: - cxVersion( int ma=0, int min=0 ); + cxVersion(int ma = 0, int min = 0); bool Parse(const std::string &Text); int Major(void) const { return mMajor; } int Minor(void) const { return mMinor; } - bool Require( int ma, int min ) const { + bool Require(int ma, int min) const { return mMajor > ma ? true : (mMajor == ma ? mMinor >= min : false); } - bool Limit( int ma, int min ) const { + bool Limit(int ma, int min) const { return mMajor < ma ? true : (mMajor == ma ? mMinor <= min : false); } - bool operator==( const cxVersion &v ) const { + bool operator==(const cxVersion &v) const { return mMajor == v.mMajor && mMinor == v.mMinor; } - bool operator>=( const cxVersion &v ) const { - return Require( v.mMajor , v.mMinor); + bool operator>=(const cxVersion &v) const { + return Require(v.mMajor, v.mMinor); } - bool operator>=( const char *c ) const { + bool operator>=(const char *c) const { cxVersion v; - if( !v.Parse(c) ) return false; - return Require( v.mMajor , v.mMinor); + if (!v.Parse(c)) + return false; + return Require(v.mMajor, v.mMinor); } - bool operator<=( const cxVersion &v ) const { - return Limit( v.mMajor , v.mMinor ); + bool operator<=(const cxVersion &v) const { + return Limit(v.mMajor, v.mMinor); } - bool operator<=( const char *c ) const { + bool operator<=(const char *c) const { cxVersion v; - if( !v.Parse(c) ) return false; - return Limit( v.mMajor , v.mMinor); + if (!v.Parse(c)) + return false; + return Limit(v.mMajor, v.mMinor); } private: @@ -74,7 +75,7 @@ private: std::string mName; std::string mTitle; cxVersion mVersion; - + cxDisplays mDisplays; cText2SkinI18n *mI18n; // TODO: should move here completely diff --git a/xml/string.c b/xml/string.c index 7568b37..3f671bd 100644 --- a/xml/string.c +++ b/xml/string.c @@ -11,7 +11,8 @@ static const char *Tokens[__COUNT_TOKEN__] = { // Channel Display "ChannelNumber", "ChannelName", "ChannelShortName", "ChannelBouquet", "ChannelPortal", "ChannelSource", "ChannelID", "PresentStartDateTime", "PresentVPSDateTime", - "CurrentEventsTitle1", "CurrentEventsStartDateTime1", "CurrentEventsStopDateTime1", "CurrentEventsChannelNumber1", "CurrentEventsChannelName1", "CurrentEventsIsRecording1", "CurrentEventsTitle2", "CurrentEventsStartDateTime2", "CurrentEventsStopDateTime2", "CurrentEventsChannelNumber2", "CurrentEventsChannelName2", "CurrentEventsIsRecording2", + "CurrentEventsTitle1", "CurrentEventsStartDateTime1", "CurrentEventsStopDateTime1", "CurrentEventsChannelNumber1", "CurrentEventsChannelName1", "CurrentEventsIsRecording1", + "CurrentEventsTitle2", "CurrentEventsStartDateTime2", "CurrentEventsStopDateTime2", "CurrentEventsChannelNumber2", "CurrentEventsChannelName2", "CurrentEventsIsRecording2", "CurrentEventsTitle3", "CurrentEventsStartDateTime3", "CurrentEventsStopDateTime3", "CurrentEventsChannelNumber3", "CurrentEventsChannelName3", "CurrentEventsIsRecording3", "TimerConflicts", "PresentEndDateTime", "PresentDuration", "PresentProgress", "PresentRemaining", diff --git a/xml/string.h b/xml/string.h index 55adbcf..a459253 100644 --- a/xml/string.h +++ b/xml/string.h @@ -111,7 +111,7 @@ enum exToken { tReplayName, tReplayDateTime, tReplayShortText, - tReplayDescription, + tReplayDescription, tReplayLanguageCode, tReplayLanguageDescription, tReplayVideoAR, @@ -171,7 +171,7 @@ enum exToken { tButtonBlue, tCanScrollUp, tCanScrollDown, - + #define __COUNT_TOKEN__ (tCanScrollDown + 1) }; @@ -5,6 +5,7 @@ #ifndef VDR_TEXT2SKIN_XML_TYPE_H #define VDR_TEXT2SKIN_XML_TYPE_H +#include <cstdlib> #include <string> #include <vdr/tools.h> #include <stdio.h> @@ -35,7 +35,7 @@ XML::XML(const string &file) { ifstream f(file.c_str(), ios::in|ios::binary|ios::ate); size = f.tellg(); f.seekg(0, ios::beg); - buffer = new char [size+1]; + buffer = new char [size]; f.read(buffer, size); f.close(); data.assign(buffer, size); |