QTfrontend/ui/widget/hedgehogerWidget.cpp
changeset 6969 3273a2b983ca
parent 6968 23722ba0f89a
child 6983 ede55af89e78
equal deleted inserted replaced
6968:23722ba0f89a 6969:3273a2b983ca
    33     if(pOurFrameTeams->overallHedgehogs + 4 > pOurFrameTeams->maxHedgehogsPerGame) {
    33     if(pOurFrameTeams->overallHedgehogs + 4 > pOurFrameTeams->maxHedgehogsPerGame) {
    34       numItems = pOurFrameTeams->maxHedgehogsPerGame - pOurFrameTeams->overallHedgehogs;
    34       numItems = pOurFrameTeams->maxHedgehogsPerGame - pOurFrameTeams->overallHedgehogs;
    35     } else numItems = 4;
    35     } else numItems = 4;
    36     pOurFrameTeams->overallHedgehogs += numItems;*/
    36     pOurFrameTeams->overallHedgehogs += numItems;*/
    37 
    37 
    38     this->setMinimumWidth(20);
    38     this->setMinimumWidth(48);
    39 }
    39 }
    40 
    40 
    41 void CHedgehogerWidget::incItems()
    41 void CHedgehogerWidget::incItems()
    42 {
    42 {
    43     //if (pOurFrameTeams->overallHedgehogs < pOurFrameTeams->maxHedgehogsPerGame) {
    43     //if (pOurFrameTeams->overallHedgehogs < pOurFrameTeams->maxHedgehogsPerGame) {
    81 
    81 
    82 void CHedgehogerWidget::paintEvent(QPaintEvent* event)
    82 void CHedgehogerWidget::paintEvent(QPaintEvent* event)
    83 {
    83 {
    84     Q_UNUSED(event);
    84     Q_UNUSED(event);
    85 
    85 
    86     if (this->width() >= 11 * numItems + 28)
    86     if (this->width() >= 11 * numItems + 26)
    87         ItemNum::paintEvent(event);
    87         ItemNum::paintEvent(event);
       
    88     else
       
    89     {
       
    90         int width = this->width() - 38;
       
    91         QPainter painter(this);
       
    92 
       
    93         for(int i=0; i<numItems; i++)
       
    94         {
       
    95             QRect target((i * width) / (numItems -1), i % 2, 25, 35);
       
    96             if (enabled)
       
    97             {
       
    98                 painter.drawImage(target, m_im);
       
    99             }
       
   100             else
       
   101             {
       
   102                 painter.drawImage(target, m_img);
       
   103             }
       
   104         }
       
   105     }
    88 
   106 
    89     QPainter painter(this);
   107     QPainter painter(this);
    90     const QFont font("MS Shell Dlg", 12);
   108     const QFont font("MS Shell Dlg", 12);
    91     painter.setFont(font);
   109     painter.setFont(font);
    92     painter.drawText(this->width() - 14, 24, QString::number(numItems));
   110     painter.drawText(this->width() - 12, 24, QString::number(numItems));
    93 
   111 
    94 }
   112 }