Ticket #4192: uilistbtntype_justification.patch

File uilistbtntype_justification.patch, 4.5 KB (added by anonymous, 16 years ago)
  • uilistbtntype.cpp

     
    17051705            font = m_fontInactive;
    17061706            p->setFont(font->face);
    17071707            p->setPen(font->color);
     1708            it.current()->setJustification(m_justify);
    17081709            it.current()->paint(p, font, x, y, active_on);
    17091710            font = m_active ? m_fontActive : m_fontInactive;;
    17101711            p->setFont(font->face);
     
    17121713        }
    17131714        else
    17141715        {
     1716            it.current()->setJustification(m_justify);
    17151717            it.current()->paint(p, font, x, y, active_on);
    17161718        }
    17171719
     
    17441746   
    17451747}
    17461748
     1749void UIListBtnType::SetJustification(int justification)
     1750{
     1751        m_justify = justification;
     1752}
     1753
    17471754void UIListBtnType::Init()
    17481755{
    17491756    QFontMetrics fm(m_fontActive->face);
     
    19351942    m_showArrow = showArrow;
    19361943    m_data      = 0;
    19371944    m_overrideInactive = false;
    1938 
     1945    m_justify = Qt::AlignLeft|Qt::AlignVCenter;
     1946   
    19391947    if (state >= NotChecked)
    19401948        m_checkable = true;
    19411949
     
    19441952    m_parent->InsertItem(this);
    19451953}
    19461954
     1955void UIListBtnTypeItem::setJustification(int justification)
     1956{
     1957        m_justify = justification;
     1958}
     1959
    19471960void UIListBtnTypeItem::CalcDimensions(void)
    19481961{
    19491962    if (!m_parent->m_initialized)
     
    21532166    tr.moveBy(x,y);
    21542167    QString text = m_parent->cutDown(m_text, &(font->face), false,
    21552168                                     tr.width(), tr.height());
    2156     p->drawText(tr, Qt::AlignLeft|Qt::AlignVCenter, text);   
     2169    p->drawText(tr, m_justify, text);   
    21572170}
    21582171
  • uilistbtntype.h

     
    175175    void  SetSpacing(int spacing);
    176176    void  SetMargin(int margin);
    177177    void  SetItemRegColor(const QColor& beg, const QColor& end, uint alpha);
    178     void  SetItemSelColor(const QColor& beg, const QColor& end, uint alpha);
    179    
     178    void  SetItemSelColor(const QColor& beg, const QColor& end, uint alpha); 
     179    void  SetJustification(int justification);
     180
    180181    void  Draw(QPainter *p, int order, int context);
    181182    void  Draw(QPainter *p, int order, int context, bool active_on);
    182183    void  SetActive(bool active);
     
    237238    int   m_itemSpacing;
    238239    int   m_itemMargin;
    239240    uint  m_itemsVisible;
    240 
     241       
     242        int m_justify;
    241243    bool  m_active;
    242244    bool  m_visible;
    243245    bool  m_showScrollArrows;
     
    337339    bool moveUpDown(bool flag);
    338340   
    339341    void paint(QPainter *p, fontProp *font, int x, int y, bool active_on);
    340    
     342    void setJustification(int justification);
     343
    341344  protected:
    342345    void  CalcDimensions(void);
    343346
     
    356359    bool           m_showArrow;
    357360
    358361    bool           m_overrideInactive;
     362    int m_justify;
    359363
    360364    friend class UIListBtnType;
    361365};
  • xmlparse.cpp

     
    34473447    QRect   area = QRect(0,0,0,0);
    34483448    QString fontActive;
    34493449    QString fontInactive;
     3450    QString align = "";
    34503451    bool    showArrow = true;
    34513452    bool    showScrollArrows = false;
    34523453    int     draworder = 0;
     
    35073508                if (getFirstText(info).lower() == "no")
    35083509                    showArrow = false;
    35093510            }
     3511            else if (info.tagName() == "align")
     3512            {
     3513                align = getFirstText(info);
     3514            }
    35103515            else if (info.tagName() == "showscrollarrows") {
    35113516                if (getFirstText(info).lower() == "yes")
    35123517                    showScrollArrows = true;
     
    35583563        }
    35593564    }
    35603565
     3566    int jst = Qt::AlignLeft|Qt::AlignVCenter;
     3567
     3568    if (!align.isNull() && !align.isEmpty())
     3569    {
     3570        if (align.lower() == "center")
     3571                jst = Qt::AlignCenter|Qt::AlignVCenter;
     3572        else if (align.lower() == "right")
     3573                jst = Qt::AlignRight|Qt::AlignVCenter;
     3574        else if (align.lower() == "left")
     3575                jst = Qt::AlignLeft|Qt::AlignVCenter;
     3576     }
     3577
    35613578    fontProp *fpActive = GetFont(fontActive);
    35623579    if (!fpActive)
    35633580    {
     
    35803597    l->SetScreen(wmult, hmult);
    35813598    l->SetFontActive(fpActive);
    35823599    l->SetFontInactive(fpInactive);
     3600    l->SetJustification(jst);
    35833601    l->SetItemRegColor(grUnselectedBeg, grUnselectedEnd, grUnselectedAlpha);
    35843602    l->SetItemSelColor(grSelectedBeg, grSelectedEnd, grSelectedAlpha);
    35853603    l->SetSpacing((int)(spacing*hmult));