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