Removed a few compiler warnings
Added app-side support for font list Added mostly-empty global font functions and documented them git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4439 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6a746063c9
commit
edd19f3d5c
@ -2173,7 +2173,7 @@ BBitmap::InitObject(BRect bounds, color_space colorSpace, uint32 flags,
|
||||
// SERVER_FALSE if the buffer was already deleted
|
||||
// Reply Data:
|
||||
// none
|
||||
status_t freestat;
|
||||
// status_t freestat;
|
||||
link->SetOpCode(AS_DELETE_BITMAP);
|
||||
link->Attach<int32>(fServerToken);
|
||||
error=link->FlushWithReply(&replydata);
|
||||
|
390
src/kits/interface/ClientFontList.cpp
Normal file
390
src/kits/interface/ClientFontList.cpp
Normal file
@ -0,0 +1,390 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// 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: ClientFontList.cpp
|
||||
// Author: DarkWyrm (bpmagic@columbus.rr.com)
|
||||
// Description: Maintainer object for the list of font families and styles which is
|
||||
// kept on the client side.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "ClientFontList.h"
|
||||
#include <File.h>
|
||||
#include <Message.h>
|
||||
#include <String.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <String.h>
|
||||
#include "PortLink.h"
|
||||
#include <ServerProtocol.h>
|
||||
#include <ServerConfig.h>
|
||||
|
||||
//#define DEBUG_CLIENT_FONT_LIST
|
||||
|
||||
class FontListFamily
|
||||
{
|
||||
public:
|
||||
FontListFamily(void);
|
||||
~FontListFamily(void);
|
||||
BString name;
|
||||
BList *styles;
|
||||
int32 flags;
|
||||
};
|
||||
|
||||
FontListFamily::FontListFamily(void)
|
||||
{
|
||||
styles=new BList(0);
|
||||
flags=0;
|
||||
}
|
||||
|
||||
FontListFamily::~FontListFamily(void)
|
||||
{
|
||||
BString *s;
|
||||
s=(BString*)styles->RemoveItem(0L);
|
||||
while(s)
|
||||
{
|
||||
delete s;
|
||||
s=(BString*)styles->RemoveItem(0L);
|
||||
}
|
||||
delete styles;
|
||||
}
|
||||
|
||||
ClientFontList::ClientFontList(void)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("ClientFontList()\n");
|
||||
#endif
|
||||
familylist=new BList(0);
|
||||
fontlock=create_sem(1,"fontlist_sem");
|
||||
}
|
||||
|
||||
ClientFontList::~ClientFontList(void)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("~ClientFontList()\n");
|
||||
#endif
|
||||
acquire_sem(fontlock);
|
||||
|
||||
font_family *fam;
|
||||
while(familylist->ItemAt(0L)!=NULL)
|
||||
{
|
||||
fam=(font_family *)familylist->RemoveItem(0L);
|
||||
delete fam;
|
||||
}
|
||||
familylist->MakeEmpty();
|
||||
delete familylist;
|
||||
delete_sem(fontlock);
|
||||
}
|
||||
|
||||
bool ClientFontList::Update(bool check_only)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("ClientFontList::Update(%s) - %s\n", (check_only)?"true":"false",SERVER_FONT_LIST);
|
||||
#endif
|
||||
// Open the font list kept in font list
|
||||
acquire_sem(fontlock);
|
||||
|
||||
// We're going to ask the server whether the list has changed
|
||||
port_id serverport;
|
||||
serverport=find_port(SERVER_PORT_NAME);
|
||||
|
||||
bool needs_update=true;
|
||||
PortLink *serverlink=new PortLink(serverport);
|
||||
|
||||
if(serverport!=B_NAME_NOT_FOUND)
|
||||
{
|
||||
status_t stat;
|
||||
int32 code;
|
||||
ssize_t buffersize;
|
||||
|
||||
serverlink->SetOpCode(AS_QUERY_FONTS_CHANGED);
|
||||
serverlink->FlushWithReply(&code, &stat, &buffersize);
|
||||
|
||||
// Attached Data: none
|
||||
// Reply: SERVER_TRUE if fonts have changed, SERVER_FALSE if not
|
||||
|
||||
needs_update=(code==SERVER_TRUE)?true:false;
|
||||
}
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
else
|
||||
{
|
||||
printf("ClientFontList::Update(): Couldn't find app_server port\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
if(check_only)
|
||||
{
|
||||
delete serverlink;
|
||||
release_sem(fontlock);
|
||||
return needs_update;
|
||||
}
|
||||
|
||||
// Don't update the list if nothing has changed
|
||||
if(needs_update)
|
||||
{
|
||||
BFile file(SERVER_FONT_LIST,B_READ_ONLY);
|
||||
BMessage fontmsg, familymsg;
|
||||
|
||||
if(file.InitCheck()==B_OK)
|
||||
{
|
||||
if(fontmsg.Unflatten(&file)==B_OK)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("Font message contents:\n");
|
||||
fontmsg.PrintToStream();
|
||||
#endif
|
||||
// Empty the font list
|
||||
FontListFamily *flf=(FontListFamily*)familylist->RemoveItem(0L);
|
||||
BString sty, extra;
|
||||
int32 famindex, styindex;
|
||||
bool tempbool;
|
||||
|
||||
while(flf)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("Removing %s from list\n",flf->name.String());
|
||||
#endif
|
||||
delete flf;
|
||||
flf=(FontListFamily*)familylist->RemoveItem(0L);
|
||||
}
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
famindex=0;
|
||||
|
||||
// Repopulate with new listings
|
||||
while(fontmsg.FindMessage("family",famindex,&familymsg)==B_OK)
|
||||
{
|
||||
famindex++;
|
||||
|
||||
flf=new FontListFamily();
|
||||
familylist->AddItem(flf);
|
||||
familymsg.FindString("name",&(flf->name));
|
||||
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("Adding %s to list\n",flf->name.String());
|
||||
#endif
|
||||
styindex=0;
|
||||
|
||||
// populate family with styles
|
||||
while(familymsg.FindString("styles",styindex,&sty)==B_OK)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("\tAdding %s\n",sty.String());
|
||||
#endif
|
||||
styindex++;
|
||||
flf->styles->AddItem(new BString(sty));
|
||||
}
|
||||
|
||||
if(familymsg.FindBool("tuned",&tempbool)==B_OK)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("Family %s has tuned fonts\n", flf->name.String());
|
||||
#endif
|
||||
flf->flags|=B_HAS_TUNED_FONT;
|
||||
}
|
||||
|
||||
if(familymsg.FindBool("fixed",&tempbool)==B_OK)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("Family %s is fixed-width\n", flf->name.String());
|
||||
#endif
|
||||
flf->flags|=B_IS_FIXED;
|
||||
}
|
||||
familymsg.MakeEmpty();
|
||||
|
||||
}
|
||||
|
||||
serverlink->SetOpCode(AS_UPDATED_CLIENT_FONTLIST);
|
||||
serverlink->Flush();
|
||||
|
||||
delete serverlink;
|
||||
release_sem(fontlock);
|
||||
return false;
|
||||
|
||||
} // end if Unflatten==B_OK
|
||||
} // end if InitCheck==B_OK
|
||||
} // end if needs_update
|
||||
|
||||
delete serverlink;
|
||||
release_sem(fontlock);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 ClientFontList::CountFamilies(void)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("ClientFontList::CountFamilies\n");
|
||||
#endif
|
||||
acquire_sem(fontlock);
|
||||
int32 count=familylist->CountItems();
|
||||
release_sem(fontlock);
|
||||
return count;
|
||||
}
|
||||
|
||||
status_t ClientFontList::GetFamily(int32 index, font_family *name, uint32 *flags=NULL)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("ClientFontList::GetFamily(%ld)\n",index);
|
||||
#endif
|
||||
if(!name)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("ClientFontList::GetFamily: NULL font_family parameter\n");
|
||||
#endif
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
acquire_sem(fontlock);
|
||||
FontListFamily *flf=(FontListFamily*)familylist->ItemAt(index);
|
||||
if(!flf)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("ClientFontList::GetFamily: index not found\n");
|
||||
#endif
|
||||
return B_ERROR;
|
||||
}
|
||||
strcpy(*name,flf->name.String());
|
||||
|
||||
|
||||
release_sem(fontlock);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
int32 ClientFontList::CountStyles(font_family f)
|
||||
{
|
||||
acquire_sem(fontlock);
|
||||
|
||||
FontListFamily *flf=NULL;
|
||||
int32 i, count=familylist->CountItems();
|
||||
bool found=false;
|
||||
|
||||
for(i=0; i<count;i++)
|
||||
{
|
||||
flf=(FontListFamily *)familylist->ItemAt(i);
|
||||
if(!flf)
|
||||
continue;
|
||||
if(flf->name.ICompare(f)==0)
|
||||
{
|
||||
found=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
count=(found)?flf->styles->CountItems():0;
|
||||
|
||||
release_sem(fontlock);
|
||||
return count;
|
||||
}
|
||||
|
||||
status_t ClientFontList::GetStyle(font_family family, int32 index, font_style *name,uint32 *flags=NULL, uint16 *face=NULL)
|
||||
{
|
||||
if(!name || !(*name) || !family)
|
||||
return B_ERROR;
|
||||
|
||||
acquire_sem(fontlock);
|
||||
|
||||
FontListFamily *flf=NULL;
|
||||
BString *style;
|
||||
int32 i, count=familylist->CountItems();
|
||||
bool found=false;
|
||||
|
||||
for(i=0; i<count;i++)
|
||||
{
|
||||
flf=(FontListFamily *)familylist->ItemAt(i);
|
||||
if(!flf)
|
||||
continue;
|
||||
if(flf->name.ICompare(family)==0)
|
||||
{
|
||||
found=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!found)
|
||||
{
|
||||
release_sem(fontlock);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
style=(BString*)flf->styles->ItemAt(index);
|
||||
if(!style)
|
||||
{
|
||||
release_sem(fontlock);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
strcpy(*name,style->String());
|
||||
|
||||
if(flags)
|
||||
*flags=flf->flags;
|
||||
|
||||
if(face)
|
||||
{
|
||||
if(style->ICompare("Roman")==0 ||
|
||||
style->ICompare("Regular")==0 ||
|
||||
style->ICompare("Normal")==0 ||
|
||||
style->ICompare("Light")==0 ||
|
||||
style->ICompare("Medium")==0 ||
|
||||
style->ICompare("Plain")==0)
|
||||
{
|
||||
*face|=B_REGULAR_FACE;
|
||||
#ifdef DEBUG_FONTSERVER
|
||||
printf("GetStyle: %s Roman face\n", style->String());
|
||||
#endif
|
||||
}
|
||||
else
|
||||
if(style->ICompare("Bold")==0)
|
||||
{
|
||||
*face|=B_BOLD_FACE;
|
||||
#ifdef DEBUG_FONTSERVER
|
||||
printf("GetStyle: %s Bold face\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
if(style->ICompare("Italic")==0)
|
||||
{
|
||||
*face|=B_ITALIC_FACE;
|
||||
#ifdef DEBUG_FONTSERVER
|
||||
printf("GetStyle: %s Italic face\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
if(style->ICompare("Bold Italic")==0)
|
||||
{
|
||||
*face|=B_ITALIC_FACE | B_BOLD_FACE;
|
||||
#ifdef DEBUG_FONTSERVER
|
||||
printf("GetStyle: %s Bold Italic face\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_FONTSERVER
|
||||
printf("GetStyle: %s Unknown face %s\n", style->String());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
release_sem(fontlock);
|
||||
return B_OK;
|
||||
}
|
||||
|
@ -26,6 +26,133 @@
|
||||
#include <Rect.h>
|
||||
#include <stdio.h>
|
||||
#include <Font.h>
|
||||
#include <PortLink.h>
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Globals
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
// The actual objects which the globals point to
|
||||
BFont be_plain_bfont;
|
||||
BFont be_bold_bfont;
|
||||
BFont be_fixed_bfont;
|
||||
|
||||
const BFont *be_plain_font=&be_plain_bfont;
|
||||
const BFont *be_bold_font=&be_bold_bfont;
|
||||
const BFont *be_fixed_font=&be_fixed_bfont;
|
||||
|
||||
|
||||
/*!
|
||||
\brief Private function used by Be. Exists only for compatibility. Does nothing.
|
||||
*/
|
||||
void _font_control_(BFont *font, int32 cmd, void *data)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the number of installed font families
|
||||
\return The number of installed font families
|
||||
*/
|
||||
int32 count_font_families(void)
|
||||
{
|
||||
// TODO: Implement
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the number of styles available for a font family
|
||||
\return The number of styles available for a font family
|
||||
*/
|
||||
int32 count_font_styles(font_family name)
|
||||
{
|
||||
// TODO: Implement
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Retrieves the family name at the specified index
|
||||
\param index Unique font identifier code.
|
||||
\param name font_family string to receive the name of the family
|
||||
\param flags iF non-NULL, the values of the flags IS_FIXED and B_HAS_TUNED_FONT are returned
|
||||
\return B_ERROR if the index does not correspond to a font family
|
||||
*/
|
||||
status_t get_font_family(int32 index, font_family *name, uint32 *flags=NULL)
|
||||
{
|
||||
// Fix over R5, which does not check for NULL font family names - it just crashes
|
||||
if(!name)
|
||||
return B_ERROR;
|
||||
|
||||
// TODO: Implement
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Retrieves the family name at the specified index
|
||||
\param index Unique font identifier code.
|
||||
\param name font_family string to receive the name of the family
|
||||
\param flags iF non-NULL, the values of the flags IS_FIXED and B_HAS_TUNED_FONT are returned
|
||||
\return B_ERROR if the index does not correspond to a font style
|
||||
*/
|
||||
status_t get_font_style(font_family family, int32 index, font_style *name, uint32 *flags)
|
||||
{
|
||||
// Fix over R5, which does not check for NULL font style names - it just crashes
|
||||
if(!name)
|
||||
return B_ERROR;
|
||||
|
||||
// TODO: Implement
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Retrieves the family name at the specified index
|
||||
\param index Unique font identifier code.
|
||||
\param name font_family string to receive the name of the family
|
||||
\param face recipient of font face value, such as B_REGULAR_FACE
|
||||
\param flags iF non-NULL, the values of the flags IS_FIXED and B_HAS_TUNED_FONT are returned
|
||||
\return B_ERROR if the index does not correspond to a font style
|
||||
|
||||
The face value returned by this function is not very reliable. At the same time, the value
|
||||
returned should be fairly reliable, returning the proper flag for 90%-99% of font names.
|
||||
*/
|
||||
status_t get_font_style(font_family family, int32 index, font_style *name,
|
||||
uint16 *face, uint32 *flags)
|
||||
{
|
||||
// Fix over R5, which does not check for NULL font style names - it just crashes
|
||||
if(!name || !face)
|
||||
return B_ERROR;
|
||||
|
||||
// TODO: Implement
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Updates the font family list
|
||||
\param check_only If true, the function only checks to see if the font list has changed
|
||||
\return true if the font list has changed, false if not.
|
||||
|
||||
Because of the differences in the R5 and OpenBeOS font subsystems, this function operates
|
||||
slightly differently, resulting in more efficient operation. A global font list for all
|
||||
applications is maintained, so calling this function will still be quite expensive,
|
||||
but it should be unnecessary in most applications.
|
||||
*/
|
||||
bool update_font_families(bool check_only)
|
||||
{
|
||||
// TODO: Implement
|
||||
}
|
||||
|
||||
status_t get_font_cache_info(uint32 id, void *set)
|
||||
{
|
||||
// TODO: Implement
|
||||
|
||||
// Note that the only reliable data from this function will probably be the cache size
|
||||
// Depending on how the font cache is implemented, this function and the corresponding
|
||||
// set function will either see major revision or completely disappear in R2.
|
||||
}
|
||||
|
||||
status_t set_font_cache_info(uint32 id, void *set)
|
||||
{
|
||||
// TODO: Implement
|
||||
|
||||
// Note that this function will likely only set the cache size in our implementation
|
||||
// because of (a) the lack of knowledge on R5's font system and (b) the fact that it
|
||||
// is a completely different font engine.
|
||||
}
|
||||
|
||||
/*
|
||||
class BFontPrivate
|
||||
{
|
||||
@ -62,42 +189,25 @@ BFontPrivate & BFontPrivate::operator=(const BFontPrivate &fontdata)
|
||||
}
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
// BFont Class Definition
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
BFont::BFont(void)
|
||||
{
|
||||
// private_data=new BFontPrivate();
|
||||
if(be_plain_font)
|
||||
{
|
||||
fFamilyID=be_plain_font->fFamilyID;
|
||||
fStyleID=be_plain_font->fStyleID;
|
||||
fSize=be_plain_font->fSize;
|
||||
fShear=be_plain_font->fShear;
|
||||
fRotation=be_plain_font->fRotation;
|
||||
fSpacing=be_plain_font->fSpacing;
|
||||
fEncoding=be_plain_font->fEncoding;
|
||||
fFace=be_plain_font->fFace;
|
||||
fHeight=be_plain_font->fHeight;
|
||||
// private_data->fPrivateFlags=be_plain_font->private_data->fPrivateFlags;
|
||||
}
|
||||
else
|
||||
{
|
||||
fFamilyID=0;
|
||||
fStyleID=0;
|
||||
fSize=0.0;
|
||||
fShear=90.0;
|
||||
fRotation=0.0;
|
||||
fSpacing=B_CHAR_SPACING;
|
||||
fEncoding=B_UNICODE_UTF8;
|
||||
fFace=B_REGULAR_FACE;
|
||||
fHeight.ascent=0.0;
|
||||
fHeight.descent=0.0;
|
||||
fHeight.leading=0.0;
|
||||
// private_data->fPrivateFlags=0;
|
||||
}
|
||||
fFamilyID=be_plain_font->fFamilyID;
|
||||
fStyleID=be_plain_font->fStyleID;
|
||||
fSize=be_plain_font->fSize;
|
||||
fShear=be_plain_font->fShear;
|
||||
fRotation=be_plain_font->fRotation;
|
||||
fSpacing=be_plain_font->fSpacing;
|
||||
fEncoding=be_plain_font->fEncoding;
|
||||
fFace=be_plain_font->fFace;
|
||||
fHeight=be_plain_font->fHeight;
|
||||
}
|
||||
|
||||
BFont::BFont(const BFont &font)
|
||||
{
|
||||
// private_data=new BFontPrivate();
|
||||
fFamilyID=font.fFamilyID;
|
||||
fStyleID=font.fStyleID;
|
||||
fSize=font.fSize;
|
||||
@ -107,12 +217,10 @@ BFont::BFont(const BFont &font)
|
||||
fEncoding=font.fEncoding;
|
||||
fFace=font.fFace;
|
||||
fHeight=font.fHeight;
|
||||
// private_data->fPrivateFlags=font.private_data->fPrivateFlags;
|
||||
}
|
||||
|
||||
BFont::BFont(const BFont *font)
|
||||
{
|
||||
// private_data=new BFontPrivate();
|
||||
if(font)
|
||||
{
|
||||
fFamilyID=font->fFamilyID;
|
||||
@ -124,76 +232,69 @@ BFont::BFont(const BFont *font)
|
||||
fEncoding=font->fEncoding;
|
||||
fFace=font->fFace;
|
||||
fHeight=font->fHeight;
|
||||
// private_data->fPrivateFlags=font->private_data->fPrivateFlags;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(be_plain_font)
|
||||
{
|
||||
fFamilyID=be_plain_font->fFamilyID;
|
||||
fStyleID=be_plain_font->fStyleID;
|
||||
fSize=be_plain_font->fSize;
|
||||
fShear=be_plain_font->fShear;
|
||||
fRotation=be_plain_font->fRotation;
|
||||
fSpacing=be_plain_font->fSpacing;
|
||||
fEncoding=be_plain_font->fEncoding;
|
||||
fFace=be_plain_font->fFace;
|
||||
fHeight=be_plain_font->fHeight;
|
||||
// private_data->fPrivateFlags=be_plain_font->private_data->fPrivateFlags;
|
||||
}
|
||||
else
|
||||
{
|
||||
fFamilyID=0;
|
||||
fStyleID=0;
|
||||
fSize=0.0;
|
||||
fShear=90.0;
|
||||
fRotation=0.0;
|
||||
fSpacing=B_CHAR_SPACING;
|
||||
fEncoding=B_UNICODE_UTF8;
|
||||
fFace=B_REGULAR_FACE;
|
||||
fHeight.ascent=0.0;
|
||||
fHeight.descent=0.0;
|
||||
fHeight.leading=0.0;
|
||||
// private_data->fPrivateFlags=0;
|
||||
}
|
||||
fFamilyID=be_plain_font->fFamilyID;
|
||||
fStyleID=be_plain_font->fStyleID;
|
||||
fSize=be_plain_font->fSize;
|
||||
fShear=be_plain_font->fShear;
|
||||
fRotation=be_plain_font->fRotation;
|
||||
fSpacing=be_plain_font->fSpacing;
|
||||
fEncoding=be_plain_font->fEncoding;
|
||||
fFace=be_plain_font->fFace;
|
||||
fHeight=be_plain_font->fHeight;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* XXX TODO: R5 doesn't have a destructor, so we get linking errors when objects compiled with old headers with the new library
|
||||
(but now we leak memory here)
|
||||
BFont::~BFont(void)
|
||||
{
|
||||
delete private_data;
|
||||
}
|
||||
/*!
|
||||
\brief Sets the font's family and style all at once
|
||||
\param family Font family to set
|
||||
\param style Font style to set
|
||||
\return B_ERROR if family or style do not exist or if style does not belong to family.
|
||||
*/
|
||||
|
||||
status_t BFont::SetFamilyAndStyle(const font_family family, const font_style style)
|
||||
{
|
||||
// R5 version always returns B_OK. That's a problem...
|
||||
|
||||
// TODO: implement
|
||||
// TODO: find out what codes are returned by this function. Be Book says this returns nothing
|
||||
|
||||
// Query server for the appropriate family and style IDs and then return the
|
||||
// appropriate value
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Sets the font's family and style all at once
|
||||
\param code Unique font identifier obtained from the server.
|
||||
*/
|
||||
void BFont::SetFamilyAndStyle(uint32 code)
|
||||
{
|
||||
fStyleID=code & 0xFFFF;
|
||||
fFamilyID=(code & 0xFFFF0000) >> 16;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Sets the font's family and face all at once
|
||||
\param family Font family to set
|
||||
\param face Font face to set.
|
||||
\return B_ERROR if family does not exists or face is an invalid value.
|
||||
|
||||
To comply with the BeBook, this function will only set valid values - i.e. passing a
|
||||
nonexistent family will cause only the face to be set. Additionally, if a particular
|
||||
face does not exist in a family, the closest match will be chosen.
|
||||
*/
|
||||
status_t BFont::SetFamilyAndFace(const font_family family, uint16 face)
|
||||
{
|
||||
// TODO: find out what codes are returned by this function. Be Book says this returns nothing
|
||||
fFace=face;
|
||||
if(face & ( B_ITALIC_FACE | B_UNDERSCORE_FACE | B_NEGATIVE_FACE | B_OUTLINED_FACE
|
||||
| B_STRIKEOUT_FACE | B_BOLD_FACE | B_REGULAR_FACE) != 0)
|
||||
{
|
||||
fFace=face;
|
||||
}
|
||||
|
||||
// TODO: finish this function by adding the app_server Family query protocol code
|
||||
if(family)
|
||||
{
|
||||
// Query server for family id for the specified family
|
||||
}
|
||||
// Query server for family id for the specified family
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
@ -284,6 +385,8 @@ uint32 BFont::Flags(void) const
|
||||
|
||||
font_direction BFont::Direction(void) const
|
||||
{
|
||||
// TODO: Query the server for the value
|
||||
|
||||
return B_FONT_LEFT_TO_RIGHT;
|
||||
}
|
||||
|
||||
@ -294,6 +397,12 @@ bool BFont::IsFixed(void) const
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns true if the font is fixed-width and contains both full and half-width characters
|
||||
|
||||
This was left unimplemented as of R5. It was a way to work with both Kanji and Roman
|
||||
characters in the same fixed-width font.
|
||||
*/
|
||||
bool BFont::IsFullAndHalfFixed(void) const
|
||||
{
|
||||
return false;
|
||||
@ -438,7 +547,6 @@ BFont &BFont::operator=(const BFont &font)
|
||||
fEncoding=font.fEncoding;
|
||||
fFace=font.fFace;
|
||||
fHeight=font.fHeight;
|
||||
// private_data->fPrivateFlags=font.private_data->fPrivateFlags;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -455,7 +563,6 @@ bool BFont::operator==(const BFont &font) const
|
||||
fHeight.ascent!=font.fHeight.ascent ||
|
||||
fHeight.descent!=font.fHeight.descent ||
|
||||
fHeight.leading!=font.fHeight.leading //||
|
||||
// private_data->fPrivateFlags!=font.private_data->fPrivateFlags
|
||||
)
|
||||
return false;
|
||||
return true;
|
||||
@ -474,7 +581,6 @@ bool BFont::operator!=(const BFont &font) const
|
||||
fHeight.ascent!=font.fHeight.ascent ||
|
||||
fHeight.descent!=font.fHeight.descent ||
|
||||
fHeight.leading!=font.fHeight.leading //||
|
||||
// private_data->fPrivateFlags!=font.private_data->fPrivateFlags
|
||||
)
|
||||
return true;
|
||||
return false;
|
||||
|
@ -155,9 +155,9 @@ status_t TPicture::Play(void **callBackTable, int32 tableEntries,
|
||||
// TODO: we should probably check if the functions in the table are not 0
|
||||
// before calling them.
|
||||
|
||||
int16 op;
|
||||
int32 size;
|
||||
off_t pos;
|
||||
int16 op=0;
|
||||
int32 size=0;
|
||||
off_t pos=0;
|
||||
|
||||
while (fData.Position() < size)
|
||||
{
|
||||
@ -403,8 +403,8 @@ status_t TPicture::Play(void **callBackTable, int32 tableEntries,
|
||||
}
|
||||
case B_PIC_SET_BLENDING_MODE:
|
||||
{
|
||||
int16 alphaSrcMode = GetInt16();
|
||||
int16 alphaFncMode = GetInt16();
|
||||
//int16 alphaSrcMode = GetInt16();
|
||||
//int16 alphaFncMode = GetInt16();
|
||||
//((fnc_Pattern)callBackTable[??])(userData, alphaSrcMode,
|
||||
// alphaFncMode);
|
||||
break;
|
||||
|
@ -4,6 +4,7 @@ INTERFACE_KIT_SOURCE =
|
||||
Box.cpp
|
||||
Button.cpp
|
||||
CheckBox.cpp
|
||||
ClientFontList.cpp
|
||||
ColorUtils.cc
|
||||
Control.cpp
|
||||
Deskbar.cpp
|
||||
|
Loading…
Reference in New Issue
Block a user