diff options
author | mrwastl <mrwastl@users.sourceforge.net> | 2010-05-04 21:03:19 +0200 |
---|---|---|
committer | mrwastl <mrwastl@users.sourceforge.net> | 2010-05-04 21:03:19 +0200 |
commit | 8a4168bd0d2e468604755398f18be1fba9046aa0 (patch) | |
tree | 56558e0517e3b63483a2813146563eaf0371c666 /layout.c | |
parent | 75ebec3efc4879fc8bee8a3ecfe71809d9fccefd (diff) | |
download | vdr-plugin-graphlcd-8a4168bd0d2e468604755398f18be1fba9046aa0.tar.gz vdr-plugin-graphlcd-8a4168bd0d2e468604755398f18be1fba9046aa0.tar.bz2 |
initial git upload, based on graphlcd-0.2.0-pre2
Diffstat (limited to 'layout.c')
-rw-r--r-- | layout.c | 170 |
1 files changed, 0 insertions, 170 deletions
diff --git a/layout.c b/layout.c deleted file mode 100644 index 254fbb1..0000000 --- a/layout.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * GraphLCD plugin for Video Disc Recorder - * - * layout.c - layout classes - * - * This file is released under the GNU General Public License. Refer - * to the COPYING file distributed with this package. - * - * (c) 2005 Andreas Regel <andreas.regel AT powarman.de> - */ - -#include <syslog.h> - -#include <fstream> - -#include "global.h" -#include "layout.h" -#include "strfct.h" - -#include <vdr/config.h> -#include <vdr/i18n.h> -#include <vdr/plugin.h> - - -cFontElement::cFontElement(const std::string & fontName) -: name(fontName), - type(0), - file(""), - size(0) -{ -} - -bool cFontElement::Load(const std::string & url) -{ - if (url.find("fnt:") == 0) - { - type = ftFNT; - if (url[4] == '/') - file = url.substr(4); - else - { - file = cPlugin::ConfigDirectory(PLUGIN_NAME); - file += "/fonts/"; - file += url.substr(4); - } - size = 0; - return font.LoadFNT(file); - } - else if (url.find("ft2:") == 0) - { - type = ftFT2; - std::string::size_type pos = url.find(":", 4); - if (pos == std::string::npos) - { - syslog(LOG_ERR, "cFontElement::Load(): No font size specified in %s\n", url.c_str()); - return false; - } - std::string tmp = url.substr(pos + 1); - size = atoi(tmp.c_str()); - if (url[4] == '/') - file = url.substr(4, pos - 4); - else - { - file = cPlugin::ConfigDirectory(PLUGIN_NAME); - file += "/fonts/"; - file += url.substr(4, pos - 4); - } -#if APIVERSNUM >= 10503 - return font.LoadFT2(file, cCharSetConv::SystemCharacterTable(), size); -#else - return font.LoadFT2(file, I18nCharSets()[Setup.OSDLanguage], size); -#endif - } - else - { - syslog(LOG_ERR, "cFontElement::Load(): Unknown font type in %s\n", url.c_str()); - return false; - } -} - - -cFontList::cFontList() -{ -} - -cFontList::~cFontList() -{ - std::list <cFontElement *>::iterator it; - cFontElement * elem; - - for (it = fonts.begin(); it != fonts.end(); it++) - { - elem = *it; - delete elem; - } - fonts.clear(); -} - -bool cFontList::Load(const std::string & fileName) -{ - std::fstream file; - char readLine[1000]; - std::string line; - -#if (__GNUC__ < 3) - file.open(fileName.c_str(), std::ios::in); -#else - file.open(fileName.c_str(), std::ios_base::in); -#endif - if (!file.is_open()) - return false; - - while (!file.eof()) - { - file.getline(readLine, 1000); - line = trim(readLine); - if (line.length() == 0) - continue; - if (line[0] == '#') - continue; - Parse(line); - } - - file.close(); - return true; -} - -bool cFontList::Parse(const std::string & line) -{ - std::string::size_type pos; - std::string fontName; - std::string fontUrl; - cFontElement * elem; - - pos = line.find("="); - if (pos == std::string::npos) - return false; - fontName = trim(line.substr(0, pos)); - fontUrl = trim(line.substr(pos + 1)); - //printf("%s = %s\n", fontName.c_str(), fontUrl.c_str()); - - elem = new cFontElement(fontName); - if (elem->Load(fontUrl)) - { - fonts.push_back(elem); - return true; - } - else - { - delete elem; - return false; - } -} - -const GLCD::cFont * cFontList::GetFont(const std::string & name) const -{ - std::list <cFontElement *>::const_iterator it; - cFontElement * elem; - - for (it = fonts.begin(); it != fonts.end(); it++) - { - elem = *it; - if (elem->Name() == name) - { - return elem->Font(); - } - } - return NULL; -} - |