parent
e705c841d7
commit
8140719777
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de>
|
||||
*
|
||||
* Copyright 2010 Stephan Aßmus <superstippi@gmx.de>
|
||||
* Copyright 2019, Haiku, Inc.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#include "SettingsWindow.h"
|
||||
@ -176,7 +176,7 @@ SettingsWindow::MessageReceived(BMessage* message)
|
||||
break;
|
||||
case MSG_STANDARD_FONT_SIZE_SELECTED:
|
||||
{
|
||||
int32 size = _SizesMenuValue(fStandardSizesMenu->Menu());
|
||||
int32 size = fStandardSizesSpinner->Value();
|
||||
fStandardFontView->SetSize(size);
|
||||
fSerifFontView->SetSize(size);
|
||||
fSansSerifFontView->SetSize(size);
|
||||
@ -185,7 +185,7 @@ SettingsWindow::MessageReceived(BMessage* message)
|
||||
}
|
||||
case MSG_FIXED_FONT_SIZE_SELECTED:
|
||||
{
|
||||
int32 size = _SizesMenuValue(fFixedSizesMenu->Menu());
|
||||
int32 size = fFixedSizesSpinner->Value();
|
||||
fFixedFontView->SetSize(size);
|
||||
_ValidateControlsEnabledStatus();
|
||||
break;
|
||||
@ -397,26 +397,21 @@ SettingsWindow::_CreateFontsPage(float spacing)
|
||||
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);
|
||||
fStandardSizesMenu->SetAlignment(B_ALIGN_RIGHT);
|
||||
fStandardSizesSpinner = new BSpinner("standard font size",
|
||||
B_TRANSLATE("Default standard font size:"),
|
||||
new BMessage(MSG_STANDARD_FONT_SIZE_SELECTED));
|
||||
fStandardSizesSpinner->SetAlignment(B_ALIGN_RIGHT);
|
||||
|
||||
_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);
|
||||
fFixedSizesMenu->SetAlignment(B_ALIGN_RIGHT);
|
||||
|
||||
_BuildSizesMenu(fFixedSizesMenu->Menu(), MSG_FIXED_FONT_SIZE_SELECTED);
|
||||
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(fStandardSizesMenu->CreateLabelLayoutItem(), 2, 0)
|
||||
.Add(fStandardSizesMenu->CreateMenuBarLayoutItem(), 3, 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)
|
||||
@ -427,8 +422,8 @@ SettingsWindow::_CreateFontsPage(float spacing)
|
||||
.Add(BSpaceLayoutItem::CreateVerticalStrut(spacing / 2), 0, 6, 2)
|
||||
.Add(fFixedFontView->CreateFontsLabelLayoutItem(), 0, 7)
|
||||
.Add(fFixedFontView->CreateFontsMenuBarLayoutItem(), 1, 7)
|
||||
.Add(fFixedSizesMenu->CreateLabelLayoutItem(), 2, 7)
|
||||
.Add(fFixedSizesMenu->CreateMenuBarLayoutItem(), 3, 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)
|
||||
@ -507,33 +502,6 @@ SettingsWindow::_CreateProxyPage(float spacing)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsWindow::_BuildSizesMenu(BMenu* menu, uint32 messageWhat)
|
||||
{
|
||||
const float kMinSize = 8.0;
|
||||
const float kMaxSize = 18.0;
|
||||
|
||||
const int32 kSizes[] = {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 21, 24, 0};
|
||||
|
||||
for (int32 i = 0; kSizes[i]; i++) {
|
||||
int32 size = kSizes[i];
|
||||
if (size < kMinSize || size > kMaxSize)
|
||||
continue;
|
||||
|
||||
char label[32];
|
||||
snprintf(label, sizeof(label), "%" B_PRId32, size);
|
||||
|
||||
BMessage* message = new BMessage(messageWhat);
|
||||
message->AddInt32("size", size);
|
||||
|
||||
BMenuItem* item = new BMenuItem(label, message);
|
||||
|
||||
menu->AddItem(item);
|
||||
item->SetTarget(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsWindow::_SetupFontSelectionView(FontSelectionView* view,
|
||||
BMessage* message)
|
||||
@ -607,10 +575,10 @@ SettingsWindow::_CanApplySettings() const
|
||||
canApply = canApply || (fFixedFontView->Font()
|
||||
!= fSettings->GetValue("fixed font", *be_fixed_font));
|
||||
|
||||
canApply = canApply || (_SizesMenuValue(fStandardSizesMenu->Menu())
|
||||
canApply = canApply || (fStandardSizesSpinner->Value()
|
||||
!= fSettings->GetValue("standard font size", kDefaultFontSize));
|
||||
|
||||
canApply = canApply || (_SizesMenuValue(fFixedSizesMenu->Menu())
|
||||
canApply = canApply || (fFixedSizesSpinner->Value()
|
||||
!= fSettings->GetValue("fixed font size", kDefaultFontSize));
|
||||
|
||||
// Proxy settings
|
||||
@ -663,8 +631,8 @@ SettingsWindow::_ApplySettings()
|
||||
fSettings->SetValue("serif font", fSerifFontView->Font());
|
||||
fSettings->SetValue("sans serif font", fSansSerifFontView->Font());
|
||||
fSettings->SetValue("fixed font", fFixedFontView->Font());
|
||||
int32 standardFontSize = _SizesMenuValue(fStandardSizesMenu->Menu());
|
||||
int32 fixedFontSize = _SizesMenuValue(fFixedSizesMenu->Menu());
|
||||
int32 standardFontSize = fStandardSizesSpinner->Value();
|
||||
int32 fixedFontSize = fFixedSizesSpinner->Value();
|
||||
fSettings->SetValue("standard font size", standardFontSize);
|
||||
fSettings->SetValue("fixed font size", fixedFontSize);
|
||||
|
||||
@ -778,8 +746,8 @@ SettingsWindow::_RevertSettings()
|
||||
int32 defaultFixedFontSize = fSettings->GetValue("fixed font size",
|
||||
kDefaultFontSize);
|
||||
|
||||
_SetSizesMenuValue(fStandardSizesMenu->Menu(), defaultFontSize);
|
||||
_SetSizesMenuValue(fFixedSizesMenu->Menu(), defaultFixedFontSize);
|
||||
fStandardSizesSpinner->SetValue(defaultFontSize);
|
||||
fFixedSizesSpinner->SetValue(defaultFixedFontSize);
|
||||
|
||||
fStandardFontView->SetFont(fSettings->GetValue("standard font",
|
||||
*be_plain_font), defaultFontSize);
|
||||
@ -887,35 +855,6 @@ SettingsWindow::_NewTabPolicy() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsWindow::_SetSizesMenuValue(BMenu* menu, int32 value)
|
||||
{
|
||||
for (int32 i = 0; BMenuItem* item = menu->ItemAt(i); i++) {
|
||||
bool marked = false;
|
||||
if (BMessage* message = item->Message()) {
|
||||
int32 size;
|
||||
if (message->FindInt32("size", &size) == B_OK && size == value)
|
||||
marked = true;
|
||||
}
|
||||
item->SetMarked(marked);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
SettingsWindow::_SizesMenuValue(BMenu* menu) const
|
||||
{
|
||||
if (BMenuItem* item = menu->FindMarked()) {
|
||||
if (BMessage* message = item->Message()) {
|
||||
int32 size;
|
||||
if (message->FindInt32("size", &size) == B_OK)
|
||||
return size;
|
||||
}
|
||||
}
|
||||
return kDefaultFontSize;
|
||||
}
|
||||
|
||||
|
||||
BFont
|
||||
SettingsWindow::_FindDefaultSerifFont() const
|
||||
{
|
||||
|
@ -36,8 +36,6 @@ private:
|
||||
BView* _CreateGeneralPage(float spacing);
|
||||
BView* _CreateFontsPage(float spacing);
|
||||
BView* _CreateProxyPage(float spacing);
|
||||
void _BuildSizesMenu(BMenu* menu,
|
||||
uint32 messageWhat);
|
||||
void _SetupFontSelectionView(
|
||||
FontSelectionView* view,
|
||||
BMessage* message);
|
||||
@ -54,9 +52,6 @@ private:
|
||||
uint32 _NewWindowPolicy() const;
|
||||
uint32 _NewTabPolicy() const;
|
||||
|
||||
void _SetSizesMenuValue(BMenu* menu, int32 value);
|
||||
int32 _SizesMenuValue(BMenu* menu) const;
|
||||
|
||||
BFont _FindDefaultSerifFont() const;
|
||||
|
||||
uint32 _ProxyPort() const;
|
||||
@ -102,8 +97,8 @@ private:
|
||||
BButton* fRevertButton;
|
||||
BButton* fChooseButton;
|
||||
|
||||
BMenuField* fStandardSizesMenu;
|
||||
BMenuField* fFixedSizesMenu;
|
||||
BSpinner* fStandardSizesSpinner;
|
||||
BSpinner* fFixedSizesSpinner;
|
||||
|
||||
BFilePanel* fOpenFilePanel;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user