use grid layout builder

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40524 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Alexander von Gluck IV 2011-02-15 23:05:10 +00:00
parent 8c3c490801
commit c44a2a9a25
2 changed files with 18 additions and 28 deletions

View File

@ -12,6 +12,7 @@
#include <GroupLayout.h> #include <GroupLayout.h>
#include <GroupLayoutBuilder.h> #include <GroupLayoutBuilder.h>
#include <GridLayoutBuilder.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <StringView.h> #include <StringView.h>
@ -23,9 +24,6 @@ InterfaceAddressView::InterfaceAddressView(BRect frame, const char* name,
fSettings(settings), fSettings(settings),
fFamily(family) fFamily(family)
{ {
float textControlW;
float textControlH;
SetLayout(new BGroupLayout(B_VERTICAL)); SetLayout(new BGroupLayout(B_VERTICAL));
// Create our controls // Create our controls
@ -39,35 +37,27 @@ InterfaceAddressView::InterfaceAddressView(BRect frame, const char* name,
fModePopUpMenu->AddItem(new BMenuItem("None", fModePopUpMenu->AddItem(new BMenuItem("None",
new BMessage(NONESEL_MSG))); new BMessage(NONESEL_MSG)));
fModeField = new BMenuField(frame, "mode", "Mode:", fModeField = new BMenuField("Mode:", fModePopUpMenu);
fModePopUpMenu, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW);
fAddressField = new BTextControl(frame, "address", "IP Address:", fAddressField = new BTextControl("IP Address:", NULL, NULL);
NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); fNetmaskField = new BTextControl("Netmask:", NULL, NULL);
fNetmaskField = new BTextControl(frame, "netmask", "Netmask:", fGatewayField = new BTextControl("Gateway:", NULL, NULL);
NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
fGatewayField = new BTextControl(frame, "gateway", "Gateway:",
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(); RevertFields();
// Do the initial field population // Do the initial field population
fModeField->SetDivider(labelSize);
fAddressField->SetDivider(labelSize);
fNetmaskField->SetDivider(labelSize);
fGatewayField->SetDivider(labelSize);
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
.Add(fModeField) .Add(BGridLayoutBuilder()
.Add(fAddressField) .Add(fModeField->CreateLabelLayoutItem(), 0, 0)
.Add(fNetmaskField) .Add(fModeField->CreateMenuBarLayoutItem(), 1, 0)
.Add(fGatewayField) .Add(fAddressField->CreateLabelLayoutItem(), 0, 1)
.Add(fAddressField->CreateTextViewLayoutItem(), 1, 1)
.Add(fNetmaskField->CreateLabelLayoutItem(), 0, 2)
.Add(fNetmaskField->CreateTextViewLayoutItem(), 1, 2)
.Add(fGatewayField->CreateLabelLayoutItem(), 0, 3)
.Add(fGatewayField->CreateTextViewLayoutItem(), 1, 3)
)
.AddGlue() .AddGlue()
.SetInsets(10, 10, 10, 10)
); );
} }