summaryrefslogtreecommitdiff
path: root/timers.c
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2013-01-13 13:52:30 +0100
committerlouis <louis.braun@gmx.de>2013-01-13 13:52:30 +0100
commit478029d0e15955cdd13b78e039e325841e7dd6ac (patch)
treef765514488f96acbc2529008cd78c5505ddf3fde /timers.c
parent8d2689ab08be6da1465506534cd4e35bf81888d2 (diff)
downloadskin-nopacity-478029d0e15955cdd13b78e039e325841e7dd6ac.tar.gz
skin-nopacity-478029d0e15955cdd13b78e039e325841e7dd6ac.tar.bz2
Changed channel info icons in DisplayChannel
Diffstat (limited to 'timers.c')
-rw-r--r--timers.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/timers.c b/timers.c
new file mode 100644
index 0000000..1e51851
--- /dev/null
+++ b/timers.c
@@ -0,0 +1,117 @@
+#include "timers.h"
+
+cNopacityTimer::cNopacityTimer(cOsd *osd, const cTimer *timer, const cFont *font, const cFont *fontLarge) {
+ this->osd = osd;
+ this->timer = timer;
+ this->font = font;
+ this->fontLarge = fontLarge;
+}
+
+cNopacityTimer::~cNopacityTimer(void) {
+ osd->DestroyPixmap(pixmap);
+ osd->DestroyPixmap(pixmapLogo);
+}
+
+void cNopacityTimer::SetGeometry(int width, int y) {
+ this->width = width;
+ this->y = y;
+}
+
+void cNopacityTimer::SetAlpha(int alpha) {
+ pixmap->SetAlpha(alpha);
+ pixmapLogo->SetAlpha(alpha);
+}
+
+void cNopacityTimer::Show(void) {
+ pixmap->SetLayer(2);
+ pixmapLogo->SetLayer(3);
+}
+
+void cNopacityTimer::Hide(void) {
+ pixmap->SetLayer(-1);
+ pixmapLogo->SetLayer(-1);
+}
+
+void cNopacityTimer::CreateDate(void) {
+ if (timer->Recording()) {
+ Date = cString::sprintf("-%s", *TimeString(timer->StopTime()));
+ } else {
+ time_t Now = time(NULL);
+ cString Today = WeekDayName(Now);
+ cString Time = TimeString(timer->StartTime());
+ cString Day = WeekDayName(timer->StartTime());
+ if (timer->StartTime() > Now + 6 * SECSINDAY)
+ Date = DayDateTime(timer->StartTime());
+ else if (strcmp(Day, Today) != 0)
+ Date = cString::sprintf("%s %s", *Day, *Time);
+ else
+ Date = Time;
+ if (timer->Flags() & tfVps)
+ Date = cString::sprintf("VPS %s", *Date);
+ }
+}
+
+void cNopacityTimer::CreateShowName(void) {
+ const cEvent *Event = timer->Event();
+ cString title("");
+ if (Event) {
+ title = Event->Title();
+ }
+ showName.Set(*title, font, width-10);
+}
+
+void cNopacityTimer::CalculateHeight(int space) {
+ int numLines = showName.Lines() + 1;
+ int lineHeight = font->Height();
+ height = config.timersLogoHeight + numLines * lineHeight + 2*space;
+}
+
+void cNopacityTimer::CreatePixmaps(int x) {
+ pixmap = osd->CreatePixmap(2, cRect(x, y, width, height));
+ pixmapLogo = osd->CreatePixmap(3, cRect(x, y, width, height));
+}
+
+void cNopacityTimer::Render(void) {
+ DrawLogo();
+ cImageLoader imgLoader;
+ if (timer->Recording()) {
+ pixmap->Fill(Theme.Color(clrDiskAlert));
+ imgLoader.DrawBackground(Theme.Color(clrDiskAlert), Theme.Color(clrMenuItemHigh), width-2, height-2);
+ pixmap->DrawImage(cPoint(1,1), imgLoader.GetImage());
+ } else {
+ pixmap->Fill(Theme.Color(clrMenuBorder));
+ imgLoader.DrawBackground(Theme.Color(clrMenuItemHighBlend), Theme.Color(clrMenuItemHigh), width-2, height-2);
+ pixmap->DrawImage(cPoint(1,1), imgLoader.GetImage());
+ }
+
+ pixmap->DrawText(cPoint(5, config.timersLogoHeight), *Date, Theme.Color(clrMenuFontTimersHeader), clrTransparent, fontLarge);
+
+ int lineHeight = font->Height();
+ int yStart = config.timersLogoHeight + lineHeight + 3;
+ int numLines = showName.Lines();
+ for (int line=0; line<numLines; line++)
+ pixmap->DrawText(cPoint(5, yStart+line*(lineHeight-2)), showName.GetLine(line), Theme.Color(clrMenuFontTimers), clrTransparent, font);
+
+}
+
+void cNopacityTimer::DrawLogo(void) {
+ pixmapLogo->Fill(clrTransparent);
+ int logoWidth = config.timersLogoWidth;
+ int logoHeight = config.timersLogoHeight;
+ const cChannel *Channel = timer->Channel();
+ if (Channel && Channel->Name()) {
+ cImageLoader imgLoader;
+ if (imgLoader.LoadLogo(Channel->Name(), logoWidth, logoHeight)) {
+ pixmapLogo->DrawImage(cPoint((width - logoWidth)/2, 1), imgLoader.GetImage());
+ } else {
+ cTextWrapper channel;
+ channel.Set(Channel->Name(), font, logoWidth);
+ int lines = channel.Lines();
+ int lineHeight = font->Height();
+ int y = 1;
+ for (int line = 0; line < lines; line++) {
+ pixmapLogo->DrawText(cPoint((logoWidth - font->Width(channel.GetLine(line)))/2, y+lineHeight*line), channel.GetLine(line), Theme.Color(clrMenuFontMenuItemHigh), clrTransparent, font);
+ }
+ }
+ }
+} \ No newline at end of file