Updated
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10791 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
80b0522e29
commit
098ad0a57f
@ -13,41 +13,28 @@
|
||||
* @param rect The size of the view.
|
||||
*/
|
||||
ButtonView::ButtonView(BRect rect)
|
||||
: BView(rect, "ButtonView", B_FOLLOW_ALL, B_WILL_DRAW)
|
||||
:BView(rect, "ButtonView", B_FOLLOW_ALL, B_WILL_DRAW)
|
||||
{
|
||||
|
||||
float x;
|
||||
float y;
|
||||
BRect viewSize = Bounds();
|
||||
BButton *rescanButton;
|
||||
BButton *defaultsButton;
|
||||
|
||||
x = viewSize.Width() / 37;
|
||||
y = viewSize.Height() / 6;
|
||||
|
||||
SetViewColor(216,216,216,0);
|
||||
|
||||
rescanButton = new BButton(*(new BRect(x, y, (9.0 * x), (4.0 * y))),
|
||||
"rescanButton",
|
||||
"Rescan",
|
||||
new BMessage(RESCAN_FONTS_MSG),
|
||||
B_FOLLOW_LEFT,
|
||||
B_WILL_DRAW
|
||||
);
|
||||
defaultsButton = new BButton(*(new BRect((11.0 * x), y, (19.0 * x), (4.0 * y))),
|
||||
"defaultsButton",
|
||||
"Defaults",
|
||||
new BMessage(RESET_FONTS_MSG),
|
||||
B_FOLLOW_LEFT,
|
||||
B_WILL_DRAW
|
||||
);
|
||||
revertButton = new BButton(*(new BRect((20.0 * x), y, (28.0 * x), (4.0 * y))),
|
||||
"revertButton",
|
||||
"Revert",
|
||||
new BMessage(REVERT_MSG),
|
||||
B_FOLLOW_LEFT,
|
||||
B_WILL_DRAW
|
||||
);
|
||||
BRect btnRect(0, 0, 75, 25);
|
||||
btnRect.OffsetBy(10, 8);
|
||||
BButton *rescanButton = new BButton(btnRect,
|
||||
"rescanButton", "Rescan",
|
||||
new BMessage(RESCAN_FONTS_MSG),
|
||||
B_FOLLOW_LEFT, B_WILL_DRAW);
|
||||
|
||||
btnRect.OffsetBy(96, 0);
|
||||
BButton *defaultsButton = new BButton(btnRect,
|
||||
"defaultsButton", "Defaults",
|
||||
new BMessage(RESET_FONTS_MSG),
|
||||
B_FOLLOW_LEFT, B_WILL_DRAW);
|
||||
|
||||
btnRect.OffsetBy(85, 0);
|
||||
revertButton = new BButton(btnRect,
|
||||
"revertButton", "Revert",
|
||||
new BMessage(REVERT_MSG),
|
||||
B_FOLLOW_LEFT, B_WILL_DRAW);
|
||||
|
||||
revertButton->SetEnabled(false);
|
||||
|
||||
@ -57,6 +44,24 @@ ButtonView::ButtonView(BRect rect)
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ButtonView::Draw(BRect update)
|
||||
{
|
||||
rgb_color dark = {100, 100, 100, 255};
|
||||
rgb_color light = {255, 255, 255, 255};
|
||||
BRect bounds(Bounds());
|
||||
BeginLineArray(6);
|
||||
AddLine(bounds.LeftTop(), bounds.RightTop(), light);
|
||||
AddLine(bounds.LeftTop(), bounds.LeftBottom(), light);
|
||||
AddLine(bounds.RightTop(), bounds.RightBottom(), dark);
|
||||
AddLine(bounds.RightBottom(), bounds.LeftBottom(), dark);
|
||||
AddLine(BPoint(95, 9), BPoint(95, 34), dark);
|
||||
AddLine(BPoint(96, 9), BPoint(96, 34), light);
|
||||
EndLineArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the state of the revert button.
|
||||
*/
|
||||
|
@ -21,11 +21,7 @@
|
||||
*/
|
||||
#define REVERT_MSG 'rvrt'
|
||||
|
||||
#ifndef _VIEW_H
|
||||
|
||||
#include <View.h>
|
||||
|
||||
#endif
|
||||
#include <View.h>
|
||||
|
||||
#ifndef _BUTTON_H
|
||||
|
||||
@ -33,14 +29,14 @@
|
||||
|
||||
#endif
|
||||
|
||||
class ButtonView : public BView{
|
||||
class ButtonView : public BView {
|
||||
|
||||
public:
|
||||
|
||||
ButtonView(BRect frame);
|
||||
bool RevertState();
|
||||
void SetRevertState(bool b);
|
||||
|
||||
void Draw(BRect);
|
||||
private:
|
||||
|
||||
/**
|
||||
|
@ -6,6 +6,10 @@
|
||||
#include "CacheView.h"
|
||||
|
||||
#endif
|
||||
#include <String.h>
|
||||
#include "Pref_Utils.h"
|
||||
|
||||
const char *kLabel = "font cache size: ";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -16,75 +20,66 @@
|
||||
* @param screenCurrVal The starting value of the screen slider.
|
||||
*/
|
||||
CacheView::CacheView(BRect rect, int minVal, int maxVal, int32 printCurrVal, int32 screenCurrVal)
|
||||
: BView(rect, "CacheView", B_FOLLOW_ALL, B_WILL_DRAW)
|
||||
:BView(rect, "CacheView", B_FOLLOW_ALL, B_WILL_DRAW)
|
||||
{
|
||||
|
||||
BRect viewSize = Bounds();
|
||||
char sliderMinLabel[10];
|
||||
char sliderMaxLabel[10];
|
||||
char msg[100];
|
||||
SetViewColor(216, 216, 216, 0);
|
||||
|
||||
origPrintVal = printCurrVal;
|
||||
origScreenVal = screenCurrVal;
|
||||
SetViewColor(216, 216, 216, 0);
|
||||
|
||||
rgb_color fillColor;
|
||||
fillColor.red = 0;
|
||||
fillColor.blue = 152;
|
||||
fillColor.green = 102;
|
||||
fillColor.red = 102;
|
||||
fillColor.blue = 203;
|
||||
fillColor.green = 152;
|
||||
|
||||
viewSize.InsetBy(15, 10);
|
||||
|
||||
sprintf(msg, "Screen font cache size : %d kB", static_cast<int>(screenCurrVal));
|
||||
|
||||
screenFCS = new BSlider(*(new BRect(viewSize.left, viewSize.top, viewSize.right, viewSize.top + 25.0)),
|
||||
"screenFontCache",
|
||||
msg,
|
||||
new BMessage(SCREEN_FCS_UPDATE_MSG),
|
||||
minVal,
|
||||
maxVal,
|
||||
B_TRIANGLE_THUMB
|
||||
);
|
||||
float fontheight = FontHeight(true);
|
||||
BRect rect(Bounds());
|
||||
rect.InsetBy(5.0, 3.0);
|
||||
rect.top += fontheight;
|
||||
rect.bottom = rect.top +(fontheight *2.0);
|
||||
BString labels(B_EMPTY_STRING);
|
||||
labels << "Screen" << kLabel << screenCurrVal << " kB";
|
||||
screenFCS = new BSlider(rect,
|
||||
"screenFontCache", labels.String(),
|
||||
new BMessage(SCREEN_FCS_UPDATE_MSG),
|
||||
minVal, maxVal, B_TRIANGLE_THUMB);
|
||||
|
||||
screenFCS->SetModificationMessage(new BMessage(SCREEN_FCS_MODIFICATION_MSG));
|
||||
|
||||
sprintf(sliderMinLabel, "%d kB", minVal);
|
||||
sprintf(sliderMaxLabel, "%d kB", maxVal);
|
||||
screenFCS->SetLimitLabels(sliderMinLabel, sliderMaxLabel);
|
||||
|
||||
BString minLabel(B_EMPTY_STRING);
|
||||
BString maxLabel(B_EMPTY_STRING);
|
||||
minLabel << minVal << " kB";
|
||||
maxLabel << maxVal << " kB";
|
||||
screenFCS->SetLimitLabels(minLabel.String(), maxLabel.String());
|
||||
screenFCS->UseFillColor(TRUE, &fillColor);
|
||||
screenFCS->SetValue(screenCurrVal);
|
||||
|
||||
viewSize.top = viewSize.top + 65.0;
|
||||
rect.OffsetTo(rect.left, rect.bottom +(fontheight *2.5));
|
||||
|
||||
sprintf(msg, "Printing font cache size : %d kB", static_cast<int>(printCurrVal));
|
||||
labels = "";
|
||||
labels << "Printing " << kLabel << printCurrVal << " kB";
|
||||
|
||||
printFCS = new BSlider(*(new BRect(viewSize.left, viewSize.top, viewSize.right, viewSize.top + 25.0)),
|
||||
"printFontCache",
|
||||
msg,
|
||||
new BMessage(PRINT_FCS_UPDATE_MSG),
|
||||
minVal,
|
||||
maxVal,
|
||||
B_TRIANGLE_THUMB
|
||||
);
|
||||
printFCS = new BSlider(rect, "printFontCache", labels.String(),
|
||||
new BMessage(PRINT_FCS_UPDATE_MSG),
|
||||
minVal, maxVal, B_TRIANGLE_THUMB);
|
||||
|
||||
printFCS->SetModificationMessage(new BMessage(PRINT_FCS_MODIFICATION_MSG));
|
||||
|
||||
printFCS->SetLimitLabels(sliderMinLabel, sliderMaxLabel);
|
||||
printFCS->SetLimitLabels(minLabel.String(), maxLabel.String());
|
||||
printFCS->UseFillColor(TRUE, &fillColor);
|
||||
printFCS->SetValue(printCurrVal);
|
||||
|
||||
viewSize.top = viewSize.top + 70.0;
|
||||
rect.OffsetTo(rect.left -1.0, rect.bottom +(fontheight *2.0));
|
||||
rect.right = rect.left +86.0;
|
||||
rect.bottom = rect.top +24.0;
|
||||
|
||||
BButton *saveCache = new BButton(*(new BRect(viewSize.left, viewSize.top, 100.0, 20.0)),
|
||||
"saveCache",
|
||||
"Save Cache",
|
||||
NULL,
|
||||
B_FOLLOW_LEFT,
|
||||
B_WILL_DRAW
|
||||
);
|
||||
BButton *saveCache = new BButton(rect,
|
||||
"saveCache", "Save Cache",
|
||||
NULL, B_FOLLOW_LEFT, B_WILL_DRAW);
|
||||
|
||||
AddChild(screenFCS);
|
||||
AddChild(printFCS);
|
||||
AddChild(saveCache);
|
||||
|
||||
AddChild(saveCache);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -129,16 +124,14 @@ int CacheView::getScreenFCSValue(){
|
||||
* Sets the sliders to their original values.
|
||||
*/
|
||||
void CacheView::revertToOriginal(){
|
||||
|
||||
BString label;
|
||||
label << "Screen " << kLabel << getScreenFCSValue();
|
||||
updateScreenFCS(label.String());
|
||||
|
||||
char msg[100];
|
||||
|
||||
screenFCS->SetValue(origScreenVal);
|
||||
sprintf(msg, "Screen font cache size : %d kB", getScreenFCSValue());
|
||||
updateScreenFCS(msg);
|
||||
|
||||
printFCS->SetValue(origPrintVal);
|
||||
sprintf(msg, "Printing font cache size : %d kB", getPrintFCSValue());
|
||||
updatePrintFCS(msg);
|
||||
label = "Printing ";
|
||||
label << kLabel << getPrintFCSValue();
|
||||
updatePrintFCS(label.String());
|
||||
|
||||
}//revertToOriginal
|
||||
|
||||
@ -146,16 +139,13 @@ void CacheView::revertToOriginal(){
|
||||
* Sets the sliders to their default values.
|
||||
*/
|
||||
void CacheView::resetToDefaults(){
|
||||
|
||||
char msg[100];
|
||||
BString label;
|
||||
label << "Screen " << kLabel << getScreenFCSValue() << " kB";
|
||||
updateScreenFCS(label.String());
|
||||
|
||||
screenFCS->SetValue((int32) 256);
|
||||
sprintf(msg, "Screen font cache size : %d kB", getScreenFCSValue());
|
||||
updateScreenFCS(msg);
|
||||
|
||||
printFCS->SetValue((int32) 256);
|
||||
sprintf(msg, "Printing font cache size : %d kB", getPrintFCSValue());
|
||||
updatePrintFCS(msg);
|
||||
label = "Printing ";
|
||||
label << kLabel << getPrintFCSValue() << " kB";
|
||||
updatePrintFCS(label.String());
|
||||
|
||||
}//revertToOriginal
|
||||
|
||||
|
@ -41,11 +41,6 @@
|
||||
|
||||
#include <Slider.h>
|
||||
|
||||
#endif
|
||||
#ifndef _STDIO_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#endif
|
||||
#ifndef _BUTTON_H
|
||||
|
||||
@ -64,7 +59,6 @@
|
||||
int getScreenFCSValue();
|
||||
void revertToOriginal();
|
||||
void resetToDefaults();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
@ -9,6 +9,18 @@
|
||||
|
||||
#endif
|
||||
|
||||
#include "Pref_Utils.h"
|
||||
|
||||
// should be changed to allow larger and smaller
|
||||
#define minSizeIndex 7
|
||||
#define maxSizeIndex 12
|
||||
|
||||
// constants for labels
|
||||
const char *kPlainFont = "Plain font:";
|
||||
const char *kBoldFont = "Bold font:";
|
||||
const char *kFixedFont = "Fixed font:";
|
||||
const char *kSize = "Size: ";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param rect The size of the view.
|
||||
@ -19,24 +31,11 @@ FontSelectionView::FontSelectionView(BRect rect, const char *name, int type)
|
||||
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
|
||||
{
|
||||
|
||||
BBox *testTextBox;
|
||||
float x;
|
||||
float y;
|
||||
BRect viewSize = Bounds();
|
||||
BMenuField *fontListField;
|
||||
BMenuField *sizeListField;
|
||||
|
||||
x = viewSize.Width() / 37;
|
||||
y = viewSize.Height() / 8;
|
||||
|
||||
minSizeIndex = 9;
|
||||
maxSizeIndex = 12;
|
||||
|
||||
switch(type){
|
||||
|
||||
case PLAIN_FONT_SELECTION_VIEW:
|
||||
|
||||
sprintf(typeLabel, "Plain font");
|
||||
sprintf(typeLabel, kPlainFont);
|
||||
origFont = be_plain_font;
|
||||
workingFont = be_plain_font;
|
||||
setSizeChangedMessage = PLAIN_SIZE_CHANGED_MSG;
|
||||
@ -51,7 +50,7 @@ FontSelectionView::FontSelectionView(BRect rect, const char *name, int type)
|
||||
|
||||
case BOLD_FONT_SELECTION_VIEW:
|
||||
|
||||
sprintf(typeLabel, "Bold font");
|
||||
sprintf(typeLabel, kBoldFont);
|
||||
origFont = be_bold_font;
|
||||
workingFont = be_bold_font;
|
||||
setSizeChangedMessage = BOLD_SIZE_CHANGED_MSG;
|
||||
@ -66,7 +65,7 @@ FontSelectionView::FontSelectionView(BRect rect, const char *name, int type)
|
||||
|
||||
case FIXED_FONT_SELECTION_VIEW:
|
||||
|
||||
sprintf(typeLabel, "Fixed font");
|
||||
sprintf(typeLabel, kFixedFont);
|
||||
origFont = be_fixed_font;
|
||||
workingFont = be_fixed_font;
|
||||
setSizeChangedMessage = FIXED_SIZE_CHANGED_MSG;
|
||||
@ -80,23 +79,42 @@ FontSelectionView::FontSelectionView(BRect rect, const char *name, int type)
|
||||
break;
|
||||
|
||||
}//switch
|
||||
|
||||
|
||||
float fontheight = FontHeight(false);
|
||||
float divider = StringWidth(kFixedFont);
|
||||
|
||||
sizeList = new BPopUpMenu("sizeList", true, true, B_ITEMS_IN_COLUMN);
|
||||
fontList = new BPopUpMenu("fontList", true, true, B_ITEMS_IN_COLUMN);
|
||||
fontListField = new BMenuField(*(new BRect(x, y, (25 * x), (3 * y))), "fontField", typeLabel, fontList);
|
||||
fontListField->SetDivider(7 * x);
|
||||
sizeListField = new BMenuField(*(new BRect((27 * x), y, (36 * x), (3 * y))), "fontField", "Size", sizeList);
|
||||
sizeListField->SetDivider(31 * x);
|
||||
|
||||
testTextBox = new BBox(*(new BRect((8 * x), (5 * y), (36 * x), (8 * y))), "TestTextBox", B_FOLLOW_ALL, B_WILL_DRAW, B_FANCY_BORDER);
|
||||
|
||||
// create menus
|
||||
// size box
|
||||
rect = Bounds();
|
||||
float x = StringWidth("999") +16;
|
||||
rect.left = rect.right -(x +StringWidth(kSize)+8.0);
|
||||
rect.bottom = fontheight +5;
|
||||
BMenuField *sizeListField = new BMenuField(rect, "fontField", kSize, sizeList, true);
|
||||
sizeListField->SetDivider(StringWidth(kSize)+5.0);
|
||||
sizeListField->SetAlignment(B_ALIGN_RIGHT);
|
||||
// font menu
|
||||
rect.right = rect.left;
|
||||
rect.left = 1;
|
||||
rect.bottom = fontheight *1.5;
|
||||
BMenuField *fontListField = new BMenuField(rect, "fontField", typeLabel, fontList, false);
|
||||
fontListField->SetDivider(divider +6.0);
|
||||
fontListField->SetAlignment(B_ALIGN_RIGHT);
|
||||
|
||||
rect = Bounds();
|
||||
rect.left = divider +8.0;
|
||||
rect.top = fontheight *1.5 +4;
|
||||
rect.InsetBy(1, 1);
|
||||
BBox *testTextBox = new BBox(rect, "TestTextBox", B_FOLLOW_ALL, B_WILL_DRAW, B_FANCY_BORDER);
|
||||
|
||||
// Place the text slightly inside the entire box area, so it doesn't overlap the box outline.
|
||||
BRect testTextRect(testTextBox->Bounds());
|
||||
testTextRect.top = 2;
|
||||
testTextRect.left = 4;
|
||||
testTextRect.bottom = testTextRect.bottom - 2;
|
||||
testTextRect.right = testTextRect.right - 4;
|
||||
testText = new BStringView(testTextRect, "testText", "The quick brown fox jumped over the lazy dog.", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
rect = testTextBox->Bounds().InsetByCopy(2, 2);
|
||||
rect.right -= 2;
|
||||
BRect testTextRect(rect);
|
||||
testText = new BStringView(testTextRect, "testText", "The quick brown fox jumps over the lazy dog.",
|
||||
B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
testText->SetFont(&workingFont);
|
||||
|
||||
fontList->SetLabelFromMarked(true);
|
||||
@ -461,7 +479,7 @@ void FontSelectionView::UpdateFontSelection(BFont *fnt){
|
||||
if(strcmp(sizeList->ItemAt(i)->Label(), size) == 0){
|
||||
|
||||
sizeList->ItemAt(i)->SetMarked(true);
|
||||
|
||||
break;
|
||||
}//if
|
||||
|
||||
}//for
|
||||
|
@ -116,7 +116,6 @@
|
||||
void emptyMenus();
|
||||
void resetToDefaults();
|
||||
void revertToOriginal();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
@ -9,26 +9,24 @@
|
||||
|
||||
#endif
|
||||
|
||||
#include "Pref_Utils.h"
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param rect The size of the view.
|
||||
*/
|
||||
FontView::FontView(BRect rect)
|
||||
: BView(rect, "FontView", B_FOLLOW_ALL, B_WILL_DRAW)
|
||||
:BView(rect, "FontView", B_FOLLOW_ALL, B_WILL_DRAW)
|
||||
{
|
||||
|
||||
float x;
|
||||
float y;
|
||||
BRect viewSize = Bounds();
|
||||
|
||||
SetViewColor(216, 216, 216, 0);
|
||||
|
||||
x = viewSize.Width() / 39;
|
||||
y = viewSize.Height() / 25;
|
||||
|
||||
plainSelectionView = new FontSelectionView(*(new BRect(x, y, (38.0 * x), (8.0 * y))), "Plain", PLAIN_FONT_SELECTION_VIEW);
|
||||
boldSelectionView = new FontSelectionView(*(new BRect(x, (9.0 * y), (38.0 * x), (16.0 * y))), "Bold", BOLD_FONT_SELECTION_VIEW);
|
||||
fixedSelectionView = new FontSelectionView(*(new BRect(x, (17.0 * y), (38.0 * x), (24.0 * y))), "Fixed", FIXED_FONT_SELECTION_VIEW);
|
||||
BRect bounds(Bounds().InsetByCopy(5, 5));
|
||||
|
||||
BRect rect(bounds);
|
||||
rect.bottom = rect.top +FontHeight(true) *3.5;
|
||||
plainSelectionView = new FontSelectionView(rect, "Plain", PLAIN_FONT_SELECTION_VIEW);
|
||||
rect.OffsetBy(0, rect.Height()+4);
|
||||
boldSelectionView = new FontSelectionView(rect, "Bold", BOLD_FONT_SELECTION_VIEW);
|
||||
rect.OffsetBy(0, rect.Height()+4);
|
||||
fixedSelectionView = new FontSelectionView(rect, "Fixed", FIXED_FONT_SELECTION_VIEW);
|
||||
|
||||
AddChild(plainSelectionView);
|
||||
AddChild(boldSelectionView);
|
||||
@ -36,6 +34,17 @@ FontView::FontView(BRect rect)
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontView::AttachedToWindow(void)
|
||||
{
|
||||
if (Parent() != NULL)
|
||||
SetViewColor(Parent()->ViewColor());
|
||||
else
|
||||
SetViewColor(219, 219, 219, 255);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calls each FontSelectionView's buildMenus() function to build the
|
||||
* font and size menus.
|
||||
|
@ -28,8 +28,8 @@
|
||||
class FontView : public BView{
|
||||
|
||||
public:
|
||||
|
||||
FontView(BRect frame);
|
||||
void AttachedToWindow(void);
|
||||
FontSelectionView *plainSelectionView;
|
||||
FontSelectionView *boldSelectionView;
|
||||
FontSelectionView *fixedSelectionView;
|
||||
@ -37,7 +37,6 @@
|
||||
void emptyMenus();
|
||||
void resetToDefaults();
|
||||
void revertToOriginal();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
58
src/prefs/fonts/FontsSettings.cpp
Normal file
58
src/prefs/fonts/FontsSettings.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
FontsSettings.cpp
|
||||
*/
|
||||
|
||||
#include <Application.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <File.h>
|
||||
#include <Path.h>
|
||||
#include <String.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "FontsSettings.h"
|
||||
|
||||
const char FontsSettings::kSettingsFile[] = "Font_Settings";
|
||||
const BPoint kDEFAULT = BPoint(100, 100);
|
||||
|
||||
FontsSettings::FontsSettings()
|
||||
{
|
||||
BPath path;
|
||||
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) {
|
||||
float x, y;
|
||||
if (file.Read(&x, sizeof(float)) != sizeof(float)) {
|
||||
x = kDEFAULT.x;
|
||||
}
|
||||
if (file.Read(&y, sizeof(float)) != sizeof(float)) {
|
||||
y = kDEFAULT.y;
|
||||
}
|
||||
f_corner = BPoint(x, y);
|
||||
} else {
|
||||
f_corner = kDEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FontsSettings::~FontsSettings()
|
||||
{
|
||||
BPath path;
|
||||
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) {
|
||||
float x = f_corner.x;
|
||||
float y = f_corner.y;
|
||||
file.Write(&x, sizeof(float));
|
||||
file.Write(&y, sizeof(float));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FontsSettings::SetWindowCorner(BPoint where)
|
||||
{
|
||||
f_corner = where;
|
||||
}
|
16
src/prefs/fonts/FontsSettings.h
Normal file
16
src/prefs/fonts/FontsSettings.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef FONTS_SETTINGS_H
|
||||
#define FONTS_SETTINGS_H
|
||||
|
||||
class FontsSettings {
|
||||
public:
|
||||
FontsSettings(void);
|
||||
~FontsSettings(void);
|
||||
|
||||
BPoint WindowCorner(void) const { return f_corner; }
|
||||
void SetWindowCorner(BPoint);
|
||||
private:
|
||||
static const char kSettingsFile[];
|
||||
BPoint f_corner;
|
||||
};
|
||||
|
||||
#endif //FONTS_SETTINGS_H
|
@ -16,27 +16,28 @@
|
||||
* @param frame The size to make the window.
|
||||
*/
|
||||
MainWindow::MainWindow(BRect frame)
|
||||
: BWindow(frame, "Fonts", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE ){
|
||||
:BWindow(frame, "Fonts", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE ){
|
||||
|
||||
BRect r;
|
||||
BTabView *tabView;
|
||||
BTab *tab;
|
||||
BBox *topLevelView;
|
||||
double buttonViewHeight = 38.0;
|
||||
double buttonViewHeight = 43.0;
|
||||
|
||||
r = Bounds();
|
||||
r.InsetBy(0, 10);
|
||||
r.bottom -= buttonViewHeight;
|
||||
r.top += 10;
|
||||
r.bottom -= buttonViewHeight+1;
|
||||
|
||||
tabView = new BTabView(r, "tab_view", B_WIDTH_FROM_WIDEST);
|
||||
tabView = new BTabView(r, "tab_view", B_WIDTH_FROM_LABEL);
|
||||
tabView->SetViewColor(216,216,216,0);
|
||||
|
||||
r = tabView->Bounds();
|
||||
r.InsetBy(5,5);
|
||||
r.bottom -= tabView->TabHeight();
|
||||
r.InsetBy(5, 5);
|
||||
r.bottom -= tabView->TabHeight();
|
||||
r.right -=2;
|
||||
tab = new BTab();
|
||||
tabView->AddTab(fontPanel = new FontView(r), tab);
|
||||
tab->SetLabel("Fonts");
|
||||
tab->SetLabel(" Fonts ");
|
||||
tab = new BTab();
|
||||
tabView->AddTab(cachePanel = new CacheView(r, 64, 4096, (int32) 256, (int32) 256), tab);
|
||||
tab->SetLabel("Cache");
|
||||
@ -59,8 +60,10 @@ MainWindow::MainWindow(BRect frame)
|
||||
*/
|
||||
bool MainWindow::QuitRequested()
|
||||
{
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return(true);
|
||||
BMessage *message = new BMessage(B_QUIT_REQUESTED);
|
||||
message->AddPoint("corner", Frame().LeftTop());
|
||||
be_app->PostMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
30
src/prefs/fonts/Pref_Utils.cpp
Normal file
30
src/prefs/fonts/Pref_Utils.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include "Pref_Utils.h"
|
||||
|
||||
float
|
||||
FontHeight(bool full, BView* target)
|
||||
{
|
||||
font_height finfo;
|
||||
if (target != NULL)
|
||||
target->GetFontHeight(&finfo);
|
||||
else
|
||||
be_plain_font->GetHeight(&finfo);
|
||||
|
||||
float height = ceil(finfo.ascent) + ceil(finfo.descent);
|
||||
|
||||
if (full)
|
||||
height += ceil(finfo.leading);
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
color_map*
|
||||
ColorMap()
|
||||
{
|
||||
color_map* cmap;
|
||||
|
||||
BScreen screen(B_MAIN_SCREEN_ID);
|
||||
cmap = (color_map*)screen.ColorMap();
|
||||
|
||||
return cmap;
|
||||
}
|
||||
|
10
src/prefs/fonts/Pref_Utils.h
Normal file
10
src/prefs/fonts/Pref_Utils.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef SHARED_PREF_UTILS
|
||||
#define SHARED_PREF_UTILS
|
||||
|
||||
#include <Screen.h>
|
||||
#include <View.h>
|
||||
|
||||
float FontHeight(bool full, BView* view = NULL);
|
||||
color_map* ColorMap();
|
||||
|
||||
#endif
|
Binary file not shown.
@ -14,6 +14,8 @@
|
||||
|
||||
#endif
|
||||
|
||||
#include "FontsSettings.h"
|
||||
|
||||
/**
|
||||
* Main method.
|
||||
*
|
||||
@ -38,22 +40,36 @@ int main(int, char**){
|
||||
* Provides a contstructor for the application.
|
||||
*/
|
||||
Font_pref::Font_pref()
|
||||
:BApplication("application/x-vnd.MSM-FontPrefPanel"){
|
||||
:BApplication("application/x-vnd.Haiku-FNPL") {
|
||||
|
||||
/*
|
||||
* The main interface window.
|
||||
*/
|
||||
MainWindow *Main;
|
||||
|
||||
/*
|
||||
* Sets the size for the main window.
|
||||
*/
|
||||
f_settings = new FontsSettings();
|
||||
BRect MainWindowRect;
|
||||
|
||||
MainWindowRect.Set(100, 80, 450, 350);
|
||||
Main = new MainWindow(MainWindowRect);
|
||||
|
||||
Main->Show();
|
||||
|
||||
MainWindowRect.Set(100, 80, 445, 343);
|
||||
window = new MainWindow(MainWindowRect);
|
||||
window->MoveTo(f_settings->WindowCorner());
|
||||
}
|
||||
|
||||
Font_pref::~Font_pref()
|
||||
{
|
||||
delete f_settings;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Font_pref::QuitRequested()
|
||||
{
|
||||
BMessage *message = CurrentMessage();
|
||||
BPoint point;
|
||||
if (message->FindPoint("corner", &point) == B_OK) {
|
||||
f_settings->SetWindowCorner(point);
|
||||
}
|
||||
|
||||
return BApplication::QuitRequested();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Font_pref::ReadyToRun()
|
||||
{
|
||||
window->Show();
|
||||
}
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
#endif
|
||||
|
||||
class FontsSettings;
|
||||
class MainWindow;
|
||||
/**
|
||||
* Main class.
|
||||
*
|
||||
@ -26,7 +28,12 @@
|
||||
* Constructor.
|
||||
*/
|
||||
Font_pref();
|
||||
|
||||
~Font_pref();
|
||||
void ReadyToRun();
|
||||
bool QuitRequested();
|
||||
private:
|
||||
FontsSettings *f_settings;
|
||||
MainWindow *window;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user