First steps to make the "Menu" preferences superfluous (just what will we do
with its fine icon?): * Added the menu font setting to the Fonts preferences app. * Made the window resizable at least in the horizontal direction. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29774 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -67,11 +67,27 @@ _get_system_default_font_(const char* which, font_family family,
|
|||||||
|
|
||||||
|
|
||||||
FontSelectionView::FontSelectionView(BRect _rect, const char* name,
|
FontSelectionView::FontSelectionView(BRect _rect, const char* name,
|
||||||
const char* label, const BFont& currentFont)
|
const char* label, const BFont* currentFont)
|
||||||
: BView(_rect, name, B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW),
|
: BView(_rect, name, B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW),
|
||||||
fSavedFont(currentFont),
|
fSavedFont(currentFont)
|
||||||
fCurrentFont(currentFont)
|
|
||||||
{
|
{
|
||||||
|
if (currentFont == NULL) {
|
||||||
|
if (!strcmp(Name(), "plain"))
|
||||||
|
fCurrentFont = *be_plain_font;
|
||||||
|
else if (!strcmp(Name(), "bold"))
|
||||||
|
fCurrentFont = *be_bold_font;
|
||||||
|
else if (!strcmp(Name(), "fixed"))
|
||||||
|
fCurrentFont = *be_fixed_font;
|
||||||
|
else if (!strcmp(Name(), "menu")) {
|
||||||
|
menu_info info;
|
||||||
|
get_menu_info(&info);
|
||||||
|
|
||||||
|
fCurrentFont.SetFamilyAndStyle(info.f_family, info.f_style);
|
||||||
|
fCurrentFont.SetSize(info.font_size);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
fCurrentFont = *currentFont;
|
||||||
|
|
||||||
fDivider = StringWidth(label) + 5;
|
fDivider = StringWidth(label) + 5;
|
||||||
|
|
||||||
fSizesMenu = new BPopUpMenu("size menu");
|
fSizesMenu = new BPopUpMenu("size menu");
|
||||||
@@ -90,7 +106,7 @@ FontSelectionView::FontSelectionView(BRect _rect, const char* name,
|
|||||||
// size menu
|
// size menu
|
||||||
rect.right = rect.left + StringWidth("Size: 99") + 30.0f;
|
rect.right = rect.left + StringWidth("Size: 99") + 30.0f;
|
||||||
fSizesMenuField = new BMenuField(rect, "sizes", "Size:", fSizesMenu, true,
|
fSizesMenuField = new BMenuField(rect, "sizes", "Size:", fSizesMenu, true,
|
||||||
B_FOLLOW_TOP);
|
B_FOLLOW_TOP | B_FOLLOW_RIGHT);
|
||||||
fSizesMenuField->SetDivider(StringWidth(fSizesMenuField->Label()) + 5.0f);
|
fSizesMenuField->SetDivider(StringWidth(fSizesMenuField->Label()) + 5.0f);
|
||||||
fSizesMenuField->SetAlignment(B_ALIGN_RIGHT);
|
fSizesMenuField->SetAlignment(B_ALIGN_RIGHT);
|
||||||
fSizesMenuField->ResizeToPreferred();
|
fSizesMenuField->ResizeToPreferred();
|
||||||
@@ -104,7 +120,8 @@ FontSelectionView::FontSelectionView(BRect _rect, const char* name,
|
|||||||
font.SetSize(kMaxSize);
|
font.SetSize(kMaxSize);
|
||||||
font_height height;
|
font_height height;
|
||||||
font.GetHeight(&height);
|
font.GetHeight(&height);
|
||||||
rect.bottom = rect.top + ceil(height.ascent + height.descent + height.leading) + 5;
|
rect.bottom = rect.top + ceil(height.ascent + height.descent
|
||||||
|
+ height.leading) + 5;
|
||||||
|
|
||||||
fPreviewBox = new BBox(rect, "preview", B_FOLLOW_LEFT_RIGHT,
|
fPreviewBox = new BBox(rect, "preview", B_FOLLOW_LEFT_RIGHT,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS);
|
B_WILL_DRAW | B_FRAME_EVENTS);
|
||||||
@@ -343,7 +360,18 @@ FontSelectionView::_UpdateSystemFont()
|
|||||||
font_style style;
|
font_style style;
|
||||||
fCurrentFont.GetFamilyAndStyle(&family, &style);
|
fCurrentFont.GetFamilyAndStyle(&family, &style);
|
||||||
|
|
||||||
_set_system_font_(Name(), family, style, fCurrentFont.Size());
|
if (!strcmp(Name(), "menu")) {
|
||||||
|
// The menu font is not handled as a system font
|
||||||
|
menu_info info;
|
||||||
|
get_menu_info(&info);
|
||||||
|
|
||||||
|
strlcpy(info.f_family, (const char*)family, B_FONT_FAMILY_LENGTH);
|
||||||
|
strlcpy(info.f_style, (const char*)style, B_FONT_STYLE_LENGTH);
|
||||||
|
info.font_size = fCurrentFont.Size();
|
||||||
|
|
||||||
|
set_menu_info(&info);
|
||||||
|
} else
|
||||||
|
_set_system_font_(Name(), family, style, fCurrentFont.Size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -470,7 +498,8 @@ FontSelectionView::UpdateFontsMenu()
|
|||||||
|
|
||||||
BMenuItem *item = new BMenuItem(style, message);
|
BMenuItem *item = new BMenuItem(style, message);
|
||||||
|
|
||||||
if (!strcmp(style, currentStyle) && !strcmp(family, currentFamily)) {
|
if (!strcmp(style, currentStyle)
|
||||||
|
&& !strcmp(family, currentFamily)) {
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
familyItem->SetMarked(true);
|
familyItem->SetMarked(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -20,46 +20,46 @@ class BStringView;
|
|||||||
|
|
||||||
|
|
||||||
class FontSelectionView : public BView {
|
class FontSelectionView : public BView {
|
||||||
public:
|
public:
|
||||||
FontSelectionView(BRect rect, const char* name, const char* label,
|
FontSelectionView(BRect rect, const char* name,
|
||||||
const BFont& currentFont);
|
const char* label, const BFont* font = NULL);
|
||||||
virtual ~FontSelectionView();
|
virtual ~FontSelectionView();
|
||||||
|
|
||||||
virtual void GetPreferredSize(float *_width, float *_height);
|
virtual void GetPreferredSize(float *_width, float *_height);
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void MessageReceived(BMessage *msg);
|
virtual void MessageReceived(BMessage *msg);
|
||||||
|
|
||||||
void SetDivider(float divider);
|
void SetDivider(float divider);
|
||||||
void RelayoutIfNeeded();
|
void RelayoutIfNeeded();
|
||||||
|
|
||||||
void SetDefaults();
|
void SetDefaults();
|
||||||
void Revert();
|
void Revert();
|
||||||
bool IsDefaultable();
|
bool IsDefaultable();
|
||||||
bool IsRevertable();
|
bool IsRevertable();
|
||||||
|
|
||||||
void UpdateFontsMenu();
|
void UpdateFontsMenu();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _SelectCurrentFont(bool select);
|
void _SelectCurrentFont(bool select);
|
||||||
void _SelectCurrentSize(bool select);
|
void _SelectCurrentSize(bool select);
|
||||||
void _UpdateFontPreview();
|
void _UpdateFontPreview();
|
||||||
void _UpdateSystemFont();
|
void _UpdateSystemFont();
|
||||||
void _BuildSizesMenu();
|
void _BuildSizesMenu();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float fDivider;
|
float fDivider;
|
||||||
|
|
||||||
BMenuField* fFontsMenuField;
|
BMenuField* fFontsMenuField;
|
||||||
BMenuField* fSizesMenuField;
|
BMenuField* fSizesMenuField;
|
||||||
BPopUpMenu* fFontsMenu;
|
BPopUpMenu* fFontsMenu;
|
||||||
BPopUpMenu* fSizesMenu;
|
BPopUpMenu* fSizesMenu;
|
||||||
|
|
||||||
BBox* fPreviewBox;
|
BBox* fPreviewBox;
|
||||||
BStringView* fPreviewText;
|
BStringView* fPreviewText;
|
||||||
|
|
||||||
BFont fSavedFont;
|
BFont fSavedFont;
|
||||||
BFont fCurrentFont;
|
BFont fCurrentFont;
|
||||||
float fMaxFontNameWidth;
|
float fMaxFontNameWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FONT_SELECTION_VIEW_H */
|
#endif /* FONT_SELECTION_VIEW_H */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -20,22 +20,28 @@ FontView::FontView(BRect _rect)
|
|||||||
|
|
||||||
float labelWidth = StringWidth("Fixed Font:") + 8;
|
float labelWidth = StringWidth("Fixed Font:") + 8;
|
||||||
|
|
||||||
fPlainView = new FontSelectionView(rect, "plain", "Plain Font:", *be_plain_font);
|
fPlainView = new FontSelectionView(rect, "plain", "Plain Font:");
|
||||||
fPlainView->SetDivider(labelWidth);
|
fPlainView->SetDivider(labelWidth);
|
||||||
fPlainView->ResizeToPreferred();
|
fPlainView->ResizeToPreferred();
|
||||||
AddChild(fPlainView);
|
AddChild(fPlainView);
|
||||||
|
|
||||||
rect.OffsetBy(0, fPlainView->Bounds().Height() + 10);
|
rect.OffsetBy(0, fPlainView->Bounds().Height() + 10);
|
||||||
fBoldView = new FontSelectionView(rect, "bold", "Bold Font:", *be_bold_font);
|
fBoldView = new FontSelectionView(rect, "bold", "Bold Font:");
|
||||||
fBoldView->SetDivider(labelWidth);
|
fBoldView->SetDivider(labelWidth);
|
||||||
fBoldView->ResizeToPreferred();
|
fBoldView->ResizeToPreferred();
|
||||||
AddChild(fBoldView);
|
AddChild(fBoldView);
|
||||||
|
|
||||||
rect.OffsetBy(0, fPlainView->Bounds().Height() + 10);
|
rect.OffsetBy(0, fPlainView->Bounds().Height() + 10);
|
||||||
fFixedView = new FontSelectionView(rect, "fixed", "Fixed Font:", *be_fixed_font);
|
fFixedView = new FontSelectionView(rect, "fixed", "Fixed Font:");
|
||||||
fFixedView->SetDivider(labelWidth);
|
fFixedView->SetDivider(labelWidth);
|
||||||
fFixedView->ResizeToPreferred();
|
fFixedView->ResizeToPreferred();
|
||||||
AddChild(fFixedView);
|
AddChild(fFixedView);
|
||||||
|
|
||||||
|
rect.OffsetBy(0, fFixedView->Bounds().Height() + 10);
|
||||||
|
fMenuView = new FontSelectionView(rect, "menu", "Menu Font:");
|
||||||
|
fMenuView->SetDivider(labelWidth);
|
||||||
|
fMenuView->ResizeToPreferred();
|
||||||
|
AddChild(fMenuView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -46,7 +52,7 @@ FontView::GetPreferredSize(float *_width, float *_height)
|
|||||||
*_width = fPlainView->Bounds().Width();
|
*_width = fPlainView->Bounds().Width();
|
||||||
|
|
||||||
if (_height)
|
if (_height)
|
||||||
*_height = fPlainView->Bounds().Height() * 3 + 20;
|
*_height = fPlainView->Bounds().Height() * 4 + 40;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -82,6 +88,7 @@ FontView::UpdateFonts()
|
|||||||
fPlainView->UpdateFontsMenu();
|
fPlainView->UpdateFontsMenu();
|
||||||
fBoldView->UpdateFontsMenu();
|
fBoldView->UpdateFontsMenu();
|
||||||
fFixedView->UpdateFontsMenu();
|
fFixedView->UpdateFontsMenu();
|
||||||
|
fMenuView->UpdateFontsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -91,21 +98,26 @@ FontView::RelayoutIfNeeded()
|
|||||||
fPlainView->RelayoutIfNeeded();
|
fPlainView->RelayoutIfNeeded();
|
||||||
fBoldView->RelayoutIfNeeded();
|
fBoldView->RelayoutIfNeeded();
|
||||||
fFixedView->RelayoutIfNeeded();
|
fFixedView->RelayoutIfNeeded();
|
||||||
|
fMenuView->RelayoutIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FontView::IsDefaultable()
|
FontView::IsDefaultable()
|
||||||
{
|
{
|
||||||
return fPlainView->IsDefaultable()
|
return fPlainView->IsDefaultable()
|
||||||
|| fBoldView->IsDefaultable()
|
|| fBoldView->IsDefaultable()
|
||||||
|| fFixedView->IsDefaultable();
|
|| fFixedView->IsDefaultable()
|
||||||
|
|| fMenuView->IsDefaultable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FontView::IsRevertable()
|
FontView::IsRevertable()
|
||||||
{
|
{
|
||||||
return fPlainView->IsRevertable()
|
return fPlainView->IsRevertable()
|
||||||
|| fBoldView->IsRevertable()
|
|| fBoldView->IsRevertable()
|
||||||
|| fFixedView->IsRevertable();
|
|| fFixedView->IsRevertable()
|
||||||
|
|| fMenuView->IsRevertable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -15,23 +15,24 @@
|
|||||||
|
|
||||||
|
|
||||||
class FontView : public BView {
|
class FontView : public BView {
|
||||||
public:
|
public:
|
||||||
FontView(BRect frame);
|
FontView(BRect frame);
|
||||||
|
|
||||||
virtual void GetPreferredSize(float *_width, float *_height);
|
virtual void GetPreferredSize(float *_width, float *_height);
|
||||||
|
|
||||||
void SetDefaults();
|
void SetDefaults();
|
||||||
void Revert();
|
void Revert();
|
||||||
void UpdateFonts();
|
void UpdateFonts();
|
||||||
void RelayoutIfNeeded();
|
void RelayoutIfNeeded();
|
||||||
|
|
||||||
bool IsDefaultable();
|
bool IsDefaultable();
|
||||||
bool IsRevertable();
|
bool IsRevertable();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FontSelectionView *fPlainView;
|
FontSelectionView* fPlainView;
|
||||||
FontSelectionView *fBoldView;
|
FontSelectionView* fBoldView;
|
||||||
FontSelectionView *fFixedView;
|
FontSelectionView* fFixedView;
|
||||||
|
FontSelectionView* fMenuView;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FONT_VIEW_H */
|
#endif /* FONT_VIEW_H */
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ static const uint32 kMsgCheckFonts = 'chkf';
|
|||||||
|
|
||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow()
|
||||||
: BWindow(BRect(100, 100, 445, 410), "Fonts", B_TITLED_WINDOW,
|
: BWindow(BRect(100, 100, 445, 410), "Fonts", B_TITLED_WINDOW,
|
||||||
B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
|
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
|
||||||
{
|
{
|
||||||
BRect rect = Bounds();
|
BRect rect = Bounds();
|
||||||
BView* view = new BView(rect, "background", B_FOLLOW_ALL, B_WILL_DRAW);
|
BView* view = new BView(rect, "background", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
@@ -89,6 +89,9 @@ MainWindow::MainWindow()
|
|||||||
+ buttonHeight);
|
+ buttonHeight);
|
||||||
view->AddChild(tabView);
|
view->AddChild(tabView);
|
||||||
fFontsView->ResizeToPreferred();
|
fFontsView->ResizeToPreferred();
|
||||||
|
|
||||||
|
SetSizeLimits(Bounds().Width(), 16347,
|
||||||
|
Bounds().Height(), Bounds().Height());
|
||||||
|
|
||||||
if (fSettings.WindowCorner() == BPoint(-1, -1)) {
|
if (fSettings.WindowCorner() == BPoint(-1, -1)) {
|
||||||
// center window on screen
|
// center window on screen
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -21,22 +21,22 @@ class FontView;
|
|||||||
|
|
||||||
|
|
||||||
class MainWindow : public BWindow {
|
class MainWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
MainWindow();
|
||||||
virtual ~MainWindow();
|
virtual ~MainWindow();
|
||||||
|
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _Center();
|
void _Center();
|
||||||
|
|
||||||
BMessageRunner* fRunner;
|
BMessageRunner* fRunner;
|
||||||
FontView* fFontsView;
|
FontView* fFontsView;
|
||||||
BButton* fDefaultsButton;
|
BButton* fDefaultsButton;
|
||||||
BButton* fRevertButton;
|
BButton* fRevertButton;
|
||||||
|
|
||||||
FontsSettings fSettings;
|
FontsSettings fSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int32 kMsgUpdate = 'updt';
|
static const int32 kMsgUpdate = 'updt';
|
||||||
|
|||||||
Reference in New Issue
Block a user