*Fixes ticket #4415.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35120 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Karsten Heimrich
2010-01-17 16:45:43 +00:00
parent f0bddd1112
commit deed298ba4
4 changed files with 53 additions and 109 deletions
@@ -94,11 +94,11 @@ InitializeBFSEditor::PartitionNameChanged(const char* name)
void void
InitializeBFSEditor::_CreateViewControls() 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 // TODO find out what is the max length for this specific FS partition name
fNameTC->TextView()->SetMaxBytes(31); fNameTC->TextView()->SetMaxBytes(31);
BPopUpMenu* blocksizeMenu = new BPopUpMenu("Blocksize"); BPopUpMenu* blocksizeMenu = new BPopUpMenu("Blocksize:");
BMessage* message = new BMessage(MSG_BLOCK_SIZE); BMessage* message = new BMessage(MSG_BLOCK_SIZE);
message->AddString("size", "1024"); message->AddString("size", "1024");
blocksizeMenu->AddItem(new BMenuItem("1024 (Mostly small files)", blocksizeMenu->AddItem(new BMenuItem("1024 (Mostly small files)",
+33 -70
View File
@@ -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. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
* Stephan Aßmus <[email protected]> * Stephan Aßmus <[email protected]>
* Bryce Groff <[email protected]> * Bryce Groff <[email protected]>
* Karsten Heimrich. <[email protected]>
*/ */
#include "CreateParamsPanel.h" #include "CreateParamsPanel.h"
#include "Support.h" #include "Support.h"
#include <Box.h>
#include <Button.h> #include <Button.h>
#include <ControlLook.h>
#include <DiskDeviceTypes.h> #include <DiskDeviceTypes.h>
#include <GridLayoutBuilder.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h> #include <GroupLayoutBuilder.h>
#include <GroupView.h>
#include <MenuField.h> #include <MenuField.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <Message.h> #include <Message.h>
@@ -22,8 +24,6 @@
#include <PopUpMenu.h> #include <PopUpMenu.h>
#include <PartitionParameterEditor.h> #include <PartitionParameterEditor.h>
#include <Partition.h> #include <Partition.h>
#include <Slider.h>
#include <SpaceLayoutItem.h>
#include <String.h> #include <String.h>
@@ -64,6 +64,7 @@ private:
CreateParamsPanel* fPanel; CreateParamsPanel* fPanel;
}; };
// #pragma mark - // #pragma mark -
@@ -149,10 +150,7 @@ CreateParamsPanel::Go(off_t& offset, off_t& size, BString& name,
return GO_CANCELED; return GO_CANCELED;
// center the panel above the parent window // center the panel above the parent window
BRect frame = Frame(); CenterIn(fWindow->Frame());
BRect parentFrame = fWindow->Frame();
MoveTo((parentFrame.left + parentFrame.right - frame.Width()) / 2.0,
(parentFrame.top + parentFrame.bottom - frame.Height()) / 2.0);
Show(); Show();
Unlock(); Unlock();
@@ -222,7 +220,7 @@ CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset,
offset + size); offset + size);
fSizeSlider->SetPosition(1.0); fSizeSlider->SetPosition(1.0);
fNameTextControl = new BTextControl("Name Control", "Partition name", fNameTextControl = new BTextControl("Name Control", "Partition name:",
"", NULL); "", NULL);
if (!parent->SupportsChildName()) if (!parent->SupportsChildName())
fNameTextControl->SetEnabled(false); fNameTextControl->SetEnabled(false);
@@ -231,8 +229,7 @@ CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset,
int32 cookie = 0; int32 cookie = 0;
BString supportedType; BString supportedType;
while (parent->GetNextSupportedChildType(&cookie, &supportedType) while (parent->GetNextSupportedChildType(&cookie, &supportedType) == B_OK) {
== B_OK) {
BMessage* message = new BMessage(MSG_PARTITION_TYPE); BMessage* message = new BMessage(MSG_PARTITION_TYPE);
message->AddString("type", supportedType); message->AddString("type", supportedType);
BMenuItem* item = new BMenuItem(supportedType, message); BMenuItem* item = new BMenuItem(supportedType, message);
@@ -242,70 +239,36 @@ CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset,
item->SetMarked(true); 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)); const float spacing = be_control_look->DefaultItemSpacing();
fCancelButton = new BButton("Cancel", new BMessage(MSG_CANCEL)); 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(fSizeSlider)
.Add(fNameTextControl) .Add(BGridLayoutBuilder(0.0, 5.0)
.Add(fTypeMenuField) .Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0)
; .Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0)
BBox* infoBox = new BBox(B_FANCY_BORDER, infoView); .Add(fTypeMenuField->CreateLabelLayoutItem(), 0, 1)
BView* rootView; .Add(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1)
)
);
parent->GetChildCreationParameterEditor(NULL, &fEditor); parent->GetChildCreationParameterEditor(NULL, &fEditor);
if (fEditor != NULL) { if (fEditor)
BBox* parameterBox = new BBox(B_FANCY_BORDER, fEditor->View()); AddChild(fEditor->View());
rootView = BGroupLayoutBuilder(B_VERTICAL, 4) BButton* okButton = new BButton("Create", new BMessage(MSG_OK));
.Add(BSpaceLayoutItem::CreateVerticalStrut(5)) AddChild(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
.AddGlue()
// slider and types .Add(new BButton("Cancel", new BMessage(MSG_CANCEL)))
.Add(infoBox) .Add(okButton)
);
.Add(BSpaceLayoutItem::CreateVerticalStrut(10)) SetDefaultButton(okButton);
// 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);
AddToSubset(fWindow); AddToSubset(fWindow);
layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
} }
+2 -5
View File
@@ -9,7 +9,6 @@
#ifndef CREATE_PARAMS_PANEL_H #ifndef CREATE_PARAMS_PANEL_H
#define CREATE_PARAMS_PANEL_H #define CREATE_PARAMS_PANEL_H
#include "Support.h"
#include <Window.h> #include <Window.h>
#include <InterfaceKit.h> #include <InterfaceKit.h>
@@ -38,7 +37,7 @@ public:
private: private:
void _CreateViewControls(BPartition* parent, void _CreateViewControls(BPartition* parent,
off_t offset, off_t size); off_t offset, off_t size);
class EscapeFilter; class EscapeFilter;
EscapeFilter* fEscapeFilter; EscapeFilter* fEscapeFilter;
sem_id fExitSemaphore; sem_id fExitSemaphore;
@@ -46,13 +45,11 @@ private:
int32 fReturnValue; int32 fReturnValue;
BPartitionParameterEditor* fEditor; BPartitionParameterEditor* fEditor;
BPopUpMenu* fTypePopUpMenu; BPopUpMenu* fTypePopUpMenu;
BMenuField* fTypeMenuField; BMenuField* fTypeMenuField;
BTextControl* fNameTextControl; BTextControl* fNameTextControl;
SizeSlider* fSizeSlider; SizeSlider* fSizeSlider;
BButton* fOKButton;
BButton* fCancelButton;
}; };
#endif // CREATE_PARAMS_PANEL_H #endif // CREATE_PARAMS_PANEL_H
+16 -32
View File
@@ -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. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
* Stephan Aßmus <[email protected]> * Stephan Aßmus <[email protected]>
* Karsten Heimrich. <[email protected]>
*/ */
#include "InitParamsPanel.h" #include "InitParamsPanel.h"
@@ -12,16 +13,11 @@
#include <stdio.h> #include <stdio.h>
#include <Button.h> #include <Button.h>
#include <GridLayoutBuilder.h> #include <ControlLook.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h> #include <GroupLayoutBuilder.h>
#include <GroupView.h>
#include <MenuField.h>
#include <MenuItem.h>
#include <Message.h> #include <Message.h>
#include <MessageFilter.h> #include <MessageFilter.h>
#include <PopUpMenu.h>
#include <TextControl.h>
#include <SpaceLayoutItem.h>
#include <String.h> #include <String.h>
@@ -86,31 +82,22 @@ InitParamsPanel::InitParamsPanel(BWindow* window, const BString& diskSystem,
AddCommonFilter(fEscapeFilter); AddCommonFilter(fEscapeFilter);
BButton* okButton = new BButton("Initialize", new BMessage(MSG_OK)); BButton* okButton = new BButton("Initialize", new BMessage(MSG_OK));
BButton* cancelButton = new BButton("Cancel", new BMessage(MSG_CANCEL));
partition->GetInitializationParameterEditor(diskSystem.String(), partition->GetInitializationParameterEditor(diskSystem.String(),
&fEditor); &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)); 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); SetDefaultButton(okButton);
// If the partition had a previous name, set to that name. // If the partition had a previous name, set to that name.
@@ -168,10 +155,7 @@ InitParamsPanel::Go(BString& name, BString& parameters)
return GO_CANCELED; return GO_CANCELED;
// center the panel above the parent window // center the panel above the parent window
BRect frame = Frame(); CenterIn(fWindow->Frame());
BRect parentFrame = fWindow->Frame();
MoveTo((parentFrame.left + parentFrame.right - frame.Width()) / 2.0,
(parentFrame.top + parentFrame.bottom - frame.Height()) / 2.0);
Show(); Show();
Unlock(); Unlock();