Updates to RGBColor and adding Doxygen documentation
Added foundation for font classes. Still not in build (on purpose) git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2342 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
c893786008
commit
8927dfb846
|
@ -0,0 +1,315 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// 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: FontFamily.cpp
|
||||
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
||||
// Description: classes to represent font styles and families
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#include "FontFamily.h"
|
||||
#include "ServerFont.h"
|
||||
#include FT_CACHE_H
|
||||
|
||||
extern FTC_Manager ftmanager;
|
||||
|
||||
/*!
|
||||
\fn FontStyle(const char *filepath, FT_Face face)
|
||||
\brief FontStyle Constructor
|
||||
\param path to a font file
|
||||
\param face FreeType handle for the font file after it is loaded - for its info only
|
||||
*/
|
||||
FontStyle::FontStyle(const char *filepath, FT_Face face)
|
||||
{
|
||||
name=new BString(face->style_name);
|
||||
cachedface=new CachedFaceRec;
|
||||
cachedface->file_path=filepath;
|
||||
family=NULL;
|
||||
instances=new BList(0);
|
||||
has_bitmaps=(face->num_fixed_sizes>0)?true:false;
|
||||
is_fixedwidth=(face->face_flags & FT_FACE_FLAG_FIXED_WIDTH)?true:false;
|
||||
is_scalable=(face->face_flags & FT_FACE_FLAG_SCALABLE)?true:false;
|
||||
has_kerning=(face->face_flags & FT_FACE_FLAG_KERNING)?true:false;
|
||||
glyphcount=face->num_glyphs;
|
||||
charmapcount=face->num_charmaps;
|
||||
tunedcount=face->num_fixed_sizes;
|
||||
path=new BString(filepath);
|
||||
fbounds.Set(0,0,0,0);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn ~FontStyle(void)
|
||||
\brief FontStyle Destructor
|
||||
|
||||
Frees all data allocated on the heap. All child ServerFonts are marked as having
|
||||
a NULL style so that each ServerFont knows that it is running on borrowed time.
|
||||
This is done because a FontStyle should be deleted only when it no longer has any
|
||||
dependencies.
|
||||
*/
|
||||
FontStyle::~FontStyle(void)
|
||||
{
|
||||
delete name;
|
||||
delete path;
|
||||
delete cachedface;
|
||||
|
||||
// Mark all instances as Free here
|
||||
int32 index=0;
|
||||
|
||||
ServerFont *fs=(ServerFont*)instances->ItemAt(index);
|
||||
|
||||
while(fs)
|
||||
{
|
||||
fs->fstyle=NULL;
|
||||
index++;
|
||||
fs=(ServerFont*)instances->ItemAt(index);
|
||||
}
|
||||
|
||||
instances->MakeEmpty();
|
||||
delete instances;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn const char *FontStyle::Name(void)
|
||||
\brief Returns the name of the style as a string
|
||||
\return The style's name
|
||||
*/
|
||||
const char *FontStyle::Name(void)
|
||||
{
|
||||
return path->String();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn FT_Face FontStyle::GetFace(void)
|
||||
\brief Returns a handle to the style in question, straight from FreeType's cache
|
||||
\return FreeType face handle or NULL if there was an internal error
|
||||
*/
|
||||
FT_Face FontStyle::GetFace(void)
|
||||
{
|
||||
FT_Face f;
|
||||
return (FTC_Manager_Lookup_Face(ftmanager,cachedface,&f)!=0)?f:NULL;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn const char *FontStyle::GetPath(void)
|
||||
\brief Returns the path to the style's font file
|
||||
\return The style's font file path
|
||||
*/
|
||||
const char *FontStyle::GetPath(void)
|
||||
{
|
||||
return path->String();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn int16 FontStyle::ConvertToUnicode(uint16 c)
|
||||
\brief Converts an ASCII character to Unicode for the style
|
||||
\param An ASCII character
|
||||
\return A Unicode value for the character
|
||||
*/
|
||||
int16 FontStyle::ConvertToUnicode(uint16 c)
|
||||
{
|
||||
FT_Face f;
|
||||
if(FTC_Manager_Lookup_Face(ftmanager,cachedface,&f)!=0)
|
||||
return 0;
|
||||
|
||||
return FT_Get_Char_Index(f,c);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn ServerFont *FontStyle::Instantiate(float size, float rotation=0.0, float shear=90.0)
|
||||
\brief Creates a new ServerFont object for the style, given size, shear, and rotation.
|
||||
\param character size in points
|
||||
\param rotation in degrees
|
||||
\param shear (slant) in degrees. 45 <= shear <= 135. 90 is vertical
|
||||
\return The new ServerFont object
|
||||
*/
|
||||
ServerFont *FontStyle::Instantiate(float size, float rotation=0.0, float shear=90.0)
|
||||
{
|
||||
ServerFont *f=new ServerFont(this, size, rotation, shear);
|
||||
instances->AddItem(f);
|
||||
return f;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn FontFamily(const char *namestr)
|
||||
\brief Constructor
|
||||
\param Name of the family
|
||||
*/
|
||||
FontFamily::FontFamily(const char *namestr)
|
||||
{
|
||||
name=new BString(namestr);
|
||||
styles=new BList(0);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn ~FontFamily(void)
|
||||
\brief Destructor
|
||||
|
||||
Deletes all child styles. Note that a FontFamily should not be deleted unless
|
||||
its styles have no dependencies or some other really good reason, such as
|
||||
system shutdown.
|
||||
*/
|
||||
FontFamily::~FontFamily(void)
|
||||
{
|
||||
delete name;
|
||||
|
||||
BString *string;
|
||||
for(int32 i=0; i<styles->CountItems(); i++)
|
||||
{
|
||||
string=(BString *)styles->RemoveItem(i);
|
||||
if(string)
|
||||
delete string;
|
||||
}
|
||||
styles->MakeEmpty(); // should be empty, but just in case...
|
||||
delete styles;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn const char *FontFamily::Name(void)
|
||||
\brief Returns the name of the family
|
||||
\return The family's name
|
||||
*/
|
||||
const char *FontFamily::Name(void)
|
||||
{
|
||||
return name->String();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void FontFamily::AddStyle(const char *path,FT_Face face)
|
||||
\brief Adds the style to the family
|
||||
\param full path to the style's font file
|
||||
\param FreeType face handle used to obtain info about the font
|
||||
*/
|
||||
void FontFamily::AddStyle(const char *path,FT_Face face)
|
||||
{
|
||||
if(!path)
|
||||
return;
|
||||
|
||||
BString style(face->style_name);
|
||||
FontStyle *item;
|
||||
|
||||
// Don't add if it already is in the family.
|
||||
int32 count=styles->CountItems();
|
||||
for(int32 i=0; i<count; i++)
|
||||
{
|
||||
item=(FontStyle *)styles->ItemAt(i);
|
||||
if(item->name->Compare(face->style_name)==0)
|
||||
return;
|
||||
}
|
||||
|
||||
item=new FontStyle(path, face);
|
||||
item->family=this;
|
||||
styles->AddItem(item);
|
||||
AddDependent();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void FontFamily::RemoveStyle(const char *style)
|
||||
\brief Removes a style from the family and deletes it
|
||||
\param Name of the style to be removed from the family
|
||||
*/
|
||||
void FontFamily::RemoveStyle(const char *style)
|
||||
{
|
||||
int32 count=styles->CountItems();
|
||||
if(!style || count<1)
|
||||
return;
|
||||
|
||||
FontStyle *fs;
|
||||
for(int32 i=0; i<count; i++)
|
||||
{
|
||||
fs=(FontStyle *)styles->ItemAt(i);
|
||||
if(fs && fs->name->Compare(style)==0)
|
||||
{
|
||||
fs=(FontStyle *)styles->RemoveItem(i);
|
||||
if(fs)
|
||||
{
|
||||
delete fs;
|
||||
RemoveDependent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn int32 FontFamily::CountStyles(void)
|
||||
\brief Returns the number of styles in the family
|
||||
\return The number of styles in the family
|
||||
*/
|
||||
int32 FontFamily::CountStyles(void)
|
||||
{
|
||||
return styles->CountItems();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool FontFamily::HasStyle(const char *style)
|
||||
\brief Determines whether the style belongs to the family
|
||||
\param Name of the style being checked
|
||||
\return True if it belongs, false if not
|
||||
*/
|
||||
bool FontFamily::HasStyle(const char *style)
|
||||
{
|
||||
int32 count=styles->CountItems();
|
||||
if(!style || count<1)
|
||||
return false;
|
||||
FontStyle *fs;
|
||||
for(int32 i=0; i<count; i++)
|
||||
{
|
||||
fs=(FontStyle *)styles->ItemAt(i);
|
||||
if(fs && fs->name->Compare(style)==0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn const char *FontFamily::GetStyle(int32 index)
|
||||
\brief Returns the name of a style in the family
|
||||
\param list index of the style to be found
|
||||
\return name of the style or NULL if the index is not valid
|
||||
*/
|
||||
const char *FontFamily::GetStyle(int32 index)
|
||||
{
|
||||
FontStyle *fs=(FontStyle*)styles->ItemAt(index);
|
||||
if(!fs)
|
||||
return NULL;
|
||||
return fs->Name();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn FontStyle *FontFamily::GetStyle(const char *style)
|
||||
\brief Get the FontStyle object for the name given
|
||||
\param Name of the style to be obtained
|
||||
\return The FontStyle object or NULL if none was found.
|
||||
|
||||
The object returned belongs to the family and must not be deleted.
|
||||
*/
|
||||
FontStyle *FontFamily::GetStyle(const char *style)
|
||||
{
|
||||
int32 count=styles->CountItems();
|
||||
if(!style || count<1)
|
||||
return NULL;
|
||||
FontStyle *fs;
|
||||
for(int32 i=0; i<count; i++)
|
||||
{
|
||||
fs=(FontStyle *)styles->ItemAt(i);
|
||||
if(fs && fs->name->Compare(style)==0)
|
||||
return fs;
|
||||
}
|
||||
return NULL;
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// 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: FontFamily.h
|
||||
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
||||
// Description: classes to represent font styles and families
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef FONT_FAMILY_H_
|
||||
#define FONT_FAMILY_H_
|
||||
|
||||
#include <String.h>
|
||||
#include <Rect.h>
|
||||
#include <Font.h>
|
||||
#include <List.h>
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include "SharedObject.h"
|
||||
|
||||
class FontFamily;
|
||||
class ServerFont;
|
||||
|
||||
enum font_format
|
||||
{
|
||||
FONT_TRUETYPE=0,
|
||||
FONT_TYPE_1,
|
||||
FONT_OPENTYPE,
|
||||
FONT_BDF,
|
||||
FONT_CFF,
|
||||
FONT_CID,
|
||||
FONT_PCF,
|
||||
FONT_PFR,
|
||||
FONT_SFNT,
|
||||
FONT_TYPE_42,
|
||||
FONT_WINFONT,
|
||||
};
|
||||
|
||||
|
||||
//! data structure used by the FreeType cache manager
|
||||
typedef struct CachedFaceRec_
|
||||
{
|
||||
BString file_path;
|
||||
int face_index;
|
||||
} CachedFaceRec, *CachedFace;
|
||||
|
||||
/*!
|
||||
\class FontStyle FontFamily.h
|
||||
\brief Object used to represent a font style
|
||||
|
||||
FontStyle objects help abstract a lot of the font engine details while
|
||||
still offering plenty of information the style in question.
|
||||
*/
|
||||
class FontStyle : public SharedObject
|
||||
{
|
||||
public:
|
||||
FontStyle(const char *filepath, FT_Face face);
|
||||
~FontStyle(void);
|
||||
ServerFont *Instantiate(float size, float rotation=0.0, float shear=90.0);
|
||||
|
||||
/*!
|
||||
\fn bool FontStyle::IsFixedWidth(void)
|
||||
\brief Determines whether the font's character width is fixed
|
||||
\return true if fixed, false if not
|
||||
*/
|
||||
bool IsFixedWidth(void) { return is_fixedwidth; }
|
||||
/*!
|
||||
\fn bool FontStyle::IsScalable(void)
|
||||
\brief Determines whether the font can be scaled to any size
|
||||
\return true if scalable, false if not
|
||||
*/
|
||||
bool IsScalable(void) { return is_scalable; }
|
||||
/*!
|
||||
\fn bool FontStyle::HasKerning(void)
|
||||
\brief Determines whether the font has kerning information
|
||||
\return true if kerning info is available, false if not
|
||||
*/
|
||||
bool HasKerning(void) { return has_kerning; }
|
||||
/*!
|
||||
\fn bool FontStyle::HasTuned(void)
|
||||
\brief Determines whether the font contains strikes
|
||||
\return true if it has strikes included, false if not
|
||||
*/
|
||||
bool HasTuned(void) { return has_bitmaps; }
|
||||
/*!
|
||||
\fn bool FontStyle::TunedCount(void)
|
||||
\brief Returns the number of strikes the style contains
|
||||
\return The number of strikes the style contains
|
||||
*/
|
||||
int32 TunedCount(void) { return tunedcount; }
|
||||
/*!
|
||||
\fn bool FontStyle::GlyphCount(void)
|
||||
\brief Returns the number of glyphs in the style
|
||||
\return The number of glyphs the style contains
|
||||
*/
|
||||
uint16 GlyphCount(void) { return glyphcount; }
|
||||
/*!
|
||||
\fn bool FontStyle::CharMapCount(void)
|
||||
\brief Returns the number of character maps the style contains
|
||||
\return The number of character maps the style contains
|
||||
*/
|
||||
uint16 CharMapCount(void) { return charmapcount; }
|
||||
const char *Name(void);
|
||||
FontFamily *Family(void) { return family; }
|
||||
FT_Face GetFace(void);
|
||||
const char *GetPath(void);
|
||||
int16 ConvertToUnicode(uint16 c);
|
||||
protected:
|
||||
friend FontFamily;
|
||||
FontFamily *family;
|
||||
uint16 glyphcount, charmapcount;
|
||||
BString *name, *path;
|
||||
BList *instances;
|
||||
bool is_fixedwidth, is_scalable, has_kerning, has_bitmaps;
|
||||
int32 tunedcount;
|
||||
CachedFace cachedface;
|
||||
uint8 format;
|
||||
BRect fbounds;
|
||||
};
|
||||
|
||||
/*!
|
||||
\class FontFamily FontFamily.h
|
||||
\brief Class representing a collection of similar styles
|
||||
|
||||
FontFamily objects bring together many styles of the same face, such as
|
||||
Arial Roman, Arial Italic, Arial Bold, etc.
|
||||
*/
|
||||
class FontFamily : public SharedObject
|
||||
{
|
||||
public:
|
||||
FontFamily(const char *namestr);
|
||||
~FontFamily(void);
|
||||
const char *Name(void);
|
||||
void AddStyle(const char *path, FT_Face face);
|
||||
void RemoveStyle(const char *style);
|
||||
bool HasStyle(const char *style);
|
||||
int32 CountStyles(void);
|
||||
const char *GetStyle(int32 index);
|
||||
FontStyle *GetStyle(const char *style);
|
||||
protected:
|
||||
BString *name;
|
||||
BList *styles;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -30,32 +30,51 @@
|
|||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
#include "RGBColor.h"
|
||||
#include "SystemPalette.h"
|
||||
|
||||
/*!
|
||||
\fn RGBColor::RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255)
|
||||
*/
|
||||
RGBColor::RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255)
|
||||
{
|
||||
SetColor(r,g,b,a);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn RGBColor::RGBColor(int r, int g, int b, int a=255)
|
||||
*/
|
||||
RGBColor::RGBColor(int r, int g, int b, int a=255)
|
||||
{
|
||||
SetColor(r,g,b,a);
|
||||
}
|
||||
|
||||
RGBColor::RGBColor(rgb_color col)
|
||||
/*!
|
||||
\fn RGBColor::RGBColor(const rgb_color &col)
|
||||
*/
|
||||
RGBColor::RGBColor(const rgb_color &col)
|
||||
{
|
||||
SetColor(col);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn RGBColor::RGBColor(uint16 col)
|
||||
*/
|
||||
RGBColor::RGBColor(uint16 col)
|
||||
{
|
||||
SetColor(col);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn RGBColor::RGBColor(uint8 col)
|
||||
*/
|
||||
RGBColor::RGBColor(uint8 col)
|
||||
{
|
||||
SetColor(col);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn RGBColor::RGBColor(const RGBColor &col)
|
||||
*/
|
||||
RGBColor::RGBColor(const RGBColor &col)
|
||||
{
|
||||
color32=col.color32;
|
||||
|
@ -63,26 +82,44 @@ RGBColor::RGBColor(const RGBColor &col)
|
|||
color8=col.color8;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn RGBColor::RGBColor(void)
|
||||
*/
|
||||
RGBColor::RGBColor(void)
|
||||
{
|
||||
SetColor(0,0,0,0);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn uint8 RGBColor::GetColor8(void)
|
||||
\return The palette index for the current color
|
||||
*/
|
||||
uint8 RGBColor::GetColor8(void)
|
||||
{
|
||||
return color8;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn uint16 RGBColor::GetColor16(void)
|
||||
\return 16-bit value of the current color, including alpha
|
||||
*/
|
||||
uint16 RGBColor::GetColor16(void)
|
||||
{
|
||||
return color16;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn rgb_color RGBColor::GetColor32(void)
|
||||
\return current color
|
||||
*/
|
||||
rgb_color RGBColor::GetColor32(void)
|
||||
{
|
||||
return color32;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void RGBColor::SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255)
|
||||
*/
|
||||
void RGBColor::SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255)
|
||||
{
|
||||
color32.red=r;
|
||||
|
@ -91,6 +128,9 @@ void RGBColor::SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255)
|
|||
color32.alpha=a;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void RGBColor::SetColor(int r, int g, int b, int a=255)
|
||||
*/
|
||||
void RGBColor::SetColor(int r, int g, int b, int a=255)
|
||||
{
|
||||
color32.red=(uint8)r;
|
||||
|
@ -99,6 +139,9 @@ void RGBColor::SetColor(int r, int g, int b, int a=255)
|
|||
color32.alpha=(uint8)a;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void RGBColor::SetColor(uint16 col16)
|
||||
*/
|
||||
void RGBColor::SetColor(uint16 col16)
|
||||
{
|
||||
color16=col16;
|
||||
|
@ -106,6 +149,9 @@ void RGBColor::SetColor(uint16 col16)
|
|||
// TODO: convert and set the 32-bit and 8-bit values
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void RGBColor::SetColor(uint8 col8)
|
||||
*/
|
||||
void RGBColor::SetColor(uint8 col8)
|
||||
{
|
||||
// Pared-down version from what is used in the app_server to
|
||||
|
@ -115,6 +161,9 @@ void RGBColor::SetColor(uint8 col8)
|
|||
// TODO: convert and set the 32-bit and 16-bit values
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void RGBColor::SetColor(const rgb_color &color)
|
||||
*/
|
||||
void RGBColor::SetColor(const rgb_color &color)
|
||||
{
|
||||
// Pared-down version from what is used in the app_server to
|
||||
|
@ -125,6 +174,9 @@ void RGBColor::SetColor(const rgb_color &color)
|
|||
// TODO: convert and set the 16-bit and 8-bit values
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void RGBColor::SetColor(const RGBColor &col)
|
||||
*/
|
||||
void RGBColor::SetColor(const RGBColor &col)
|
||||
{
|
||||
color32=col.color32;
|
||||
|
@ -132,7 +184,9 @@ void RGBColor::SetColor(const RGBColor &col)
|
|||
color8=col.color8;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\fn RGBColor & RGBColor::operator=(const RGBColor &col)
|
||||
*/
|
||||
RGBColor & RGBColor::operator=(const RGBColor &col)
|
||||
{
|
||||
color32=col.color32;
|
||||
|
@ -141,6 +195,9 @@ RGBColor & RGBColor::operator=(const RGBColor &col)
|
|||
return *this;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn RGBColor & RGBColor::operator=(const rgb_color &col)
|
||||
*/
|
||||
RGBColor & RGBColor::operator=(const rgb_color &col)
|
||||
{
|
||||
color32=col;
|
||||
|
@ -202,17 +259,28 @@ RGBColor RGBColor::MakeBlendColor(RGBColor color, float position)
|
|||
return RGBColor(newcol);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void RGBColor::PrintToStream(void)
|
||||
*/
|
||||
void RGBColor::PrintToStream(void)
|
||||
{
|
||||
printf("RGBColor (%u,%u,%u,%u)\n", color32.red,color32.green,color32.blue,color32.alpha);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool RGBColor::operator==(const rgb_color &col)
|
||||
\return true if all color elements are exactly equal
|
||||
*/
|
||||
bool RGBColor::operator==(const rgb_color &col)
|
||||
{
|
||||
return (color32.red==col.red && color32.green==col.green
|
||||
&& color32.blue==col.blue)?true:false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool RGBColor::operator==(const RGBColor &col)
|
||||
\return true if all color elements are exactly equal
|
||||
*/
|
||||
bool RGBColor::operator==(const RGBColor &col)
|
||||
{
|
||||
return (color32.red==col.color32.red && color32.green==col.color32.green
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
#include <GraphicsDefs.h>
|
||||
|
||||
/*!
|
||||
\class RGBColor
|
||||
\brief A color class to encapsulate color space ugliness
|
||||
\class RGBColor RGBColor.h
|
||||
\brief A color class to encapsulate color space ugliness in the app_server
|
||||
|
||||
RGBColors can be used to perform tasks much more difficult using rgb_colors. This
|
||||
class is limited to the app_server because of the access to the system palette for
|
||||
|
@ -59,7 +59,7 @@ public:
|
|||
void SetColor(int r, int g, int b, int a=255);
|
||||
void SetColor(uint16 color16);
|
||||
void SetColor(uint8 color8);
|
||||
void SetColor(rgb_color color);
|
||||
void SetColor(const rgb_color &color);
|
||||
void SetColor(const RGBColor &col);
|
||||
|
||||
RGBColor MakeBlendColor(RGBColor color, float position);
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// 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: ServerFont.cpp
|
||||
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
||||
// Description: Shadow BFont class
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#include "FontFamily.h"
|
||||
#include "ServerFont.h"
|
||||
|
||||
|
||||
/*!
|
||||
\fn ServerFont(FontStyle *style, float size, float rotation, float shear, uint16 flags, uint8 spacing)
|
||||
\brief Constructor
|
||||
\param Style object to which the ServerFont belongs
|
||||
\param Character size in points
|
||||
\param Rotation in degrees
|
||||
\param Shear (slant) in degrees. 45 <= shear <= 135
|
||||
\param Style flags as defined in <Font.h>
|
||||
\spacing String spacing flag as defined in <Font.h>
|
||||
*/
|
||||
ServerFont::ServerFont(FontStyle *style, float size, float rotation, float shear,
|
||||
uint16 flags, uint8 spacing)
|
||||
{
|
||||
fstyle=style;
|
||||
fsize=size;
|
||||
frotation=rotation;
|
||||
fshear=shear;
|
||||
fflags=flags;
|
||||
fspacing=spacing;
|
||||
fdirection=B_FONT_LEFT_TO_RIGHT;
|
||||
fface=B_REGULAR_FACE;
|
||||
ftruncate=B_TRUNCATE_END;
|
||||
fencoding=B_UNICODE_UTF8;
|
||||
fbounds.Set(0,0,0,0);
|
||||
if(fstyle)
|
||||
fstyle->AddDependent();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn ServerFont(FontStyle *style, float size, float rotation, float shear, uint16 flags, uint8 spacing)
|
||||
\brief Copy Constructor
|
||||
\param ServerFont to copy
|
||||
*/
|
||||
ServerFont::ServerFont(const ServerFont &font)
|
||||
{
|
||||
fstyle=font.fstyle;
|
||||
fsize=font.fsize;
|
||||
frotation=font.frotation;
|
||||
fshear=font.fshear;
|
||||
fflags=font.fflags;
|
||||
fspacing=font.fspacing;
|
||||
fdirection=font.fdirection;
|
||||
fface=font.fface;
|
||||
ftruncate=font.ftruncate;
|
||||
fencoding=font.fencoding;
|
||||
fbounds.Set(0,0,0,0);
|
||||
if(fstyle)
|
||||
fstyle->AddDependent();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn ServerFont(FontStyle *style, float size, float rotation, float shear, uint16 flags, uint8 spacing)
|
||||
\brief Destructor
|
||||
|
||||
Removes itself as a dependency of its owning style.
|
||||
*/
|
||||
ServerFont::~ServerFont(void)
|
||||
{
|
||||
if(fstyle)
|
||||
fstyle->RemoveDependent();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn int32 ServerFont::CountTuned(void)
|
||||
\brief Returns the number of strikes in the font
|
||||
\return The number of strikes in the font
|
||||
*/
|
||||
int32 ServerFont::CountTuned(void)
|
||||
{
|
||||
if(fstyle)
|
||||
fstyle->TunedCount();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn font_file_format ServerFont::FileFormat(void)
|
||||
\brief Returns the file format of the font. Currently unimplemented.
|
||||
\return B_TRUETYPE_WINDOWS
|
||||
*/
|
||||
font_file_format ServerFont::FileFormat(void)
|
||||
{
|
||||
// TODO: implement
|
||||
return B_TRUETYPE_WINDOWS;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn BRect ServerFont::BoundingBox(void)
|
||||
\brief Returns a BRect which encloses the entire font
|
||||
\return A BRect which encloses the entire font
|
||||
*/
|
||||
BRect ServerFont::BoundingBox(void)
|
||||
{
|
||||
return fbounds;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void ServerFont::Height(font_height *fh)
|
||||
\brief Obtains the height values for characters in the font in its current state
|
||||
\param pointer to a font_height object to receive the values for the font
|
||||
*/
|
||||
void ServerFont::Height(font_height *fh)
|
||||
{
|
||||
fh->ascent=fheight.ascent;
|
||||
fh->descent=fheight.descent;
|
||||
fh->leading=fheight.leading;
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// 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: ServerFont.h
|
||||
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
||||
// Description: Shadow BFont class
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef SERVERFONT_H_
|
||||
#define SERVERFONT_H_
|
||||
|
||||
#include <Rect.h>
|
||||
#include <Font.h>
|
||||
|
||||
class FontStyle;
|
||||
|
||||
class ServerFont
|
||||
{
|
||||
public:
|
||||
ServerFont(FontStyle *fstyle, float fsize=12.0, float frotation=0.0, float fshear=90.0,
|
||||
uint16 flags=0, uint8 spacing=B_CHAR_SPACING);
|
||||
ServerFont(const ServerFont &font);
|
||||
~ServerFont(void);
|
||||
font_direction Direction(void) { return fdirection; }
|
||||
uint8 Encoding(void) { return fencoding; }
|
||||
edge_info Edges(void) { return fedges; }
|
||||
uint32 Flags(void) { return fflags; }
|
||||
uint8 Spacing(void) { return fspacing; }
|
||||
float Shear(void) { return fshear; }
|
||||
float Rotation(void) { return frotation; }
|
||||
float Size(void) { return fsize; }
|
||||
uint16 Face(void) { return fface; }
|
||||
uint32 CountGlyphs(void);
|
||||
int32 CountTuned(void);
|
||||
font_file_format FileFormat(void);
|
||||
FontStyle *Style(void) { return fstyle; }
|
||||
|
||||
void SetDirection(const font_direction &dir) { fdirection=dir; }
|
||||
void SetEdges(const edge_info &info) { fedges=info; }
|
||||
void SetEncoding(uint8 encoding) { fencoding=encoding; }
|
||||
void SetFlags(const uint32 &value) { fflags=value; }
|
||||
void SetSpacing(const uint8 &value) { fspacing=value; }
|
||||
void SetShear(const float &value) { fshear=value; }
|
||||
void SetSize(const float &value) { fsize=value; }
|
||||
void SetRotation(const float &value) { frotation=value; }
|
||||
void SetFace(const uint16 &value) { fface=value; }
|
||||
|
||||
BRect BoundingBox(void);
|
||||
void Height(font_height *fh);
|
||||
protected:
|
||||
friend FontStyle;
|
||||
FontStyle *fstyle;
|
||||
font_height fheight;
|
||||
edge_info fedges;
|
||||
float fsize, frotation, fshear;
|
||||
BRect fbounds;
|
||||
uint32 fflags;
|
||||
uint8 fspacing;
|
||||
uint16 fface;
|
||||
font_direction fdirection;
|
||||
uint8 ftruncate;
|
||||
uint8 fencoding;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,55 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// 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: SharedObject.h
|
||||
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
||||
// Description: This class is used as a base class for other objects which
|
||||
// must be shared. By using this, objects which depend on its
|
||||
// existence can be somewhat sure that the shared object will
|
||||
// not be deleted until nothing depends on it.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef SHAREDOBJ_H_
|
||||
#define SHAREDOBJ_H_
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
/*!
|
||||
\class SharedObject SharedObject.h
|
||||
\brief Base class for shared objects
|
||||
|
||||
SharedObjects track dependencies upon a particular object. In this way, is is
|
||||
possible to ensure that a shared resource is not deleted if something else
|
||||
needs it. How the dependency tracking is done largely depends on the child class.
|
||||
*/
|
||||
class SharedObject
|
||||
{
|
||||
public:
|
||||
SharedObject(void) { dependents=0; }
|
||||
virtual ~SharedObject(void){}
|
||||
virtual void AddDependent(void) { dependents++; }
|
||||
virtual void RemoveDependent(void) { dependents--; }
|
||||
virtual bool HasDependents(void) { return (dependents>0)?true:false; }
|
||||
private:
|
||||
uint32 dependents;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -29,8 +29,19 @@
|
|||
// Local Includes --------------------------------------------------------------
|
||||
#include "SystemPalette.h"
|
||||
|
||||
/*!
|
||||
\var rgb_color system_palette[256]
|
||||
\brief The global array of colors for the system palette.
|
||||
|
||||
Whenever the system's color palette is referenced, this is the variable used.
|
||||
*/
|
||||
rgb_color system_palette[256];
|
||||
|
||||
/*!
|
||||
\fn void GenerateSystemPalette(rgb_color *palette)
|
||||
\brief Takes a 256-element rgb_color array and places the BeOS System
|
||||
palette in it.
|
||||
*/
|
||||
void GenerateSystemPalette(rgb_color *palette)
|
||||
{
|
||||
int i,j,index=0;
|
||||
|
|
Loading…
Reference in New Issue