void BIconRule::Draw(BRect updateRect) { int32 count = CountIcons(); if (count == 0) return; rgb_color panelColor = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color lightColor = tint_color(panelColor, B_DARKEN_1_TINT); rgb_color darkColor = tint_color(lightColor, B_DARKEN_2_TINT); SetHighColor(darkColor); StrokeLine(Bounds().LeftTop(), Bounds().RightTop()); StrokeLine(Bounds().LeftTop(), Bounds().LeftBottom()); SetHighColor(lightColor); StrokeLine(Bounds().LeftBottom(), Bounds().RightBottom()); StrokeLine(Bounds().RightTop(), Bounds().RightBottom()); BRect itemFrame(kEdgeOffset, kBorderOffset, -1, kBorderOffset + 64); for (int32 i = 0; i < count; i++) { BIconItem* item = fIcons.ItemAt(i); float width = StringWidth(item->Label()) + StringWidth(" ") * 2; if (width < 64.0f) width = 64.0f; itemFrame.right = itemFrame.left + width - 1; if (itemFrame.Intersects(updateRect)) { item->SetFrame(itemFrame); item->Draw(); } itemFrame.left = itemFrame.right + kEdgeOffset + 1; } }
void BListView::Draw(BRect updateRect) { int32 count = CountItems(); if (count == 0) return; BRect itemFrame(0, 0, Bounds().right, -1); for (int i = 0; i < count; i++) { BListItem* item = ItemAt(i); itemFrame.bottom = itemFrame.top + ceilf(item->Height()) - 1; if (itemFrame.Intersects(updateRect)) DrawItem(item, itemFrame); itemFrame.top = itemFrame.bottom + 1; } }