void MimeTypeItem::DrawItem(BView* owner, BRect frame, bool complete) { BFont font; if (IsSupertypeOnly()) { owner->GetFont(&font); BFont boldFont(font); boldFont.SetFace(B_BOLD_FACE); owner->SetFont(&boldFont); } BRect rect = frame; if (fFlat) { // This is where the latch would be - yet can freely consider this // as an ugly hack rect.left -= 11.0f; } if (fShowIcon) { rgb_color lowColor = owner->LowColor(); if (IsSelected() || complete) { if (IsSelected()) owner->SetLowColor(ui_color(B_LIST_SELECTED_BACKGROUND_COLOR)); owner->FillRect(rect, B_SOLID_LOW); } BBitmap bitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_RGBA32); BMimeType mimeType(fType.String()); status_t status = icon_for_type(mimeType, bitmap, B_MINI_ICON); if (status < B_OK) { // get default generic/application icon BMimeType genericType(fApplicationMode ? B_ELF_APP_MIME_TYPE : B_FILE_MIME_TYPE); status = icon_for_type(genericType, bitmap, B_MINI_ICON); } if (status == B_OK) { BPoint point(rect.left + 2.0f, rect.top + (rect.Height() - B_MINI_ICON) / 2.0f); owner->SetDrawingMode(B_OP_ALPHA); owner->DrawBitmap(&bitmap, point); } owner->SetDrawingMode(B_OP_COPY); owner->MovePenTo(rect.left + B_MINI_ICON + 8.0f, frame.top + fBaselineOffset); owner->DrawString(Text()); owner->SetLowColor(lowColor); } else BStringItem::DrawItem(owner, rect, complete); if (IsSupertypeOnly()) owner->SetFont(&font); }
void HTGTweetMenuItem::setLinkIconUrl(std::string& url) { this->linkIconUrl = url; if(linkIconUrl.find(".ico") == std::string::npos) { /*Load generic icon*/ BRect iconRect(0, 0, B_MINI_ICON-1, B_MINI_ICON-1); linkIcon = new BBitmap(iconRect, B_RGBA32); BMimeType mimeType("text/html"); icon_for_type(mimeType,*linkIcon,B_MINI_ICON); if(Menu()->LockLooper()) { Menu()->Invalidate(); Menu()->UnlockLooper(); } } else if(!linkIconDownloadInProgress) { downloadLinkIcon(); } }