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