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