void KeyValueListBox::_updateItemText(gfx::Engine& painter, ListBoxItem& item, const Rect& textRect, Font font, const Rect& frameRect ) { ListBox::_updateItemText( painter, item, textRect, font, frameRect ); Font f = Font::create( "FONT_1" ); std::string str = item.data( "key" ).toString(); Rect finalRect = f.getTextRect( str, Rect( 0, 0, frameRect.width() / 2, frameRect.height() ), align::center, align::center ); item.draw( str, f, finalRect.lefttop() - Point( 10, 0) ); str = item.data( "value" ).toString(); finalRect = f.getTextRect( str, Rect( frameRect.width()/2, 0, frameRect.width(), frameRect.height() ), align::upperLeft, align::center ); item.draw( str, f, finalRect.lefttop() - Point( 10, 0) ); }
void FileListBox::_updateItemText(gfx::Engine& painter, ListBoxItem& item, const Rect& textRect, Font font, const Rect& frameRect ) { ListBox::_updateItemText( painter, item, textRect, font, frameRect ); if( !isFlag( showExtension ) ) { item.clear(); std::string text = vfs::Path( item.text() ).baseName( false ).toString(); Rect finalRect = font.getTextRect( text, Rect( Point(), frameRect.size() ), align::upperLeft, align::center ); item.draw( text, font, finalRect.lefttop() + Point( 10, 0) ); } if( isFlag( showTime ) ) { Font f = Font::create( FONT_1 ); std::string timeStr = item.data( "time" ).toString(); Rect finalRect = f.getTextRect( timeStr, Rect( Point(), frameRect.size() ), align::lowerRight, align::center ); item.draw( timeStr, f, finalRect.lefttop() - Point( 10, 0) ); } }