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