* Fixed build under R5/Dano that was broken since Stippi added vector icon support.

* Separated Haiku's icon stuff a bit better, so that Tracker can still be built
  without having Haiku headers around.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19871 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-01-19 23:16:41 +00:00
parent 6486616423
commit eaac07392a
6 changed files with 63 additions and 49 deletions
+20 -14
View File
@@ -32,17 +32,20 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "Bitmaps.h"
#include "Utilities.h"
#include <Autolock.h>
#include <Bitmap.h>
#include <Debug.h>
#include <DataIO.h>
#include <File.h>
#include <IconUtils.h>
#include <String.h>
#include <SupportDefs.h>
#include "Bitmaps.h"
#include "Utilities.h"
#ifdef __HAIKU__
# include <IconUtils.h>
#endif
BImageResources::BImageResources(void *memAddr)
@@ -138,11 +141,12 @@ BImageResources::GetIconResource(int32 id, icon_size size, BBitmap *dest) const
size_t length = 0;
const void *data;
#ifdef __HAIKU__
// try to load vector icon
data = LoadResource(B_VECTOR_ICON_TYPE, id, &length);
if (data && BIconUtils::GetVectorIcon((uint8*)data, length, dest) == B_OK)
if (data != NULL && BIconUtils::GetVectorIcon((uint8*)data, length, dest) == B_OK)
return B_OK;
#endif
// fall back to R5 icon
if (size != B_LARGE_ICON && size != B_MINI_ICON)
@@ -151,21 +155,20 @@ BImageResources::GetIconResource(int32 id, icon_size size, BBitmap *dest) const
length = 0;
data = LoadResource(size == B_LARGE_ICON ? 'ICON' : 'MICN', id, &length);
if (data == 0 || length != (size_t)(size == B_LARGE_ICON ? 1024 : 256)) {
if (data == NULL || length != (size_t)(size == B_LARGE_ICON ? 1024 : 256)) {
TRESPASS();
return B_ERROR;
}
status_t ret = B_OK;
#ifdef __HAIKU__
if (dest->ColorSpace() != B_CMAP8) {
ret = BIconUtils::ConvertFromCMAP8((uint8*)data, size, size,
return BIconUtils::ConvertFromCMAP8((uint8*)data, size, size,
size, dest);
} else {
dest->SetBits(data, (int32)length, 0, B_CMAP8);
}
#endif
return ret;
dest->SetBits(data, (int32)length, 0, B_CMAP8);
return B_OK;
}
@@ -173,17 +176,20 @@ status_t
BImageResources::GetIconResource(int32 id, const uint8** iconData,
size_t* iconSize) const
{
#ifdef __HAIKU__
// try to load vector icon data from resources
size_t length = 0;
const void* data = LoadResource(B_VECTOR_ICON_TYPE, id, &length);
if (!data)
if (data == NULL)
return B_ERROR;
*iconData = (const uint8*)data;
*iconSize = length;
return B_OK;
#else
return B_ERROR;
#endif
}
+4 -4
View File
@@ -3428,7 +3428,7 @@ BContainerWindow::RestoreWindowState(AttributeStreamNode *node)
if (fContainerWindowFlags & kIsHidden)
Minimize(true);
#if __HAIKU__
#ifdef __HAIKU__
// restore window decor settings
int32 size = node->Contains(kAttrWindowDecor, B_RAW_TYPE);
if (size > 0) {
@@ -3476,7 +3476,7 @@ BContainerWindow::RestoreWindowState(const BMessage &message)
if (fContainerWindowFlags & kIsHidden)
Minimize(true);
#if __HAIKU__
#ifdef __HAIKU__
// restore window decor settings
BMessage decorSettings;
if ((fContainerWindowFlags & kRestoreDecor)
@@ -3509,7 +3509,7 @@ BContainerWindow::SaveWindowState(AttributeStreamNode *node)
node->Write(workspaceAttributeName, 0, B_INT32_TYPE, sizeof(uint32),
&workspaces);
#if __HAIKU__
#ifdef __HAIKU__
BMessage decorSettings;
if (GetDecoratorSettings(&decorSettings) == B_OK) {
int32 size = decorSettings.FlattenedSize();
@@ -3541,7 +3541,7 @@ BContainerWindow::SaveWindowState(BMessage &message) const
message.AddRect(rectAttributeName, frame);
message.AddInt32(workspaceAttributeName, (int32)Workspaces());
#if __HAIKU__
#ifdef __HAIKU__
BMessage decorSettings;
if (GetDecoratorSettings(&decorSettings) == B_OK) {
message.AddMessage(kAttrWindowDecor, &decorSettings);
+10 -9
View File
@@ -2145,21 +2145,20 @@ FSGetDeskDir(BDirectory *deskDir, dev_t dev)
size_t size;
const void* data = GetTrackerResources()->
LoadResource('ICON', kResDeskIcon, &size);
if (data)
if (data != NULL)
deskDir->WriteAttr(kAttrLargeIcon, 'ICON', 0, data, size);
data = GetTrackerResources()->
LoadResource('MICN', kResDeskIcon, &size);
if (data)
if (data != NULL)
deskDir->WriteAttr(kAttrMiniIcon, 'MICN', 0, data, size);
#ifdef __HAIKU__
data = GetTrackerResources()->
LoadResource(B_VECTOR_ICON_TYPE, kResDeskIcon, &size);
if (data)
if (data != NULL)
deskDir->WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 0, data, size);
#endif
return B_OK;
}
@@ -2647,22 +2646,24 @@ FSCreateTrashDirs()
size_t size;
const void* data = GetTrackerResources()->
LoadResource('ICON', kResTrashIcon, &size);
if (data) {
if (data != NULL) {
trashDir.WriteAttr(kAttrLargeIcon, 'ICON', 0,
data, size);
}
data = GetTrackerResources()->
LoadResource('MICN', kResTrashIcon, &size);
if (data) {
if (data != NULL) {
trashDir.WriteAttr(kAttrMiniIcon, 'MICN', 0,
data, size);
}
#ifdef __HAIKU
data = GetTrackerResources()->
LoadResource(B_VECTOR_ICON_TYPE, kResTrashIcon, &size);
if (data) {
if (data != NULL) {
trashDir.WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 0,
data, size);
}
#endif
}
}
}
+6 -1
View File
@@ -17,6 +17,11 @@ SubDirC++Flags
# -D_SILENTLY_CORRECT_FILE_NAMES=1
;
local vector_icon_libs ;
if $(TARGET_PLATFORM) = haiku {
vector_icon_libs = libicon.a libagg.a ;
}
SharedLibrary libtracker.so :
AttributeStream.cpp
AutoMounter.cpp
@@ -88,7 +93,7 @@ SharedLibrary libtracker.so :
VolumeWindow.cpp
WidgetAttributeText.cpp
: be translation libicon.a libagg.a
: be translation $(vector_icon_libs)
;
+3 -3
View File
@@ -164,7 +164,7 @@ TTracker::InstallMimeIfNeeded(const char *type, int32 bitsID,
# define B_BITMAP_NO_SERVER_LINK 0
#endif
#if __HAIKU__
#ifdef __HAIKU__
BBitmap vectorIcon(BRect(0, 0, 31, 31), B_BITMAP_NO_SERVER_LINK, B_RGB32);
#endif
BBitmap largeIcon(BRect(0, 0, 31, 31), B_BITMAP_NO_SERVER_LINK, B_CMAP8);
@@ -175,7 +175,7 @@ TTracker::InstallMimeIfNeeded(const char *type, int32 bitsID,
bool installed = mime.IsInstalled();
if (!installed
#if __HAIKU__
#ifdef __HAIKU__
|| (bitsID >= 0 && ((forceMask & kForceLargeIcon)
|| mime.GetIcon(&vectorIcon, B_LARGE_ICON) != B_OK))
#endif
@@ -194,7 +194,7 @@ TTracker::InstallMimeIfNeeded(const char *type, int32 bitsID,
mime.Install();
if (bitsID >= 0) {
#if __HAIKU__
#ifdef __HAIKU__
const uint8* iconData;
size_t iconSize;
if (GetTrackerResources()->
+20 -18
View File
@@ -32,18 +32,21 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include <ctype.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <stdarg.h>
#include "Attributes.h"
#include "MimeTypes.h"
#include "Model.h"
#include "Utilities.h"
#include "ContainerWindow.h"
#ifdef __HAIKU__
# include <IconUtils.h>
#endif
#include <Bitmap.h>
#include <Debug.h>
#include <Directory.h>
#include <fs_attr.h>
#include <fs_info.h>
#include <IconUtils.h>
#include <MenuItem.h>
#include <OS.h>
#include <PopUpMenu.h>
@@ -54,24 +57,23 @@ All rights reserved.
#include <VolumeRoster.h>
#include <Window.h>
#include <ctype.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <stdarg.h>
#if B_BEOS_VERSION_DANO
#define _IMPEXP_BE
# define _IMPEXP_BE
#endif
extern _IMPEXP_BE const uint32 LARGE_ICON_TYPE;
extern _IMPEXP_BE const uint32 MINI_ICON_TYPE;
#if B_BEOS_VERSION_DANO
#undef _IMPEXP_BE
# undef _IMPEXP_BE
#endif
#include "Attributes.h"
#include "MimeTypes.h"
#include "Model.h"
#include "Utilities.h"
#include "ContainerWindow.h"
#include <fs_attr.h>
FILE *logFile = NULL;