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