- Add device class in listitem

- Add scrollbar to the list of remote devices
- Draw a Rect where an icon is suposed to be located



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29362 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes
2009-03-01 13:05:41 +00:00
parent 623f4e6534
commit cafd739df8
4 changed files with 26 additions and 13 deletions
+13 -5
View File
@@ -14,7 +14,7 @@
#define PIXELS_FOR_ICON 32 #define PIXELS_FOR_ICON 32
#define INSETS 2 #define INSETS 5
#define TEXT_ROWS 2 #define TEXT_ROWS 2
namespace Bluetooth { namespace Bluetooth {
@@ -83,12 +83,19 @@ DeviceListItem::DrawItem(BView *owner, BRect itemRect, bool complete)
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 + 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);
owner->DrawString(bdaddrUtils::ToString(fAddress)); BString secondLine;
secondLine << bdaddrUtils::ToString(fAddress) << " ";
fClass.GetMajorDeviceClass(secondLine);
secondLine << " / ";
fClass.GetMinorDeviceClass(secondLine);
owner->DrawString(secondLine.String());
point -= BPoint(0, (finfo.ascent + finfo.descent + finfo.leading)); point -= BPoint(0, (finfo.ascent + finfo.descent + finfo.leading));
@@ -97,8 +104,10 @@ DeviceListItem::DrawItem(BView *owner, BRect itemRect, bool complete)
owner->DrawString(fName.String()); owner->DrawString(fName.String());
// TODO: Stroke icon // TODO: Stroke icon
owner->StrokeRect(BRect(itemRect.left + INSETS, itemRect.top + INSETS,
itemRect.left + PIXELS_FOR_ICON, itemRect.top + PIXELS_FOR_ICON));
// TODO: Draw rssi // TODO: Draw rssi
} }
@@ -109,7 +118,6 @@ DeviceListItem::Update(BView *owner, const BFont *font)
font_height height; font_height height;
font->GetHeight(&height); font->GetHeight(&height);
//SetHeight(finfo.leading*TEXT_ROWS + TEXT_ROWS*INSETS + 50);
SetHeight((height.ascent + height.descent + height.leading) * TEXT_ROWS + TEXT_ROWS*INSETS); SetHeight((height.ascent + height.descent + height.leading) * TEXT_ROWS + TEXT_ROWS*INSETS);
+9 -5
View File
@@ -6,13 +6,14 @@
#include <Alert.h> #include <Alert.h>
#include <Button.h> #include <Button.h>
#include <GroupLayoutBuilder.h> #include <GroupLayoutBuilder.h>
#include <ListView.h>
#include <ListItem.h>
#include <MessageRunner.h>
#include <ScrollView.h>
#include <StatusBar.h> #include <StatusBar.h>
#include <SpaceLayoutItem.h> #include <SpaceLayoutItem.h>
#include <TextView.h> #include <TextView.h>
#include <TabView.h> #include <TabView.h>
#include <ListView.h>
#include <ListItem.h>
#include <MessageRunner.h>
#include <bluetooth/DiscoveryAgent.h> #include <bluetooth/DiscoveryAgent.h>
#include <bluetooth/DiscoveryListener.h> #include <bluetooth/DiscoveryListener.h>
@@ -82,7 +83,7 @@ private:
InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice) InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice)
: BWindow(frame, "Bluetooth", B_FLOATING_WINDOW, : BWindow(frame, "Bluetooth", B_FLOATING_WINDOW,
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS, B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS,
B_ALL_WORKSPACES ), fScanning(false) B_ALL_WORKSPACES ), fScanning(false)
, fLocalDevice(lDevice) , fLocalDevice(lDevice)
{ {
@@ -111,6 +112,8 @@ InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice)
fRemoteList = new BListView("AttributeList", B_SINGLE_SELECTION_LIST); fRemoteList = new BListView("AttributeList", B_SINGLE_SELECTION_LIST);
fScrollView = new BScrollView("ScrollView", fRemoteList, 0, false, true);
fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
if (fLocalDevice != NULL) { if (fLocalDevice != NULL) {
fMessage->SetText("Check that the bluetooth capabilities of your remote device" fMessage->SetText("Check that the bluetooth capabilities of your remote device"
@@ -137,7 +140,7 @@ InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice)
.Add(BSpaceLayoutItem::CreateVerticalStrut(5)) .Add(BSpaceLayoutItem::CreateVerticalStrut(5))
.Add(fScanProgress) .Add(fScanProgress)
.Add(BSpaceLayoutItem::CreateVerticalStrut(5)) .Add(BSpaceLayoutItem::CreateVerticalStrut(5))
.Add(fRemoteList) .Add(fScrollView)
.Add(BSpaceLayoutItem::CreateVerticalStrut(5)) .Add(BSpaceLayoutItem::CreateVerticalStrut(5))
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
.Add(fAddButton) .Add(fAddButton)
@@ -185,6 +188,7 @@ InquiryPanel::MessageReceived(BMessage *message)
message.AddPointer("device", item); message.AddPointer("device", item);
be_app->PostMessage(&message); be_app->PostMessage(&message);
// TODO: all others listitems can be deleted
} }
break; break;
+2
View File
@@ -15,6 +15,7 @@ class BStatusBar;
class BButton; class BButton;
class BTextView; class BTextView;
class BListView; class BListView;
class BScrollView;
class LocalDevice; class LocalDevice;
class DiscoveryAgent; class DiscoveryAgent;
class DiscoveryListener; class DiscoveryListener;
@@ -32,6 +33,7 @@ private:
BButton* fInquiryButton; BButton* fInquiryButton;
BTextView* fMessage; BTextView* fMessage;
BListView* fRemoteList; BListView* fRemoteList;
BScrollView* fScrollView;
BMessageRunner* fRunner; BMessageRunner* fRunner;
bool fScanning; bool fScanning;
@@ -58,8 +58,7 @@ RemoteDevicesView::RemoteDevicesView(const char *name, uint32 flags)
SetLayout(new BGroupLayout(B_VERTICAL)); SetLayout(new BGroupLayout(B_VERTICAL));
// TODO: Make list view and scroller use all the additional height // TODO: use all the additional height
// available!
AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 10) AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 10)
.Add(fScrollView) .Add(fScrollView)
//.Add(BSpaceLayoutItem::CreateHorizontalStrut(5)) //.Add(BSpaceLayoutItem::CreateHorizontalStrut(5))
@@ -106,7 +105,7 @@ RemoteDevicesView::MessageReceived(BMessage *msg)
switch(msg->what) { switch(msg->what) {
case kMsgAddDevices: case kMsgAddDevices:
{ {
InquiryPanel* iPanel = new InquiryPanel(BRect(100,100,400,400), ActiveLocalDevice); InquiryPanel* iPanel = new InquiryPanel(BRect(100,100,450,450), ActiveLocalDevice);
iPanel->Show(); iPanel->Show();
} }
break; break;