aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttribute.h
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 18:54:10 +1000
committerDavid Walter Seikel2013-01-13 18:54:10 +1000
commit959831f4ef5a3e797f576c3de08cd65032c997ad (patch)
treee7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttribute.h
parentAdd info about changes to Irrlicht. (diff)
downloadSledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to '')
-rw-r--r--libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttribute.h338
1 files changed, 169 insertions, 169 deletions
diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttribute.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttribute.h
index 0585498..1f2b092 100644
--- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttribute.h
+++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttribute.h
@@ -1,169 +1,169 @@
1/* 1/*
2 This base class is used by the Attribute editor for making your own attribute types. 2 This base class is used by the Attribute editor for making your own attribute types.
3 3
4 The attribute editor will try and create an attribute called "AttribType_attribute", 4 The attribute editor will try and create an attribute called "AttribType_attribute",
5 and if it fails, it will create a "string_attribute". 5 and if it fails, it will create a "string_attribute".
6 6
7*/ 7*/
8 8
9#ifndef __C_GUI_ATTRIBUTE_H_INCLUDED__ 9#ifndef __C_GUI_ATTRIBUTE_H_INCLUDED__
10#define __C_GUI_ATTRIBUTE_H_INCLUDED__ 10#define __C_GUI_ATTRIBUTE_H_INCLUDED__
11 11
12#include "IGUIElement.h" 12#include "IGUIElement.h"
13#include "IGUIEnvironment.h" 13#include "IGUIEnvironment.h"
14#include "IGUIFont.h" 14#include "IGUIFont.h"
15#include "IGUIStaticText.h" 15#include "IGUIStaticText.h"
16#include "IAttributes.h" 16#include "IAttributes.h"
17#include "CGUIEditWorkspace.h" 17#include "CGUIEditWorkspace.h"
18 18
19namespace irr 19namespace irr
20{ 20{
21 21
22namespace gui 22namespace gui
23{ 23{
24 24
25 const u32 ATTRIBEDIT_ATTRIB_CHANGED=MAKE_IRR_ID('A','T','T','R'); 25 const u32 ATTRIBEDIT_ATTRIB_CHANGED=MAKE_IRR_ID('A','T','T','R');
26 26
27 class CGUIAttribute : public IGUIElement 27 class CGUIAttribute : public IGUIElement
28 { 28 {
29 public: 29 public:
30 //! constructor 30 //! constructor
31 CGUIAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : 31 CGUIAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) :
32 IGUIElement(EGUIET_ELEMENT, environment, parent, -1, core::rect<s32>(0, 0, 100, 100) ), 32 IGUIElement(EGUIET_ELEMENT, environment, parent, -1, core::rect<s32>(0, 0, 100, 100) ),
33 AttribName(0), Attribs(0), Index(0), MyParentID(myParentID) 33 AttribName(0), Attribs(0), Index(0), MyParentID(myParentID)
34 { 34 {
35 35
36 #ifdef _DEBUG 36 #ifdef _DEBUG
37 setDebugName("CGUIAttribute"); 37 setDebugName("CGUIAttribute");
38 #endif 38 #endif
39 39
40 AttribName = environment->addStaticText(0, 40 AttribName = environment->addStaticText(0,
41 core::rect<s32>(0, 0, 41 core::rect<s32>(0, 0,
42 100, Environment->getSkin()->getFont()->getDimension(L"A").Height), 42 100, Environment->getSkin()->getFont()->getDimension(L"A").Height),
43 false, false, this, -1, false); 43 false, false, this, -1, false);
44 AttribName->grab(); 44 AttribName->grab();
45 AttribName->setSubElement(true); 45 AttribName->setSubElement(true);
46 AttribName->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); 46 AttribName->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
47 } 47 }
48 48
49 virtual ~CGUIAttribute() 49 virtual ~CGUIAttribute()
50 { 50 {
51 if (Attribs) 51 if (Attribs)
52 Attribs->drop(); 52 Attribs->drop();
53 if (AttribName) 53 if (AttribName)
54 AttribName->drop(); 54 AttribName->drop();
55 } 55 }
56 56
57 virtual bool OnEvent(const SEvent &e) 57 virtual bool OnEvent(const SEvent &e)
58 { 58 {
59 if (IsEnabled) 59 if (IsEnabled)
60 { 60 {
61 switch (e.EventType) 61 switch (e.EventType)
62 { 62 {
63 case EET_GUI_EVENT: 63 case EET_GUI_EVENT:
64 switch (e.GUIEvent.EventType) 64 switch (e.GUIEvent.EventType)
65 { 65 {
66 case EGET_ELEMENT_FOCUSED: 66 case EGET_ELEMENT_FOCUSED:
67 if (Parent && isMyChild(e.GUIEvent.Caller)) 67 if (Parent && isMyChild(e.GUIEvent.Caller))
68 Parent->bringToFront(this); 68 Parent->bringToFront(this);
69 break; 69 break;
70 case EGET_ELEMENT_HOVERED: 70 case EGET_ELEMENT_HOVERED:
71 case EGET_ELEMENT_LEFT: 71 case EGET_ELEMENT_LEFT:
72 return IGUIElement::OnEvent(e); 72 return IGUIElement::OnEvent(e);
73 case EGET_ELEMENT_FOCUS_LOST: 73 case EGET_ELEMENT_FOCUS_LOST:
74 updateAttrib(); 74 updateAttrib();
75 return IGUIElement::OnEvent(e); 75 return IGUIElement::OnEvent(e);
76 default: 76 default:
77 return updateAttrib(); 77 return updateAttrib();
78 } 78 }
79 break; 79 break;
80 case EET_KEY_INPUT_EVENT: 80 case EET_KEY_INPUT_EVENT:
81 return true; 81 return true;
82 default: 82 default:
83 break; 83 break;
84 } 84 }
85 } 85 }
86 86
87 return IGUIElement::OnEvent(e); 87 return IGUIElement::OnEvent(e);
88 } 88 }
89 89
90 //! sets the attribute to use 90 //! sets the attribute to use
91 virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) 91 virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex)
92 { 92 {
93 if (Attribs) 93 if (Attribs)
94 Attribs->drop(); 94 Attribs->drop();
95 Attribs = attribs; 95 Attribs = attribs;
96 if (Attribs) 96 if (Attribs)
97 Attribs->grab(); 97 Attribs->grab();
98 Index = attribIndex; 98 Index = attribIndex;
99 99
100 core::stringw name(attribs->getAttributeName(attribIndex)); 100 core::stringw name(attribs->getAttributeName(attribIndex));
101 name += L" ("; 101 name += L" (";
102 name += attribs->getAttributeTypeString(attribIndex); 102 name += attribs->getAttributeTypeString(attribIndex);
103 name += L")"; 103 name += L")";
104 AttribName->setText(name.c_str()); 104 AttribName->setText(name.c_str());
105 105
106 core::rect<s32> r = Parent->getAbsolutePosition(); 106 core::rect<s32> r = Parent->getAbsolutePosition();
107 core::rect<s32> r2(0, 5, 107 core::rect<s32> r2(0, 5,
108 r.getWidth(), Environment->getSkin()->getFont()->getDimension(L"A").Height + 10 ); 108 r.getWidth(), Environment->getSkin()->getFont()->getDimension(L"A").Height + 10 );
109 109
110 AttribName->setRelativePosition(r2); 110 AttribName->setRelativePosition(r2);
111 111
112 // get minimum height 112 // get minimum height
113 s32 y=0; 113 s32 y=0;
114 core::list<IGUIElement*>::Iterator it = Children.begin(); 114 core::list<IGUIElement*>::Iterator it = Children.begin();
115 for (; it != Children.end(); ++it) 115 for (; it != Children.end(); ++it)
116 { 116 {
117 if (y < (*it)->getRelativePosition().LowerRightCorner.Y) 117 if (y < (*it)->getRelativePosition().LowerRightCorner.Y)
118 y = (*it)->getRelativePosition().LowerRightCorner.Y; 118 y = (*it)->getRelativePosition().LowerRightCorner.Y;
119 } 119 }
120 setMinSize( core::dimension2du(0, y+5)); 120 setMinSize( core::dimension2du(0, y+5));
121 121
122 updateAttrib(false); 122 updateAttrib(false);
123 } 123 }
124 124
125 //! sets the parent ID, for identifying where events came from 125 //! sets the parent ID, for identifying where events came from
126 void setParentID(s32 parentID) 126 void setParentID(s32 parentID)
127 { 127 {
128 MyParentID = parentID; 128 MyParentID = parentID;
129 } 129 }
130 130
131 //! save the attribute and possibly post the event to its parent 131 //! save the attribute and possibly post the event to its parent
132 virtual bool updateAttrib(bool sendEvent=true) 132 virtual bool updateAttrib(bool sendEvent=true)
133 { 133 {
134 if (Attribs && IsEnabled && sendEvent) 134 if (Attribs && IsEnabled && sendEvent)
135 { 135 {
136 // build event and pass to parent 136 // build event and pass to parent
137 SEvent event; 137 SEvent event;
138 event.EventType = (EEVENT_TYPE)ATTRIBEDIT_ATTRIB_CHANGED; 138 event.EventType = (EEVENT_TYPE)ATTRIBEDIT_ATTRIB_CHANGED;
139 event.UserEvent.UserData1 = MyParentID; 139 event.UserEvent.UserData1 = MyParentID;
140 event.UserEvent.UserData2 = Index; 140 event.UserEvent.UserData2 = Index;
141 return Parent->OnEvent(event); 141 return Parent->OnEvent(event);
142 } 142 }
143 143
144 return true; 144 return true;
145 } 145 }
146 146
147 virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) 147 virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0)
148 { 148 {
149 IGUIElement::serializeAttributes(out, options); 149 IGUIElement::serializeAttributes(out, options);
150 } 150 }
151 151
152 virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) 152 virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
153 { 153 {
154 IGUIElement::deserializeAttributes(in, options); 154 IGUIElement::deserializeAttributes(in, options);
155 if (AttribName) 155 if (AttribName)
156 AttribName->setText(Text.c_str()); 156 AttribName->setText(Text.c_str());
157 } 157 }
158 158
159 protected: 159 protected:
160 IGUIStaticText* AttribName; 160 IGUIStaticText* AttribName;
161 io::IAttributes* Attribs; 161 io::IAttributes* Attribs;
162 u32 Index; 162 u32 Index;
163 s32 MyParentID; 163 s32 MyParentID;
164 }; 164 };
165 165
166} // namespace gui 166} // namespace gui
167} // namespace irr 167} // namespace irr
168 168
169#endif 169#endif