diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp index f115be17b8..e5335c00bb 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp @@ -65,21 +65,19 @@ InterfacesAddOn::CreateView(BRect *bounds) // Construct the ListView fListview = new InterfacesListView(intViewRect, "interfaces", B_FOLLOW_ALL_SIDES); - fListview->SetSelectionMessage(new BMessage(kMsgInterfaceSel)); - fListview->SetInvocationMessage(new BMessage(kMsgInterfaceAct)); + fListview->SetSelectionMessage(new BMessage(kMsgInterfaceSelected)); + fListview->SetInvocationMessage(new BMessage(kMsgInterfaceConfigure)); BScrollView* scrollView = new BScrollView(NULL, fListview, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS, false, true); // Construct the BButtons fConfigure = new BButton(intViewRect, "configure", - "Configure" B_UTF8_ELLIPSIS, new BMessage(kMsgInterfaceCfg)); - + "Configure" B_UTF8_ELLIPSIS, new BMessage(kMsgInterfaceConfigure)); fConfigure->SetEnabled(false); fOnOff = new BButton(intViewRect, "onoff", "Disable", - new BMessage(kMsgInterfaceTog)); - + new BMessage(kMsgInterfaceToggle)); fOnOff->SetEnabled(false); // Build the layout @@ -127,7 +125,7 @@ InterfacesAddOn::MessageReceived(BMessage* msg) } switch (msg->what) { - case kMsgInterfaceSel: + case kMsgInterfaceSelected: { fOnOff->SetEnabled(item != NULL); fConfigure->SetEnabled(item != NULL); @@ -138,8 +136,7 @@ InterfacesAddOn::MessageReceived(BMessage* msg) break; } - case kMsgInterfaceAct: - case kMsgInterfaceCfg: + case kMsgInterfaceConfigure: { if (!item) break; @@ -149,7 +146,7 @@ InterfacesAddOn::MessageReceived(BMessage* msg) break; } - case kMsgInterfaceTog: + case kMsgInterfaceToggle: { if (!item) break; diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h index 7b55727243..0c0a8485b7 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h @@ -20,6 +20,11 @@ #include "InterfacesListView.h" +static const uint32 kMsgInterfaceSelected = 'ifce'; +static const uint32 kMsgInterfaceConfigure = 'ifcf'; +static const uint32 kMsgInterfaceToggle = 'onof'; + + class InterfacesAddOn : public NetworkSetupAddOn, public BBox { public: @@ -31,11 +36,6 @@ public: BView* CreateView(BRect *bounds); - static const uint32 kMsgInterfaceSel = 'ifce'; - static const uint32 kMsgInterfaceAct = 'ifac'; - static const uint32 kMsgInterfaceCfg = 'ifcf'; - static const uint32 kMsgInterfaceTog = 'onof'; - void AttachedToWindow(); void MessageReceived(BMessage* msg); diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp index 585a3df437..5b6a61029a 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -144,9 +145,9 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete) iconPt += BPoint(4, 4); statePt += BPoint(0, fFirstlineOffset); - namePt += BPoint(32 + 12, fFirstlineOffset); - v4addrPt += BPoint(32 + 12, fSecondlineOffset); - v6addrPt += BPoint(32 + 12, fThirdlineOffset); + namePt += BPoint(ICON_SIZE + 12, fFirstlineOffset); + v4addrPt += BPoint(ICON_SIZE + 12, fSecondlineOffset); + v6addrPt += BPoint(ICON_SIZE + 12, fThirdlineOffset); statePt -= BPoint(be_plain_font->StringWidth(interfaceState.String()), 0); @@ -274,7 +275,8 @@ InterfaceListItem::_PopulateBitmaps(const char* mediaType) { if (interfaceHVIF) { // Now build the bitmap - interfaceBitmap = new BBitmap(BRect(0, 0, 31, 31), 0, B_RGBA32); + interfaceBitmap = new BBitmap(BRect(0, 0, ICON_SIZE, ICON_SIZE), + 0, B_RGBA32); if (BIconUtils::GetVectorIcon(interfaceHVIF, iconSize, interfaceBitmap) == B_OK) fIcon = interfaceBitmap; @@ -287,7 +289,8 @@ InterfaceListItem::_PopulateBitmaps(const char* mediaType) { B_VECTOR_ICON_TYPE, "offline", &iconSize); if (offlineHVIF) { - fIconOffline = new BBitmap(BRect(0, 0, 31, 31), 0, B_RGBA32); + fIconOffline = new BBitmap(BRect(0, 0, ICON_SIZE, ICON_SIZE), + 0, B_RGBA32); BIconUtils::GetVectorIcon(offlineHVIF, iconSize, fIconOffline); } @@ -295,7 +298,8 @@ InterfaceListItem::_PopulateBitmaps(const char* mediaType) { B_VECTOR_ICON_TYPE, "pending", &iconSize); if (pendingHVIF) { - fIconPending = new BBitmap(BRect(0, 0, 31, 31), 0, B_RGBA32); + fIconPending = new BBitmap(BRect(0, 0, ICON_SIZE, ICON_SIZE), + 0, B_RGBA32); BIconUtils::GetVectorIcon(pendingHVIF, iconSize, fIconPending); } @@ -303,7 +307,8 @@ InterfaceListItem::_PopulateBitmaps(const char* mediaType) { B_VECTOR_ICON_TYPE, "online", &iconSize); if (onlineHVIF) { - fIconOnline = new BBitmap(BRect(0, 0, 31, 31), 0, B_RGBA32); + fIconOnline = new BBitmap(BRect(0, 0, ICON_SIZE, ICON_SIZE), + 0, B_RGBA32); BIconUtils::GetVectorIcon(onlineHVIF, iconSize, fIconOnline); } @@ -366,6 +371,36 @@ InterfacesListView::MessageReceived(BMessage* message) } +void +InterfacesListView::MouseDown(BPoint point) +{ + BMessage *msg = Window()->CurrentMessage(); + BListView::MouseDown(point); + + // if user is clicking and an item that has been selected + // via MouseDown call above. (eg. user clicked a list item) + if (msg->what == B_MOUSE_DOWN + && this->CurrentSelection() >= 0) { + uint32 buttons = 0; + msg->FindInt32("buttons", (int32 *)&buttons); + + // was it the secondary mouse button? If so show interface options + if (buttons & B_SECONDARY_MOUSE_BUTTON) { + BPopUpMenu *menu = new BPopUpMenu("IntefaceOptions"); + menu->SetFont(be_plain_font); + menu->AddItem(new BMenuItem("Renegotiate Address", + new BMessage(kMsgInterfaceReconfigure))); + menu->Go(ConvertToScreen(point)); + //if (selected) + // Window()->PostMessage(selected->Message()->what); + //delete menu; + return; + } + } + return; +} + + InterfaceListItem * InterfacesListView::FindItem(const char* name) { diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.h b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.h index 881d29ffef..d65f3a4ae8 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.h +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.h @@ -19,13 +19,20 @@ #include #include #include +#include #include #include +#include #include #include "NetworkSettings.h" +#define ICON_SIZE 37 + + +static const uint32 kMsgInterfaceReconfigure = 'ifre'; + class InterfaceListItem : public BListItem { public: InterfaceListItem(const char* name); @@ -78,6 +85,7 @@ public: protected: virtual void AttachedToWindow(); virtual void DetachedFromWindow(); + virtual void MouseDown(BPoint point); virtual void MessageReceived(BMessage* message);