Delete fonts preferences.
It was merged into Appearance.
This commit is contained in:
parent
55f5f25940
commit
2a70d7d0e1
@ -6,7 +6,6 @@ SubInclude HAIKU_TOP src preferences bluetooth ;
|
||||
SubInclude HAIKU_TOP src preferences datatranslations ;
|
||||
SubInclude HAIKU_TOP src preferences deskbar ;
|
||||
SubInclude HAIKU_TOP src preferences filetypes ;
|
||||
SubInclude HAIKU_TOP src preferences fonts ;
|
||||
SubInclude HAIKU_TOP src preferences joysticks ;
|
||||
SubInclude HAIKU_TOP src preferences keyboard ;
|
||||
SubInclude HAIKU_TOP src preferences keymap ;
|
||||
|
@ -1,480 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001-2011, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Mark Hogben
|
||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
* Philippe Saint-Pierre, stpere@gmail.com
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
*/
|
||||
|
||||
#include "FontSelectionView.h"
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include <Box.h>
|
||||
#include <Catalog.h>
|
||||
#include <Locale.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <String.h>
|
||||
#include <StringView.h>
|
||||
#include <LayoutItem.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "Font Selection view"
|
||||
|
||||
|
||||
#define INSTANT_UPDATE
|
||||
// if defined, the system font will be updated immediately, and not
|
||||
// only on exit
|
||||
|
||||
static const float kMinSize = 8.0;
|
||||
static const float kMaxSize = 18.0;
|
||||
|
||||
|
||||
// private font API
|
||||
extern void _set_system_font_(const char *which, font_family family,
|
||||
font_style style, float size);
|
||||
extern status_t _get_system_default_font_(const char* which,
|
||||
font_family family, font_style style, float* _size);
|
||||
|
||||
|
||||
#ifdef B_BEOS_VERSION_DANO
|
||||
// this call only exists under R5
|
||||
void
|
||||
_set_system_font_(const char *which, font_family family,
|
||||
font_style style, float size)
|
||||
{
|
||||
puts("you don't have _set_system_font_()");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(HAIKU_TARGET_PLATFORM_HAIKU) && !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
|
||||
// this call only exists under Haiku (and the test environment)
|
||||
status_t
|
||||
_get_system_default_font_(const char* which, font_family family,
|
||||
font_style style, float* _size)
|
||||
{
|
||||
puts("you don't have _get_system_default_font_()");
|
||||
return B_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
FontSelectionView::FontSelectionView(const char* name,
|
||||
const char* label, const BFont* currentFont)
|
||||
: BView(name, B_WILL_DRAW)
|
||||
{
|
||||
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;
|
||||
|
||||
fSavedFont = fCurrentFont;
|
||||
|
||||
fSizesMenu = new BPopUpMenu("size menu");
|
||||
_BuildSizesMenu();
|
||||
|
||||
fFontsMenu = new BPopUpMenu("font menu");
|
||||
|
||||
// font menu
|
||||
fFontsMenuField = new BMenuField("fonts", label, fFontsMenu);
|
||||
fFontsMenuField->SetAlignment(B_ALIGN_RIGHT);
|
||||
|
||||
// size menu
|
||||
fSizesMenuField = new BMenuField("size", B_TRANSLATE("Size:"), fSizesMenu);
|
||||
fSizesMenuField->SetAlignment(B_ALIGN_RIGHT);
|
||||
|
||||
// preview
|
||||
fPreviewText = new BStringView("preview text",
|
||||
B_TRANSLATE_COMMENT("The quick brown fox jumps over the lazy dog.",
|
||||
"Don't translate this literally ! Use a phrase showing all chars "
|
||||
"from A to Z."));
|
||||
|
||||
fPreviewText->SetFont(&fCurrentFont);
|
||||
fPreviewText->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||
|
||||
// box around preview
|
||||
fPreviewBox = new BBox("preview box", B_WILL_DRAW | B_FRAME_EVENTS);
|
||||
fPreviewBox->AddChild(BGroupLayoutBuilder(B_HORIZONTAL)
|
||||
.Add(fPreviewText)
|
||||
.SetInsets(5, 5, 5, 5)
|
||||
.TopView()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
FontSelectionView::~FontSelectionView()
|
||||
{
|
||||
#ifndef INSTANT_UPDATE
|
||||
_UpdateSystemFont();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
BView*
|
||||
FontSelectionView::GetPreviewBox()
|
||||
{
|
||||
return fPreviewBox;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontSelectionView::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch (msg->what) {
|
||||
case kMsgSetSize:
|
||||
{
|
||||
int32 size;
|
||||
if (msg->FindInt32("size", &size) != B_OK
|
||||
|| size == fCurrentFont.Size())
|
||||
break;
|
||||
|
||||
fCurrentFont.SetSize(size);
|
||||
_UpdateFontPreview();
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgSetFamily:
|
||||
{
|
||||
const char* family;
|
||||
if (msg->FindString("family", &family) != B_OK)
|
||||
break;
|
||||
|
||||
font_style style;
|
||||
fCurrentFont.GetFamilyAndStyle(NULL, &style);
|
||||
|
||||
BMenuItem *familyItem = fFontsMenu->FindItem(family);
|
||||
if (familyItem != NULL) {
|
||||
_SelectCurrentFont(false);
|
||||
|
||||
BMenuItem *item = familyItem->Submenu()->FindItem(style);
|
||||
if (item == NULL)
|
||||
item = familyItem->Submenu()->ItemAt(0);
|
||||
|
||||
if (item != NULL) {
|
||||
item->SetMarked(true);
|
||||
fCurrentFont.SetFamilyAndStyle(family, item->Label());
|
||||
_UpdateFontPreview();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgSetStyle:
|
||||
{
|
||||
const char* family;
|
||||
const char* style;
|
||||
if (msg->FindString("family", &family) != B_OK
|
||||
|| msg->FindString("style", &style) != B_OK)
|
||||
break;
|
||||
|
||||
BMenuItem *familyItem = fFontsMenu->FindItem(family);
|
||||
if (!familyItem)
|
||||
break;
|
||||
|
||||
_SelectCurrentFont(false);
|
||||
familyItem->SetMarked(true);
|
||||
|
||||
fCurrentFont.SetFamilyAndStyle(family, style);
|
||||
_UpdateFontPreview();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BView::MessageReceived(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BLayoutItem*
|
||||
FontSelectionView::CreateSizesLabelLayoutItem()
|
||||
{
|
||||
return fSizesMenuField->CreateLabelLayoutItem();
|
||||
}
|
||||
|
||||
|
||||
BLayoutItem*
|
||||
FontSelectionView::CreateSizesMenuBarLayoutItem()
|
||||
{
|
||||
return fSizesMenuField->CreateMenuBarLayoutItem();
|
||||
}
|
||||
|
||||
|
||||
BLayoutItem*
|
||||
FontSelectionView::CreateFontsLabelLayoutItem()
|
||||
{
|
||||
return fFontsMenuField->CreateLabelLayoutItem();
|
||||
}
|
||||
|
||||
|
||||
BLayoutItem*
|
||||
FontSelectionView::CreateFontsMenuBarLayoutItem()
|
||||
{
|
||||
return fFontsMenuField->CreateMenuBarLayoutItem();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontSelectionView::_BuildSizesMenu()
|
||||
{
|
||||
const int32 sizes[] = {7, 8, 9, 10, 11, 12, 13, 14, 18, 21, 24, 0};
|
||||
|
||||
// build size menu
|
||||
for (int32 i = 0; sizes[i]; i++) {
|
||||
int32 size = sizes[i];
|
||||
if (size < kMinSize || size > kMaxSize)
|
||||
continue;
|
||||
|
||||
char label[32];
|
||||
snprintf(label, sizeof(label), "%ld", size);
|
||||
|
||||
BMessage* message = new BMessage(kMsgSetSize);
|
||||
message->AddInt32("size", size);
|
||||
message->AddString("name", Name());
|
||||
|
||||
BMenuItem* item = new BMenuItem(label, message);
|
||||
if (size == fCurrentFont.Size())
|
||||
item->SetMarked(true);
|
||||
|
||||
fSizesMenu->AddItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontSelectionView::_SelectCurrentFont(bool select)
|
||||
{
|
||||
font_family family;
|
||||
font_style style;
|
||||
fCurrentFont.GetFamilyAndStyle(&family, &style);
|
||||
|
||||
BMenuItem *item = fFontsMenu->FindItem(family);
|
||||
if (item != NULL) {
|
||||
item->SetMarked(select);
|
||||
|
||||
if (item->Submenu() != NULL) {
|
||||
item = item->Submenu()->FindItem(style);
|
||||
if (item != NULL)
|
||||
item->SetMarked(select);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontSelectionView::_SelectCurrentSize(bool select)
|
||||
{
|
||||
char label[16];
|
||||
snprintf(label, sizeof(label), "%ld", (int32)fCurrentFont.Size());
|
||||
|
||||
BMenuItem* item = fSizesMenu->FindItem(label);
|
||||
if (item != NULL)
|
||||
item->SetMarked(select);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontSelectionView::_UpdateFontPreview()
|
||||
{
|
||||
fPreviewText->SetFont(&fCurrentFont);
|
||||
|
||||
#ifdef INSTANT_UPDATE
|
||||
_UpdateSystemFont();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontSelectionView::_UpdateSystemFont()
|
||||
{
|
||||
font_family family;
|
||||
font_style style;
|
||||
fCurrentFont.GetFamilyAndStyle(&family, &style);
|
||||
|
||||
if (strcmp(Name(), "menu") == 0) {
|
||||
// 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());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontSelectionView::SetDefaults()
|
||||
{
|
||||
font_family family;
|
||||
font_style style;
|
||||
float size;
|
||||
const char* fontName;
|
||||
|
||||
if (strcmp(Name(), "menu") == 0)
|
||||
fontName = "plain";
|
||||
else
|
||||
fontName = Name();
|
||||
|
||||
if (_get_system_default_font_(fontName, family, style, &size) != B_OK) {
|
||||
Revert();
|
||||
return;
|
||||
}
|
||||
|
||||
BFont defaultFont;
|
||||
defaultFont.SetFamilyAndStyle(family, style);
|
||||
defaultFont.SetSize(size);
|
||||
|
||||
if (defaultFont == fCurrentFont)
|
||||
return;
|
||||
|
||||
_SelectCurrentFont(false);
|
||||
|
||||
fCurrentFont = defaultFont;
|
||||
_UpdateFontPreview();
|
||||
|
||||
_SelectCurrentFont(true);
|
||||
_SelectCurrentSize(true);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontSelectionView::Revert()
|
||||
{
|
||||
if (!IsRevertable())
|
||||
return;
|
||||
|
||||
_SelectCurrentFont(false);
|
||||
|
||||
fCurrentFont = fSavedFont;
|
||||
_UpdateFontPreview();
|
||||
|
||||
_SelectCurrentFont(true);
|
||||
_SelectCurrentSize(true);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
FontSelectionView::IsDefaultable()
|
||||
{
|
||||
font_family defaultFamily;
|
||||
font_style defaultStyle;
|
||||
float defaultSize;
|
||||
const char* fontName;
|
||||
|
||||
if (strcmp(Name(), "menu") == 0)
|
||||
fontName = "plain";
|
||||
else
|
||||
fontName = Name();
|
||||
|
||||
if (_get_system_default_font_(fontName, defaultFamily, defaultStyle,
|
||||
&defaultSize) != B_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
font_family currentFamily;
|
||||
font_style currentStyle;
|
||||
float currentSize;
|
||||
|
||||
fCurrentFont.GetFamilyAndStyle(¤tFamily, ¤tStyle);
|
||||
currentSize = fCurrentFont.Size();
|
||||
|
||||
return strcmp(currentFamily, defaultFamily) != 0
|
||||
|| strcmp(currentStyle, defaultStyle) != 0
|
||||
|| currentSize != defaultSize;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
FontSelectionView::IsRevertable()
|
||||
{
|
||||
return fCurrentFont != fSavedFont;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontSelectionView::UpdateFontsMenu()
|
||||
{
|
||||
int32 numFamilies = count_font_families();
|
||||
|
||||
fFontsMenu->RemoveItems(0, fFontsMenu->CountItems(), true);
|
||||
BFont font;
|
||||
fFontsMenu->GetFont(&font);
|
||||
|
||||
font_family currentFamily;
|
||||
font_style currentStyle;
|
||||
fCurrentFont.GetFamilyAndStyle(¤tFamily, ¤tStyle);
|
||||
|
||||
for (int32 i = 0; i < numFamilies; i++) {
|
||||
font_family family;
|
||||
uint32 flags;
|
||||
if (get_font_family(i, &family, &flags) != B_OK)
|
||||
continue;
|
||||
|
||||
// if we're setting the fixed font, we only want to show fixed fonts
|
||||
if (!strcmp(Name(), "fixed") && (flags & B_IS_FIXED) == 0)
|
||||
continue;
|
||||
|
||||
float width = font.StringWidth(family);
|
||||
if (width > fMaxFontNameWidth)
|
||||
fMaxFontNameWidth = width;
|
||||
|
||||
BMenu* stylesMenu = new BMenu(family);
|
||||
stylesMenu->SetRadioMode(true);
|
||||
stylesMenu->SetFont(&font);
|
||||
|
||||
BMessage* message = new BMessage(kMsgSetFamily);
|
||||
message->AddString("family", family);
|
||||
message->AddString("name", Name());
|
||||
|
||||
BMenuItem* familyItem = new BMenuItem(stylesMenu, message);
|
||||
fFontsMenu->AddItem(familyItem);
|
||||
|
||||
int32 numStyles = count_font_styles(family);
|
||||
|
||||
for (int32 j = 0; j < numStyles; j++) {
|
||||
font_style style;
|
||||
if (get_font_style(family, j, &style, &flags) != B_OK)
|
||||
continue;
|
||||
|
||||
message = new BMessage(kMsgSetStyle);
|
||||
message->AddString("family", (char*)family);
|
||||
message->AddString("style", (char*)style);
|
||||
message->AddString("name", Name());
|
||||
|
||||
BMenuItem *item = new BMenuItem(style, message);
|
||||
|
||||
if (!strcmp(style, currentStyle)
|
||||
&& !strcmp(family, currentFamily)) {
|
||||
item->SetMarked(true);
|
||||
familyItem->SetMarked(true);
|
||||
}
|
||||
stylesMenu->AddItem(item);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Mark Hogben
|
||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
* Philippe Saint-Pierre, stpere@gmail.com
|
||||
*/
|
||||
#ifndef FONT_SELECTION_VIEW_H
|
||||
#define FONT_SELECTION_VIEW_H
|
||||
|
||||
|
||||
#include <View.h>
|
||||
|
||||
class BLayoutItem;
|
||||
class BBox;
|
||||
class BMenuField;
|
||||
class BPopUpMenu;
|
||||
class BStringView;
|
||||
|
||||
static const int32 kMsgSetFamily = 'fmly';
|
||||
static const int32 kMsgSetStyle = 'styl';
|
||||
static const int32 kMsgSetSize = 'size';
|
||||
|
||||
|
||||
class FontSelectionView : public BView {
|
||||
public:
|
||||
FontSelectionView(const char* name,
|
||||
const char* label,
|
||||
const BFont* font = NULL);
|
||||
virtual ~FontSelectionView();
|
||||
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
void SetDefaults();
|
||||
void Revert();
|
||||
bool IsDefaultable();
|
||||
bool IsRevertable();
|
||||
|
||||
void UpdateFontsMenu();
|
||||
|
||||
BLayoutItem* CreateSizesLabelLayoutItem();
|
||||
BLayoutItem* CreateSizesMenuBarLayoutItem();
|
||||
|
||||
BLayoutItem* CreateFontsLabelLayoutItem();
|
||||
BLayoutItem* CreateFontsMenuBarLayoutItem();
|
||||
|
||||
BView* GetPreviewBox();
|
||||
|
||||
private:
|
||||
void _SelectCurrentFont(bool select);
|
||||
void _SelectCurrentSize(bool select);
|
||||
void _UpdateFontPreview();
|
||||
void _UpdateSystemFont();
|
||||
void _BuildSizesMenu();
|
||||
|
||||
protected:
|
||||
BMenuField* fFontsMenuField;
|
||||
BMenuField* fSizesMenuField;
|
||||
BPopUpMenu* fFontsMenu;
|
||||
BPopUpMenu* fSizesMenu;
|
||||
|
||||
BBox* fPreviewBox;
|
||||
BStringView* fPreviewText;
|
||||
|
||||
BFont fSavedFont;
|
||||
BFont fCurrentFont;
|
||||
float fMaxFontNameWidth;
|
||||
};
|
||||
|
||||
#endif // FONT_SELECTION_VIEW_H
|
@ -1,154 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Mark Hogben
|
||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
* Philippe St-Pierre, stpere@gmail.com
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
*/
|
||||
|
||||
#include "FontView.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <GridLayoutBuilder.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <Locale.h>
|
||||
#include <SpaceLayoutItem.h>
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "Font view"
|
||||
|
||||
static void
|
||||
add_font_selection_view(BGridLayout* layout, FontSelectionView* view,
|
||||
int32& row, bool withExtraSpace)
|
||||
{
|
||||
layout->AddItem(view->CreateFontsLabelLayoutItem(), 0, row);
|
||||
layout->AddItem(view->CreateFontsMenuBarLayoutItem(), 1, row);
|
||||
|
||||
layout->AddItem(BSpaceLayoutItem::CreateGlue(), 2, row);
|
||||
|
||||
layout->AddItem(view->CreateSizesLabelLayoutItem(), 3, row);
|
||||
layout->AddItem(view->CreateSizesMenuBarLayoutItem(), 4, row);
|
||||
|
||||
row++;
|
||||
|
||||
layout->AddItem(BSpaceLayoutItem::CreateGlue(), 0, row);
|
||||
layout->AddView(view->GetPreviewBox(), 1, row, 4);
|
||||
|
||||
row++;
|
||||
|
||||
if (withExtraSpace) {
|
||||
layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(5), 0, row, 5);
|
||||
row++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FontView::FontView()
|
||||
: BView("Fonts", B_WILL_DRAW )
|
||||
{
|
||||
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
||||
|
||||
fPlainView = new FontSelectionView("plain", B_TRANSLATE("Plain font:"));
|
||||
fBoldView = new FontSelectionView("bold", B_TRANSLATE("Bold font:"));
|
||||
fFixedView = new FontSelectionView("fixed", B_TRANSLATE("Fixed font:"));
|
||||
fMenuView = new FontSelectionView("menu", B_TRANSLATE("Menu font:"));
|
||||
|
||||
BGridLayout* layout = new BGridLayout(5, 5);
|
||||
layout->SetInsets(10, 10, 10, 10);
|
||||
SetLayout(layout);
|
||||
|
||||
int32 row = 0;
|
||||
add_font_selection_view(layout, fPlainView, row, true);
|
||||
add_font_selection_view(layout, fBoldView, row, true);
|
||||
add_font_selection_view(layout, fFixedView, row, true);
|
||||
add_font_selection_view(layout, fMenuView, row, false);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontView::SetDefaults()
|
||||
{
|
||||
fPlainView->SetDefaults();
|
||||
fBoldView->SetDefaults();
|
||||
fFixedView->SetDefaults();
|
||||
fMenuView->SetDefaults();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontView::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case kMsgSetSize:
|
||||
case kMsgSetFamily:
|
||||
case kMsgSetStyle:
|
||||
{
|
||||
const char* name;
|
||||
if (message->FindString("name", &name) != B_OK)
|
||||
break;
|
||||
|
||||
if (!strcmp(name, "plain"))
|
||||
fPlainView->MessageReceived(message);
|
||||
else if (!strcmp(name, "bold"))
|
||||
fBoldView->MessageReceived(message);
|
||||
else if (!strcmp(name, "fixed"))
|
||||
fFixedView->MessageReceived(message);
|
||||
else if (!strcmp(name, "menu"))
|
||||
fMenuView->MessageReceived(message);
|
||||
else
|
||||
break;
|
||||
|
||||
Window()->PostMessage(kMsgUpdate);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontView::Revert()
|
||||
{
|
||||
fPlainView->Revert();
|
||||
fBoldView->Revert();
|
||||
fFixedView->Revert();
|
||||
fMenuView->Revert();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontView::UpdateFonts()
|
||||
{
|
||||
fPlainView->UpdateFontsMenu();
|
||||
fBoldView->UpdateFontsMenu();
|
||||
fFixedView->UpdateFontsMenu();
|
||||
fMenuView->UpdateFontsMenu();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
FontView::IsDefaultable()
|
||||
{
|
||||
return fPlainView->IsDefaultable()
|
||||
|| fBoldView->IsDefaultable()
|
||||
|| fFixedView->IsDefaultable()
|
||||
|| fMenuView->IsDefaultable();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
FontView::IsRevertable()
|
||||
{
|
||||
return fPlainView->IsRevertable()
|
||||
|| fBoldView->IsRevertable()
|
||||
|| fFixedView->IsRevertable()
|
||||
|| fMenuView->IsRevertable();
|
||||
}
|
||||
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Mark Hogben
|
||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
* Philippe Saint-Pierre, stpere@gmail.com
|
||||
*/
|
||||
#ifndef FONT_VIEW_H
|
||||
#define FONT_VIEW_H
|
||||
|
||||
#include "FontSelectionView.h"
|
||||
#include "MainWindow.h"
|
||||
#include <Message.h>
|
||||
|
||||
class FontView : public BView {
|
||||
public:
|
||||
FontView();
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
void SetDefaults();
|
||||
void Revert();
|
||||
void UpdateFonts();
|
||||
|
||||
bool IsDefaultable();
|
||||
bool IsRevertable();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
FontSelectionView* fPlainView;
|
||||
FontSelectionView* fBoldView;
|
||||
FontSelectionView* fFixedView;
|
||||
FontSelectionView* fMenuView;
|
||||
};
|
||||
|
||||
|
||||
#endif /* FONT_VIEW_H */
|
@ -1,38 +0,0 @@
|
||||
|
||||
resource app_signature "application/x-vnd.Haiku-Fonts";
|
||||
|
||||
resource app_name_catalog_entry "x-vnd.Haiku-Fonts:System name:Fonts";
|
||||
|
||||
resource app_version {
|
||||
major = 1,
|
||||
middle = 0,
|
||||
minor = 0,
|
||||
|
||||
/* 0 = development 1 = alpha 2 = beta
|
||||
3 = gamma 4 = golden master 5 = final */
|
||||
variety = 2,
|
||||
|
||||
internal = 0,
|
||||
|
||||
short_info = "Fonts",
|
||||
long_info = "Fonts ©2002-2009 Haiku"
|
||||
};
|
||||
|
||||
resource app_flags B_SINGLE_LAUNCH;
|
||||
|
||||
resource vector_icon {
|
||||
$"6E63696608050004005F020006023D5F39368F62B905F93FFB6B4ACB36BEDE32"
|
||||
$"00032288FF1944E7020006023AAFCC3BFAA8BF50A93E3D044B460F48AEEC0002"
|
||||
$"0258FF1919E7020006023BA7EB3CD6E4BF5D013E2A4C4B0DDA478DDF0097C3FF"
|
||||
$"FF376AFF02000602380D3A384399BEF6CA3EAF9C4B2833C6F2DC00E3ECFFFFAC"
|
||||
$"C7FF02000602371F7FB98A813FA8F13D3A58C4B8AC48909300CEDEFFFF3778FF"
|
||||
$"02000602371F7FB98A813FA8F13D3A58C60C5648909300BADAFFFF032E850B0A"
|
||||
$"0432482C503E543C4B0A0550485452485E565A60500A0A47273D24322A244A2C"
|
||||
$"4E34C2B0BE5BC408BFBFC94F485C52520A0447273C2D485C52520A08BE5AC40E"
|
||||
$"4058485CBE3D2D322A244A2C4EB935C20F0A03BC12BB843BC1D3B9EBC0700A03"
|
||||
$"BC12BB84BCC2BE1AB9EBC0700A03BD75C0B13BC1D3B9EBC0700A03BCC2BE1ABD"
|
||||
$"75C0B1B9EBC0700A032C4E34C2B0B939C20A0A043D24322A3C2D4727090A0102"
|
||||
$"0001000A0001021001178400040A020103000A030109000A030106000A060107"
|
||||
$"000A070108000A04020405000A05010A00"
|
||||
};
|
||||
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Mark Hogben
|
||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
*/
|
||||
|
||||
|
||||
#include <Application.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <File.h>
|
||||
#include <Path.h>
|
||||
#include <Font.h>
|
||||
#include <String.h>
|
||||
#include <stdio.h>
|
||||
#include <Message.h>
|
||||
|
||||
#include "FontsSettings.h"
|
||||
|
||||
static const char kSettingsFile[] = "Font_Settings";
|
||||
|
||||
|
||||
FontsSettings::FontsSettings()
|
||||
{
|
||||
BPath path;
|
||||
BMessage msg;
|
||||
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
|
||||
path.Append(kSettingsFile);
|
||||
BFile file(path.Path(), B_READ_ONLY);
|
||||
|
||||
if (file.InitCheck() != B_OK)
|
||||
SetDefaults();
|
||||
else if (msg.Unflatten(&file) != B_OK)
|
||||
SetDefaults();
|
||||
else
|
||||
msg.FindPoint("windowlocation", &fCorner);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FontsSettings::~FontsSettings()
|
||||
{
|
||||
BPath path;
|
||||
BMessage msg;
|
||||
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK)
|
||||
return;
|
||||
|
||||
path.Append(kSettingsFile);
|
||||
BFile file(path.Path(), B_WRITE_ONLY|B_CREATE_FILE);
|
||||
|
||||
if (file.InitCheck() == B_OK) {
|
||||
msg.AddPoint("windowlocation", fCorner);
|
||||
msg.Flatten(&file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontsSettings::SetWindowCorner(BPoint where)
|
||||
{
|
||||
fCorner = where;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontsSettings::SetDefaults()
|
||||
{
|
||||
fCorner.Set(-1, -1);
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Mark Hogben
|
||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
*/
|
||||
#ifndef FONTS_SETTINGS_H
|
||||
#define FONTS_SETTINGS_H
|
||||
|
||||
|
||||
#include <Point.h>
|
||||
|
||||
|
||||
class FontsSettings {
|
||||
public:
|
||||
FontsSettings();
|
||||
~FontsSettings();
|
||||
|
||||
BPoint WindowCorner() const { return fCorner; }
|
||||
void SetWindowCorner(BPoint);
|
||||
|
||||
void SetDefaults();
|
||||
|
||||
private:
|
||||
BPoint fCorner;
|
||||
};
|
||||
|
||||
#endif /* FONTS_SETTINGS_H */
|
@ -1,21 +0,0 @@
|
||||
SubDir HAIKU_TOP src preferences fonts ;
|
||||
|
||||
Preference Fonts :
|
||||
FontSelectionView.cpp
|
||||
FontsSettings.cpp
|
||||
FontView.cpp
|
||||
main.cpp
|
||||
MainWindow.cpp
|
||||
: be [ TargetLibsupc++ ] localestub
|
||||
: Fonts.rdef
|
||||
;
|
||||
|
||||
DoCatalogs Fonts :
|
||||
x-vnd.Haiku-Fonts
|
||||
:
|
||||
FontSelectionView.cpp
|
||||
FontView.cpp
|
||||
main.cpp
|
||||
MainWindow.cpp
|
||||
;
|
||||
|
@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Mark Hogben
|
||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
|
||||
* Philippe Saint-Pierre, stpere@gmail.com
|
||||
*/
|
||||
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Button.h>
|
||||
#include <Box.h>
|
||||
#include <Catalog.h>
|
||||
#include <ControlLook.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <Locale.h>
|
||||
#include <MessageRunner.h>
|
||||
#include <Screen.h>
|
||||
#include <TabView.h>
|
||||
#include <TextView.h>
|
||||
|
||||
#include "FontView.h"
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "Main window"
|
||||
|
||||
|
||||
static const uint32 kMsgSetDefaults = 'dflt';
|
||||
static const uint32 kMsgRevert = 'rvrt';
|
||||
static const uint32 kMsgCheckFonts = 'chkf';
|
||||
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: BWindow(BRect(0, 0, 1, 1), B_TRANSLATE_SYSTEM_NAME("Fonts"), B_TITLED_WINDOW,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
|
||||
{
|
||||
fDefaultsButton = new BButton("defaults", B_TRANSLATE("Defaults"),
|
||||
new BMessage(kMsgSetDefaults), B_WILL_DRAW);
|
||||
fDefaultsButton->SetEnabled(false);
|
||||
|
||||
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
|
||||
new BMessage(kMsgRevert), B_WILL_DRAW);
|
||||
fRevertButton->SetEnabled(false);
|
||||
|
||||
// BTabView* tabView = new BTabView("tabview", B_WIDTH_FROM_LABEL);
|
||||
|
||||
BBox* box = new BBox(B_FANCY_BORDER, NULL);
|
||||
|
||||
fFontsView = new FontView();
|
||||
|
||||
// tabView->AddTab(fFontsView);
|
||||
box->AddChild(fFontsView);
|
||||
|
||||
fFontsView->UpdateFonts();
|
||||
|
||||
const float kInset = be_control_look->DefaultItemSpacing();
|
||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||
.SetInsets(kInset, kInset, kInset, kInset)
|
||||
.Add(box)
|
||||
// .Add(tabView)
|
||||
.AddStrut(kInset)
|
||||
.AddGroup(B_HORIZONTAL)
|
||||
.Add(fDefaultsButton)
|
||||
.AddStrut(kInset)
|
||||
.Add(fRevertButton)
|
||||
.AddGlue();
|
||||
|
||||
if (fSettings.WindowCorner() == BPoint(-1, -1)) {
|
||||
// center window on screen
|
||||
CenterOnScreen();
|
||||
} else {
|
||||
MoveTo(fSettings.WindowCorner());
|
||||
|
||||
// make sure window is on screen
|
||||
BScreen screen(this);
|
||||
if (!screen.Frame().InsetByCopy(10, 10).Intersects(Frame()))
|
||||
CenterOnScreen();
|
||||
}
|
||||
|
||||
fRunner = new BMessageRunner(this, new BMessage(kMsgCheckFonts), 3000000);
|
||||
// every 3 seconds
|
||||
|
||||
fDefaultsButton->SetEnabled(fFontsView->IsDefaultable());
|
||||
}
|
||||
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete fRunner;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
MainWindow::QuitRequested()
|
||||
{
|
||||
fSettings.SetWindowCorner(Frame().LeftTop());
|
||||
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::MessageReceived(BMessage *message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case kMsgSetSize:
|
||||
case kMsgSetFamily:
|
||||
case kMsgSetStyle:
|
||||
fFontsView->MessageReceived(message);
|
||||
break;
|
||||
|
||||
case kMsgUpdate:
|
||||
fDefaultsButton->SetEnabled(fFontsView->IsDefaultable());
|
||||
fRevertButton->SetEnabled(fFontsView->IsRevertable());
|
||||
break;
|
||||
|
||||
case kMsgSetDefaults:
|
||||
fFontsView->SetDefaults();
|
||||
fDefaultsButton->SetEnabled(false);
|
||||
fRevertButton->SetEnabled(fFontsView->IsRevertable());
|
||||
break;
|
||||
|
||||
case kMsgRevert:
|
||||
fFontsView->Revert();
|
||||
fDefaultsButton->SetEnabled(fFontsView->IsDefaultable());
|
||||
fRevertButton->SetEnabled(false);
|
||||
break;
|
||||
|
||||
case kMsgCheckFonts:
|
||||
if (update_font_families(true))
|
||||
fFontsView->UpdateFonts();
|
||||
break;
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::_Center()
|
||||
{
|
||||
BRect screenFrame = BScreen(this).Frame();
|
||||
BRect windowRect = Frame();
|
||||
|
||||
MoveTo(
|
||||
(screenFrame.Width() - windowRect.Width()) / 2,
|
||||
(screenFrame.Height() - windowRect.Height()) / 2);
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Mark Hogben
|
||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
*/
|
||||
#ifndef MAIN_WINDOW_H
|
||||
#define MAIN_WINDOW_H
|
||||
|
||||
|
||||
#include "FontsSettings.h"
|
||||
|
||||
#include <Window.h>
|
||||
|
||||
class BButton;
|
||||
class BMessageRunner;
|
||||
class FontView;
|
||||
|
||||
|
||||
class MainWindow : public BWindow {
|
||||
public:
|
||||
MainWindow();
|
||||
virtual ~MainWindow();
|
||||
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
|
||||
private:
|
||||
void _Center();
|
||||
|
||||
BMessageRunner* fRunner;
|
||||
FontView* fFontsView;
|
||||
BButton* fDefaultsButton;
|
||||
BButton* fRevertButton;
|
||||
|
||||
FontsSettings fSettings;
|
||||
};
|
||||
|
||||
static const int32 kMsgUpdate = 'updt';
|
||||
|
||||
#endif // MAIN_WINDOW_H
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Mark Hogben
|
||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
*/
|
||||
|
||||
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Catalog.h>
|
||||
#include <Locale.h>
|
||||
#include <TextView.h>
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "main"
|
||||
|
||||
class FontsApp : public BApplication {
|
||||
public:
|
||||
FontsApp();
|
||||
|
||||
virtual void AboutRequested();
|
||||
};
|
||||
|
||||
|
||||
FontsApp::FontsApp()
|
||||
: BApplication("application/x-vnd.Haiku-Fonts")
|
||||
{
|
||||
MainWindow *window = new MainWindow();
|
||||
window->Show();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontsApp::AboutRequested()
|
||||
{
|
||||
BAlert *alert = new BAlert("about", B_TRANSLATE("Fonts\n"
|
||||
"\tCopyright 2004-2005, Haiku.\n\n"), B_TRANSLATE("OK"));
|
||||
BTextView *view = alert->TextView();
|
||||
BFont font;
|
||||
|
||||
view->SetStylable(true);
|
||||
|
||||
view->GetFont(&font);
|
||||
font.SetSize(18);
|
||||
font.SetFace(B_BOLD_FACE);
|
||||
view->SetFontAndColor(0, 5, &font);
|
||||
|
||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
||||
alert->Go();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
int
|
||||
main(int, char**)
|
||||
{
|
||||
FontsApp app;
|
||||
app.Run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user