Zachary Hall
f63aa4da7a
Some checks failed
Build / build-android (push) Blocked by required conditions
Build / build-windows (push) Blocked by required conditions
Build / build-gentoo (push) Failing after 1m20s
Build / download-system-deps (push) Successful in 3m31s
Build / get-source-code (push) Successful in 7m5s
Build / build-appimage (push) Has been cancelled
34 lines
No EOL
904 B
C
34 lines
No EOL
904 B
C
#pragma once
|
|
#include <Bitmap.h>
|
|
#include <Rect.h>
|
|
#include <Application.h>
|
|
#include <IconUtils.h>
|
|
#include <SupportDefs.h>
|
|
#include <TypeConstants.h>
|
|
#include <Resources.h>
|
|
inline BBitmap *load_icon(int32 id, BRect rect = BRect(0, 0, 16, 16)) {
|
|
const void *data = NULL;
|
|
size_t size = 0;
|
|
data = BApplication::AppResources()->LoadResource(B_VECTOR_ICON_TYPE, id, &size);
|
|
if (data != NULL) {
|
|
BBitmap *icon = new BBitmap(rect, B_RGBA32);
|
|
if (icon->InitCheck() == B_OK && BIconUtils::GetVectorIcon((const uint8 *)data, size, icon) == B_OK) {
|
|
return icon;
|
|
} else {
|
|
delete icon;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
inline BBitmap *make_empty_icon() {
|
|
return new BBitmap(BRect(0, 0, 0, 0), B_RGBA32);
|
|
}
|
|
inline BBitmap *get_empty_icon() {
|
|
static BBitmap *empty_icon = nullptr;
|
|
if (empty_icon == nullptr) {
|
|
empty_icon = make_empty_icon();
|
|
}
|
|
return empty_icon;
|
|
}
|
|
|
|
#define CLASS(name) class Haiku##name |