From a0a9cb5c21dfe963f8f73f002e89aad69aa5318b Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Thu, 10 Mar 2011 22:20:23 +0000 Subject: [PATCH] remove right-click menu in InterfaceView; add FrameResized hook to invalidate to correct tearing right status text; Add heal button to renegotiate interface address.. this also balances the buttons on the bottom. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40908 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../InterfacesAddOn/InterfacesAddOn.cpp | 13 ++++++- .../preflet/InterfacesAddOn/InterfacesAddOn.h | 2 + .../InterfacesAddOn/InterfacesListView.cpp | 37 ++++--------------- .../InterfacesAddOn/InterfacesListView.h | 4 +- 4 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp index e5335c00bb..ca0985e1d3 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp @@ -80,6 +80,10 @@ InterfacesAddOn::CreateView(BRect *bounds) new BMessage(kMsgInterfaceToggle)); fOnOff->SetEnabled(false); + fHeal = new BButton(intViewRect, "heal", + "Heal", new BMessage(kMsgInterfaceHeal)); + fHeal->SetEnabled(false); + // Build the layout SetLayout(new BGroupLayout(B_VERTICAL)); @@ -89,6 +93,7 @@ InterfacesAddOn::CreateView(BRect *bounds) .Add(fConfigure) .Add(fOnOff) .AddGlue() + .Add(fHeal) .End() .SetInsets(10, 10, 10, 10) ); @@ -104,6 +109,7 @@ InterfacesAddOn::AttachedToWindow() fListview->SetTarget(this); fConfigure->SetTarget(this); fOnOff->SetTarget(this); + fHeal->SetTarget(this); } @@ -127,11 +133,13 @@ InterfacesAddOn::MessageReceived(BMessage* msg) switch (msg->what) { case kMsgInterfaceSelected: { - fOnOff->SetEnabled(item != NULL); fConfigure->SetEnabled(item != NULL); + fOnOff->SetEnabled(item != NULL); + fHeal->SetEnabled(item != NULL); if (!item) break; fConfigure->SetEnabled(!item->IsDisabled()); + fHeal->SetEnabled(!item->IsDisabled()); fOnOff->SetLabel(item->IsDisabled() ? "Enable" : "Disable"); break; } @@ -152,8 +160,9 @@ InterfacesAddOn::MessageReceived(BMessage* msg) break; item->SetDisabled(!item->IsDisabled()); - fOnOff->SetLabel(item->IsDisabled() ? "Enable" : "Disable"); fConfigure->SetEnabled(!item->IsDisabled()); + fOnOff->SetLabel(item->IsDisabled() ? "Enable" : "Disable"); + fHeal->SetEnabled(!item->IsDisabled()); fListview->Invalidate(); break; } diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h index 0c0a8485b7..22d5a71789 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h @@ -23,6 +23,7 @@ static const uint32 kMsgInterfaceSelected = 'ifce'; static const uint32 kMsgInterfaceConfigure = 'ifcf'; static const uint32 kMsgInterfaceToggle = 'onof'; +static const uint32 kMsgInterfaceHeal = 'heal'; class InterfacesAddOn : public NetworkSetupAddOn, public BBox @@ -43,6 +44,7 @@ private: InterfacesListView* fListview; BButton* fConfigure; BButton* fOnOff; + BButton* fHeal; }; diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp index 5b6a61029a..d41804cf8c 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp @@ -342,6 +342,13 @@ InterfacesListView::AttachedToWindow() } +void +InterfacesListView::FrameResized(float width, float height) +{ + Invalidate(); +} + + void InterfacesListView::DetachedFromWindow() { @@ -371,36 +378,6 @@ 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 d65f3a4ae8..8bf8ded916 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.h +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.h @@ -31,8 +31,6 @@ #define ICON_SIZE 37 -static const uint32 kMsgInterfaceReconfigure = 'ifre'; - class InterfaceListItem : public BListItem { public: InterfaceListItem(const char* name); @@ -85,7 +83,7 @@ public: protected: virtual void AttachedToWindow(); virtual void DetachedFromWindow(); - virtual void MouseDown(BPoint point); + virtual void FrameResized(float width, float height); virtual void MessageReceived(BMessage* message);