1/*
2 * Copyright 2006, Haiku.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Stephan Aßmus <superstippi@gmx.de>
7 */
8
9#ifndef TRANSFORMABLE_H
10#define TRANSFORMABLE_H
11
12#include <Rect.h>
13
14#include <agg_trans_affine.h>
15
16#include "IconBuild.h"
17
18
19_BEGIN_ICON_NAMESPACE
20
21
22class Transformable : public agg::trans_affine {
23 public:
24	enum {
25		matrix_size = 6,
26	};
27
28								Transformable();
29								Transformable(const Transformable& other);
30	virtual						~Transformable();
31
32			void				StoreTo(double matrix[matrix_size]) const;
33			void				LoadFrom(const double matrix[matrix_size]);
34
35								// set to or combine with other matrix
36			void				SetTransform(const Transformable& other);
37			Transformable&		operator=(const Transformable& other);
38			Transformable&		Multiply(const Transformable& other);
39	virtual	void				Reset();
40
41			void				Invert();
42
43			bool				IsIdentity() const;
44			bool				IsTranslationOnly() const;
45			bool				IsNotDistorted() const;
46			bool				IsValid() const;
47
48			bool				operator==(const Transformable& other) const;
49			bool				operator!=(const Transformable& other) const;
50
51								// transforms coordiantes
52			void				Transform(double* x, double* y) const;
53			void				Transform(BPoint* point) const;
54			BPoint				Transform(const BPoint& point) const;
55
56			void				InverseTransform(double* x, double* y) const;
57			void				InverseTransform(BPoint* point) const;
58			BPoint				InverseTransform(const BPoint& point) const;
59
60								// transforms the rectangle "bounds" and
61								// returns the *bounding box* of that
62			BRect				TransformBounds(BRect bounds) const;
63
64								// some convenience functions
65	virtual	void				TranslateBy(BPoint offset);
66	virtual	void				RotateBy(BPoint origin, double degrees);
67	virtual	void				ScaleBy(BPoint origin, double xScale, double yScale);
68	virtual	void				ShearBy(BPoint origin, double xShear, double yShear);
69
70	virtual	void				TransformationChanged();
71		// hook function that is called when the transformation
72		// is changed for some reason
73};
74
75
76_END_ICON_NAMESPACE
77
78
79_USING_ICON_NAMESPACE
80
81
82#endif // TRANSFORMABLE_H
83
84