[haiku-commits] r40908 - haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn

  • From: kallisti5@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 10 Mar 2011 23:20:23 +0100 (CET)

Author: kallisti5
Date: 2011-03-10 23:20:23 +0100 (Thu, 10 Mar 2011)
New Revision: 40908
Changeset: http://dev.haiku-os.org/changeset/40908

Modified:
   haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp
   haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h
   haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp
   haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.h
Log:
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.

Modified: 
haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp
===================================================================
--- haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp  
2011-03-10 21:44:36 UTC (rev 40907)
+++ haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.cpp  
2011-03-10 22:20:23 UTC (rev 40908)
@@ -80,6 +80,10 @@
                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 @@
                        .Add(fConfigure)
                        .Add(fOnOff)
                        .AddGlue()
+                       .Add(fHeal)
                .End()
                .SetInsets(10, 10, 10, 10)
        );
@@ -104,6 +109,7 @@
        fListview->SetTarget(this);
        fConfigure->SetTarget(this);
        fOnOff->SetTarget(this);
+       fHeal->SetTarget(this);
 }
 
 
@@ -127,11 +133,13 @@
        switch (msg->what) {
                case kMsgInterfaceSelected:
                {
+                       fConfigure->SetEnabled(item != NULL);
                        fOnOff->SetEnabled(item != NULL);
-                       fConfigure->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 @@
                                break;
 
                        item->SetDisabled(!item->IsDisabled());
+                       fConfigure->SetEnabled(!item->IsDisabled());
                        fOnOff->SetLabel(item->IsDisabled() ? "Enable" : 
"Disable");
-                       fConfigure->SetEnabled(!item->IsDisabled());
+                       fHeal->SetEnabled(!item->IsDisabled());
                        fListview->Invalidate();
                        break;
                }

Modified: 
haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h
===================================================================
--- haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h    
2011-03-10 21:44:36 UTC (rev 40907)
+++ haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesAddOn.h    
2011-03-10 22:20:23 UTC (rev 40908)
@@ -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 @@
                        InterfacesListView*     fListview;
                        BButton*                        fConfigure;
                        BButton*                        fOnOff;
+                       BButton*                        fHeal;
 };
 
 

Modified: 
haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp
===================================================================
--- 
haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp   
    2011-03-10 21:44:36 UTC (rev 40907)
+++ 
haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.cpp   
    2011-03-10 22:20:23 UTC (rev 40908)
@@ -343,6 +343,13 @@
 
 
 void
+InterfacesListView::FrameResized(float width, float height)
+{
+       Invalidate();
+}
+
+
+void
 InterfacesListView::DetachedFromWindow()
 {
        BListView::DetachedFromWindow();
@@ -371,36 +378,6 @@
 }
 
 
-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)
 {

Modified: 
haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.h
===================================================================
--- haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.h 
2011-03-10 21:44:36 UTC (rev 40907)
+++ haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn/InterfacesListView.h 
2011-03-10 22:20:23 UTC (rev 40908)
@@ -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 @@
 protected:
        virtual void                            AttachedToWindow();
        virtual void                            DetachedFromWindow();
-       virtual void                            MouseDown(BPoint point);
+       virtual void                            FrameResized(float width, float 
height);
 
        virtual void                            MessageReceived(BMessage* 
message);
 


Other related posts:

  • » [haiku-commits] r40908 - haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn - kallisti5