equal
deleted
inserted
replaced
2 |
2 |
3 #include <QMouseEvent> |
3 #include <QMouseEvent> |
4 #include <QPainter> |
4 #include <QPainter> |
5 |
5 |
6 CHedgehogerWidget::CHedgehogerWidget(QWidget * parent) : |
6 CHedgehogerWidget::CHedgehogerWidget(QWidget * parent) : |
7 QWidget(parent), numHedgedogs(4) |
7 QWidget(parent), numHedgehogs(4) |
8 { |
8 { |
9 } |
9 } |
10 |
10 |
11 void CHedgehogerWidget::mousePressEvent ( QMouseEvent * event ) |
11 void CHedgehogerWidget::mousePressEvent ( QMouseEvent * event ) |
12 { |
12 { |
13 if(event->button()==Qt::LeftButton) { |
13 if(event->button()==Qt::LeftButton) { |
14 event->accept(); |
14 event->accept(); |
15 if(numHedgedogs < 8) numHedgedogs++; |
15 if(numHedgehogs < 8) numHedgehogs++; |
16 } else if (event->button()==Qt::RightButton) { |
16 } else if (event->button()==Qt::RightButton) { |
17 event->accept(); |
17 event->accept(); |
18 if(numHedgedogs > 3) numHedgedogs--; |
18 if(numHedgehogs > 3) numHedgehogs--; |
19 } else { |
19 } else { |
20 event->ignore(); |
20 event->ignore(); |
21 return; |
21 return; |
22 } |
22 } |
23 repaint(); |
23 repaint(); |
27 { |
27 { |
28 QImage image(":/res/hh25x25.png"); |
28 QImage image(":/res/hh25x25.png"); |
29 |
29 |
30 QPainter painter(this); |
30 QPainter painter(this); |
31 |
31 |
32 for(int i=0; i<numHedgedogs; i++) { |
32 for(int i=0; i<numHedgehogs; i++) { |
33 QRect target(11 * i, i % 2, 25, 25); |
33 QRect target(11 * i, i % 2, 25, 25); |
34 painter.drawImage(target, image); |
34 painter.drawImage(target, image); |
35 } |
35 } |
36 } |
36 } |
|
37 |
|
38 unsigned char CHedgehogerWidget::getHedgehogsNum() |
|
39 { |
|
40 return numHedgehogs; |
|
41 } |