- Implement a suitable BListItem(me) for bluetooth Devices
- Add functionality to the Menu starting or shutting down the server(Monni) - Add the desired device after the inquiry to the RemoveDevices List (Monni & me) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29361 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -24,45 +24,48 @@ void
|
|||||||
BluetoothApplication::AboutRequested()
|
BluetoothApplication::AboutRequested()
|
||||||
{
|
{
|
||||||
|
|
||||||
(new BAlert("about", "Haiku Bluetooth System, (ARCE)
|
(new BAlert("about", "Haiku Bluetooth System, (ARCE)\n\n"
|
||||||
|
"Created by Oliver Ruiz Dorantes\n\n"
|
||||||
Created by Oliver Ruiz Dorantes
|
"With support of:\n"
|
||||||
|
" - Mika Lindqvist\n"
|
||||||
With support of:
|
" - Maksym Yevmenkin\n\n"
|
||||||
- Mika Lindqvist
|
"Thanks to the individuals who helped...\n\n"
|
||||||
- Maksym Yevmenkin
|
"Shipping/donating hardware:\n"
|
||||||
|
" - Henry Jair Abril Florez(el Colombian)\n"
|
||||||
Thanks to the individuals who helped...
|
" & Stefanie Bartolich\n"
|
||||||
|
" - Dennis d'Entremont\n"
|
||||||
Shipping/donating hardware:
|
" - Luroh\n"
|
||||||
- Henry Jair Abril Florez(el Colombian)
|
" - Pieter Panman\n\n"
|
||||||
& Stefanie Bartolich
|
"Economically:\n"
|
||||||
- Dennis d'Entremont
|
" - Karl von Dorf, Andrea Bernardi (OSDrawer),\n"
|
||||||
- Luroh
|
" - Matt M, Doug F, Hubert H,\n"
|
||||||
- Pieter Panman
|
" - Sebastian B, Andrew M, Jared E,\n"
|
||||||
|
" - Frederik H, Tom S, Ferry B,\n"
|
||||||
Economically:
|
" - Greg G, David F, Richard S, Martin W:\n\n"
|
||||||
- Karl von Dorf, Andrea Bernardi (OSDrawer),
|
"With patches:\n"
|
||||||
- Matt M, Doug F, Hubert H,
|
" - Fredrik Ekdahl\n"
|
||||||
- Sebastian B, Andrew M, Jared E,
|
" - Andreas Färber\n\n"
|
||||||
- Frederik H, Tom S, Ferry B,
|
"Testing:\n"
|
||||||
- Greg G, David F, Richard S, Martin W:
|
" - Petter H. Juliussen\n"
|
||||||
|
" - Raynald Lesieur\n"
|
||||||
With patches:
|
" - Adrien Destugues\n"
|
||||||
- Fredrik Ekdahl
|
" - Jörg Meyer\n\n"
|
||||||
- Andreas Färber
|
"Who gave me all the knowledge:\n"
|
||||||
|
" - the yellowTAB team", "OK"))->Go();
|
||||||
Testing:
|
|
||||||
- Petter H. Juliussen
|
|
||||||
- Raynald Lesieur
|
|
||||||
- Adrien Destugues
|
|
||||||
- Jörg Meyer
|
|
||||||
|
|
||||||
Who gave me all the knowledge:
|
|
||||||
- the yellowTAB team", "OK"))->Go();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BluetoothApplication::MessageReceived(BMessage *message)
|
||||||
|
{
|
||||||
|
switch (message->what) {
|
||||||
|
case kMsgAddToRemoteList:
|
||||||
|
fWindow->PostMessage(message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
BApplication::MessageReceived(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int, char**)
|
main(int, char**)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class BluetoothApplication : public BApplication
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
BluetoothApplication(void);
|
BluetoothApplication(void);
|
||||||
|
virtual void MessageReceived(BMessage*);
|
||||||
virtual void AboutRequested();
|
virtual void AboutRequested();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
#include <SpaceLayoutItem.h>
|
#include <SpaceLayoutItem.h>
|
||||||
#include <TabView.h>
|
#include <TabView.h>
|
||||||
|
#include <Roster.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <bluetooth/LocalDevice.h>
|
#include <bluetooth/LocalDevice.h>
|
||||||
#include "RemoteDevicesView.h"
|
#include "RemoteDevicesView.h"
|
||||||
@@ -105,6 +107,25 @@ BluetoothWindow::MessageReceived(BMessage *message)
|
|||||||
|| fAntialiasingSettings->IsDefaultable());
|
|| fAntialiasingSettings->IsDefaultable());
|
||||||
fRevertButton->SetEnabled(false);
|
fRevertButton->SetEnabled(false);
|
||||||
*/ break;
|
*/ break;
|
||||||
|
case kMsgStartServices:
|
||||||
|
printf("kMsgStartServices\n");
|
||||||
|
if (!be_roster->IsRunning("application/x-vnd.Be-bluetooth_server"))
|
||||||
|
{
|
||||||
|
printf("kMsgStopServices: %s\n", strerror(be_roster->Launch("application/x-vnd.Be-bluetooth_server")));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case kMsgStopServices:
|
||||||
|
printf("kMsgStopServices\n");
|
||||||
|
if (be_roster->IsRunning("application/x-vnd.Be-bluetooth_server"))
|
||||||
|
{
|
||||||
|
printf("kMsgStopServices: %s\n", strerror(BMessenger("application/x-vnd.Be-bluetooth_server").SendMessage(B_QUIT_REQUESTED)));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case kMsgAddToRemoteList:
|
||||||
|
{
|
||||||
|
PostMessage(message, fRemoteDevices);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case B_ABOUT_REQUESTED:
|
case B_ABOUT_REQUESTED:
|
||||||
be_app->PostMessage(message);
|
be_app->PostMessage(message);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -2,86 +2,126 @@
|
|||||||
* Copyright 2009, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
|
* Copyright 2009, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#include "DeviceListItem.h"
|
|
||||||
#include <bluetooth/bdaddrUtils.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
namespace bluetooth {
|
#include <bluetooth/bdaddrUtils.h>
|
||||||
|
#include <bluetooth/BluetoothDevice.h>
|
||||||
|
|
||||||
RangeItem::RangeItem(uint32 lowAddress, uint32 highAddress, const char* name)
|
|
||||||
: BListItem(),
|
|
||||||
fLowAddress(lowAddress),
|
|
||||||
fHighAddress(highAddress)
|
|
||||||
{
|
|
||||||
fName = strdup(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
RangeItem::~RangeItem()
|
#include "DeviceListItem.h"
|
||||||
{
|
|
||||||
delete fName;
|
|
||||||
}
|
#define PIXELS_FOR_ICON 32
|
||||||
|
#define INSETS 2
|
||||||
|
#define TEXT_ROWS 2
|
||||||
|
|
||||||
|
namespace Bluetooth {
|
||||||
|
|
||||||
|
DeviceListItem::DeviceListItem(BluetoothDevice* bDevice)
|
||||||
|
: BListItem(),
|
||||||
|
fDevice(bDevice)
|
||||||
|
{
|
||||||
|
SetDevice(fDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DeviceListItem::DeviceListItem(bdaddr_t bdaddr, DeviceClass dClass, int32 rssi = 0)
|
||||||
|
: BListItem(),
|
||||||
|
fDevice(NULL),
|
||||||
|
fAddress(bdaddr),
|
||||||
|
fClass(dClass),
|
||||||
|
fName("unknown"),
|
||||||
|
fRSSI(rssi)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************
|
|
||||||
* DrawItem
|
|
||||||
***********************************************************/
|
|
||||||
void
|
void
|
||||||
RangeItem::DrawItem(BView *owner, BRect itemRect, bool complete)
|
DeviceListItem::SetDevice(BluetoothDevice* bDevice)
|
||||||
{
|
{
|
||||||
rgb_color kBlack = { 0,0,0,0 };
|
fAddress = bDevice->GetBluetoothAddress();
|
||||||
rgb_color kHighlight = { 156,154,156,0 };
|
fClass = bDevice->GetDeviceClass();
|
||||||
|
fName = bDevice->GetFriendlyName();
|
||||||
if (IsSelected() || complete) {
|
// AKAIR rssi can only be got at inquiry time...
|
||||||
rgb_color color;
|
|
||||||
if (IsSelected())
|
|
||||||
color = kHighlight;
|
|
||||||
else
|
|
||||||
color = owner->ViewColor();
|
|
||||||
|
|
||||||
owner->SetHighColor(color);
|
|
||||||
owner->SetLowColor(color);
|
|
||||||
owner->FillRect(itemRect);
|
|
||||||
owner->SetHighColor(kBlack);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
owner->SetLowColor(owner->ViewColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
BFont font = be_plain_font;
|
|
||||||
font_height finfo;
|
|
||||||
font.GetHeight(&finfo);
|
|
||||||
|
|
||||||
BPoint point = BPoint(itemRect.left + 17, itemRect.bottom - finfo.descent + 1);
|
|
||||||
owner->SetFont(be_fixed_font);
|
|
||||||
owner->SetHighColor(kBlack);
|
|
||||||
owner->MovePenTo(point);
|
|
||||||
|
|
||||||
/* if (fLowAddress >= 0) {
|
|
||||||
char string[255];
|
|
||||||
sprintf(string, "0x%04lx - 0x%04lx", fLowAddress, fHighAddress);
|
|
||||||
owner->DrawString(string);
|
|
||||||
}
|
|
||||||
point += BPoint(174, 0);*/
|
|
||||||
owner->SetFont(be_plain_font);
|
|
||||||
owner->MovePenTo(point);
|
|
||||||
owner->DrawString(fName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
RangeItem::Compare(const void *firstArg, const void *secondArg)
|
DeviceListItem::~DeviceListItem()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************
|
||||||
|
* DrawItem
|
||||||
|
***********************************************************/
|
||||||
|
void
|
||||||
|
DeviceListItem::DrawItem(BView *owner, BRect itemRect, bool complete)
|
||||||
|
{
|
||||||
|
rgb_color kBlack = { 0,0,0,0 };
|
||||||
|
rgb_color kHighlight = { 156,154,156,0 };
|
||||||
|
|
||||||
|
if (IsSelected() || complete) {
|
||||||
|
rgb_color color;
|
||||||
|
if (IsSelected())
|
||||||
|
color = kHighlight;
|
||||||
|
else
|
||||||
|
color = owner->ViewColor();
|
||||||
|
|
||||||
|
owner->SetHighColor(color);
|
||||||
|
owner->SetLowColor(color);
|
||||||
|
owner->FillRect(itemRect);
|
||||||
|
owner->SetHighColor(kBlack);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
owner->SetLowColor(owner->ViewColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
font_height finfo;
|
||||||
|
be_plain_font->GetHeight(&finfo);
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
point -= BPoint(0, (finfo.ascent + finfo.descent + finfo.leading));
|
||||||
|
|
||||||
|
owner->SetFont(be_plain_font);
|
||||||
|
owner->MovePenTo(point);
|
||||||
|
owner->DrawString(fName.String());
|
||||||
|
|
||||||
|
// TODO: Stroke icon
|
||||||
|
|
||||||
|
// TODO: Draw rssi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DeviceListItem::Update(BView *owner, const BFont *font)
|
||||||
{
|
{
|
||||||
const RangeItem *item1 = *static_cast<const RangeItem * const *>(firstArg);
|
BListItem::Update(owner,font);
|
||||||
const RangeItem *item2 = *static_cast<const RangeItem * const *>(secondArg);
|
|
||||||
|
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);
|
||||||
|
|
||||||
if (item1->fLowAddress < item2->fLowAddress) {
|
|
||||||
return -1;
|
|
||||||
} else if (item1->fLowAddress > item2->fLowAddress) {
|
|
||||||
return 1;
|
|
||||||
} else
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
DeviceListItem::Compare(const void *firstArg, const void *secondArg)
|
||||||
|
{
|
||||||
|
const DeviceListItem *item1 = *static_cast<const DeviceListItem * const *>(firstArg);
|
||||||
|
const DeviceListItem *item2 = *static_cast<const DeviceListItem * const *>(secondArg);
|
||||||
|
|
||||||
|
return (int)bdaddrUtils::Compare((bdaddr_t*)&item1->fAddress, (bdaddr_t*)&item2->fAddress);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,20 +6,37 @@
|
|||||||
#define DEVICELISTITEM_H_
|
#define DEVICELISTITEM_H_
|
||||||
|
|
||||||
#include <ListItem.h>
|
#include <ListItem.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
namespace bluetooth {
|
#include <bluetooth/bluetooth.h>
|
||||||
|
#include <bluetooth/DeviceClass.h>
|
||||||
|
|
||||||
// TODO: Implement a BluetoothDeviceListItem class, this one is stolen from somewhere .....
|
class BluetoothDevice;
|
||||||
class RangeItem : public BListItem
|
|
||||||
|
namespace Bluetooth {
|
||||||
|
|
||||||
|
class DeviceListItem : public BListItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RangeItem(uint32 lowAddress, uint32 highAddress, const char* name);
|
DeviceListItem(BluetoothDevice* bDevice);
|
||||||
~RangeItem();
|
DeviceListItem(bdaddr_t bdaddr, DeviceClass dClass, int32 rssi = 0);
|
||||||
virtual void DrawItem(BView *, BRect, bool = false);
|
|
||||||
|
~DeviceListItem();
|
||||||
|
|
||||||
|
void DrawItem(BView *, BRect, bool = false);
|
||||||
|
void Update(BView *owner, const BFont *font);
|
||||||
|
|
||||||
static int Compare(const void *firstArg, const void *secondArg);
|
static int Compare(const void *firstArg, const void *secondArg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char* fName;
|
void SetDevice(BluetoothDevice* bDevice);
|
||||||
uint32 fLowAddress, fHighAddress;
|
|
||||||
|
BluetoothDevice* fDevice;
|
||||||
|
bdaddr_t fAddress;
|
||||||
|
DeviceClass fClass;
|
||||||
|
BString fName;
|
||||||
|
int32 fRSSI;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,9 @@
|
|||||||
|
|
||||||
#include "InquiryPanel.h"
|
#include "InquiryPanel.h"
|
||||||
#include "DeviceListItem.h"
|
#include "DeviceListItem.h"
|
||||||
|
#include "defs.h"
|
||||||
|
|
||||||
using namespace bluetooth;
|
using Bluetooth::DeviceListItem;
|
||||||
|
|
||||||
// private funcionaility provided by kit
|
// private funcionaility provided by kit
|
||||||
extern uint8 GetInquiryTime();
|
extern uint8 GetInquiryTime();
|
||||||
@@ -34,7 +35,6 @@ static const uint32 kMsgShowDebug = 'ShDG';
|
|||||||
static const uint32 kMsgInquiry = 'iQbt';
|
static const uint32 kMsgInquiry = 'iQbt';
|
||||||
static const uint32 kMsgAddListDevice = 'aDdv';
|
static const uint32 kMsgAddListDevice = 'aDdv';
|
||||||
|
|
||||||
static const uint32 kMsgAddToRemoteList = 'aDdL';
|
|
||||||
static const uint32 kMsgSecond = 'sCMs';
|
static const uint32 kMsgSecond = 'sCMs';
|
||||||
|
|
||||||
|
|
||||||
@@ -52,7 +52,8 @@ public:
|
|||||||
DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod)
|
DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod)
|
||||||
{
|
{
|
||||||
BMessage* message = new BMessage(kMsgAddListDevice);
|
BMessage* message = new BMessage(kMsgAddListDevice);
|
||||||
message->AddPointer("remote", btDevice);
|
|
||||||
|
message->AddPointer("remoteItem", new DeviceListItem(btDevice->GetBluetoothAddress(), cod));
|
||||||
|
|
||||||
fInquiryPanel->PostMessage(message);
|
fInquiryPanel->PostMessage(message);
|
||||||
}
|
}
|
||||||
@@ -85,18 +86,17 @@ InquiryPanel::InquiryPanel(BRect frame, LocalDevice* lDevice)
|
|||||||
B_ALL_WORKSPACES ), fScanning(false)
|
B_ALL_WORKSPACES ), fScanning(false)
|
||||||
, fLocalDevice(lDevice)
|
, fLocalDevice(lDevice)
|
||||||
{
|
{
|
||||||
BRect iDontCare(0,0,0,0);
|
// BRect iDontCare(0,0,0,0);
|
||||||
|
|
||||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||||
|
|
||||||
fScanProgress = new BStatusBar(iDontCare, "status", "Scanning progress", "");
|
fScanProgress = new BStatusBar("status", "Scanning progress", "");
|
||||||
activeColor = fScanProgress->BarColor();
|
activeColor = fScanProgress->BarColor();
|
||||||
|
|
||||||
if (fLocalDevice == NULL)
|
if (fLocalDevice == NULL)
|
||||||
fLocalDevice = LocalDevice::GetLocalDevice();
|
fLocalDevice = LocalDevice::GetLocalDevice();
|
||||||
|
|
||||||
fMessage = new BTextView(iDontCare, "description",
|
fMessage = new BTextView("description", B_WILL_DRAW);
|
||||||
iDontCare, B_FOLLOW_NONE, B_WILL_DRAW | B_SUPPORTS_LAYOUT);
|
|
||||||
fMessage->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
fMessage->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
fMessage->SetLowColor(fMessage->ViewColor());
|
fMessage->SetLowColor(fMessage->ViewColor());
|
||||||
fMessage->MakeEditable(false);
|
fMessage->MakeEditable(false);
|
||||||
@@ -167,11 +167,24 @@ InquiryPanel::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
case kMsgAddListDevice:
|
case kMsgAddListDevice:
|
||||||
{
|
{
|
||||||
RemoteDevice* rDevice;
|
DeviceListItem* listItem;
|
||||||
|
|
||||||
message->FindPointer("remote", (void **)&rDevice);
|
message->FindPointer("remoteItem", (void **)&listItem);
|
||||||
|
|
||||||
fRemoteList->AddItem(new RangeItem(0,1,bdaddrUtils::ToString(rDevice->GetBluetoothAddress())));
|
fRemoteList->AddItem(listItem);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kMsgAddToRemoteList:
|
||||||
|
{
|
||||||
|
message->PrintToStream();
|
||||||
|
int32 index = fRemoteList->CurrentSelection(0);
|
||||||
|
DeviceListItem* item = (DeviceListItem*) fRemoteList->ItemAt(index);
|
||||||
|
|
||||||
|
BMessage message(kMsgAddToRemoteList);
|
||||||
|
message.AddPointer("device", item);
|
||||||
|
|
||||||
|
be_app->PostMessage(&message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -205,7 +218,7 @@ InquiryPanel::MessageReceived(BMessage *message)
|
|||||||
scanningTime = scanningTime + 1;
|
scanningTime = scanningTime + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fRemoteList->CurrentSelection() < 0)
|
if (fRemoteList->CurrentSelection() < 0 || fScanning)
|
||||||
fAddButton->SetEnabled(false);
|
fAddButton->SetEnabled(false);
|
||||||
else
|
else
|
||||||
fAddButton->SetEnabled(true);
|
fAddButton->SetEnabled(true);
|
||||||
|
|||||||
@@ -21,36 +21,39 @@
|
|||||||
#include "RemoteDevicesView.h"
|
#include "RemoteDevicesView.h"
|
||||||
|
|
||||||
static const uint32 kMsgAddDevices = 'ddDv';
|
static const uint32 kMsgAddDevices = 'ddDv';
|
||||||
|
static const uint32 kMsgRemoveDevice = 'rmDv';
|
||||||
|
static const uint32 kMsgTrustDevice = 'trDv';
|
||||||
|
static const uint32 kMsgBlockDevice = 'blDv';
|
||||||
|
static const uint32 kMsgRefreshDevices = 'rfDv';
|
||||||
|
|
||||||
RemoteDevicesView::RemoteDevicesView(const char *name, uint32 flags)
|
RemoteDevicesView::RemoteDevicesView(const char *name, uint32 flags)
|
||||||
: BView(name, flags)
|
: BView(name, flags)
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
addButton = new BButton(BRect(5,5,5,5), "add", "Add" B_UTF8_ELLIPSIS,
|
addButton = new BButton("add", "Add" B_UTF8_ELLIPSIS,
|
||||||
new BMessage(kMsgAddDevices), B_FOLLOW_RIGHT);
|
new BMessage(kMsgAddDevices));
|
||||||
|
|
||||||
BButton* removeButton = new BButton(BRect(5,5,5,5), "remove", "Remove",
|
removeButton = new BButton("remove", "Remove",
|
||||||
new BMessage(kMsgAddDevices), B_FOLLOW_RIGHT);
|
new BMessage(kMsgRemoveDevice));
|
||||||
|
|
||||||
BButton* trustButton = new BButton(BRect(5,5,5,5), "trust", "As Trusted",
|
trustButton = new BButton("trust", "As Trusted",
|
||||||
new BMessage(kMsgAddDevices), B_FOLLOW_RIGHT);
|
new BMessage(kMsgTrustDevice));
|
||||||
|
|
||||||
|
|
||||||
BButton* blockButton = new BButton(BRect(5,5,5,5), "trust", "As Blocked",
|
blockButton = new BButton("trust", "As Blocked",
|
||||||
new BMessage(kMsgAddDevices), B_FOLLOW_RIGHT);
|
new BMessage(kMsgBlockDevice));
|
||||||
|
|
||||||
|
|
||||||
BButton* availButton = new BButton(BRect(5,5,5,5), "check", "Refresh" B_UTF8_ELLIPSIS,
|
availButton = new BButton("check", "Refresh" B_UTF8_ELLIPSIS,
|
||||||
new BMessage(kMsgAddDevices), B_FOLLOW_RIGHT);
|
new BMessage(kMsgRefreshDevices));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Set up list of color attributes
|
// Set up device list
|
||||||
fAttrList = new BListView("AttributeList", B_SINGLE_SELECTION_LIST);
|
fDeviceList = new BListView("DeviceList", B_SINGLE_SELECTION_LIST);
|
||||||
|
|
||||||
fScrollView = new BScrollView("ScrollView", fAttrList, 0, false, true);
|
fScrollView = new BScrollView("ScrollView", fDeviceList, 0, false, true);
|
||||||
fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
SetLayout(new BGroupLayout(B_VERTICAL));
|
||||||
@@ -74,7 +77,7 @@ RemoteDevicesView::RemoteDevicesView(const char *name, uint32 flags)
|
|||||||
.SetInsets(5, 5, 5, 100)
|
.SetInsets(5, 5, 5, 100)
|
||||||
);
|
);
|
||||||
|
|
||||||
fAttrList->SetSelectionMessage(NULL);
|
fDeviceList->SetSelectionMessage(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteDevicesView::~RemoteDevicesView(void)
|
RemoteDevicesView::~RemoteDevicesView(void)
|
||||||
@@ -85,25 +88,21 @@ RemoteDevicesView::~RemoteDevicesView(void)
|
|||||||
void
|
void
|
||||||
RemoteDevicesView::AttachedToWindow(void)
|
RemoteDevicesView::AttachedToWindow(void)
|
||||||
{
|
{
|
||||||
fAttrList->SetTarget(this);
|
fDeviceList->SetTarget(this);
|
||||||
addButton->SetTarget(this);
|
addButton->SetTarget(this);
|
||||||
|
removeButton->SetTarget(this);
|
||||||
|
trustButton->SetTarget(this);
|
||||||
|
blockButton->SetTarget(this);
|
||||||
|
availButton->SetTarget(this);
|
||||||
|
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
fAttrList->Select(0);
|
fDeviceList->Select(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RemoteDevicesView::MessageReceived(BMessage *msg)
|
RemoteDevicesView::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
if (msg->WasDropped()) {
|
printf("what = %ld\n", msg->what);
|
||||||
rgb_color *color;
|
|
||||||
ssize_t size;
|
|
||||||
|
|
||||||
if (msg->FindData("RGBColor", (type_code)'RGBC', (const void**)&color, &size) == B_OK) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(msg->what) {
|
switch(msg->what) {
|
||||||
case kMsgAddDevices:
|
case kMsgAddDevices:
|
||||||
{
|
{
|
||||||
@@ -111,6 +110,17 @@ RemoteDevicesView::MessageReceived(BMessage *msg)
|
|||||||
iPanel->Show();
|
iPanel->Show();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case kMsgRemoveDevice:
|
||||||
|
printf("kMsgRemoveDevice: %ld\n", fDeviceList->CurrentSelection(0));
|
||||||
|
fDeviceList->RemoveItem(fDeviceList->CurrentSelection(0));
|
||||||
|
break;
|
||||||
|
case kMsgAddToRemoteList:
|
||||||
|
{
|
||||||
|
BListItem* device;
|
||||||
|
msg->FindPointer("device", (void**)&device);
|
||||||
|
fDeviceList->AddItem(device);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(msg);
|
BView::MessageReceived(msg);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -40,7 +40,11 @@ protected:
|
|||||||
void UpdateAllColors();
|
void UpdateAllColors();
|
||||||
|
|
||||||
BButton* addButton;
|
BButton* addButton;
|
||||||
BListView* fAttrList;
|
BButton* removeButton;
|
||||||
|
BButton* trustButton;
|
||||||
|
BButton* blockButton;
|
||||||
|
BButton* availButton;
|
||||||
|
BListView* fDeviceList;
|
||||||
BScrollView* fScrollView;
|
BScrollView* fScrollView;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
const uint32 kBorderSpace = 10;
|
const uint32 kBorderSpace = 10;
|
||||||
const uint32 kItemSpace = 7;
|
const uint32 kItemSpace = 7;
|
||||||
|
|
||||||
|
static const uint32 kMsgAddToRemoteList = 'aDdL';
|
||||||
|
|
||||||
extern LocalDevice* ActiveLocalDevice;
|
extern LocalDevice* ActiveLocalDevice;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user