Serious cleanup:
Most files updated to style guidelines Panel now updates cache size temporarily disabled revert code while cleaning up the code settings file is now a flattened BMessage for the app_server's sake Unhacking some of the code git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13020 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,47 +1,36 @@
|
|||||||
/*! \file ButtonView.cpp
|
/*
|
||||||
* \brief Code for the ButtonView.
|
* Copyright 2001-2005, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
#include "ButtonView.h"
|
||||||
|
|
||||||
#ifndef BUTTON_VIEW_H
|
|
||||||
|
|
||||||
#include "ButtonView.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param rect The size of the view.
|
|
||||||
*/
|
|
||||||
ButtonView::ButtonView(BRect rect)
|
ButtonView::ButtonView(BRect rect)
|
||||||
:BView(rect, "ButtonView", B_FOLLOW_ALL, B_WILL_DRAW)
|
: BView(rect, "ButtonView", B_FOLLOW_ALL, B_WILL_DRAW)
|
||||||
{
|
{
|
||||||
SetViewColor(216,216,216,0);
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
BRect btnRect(0, 0, 75, 25);
|
BRect btnRect(0, 0, 75, 25);
|
||||||
btnRect.OffsetBy(10, 8);
|
btnRect.OffsetBy(10, 8);
|
||||||
BButton *rescanButton = new BButton(btnRect,
|
BButton *rescanButton = new BButton(btnRect, "rescanButton", "Rescan",
|
||||||
"rescanButton", "Rescan",
|
new BMessage(RESCAN_FONTS_MSG),
|
||||||
new BMessage(RESCAN_FONTS_MSG),
|
B_FOLLOW_LEFT, B_WILL_DRAW);
|
||||||
B_FOLLOW_LEFT, B_WILL_DRAW);
|
AddChild(rescanButton);
|
||||||
|
|
||||||
btnRect.OffsetBy(96, 0);
|
btnRect.OffsetBy(96, 0);
|
||||||
BButton *defaultsButton = new BButton(btnRect,
|
BButton *defaultsButton = new BButton(btnRect, "defaultsButton",
|
||||||
"defaultsButton", "Defaults",
|
"Defaults",
|
||||||
new BMessage(RESET_FONTS_MSG),
|
new BMessage(RESET_FONTS_MSG),
|
||||||
B_FOLLOW_LEFT, B_WILL_DRAW);
|
B_FOLLOW_LEFT, B_WILL_DRAW);
|
||||||
|
AddChild(defaultsButton);
|
||||||
|
|
||||||
btnRect.OffsetBy(85, 0);
|
btnRect.OffsetBy(85, 0);
|
||||||
revertButton = new BButton(btnRect,
|
revertButton = new BButton(btnRect, "revertButton", "Revert",
|
||||||
"revertButton", "Revert",
|
new BMessage(REVERT_MSG),
|
||||||
new BMessage(REVERT_MSG),
|
B_FOLLOW_LEFT, B_WILL_DRAW);
|
||||||
B_FOLLOW_LEFT, B_WILL_DRAW);
|
|
||||||
|
|
||||||
revertButton->SetEnabled(false);
|
|
||||||
|
|
||||||
AddChild(rescanButton);
|
|
||||||
AddChild(defaultsButton);
|
|
||||||
AddChild(revertButton);
|
AddChild(revertButton);
|
||||||
|
|
||||||
|
revertButton->SetEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -51,31 +40,27 @@ ButtonView::Draw(BRect update)
|
|||||||
rgb_color dark = {100, 100, 100, 255};
|
rgb_color dark = {100, 100, 100, 255};
|
||||||
rgb_color light = {255, 255, 255, 255};
|
rgb_color light = {255, 255, 255, 255};
|
||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
|
|
||||||
BeginLineArray(6);
|
BeginLineArray(6);
|
||||||
AddLine(bounds.LeftTop(), bounds.RightTop(), light);
|
|
||||||
AddLine(bounds.LeftTop(), bounds.LeftBottom(), light);
|
AddLine(bounds.LeftTop(), bounds.RightTop(), light);
|
||||||
AddLine(bounds.RightTop(), bounds.RightBottom(), dark);
|
AddLine(bounds.LeftTop(), bounds.LeftBottom(), light);
|
||||||
AddLine(bounds.RightBottom(), bounds.LeftBottom(), dark);
|
AddLine(bounds.RightTop(), bounds.RightBottom(), dark);
|
||||||
AddLine(BPoint(95, 9), BPoint(95, 34), dark);
|
AddLine(bounds.RightBottom(), bounds.LeftBottom(), dark);
|
||||||
AddLine(BPoint(96, 9), BPoint(96, 34), light);
|
AddLine(BPoint(95, 9), BPoint(95, 34), dark);
|
||||||
|
AddLine(BPoint(96, 9), BPoint(96, 34), light);
|
||||||
|
|
||||||
EndLineArray();
|
EndLineArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
bool
|
||||||
* Returns the state of the revert button.
|
ButtonView::RevertState()
|
||||||
*/
|
{
|
||||||
bool ButtonView::RevertState(){
|
|
||||||
|
|
||||||
return revertButton->IsEnabled();
|
return revertButton->IsEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
}//RevertState
|
void ButtonView::SetRevertState(bool b)
|
||||||
|
{
|
||||||
/**
|
|
||||||
* Sets the state of the revert button.
|
|
||||||
*/
|
|
||||||
void ButtonView::SetRevertState(bool b){
|
|
||||||
|
|
||||||
revertButton->SetEnabled(b);
|
revertButton->SetEnabled(b);
|
||||||
|
}
|
||||||
}//SetRevertState
|
|
||||||
|
|||||||
@@ -1,49 +1,34 @@
|
|||||||
/*! \file ButtonView.h
|
/*
|
||||||
* \brief Header file for the ButtonView class.
|
* Copyright 2001-2005, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BUTTON_VIEW_H
|
#ifndef BUTTON_VIEW_H
|
||||||
|
#define BUTTON_VIEW_H
|
||||||
|
|
||||||
#define BUTTON_VIEW_H
|
#include <View.h>
|
||||||
|
#include <Button.h>
|
||||||
|
|
||||||
/*!
|
// Message sent when the rescan button is sent.
|
||||||
* Message sent when the rescan button is sent.
|
#define RESCAN_FONTS_MSG 'rscn'
|
||||||
*/
|
|
||||||
#define RESCAN_FONTS_MSG 'rscn'
|
|
||||||
|
|
||||||
/*!
|
// Message sent when the reset button is sent.
|
||||||
* Message sent when the reset button is sent.
|
#define RESET_FONTS_MSG 'rset'
|
||||||
*/
|
|
||||||
#define RESET_FONTS_MSG 'rset'
|
|
||||||
|
|
||||||
/*!
|
// Message sent when the revert button is sent.
|
||||||
* Message sent when the revert button is sent.
|
#define REVERT_MSG 'rvrt'
|
||||||
*/
|
|
||||||
#define REVERT_MSG 'rvrt'
|
|
||||||
|
|
||||||
#include <View.h>
|
|
||||||
|
|
||||||
#ifndef _BUTTON_H
|
|
||||||
|
|
||||||
#include <Button.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class ButtonView : public BView {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
class ButtonView : public BView
|
||||||
|
{
|
||||||
|
public:
|
||||||
ButtonView(BRect frame);
|
ButtonView(BRect frame);
|
||||||
bool RevertState();
|
bool RevertState();
|
||||||
void SetRevertState(bool b);
|
void SetRevertState(bool b);
|
||||||
void Draw(BRect);
|
void Draw(BRect);
|
||||||
private:
|
|
||||||
|
|
||||||
/**
|
private:
|
||||||
* The revert button.
|
|
||||||
*/
|
|
||||||
BButton *revertButton;
|
|
||||||
|
|
||||||
};
|
BButton *revertButton;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+113
-95
@@ -1,130 +1,147 @@
|
|||||||
/*! \file CacheView.cpp
|
/*
|
||||||
* \brief The file that contains code for the CacheView.
|
* Copyright 2001-2005, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef CACHE_VIEW_H
|
#include "CacheView.h"
|
||||||
|
|
||||||
#include "CacheView.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include "Pref_Utils.h"
|
#include "Pref_Utils.h"
|
||||||
|
|
||||||
const char *kLabel = "font cache size: ";
|
#define PRINT_FCS_UPDATE_MSG 'pfum'
|
||||||
|
#define SCREEN_FCS_UPDATE_MSG 'sfum'
|
||||||
|
#define PRINT_FCS_MODIFICATION_MSG 'pfmm'
|
||||||
|
#define SCREEN_FCS_MODIFICATION_MSG 'sfmm'
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
CacheView::CacheView(const BRect &frame, const int32 &sliderMin,
|
||||||
* @param rect The size of the view.
|
const int32 &sliderMax, const int32 &printVal,
|
||||||
* @param minVal The minimum value of the cache sliders.
|
const int32 &screenVal)
|
||||||
* @param maxVal The maximum value of the cache sliders.
|
|
||||||
* @param printCurrVal The starting value of the print slider.
|
: BView(frame, "Cache", B_FOLLOW_ALL, B_WILL_DRAW),
|
||||||
* @param screenCurrVal The starting value of the screen slider.
|
fSavedPrintValue(printVal),
|
||||||
*/
|
fSavedScreenValue(screenVal)
|
||||||
CacheView::CacheView(BRect rect, int minVal, int maxVal, int32 printCurrVal, int32 screenCurrVal)
|
|
||||||
:BView(rect, "CacheView", B_FOLLOW_ALL, B_WILL_DRAW)
|
|
||||||
{
|
{
|
||||||
SetViewColor(216, 216, 216, 0);
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
origPrintVal = printCurrVal;
|
rgb_color fillColor = { 102, 152, 203, 255 };
|
||||||
origScreenVal = screenCurrVal;
|
|
||||||
|
|
||||||
rgb_color fillColor;
|
|
||||||
fillColor.red = 102;
|
|
||||||
fillColor.blue = 203;
|
|
||||||
fillColor.green = 152;
|
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
BString minLabel(B_EMPTY_STRING);
|
BString minLabel(B_EMPTY_STRING);
|
||||||
BString maxLabel(B_EMPTY_STRING);
|
BString maxLabel(B_EMPTY_STRING);
|
||||||
minLabel << minVal << " kB";
|
|
||||||
maxLabel << maxVal << " kB";
|
float fontheight = FontHeight(true);
|
||||||
screenFCS->SetLimitLabels(minLabel.String(), maxLabel.String());
|
|
||||||
screenFCS->UseFillColor(TRUE, &fillColor);
|
BRect rect( Bounds().InsetByCopy(5.0,3.0) );
|
||||||
screenFCS->SetValue(screenCurrVal);
|
rect.top += fontheight;
|
||||||
|
rect.bottom = rect.top +(fontheight *2.0);
|
||||||
|
|
||||||
|
BString labels(B_EMPTY_STRING);
|
||||||
|
labels << "Screen font cache size: " << screenVal << " kB";
|
||||||
|
|
||||||
|
fScreenSlider = new BSlider(rect, "screenslider", labels.String(),
|
||||||
|
new BMessage(SCREEN_FCS_UPDATE_MSG),
|
||||||
|
sliderMin, sliderMax, B_TRIANGLE_THUMB);
|
||||||
|
|
||||||
|
fScreenSlider->SetModificationMessage(new BMessage(SCREEN_FCS_MODIFICATION_MSG));
|
||||||
|
AddChild(fScreenSlider);
|
||||||
|
|
||||||
|
minLabel << sliderMin << " kB";
|
||||||
|
maxLabel << sliderMax << " kB";
|
||||||
|
|
||||||
|
fScreenSlider->SetLimitLabels(minLabel.String(), maxLabel.String());
|
||||||
|
fScreenSlider->UseFillColor(TRUE, &fillColor);
|
||||||
|
fScreenSlider->SetValue(screenVal);
|
||||||
|
|
||||||
rect.OffsetTo(rect.left, rect.bottom +(fontheight *2.5));
|
rect.OffsetTo(rect.left, rect.bottom +(fontheight *2.5));
|
||||||
|
|
||||||
labels = "";
|
labels = "";
|
||||||
labels << "Printing " << kLabel << printCurrVal << " kB";
|
labels << "Printing font cache size: " << printVal << " kB";
|
||||||
|
|
||||||
printFCS = new BSlider(rect, "printFontCache", labels.String(),
|
fPrintSlider = new BSlider(rect, "printFontCache", labels.String(),
|
||||||
new BMessage(PRINT_FCS_UPDATE_MSG),
|
new BMessage(PRINT_FCS_UPDATE_MSG),
|
||||||
minVal, maxVal, B_TRIANGLE_THUMB);
|
sliderMin, sliderMax, B_TRIANGLE_THUMB);
|
||||||
|
AddChild(fPrintSlider);
|
||||||
|
|
||||||
printFCS->SetModificationMessage(new BMessage(PRINT_FCS_MODIFICATION_MSG));
|
fPrintSlider->SetModificationMessage(new BMessage(PRINT_FCS_MODIFICATION_MSG));
|
||||||
|
|
||||||
printFCS->SetLimitLabels(minLabel.String(), maxLabel.String());
|
fPrintSlider->SetLimitLabels(minLabel.String(), maxLabel.String());
|
||||||
printFCS->UseFillColor(TRUE, &fillColor);
|
fPrintSlider->UseFillColor(TRUE, &fillColor);
|
||||||
printFCS->SetValue(printCurrVal);
|
fPrintSlider->SetValue(printVal);
|
||||||
|
|
||||||
rect.OffsetTo(rect.left -1.0, rect.bottom +(fontheight *2.0));
|
rect.OffsetTo(rect.left -1.0, rect.bottom +(fontheight *2.0));
|
||||||
rect.right = rect.left +86.0;
|
rect.right = rect.left +86.0;
|
||||||
rect.bottom = rect.top +24.0;
|
rect.bottom = rect.top +24.0;
|
||||||
|
|
||||||
BButton *saveCache = new BButton(rect,
|
// TODO: find out what 'Save Cache' does and implement
|
||||||
"saveCache", "Save Cache",
|
fSaveCache = new BButton(rect, "saveCache", "Save Cache",
|
||||||
NULL, B_FOLLOW_LEFT, B_WILL_DRAW);
|
NULL, B_FOLLOW_LEFT, B_WILL_DRAW);
|
||||||
|
AddChild(fSaveCache);
|
||||||
AddChild(screenFCS);
|
|
||||||
AddChild(printFCS);
|
|
||||||
AddChild(saveCache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void
|
||||||
* Updates the label on the print slider.
|
CacheView::AttachedToWindow(void)
|
||||||
* @param txt The text to update the slider to.
|
{
|
||||||
*/
|
fScreenSlider->SetTarget(this);
|
||||||
void CacheView::updatePrintFCS(const char* txt){
|
fPrintSlider->SetTarget(this);
|
||||||
|
fSaveCache->SetTarget(this);
|
||||||
|
}
|
||||||
|
|
||||||
printFCS->SetLabel(txt);
|
void
|
||||||
|
CacheView::MessageReceived(BMessage *msg)
|
||||||
|
{
|
||||||
|
switch(msg->what)
|
||||||
|
{
|
||||||
|
case PRINT_FCS_MODIFICATION_MSG:
|
||||||
|
{
|
||||||
|
struct font_cache_info fontCacheInfo;
|
||||||
|
|
||||||
}//updatePrintFCS
|
get_font_cache_info(B_PRINTING_FONT_CACHE|B_DEFAULT_CACHE_SETTING,
|
||||||
|
&fontCacheInfo);
|
||||||
|
fontCacheInfo.cache_size = fPrintSlider->Value() << 10;
|
||||||
|
set_font_cache_info(B_PRINTING_FONT_CACHE|B_DEFAULT_CACHE_SETTING,
|
||||||
|
&fontCacheInfo);
|
||||||
|
|
||||||
/**
|
BString str("Printing font cache size : ");
|
||||||
* Updates the label on the screen slider.
|
str << fPrintSlider->Value() << " kB";
|
||||||
* @param txt The text to update the slider to.
|
fPrintSlider->SetLabel(str.String());
|
||||||
*/
|
|
||||||
void CacheView::updateScreenFCS(const char* txt){
|
|
||||||
|
|
||||||
screenFCS->SetLabel(txt);
|
// TODO: set revert state
|
||||||
|
// buttonView->SetRevertState(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SCREEN_FCS_MODIFICATION_MSG:
|
||||||
|
{
|
||||||
|
struct font_cache_info fontCacheInfo;
|
||||||
|
|
||||||
}//updatePrintFCS
|
get_font_cache_info(B_SCREEN_FONT_CACHE|B_DEFAULT_CACHE_SETTING,
|
||||||
|
&fontCacheInfo);
|
||||||
|
fontCacheInfo.cache_size = fScreenSlider->Value() << 10;
|
||||||
|
set_font_cache_info(B_SCREEN_FONT_CACHE|B_DEFAULT_CACHE_SETTING,
|
||||||
|
&fontCacheInfo);
|
||||||
|
|
||||||
/**
|
BString str("Screen font cache size : ");
|
||||||
* Gets the current value of the print slider.
|
str << fScreenSlider->Value() << " kB";
|
||||||
*/
|
fScreenSlider->SetLabel(str.String());
|
||||||
int CacheView::getPrintFCSValue(){
|
|
||||||
|
|
||||||
return int(printFCS->Value());
|
// TODO: set revert state
|
||||||
|
// buttonView->SetRevertState(true);
|
||||||
}//getPrintValue
|
break;
|
||||||
|
}
|
||||||
/**
|
default:
|
||||||
* Gets the current value of the screen slider.
|
{
|
||||||
*/
|
BView::MessageReceived(msg);
|
||||||
int CacheView::getScreenFCSValue(){
|
break;
|
||||||
|
}
|
||||||
return int(screenFCS->Value());
|
}
|
||||||
|
}
|
||||||
}//getPrintValue
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the sliders to their original values.
|
* Sets the sliders to their original values.
|
||||||
*/
|
*/
|
||||||
void CacheView::revertToOriginal(){
|
void CacheView::revertToOriginal(){
|
||||||
|
// TODO: fix
|
||||||
|
/*
|
||||||
BString label;
|
BString label;
|
||||||
label << "Screen " << kLabel << getScreenFCSValue();
|
label << "Screen " << kLabel << getScreenFCSValue();
|
||||||
updateScreenFCS(label.String());
|
updateScreenFCS(label.String());
|
||||||
@@ -132,20 +149,21 @@ void CacheView::revertToOriginal(){
|
|||||||
label = "Printing ";
|
label = "Printing ";
|
||||||
label << kLabel << getPrintFCSValue();
|
label << kLabel << getPrintFCSValue();
|
||||||
updatePrintFCS(label.String());
|
updatePrintFCS(label.String());
|
||||||
|
*/
|
||||||
}//revertToOriginal
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the sliders to their default values.
|
* Sets the sliders to their default values.
|
||||||
*/
|
*/
|
||||||
void CacheView::resetToDefaults(){
|
void CacheView::resetToDefaults(){
|
||||||
BString label;
|
// TODO: fix
|
||||||
|
/* BString label;
|
||||||
label << "Screen " << kLabel << getScreenFCSValue() << " kB";
|
label << "Screen " << kLabel << getScreenFCSValue() << " kB";
|
||||||
updateScreenFCS(label.String());
|
updateScreenFCS(label.String());
|
||||||
|
|
||||||
label = "Printing ";
|
label = "Printing ";
|
||||||
label << kLabel << getPrintFCSValue() << " kB";
|
label << kLabel << getPrintFCSValue() << " kB";
|
||||||
updatePrintFCS(label.String());
|
updatePrintFCS(label.String());
|
||||||
|
*/
|
||||||
}//revertToOriginal
|
}
|
||||||
|
|
||||||
|
|||||||
+27
-76
@@ -1,86 +1,37 @@
|
|||||||
/*! \file CacheView.h
|
/*
|
||||||
* \brief Header file for the CacheView class.
|
* Copyright 2001-2005, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CACHE_VIEW_H
|
#ifndef CACHE_VIEW_H
|
||||||
|
#define CACHE_VIEW_H
|
||||||
|
|
||||||
#define CACHE_VIEW_H
|
#include <View.h>
|
||||||
|
#include <Box.h>
|
||||||
|
#include <Slider.h>
|
||||||
|
#include <Button.h>
|
||||||
|
|
||||||
/*!
|
class CacheView : public BView
|
||||||
* Message sent when the print slider is updated.
|
{
|
||||||
*/
|
public:
|
||||||
#define PRINT_FCS_UPDATE_MSG 'pfum'
|
CacheView(const BRect &frame, const int32 &sliderMin,
|
||||||
|
const int32 &sliderMax, const int32 &printVal,
|
||||||
|
const int32 &screenVal);
|
||||||
|
void AttachedToWindow(void);
|
||||||
|
void MessageReceived(BMessage *msg);
|
||||||
|
|
||||||
/*!
|
void revertToOriginal();
|
||||||
* Message sent when the screen slider is updated.
|
void resetToDefaults();
|
||||||
*/
|
|
||||||
#define SCREEN_FCS_UPDATE_MSG 'sfum'
|
|
||||||
|
|
||||||
/*!
|
private:
|
||||||
* Message sent when the print slider is modified.
|
|
||||||
*/
|
|
||||||
#define PRINT_FCS_MODIFICATION_MSG 'pfmm'
|
|
||||||
|
|
||||||
/*!
|
BSlider *fScreenSlider;
|
||||||
* Message sent when the screen slider is modified.
|
BSlider *fPrintSlider;
|
||||||
*/
|
BButton *fSaveCache;
|
||||||
#define SCREEN_FCS_MODIFICATION_MSG 'sfmm'
|
|
||||||
|
|
||||||
#ifndef _VIEW_H
|
// The original slider values
|
||||||
|
int32 fSavedPrintValue;
|
||||||
#include <View.h>
|
int32 fSavedScreenValue;
|
||||||
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _BOX_H
|
|
||||||
|
|
||||||
#include <Box.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#ifndef _SLIDER_H
|
|
||||||
|
|
||||||
#include <Slider.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#ifndef _BUTTON_H
|
|
||||||
|
|
||||||
#include <Button.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class CacheView : public BView{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
CacheView(BRect frame, int minVal, int maxVal, int32 printCurrVal, int32 screenCurrVal);
|
|
||||||
void updatePrintFCS(const char* txt);
|
|
||||||
void updateScreenFCS(const char* txt);
|
|
||||||
int getPrintFCSValue();
|
|
||||||
int getScreenFCSValue();
|
|
||||||
void revertToOriginal();
|
|
||||||
void resetToDefaults();
|
|
||||||
private:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The screen cache slider.
|
|
||||||
*/
|
|
||||||
BSlider *screenFCS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The print cache slider.
|
|
||||||
*/
|
|
||||||
BSlider *printFCS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The original print slider value.
|
|
||||||
*/
|
|
||||||
int32 origPrintVal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The original screen slider value.
|
|
||||||
*/
|
|
||||||
int32 origScreenVal;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,84 +1,67 @@
|
|||||||
/*! \file FontSelectionView.cpp
|
/*
|
||||||
\brief Header for the FontSelectionView class.
|
* Copyright 2001-2005, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
#ifndef FONT_SELECTION_VIEW_H
|
#include "FontSelectionView.h"
|
||||||
|
|
||||||
#include "FontSelectionView.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Pref_Utils.h"
|
#include "Pref_Utils.h"
|
||||||
|
|
||||||
|
#define SIZE_CHANGED_MSG 'plsz'
|
||||||
|
#define FONT_CHANGED_MSG 'plfn'
|
||||||
|
#define STYLE_CHANGED_MSG 'plst'
|
||||||
|
|
||||||
// should be changed to allow larger and smaller
|
// should be changed to allow larger and smaller
|
||||||
#define minSizeIndex 7
|
#define minSizeIndex 9
|
||||||
#define maxSizeIndex 12
|
#define maxSizeIndex 14
|
||||||
|
|
||||||
// constants for labels
|
// constants for labels
|
||||||
const char *kPlainFont = "Plain font:";
|
const char *kPlainFont = "Plain font:";
|
||||||
const char *kBoldFont = "Bold font:";
|
const char *kBoldFont = "Bold font:";
|
||||||
const char *kFixedFont = "Fixed font:";
|
const char *kFixedFont = "Fixed font:";
|
||||||
const char *kSize = "Size: ";
|
const char *kSize = "Size: ";
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param rect The size of the view.
|
|
||||||
* @param name The name of the view.
|
|
||||||
* @param type The type of the view: plain, italic, etc.
|
|
||||||
*/
|
|
||||||
FontSelectionView::FontSelectionView(BRect rect, const char *name, int type)
|
FontSelectionView::FontSelectionView(BRect rect, const char *name, int type)
|
||||||
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
|
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
|
||||||
{
|
{
|
||||||
|
switch(type)
|
||||||
switch(type){
|
{
|
||||||
|
|
||||||
case PLAIN_FONT_SELECTION_VIEW:
|
|
||||||
|
|
||||||
sprintf(typeLabel, kPlainFont);
|
|
||||||
origFont = be_plain_font;
|
|
||||||
workingFont = be_plain_font;
|
|
||||||
setSizeChangedMessage = PLAIN_SIZE_CHANGED_MSG;
|
|
||||||
setFontChangedMessage = PLAIN_FONT_CHANGED_MSG;
|
|
||||||
setStyleChangedMessage = PLAIN_STYLE_CHANGED_MSG;
|
|
||||||
|
|
||||||
defaultFont = new BFont();
|
|
||||||
defaultFont->SetFamilyAndStyle("Swis721 BT", "Roman");
|
|
||||||
defaultFont->SetSize(10.0);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BOLD_FONT_SELECTION_VIEW:
|
case BOLD_FONT_SELECTION_VIEW:
|
||||||
|
{
|
||||||
sprintf(typeLabel, kBoldFont);
|
sprintf(typeLabel, kBoldFont);
|
||||||
origFont = be_bold_font;
|
origFont = be_bold_font;
|
||||||
workingFont = be_bold_font;
|
workingFont = be_bold_font;
|
||||||
setSizeChangedMessage = BOLD_SIZE_CHANGED_MSG;
|
|
||||||
setFontChangedMessage = BOLD_FONT_CHANGED_MSG;
|
|
||||||
setStyleChangedMessage = BOLD_STYLE_CHANGED_MSG;
|
|
||||||
|
|
||||||
defaultFont = new BFont();
|
defaultFont = new BFont();
|
||||||
defaultFont->SetFamilyAndStyle("Swis721 BT", "Bold");
|
defaultFont->SetFamilyAndStyle("Swis721 BT", "Bold");
|
||||||
defaultFont->SetSize(12.0);
|
defaultFont->SetSize(12.0);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case FIXED_FONT_SELECTION_VIEW:
|
case FIXED_FONT_SELECTION_VIEW:
|
||||||
|
{
|
||||||
sprintf(typeLabel, kFixedFont);
|
sprintf(typeLabel, kFixedFont);
|
||||||
origFont = be_fixed_font;
|
origFont = be_fixed_font;
|
||||||
workingFont = be_fixed_font;
|
workingFont = be_fixed_font;
|
||||||
setSizeChangedMessage = FIXED_SIZE_CHANGED_MSG;
|
|
||||||
setFontChangedMessage = FIXED_FONT_CHANGED_MSG;
|
|
||||||
setStyleChangedMessage = FIXED_STYLE_CHANGED_MSG;
|
|
||||||
|
|
||||||
defaultFont = new BFont();
|
defaultFont = new BFont();
|
||||||
defaultFont->SetFamilyAndStyle("Courier10 BT", "Roman");
|
defaultFont->SetFamilyAndStyle("Courier10 BT", "Roman");
|
||||||
defaultFont->SetSize(12.0);
|
defaultFont->SetSize(12.0);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
sprintf(typeLabel, kPlainFont);
|
||||||
|
origFont = be_plain_font;
|
||||||
|
workingFont = be_plain_font;
|
||||||
|
|
||||||
}//switch
|
defaultFont = new BFont();
|
||||||
|
defaultFont->SetFamilyAndStyle("Swis721 BT", "Roman");
|
||||||
|
defaultFont->SetSize(10.0);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float fontheight = FontHeight(false);
|
float fontheight = FontHeight(false);
|
||||||
float divider = StringWidth(kFixedFont);
|
float divider = StringWidth(kFixedFont);
|
||||||
@@ -87,7 +70,8 @@ FontSelectionView::FontSelectionView(BRect rect, const char *name, int type)
|
|||||||
fontList = new BPopUpMenu("fontList", true, true, B_ITEMS_IN_COLUMN);
|
fontList = new BPopUpMenu("fontList", true, true, B_ITEMS_IN_COLUMN);
|
||||||
|
|
||||||
// create menus
|
// create menus
|
||||||
// size box
|
|
||||||
|
// size box
|
||||||
rect = Bounds();
|
rect = Bounds();
|
||||||
float x = StringWidth("999") +16;
|
float x = StringWidth("999") +16;
|
||||||
rect.left = rect.right -(x +StringWidth(kSize)+8.0);
|
rect.left = rect.right -(x +StringWidth(kSize)+8.0);
|
||||||
@@ -95,7 +79,8 @@ FontSelectionView::FontSelectionView(BRect rect, const char *name, int type)
|
|||||||
BMenuField *sizeListField = new BMenuField(rect, "fontField", kSize, sizeList, true);
|
BMenuField *sizeListField = new BMenuField(rect, "fontField", kSize, sizeList, true);
|
||||||
sizeListField->SetDivider(StringWidth(kSize)+5.0);
|
sizeListField->SetDivider(StringWidth(kSize)+5.0);
|
||||||
sizeListField->SetAlignment(B_ALIGN_RIGHT);
|
sizeListField->SetAlignment(B_ALIGN_RIGHT);
|
||||||
// font menu
|
|
||||||
|
// font menu
|
||||||
rect.right = rect.left;
|
rect.right = rect.left;
|
||||||
rect.left = 1;
|
rect.left = 1;
|
||||||
rect.bottom = fontheight *1.5;
|
rect.bottom = fontheight *1.5;
|
||||||
@@ -130,152 +115,170 @@ FontSelectionView::FontSelectionView(BRect rect, const char *name, int type)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
FontSelectionView::~FontSelectionView(void)
|
||||||
* Emptys the menu so it can be rebuilt.
|
{
|
||||||
* @param m The menu to empty.
|
delete defaultFont;
|
||||||
*/
|
}
|
||||||
void FontSelectionView::emptyMenu(BPopUpMenu *m){
|
|
||||||
|
|
||||||
int32 cnt;
|
void
|
||||||
int32 numItemsInMenu = m->CountItems();
|
FontSelectionView::AttachedToWindow(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
for(cnt = 0;cnt < numItemsInMenu;cnt++){
|
void
|
||||||
|
FontSelectionView::MessageReceived(BMessage *msg)
|
||||||
|
{
|
||||||
|
switch(msg->what)
|
||||||
|
{
|
||||||
|
/* case SIZE_CHANGED_MSG: {
|
||||||
|
|
||||||
BMenu *tmp;
|
updateSize(fSelectorView->plainSelectionView);
|
||||||
BMenuItem *tmpI;
|
fButtonView->SetRevertState(true);
|
||||||
int32 cnt2;
|
break;
|
||||||
int32 numItemsInSubmenu;
|
}
|
||||||
|
case FONT_CHANGED_MSG: {
|
||||||
|
|
||||||
tmpI = m->RemoveItem((int32) 0);
|
updateFont(fSelectorView->plainSelectionView);
|
||||||
tmp = tmpI->Submenu();
|
fButtonView->SetRevertState(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STYLE_CHANGED_MSG: {
|
||||||
|
|
||||||
if(tmp != NULL){
|
updateStyle(fSelectorView->plainSelectionView);
|
||||||
|
fButtonView->SetRevertState(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RESCAN_FONTS_MSG: {
|
||||||
|
|
||||||
numItemsInSubmenu = tmp->CountItems();
|
update_font_families(false);
|
||||||
for(cnt2 = 0;cnt2 < numItemsInSubmenu;cnt2++){
|
fSelectorView->emptyMenus();
|
||||||
|
fSelectorView->buildMenus();
|
||||||
|
updateFont(fSelectorView->plainSelectionView);
|
||||||
|
updateFont(fSelectorView->boldSelectionView);
|
||||||
|
updateFont(fSelectorView->fixedSelectionView);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RESET_FONTS_MSG: {
|
||||||
|
|
||||||
BMenuItem *tmpItem;
|
fSelectorView->resetToDefaults();
|
||||||
|
fCacheView->resetToDefaults();
|
||||||
|
fButtonView->SetRevertState(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*/ default:
|
||||||
|
BView::MessageReceived(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tmpItem = tmp->RemoveItem((int32) 0);
|
void FontSelectionView::emptyMenus(void)
|
||||||
delete tmpItem;
|
{
|
||||||
|
// Empty the font list
|
||||||
|
for(int32 i = 0; i < fontList->CountItems(); i++)
|
||||||
|
{
|
||||||
|
BMenu *menu = fontList->SubmenuAt(0L);
|
||||||
|
|
||||||
}//for
|
// We should never have a regular menu item in the font list
|
||||||
|
if(!menu)
|
||||||
|
continue;
|
||||||
|
|
||||||
}//if
|
for(int32 j=0; j < menu->CountItems(); j++)
|
||||||
|
{
|
||||||
|
BMenuItem *item = menu->RemoveItem(0L);
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
|
||||||
delete tmpI;
|
fontList->RemoveItem(menu);
|
||||||
|
delete menu;
|
||||||
|
}
|
||||||
|
|
||||||
}//for
|
// empty the size list
|
||||||
|
for(int32 i = 0; i < sizeList->CountItems(); i++)
|
||||||
}//emptyMenu
|
{
|
||||||
|
BMenuItem *item = sizeList->RemoveItem(0L);
|
||||||
/**
|
delete item;
|
||||||
* Emptys both the font and the size menus.
|
}
|
||||||
*/
|
}
|
||||||
void FontSelectionView::emptyMenus(){
|
|
||||||
|
|
||||||
//empty font menu
|
|
||||||
emptyMenu(fontList);
|
|
||||||
|
|
||||||
//empty size menu
|
|
||||||
emptyMenu(sizeList);
|
|
||||||
|
|
||||||
}//emptyMenus
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the font and size menus.
|
|
||||||
*/
|
|
||||||
void FontSelectionView::buildMenus(){
|
|
||||||
|
|
||||||
|
void FontSelectionView::buildMenus(void)
|
||||||
|
{
|
||||||
int32 numFamilies;
|
int32 numFamilies;
|
||||||
int counter;
|
int counter;
|
||||||
|
|
||||||
numFamilies = count_font_families();
|
numFamilies = count_font_families();
|
||||||
for ( int32 i = 0; i < numFamilies; i++ ) {
|
for ( int32 i = 0; i < numFamilies; i++ )
|
||||||
|
{
|
||||||
font_family family;
|
font_family family;
|
||||||
|
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
|
int32 numStyles;
|
||||||
|
|
||||||
if ( get_font_family(i, &family, &flags) == B_OK ) {
|
BMenu *tmpStyleMenu;
|
||||||
|
bool markFamily;
|
||||||
|
|
||||||
BMenu *tmpStyleMenu;
|
if ( get_font_family(i, &family, &flags) != B_OK )
|
||||||
int32 numStyles;
|
continue;
|
||||||
bool markFamily;
|
|
||||||
|
|
||||||
markFamily = false;
|
|
||||||
|
|
||||||
tmpStyleMenu = new BMenu(family);
|
markFamily = false;
|
||||||
tmpStyleMenu->SetRadioMode(true);
|
|
||||||
numStyles = count_font_styles(family);
|
|
||||||
for ( int32 j = 0; j < numStyles; j++ ) {
|
|
||||||
|
|
||||||
font_style style;
|
tmpStyleMenu = new BMenu(family);
|
||||||
if ( get_font_style(family, j, &style, &flags) == B_OK ) {
|
tmpStyleMenu->SetRadioMode(true);
|
||||||
|
numStyles = count_font_styles(family);
|
||||||
|
|
||||||
BMenuItem *tmpItem;
|
for ( int32 j = 0; j < numStyles; j++ )
|
||||||
char workingStyle[64];
|
{
|
||||||
char workingFamily[64];
|
font_style style;
|
||||||
|
BMenuItem *tmpItem;
|
||||||
|
|
||||||
workingFont.GetFamilyAndStyle(&workingFamily, &workingStyle);
|
char workingStyle[64];
|
||||||
tmpItem = new BMenuItem(style, new BMessage(setStyleChangedMessage));
|
char workingFamily[64];
|
||||||
if((strcmp(style, workingStyle) == 0) && (strcmp(family, workingFamily) == 0)){
|
|
||||||
|
|
||||||
markFamily = true;
|
if (get_font_style(family, j, &style, &flags) != B_OK)
|
||||||
tmpItem->SetMarked(true);
|
continue;
|
||||||
|
|
||||||
}//if
|
|
||||||
|
|
||||||
tmpStyleMenu->AddItem(tmpItem);
|
workingFont.GetFamilyAndStyle(&workingFamily, &workingStyle);
|
||||||
|
tmpItem = new BMenuItem(style, new BMessage(STYLE_CHANGED_MSG));
|
||||||
|
|
||||||
}//if
|
if((strcmp(style, workingStyle) == 0) && (strcmp(family, workingFamily) == 0))
|
||||||
|
{
|
||||||
|
markFamily = true;
|
||||||
|
tmpItem->SetMarked(true);
|
||||||
|
}
|
||||||
|
tmpStyleMenu->AddItem(tmpItem);
|
||||||
|
}
|
||||||
|
|
||||||
}//for
|
fontList->AddItem(new BMenuItem((tmpStyleMenu), new BMessage(FONT_CHANGED_MSG)));
|
||||||
|
|
||||||
fontList->AddItem(new BMenuItem((tmpStyleMenu), new BMessage(setFontChangedMessage)));
|
if(markFamily)
|
||||||
|
tmpStyleMenu->Superitem()->SetMarked(true);
|
||||||
if(markFamily){
|
}
|
||||||
|
|
||||||
tmpStyleMenu->Superitem()->SetMarked(true);
|
|
||||||
|
|
||||||
}//if
|
|
||||||
|
|
||||||
}//if
|
|
||||||
|
|
||||||
}//for
|
|
||||||
|
|
||||||
//build size menu
|
|
||||||
for(counter = minSizeIndex;counter < (maxSizeIndex + 1);counter++){
|
|
||||||
|
|
||||||
|
// build size menu
|
||||||
|
for(counter = minSizeIndex; counter < (maxSizeIndex + 1); counter++)
|
||||||
|
{
|
||||||
char buf[1];
|
char buf[1];
|
||||||
BMenuItem *tmp;
|
BMenuItem *tmp;
|
||||||
|
|
||||||
sprintf(buf, "%d", counter);
|
sprintf(buf, "%d", counter);
|
||||||
sizeList->AddItem(tmp = new BMenuItem(buf, new BMessage(setSizeChangedMessage)));
|
sizeList->AddItem(tmp = new BMenuItem(buf, new BMessage(SIZE_CHANGED_MSG)));
|
||||||
if(counter == (int) workingFont.Size()){
|
if(counter == (int) workingFont.Size())
|
||||||
|
|
||||||
tmp->SetMarked(true);
|
tmp->SetMarked(true);
|
||||||
|
}
|
||||||
}//if
|
}
|
||||||
|
|
||||||
}//for
|
|
||||||
|
|
||||||
}//buildMenus
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes the test text in the given font.
|
* Writes the test text in the given font.
|
||||||
* @param fnt The font to write the test text in.
|
* @param fnt The font to write the test text in.
|
||||||
*/
|
*/
|
||||||
void FontSelectionView::SetTestTextFont(BFont *fnt){
|
void FontSelectionView::SetTestTextFont(BFont *fnt)
|
||||||
|
{
|
||||||
testText->SetFont(fnt, B_FONT_ALL);
|
testText->SetFont(fnt, B_FONT_ALL);
|
||||||
testText->Invalidate();
|
testText->Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
}//SetTextTextFont
|
BFont FontSelectionView::GetTestTextFont()
|
||||||
|
{
|
||||||
/**
|
|
||||||
* Gets the current font.
|
|
||||||
*/
|
|
||||||
BFont FontSelectionView::GetTestTextFont(){
|
|
||||||
|
|
||||||
BFont rtrnFont;
|
BFont rtrnFont;
|
||||||
|
|
||||||
@@ -283,94 +286,66 @@ BFont FontSelectionView::GetTestTextFont(){
|
|||||||
|
|
||||||
return rtrnFont;
|
return rtrnFont;
|
||||||
|
|
||||||
}//SetTextTextFont
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the selected size.
|
|
||||||
*/
|
|
||||||
float FontSelectionView::GetSelectedSize(){
|
|
||||||
|
|
||||||
|
float
|
||||||
|
FontSelectionView::GetSelectedSize()
|
||||||
|
{
|
||||||
return minSizeIndex + sizeList->IndexOf(sizeList->FindMarked());
|
return minSizeIndex + sizeList->IndexOf(sizeList->FindMarked());
|
||||||
|
|
||||||
}//GetSelectedSize
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the selected font_family.
|
|
||||||
* @param family The selected font_family.
|
|
||||||
*/
|
|
||||||
void FontSelectionView::GetSelectedFont(font_family *family){
|
|
||||||
|
|
||||||
|
void FontSelectionView::GetSelectedFont(font_family *family)
|
||||||
|
{
|
||||||
int numFamilies = count_font_families();
|
int numFamilies = count_font_families();
|
||||||
for ( int32 i = 0; i < numFamilies; i++ ) {
|
for ( int32 i = 0; i < numFamilies; i++ )
|
||||||
|
{
|
||||||
font_family fam;
|
font_family fam;
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
|
|
||||||
if ( get_font_family(i, &fam, &flags) == B_OK ) {
|
if ( get_font_family(i, &fam, &flags) == B_OK )
|
||||||
|
{
|
||||||
if(strcmp(fam, fontList->FindMarked()->Label()) == 0){
|
if(strcmp(fam, fontList->FindMarked()->Label()) == 0)
|
||||||
|
|
||||||
get_font_family(i, family, &flags);
|
get_font_family(i, family, &flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}//if
|
void FontSelectionView::GetSelectedStyle(font_style *style)
|
||||||
|
{
|
||||||
}//if
|
|
||||||
|
|
||||||
}//for
|
|
||||||
|
|
||||||
}//GetSelectedFont
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the selected style.
|
|
||||||
* @param style The selected style.
|
|
||||||
*/
|
|
||||||
void FontSelectionView::GetSelectedStyle(font_style *style){
|
|
||||||
|
|
||||||
int numFamilies = count_font_families();
|
int numFamilies = count_font_families();
|
||||||
font_family curr;
|
font_family curr;
|
||||||
|
|
||||||
GetSelectedFont(&curr);
|
GetSelectedFont(&curr);
|
||||||
|
|
||||||
for ( int32 i = 0; i < numFamilies; i++ ) {
|
for ( int32 i = 0; i < numFamilies; i++ )
|
||||||
|
{
|
||||||
font_family fam;
|
font_family fam;
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
|
|
||||||
if ( get_font_family(i, &fam, &flags) == B_OK ) {
|
if (get_font_family(i, &fam, &flags) == B_OK && strcmp(fam, curr) == 0 )
|
||||||
|
{
|
||||||
if(strcmp(fam, curr) == 0){
|
int32 numStyles = count_font_styles(fam);
|
||||||
|
for ( int32 j = 0; j < numStyles; j++ )
|
||||||
int32 numStyles = count_font_styles(fam);
|
{
|
||||||
for ( int32 j = 0; j < numStyles; j++ ) {
|
font_style sty;
|
||||||
|
if ( get_font_style(fam, j, &sty, &flags) == B_OK )
|
||||||
font_style sty;
|
{
|
||||||
if ( get_font_style(fam, j, &sty, &flags) == B_OK ) {
|
if(strcmp(sty, fontList->FindMarked()->Submenu()->FindMarked()->Label()) == 0)
|
||||||
|
get_font_style(fam, j, style, &flags);
|
||||||
if(strcmp(sty, fontList->FindMarked()->Submenu()->FindMarked()->Label()) == 0){
|
}
|
||||||
|
}
|
||||||
get_font_style(fam, j, style, &flags);
|
}
|
||||||
|
}
|
||||||
}//if
|
}
|
||||||
|
|
||||||
}//if
|
|
||||||
|
|
||||||
}//for
|
|
||||||
|
|
||||||
}//if
|
|
||||||
|
|
||||||
}//if
|
|
||||||
|
|
||||||
}//for
|
|
||||||
|
|
||||||
}//GetSelectedStyle
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a style is selected, this function is called to update the font menu,
|
* If a style is selected, this function is called to update the font menu,
|
||||||
* in case the selected style is from a non selected font. It also marks the
|
* in case the selected style is from a non selected font. It also marks the
|
||||||
* selected style, and unmarks all other styles.
|
* selected style, and unmarks all other styles.
|
||||||
*/
|
*/
|
||||||
void FontSelectionView::UpdateFontSelectionFromStyle(){
|
void FontSelectionView::UpdateFontSelectionFromStyle()
|
||||||
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for(i = 0;i < fontList->CountItems();i++){
|
for(i = 0;i < fontList->CountItems();i++){
|
||||||
@@ -393,38 +368,28 @@ void FontSelectionView::UpdateFontSelectionFromStyle(){
|
|||||||
}//for
|
}//for
|
||||||
|
|
||||||
}//for
|
}//for
|
||||||
|
}
|
||||||
}//UpdateFontSelection
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the font menu based on the user selection.
|
* Updates the font menu based on the user selection.
|
||||||
*/
|
*/
|
||||||
void FontSelectionView::UpdateFontSelection(){
|
void FontSelectionView::UpdateFontSelection()
|
||||||
|
{
|
||||||
int i = 0;
|
for(int32 i = 0; i < fontList->CountItems();i++)
|
||||||
|
{
|
||||||
for(i = 0;i < fontList->CountItems();i++){
|
for(int32 j = 0;j < fontList->ItemAt(i)->Submenu()->CountItems();j++)
|
||||||
|
{
|
||||||
int j = 0;
|
if(fontList->ItemAt(i)->Submenu()->ItemAt(j)->IsMarked())
|
||||||
|
{
|
||||||
for(j = 0;j < fontList->ItemAt(i)->Submenu()->CountItems();j++){
|
if(strcmp(fontList->ItemAt(i)->Label(), fontList->FindMarked()->Label()) > 0)
|
||||||
|
{
|
||||||
if(fontList->ItemAt(i)->Submenu()->ItemAt(j)->IsMarked()){
|
|
||||||
|
|
||||||
if(strcmp(fontList->ItemAt(i)->Label(), fontList->FindMarked()->Label()) > 0){
|
|
||||||
|
|
||||||
fontList->ItemAt(i)->Submenu()->FindMarked()->SetMarked(false);
|
fontList->ItemAt(i)->Submenu()->FindMarked()->SetMarked(false);
|
||||||
fontList->FindMarked()->Submenu()->ItemAt(0)->SetMarked(true);
|
fontList->FindMarked()->Submenu()->ItemAt(0)->SetMarked(true);
|
||||||
|
}
|
||||||
}//if
|
}
|
||||||
|
}
|
||||||
}//if
|
}
|
||||||
|
}
|
||||||
}//for
|
|
||||||
|
|
||||||
}//for
|
|
||||||
|
|
||||||
}//UpdateFontSelection
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the font and size menus based on the given font.
|
* Updates the font and size menus based on the given font.
|
||||||
|
|||||||
@@ -1,187 +1,64 @@
|
|||||||
/*! \file FontSelectionView.h
|
/*
|
||||||
\brief Header for the FontSelectionView class.
|
* Copyright 2001-2005, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
#ifndef FONT_SELECTION_VIEW_H
|
#ifndef FONT_SELECTION_VIEW_H
|
||||||
|
#define FONT_SELECTION_VIEW_H
|
||||||
|
|
||||||
#define FONT_SELECTION_VIEW_H
|
#include <View.h>
|
||||||
|
#include <Box.h>
|
||||||
|
#include <StringView.h>
|
||||||
|
#include <PopUpMenu.h>
|
||||||
|
#include <MenuField.h>
|
||||||
|
#include <MenuItem.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
/*!
|
enum
|
||||||
* Constant to define that the view is a plain view.
|
{
|
||||||
*/
|
PLAIN_FONT_SELECTION_VIEW=1,
|
||||||
#define PLAIN_FONT_SELECTION_VIEW 1
|
BOLD_FONT_SELECTION_VIEW,
|
||||||
/*!
|
FIXED_FONT_SELECTION_VIEW
|
||||||
* Constant to define that the view is a bold view.
|
};
|
||||||
*/
|
|
||||||
#define BOLD_FONT_SELECTION_VIEW 2
|
|
||||||
/*!
|
|
||||||
* Constant to define that the view is a fixed view.
|
|
||||||
*/
|
|
||||||
#define FIXED_FONT_SELECTION_VIEW 3
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* The plain size menu was changed.
|
|
||||||
*/
|
|
||||||
#define PLAIN_SIZE_CHANGED_MSG 'plsz'
|
|
||||||
/*!
|
|
||||||
* The bold size menu was changed.
|
|
||||||
*/
|
|
||||||
#define BOLD_SIZE_CHANGED_MSG 'blsz'
|
|
||||||
/*!
|
|
||||||
* The fixed size menu was changed.
|
|
||||||
*/
|
|
||||||
#define FIXED_SIZE_CHANGED_MSG 'fxsz'
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* The plain font menu was changed.
|
|
||||||
*/
|
|
||||||
#define PLAIN_FONT_CHANGED_MSG 'plfn'
|
|
||||||
/*!
|
|
||||||
* The bold font menu was changed.
|
|
||||||
*/
|
|
||||||
#define BOLD_FONT_CHANGED_MSG 'blfn'
|
|
||||||
/*!
|
|
||||||
* The fixed font menu was changed.
|
|
||||||
*/
|
|
||||||
#define FIXED_FONT_CHANGED_MSG 'fxfn'
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* The plain style menu was changed.
|
|
||||||
*/
|
|
||||||
#define PLAIN_STYLE_CHANGED_MSG 'plst'
|
|
||||||
/*!
|
|
||||||
* The bold style menu was changed.
|
|
||||||
*/
|
|
||||||
#define BOLD_STYLE_CHANGED_MSG 'blst'
|
|
||||||
/*!
|
|
||||||
* The fixed style menu was changed.
|
|
||||||
*/
|
|
||||||
#define FIXED_STYLE_CHANGED_MSG 'fxst'
|
|
||||||
|
|
||||||
#ifndef _VIEW_H
|
|
||||||
|
|
||||||
#include <View.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _BOX_H
|
|
||||||
|
|
||||||
#include <Box.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _STRING_VIEW_H
|
|
||||||
|
|
||||||
#include <StringView.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _POP_UP_MENU_H
|
|
||||||
|
|
||||||
#include <PopUpMenu.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _MENU_FIELD_H
|
|
||||||
|
|
||||||
#include <MenuField.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _MENU_ITEM_H
|
|
||||||
|
|
||||||
#include <MenuItem.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#ifndef _STDIO_H
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class FontSelectionView : public BView{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
class FontSelectionView : public BView
|
||||||
|
{
|
||||||
|
public:
|
||||||
FontSelectionView(BRect rect, const char *name, int type);
|
FontSelectionView(BRect rect, const char *name, int type);
|
||||||
void SetTestTextFont(BFont *fnt);
|
~FontSelectionView(void);
|
||||||
BFont GetTestTextFont();
|
void AttachedToWindow(void);
|
||||||
float GetSelectedSize();
|
void MessageReceived(BMessage *msg);
|
||||||
void GetSelectedFont(font_family *family);
|
|
||||||
void GetSelectedStyle(font_style *style);
|
|
||||||
void UpdateFontSelectionFromStyle();
|
|
||||||
void UpdateFontSelection();
|
|
||||||
void buildMenus();
|
|
||||||
void emptyMenus();
|
|
||||||
void resetToDefaults();
|
|
||||||
void revertToOriginal();
|
|
||||||
private:
|
|
||||||
|
|
||||||
/**
|
void SetTestTextFont(BFont *fnt);
|
||||||
* The test text display view.
|
BFont GetTestTextFont();
|
||||||
*/
|
float GetSelectedSize();
|
||||||
BStringView *testText;
|
void GetSelectedFont(font_family *family);
|
||||||
|
void GetSelectedStyle(font_style *style);
|
||||||
|
void UpdateFontSelectionFromStyle();
|
||||||
|
void UpdateFontSelection();
|
||||||
|
void resetToDefaults();
|
||||||
|
void revertToOriginal();
|
||||||
|
|
||||||
/**
|
private:
|
||||||
* The font menu.
|
void buildMenus(void);
|
||||||
*/
|
void emptyMenus(void);
|
||||||
BPopUpMenu *fontList;
|
|
||||||
|
|
||||||
/**
|
void EmptyMenu(BPopUpMenu *m);
|
||||||
* The size menu.
|
void UpdateFontSelection(BFont *fnt);
|
||||||
*/
|
|
||||||
BPopUpMenu *sizeList;
|
|
||||||
|
|
||||||
/**
|
BStringView *testText;
|
||||||
* The minimum font size allowed.
|
|
||||||
*/
|
|
||||||
int minSizeIndex;
|
|
||||||
|
|
||||||
/**
|
BPopUpMenu *fontList;
|
||||||
* The maximum font size allowed.
|
BPopUpMenu *sizeList;
|
||||||
*/
|
|
||||||
int maxSizeIndex;
|
|
||||||
|
|
||||||
/**
|
int minSizeIndex;
|
||||||
* The message sent when the size menu is changed.
|
int maxSizeIndex;
|
||||||
*/
|
|
||||||
uint32 setSizeChangedMessage;
|
|
||||||
|
|
||||||
/**
|
char typeLabel[30];
|
||||||
* The message sent when the font menu is changed.
|
|
||||||
*/
|
|
||||||
uint32 setFontChangedMessage;
|
|
||||||
|
|
||||||
/**
|
BFont origFont;
|
||||||
* The message sent when the style menu is changed.
|
BFont workingFont;
|
||||||
*/
|
BFont *defaultFont;
|
||||||
uint32 setStyleChangedMessage;
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* The label that shows what type the view is.
|
|
||||||
*/
|
|
||||||
char typeLabel[30];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The original font, set when the view is instantiated.
|
|
||||||
*/
|
|
||||||
BFont origFont;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The current font.
|
|
||||||
*/
|
|
||||||
BFont workingFont;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The default font.
|
|
||||||
*/
|
|
||||||
BFont *defaultFont;
|
|
||||||
|
|
||||||
void emptyMenu(BPopUpMenu *m);
|
|
||||||
void UpdateFontSelection(BFont *fnt);
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,95 +1,62 @@
|
|||||||
/*! \file FontView.cpp
|
/*
|
||||||
\brief Header for the FontView class.
|
* Copyright 2001-2005, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
#ifndef FONT_VIEW_H
|
#include "FontView.h"
|
||||||
|
|
||||||
#include "FontView.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Pref_Utils.h"
|
#include "Pref_Utils.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
* @param rect The size of the view.
|
|
||||||
*/
|
|
||||||
FontView::FontView(BRect rect)
|
FontView::FontView(BRect rect)
|
||||||
:BView(rect, "FontView", B_FOLLOW_ALL, B_WILL_DRAW)
|
: BView(rect, "Fonts", B_FOLLOW_ALL, B_WILL_DRAW)
|
||||||
{
|
{
|
||||||
BRect bounds(Bounds().InsetByCopy(5, 5));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
|
BRect bounds( Bounds().InsetByCopy(5, 5) );
|
||||||
BRect rect(bounds);
|
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);
|
|
||||||
|
|
||||||
|
rect.bottom = rect.top + FontHeight(true) *3.5;
|
||||||
|
plainSelectionView = new FontSelectionView(rect, "Plain",
|
||||||
|
PLAIN_FONT_SELECTION_VIEW);
|
||||||
AddChild(plainSelectionView);
|
AddChild(plainSelectionView);
|
||||||
AddChild(boldSelectionView);
|
|
||||||
AddChild(fixedSelectionView);
|
|
||||||
|
|
||||||
|
rect.OffsetBy(0, rect.Height() + 4);
|
||||||
|
boldSelectionView = new FontSelectionView(rect, "Bold",
|
||||||
|
BOLD_FONT_SELECTION_VIEW);
|
||||||
|
AddChild(boldSelectionView);
|
||||||
|
|
||||||
|
rect.OffsetBy(0, rect.Height() + 4);
|
||||||
|
fixedSelectionView = new FontSelectionView(rect, "Fixed",
|
||||||
|
FIXED_FONT_SELECTION_VIEW);
|
||||||
|
AddChild(fixedSelectionView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FontView::AttachedToWindow(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.
|
|
||||||
*/
|
|
||||||
void FontView::buildMenus(){
|
|
||||||
|
|
||||||
plainSelectionView->buildMenus();
|
|
||||||
boldSelectionView->buildMenus();
|
|
||||||
fixedSelectionView->buildMenus();
|
|
||||||
|
|
||||||
}//buildMenus
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls each FontSelectionView's emptyMenus() function to clear the
|
|
||||||
* font and size menus.
|
|
||||||
*/
|
|
||||||
void FontView::emptyMenus(){
|
|
||||||
|
|
||||||
plainSelectionView->emptyMenus();
|
|
||||||
boldSelectionView->emptyMenus();
|
|
||||||
fixedSelectionView->emptyMenus();
|
|
||||||
|
|
||||||
}//buildMenus
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls each FontSelectionView's resetToDefaults() function to reset
|
* Calls each FontSelectionView's resetToDefaults() function to reset
|
||||||
* the font and size menus to the default font.
|
* the font and size menus to the default font.
|
||||||
*/
|
*/
|
||||||
void FontView::resetToDefaults(){
|
void
|
||||||
|
FontView::resetToDefaults()
|
||||||
|
{
|
||||||
plainSelectionView->resetToDefaults();
|
plainSelectionView->resetToDefaults();
|
||||||
boldSelectionView->resetToDefaults();
|
boldSelectionView->resetToDefaults();
|
||||||
fixedSelectionView->resetToDefaults();
|
fixedSelectionView->resetToDefaults();
|
||||||
|
}
|
||||||
}//resetToDefaults
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls each FontSelectionView's revertToOriginal() function to reset
|
* Calls each FontSelectionView's revertToOriginal() function to reset
|
||||||
* the font and size menus to the original font.
|
* the font and size menus to the original font.
|
||||||
*/
|
*/
|
||||||
void FontView::revertToOriginal(){
|
void
|
||||||
|
FontView::revertToOriginal()
|
||||||
|
{
|
||||||
plainSelectionView->revertToOriginal();
|
plainSelectionView->revertToOriginal();
|
||||||
boldSelectionView->revertToOriginal();
|
boldSelectionView->revertToOriginal();
|
||||||
fixedSelectionView->revertToOriginal();
|
fixedSelectionView->revertToOriginal();
|
||||||
|
}
|
||||||
}//resetToDefaults
|
|
||||||
|
|
||||||
|
|||||||
+21
-36
@@ -1,42 +1,27 @@
|
|||||||
/*! \file FontView.h
|
/*
|
||||||
\brief Header for the FontView class.
|
* Copyright 2001-2005, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
#ifndef FONT_VIEW_H
|
#ifndef FONT_VIEW_H
|
||||||
|
#define FONT_VIEW_H
|
||||||
|
|
||||||
#define FONT_VIEW_H
|
#include <Box.h>
|
||||||
|
#include <View.h>
|
||||||
|
#include "FontSelectionView.h"
|
||||||
|
|
||||||
#ifndef _VIEW_H
|
class FontView : public BView
|
||||||
|
{
|
||||||
#include <View.h>
|
public:
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FONT_SELECTION_VIEW_H
|
|
||||||
|
|
||||||
#include "FontSelectionView.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _BOX_H
|
|
||||||
|
|
||||||
#include <Box.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class FontView : public BView{
|
|
||||||
|
|
||||||
public:
|
|
||||||
FontView(BRect frame);
|
FontView(BRect frame);
|
||||||
void AttachedToWindow(void);
|
void AttachedToWindow(void);
|
||||||
FontSelectionView *plainSelectionView;
|
|
||||||
FontSelectionView *boldSelectionView;
|
void resetToDefaults();
|
||||||
FontSelectionView *fixedSelectionView;
|
void revertToOriginal();
|
||||||
void buildMenus();
|
|
||||||
void emptyMenus();
|
FontSelectionView *plainSelectionView;
|
||||||
void resetToDefaults();
|
FontSelectionView *boldSelectionView;
|
||||||
void revertToOriginal();
|
FontSelectionView *fixedSelectionView;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,36 +1,38 @@
|
|||||||
/*
|
/*
|
||||||
FontsSettings.cpp
|
* Copyright 2001-2005, Haiku.
|
||||||
*/
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
#include <Font.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <Message.h>
|
||||||
|
|
||||||
#include "FontsSettings.h"
|
#include "FontsSettings.h"
|
||||||
|
|
||||||
const char FontsSettings::kSettingsFile[] = "Font_Settings";
|
static const char kSettingsFile[] = "Font_Settings";
|
||||||
const BPoint kDEFAULT = BPoint(100, 100);
|
|
||||||
|
|
||||||
FontsSettings::FontsSettings()
|
FontsSettings::FontsSettings()
|
||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
|
BMessage msg;
|
||||||
|
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
|
||||||
path.Append(kSettingsFile);
|
path.Append(kSettingsFile);
|
||||||
BFile file(path.Path(), B_READ_ONLY);
|
BFile file(path.Path(), B_READ_ONLY);
|
||||||
if (file.InitCheck() == B_OK) {
|
|
||||||
float x, y;
|
if (file.InitCheck() != B_OK)
|
||||||
if (file.Read(&x, sizeof(float)) != sizeof(float)) {
|
SetDefaults();
|
||||||
x = kDEFAULT.x;
|
else
|
||||||
}
|
if (msg.Unflatten(&file) != B_OK)
|
||||||
if (file.Read(&y, sizeof(float)) != sizeof(float)) {
|
SetDefaults();
|
||||||
y = kDEFAULT.y;
|
else
|
||||||
}
|
{
|
||||||
f_corner = BPoint(x, y);
|
msg.FindPoint("windowlocation",&fCorner);
|
||||||
} else {
|
|
||||||
f_corner = kDEFAULT;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,15 +40,32 @@ FontsSettings::FontsSettings()
|
|||||||
FontsSettings::~FontsSettings()
|
FontsSettings::~FontsSettings()
|
||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
|
BMessage msg;
|
||||||
|
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK)
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
path.Append(kSettingsFile);
|
path.Append(kSettingsFile);
|
||||||
BFile file(path.Path(), B_WRITE_ONLY|B_CREATE_FILE);
|
BFile file(path.Path(), B_WRITE_ONLY|B_CREATE_FILE);
|
||||||
|
|
||||||
if (file.InitCheck() == B_OK) {
|
if (file.InitCheck() == B_OK) {
|
||||||
float x = f_corner.x;
|
msg.AddPoint("windowlocation",fCorner);
|
||||||
float y = f_corner.y;
|
|
||||||
file.Write(&x, sizeof(float));
|
// We need to add this to the settings file so that the app_server
|
||||||
file.Write(&y, sizeof(float));
|
// can get the font cache info on startup. This is the only
|
||||||
|
// place in the Fonts app that we actually need to do this because
|
||||||
|
// any other changes made are made through the API
|
||||||
|
struct font_cache_info cacheInfo;
|
||||||
|
|
||||||
|
get_font_cache_info(B_SCREEN_FONT_CACHE|B_DEFAULT_CACHE_SETTING,
|
||||||
|
&cacheInfo);
|
||||||
|
msg.AddInt32("screencachesize",cacheInfo.cache_size);
|
||||||
|
|
||||||
|
get_font_cache_info(B_PRINTING_FONT_CACHE|B_DEFAULT_CACHE_SETTING,
|
||||||
|
&cacheInfo);
|
||||||
|
msg.AddInt32("printcachesize",cacheInfo.cache_size);
|
||||||
|
|
||||||
|
msg.Flatten(&file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,5 +73,12 @@ FontsSettings::~FontsSettings()
|
|||||||
void
|
void
|
||||||
FontsSettings::SetWindowCorner(BPoint where)
|
FontsSettings::SetWindowCorner(BPoint where)
|
||||||
{
|
{
|
||||||
f_corner = where;
|
fCorner = where;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FontsSettings::SetDefaults(void)
|
||||||
|
{
|
||||||
|
fCorner.Set(100,100);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2001-2005, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
#ifndef FONTS_SETTINGS_H
|
#ifndef FONTS_SETTINGS_H
|
||||||
#define FONTS_SETTINGS_H
|
#define FONTS_SETTINGS_H
|
||||||
|
|
||||||
class FontsSettings {
|
class FontsSettings
|
||||||
public:
|
{
|
||||||
FontsSettings(void);
|
public:
|
||||||
~FontsSettings(void);
|
FontsSettings(void);
|
||||||
|
~FontsSettings(void);
|
||||||
|
|
||||||
BPoint WindowCorner(void) const { return f_corner; }
|
BPoint WindowCorner(void) const { return fCorner; }
|
||||||
void SetWindowCorner(BPoint);
|
void SetWindowCorner(BPoint);
|
||||||
private:
|
|
||||||
static const char kSettingsFile[];
|
void SetDefaults(void);
|
||||||
BPoint f_corner;
|
|
||||||
|
private:
|
||||||
|
BPoint fCorner;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //FONTS_SETTINGS_H
|
#endif //FONTS_SETTINGS_H
|
||||||
|
|||||||
+108
-150
@@ -1,214 +1,175 @@
|
|||||||
/*! \file MainWindow.cpp
|
/*
|
||||||
* \brief Code for the main window.
|
* Copyright 2001-2005, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Displays the main window.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MAIN_WINDOW_H
|
|
||||||
|
|
||||||
#include "MainWindow.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
* @param frame The size to make the window.
|
|
||||||
*/
|
*/
|
||||||
MainWindow::MainWindow(BRect frame)
|
#include "MainWindow.h"
|
||||||
:BWindow(frame, "Fonts", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE ){
|
|
||||||
|
|
||||||
|
MainWindow::MainWindow(void)
|
||||||
|
: BWindow( BRect(100,80,445,343) , "Fonts", B_TITLED_WINDOW, B_NOT_RESIZABLE |
|
||||||
|
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE )
|
||||||
|
{
|
||||||
BRect r;
|
BRect r;
|
||||||
BTabView *tabView;
|
BTabView *tabView;
|
||||||
BTab *tab;
|
|
||||||
BBox *topLevelView;
|
BBox *topLevelView;
|
||||||
double buttonViewHeight = 43.0;
|
double buttonViewHeight = 43.0;
|
||||||
|
|
||||||
|
struct font_cache_info cacheInfo;
|
||||||
|
int32 screenCacheSize, printCacheSize;
|
||||||
|
|
||||||
|
get_font_cache_info(B_SCREEN_FONT_CACHE|B_DEFAULT_CACHE_SETTING, &cacheInfo);
|
||||||
|
screenCacheSize = cacheInfo.cache_size >> 10;
|
||||||
|
|
||||||
|
get_font_cache_info(B_PRINTING_FONT_CACHE|B_DEFAULT_CACHE_SETTING, &cacheInfo);
|
||||||
|
printCacheSize = cacheInfo.cache_size >> 10;
|
||||||
|
|
||||||
r = Bounds();
|
r = Bounds();
|
||||||
r.top += 10;
|
r.top += 10;
|
||||||
r.bottom -= buttonViewHeight+1;
|
r.bottom -= buttonViewHeight+1;
|
||||||
|
|
||||||
tabView = new BTabView(r, "tab_view", B_WIDTH_FROM_LABEL);
|
tabView = new BTabView(r, "tabview", B_WIDTH_FROM_LABEL);
|
||||||
tabView->SetViewColor(216,216,216,0);
|
tabView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
r = tabView->Bounds();
|
r = tabView->Bounds();
|
||||||
r.InsetBy(5, 5);
|
r.InsetBy(5, 5);
|
||||||
r.bottom -= tabView->TabHeight();
|
r.bottom -= tabView->TabHeight();
|
||||||
r.right -=2;
|
r.right -=2;
|
||||||
tab = new BTab();
|
|
||||||
tabView->AddTab(fontPanel = new FontView(r), tab);
|
fSelectorView = new FontView(r);
|
||||||
tab->SetLabel(" Fonts ");
|
tabView->AddTab(fSelectorView);
|
||||||
tab = new BTab();
|
|
||||||
tabView->AddTab(cachePanel = new CacheView(r, 64, 4096, (int32) 256, (int32) 256), tab);
|
fCacheView = new CacheView(r, 64, 4096, printCacheSize, screenCacheSize);
|
||||||
tab->SetLabel("Cache");
|
tabView->AddTab(fCacheView);
|
||||||
|
|
||||||
r = Bounds();
|
r = Bounds();
|
||||||
r.top = r.bottom - buttonViewHeight;
|
r.top = r.bottom - buttonViewHeight;
|
||||||
|
|
||||||
buttonView = new ButtonView(r);
|
fButtonView = new ButtonView(r);
|
||||||
|
|
||||||
topLevelView = new BBox(Bounds(), "TopLevelView", B_FOLLOW_ALL, B_WILL_DRAW, B_NO_BORDER);
|
topLevelView = new BBox(Bounds(), "TopLevelView", B_FOLLOW_ALL, B_WILL_DRAW, B_NO_BORDER);
|
||||||
|
|
||||||
AddChild(topLevelView);
|
AddChild(topLevelView);
|
||||||
topLevelView->AddChild(buttonView);
|
topLevelView->AddChild(fButtonView);
|
||||||
topLevelView->AddChild(tabView);
|
topLevelView->AddChild(tabView);
|
||||||
|
|
||||||
|
MoveTo(fSettings.WindowCorner());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
bool
|
||||||
* Runs when the user quits the application.
|
MainWindow::QuitRequested(void)
|
||||||
*/
|
|
||||||
bool MainWindow::QuitRequested()
|
|
||||||
{
|
{
|
||||||
BMessage *message = new BMessage(B_QUIT_REQUESTED);
|
fSettings.SetWindowCorner(Frame().LeftTop());
|
||||||
message->AddPoint("corner", Frame().LeftTop());
|
|
||||||
be_app->PostMessage(message);
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void
|
||||||
* Handles messages sent to the class.
|
MainWindow::MessageReceived(BMessage *message)
|
||||||
* @param message The message to be handled.
|
{
|
||||||
*/
|
switch(message->what) {
|
||||||
void MainWindow::MessageReceived(BMessage *message){
|
|
||||||
|
|
||||||
char msg[100];
|
/* case PLAIN_SIZE_CHANGED_MSG: {
|
||||||
|
|
||||||
switch(message->what){
|
updateSize(fSelectorView->plainSelectionView);
|
||||||
|
fButtonView->SetRevertState(true);
|
||||||
case PLAIN_SIZE_CHANGED_MSG:
|
|
||||||
|
|
||||||
updateSize(fontPanel->plainSelectionView);
|
|
||||||
buttonView->SetRevertState(true);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case BOLD_SIZE_CHANGED_MSG: {
|
||||||
|
|
||||||
case BOLD_SIZE_CHANGED_MSG:
|
updateSize(fSelectorView->boldSelectionView);
|
||||||
|
fButtonView->SetRevertState(true);
|
||||||
updateSize(fontPanel->boldSelectionView);
|
|
||||||
buttonView->SetRevertState(true);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case FIXED_SIZE_CHANGED_MSG: {
|
||||||
|
|
||||||
case FIXED_SIZE_CHANGED_MSG:
|
updateSize(fSelectorView->fixedSelectionView);
|
||||||
|
fButtonView->SetRevertState(true);
|
||||||
updateSize(fontPanel->fixedSelectionView);
|
|
||||||
buttonView->SetRevertState(true);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case PLAIN_FONT_CHANGED_MSG: {
|
||||||
|
|
||||||
case PLAIN_FONT_CHANGED_MSG:
|
updateFont(fSelectorView->plainSelectionView);
|
||||||
|
fButtonView->SetRevertState(true);
|
||||||
updateFont(fontPanel->plainSelectionView);
|
|
||||||
buttonView->SetRevertState(true);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case BOLD_FONT_CHANGED_MSG: {
|
||||||
|
|
||||||
case BOLD_FONT_CHANGED_MSG:
|
updateFont(fSelectorView->boldSelectionView);
|
||||||
|
fButtonView->SetRevertState(true);
|
||||||
updateFont(fontPanel->boldSelectionView);
|
|
||||||
buttonView->SetRevertState(true);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case FIXED_FONT_CHANGED_MSG: {
|
||||||
|
|
||||||
case FIXED_FONT_CHANGED_MSG:
|
updateFont(fSelectorView->fixedSelectionView);
|
||||||
|
fButtonView->SetRevertState(true);
|
||||||
updateFont(fontPanel->fixedSelectionView);
|
|
||||||
buttonView->SetRevertState(true);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case PLAIN_STYLE_CHANGED_MSG: {
|
||||||
|
|
||||||
case PLAIN_STYLE_CHANGED_MSG:
|
updateStyle(fSelectorView->plainSelectionView);
|
||||||
|
fButtonView->SetRevertState(true);
|
||||||
updateStyle(fontPanel->plainSelectionView);
|
|
||||||
buttonView->SetRevertState(true);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case BOLD_STYLE_CHANGED_MSG: {
|
||||||
|
|
||||||
case BOLD_STYLE_CHANGED_MSG:
|
updateStyle(fSelectorView->boldSelectionView);
|
||||||
|
fButtonView->SetRevertState(true);
|
||||||
updateStyle(fontPanel->boldSelectionView);
|
|
||||||
buttonView->SetRevertState(true);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case FIXED_STYLE_CHANGED_MSG: {
|
||||||
|
|
||||||
case FIXED_STYLE_CHANGED_MSG:
|
updateStyle(fSelectorView->fixedSelectionView);
|
||||||
|
fButtonView->SetRevertState(true);
|
||||||
updateStyle(fontPanel->fixedSelectionView);
|
|
||||||
buttonView->SetRevertState(true);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case RESCAN_FONTS_MSG:
|
case RESCAN_FONTS_MSG: {
|
||||||
|
|
||||||
update_font_families(false);
|
update_font_families(false);
|
||||||
fontPanel->emptyMenus();
|
fSelectorView->emptyMenus();
|
||||||
fontPanel->buildMenus();
|
fSelectorView->buildMenus();
|
||||||
updateFont(fontPanel->plainSelectionView);
|
updateFont(fSelectorView->plainSelectionView);
|
||||||
updateFont(fontPanel->boldSelectionView);
|
updateFont(fSelectorView->boldSelectionView);
|
||||||
updateFont(fontPanel->fixedSelectionView);
|
updateFont(fSelectorView->fixedSelectionView);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case RESET_FONTS_MSG: {
|
||||||
|
|
||||||
case RESET_FONTS_MSG:
|
fSelectorView->resetToDefaults();
|
||||||
|
fCacheView->resetToDefaults();
|
||||||
fontPanel->resetToDefaults();
|
fButtonView->SetRevertState(true);
|
||||||
cachePanel->resetToDefaults();
|
|
||||||
buttonView->SetRevertState(true);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
*/ case REVERT_MSG: {
|
||||||
|
|
||||||
case REVERT_MSG:
|
fSelectorView->revertToOriginal();
|
||||||
|
fCacheView->revertToOriginal();
|
||||||
fontPanel->revertToOriginal();
|
fButtonView->SetRevertState(false);
|
||||||
cachePanel->revertToOriginal();
|
|
||||||
buttonView->SetRevertState(false);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case PRINT_FCS_UPDATE_MSG:
|
default: {
|
||||||
|
|
||||||
printf("print update message\n");
|
|
||||||
//buttonView->SetRevertState(true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PRINT_FCS_MODIFICATION_MSG:
|
|
||||||
|
|
||||||
sprintf(msg, "Printing font cache size : %d kB", cachePanel->getPrintFCSValue());
|
|
||||||
cachePanel->updatePrintFCS(msg);
|
|
||||||
buttonView->SetRevertState(true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SCREEN_FCS_UPDATE_MSG:
|
|
||||||
|
|
||||||
printf("screen update message\n");
|
|
||||||
//buttonView->SetRevertState(true);
|
|
||||||
buttonView->SetRevertState(true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SCREEN_FCS_MODIFICATION_MSG:
|
|
||||||
|
|
||||||
sprintf(msg, "Screen font cache size : %d kB", cachePanel->getScreenFCSValue());
|
|
||||||
cachePanel->updateScreenFCS(msg);
|
|
||||||
buttonView->SetRevertState(true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
|
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Sets the size of the test text when a new size is picked.
|
||||||
* Sets the size of the test text when a new size is picked.
|
void
|
||||||
* @param theView The FontSelectionView that is affected.
|
MainWindow::updateSize(FontSelectionView *theView)
|
||||||
*/
|
{
|
||||||
void MainWindow::updateSize(FontSelectionView *theView){
|
|
||||||
|
|
||||||
BFont workingFont;
|
BFont workingFont;
|
||||||
|
|
||||||
workingFont = theView->GetTestTextFont();
|
workingFont = theView->GetTestTextFont();
|
||||||
workingFont.SetSize(theView->GetSelectedSize());
|
workingFont.SetSize(theView->GetSelectedSize());
|
||||||
theView->SetTestTextFont(&workingFont);
|
theView->SetTestTextFont(&workingFont);
|
||||||
|
}
|
||||||
|
|
||||||
}//updateSize
|
// Updates the test text to the selected font.
|
||||||
|
void
|
||||||
/**
|
MainWindow::updateFont(FontSelectionView *theView)
|
||||||
* Updates the test text to the selected font.
|
{
|
||||||
* @param theView The FontSelectionView that is affected.
|
|
||||||
*/
|
|
||||||
void MainWindow::updateFont(FontSelectionView *theView){
|
|
||||||
|
|
||||||
BFont workingFont;
|
BFont workingFont;
|
||||||
font_family updateTo;
|
font_family updateTo;
|
||||||
|
|
||||||
@@ -217,15 +178,12 @@ void MainWindow::updateFont(FontSelectionView *theView){
|
|||||||
theView->GetSelectedFont(&updateTo);
|
theView->GetSelectedFont(&updateTo);
|
||||||
workingFont.SetFamilyAndStyle(updateTo, NULL);
|
workingFont.SetFamilyAndStyle(updateTo, NULL);
|
||||||
theView->SetTestTextFont(&workingFont);
|
theView->SetTestTextFont(&workingFont);
|
||||||
|
}
|
||||||
|
|
||||||
}//updateFont
|
// Updates the test text to the selected style.
|
||||||
|
void
|
||||||
/**
|
MainWindow::updateStyle(FontSelectionView *theView)
|
||||||
* Updates the test text to the selected style.
|
{
|
||||||
* @param theView The FontSelectionView that is affected.
|
|
||||||
*/
|
|
||||||
void MainWindow::updateStyle(FontSelectionView *theView){
|
|
||||||
|
|
||||||
BFont workingFont;
|
BFont workingFont;
|
||||||
font_style updateTo;
|
font_style updateTo;
|
||||||
font_family update;
|
font_family update;
|
||||||
@@ -236,5 +194,5 @@ void MainWindow::updateStyle(FontSelectionView *theView){
|
|||||||
theView->GetSelectedFont(&update);
|
theView->GetSelectedFont(&update);
|
||||||
workingFont.SetFamilyAndStyle(update, updateTo);
|
workingFont.SetFamilyAndStyle(update, updateTo);
|
||||||
theView->SetTestTextFont(&workingFont);
|
theView->SetTestTextFont(&workingFont);
|
||||||
|
}
|
||||||
|
|
||||||
}//updateStyle
|
|
||||||
|
|||||||
@@ -1,82 +1,40 @@
|
|||||||
/*! \file MainWindow.h
|
/*
|
||||||
\brief Header for the MainWindow class.
|
* Copyright 2001-2005, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
#ifndef MAIN_WINDOW_H
|
#ifndef MAIN_WINDOW_H
|
||||||
|
#define MAIN_WINDOW_H
|
||||||
|
|
||||||
#define MAIN_WINDOW_H
|
#include <Application.h>
|
||||||
|
#include <Window.h>
|
||||||
|
#include <TabView.h>
|
||||||
|
#include <Box.h>
|
||||||
|
|
||||||
#ifndef _APPLICATION_H
|
#include "FontView.h"
|
||||||
|
#include "CacheView.h"
|
||||||
|
#include "ButtonView.h"
|
||||||
|
#include "FontsSettings.h"
|
||||||
|
|
||||||
#include <Application.h>
|
class MainWindow : public BWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MainWindow(void);
|
||||||
|
virtual bool QuitRequested(void);
|
||||||
|
virtual void MessageReceived(BMessage *message);
|
||||||
|
|
||||||
#endif
|
private:
|
||||||
#ifndef _WINDOW_H
|
|
||||||
|
|
||||||
#include <Window.h>
|
void updateSize(FontSelectionView *theView);
|
||||||
|
void updateFont(FontSelectionView *theView);
|
||||||
|
void updateStyle(FontSelectionView *theView);
|
||||||
|
|
||||||
#endif
|
FontView *fSelectorView;
|
||||||
#ifndef _TAB_VIEW_H
|
ButtonView *fButtonView;
|
||||||
|
CacheView *fCacheView;
|
||||||
|
|
||||||
#include <TabView.h>
|
FontsSettings fSettings;
|
||||||
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FONT_VIEW_H
|
|
||||||
|
|
||||||
#include "FontView.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CACHE_VIEW_H
|
|
||||||
|
|
||||||
#include "CacheView.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef BUTTON_VIEW_H
|
|
||||||
|
|
||||||
#include "ButtonView.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _BOX_H
|
|
||||||
|
|
||||||
#include <Box.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class MainWindow : public BWindow{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
MainWindow(BRect frame);
|
|
||||||
virtual bool QuitRequested();
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The panel that shows the font selection views.
|
|
||||||
*/
|
|
||||||
FontView *fontPanel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The panel that holds the default, revert and rescan buttons.
|
|
||||||
*/
|
|
||||||
ButtonView *buttonView;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The panel that holds the sliders for adjusting the cache sizes.
|
|
||||||
*/
|
|
||||||
CacheView *cachePanel;
|
|
||||||
|
|
||||||
void updateSize(FontSelectionView *theView);
|
|
||||||
void updateFont(FontSelectionView *theView);
|
|
||||||
void updateStyle(FontSelectionView *theView);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+13
-65
@@ -1,75 +1,23 @@
|
|||||||
/*! \file main.cpp
|
/*
|
||||||
\brief Code for the main class.
|
* Copyright 2001-2005, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
#ifndef MAIN_WINDOW_H
|
#include "MainWindow.h"
|
||||||
|
#include "main.h"
|
||||||
#include "MainWindow.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#ifndef MAIN_H
|
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "FontsSettings.h"
|
#include "FontsSettings.h"
|
||||||
|
|
||||||
/**
|
int main(int, char**)
|
||||||
* Main method.
|
{
|
||||||
*
|
FontApp fontApp;
|
||||||
* Starts the whole thing.
|
|
||||||
*/
|
|
||||||
int main(int, char**){
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An instance of the application.
|
|
||||||
*/
|
|
||||||
Font_pref fontApp;
|
|
||||||
|
|
||||||
fontApp.Run();
|
fontApp.Run();
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
FontApp::FontApp()
|
||||||
* Constructor.
|
: BApplication("application/x-vnd.Haiku-FNPL")
|
||||||
*
|
|
||||||
* Provides a contstructor for the application.
|
|
||||||
*/
|
|
||||||
Font_pref::Font_pref()
|
|
||||||
:BApplication("application/x-vnd.Haiku-FNPL") {
|
|
||||||
|
|
||||||
f_settings = new FontsSettings();
|
|
||||||
BRect MainWindowRect;
|
|
||||||
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()
|
|
||||||
{
|
{
|
||||||
|
MainWindow *window = new MainWindow();
|
||||||
window->Show();
|
window->Show();
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-34
@@ -1,39 +1,17 @@
|
|||||||
/*! \file main.h
|
/*
|
||||||
\brief Header file for the main class.
|
* Copyright 2001-2005, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
#ifndef MAIN_H
|
#ifndef MAIN_H
|
||||||
|
#define MAIN_H
|
||||||
|
|
||||||
#define MAIN_H
|
#include <Application.h>
|
||||||
|
|
||||||
#ifndef _APPLICATION_H
|
class FontApp : public BApplication
|
||||||
|
{
|
||||||
#include <Application.h>
|
public:
|
||||||
|
FontApp(void);
|
||||||
#endif
|
};
|
||||||
|
|
||||||
class FontsSettings;
|
|
||||||
class MainWindow;
|
|
||||||
/**
|
|
||||||
* Main class.
|
|
||||||
*
|
|
||||||
* Gets everything going.
|
|
||||||
*/
|
|
||||||
class Font_pref : public BApplication{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
Font_pref();
|
|
||||||
~Font_pref();
|
|
||||||
void ReadyToRun();
|
|
||||||
bool QuitRequested();
|
|
||||||
private:
|
|
||||||
FontsSettings *f_settings;
|
|
||||||
MainWindow *window;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user