summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlordjaxom <lordjaxom>2004-12-14 20:05:40 +0000
committerlordjaxom <lordjaxom>2004-12-14 20:05:40 +0000
commitb8f29c674cc0ccca207123342c1344bbd0f13796 (patch)
tree2af468bf7acc6df510241c1090d7e6538b6b3cf1
parent3b0999969632e2820b846ca8adcef6b346ff7441 (diff)
downloadvdr-plugin-text2skin-b8f29c674cc0ccca207123342c1344bbd0f13796.tar.gz
vdr-plugin-text2skin-b8f29c674cc0ccca207123342c1344bbd0f13796.tar.bz2
1.0-pre4v1.0-pre4
-rw-r--r--Makefile2
-rw-r--r--bitmap.c58
-rw-r--r--bitmap.h7
-rw-r--r--cache.c69
-rw-r--r--cache.h61
-rw-r--r--common.c30
-rw-r--r--common.h6
-rw-r--r--display.c131
-rw-r--r--display.h17
-rw-r--r--font.c7
-rw-r--r--graphtft/font.c65
-rw-r--r--graphtft/font.h5
-rw-r--r--loader.c7
-rw-r--r--render.c36
-rw-r--r--render.h21
-rw-r--r--text2skin.c4
-rw-r--r--xml/function.c4
-rw-r--r--xml/function.h2
-rw-r--r--xml/object.c65
-rw-r--r--xml/object.h9
-rw-r--r--xml/parser.c10
-rw-r--r--xml/string.c5
-rw-r--r--xml/string.h5
-rw-r--r--xml/type.c2
-rw-r--r--xml/type.h4
-rw-r--r--xml/xml.c2
26 files changed, 407 insertions, 227 deletions
diff --git a/Makefile b/Makefile
index 9dd7165..c8bf7ed 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ HAVE_FREETYPE=1
# DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING
# -------------------------------------------------------------
#
-# $Id: Makefile,v 1.8 2004/12/09 12:43:14 lordjaxom Exp $
+# $Id: Makefile,v 1.9 2004/12/12 20:26:25 lordjaxom Exp $
#
# The official name of this plugin.
diff --git a/bitmap.c b/bitmap.c
index 0cbc417..227151e 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -1,5 +1,5 @@
/*
- * $Id: bitmap.c,v 1.3 2004/12/08 18:47:37 lordjaxom Exp $
+ * $Id: bitmap.c,v 1.6 2004/12/14 20:02:31 lordjaxom Exp $
*/
#include "bitmap.h"
@@ -18,21 +18,24 @@ using namespace Magick;
cText2SkinCache cText2SkinBitmap::mCache(Text2SkinSetup.MaxCacheFill);
cText2SkinBitmap *cText2SkinBitmap::Load(const std::string &Filename, int Alpha, int height, int width, int colors) {
- if (mCache.Contains(Filename))
- return mCache[Filename];
+ tBitmapSpec spec(Filename, Alpha, height, width, colors);
+
+ cText2SkinBitmap *res = NULL;
+ if (mCache.Contains(spec))
+ res = mCache[spec];
else {
- cText2SkinBitmap *bmp = new cText2SkinBitmap;
+ res = new cText2SkinBitmap;
int len = Filename.length();
bool result = false;
if (len > 4) {
if (Filename.substr(len - 4, 4) == ".xpm")
- result = bmp->LoadXpm(Filename.c_str());
+ result = res->LoadXpm(Filename.c_str());
else {
#ifdef HAVE_IMLIB2
- result = bmp->LoadImlib(Filename.c_str(),height,width,colors);
+ result = res->LoadImlib(Filename.c_str(),height,width,colors, false);
#else
# ifdef HAVE_IMAGEMAGICK
- result = bmp->LoadMagick(Filename.c_str(),height,width,colors);
+ result = res->LoadMagick(Filename.c_str(),height,width,colors, false);
# else
esyslog("ERROR: text2skin: unknown file format for %s", Filename);
# endif
@@ -42,12 +45,38 @@ cText2SkinBitmap *cText2SkinBitmap::Load(const std::string &Filename, int Alpha,
esyslog("ERROR: text2skin: filename %s too short to identify format", Filename.c_str());
if (result) {
- bmp->SetAlpha(Alpha);
- return (mCache[Filename] = bmp);
+ res->SetAlpha(Alpha);
+ mCache[spec] = res;
} else
- delete bmp;
+ DELETENULL(res);
}
- return false;
+ return res;
+}
+
+bool cText2SkinBitmap::Available(const std::string &Filename)
+{
+ bool res = false;
+ if (mCache.Contains(Filename))
+ res = true;
+ else {
+ cText2SkinBitmap *bmp = new cText2SkinBitmap;
+ int len = Filename.length();
+ if (len > 4) {
+ if (Filename.substr(len - 4, 4) == ".xpm")
+ res = bmp->LoadXpm(Filename.c_str());
+ else {
+#ifdef HAVE_IMLIB2
+ res = bmp->LoadImlib(Filename.c_str(), 0, 0, 0, true);
+#else
+# ifdef HAVE_IMAGEMAGICK
+ res = bmp->LoadMagick(Filename.c_str(), 0, 0, 0, true);
+# endif
+#endif
+ }
+ }
+ delete bmp;
+ }
+ return res;
}
cText2SkinBitmap::cText2SkinBitmap(void) {
@@ -110,7 +139,7 @@ bool cText2SkinBitmap::LoadXpm(const char *Filename) {
}
#ifdef HAVE_IMLIB2
-bool cText2SkinBitmap::LoadImlib(const char *Filename, int height, int width, int colors) {
+bool cText2SkinBitmap::LoadImlib(const char *Filename, int height, int width, int colors, bool Quiet) {
Imlib_Image image;
unsigned char * outputImage = NULL;
unsigned int * outputPalette = NULL;
@@ -155,7 +184,7 @@ bool cText2SkinBitmap::LoadImlib(const char *Filename, int height, int width, in
#endif
#ifdef HAVE_IMAGEMAGICK
-bool cText2SkinBitmap::LoadMagick(const char *Filename, int height, int width, int colors) {
+bool cText2SkinBitmap::LoadMagick(const char *Filename, int height, int width, int colors, bool Quiet) {
std::vector<Image> images;
cBitmap *bmp = NULL;
try {
@@ -197,7 +226,8 @@ bool cText2SkinBitmap::LoadMagick(const char *Filename, int height, int width, i
mBitmaps.push_back(bmp);
}
} catch (Exception &e) {
- esyslog("ERROR: text2skin: Couldn't load %s: %s", Filename, e.what());
+ if (!Quiet)
+ esyslog("ERROR: text2skin: Couldn't load %s: %s", Filename, e.what());
delete bmp;
return false;
}
diff --git a/bitmap.h b/bitmap.h
index 632408e..9bfa984 100644
--- a/bitmap.h
+++ b/bitmap.h
@@ -1,5 +1,5 @@
/*
- * $Id: bitmap.h,v 1.2 2004/12/08 18:47:37 lordjaxom Exp $
+ * $Id: bitmap.h,v 1.4 2004/12/14 13:13:10 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_BITMAP_H
@@ -23,6 +23,7 @@ private:
public:
static cText2SkinBitmap *Load(const std::string &Filename, int Alpha = 0, int height = 0, int width = 0, int colors = 0);
+ static bool Available(const std::string &Filename);
static void ResetCache(void) { mCache.Reset(); }
static void FlushCache(void) { mCache.Flush(); }
@@ -35,10 +36,10 @@ public:
bool LoadXpm(const char *Filename);
#ifdef HAVE_IMLIB2
- bool LoadImlib(const char *Filename,int height = 0, int width = 0, int colors = 0);
+ bool LoadImlib(const char *Filename,int height, int width, int colors, bool Quiet);
#endif
#ifdef HAVE_IMAGEMAGICK
- bool LoadMagick(const char *Filename,int height = 0, int width = 0, int colors = 0);
+ bool LoadMagick(const char *Filename,int height, int width, int colors, bool Quiet);
#endif
};
diff --git a/cache.c b/cache.c
index 6c3f99a..0c2cfaf 100644
--- a/cache.c
+++ b/cache.c
@@ -1,5 +1,5 @@
/*
- * $Id: cache.c,v 1.2 2004/06/18 16:08:11 lordjaxom Exp $
+ * $Id: cache.c,v 1.4 2004/12/14 20:02:31 lordjaxom Exp $
*/
#include "cache.h"
@@ -19,39 +19,56 @@ void cText2SkinCache::Delete(const key_type &Key, data_type &Data) {
void cText2SkinCache::Flush(void) {
mUsage.clear();
- item_iterator it = mItems.begin();
- for (; it != mItems.end(); ++it)
- Delete((*it).first, (*it).second);
- mItems.clear();
+ name_iterator it = mNames.begin();
+ for (; it != mNames.end(); ++it) {
+ item_iterator it2 = (*it).second.begin();
+ for (; it2 != (*it).second.end(); ++it2)
+ Delete((*it2).first, (*it2).second);
+ (*it).second.clear();
+ }
+ mNames.clear();
}
void cText2SkinCache::Reset(void) {
- item_iterator it = mItems.begin();
- for (; it != mItems.end(); ++it)
- (*it).second->Reset();
+ name_iterator it = mNames.begin();
+ for (; it != mNames.end(); ++it) {
+ item_iterator it2 = (*it).second.begin();
+ for (; it2 != (*it).second.end(); ++it2)
+ (*it2).second->Reset();
+ }
}
cText2SkinCache::data_type &cText2SkinCache::operator[](const key_type &Key) {
- item_iterator it = mItems.find(Key);
- if (it != mItems.end()) {
- usage_iterator ut = mUsage.begin();
- for (; ut != mUsage.end(); ++ut) {
- if ((*ut) == Key) {
- mUsage.erase(ut);
- break;
- }
- }
- mUsage.push_back(Key);
- } else {
- if ((int)mItems.size() == mMaxItems) {
+ name_iterator it = mNames.find(Key.Filename);
+ if (it != mNames.end()) {
+ item_iterator it2 = (*it).second.find(Key);
+ if (it2 != (*it).second.end()) {
usage_iterator ut = mUsage.begin();
- Delete(*ut, mItems[*ut]);
- mItems.erase(*ut);
- mUsage.erase(mUsage.begin());
+ for (; ut != mUsage.end(); ++ut) {
+ if ((*ut) == Key) {
+ mUsage.erase(ut);
+ break;
+ }
+ }
+ mUsage.push_back(Key);
+ return (*it2).second;
}
- it = mItems.insert(item_map::value_type(Key, data_type())).first;
- mUsage.push_back(Key);
}
- return (*it).second;
+
+ if (it == mNames.end())
+ it = mNames.insert(name_map::value_type(Key.Filename, item_map())).first;
+
+ if ((int)mUsage.size() == mMaxItems) {
+ usage_iterator ut = mUsage.begin();
+ Delete(*ut, (*it).second[*ut]);
+ (*it).second.erase(*ut);
+ if ((*it).second.size() == 0)
+ mNames.erase((*ut).Filename);
+ mUsage.erase(mUsage.begin());
+ }
+
+ item_iterator it2 = (*it).second.insert(item_map::value_type(Key, data_type())).first;
+ mUsage.push_back(Key);
+ return (*it2).second;
}
diff --git a/cache.h b/cache.h
index 61b77e2..3d26055 100644
--- a/cache.h
+++ b/cache.h
@@ -1,11 +1,12 @@
/*
- * $Id: cache.h,v 1.5 2004/06/18 16:08:11 lordjaxom Exp $
+ * $Id: cache.h,v 1.3 2004/12/14 20:02:31 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_CACHE_HPP
#define VDR_TEXT2SKIN_CACHE_HPP
#include "common.h"
+#include "xml/object.h"
#include <vdr/tools.h>
#include <map>
#include <vector>
@@ -13,17 +14,59 @@
class cText2SkinBitmap;
+struct tBitmapSpec {
+ std::string Filename;
+ int Alpha;
+ int Width;
+ int Height;
+ int Colors;
+
+ tBitmapSpec(const std::string &filename, int alpha, int width, int height, int colors):
+ Filename(filename), Alpha(alpha), Width(width), Height(height), Colors(colors) {}
+
+ bool operator<(const tBitmapSpec &Src) const;
+ bool operator==(const tBitmapSpec &Src) const;
+};
+
+inline bool tBitmapSpec::operator<(const tBitmapSpec &Src) const
+{
+ if (Filename == Src.Filename) {
+ if (Alpha == Src.Alpha) {
+ if (Width == Src.Width) {
+ if (Height == Src.Height)
+ return Colors < Src.Colors;
+ return Height < Src.Height;
+ }
+ return Width < Src.Width;
+ }
+ return Alpha < Src.Alpha;
+ }
+ return Filename < Src.Filename;
+}
+
+inline bool tBitmapSpec::operator==(const tBitmapSpec &Src) const
+{
+ return Filename == Src.Filename
+ && Alpha == Src.Alpha
+ && Width == Src.Width
+ && Height == Src.Height
+ && Colors == Src.Colors;
+}
+
class cText2SkinCache {
private:
- typedef std::string key_type;
+ typedef std::string name_type;
+ typedef tBitmapSpec key_type;
typedef cText2SkinBitmap* data_type;
typedef std::map<key_type,data_type> item_map;
typedef item_map::iterator item_iterator;
+ typedef std::map<name_type,item_map> name_map;
+ typedef name_map::iterator name_iterator;
typedef std::vector<key_type> usage_list;
typedef usage_list::iterator usage_iterator;
- item_map mItems;
+ name_map mNames;
usage_list mUsage;
int mMaxItems;
@@ -37,12 +80,20 @@ public:
void Reset(void);
void Flush(void);
bool Contains(const key_type &Key);
+ bool Contains(const name_type &Name);
data_type &operator[](const key_type &Key);
- uint Count(void) { return mItems.size(); }
+ uint Count(void) { return mUsage.size(); }
};
inline bool cText2SkinCache::Contains(const key_type &Key) {
- return mItems.find(Key) != mItems.end();
+ name_iterator it = mNames.find(Key.Filename);
+ if (it != mNames.end())
+ return (*it).second.find(Key) != (*it).second.end();
+ return false;
+}
+
+inline bool cText2SkinCache::Contains(const name_type &Key) {
+ return mNames.find(Key) != mNames.end();
}
#endif // VDR_TEXT2SKIN_CACHE_HPP
diff --git a/common.c b/common.c
index 42e4e4f..7a45a02 100644
--- a/common.c
+++ b/common.c
@@ -1,12 +1,14 @@
/*
- * $Id: common.c,v 1.2 2004/12/06 22:35:54 lordjaxom Exp $
+ * $Id: common.c,v 1.4 2004/12/14 20:02:31 lordjaxom Exp $
*/
#include "common.h"
#include <vdr/plugin.h>
-std::string SkinPath(void) {
- return cPlugin::ConfigDirectory(PLUGIN_NAME_I18N);
+const std::string &SkinPath(void) {
+ // should never change
+ static std::string path = cPlugin::ConfigDirectory(PLUGIN_NAME_I18N);
+ return path;
}
const char *ChannelNumber(const cChannel *Channel, int Number) {
@@ -24,15 +26,17 @@ const char *ChannelNumber(const cChannel *Channel, int Number) {
const char *ChannelName(const cChannel *Channel, int Number) {
static char buffer[256];
buffer[0] = '\0';
- if (Channel)
+ if (Channel)
snprintf(buffer, sizeof(buffer), "%s", Channel->Name());
else if (!Number)
snprintf(buffer, sizeof(buffer), "%s", tr("*** Invalid Channel ***"));
+#if VDRVERSNUM < 10315
char *ptr;
if ((ptr = strchr(buffer, ',')) != NULL
|| (ptr = strchr(buffer, ';')) != NULL)
*ptr = '\0';
+#endif
return buffer;
}
@@ -40,10 +44,15 @@ const char *ChannelShortName(const cChannel *Channel, int Number) {
static char buffer[256];
buffer[0] = '\0';
if (Channel)
+#if VDRVERSNUM < 10315
snprintf(buffer, sizeof(buffer), "%s", Channel->Name());
+#else
+ snprintf(buffer, sizeof(buffer), "%s", Channel->ShortName(true));
+#endif
else if (!Number)
snprintf(buffer, sizeof(buffer), "%s", tr("*** Invalid Channel ***"));
+#if VDRVERSNUM < 10315
char *ptr;
if ((ptr = strchr(buffer, ',')) != NULL) {
char *start = ptr + 1;
@@ -52,25 +61,34 @@ const char *ChannelShortName(const cChannel *Channel, int Number) {
return start;
} else if ((ptr = strchr(buffer, ';')) != NULL)
*ptr = '\0';
+#endif
return buffer;
}
-
+/*
const char *ChannelBouquet(const cChannel *Channel, int Number) {
static char buffer[256];
buffer[0] = '\0';
if (Channel)
+#if VDRVERSNUM < 10315
snprintf(buffer, sizeof(buffer), "%s", Channel->Name());
+#else
+ snprintf(buffer, sizeof(buffer), "%s", Channel->Provider());
+#endif
else if (!Number)
snprintf(buffer, sizeof(buffer), "%s", tr("*** Invalid Channel ***"));
+#if VDRVERSNUM < 10315
char *ptr;
if ((ptr = strchr(buffer, ';')) != NULL)
return ptr + 1;
else
return "";
+#else
+ return buffer;
+#endif
}
-
+*/
cxType TimeType(time_t Time, const std::string &Format) {
static char result[1000];
struct tm tm_r, *tm;
diff --git a/common.h b/common.h
index 12987d8..52d1ad4 100644
--- a/common.h
+++ b/common.h
@@ -1,5 +1,5 @@
/*
- * $Id: common.h,v 1.3 2004/12/08 17:13:25 lordjaxom Exp $
+ * $Id: common.h,v 1.5 2004/12/14 20:02:31 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_COMMON_H
@@ -29,11 +29,11 @@ class cChannel;
// helper functions
-std::string SkinPath(void);
+const std::string &SkinPath(void);
const char *ChannelNumber(const cChannel *Channel, int Number);
const char *ChannelName(const cChannel *Channel, int Number);
const char *ChannelShortName(const cChannel *Channel, int Number);
-const char *ChannelBouquet(const cChannel *Channel, int Number);
+//const char *ChannelBouquet(const cChannel *Channel, int Number);
cxType TimeType(time_t Time, const std::string &Format);
diff --git a/display.c b/display.c
index b3d0d5f..2a6c25f 100644
--- a/display.c
+++ b/display.c
@@ -1,5 +1,5 @@
/*
- * $Id: display.c,v 1.6 2004/12/10 21:46:46 lordjaxom Exp $
+ * $Id: display.c,v 1.9 2004/12/14 20:02:31 lordjaxom Exp $
*/
#include "render.h"
@@ -19,14 +19,16 @@ cText2SkinDisplayChannel::cText2SkinDisplayChannel(cText2SkinLoader *Loader, boo
mPresent(NULL),
mFollowing(NULL),
mType(mtStatus),
- mText("") {
+ mText("")
+{
}
-cText2SkinDisplayChannel::~cText2SkinDisplayChannel() {
- Dprintf("~cTe...\n");
+cText2SkinDisplayChannel::~cText2SkinDisplayChannel()
+{
}
-void cText2SkinDisplayChannel::SetChannel(const cChannel *Channel, int Number) {
+void cText2SkinDisplayChannel::SetChannel(const cChannel *Channel, int Number)
+{
if (mChannel != Channel || mNumber != Number) {
mChannel = Channel;
mNumber = Number;
@@ -34,8 +36,8 @@ void cText2SkinDisplayChannel::SetChannel(const cChannel *Channel, int Number) {
}
}
-void cText2SkinDisplayChannel::SetEvents(const cEvent *Present,
- const cEvent *Following) {
+void cText2SkinDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Following)
+{
if (mPresent != Present || mFollowing != Following) {
mPresent = Present;
mFollowing = Following;
@@ -43,7 +45,8 @@ void cText2SkinDisplayChannel::SetEvents(const cEvent *Present,
}
}
-void cText2SkinDisplayChannel::SetMessage(eMessageType Type, const char *Text) {
+void cText2SkinDisplayChannel::SetMessage(eMessageType Type, const char *Text)
+{
if (Text == NULL) Text = "";
if (mType != Type || mText != Text) {
mType = Type;
@@ -52,55 +55,63 @@ void cText2SkinDisplayChannel::SetMessage(eMessageType Type, const char *Text) {
}
}
-void cText2SkinDisplayChannel::SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue) {
+void cText2SkinDisplayChannel::SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue)
+{
Dprintf("SetButtons(%s, %s, %s, %s)\n", Red, Green, Yellow, Blue);
}
-void cText2SkinDisplayChannel::Flush(void) {
- cText2SkinRender::Flush();
-}
-
-cxType cText2SkinDisplayChannel::GetTokenData(const txToken &Token) {
+cxType cText2SkinDisplayChannel::GetTokenData(const txToken &Token)
+{
switch (Token.Type) {
case tChannelNumber:
return mChannel != NULL
? (cxType)ChannelNumber(mChannel, mNumber)
- : (cxType)false;
+ : (cxType)false;
case tChannelName:
return mChannel != NULL
? (cxType)ChannelName(mChannel, mNumber)
- : (cxType)false;
+ : (cxType)false;
case tChannelShortName:
return mChannel != NULL
? (cxType)ChannelShortName(mChannel, mNumber)
- : (cxType)false;
+ : (cxType)false;
case tChannelBouquet:
return mChannel != NULL
- ? (cxType)ChannelBouquet(mChannel, mNumber)
- : (cxType)false;
-
+ ? (cxType)mChannel->Provider()
+ : (cxType)false;
+
+ case tChannelPortal:
+ return mChannel != NULL
+ ? (cxType)mChannel->PortalName()
+ : (cxType)false;
+
+ case tChannelSource:
+ return mChannel != NULL
+ ? (cxType)Sources.Get(mChannel->Source())->Description()
+ : (cxType)false;
+
case tPresentStartDateTime:
return mPresent != NULL
? (cxType)TimeType(mPresent->StartTime(), Token.Attrib)
- : (cxType)false;
+ : (cxType)false;
case tPresentVPSDateTime:
return mPresent != NULL
? (cxType)TimeType(mPresent->Vps(), Token.Attrib)
- : (cxType)false;
+ : (cxType)false;
case tPresentEndDateTime:
return mPresent != NULL
? (cxType)TimeType(mPresent->EndTime(), Token.Attrib)
- : (cxType)false;
+ : (cxType)false;
case tPresentProgress:
return mPresent != NULL
? (cxType)TimeType(time(NULL) - mPresent->StartTime(), Token.Attrib)
- : (cxType)false;
+ : (cxType)false;
case tPresentDuration:
return mPresent != NULL
@@ -110,52 +121,52 @@ cxType cText2SkinDisplayChannel::GetTokenData(const txToken &Token) {
case tPresentTitle:
return mPresent != NULL
? (cxType)mPresent->Title()
- : (cxType)false;
+ : (cxType)false;
case tPresentShortText:
return mPresent != NULL
? (cxType)mPresent->ShortText()
- : (cxType)false;
+ : (cxType)false;
case tPresentDescription:
return mPresent != NULL
? (cxType)mPresent->Description()
- : (cxType)false;
+ : (cxType)false;
case tFollowingStartDateTime:
return mFollowing != NULL
? (cxType)TimeType(mFollowing->StartTime(), Token.Attrib)
- : (cxType)false;
+ : (cxType)false;
case tFollowingVPSDateTime:
return mFollowing != NULL
? (cxType)TimeType(mFollowing->Vps(), Token.Attrib)
- : (cxType)false;
+ : (cxType)false;
case tFollowingEndDateTime:
return mFollowing != NULL
? (cxType)TimeType(mFollowing->EndTime(), Token.Attrib)
- : (cxType)false;
+ : (cxType)false;
case tFollowingDuration:
return mFollowing != NULL
? (cxType)TimeType(mFollowing->Duration(), Token.Attrib)
- : (cxType)false;
+ : (cxType)false;
case tFollowingTitle:
return mFollowing != NULL
? (cxType)mFollowing->Title()
- : (cxType)false;
+ : (cxType)false;
case tFollowingShortText:
return mFollowing != NULL
? (cxType)mFollowing->ShortText()
- : (cxType)false;
+ : (cxType)false;
case tFollowingDescription:
return mFollowing != NULL
? (cxType)mFollowing->Description()
- : (cxType)false;
+ : (cxType)false;
case tLanguage: {
int cur;
@@ -203,22 +214,22 @@ cxType cText2SkinDisplayChannel::GetTokenData(const txToken &Token) {
case tMessageInfo:
return mType == mtInfo
? (cxType)mText
- : (cxType)false;
+ : (cxType)false;
case tMessageWarning:
return mType == mtWarning
? (cxType)mText
- : (cxType)false;
+ : (cxType)false;
case tMessageStatus:
return mType == mtStatus
? (cxType)mText
- : (cxType)false;
+ : (cxType)false;
case tMessageError:
return mType == mtError
? (cxType)mText
- : (cxType)false;
+ : (cxType)false;
default: break;
}
@@ -247,10 +258,6 @@ void cText2SkinDisplayVolume::SetVolume(int Current, int Total, bool Mute) {
}
}
-void cText2SkinDisplayVolume::Flush(void) {
- cText2SkinRender::Flush();
-}
-
cxType cText2SkinDisplayVolume::GetTokenData(const txToken &Token) {
switch (Token.Type) {
case tVolumeCurrent:
@@ -354,10 +361,6 @@ void cText2SkinDisplayReplay::SetMessage(eMessageType Type, const char *Text) {
}
}
-void cText2SkinDisplayReplay::Flush(void) {
- cText2SkinRender::Flush();
-}
-
cxType cText2SkinDisplayReplay::GetTokenData(const txToken &Token) {
switch (Token.Type) {
case tReplayTitle:
@@ -379,40 +382,40 @@ cxType cText2SkinDisplayReplay::GetTokenData(const txToken &Token) {
return mPrompt;
case tIsPlaying:
- return mStateInfo && (mSpeed == -1 && mPlay);
+ return mStateInfo && mSpeed == -1 && mPlay;
case tIsPausing:
- return mStateInfo && (mSpeed == -1 && !mPlay);
+ return mStateInfo && mSpeed == -1 && !mPlay;
case tIsFastForward:
- if (mStateInfo && (mSpeed != -1 && mPlay && mForward)) {
+ if (mStateInfo && mSpeed != -1 && mPlay && mForward) {
return Token.Attrib.length() > 0
? (cxType)(mSpeed == atoi(Token.Attrib.c_str()))
- : (cxType)true;
+ : (cxType)true;
}
return false;
case tIsFastRewind:
- if (mStateInfo && (mSpeed != -1 && mPlay && !mForward)) {
+ if (mStateInfo && mSpeed != -1 && mPlay && !mForward) {
return Token.Attrib.length() > 0
? (cxType)(mSpeed == atoi(Token.Attrib.c_str()))
- : (cxType)true;
+ : (cxType)true;
}
return false;
case tIsSlowForward:
- if (mStateInfo && (mSpeed != -1 && !mPlay && mForward)) {
+ if (mStateInfo && mSpeed != -1 && !mPlay && mForward) {
return Token.Attrib.length() > 0
? (cxType)(mSpeed == atoi(Token.Attrib.c_str()))
- : (cxType)true;
+ : (cxType)true;
}
return false;
case tIsSlowRewind:
- if (mStateInfo && (mSpeed != -1 && !mPlay && !mForward)) {
+ if (mStateInfo && mSpeed != -1 && !mPlay && !mForward) {
return Token.Attrib.length() > 0
? (cxType)(mSpeed == atoi(Token.Attrib.c_str()))
- : (cxType)true;
+ : (cxType)true;
}
return false;
@@ -422,22 +425,22 @@ cxType cText2SkinDisplayReplay::GetTokenData(const txToken &Token) {
case tMessageInfo:
return mType == mtInfo
? (cxType)mText
- : (cxType)false;
+ : (cxType)false;
case tMessageWarning:
return mType == mtWarning
? (cxType)mText
- : (cxType)false;
+ : (cxType)false;
case tMessageStatus:
return mType == mtStatus
? (cxType)mText
- : (cxType)false;
+ : (cxType)false;
case tMessageError:
return mType == mtError
? (cxType)mText
- : (cxType)false;
+ : (cxType)false;
case tReplayMode:
return cText2SkinStatus::ReplayMode();
@@ -467,10 +470,6 @@ void cText2SkinDisplayMessage::SetMessage(eMessageType Type, const char *Text) {
}
}
-void cText2SkinDisplayMessage::Flush(void) {
- cText2SkinRender::Flush();
-}
-
cxType cText2SkinDisplayMessage::GetTokenData(const txToken &Token) {
switch (Token.Type) {
case tMessage:
@@ -649,10 +648,6 @@ void cText2SkinDisplayMenu::Scroll(bool Up, bool Page) {
SetDirty();
}
-void cText2SkinDisplayMenu::Flush(void) {
- cText2SkinRender::Flush();
-}
-
cxType cText2SkinDisplayMenu::GetTokenData(const txToken &Token) {
switch (Token.Type) {
case tMenuItem:
diff --git a/display.h b/display.h
index f12bb83..1c540d4 100644
--- a/display.h
+++ b/display.h
@@ -1,5 +1,5 @@
/*
- * $Id: display.h,v 1.5 2004/12/10 21:46:46 lordjaxom Exp $
+ * $Id: display.h,v 1.7 2004/12/14 20:02:31 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_SKIN_H
@@ -35,7 +35,8 @@ public:
virtual void SetEvents(const cEvent *Present, const cEvent *Following);
virtual void SetMessage(eMessageType Type, const char *Text);
virtual void SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue);
- virtual void Flush(void);
+
+ virtual void Flush(void) { cText2SkinRender::Flush(); }
};
class cText2SkinDisplayVolume: public cSkinDisplayVolume, public cText2SkinRender {
@@ -51,7 +52,8 @@ public:
cText2SkinDisplayVolume(cText2SkinLoader *Loader);
virtual ~cText2SkinDisplayVolume();
virtual void SetVolume(int Current, int Total, bool Mute);
- virtual void Flush(void);
+
+ virtual void Flush(void) { cText2SkinRender::Flush(); }
};
class cText2SkinDisplayReplay: public cSkinDisplayReplay, public cText2SkinRender {
@@ -85,7 +87,8 @@ public:
virtual void SetTotal(const char *Total);
virtual void SetJump(const char *Jump);
virtual void SetMessage(eMessageType Type, const char *Text);
- virtual void Flush(void);
+
+ virtual void Flush(void) { cText2SkinRender::Flush(); }
};
class cText2SkinDisplayMessage: public cSkinDisplayMessage, public cText2SkinRender {
@@ -100,7 +103,8 @@ public:
cText2SkinDisplayMessage(cText2SkinLoader *Loader);
virtual ~cText2SkinDisplayMessage();
virtual void SetMessage(eMessageType Type, const char *Text);
- virtual void Flush(void);
+
+ virtual void Flush(void) { cText2SkinRender::Flush(); }
};
class cText2SkinDisplayMenu: public cSkinDisplayMenu, public cText2SkinRender {
@@ -158,7 +162,8 @@ public:
virtual void SetText(const char *Text, bool FixedFont);
virtual void SetTabs(int Tab1, int Tab2, int Tab3, int Tab4, int Tab5);
virtual void Scroll(bool Up, bool Page);
- virtual void Flush(void);
+
+ virtual void Flush(void) { cText2SkinRender::Flush(); }
};
inline bool cText2SkinDisplayMenu::HasTabText(int Index, int n)
diff --git a/font.c b/font.c
index 7320f8a..ff26fea 100644
--- a/font.c
+++ b/font.c
@@ -1,5 +1,5 @@
/*
- * $Id: font.c,v 1.5 2004/12/08 17:23:17 lordjaxom Exp $
+ * $Id: font.c,v 1.6 2004/12/14 20:02:31 lordjaxom Exp $
*/
#include "font.h"
@@ -30,8 +30,9 @@ const cFont *cText2SkinFont::Load(const std::string &Path, const std::string &Fi
const cFont *res = NULL;
#ifdef HAVE_FREETYPE
char *cachename;
- asprintf(&cachename, "%s_%d", Filename.c_str(), Size);
- if (mFontCache.Load(Path + "/" + Filename, cachename, Size))
+ asprintf(&cachename, "%s_%d_%d", Filename.c_str(), Size, Setup.OSDLanguage);
+ Dprintf("trying now: %s %s\n", (Path + "/" + Filename).c_str(), cachename);
+ if (mFontCache.Load(Path + "/" + Filename, cachename, Size, Setup.OSDLanguage))
res = mFontCache.GetFont(cachename);
else
esyslog("ERROR: Text2Skin: Couldn't load font %s:%d", Filename.c_str(), Size);
diff --git a/graphtft/font.c b/graphtft/font.c
index e38b283..54b6083 100644
--- a/graphtft/font.c
+++ b/graphtft/font.c
@@ -1,10 +1,11 @@
/*
- * $Id: font.c,v 1.3 2004/12/09 12:43:14 lordjaxom Exp $
+ * $Id: font.c,v 1.6 2004/12/14 20:02:31 lordjaxom Exp $
*
* Taken from GraphTFT
*/
#include "font.h"
+#include <iconv.h>
#include <stdio.h>
cGraphtftFont::cGraphtftFont()
@@ -16,7 +17,7 @@ cGraphtftFont::cGraphtftFont()
int error = FT_Init_FreeType(&_library);
if (error)
{
- fprintf(stderr, "ERROR: Could not init freetyie library\n");
+ esyslog("ERROR: Could not init freetype library");
}
}
@@ -35,22 +36,22 @@ cGraphtftFont::~cGraphtftFont()
}
}
-bool cGraphtftFont::Load(string Filename, string CacheName, int Size, int Width)
+bool cGraphtftFont::Load(string Filename, string CacheName, int Size, int Language, int Width, int format)
{
if ( _cache.find(CacheName) != _cache.end() )
return true;
- int error = FT_New_Face(_library, Filename.c_str(), 0, &_face);
+ int error = FT_New_Face(_library, Filename.c_str(), format, &_face);
// every thing ok?
if (error == FT_Err_Unknown_File_Format)
{
- fprintf(stderr, "ERROR: Font file (%s) could be opened and read, but it appears that its font format is unsupported\n", Filename.c_str());
+ esyslog("ERROR: Font file (%s) could be opened and read, but it appears that its font format is unsupported", Filename.c_str());
return false;
}
else if (error)
{
- fprintf(stderr, "ERROR: Font file (%s) could be opened or read, or simply it is broken\n", Filename.c_str());
+ esyslog("ERROR: Font file (%s) could be opened or read, or simply it is broken", Filename.c_str());
return false;
}
@@ -67,6 +68,52 @@ bool cGraphtftFont::Load(string Filename, string CacheName, int Size, int Width)
0 // vertical device resolution (dpi)
);
+ iconv_t cd;
+ char from_code[255];
+ wchar_t utf_buff[256];
+
+ // XXX: Get this values from i18n
+ switch(Language) {
+ case 11:
+ strcpy(from_code,"ISO8859-7");
+ break;
+ case 13:
+ case 17:
+ strcpy(from_code,"ISO8859-2");
+ break;
+ case 16:
+ strcpy(from_code,"ISO8859-5");
+ break;
+ default :
+ strcpy(from_code,"ISO8859-15");
+ break;
+ }
+
+ if ((cd = iconv_open("WCHAR_T",from_code)) == (iconv_t)-1) {
+ esyslog("ERROR: Iconv encoding not supported: %m");
+ return false; //encoding no supportet
+ }
+
+ for (int c = 0; c < 256; c++) {
+
+ char char_buff = c;
+ wchar_t wchar_buff;
+
+ char *in_buff,*out_buff;
+ size_t in_len, out_len, count;
+
+ in_len=1; out_len=4;
+ in_buff=(char*)&char_buff;
+ out_buff=(char *)&wchar_buff;
+ count = iconv(cd,&in_buff,&in_len,&out_buff,&out_len);
+ if ( (size_t)-1 == count ){
+ //printf("ERROR - PREPARING TABLE CHAR %d \n", c);
+ utf_buff[c] = 0;
+ }
+ utf_buff[c] = wchar_buff;
+ }
+ iconv_close(cd);
+
/* load glyph image into the slot (erase previous one) */
error = FT_Load_Char( _face, '_', FT_LOAD_RENDER );
if ( error )
@@ -80,7 +127,7 @@ bool cGraphtftFont::Load(string Filename, string CacheName, int Size, int Width)
for (int i = 0; i < 225; i++)
for (int j = 0; j < num_rows; j++)
- font_data[(i*num_rows)+j]=0x00;
+ font_data[(i*num_rows)+j]=0x0000000000000000;
font_data[0+0]=_slot->bitmap.width+2;
font_data[0+1]=num_rows_global;
@@ -91,13 +138,13 @@ bool cGraphtftFont::Load(string Filename, string CacheName, int Size, int Width)
{
//Get FT char index
- glyph_index = FT_Get_Char_Index( _face, num_char );
+ glyph_index = FT_Get_Char_Index( _face, utf_buff[num_char] );
//Load the char
error = FT_Load_Glyph( _face, glyph_index, FT_LOAD_DEFAULT );
if ( error ) continue; /* ignore errors */
- // convert to an mono bitmap
+ // convert to a mono bitmap
error = FT_Render_Glyph( _face->glyph, ft_render_mode_mono );
if ( error ) continue;
diff --git a/graphtft/font.h b/graphtft/font.h
index 5e23498..8969287 100644
--- a/graphtft/font.h
+++ b/graphtft/font.h
@@ -1,5 +1,5 @@
/*
- * $Id: font.h,v 1.2 2004/12/06 21:19:07 lordjaxom Exp $
+ * $Id: font.h,v 1.5 2004/12/14 20:02:31 lordjaxom Exp $
*
* Taken from GraphTFT
*/
@@ -13,6 +13,7 @@
#include <ft2build.h>
#include FT_FREETYPE_H
#include <vdr/font.h>
+#include <vdr/config.h>
using std::map;
using std::string;
@@ -29,7 +30,7 @@ public:
cGraphtftFont();
~cGraphtftFont();
- bool Load(string Filename, string CacheName, int Size, int Width = 0);
+ bool Load(string Filename, string CacheName, int Size, int Language = 0, int Width = 0, int Format = 0);
const cFont* GetFont(string CacheName);
void Clear(string CacheName);
void Clear();
diff --git a/loader.c b/loader.c
index d4bc27f..6d5db49 100644
--- a/loader.c
+++ b/loader.c
@@ -1,5 +1,5 @@
/*
- * $Id: loader.c,v 1.4 2004/12/08 17:13:25 lordjaxom Exp $
+ * $Id: loader.c,v 1.6 2004/12/14 20:02:31 lordjaxom Exp $
*/
#include "loader.h"
@@ -24,7 +24,8 @@ void cText2SkinLoader::Start(void) {
if (strcmp(result->d_name, ".") == 0 || strcmp(result->d_name, "..") == 0)
continue;
asprintf(&path, "%s/%s", SkinPath().c_str(), result->d_name);
- if (stat(path, &buf) == 0 && S_ISDIR(buf.st_mode))
+ if (stat((SkinPath() + "/" + result->d_name).c_str(), &buf) == 0
+ && S_ISDIR(buf.st_mode))
Load(result->d_name);
free(path);
}
@@ -34,7 +35,7 @@ void cText2SkinLoader::Start(void) {
void cText2SkinLoader::Load(const char *Skin) {
cText2SkinI18n *translations = NULL;
- std::string transfile = (std::string)SkinPath() + "/" + Skin + "/" + Skin + ".trans";
+ std::string transfile = SkinPath() + "/" + Skin + "/" + Skin + ".trans";
if (access(transfile.c_str(), F_OK) == 0) {
translations = new cText2SkinI18n(Skin);
if (!translations->Load(transfile))
diff --git a/render.c b/render.c
index 502a3ca..6d1109b 100644
--- a/render.c
+++ b/render.c
@@ -1,5 +1,5 @@
/*
- * $Id: render.c,v 1.7 2004/12/10 21:46:46 lordjaxom Exp $
+ * $Id: render.c,v 1.10 2004/12/14 20:02:31 lordjaxom Exp $
*/
#include "render.h"
@@ -29,8 +29,6 @@ cText2SkinRender::cText2SkinRender(cText2SkinLoader *Loader, cxDisplay::eType Di
mActive(false),
mDoUpdate(),
mDoUpdateMutex(),
- //mDoneUpdate(),
- //mDoneUpdateMutex(),
mStarted(),
mUpdateIn(0),
mBaseSize()
@@ -96,7 +94,8 @@ cText2SkinRender::cText2SkinRender(cText2SkinLoader *Loader, cxDisplay::eType Di
}
}
-cText2SkinRender::~cText2SkinRender() {
+cText2SkinRender::~cText2SkinRender()
+{
if (mActive) {
mActive = false;
Flush(true);
@@ -104,11 +103,12 @@ cText2SkinRender::~cText2SkinRender() {
}
delete mScroller;
delete mScreen;
- cText2SkinBitmap::ResetCache();
+ //cText2SkinBitmap::ResetCache();
mRender = NULL;
}
-void cText2SkinRender::Action(void) {
+void cText2SkinRender::Action(void)
+{
mActive = true;
mDoUpdateMutex.Lock();
mStarted.Broadcast();
@@ -120,15 +120,12 @@ void cText2SkinRender::Action(void) {
mUpdateIn = 0; // has to be re-set within Update();
Update();
-
- //mDoneUpdateMutex.Lock();
- //mDoneUpdate.Broadcast();
- //mDoneUpdateMutex.Unlock();
}
mDoUpdateMutex.Unlock();
}
-void cText2SkinRender::Update(void) {
+void cText2SkinRender::Update(void)
+{
Dbench(update);
for (uint i = 0; i < mDisplay->Objects(); ++i)
@@ -147,7 +144,8 @@ void cText2SkinRender::DrawObject(const cxObject *Object)
switch (Object->Type()) {
case cxObject::image:
- DrawImage(Object->Pos(), Object->Bg(), Object->Fg(), Object->Alpha(), Object->Path());
+ DrawImage(Object->Pos(), Object->Size(), Object->Bg(), Object->Fg(), Object->Alpha(),
+ Object->Colors(), Object->Path());
break;
case cxObject::text:
@@ -245,12 +243,14 @@ void cText2SkinRender::DrawObject(const cxObject *Object)
}
}
-void cText2SkinRender::DrawImage(const txPoint &Pos, const tColor *Bg, const tColor *Fg, int Alpha,
- const std::string &Path)
+void cText2SkinRender::DrawImage(const txPoint &Pos, const txSize &Size, const tColor *Bg,
+ const tColor *Fg, int Alpha, int Colors, const std::string &Path)
{
cText2SkinBitmap *bmp;
Dprintf("trying to draw image %s to %dx%d - alpha %d\n", ImagePath(Path).c_str(), Pos.x, Pos.y, Alpha);
- if ((bmp = cText2SkinBitmap::Load(ImagePath(Path), Alpha)) != NULL) {
+
+ if ((bmp = cText2SkinBitmap::Load(ImagePath(Path), Alpha, Size.h > 1 ? Size.h : 0,
+ Size.w > 1 ? Size.w : 0, Colors)) != NULL) {
//Dprintf("success loading image\n");
if (Bg) bmp->SetColor(0, *Bg);
if (Fg) bmp->SetColor(1, *Fg);
@@ -408,7 +408,7 @@ std::string cText2SkinRender::ImagePath(const std::string &Filename)
{
if (mRender)
return mRender->mBasePath + "/" + Filename;
- return "";
+ return cxFunction::False;
}
/* TODO: translation when parsing
@@ -435,9 +435,9 @@ cxType cText2SkinRender::GetToken(const txToken &Token)
int pos = -1;
if (Token.Type == tMenuCurrent && (pos = str.rfind(' ')) != -1)
- return str.substr(pos + 1);
+ res = str.substr(pos + 1);
else if (Token.Type == tMenuTitle && (pos = str.find(' ')) != -1)
- return str.substr(0, pos);
+ res = str.substr(0, pos);
}
}
return res;
diff --git a/render.h b/render.h
index 0ce7d40..61f5d60 100644
--- a/render.h
+++ b/render.h
@@ -1,5 +1,5 @@
/*
- * $Id: render.h,v 1.6 2004/12/10 21:46:46 lordjaxom Exp $
+ * $Id: render.h,v 1.8 2004/12/14 20:02:31 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_RENDER_H
@@ -48,8 +48,6 @@ private:
cCondVar mDoUpdate;
cMutex mDoUpdateMutex;
- //cCondVar mDoneUpdate;
- //cMutex mDoneUpdateMutex;
cCondVar mStarted;
int mUpdateIn;
@@ -66,10 +64,10 @@ protected:
void DrawObject(const cxObject *Object);
void DrawBackground(const txPoint &Pos, const txSize &Size, const tColor *Bg, const tColor *Fg,
int Alpha, const std::string &Path);
- void DrawImage(const txPoint &Pos, const tColor *Bg, const tColor *Fg, int Alpha,
- const std::string &Path);
- void DrawText(const txPoint &Pos, const txSize &Size, const tColor *Fg,
- const std::string &Text, const cFont *Font, int Align);
+ void DrawImage(const txPoint &Pos, const txSize &Size, const tColor *Bg, const tColor *Fg,
+ int Alpha, int Colors, const std::string &Path);
+ void DrawText(const txPoint &Pos, const txSize &Size, const tColor *Fg, const std::string &Text,
+ const cFont *Font, int Align);
void DrawRectangle(const txPoint &Pos, const txSize &Size,
const tColor *Fg);
void DrawEllipse(const txPoint &Pos, const txSize &Size, const tColor *Fg,
@@ -118,18 +116,9 @@ public:
inline void cText2SkinRender::Flush(bool Force) {
if (mDirty || Force) {
- //mDoneUpdateMutex.Lock();
-
mDoUpdateMutex.Lock();
mDoUpdate.Broadcast();
mDoUpdateMutex.Unlock();
-
- //if (mActive) {
- //Dprintf("flush wait\n");
- //mDoneUpdate.Wait(mDoneUpdateMutex);
- //Dprintf("flush wait done\n");
- //}
- //mDoneUpdateMutex.Unlock();
mDirty = false;
}
diff --git a/text2skin.c b/text2skin.c
index 3c73107..e6b9f7f 100644
--- a/text2skin.c
+++ b/text2skin.c
@@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
- * $Id: text2skin.c,v 1.3 2004/12/10 21:46:46 lordjaxom Exp $
+ * $Id: text2skin.c,v 1.4 2004/12/12 20:26:25 lordjaxom Exp $
*/
#include "text2skin.h"
@@ -12,7 +12,7 @@
#include "i18n.h"
#include "loader.h"
-const char *cText2SkinPlugin::VERSION = "1.0-pre3";
+const char *cText2SkinPlugin::VERSION = "1.0-pre4";
const char *cText2SkinPlugin::SKINVERSION = "1.0";
const char *cText2SkinPlugin::DESCRIPTION = "Loader for text-based skins";
diff --git a/xml/function.c b/xml/function.c
index 3243257..597bece 100644
--- a/xml/function.c
+++ b/xml/function.c
@@ -1,5 +1,5 @@
/*
- * $Id: function.c,v 1.5 2004/12/10 21:46:46 lordjaxom Exp $
+ * $Id: function.c,v 1.7 2004/12/14 13:13:10 lordjaxom Exp $
*/
#include "xml/function.h"
@@ -160,7 +160,7 @@ const std::string &cxFunction::FunFile(const std::string &Param) const
{
std::string path = cText2SkinRender::ImagePath(Param);
Dprintf("checking file(%s) in cache\n", path.c_str());
- return cText2SkinBitmap::Load(path) ? Param : False;
+ return cText2SkinBitmap::Available(path) ? Param : False;
}
std::string cxFunction::FunPlugin(const std::string &Param) const
diff --git a/xml/function.h b/xml/function.h
index 49928af..abd1199 100644
--- a/xml/function.h
+++ b/xml/function.h
@@ -1,5 +1,5 @@
/*
- * $Id: function.h,v 1.4 2004/12/08 18:47:37 lordjaxom Exp $
+ * $Id: function.h,v 1.5 2004/12/12 20:26:25 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_XML_FUNCTION_H
diff --git a/xml/object.c b/xml/object.c
index 6932106..b0b8dc0 100644
--- a/xml/object.c
+++ b/xml/object.c
@@ -1,5 +1,5 @@
/*
- * $Id: object.c,v 1.4 2004/12/08 17:13:26 lordjaxom Exp $
+ * $Id: object.c,v 1.5 2004/12/14 20:02:31 lordjaxom Exp $
*/
#include "xml/object.h"
@@ -15,10 +15,12 @@ cxObject::cxObject(cxDisplay *parent):
mPos1(0, 0),
mPos2(-1, -1),
mAlpha(255),
+ mColors(0),
mArc(0),
mAlign(taDefault),
mCondition(NULL),
- mFont(cFont::GetFont(fontOsd)),
+ mFontFace("Osd"),
+ mFontSize(0),
mObjects(NULL),
mDisplay(parent),
mSkin(parent->Skin())
@@ -30,6 +32,7 @@ cxObject::cxObject(const cxObject &Src):
mPos1(Src.mPos1),
mPos2(Src.mPos2),
mAlpha(Src.mAlpha),
+ mColors(Src.mColors),
mArc(Src.mArc),
mFg(Src.mFg),
mBg(Src.mBg),
@@ -42,7 +45,8 @@ cxObject::cxObject(const cxObject &Src):
mCondition(NULL),
mCurrent(Src.mCurrent),
mTotal(Src.mTotal),
- mFont(Src.mFont),
+ mFontFace(Src.mFontFace),
+ mFontSize(Src.mFontSize),
mObjects(NULL),
mDisplay(Src.mDisplay),
mSkin(Src.mSkin)
@@ -59,7 +63,8 @@ cxObject::~cxObject()
delete mObjects;
}
-bool cxObject::ParseType(const std::string &Text) {
+bool cxObject::ParseType(const std::string &Text)
+{
for (int i = 0; i < (int)__COUNT_OBJECT__; ++i) {
if (ObjectNames[i] == Text) {
mType = (eType)i;
@@ -69,7 +74,8 @@ bool cxObject::ParseType(const std::string &Text) {
return false;
}
-bool cxObject::ParseCondition(const std::string &Text) {
+bool cxObject::ParseCondition(const std::string &Text)
+{
cxFunction *result = new cxFunction;
if (result->Parse(Text)) {
delete mCondition;
@@ -79,7 +85,8 @@ bool cxObject::ParseCondition(const std::string &Text) {
return false;
}
-bool cxObject::ParseAlignment(const std::string &Text) {
+bool cxObject::ParseAlignment(const std::string &Text)
+{
if (Text == "center") mAlign = (eTextAlignment)(taTop | taCenter);
else if (Text == "right") mAlign = (eTextAlignment)(taTop | taRight);
else if (Text == "left") mAlign = (eTextAlignment)(taTop | taLeft);
@@ -88,38 +95,48 @@ bool cxObject::ParseAlignment(const std::string &Text) {
return true;
}
-bool cxObject::ParseFontFace(const std::string &Text) {
- /*for (int i = 0; i < eDvbFontSize; ++i) {
- if (FontNames[i] == Text) {
- mFont = cFont::GetFont((eDvbFont)i);
- return true;
- }
- }*/
-
+bool cxObject::ParseFontFace(const std::string &Text)
+{
int size = 0, pos;
std::string face = Text;
if ((pos = face.find(':')) != -1) {
size = atoi(face.substr(pos + 1).c_str());
face.erase(pos);
}
- Dprintf("trying: %s %d\n", ((std::string)SkinPath() + "/fonts/" + face).c_str(), size);
- if ((mFont = cText2SkinFont::Load(SkinPath() + "/fonts", face, size)) != NULL)
- return true;
- else if ((mFont = cText2SkinFont::Load(SkinPath() + "/" + mSkin->Name(), face, size)) != NULL)
- return true;
- return false;
-}
-const std::string &cxObject::TypeName(void) const {
+ mFontFace = face;
+ mFontSize = size;
+ return true;
+}
+
+const std::string &cxObject::TypeName(void) const
+{
return ObjectNames[mType];
}
-txPoint cxObject::Pos(void) const {
+const cFont *cxObject::Font(void) const
+{
+ const cFont *font;
+
+ Dprintf("trying: %s %d\n", (SkinPath() + "/fonts/" + mFontFace).c_str(), mFontSize);
+ if ((font = cText2SkinFont::Load(SkinPath() + "/fonts", mFontFace, mFontSize)) != NULL)
+ return font;
+
+ Dprintf("trying: %s %d\n", (SkinPath() + "/" + mSkin->Name() + "/" + mFontFace).c_str(), mFontSize);
+ if ((font = cText2SkinFont::Load(SkinPath() + "/" + mSkin->Name(), mFontFace, mFontSize)) != NULL)
+ return font;
+
+ return cFont::GetFont(fontOsd);
+}
+
+txPoint cxObject::Pos(void) const
+{
return txPoint(mSkin->BaseOffset().x + (mPos1.x < 0 ? Skin()->BaseSize().w + mPos1.x : mPos1.x),
mSkin->BaseOffset().y + (mPos1.y < 0 ? Skin()->BaseSize().h + mPos1.y : mPos1.y));
}
-txSize cxObject::Size(void) const {
+txSize cxObject::Size(void) const
+{
txPoint p1(mSkin->BaseOffset().x + (mPos1.x < 0 ? Skin()->BaseSize().w + mPos1.x : mPos1.x),
mSkin->BaseOffset().y + (mPos1.y < 0 ? Skin()->BaseSize().h + mPos1.y : mPos1.y));
txPoint p2(mSkin->BaseOffset().x + (mPos2.x < 0 ? Skin()->BaseSize().w + mPos2.x : mPos2.x),
diff --git a/xml/object.h b/xml/object.h
index 8b134a9..41a626a 100644
--- a/xml/object.h
+++ b/xml/object.h
@@ -1,5 +1,5 @@
/*
- * $Id: object.h,v 1.4 2004/12/08 17:13:26 lordjaxom Exp $
+ * $Id: object.h,v 1.5 2004/12/14 20:02:31 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_XML_OBJECT_H
@@ -65,6 +65,7 @@ private:
txPoint mPos1;
txPoint mPos2;
int mAlpha;
+ int mColors;
int mArc;
std::string mFg;
std::string mBg;
@@ -77,7 +78,8 @@ private:
cxFunction *mCondition;
cxString mCurrent;
cxString mTotal;
- const cFont *mFont;
+ std::string mFontFace;
+ int mFontSize;
cxObjects *mObjects; // used for block objects such as <list>
cxDisplay *mDisplay;
cxSkin *mSkin;
@@ -97,19 +99,20 @@ public:
eType Type(void) const { return mType; }
cxFunction *Condition(void) const { return mCondition; }
int Alpha(void) const { return mAlpha; }
+ int Colors(void) const { return mColors; }
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 cFont *Font(void) const;
const tColor *Fg(void) const;
const tColor *Bg(void) const;
const tColor *Mark(void) const;
diff --git a/xml/parser.c b/xml/parser.c
index 8842d19..62cc69c 100644
--- a/xml/parser.c
+++ b/xml/parser.c
@@ -1,5 +1,5 @@
/*
- * $Id: parser.c,v 1.5 2004/12/10 21:46:46 lordjaxom Exp $
+ * $Id: parser.c,v 1.7 2004/12/14 20:02:31 lordjaxom Exp $
*/
#include "xml/parser.h"
@@ -32,7 +32,6 @@
#define ATTRIB_OPT_STRING(_attr,_target) \
if (attrs.find(_attr) != attrs.end()) { \
_target = attrs[_attr]; \
- attrs.erase(_attr); \
}
#define ATTRIB_MAN_STRING(_attr,_target) \
@@ -53,9 +52,8 @@
return false; \
} else \
_target = _l; \
- attrs.erase(_attr); \
}
-
+
#define ATTRIB_MAN_NUMBER(_attr,_target) \
ATTRIB_OPT_NUMBER(_attr,_target) \
else { \
@@ -71,7 +69,6 @@
attrs[_attr].c_str(), _attr); \
return false; \
} \
- attrs.erase(_attr); \
}
#define ATTRIB_MAN_FUNC(_attr,_func) \
@@ -140,7 +137,10 @@ bool xStartElem(const std::string &name, std::map<std::string,std::string> &attr
if (name == "image") {
ATTRIB_OPT_NUMBER("x", object->mPos1.x);
ATTRIB_OPT_NUMBER("y", object->mPos1.y);
+ ATTRIB_OPT_NUMBER("x", object->mPos2.x);
+ ATTRIB_OPT_NUMBER("y", object->mPos2.y);
ATTRIB_OPT_NUMBER("alpha", object->mAlpha);
+ ATTRIB_OPT_NUMBER("colors", object->mColors);
ATTRIB_OPT_STRING("color", object->mFg);
ATTRIB_OPT_STRING("bgColor", object->mBg);
ATTRIB_MAN_FUNC ("path", object->mPath.Parse);
diff --git a/xml/string.c b/xml/string.c
index 269aa0f..3748df2 100644
--- a/xml/string.c
+++ b/xml/string.c
@@ -1,5 +1,5 @@
/*
- * $Id: string.c,v 1.5 2004/12/08 17:22:28 lordjaxom Exp $
+ * $Id: string.c,v 1.7 2004/12/14 13:13:10 lordjaxom Exp $
*/
#include "xml/string.h"
@@ -10,7 +10,8 @@ static const char *Tokens[__COUNT_TOKEN__] = {
"DateTime",
// Channel Display
- "ChannelNumber", "ChannelName", "ChannelShortName", "ChannelBouquet", "PresentStartDateTime",
+ "ChannelNumber", "ChannelName", "ChannelShortName", "ChannelBouquet", "ChannelPortal",
+ "ChannelSource", "PresentStartDateTime",
"PresentVPSDateTime", "PresentEndDateTime", "PresentDuration", "PresentProgress",
"PresentTitle", "PresentShortText", "PresentDescription", "FollowingStartDateTime",
"FollowingVPSDateTime", "FollowingEndDateTime", "FollowingDuration",
diff --git a/xml/string.h b/xml/string.h
index 5c89d13..650e7f7 100644
--- a/xml/string.h
+++ b/xml/string.h
@@ -1,5 +1,5 @@
/*
- * $Id: string.h,v 1.5 2004/12/08 18:47:37 lordjaxom Exp $
+ * $Id: string.h,v 1.7 2004/12/14 20:02:31 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_XML_STRING_H
@@ -17,6 +17,8 @@ enum exToken {
tChannelName,
tChannelShortName,
tChannelBouquet,
+ tChannelPortal,
+ tChannelSource,
// next 8 also in Menu
tPresentStartDateTime,
tPresentVPSDateTime,
@@ -100,6 +102,7 @@ struct txToken {
txToken(void): Index(-1), Tab(-1) {}
txToken(exToken t, uint o, const std::string &a): Type(t), Offset(o), Attrib(a), Index(-1), Tab(-1) {}
+
static std::string Token(const txToken &Token);
};
diff --git a/xml/type.c b/xml/type.c
index 0cb5c9a..f26a036 100644
--- a/xml/type.c
+++ b/xml/type.c
@@ -1,5 +1,5 @@
/*
- * $Id: type.c,v 1.2 2004/12/08 17:13:26 lordjaxom Exp $
+ * $Id: type.c,v 1.3 2004/12/12 20:26:25 lordjaxom Exp $
*/
#include "xml/type.h"
diff --git a/xml/type.h b/xml/type.h
index 14e7cca..1776ddf 100644
--- a/xml/type.h
+++ b/xml/type.h
@@ -1,5 +1,5 @@
/*
- * $Id: type.h,v 1.3 2004/12/08 17:13:26 lordjaxom Exp $
+ * $Id: type.h,v 1.5 2004/12/14 20:02:31 lordjaxom Exp $
*/
#ifndef VDR_TEXT2SKIN_XML_TYPE_H
@@ -22,12 +22,12 @@ private:
int mNumber;
public:
+ cxType(void): mType(boolean), mNumber(0) {}
cxType(const char *String): mType(string), mString(String ?: "") {}
cxType(std::string String): mType(string), mString(String) {}
cxType(int Number): mType(number), mNumber(Number) {}
cxType(time_t Number): mType(number), mNumber(Number) {}
cxType(bool Value): mType(boolean), mNumber(Value ? 1 : 0) {}
- cxType(const cxType &Src): mType(Src.mType), mString(Src.mString), mNumber(Src.mNumber) {}
const std::string &String(void);
int Number(void) const;
diff --git a/xml/xml.c b/xml/xml.c
index ebf7d00..2a239af 100644
--- a/xml/xml.c
+++ b/xml/xml.c
@@ -1,5 +1,5 @@
/*
- * $Id: xml.c,v 1.2 2004/12/06 15:01:02 lordjaxom Exp $
+ * $Id: xml.c,v 1.3 2004/12/12 20:26:25 lordjaxom Exp $
* This module was kindly provided by Clemens Kirchgatterer
*/