* the FontManager is now a looper (but doesn't do anything useful yet).
* moved the system default font functionality into the DesktopSettings class. * ServerFont::SetStyle() is now a public method. * Improved font fallback routines: they will never end up without a font if there is at least one font installed. * fixed some minor bugs in the DecorManager. * Decorator now get a DesktopSettings object passed - dunno if that's a good idea (since we'll have to open the DesktopSettings header), but it works for now (and something like this is probably needed anyway). * a clean ServerFont is now set to the system default font - and not to the (user chosen) desktop default font anymore (since the font manager doesn't know about that one). * Improved font directory scanning in the font manager a bit, it's now using find_directory() instead of hard-coded paths. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14666 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,33 +1,15 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: Decorator.h
|
||||
// Author: DarkWyrm <[email protected]>
|
||||
// Stephan Aßmus <[email protected]>
|
||||
// Description: Base class for window decorators
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* DarkWyrm <[email protected]>
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
#ifndef _DECORATOR_H_
|
||||
#define _DECORATOR_H_
|
||||
|
||||
|
||||
#include <Rect.h>
|
||||
#include <Region.h>
|
||||
#include <String.h>
|
||||
@@ -36,10 +18,12 @@
|
||||
#include "ColorSet.h"
|
||||
#include "LayerData.h"
|
||||
|
||||
class DesktopSettings;
|
||||
class DisplayDriver;
|
||||
class ServerFont;
|
||||
class BRegion;
|
||||
|
||||
|
||||
typedef enum {
|
||||
DEC_NONE = 0,
|
||||
DEC_ZOOM,
|
||||
@@ -63,10 +47,8 @@ typedef enum {
|
||||
|
||||
class Decorator {
|
||||
public:
|
||||
Decorator(BRect rect,
|
||||
int32 wlook,
|
||||
int32 wfeel,
|
||||
int32 wflags);
|
||||
Decorator(DesktopSettings& settings, BRect rect,
|
||||
int32 look, int32 feel, int32 flags);
|
||||
virtual ~Decorator();
|
||||
|
||||
void SetColors(const ColorSet &cset);
|
||||
@@ -145,7 +127,7 @@ class Decorator {
|
||||
|
||||
virtual void _DrawFrame(BRect r);
|
||||
virtual void _DrawTab(BRect r);
|
||||
|
||||
|
||||
virtual void _DrawClose(BRect r);
|
||||
virtual void _DrawTitle(BRect r);
|
||||
virtual void _DrawZoom(BRect r);
|
||||
@@ -153,7 +135,7 @@ class Decorator {
|
||||
|
||||
virtual void _SetFocus();
|
||||
virtual void _SetColors();
|
||||
|
||||
|
||||
ColorSet* _colors;
|
||||
DisplayDriver* _driver;
|
||||
DrawData _drawdata;
|
||||
@@ -182,6 +164,7 @@ class Decorator {
|
||||
|
||||
// add-on stuff
|
||||
typedef float get_version(void);
|
||||
typedef Decorator* create_decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags);
|
||||
typedef Decorator* create_decorator(DesktopSettings& desktopSettings, BRect rect,
|
||||
int32 look, int32 feel, int32 flags);
|
||||
|
||||
#endif
|
||||
#endif /* _DECORATOR_H_ */
|
||||
|
||||
@@ -10,9 +10,7 @@
|
||||
#define FONT_MANAGER_H
|
||||
|
||||
|
||||
#include <Font.h>
|
||||
#include <Locker.h>
|
||||
#include <OS.h>
|
||||
#include <Looper.h>
|
||||
#include <ObjectList.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
@@ -31,20 +29,19 @@ class ServerFont;
|
||||
\class FontManager FontManager.h
|
||||
\brief Manager for the largest part of the font subsystem
|
||||
*/
|
||||
class FontManager : public BLocker {
|
||||
class FontManager : public BLooper {
|
||||
public:
|
||||
FontManager();
|
||||
~FontManager();
|
||||
virtual ~FontManager();
|
||||
|
||||
status_t InitCheck() { return fInitStatus; }
|
||||
|
||||
int32 CountFamilies();
|
||||
int32 CountStyles(const char *family);
|
||||
void RemoveFamily(const char *family);
|
||||
void ScanSystemFolders();
|
||||
status_t ScanDirectory(const char *path);
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
int32 CountFamilies() const;
|
||||
int32 CountStyles(const char *family) const;
|
||||
FontFamily* FamilyAt(int32 index) const;
|
||||
|
||||
FontFamily* GetFamilyByIndex(int32 index) const;
|
||||
FontFamily *GetFamily(uint16 familyID) const;
|
||||
FontFamily *GetFamily(const char *name) const;
|
||||
|
||||
@@ -53,14 +50,11 @@ class FontManager : public BLocker {
|
||||
uint16 styleID = 0xffff, uint16 face = 0);
|
||||
FontStyle *GetStyle(const char *family, uint16 styleID);
|
||||
FontStyle *GetStyle(uint16 familyID, uint16 styleID);
|
||||
FontStyle* FindStyleMatchingFace(uint16 face) const;
|
||||
|
||||
ServerFont *GetSystemPlain();
|
||||
ServerFont *GetSystemBold();
|
||||
ServerFont *GetSystemFixed();
|
||||
|
||||
bool SetSystemPlain(const char *family, const char *style, float size);
|
||||
bool SetSystemBold(const char *family, const char *style, float size);
|
||||
bool SetSystemFixed(const char *family, const char *style, float size);
|
||||
ServerFont* GetFont(const char *family, const char *style, float size);
|
||||
ServerFont* GetFont(uint16 face, float size);
|
||||
const ServerFont* DefaultFont() const;
|
||||
|
||||
bool FontsNeedUpdated() { return fNeedUpdate; }
|
||||
/*!
|
||||
@@ -68,15 +62,27 @@ class FontManager : public BLocker {
|
||||
*/
|
||||
void FontsUpdated() { fNeedUpdate = false; }
|
||||
|
||||
void AttachUser(uid_t userID);
|
||||
void DetachUser(uid_t userID);
|
||||
|
||||
private:
|
||||
void _AddFont(BPath &path);
|
||||
void _SetDefaultFont();
|
||||
void _ScanSystemFonts();
|
||||
status_t _AddPath(const char* path);
|
||||
status_t _AddPath(BEntry& entry);
|
||||
|
||||
void _RemoveFamily(const char *family);
|
||||
|
||||
status_t _ScanDirectory(BEntry &entry);
|
||||
void _AddFont(BPath& path);
|
||||
|
||||
FT_CharMap _GetSupportedCharmap(const FT_Face &face);
|
||||
|
||||
private:
|
||||
status_t fInitStatus;
|
||||
BObjectList<node_ref> fFontDirectories;
|
||||
BObjectList<FontFamily> fFamilies;
|
||||
ServerFont *fPlain, *fBold, *fFixed;
|
||||
ServerFont *fDefaultFont;
|
||||
bool fNeedUpdate;
|
||||
int32 fNextID;
|
||||
};
|
||||
|
||||
@@ -60,15 +60,15 @@
|
||||
# define DEFAULT_PLAIN_FONT_FAMILY "Bitstream Vera Sans"
|
||||
# define FALLBACK_PLAIN_FONT_FAMILY "Swis721 BT"
|
||||
# define DEFAULT_PLAIN_FONT_STYLE "Roman"
|
||||
# define DEFAULT_PLAIN_FONT_SIZE 12
|
||||
# define DEFAULT_PLAIN_FONT_SIZE 12.0f
|
||||
# define DEFAULT_BOLD_FONT_FAMILY "Bitstream Vera Sans"
|
||||
# define FALLBACK_BOLD_FONT_FAMILY "Swis721 BT"
|
||||
# define DEFAULT_BOLD_FONT_STYLE "Bold"
|
||||
# define DEFAULT_BOLD_FONT_SIZE 12
|
||||
# define DEFAULT_BOLD_FONT_SIZE 12.0f
|
||||
# define DEFAULT_FIXED_FONT_FAMILY "Bitstream Vera Sans Mono"
|
||||
# define FALLBACK_FIXED_FONT_FAMILY "Courier10 BT"
|
||||
# define DEFAULT_FIXED_FONT_STYLE "Roman"
|
||||
# define DEFAULT_FIXED_FONT_SIZE 12
|
||||
# define DEFAULT_FIXED_FONT_SIZE 12.0f
|
||||
// This is the port capacity for all monitoring objects - ServerApps
|
||||
// and ServerWindows
|
||||
#define DEFAULT_MONITOR_PORT_SIZE 30
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
* Authors:
|
||||
* DarkWyrm <[email protected]>
|
||||
* Jérôme Duval, [email protected]
|
||||
* Axel Dörfler, [email protected]
|
||||
*/
|
||||
#ifndef SERVERFONT_H_
|
||||
#define SERVERFONT_H_
|
||||
#ifndef SERVER_FONT_H
|
||||
#define SERVER_FONT_H
|
||||
|
||||
|
||||
#include <Font.h>
|
||||
@@ -62,7 +63,8 @@ class ServerFont {
|
||||
const char* GetFamily() const;
|
||||
const char* GetPath() const
|
||||
{ return fStyle->Path(); }
|
||||
|
||||
|
||||
void SetStyle(FontStyle& style);
|
||||
status_t SetFamilyAndStyle(uint16 familyID,
|
||||
uint16 styleID);
|
||||
status_t SetFamilyAndStyle(uint32 fontID);
|
||||
@@ -151,8 +153,6 @@ class ServerFont {
|
||||
|
||||
protected:
|
||||
friend class FontStyle;
|
||||
void _SetStyle(FontStyle* style);
|
||||
|
||||
|
||||
FontStyle* fStyle;
|
||||
edge_info fEdges;
|
||||
@@ -167,5 +167,4 @@ protected:
|
||||
uint32 fEncoding;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* SERVER_FONT_H */
|
||||
|
||||
@@ -100,49 +100,10 @@ AppServer::AppServer()
|
||||
|
||||
// Create the font server and scan the proper directories.
|
||||
gFontManager = new FontManager;
|
||||
gFontManager->Lock();
|
||||
gFontManager->ScanSystemFolders();
|
||||
if (gFontManager->InitCheck() != B_OK)
|
||||
debugger("font manager could not be initialized!");
|
||||
|
||||
if (!gFontManager->SetSystemPlain(DEFAULT_PLAIN_FONT_FAMILY,
|
||||
DEFAULT_PLAIN_FONT_STYLE,
|
||||
DEFAULT_PLAIN_FONT_SIZE) &&
|
||||
!gFontManager->SetSystemPlain(FALLBACK_PLAIN_FONT_FAMILY,
|
||||
DEFAULT_PLAIN_FONT_STYLE,
|
||||
DEFAULT_PLAIN_FONT_SIZE)) {
|
||||
printf("Couldn't set plain to %s (fallback: %s), %s %d pt\n",
|
||||
DEFAULT_PLAIN_FONT_FAMILY,
|
||||
FALLBACK_PLAIN_FONT_FAMILY,
|
||||
DEFAULT_PLAIN_FONT_STYLE,
|
||||
DEFAULT_PLAIN_FONT_SIZE);
|
||||
}
|
||||
|
||||
if (!gFontManager->SetSystemBold(DEFAULT_BOLD_FONT_FAMILY,
|
||||
DEFAULT_BOLD_FONT_STYLE,
|
||||
DEFAULT_BOLD_FONT_SIZE) &&
|
||||
!gFontManager->SetSystemBold(FALLBACK_BOLD_FONT_FAMILY,
|
||||
DEFAULT_BOLD_FONT_STYLE,
|
||||
DEFAULT_BOLD_FONT_SIZE)) {
|
||||
printf("Couldn't set bold to %s (fallback: %s), %s %d pt\n",
|
||||
DEFAULT_BOLD_FONT_FAMILY,
|
||||
FALLBACK_BOLD_FONT_FAMILY,
|
||||
DEFAULT_BOLD_FONT_STYLE,
|
||||
DEFAULT_BOLD_FONT_SIZE);
|
||||
}
|
||||
|
||||
if (!gFontManager->SetSystemFixed(DEFAULT_FIXED_FONT_FAMILY,
|
||||
DEFAULT_FIXED_FONT_STYLE,
|
||||
DEFAULT_FIXED_FONT_SIZE) &&
|
||||
!gFontManager->SetSystemFixed(FALLBACK_FIXED_FONT_FAMILY,
|
||||
DEFAULT_FIXED_FONT_STYLE,
|
||||
DEFAULT_FIXED_FONT_SIZE)) {
|
||||
printf("Couldn't set fixed to %s (fallback: %s), %s %d pt\n",
|
||||
DEFAULT_FIXED_FONT_FAMILY,
|
||||
FALLBACK_FIXED_FONT_FAMILY,
|
||||
DEFAULT_FIXED_FONT_STYLE,
|
||||
DEFAULT_FIXED_FONT_SIZE);
|
||||
}
|
||||
|
||||
gFontManager->Unlock();
|
||||
gFontManager->Run();
|
||||
|
||||
// Load the GUI colors here and set the global set to the values contained therein. If this
|
||||
// is not possible, set colors to the defaults
|
||||
|
||||
@@ -7,14 +7,17 @@
|
||||
|
||||
|
||||
#include <Directory.h>
|
||||
#include <Rect.h>
|
||||
#include <Entry.h>
|
||||
#include <File.h>
|
||||
#include <Message.h>
|
||||
#include <Entry.h>
|
||||
#include <Path.h>
|
||||
#include <Rect.h>
|
||||
|
||||
#include "AppServer.h"
|
||||
#include "ColorSet.h"
|
||||
#include "DefaultDecorator.h"
|
||||
#include "Desktop.h"
|
||||
#include "DesktopSettings.h"
|
||||
#include "ServerConfig.h"
|
||||
#include "DecorManager.h"
|
||||
|
||||
@@ -23,37 +26,38 @@
|
||||
DecorManager gDecorManager;
|
||||
|
||||
|
||||
Decorator* create_default_decorator(BRect rect, int32 wlook, int32 wfeel,
|
||||
int32 wflags);
|
||||
|
||||
// This is a class used only by the DecorManager to track all the decorators in memory
|
||||
class DecorInfo {
|
||||
public:
|
||||
DecorInfo(const image_id &id, const char *name,
|
||||
create_decorator *alloc);
|
||||
~DecorInfo(void);
|
||||
image_id GetID(void) const { return fID; }
|
||||
const char* GetName(void) const { return fName.String(); }
|
||||
Decorator* Instantiate(BRect rect, const char *title,
|
||||
int32 wlook, int32 wfeel,
|
||||
int32 wflags, DisplayDriver *ddriver);
|
||||
private:
|
||||
image_id fID;
|
||||
BString fName;
|
||||
create_decorator *fAllocator;
|
||||
public:
|
||||
DecorInfo(image_id id, const char* name,
|
||||
create_decorator* allocator = NULL);
|
||||
~DecorInfo();
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
image_id ID() const { return fID; }
|
||||
const char* Name() const { return fName.String(); }
|
||||
|
||||
Decorator* Instantiate(Desktop* desktop, BRect rect, const char* title,
|
||||
int32 look, int32 feel, int32 flags);
|
||||
|
||||
private:
|
||||
image_id fID;
|
||||
BString fName;
|
||||
create_decorator *fAllocator;
|
||||
};
|
||||
|
||||
|
||||
DecorInfo::DecorInfo(const image_id &id, const char *name, create_decorator *alloc)
|
||||
DecorInfo::DecorInfo(image_id id, const char* name, create_decorator* allocator)
|
||||
:
|
||||
fID(id),
|
||||
fName(name),
|
||||
fAllocator(alloc)
|
||||
fAllocator(allocator)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DecorInfo::~DecorInfo(void)
|
||||
DecorInfo::~DecorInfo()
|
||||
{
|
||||
// Do nothing. Normal programming practice would say that one should unload
|
||||
// the object's associate image_id. However, there is some funkiness with
|
||||
@@ -68,20 +72,30 @@ DecorInfo::~DecorInfo(void)
|
||||
|
||||
|
||||
Decorator *
|
||||
DecorInfo::Instantiate(BRect rect, const char *title, int32 wlook, int32 wfeel,
|
||||
int32 wflags, DisplayDriver *ddriver)
|
||||
DecorInfo::Instantiate(Desktop* desktop, BRect rect, const char *title,
|
||||
int32 look, int32 feel, int32 flags)
|
||||
{
|
||||
Decorator *dec = fAllocator(rect, wlook, wfeel, wflags);
|
||||
|
||||
dec->SetDriver(ddriver);
|
||||
DesktopSettings settings(desktop);
|
||||
Decorator *decorator;
|
||||
|
||||
try {
|
||||
if (fAllocator != NULL)
|
||||
decorator = fAllocator(settings, rect, look, feel, flags);
|
||||
else
|
||||
decorator = new DefaultDecorator(settings, rect, look, feel, flags);
|
||||
} catch (...) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
decorator->SetDriver(desktop->GetDisplayDriver());
|
||||
|
||||
gGUIColorSet.Lock();
|
||||
dec->SetColors(gGUIColorSet);
|
||||
decorator->SetColors(gGUIColorSet);
|
||||
gGUIColorSet.Unlock();
|
||||
|
||||
dec->SetTitle(title);
|
||||
decorator->SetTitle(title);
|
||||
|
||||
return dec;
|
||||
return decorator;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,9 +108,9 @@ DecorManager::DecorManager()
|
||||
fCurrentDecor(NULL)
|
||||
{
|
||||
// Start with the default decorator - index is always 0
|
||||
DecorInfo *defaultDecor = new DecorInfo(-1, "Default", create_default_decorator);
|
||||
fDecorList.AddItem( defaultDecor );
|
||||
|
||||
DecorInfo *defaultDecor = new DecorInfo(-1, "Default", NULL);
|
||||
fDecorList.AddItem(defaultDecor);
|
||||
|
||||
// Add any on disk
|
||||
RescanDecorators();
|
||||
|
||||
@@ -112,18 +126,18 @@ DecorManager::DecorManager()
|
||||
if (file.InitCheck() == B_OK && settings.Unflatten(&file) == B_OK) {
|
||||
BString itemtext;
|
||||
if (settings.FindString("decorator", &itemtext) == B_OK) {
|
||||
fCurrentDecor = FindDecor(itemtext.String());
|
||||
fCurrentDecor = _FindDecor(itemtext.String());
|
||||
}
|
||||
}
|
||||
|
||||
if (!fCurrentDecor)
|
||||
fCurrentDecor = (DecorInfo*) fDecorList.ItemAt(0L);
|
||||
fCurrentDecor = (DecorInfo*)fDecorList.ItemAt(0L);
|
||||
}
|
||||
|
||||
|
||||
DecorManager::~DecorManager()
|
||||
{
|
||||
EmptyList();
|
||||
_EmptyList();
|
||||
}
|
||||
|
||||
|
||||
@@ -136,11 +150,10 @@ DecorManager::RescanDecorators()
|
||||
return;
|
||||
|
||||
entry_ref ref;
|
||||
BString fullpath;
|
||||
|
||||
while (dir.GetNextRef(&ref) == B_OK) {
|
||||
fullpath = DECORATORS_DIR;
|
||||
fullpath += ref.name;
|
||||
BPath path;
|
||||
path.SetTo(DECORATORS_DIR);
|
||||
path.Append(ref.name);
|
||||
|
||||
// Because this function is used for both initialization and for keeping
|
||||
// the list up to date, check for existence in the list. Note that we
|
||||
@@ -149,11 +162,11 @@ DecorManager::RescanDecorators()
|
||||
// been deleted, it is still available until the next boot, at which point
|
||||
// it will obviously not be loaded.
|
||||
|
||||
if (FindDecor(ref.name))
|
||||
if (_FindDecor(ref.name))
|
||||
continue;
|
||||
|
||||
image_id tempID = load_add_on(fullpath.String());
|
||||
if (tempID == B_ERROR)
|
||||
image_id image = load_add_on(path.Path());
|
||||
if (image != B_OK)
|
||||
continue;
|
||||
|
||||
// As of now, we do nothing with decorator versions, but the possibility
|
||||
@@ -161,25 +174,25 @@ DecorManager::RescanDecorators()
|
||||
// to do so. If we *did* do anything with decorator versions, the
|
||||
// assignment would go here.
|
||||
|
||||
create_decorator *createfunc;
|
||||
create_decorator* createFunc;
|
||||
|
||||
// Get the instantiation function
|
||||
status_t status = get_image_symbol(tempID, "instantiate_decorator",
|
||||
B_SYMBOL_TYPE_TEXT, (void**)&createfunc);
|
||||
status_t status = get_image_symbol(image, "instantiate_decorator",
|
||||
B_SYMBOL_TYPE_TEXT, (void**)&createFunc);
|
||||
if (status != B_OK) {
|
||||
unload_add_on(tempID);
|
||||
unload_add_on(image);
|
||||
continue;
|
||||
}
|
||||
|
||||
fDecorList.AddItem(new DecorInfo(tempID, ref.name, createfunc));
|
||||
// TODO: unload images until they are actually used!
|
||||
fDecorList.AddItem(new DecorInfo(image, ref.name, createFunc));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Decorator *
|
||||
DecorManager::AllocateDecorator(BRect rect, const char *title,
|
||||
int32 wlook, int32 wfeel,
|
||||
int32 wflags, DisplayDriver *ddriver)
|
||||
DecorManager::AllocateDecorator(Desktop* desktop, BRect rect, const char *title,
|
||||
int32 look, int32 feel, int32 flags)
|
||||
{
|
||||
// Create a new instance of the current decorator. Ownership is that of the caller
|
||||
|
||||
@@ -189,26 +202,26 @@ DecorManager::AllocateDecorator(BRect rect, const char *title,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return fCurrentDecor->Instantiate(rect, title, wlook, wfeel, wflags, ddriver);
|
||||
return fCurrentDecor->Instantiate(desktop, rect, title, look, feel, flags);
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
DecorManager::CountDecorators(void) const
|
||||
DecorManager::CountDecorators() const
|
||||
{
|
||||
return fDecorList.CountItems();
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
DecorManager::GetDecorator(void) const
|
||||
DecorManager::GetDecorator() const
|
||||
{
|
||||
return fDecorList.IndexOf(fCurrentDecor);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
DecorManager::SetDecorator(const int32 &index)
|
||||
DecorManager::SetDecorator(int32 index)
|
||||
{
|
||||
DecorInfo *newDecInfo = (DecorInfo*)fDecorList.ItemAt(index);
|
||||
|
||||
@@ -222,7 +235,7 @@ DecorManager::SetDecorator(const int32 &index)
|
||||
|
||||
|
||||
bool
|
||||
DecorManager::SetR5Decorator(const int32 &value)
|
||||
DecorManager::SetR5Decorator(int32 value)
|
||||
{
|
||||
BString string;
|
||||
|
||||
@@ -235,7 +248,7 @@ DecorManager::SetR5Decorator(const int32 &value)
|
||||
return false;
|
||||
}
|
||||
|
||||
DecorInfo *newDecInfo = FindDecor(string.String());
|
||||
DecorInfo *newDecInfo = _FindDecor(string.String());
|
||||
if (newDecInfo) {
|
||||
fCurrentDecor = newDecInfo;
|
||||
return true;
|
||||
@@ -246,53 +259,41 @@ DecorManager::SetR5Decorator(const int32 &value)
|
||||
|
||||
|
||||
const char *
|
||||
DecorManager::GetDecoratorName(const int32 &index)
|
||||
DecorManager::GetDecoratorName(int32 index)
|
||||
{
|
||||
DecorInfo *info = (DecorInfo*)fDecorList.ItemAt(index);
|
||||
|
||||
DecorInfo *info = fDecorList.ItemAt(index);
|
||||
if (info)
|
||||
return info->GetName();
|
||||
return info->Name();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DecorManager::EmptyList(void)
|
||||
DecorManager::_EmptyList()
|
||||
{
|
||||
for (int32 i = 0; i < fDecorList.CountItems(); i++) {
|
||||
DecorInfo *info = (DecorInfo*)fDecorList.ItemAt(i);
|
||||
delete info;
|
||||
delete fDecorList.ItemAt(i);;
|
||||
}
|
||||
|
||||
fDecorList.MakeEmpty();
|
||||
fCurrentDecor = NULL;
|
||||
}
|
||||
|
||||
|
||||
DecorInfo*
|
||||
DecorManager::FindDecor(const char *name)
|
||||
DecorManager::_FindDecor(const char *name)
|
||||
{
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
for (int32 i = 0; i < fDecorList.CountItems(); i++) {
|
||||
DecorInfo *info = (DecorInfo*)fDecorList.ItemAt(i);
|
||||
DecorInfo* info = fDecorList.ItemAt(i);
|
||||
|
||||
if (info && strcmp(name, info->GetName()) == 0)
|
||||
if (strcmp(name, info->Name()) == 0)
|
||||
return info;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
// This is the allocator function for the default decorator
|
||||
Decorator*
|
||||
create_default_decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
|
||||
{
|
||||
return new DefaultDecorator(rect, wlook, wfeel, wflags);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,50 +4,52 @@
|
||||
*
|
||||
* Author: DarkWyrm <[email protected]>
|
||||
*/
|
||||
#ifndef DECORMANAGER_H
|
||||
#define DECORMANAGER_H
|
||||
#ifndef DECOR_MANAGER_H
|
||||
#define DECOR_MANAGER_H
|
||||
|
||||
|
||||
#include <image.h>
|
||||
#include <String.h>
|
||||
#include <Locker.h>
|
||||
#include <List.h>
|
||||
#include <ObjectList.h>
|
||||
|
||||
#include "Decorator.h"
|
||||
#include "DisplayDriver.h"
|
||||
|
||||
class DecorInfo;
|
||||
class Desktop;
|
||||
|
||||
class DecorManager : public BLocker
|
||||
{
|
||||
public:
|
||||
DecorManager(void);
|
||||
~DecorManager(void);
|
||||
|
||||
void RescanDecorators(void);
|
||||
|
||||
Decorator * AllocateDecorator(BRect rect, const char *title,
|
||||
int32 wlook, int32 wfeel,
|
||||
int32 wflags, DisplayDriver *ddriver);
|
||||
|
||||
int32 CountDecorators(void) const;
|
||||
|
||||
int32 GetDecorator(void) const;
|
||||
bool SetDecorator(const int32 &index);
|
||||
bool SetR5Decorator(const int32 &value);
|
||||
const char * GetDecoratorName(const int32 &index);
|
||||
|
||||
// TODO: Implement this method once the rest of the necessary infrastructure
|
||||
// is in place
|
||||
// status_t GetPreview(const int32 &index, ServerBitmap *bitmap);
|
||||
|
||||
private:
|
||||
void EmptyList(void);
|
||||
DecorInfo* FindDecor(const char *name);
|
||||
|
||||
BList fDecorList;
|
||||
DecorInfo* fCurrentDecor;
|
||||
|
||||
class DecorManager : public BLocker {
|
||||
public:
|
||||
DecorManager();
|
||||
~DecorManager();
|
||||
|
||||
void RescanDecorators();
|
||||
|
||||
Decorator* AllocateDecorator(Desktop* desktop, BRect rect,
|
||||
const char *title, int32 look, int32 feel,
|
||||
int32 flags);
|
||||
|
||||
int32 CountDecorators() const;
|
||||
|
||||
int32 GetDecorator() const;
|
||||
bool SetDecorator(int32 index);
|
||||
bool SetR5Decorator(int32 value);
|
||||
const char* GetDecoratorName(int32 index);
|
||||
|
||||
// TODO: Implement this method once the rest of the necessary infrastructure
|
||||
// is in place
|
||||
//status_t GetPreview(int32 index, ServerBitmap *bitmap);
|
||||
|
||||
private:
|
||||
void _EmptyList();
|
||||
DecorInfo* _FindDecor(const char *name);
|
||||
|
||||
BObjectList<DecorInfo> fDecorList;
|
||||
DecorInfo* fCurrentDecor;
|
||||
};
|
||||
|
||||
extern DecorManager gDecorManager;
|
||||
|
||||
#endif
|
||||
#endif /* DECOR_MANAGER_H */
|
||||
|
||||
@@ -1,36 +1,23 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: Decorator.cpp
|
||||
// Author: DarkWyrm <[email protected]>
|
||||
// Stephan Aßmus <[email protected]>
|
||||
// Description: Base class for window decorators
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#include <Region.h>
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* DarkWyrm <[email protected]>
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
/** Base class for window decorators */
|
||||
|
||||
#include "ColorSet.h"
|
||||
#include "Decorator.h"
|
||||
#include "DisplayDriver.h"
|
||||
|
||||
#include <Region.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/*!
|
||||
\brief Constructor
|
||||
\param rect Size of client area
|
||||
@@ -41,14 +28,15 @@
|
||||
Does general initialization of internal data members and creates a colorset
|
||||
object.
|
||||
*/
|
||||
Decorator::Decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
|
||||
Decorator::Decorator(DesktopSettings& settings, BRect rect, int32 look,
|
||||
int32 feel, int32 flags)
|
||||
: _colors(new ColorSet()),
|
||||
_driver(NULL),
|
||||
_drawdata(),
|
||||
|
||||
_look(wlook),
|
||||
_feel(wfeel),
|
||||
_flags(wflags),
|
||||
_look(look),
|
||||
_feel(feel),
|
||||
_flags(flags),
|
||||
|
||||
_zoomrect(),
|
||||
_closerect(),
|
||||
|
||||
@@ -4,24 +4,26 @@
|
||||
*
|
||||
* Authors:
|
||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
*/
|
||||
|
||||
/** Default and fallback decorator for the app_server - the yellow tabs */
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Rect.h>
|
||||
#include <View.h>
|
||||
#include "DefaultDecorator.h"
|
||||
|
||||
#include "ColorUtils.h"
|
||||
#include "DesktopSettings.h"
|
||||
#include "DisplayDriver.h"
|
||||
#include "FontManager.h"
|
||||
#include "LayerData.h"
|
||||
#include "PatternHandler.h"
|
||||
#include "RGBColor.h"
|
||||
|
||||
#include "DefaultDecorator.h"
|
||||
#include <Rect.h>
|
||||
#include <View.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
//#define USE_VIEW_FILL_HACK
|
||||
|
||||
@@ -33,12 +35,17 @@
|
||||
# define STRACE(x) ;
|
||||
#endif
|
||||
|
||||
DefaultDecorator::DefaultDecorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
|
||||
: Decorator(rect, wlook, wfeel, wflags),
|
||||
fTruncatedTitle("")
|
||||
|
||||
DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
|
||||
int32 look, int32 feel, int32 flags)
|
||||
: Decorator(settings, rect, look, feel, flags)
|
||||
{
|
||||
ServerFont font(_look == B_FLOATING_WINDOW_LOOK ?
|
||||
*gFontManager->GetSystemPlain() : *gFontManager->GetSystemBold());
|
||||
ServerFont font;
|
||||
if (_look == B_FLOATING_WINDOW_LOOK)
|
||||
settings.GetDefaultPlainFont(font);
|
||||
else
|
||||
settings.GetDefaultBoldFont(font);
|
||||
|
||||
font.SetFlags(B_FORCE_ANTIALIASING);
|
||||
font.SetSpacing(B_STRING_SPACING);
|
||||
SetFont(&font);
|
||||
|
||||
@@ -1,43 +1,27 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, Haiku, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: DefaultDecorator.h
|
||||
// Author: DarkWyrm <[email protected]>
|
||||
// Description: Fallback decorator for the app_server
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef _DEFAULT_DECORATOR_H_
|
||||
#define _DEFAULT_DECORATOR_H_
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
*/
|
||||
#ifndef DEFAULT_DECORATOR_H
|
||||
#define DEFAULT_DECORATOR_H
|
||||
|
||||
|
||||
#include "Decorator.h"
|
||||
#include <Region.h>
|
||||
|
||||
class Desktop;
|
||||
|
||||
|
||||
class DefaultDecorator: public Decorator {
|
||||
public:
|
||||
DefaultDecorator(BRect frame,
|
||||
int32 look,
|
||||
int32 feel,
|
||||
int32 flags);
|
||||
DefaultDecorator(DesktopSettings& settings, BRect frame,
|
||||
int32 look, int32 feel, int32 flags);
|
||||
virtual ~DefaultDecorator();
|
||||
|
||||
|
||||
virtual void MoveBy(float x, float y);
|
||||
virtual void MoveBy(BPoint pt);
|
||||
virtual void ResizeBy(float x, float y);
|
||||
@@ -98,4 +82,4 @@ private:
|
||||
int32 fTruncatedTitleLength;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* DEFAULT_DECORATOR_H */
|
||||
|
||||
@@ -75,6 +75,7 @@ Desktop::Desktop(uid_t userID)
|
||||
return;
|
||||
|
||||
fLink.SetReceiverPort(fMessagePort);
|
||||
gFontManager->AttachUser(fUserID);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +88,7 @@ Desktop::~Desktop()
|
||||
delete fSettings;
|
||||
|
||||
delete_port(fMessagePort);
|
||||
gFontManager->DetachUser(fUserID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "DesktopSettings.h"
|
||||
#include "DesktopSettingsPrivate.h"
|
||||
#include "Desktop.h"
|
||||
#include "FontManager.h"
|
||||
#include "ServerConfig.h"
|
||||
|
||||
|
||||
DesktopSettings::Private::Private()
|
||||
@@ -30,6 +32,17 @@ DesktopSettings::Private::~Private()
|
||||
void
|
||||
DesktopSettings::Private::_SetDefaults()
|
||||
{
|
||||
_SetFont(fPlainFont, DEFAULT_PLAIN_FONT_FAMILY, DEFAULT_PLAIN_FONT_STYLE,
|
||||
DEFAULT_PLAIN_FONT_SIZE, FALLBACK_PLAIN_FONT_FAMILY, DEFAULT_PLAIN_FONT_STYLE,
|
||||
B_REGULAR_FACE);
|
||||
_SetFont(fBoldFont, DEFAULT_BOLD_FONT_FAMILY, DEFAULT_BOLD_FONT_STYLE,
|
||||
DEFAULT_BOLD_FONT_SIZE, FALLBACK_BOLD_FONT_FAMILY, DEFAULT_BOLD_FONT_STYLE,
|
||||
B_BOLD_FACE);
|
||||
_SetFont(fFixedFont, DEFAULT_FIXED_FONT_FAMILY, DEFAULT_FIXED_FONT_STYLE,
|
||||
DEFAULT_FIXED_FONT_SIZE, FALLBACK_FIXED_FONT_FAMILY, DEFAULT_FIXED_FONT_STYLE,
|
||||
B_REGULAR_FACE);
|
||||
fFixedFont.SetSpacing(B_FIXED_SPACING);
|
||||
|
||||
fMouseMode = B_NORMAL_MOUSE;
|
||||
|
||||
// init scrollbar info
|
||||
@@ -54,6 +67,28 @@ DesktopSettings::Private::_SetDefaults()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::Private::_SetFont(ServerFont &font, const char *familyName,
|
||||
const char *styleName, float size, const char *fallbackFamily,
|
||||
const char *fallbackStyle, uint16 fallbackFace)
|
||||
{
|
||||
BAutolock locker(gFontManager);
|
||||
|
||||
// try to find a matching font
|
||||
|
||||
FontStyle* style = gFontManager->GetStyle(familyName, styleName);
|
||||
if (style == NULL) {
|
||||
style = gFontManager->GetStyle(fallbackFamily, fallbackStyle);
|
||||
if (style == NULL) {
|
||||
style = gFontManager->FindStyleMatchingFace(fallbackFace);
|
||||
}
|
||||
}
|
||||
|
||||
if (style != NULL)
|
||||
font.SetStyle(*style);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
DesktopSettings::Private::_Load()
|
||||
{
|
||||
@@ -69,6 +104,48 @@ DesktopSettings::Private::Save()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::Private::SetDefaultPlainFont(const ServerFont &font)
|
||||
{
|
||||
fPlainFont = font;
|
||||
}
|
||||
|
||||
|
||||
const ServerFont &
|
||||
DesktopSettings::Private::DefaultPlainFont() const
|
||||
{
|
||||
return fPlainFont;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::Private::SetDefaultBoldFont(const ServerFont &font)
|
||||
{
|
||||
fBoldFont = font;
|
||||
}
|
||||
|
||||
|
||||
const ServerFont &
|
||||
DesktopSettings::Private::DefaultBoldFont() const
|
||||
{
|
||||
return fBoldFont;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::Private::SetDefaultFixedFont(const ServerFont &font)
|
||||
{
|
||||
fFixedFont = font;
|
||||
}
|
||||
|
||||
|
||||
const ServerFont &
|
||||
DesktopSettings::Private::DefaultFixedFont() const
|
||||
{
|
||||
return fFixedFont;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::Private::SetScrollBarInfo(const scroll_bar_info& info)
|
||||
{
|
||||
@@ -174,6 +251,48 @@ DesktopSettings::~DesktopSettings()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::SetDefaultPlainFont(const ServerFont &font)
|
||||
{
|
||||
fSettings->SetDefaultPlainFont(font);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::GetDefaultPlainFont(ServerFont &font) const
|
||||
{
|
||||
font = fSettings->DefaultPlainFont();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::SetDefaultBoldFont(const ServerFont &font)
|
||||
{
|
||||
fSettings->SetDefaultBoldFont(font);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::GetDefaultBoldFont(ServerFont &font) const
|
||||
{
|
||||
font = fSettings->DefaultBoldFont();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::SetDefaultFixedFont(const ServerFont &font)
|
||||
{
|
||||
fSettings->SetDefaultFixedFont(font);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::GetDefaultFixedFont(ServerFont &font) const
|
||||
{
|
||||
font = fSettings->DefaultFixedFont();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::SetScrollBarInfo(const scroll_bar_info& info)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <Message.h>
|
||||
|
||||
class Desktop;
|
||||
class ServerFont;
|
||||
|
||||
|
||||
static const int32 kMaxWorkspaces = 32;
|
||||
@@ -26,6 +27,15 @@ class DesktopSettings {
|
||||
|
||||
status_t Save();
|
||||
|
||||
void SetDefaultPlainFont(const ServerFont& font);
|
||||
void GetDefaultPlainFont(ServerFont& font) const;
|
||||
|
||||
void SetDefaultBoldFont(const ServerFont& font);
|
||||
void GetDefaultBoldFont(ServerFont& font) const;
|
||||
|
||||
void SetDefaultFixedFont(const ServerFont& font);
|
||||
void GetDefaultFixedFont(ServerFont& font) const;
|
||||
|
||||
void SetScrollBarInfo(const scroll_bar_info& info);
|
||||
void GetScrollBarInfo(scroll_bar_info& info) const;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
|
||||
#include "DesktopSettings.h"
|
||||
#include "ServerFont.h"
|
||||
|
||||
#include <Locker.h>
|
||||
|
||||
@@ -21,6 +22,15 @@ class DesktopSettings::Private : public BLocker {
|
||||
|
||||
status_t Save();
|
||||
|
||||
void SetDefaultPlainFont(const ServerFont& font);
|
||||
const ServerFont& DefaultPlainFont() const;
|
||||
|
||||
void SetDefaultBoldFont(const ServerFont& font);
|
||||
const ServerFont& DefaultBoldFont() const;
|
||||
|
||||
void SetDefaultFixedFont(const ServerFont& font);
|
||||
const ServerFont& DefaultFixedFont() const;
|
||||
|
||||
void SetScrollBarInfo(const scroll_bar_info &info);
|
||||
const scroll_bar_info& ScrollBarInfo() const;
|
||||
|
||||
@@ -39,8 +49,15 @@ class DesktopSettings::Private : public BLocker {
|
||||
|
||||
private:
|
||||
void _SetDefaults();
|
||||
void _SetFont(ServerFont& font, const char* family, const char* style,
|
||||
float size, const char *fallbackFamily,
|
||||
const char* fallbackStyle, uint16 fallbackFace);
|
||||
status_t _Load();
|
||||
|
||||
ServerFont fPlainFont;
|
||||
ServerFont fBoldFont;
|
||||
ServerFont fFixedFont;
|
||||
|
||||
scroll_bar_info fScrollBarInfo;
|
||||
menu_info fMenuInfo;
|
||||
mode_mouse fMouseMode;
|
||||
|
||||
+145
-131
@@ -4,23 +4,26 @@
|
||||
*
|
||||
* Authors:
|
||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
*/
|
||||
|
||||
/** Handles the largest part of the font subsystem */
|
||||
/** Manages font families and styles */
|
||||
|
||||
|
||||
#include <FontFamily.h>
|
||||
#include <FontManager.h>
|
||||
#include <ServerConfig.h>
|
||||
#include <ServerFont.h>
|
||||
|
||||
#include <Autolock.h>
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Message.h>
|
||||
#include <Path.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <FontManager.h>
|
||||
#include <FontFamily.h>
|
||||
#include <ServerFont.h>
|
||||
#include "ServerConfig.h"
|
||||
|
||||
#include <new>
|
||||
|
||||
|
||||
@@ -50,15 +53,22 @@ face_requester(FTC_FaceID face_id, FT_Library library,
|
||||
|
||||
//! Does basic set up so that directories can be scanned
|
||||
FontManager::FontManager()
|
||||
: BLocker("font server lock"),
|
||||
: BLooper("Font Manager"),
|
||||
fFamilies(20),
|
||||
fPlain(NULL),
|
||||
fBold(NULL),
|
||||
fFixed(NULL),
|
||||
fDefaultFont(NULL),
|
||||
fNextID(0)
|
||||
{
|
||||
fInitStatus = FT_Init_FreeType(&gFreeTypeLibrary) == 0 ? B_OK : B_ERROR;
|
||||
|
||||
if (fInitStatus == B_OK) {
|
||||
_ScanSystemFonts();
|
||||
|
||||
if (CountFamilies() != 0)
|
||||
_SetDefaultFont();
|
||||
else
|
||||
fInitStatus = B_ENTRY_NOT_FOUND;
|
||||
}
|
||||
|
||||
/*
|
||||
Fire up the font caching subsystem.
|
||||
The three zeros tell FreeType to use the defaults, which are 2 faces,
|
||||
@@ -79,30 +89,10 @@ FontManager::~FontManager()
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Counts the number of font families available
|
||||
\return The number of unique font families currently available
|
||||
*/
|
||||
int32
|
||||
FontManager::CountFamilies(void)
|
||||
void
|
||||
FontManager::MessageReceived(BMessage* message)
|
||||
{
|
||||
return fFamilies.CountItems();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Counts the number of styles available in a font family
|
||||
\param family Name of the font family to scan
|
||||
\return The number of font styles currently available for the font family
|
||||
*/
|
||||
int32
|
||||
FontManager::CountStyles(const char *familyName)
|
||||
{
|
||||
FontFamily *family = GetFamily(familyName);
|
||||
if (family)
|
||||
return family->CountStyles();
|
||||
|
||||
return 0;
|
||||
// nothing to do here yet
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +101,7 @@ FontManager::CountStyles(const char *familyName)
|
||||
\param family The family to remove
|
||||
*/
|
||||
void
|
||||
FontManager::RemoveFamily(const char *familyName)
|
||||
FontManager::_RemoveFamily(const char *familyName)
|
||||
{
|
||||
FontFamily *family = GetFamily(familyName);
|
||||
if (family) {
|
||||
@@ -121,17 +111,36 @@ FontManager::RemoveFamily(const char *familyName)
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets the font that will be used when you create an empty
|
||||
ServerFont without specifying a style.
|
||||
*/
|
||||
void
|
||||
FontManager::_SetDefaultFont()
|
||||
{
|
||||
FontStyle* style = GetStyle(DEFAULT_PLAIN_FONT_FAMILY, DEFAULT_PLAIN_FONT_STYLE);
|
||||
if (style == NULL) {
|
||||
style = FindStyleMatchingFace(B_REGULAR_FACE);
|
||||
if (style == NULL)
|
||||
style = FamilyAt(0)->StyleAt(0);
|
||||
}
|
||||
|
||||
fDefaultFont = new ServerFont(*style, DEFAULT_PLAIN_FONT_SIZE);
|
||||
}
|
||||
|
||||
|
||||
//! Scans the four default system font folders
|
||||
void
|
||||
FontManager::ScanSystemFolders(void)
|
||||
FontManager::_ScanSystemFonts()
|
||||
{
|
||||
ScanDirectory("/boot/beos/etc/fonts/ttfonts/");
|
||||
|
||||
BPath path;
|
||||
if (find_directory(B_BEOS_FONTS_DIRECTORY, &path) == B_OK)
|
||||
_AddPath(path.Path());
|
||||
|
||||
// We don't scan these in test mode to help shave off some startup time
|
||||
#if !TEST_MODE
|
||||
ScanDirectory("/boot/beos/etc/fonts/PS-Type1/");
|
||||
ScanDirectory("/boot/home/config/fonts/ttfonts/");
|
||||
ScanDirectory("/boot/home/config/fonts/psfonts/");
|
||||
if (find_directory(B_COMMON_FONTS_DIRECTORY, &path) == B_OK)
|
||||
_AddPath(path.Path());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -176,29 +185,62 @@ FontManager::_AddFont(BPath &path)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
FontManager::_AddPath(const char* path)
|
||||
{
|
||||
BEntry entry;
|
||||
status_t status = entry.SetTo(path);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
return _AddPath(entry);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
FontManager::_AddPath(BEntry& entry)
|
||||
{
|
||||
status_t status = _ScanDirectory(entry);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
node_ref nodeRef;
|
||||
if (entry.GetNodeRef(&nodeRef) != B_OK)
|
||||
return status;
|
||||
|
||||
// TODO: don't add it twice!
|
||||
// TODO: monitor this directory!
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Scan a folder for all valid fonts
|
||||
\param directoryPath Path of the folder to scan.
|
||||
*/
|
||||
status_t
|
||||
FontManager::ScanDirectory(const char *directoryPath)
|
||||
FontManager::_ScanDirectory(BEntry& entry)
|
||||
{
|
||||
// This bad boy does all the real work. It loads each entry in the
|
||||
// directory. If a valid font file, it adds both the family and the style.
|
||||
// Both family and style are stored internally as BStrings. Once everything
|
||||
|
||||
BDirectory dir;
|
||||
status_t status = dir.SetTo(directoryPath);
|
||||
status_t status = dir.SetTo(&entry);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
BEntry entry;
|
||||
while (dir.GetNextEntry(&entry) == B_OK) {
|
||||
BPath path;
|
||||
status = entry.GetPath(&path);
|
||||
if (status < B_OK)
|
||||
continue;
|
||||
|
||||
if (entry.IsDirectory()) {
|
||||
// scan this directory recursively
|
||||
_AddPath(entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO: Commenting this out makes my "Unicode glyph lookup"
|
||||
// work with our default fonts. The real fix is to select the
|
||||
@@ -265,8 +307,35 @@ FontManager::_GetSupportedCharmap(const FT_Face& face)
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Counts the number of font families available
|
||||
\return The number of unique font families currently available
|
||||
*/
|
||||
int32
|
||||
FontManager::CountFamilies() const
|
||||
{
|
||||
return fFamilies.CountItems();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Counts the number of styles available in a font family
|
||||
\param family Name of the font family to scan
|
||||
\return The number of font styles currently available for the font family
|
||||
*/
|
||||
int32
|
||||
FontManager::CountStyles(const char *familyName) const
|
||||
{
|
||||
FontFamily *family = GetFamily(familyName);
|
||||
if (family)
|
||||
return family->CountStyles();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
FontFamily*
|
||||
FontManager::GetFamilyByIndex(int32 index) const
|
||||
FontManager::FamilyAt(int32 index) const
|
||||
{
|
||||
return fFamilies.ItemAt(index);
|
||||
}
|
||||
@@ -378,106 +447,51 @@ FontManager::GetStyle(uint16 familyID, uint16 styleID)
|
||||
|
||||
|
||||
/*!
|
||||
\brief Returns the current object used for the regular style
|
||||
\return A ServerFont pointer which is the plain font.
|
||||
|
||||
Do NOT delete this object. If you access it, make a copy of it.
|
||||
\brief If you don't find your preferred font style, but are anxious
|
||||
to have one fitting your needs, you may want to use this method.
|
||||
*/
|
||||
ServerFont*
|
||||
FontManager::GetSystemPlain()
|
||||
FontStyle*
|
||||
FontManager::FindStyleMatchingFace(uint16 face) const
|
||||
{
|
||||
return fPlain;
|
||||
int32 count = fFamilies.CountItems();
|
||||
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
FontFamily* family = fFamilies.ItemAt(i);
|
||||
FontStyle* style = family->GetStyleMatchingFace(face);
|
||||
if (style != NULL)
|
||||
return style;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Returns the current object used for the bold style
|
||||
\return A ServerFont pointer which is the bold font.
|
||||
|
||||
Do NOT delete this object. If you access it, make a copy of it.
|
||||
*/
|
||||
ServerFont*
|
||||
FontManager::GetSystemBold()
|
||||
const ServerFont*
|
||||
FontManager::DefaultFont() const
|
||||
{
|
||||
return fBold;
|
||||
return fDefaultFont;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Returns the current object used for the fixed style
|
||||
\return A ServerFont pointer which is the fixed font.
|
||||
|
||||
Do NOT delete this object. If you access it, make a copy of it.
|
||||
*/
|
||||
ServerFont*
|
||||
FontManager::GetSystemFixed()
|
||||
void
|
||||
FontManager::AttachUser(uid_t userID)
|
||||
{
|
||||
return fFixed;
|
||||
BAutolock locker(this);
|
||||
|
||||
/*
|
||||
BPath path;
|
||||
status_t status = find_directory(B_USER_FONTS_DIRECTORY, &path);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
_AddPath(path.Path());
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets the system's plain font to the specified family and style
|
||||
\param family Name of the font's family
|
||||
\param style Name of the style desired
|
||||
\param size Size desired
|
||||
\return true if successful, false if not.
|
||||
|
||||
*/
|
||||
bool
|
||||
FontManager::SetSystemPlain(const char* familyName, const char* styleName, float size)
|
||||
void
|
||||
FontManager::DetachUser(uid_t userID)
|
||||
{
|
||||
FontStyle *style = GetStyle(familyName, styleName);
|
||||
if (style == NULL)
|
||||
return false;
|
||||
|
||||
delete fPlain;
|
||||
fPlain = new ServerFont(*style, size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets the system's bold font to the specified family and style
|
||||
\param family Name of the font's family
|
||||
\param style Name of the style desired
|
||||
\param size Size desired
|
||||
\return true if successful, false if not.
|
||||
|
||||
*/
|
||||
bool
|
||||
FontManager::SetSystemBold(const char* familyName, const char* styleName, float size)
|
||||
{
|
||||
FontStyle *style = GetStyle(familyName, styleName);
|
||||
if (style == NULL)
|
||||
return false;
|
||||
|
||||
delete fBold;
|
||||
fBold = new ServerFont(*style, size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets the system's fixed font to the specified family and style
|
||||
\param family Name of the font's family
|
||||
\param style Name of the style desired
|
||||
\param size Size desired
|
||||
\return true if successful, false if not.
|
||||
|
||||
*/
|
||||
bool
|
||||
FontManager::SetSystemFixed(const char* familyName, const char* styleName, float size)
|
||||
{
|
||||
FontStyle *style = GetStyle(familyName, styleName);
|
||||
if (style == NULL)
|
||||
return false;
|
||||
|
||||
delete fFixed;
|
||||
fFixed = new ServerFont(*style, size);
|
||||
|
||||
return true;
|
||||
BAutolock locker(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "LayerData.h"
|
||||
|
||||
|
||||
// constructor
|
||||
DrawData::DrawData()
|
||||
: fOrigin(0.0, 0.0),
|
||||
fScale(1.0),
|
||||
@@ -34,7 +33,6 @@ DrawData::DrawData()
|
||||
fAlphaFncMode(B_ALPHA_OVERLAY),
|
||||
fPenLocation(0.0, 0.0),
|
||||
fPenSize(1.0),
|
||||
fFont(*gFontManager->GetSystemPlain()),
|
||||
fFontAliasing(false),
|
||||
fSubPixelPrecise(false),
|
||||
fLineCapMode(B_BUTT_CAP),
|
||||
@@ -44,14 +42,14 @@ DrawData::DrawData()
|
||||
fUnscaledFontSize = fFont.Size();
|
||||
}
|
||||
|
||||
// copy constructor
|
||||
|
||||
DrawData::DrawData(const DrawData& from)
|
||||
: fClippingRegion(NULL)
|
||||
{
|
||||
*this = from;
|
||||
}
|
||||
|
||||
// copy constructor
|
||||
|
||||
DrawData::DrawData(const DrawData* from)
|
||||
: fOrigin(0.0, 0.0),
|
||||
fScale(1.0),
|
||||
|
||||
@@ -1134,27 +1134,13 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
gFontManager->Lock();
|
||||
bool needsUpdate = gFontManager->FontsNeedUpdated();
|
||||
gFontManager->Unlock();
|
||||
|
||||
if(checkonly)
|
||||
{
|
||||
|
||||
if (checkonly) {
|
||||
fLink.StartMessage(needsUpdate ? SERVER_TRUE : SERVER_FALSE);
|
||||
fLink.Flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(needsUpdate)
|
||||
{
|
||||
gFontManager->Lock();
|
||||
gFontManager->ScanSystemFolders();
|
||||
gFontManager->Unlock();
|
||||
fLink.StartMessage(SERVER_TRUE);
|
||||
fLink.Flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
fLink.StartMessage(SERVER_FALSE);
|
||||
fLink.Flush();
|
||||
}
|
||||
} else {
|
||||
fLink.StartMessage(SERVER_FALSE);
|
||||
fLink.Flush();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1172,7 +1158,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
|
||||
gFontManager->Lock();
|
||||
|
||||
FontFamily *family = gFontManager->GetFamilyByIndex(index);
|
||||
FontFamily *family = gFontManager->FamilyAt(index);
|
||||
if (family) {
|
||||
fLink.StartMessage(B_OK);
|
||||
fLink.AttachString(family->Name());
|
||||
@@ -1555,32 +1541,28 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
// 4) uint16 - face flags
|
||||
// 5) uint32 - font flags
|
||||
|
||||
gFontManager->Lock();
|
||||
DesktopSettings settings(fDesktop);
|
||||
|
||||
ServerFont *font = NULL;
|
||||
ServerFont font;
|
||||
switch (code) {
|
||||
case AS_SET_SYSFONT_PLAIN:
|
||||
font = gFontManager->GetSystemPlain();
|
||||
settings.GetDefaultPlainFont(font);
|
||||
break;
|
||||
case AS_SET_SYSFONT_BOLD:
|
||||
font = gFontManager->GetSystemBold();
|
||||
settings.GetDefaultBoldFont(font);
|
||||
break;
|
||||
case AS_SET_SYSFONT_FIXED:
|
||||
font = gFontManager->GetSystemFixed();
|
||||
settings.GetDefaultFixedFont(font);
|
||||
break;
|
||||
}
|
||||
|
||||
if (font != NULL) {
|
||||
fLink.StartMessage(B_OK);
|
||||
fLink.Attach<uint16>(font->FamilyID());
|
||||
fLink.Attach<uint16>(font->StyleID());
|
||||
fLink.Attach<float>(font->Size());
|
||||
fLink.Attach<uint16>(font->Face());
|
||||
fLink.Attach<uint32>(font->Flags());
|
||||
} else
|
||||
fLink.StartMessage(B_BAD_VALUE);
|
||||
fLink.StartMessage(B_OK);
|
||||
fLink.Attach<uint16>(font.FamilyID());
|
||||
fLink.Attach<uint16>(font.StyleID());
|
||||
fLink.Attach<float>(font.Size());
|
||||
fLink.Attach<uint16>(font.Face());
|
||||
fLink.Attach<uint32>(font.Flags());
|
||||
|
||||
gFontManager->Unlock();
|
||||
fLink.Flush();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ ServerFont::ServerFont()
|
||||
:
|
||||
fStyle(NULL)
|
||||
{
|
||||
*this = *gFontManager->GetSystemPlain();
|
||||
*this = *gFontManager->DefaultFont();
|
||||
}
|
||||
|
||||
|
||||
@@ -190,8 +190,7 @@ ServerFont::operator=(const ServerFont& font)
|
||||
fEncoding = font.fEncoding;
|
||||
fBounds = font.fBounds;
|
||||
|
||||
_SetStyle(font.fStyle);
|
||||
|
||||
SetStyle(*font.fStyle);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -232,6 +231,21 @@ ServerFont::GetFamily() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ServerFont::SetStyle(FontStyle& style)
|
||||
{
|
||||
if (&style != fStyle) {
|
||||
// detach from old style
|
||||
if (fStyle)
|
||||
fStyle->Release();
|
||||
|
||||
// attach to new style
|
||||
fStyle = &style;
|
||||
fStyle->Acquire();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Sets the ServerFont instance to whatever font is specified
|
||||
\param familyID ID number of the family to set
|
||||
@@ -254,7 +268,7 @@ ServerFont::SetFamilyAndStyle(uint16 familyID, uint16 styleID)
|
||||
if (!style)
|
||||
return B_ERROR;
|
||||
|
||||
_SetStyle(style);
|
||||
SetStyle(*style);
|
||||
style->Release();
|
||||
|
||||
return B_OK;
|
||||
@@ -708,20 +722,3 @@ ServerFont::TruncateString(BString* inOut, uint32 mode, float width) const
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ServerFont::_SetStyle(FontStyle* style)
|
||||
{
|
||||
if (style == NULL)
|
||||
debugger("set NULL style!");
|
||||
|
||||
if (style != fStyle) {
|
||||
// detach from old style
|
||||
if (fStyle)
|
||||
fStyle->Release();
|
||||
|
||||
// attach to new style
|
||||
fStyle = style;
|
||||
fStyle->Acquire();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "MessagePrivate.h"
|
||||
#include "PortLink.h"
|
||||
#include "RootLayer.h"
|
||||
#include "ServerApp.h"
|
||||
#include "ServerWindow.h"
|
||||
#include "TokenHandler.h"
|
||||
#include "Workspace.h"
|
||||
@@ -110,8 +111,8 @@ WinBorder::WinBorder(const BRect &frame,
|
||||
QuietlySetFeel(feel);
|
||||
|
||||
if (fFeel != B_NO_BORDER_WINDOW_LOOK) {
|
||||
fDecorator = gDecorManager.AllocateDecorator(frame, name, fLook, fFeel,
|
||||
fWindowFlags, fDriver);
|
||||
fDecorator = gDecorManager.AllocateDecorator(window->App()->GetDesktop(), frame,
|
||||
name, fLook, fFeel, fWindowFlags);
|
||||
if (fDecorator)
|
||||
fDecorator->GetSizeLimits(&fMinWidth, &fMinHeight, &fMaxWidth, &fMaxHeight);
|
||||
}
|
||||
|
||||
@@ -89,9 +89,6 @@ Painter::Painter()
|
||||
fPatternHandler(new PatternHandler()),
|
||||
fTextRenderer(new AGGTextRenderer())
|
||||
{
|
||||
if (gFontManager && gFontManager->GetSystemPlain())
|
||||
fFont = *gFontManager->GetSystemPlain();
|
||||
|
||||
_UpdateFont();
|
||||
_UpdateLineWidth();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user