Implemented WriteSetFontFamily() and WriteSetFontStyle(). Only the

server side functions are missing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21941 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2007-08-14 09:17:21 +00:00
parent 2f99607b77
commit feb557a6d1
3 changed files with 32 additions and 18 deletions
@@ -36,8 +36,8 @@ public:
status_t WritePushState(); status_t WritePushState();
status_t WritePopState(); status_t WritePopState();
status_t WriteSetFontFamily(const font_family &family); status_t WriteSetFontFamily(const font_family family);
status_t WriteSetFontStyle(const font_style &style); status_t WriteSetFontStyle(const font_style style);
status_t WriteSetFontSpacing(const int32 &spacing); status_t WriteSetFontSpacing(const int32 &spacing);
status_t WriteSetFontSize(const float &size); status_t WriteSetFontSize(const float &size);
status_t WriteSetFontRotation(const float &rotation); status_t WriteSetFontRotation(const float &rotation);
+21 -8
View File
@@ -18,6 +18,9 @@
#define THROW_ERROR(error) throw (status_t)(error) #define THROW_ERROR(error) throw (status_t)(error)
// TODO: Review writing of strings. AFAIK in the picture data format
// They are not supposed to be NULL terminated (at least, it's not mandatory)
// and we should write their size.
PictureDataWriter::PictureDataWriter() PictureDataWriter::PictureDataWriter()
: :
fData(NULL) fData(NULL)
@@ -384,21 +387,31 @@ PictureDataWriter::WriteDrawPicture(const BPoint &where, const int32 &token)
status_t status_t
PictureDataWriter::WriteSetFontFamily(const font_family &family) PictureDataWriter::WriteSetFontFamily(const font_family family)
{ {
/*BeginOp(B_PIC_SET_FONT_FAMILY); try {
Write( BeginOp(B_PIC_SET_FONT_FAMILY);
EndOp();*/ WriteData(family, strlen(family));
Write<int8>(0);
EndOp();
} catch (status_t &status) {
return status;
}
return B_OK; return B_OK;
} }
status_t status_t
PictureDataWriter::WriteSetFontStyle(const font_style &style) PictureDataWriter::WriteSetFontStyle(const font_style style)
{ {
/*BeginOp(B_PIC_SET_FONT_STYLE); try {
Write( BeginOp(B_PIC_SET_FONT_STYLE);
EndOp();*/ WriteData(style, strlen(style));
Write<int8>(0);
EndOp();
} catch (status_t &status) {
return status;
}
return B_OK; return B_OK;
} }
+9 -8
View File
@@ -12,6 +12,7 @@
#include "DrawingEngine.h" #include "DrawingEngine.h"
#include "ServerApp.h" #include "ServerApp.h"
#include "ServerBitmap.h" #include "ServerBitmap.h"
#include "ServerFont.h"
#include "ServerPicture.h" #include "ServerPicture.h"
#include "ServerTokenSpace.h" #include "ServerTokenSpace.h"
#include "ViewLayer.h" #include "ViewLayer.h"
@@ -581,14 +582,16 @@ set_scale(ViewLayer *view, float scale)
static void static void
set_font_family(ViewLayer *view, const char *family) set_font_family(ViewLayer *view, const char *family)
{ {
printf("SetFontFamily(%s)\n", family); // TODO: Implement
// Can we have a ServerFont::SetFamily() which accepts a string ?
} }
static void static void
set_font_style(ViewLayer *view, const char *style) set_font_style(ViewLayer *view, const char *style)
{ {
printf("SetFontStyle(%s)\n", style); // TODO: Implement
// Can we have a ServerFont::SetStyle() which accepts a string ?
} }
@@ -831,12 +834,10 @@ ServerPicture::SetFontFromLink(BPrivate::LinkReceiver& link)
if (mask & B_FONT_FAMILY_AND_STYLE) { if (mask & B_FONT_FAMILY_AND_STYLE) {
uint32 fontID; uint32 fontID;
link.Read<uint32>(&fontID); link.Read<uint32>(&fontID);
//uint16 style = fontID & 0xFFFF; ServerFont font;
//uint16 family = (fontID & 0xFFFF0000) >> 16; font.SetFamilyAndStyle(fontID);
// TODO: WriteSetFamily() and WriteSetStyle() WriteSetFontFamily((font_family)font.Family());
// accept font_family and font_style parameters, not uint16 WriteSetFontStyle((font_style)font.Style());
//WriteSetFontFamily(family);
//WriteSetFontStyle(style);
} }
if (mask & B_FONT_SIZE) { if (mask & B_FONT_SIZE) {