Ticket #9265: bluetoothUI.patch
File bluetoothUI.patch, 8.7 KB (added by , 12 years ago) |
---|
-
new file headers/private/bluetooth/BluetoothIconView.h
diff --git a/headers/private/bluetooth/BluetoothIconView.h b/headers/private/bluetooth/BluetoothIconView.h new file mode 100644 index 0000000..d8a266f
- + 1 /* 2 * Copyright 2012, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Tri-Edge AI <triedgeai@gmail.com> 7 */ 8 9 #ifndef _BLUETOOTH_ICON_VIEW_H_ 10 #define _BLUETOOTH_ICON_VIEW_H_ 11 12 #include <View.h> 13 #include <Bitmap.h> 14 #include <MimeType.h> 15 #include <IconUtils.h> 16 17 namespace Bluetooth 18 { 19 20 class BluetoothIconView : public BView 21 { 22 public: 23 BluetoothIconView(); 24 void Draw(BRect rect); 25 26 private: 27 BBitmap* bitmap; 28 }; 29 30 } 31 32 #endif /* _BLUETOOTH_ICON_VIEW_H_ */ -
headers/private/bluetooth/ConnectionIncoming.h
diff --git a/headers/private/bluetooth/ConnectionIncoming.h b/headers/private/bluetooth/ConnectionIncoming.h index f8292f8..1ce2d44 100644
a b 1 /* 1 /* 2 2 * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com 3 * 3 * 4 4 * All rights reserved. Distributed under the terms of the MIT License. 5 * 6 */ 5 * 6 */ 7 7 8 8 #ifndef _CONNECTION_INCOMING_H_ 9 9 #define _CONNECTION_INCOMING_H_ 10 10 11 12 //----------------------- Global includes ----------------------13 11 #include <AppKit.h> 14 12 #include <SupportKit.h> 15 13 #include <InterfaceKit.h> 14 15 #include <ConnectionView.h> 16 #include <bluetooth/RemoteDevice.h> 17 16 18 #include <iostream> 17 19 #include <stdio.h> 18 20 #include <stdlib.h> 19 21 20 namespace Bluetooth { 21 22 class RemoteDevice; 23 24 class ConnectionView 25 : public BView 22 namespace Bluetooth 26 23 { 27 public:28 ConnectionView(BRect frame, const char *name);29 ~ConnectionView();30 virtual void MessageReceived(BMessage *message);31 void Draw(BRect update);32 void Pulse();33 34 private:35 36 37 };38 24 25 class RemoteDevice; 26 class ConnectionView; 39 27 40 28 class ConnectionIncoming : public BWindow 41 29 { 42 30 public: 43 31 ConnectionIncoming(RemoteDevice* rDevice); 44 32 ~ConnectionIncoming(); 45 virtual void MessageReceived(BMessage *message); 33 34 virtual void MessageReceived(BMessage* message); 46 35 virtual bool QuitRequested(); 47 36 48 37 private: 49 ConnectionView* _ConnectionView;38 ConnectionView* view; 50 39 }; 51 40 52 41 } … … private: 55 44 using Bluetooth::ConnectionIncoming; 56 45 #endif 57 46 58 59 #endif 47 #endif /* _CONNECTION_INCOMING_H_ */ -
new file headers/private/bluetooth/ConnectionView.h
diff --git a/headers/private/bluetooth/ConnectionView.h b/headers/private/bluetooth/ConnectionView.h new file mode 100644 index 0000000..4d338f1
- + 1 /* 2 * Copyright 2012, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Tri-Edge AI <triedgeai@gmail.com> 7 */ 8 9 #ifndef _CONNECTION_VIEW_H_ 10 #define _CONNECTION_VIEW_H_ 11 12 #include <Window.h> 13 #include <View.h> 14 #include <StringView.h> 15 #include <GroupLayout.h> 16 #include <GroupLayoutBuilder.h> 17 #include <Font.h> 18 #include <String.h> 19 20 namespace Bluetooth 21 { 22 23 class ConnectionView : public BView 24 { 25 public: 26 ConnectionView::ConnectionView(BRect frame, 27 BString device); 28 void Pulse(); 29 private: 30 BString strMessage; 31 BStringView* vMessage; 32 }; 33 34 } 35 36 #endif /* _CONNECTION_VIEW_H_ */ -
new file src/kits/bluetooth/UI/BluetoothIconView.cpp
diff --git a/src/kits/bluetooth/UI/BluetoothIconView.cpp b/src/kits/bluetooth/UI/BluetoothIconView.cpp new file mode 100644 index 0000000..2e3d882
- + 1 /* 2 * Copyright 2012, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Tri-Edge AI <triedgeai@gmail.com> 7 */ 8 9 #include <BluetoothIconView.h> 10 11 namespace Bluetooth 12 { 13 14 BluetoothIconView::BluetoothIconView() 15 : 16 BView(BRect(0, 0, 80, 80), "", B_FOLLOW_ALL, B_WILL_DRAW) 17 { 18 bitmap = new BBitmap(BRect(0, 0, 64, 64), 0, B_RGBA32); 19 20 uint8* ticon; 21 size_t tsize; 22 23 BMimeType mime("application/x-vnd.Haiku-bluetooth_server"); 24 mime.GetIcon(&ticon, &tsize); 25 26 BIconUtils::GetVectorIcon(ticon, tsize, bitmap); 27 28 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 29 SetDrawingMode(B_OP_ALPHA); 30 SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); 31 } 32 33 34 void 35 BluetoothIconView::Draw(BRect rect) 36 { 37 this->DrawBitmap(bitmap); 38 } 39 40 } -
src/kits/bluetooth/UI/ConnectionIncoming.cpp
diff --git a/src/kits/bluetooth/UI/ConnectionIncoming.cpp b/src/kits/bluetooth/UI/ConnectionIncoming.cpp index 1aced3a..17c05d2 100644
a b 1 /* 1 /* 2 2 * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com 3 * 3 * 4 4 * All rights reserved. Distributed under the terms of the MIT License. 5 * 6 */ 5 * 6 */ 7 7 8 8 #include <ConnectionIncoming.h> 9 #include <ConnectionView.h> 9 10 10 #define B_PULSES_BY_SECOND(x) (2*x) 11 12 namespace Bluetooth { 13 14 ConnectionView::ConnectionView(BRect frame, const char *name): BView(BRect(0, 0, 400, 400), "MyViewName", 15 B_FOLLOW_LEFT | B_FOLLOW_TOP, 16 B_WILL_DRAW | B_PULSE_NEEDED) 11 namespace Bluetooth 17 12 { 18 13 19 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 20 21 } 22 23 ConnectionView::~ConnectionView() 24 { 25 26 } 27 28 29 void ConnectionView::MessageReceived(BMessage *message) 30 { 31 switch(message->what) 32 { 33 default: 14 ConnectionIncoming::ConnectionIncoming(RemoteDevice* rDevice) 15 : 16 BWindow(BRect(600, 100, 1000, 180), "Incoming connection", 17 B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, 18 B_NOT_ZOOMABLE | B_NOT_RESIZABLE) 19 // 400x80 20 { 21 SetPulseRate(1 * 1000 * 1000); 22 // 1 second 34 23 35 break; 36 } 37 } 38 39 40 void ConnectionView::Draw(BRect update) 41 { 42 43 } 44 45 46 void ConnectionView::Pulse() 47 { 48 static int a = 0; 24 if (rDevice != NULL) 25 view = new ConnectionView(BRect(0, 0, 400, 80), rDevice->GetFriendlyName()); 26 else 27 view = new ConnectionView(BRect(0, 0, 400, 80), "<unknown_device>"); 49 28 50 if (a++ == B_PULSES_BY_SECOND(5)) { 51 // BUG: for some reason the window is not being removed... 52 Window()->PostMessage(B_QUIT_REQUESTED); 53 Window()->Quit(); 54 } 55 } 56 57 58 59 //--------------------------------------------------------------- 60 ConnectionIncoming::ConnectionIncoming(RemoteDevice* rDevice) 61 : BWindow(BRect(700, 100, 900, 150), "Connection completed", 62 B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, 63 B_NOT_ZOOMABLE | B_NOT_RESIZABLE) 64 { 65 _ConnectionView = new ConnectionView(BRect(0, 0, 400, 400),"mViewName"); 66 67 AddChild(_ConnectionView); 29 AddChild(view); 68 30 } 69 31 70 32 71 33 ConnectionIncoming::~ConnectionIncoming() 72 34 { 73 35 74 36 } 75 37 76 38 77 void ConnectionIncoming::MessageReceived(BMessage *message) 39 void 40 ConnectionIncoming::MessageReceived(BMessage* message) 78 41 { 79 switch (message->what)42 switch (message->what) 80 43 { 81 44 default: 82 45 … … void ConnectionIncoming::MessageReceived(BMessage *message) 85 48 } 86 49 87 50 88 bool ConnectionIncoming::QuitRequested() 51 bool 52 ConnectionIncoming::QuitRequested() 89 53 { 90 54 return BWindow::QuitRequested(); 91 55 } -
new file src/kits/bluetooth/UI/ConnectionView.cpp
diff --git a/src/kits/bluetooth/UI/ConnectionView.cpp b/src/kits/bluetooth/UI/ConnectionView.cpp new file mode 100644 index 0000000..05fcfed
- + 1 /* 2 * Copyright 2012, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Tri-Edge AI <triedgeai@gmail.com> 7 */ 8 9 #include <ConnectionView.h> 10 #include <BluetoothIconView.h> 11 12 namespace Bluetooth 13 { 14 15 ConnectionView::ConnectionView(BRect frame, BString device) 16 : 17 BView(frame, "ConnectionView", 0, B_PULSE_NEEDED) 18 { 19 BFont font; 20 21 font.SetFace(B_BOLD_FACE); 22 23 SetLayout(new BGroupLayout(B_HORIZONTAL)); 24 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 25 26 BluetoothIconView* vIcon = new BluetoothIconView(); 27 28 strMessage = "A new connection is incoming.."; 29 30 vMessage = new BStringView(frame, "", 31 strMessage, 32 B_FOLLOW_LEFT); 33 34 vMessage->SetAlignment(B_ALIGN_LEFT); 35 36 BStringView* vDevice = new BStringView(frame, "", 37 "Remote Device: ", B_FOLLOW_LEFT); 38 39 vDevice->SetFont(&font, B_FONT_FACE); 40 41 BStringView* vDeviceText = new BStringView(frame, "", 42 device, B_FOLLOW_RIGHT); 43 44 AddChild(BGroupLayoutBuilder(B_HORIZONTAL, B_USE_DEFAULT_SPACING) 45 .Add(BGroupLayoutBuilder(B_VERTICAL, 0) 46 .Add(vIcon) 47 .SetInsets(8, 8, 8, 8) 48 ) 49 .Add(BGroupLayoutBuilder(B_VERTICAL, B_USE_DEFAULT_SPACING) 50 .AddGlue() 51 .Add(vMessage) 52 .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) 53 .Add(vDevice) 54 .Add(vDeviceText) 55 ) 56 .AddGlue(3.0f) 57 ) 58 .AddGlue() 59 ); 60 } 61 62 63 void 64 ConnectionView::Pulse() 65 { 66 static int pulses = 0; 67 68 pulses++; 69 70 if (pulses >= 5) { 71 Window()->PostMessage(B_QUIT_REQUESTED); 72 } else { 73 strMessage += "."; 74 vMessage->SetText(strMessage); 75 } 76 } 77 78 } 79