diff options
author | Christian Tusche <chr13@gmx.net> | 2007-05-06 17:26:51 +0200 |
---|---|---|
committer | Thomas Günther <tom@toms-cafe.de> | 2009-06-04 00:46:32 +0200 |
commit | b32f1eaf9ae246f656ebd27c2fbb5d29d2bec34c (patch) | |
tree | bcecfb3d782d7b0c3690403276be18ab8f76717e | |
parent | 0b3f86344a87940d324695e0bc9449c35cbf60d4 (diff) | |
download | vdr-plugin-text2skin-b32f1eaf9ae246f656ebd27c2fbb5d29d2bec34c.tar.gz vdr-plugin-text2skin-b32f1eaf9ae246f656ebd27c2fbb5d29d2bec34c.tar.bz2 |
2007-05-06: Version 1.1-cvs_ext-0.10b (text2skin-1.1-cvs_ext-0.10b.diff)
- increase skin file version to 1.1
- the position of list items is interpreted relative to the "list" container
when file version >= 1.1
- when a position is specified for "block" elements, the position of all
contained elements is interpreted relative to the container position
-rw-r--r-- | HISTORY | 8 | ||||
-rw-r--r-- | loader.c | 5 | ||||
-rw-r--r-- | render.c | 8 | ||||
-rw-r--r-- | text2skin.c | 2 | ||||
-rw-r--r-- | xml/parser.c | 4 | ||||
-rw-r--r-- | xml/skin.c | 34 | ||||
-rw-r--r-- | xml/skin.h | 42 |
7 files changed, 95 insertions, 8 deletions
@@ -1,6 +1,14 @@ VDR Plugin 'text2skin' Revision History --------------------------------------- +2007-05-06: Version 1.1-cvs_ext-0.10b (text2skin-1.1-cvs_ext-0.10b.diff) + +- increase skin file version to 1.1 +- the position of list items is interpreted relative to the "list" container + when file version >= 1.1 +- when a position is specified for "block" elements, the position of all + contained elements is interpreted relative to the container position + 2007-05-06: Version 1.1-cvs_ext-0.10a (text2skin-1.1-cvs_ext-0.10a.diff) - increased efficiency in drawing list items in the main menu @@ -52,11 +52,12 @@ void cText2SkinLoader::Load(const char *Skin) { cxSkin *skin = xmlParse(Skin, skinfile, translations, theme); if (skin) { - if (skin->Version() == cText2SkinPlugin::SkinVersion()) { + if( skin->Version() <= cText2SkinPlugin::SkinVersion() ) { new cText2SkinLoader(skin, translations, theme, Skin, skin->Title()); return; } else - esyslog("ERROR: text2skin: Skin is version %s, expecting %s", skin->Version().c_str(), + esyslog("ERROR: text2skin: Skin is version %i,%i, expecting <= %s", + skin->Version().Major(), skin->Version().Minor(), cText2SkinPlugin::SkinVersion()); } else esyslog("ERROR: error in skin file"); @@ -178,7 +178,13 @@ void cText2SkinRender::DrawObject( cxObject *Object, pos = Object->Pos(BaseOffset, BaseSize); - size = Object->Size(BaseOffset, BaseSize); + if( ListItem >= 0 && !mSkin->Version().Require(1,1) ) { + // Object is part of al list + // Calculate offset of list item relative to the list offset + size = Object->Size(); + } else { + size = Object->Size(BaseOffset, BaseSize); + } switch (Object->Type()) { diff --git a/text2skin.c b/text2skin.c index dc41f15..04b3d72 100644 --- a/text2skin.c +++ b/text2skin.c @@ -15,7 +15,7 @@ #include "status.h" const char *cText2SkinPlugin::VERSION = "1.1-cvs_ext-0.10"; -const char *cText2SkinPlugin::SKINVERSION = "1.0"; +const char *cText2SkinPlugin::SKINVERSION = "1.1"; const char *cText2SkinPlugin::DESCRIPTION = "Loader for text-based skins"; cText2SkinPlugin::cText2SkinPlugin(void) { diff --git a/xml/parser.c b/xml/parser.c index f573398..0045af1 100644 --- a/xml/parser.c +++ b/xml/parser.c @@ -45,7 +45,7 @@ #define ATTRIB_OPT_NUMBER(_attr,_target) \ if (attrs.find(_attr) != attrs.end()) { \ char *_e; const char *_t = attrs[_attr].c_str(); \ - long _l = strtol(_t, &_e, 10); \ + long _l = strtol(_t, &_e, 0); \ if (_e ==_t || *_e != '\0') { \ esyslog("ERROR: Text2Skin: Invalid numeric value \"%s\" in attribute %s", \ _t, _attr); \ @@ -91,7 +91,7 @@ bool xStartElem(const std::string &name, std::map<std::string,std::string> &attr if (context.size() == 0) { if (name == "skin") { - ATTRIB_MAN_STRING("version", skin->mVersion); + ATTRIB_MAN_FUNC ("version", skin->mVersion.Parse); ATTRIB_MAN_STRING("name", skin->mTitle); ATTRIB_MAN_FUNC ("screenBase", skin->ParseBase); } @@ -9,6 +9,40 @@ const std::string ScreenBases[] = { "relative", "absolute" }; +cxVersion::cxVersion(int ma, int min): + mMajor(ma), + mMinor(min) +{ +} + +bool cxVersion::Parse(const std::string &Text) +{ + int dot = Text.find("."); + std::string ma(Text, 0, dot), min(Text, dot+1); + char *e = NULL; + const char *t = NULL; + long l=0; + + t = ma.c_str(); + l = strtol(t, &e, 10); + if (e ==t || *e != '\0') { + return false; + } else { + mMajor = l; + } + + t = min.c_str(); + l = strtol(t, &e, 10); + if (e ==t || *e != '\0') { + return false; + } else { + mMinor = l; + } + + return true; +} + + cxSkin::cxSkin(const std::string &Name, cText2SkinI18n *I18n, cText2SkinTheme *Theme): mName(Name), mI18n(I18n), @@ -15,6 +15,44 @@ class cText2SkinI18n; class cText2SkinTheme; + +class cxVersion { +public: + 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 { + return mMajor > ma ? true : (mMajor == ma ? mMinor >= min : false); + } + bool Limit( int ma, int min ) const { + return mMajor < ma ? true : (mMajor == ma ? mMinor <= min : false); + } + bool cxVersion::operator==( const cxVersion &v ) const { + return mMajor == v.mMajor && mMinor == v.mMinor; + } + bool cxVersion::operator>=( const cxVersion &v ) const { + return Require( v.mMajor , v.mMinor); + } + bool cxVersion::operator>=( const char *c ) const { + cxVersion v; + if( !v.Parse(c) ) return false; + return Require( v.mMajor , v.mMinor); + } + bool cxVersion::operator<=( const cxVersion &v ) const { + return Limit( v.mMajor , v.mMinor ); + } + bool cxVersion::operator<=( const char *c ) const { + cxVersion v; + if( !v.Parse(c) ) return false; + return Limit( v.mMajor , v.mMinor); + } + +private: + int mMajor; + int mMinor; +}; + class cxSkin { friend bool xStartElem(const std::string &name, std::map<std::string,std::string> &attrs); friend bool xEndElem(const std::string &name); @@ -35,7 +73,7 @@ private: txSize mBaseSize; std::string mName; std::string mTitle; - std::string mVersion; + cxVersion mVersion; cxDisplays mDisplays; @@ -55,7 +93,7 @@ public: const txSize &BaseSize(void) const { return mBaseSize; } const std::string &Name(void) const { return mName; } const std::string &Title(void) const { return mTitle; } - const std::string &Version(void) const { return mVersion; } + const cxVersion &Version(void) const { return mVersion; } // functions for object classes to obtain dynamic item information std::string Translate(const std::string &Text); |