#include <cLabel.h>
Public Member Functions | |
virtual | ~Label () |
void | Render () |
Do- nothing destructor. | |
bool | Process (tXmlParser::node cur) |
Passes on to all Process() functions of the base classes and calls Base::DisplayError() on failure. |
Definition at line 43 of file cLabel.h.
virtual cWidget::Label::~Label | ( | ) | [inline, virtual] |
void cWidget::Label::Render | ( | ) | [virtual] |
Do- nothing destructor.
Renders the label and the caption
Implements cWidget::Base.
Definition at line 49 of file cLabel.cpp.
References c, rTextField::GetTextLength(), height, cWidget::WithCaption::m_caption, cWidget::WithCaption::m_captionloc, cWidget::WithCoordinates::m_position, cWidget::WithCoordinates::m_size, cWidget::WithTable::m_table, cWidget::WithCaption::off, pos, sr_fontCockpit, cWidget::WithCaption::top, width, tCoord::x, and tCoord::y.
00050 { 00051 std::deque<std::deque<tString> > contents; 00052 unsigned maxlen = 0; 00053 { 00054 for(std::deque<std::deque<std::deque<tValue::Set> > >::iterator i(m_table.begin()); i!=m_table.end(); ++i) { 00055 if(i->size() > maxlen) maxlen = i->size(); 00056 } 00057 } 00058 std::deque<float> coloumns(maxlen, 0.); //max widths 00059 { 00060 for(std::deque<std::deque<std::deque<tValue::Set> > >::iterator i(m_table.begin()); i!=m_table.end(); ++i) { 00061 contents.push_back(std::deque<tString>()); 00062 std::deque<float>::iterator m(coloumns.begin()); 00063 for(std::deque<std::deque<tValue::Set> >::iterator j(i->begin()); j!=i->end(); ++j, ++m) { 00064 tColoredString result; 00065 for(std::deque<tValue::Set>::iterator k(j->begin()); k!=j->end(); ++k) { 00066 result += k->GetVal().GetString(); 00067 } 00068 float size = rTextField::GetTextLength(result, m_size.y, true); 00069 if(size > *m) { 00070 *m = size; 00071 } 00072 contents.back().push_back(result); 00073 } 00074 } 00075 } 00076 if(m_captionloc != off) { 00077 int height = m_table.size(); 00078 float width = std::accumulate(coloumns.begin(), coloumns.end(), float()) + (maxlen - 1)*m_size.x; 00079 00080 tCoord captionloc(m_position.x + (width-rTextField::GetTextLength(m_caption, m_size.y))/2., 0); 00081 if(m_captionloc == top) { 00082 captionloc.y = m_position.y + m_size.y; 00083 } else if(m_captionloc) { 00084 captionloc.y = m_position.y - height*m_size.y; 00085 } 00086 rTextField c(captionloc.x,captionloc.y,m_size.y,sr_fontCockpit); 00087 c<<m_caption; 00088 } 00089 00090 tCoord pos(0.,m_position.y); 00091 //now displaying the results 00092 { 00093 for(std::deque<std::deque<tString> >::iterator i(contents.begin()); i != contents.end(); ++i) { 00094 pos.x = m_position.x; 00095 std::deque<float>::iterator m(coloumns.begin()); 00096 for(std::deque<tString>::iterator j(i->begin()); j != i->end(); ++j, ++m) { 00097 rTextField c(pos.x,pos.y,m_size.y, sr_fontCockpit); 00098 c<<*j; 00099 pos.x += *m+m_size.x; 00100 } 00101 pos.y -= m_size.y; 00102 } 00103 } 00104 }
bool cWidget::Label::Process | ( | tXmlParser::node | cur | ) | [virtual] |
Passes on to all Process() functions of the base classes and calls Base::DisplayError() on failure.
Reimplemented from cWidget::WithCoordinates.
Definition at line 37 of file cLabel.cpp.
References cWidget::Base::DisplayError(), cWidget::WithCaption::Process(), cWidget::WithCoordinates::Process(), and cWidget::WithTable::Process().
00037 { 00038 if ( 00039 WithTable ::Process(cur) || 00040 WithCoordinates ::Process(cur) || 00041 WithCaption ::Process(cur)) 00042 return true; 00043 else { 00044 DisplayError(cur); 00045 return false; 00046 } 00047 }