Patch by Joerg Meyer,
- Add some icons for some devices depending on major class - Same code will be placed later in the BluetoothDeviceView - Styling git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29783 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -120,7 +120,7 @@ BluetoothDeviceView::SetBluetoothDevice(BluetoothDevice* bDevice)
|
|||||||
|
|
||||||
str = "";
|
str = "";
|
||||||
if (bDevice->GetProperty("manufacturer", &value) == B_OK)
|
if (bDevice->GetProperty("manufacturer", &value) == B_OK)
|
||||||
str << "Manufacturer: " << GetManufacturer(value);
|
str << "Manufacturer: " << GetManufacturer(value);
|
||||||
fManufacturerProperties->SetText(str.String());
|
fManufacturerProperties->SetText(str.String());
|
||||||
|
|
||||||
str = "";
|
str = "";
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ BluetoothApplication::AboutRequested()
|
|||||||
" - Fredrik Ekdahl\n"
|
" - Fredrik Ekdahl\n"
|
||||||
" - Raynald Lesieur\n"
|
" - Raynald Lesieur\n"
|
||||||
" - Andreas Färber\n\n"
|
" - Andreas Färber\n\n"
|
||||||
|
" - Jörg Meyer\n"
|
||||||
"Testing:\n"
|
"Testing:\n"
|
||||||
" - Petter H. Juliussen\n"
|
" - Petter H. Juliussen\n"
|
||||||
" - Adrien Destugues\n"
|
" - Adrien Destugues\n\n"
|
||||||
" - Jörg Meyer\n\n"
|
|
||||||
"Who gave me all the knowledge:\n"
|
"Who gave me all the knowledge:\n"
|
||||||
" - the yellowTAB team", "OK"))->Go();
|
" - the yellowTAB team", "OK"))->Go();
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <bluetooth/bdaddrUtils.h>
|
#include <bluetooth/bdaddrUtils.h>
|
||||||
#include <bluetooth/BluetoothDevice.h>
|
#include <bluetooth/BluetoothDevice.h>
|
||||||
|
#include "../media/iconfile.h"
|
||||||
|
|
||||||
|
|
||||||
#include "DeviceListItem.h"
|
#include "DeviceListItem.h"
|
||||||
@@ -44,7 +45,7 @@ DeviceListItem::SetDevice(BluetoothDevice* bDevice)
|
|||||||
{
|
{
|
||||||
fAddress = bDevice->GetBluetoothAddress();
|
fAddress = bDevice->GetBluetoothAddress();
|
||||||
fClass = bDevice->GetDeviceClass();
|
fClass = bDevice->GetDeviceClass();
|
||||||
fName = bDevice->GetFriendlyName();
|
fName = bDevice->GetFriendlyName();
|
||||||
// AKAIR rssi can only be got at inquiry time...
|
// AKAIR rssi can only be got at inquiry time...
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,41 +56,38 @@ DeviceListItem::~DeviceListItem()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************
|
|
||||||
* DrawItem
|
|
||||||
***********************************************************/
|
|
||||||
void
|
void
|
||||||
DeviceListItem::DrawItem(BView *owner, BRect itemRect, bool complete)
|
DeviceListItem::DrawItem(BView* owner, BRect itemRect, bool complete)
|
||||||
{
|
{
|
||||||
rgb_color kBlack = { 0,0,0,0 };
|
rgb_color kBlack = { 0,0,0,0 };
|
||||||
rgb_color kHighlight = { 156,154,156,0 };
|
rgb_color kHighlight = { 156,154,156,0 };
|
||||||
|
|
||||||
if (IsSelected() || complete) {
|
if (IsSelected() || complete) {
|
||||||
rgb_color color;
|
rgb_color color;
|
||||||
if (IsSelected())
|
if (IsSelected())
|
||||||
color = kHighlight;
|
color = kHighlight;
|
||||||
else
|
else
|
||||||
color = owner->ViewColor();
|
color = owner->ViewColor();
|
||||||
|
|
||||||
owner->SetHighColor(color);
|
owner->SetHighColor(color);
|
||||||
owner->SetLowColor(color);
|
owner->SetLowColor(color);
|
||||||
owner->FillRect(itemRect);
|
owner->FillRect(itemRect);
|
||||||
owner->SetHighColor(kBlack);
|
owner->SetHighColor(kBlack);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
owner->SetLowColor(owner->ViewColor());
|
owner->SetLowColor(owner->ViewColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
font_height finfo;
|
font_height finfo;
|
||||||
be_plain_font->GetHeight(&finfo);
|
be_plain_font->GetHeight(&finfo);
|
||||||
|
|
||||||
BPoint point = BPoint(itemRect.left + PIXELS_FOR_ICON + INSETS, itemRect.bottom - finfo.descent + 1);
|
BPoint point = BPoint(itemRect.left + PIXELS_FOR_ICON + 2*INSETS, itemRect.bottom - finfo.descent + 1);
|
||||||
owner->SetFont(be_fixed_font);
|
owner->SetFont(be_fixed_font);
|
||||||
owner->SetHighColor(kBlack);
|
owner->SetHighColor(kBlack);
|
||||||
owner->MovePenTo(point);
|
owner->MovePenTo(point);
|
||||||
|
|
||||||
BString secondLine;
|
BString secondLine;
|
||||||
|
|
||||||
secondLine << bdaddrUtils::ToString(fAddress) << " ";
|
secondLine << bdaddrUtils::ToString(fAddress) << " ";
|
||||||
fClass.GetMajorDeviceClass(secondLine);
|
fClass.GetMajorDeviceClass(secondLine);
|
||||||
secondLine << " / ";
|
secondLine << " / ";
|
||||||
@@ -103,9 +101,64 @@ DeviceListItem::DrawItem(BView *owner, BRect itemRect, bool complete)
|
|||||||
owner->MovePenTo(point);
|
owner->MovePenTo(point);
|
||||||
owner->DrawString(fName.String());
|
owner->DrawString(fName.String());
|
||||||
|
|
||||||
// TODO: Stroke icon
|
// TODO: Generalize this
|
||||||
owner->StrokeRect(BRect(itemRect.left + INSETS, itemRect.top + INSETS,
|
switch (fClass.GetMajorDeviceClass()) {
|
||||||
itemRect.left + PIXELS_FOR_ICON, itemRect.top + PIXELS_FOR_ICON));
|
case 1:
|
||||||
|
{
|
||||||
|
BRect iconRect(0,0,15,15);
|
||||||
|
BBitmap *icon=new BBitmap(iconRect, B_CMAP8);
|
||||||
|
icon->SetBits(kTVBits, kTVWidth*kTVHeight, 0, kTVColorSpace);
|
||||||
|
owner->DrawBitmap(icon, iconRect,BRect(itemRect.left + INSETS, itemRect.top + INSETS,
|
||||||
|
itemRect.left + INSETS + PIXELS_FOR_ICON, itemRect.top + INSETS + PIXELS_FOR_ICON));
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
BRect iconRect(0,0,15,15);
|
||||||
|
BBitmap *icon=new BBitmap(iconRect, B_CMAP8);
|
||||||
|
icon->SetBits(kMixerBits, kMixerWidth*kMixerHeight, 0, kMixerColorSpace);
|
||||||
|
owner->DrawBitmap(icon, iconRect,BRect(itemRect.left + INSETS, itemRect.top + INSETS,
|
||||||
|
itemRect.left + INSETS + PIXELS_FOR_ICON, itemRect.top + INSETS + PIXELS_FOR_ICON));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2: // phone
|
||||||
|
owner->StrokeRoundRect(BRect(itemRect.left + INSETS + uint(PIXELS_FOR_ICON/4),
|
||||||
|
itemRect.top + INSETS + 6,
|
||||||
|
itemRect.left + INSETS + uint(PIXELS_FOR_ICON*3/4),
|
||||||
|
itemRect.top + INSETS + PIXELS_FOR_ICON - 2), 2, 2);
|
||||||
|
owner->StrokeRect(BRect(itemRect.left + INSETS + uint(PIXELS_FOR_ICON/4) + 4,
|
||||||
|
itemRect.top + INSETS + 10,
|
||||||
|
itemRect.left + INSETS + uint(PIXELS_FOR_ICON*3/4) - 4,
|
||||||
|
itemRect.top + INSETS + uint(PIXELS_FOR_ICON*3/4)));
|
||||||
|
owner->StrokeLine(BPoint(itemRect.left + INSETS + uint(PIXELS_FOR_ICON/4) + 4,
|
||||||
|
itemRect.top + INSETS + PIXELS_FOR_ICON - 6),
|
||||||
|
BPoint(itemRect.left + INSETS + uint(PIXELS_FOR_ICON*3/4) - 4,
|
||||||
|
itemRect.top + INSETS + PIXELS_FOR_ICON - 6));
|
||||||
|
owner->StrokeLine(BPoint(itemRect.left + INSETS + uint(PIXELS_FOR_ICON/4) + 4,
|
||||||
|
itemRect.top + INSETS + PIXELS_FOR_ICON - 4),
|
||||||
|
BPoint(itemRect.left + INSETS + uint(PIXELS_FOR_ICON*3/4) - 4,
|
||||||
|
itemRect.top + INSETS + PIXELS_FOR_ICON - 4));
|
||||||
|
owner->StrokeLine(BPoint(itemRect.left + INSETS + uint(PIXELS_FOR_ICON/4) + 4,
|
||||||
|
itemRect.top + INSETS + 2),
|
||||||
|
BPoint(itemRect.left + INSETS + uint(PIXELS_FOR_ICON/4) + 4,
|
||||||
|
itemRect.top + INSETS + 6));
|
||||||
|
break;
|
||||||
|
default: // Bluetooth Logo
|
||||||
|
owner->StrokeLine(BPoint(itemRect.left + INSETS + uint(PIXELS_FOR_ICON/4),
|
||||||
|
itemRect.top + INSETS + uint(PIXELS_FOR_ICON*3/4)),
|
||||||
|
BPoint(itemRect.left + INSETS + uint(PIXELS_FOR_ICON*3/4),
|
||||||
|
itemRect.top + INSETS + uint(PIXELS_FOR_ICON/4)));
|
||||||
|
owner->StrokeLine(BPoint(itemRect.left + INSETS + uint(PIXELS_FOR_ICON/2),
|
||||||
|
itemRect.top + INSETS +2));
|
||||||
|
owner->StrokeLine(BPoint(itemRect.left + INSETS + uint(PIXELS_FOR_ICON/2),
|
||||||
|
itemRect.top + INSETS + PIXELS_FOR_ICON - 2));
|
||||||
|
owner->StrokeLine(BPoint(itemRect.left + INSETS + uint(PIXELS_FOR_ICON*3/4),
|
||||||
|
itemRect.top + INSETS + uint(PIXELS_FOR_ICON*3/4)));
|
||||||
|
owner->StrokeLine(BPoint(itemRect.left + INSETS + uint(PIXELS_FOR_ICON/4),
|
||||||
|
itemRect.top + INSETS + uint(PIXELS_FOR_ICON/4)));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Draw rssi
|
// TODO: Draw rssi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user