summaryrefslogtreecommitdiff
path: root/dummygrid.c
blob: 7f943fcf88b351dbedc9aa7e93192d55b21b50cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "dummygrid.h"

cDummyGrid::cDummyGrid(cChannelColumn *c, time_t start, time_t end) : cGrid(c) {
    this->start = start;
    this->end = end;
    strText = tr("No EPG Information available");
    dummy = true;
}

cDummyGrid::~cDummyGrid(void) {
}

void cDummyGrid::SetViewportHeight() {
    int viewportHeightOld = viewportHeight;
    viewportHeight = Duration() / 60 * tvguideConfig.minutePixel;
    if (viewportHeight != viewportHeightOld)
        dirty = true;
}

void cDummyGrid::PositionPixmap() {
    int x0, y0;
    if (tvguideConfig.displayMode == eVertical) {
        x0 = column->getX();
        y0 = tvguideConfig.statusHeaderHeight + tvguideConfig.channelHeaderHeight;
        if ( column->Start() < StartTime() ) {
            y0 += (StartTime() - column->Start())/60*tvguideConfig.minutePixel;
        }
        if (!pixmap) {
            pixmap = osdManager.requestPixmap(-1, cRect(x0, y0, tvguideConfig.colWidth, viewportHeight));
        } else if (dirty) {
            osdManager.releasePixmap(pixmap);
            pixmap = osdManager.requestPixmap(-1, cRect(x0, y0, tvguideConfig.colWidth, viewportHeight));
        } else {
            pixmap->SetViewPort(cRect(x0, y0, tvguideConfig.colWidth, viewportHeight));
        }
    } else if (tvguideConfig.displayMode == eHorizontal) {
        x0 = tvguideConfig.channelHeaderWidth;
        y0 = column->getY();
        if ( column->Start() < StartTime() ) {
            x0 += (StartTime() - column->Start())/60*tvguideConfig.minutePixel;
        }
        if (!pixmap) {
            pixmap = osdManager.requestPixmap(-1, cRect(x0, y0, viewportHeight, tvguideConfig.rowHeight));
        } else if (dirty) {
            osdManager.releasePixmap(pixmap);
            pixmap = osdManager.requestPixmap(-1, cRect(x0, y0, viewportHeight, tvguideConfig.rowHeight));
        } else {
            pixmap->SetViewPort(cRect(x0, y0, viewportHeight, tvguideConfig.rowHeight));
        }
    }
}

void cDummyGrid::setText() {
    if (tvguideConfig.displayMode == eVertical) {
        text->Set(*strText, tvguideConfig.FontGrid, tvguideConfig.colWidth-2*borderWidth);
    }
}

void cDummyGrid::drawText() {
    if (tvguideConfig.displayMode == eVertical) {
        if (Height()/tvguideConfig.minutePixel < 6)
            return;
        int textHeight = tvguideConfig.FontGrid->Height();
        int textLines = text->Lines();
        for (int i=0; i<textLines; i++) {
            pixmap->DrawText(cPoint(borderWidth, borderWidth + i*textHeight), text->GetLine(i), theme.Color(clrFont), clrTransparent, tvguideConfig.FontGrid);
        
        }
    } else if (tvguideConfig.displayMode == eHorizontal) {
        int titleY = (tvguideConfig.rowHeight - tvguideConfig.FontGridHorizontal->Height())/2;
        pixmap->DrawText(cPoint(borderWidth, titleY), *strText, theme.Color(clrFont), clrTransparent, tvguideConfig.FontGridHorizontal);
    }
}
cString cDummyGrid::getText(void) {
    return strText;
}

cString cDummyGrid::getTimeString(void) {
    return cString::sprintf("%s - %s", *TimeString(start), *TimeString(end));
}

void cDummyGrid::debug() {
    esyslog("tvguide dummygrid: %s: %s, %s, viewportHeight: %d px, Duration: %ld min, active: %d", 
                column->Name(),
                *cMyTime::printTime(start), 
                *cMyTime::printTime(end), 
                viewportHeight, 
                Duration()/60,
                active);
}