haiku/headers/os/interface/Shape.h

118 lines
2.7 KiB
C
Raw Normal View History

/*
2014-07-15 03:02:44 +04:00
* Copyright 2002-2010 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _SHAPE_H
#define _SHAPE_H
#include <Archivable.h>
2014-07-15 03:02:44 +04:00
class BPoint;
class BRect;
class BShape;
namespace BPrivate {
class ServerLink;
class PicturePlayer;
};
class BShapeIterator {
public:
BShapeIterator();
virtual ~BShapeIterator();
virtual status_t IterateMoveTo(BPoint* point);
virtual status_t IterateLineTo(int32 lineCount,
2014-07-15 03:02:44 +04:00
BPoint* linePoints);
virtual status_t IterateBezierTo(int32 bezierCount,
2014-07-15 03:02:44 +04:00
BPoint* bezierPoints);
virtual status_t IterateClose();
Basically, this changeset implements BShape::ArcTo(). In more detail: * Added BShape::ArcTo() and BShapeIterator::IterateArcTo(), using a previously unused virtual slot. (Added the symbols for binary compatibility for GCC2 and GCC4.) * Added operator=(), operator==() and operator!=() to BShape. * Added BShape::BezierTo() version taking three points, which is sometimes more convenient. * Added the four new shape data ops OP_LARGE_ARC_TO_CW, OP_LARGE_ARC_TO_CCW, OP_SMALL_ARC_TO_CW and OP_SMALL_ARC_TO_CCW. For a single arc, provided the radius is large enough, there are four possibilities to draw the arc, these are controlled by the two boolean flags to ArcTo() and mapped to the new commands accordingly. * Some style cleanup in Shape.cpp (sorry for mixing it up, but it gets worse below...) * Added ShapeTest to src/tests/servers/app. * Changed the way BShapes are transformed from view to screen space in the app_server. For arcs, it would be nontrivial to apply a proper transformation, it's much easier to let AGG take care of it. This affects ServerPicture as well. * Wrapped iterating the BShape into try/catch blocks in ShapeIterator. But I really don't understand the purpose of the class in the first place. Maybe it can now be dropped, since coordinates don't have to be transformed in place anymore. * Refactored copy&paste shape iteration code in Painter. The transformation to screen space happens there. * Since RemoteDrawingEngine needed to be adopted anyway, I also updated it for the new DrawString() with offsets version. But the client still needs to be adapted. * Style cleanup in Painter.h git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35905 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 19:58:19 +03:00
virtual status_t IterateArcTo(float& rx, float& ry,
float& angle, bool largeArc,
bool counterClockWise, BPoint& point);
status_t Iterate(BShape* shape);
private:
virtual void _ReservedShapeIterator2();
virtual void _ReservedShapeIterator3();
virtual void _ReservedShapeIterator4();
uint32 reserved[4];
};
class BShape : public BArchivable {
public:
BShape();
BShape(const BShape& other);
BShape(BMessage* archive);
virtual ~BShape();
static BArchivable* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* archive,
bool deep = true) const;
Basically, this changeset implements BShape::ArcTo(). In more detail: * Added BShape::ArcTo() and BShapeIterator::IterateArcTo(), using a previously unused virtual slot. (Added the symbols for binary compatibility for GCC2 and GCC4.) * Added operator=(), operator==() and operator!=() to BShape. * Added BShape::BezierTo() version taking three points, which is sometimes more convenient. * Added the four new shape data ops OP_LARGE_ARC_TO_CW, OP_LARGE_ARC_TO_CCW, OP_SMALL_ARC_TO_CW and OP_SMALL_ARC_TO_CCW. For a single arc, provided the radius is large enough, there are four possibilities to draw the arc, these are controlled by the two boolean flags to ArcTo() and mapped to the new commands accordingly. * Some style cleanup in Shape.cpp (sorry for mixing it up, but it gets worse below...) * Added ShapeTest to src/tests/servers/app. * Changed the way BShapes are transformed from view to screen space in the app_server. For arcs, it would be nontrivial to apply a proper transformation, it's much easier to let AGG take care of it. This affects ServerPicture as well. * Wrapped iterating the BShape into try/catch blocks in ShapeIterator. But I really don't understand the purpose of the class in the first place. Maybe it can now be dropped, since coordinates don't have to be transformed in place anymore. * Refactored copy&paste shape iteration code in Painter. The transformation to screen space happens there. * Since RemoteDrawingEngine needed to be adopted anyway, I also updated it for the new DrawString() with offsets version. But the client still needs to be adapted. * Style cleanup in Painter.h git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35905 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 19:58:19 +03:00
BShape& operator=(const BShape& other);
bool operator==(const BShape& other) const;
bool operator!=(const BShape& other) const;
void Clear();
BRect Bounds() const;
BPoint CurrentPosition() const;
status_t AddShape(const BShape* other);
status_t MoveTo(BPoint point);
status_t LineTo(BPoint linePoint);
status_t BezierTo(BPoint controlPoints[3]);
Basically, this changeset implements BShape::ArcTo(). In more detail: * Added BShape::ArcTo() and BShapeIterator::IterateArcTo(), using a previously unused virtual slot. (Added the symbols for binary compatibility for GCC2 and GCC4.) * Added operator=(), operator==() and operator!=() to BShape. * Added BShape::BezierTo() version taking three points, which is sometimes more convenient. * Added the four new shape data ops OP_LARGE_ARC_TO_CW, OP_LARGE_ARC_TO_CCW, OP_SMALL_ARC_TO_CW and OP_SMALL_ARC_TO_CCW. For a single arc, provided the radius is large enough, there are four possibilities to draw the arc, these are controlled by the two boolean flags to ArcTo() and mapped to the new commands accordingly. * Some style cleanup in Shape.cpp (sorry for mixing it up, but it gets worse below...) * Added ShapeTest to src/tests/servers/app. * Changed the way BShapes are transformed from view to screen space in the app_server. For arcs, it would be nontrivial to apply a proper transformation, it's much easier to let AGG take care of it. This affects ServerPicture as well. * Wrapped iterating the BShape into try/catch blocks in ShapeIterator. But I really don't understand the purpose of the class in the first place. Maybe it can now be dropped, since coordinates don't have to be transformed in place anymore. * Refactored copy&paste shape iteration code in Painter. The transformation to screen space happens there. * Since RemoteDrawingEngine needed to be adopted anyway, I also updated it for the new DrawString() with offsets version. But the client still needs to be adapted. * Style cleanup in Painter.h git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35905 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-03-18 19:58:19 +03:00
status_t BezierTo(const BPoint& control1,
const BPoint& control2,
const BPoint& endPoint);
status_t ArcTo(float rx, float ry,
float angle, bool largeArc,
bool counterClockWise,
const BPoint& point);
status_t Close();
private:
// FBC padding
2014-07-15 03:02:44 +04:00
virtual status_t Perform(perform_code code, void* data);
virtual void _ReservedShape1();
virtual void _ReservedShape2();
virtual void _ReservedShape3();
virtual void _ReservedShape4();
private:
friend class BShapeIterator;
friend class BView;
friend class BFont;
friend class BPrivate::PicturePlayer;
friend class BPrivate::ServerLink;
void GetData(int32* opCount, int32* ptCount,
uint32** opList, BPoint** ptList);
void SetData(int32 opCount, int32 ptCount,
const uint32* opList,
const BPoint* ptList);
void InitData();
bool AllocatePts(int32 count);
bool AllocateOps(int32 count);
private:
uint32 fState;
uint32 fBuildingOp;
void* fPrivateData;
uint32 reserved[4];
};
2014-07-15 03:02:44 +04:00
#endif // _SHAPE_H