Added support for the vector icons to FileTypes and DiskProbe.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19194 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
#include "AttributeEditors.h"
|
||||
#include "DataEditor.h"
|
||||
|
||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
# include <IconUtils.h>
|
||||
#endif
|
||||
|
||||
#include <MenuItem.h>
|
||||
#include <StringView.h>
|
||||
#include <TextControl.h>
|
||||
@@ -764,7 +768,8 @@ ImageView::ImageView(BRect rect, DataEditor &editor)
|
||||
fEditor(editor),
|
||||
fBitmap(NULL)
|
||||
{
|
||||
if (editor.Type() == 'MICN' || editor.Type() == 'ICON')
|
||||
if (editor.Type() == 'MICN' || editor.Type() == 'ICON'
|
||||
|| (!strcmp(editor.Attribute(), "BEOS:ICON") && editor.Type() == B_RAW_TYPE))
|
||||
SetName("Icon View");
|
||||
|
||||
fDescriptionView = new BStringView(Bounds(), "", "Could not read image", B_FOLLOW_NONE);
|
||||
@@ -817,8 +822,11 @@ ImageView::MessageReceived(BMessage *message)
|
||||
void
|
||||
ImageView::Draw(BRect updateRect)
|
||||
{
|
||||
if (fBitmap != NULL)
|
||||
if (fBitmap != NULL) {
|
||||
SetDrawingMode(B_OP_ALPHA);
|
||||
DrawBitmap(fBitmap, BPoint((Bounds().Width() - fBitmap->Bounds().Width()) / 2, 0));
|
||||
SetDrawingMode(B_OP_COPY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -848,6 +856,10 @@ ImageView::UpdateImage()
|
||||
fEditor.SetViewSize(viewSize);
|
||||
return;
|
||||
}
|
||||
if (fBitmap != NULL && !strcmp(fEditor.Attribute(), "BEOS:ICON")
|
||||
&& fEditor.Type() == B_RAW_TYPE) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete fBitmap;
|
||||
fBitmap = NULL;
|
||||
@@ -863,6 +875,20 @@ ImageView::UpdateImage()
|
||||
if (fBitmap->InitCheck() == B_OK)
|
||||
fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8);
|
||||
break;
|
||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
case B_RAW_TYPE:
|
||||
if (strcmp(fEditor.Attribute(), "BEOS:ICON"))
|
||||
break;
|
||||
|
||||
fBitmap = new BBitmap(BRect(0, 0, 127, 127), B_RGB32);
|
||||
if (fBitmap->InitCheck() != B_OK || fEditor.FileSize() > 64 * 1024
|
||||
|| BIconUtils::GetVectorIcon((const uint8 *)data,
|
||||
(size_t)fEditor.FileSize(), fBitmap) != B_OK) {
|
||||
delete fBitmap;
|
||||
fBitmap = NULL;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case 'PNG ':
|
||||
{
|
||||
BMemoryIO stream(data, fEditor.FileSize());
|
||||
@@ -883,19 +909,23 @@ ImageView::UpdateImage()
|
||||
// Update the bitmap description. If no image can be displayed,
|
||||
// we will show our "unsupported" message
|
||||
|
||||
if (fBitmap->InitCheck() != B_OK) {
|
||||
if (fBitmap != NULL && fBitmap->InitCheck() != B_OK) {
|
||||
delete fBitmap;
|
||||
fBitmap = NULL;
|
||||
}
|
||||
|
||||
if (fBitmap != NULL) {
|
||||
char buffer[256];
|
||||
const char *type;
|
||||
const char *type = "Unknown Type";
|
||||
switch (fEditor.Type()) {
|
||||
case 'MICN':
|
||||
case 'ICON':
|
||||
type = "Icon";
|
||||
break;
|
||||
case B_RAW_TYPE:
|
||||
if (!strcmp(fEditor.Attribute(), "BEOS:ICON"))
|
||||
type = "Icon";
|
||||
break;
|
||||
case 'PNG ':
|
||||
type = "PNG Format";
|
||||
break;
|
||||
@@ -903,7 +933,6 @@ ImageView::UpdateImage()
|
||||
type = "Flattened Bitmap";
|
||||
break;
|
||||
default:
|
||||
type = "Unknown Type";
|
||||
break;
|
||||
}
|
||||
const char *colorSpace;
|
||||
@@ -1017,6 +1046,11 @@ GetTypeEditorFor(BRect rect, DataEditor &editor)
|
||||
return new ImageView(rect, editor);
|
||||
}
|
||||
|
||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
if (!strcmp(editor.Attribute(), "BEOS:ICON") && editor.Type() == B_RAW_TYPE)
|
||||
return new ImageView(rect, editor);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ SubDir HAIKU_TOP src apps diskprobe ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
UseLibraryHeaders icon ;
|
||||
UsePrivateHeaders shared ;
|
||||
|
||||
Application DiskProbe :
|
||||
|
||||
@@ -236,7 +236,7 @@ IconView::Draw(BRect updateRect)
|
||||
if (fBitmap == NULL)
|
||||
return;
|
||||
|
||||
SetDrawingMode(B_OP_OVER);
|
||||
SetDrawingMode(B_OP_ALPHA);
|
||||
DrawBitmap(fBitmap, updateRect, updateRect);
|
||||
SetDrawingMode(B_OP_COPY);
|
||||
}
|
||||
@@ -246,7 +246,7 @@ void
|
||||
IconView::UpdateIcon()
|
||||
{
|
||||
if (fBitmap == NULL)
|
||||
fBitmap = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8);
|
||||
fBitmap = new BBitmap(BRect(0, 0, 31, 31), B_RGB32);
|
||||
|
||||
if (fBitmap != NULL) {
|
||||
status_t status = B_ERROR;
|
||||
|
||||
@@ -115,7 +115,7 @@ TypeIconView::SetTo(BMimeType* type)
|
||||
if (type != NULL) {
|
||||
if (fIcon == NULL) {
|
||||
fIcon = new BBitmap(BRect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1),
|
||||
B_CMAP8);
|
||||
B_RGB32);
|
||||
}
|
||||
|
||||
icon_for_type(*type, *fIcon, B_LARGE_ICON, &fIconSource);
|
||||
|
||||
@@ -96,8 +96,8 @@ IconView::SetTo(entry_ref* ref)
|
||||
if (node.InitCheck() != B_OK
|
||||
|| info.InitCheck() != B_OK)
|
||||
return;
|
||||
|
||||
BBitmap* icon = new BBitmap(BRect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1), B_CMAP8);
|
||||
|
||||
BBitmap* icon = new BBitmap(BRect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1), B_RGB32);
|
||||
if (info.GetIcon(icon, B_LARGE_ICON) != B_OK) {
|
||||
delete icon;
|
||||
return;
|
||||
|
||||
@@ -137,7 +137,7 @@ MimeTypeItem::DrawItem(BView* owner, BRect frame, bool complete)
|
||||
owner->FillRect(rect, B_SOLID_LOW);
|
||||
}
|
||||
|
||||
BBitmap bitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_CMAP8);
|
||||
BBitmap bitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_RGB32);
|
||||
BMimeType mimeType(fType.String());
|
||||
status_t status = icon_for_type(mimeType, bitmap, B_MINI_ICON);
|
||||
if (status < B_OK) {
|
||||
|
||||
Reference in New Issue
Block a user