Some more updates from Marc Flerackers. Text drawing should work
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19277 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5770ac4cd8
commit
3f4cc718eb
|
@ -1,17 +1,14 @@
|
||||||
#include <iostream>
|
/*
|
||||||
#include <expat.h>
|
* Copyright 2006, Haiku Inc.
|
||||||
#include <AppKit.h>
|
* Distributed under the terms of the MIT License.
|
||||||
#include <InterfaceKit.h>
|
*
|
||||||
#include <SupportKit.h>
|
* Authors:
|
||||||
#include <TranslationUtils.h>
|
* Marc Flerackers (mflerackers@androme.be)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "Matrix.h"
|
|
||||||
#include "SVGViewView.h"
|
#include "SVGViewView.h"
|
||||||
|
|
||||||
struct named_color {
|
|
||||||
const char *name;
|
|
||||||
rgb_color color;
|
|
||||||
};
|
|
||||||
|
|
||||||
named_color colors[] = {
|
named_color colors[] = {
|
||||||
{ "aliceblue", { 240, 248, 255, 255 } },
|
{ "aliceblue", { 240, 248, 255, 255 } },
|
||||||
|
@ -164,61 +161,69 @@ named_color colors[] = {
|
||||||
{ NULL , { 0, 0, 0, 255 } },
|
{ NULL , { 0, 0, 0, 255 } },
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
// Globals ---------------------------------------------------------------------
|
||||||
STROKE_FLAG = 0x01,
|
|
||||||
FILL_FLAG = 0x02,
|
|
||||||
STROKE_WIDTH_FLAG = 0x04,
|
|
||||||
LINE_MODE_FLAG = 0x08,
|
|
||||||
FONT_SIZE_FLAG = 0x10,
|
|
||||||
MATRIX_FLAG = 0x20,
|
|
||||||
|
|
||||||
};
|
// Svg2PictureView class -------------------------------------------------------
|
||||||
|
Svg2PictureView::Svg2PictureView(BRect frame, const char *filename)
|
||||||
|
: BView(frame, "", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS),
|
||||||
|
fFileName(filename),
|
||||||
|
fPicture(NULL)
|
||||||
|
{
|
||||||
|
fPicture = new BPicture();
|
||||||
|
}
|
||||||
|
|
||||||
struct _state_ {
|
|
||||||
|
|
||||||
_state_() { set_default_values(); }
|
Svg2PictureView::~Svg2PictureView()
|
||||||
_state_(_state_ &state) { *this = state; }
|
{
|
||||||
void set_default_values()
|
delete fPicture;
|
||||||
{
|
}
|
||||||
fFlags = 0;
|
|
||||||
fStrokeColor.red = 0; fStrokeColor.green = 0;
|
|
||||||
fStrokeColor.blue = 0; fStrokeColor.alpha = 255;
|
void
|
||||||
fStroke = false;
|
Svg2PictureView::AttachedToWindow()
|
||||||
fFillColor.red = 0; fFillColor.green = 0;
|
{
|
||||||
fFillColor.blue = 0; fFillColor.alpha = 255;
|
BeginPicture(fPicture);
|
||||||
fFill = true;
|
|
||||||
fStrokeWidth = 1.0f;
|
bool done = false;
|
||||||
fLineCap = B_BUTT_CAP;
|
FILE *file = fopen(fFileName.String(), "rb");
|
||||||
fLineJoin = B_MITER_JOIN;
|
if (file) {
|
||||||
fLineMiterLimit = B_DEFAULT_MITER_LIMIT;
|
XML_Parser parser = XML_ParserCreate("UTF-8");
|
||||||
fFontSize = 9.0f;
|
XML_SetUserData(parser, this);
|
||||||
|
XML_SetElementHandler(parser, (XML_StartElementHandler)_StartElement, (XML_EndElementHandler)_EndElement);
|
||||||
|
XML_SetCharacterDataHandler(parser, (XML_CharacterDataHandler)_CharacterDataHandler);
|
||||||
|
|
||||||
|
while (!done) {
|
||||||
|
char buf[256];
|
||||||
|
size_t len = fread(buf, 1, sizeof(buf), file);
|
||||||
|
done = len < sizeof(buf);
|
||||||
|
if (!XML_Parse(parser, buf, len, done))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 fFlags;
|
XML_ParserFree(parser);
|
||||||
rgb_color fStrokeColor;
|
fclose(file);
|
||||||
bool fStroke;
|
}
|
||||||
rgb_color fFillColor;
|
fPicture = EndPicture();
|
||||||
bool fFill;
|
}
|
||||||
float fStrokeWidth;
|
|
||||||
cap_mode fLineCap;
|
|
||||||
join_mode fLineJoin;
|
|
||||||
float fLineMiterLimit;
|
|
||||||
float fFontSize;
|
|
||||||
BMatrix fMatrix;
|
|
||||||
};
|
|
||||||
|
|
||||||
_state_ fState;
|
|
||||||
BList fStack;
|
|
||||||
//BList fGradients;
|
|
||||||
|
|
||||||
bool HasAttribute(const XML_Char **attributes, const char *name) {
|
void
|
||||||
|
Svg2PictureView::Draw(BRect updateRect)
|
||||||
|
{
|
||||||
|
if (fPicture)
|
||||||
|
DrawPicture(fPicture);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
bool Svg2PictureView::HasAttribute(const XML_Char **attributes, const char *name) {
|
||||||
while (*attributes && strcasecmp(*attributes, name) != 0)
|
while (*attributes && strcasecmp(*attributes, name) != 0)
|
||||||
attributes += 2;
|
attributes += 2;
|
||||||
|
|
||||||
return (*attributes);
|
return (*attributes);
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
float GetFloatAttribute(const XML_Char **attributes, const char *name) {
|
float Svg2PictureView::GetFloatAttribute(const XML_Char **attributes, const char *name) {
|
||||||
while (*attributes && strcasecmp(*attributes, name) != 0)
|
while (*attributes && strcasecmp(*attributes, name) != 0)
|
||||||
attributes += 2;
|
attributes += 2;
|
||||||
|
|
||||||
|
@ -227,8 +232,8 @@ float GetFloatAttribute(const XML_Char **attributes, const char *name) {
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
const char *GetStringAttribute(const XML_Char **attributes, const char *name) {
|
const char *Svg2PictureView::GetStringAttribute(const XML_Char **attributes, const char *name) {
|
||||||
while (*attributes && strcasecmp(*attributes, name) != 0)
|
while (*attributes && strcasecmp(*attributes, name) != 0)
|
||||||
attributes += 2;
|
attributes += 2;
|
||||||
|
|
||||||
|
@ -237,8 +242,8 @@ const char *GetStringAttribute(const XML_Char **attributes, const char *name) {
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
rgb_color GetColorAttribute(const XML_Char **attributes, const char *name, uint8 alpha) {
|
rgb_color Svg2PictureView::GetColorAttribute(const XML_Char **attributes, const char *name, uint8 alpha) {
|
||||||
const char *attr = GetStringAttribute(attributes, name);
|
const char *attr = GetStringAttribute(attributes, name);
|
||||||
|
|
||||||
if (!attr)
|
if (!attr)
|
||||||
|
@ -290,7 +295,7 @@ rgb_color GetColorAttribute(const XML_Char **attributes, const char *name, uint8
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (strcasecmp(attr, "url")) {
|
if (strcasecmp(attr, "url")) {
|
||||||
const char *grad = strchr(attr, '#');
|
const char *grad = strchr(attr, '#');
|
||||||
|
|
||||||
if (grad) {
|
if (grad) {
|
||||||
|
@ -304,7 +309,7 @@ rgb_color GetColorAttribute(const XML_Char **attributes, const char *name, uint8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
for (int32 i = 0; colors[i].name != NULL; i++)
|
for (int32 i = 0; colors[i].name != NULL; i++)
|
||||||
if (strcasecmp(colors[i].name, attr) == 0) {
|
if (strcasecmp(colors[i].name, attr) == 0) {
|
||||||
|
@ -317,8 +322,8 @@ rgb_color GetColorAttribute(const XML_Char **attributes, const char *name, uint8
|
||||||
color.alpha = alpha;
|
color.alpha = alpha;
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
void GetPolygonAttribute(const XML_Char **attributes, const char *name, BShape &shape) {
|
void Svg2PictureView::GetPolygonAttribute(const XML_Char **attributes, const char *name, BShape &shape) {
|
||||||
const char *attr = NULL;
|
const char *attr = NULL;
|
||||||
|
|
||||||
while (*attributes && strcasecmp(*attributes, name) != 0)
|
while (*attributes && strcasecmp(*attributes, name) != 0)
|
||||||
|
@ -363,8 +368,8 @@ void GetPolygonAttribute(const XML_Char **attributes, const char *name, BShape &
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
void GetMatrixAttribute(const XML_Char **attributes, const char *name, BMatrix *matrix) {
|
void Svg2PictureView::GetMatrixAttribute(const XML_Char **attributes, const char *name, BMatrix *matrix) {
|
||||||
const char *attr = NULL;
|
const char *attr = NULL;
|
||||||
|
|
||||||
while (*attributes && strcasecmp(*attributes, name) != 0)
|
while (*attributes && strcasecmp(*attributes, name) != 0)
|
||||||
|
@ -434,7 +439,7 @@ void GetMatrixAttribute(const XML_Char **attributes, const char *name, BMatrix *
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
double CalcVectorAngle(double ux, double uy, double vx, double vy) {
|
double CalcVectorAngle(double ux, double uy, double vx, double vy) {
|
||||||
double ta = atan2(uy, ux);
|
double ta = atan2(uy, ux);
|
||||||
double tb = atan2(vy, vx);
|
double tb = atan2(vy, vx);
|
||||||
|
@ -444,7 +449,7 @@ double CalcVectorAngle(double ux, double uy, double vx, double vy) {
|
||||||
|
|
||||||
return 6.28318530718 - (ta - tb);
|
return 6.28318530718 - (ta - tb);
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
char *SkipFloat(char *string) {
|
char *SkipFloat(char *string) {
|
||||||
if (*string == '-')
|
if (*string == '-')
|
||||||
string++;
|
string++;
|
||||||
|
@ -453,26 +458,20 @@ char *SkipFloat(char *string) {
|
||||||
|
|
||||||
return string + len;
|
return string + len;
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
char *FindFloat(char *string) {
|
char *FindFloat(char *string) {
|
||||||
return strpbrk(string, "1234567890-.");
|
return strpbrk(string, "1234567890-.");
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
float GetFloat(char **string) {
|
float GetFloat(char **string) {
|
||||||
*string = FindFloat(*string);
|
*string = FindFloat(*string);
|
||||||
float f = atof(*string);
|
float f = atof(*string);
|
||||||
*string = SkipFloat(*string);
|
*string = SkipFloat(*string);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
void GetShapeAttribute(const XML_Char **attributes, const char *name, BShape &shape) {
|
void Svg2PictureView::GetShapeAttribute(const XML_Char **attributes, const char *name, BShape &shape) {
|
||||||
const char *attr = NULL;
|
const char *attr = GetStringAttribute(attributes, name);
|
||||||
|
|
||||||
while (*attributes && strcasecmp(*attributes, name) != 0)
|
|
||||||
attributes += 2;
|
|
||||||
|
|
||||||
if (*attributes)
|
|
||||||
attr = *(attributes + 1);
|
|
||||||
|
|
||||||
if (!attr)
|
if (!attr)
|
||||||
return;
|
return;
|
||||||
|
@ -590,12 +589,16 @@ void GetShapeAttribute(const XML_Char **attributes, const char *name, BShape &sh
|
||||||
case 'q':
|
case 'q':
|
||||||
{
|
{
|
||||||
if (command == 'Q') {
|
if (command == 'Q') {
|
||||||
if (sscanf(ptr, "Q %f %f %f %f", &x1, &y1, &x, &y) != 4)
|
x1 = GetFloat(&ptr);
|
||||||
sscanf(ptr, "Q %f,%f %f,%f", &x1, &y1, &x, &y);
|
y1 = GetFloat(&ptr);
|
||||||
|
x = GetFloat(&ptr);
|
||||||
|
y = GetFloat(&ptr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (sscanf(ptr, "q %f %f %f %f", &x1, &y1, &x, &y) != 4)
|
x1 = GetFloat(&ptr);
|
||||||
sscanf(ptr, "q %f,%f %f,%f", &x1, &y1, &x, &y);
|
y1 = GetFloat(&ptr);
|
||||||
|
x = GetFloat(&ptr);
|
||||||
|
y = GetFloat(&ptr);
|
||||||
|
|
||||||
x1 += pos.x;
|
x1 += pos.x;
|
||||||
y1 += pos.y;
|
y1 += pos.y;
|
||||||
|
@ -624,19 +627,25 @@ void GetShapeAttribute(const XML_Char **attributes, const char *name, BShape &sh
|
||||||
y1 = pos.y;
|
y1 = pos.y;
|
||||||
|
|
||||||
if (command == 'A') {
|
if (command == 'A') {
|
||||||
if (sscanf(ptr, "A %f %f %f %d %d %f %f", &rx, &ry, &angle,
|
rx = GetFloat(&ptr);
|
||||||
&largeArcFlag, &sweepFlag, &x, &y) != 7)
|
ry = GetFloat(&ptr);
|
||||||
sscanf(ptr, "A %f,%f %f %d,%d %f,%f", &rx, &ry, &angle,
|
angle = GetFloat(&ptr);
|
||||||
&largeArcFlag, &sweepFlag, &x, &y);
|
largeArcFlag = GetFloat(&ptr);
|
||||||
|
sweepFlag = GetFloat(&ptr);
|
||||||
|
x = GetFloat(&ptr);
|
||||||
|
y = GetFloat(&ptr);
|
||||||
|
|
||||||
x2 = x;
|
x2 = x;
|
||||||
y2 = y;
|
y2 = y;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (sscanf(ptr, "a %f %f %f %d %d %f %f", &rx, &ry, &angle,
|
rx = GetFloat(&ptr);
|
||||||
&largeArcFlag, &sweepFlag, &x, &y) != 7)
|
ry = GetFloat(&ptr);
|
||||||
sscanf(ptr, "a %f,%f %f %d,%d %f,%f", &rx, &ry, &angle,
|
angle = GetFloat(&ptr);
|
||||||
&largeArcFlag, &sweepFlag, &x, &y);
|
largeArcFlag = GetFloat(&ptr);
|
||||||
|
sweepFlag = GetFloat(&ptr);
|
||||||
|
x = GetFloat(&ptr);
|
||||||
|
y = GetFloat(&ptr);
|
||||||
|
|
||||||
x2 = x + pos.x;
|
x2 = x + pos.x;
|
||||||
y2 = y + pos.y;
|
y2 = y + pos.y;
|
||||||
|
@ -819,12 +828,12 @@ void GetShapeAttribute(const XML_Char **attributes, const char *name, BShape &sh
|
||||||
case 't':
|
case 't':
|
||||||
{
|
{
|
||||||
if (command == 'T') {
|
if (command == 'T') {
|
||||||
if (sscanf(ptr, "T %f %f", &x, &y) != 2)
|
x = GetFloat(&ptr);
|
||||||
sscanf(ptr, "T %f,%f", &x, &y);
|
y = GetFloat(&ptr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (sscanf(ptr, "t %f %f", &x, &y) != 2)
|
x = GetFloat(&ptr);
|
||||||
sscanf(ptr, "t %f,%f", &x, &y);
|
y = GetFloat(&ptr);
|
||||||
|
|
||||||
x += pos.x;
|
x += pos.x;
|
||||||
y += pos.y;
|
y += pos.y;
|
||||||
|
@ -859,8 +868,8 @@ void GetShapeAttribute(const XML_Char **attributes, const char *name, BShape &sh
|
||||||
prevCommand = command;
|
prevCommand = command;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
void CheckAttributes(const XML_Char **attributes, BView *view) {
|
void Svg2PictureView::CheckAttributes(const XML_Char **attributes) {
|
||||||
uint8 alpha = fState.fStrokeColor.alpha;
|
uint8 alpha = fState.fStrokeColor.alpha;
|
||||||
|
|
||||||
if (HasAttribute(attributes, "opacity")) {
|
if (HasAttribute(attributes, "opacity")) {
|
||||||
|
@ -871,14 +880,22 @@ void CheckAttributes(const XML_Char **attributes, BView *view) {
|
||||||
fState.fFlags |= FILL_FLAG;
|
fState.fFlags |= FILL_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (HasAttribute(attributes, "color")) {
|
||||||
|
fState.fCurrentColor = GetColorAttribute(attributes, "color", fState.fCurrentColor.alpha);
|
||||||
|
}
|
||||||
|
|
||||||
if (HasAttribute(attributes, "stroke")) {
|
if (HasAttribute(attributes, "stroke")) {
|
||||||
const char *stroke = GetStringAttribute(attributes, "stroke");
|
const char *stroke = GetStringAttribute(attributes, "stroke");
|
||||||
if (strcasecmp(stroke, "none") == 0)
|
if (strcasecmp(stroke, "none") == 0)
|
||||||
fState.fStroke = false;
|
fState.fStroke = false;
|
||||||
|
else if (strcasecmp(stroke, "currentColor") == 0) {
|
||||||
|
fState.fStrokeColor = fState.fCurrentColor;
|
||||||
|
fState.fStroke = true;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
fState.fStrokeColor = GetColorAttribute(attributes, "stroke", fState.fFillColor.alpha);
|
fState.fStrokeColor = GetColorAttribute(attributes, "stroke", fState.fFillColor.alpha);
|
||||||
fState.fStroke = true;
|
fState.fStroke = true;
|
||||||
view->SetHighColor(fState.fStrokeColor);
|
SetHighColor(fState.fStrokeColor);
|
||||||
}
|
}
|
||||||
fState.fFlags |= STROKE_FLAG;
|
fState.fFlags |= STROKE_FLAG;
|
||||||
}
|
}
|
||||||
|
@ -892,6 +909,10 @@ void CheckAttributes(const XML_Char **attributes, BView *view) {
|
||||||
const char *fill = GetStringAttribute(attributes, "fill");
|
const char *fill = GetStringAttribute(attributes, "fill");
|
||||||
if (strcasecmp(fill, "none") == 0)
|
if (strcasecmp(fill, "none") == 0)
|
||||||
fState.fFill = false;
|
fState.fFill = false;
|
||||||
|
else if (strcasecmp(fill, "currentColor") == 0) {
|
||||||
|
fState.fFillColor = fState.fCurrentColor;
|
||||||
|
fState.fFill = true;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
fState.fFillColor = GetColorAttribute(attributes, "fill", fState.fFillColor.alpha);
|
fState.fFillColor = GetColorAttribute(attributes, "fill", fState.fFillColor.alpha);
|
||||||
fState.fFill = true;
|
fState.fFill = true;
|
||||||
|
@ -906,7 +927,7 @@ void CheckAttributes(const XML_Char **attributes, BView *view) {
|
||||||
|
|
||||||
if (HasAttribute(attributes, "stroke-width")) {
|
if (HasAttribute(attributes, "stroke-width")) {
|
||||||
fState.fStrokeWidth = GetFloatAttribute(attributes, "stroke-width");
|
fState.fStrokeWidth = GetFloatAttribute(attributes, "stroke-width");
|
||||||
view->SetPenSize(fState.fStrokeWidth);
|
SetPenSize(fState.fStrokeWidth);
|
||||||
fState.fFlags |= STROKE_WIDTH_FLAG;
|
fState.fFlags |= STROKE_WIDTH_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -920,7 +941,7 @@ void CheckAttributes(const XML_Char **attributes, BView *view) {
|
||||||
else if (strcasecmp(stroke_linecap, "square") == 0)
|
else if (strcasecmp(stroke_linecap, "square") == 0)
|
||||||
fState.fLineCap = B_SQUARE_CAP;
|
fState.fLineCap = B_SQUARE_CAP;
|
||||||
|
|
||||||
view->SetLineMode(fState.fLineCap, view->LineJoinMode(), view->LineMiterLimit());
|
SetLineMode(fState.fLineCap, LineJoinMode(), LineMiterLimit());
|
||||||
fState.fFlags |= LINE_MODE_FLAG;
|
fState.fFlags |= LINE_MODE_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -934,19 +955,19 @@ void CheckAttributes(const XML_Char **attributes, BView *view) {
|
||||||
else if (strcasecmp(stroke_linejoin, "bevel") == 0)
|
else if (strcasecmp(stroke_linejoin, "bevel") == 0)
|
||||||
fState.fLineJoin = B_BEVEL_JOIN;
|
fState.fLineJoin = B_BEVEL_JOIN;
|
||||||
|
|
||||||
view->SetLineMode(view->LineCapMode(), fState.fLineJoin, view->LineMiterLimit());
|
SetLineMode(LineCapMode(), fState.fLineJoin, LineMiterLimit());
|
||||||
fState.fFlags |= LINE_MODE_FLAG;
|
fState.fFlags |= LINE_MODE_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasAttribute(attributes, "stroke-miterlimit")) {
|
if (HasAttribute(attributes, "stroke-miterlimit")) {
|
||||||
fState.fLineMiterLimit = GetFloatAttribute(attributes, "stroke-miterlimit");
|
fState.fLineMiterLimit = GetFloatAttribute(attributes, "stroke-miterlimit");
|
||||||
view->SetLineMode(view->LineCapMode(), view->LineJoinMode(), fState.fLineMiterLimit);
|
SetLineMode(LineCapMode(), LineJoinMode(), fState.fLineMiterLimit);
|
||||||
fState.fFlags |= LINE_MODE_FLAG;
|
fState.fFlags |= LINE_MODE_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasAttribute(attributes, "font-size")) {
|
if (HasAttribute(attributes, "font-size")) {
|
||||||
fState.fFontSize = GetFloatAttribute(attributes, "font-size");
|
fState.fFontSize = GetFloatAttribute(attributes, "font-size");
|
||||||
view->SetFontSize(fState.fFontSize);
|
SetFontSize(fState.fFontSize);
|
||||||
fState.fFlags |= FONT_SIZE_FLAG;
|
fState.fFlags |= FONT_SIZE_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -957,61 +978,22 @@ void CheckAttributes(const XML_Char **attributes, BView *view) {
|
||||||
fState.fFlags |= MATRIX_FLAG;
|
fState.fFlags |= MATRIX_FLAG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
void Push() {
|
void Svg2PictureView::StartElement(const XML_Char *name, const XML_Char **attributes) {
|
||||||
_state_ *state = new _state_(fState);
|
|
||||||
|
|
||||||
fStack.AddItem(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Pop(BView *view) {
|
|
||||||
if (fStack.CountItems() == 0)
|
|
||||||
printf("Unbalance Push/Pop\n");
|
|
||||||
|
|
||||||
_state_ *state = (_state_*)fStack.LastItem();
|
|
||||||
|
|
||||||
if (fState.fFlags & STROKE_FLAG)
|
|
||||||
{
|
|
||||||
if (state->fStroke)
|
|
||||||
view->SetHighColor(state->fStrokeColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fState.fFlags & FILL_FLAG)
|
|
||||||
{
|
|
||||||
if (state->fFill)
|
|
||||||
view->SetHighColor(state->fFillColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fState.fFlags & STROKE_WIDTH_FLAG)
|
|
||||||
view->SetPenSize(state->fStrokeWidth);
|
|
||||||
|
|
||||||
if (fState.fFlags & LINE_MODE_FLAG)
|
|
||||||
view->SetLineMode(state->fLineCap, state->fLineJoin, state->fLineMiterLimit);
|
|
||||||
|
|
||||||
if (fState.fFlags & FONT_SIZE_FLAG)
|
|
||||||
view->SetFontSize(state->fFontSize);
|
|
||||||
|
|
||||||
fState = *state;
|
|
||||||
|
|
||||||
fStack.RemoveItem(state);
|
|
||||||
delete state;
|
|
||||||
}
|
|
||||||
|
|
||||||
void startElement(BView *view, const XML_Char *name, const XML_Char **attributes) {
|
|
||||||
Push();
|
Push();
|
||||||
CheckAttributes(attributes, view);
|
CheckAttributes(attributes);
|
||||||
|
|
||||||
if (strcasecmp(name, "circle") == 0) {
|
if (strcasecmp(name, "circle") == 0) {
|
||||||
BPoint c(GetFloatAttribute(attributes, "cx"), GetFloatAttribute(attributes, "cy"));
|
BPoint c(GetFloatAttribute(attributes, "cx"), GetFloatAttribute(attributes, "cy"));
|
||||||
float r = GetFloatAttribute(attributes, "r");
|
float r = GetFloatAttribute(attributes, "r");
|
||||||
|
|
||||||
if (fState.fFill) {
|
if (fState.fFill) {
|
||||||
view->SetHighColor(fState.fFillColor);
|
SetHighColor(fState.fFillColor);
|
||||||
view->FillEllipse(c, r, r);
|
FillEllipse(c, r, r);
|
||||||
view->SetHighColor(fState.fStrokeColor);
|
SetHighColor(fState.fStrokeColor);
|
||||||
}
|
}
|
||||||
if (fState.fStroke)
|
if (fState.fStroke)
|
||||||
view->StrokeEllipse(c, r, r);
|
StrokeEllipse(c, r, r);
|
||||||
}
|
}
|
||||||
else if (strcasecmp(name, "ellipse") == 0) {
|
else if (strcasecmp(name, "ellipse") == 0) {
|
||||||
BPoint c(GetFloatAttribute(attributes, "cx"), GetFloatAttribute(attributes, "cy"));
|
BPoint c(GetFloatAttribute(attributes, "cx"), GetFloatAttribute(attributes, "cy"));
|
||||||
|
@ -1019,12 +1001,12 @@ void startElement(BView *view, const XML_Char *name, const XML_Char **attributes
|
||||||
float ry = GetFloatAttribute(attributes, "ry");
|
float ry = GetFloatAttribute(attributes, "ry");
|
||||||
|
|
||||||
if (fState.fFill) {
|
if (fState.fFill) {
|
||||||
view->SetHighColor(fState.fFillColor);
|
SetHighColor(fState.fFillColor);
|
||||||
view->FillEllipse(c, rx, ry);
|
FillEllipse(c, rx, ry);
|
||||||
view->SetHighColor(fState.fStrokeColor);
|
SetHighColor(fState.fStrokeColor);
|
||||||
}
|
}
|
||||||
if (fState.fStroke)
|
if (fState.fStroke)
|
||||||
view->StrokeEllipse(c, rx, ry);
|
StrokeEllipse(c, rx, ry);
|
||||||
}
|
}
|
||||||
else if (strcasecmp(name, "image") == 0) {
|
else if (strcasecmp(name, "image") == 0) {
|
||||||
BPoint topLeft(GetFloatAttribute(attributes, "x"), GetFloatAttribute(attributes, "y"));
|
BPoint topLeft(GetFloatAttribute(attributes, "x"), GetFloatAttribute(attributes, "y"));
|
||||||
|
@ -1040,7 +1022,7 @@ void startElement(BView *view, const XML_Char *name, const XML_Char **attributes
|
||||||
BBitmap *bitmap = BTranslationUtils::GetBitmap(href);
|
BBitmap *bitmap = BTranslationUtils::GetBitmap(href);
|
||||||
|
|
||||||
if (bitmap) {
|
if (bitmap) {
|
||||||
view->DrawBitmap(bitmap, BRect(topLeft, bottomRight));
|
DrawBitmap(bitmap, BRect(topLeft, bottomRight));
|
||||||
delete bitmap;
|
delete bitmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1052,26 +1034,30 @@ void startElement(BView *view, const XML_Char *name, const XML_Char **attributes
|
||||||
fState.fMatrix.Transform(&from);
|
fState.fMatrix.Transform(&from);
|
||||||
fState.fMatrix.Transform(&to);
|
fState.fMatrix.Transform(&to);
|
||||||
|
|
||||||
view->StrokeLine(from, to);
|
StrokeLine(from, to);
|
||||||
}
|
}
|
||||||
/*else if (strcasecmp(name, "linearGradient") == 0) {
|
else if (strcasecmp(name, "linearGradient") == 0) {
|
||||||
named_color *gradient = GetFloatAttribute(element);
|
fGradient = new named_gradient;
|
||||||
|
|
||||||
if (gradient)
|
fGradient->name = strdup(GetStringAttribute(attributes, "id"));
|
||||||
fGradients.AddItem(gradient);
|
fGradient->color.red = 0;
|
||||||
}*/
|
fGradient->color.green = 0;
|
||||||
|
fGradient->color.blue = 0;
|
||||||
|
fGradient->color.alpha = 255;
|
||||||
|
fGradient->started = false;
|
||||||
|
}
|
||||||
else if (strcasecmp(name, "path") == 0) {
|
else if (strcasecmp(name, "path") == 0) {
|
||||||
BShape shape;
|
BShape shape;
|
||||||
GetShapeAttribute(attributes, "d", shape);
|
GetShapeAttribute(attributes, "d", shape);
|
||||||
fState.fMatrix.Transform(shape);
|
fState.fMatrix.Transform(shape);
|
||||||
|
|
||||||
if (fState.fFill) {
|
if (fState.fFill) {
|
||||||
view->SetHighColor(fState.fFillColor);
|
SetHighColor(fState.fFillColor);
|
||||||
view->FillShape(&shape);
|
FillShape(&shape);
|
||||||
view->SetHighColor(fState.fStrokeColor);
|
SetHighColor(fState.fStrokeColor);
|
||||||
}
|
}
|
||||||
if (fState.fStroke)
|
if (fState.fStroke)
|
||||||
view->StrokeShape(&shape);
|
StrokeShape(&shape);
|
||||||
}
|
}
|
||||||
else if (strcasecmp(name, "polygon") == 0) {
|
else if (strcasecmp(name, "polygon") == 0) {
|
||||||
BShape shape;
|
BShape shape;
|
||||||
|
@ -1080,12 +1066,12 @@ void startElement(BView *view, const XML_Char *name, const XML_Char **attributes
|
||||||
fState.fMatrix.Transform(shape);
|
fState.fMatrix.Transform(shape);
|
||||||
|
|
||||||
if (fState.fFill) {
|
if (fState.fFill) {
|
||||||
view->SetHighColor(fState.fFillColor);
|
SetHighColor(fState.fFillColor);
|
||||||
view->FillShape(&shape);
|
FillShape(&shape);
|
||||||
view->SetHighColor(fState.fStrokeColor);
|
SetHighColor(fState.fStrokeColor);
|
||||||
}
|
}
|
||||||
if (fState.fStroke)
|
if (fState.fStroke)
|
||||||
view->StrokeShape(&shape);
|
StrokeShape(&shape);
|
||||||
}
|
}
|
||||||
else if (strcasecmp(name, "polyline") == 0) {
|
else if (strcasecmp(name, "polyline") == 0) {
|
||||||
BShape shape;
|
BShape shape;
|
||||||
|
@ -1093,12 +1079,37 @@ void startElement(BView *view, const XML_Char *name, const XML_Char **attributes
|
||||||
fState.fMatrix.Transform(shape);
|
fState.fMatrix.Transform(shape);
|
||||||
|
|
||||||
if (fState.fFill) {
|
if (fState.fFill) {
|
||||||
view->SetHighColor(fState.fFillColor);
|
SetHighColor(fState.fFillColor);
|
||||||
view->FillShape(&shape);
|
FillShape(&shape);
|
||||||
view->SetHighColor(fState.fStrokeColor);
|
SetHighColor(fState.fStrokeColor);
|
||||||
}
|
}
|
||||||
if (fState.fStroke)
|
if (fState.fStroke)
|
||||||
view->StrokeShape(&shape);
|
StrokeShape(&shape);
|
||||||
|
}
|
||||||
|
else if (strcasecmp(name, "radialGradient") == 0) {
|
||||||
|
fGradient = new named_gradient;
|
||||||
|
|
||||||
|
fGradient->name = strdup(GetStringAttribute(attributes, "id"));
|
||||||
|
fGradient->color.red = 0;
|
||||||
|
fGradient->color.green = 0;
|
||||||
|
fGradient->color.blue = 0;
|
||||||
|
fGradient->color.alpha = 255;
|
||||||
|
fGradient->started = false;
|
||||||
|
}
|
||||||
|
else if (strcasecmp(name, "stop") == 0) {
|
||||||
|
rgb_color color = GetColorAttribute(attributes, "stop-color", 255);
|
||||||
|
|
||||||
|
if (fGradient) {
|
||||||
|
if (fGradient->started) {
|
||||||
|
fGradient->color.red = (int8)(((int32)fGradient->color.red + (int32)color.red) / 2);
|
||||||
|
fGradient->color.green = (int8)(((int32)fGradient->color.green + (int32)color.green) / 2);
|
||||||
|
fGradient->color.blue = (int8)(((int32)fGradient->color.blue + (int32)color.blue) / 2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fGradient->color = color;
|
||||||
|
fGradient->started = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (strcasecmp(name, "rect") == 0) {
|
else if (strcasecmp(name, "rect") == 0) {
|
||||||
BPoint points[4];
|
BPoint points[4];
|
||||||
|
@ -1160,83 +1171,97 @@ void startElement(BView *view, const XML_Char *name, const XML_Char **attributes
|
||||||
|
|
||||||
if (fState.fFill)
|
if (fState.fFill)
|
||||||
{
|
{
|
||||||
view->SetHighColor(fState.fFillColor);
|
SetHighColor(fState.fFillColor);
|
||||||
view->FillShape(&shape);
|
FillShape(&shape);
|
||||||
view->SetHighColor(fState.fStrokeColor);
|
SetHighColor(fState.fStrokeColor);
|
||||||
}
|
}
|
||||||
if (fState.fStroke)
|
if (fState.fStroke)
|
||||||
view->StrokeShape(&shape);
|
StrokeShape(&shape);
|
||||||
}
|
}
|
||||||
/*else if (strcasecmp(name, "text") == 0) {
|
else if (strcasecmp(name, "text") == 0) {
|
||||||
BPoint point(GetFloatAttribute(attributes, "x"), GetFloatAttribute(attributes, "y"));
|
fTextPosition.Set(GetFloatAttribute(attributes, "x"), GetFloatAttribute(attributes, "y"));
|
||||||
|
fState.fMatrix.Transform(&fTextPosition);
|
||||||
fState.fMatrix.Transform(&point);
|
}
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
void Svg2PictureView::EndElement(const XML_Char *name) {
|
||||||
|
if (strcasecmp(name, "linearGradient") == 0) {
|
||||||
|
if (fGradient)
|
||||||
|
fGradients.AddItem(fGradient);
|
||||||
|
fGradient = NULL;
|
||||||
|
}
|
||||||
|
else if (strcasecmp(name, "radialGradient") == 0) {
|
||||||
|
if (fGradient)
|
||||||
|
fGradients.AddItem(fGradient);
|
||||||
|
fGradient = NULL;
|
||||||
|
}
|
||||||
|
else if (strcasecmp(name, "text") == 0) {
|
||||||
if (fState.fFill)
|
if (fState.fFill)
|
||||||
{
|
{
|
||||||
view->SetHighColor(fState.fFillColor);
|
SetHighColor(fState.fFillColor);
|
||||||
view->DrawString(GetText(element), point); // We need to get the text using another callback
|
DrawString(fText.String(), fTextPosition);
|
||||||
view->SetHighColor(fState.fStrokeColor);
|
SetHighColor(fState.fStrokeColor);
|
||||||
}
|
}
|
||||||
if (fState.fStroke)
|
if (fState.fStroke)
|
||||||
view->DrawString(GetText(element), point);
|
DrawString(fText.String(), fTextPosition);
|
||||||
|
printf("%f, %f\n", fTextPosition.x, fTextPosition.y);
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
endElement(BView *view, const XML_Char *name)
|
|
||||||
{
|
|
||||||
Pop(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Svg2PictureView::Svg2PictureView(BRect frame, const char *filename)
|
|
||||||
: BView(frame, "", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS),
|
|
||||||
fPicture(NULL)
|
|
||||||
{
|
|
||||||
fFilename = filename;
|
|
||||||
fPicture = new BPicture;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Svg2PictureView::~Svg2PictureView()
|
|
||||||
{
|
|
||||||
delete fPicture;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Svg2PictureView::AttachedToWindow()
|
|
||||||
{
|
|
||||||
BeginPicture(fPicture);
|
|
||||||
char buf[256];
|
|
||||||
bool done = false;
|
|
||||||
FILE *file = fopen(fFilename.String(), "rb");
|
|
||||||
|
|
||||||
if (file) {
|
|
||||||
XML_Parser parser = XML_ParserCreate("UTF-8");
|
|
||||||
XML_SetUserData(parser, this);
|
|
||||||
XML_SetElementHandler(parser, (XML_StartElementHandler)startElement, (XML_EndElementHandler)endElement);
|
|
||||||
|
|
||||||
while (!done) {
|
|
||||||
size_t len = fread(buf, 1, sizeof(buf), file);
|
|
||||||
done = len < sizeof(buf);
|
|
||||||
if (!XML_Parse(parser, buf, len, done))
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XML_ParserFree(parser);
|
Pop();
|
||||||
fclose(file);
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
void Svg2PictureView::CharacterDataHandler(const XML_Char *s, int len) {
|
||||||
|
fText.SetTo(s, len);
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
void Svg2PictureView::Push() {
|
||||||
|
_state_ *state = new _state_(fState);
|
||||||
|
|
||||||
|
fStack.AddItem(state);
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
void Svg2PictureView::Pop() {
|
||||||
|
if (fStack.CountItems() == 0)
|
||||||
|
printf("Unbalanced Push/Pop\n");
|
||||||
|
|
||||||
|
_state_ *state = (_state_*)fStack.LastItem();
|
||||||
|
|
||||||
|
if (fState.fFlags & STROKE_FLAG)
|
||||||
|
{
|
||||||
|
if (state->fStroke)
|
||||||
|
SetHighColor(state->fStrokeColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
EndPicture();
|
if (fState.fFlags & FILL_FLAG)
|
||||||
}
|
{
|
||||||
|
if (state->fFill)
|
||||||
|
SetHighColor(state->fFillColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fState.fFlags & STROKE_WIDTH_FLAG)
|
||||||
|
SetPenSize(state->fStrokeWidth);
|
||||||
|
|
||||||
void
|
if (fState.fFlags & LINE_MODE_FLAG)
|
||||||
Svg2PictureView::Draw(BRect updateRect)
|
SetLineMode(state->fLineCap, state->fLineJoin, state->fLineMiterLimit);
|
||||||
{
|
|
||||||
DrawPicture(fPicture);
|
if (fState.fFlags & FONT_SIZE_FLAG)
|
||||||
|
SetFontSize(state->fFontSize);
|
||||||
|
|
||||||
|
fState = *state;
|
||||||
|
|
||||||
|
fStack.RemoveItem(state);
|
||||||
|
delete state;
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
void Svg2PictureView::_StartElement(Svg2PictureView *view, const XML_Char *name, const XML_Char **attributes) {
|
||||||
|
view->StartElement(name, attributes);
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
void Svg2PictureView::_EndElement(Svg2PictureView *view, const XML_Char *name) {
|
||||||
|
view->EndElement(name);
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
void Svg2PictureView::_CharacterDataHandler(Svg2PictureView *view, const XML_Char *s, int len) {
|
||||||
|
view->CharacterDataHandler(s, len);
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,22 +1,119 @@
|
||||||
#ifndef _SVG_VIEW_VIEW_H
|
#ifndef _SVGVIEW_VIEW_H
|
||||||
#define _SVG_VIEW_VIEW_H
|
#define _SVGVIEW_VIEW_H
|
||||||
|
|
||||||
#include <String.h>
|
// Standard Includes -----------------------------------------------------------
|
||||||
#include <View.h>
|
#include <expat.h>
|
||||||
|
|
||||||
|
// System Includes -------------------------------------------------------------
|
||||||
|
#include <InterfaceKit.h>
|
||||||
|
#include <SupportKit.h>
|
||||||
|
#include <TranslationUtils.h>
|
||||||
|
|
||||||
class BPicture;
|
// Project Includes ------------------------------------------------------------
|
||||||
|
#include "Matrix.h"
|
||||||
|
|
||||||
|
// Local Includes --------------------------------------------------------------
|
||||||
|
|
||||||
|
// Local Defines ---------------------------------------------------------------
|
||||||
|
struct named_color {
|
||||||
|
const char *name;
|
||||||
|
rgb_color color;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct named_gradient {
|
||||||
|
const char *name;
|
||||||
|
rgb_color color;
|
||||||
|
bool started;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
STROKE_FLAG = 0x01,
|
||||||
|
FILL_FLAG = 0x02,
|
||||||
|
STROKE_WIDTH_FLAG = 0x04,
|
||||||
|
LINE_MODE_FLAG = 0x08,
|
||||||
|
FONT_SIZE_FLAG = 0x10,
|
||||||
|
MATRIX_FLAG = 0x20,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _state_ {
|
||||||
|
|
||||||
|
_state_() { set_default_values(); }
|
||||||
|
_state_(_state_ &state) { *this = state; }
|
||||||
|
void set_default_values()
|
||||||
|
{
|
||||||
|
fFlags = 0;
|
||||||
|
fCurrentColor.red = 0; fCurrentColor.green = 0;
|
||||||
|
fCurrentColor.blue = 0; fCurrentColor.alpha = 255;
|
||||||
|
fStrokeColor.red = 0; fStrokeColor.green = 0;
|
||||||
|
fStrokeColor.blue = 0; fStrokeColor.alpha = 255;
|
||||||
|
fStroke = false;
|
||||||
|
fFillColor.red = 0; fFillColor.green = 0;
|
||||||
|
fFillColor.blue = 0; fFillColor.alpha = 255;
|
||||||
|
fFill = true;
|
||||||
|
fStrokeWidth = 1.0f;
|
||||||
|
fLineCap = B_BUTT_CAP;
|
||||||
|
fLineJoin = B_MITER_JOIN;
|
||||||
|
fLineMiterLimit = B_DEFAULT_MITER_LIMIT;
|
||||||
|
fFontSize = 9.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 fFlags;
|
||||||
|
rgb_color fCurrentColor;
|
||||||
|
rgb_color fStrokeColor;
|
||||||
|
bool fStroke;
|
||||||
|
rgb_color fFillColor;
|
||||||
|
bool fFill;
|
||||||
|
float fStrokeWidth;
|
||||||
|
cap_mode fLineCap;
|
||||||
|
join_mode fLineJoin;
|
||||||
|
float fLineMiterLimit;
|
||||||
|
float fFontSize;
|
||||||
|
BMatrix fMatrix;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Globals ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Svg2PictureView class -------------------------------------------------------
|
||||||
class Svg2PictureView : public BView {
|
class Svg2PictureView : public BView {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Svg2PictureView(BRect frame, const char *filename);
|
Svg2PictureView(BRect frame, const char *fileName);
|
||||||
~Svg2PictureView();
|
~Svg2PictureView();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BString fFilename;
|
bool HasAttribute(const XML_Char **attributes, const char *name);
|
||||||
|
float GetFloatAttribute(const XML_Char **attributes, const char *name);
|
||||||
|
const char *GetStringAttribute(const XML_Char **attributes, const char *name);
|
||||||
|
rgb_color GetColorAttribute(const XML_Char **attributes, const char *name, uint8 alpha);
|
||||||
|
void GetPolygonAttribute(const XML_Char **attributes, const char *name, BShape &shape);
|
||||||
|
void GetMatrixAttribute(const XML_Char **attributes, const char *name, BMatrix *matrix);
|
||||||
|
void GetShapeAttribute(const XML_Char **attributes, const char *name, BShape &shape);
|
||||||
|
void CheckAttributes(const XML_Char **attributes);
|
||||||
|
void StartElement(const XML_Char *name, const XML_Char **attributes);
|
||||||
|
void EndElement(const XML_Char *name);
|
||||||
|
void CharacterDataHandler(const XML_Char *s, int len);
|
||||||
|
|
||||||
|
void Push();
|
||||||
|
void Pop();
|
||||||
|
|
||||||
|
static void _StartElement(Svg2PictureView *view, const XML_Char *name, const XML_Char **attributes);
|
||||||
|
static void _EndElement(Svg2PictureView *view, const XML_Char *name);
|
||||||
|
static void _CharacterDataHandler(Svg2PictureView *view, const XML_Char *s, int len);
|
||||||
|
|
||||||
|
_state_ fState;
|
||||||
|
BList fStack;
|
||||||
|
named_gradient *fGradient;
|
||||||
|
BList fGradients;
|
||||||
|
BPoint fTextPosition;
|
||||||
|
BString fText;
|
||||||
|
|
||||||
|
BString fFileName;
|
||||||
BPicture *fPicture;
|
BPicture *fPicture;
|
||||||
};
|
};
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
#endif // _SVG_VIEW_VIEW_H
|
#endif // _SVGVIEW_VIEW_H
|
||||||
|
|
Loading…
Reference in New Issue