1fb07ece0SStephan Aßmus /* 2*325a6253SAxel 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 16*325a6253SAxel Dörfler #ifdef ICON_O_MATIC 17*325a6253SAxel Dörfler # include <Message.h> 18*325a6253SAxel Dörfler #endif 19*325a6253SAxel Dörfler 20*325a6253SAxel Dörfler using namespace BPrivate::Icon; 21*325a6253SAxel Dörfler 22*325a6253SAxel 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 #ifdef ICON_O_MATIC 42fb07ece0SStephan Aßmus // TransformerFor 43fb07ece0SStephan Aßmus Transformer* 44fb07ece0SStephan Aßmus TransformerFactory::TransformerFor(BMessage* message, 45fb07ece0SStephan Aßmus VertexSource& source) 46fb07ece0SStephan Aßmus { 47fb07ece0SStephan Aßmus switch (message->what) { 48fb07ece0SStephan Aßmus case AffineTransformer::archive_code: 49fb07ece0SStephan Aßmus return new AffineTransformer(source, message); 50fb07ece0SStephan Aßmus case PerspectiveTransformer::archive_code: 51fb07ece0SStephan Aßmus return new PerspectiveTransformer(source, message); 52fb07ece0SStephan Aßmus case ContourTransformer::archive_code: 53fb07ece0SStephan Aßmus return new ContourTransformer(source, message); 54fb07ece0SStephan Aßmus case StrokeTransformer::archive_code: 55fb07ece0SStephan Aßmus return new StrokeTransformer(source, message); 56fb07ece0SStephan Aßmus } 57fb07ece0SStephan Aßmus 58fb07ece0SStephan Aßmus return NULL; 59fb07ece0SStephan Aßmus } 60fb07ece0SStephan Aßmus 61fb07ece0SStephan Aßmus // NextType 62fb07ece0SStephan Aßmus bool 63fb07ece0SStephan Aßmus TransformerFactory::NextType(int32* cookie, uint32* type, BString* name) 64fb07ece0SStephan Aßmus { 65fb07ece0SStephan Aßmus *type = *cookie; 66fb07ece0SStephan Aßmus *cookie = *cookie + 1; 67fb07ece0SStephan Aßmus 68fb07ece0SStephan Aßmus switch (*type) { 69fb07ece0SStephan Aßmus case 0: 70fb07ece0SStephan Aßmus *name = "Transformation"; 71fb07ece0SStephan Aßmus return true; 72fb07ece0SStephan Aßmus case 1: 73fb07ece0SStephan Aßmus *name = "Perspective"; 74fb07ece0SStephan Aßmus return true; 75fb07ece0SStephan Aßmus case 2: 76fb07ece0SStephan Aßmus *name = "Contour"; 77fb07ece0SStephan Aßmus return true; 78fb07ece0SStephan Aßmus case 3: 79fb07ece0SStephan Aßmus *name = "Stroke"; 80fb07ece0SStephan Aßmus return true; 81fb07ece0SStephan Aßmus } 82fb07ece0SStephan Aßmus 83fb07ece0SStephan Aßmus return false; 84fb07ece0SStephan Aßmus } 85fb07ece0SStephan Aßmus #endif // ICON_O_MATIC 86