summaryrefslogtreecommitdiff
path: root/footer.c
blob: 36bf652872c617e5c78afbff2aa2747290d43cc7 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <string>
#include "imageloader.h"
#include "tools.h"
#include "footer.h"

cFooter::cFooter(cChannelGroups *channelGroups) {
    this->channelGroups = channelGroups;
    currentGroup = -1;
    buttonBorder = 20;
    buttonWidth = (tvguideConfig.osdWidth - tvguideConfig.timeLineWidth - 5*buttonBorder)/4;
    buttonHeight= tvguideConfig.footerHeight - 2*buttonBorder;
    buttonY = (tvguideConfig.footerHeight - buttonHeight)/2;
    SetButtonPositions();
    
    footer = osdManager.requestPixmap(2, cRect( tvguideConfig.timeLineWidth, 
                                                tvguideConfig.osdHeight - tvguideConfig.footerHeight, 
                                                tvguideConfig.osdWidth - tvguideConfig.timeLineWidth, 
                                                tvguideConfig.footerHeight),
                                         cRect::Null);
    footer->Fill(clrTransparent);
}

cFooter::~cFooter(void) {
    osdManager.releasePixmap(footer);
}

void cFooter::SetButtonPositions(void) {
    for (int i=0; i < 4; i++) {
        positionButtons[i] = -1;
    }
    /*
    red button = 0
    green button = 1
    yellow button = 2
    blue button = 3
    */
    for (int button=0; button<4; button++) {
        if (Setup.ColorKey0 == button) {
            positionButtons[button] = 0;
            continue;
        }
        if (Setup.ColorKey1 == button) {
            positionButtons[button] = 1;
            continue;
        }
        if (Setup.ColorKey2 == button) {
            positionButtons[button] = 2;
            continue;
        }
        if (Setup.ColorKey3 == button) {
            positionButtons[button] = 3;
            continue;
        }
    }
}

void cFooter::DrawButton(const char *text, tColor color, tColor borderColor, int num) {
    tColor colorTextBack = (tvguideConfig.useBlending==0)?color:clrTransparent;
    int left = num * buttonWidth + (num + 1) * buttonBorder;
    footer->DrawRectangle(cRect(left, buttonY, buttonWidth, buttonHeight), borderColor);
    if (tvguideConfig.useBlending) {
        cImageLoader imgLoader;
        imgLoader.DrawBackground(theme.Color(clrButtonBlend), color, buttonWidth-4, buttonHeight-4);
        footer->DrawImage(cPoint(left+2, buttonY+2), imgLoader.GetImage());    
    } else {
        footer->DrawRectangle(cRect(left, buttonY, buttonWidth, buttonHeight), borderColor); 
        footer->DrawRectangle(cRect(left+2, buttonY+2, buttonWidth-4, buttonHeight-4), color); 
    }
    int textWidth = tvguideConfig.FontButton->Width(text);
    int textHeight = tvguideConfig.FontButton->Height();
    footer->DrawText(cPoint(left + (buttonWidth-textWidth)/2, buttonY + (buttonHeight-textHeight)/2), text, theme.Color(clrFontButtons), colorTextBack, tvguideConfig.FontButton);
}

void cFooter::drawRedButton() {
    cString text(tr("Search & Rec"));
    DrawButton(*text, theme.Color(clrButtonRed), theme.Color(clrButtonRedBorder), positionButtons[0]);
}

void cFooter::drawGreenButton() {
    cString text = cString::sprintf("%d %s", tvguideConfig.jumpChannels, tr("Channels back"));
    DrawButton(*text, theme.Color(clrButtonGreen), theme.Color(clrButtonGreenBorder), positionButtons[1]);
}

void cFooter::drawGreenButton(const char *text) {
    std::string cuttedText = CutText(text, buttonWidth-6, tvguideConfig.FontButton);
    DrawButton(cuttedText.c_str(), theme.Color(clrButtonGreen), theme.Color(clrButtonGreenBorder), positionButtons[1]);
}

void cFooter::drawYellowButton() {
    cString text = cString::sprintf("%d %s", tvguideConfig.jumpChannels, tr("Channels forward"));
    DrawButton(*text, theme.Color(clrButtonYellow), theme.Color(clrButtonYellowBorder), positionButtons[2]);
}

void cFooter::drawYellowButton(const char *text) {
    std::string cuttedText = CutText(text, buttonWidth-6, tvguideConfig.FontButton);
    DrawButton(cuttedText.c_str(), theme.Color(clrButtonYellow), theme.Color(clrButtonYellowBorder), positionButtons[2]);
}

void cFooter::drawBlueButton() {
    cString text;
    if (tvguideConfig.blueKeyMode == 0)
        text = tr("Switch to Channel");
    else if (tvguideConfig.blueKeyMode == 1)
        text = tr("Detailed EPG");
    DrawButton(*text, theme.Color(clrButtonBlue), theme.Color(clrButtonBlueBorder), positionButtons[3]);
}

void cFooter::UpdateGroupButtons(const cChannel *channel) {
    int group = channelGroups->GetGroup(channel);
    if (group != currentGroup) {
        currentGroup = group;
        drawGreenButton(channelGroups->GetPrev(group));
        drawYellowButton(channelGroups->GetNext(group));
    }
}