BView*
SettingsWindow::_CreateFontsPage(float spacing)
{
	fStandardFontView = new FontSelectionView("standard",
		B_TRANSLATE("Standard font:"), true, be_plain_font);
	BFont defaultSerifFont = _FindDefaultSerifFont();
	fSerifFontView = new FontSelectionView("serif",
		B_TRANSLATE("Serif font:"), true, &defaultSerifFont);
	fSansSerifFontView = new FontSelectionView("sans serif",
		B_TRANSLATE("Sans serif font:"), true, be_plain_font);
	fFixedFontView = new FontSelectionView("fixed",
		B_TRANSLATE("Fixed font:"), true, be_fixed_font);

	fStandardSizesMenu =  new BMenuField("standard font size",
		B_TRANSLATE("Default standard font size:"), new BPopUpMenu("sizes"),
		B_WILL_DRAW);
	_BuildSizesMenu(fStandardSizesMenu->Menu(),
		MSG_STANDARD_FONT_SIZE_SELECTED);

	fFixedSizesMenu =  new BMenuField("fixed font size",
		B_TRANSLATE("Default fixed font size:"), new BPopUpMenu("sizes"),
		B_WILL_DRAW);
	_BuildSizesMenu(fFixedSizesMenu->Menu(), MSG_FIXED_FONT_SIZE_SELECTED);

	BView* view = BGridLayoutBuilder(spacing / 2, spacing / 2)
		.Add(fStandardFontView->CreateFontsLabelLayoutItem(), 0, 0)
		.Add(fStandardFontView->CreateFontsMenuBarLayoutItem(), 1, 0)
		.Add(fStandardFontView->PreviewBox(), 0, 1, 2)
		.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 0, 2, 2)

		.Add(fSerifFontView->CreateFontsLabelLayoutItem(), 0, 3)
		.Add(fSerifFontView->CreateFontsMenuBarLayoutItem(), 1, 3)
		.Add(fSerifFontView->PreviewBox(), 0, 4, 2)
		.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 0, 5, 2)

		.Add(fSansSerifFontView->CreateFontsLabelLayoutItem(), 0, 6)
		.Add(fSansSerifFontView->CreateFontsMenuBarLayoutItem(), 1, 6)
		.Add(fSansSerifFontView->PreviewBox(), 0, 7, 2)
		.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 0, 8, 2)

		.Add(fFixedFontView->CreateFontsLabelLayoutItem(), 0, 9)
		.Add(fFixedFontView->CreateFontsMenuBarLayoutItem(), 1, 9)
		.Add(fFixedFontView->PreviewBox(), 0, 10, 2)
		.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 0, 11, 2)

		.Add(fStandardSizesMenu->CreateLabelLayoutItem(), 0, 12)
		.Add(fStandardSizesMenu->CreateMenuBarLayoutItem(), 1, 12)
		.Add(fFixedSizesMenu->CreateLabelLayoutItem(), 0, 13)
		.Add(fFixedSizesMenu->CreateMenuBarLayoutItem(), 1, 13)

		.SetInsets(spacing, spacing, spacing, spacing)

		.View()
	;

	view->SetName(B_TRANSLATE("Fonts"));
	return view;
}
Esempio n. 2
0
BView*
SettingsWindow::_CreateFontsPage(float spacing)
{
	fStandardFontView = new FontSelectionView("standard",
		B_TRANSLATE("Standard font:"), true, be_plain_font);
	BFont defaultSerifFont = _FindDefaultSerifFont();
	fSerifFontView = new FontSelectionView("serif",
		B_TRANSLATE("Serif font:"), true, &defaultSerifFont);
	fSansSerifFontView = new FontSelectionView("sans serif",
		B_TRANSLATE("Sans serif font:"), true, be_plain_font);
	fFixedFontView = new FontSelectionView("fixed",
		B_TRANSLATE("Fixed font:"), true, be_fixed_font);

	fStandardSizesSpinner = new BSpinner("standard font size",
		B_TRANSLATE("Default standard font size:"),
		new BMessage(MSG_STANDARD_FONT_SIZE_SELECTED));
	fStandardSizesSpinner->SetAlignment(B_ALIGN_RIGHT);

	fFixedSizesSpinner = new BSpinner("fixed font size",
		B_TRANSLATE("Default fixed font size:"),
		new BMessage(MSG_FIXED_FONT_SIZE_SELECTED));
	fFixedSizesSpinner->SetAlignment(B_ALIGN_RIGHT);

	BView* view = BGridLayoutBuilder(spacing / 2, spacing / 2)
		.Add(fStandardFontView->CreateFontsLabelLayoutItem(), 0, 0)
		.Add(fStandardFontView->CreateFontsMenuBarLayoutItem(), 1, 0)
		.Add(fStandardSizesSpinner->CreateLabelLayoutItem(), 2, 0)
		.Add(fStandardSizesSpinner->CreateTextViewLayoutItem(), 3, 0)
		.Add(fStandardFontView->PreviewBox(), 1, 1, 3)
		.Add(fSerifFontView->CreateFontsLabelLayoutItem(), 0, 2)
		.Add(fSerifFontView->CreateFontsMenuBarLayoutItem(), 1, 2)
		.Add(fSerifFontView->PreviewBox(), 1, 3, 3)
		.Add(fSansSerifFontView->CreateFontsLabelLayoutItem(), 0, 4)
		.Add(fSansSerifFontView->CreateFontsMenuBarLayoutItem(), 1, 4)
		.Add(fSansSerifFontView->PreviewBox(), 1, 5, 3)
		.Add(BSpaceLayoutItem::CreateVerticalStrut(spacing / 2), 0, 6, 2)
		.Add(fFixedFontView->CreateFontsLabelLayoutItem(), 0, 7)
		.Add(fFixedFontView->CreateFontsMenuBarLayoutItem(), 1, 7)
		.Add(fFixedSizesSpinner->CreateLabelLayoutItem(), 2, 7)
		.Add(fFixedSizesSpinner->CreateTextViewLayoutItem(), 3, 7)
		.Add(fFixedFontView->PreviewBox(), 1, 8, 3)
		.SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
			B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING)
		.View();

	view->SetName(B_TRANSLATE("Fonts"));
	return view;
}
void
SettingsWindow::_RevertSettings()
{
	fStartPageControl->SetText(
		fSettings->GetValue(kSettingsKeyStartPageURL, kDefaultStartPageURL));

	fSearchPageControl->SetText(
		fSettings->GetValue(kSettingsKeySearchPageURL, kDefaultSearchPageURL));

	fDownloadFolderControl->SetText(
		fSettings->GetValue(kSettingsKeyDownloadPath, kDefaultDownloadPath));
	fShowTabsIfOnlyOnePage->SetValue(
		fSettings->GetValue(kSettingsKeyShowTabsIfSinglePageOpen, true));
	fAutoHideInterfaceInFullscreenMode->SetValue(
		fSettings->GetValue(kSettingsKeyAutoHideInterfaceInFullscreenMode,
			false));
	fAutoHidePointer->SetValue(
		fSettings->GetValue(kSettingsKeyAutoHidePointer, false));
	fShowHomeButton->SetValue(
		fSettings->GetValue(kSettingsKeyShowHomeButton, true));

	BString text;
	text << BrowsingHistory::DefaultInstance()->MaxHistoryItemAge();
	fDaysInHistoryMenuControl->SetText(text.String());

	// New window policy
	uint32 newWindowPolicy = fSettings->GetValue(kSettingsKeyNewWindowPolicy,
		(uint32)OpenStartPage);
	switch (newWindowPolicy) {
		default:
		case OpenStartPage:
			fNewWindowBehaviorOpenHomeItem->SetMarked(true);
			break;
		case OpenSearchPage:
			fNewWindowBehaviorOpenSearchItem->SetMarked(true);
			break;
		case OpenBlankPage:
			fNewWindowBehaviorOpenBlankItem->SetMarked(true);
			break;
	}

	// New tab policy
	uint32 newTabPolicy = fSettings->GetValue(kSettingsKeyNewTabPolicy,
		(uint32)OpenBlankPage);
	switch (newTabPolicy) {
		default:
		case OpenBlankPage:
			fNewTabBehaviorOpenBlankItem->SetMarked(true);
			break;
		case OpenStartPage:
			fNewTabBehaviorOpenHomeItem->SetMarked(true);
			break;
		case OpenSearchPage:
			fNewTabBehaviorOpenSearchItem->SetMarked(true);
			break;
		case CloneCurrentPage:
			fNewTabBehaviorCloneCurrentItem->SetMarked(true);
			break;
	}

	// Font settings
	int32 defaultFontSize = fSettings->GetValue("standard font size",
		kDefaultFontSize);
	int32 defaultFixedFontSize = fSettings->GetValue("fixed font size",
		kDefaultFontSize);

	_SetSizesMenuValue(fStandardSizesMenu->Menu(), defaultFontSize);
	_SetSizesMenuValue(fFixedSizesMenu->Menu(), defaultFixedFontSize);

	fStandardFontView->SetFont(fSettings->GetValue("standard font",
		*be_plain_font), defaultFontSize);
	fSerifFontView->SetFont(fSettings->GetValue("serif font",
		_FindDefaultSerifFont()), defaultFontSize);
	fSansSerifFontView->SetFont(fSettings->GetValue("sans serif font",
		*be_plain_font), defaultFontSize);
	fFixedFontView->SetFont(fSettings->GetValue("fixed font",
		*be_fixed_font), defaultFixedFontSize);

	// Proxy settings
	fUseProxyCheckBox->SetValue(fSettings->GetValue(kSettingsKeyUseProxy,
		false));
	fProxyAddressControl->SetText(fSettings->GetValue(kSettingsKeyProxyAddress,
		""));
	text = "";
	text << fSettings->GetValue(kSettingsKeyProxyPort, (uint32)0);
	fProxyPortControl->SetText(text.String());
	fUseProxyAuthCheckBox->SetValue(fSettings->GetValue(kSettingsKeyUseProxyAuth,
		false));
	fProxyUsernameControl->SetText(fSettings->GetValue(kSettingsKeyProxyUsername,
		""));
	fProxyPasswordControl->SetText(fSettings->GetValue(kSettingsKeyProxyPassword,
		""));

	_ValidateControlsEnabledStatus();
}
bool
SettingsWindow::_CanApplySettings() const
{
	bool canApply = false;

	// General settings
	canApply = canApply || (strcmp(fStartPageControl->Text(),
		fSettings->GetValue(kSettingsKeyStartPageURL,
			kDefaultStartPageURL)) != 0);

	canApply = canApply || (strcmp(fSearchPageControl->Text(),
		fSettings->GetValue(kSettingsKeySearchPageURL,
			kDefaultSearchPageURL)) != 0);

	canApply = canApply || (strcmp(fDownloadFolderControl->Text(),
		fSettings->GetValue(kSettingsKeyDownloadPath,
			kDefaultDownloadPath)) != 0);

	canApply = canApply || ((fShowTabsIfOnlyOnePage->Value() == B_CONTROL_ON)
		!= fSettings->GetValue(kSettingsKeyShowTabsIfSinglePageOpen, true));

	canApply = canApply || (
		(fAutoHideInterfaceInFullscreenMode->Value() == B_CONTROL_ON)
		!= fSettings->GetValue(kSettingsKeyAutoHideInterfaceInFullscreenMode,
			false));

	canApply = canApply || (
		(fAutoHidePointer->Value() == B_CONTROL_ON)
		!= fSettings->GetValue(kSettingsKeyAutoHidePointer, false));

	canApply = canApply || ((fShowHomeButton->Value() == B_CONTROL_ON)
		!= fSettings->GetValue(kSettingsKeyShowHomeButton, true));

	canApply = canApply || (_MaxHistoryAge()
		!= BrowsingHistory::DefaultInstance()->MaxHistoryItemAge());

	// New window policy
	canApply = canApply || (_NewWindowPolicy()
		!= fSettings->GetValue(kSettingsKeyNewWindowPolicy,
			(uint32)OpenStartPage));

	// New tab policy
	canApply = canApply || (_NewTabPolicy()
		!= fSettings->GetValue(kSettingsKeyNewTabPolicy,
			(uint32)OpenBlankPage));

	// Font settings
	canApply = canApply || (fStandardFontView->Font()
		!= fSettings->GetValue("standard font", *be_plain_font));

	canApply = canApply || (fSerifFontView->Font()
		!= fSettings->GetValue("serif font", _FindDefaultSerifFont()));

	canApply = canApply || (fSansSerifFontView->Font()
		!= fSettings->GetValue("sans serif font", *be_plain_font));

	canApply = canApply || (fFixedFontView->Font()
		!= fSettings->GetValue("fixed font", *be_fixed_font));

	canApply = canApply || (_SizesMenuValue(fStandardSizesMenu->Menu())
		!= fSettings->GetValue("standard font size", kDefaultFontSize));

	canApply = canApply || (_SizesMenuValue(fFixedSizesMenu->Menu())
		!= fSettings->GetValue("fixed font size", kDefaultFontSize));

	// Proxy settings
	canApply = canApply || ((fUseProxyCheckBox->Value() == B_CONTROL_ON)
		!= fSettings->GetValue(kSettingsKeyUseProxy, false));

	canApply = canApply || (strcmp(fProxyAddressControl->Text(),
		fSettings->GetValue(kSettingsKeyProxyAddress, "")) != 0);

	canApply = canApply || (_ProxyPort()
		!= fSettings->GetValue(kSettingsKeyProxyPort, (uint32)0));

	canApply = canApply || ((fUseProxyAuthCheckBox->Value() == B_CONTROL_ON)
		!= fSettings->GetValue(kSettingsKeyUseProxyAuth, false));

	canApply = canApply || (strcmp(fProxyUsernameControl->Text(),
		fSettings->GetValue(kSettingsKeyProxyUsername, "")) != 0);

	canApply = canApply || (strcmp(fProxyPasswordControl->Text(),
		fSettings->GetValue(kSettingsKeyProxyPassword, "")) != 0);

	return canApply;
}