Exemple #1
0
void
FileSelectionPage::_Layout()
{
	LayoutDescriptionVertically(fDescription);

	float left = fFile->Frame().left;
	float top = fDescription->Frame().bottom + kTextDistance;

	// center "file" text field and "select" button vertically
	float selectTop = top;
	float fileTop = top;
	float fileHeight = fFile->Bounds().Height();
	float selectHeight = fSelect->Bounds().Height();
	if (fileHeight < selectHeight) {
		int delta = (int)((selectHeight - fileHeight + 1) / 2);
		fileTop += delta;
	} else {
		int delta = (int)((fileHeight - selectHeight + 1) / 2);
		selectTop += delta;
	}

	fFile->MoveTo(left, fileTop);

	float width = fSelect->Frame().left - kFileButtonDistance - left;
	fFile->ResizeTo(width, fileHeight);

	left = fSelect->Frame().left;
	fSelect->MoveTo(left, selectTop);
}
void
DefaultPartitionPage::_BuildUI()
{
	const float kTextDistance = be_control_look->DefaultItemSpacing();
	BRect rect(Bounds());

	BString text;
	text << B_TRANSLATE_COMMENT("Default Partition", "Title") << "\n"
		<< B_TRANSLATE("Please specify a default partition and a timeout.\n"
			"The boot menu will load the default partition after "
			"the timeout unless you select another partition. You "
			"can also have the boot menu wait indefinitely for you "
			"to select a partition.\n"
			"Keep the 'ALT' key pressed to disable the timeout at boot time.");

	fDescription = CreateDescription(rect, "description", text);
	MakeHeading(fDescription);
	AddChild(fDescription);
	LayoutDescriptionVertically(fDescription);
	rect.top = fDescription->Frame().bottom + kTextDistance;

	BPopUpMenu* popUpMenu = _CreatePopUpMenu();
	fDefaultPartition = new BMenuField(rect, "partitions",
		B_TRANSLATE_COMMENT("Default Partition:", "Menu field label"),
		popUpMenu);
	float divider = be_plain_font->StringWidth(fDefaultPartition->Label()) + 3;
	fDefaultPartition->SetDivider(divider);
	AddChild(fDefaultPartition);
	fDefaultPartition->ResizeToPreferred();

	// timeout slider
	rect.top = fDefaultPartition->Frame().bottom + kTextDistance;
	int32 timeout;
	fSettings->FindInt32("timeout", &timeout);
	BString timeoutLabel;
	_GetTimeoutLabel(timeout, timeoutLabel);

	int32 sliderValue = get_index_for_timeout(timeout);

	fTimeoutSlider = new BSlider(rect, "timeout", timeoutLabel.String(),
		new BMessage(kMsgTimeout), 0, kNumberOfTimeoutOptions-1,
		B_BLOCK_THUMB,
		B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fTimeoutSlider->SetModificationMessage(new BMessage(kMsgTimeout));
	fTimeoutSlider->SetValue(sliderValue);
	fTimeoutSlider->SetLimitLabels(B_TRANSLATE("Immediately"),
		B_TRANSLATE("Never"));
	fTimeoutSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fTimeoutSlider->SetHashMarkCount(kNumberOfTimeoutOptions);
	fTimeoutSlider->ResizeToPreferred();
	AddChild(fTimeoutSlider);

	_Layout();
}
void
DefaultPartitionPage::_Layout()
{
	LayoutDescriptionVertically(fDescription);

	const float kTextDistance = be_control_look->DefaultItemSpacing();
	float left = fDefaultPartition->Frame().left;
	float top = fDescription->Frame().bottom + kTextDistance;

	fDefaultPartition->MoveTo(left, top);
	top = fDefaultPartition->Frame().bottom + kTextDistance;

	fTimeoutSlider->MoveTo(left, top);
}