void BBitmapColumn::DrawField(BField* field, BRect rect, BView* parent) { BBitmapField *bitmapField = static_cast<BBitmapField *>(field); const BBitmap *bitmap = bitmapField->Bitmap(); if (bitmap != NULL) { float x = 0.0; float y; BRect r = bitmap->Bounds(); y = rect.top + ((rect.Height() - r.Height()) / 2); switch (Alignment()) { case B_ALIGN_LEFT: x = rect.left + kTEXT_MARGIN; break; case B_ALIGN_CENTER: x = rect.left + ((rect.Width() - r.Width()) / 2); break; case B_ALIGN_RIGHT: x = rect.right - kTEXT_MARGIN - r.Width(); break; } parent->SetDrawingMode(B_OP_ALPHA); parent->DrawBitmap(bitmap, BPoint(x, y)); parent->SetDrawingMode(B_OP_OVER); } }
void BBitmapColumn::DrawField(BField* field, BRect rect, BView* parent) { BBitmapField *bitmapField = static_cast<BBitmapField *>(field); const BBitmap *bitmap = bitmapField->Bitmap(); if (bitmap != NULL) { float x = 0.0; BRect r = bitmap->Bounds(); float y = rect.top + ((rect.Height() - r.Height()) / 2); switch (Alignment()) { default: case B_ALIGN_LEFT: x = rect.left + kTEXT_MARGIN; break; case B_ALIGN_CENTER: x = rect.left + ((rect.Width() - r.Width()) / 2); break; case B_ALIGN_RIGHT: x = rect.right - kTEXT_MARGIN - r.Width(); break; } // setup drawing mode according to bitmap color space, // restore previous mode after drawing drawing_mode oldMode = parent->DrawingMode(); if (bitmap->ColorSpace() == B_RGBA32 || bitmap->ColorSpace() == B_RGBA32_BIG) { parent->SetDrawingMode(B_OP_ALPHA); parent->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); } else { parent->SetDrawingMode(B_OP_OVER); } parent->DrawBitmap(bitmap, BPoint(x, y)); parent->SetDrawingMode(oldMode); } }