image_cell.cpp
788 Bytes
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
#include "image_cell.h"
#include <assert.h>
namespace Probability {
ImageCell::ImageCell() :
HighlightCell(),
m_icon(nullptr),
m_focusedIcon(nullptr)
{
}
void ImageCell::setHighlighted(bool highlight) {
HighlightCell::setHighlighted(highlight);
if (isHighlighted()) {
m_iconView.setImage(m_focusedIcon);
} else {
m_iconView.setImage(m_icon);
}
}
void ImageCell::setImage(const Image * image, const Image * focusedImage) {
m_icon = image;
m_focusedIcon = focusedImage;
setHighlighted(isHighlighted());
markRectAsDirty(bounds());
}
int ImageCell::numberOfSubviews() const {
return 1;
}
View * ImageCell::subviewAtIndex(int index) {
assert(index == 0);
return &m_iconView;
}
void ImageCell::layoutSubviews() {
m_iconView.setFrame(bounds());
}
}