haiku/headers/os/interface/IconUtils.h
PulkoMandy 4dbd474753 Add BIconUtils::GetSystemIcon
Allow to easily access the alert icons and anything that's added to app_server
resources.

Fixes #10887.

Convert BAlert, Debugger AlertWithCheckbox and Keymap ModifierKeysWindow
to make use of it, removing the duplicate code to locate app_server
resources.

The resources are initialized only once (per application), so there is no need
to reload them for every access to the icons.

In the ticket there is discussion about putting this in BControlLook,
but I think this should in fact be moved fully into app_server with
special drawing commands for well-known icons. That would avoid loading
and rendering the icon on the application side to then send it to
app_server (especially in remote_app_server case)?

In any case, this simple API can serve as a base for applications to
use, and we can change how it is implemented later on.

Change-Id: Id370526ae5cf165cfb8bc277bc8a7f46c26f542d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6463
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2023-05-24 10:58:48 +00:00

56 lines
1.4 KiB
C++

/*
* Copyright 2006-2023, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _ICON_UTILS_H
#define _ICON_UTILS_H
#include <Mime.h>
class BBitmap;
class BNode;
class BIconUtils {
BIconUtils();
~BIconUtils();
BIconUtils(const BIconUtils&);
BIconUtils& operator=(const BIconUtils&);
public:
static status_t GetIcon(BNode* node,
const char* vectorIconAttrName,
const char* smallIconAttrName,
const char* largeIconAttrName,
icon_size size, BBitmap* result);
static status_t GetVectorIcon(BNode* node,
const char* attrName, BBitmap* result);
static status_t GetVectorIcon(const uint8* buffer,
size_t size, BBitmap* result);
static status_t GetCMAP8Icon(BNode* node,
const char* smallIconAttrName,
const char* largeIconAttrName,
icon_size size, BBitmap* icon);
static status_t GetSystemIcon(const char* iconName, BBitmap* result);
static status_t ConvertFromCMAP8(BBitmap* source,
BBitmap* result);
static status_t ConvertToCMAP8(BBitmap* source,
BBitmap* result);
static status_t ConvertFromCMAP8(const uint8* data,
uint32 width, uint32 height,
uint32 bytesPerRow, BBitmap* result);
static status_t ConvertToCMAP8(const uint8* data,
uint32 width, uint32 height,
uint32 bytesPerRow, BBitmap* result);
};
#endif // _ICON_UTILS_H