void JobItem::DrawItem(BView *owner, BRect, bool complete) { BListView* list = dynamic_cast<BListView*>(owner); if (list) { BFont font; owner->GetFont(&font); font_height height; font.GetHeight(&height); float fntheight = height.ascent + height.descent + height.leading; BRect bounds = list->ItemFrame(list->IndexOf(this)); rgb_color color = owner->ViewColor(); rgb_color oldViewColor = color; rgb_color oldLowColor = owner->LowColor(); rgb_color oldHighColor = owner->HighColor(); if (IsSelected()) color = tint_color(color, B_HIGHLIGHT_BACKGROUND_TINT); owner->SetViewColor(color); owner->SetHighColor(color); owner->SetLowColor(color); owner->FillRect(bounds); owner->SetLowColor(oldLowColor); owner->SetHighColor(oldHighColor); BPoint iconPt(bounds.LeftTop() + BPoint(2.0, 2.0)); float iconHeight = B_MINI_ICON; #ifdef ANTARES_TARGET_PLATFORM_ANTARES if (fIcon) iconHeight = fIcon->Bounds().Height(); #endif BPoint leftTop(bounds.LeftTop() + BPoint(12.0 + iconHeight, 2.0)); BPoint namePt(leftTop + BPoint(0.0, fntheight)); BPoint statusPt(leftTop + BPoint(0.0, fntheight * 2.0)); float x = owner->StringWidth(fPages.String()) + 32.0; BPoint pagePt(bounds.RightTop() + BPoint(-x, fntheight)); BPoint sizePt(bounds.RightTop() + BPoint(-x, fntheight * 2.0)); drawing_mode mode = owner->DrawingMode(); #ifdef ANTARES_TARGET_PLATFORM_ANTARES owner->SetDrawingMode(B_OP_ALPHA); #else owner->SetDrawingMode(B_OP_OVER); #endif if (fIcon) owner->DrawBitmap(fIcon, iconPt); // left of item owner->DrawString(fName.String(), fName.Length(), namePt); owner->DrawString(fStatus.String(), fStatus.Length(), statusPt); // right of item owner->DrawString(fPages.String(), fPages.Length(), pagePt); owner->DrawString(fSize.String(), fSize.Length(), sizePt); owner->SetDrawingMode(mode); owner->SetViewColor(oldViewColor); } }
void PrinterItem::DrawItem(BView *owner, BRect /*bounds*/, bool complete) { BListView* list = dynamic_cast<BListView*>(owner); if (list == NULL) return; BFont font; owner->GetFont(&font); font_height height; font.GetHeight(&height); float fntheight = height.ascent + height.descent + height.leading; BRect bounds = list->ItemFrame(list->IndexOf(this)); rgb_color color = owner->ViewColor(); rgb_color oldLowColor = owner->LowColor(); rgb_color oldHighColor = owner->HighColor(); if (IsSelected()) color = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR); owner->SetLowColor(color); owner->SetHighColor(color); owner->FillRect(bounds); owner->SetLowColor(oldLowColor); owner->SetHighColor(oldHighColor); float iconColumnWidth = B_LARGE_ICON + 8.0; float x = iconColumnWidth; BPoint iconPt(bounds.LeftTop() + BPoint(2.0, 2.0)); BPoint namePt(iconPt + BPoint(x, fntheight)); BPoint driverPt(iconPt + BPoint(x, fntheight * 2.0)); BPoint defaultPt(iconPt + BPoint(x, fntheight * 3.0)); BPoint transportPt(iconPt + BPoint(x, fntheight * 3.0)); float totalWidth = bounds.Width() - iconColumnWidth; float maximumWidth = fLayoutData.fLeftColumnMaximumWidth + fLayoutData.fRightColumnMaximumWidth; float width; if (totalWidth < maximumWidth) { width = fLayoutData.fRightColumnMaximumWidth * totalWidth / maximumWidth; } else { width = fLayoutData.fRightColumnMaximumWidth; } BPoint pendingPt(bounds.right - width - 8.0, namePt.y); BPoint commentPt(bounds.right - width - 8.0, driverPt.y); drawing_mode mode = owner->DrawingMode(); #ifdef HAIKU_TARGET_PLATFORM_HAIKU owner->SetDrawingMode(B_OP_ALPHA); #else owner->SetDrawingMode(B_OP_OVER); #endif if (IsActivePrinter()) { if (sSelectedIcon && sSelectedIcon->IsValid()) owner->DrawBitmap(sSelectedIcon, iconPt); else owner->DrawString(B_TRANSLATE("Default Printer"), defaultPt); } else { if (sIcon && sIcon->IsValid()) owner->DrawBitmap(sIcon, iconPt); } owner->SetDrawingMode(B_OP_OVER); // left of item BString s = fName; owner->SetFont(be_bold_font); owner->TruncateString(&s, B_TRUNCATE_MIDDLE, pendingPt.x - namePt.x); owner->DrawString(s.String(), s.Length(), namePt); owner->SetFont(&font); s = B_TRANSLATE("Driver: %driver%"); s.ReplaceFirst("%driver%", fDriverName); owner->TruncateString(&s, B_TRUNCATE_END, commentPt.x - driverPt.x); owner->DrawString(s.String(), s.Length(), driverPt); if (fTransport.Length() > 0) { s = B_TRANSLATE("Transport: %transport% %transport_address%"); s.ReplaceFirst("%transport%", fTransport); s.ReplaceFirst("%transport_address%", fTransportAddress); owner->TruncateString(&s, B_TRUNCATE_BEGINNING, totalWidth); owner->DrawString(s.String(), s.Length(), transportPt); } // right of item s = fPendingJobs; owner->TruncateString(&s, B_TRUNCATE_END, bounds.Width() - pendingPt.x); owner->DrawString(s.String(), s.Length(), pendingPt); s = fComments; owner->TruncateString(&s, B_TRUNCATE_MIDDLE, bounds.Width() - commentPt.x); owner->DrawString(s.String(), s.Length(), commentPt); owner->SetDrawingMode(mode); }
void JobItem::DrawItem(BView *owner, BRect, bool complete) { BListView* list = dynamic_cast<BListView*>(owner); if (list) { BFont font; owner->GetFont(&font); font_height height; font.GetHeight(&height); float fntheight = height.ascent + height.descent + height.leading; BRect bounds = list->ItemFrame(list->IndexOf(this)); rgb_color color = owner->ViewColor(); rgb_color oldLowColor = owner->LowColor(); rgb_color oldHighColor = owner->HighColor(); if (IsSelected()) color = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR); owner->SetHighColor(color); owner->SetLowColor(color); owner->FillRect(bounds); owner->SetLowColor(oldLowColor); owner->SetHighColor(oldHighColor); BPoint iconPt(bounds.LeftTop() + BPoint(2.0, 2.0)); float iconHeight = B_MINI_ICON; #ifdef HAIKU_TARGET_PLATFORM_HAIKU if (fIcon) iconHeight = fIcon->Bounds().Height(); #endif BPoint leftTop(bounds.LeftTop() + BPoint(12.0 + iconHeight, 2.0)); BPoint namePt(leftTop + BPoint(0.0, fntheight)); BPoint statusPt(leftTop + BPoint(0.0, fntheight * 2.0)); float x = owner->StringWidth(fPages.String()) + 32.0; BPoint pagePt(bounds.RightTop() + BPoint(-x, fntheight)); BPoint sizePt(bounds.RightTop() + BPoint(-x, fntheight * 2.0)); drawing_mode mode = owner->DrawingMode(); #ifdef HAIKU_TARGET_PLATFORM_HAIKU owner->SetDrawingMode(B_OP_ALPHA); #else owner->SetDrawingMode(B_OP_OVER); #endif if (fIcon) owner->DrawBitmap(fIcon, iconPt); // left of item BString name = fName; owner->TruncateString(&name, B_TRUNCATE_MIDDLE, pagePt.x - namePt.x); owner->DrawString(name.String(), name.Length(), namePt); BString status = fStatus; owner->TruncateString(&status, B_TRUNCATE_MIDDLE, sizePt.x - statusPt.x); owner->DrawString(status.String(), status.Length(), statusPt); // right of item owner->DrawString(fPages.String(), fPages.Length(), pagePt); owner->DrawString(fSize.String(), fSize.Length(), sizePt); owner->SetDrawingMode(mode); } }