diff --git a/src/add-ons/disk_systems/bfs/InitializeParameterEditor.cpp b/src/add-ons/disk_systems/bfs/InitializeParameterEditor.cpp index ab00f1ece5..6af76964bf 100644 --- a/src/add-ons/disk_systems/bfs/InitializeParameterEditor.cpp +++ b/src/add-ons/disk_systems/bfs/InitializeParameterEditor.cpp @@ -94,11 +94,11 @@ InitializeBFSEditor::PartitionNameChanged(const char* name) void InitializeBFSEditor::_CreateViewControls() { - fNameTC = new BTextControl("Name", "Haiku", NULL); + fNameTC = new BTextControl("Name:", "Haiku", NULL); // TODO find out what is the max length for this specific FS partition name fNameTC->TextView()->SetMaxBytes(31); - BPopUpMenu* blocksizeMenu = new BPopUpMenu("Blocksize"); + BPopUpMenu* blocksizeMenu = new BPopUpMenu("Blocksize:"); BMessage* message = new BMessage(MSG_BLOCK_SIZE); message->AddString("size", "1024"); blocksizeMenu->AddItem(new BMenuItem("1024 (Mostly small files)", diff --git a/src/apps/drivesetup/CreateParamsPanel.cpp b/src/apps/drivesetup/CreateParamsPanel.cpp index 7a8b6d2bd2..58a39df1d5 100644 --- a/src/apps/drivesetup/CreateParamsPanel.cpp +++ b/src/apps/drivesetup/CreateParamsPanel.cpp @@ -1,20 +1,22 @@ /* - * Copyright 2008-2009 Haiku Inc. All rights reserved. + * Copyright 2008-20010 Haiku Inc. All rights reserved. * Distributed under the terms of the MIT license. * * Authors: * Stephan Aßmus * Bryce Groff + * Karsten Heimrich. */ #include "CreateParamsPanel.h" #include "Support.h" -#include #include +#include #include +#include +#include #include -#include #include #include #include @@ -22,8 +24,6 @@ #include #include #include -#include -#include #include @@ -64,6 +64,7 @@ private: CreateParamsPanel* fPanel; }; + // #pragma mark - @@ -149,10 +150,7 @@ CreateParamsPanel::Go(off_t& offset, off_t& size, BString& name, return GO_CANCELED; // center the panel above the parent window - BRect frame = Frame(); - BRect parentFrame = fWindow->Frame(); - MoveTo((parentFrame.left + parentFrame.right - frame.Width()) / 2.0, - (parentFrame.top + parentFrame.bottom - frame.Height()) / 2.0); + CenterIn(fWindow->Frame()); Show(); Unlock(); @@ -222,7 +220,7 @@ CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset, offset + size); fSizeSlider->SetPosition(1.0); - fNameTextControl = new BTextControl("Name Control", "Partition name", + fNameTextControl = new BTextControl("Name Control", "Partition name:", "", NULL); if (!parent->SupportsChildName()) fNameTextControl->SetEnabled(false); @@ -231,8 +229,7 @@ CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset, int32 cookie = 0; BString supportedType; - while (parent->GetNextSupportedChildType(&cookie, &supportedType) - == B_OK) { + while (parent->GetNextSupportedChildType(&cookie, &supportedType) == B_OK) { BMessage* message = new BMessage(MSG_PARTITION_TYPE); message->AddString("type", supportedType); BMenuItem* item = new BMenuItem(supportedType, message); @@ -242,70 +239,36 @@ CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset, item->SetMarked(true); } - fTypeMenuField = new BMenuField("Partition type", fTypePopUpMenu, NULL); + fTypeMenuField = new BMenuField("Partition type:", fTypePopUpMenu, NULL); - fOKButton = new BButton("Create", new BMessage(MSG_OK)); - fCancelButton = new BButton("Cancel", new BMessage(MSG_CANCEL)); + const float spacing = be_control_look->DefaultItemSpacing(); + BGroupLayout* layout = new BGroupLayout(B_VERTICAL, spacing); + layout->SetInsets(spacing, spacing, spacing, spacing); - BView* infoView = BGroupLayoutBuilder(B_VERTICAL, 3) + SetLayout(layout); + + AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing) .Add(fSizeSlider) - .Add(fNameTextControl) - .Add(fTypeMenuField) - ; - BBox* infoBox = new BBox(B_FANCY_BORDER, infoView); - BView* rootView; + .Add(BGridLayoutBuilder(0.0, 5.0) + .Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0) + .Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0) + .Add(fTypeMenuField->CreateLabelLayoutItem(), 0, 1) + .Add(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1) + ) + ); parent->GetChildCreationParameterEditor(NULL, &fEditor); - if (fEditor != NULL) { - BBox* parameterBox = new BBox(B_FANCY_BORDER, fEditor->View()); + if (fEditor) + AddChild(fEditor->View()); - rootView = BGroupLayoutBuilder(B_VERTICAL, 4) - .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) - - // slider and types - .Add(infoBox) - - .Add(BSpaceLayoutItem::CreateVerticalStrut(10)) - - // editor's view - .Add(parameterBox) - - // controls - .AddGroup(B_HORIZONTAL, 10) - .Add(BSpaceLayoutItem::CreateHorizontalStrut(5)) - .AddGlue() - .Add(fCancelButton) - .Add(fOKButton) - .Add(BSpaceLayoutItem::CreateHorizontalStrut(5)) - .End() - - .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) - ; - } else { - rootView = BGroupLayoutBuilder(B_VERTICAL, 4) - .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) - - // slider and types - .Add(infoBox) - - .Add(BSpaceLayoutItem::CreateVerticalStrut(10)) - - // controls - .AddGroup(B_HORIZONTAL, 10) - .Add(BSpaceLayoutItem::CreateHorizontalStrut(5)) - .AddGlue() - .Add(fCancelButton) - .Add(fOKButton) - .Add(BSpaceLayoutItem::CreateHorizontalStrut(5)) - .End() - - .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) - ; - } - - SetLayout(new BGroupLayout(B_HORIZONTAL)); - AddChild(rootView); - SetDefaultButton(fOKButton); + BButton* okButton = new BButton("Create", new BMessage(MSG_OK)); + AddChild(BGroupLayoutBuilder(B_HORIZONTAL, spacing) + .AddGlue() + .Add(new BButton("Cancel", new BMessage(MSG_CANCEL))) + .Add(okButton) + ); + SetDefaultButton(okButton); AddToSubset(fWindow); + layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); } diff --git a/src/apps/drivesetup/CreateParamsPanel.h b/src/apps/drivesetup/CreateParamsPanel.h index 774836a215..9b9221595f 100644 --- a/src/apps/drivesetup/CreateParamsPanel.h +++ b/src/apps/drivesetup/CreateParamsPanel.h @@ -9,7 +9,6 @@ #ifndef CREATE_PARAMS_PANEL_H #define CREATE_PARAMS_PANEL_H -#include "Support.h" #include #include @@ -38,7 +37,7 @@ public: private: void _CreateViewControls(BPartition* parent, off_t offset, off_t size); - + class EscapeFilter; EscapeFilter* fEscapeFilter; sem_id fExitSemaphore; @@ -46,13 +45,11 @@ private: int32 fReturnValue; BPartitionParameterEditor* fEditor; - + BPopUpMenu* fTypePopUpMenu; BMenuField* fTypeMenuField; BTextControl* fNameTextControl; SizeSlider* fSizeSlider; - BButton* fOKButton; - BButton* fCancelButton; }; #endif // CREATE_PARAMS_PANEL_H diff --git a/src/apps/drivesetup/InitParamsPanel.cpp b/src/apps/drivesetup/InitParamsPanel.cpp index af46af8055..603089970f 100644 --- a/src/apps/drivesetup/InitParamsPanel.cpp +++ b/src/apps/drivesetup/InitParamsPanel.cpp @@ -1,9 +1,10 @@ /* - * Copyright 2008-2009 Haiku Inc. All rights reserved. + * Copyright 2008-2010 Haiku Inc. All rights reserved. * Distributed under the terms of the MIT license. * * Authors: * Stephan Aßmus +* Karsten Heimrich. */ #include "InitParamsPanel.h" @@ -12,16 +13,11 @@ #include #include -#include +#include +#include #include -#include -#include -#include #include #include -#include -#include -#include #include @@ -86,31 +82,22 @@ InitParamsPanel::InitParamsPanel(BWindow* window, const BString& diskSystem, AddCommonFilter(fEscapeFilter); BButton* okButton = new BButton("Initialize", new BMessage(MSG_OK)); - BButton* cancelButton = new BButton("Cancel", new BMessage(MSG_CANCEL)); partition->GetInitializationParameterEditor(diskSystem.String(), &fEditor); - BView* rootView = BGroupLayoutBuilder(B_VERTICAL, 5) - .Add(BSpaceLayoutItem::CreateVerticalStrut(10)) - - // test views - .Add(fEditor->View()) - - // controls - .AddGroup(B_HORIZONTAL, 10) - .Add(BSpaceLayoutItem::CreateHorizontalStrut(5)) - .AddGlue() - .Add(cancelButton) - .Add(okButton) - .Add(BSpaceLayoutItem::CreateHorizontalStrut(5)) - .End() - - .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) - ; - SetLayout(new BGroupLayout(B_HORIZONTAL)); - AddChild(rootView); + const float spacing = be_control_look->DefaultItemSpacing(); + AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing) + .Add(fEditor->View()) + .AddGroup(B_HORIZONTAL, spacing) + .AddGlue() + .Add(new BButton("Cancel", new BMessage(MSG_CANCEL))) + .Add(okButton) + .End() + .SetInsets(spacing, spacing, spacing, spacing) + ); + SetDefaultButton(okButton); // If the partition had a previous name, set to that name. @@ -168,10 +155,7 @@ InitParamsPanel::Go(BString& name, BString& parameters) return GO_CANCELED; // center the panel above the parent window - BRect frame = Frame(); - BRect parentFrame = fWindow->Frame(); - MoveTo((parentFrame.left + parentFrame.right - frame.Width()) / 2.0, - (parentFrame.top + parentFrame.bottom - frame.Height()) / 2.0); + CenterIn(fWindow->Frame()); Show(); Unlock();