diff options
author | louis <louis.braun@gmx.de> | 2013-05-20 11:37:37 +0200 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2013-05-20 11:37:37 +0200 |
commit | c611e004582067640111ef2f023410025201157d (patch) | |
tree | 3a71e9893bffa4bf9d38c49389dad5f43d046ec3 /osdmanager.c | |
parent | 063094f442c0ac3c592d2e5bb5c416d6820d2602 (diff) | |
download | vdr-plugin-tvguide-c611e004582067640111ef2f023410025201157d.tar.gz vdr-plugin-tvguide-c611e004582067640111ef2f023410025201157d.tar.bz2 |
rewrote epg grid handling and scrolling, added status header
Diffstat (limited to 'osdmanager.c')
-rw-r--r-- | osdmanager.c | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/osdmanager.c b/osdmanager.c index fb0ec6e..bc9662d 100644 --- a/osdmanager.c +++ b/osdmanager.c @@ -1,17 +1,19 @@ +#include <string>
+#include <sstream>
+
#ifndef __TVGUIDE_OSDMANAGER_H
#define __TVGUIDE_OSDMANAGER_H
class cOsdManager {
private:
cOsd *osd;
- int activePixmaps;
public:
cOsdManager(void);
bool setOsd();
void setBackground();
void flush() {osd->Flush();};
- cPixmap *requestPixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null, const char *caller = "anonymous");
- void releasePixmap(cPixmap *pixmap, const char *caller = "anonymous");
+ cPixmap *requestPixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null);
+ void releasePixmap(cPixmap *pixmap);
void deleteOsd() {delete osd;};
int Width() { return osd->Width(); };
int Height() { return osd->Height(); };
@@ -20,7 +22,6 @@ class cOsdManager { #endif //__TVGUIDE_OSDMANAGER_H
cOsdManager::cOsdManager(void) {
- activePixmaps = 0;
}
bool cOsdManager::setOsd() {
@@ -35,18 +36,48 @@ bool cOsdManager::setOsd() { }
void cOsdManager::setBackground() {
- osd->DrawRectangle(0, 0, cOsd::OsdWidth(), cOsd::OsdHeight(), theme.Color(clrBackgroundOSD));
+ if (tvguideConfig.displayStatusHeader && tvguideConfig.scaleVideo) {
+ osd->DrawRectangle(0, 0, cOsd::OsdWidth() - tvguideConfig.statusHeaderHeight * 16 / 9, tvguideConfig.statusHeaderHeight, theme.Color(clrBackgroundOSD));
+ osd->DrawRectangle(0, tvguideConfig.statusHeaderHeight, cOsd::OsdWidth(), cOsd::OsdHeight() - tvguideConfig.statusHeaderHeight, theme.Color(clrBackgroundOSD));
+ }
+ else
+ osd->DrawRectangle(0, 0, cOsd::OsdWidth(), cOsd::OsdHeight(), theme.Color(clrBackgroundOSD));
}
-cPixmap *cOsdManager::requestPixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort, const char *caller) {
- if (activePixmaps >= 64)
- return NULL;
- activePixmaps++;
- //esyslog("tvguide: Pixmap angefordert von %s, verwendet: %d", caller, activePixmaps);
+
+cPixmap *cOsdManager::requestPixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort) {
return osd->CreatePixmap(Layer, ViewPort, DrawPort);
- }
+}
-void cOsdManager::releasePixmap(cPixmap *pixmap, const char *caller) {
- activePixmaps--;
- //esyslog("tvguide: Pixmap geloescht von %s, verwendet: %d", caller, activePixmaps);
+void cOsdManager::releasePixmap(cPixmap *pixmap) {
+ if (!pixmap)
+ return;
osd->DestroyPixmap(pixmap);
+}
+
+static std::string CutText(std::string text, int width, const cFont *font) {
+ if (width <= font->Size())
+ return text.c_str();
+ if (font->Width(text.c_str()) < width)
+ return text.c_str();
+ cTextWrapper twText;
+ twText.Set(text.c_str(), font, width);
+ std::string cuttedTextNative = twText.GetLine(0);
+ std::stringstream sstrText;
+ sstrText << cuttedTextNative << "...";
+ std::string cuttedText = sstrText.str();
+ int actWidth = font->Width(cuttedText.c_str());
+ if (actWidth > width) {
+ int overlap = actWidth - width;
+ int charWidth = font->Width(".");
+ if (charWidth == 0)
+ charWidth = 1;
+ int cutChars = overlap / charWidth;
+ if (cutChars > 0) {
+ cuttedTextNative = cuttedTextNative.substr(0, cuttedTextNative.length() - cutChars);
+ std::stringstream sstrText2;
+ sstrText2 << cuttedTextNative << "...";
+ cuttedText = sstrText2.str();
+ }
+ }
+ return cuttedText;
}
\ No newline at end of file |