From f565d142b370c0b53486d8f33f290849bac8ad6a Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Tue, 15 Feb 2011 00:04:27 +0000 Subject: [PATCH] added BTextControls for IP address and Netmask configuration git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40500 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../InterfacesAddOn/InterfaceAddressView.cpp | 34 ++++++++++++++++--- .../InterfacesAddOn/InterfaceAddressView.h | 6 ++++ .../InterfacesAddOn/InterfaceWindow.cpp | 2 +- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.cpp b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.cpp index 017a05123b..45d5a40771 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.cpp +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.cpp @@ -21,18 +21,33 @@ InterfaceAddressView::InterfaceAddressView(BRect frame, const char* name, fSettings(settings), fFamily(family) { + float textControlW; + float textControlH; + SetLayout(new BGroupLayout(B_VERTICAL)); - // TODO : Draw address fields in a generic way - BStringView* address = new BStringView(Bounds(), "address", - fSettings->IP(family)); + // Create our controls + fAddressField = new BTextControl(frame, "address", "IP Address:", + NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); + fNetmaskField = new BTextControl(frame, "netmask", "Netmask:", + NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); + + fAddressField->GetPreferredSize(&textControlW, &textControlH); + float labelSize = ( textControlW + 50 ) + - fAddressField->StringWidth("XXX.XXX.XXX.XXX"); + + _RevertFields(); + // Do the initial field population + + fAddressField->SetDivider(labelSize); + fNetmaskField->SetDivider(labelSize); AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) - .Add(address) + .Add(fAddressField) + .Add(fNetmaskField) .AddGlue() .SetInsets(10, 10, 10, 10) ); - } @@ -42,3 +57,12 @@ InterfaceAddressView::~InterfaceAddressView() } +status_t +InterfaceAddressView::_RevertFields() +{ + // Populate address fields with current settings + fAddressField->SetText(fSettings->IP(fFamily)); + fNetmaskField->SetText(fSettings->Netmask(fFamily)); + + return B_OK; +} diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.h b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.h index d28c019c96..d115ea12b4 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.h +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceAddressView.h @@ -13,6 +13,7 @@ #include #include +#include class InterfaceAddressView : public BView { @@ -23,8 +24,13 @@ public: virtual ~InterfaceAddressView(); private: + status_t _RevertFields(); NetworkSettings* fSettings; int fFamily; + + BTextControl* fAddressField; + BTextControl* fNetmaskField; + BTextControl* fGatewayField; }; diff --git a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceWindow.cpp b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceWindow.cpp index 0bb55ded82..6c51fd5fd3 100644 --- a/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceWindow.cpp +++ b/src/tests/kits/net/preflet/InterfacesAddOn/InterfaceWindow.cpp @@ -17,7 +17,7 @@ InterfaceWindow::InterfaceWindow(NetworkSettings* settings) - : BWindow(BRect(50, 50, 400, 302), "Interface Settings", + : BWindow(BRect(50, 50, 370, 350), "Interface Settings", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE, B_CURRENT_WORKSPACE)