summaryrefslogtreecommitdiff
path: root/headergrid.c
blob: 41a95f4043cae4a0c471a5f587a656a04ea29f1e (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
#include "headergrid.h"

cHeaderGrid::cHeaderGrid(void) : cGrid(NULL) {
    pixmap = NULL;
    pixmapLogo = NULL;
}

cHeaderGrid::~cHeaderGrid(void) {
    osdManager.releasePixmap(pixmapLogo);
}

void cHeaderGrid::createBackground(int num) {
    color = theme.Color(clrHeader);
    colorBlending = theme.Color(clrHeaderBlending);
    pixmap = osdManager.requestPixmap(2, cRect( tvguideConfig.timeColWidth + num*tvguideConfig.colWidth, 
                                                tvguideConfig.statusHeaderHeight, 
                                                tvguideConfig.colWidth, 
                                                tvguideConfig.headerHeight)
                                       , cRect::Null);
	if (!pixmap) {
		return;
	}
    pixmapLogo = osdManager.requestPixmap(3, cRect( tvguideConfig.timeColWidth + num*tvguideConfig.colWidth, 
                                                    tvguideConfig.statusHeaderHeight, 
                                                    tvguideConfig.colWidth, 
                                                    tvguideConfig.headerHeight)
                                           , cRect::Null);
    if (!pixmapLogo) {
		return;
	}
    pixmapLogo->Fill(clrTransparent);
	drawBackground();
}

void cHeaderGrid::drawChannel(const cChannel *channel) {
    cTextWrapper tw;
	cString headerText = cString::sprintf("%d - %s", channel->Number(), channel->Name());
	tw.Set(*headerText, tvguideConfig.FontHeader, tvguideConfig.colWidth - 8);
	int lines = tw.Lines();
	int lineHeight = tvguideConfig.FontHeader->Height();
	int yStart = (tvguideConfig.headerHeight - lines*lineHeight)/2 + 8;
	if (!tvguideConfig.hideChannelLogos) {
		cImageLoader imgLoader;
		if (imgLoader.LoadLogo(channel->Name())) {
				cImage logo = imgLoader.GetImage();
				int logoX = (tvguideConfig.colWidth - tvguideConfig.logoWidth)/2;
				pixmapLogo->DrawImage(cPoint(logoX, 5), logo);
		}
		yStart = tvguideConfig.logoHeight + 8;
	}
	for (int i=0; i<lines; i++) {
		int textWidth = tvguideConfig.FontHeader->Width(tw.GetLine(i));
		int xText = (tvguideConfig.colWidth - textWidth) / 2;
		if (xText < 0) 
			xText = 0;
		pixmap->DrawText(cPoint(xText, yStart + i*lineHeight), tw.GetLine(i), theme.Color(clrFontHeader), clrTransparent, tvguideConfig.FontHeader);
	}
	drawBorder();
}

void cHeaderGrid::setPosition(int num) {
	pixmap->SetViewPort(cRect(      tvguideConfig.timeColWidth + num*tvguideConfig.colWidth, 
                                    tvguideConfig.statusHeaderHeight, 
                                    tvguideConfig.colWidth, 
                                    tvguideConfig.headerHeight));
	pixmapLogo->SetViewPort(cRect(  tvguideConfig.timeColWidth + num*tvguideConfig.colWidth, 
                                    tvguideConfig.statusHeaderHeight, 
                                    tvguideConfig.colWidth, 
                                    tvguideConfig.headerHeight));
}