1/*
2 * Copyright 2013, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _INTERFACE__ICON_H_
6#define _INTERFACE__ICON_H_
7
8
9#include <InterfaceDefs.h>
10#include <ObjectList.h>
11#include <Rect.h>
12
13
14class BBitmap;
15
16
17namespace BPrivate {
18
19
20class BIcon {
21public:
22								BIcon();
23								~BIcon();
24
25			status_t			SetTo(const BBitmap* bitmap, uint32 flags = 0);
26
27			bool				SetBitmap(BBitmap* bitmap, uint32 which);
28			BBitmap*			Bitmap(uint32 which) const;
29
30			status_t			SetExternalBitmap(const BBitmap* bitmap,
31									uint32 which, uint32 flags);
32
33			BBitmap*			CreateBitmap(const BRect& bounds,
34									color_space colorSpace, uint32 which);
35			BBitmap*			CopyBitmap(const BBitmap& bitmapToClone,
36									uint32 which);
37			void				DeleteBitmaps();
38
39	// convenience methods for icon owners
40	static	status_t			UpdateIcon(const BBitmap* bitmap, uint32 flags,
41									BIcon*& _icon);
42	static	status_t			SetIconBitmap(const BBitmap* bitmap,
43									uint32 which, uint32 flags, BIcon*& _icon);
44
45private:
46			typedef BObjectList<BBitmap> BitmapList;
47
48private:
49	static	BBitmap*			_ConvertToRGB32(const BBitmap* bitmap,
50									bool noAppServerLink = false);
51	static	status_t			_TrimBitmap(const BBitmap* bitmap,
52									bool keepAspect, BBitmap*& _trimmedBitmap);
53			status_t			_MakeBitmaps(const BBitmap* bitmap,
54									uint32 flags);
55
56private:
57			BitmapList			fEnabledBitmaps;
58			BitmapList			fDisabledBitmaps;
59};
60
61
62}	// namespace BPrivate
63
64
65using BPrivate::BIcon;
66
67
68#endif	// _INTERFACE__ICON_H_
69