xref: /haiku/src/libs/icon/transformer/TransformerFactory.cpp (revision c16bcdfcb779bf4d85a8aceb10602581d3de104f)
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
17*c16bcdfcSJoachim Seemer #include <Catalog.h>
18325a6253SAxel Dörfler #include <Message.h>
19*c16bcdfcSJoachim Seemer 
20*c16bcdfcSJoachim Seemer #undef B_TRANSLATE_CONTEXT
21*c16bcdfcSJoachim Seemer #define B_TRANSLATE_CONTEXT "Transformation"
22325a6253SAxel Dörfler #endif
23325a6253SAxel Dörfler 
2425dc253dSIngo Weinhold 
2525dc253dSIngo Weinhold _USING_ICON_NAMESPACE
26325a6253SAxel Dörfler 
27325a6253SAxel Dörfler 
28fb07ece0SStephan Aßmus // TransformerFor
29fb07ece0SStephan Aßmus Transformer*
30fb07ece0SStephan Aßmus TransformerFactory::TransformerFor(uint32 type, VertexSource& source)
31fb07ece0SStephan Aßmus {
32fb07ece0SStephan Aßmus 	switch (type) {
33fb07ece0SStephan Aßmus 		case 0:
34fb07ece0SStephan Aßmus 			return new AffineTransformer(source);
35fb07ece0SStephan Aßmus 		case 1:
36fb07ece0SStephan Aßmus 			return new PerspectiveTransformer(source);
37fb07ece0SStephan Aßmus 		case 2:
38fb07ece0SStephan Aßmus 			return new ContourTransformer(source);
39fb07ece0SStephan Aßmus 		case 3:
40fb07ece0SStephan Aßmus 			return new StrokeTransformer(source);
41fb07ece0SStephan Aßmus 	}
42fb07ece0SStephan Aßmus 
43fb07ece0SStephan Aßmus 	return NULL;
44fb07ece0SStephan Aßmus }
45fb07ece0SStephan Aßmus 
46fb07ece0SStephan Aßmus // TransformerFor
47fb07ece0SStephan Aßmus Transformer*
48fb07ece0SStephan Aßmus TransformerFactory::TransformerFor(BMessage* message,
49fb07ece0SStephan Aßmus 								   VertexSource& source)
50fb07ece0SStephan Aßmus {
51fb07ece0SStephan Aßmus 	switch (message->what) {
52fb07ece0SStephan Aßmus 		case AffineTransformer::archive_code:
53fb07ece0SStephan Aßmus 			return new AffineTransformer(source, message);
54fb07ece0SStephan Aßmus 		case PerspectiveTransformer::archive_code:
55fb07ece0SStephan Aßmus 			return new PerspectiveTransformer(source, message);
56fb07ece0SStephan Aßmus 		case ContourTransformer::archive_code:
57fb07ece0SStephan Aßmus 			return new ContourTransformer(source, message);
58fb07ece0SStephan Aßmus 		case StrokeTransformer::archive_code:
59fb07ece0SStephan Aßmus 			return new StrokeTransformer(source, message);
60fb07ece0SStephan Aßmus 	}
61fb07ece0SStephan Aßmus 
62fb07ece0SStephan Aßmus 	return NULL;
63fb07ece0SStephan Aßmus }
64fb07ece0SStephan Aßmus 
658b8d44bfSMichael Lotz #ifdef ICON_O_MATIC
668b8d44bfSMichael Lotz 
67fb07ece0SStephan Aßmus // NextType
68fb07ece0SStephan Aßmus bool
69fb07ece0SStephan Aßmus TransformerFactory::NextType(int32* cookie, uint32* type, BString* name)
70fb07ece0SStephan Aßmus {
71fb07ece0SStephan Aßmus 	*type = *cookie;
72fb07ece0SStephan Aßmus 	*cookie = *cookie + 1;
73fb07ece0SStephan Aßmus 
74fb07ece0SStephan Aßmus 	switch (*type) {
75fb07ece0SStephan Aßmus 		case 0:
76*c16bcdfcSJoachim Seemer 			*name = B_TRANSLATE("Transformation");
77fb07ece0SStephan Aßmus 			return true;
78fb07ece0SStephan Aßmus 		case 1:
79*c16bcdfcSJoachim Seemer 			*name = B_TRANSLATE("Perspective");
80fb07ece0SStephan Aßmus 			return true;
81fb07ece0SStephan Aßmus 		case 2:
82*c16bcdfcSJoachim Seemer 			*name = B_TRANSLATE("Contour");
83fb07ece0SStephan Aßmus 			return true;
84fb07ece0SStephan Aßmus 		case 3:
85*c16bcdfcSJoachim Seemer 			*name = B_TRANSLATE("Stroke");
86fb07ece0SStephan Aßmus 			return true;
87fb07ece0SStephan Aßmus 	}
88fb07ece0SStephan Aßmus 
89fb07ece0SStephan Aßmus 	return false;
90fb07ece0SStephan Aßmus }
91fb07ece0SStephan Aßmus #endif // ICON_O_MATIC
92