diff options
Diffstat (limited to 'libraries/irrlicht-1.8/tools/GUIEditor/CGUIStringAttribute.h')
-rw-r--r-- | libraries/irrlicht-1.8/tools/GUIEditor/CGUIStringAttribute.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIStringAttribute.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIStringAttribute.h new file mode 100644 index 0000000..af9ac03 --- /dev/null +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIStringAttribute.h | |||
@@ -0,0 +1,70 @@ | |||
1 | #ifndef __C_GUI_STRING_ATTRIBUTE_H_INCLUDED__ | ||
2 | #define __C_GUI_STRING_ATTRIBUTE_H_INCLUDED__ | ||
3 | |||
4 | #include "CGUIAttribute.h" | ||
5 | #include "IGUIEditBox.h" | ||
6 | #include "EGUIEditTypes.h" | ||
7 | |||
8 | namespace irr | ||
9 | { | ||
10 | namespace gui | ||
11 | { | ||
12 | |||
13 | class CGUIStringAttribute : public CGUIAttribute | ||
14 | { | ||
15 | public: | ||
16 | // | ||
17 | CGUIStringAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : | ||
18 | CGUIAttribute(environment, parent, myParentID), | ||
19 | AttribEditBox(0) | ||
20 | { | ||
21 | core::rect<s32> r = getAbsolutePosition(); | ||
22 | core::rect<s32> r2(0, Environment->getSkin()->getFont()->getDimension(L"A").Height + 10, | ||
23 | r.getWidth() - 5, | ||
24 | Environment->getSkin()->getFont()->getDimension(L"A").Height*2 + 15 ); | ||
25 | |||
26 | AttribEditBox = environment->addEditBox(0, r2, true, this, -1); | ||
27 | AttribEditBox->grab(); | ||
28 | AttribEditBox->setSubElement(true); | ||
29 | AttribEditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); | ||
30 | |||
31 | } | ||
32 | |||
33 | virtual ~CGUIStringAttribute() | ||
34 | { | ||
35 | if (AttribEditBox) | ||
36 | AttribEditBox->drop(); | ||
37 | } | ||
38 | |||
39 | virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) | ||
40 | { | ||
41 | AttribEditBox->setText(attribs->getAttributeAsStringW(attribIndex).c_str()); | ||
42 | CGUIAttribute::setAttrib(attribs, attribIndex); | ||
43 | } | ||
44 | |||
45 | //! save the attribute and possibly post the event to its parent | ||
46 | virtual bool updateAttrib(bool sendEvent=true) | ||
47 | { | ||
48 | if (!Attribs) | ||
49 | return true; | ||
50 | |||
51 | Attribs->setAttribute(Index, AttribEditBox->getText()); | ||
52 | AttribEditBox->setText(Attribs->getAttributeAsStringW(Index).c_str()); | ||
53 | |||
54 | return CGUIAttribute::updateAttrib(sendEvent); | ||
55 | } | ||
56 | |||
57 | //! Returns the type name of the gui element. | ||
58 | virtual const c8* getTypeName() const | ||
59 | { | ||
60 | return GUIEditElementTypeNames[EGUIEDIT_STRINGATTRIBUTE]; | ||
61 | } | ||
62 | |||
63 | private: | ||
64 | IGUIEditBox* AttribEditBox; | ||
65 | }; | ||
66 | |||
67 | } // namespace gui | ||
68 | } // namespace irr | ||
69 | |||
70 | #endif | ||