Ticket #4192: uilistbtntype_justification.patch
File uilistbtntype_justification.patch, 4.5 KB (added by , 16 years ago) |
---|
-
uilistbtntype.cpp
1705 1705 font = m_fontInactive; 1706 1706 p->setFont(font->face); 1707 1707 p->setPen(font->color); 1708 it.current()->setJustification(m_justify); 1708 1709 it.current()->paint(p, font, x, y, active_on); 1709 1710 font = m_active ? m_fontActive : m_fontInactive;; 1710 1711 p->setFont(font->face); … … 1712 1713 } 1713 1714 else 1714 1715 { 1716 it.current()->setJustification(m_justify); 1715 1717 it.current()->paint(p, font, x, y, active_on); 1716 1718 } 1717 1719 … … 1744 1746 1745 1747 } 1746 1748 1749 void UIListBtnType::SetJustification(int justification) 1750 { 1751 m_justify = justification; 1752 } 1753 1747 1754 void UIListBtnType::Init() 1748 1755 { 1749 1756 QFontMetrics fm(m_fontActive->face); … … 1935 1942 m_showArrow = showArrow; 1936 1943 m_data = 0; 1937 1944 m_overrideInactive = false; 1938 1945 m_justify = Qt::AlignLeft|Qt::AlignVCenter; 1946 1939 1947 if (state >= NotChecked) 1940 1948 m_checkable = true; 1941 1949 … … 1944 1952 m_parent->InsertItem(this); 1945 1953 } 1946 1954 1955 void UIListBtnTypeItem::setJustification(int justification) 1956 { 1957 m_justify = justification; 1958 } 1959 1947 1960 void UIListBtnTypeItem::CalcDimensions(void) 1948 1961 { 1949 1962 if (!m_parent->m_initialized) … … 2153 2166 tr.moveBy(x,y); 2154 2167 QString text = m_parent->cutDown(m_text, &(font->face), false, 2155 2168 tr.width(), tr.height()); 2156 p->drawText(tr, Qt::AlignLeft|Qt::AlignVCenter, text);2169 p->drawText(tr, m_justify, text); 2157 2170 } 2158 2171 -
uilistbtntype.h
175 175 void SetSpacing(int spacing); 176 176 void SetMargin(int margin); 177 177 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 180 181 void Draw(QPainter *p, int order, int context); 181 182 void Draw(QPainter *p, int order, int context, bool active_on); 182 183 void SetActive(bool active); … … 237 238 int m_itemSpacing; 238 239 int m_itemMargin; 239 240 uint m_itemsVisible; 240 241 242 int m_justify; 241 243 bool m_active; 242 244 bool m_visible; 243 245 bool m_showScrollArrows; … … 337 339 bool moveUpDown(bool flag); 338 340 339 341 void paint(QPainter *p, fontProp *font, int x, int y, bool active_on); 340 342 void setJustification(int justification); 343 341 344 protected: 342 345 void CalcDimensions(void); 343 346 … … 356 359 bool m_showArrow; 357 360 358 361 bool m_overrideInactive; 362 int m_justify; 359 363 360 364 friend class UIListBtnType; 361 365 }; -
xmlparse.cpp
3447 3447 QRect area = QRect(0,0,0,0); 3448 3448 QString fontActive; 3449 3449 QString fontInactive; 3450 QString align = ""; 3450 3451 bool showArrow = true; 3451 3452 bool showScrollArrows = false; 3452 3453 int draworder = 0; … … 3507 3508 if (getFirstText(info).lower() == "no") 3508 3509 showArrow = false; 3509 3510 } 3511 else if (info.tagName() == "align") 3512 { 3513 align = getFirstText(info); 3514 } 3510 3515 else if (info.tagName() == "showscrollarrows") { 3511 3516 if (getFirstText(info).lower() == "yes") 3512 3517 showScrollArrows = true; … … 3558 3563 } 3559 3564 } 3560 3565 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 3561 3578 fontProp *fpActive = GetFont(fontActive); 3562 3579 if (!fpActive) 3563 3580 { … … 3580 3597 l->SetScreen(wmult, hmult); 3581 3598 l->SetFontActive(fpActive); 3582 3599 l->SetFontInactive(fpInactive); 3600 l->SetJustification(jst); 3583 3601 l->SetItemRegColor(grUnselectedBeg, grUnselectedEnd, grUnselectedAlpha); 3584 3602 l->SetItemSelColor(grSelectedBeg, grSelectedEnd, grSelectedAlpha); 3585 3603 l->SetSpacing((int)(spacing*hmult));