-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboard.cpp
executable file
·148 lines (111 loc) · 2.02 KB
/
board.cpp
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
116
117
118
119
120
121
122
123
124
125
126
127
#include "board.h"
#include "CPicturesStorage.h"
#include "widgets/WgClock.h"
#include "widgets/WgCalendar.h"
#include "widgets/WgForecast.h"
#include "widgets/WgAds.h"
Board::Board()
{
cleanWidgets();
addWidget(new WgAds(1280, 720, 1, 8, md2x8));
addWidget(new WgForecast(1280, 720, 4, 8, md1x2));
addWidget(new WgClock(1280, 720, 4, 6, md1x3));
addWidget(new WgCalendar(1280, 720, 4, 3, md1x3));
first = -1;
next = -1;
}
Board::~Board()
{
for(int i = 0; i < WIDGETS_COUNT; i++)
{
if(widgets[i]) delete widgets[i];
}
}
void Board::update()
{
// update data (check weather, check time and blah blah blah ... )
for(int i = 0; i < WIDGETS_COUNT; i++)
{
if(widgets[i]) widgets[i]->update();
}
}
void Board::render()
{
// just drowing functions!!!
// p.s do not change name of function (drawClock, drawWeather ... name it just render();
PicStorage->ScreenBackgroud->render(0,0);
PicStorage->Logo->render(20,560,0.6,0.6,0,0,0);
for(int i = 0; i < WIDGETS_COUNT; i++)
{
if(widgets[i])
{
widgets[i]->render();
}
}
}
void Board::addWidget(IWidget *widget)
{
for(int i = 0; i < WIDGETS_COUNT; i++)
{
if(widgets[i] == NULL)
{
widgets[i] = widget;
widgets[i]->setId(i);
return;
}
}
}
void Board::cleanWidgets()
{
for(int i = 0; i < WIDGETS_COUNT; i++)
{
//if(widgets[i]) delete widgets[i];
widgets[i] = NULL;
}
}
IWidget **Board::getWidgets()
{
return widgets;
}
IWidget *Board::findFirst()
{
for(int i = 0; i < WIDGETS_COUNT; i++)
{
if(widgets[i])
{
first = i;
next = i + 1;
return widgets[i];
}
}
return NULL;
}
IWidget *Board::findNext()
{
if(first != -1 && next != -1 && next < WIDGETS_COUNT)
{
for(int i = next; i < WIDGETS_COUNT; i++)
{
if(widgets[i])
{
if(next + 1 < WIDGETS_COUNT) next = i + 1;
else return NULL;
return widgets[i];
}
}
return NULL;
}
return NULL;
}
int Board::countWidgets()
{
int wCount = 0;
for(int i = 0; i < WIDGETS_COUNT; i++)
{
if(widgets[i])
{
wCount++;
}
}
return wCount;
}