1 /*
2 * Copyright 2021, Haiku, Inc.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 * Tri-Edge AI <triedgeai@gmail.com>
7 */
8
9 #include <BluetoothIconView.h>
10
11 #include <stdio.h>
12
13 namespace Bluetooth {
14
15 BBitmap* BluetoothIconView::fBitmap = NULL;
16 int32 BluetoothIconView::fRefCount = 0;
17
BluetoothIconView()18 BluetoothIconView::BluetoothIconView()
19 :
20 BView(BRect(0, 0, 80, 80), "", B_FOLLOW_ALL, B_WILL_DRAW)
21 {
22 if (fRefCount == 0) {
23 fBitmap = new BBitmap(BRect(0, 0, 64, 64), 0, B_RGBA32);
24
25 uint8* tempIcon;
26 size_t tempSize;
27
28 BMimeType mime("application/x-vnd.Haiku-bluetooth_server");
29 mime.GetIcon(&tempIcon, &tempSize);
30
31 BIconUtils::GetVectorIcon(tempIcon, tempSize, fBitmap);
32
33 fRefCount++;
34 } else {
35 fRefCount++;
36 }
37
38 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
39 SetDrawingMode(B_OP_ALPHA);
40 SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
41 }
42
43
~BluetoothIconView()44 BluetoothIconView::~BluetoothIconView()
45 {
46 fRefCount--;
47
48 if (fRefCount <= 0)
49 delete fBitmap;
50 }
51
52
53 void
Draw(BRect rect)54 BluetoothIconView::Draw(BRect rect)
55 {
56 this->DrawBitmap(fBitmap);
57 }
58
59 }
60