1
#include "CGUIEditFactory.h"
2
#include "IGUIEnvironment.h"
5
#include "EGUIEditTypes.h"
7
#include "CGUIEditWorkspace.h"
8
#include "CGUIEditWindow.h"
10
#include "CGUITextureCacheBrowser.h"
11
#include "CGUIAttributeEditor.h"
12
#include "CGUIStringAttribute.h"
13
#include "CGUIBoolAttribute.h"
14
#include "CGUIEnumAttribute.h"
15
#include "CGUIColorAttribute.h"
16
#include "CGUITextureAttribute.h"
17
#include "CGUIDummyEditorStub.h"
24
CGUIEditFactory::CGUIEditFactory(IGUIEnvironment* env)
28
setDebugName("CGUIEditFactory");
31
// don't grab the gui environment here to prevent cyclic references
35
CGUIEditFactory::~CGUIEditFactory()
40
//! adds an element to the environment based on its type name
41
IGUIElement* CGUIEditFactory::addGUIElement(const c8* typeName, IGUIElement* parent)
44
here we create elements, add them to the manager, and then drop them
47
core::stringc elementType(typeName);
50
parent = Environment->getRootGUIElement();
53
if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIEDIT]))
54
ret = new CGUIEditWorkspace(Environment, -1, 0);
56
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIEDITWINDOW]))
57
ret = new CGUIEditWindow(Environment, core::rect<s32>(0,0,100,100), 0);
58
// Klasker's GUI Panel
59
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIPANEL]))
60
ret = new CGUIPanel(Environment, 0);
61
// texture cache browser
62
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_TEXTUREBROWSER]))
63
ret = new CGUITextureCacheBrowser(Environment, -1, 0);
64
// block of attribute editors
65
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_ATTRIBUTEEDITOR]))
66
ret = new CGUIAttributeEditor(Environment, -1, 0);
67
//! single attribute editors
68
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_STRINGATTRIBUTE]))
69
ret = new CGUIStringAttribute(Environment, 0, -1);
70
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_BOOLATTRIBUTE]))
71
ret = new CGUIBoolAttribute(Environment, 0, -1);
72
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_ENUMATTRIBUTE]))
73
ret = new CGUIEnumAttribute(Environment, 0, -1);
74
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORATTRIBUTE]))
75
ret = new CGUIColorAttribute(Environment, 0, -1);
76
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORFATTRIBUTE]))
77
ret = new CGUIColorAttribute(Environment, 0, -1);
78
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_TEXTUREATTRIBUTE]))
79
ret = new CGUITextureAttribute(Environment, 0, -1);
80
// stubs and custom editors
81
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_CONTEXTMENUEDITOR]) ||
82
elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_MENUEDITOR]) ||
83
elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_FILEDIALOGEDITOR]) ||
84
elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORDIALOGEDITOR]) ||
85
elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_MODALSCREENEDITOR]) )
86
ret = new CGUIDummyEditorStub(Environment, 0, typeName);
88
// add the element to its parent
90
parent->addChild(ret);
92
// the environment now has the reference, so we can drop the element
100
//! returns amount of element types this factory is able to create
101
s32 CGUIEditFactory::getCreatableGUIElementTypeCount() const
103
return EGUIEDIT_COUNT;
107
//! returns type name of a createable element type
108
const c8* CGUIEditFactory::getCreateableGUIElementTypeName(s32 idx) const
110
if (idx>=0 && idx<EGUIEDIT_COUNT)
111
return GUIEditElementTypeNames[idx];
118
} // end namespace gui
119
} // end namespace irr