aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/tools/GUIEditor/CGUIEditFactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/tools/GUIEditor/CGUIEditFactory.cpp')
-rw-r--r--src/others/irrlicht-1.8.1/tools/GUIEditor/CGUIEditFactory.cpp120
1 files changed, 120 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/tools/GUIEditor/CGUIEditFactory.cpp b/src/others/irrlicht-1.8.1/tools/GUIEditor/CGUIEditFactory.cpp
new file mode 100644
index 0000000..9552745
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/tools/GUIEditor/CGUIEditFactory.cpp
@@ -0,0 +1,120 @@
1#include "CGUIEditFactory.h"
2#include "IGUIEnvironment.h"
3#include "irrString.h"
4
5#include "EGUIEditTypes.h"
6
7#include "CGUIEditWorkspace.h"
8#include "CGUIEditWindow.h"
9#include "CGUIPanel.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"
18
19namespace irr
20{
21namespace gui
22{
23
24CGUIEditFactory::CGUIEditFactory(IGUIEnvironment* env)
25: Environment(env)
26{
27 #ifdef _DEBUG
28 setDebugName("CGUIEditFactory");
29 #endif
30
31 // don't grab the gui environment here to prevent cyclic references
32}
33
34
35CGUIEditFactory::~CGUIEditFactory()
36{
37}
38
39
40//! adds an element to the environment based on its type name
41IGUIElement* CGUIEditFactory::addGUIElement(const c8* typeName, IGUIElement* parent)
42{
43 /*
44 here we create elements, add them to the manager, and then drop them
45 */
46
47 core::stringc elementType(typeName);
48 IGUIElement* ret=0;
49 if (!parent)
50 parent = Environment->getRootGUIElement();
51
52 // editor workspace
53 if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIEDIT]))
54 ret = new CGUIEditWorkspace(Environment, -1, 0);
55 // editor window
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);
87
88 // add the element to its parent
89 if (ret)
90 parent->addChild(ret);
91
92 // the environment now has the reference, so we can drop the element
93 if (ret)
94 ret->drop();
95
96 return ret;
97}
98
99
100//! returns amount of element types this factory is able to create
101s32 CGUIEditFactory::getCreatableGUIElementTypeCount() const
102{
103 return EGUIEDIT_COUNT;
104}
105
106
107//! returns type name of a createable element type
108const c8* CGUIEditFactory::getCreateableGUIElementTypeName(s32 idx) const
109{
110 if (idx>=0 && idx<EGUIEDIT_COUNT)
111 return GUIEditElementTypeNames[idx];
112
113 return 0;
114}
115
116
117
118} // end namespace gui
119} // end namespace irr
120