From 17836d5ed0b47cea4bf4db2e578157bdfde1ced8 Mon Sep 17 00:00:00 2001 From: Oliver Ruiz Dorantes Date: Fri, 25 Dec 2009 17:51:37 +0000 Subject: [PATCH] Place all Device's feature strings left aligned git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34774 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../bluetooth/BluetoothDeviceView.cpp | 98 +++++++++++-------- .../bluetooth/BluetoothDeviceView.h | 58 +++-------- 2 files changed, 68 insertions(+), 88 deletions(-) diff --git a/src/preferences/bluetooth/BluetoothDeviceView.cpp b/src/preferences/bluetooth/BluetoothDeviceView.cpp index bccb27dd18..a3735c08f5 100644 --- a/src/preferences/bluetooth/BluetoothDeviceView.cpp +++ b/src/preferences/bluetooth/BluetoothDeviceView.cpp @@ -21,7 +21,7 @@ #define TR_CONTEXT "Device View" BluetoothDeviceView::BluetoothDeviceView(BRect frame, BluetoothDevice* bDevice, uint32 resizingMode, uint32 flags) - : BView(frame,"BluetoothDeviceView", resizingMode, flags | B_WILL_DRAW), + : BView(frame,"BluetoothDeviceView", resizingMode, flags | B_WILL_DRAW), fDevice(bDevice) { SetViewColor(B_TRANSPARENT_COLOR); @@ -31,24 +31,35 @@ BluetoothDeviceView::BluetoothDeviceView(BRect frame, BluetoothDevice* bDevice, fName = new BStringView("name", ""); fName->SetFont(be_bold_font); - + fName->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); + fBdaddr = new BStringView("bdaddr", bdaddrUtils::ToString(bdaddrUtils::NullAddress())); - - fClassService = new BStringView("ServiceClass", TR("Service Classes: ")); + fBdaddr->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); + + fClassService = new BStringView("ServiceClass", TR("Service classes: ")); + fClassService->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); fClass = new BStringView("class", "- / -"); + fClass->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); fHCIVersionProperties = new BStringView("hci", ""); + fHCIVersionProperties->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); fLMPVersionProperties = new BStringView("lmp", ""); + fLMPVersionProperties->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); fManufacturerProperties = new BStringView("manufacturer", ""); - fBuffersProperties = new BStringView("buffers", ""); + fManufacturerProperties->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); + fACLBuffersProperties = new BStringView("buffers acl", ""); + fACLBuffersProperties->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); + fSCOBuffersProperties = new BStringView("buffers sco", ""); + fSCOBuffersProperties->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); + fIcon = new BView(BRect(0, 0, 32 - 1, 32 - 1),"Icon", B_FOLLOW_ALL, B_WILL_DRAW); fIcon->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - + SetBluetoothDevice(bDevice); - AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 10) + AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 5) .Add(fIcon) .AddGlue() .Add(BGroupLayoutBuilder(B_VERTICAL) @@ -56,22 +67,24 @@ BluetoothDeviceView::BluetoothDeviceView(BRect frame, BluetoothDevice* bDevice, .AddGlue() .Add(fBdaddr) .AddGlue() - .AddGlue() .Add(fClass) .AddGlue() .Add(fClassService) .AddGlue() + .AddGlue() .Add(fHCIVersionProperties) .AddGlue() .Add(fLMPVersionProperties) .AddGlue() .Add(fManufacturerProperties) .AddGlue() - .Add(fBuffersProperties) - .SetInsets(5, 25, 25, 25) + .Add(fACLBuffersProperties) + .AddGlue() + .Add(fSCOBuffersProperties) + .SetInsets(5, 5, 5, 5) ) - .Add(BSpaceLayoutItem::CreateHorizontalStrut(10) - ).SetInsets(20, 20, 20, 20) + // .Add(BSpaceLayoutItem::CreateHorizontalStrut(5)) + .SetInsets(10, 10, 10, 10) ); } @@ -87,63 +100,64 @@ void BluetoothDeviceView::SetBluetoothDevice(BluetoothDevice* bDevice) { if (bDevice != NULL) { - - SetName(bDevice->GetFriendlyName().String()); - + + SetName(bDevice->GetFriendlyName().String()); + fName->SetText(bDevice->GetFriendlyName().String()); fBdaddr->SetText(bdaddrUtils::ToString(bDevice->GetBluetoothAddress())); - BString str(TR("Service classes: ")); bDevice->GetDeviceClass().GetServiceClass(str); fClassService->SetText(str.String()); - + str = ""; bDevice->GetDeviceClass().GetMajorDeviceClass(str); str << " / "; bDevice->GetDeviceClass().GetMinorDeviceClass(str); fClass->SetText(str.String()); - + bDevice->GetDeviceClass().Draw(fIcon, BPoint(Bounds().left, Bounds().top)); - + uint32 value; - + str = ""; - if (bDevice->GetProperty("hci_version", &value) == B_OK) + if (bDevice->GetProperty("hci_version", &value) == B_OK) str << "HCI ver: " << BluetoothHciVersion(value); - if (bDevice->GetProperty("hci_revision", &value) == B_OK) + if (bDevice->GetProperty("hci_revision", &value) == B_OK) str << " HCI rev: " << value ; - - fHCIVersionProperties->SetText(str.String()); - + + fHCIVersionProperties->SetText(str.String()); + str = ""; - if (bDevice->GetProperty("lmp_version", &value) == B_OK) + if (bDevice->GetProperty("lmp_version", &value) == B_OK) str << "LMP ver: " << BluetoothLmpVersion(value); - if (bDevice->GetProperty("lmp_subversion", &value) == B_OK) + if (bDevice->GetProperty("lmp_subversion", &value) == B_OK) str << " LMP subver: " << value; - fLMPVersionProperties->SetText(str.String()); - - str = ""; - if (bDevice->GetProperty("manufacturer", &value) == B_OK) + fLMPVersionProperties->SetText(str.String()); + + str = ""; + if (bDevice->GetProperty("manufacturer", &value) == B_OK) str << "Manufacturer: " << BluetoothManufacturer(value); fManufacturerProperties->SetText(str.String()); str = ""; - if (bDevice->GetProperty("acl_mtu", &value) == B_OK) + if (bDevice->GetProperty("acl_mtu", &value) == B_OK) str << "ACL mtu: " << value; - if (bDevice->GetProperty("acl_max_pkt", &value) == B_OK) + if (bDevice->GetProperty("acl_max_pkt", &value) == B_OK) str << " packets: " << value; - if (bDevice->GetProperty("sco_mtu", &value) == B_OK) - str << " SCO mtu: " << value; - if (bDevice->GetProperty("sco_max_pkt", &value) == B_OK) - str << " packets: " << value; - - fBuffersProperties->SetText(str.String()); + fACLBuffersProperties->SetText(str.String()); + + str = ""; + if (bDevice->GetProperty("sco_mtu", &value) == B_OK) + str << "SCO mtu: " << value; + if (bDevice->GetProperty("sco_max_pkt", &value) == B_OK) + str << " packets: " << value; + fSCOBuffersProperties->SetText(str.String()); + - } - - + + } diff --git a/src/preferences/bluetooth/BluetoothDeviceView.h b/src/preferences/bluetooth/BluetoothDeviceView.h index 3316aff2aa..af5f4c9676 100644 --- a/src/preferences/bluetooth/BluetoothDeviceView.h +++ b/src/preferences/bluetooth/BluetoothDeviceView.h @@ -20,67 +20,33 @@ class BitmapView; class BluetoothDeviceView : public BView { public: - BluetoothDeviceView(BRect frame, BluetoothDevice* bDevice, - uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, + BluetoothDeviceView(BRect frame, BluetoothDevice* bDevice, + uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW); ~BluetoothDeviceView(void); - - void SetBluetoothDevice(BluetoothDevice* bdev); - virtual void MessageReceived(BMessage *msg); - virtual void SetTarget(BHandler *tgt); + void SetBluetoothDevice(BluetoothDevice* bDevice); + + virtual void MessageReceived(BMessage* message); + virtual void SetTarget(BHandler* target); virtual void SetEnabled(bool value); - + protected: BluetoothDevice* fDevice; - + BStringView* fName; BStringView* fBdaddr; BStringView* fClassService; BStringView* fClass; - + BStringView* fHCIVersionProperties; BStringView* fLMPVersionProperties; BStringView* fManufacturerProperties; - - BStringView* fBuffersProperties; + + BStringView* fACLBuffersProperties; + BStringView* fSCOBuffersProperties; BView* fIcon; - -}; - - -class BitmapView : public BView -{ - public: - BitmapView(BBitmap *bitmap) : BView(bitmap->Bounds(), NULL, - B_FOLLOW_NONE, B_WILL_DRAW) - { - fBitmap = bitmap; - - SetDrawingMode(B_OP_ALPHA); - SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); - } - - ~BitmapView() - { - delete fBitmap; - } - - virtual void AttachedToWindow() - { - //SetViewColor(Parent()->ViewColor()); - - //MoveTo((Parent()->Bounds().Width() - Bounds().Width()) / 2, Frame().top); - } - - virtual void Draw(BRect updateRect) - { - DrawBitmap(fBitmap, updateRect, updateRect); - } - - private: - BBitmap *fBitmap; };