xref: /haiku/src/libs/icon/transformer/TransformerFactory.cpp (revision fb07ece069b8b7ca52eda06449ce2f0460b294ab)
1*fb07ece0SStephan Aßmus /*
2*fb07ece0SStephan Aßmus  * Copyright 2006, Haiku.
3*fb07ece0SStephan Aßmus  * Distributed under the terms of the MIT License.
4*fb07ece0SStephan Aßmus  *
5*fb07ece0SStephan Aßmus  * Authors:
6*fb07ece0SStephan Aßmus  *		Stephan Aßmus <superstippi@gmx.de>
7*fb07ece0SStephan Aßmus  */
8*fb07ece0SStephan Aßmus 
9*fb07ece0SStephan Aßmus #include "TransformerFactory.h"
10*fb07ece0SStephan Aßmus 
11*fb07ece0SStephan Aßmus #ifdef ICON_O_MATIC
12*fb07ece0SStephan Aßmus # include <Message.h>
13*fb07ece0SStephan Aßmus #endif
14*fb07ece0SStephan Aßmus 
15*fb07ece0SStephan Aßmus #include "AffineTransformer.h"
16*fb07ece0SStephan Aßmus #include "ContourTransformer.h"
17*fb07ece0SStephan Aßmus #include "PerspectiveTransformer.h"
18*fb07ece0SStephan Aßmus #include "StrokeTransformer.h"
19*fb07ece0SStephan Aßmus 
20*fb07ece0SStephan Aßmus // TransformerFor
21*fb07ece0SStephan Aßmus Transformer*
22*fb07ece0SStephan Aßmus TransformerFactory::TransformerFor(uint32 type, VertexSource& source)
23*fb07ece0SStephan Aßmus {
24*fb07ece0SStephan Aßmus 	switch (type) {
25*fb07ece0SStephan Aßmus 		case 0:
26*fb07ece0SStephan Aßmus 			return new AffineTransformer(source);
27*fb07ece0SStephan Aßmus 		case 1:
28*fb07ece0SStephan Aßmus 			return new PerspectiveTransformer(source);
29*fb07ece0SStephan Aßmus 		case 2:
30*fb07ece0SStephan Aßmus 			return new ContourTransformer(source);
31*fb07ece0SStephan Aßmus 		case 3:
32*fb07ece0SStephan Aßmus 			return new StrokeTransformer(source);
33*fb07ece0SStephan Aßmus 	}
34*fb07ece0SStephan Aßmus 
35*fb07ece0SStephan Aßmus 	return NULL;
36*fb07ece0SStephan Aßmus }
37*fb07ece0SStephan Aßmus 
38*fb07ece0SStephan Aßmus #ifdef ICON_O_MATIC
39*fb07ece0SStephan Aßmus // TransformerFor
40*fb07ece0SStephan Aßmus Transformer*
41*fb07ece0SStephan Aßmus TransformerFactory::TransformerFor(BMessage* message,
42*fb07ece0SStephan Aßmus 								   VertexSource& source)
43*fb07ece0SStephan Aßmus {
44*fb07ece0SStephan Aßmus 	switch (message->what) {
45*fb07ece0SStephan Aßmus 		case AffineTransformer::archive_code:
46*fb07ece0SStephan Aßmus 			return new AffineTransformer(source, message);
47*fb07ece0SStephan Aßmus 		case PerspectiveTransformer::archive_code:
48*fb07ece0SStephan Aßmus 			return new PerspectiveTransformer(source, message);
49*fb07ece0SStephan Aßmus 		case ContourTransformer::archive_code:
50*fb07ece0SStephan Aßmus 			return new ContourTransformer(source, message);
51*fb07ece0SStephan Aßmus 		case StrokeTransformer::archive_code:
52*fb07ece0SStephan Aßmus 			return new StrokeTransformer(source, message);
53*fb07ece0SStephan Aßmus 	}
54*fb07ece0SStephan Aßmus 
55*fb07ece0SStephan Aßmus 	return NULL;
56*fb07ece0SStephan Aßmus }
57*fb07ece0SStephan Aßmus 
58*fb07ece0SStephan Aßmus // NextType
59*fb07ece0SStephan Aßmus bool
60*fb07ece0SStephan Aßmus TransformerFactory::NextType(int32* cookie, uint32* type, BString* name)
61*fb07ece0SStephan Aßmus {
62*fb07ece0SStephan Aßmus 	*type = *cookie;
63*fb07ece0SStephan Aßmus 	*cookie = *cookie + 1;
64*fb07ece0SStephan Aßmus 
65*fb07ece0SStephan Aßmus 	switch (*type) {
66*fb07ece0SStephan Aßmus 		case 0:
67*fb07ece0SStephan Aßmus 			*name = "Transformation";
68*fb07ece0SStephan Aßmus 			return true;
69*fb07ece0SStephan Aßmus 		case 1:
70*fb07ece0SStephan Aßmus 			*name = "Perspective";
71*fb07ece0SStephan Aßmus 			return true;
72*fb07ece0SStephan Aßmus 		case 2:
73*fb07ece0SStephan Aßmus 			*name = "Contour";
74*fb07ece0SStephan Aßmus 			return true;
75*fb07ece0SStephan Aßmus 		case 3:
76*fb07ece0SStephan Aßmus 			*name = "Stroke";
77*fb07ece0SStephan Aßmus 			return true;
78*fb07ece0SStephan Aßmus 	}
79*fb07ece0SStephan Aßmus 
80*fb07ece0SStephan Aßmus 	return false;
81*fb07ece0SStephan Aßmus }
82*fb07ece0SStephan Aßmus #endif // ICON_O_MATIC
83