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