QTfrontend/ui/widget/hedgehogerWidget.cpp
changeset 6968 23722ba0f89a
parent 6952 7f70f37bbf08
child 6969 3273a2b983ca
equal deleted inserted replaced
6967:1224c6fb36c3 6968:23722ba0f89a
    17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    18  */
    18  */
    19 
    19 
    20 #include "hedgehogerWidget.h"
    20 #include "hedgehogerWidget.h"
    21 
    21 
       
    22 #include <QPainter>
       
    23 
    22 #include "frameTeam.h"
    24 #include "frameTeam.h"
    23 
    25 
    24 CHedgehogerWidget::CHedgehogerWidget(const QImage& im, const QImage& img, QWidget * parent) :
    26 CHedgehogerWidget::CHedgehogerWidget(const QImage& im, const QImage& img, QWidget * parent) :
    25     ItemNum(im, img, parent, 1)
    27     ItemNum(im, img, parent, 1)
    26 {
    28 {
    30     }
    32     }
    31     if(pOurFrameTeams->overallHedgehogs + 4 > pOurFrameTeams->maxHedgehogsPerGame) {
    33     if(pOurFrameTeams->overallHedgehogs + 4 > pOurFrameTeams->maxHedgehogsPerGame) {
    32       numItems = pOurFrameTeams->maxHedgehogsPerGame - pOurFrameTeams->overallHedgehogs;
    34       numItems = pOurFrameTeams->maxHedgehogsPerGame - pOurFrameTeams->overallHedgehogs;
    33     } else numItems = 4;
    35     } else numItems = 4;
    34     pOurFrameTeams->overallHedgehogs += numItems;*/
    36     pOurFrameTeams->overallHedgehogs += numItems;*/
       
    37 
       
    38     this->setMinimumWidth(20);
    35 }
    39 }
    36 
    40 
    37 void CHedgehogerWidget::incItems()
    41 void CHedgehogerWidget::incItems()
    38 {
    42 {
    39     //if (pOurFrameTeams->overallHedgehogs < pOurFrameTeams->maxHedgehogsPerGame) {
    43     //if (pOurFrameTeams->overallHedgehogs < pOurFrameTeams->maxHedgehogsPerGame) {
    72 
    76 
    73 unsigned char CHedgehogerWidget::getHedgehogsNum() const
    77 unsigned char CHedgehogerWidget::getHedgehogsNum() const
    74 {
    78 {
    75     return numItems;
    79     return numItems;
    76 }
    80 }
       
    81 
       
    82 void CHedgehogerWidget::paintEvent(QPaintEvent* event)
       
    83 {
       
    84     Q_UNUSED(event);
       
    85 
       
    86     if (this->width() >= 11 * numItems + 28)
       
    87         ItemNum::paintEvent(event);
       
    88 
       
    89     QPainter painter(this);
       
    90     const QFont font("MS Shell Dlg", 12);
       
    91     painter.setFont(font);
       
    92     painter.drawText(this->width() - 14, 24, QString::number(numItems));
       
    93 
       
    94 }