- 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

View File

@ -14,7 +14,7 @@
#define PIXELS_FOR_ICON 32
#define INSETS 2
#define INSETS 5
#define TEXT_ROWS 2
namespace Bluetooth {
@ -83,12 +83,19 @@ DeviceListItem::DrawItem(BView *owner, BRect itemRect, bool complete)
font_height 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->SetHighColor(kBlack);
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));
@ -97,8 +104,10 @@ DeviceListItem::DrawItem(BView *owner, BRect itemRect, bool complete)
owner->DrawString(fName.String());
// 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
}
@ -109,7 +118,6 @@ DeviceListItem::Update(BView *owner, const BFont *font)
font_height 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);

View File

@ -6,13 +6,14 @@
#include <Alert.h>
#include <Button.h>
#include <GroupLayoutBuilder.h>
#include <ListView.h>
#include <ListItem.h>
#include <MessageRunner.h>
#include <ScrollView.h>
#include <StatusBar.h>
#include <SpaceLayoutItem.h>
#include <TextView.h>
#include <TabView.h>
#include <ListView.h>
#include <ListItem.h>
#include <MessageRunner.h>
#include <bluetooth/DiscoveryAgent.h>
#include <bluetooth/DiscoveryListener.h>
@ -82,7 +83,7 @@ private:
InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice)
: 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)
, fLocalDevice(lDevice)
{
@ -111,6 +112,8 @@ InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice)
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) {
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(fScanProgress)
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
.Add(fRemoteList)
.Add(fScrollView)
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
.Add(fAddButton)
@ -185,6 +188,7 @@ InquiryPanel::MessageReceived(BMessage *message)
message.AddPointer("device", item);
be_app->PostMessage(&message);
// TODO: all others listitems can be deleted
}
break;

View File

@ -15,6 +15,7 @@ class BStatusBar;
class BButton;
class BTextView;
class BListView;
class BScrollView;
class LocalDevice;
class DiscoveryAgent;
class DiscoveryListener;
@ -32,6 +33,7 @@ private:
BButton* fInquiryButton;
BTextView* fMessage;
BListView* fRemoteList;
BScrollView* fScrollView;
BMessageRunner* fRunner;
bool fScanning;

View File

@ -58,8 +58,7 @@ RemoteDevicesView::RemoteDevicesView(const char *name, uint32 flags)
SetLayout(new BGroupLayout(B_VERTICAL));
// TODO: Make list view and scroller use all the additional height
// available!
// TODO: use all the additional height
AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 10)
.Add(fScrollView)
//.Add(BSpaceLayoutItem::CreateHorizontalStrut(5))
@ -106,7 +105,7 @@ RemoteDevicesView::MessageReceived(BMessage *msg)
switch(msg->what) {
case kMsgAddDevices:
{
InquiryPanel* iPanel = new InquiryPanel(BRect(100,100,400,400), ActiveLocalDevice);
InquiryPanel* iPanel = new InquiryPanel(BRect(100,100,450,450), ActiveLocalDevice);
iPanel->Show();
}
break;