diff options
author | lordjaxom <lordjaxom> | 2005-01-01 23:44:36 +0000 |
---|---|---|
committer | lordjaxom <lordjaxom> | 2005-01-01 23:44:36 +0000 |
commit | 4e0b98bf0cca1afa86b8c655c490392a70b56b36 (patch) | |
tree | 3bd0c33e090c67cbf948c9336317e4fdb175d9fa | |
parent | 929d806fbc6c2d05317cd7357861d371a29c290f (diff) | |
download | vdr-plugin-text2skin-4e0b98bf0cca1afa86b8c655c490392a70b56b36.tar.gz vdr-plugin-text2skin-4e0b98bf0cca1afa86b8c655c490392a70b56b36.tar.bz2 |
- some formatting issues
- moved translation to skin object
-rw-r--r-- | loader.c | 4 | ||||
-rw-r--r-- | render.c | 8 | ||||
-rw-r--r-- | render.h | 3 | ||||
-rw-r--r-- | xml/function.c | 9 | ||||
-rw-r--r-- | xml/function.h | 5 | ||||
-rw-r--r-- | xml/object.c | 20 | ||||
-rw-r--r-- | xml/object.h | 6 | ||||
-rw-r--r-- | xml/parser.c | 7 | ||||
-rw-r--r-- | xml/parser.h | 7 | ||||
-rw-r--r-- | xml/skin.c | 23 | ||||
-rw-r--r-- | xml/skin.h | 27 | ||||
-rw-r--r-- | xml/string.c | 17 | ||||
-rw-r--r-- | xml/string.h | 9 |
13 files changed, 93 insertions, 52 deletions
@@ -1,5 +1,5 @@ /* - * $Id: loader.c,v 1.1 2004/12/19 22:03:14 lordjaxom Exp $ + * $Id: loader.c,v 1.2 2005/01/01 23:44:36 lordjaxom Exp $ */ #include "loader.h" @@ -50,7 +50,7 @@ void cText2SkinLoader::Load(const char *Skin) { if (access(skinfile.c_str(), F_OK) == 0) { isyslog("parsing %s", skinfile.c_str()); - cxSkin *skin = xmlParse(Skin, skinfile); + cxSkin *skin = xmlParse(Skin, skinfile, translations, theme); if (skin) { if (skin->Version() == cText2SkinPlugin::SkinVersion()) { new cText2SkinLoader(skin, translations, theme, Skin, skin->Title()); @@ -1,5 +1,5 @@ /* - * $Id: render.c,v 1.11 2004/12/29 22:24:25 lordjaxom Exp $ + * $Id: render.c,v 1.12 2005/01/01 23:44:36 lordjaxom Exp $ */ #include "render.h" @@ -510,8 +510,7 @@ std::string cText2SkinRender::ImagePath(const std::string &Filename) return cxFunction::False; } -/* TODO: translation when parsing -string cText2SkinRender::Translate(const string &Text) { +/*std::string cText2SkinRender::Translate(const std::string &Text) { if (mRender != NULL) { string result; if (mRender->mI18n != NULL) @@ -521,8 +520,7 @@ string cText2SkinRender::Translate(const string &Text) { return result; } return Text; -} -*/ +}*/ cxType cText2SkinRender::GetToken(const txToken &Token) { @@ -1,5 +1,5 @@ /* - * $Id: render.h,v 1.6 2004/12/28 18:06:02 lordjaxom Exp $ + * $Id: render.h,v 1.7 2005/01/01 23:44:36 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_RENDER_H @@ -126,6 +126,7 @@ public: virtual ~cText2SkinRender(); // functions for object classes to obtain dynamic item information + //static std::string Translate(const std::string &Text); static txPoint Transform(const txPoint &Pos); static bool ItemColor(const std::string &Color, tColor &Result); static std::string ImagePath(const std::string &Filename); diff --git a/xml/function.c b/xml/function.c index 00eea35..92b8926 100644 --- a/xml/function.c +++ b/xml/function.c @@ -1,5 +1,5 @@ /* - * $Id: function.c,v 1.3 2004/12/29 22:22:16 lordjaxom Exp $ + * $Id: function.c,v 1.4 2005/01/01 23:44:36 lordjaxom Exp $ */ #include "xml/function.h" @@ -16,9 +16,10 @@ static const char *Internals[] = { const std::string cxFunction::False = ""; const std::string cxFunction::True = "1"; -cxFunction::cxFunction(void): +cxFunction::cxFunction(cxSkin *Skin): + mSkin(Skin), mType(string), - mString(), + mString(Skin), mNumber(0), mNumParams(0) { @@ -108,7 +109,7 @@ bool cxFunction::Parse(const std::string &Text) } if (inExpr == 1) { - expr = new cxFunction; + expr = new cxFunction(mSkin); if (!expr->Parse(std::string(last, ptr - last))) { delete expr; return false; diff --git a/xml/function.h b/xml/function.h index 3b9155b..dce7fd8 100644 --- a/xml/function.h +++ b/xml/function.h @@ -1,5 +1,5 @@ /* - * $Id: function.h,v 1.2 2004/12/28 01:24:35 lordjaxom Exp $ + * $Id: function.h,v 1.3 2005/01/01 23:44:36 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_XML_FUNCTION_H @@ -35,6 +35,7 @@ public: static const std::string True; private: + cxSkin *mSkin; eType mType; cxString mString; int mNumber; @@ -46,7 +47,7 @@ protected: std::string FunPlugin(const std::string &Param) const; public: - cxFunction(void); + cxFunction(cxSkin *Skin); cxFunction(const cxString &String); cxFunction(const cxFunction &Src); ~cxFunction(); diff --git a/xml/object.c b/xml/object.c index e9d54ca..f55af07 100644 --- a/xml/object.c +++ b/xml/object.c @@ -1,5 +1,5 @@ /* - * $Id: object.c,v 1.7 2004/12/29 00:38:08 lordjaxom Exp $ + * $Id: object.c,v 1.8 2005/01/01 23:44:36 lordjaxom Exp $ */ #include "xml/object.h" @@ -11,26 +11,32 @@ static const std::string ObjectNames[] = "scrolltext", "scrollbar", "block", "list", "item" }; cxObject::cxObject(cxDisplay *parent): + mDisplay(parent), + mSkin(parent->Skin()), mType((eType)__COUNT_OBJECT__), mPos1(0, 0), mPos2(-1, -1), mAlpha(255), mColors(0), mArc(0), + mPath(parent->Skin()), + mText(mSkin), mAlign(taDefault), mCondition(NULL), + mCurrent(mSkin), + mTotal(mSkin), mFontFace("Osd"), mFontSize(0), mFontWidth(0), mDelay(150), mIndex(0), - mObjects(NULL), - mDisplay(parent), - mSkin(parent->Skin()) + mObjects(NULL) { } cxObject::cxObject(const cxObject &Src): + mDisplay(Src.mDisplay), + mSkin(Src.mSkin), mType(Src.mType), mPos1(Src.mPos1), mPos2(Src.mPos2), @@ -52,9 +58,7 @@ cxObject::cxObject(const cxObject &Src): mFontSize(Src.mFontSize), mFontWidth(Src.mFontSize), mDelay(Src.mDelay), - mObjects(NULL), - mDisplay(Src.mDisplay), - mSkin(Src.mSkin) + mObjects(NULL) { if (Src.mCondition) mCondition = new cxFunction(*Src.mCondition); @@ -81,7 +85,7 @@ bool cxObject::ParseType(const std::string &Text) bool cxObject::ParseCondition(const std::string &Text) { - cxFunction *result = new cxFunction; + cxFunction *result = new cxFunction(mSkin); if (result->Parse(Text)) { delete mCondition; mCondition = result; diff --git a/xml/object.h b/xml/object.h index 7d791fd..fca86f2 100644 --- a/xml/object.h +++ b/xml/object.h @@ -1,5 +1,5 @@ /* - * $Id: object.h,v 1.4 2004/12/28 14:35:54 lordjaxom Exp $ + * $Id: object.h,v 1.5 2005/01/01 23:44:36 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_XML_OBJECT_H @@ -63,6 +63,8 @@ public: }; private: + cxDisplay *mDisplay; + cxSkin *mSkin; eType mType; txPoint mPos1; txPoint mPos2; @@ -86,8 +88,6 @@ private: uint mDelay; uint mIndex; cxObjects *mObjects; // used for block objects such as <list> - cxDisplay *mDisplay; - cxSkin *mSkin; public: cxObject(cxDisplay *parent); diff --git a/xml/parser.c b/xml/parser.c index 02c1c4a..b83e684 100644 --- a/xml/parser.c +++ b/xml/parser.c @@ -1,5 +1,5 @@ /* - * $Id: parser.c,v 1.5 2004/12/29 00:38:08 lordjaxom Exp $ + * $Id: parser.c,v 1.6 2005/01/01 23:44:36 lordjaxom Exp $ */ #include "xml/parser.h" @@ -272,8 +272,9 @@ bool xEndElem(const std::string &name) { return true; } -cxSkin *xmlParse(const std::string &name, const std::string &fileName) { - skin = new cxSkin(name); +cxSkin *xmlParse(const std::string &name, const std::string &fileName, cText2SkinI18n *I18n, + cText2SkinTheme *Theme) { + skin = new cxSkin(name, I18n, Theme); context.clear(); XML xml(fileName); diff --git a/xml/parser.h b/xml/parser.h index 5f37118..8b4e088 100644 --- a/xml/parser.h +++ b/xml/parser.h @@ -1,5 +1,5 @@ /* - * $Id: parser.h,v 1.1 2004/12/19 22:03:28 lordjaxom Exp $ + * $Id: parser.h,v 1.2 2005/01/01 23:44:36 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_PARSER_H @@ -8,7 +8,10 @@ #include <string> class cxSkin; +class cText2SkinI18n; +class cText2SkinTheme; -cxSkin *xmlParse(const std::string &name, const std::string &fileName); +cxSkin *xmlParse(const std::string &name, const std::string &fileName, cText2SkinI18n *I18n, + cText2SkinTheme *Theme); #endif // VDR_TEXT2SKIN_PARSER_H @@ -1,18 +1,23 @@ /* - * $Id: skin.c,v 1.2 2004/12/21 18:35:54 lordjaxom Exp $ + * $Id: skin.c,v 1.3 2005/01/01 23:44:36 lordjaxom Exp $ */ #include "xml/skin.h" +#include "i18n.h" #include <vdr/tools.h> #include <vdr/config.h> const std::string ScreenBases[] = { "relative", "absolute" }; -cxSkin::cxSkin(const std::string &Name): - mName(Name) { +cxSkin::cxSkin(const std::string &Name, cText2SkinI18n *I18n, cText2SkinTheme *Theme): + mName(Name), + mI18n(I18n), + mTheme(Theme) +{ } -void cxSkin::SetBase(eScreenBase Base) { +void cxSkin::SetBase(eScreenBase Base) +{ if (Base != (eScreenBase)-1) mBase = Base; @@ -32,7 +37,8 @@ void cxSkin::SetBase(eScreenBase Base) { } } -bool cxSkin::ParseBase(const std::string &Text) { +bool cxSkin::ParseBase(const std::string &Text) +{ int i; for (i = 0; i < (int)__COUNT_BASE__; ++i) { if (ScreenBases[i] == Text) @@ -44,3 +50,10 @@ bool cxSkin::ParseBase(const std::string &Text) { } return false; } + +std::string cxSkin::Translate(const std::string &Text) +{ + if (mI18n != NULL) + return mI18n->Translate(Text); + return Text; +} @@ -1,5 +1,5 @@ /* - * $Id: skin.h,v 1.2 2004/12/21 18:35:55 lordjaxom Exp $ + * $Id: skin.h,v 1.3 2005/01/01 23:44:36 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_XML_SKIN_H @@ -13,6 +13,9 @@ // --- cxSkin ----------------------------------------------------------------- +class cText2SkinI18n; +class cText2SkinTheme; + class cxSkin { friend bool xStartElem(const std::string &name, std::map<std::string,std::string> &attrs); friend bool xEndElem(const std::string &name); @@ -28,17 +31,20 @@ public: }; private: - eScreenBase mBase; - txPoint mBaseOffset; - txSize mBaseSize; - std::string mName; - std::string mTitle; - std::string mVersion; + eScreenBase mBase; + txPoint mBaseOffset; + txSize mBaseSize; + std::string mName; + std::string mTitle; + std::string mVersion; + + cxDisplays mDisplays; - cxDisplays mDisplays; + cText2SkinI18n *mI18n; // TODO: should move here completely + cText2SkinTheme *mTheme; public: - cxSkin(const std::string &Name); + cxSkin(const std::string &Name, cText2SkinI18n *I18n, cText2SkinTheme *Theme); cxDisplay *Get(cxDisplay::eType Type); @@ -51,6 +57,9 @@ public: const std::string &Name(void) const { return mName; } const std::string &Title(void) const { return mTitle; } const std::string &Version(void) const { return mVersion; } + + // functions for object classes to obtain dynamic item information + std::string Translate(const std::string &Text); }; inline cxDisplay *cxSkin::Get(cxDisplay::eType Type) { diff --git a/xml/string.c b/xml/string.c index a037de0..594b4b6 100644 --- a/xml/string.c +++ b/xml/string.c @@ -1,10 +1,9 @@ /* - * $Id: string.c,v 1.3 2004/12/21 20:26:25 lordjaxom Exp $ + * $Id: string.c,v 1.4 2005/01/01 23:44:36 lordjaxom Exp $ */ #include "xml/string.h" #include "render.h" -#include <vdr/tools.h> static const char *Tokens[__COUNT_TOKEN__] = { "DateTime", @@ -37,7 +36,8 @@ static const char *Tokens[__COUNT_TOKEN__] = { "CanScrollDown" }; -std::string txToken::Token(const txToken &Token) { +std::string txToken::Token(const txToken &Token) +{ std::string result = (std::string)"{" + Tokens[Token.Type]; //if (Token.Attrib.length() > 0) // result += ":" + Token.Attrib; @@ -46,17 +46,22 @@ std::string txToken::Token(const txToken &Token) { return result; } -cxString::cxString(void) { +cxString::cxString(cxSkin *Skin): + mSkin(Skin) +{ } -bool cxString::Parse(const std::string &Text) { - const char *text = Text.c_str(); +bool cxString::Parse(const std::string &Text) +{ + std::string trans = mSkin->Translate(Text); + const char *text = trans.c_str(); const char *ptr = text, *last = text; bool inToken = false; bool inAttrib = false; int offset = 0; Dprintf("parsing: %s\n", Text.c_str()); + mOriginal = Text; for (; *ptr; ++ptr) { if (inToken && *ptr == '\\') { diff --git a/xml/string.h b/xml/string.h index f441c9f..e97b5d4 100644 --- a/xml/string.h +++ b/xml/string.h @@ -1,5 +1,5 @@ /* - * $Id: string.h,v 1.4 2004/12/28 01:24:35 lordjaxom Exp $ + * $Id: string.h,v 1.5 2005/01/01 23:44:36 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_XML_STRING_H @@ -164,15 +164,20 @@ inline bool operator< (const txToken &A, const txToken &B) : A.Type < B.Type; } +class cxSkin; + class cxString { private: std::string mText; + std::string mOriginal; std::vector<txToken> mTokens; + cxSkin *mSkin; public: - cxString(void); + cxString(cxSkin *Skin); bool Parse(const std::string &Text); + bool Parse(void) { return Parse(mOriginal); } cxType Evaluate(void) const; void SetListIndex(uint Index, int Tab); |