More or less rewrote the font preferences panel:

* no more "Rescan" button (although the font list is never updated yet)
* completely font sensitive
* centers window on screen if settings are invalid or not existing
* now updates the system fonts instantly, and not when you close the app
* added author list, although I am not sure who actually initially wrote it
  (our CVS history unfortunately doesn't reach that far)
* major cleanup
* removed unused stuff
* and more.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14802 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-11-09 18:42:05 +00:00
parent f1d70d8037
commit 74ca263c69
16 changed files with 717 additions and 1415 deletions
-691
View File
@@ -1,691 +0,0 @@
# Doxyfile 1.2.1
# This file describes the settings to be used by doxygen for a project
#
# All text after a hash (#) is considered a comment and will be ignored
# The format is:
# TAG = value [value, ...]
# For lists items can also be appended using:
# TAG += value [value, ...]
# Values that contain spaces should be placed between quotes (" ")
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project.
PROJECT_NAME = "Fonts Preferences App"
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 1
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
OUTPUT_DIRECTORY = ../docs/api/
# The OUTPUT_LANGUAGE tag is used to specify the language in which all
# documentation generated by doxygen is written. Doxygen will use this
# information to generate all constant output in the proper language.
# The default language is English, other supported languages are:
# Dutch, French, Italian, Czech, Swedish, German, Finnish, Japanese,
# Spanish, Russian, Croatian, Polish, and Portuguese.
OUTPUT_LANGUAGE = English
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
# documentation are documented, even if no documentation was available.
# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
EXTRACT_ALL = YES
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
EXTRACT_PRIVATE = YES
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
EXTRACT_STATIC = YES
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
# undocumented members of documented classes, files or namespaces.
# If set to NO (the default) these members will be included in the
# various overviews, but no documentation section is generated.
# This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_MEMBERS = NO
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy.
# If set to NO (the default) these class will be included in the various
# overviews. This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_CLASSES = NO
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
# include brief member descriptions after the members that are listed in
# the file and class documentation (similar to JavaDoc).
# Set to NO to disable this.
BRIEF_MEMBER_DESC = YES
# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
# the brief description of a member or function before the detailed description.
# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
# brief descriptions will be completely suppressed.
REPEAT_BRIEF = YES
# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
# Doxygen will generate a detailed section even if there is only a brief
# description.
ALWAYS_DETAILED_SEC = YES
# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
# path before files name in the file list and in the header files. If set
# to NO the shortest path that makes the file name unique will be used.
FULL_PATH_NAMES = NO
# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
# can be used to strip a user defined part of the path. Stripping is
# only done if one of the specified strings matches the left-hand part of
# the path. It is allowed to use relative paths in the argument list.
STRIP_FROM_PATH =
# The INTERNAL_DOCS tag determines if documentation
# that is typed after a \internal command is included. If the tag is set
# to NO (the default) then the documentation will be excluded.
# Set it to YES to include the internal documentation.
INTERNAL_DOCS = NO
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
# generate a class diagram (in Html and LaTeX) for classes with base or
# super classes. Setting the tag to NO turns the diagrams off.
CLASS_DIAGRAMS = YES
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
# be generated. Documented entities will be cross-referenced with these sources.
SOURCE_BROWSER = YES
# Setting the INLINE_SOURCES tag to YES will include the body
# of functions and classes directly in the documentation.
INLINE_SOURCES = NO
# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
# doxygen to hide any special comment blocks from generated source code
# fragments. Normal C and C++ comments will always remain visible.
STRIP_CODE_COMMENTS = YES
# If the CASE_SENSE_NAMES tag is set to NO (the default) then Doxygen
# will only generate file names in lower case letters. If set to
# YES upper case letters are also allowed. This is useful if you have
# classes or files whose names only differ in case and if your file system
# supports case sensitive file names.
CASE_SENSE_NAMES = YES
# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
# will show members with their full class and namespace scopes in the
# documentation. If set to YES the scope will be hidden.
HIDE_SCOPE_NAMES = NO
# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
# will generate a verbatim copy of the header file for each class for
# which an include is specified. Set to NO to disable this.
VERBATIM_HEADERS = YES
# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
# will put list of the files that are included by a file in the documentation
# of that file.
SHOW_INCLUDE_FILES = YES
# If the JAVADOC_AUTOBRIEF tag is set to YES (the default) then Doxygen
# will interpret the first line (until the first dot) of a JavaDoc-style
# comment as the brief description. If set to NO, the Javadoc-style will
# behave just like the Qt-style comments.
JAVADOC_AUTOBRIEF = YES
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
# member inherits the documentation from any documented member that it
# reimplements.
INHERIT_DOCS = YES
# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
# is inserted in the documentation for inline members.
INLINE_INFO = YES
# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
# will sort the (detailed) documentation of file and class members
# alphabetically by member name. If set to NO the members will appear in
# declaration order.
SORT_MEMBER_DOCS = YES
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
# Doxygen uses this value to replace tabs by spaces in code fragments.
TAB_SIZE = 4
# The ENABLE_SECTIONS tag can be used to enable conditional
# documentation sections, marked by \if sectionname ... \endif.
ENABLED_SECTIONS =
# The GENERATE_TODOLIST tag can be used to enable (YES) or
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
GENERATE_TODOLIST = YES
# The GENERATE_TESTLIST tag can be used to enable (YES) or
# disable (NO) the test list. This list is created by putting \test
# commands in the documentation.
GENERATE_TESTLIST = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
# The QUIET tag can be used to turn on/off the messages that are generated
# by doxygen. Possible values are YES and NO. If left blank NO is used.
QUIET = NO
# The WARNINGS tag can be used to turn on/off the warning messages that are
# generated by doxygen. Possible values are YES and NO. If left blank
# NO is used.
WARNINGS = YES
# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
# automatically be disabled.
WARN_IF_UNDOCUMENTED = YES
# The WARN_FORMAT tag determines the format of the warning messages that
# doxygen can produce. The string should contain the $file, $line, and $text
# tags, which will be replaced by the file and line number from which the
# warning originated and the warning text.
WARN_FORMAT = "$file:$line: $text"
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
# The INPUT tag can be used to specify the files and/or directories that contain
# documented source files. You may enter file names like "myfile.cpp" or
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = .
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
FILE_PATTERNS = *.cpp *.h
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
# If left blank NO is used.
RECURSIVE = NO
# The EXCLUDE tag can be used to specify files and/or directories that should
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE =
# If the value of the INPUT tag contains directories, you can use the
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
# certain files from those directories.
EXCLUDE_PATTERNS =
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
# the \include command).
EXAMPLE_PATH =
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
EXAMPLE_PATTERNS =
# The IMAGE_PATH tag can be used to specify one or more files or
# directories that contain image that are included in the documentation (see
# the \image command).
IMAGE_PATH =
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
# by executing (via popen()) the command <filter> <input-file>, where <filter>
# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
# input file. Doxygen will then use the output that the filter program writes
# to standard output.
INPUT_FILTER =
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
# of all compounds will be generated. Enable this if the project
# contains a lot of classes, structs, unions or interfaces.
ALPHABETICAL_INDEX = YES
# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
# in which this list will be split (can be a number in the range [1..20])
COLS_IN_ALPHA_INDEX = 5
# In case all classes in a project start with a common prefix, all
# classes will be put under the same header in the alphabetical index.
# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
# should be ignored while generating the index headers.
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
# generate HTML output.
GENERATE_HTML = YES
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `html' will be used as the default path.
HTML_OUTPUT =
# The HTML_HEADER tag can be used to specify a personal HTML header for
# each generated HTML page. If it is left blank doxygen will generate a
# standard header.
HTML_HEADER =
# The HTML_FOOTER tag can be used to specify a personal HTML footer for
# each generated HTML page. If it is left blank doxygen will generate a
# standard footer.
HTML_FOOTER =
# The HTML_STYLESHEET tag can be used to specify a user defined cascading
# style sheet that is used by each HTML page. It can be used to
# fine-tune the look of the HTML output. If the tag is left blank doxygen
# will generate a default style sheet
HTML_STYLESHEET =
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
# files or namespaces will be aligned in HTML using tables. If set to
# NO a bullet list will be used.
HTML_ALIGN_MEMBERS = YES
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
# will be generated that can be used as input for tools like the
# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
# of the generated HTML documentation.
GENERATE_HTMLHELP = NO
# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
# top of each HTML page. The value NO (the default) enables the index and
# the value YES disables it.
DISABLE_INDEX = NO
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
# generate Latex output.
GENERATE_LATEX = NO
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `latex' will be used as the default path.
LATEX_OUTPUT = latex
# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
# LaTeX documents. This may be useful for small projects and may help to
# save some trees in general.
COMPACT_LATEX = NO
# The PAPER_TYPE tag can be used to set the paper type that is used
# by the printer. Possible values are: a4, a4wide, letter, legal and
# executive. If left blank a4wide will be used.
PAPER_TYPE = a4wide
# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
# packages that should be included in the LaTeX output.
EXTRA_PACKAGES =
# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
# the generated latex document. The header should contain everything until
# the first chapter. If it is left blank doxygen will generate a
# standard header. Notice: only use this tag if you know what you are doing!
LATEX_HEADER =
# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
# is prepared for conversion to pdf (using ps2pdf). The pdf file will
# contain links (just like the HTML output) instead of page references
# This makes the output suitable for online browsing using a pdf viewer.
PDF_HYPERLINKS = NO
# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
# plain latex in the generated Makefile. Set this option to YES to get a
# higher quality PDF documentation.
USE_PDFLATEX = NO
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
# command to the generated LaTeX files. This will instruct LaTeX to keep
# running if errors occur, instead of asking the user for help.
# This option is also used when generating formulas in HTML.
LATEX_BATCHMODE = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
# The RTF output is optimised for Word 97 and may not look very pretty with
# other RTF readers or editors.
GENERATE_RTF = NO
# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `rtf' will be used as the default path.
RTF_OUTPUT = rtf
# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
# RTF documents. This may be useful for small projects and may help to
# save some trees in general.
COMPACT_RTF = NO
# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
# will contain hyperlink fields. The RTF file will
# contain links (just like the HTML output) instead of page references.
# This makes the output suitable for online browsing using a WORD or other.
# programs which support those fields.
# Note: wordpad (write) and others do not support links.
RTF_HYPERLINKS = NO
# Load stylesheet definitions from file. Syntax is similar to doxygen's
# config file, i.e. a series of assigments. You only have to provide
# replacements, missing definitions are set to their default value.
RTF_STYLESHEET_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
# generate man pages
GENERATE_MAN = NO
# The MAN_OUTPUT tag is used to specify where the man pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `man' will be used as the default path.
MAN_OUTPUT = man
# The MAN_EXTENSION tag determines the extension that is added to
# the generated man pages (default is the subroutine's section .3)
MAN_EXTENSION = .3
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
# If the GENERATE_XML tag is set to YES Doxygen will
# generate an XML file that captures the structure of
# the code including all documentation. Warning: This feature
# is still experimental and very incomplete.
GENERATE_XML = NO
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
# evaluate all C-preprocessor directives found in the sources and include
# files.
ENABLE_PREPROCESSING = YES
# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
# names in the source code. If set to NO (the default) only conditional
# compilation will be performed. Macro expansion can be done in a controlled
# way by setting EXPAND_ONLY_PREDEF to YES.
MACRO_EXPANSION = NO
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
# then the macro expansion is limited to the macros specified with the
# PREDEFINED and EXPAND_AS_PREDEFINED tags.
EXPAND_ONLY_PREDEF = NO
# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
# in the INCLUDE_PATH (see below) will be search if a #include is found.
SEARCH_INCLUDES = YES
# The INCLUDE_PATH tag can be used to specify one or more directories that
# contain include files that are not input files but should be processed by
# the preprocessor.
INCLUDE_PATH =
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
# directories. If left blank, the patterns specified with FILE_PATTERNS will
# be used.
INCLUDE_FILE_PATTERNS =
# The PREDEFINED tag can be used to specify one or more macro names that
# are defined before the preprocessor is started (similar to the -D option of
# gcc). The argument of the tag is a list of macros of the form: name
# or name=definition (no spaces). If the definition and the = are
# omitted =1 is assumed.
PREDEFINED =
# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
# The macro definition that is found in the sources will be used.
# Use the PREDEFINED tag if you want to use a different macro definition.
EXPAND_AS_DEFINED =
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
# The TAGFILES tag can be used to specify one or more tagfiles.
TAGFILES =
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
# a tag file that is based on the input files it reads.
GENERATE_TAGFILE =
# If the ALLEXTERNALS tag is set to YES all external classes will be listed
# in the class index. If set to NO only the inherited external classes
# will be listed.
ALLEXTERNALS = NO
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of `which perl').
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
# available from the path. This tool is part of Graphviz, a graph visualization
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
HAVE_DOT = YES
# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect inheritance relations. Setting this tag to YES will force the
# the CLASS_DIAGRAMS tag to NO.
CLASS_GRAPH = YES
# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect implementation dependencies (inheritance, containment, and
# class references variables) of the class with other documented classes.
COLLABORATION_GRAPH = YES
# If the ENABLE_PREPROCESSING, INCLUDE_GRAPH, and HAVE_DOT tags are set to
# YES then doxygen will generate a graph for each documented file showing
# the direct and indirect include dependencies of the file with other
# documented files.
INCLUDE_GRAPH = YES
# If the ENABLE_PREPROCESSING, INCLUDED_BY_GRAPH, and HAVE_DOT tags are set to
# YES then doxygen will generate a graph for each documented header file showing
# the documented files that directly or indirectly include this file
INCLUDED_BY_GRAPH = YES
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
# will graphical hierarchy of all classes instead of a textual one.
GRAPHICAL_HIERARCHY = YES
# The tag DOT_PATH can be used to specify the path where the dot tool can be
# found. If left blank, it is assumed the dot tool can be found on the path.
DOT_PATH =
# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
# this value, doxygen will try to truncate the graph, so that it fits within
# the specified constraint. Beware that most browsers cannot cope with very
# large images.
MAX_DOT_GRAPH_WIDTH = 1024
# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
# this value, doxygen will try to truncate the graph, so that it fits within
# the specified constraint. Beware that most browsers cannot cope with very
# large images.
MAX_DOT_GRAPH_HEIGHT = 1024
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
# The SEARCHENGINE tag specifies whether or not a search engine should be
# used. If set to NO the values of all tags below this one will be ignored.
SEARCHENGINE = NO
# The CGI_NAME tag should be the name of the CGI script that
# starts the search engine (doxysearch) with the correct parameters.
# A script with this name will be generated by doxygen.
CGI_NAME = search.cgi
# The CGI_URL tag should be the absolute URL to the directory where the
# cgi binaries are located. See the documentation of your http daemon for
# details.
CGI_URL =
# The DOC_URL tag should be the absolute URL to the directory where the
# documentation is located. If left blank the absolute path to the
# documentation, with file:// prepended to it, will be used.
DOC_URL =
# The DOC_ABSPATH tag should be the absolute path to the directory where the
# documentation is located. If left blank the directory on the local machine
# will be used.
DOC_ABSPATH =
# The BIN_ABSPATH tag must point to the directory where the doxysearch binary
# is installed.
BIN_ABSPATH = /usr/local/bin/
# The EXT_DOC_PATHS tag can be used to specify one or more paths to
# documentation generated for other projects. This allows doxysearch to search
# the documentation for these projects as well.
EXT_DOC_PATHS =
-67
View File
@@ -1,67 +0,0 @@
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
*/
#include "ButtonView.h"
#include "MainWindow.h"
ButtonView::ButtonView(BRect rect)
: BView(rect, "ButtonView", B_FOLLOW_ALL, B_WILL_DRAW)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BRect btnRect(0, 0, 75, 25);
btnRect.OffsetBy(10, 8);
BButton *rescanButton = new BButton(btnRect, "rescanButton", "Rescan",
new BMessage(M_RESCAN_FONTS),
B_FOLLOW_LEFT, B_WILL_DRAW);
AddChild(rescanButton);
btnRect.OffsetBy(96, 0);
BButton *defaultsButton = new BButton(btnRect, "defaultsButton",
"Defaults",
new BMessage(M_SET_DEFAULTS),
B_FOLLOW_LEFT, B_WILL_DRAW);
AddChild(defaultsButton);
btnRect.OffsetBy(85, 0);
fRevertButton = new BButton(btnRect, "fRevertButton", "Revert",
new BMessage(M_REVERT),
B_FOLLOW_LEFT, B_WILL_DRAW);
AddChild(fRevertButton);
fRevertButton->SetEnabled(false);
}
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();
}
bool
ButtonView::RevertState(void) const
{
return fRevertButton->IsEnabled();
}
void ButtonView::SetRevertState(bool value)
{
fRevertButton->SetEnabled(value);
}
-28
View File
@@ -1,28 +0,0 @@
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
*/
#ifndef BUTTON_VIEW_H
#define BUTTON_VIEW_H
#include <View.h>
#include <Button.h>
// Message sent when the rescan button is sent.
#define M_RESCAN_FONTS 'rscn'
class ButtonView : public BView
{
public:
ButtonView(BRect frame);
bool RevertState() const;
void SetRevertState(bool b);
void Draw(BRect);
private:
BButton *fRevertButton;
};
#endif
+373 -397
View File
@@ -2,467 +2,443 @@
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Mark Hogben
* DarkWyrm <[email protected]>
* Axel Dörfler, [email protected]
*/
#include "FontSelectionView.h"
#include "MainWindow.h"
#include "Pref_Utils.h"
#include <Box.h>
#include <MenuField.h>
#include <MenuItem.h>
#include <PopUpMenu.h>
#include <String.h>
#include <StringView.h>
#define SIZE_CHANGED_MSG 'plsz'
#define FONT_CHANGED_MSG 'plfn'
#define STYLE_CHANGED_MSG 'plst'
#include <stdio.h>
// should be changed to allow larger and smaller
#define MIN_SIZE_INDEX 9
#define MAX_SIZE_INDEX 14
extern void _set_system_font_(const char *which, font_family family, font_style style, float size);
#define INSTANT_UPDATE
// if defined, the system font will be updated immediately, and not
// only on exit
FontSelectionView::FontSelectionView(BRect rect, const char *name, int type)
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW),
fType(type)
static const int32 kMsgSetFamily = 'fmly';
static const int32 kMsgSetStyle = 'styl';
static const int32 kMsgSetSize = 'size';
static const float kMinSize = 8.0;
static const float kMaxSize = 18.0;
// private font API
extern void _set_system_font_(const char *which, font_family family,
font_style style, float size);
extern status_t _get_system_default_font_(const char* which,
font_family family, font_style style, float* _size);
#ifndef __HAIKU__
#ifdef B_BEOS_VERSION_DANO
// this call only exists under R5
void
_set_system_font_(const char *which, font_family family,
font_style style, float size)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BString typelabel;
switch(fType)
{
case BOLD_FONT_SELECTION_VIEW:
{
typelabel="Bold font:";
fSavedFont = be_bold_font;
fCurrentFont = be_bold_font;
fDefaultFont.SetFamilyAndStyle("Swis721 BT", "Bold");
fDefaultFont.SetSize(12.0);
break;
}
case FIXED_FONT_SELECTION_VIEW:
{
typelabel="Fixed font:";
fSavedFont = be_fixed_font;
fCurrentFont = be_fixed_font;
fDefaultFont = new BFont();
fDefaultFont.SetFamilyAndStyle("Courier10 BT", "Roman");
fDefaultFont.SetSize(12.0);
break;
}
default:
{
typelabel="Plain font:";
fSavedFont = be_plain_font;
fCurrentFont = be_plain_font;
fDefaultFont = new BFont();
fDefaultFont.SetFamilyAndStyle("Swis721 BT", "Roman");
fDefaultFont.SetSize(10.0);
break;
}
}
puts("you don't have _set_system_font_()");
}
#endif
/*
status_t
_get_system_default_font_(const char* which, font_family family,
font_style style, float* _size)
{
puts("you don't have _get_system_default_font_()");
return B_ERROR;
}
*/
#endif // !__HAIKU__
float fontheight = FontHeight(false);
float divider = StringWidth("Fixed font:");
fSizeMenu = new BPopUpMenu("fSizeMenu", true, true, B_ITEMS_IN_COLUMN);
fFontMenu = new BPopUpMenu("fFontMenu", true, true, B_ITEMS_IN_COLUMN);
// size box
BRect r( Bounds() );
float x = StringWidth("999") + 16;
r.left = r.right -( x + StringWidth("Size: ") + 8.0 );
r.bottom = fontheight +5;
BMenuField *fSizeMenuField = new BMenuField(r, "fontField", "Size: ", fSizeMenu, true);
fSizeMenuField->SetDivider( StringWidth("Size: ") + 5.0 );
fSizeMenuField->SetAlignment(B_ALIGN_RIGHT);
AddChild(fSizeMenuField);
FontSelectionView::FontSelectionView(BRect rect, const char* name,
const char* label, const BFont& currentFont)
: BView(rect, name, B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW),
fSavedFont(currentFont),
fCurrentFont(currentFont)
{
fDivider = StringWidth(label) + 5;
fSizesMenu = new BPopUpMenu("size menu");
_BuildSizesMenu();
fFontsMenu = new BPopUpMenu("font menu");
// font menu
r.right = r.left;
r.left = 1;
r.bottom = fontheight *1.5;
BMenuField *fFontMenuField = new BMenuField(r, "fontField", typelabel.String(), fFontMenu, false);
fFontMenuField->SetDivider(divider + 6.0);
fFontMenuField->SetAlignment(B_ALIGN_RIGHT);
AddChild(fFontMenuField);
r = Bounds();
r.left = divider +8.0;
r.top = fontheight *1.5 +4;
r.InsetBy(1, 1);
BBox *fPreviewTextBox = new BBox(r, "TestTextBox", B_FOLLOW_ALL, B_WILL_DRAW, B_FANCY_BORDER);
AddChild(fPreviewTextBox);
BRect rect(Bounds());
fFontsMenuField = new BMenuField(rect, "fonts", label, fFontsMenu, false);
fFontsMenuField->SetDivider(fDivider);
fFontsMenuField->SetAlignment(B_ALIGN_RIGHT);
fFontsMenuField->ResizeToPreferred();
AddChild(fFontsMenuField);
// Place the text slightly inside the entire box area, so it doesn't overlap the box outline.
r = fPreviewTextBox->Bounds().InsetByCopy(2, 2);
r.right -= 2;
BRect fPreviewTextRect(r);
fPreviewText = new BStringView(fPreviewTextRect, "fPreviewText", "The quick brown fox jumps over the lazy dog.",
B_FOLLOW_ALL, B_WILL_DRAW);
// size menu
rect.right = rect.left + StringWidth("99") + 40;
fSizesMenuField = new BMenuField(rect, "sizes", "Size:", fSizesMenu, true,
B_FOLLOW_RIGHT | B_FOLLOW_TOP);
fSizesMenuField->SetDivider(StringWidth(fSizesMenuField->Label()) + 5.0);
fSizesMenuField->SetAlignment(B_ALIGN_RIGHT);
fSizesMenuField->ResizeToPreferred();
rect = Bounds();
fSizesMenuField->MoveBy(rect.right - fSizesMenuField->Bounds().Width(), 0);
AddChild(fSizesMenuField);
rect.top += fFontsMenuField->Bounds().Height() + 5;
rect.left = fDivider;
BFont font = be_plain_font;
font.SetSize(kMaxSize);
font_height height;
font.GetHeight(&height);
rect.bottom = rect.top + floorf(height.ascent + height.descent + height.leading) + 5;
fPreviewBox = new BBox(rect, "preview", B_FOLLOW_LEFT_RIGHT,
B_WILL_DRAW | B_FRAME_EVENTS);
AddChild(fPreviewBox);
// Place the text slightly inside the entire box area, so
// it doesn't overlap the box outline.
rect = fPreviewBox->Bounds().InsetByCopy(3, 3);
fPreviewText = new BStringView(rect, "preview text",
"The quick brown fox jumps over the lazy dog.",
B_FOLLOW_LEFT_RIGHT);
fPreviewText->SetFont(&fCurrentFont);
fPreviewTextBox->AddChild(fPreviewText);
fPreviewBox->AddChild(fPreviewText);
}
FontSelectionView::~FontSelectionView(void)
FontSelectionView::~FontSelectionView()
{
font_family family;
font_style style;
fCurrentFont.GetFamilyAndStyle(&family,&style);
switch(fType)
{
case PLAIN_FONT_SELECTION_VIEW:
{
_set_system_font_("plain", family, style, fCurrentFont.Size());
break;
}
case BOLD_FONT_SELECTION_VIEW:
{
_set_system_font_("bold", family, style, fCurrentFont.Size());
break;
}
case FIXED_FONT_SELECTION_VIEW:
{
_set_system_font_("fixed", family, style, fCurrentFont.Size());
break;
}
default:
{
break;
}
}
#ifdef INSTANT_UPDATE
_UpdateSystemFont();
#endif
}
void
FontSelectionView::AttachedToWindow(void)
FontSelectionView::GetPreferredSize(float *_width, float *_height)
{
BuildMenus();
// don't change the width if it is large enough
if (_width) {
*_width = fMaxFontNameWidth + 40 + fDivider
+ fSizesMenuField->Bounds().Width();
if (*_width < Bounds().Width())
*_width = Bounds().Width();
}
if (_height) {
BView* view = FindView("preview");
if (view != NULL)
*_height = view->Frame().bottom + 1;
}
}
void
FontSelectionView::SetDivider(float divider)
{
fFontsMenuField->SetDivider(divider);
fPreviewBox->ResizeBy(fDivider - divider, 0);
fPreviewBox->MoveBy(divider - fDivider, 0);
// if the view is not yet attached to a window, the resizing mode is ignored
if (Window() == NULL)
fPreviewText->ResizeBy(fDivider - divider, 0);
fDivider = divider;
}
void
FontSelectionView::AttachedToWindow()
{
if (Parent() != NULL)
SetViewColor(Parent()->ViewColor());
else
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fSizesMenu->SetTargetForItems(this);
UpdateFontsMenu();
}
void
FontSelectionView::MessageReceived(BMessage *msg)
{
switch(msg->what)
{
case SIZE_CHANGED_MSG:
switch (msg->what) {
case kMsgSetSize:
{
int32 size;
if(msg->FindInt32("size",&size)!=B_OK)
if (msg->FindInt32("size", &size) != B_OK
|| size == fCurrentFont.Size())
break;
BString str(B_EMPTY_STRING);
str << size;
BMenuItem *item=fSizeMenu->FindItem(str.String());
if(item)
{
item->SetMarked(true);
fCurrentFont.SetSize(size);
fPreviewText->SetFont(&fCurrentFont, B_FONT_ALL);
fPreviewText->Invalidate();
}
NotifyFontChange();
Window()->PostMessage(M_ENABLE_REVERT);
fCurrentFont.SetSize(size);
_UpdateFontPreview();
Window()->PostMessage(kMsgUpdate);
break;
}
case FONT_CHANGED_MSG:
case kMsgSetFamily:
{
BString str;
if(msg->FindString("family",&str)!=B_OK)
const char* family;
if (msg->FindString("family", &family) != B_OK)
break;
font_family family;
sprintf(family,"%s",str.String());
BMenuItem *menu=fFontMenu->FindItem(family);
if(menu)
{
menu->SetMarked(true);
fCurrentFont.SetFamilyAndFace(family,B_REGULAR_FACE);
font_style style;
fCurrentFont.GetFamilyAndStyle(&family,&style);
BMenuItem *item=menu->Submenu()->FindItem(style);
if(item)
{
fCurrentStyle->SetMarked(false);
font_style style;
fCurrentFont.GetFamilyAndStyle(NULL, &style);
BMenuItem *familyItem = fFontsMenu->FindItem(family);
if (familyItem != NULL) {
_SelectCurrentFont(false);
BMenuItem *item = familyItem->Submenu()->FindItem(style);
if (item == NULL)
item = familyItem->Submenu()->ItemAt(0);
if (item != NULL) {
item->SetMarked(true);
fCurrentStyle=item;
fPreviewText->SetFont(&fCurrentFont, B_FONT_ALL);
fPreviewText->Invalidate();
fCurrentFont.SetFamilyAndStyle(family, item->Label());
_UpdateFontPreview();
}
}
NotifyFontChange();
Window()->PostMessage(M_ENABLE_REVERT);
Window()->PostMessage(kMsgUpdate);
break;
}
case STYLE_CHANGED_MSG:
case kMsgSetStyle:
{
BString str;
if(msg->FindString("family",&str)!=B_OK)
const char* family;
const char* style;
if (msg->FindString("family", &family) != B_OK
|| msg->FindString("style", &style) != B_OK)
break;
font_family family;
font_style style;
sprintf(family,"%s",str.String());
if(msg->FindString("style",&str)!=B_OK)
BMenuItem *familyItem = fFontsMenu->FindItem(family);
if (!familyItem)
break;
sprintf(style,"%s",str.String());
BMenuItem *menu=fFontMenu->FindItem(family);
if(!menu)
break;
BMenuItem *item=menu->Submenu()->FindItem(style);
if(item)
{
fCurrentStyle->SetMarked(false);
menu->SetMarked(true);
item->SetMarked(true);
fCurrentStyle=item;
fCurrentFont.SetFamilyAndStyle(family,style);
fPreviewText->SetFont(&fCurrentFont, B_FONT_ALL);
fPreviewText->Invalidate();
}
NotifyFontChange();
Window()->PostMessage(M_ENABLE_REVERT);
_SelectCurrentFont(false);
familyItem->SetMarked(true);
fCurrentFont.SetFamilyAndStyle(family, style);
_UpdateFontPreview();
Window()->PostMessage(kMsgUpdate);
break;
}
default:
BView::MessageReceived(msg);
}
}
void
FontSelectionView::EmptyMenus(void)
FontSelectionView::_BuildSizesMenu()
{
// Empty the font list
for(int32 i = 0; i < fFontMenu->CountItems(); i++)
{
BMenu *menu = fFontMenu->SubmenuAt(0L);
// We should never have a regular menu item in the font list
if(!menu)
const int32 sizes[] = {7, 8, 9, 10, 11, 12, 13, 14, 18, 21, 24, 0};
// build size menu
for (int32 i = 0; sizes[i]; i++) {
int32 size = sizes[i];
if (size < kMinSize || size > kMaxSize)
continue;
for(int32 j=0; j < menu->CountItems(); j++)
{
BMenuItem *item = menu->RemoveItem(0L);
delete item;
}
fFontMenu->RemoveItem(menu);
delete menu;
}
// empty the size list
for(int32 i = 0; i < fSizeMenu->CountItems(); i++)
{
BMenuItem *item = fSizeMenu->RemoveItem(0L);
delete item;
char label[32];
snprintf(label, sizeof(label), "%ld", size);
BMessage* message = new BMessage(kMsgSetSize);
message->AddInt32("size", size);
BMenuItem* item = new BMenuItem(label, message);
if (size == fCurrentFont.Size())
item->SetMarked(true);
fSizesMenu->AddItem(item);
}
}
void
FontSelectionView::BuildMenus(void)
FontSelectionView::_SelectCurrentFont(bool select)
{
int32 numFamilies;
int counter;
BMessage *msg;
numFamilies = count_font_families();
for ( int32 i = 0; i < numFamilies; i++ )
{
font_family family;
font_style style;
fCurrentFont.GetFamilyAndStyle(&family, &style);
BMenuItem *item = fFontsMenu->FindItem(family);
if (item != NULL) {
item->SetMarked(select);
if (item->Submenu() != NULL) {
item = item->Submenu()->FindItem(style);
if (item != NULL)
item->SetMarked(select);
}
}
}
void
FontSelectionView::_SelectCurrentSize(bool select)
{
char label[16];
snprintf(label, sizeof(label), "%ld", (int32)fCurrentFont.Size());
BMenuItem* item = fSizesMenu->FindItem(label);
if (item != NULL)
item->SetMarked(select);
}
void
FontSelectionView::_UpdateFontPreview()
{
fPreviewText->SetFont(&fCurrentFont);
fPreviewText->Invalidate();
#ifdef INSTANT_UPDATE
_UpdateSystemFont();
#endif
}
void
FontSelectionView::_UpdateSystemFont()
{
font_family family;
font_style style;
fCurrentFont.GetFamilyAndStyle(&family, &style);
_set_system_font_(Name(), family, style, fCurrentFont.Size());
}
void
FontSelectionView::SetDefaults()
{
font_family family;
font_style style;
float size;
if (_get_system_default_font_(Name(), family, style, &size) != B_OK) {
Revert();
return;
}
BFont defaultFont;
defaultFont.SetFamilyAndStyle(family, style);
defaultFont.SetSize(size);
defaultFont.GetFamilyAndStyle(&family, &style);
_SelectCurrentFont(false);
fCurrentFont = defaultFont;
_UpdateFontPreview();
_SelectCurrentFont(true);
_SelectCurrentSize(true);
}
void
FontSelectionView::Revert()
{
if (!IsRevertable())
return;
_SelectCurrentFont(false);
fCurrentFont = fSavedFont;
_UpdateFontPreview();
_SelectCurrentFont(true);
_SelectCurrentSize(true);
}
bool
FontSelectionView::IsRevertable()
{
return fCurrentFont != fSavedFont;
}
void
FontSelectionView::UpdateFontsMenu()
{
int32 numFamilies = count_font_families();
fFontsMenu->RemoveItems(0, fFontsMenu->CountItems(), true);
BFont font;
fFontsMenu->GetFont(&font);
font_family currentFamily;
font_style currentStyle;
fCurrentFont.GetFamilyAndStyle(&currentFamily, &currentStyle);
for (int32 i = 0; i < numFamilies; i++) {
font_family family;
uint32 flags;
int32 numStyles;
BMenu *tmpStyleMenu;
bool markFamily;
if ( get_font_family(i, &family, &flags) != B_OK )
if (get_font_family(i, &family, &flags) != B_OK)
continue;
markFamily = false;
tmpStyleMenu = new BMenu(family);
tmpStyleMenu->SetRadioMode(true);
numStyles = count_font_styles(family);
for ( int32 j = 0; j < numStyles; j++ )
{
// if we're setting the fixed font, we only want to show fixed fonts
if (!strcmp(Name(), "fixed") && (flags & B_IS_FIXED) == 0)
continue;
float width = font.StringWidth(family);
if (width > fMaxFontNameWidth)
fMaxFontNameWidth = width;
BMenu* stylesMenu = new BMenu(family);
stylesMenu->SetRadioMode(true);
stylesMenu->SetFont(&font);
BMessage* message = new BMessage(kMsgSetFamily);
message->AddString("family", family);
BMenuItem* familyItem = new BMenuItem(stylesMenu, message);
fFontsMenu->AddItem(familyItem);
int32 numStyles = count_font_styles(family);
for (int32 j = 0; j < numStyles; j++) {
font_style style;
BMenuItem *tmpItem;
char workingStyle[64];
char workingFamily[64];
if (get_font_style(family, j, &style, &flags) != B_OK)
continue;
fCurrentFont.GetFamilyAndStyle(&workingFamily, &workingStyle);
msg = new BMessage(STYLE_CHANGED_MSG);
msg->AddString("family",(char*)family);
msg->AddString("style",(char*)style);
tmpItem = new BMenuItem(style, msg);
if((strcmp(style, workingStyle) == 0) && (strcmp(family, workingFamily) == 0))
{
markFamily = true;
tmpItem->SetMarked(true);
fCurrentStyle=tmpItem;
message = new BMessage(kMsgSetStyle);
message->AddString("family", (char*)family);
message->AddString("style", (char*)style);
BMenuItem *item = new BMenuItem(style, message);
if (!strcmp(style, currentStyle) && !strcmp(family, currentFamily)) {
item->SetMarked(true);
familyItem->SetMarked(true);
}
tmpStyleMenu->AddItem(tmpItem);
stylesMenu->AddItem(item);
}
msg = new BMessage(FONT_CHANGED_MSG);
msg->AddString("family",family);
fFontMenu->AddItem(new BMenuItem((tmpStyleMenu), msg));
tmpStyleMenu->SetTargetForItems(this);
if(markFamily)
tmpStyleMenu->Superitem()->SetMarked(true);
stylesMenu->SetTargetForItems(this);
}
fFontMenu->SetTargetForItems(this);
// build size menu
for(counter = MIN_SIZE_INDEX; counter < (MAX_SIZE_INDEX + 1); counter++)
{
char buf[1];
BMenuItem *tmp;
sprintf(buf, "%d", counter);
msg = new BMessage(SIZE_CHANGED_MSG);
msg->AddInt32("size",counter);
fSizeMenu->AddItem(tmp = new BMenuItem(buf, msg));
if(counter == (int) fCurrentFont.Size())
tmp->SetMarked(true);
}
fSizeMenu->SetTargetForItems(this);
}
// This method is called by outsiders only. As a result,
// the owning window is NOT notified
void
FontSelectionView::SetDefaults(void)
{
font_family family;
font_style style;
fDefaultFont.GetFamilyAndStyle(&family, &style);
BMenuItem *menu=fFontMenu->FindItem(family);
if(!menu)
return;
BMenuItem *item=menu->Submenu()->FindItem(style);
if(!item)
return;
fCurrentStyle->SetMarked(false);
menu->SetMarked(true);
item->SetMarked(true);
fCurrentStyle=item;
char string[5];
sprintf(string,"%d",(int)fDefaultFont.Size());
item = fSizeMenu->FindItem(string);
if(item)
item->SetMarked(true);
fCurrentFont=fDefaultFont;
fPreviewText->SetFont(&fCurrentFont, B_FONT_ALL);
fPreviewText->Invalidate();
fFontsMenu->SetTargetForItems(this);
}
// This method is called by outsiders only. As a result,
// the owning window is NOT notified
void
FontSelectionView::Revert(void)
{
font_family family;
font_style style;
fSavedFont.GetFamilyAndStyle(&family, &style);
BMenuItem *menu=fFontMenu->FindItem(family);
if(!menu)
return;
BMenuItem *item=menu->Submenu()->FindItem(style);
if(!item)
return;
fCurrentStyle->SetMarked(false);
menu->SetMarked(true);
item->SetMarked(true);
fCurrentStyle=item;
char string[5];
sprintf(string,"%d",(int)fSavedFont.Size());
item = fSizeMenu->FindItem(string);
if(item)
item->SetMarked(true);
fCurrentFont=fSavedFont;
fPreviewText->SetFont(&fCurrentFont, B_FONT_ALL);
fPreviewText->Invalidate();
}
void
FontSelectionView::NotifyFontChange(void)
{
BMessage msg;
switch(fType)
{
case BOLD_FONT_SELECTION_VIEW:
{
msg.what=M_SET_BOLD;
break;
}
case FIXED_FONT_SELECTION_VIEW:
{
msg.what=M_SET_FIXED;
break;
}
default:
{
msg.what=M_SET_PLAIN;
break;
}
}
font_family family;
font_style style;
fCurrentFont.GetFamilyAndStyle(&family,&style);
msg.AddInt32("size",fCurrentFont.Size());
msg.AddString("family",family);
msg.AddString("style",style);
Window()->PostMessage(&msg);
}
void
FontSelectionView::RescanFonts(void)
{
EmptyMenus();
BuildMenus();
}
+52 -45
View File
@@ -2,55 +2,62 @@
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Mark Hogben
* DarkWyrm <[email protected]>
* Axel Dörfler, [email protected]
*/
#ifndef 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>
#include <String.h>
enum
{
PLAIN_FONT_SELECTION_VIEW=1,
BOLD_FONT_SELECTION_VIEW,
FIXED_FONT_SELECTION_VIEW
class BBox;
class BMenuField;
class BPopUpMenu;
class BStringView;
class FontSelectionView : public BView {
public:
FontSelectionView(BRect rect, const char* name, const char* label,
const BFont& currentFont);
virtual ~FontSelectionView();
virtual void GetPreferredSize(float *_width, float *_height);
virtual void AttachedToWindow();
virtual void MessageReceived(BMessage *msg);
void SetDivider(float divider);
void SetDefaults();
void Revert();
bool IsRevertable();
void UpdateFontsMenu();
private:
void _SelectCurrentFont(bool select);
void _SelectCurrentSize(bool select);
void _UpdateFontPreview();
void _UpdateSystemFont();
void _BuildSizesMenu();
protected:
float fDivider;
BMenuField* fFontsMenuField;
BMenuField* fSizesMenuField;
BPopUpMenu* fFontsMenu;
BPopUpMenu* fSizesMenu;
BBox* fPreviewBox;
BStringView* fPreviewText;
BFont fSavedFont;
BFont fCurrentFont;
float fMaxFontNameWidth;
};
class FontSelectionView : public BView
{
public:
FontSelectionView(BRect rect, const char *name, int type);
~FontSelectionView(void);
void AttachedToWindow(void);
void MessageReceived(BMessage *msg);
void SetDefaults(void);
void Revert(void);
void RescanFonts(void);
private:
void BuildMenus(void);
void EmptyMenus(void);
void NotifyFontChange(void);
BStringView *fPreviewText;
BPopUpMenu *fFontMenu;
BPopUpMenu *fSizeMenu;
int fType;
BFont fSavedFont;
BFont fCurrentFont;
BFont fDefaultFont;
BMenuItem *fCurrentStyle;
};
#endif
#endif /* FONT_SELECTION_VIEW_H */
+66 -28
View File
@@ -2,56 +2,94 @@
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Mark Hogben
* DarkWyrm <[email protected]>
* Axel Dörfler, [email protected]
*/
#include "FontView.h"
#include "Pref_Utils.h"
FontView::FontView(BRect rect)
: BView(rect, "Fonts", B_FOLLOW_ALL, B_WILL_DRAW)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BRect bounds( Bounds().InsetByCopy(5, 5) );
BRect rect(bounds);
rect.bottom = rect.top + FontHeight(true) *3.5;
fPlainView = new FontSelectionView(rect, "Plain",
PLAIN_FONT_SELECTION_VIEW);
BRect rect(Bounds());
float labelWidth = StringWidth("Fixed Font:") + 8;
fPlainView = new FontSelectionView(rect, "plain", "Plain Font:", *be_plain_font);
fPlainView->SetDivider(labelWidth);
fPlainView->ResizeToPreferred();
AddChild(fPlainView);
rect.OffsetBy(0, rect.Height() + 4);
fBoldView = new FontSelectionView(rect, "Bold",
BOLD_FONT_SELECTION_VIEW);
rect.OffsetBy(0, fPlainView->Bounds().Height() + 10);
fBoldView = new FontSelectionView(rect, "bold", "Bold Font:", *be_bold_font);
fBoldView->SetDivider(labelWidth);
fBoldView->ResizeToPreferred();
AddChild(fBoldView);
rect.OffsetBy(0, rect.Height() + 4);
fFixedView = new FontSelectionView(rect, "Fixed",
FIXED_FONT_SELECTION_VIEW);
rect.OffsetBy(0, fPlainView->Bounds().Height() + 10);
fFixedView = new FontSelectionView(rect, "fixed", "Fixed Font:", *be_fixed_font);
fFixedView->SetDivider(labelWidth);
fFixedView->ResizeToPreferred();
AddChild(fFixedView);
}
void
FontView::SetDefaults(void)
FontView::GetPreferredSize(float *_width, float *_height)
{
fPlainView->SetDefaults();
fBoldView->SetDefaults();
fFixedView->SetDefaults();
if (_width)
*_width = fPlainView->Bounds().Width();
if (_height)
*_height = fPlainView->Bounds().Height() * 3 + 20;
}
void
FontView::Revert(void)
FontView::SetDefaults()
{
fPlainView->Revert();
fBoldView->Revert();
fFixedView->Revert();
for (int32 i = 0; i < CountChildren(); i++) {
FontSelectionView* view = dynamic_cast<FontSelectionView *>(ChildAt(i));
if (view == NULL)
continue;
view->SetDefaults();
}
}
void
FontView::RescanFonts(void)
FontView::Revert()
{
fPlainView->RescanFonts();
fBoldView->RescanFonts();
fFixedView->RescanFonts();
for (int32 i = 0; i < CountChildren(); i++) {
FontSelectionView* view = dynamic_cast<FontSelectionView *>(ChildAt(i));
if (view == NULL)
continue;
view->Revert();
}
}
void
FontView::UpdateFonts()
{
fPlainView->UpdateFontsMenu();
fBoldView->UpdateFontsMenu();
fFixedView->UpdateFontsMenu();
}
bool
FontView::IsRevertable()
{
return fPlainView->IsRevertable()
|| fBoldView->IsRevertable()
|| fFixedView->IsRevertable();
}
+21 -14
View File
@@ -2,27 +2,34 @@
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Mark Hogben
* DarkWyrm <[email protected]>
* Axel Dörfler, [email protected]
*/
#ifndef FONT_VIEW_H
#define FONT_VIEW_H
#include <Box.h>
#include <View.h>
#include "FontSelectionView.h"
class FontView : public BView
{
public:
FontView(BRect frame);
void SetDefaults(void);
void Revert(void);
void RescanFonts(void);
private:
class FontView : public BView {
public:
FontView(BRect frame);
FontSelectionView *fPlainView;
FontSelectionView *fBoldView;
FontSelectionView *fFixedView;
virtual void GetPreferredSize(float *_width, float *_height);
void SetDefaults();
void Revert();
void UpdateFonts();
bool IsRevertable();
private:
FontSelectionView *fPlainView;
FontSelectionView *fBoldView;
FontSelectionView *fFixedView;
};
#endif
#endif /* FONT_VIEW_H */
+6 -1
View File
@@ -1,6 +1,11 @@
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Mark Hogben
* DarkWyrm <[email protected]>
* Axel Dörfler, [email protected]
*/
@@ -65,6 +70,6 @@ FontsSettings::SetWindowCorner(BPoint where)
void
FontsSettings::SetDefaults()
{
fCorner.Set(100, 100);
fCorner.Set(-1, -1);
}
+21 -14
View File
@@ -2,23 +2,30 @@
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Mark Hogben
* DarkWyrm <[email protected]>
* Axel Dörfler, [email protected]
*/
#ifndef FONTS_SETTINGS_H
#define FONTS_SETTINGS_H
class FontsSettings
{
public:
FontsSettings(void);
~FontsSettings(void);
BPoint WindowCorner(void) const { return fCorner; }
void SetWindowCorner(BPoint);
void SetDefaults(void);
private:
BPoint fCorner;
#include <Point.h>
class FontsSettings {
public:
FontsSettings();
~FontsSettings();
BPoint WindowCorner() const { return fCorner; }
void SetWindowCorner(BPoint);
void SetDefaults();
private:
BPoint fCorner;
};
#endif
#endif /* FONTS_SETTINGS_H */
+8 -3
View File
@@ -1,14 +1,19 @@
SubDir HAIKU_TOP src preferences fonts ;
SetSubDirSupportedPlatformsBeOSCompatible ;
AddSubDirSupportedPlatforms libbe_test ;
Preference Fonts :
ButtonView.cpp
FontSelectionView.cpp
FontsSettings.cpp
FontView.cpp
main.cpp
MainWindow.cpp
Pref_Utils.cpp
: libbe.so
: be
: Fonts.rdef
;
if $(TARGET_PLATFORM) = libbe_test {
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : Fonts
: tests!apps ;
}
+102 -45
View File
@@ -1,48 +1,98 @@
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Mark Hogben
* DarkWyrm <[email protected]>
* Axel Dörfler, [email protected]
*/
#include "FontView.h"
#include "MainWindow.h"
#include <Application.h>
#include <Button.h>
#include <Screen.h>
#include <TabView.h>
static const uint32 kMsgSetDefaults = 'dflt';
static const uint32 kMsgRevert = 'rvrt';
MainWindow::MainWindow()
: BWindow( BRect(100,80,445,343) , "Fonts", B_TITLED_WINDOW,
: BWindow(BRect(100, 100, 445, 340), "Fonts", B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
{
BRect r;
BTabView *tabView;
BBox *topLevelView;
double buttonViewHeight = 43.0;
r = Bounds();
r.top += 10;
r.bottom -= buttonViewHeight+1;
tabView = new BTabView(r, "tabview", B_WIDTH_FROM_LABEL);
tabView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
r = tabView->Bounds();
r.InsetBy(5, 5);
r.bottom -= tabView->TabHeight();
r.right -=2;
fSelectorView = new FontView(r);
tabView->AddTab(fSelectorView);
r = Bounds();
r.top = r.bottom - buttonViewHeight;
fButtonView = new ButtonView(r);
topLevelView = new BBox(Bounds(), "TopLevelView", B_FOLLOW_ALL, B_WILL_DRAW, B_NO_BORDER);
AddChild(topLevelView);
topLevelView->AddChild(fButtonView);
topLevelView->AddChild(tabView);
MoveTo(fSettings.WindowCorner());
BRect rect = Bounds();
BView* view = new BView(rect, "background", B_FOLLOW_ALL, B_WILL_DRAW);
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(view);
rect.left = 10;
rect.top = rect.bottom - 10;
BButton *button = new BButton(rect, "defaults", "Defaults",
new BMessage(kMsgSetDefaults), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
button->ResizeToPreferred();
float buttonHeight = button->Bounds().Height();
button->MoveBy(0, -buttonHeight);
view->AddChild(button);
rect = button->Frame();
rect.OffsetBy(button->Bounds().Width() + 10, 0);
fRevertButton = new BButton(rect, "revert", "Revert",
new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
fRevertButton->ResizeToPreferred();
fRevertButton->SetEnabled(false);
view->AddChild(fRevertButton);
rect = Bounds();
rect.top += 5;
rect.bottom -= 20 + buttonHeight;
BTabView *tabView = new BTabView(rect, "tabview", B_WIDTH_FROM_LABEL);
rect = tabView->ContainerView()->Bounds().InsetByCopy(5, 8);
fFontsView = new FontView(rect);
tabView->AddTab(fFontsView);
float width, height;
fFontsView->GetPreferredSize(&width, &height);
// make sure the tab is large enough for the fonts view
float widthDiff = width + 10
- tabView->ContainerView()->Bounds().Width();
if (widthDiff > 0) {
tabView->ResizeBy(widthDiff, 0);
tabView->ContainerView()->ResizeBy(widthDiff, 0);
}
float heightDiff = height + 16
- tabView->ContainerView()->Bounds().Height();
if (heightDiff > 0) {
tabView->ResizeBy(0, heightDiff);
tabView->ContainerView()->ResizeBy(0, heightDiff);
}
ResizeTo(tabView->Bounds().Width(), tabView->Frame().bottom + 20 + buttonHeight);
view->AddChild(tabView);
fFontsView->ResizeToPreferred();
if (fSettings.WindowCorner() == BPoint(-1, -1)) {
// center window on screen
_Center();
} else {
MoveTo(fSettings.WindowCorner());
// make sure window is on screen
BScreen screen(this);
if (Frame().left > screen.Frame().right - 10
|| Frame().top > screen.Frame().bottom - 10)
_Center();
}
}
@@ -60,22 +110,18 @@ void
MainWindow::MessageReceived(BMessage *message)
{
switch (message->what) {
case M_ENABLE_REVERT:
fButtonView->SetRevertState(true);
case kMsgUpdate:
fRevertButton->SetEnabled(fFontsView->IsRevertable());
break;
case M_RESCAN_FONTS:
fSelectorView->RescanFonts();
case kMsgSetDefaults:
fFontsView->SetDefaults();
fRevertButton->SetEnabled(true);
break;
case M_SET_DEFAULTS:
fSelectorView->SetDefaults();
fButtonView->SetRevertState(true);
break;
case M_REVERT:
fSelectorView->Revert();
fButtonView->SetRevertState(false);
case kMsgRevert:
fFontsView->Revert();
fRevertButton->SetEnabled(false);
break;
default:
@@ -83,3 +129,14 @@ MainWindow::MessageReceived(BMessage *message)
break;
}
}
void
MainWindow::_Center()
{
BScreen screen;
BRect screenFrame = screen.Frame();
MoveTo(screenFrame.left + (screenFrame.Width() - Bounds().Width()) / 2,
screenFrame.top + (screenFrame.Height() - Bounds().Height()) / 2);
}
+15 -14
View File
@@ -1,26 +1,23 @@
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Mark Hogben
* DarkWyrm <[email protected]>
* Axel Dörfler, [email protected]
*/
#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H
#include <Application.h>
#include <Window.h>
#include <TabView.h>
#include <Box.h>
#include "FontView.h"
#include "ButtonView.h"
#include "FontsSettings.h"
#define M_ENABLE_REVERT 'enrv'
#define M_REVERT 'rvrt'
#define M_SET_DEFAULTS 'stdf'
#include <Window.h>
class BButton;
class FontView;
#define M_SET_PLAIN 'stpl'
#define M_SET_BOLD 'stbl'
#define M_SET_FIXED 'stfx'
class MainWindow : public BWindow {
public:
@@ -30,10 +27,14 @@ class MainWindow : public BWindow {
virtual void MessageReceived(BMessage *message);
private:
FontView *fSelectorView;
ButtonView *fButtonView;
void _Center();
FontView* fFontsView;
BButton* fRevertButton;
FontsSettings fSettings;
};
static const int32 kMsgUpdate = 'updt';
#endif /* MAIN_WINDOW_H */
-30
View File
@@ -1,30 +0,0 @@
#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
View File
@@ -1,10 +0,0 @@
#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
+53 -11
View File
@@ -2,22 +2,64 @@
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Mark Hogben
* DarkWyrm <[email protected]>
* Axel Dörfler, [email protected]
*/
#include "MainWindow.h"
#include "main.h"
#include "FontsSettings.h"
int main(int, char**)
{
FontApp fontApp;
fontApp.Run();
return(0);
}
#include <Alert.h>
#include <Application.h>
#include <TextView.h>
FontApp::FontApp()
: BApplication("application/x-vnd.Haiku-FNPL")
class FontsApp : public BApplication {
public:
FontsApp();
virtual void AboutRequested();
};
FontsApp::FontsApp()
: BApplication("application/x-vnd.Haiku-Fonts")
{
MainWindow *window = new MainWindow();
window->Show();
}
void
FontsApp::AboutRequested()
{
BAlert *alert = new BAlert("about", "Fonts\n"
"\tCopyright 2004-2005, Haiku.\n\n", "Ok");
BTextView *view = alert->TextView();
BFont font;
view->SetStylable(true);
view->GetFont(&font);
font.SetSize(18);
font.SetFace(B_BOLD_FACE);
view->SetFontAndColor(0, 5, &font);
alert->Go();
}
// #pragma mark -
int
main(int, char**)
{
FontsApp app;
app.Run();
return 0;
}
-17
View File
@@ -1,17 +0,0 @@
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
*/
#ifndef MAIN_H
#define MAIN_H
#include <Application.h>
class FontApp : public BApplication
{
public:
FontApp(void);
};
#endif