13 TextView * textView = textViewAtIndex(index);
28 int BannerView::numberOfSubviews()
const {
32 void BannerView::layoutSubviews() {
40 TextView * textViewPreviousLine = textViewAtIndex(0);
41 int indexOfFirstViewOfCurrentLine = 0;
44 for (
int i = 0; i <= numberOfSubviews(); i++) {
47 if (i < numberOfSubviews()) {
48 textView = textViewAtIndex(i);
52 if (lineWidth + currentViewWidth > totalWidth) {
54 int nbOfTextViewInLine = i > indexOfFirstViewOfCurrentLine ? i-indexOfFirstViewOfCurrentLine : 1;
55 KDCoordinate roundingError = totalWidth-lineWidth-nbOfTextViewInLine*(int)((totalWidth-lineWidth)/nbOfTextViewInLine);
56 for (
int j = indexOfFirstViewOfCurrentLine; j < i; j++) {
57 textViewPreviousLine = textViewAtIndex(j);
60 textWidth = j == i-1 ? textWidth + roundingError : textWidth;
62 textViewPreviousLine->
setFrame(
KDRect(x, y, textWidth, textHeight));
68 indexOfFirstViewOfCurrentLine = i;
70 lineWidth += currentViewWidth;
74 View * BannerView::subviewAtIndex(
int index) {
75 assert(index >= 0 && index < numberOfSubviews());
76 return textViewAtIndex(index);
79 int BannerView::numberOfLines()
const {
83 for (
int i = 0; i < numberOfSubviews(); i++) {
85 if (usedWidth+textWidth > width) {
86 usedWidth = textWidth;
89 usedWidth += textWidth;
void setLegendAtIndex(char *text, int index)
void setFrame(KDRect frame)
constexpr KDCoordinate width() const
static KDSize stringSize(const char *text, FontSize size=FontSize::Large)
void setMessageAtIndex(I18n::Message text, int index)
KDSize minimalSizeForOptimalDisplay() const override
virtual void setText(const char *text)=0
void setMessage(I18n::Message message)
KDCoordinate width() const
static constexpr KDSize charSize(FontSize size=FontSize::Large)
KDSize minimalSizeForOptimalDisplay() const override
constexpr KDCoordinate height() const