1b63e3a34SAlex Wilson /*
2b63e3a34SAlex Wilson * Copyright 2010, Haiku, Inc. All rights reserved.
3b63e3a34SAlex Wilson * Distributed under the terms of the MIT License.
4b63e3a34SAlex Wilson */
5b63e3a34SAlex Wilson
6b63e3a34SAlex Wilson #include "MediaIcons.h"
7b63e3a34SAlex Wilson
8b63e3a34SAlex Wilson #include <Application.h>
9b63e3a34SAlex Wilson #include <File.h>
10b63e3a34SAlex Wilson #include <Resources.h>
11b63e3a34SAlex Wilson #include <Roster.h>
12b63e3a34SAlex Wilson
13b63e3a34SAlex Wilson #include "IconHandles.h"
14b63e3a34SAlex Wilson
15b63e3a34SAlex Wilson
16b63e3a34SAlex Wilson const BRect MediaIcons::sBounds(0, 0, 15, 15);
17b63e3a34SAlex Wilson
18*e7b99741SAlex Wilson
IconSet()19*e7b99741SAlex Wilson MediaIcons::IconSet::IconSet()
20*e7b99741SAlex Wilson :
21*e7b99741SAlex Wilson inputIcon(MediaIcons::sBounds, B_CMAP8),
22*e7b99741SAlex Wilson outputIcon(MediaIcons::sBounds, B_CMAP8)
23*e7b99741SAlex Wilson {
24*e7b99741SAlex Wilson }
25*e7b99741SAlex Wilson
26*e7b99741SAlex Wilson
27*e7b99741SAlex Wilson
MediaIcons()28b63e3a34SAlex Wilson MediaIcons::MediaIcons()
29b63e3a34SAlex Wilson :
30b63e3a34SAlex Wilson devicesIcon(sBounds, B_CMAP8),
31*e7b99741SAlex Wilson mixerIcon(sBounds, B_CMAP8)
32b63e3a34SAlex Wilson {
33b63e3a34SAlex Wilson app_info info;
34b63e3a34SAlex Wilson be_app->GetAppInfo(&info);
35b63e3a34SAlex Wilson BFile executableFile(&info.ref, B_READ_ONLY);
36b63e3a34SAlex Wilson BResources resources(&executableFile);
37b63e3a34SAlex Wilson resources.PreloadResourceType(B_COLOR_8_BIT_TYPE);
38b63e3a34SAlex Wilson
39b63e3a34SAlex Wilson _LoadBitmap(&resources, devices_icon, &devicesIcon);
40b63e3a34SAlex Wilson _LoadBitmap(&resources, mixer_icon, &mixerIcon);
41*e7b99741SAlex Wilson _LoadBitmap(&resources, tv_icon, &videoIcons.outputIcon);
42*e7b99741SAlex Wilson _LoadBitmap(&resources, cam_icon, &videoIcons.inputIcon);
43*e7b99741SAlex Wilson _LoadBitmap(&resources, mic_icon, &audioIcons.inputIcon);
44*e7b99741SAlex Wilson _LoadBitmap(&resources, speaker_icon, &audioIcons.outputIcon);
45b63e3a34SAlex Wilson }
46b63e3a34SAlex Wilson
47b63e3a34SAlex Wilson
48b63e3a34SAlex Wilson void
_LoadBitmap(BResources * resources,int32 id,BBitmap * bitmap)49b63e3a34SAlex Wilson MediaIcons::_LoadBitmap(BResources* resources, int32 id, BBitmap* bitmap)
50b63e3a34SAlex Wilson {
51b63e3a34SAlex Wilson size_t size;
52b63e3a34SAlex Wilson const void* bits = resources->LoadResource(B_COLOR_8_BIT_TYPE, id, &size);
53b63e3a34SAlex Wilson bitmap->SetBits(bits, size, 0, B_CMAP8);
54b63e3a34SAlex Wilson }
55b63e3a34SAlex Wilson
56b63e3a34SAlex Wilson
57b63e3a34SAlex Wilson BRect
IconRectAt(const BPoint & topLeft)58b63e3a34SAlex Wilson MediaIcons::IconRectAt(const BPoint& topLeft)
59b63e3a34SAlex Wilson {
60b63e3a34SAlex Wilson return BRect(sBounds).OffsetToSelf(topLeft);
61b63e3a34SAlex Wilson }
62