Ticket #6055: autosize.diff
File autosize.diff, 2.6 KB (added by , 17 years ago) |
---|
-
libs/libmythui/mythuitext.cpp
24 24 incR(0.0), incG(0.0), incB(0.0) 25 25 { 26 26 m_MultiLine = false; 27 m_AutoSize = false; 27 28 m_scrolling = false; 28 29 m_scrollDirection = ScrollLeft; 29 30 … … 47 48 incR(0.0), incG(0.0), incB(0.0) 48 49 { 49 50 m_MultiLine = false; 51 m_AutoSize = false; 52 50 53 SetArea(displayRect); 51 54 m_FontStates.insert("default", font); 52 55 *m_Font = m_FontStates["default"]; … … 101 104 102 105 m_Message = newtext; 103 106 m_CutMessage = ""; 107 108 if (m_AutoSize) 109 { 110 QFontMetrics fm(GetFontProperties()->face()); 111 QSize stringSize = fm.size(Qt::TextSingleLine, m_Message); 112 SetDrawRectSize(stringSize.width(), m_Area.height()); 113 } 114 104 115 SetRedraw(); 105 116 } 106 117 … … 173 184 SetRedraw(); 174 185 } 175 186 187 void MythUIText::SetAutoSize(bool autosize) 188 { 189 m_AutoSize = autosize; 190 SetRedraw(); 191 } 192 176 193 void MythUIText::SetArea(const MythRect &rect) 177 194 { 178 195 MythUIType::SetArea(rect); … … 396 413 } 397 414 398 415 bool MythUIText::ParseElement(QDomElement &element) 399 { 416 { 400 417 if (element.tagName() == "area") 401 418 { 402 419 SetArea(parseRect(element)); … … 452 469 { 453 470 SetMultiLine(parseBool(element)); 454 471 } 472 else if (element.tagName() == "autosize") 473 { 474 SetAutoSize(parseBool(element)); 475 } 455 476 else if (element.tagName() == "align") 456 477 { 457 478 QString align = getFirstText(element).toLower(); … … 533 554 534 555 m_Cutdown = text->m_Cutdown; 535 556 m_MultiLine = text->m_MultiLine; 557 m_AutoSize = text->m_AutoSize; 536 558 537 559 QMutableMapIterator<QString, MythFontProperties> it(text->m_FontStates); 538 560 while (it.hasNext()) -
libs/libmythui/mythuitext.h
66 66 bool GetCutDown(void) const { return m_Cutdown; } 67 67 void SetMultiLine(bool multiline); 68 68 bool GetMultiLine(void) const { return m_MultiLine; } 69 69 void SetAutoSize(bool autosize); 70 bool GetAutoSize(void) const { return m_AutoSize; } 71 70 72 void SetArea(const MythRect &rect); 71 73 void SetPosition(const MythPoint &pos); 72 74 MythRect GetDrawRect(void) { return m_drawRect; } … … 90 92 91 93 bool m_Cutdown; 92 94 bool m_MultiLine; 95 bool m_AutoSize; 93 96 94 97 MythFontProperties* m_Font; 95 98 QMap<QString, MythFontProperties> m_FontStates;