aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/tools/GUIEditor/CGUIBoolAttribute.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/tools/GUIEditor/CGUIBoolAttribute.h')
-rw-r--r--src/others/irrlicht-1.8.1/tools/GUIEditor/CGUIBoolAttribute.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/tools/GUIEditor/CGUIBoolAttribute.h b/src/others/irrlicht-1.8.1/tools/GUIEditor/CGUIBoolAttribute.h
new file mode 100644
index 0000000..b0521db
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/tools/GUIEditor/CGUIBoolAttribute.h
@@ -0,0 +1,68 @@
1#ifndef __C_GUI_BOOL_ATTRIBUTE_H_INCLUDED__
2#define __C_GUI_BOOL_ATTRIBUTE_H_INCLUDED__
3
4#include "CGUIAttribute.h"
5#include "IGUICheckBox.h"
6#include "EGUIEditTypes.h"
7
8namespace irr
9{
10namespace gui
11{
12
13 class CGUIBoolAttribute : public CGUIAttribute
14 {
15 public:
16 //
17 CGUIBoolAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) :
18 CGUIAttribute(environment, parent, myParentID), AttribCheckBox(0)
19 {
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 AttribCheckBox = environment->addCheckBox(false, r2, this);
27 AttribCheckBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
28 AttribCheckBox->setSubElement(true);
29 AttribCheckBox->grab();
30 }
31
32 virtual ~CGUIBoolAttribute()
33 {
34 if (AttribCheckBox)
35 AttribCheckBox->drop();
36 }
37
38 virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex)
39 {
40 AttribCheckBox->setChecked(attribs->getAttributeAsBool(attribIndex));
41 CGUIAttribute::setAttrib(attribs, attribIndex);
42 }
43
44 // save the attribute and possibly post the event to its parent
45 virtual bool updateAttrib(bool sendEvent=true)
46 {
47 if (!Attribs)
48 return true;
49
50 Attribs->setAttribute(Index, AttribCheckBox->isChecked());
51
52 return CGUIAttribute::updateAttrib(sendEvent);
53 }
54
55 //! Returns the type name of the gui element.
56 virtual const c8* getTypeName() const
57 {
58 return GUIEditElementTypeNames[EGUIEDIT_BOOLATTRIBUTE];
59 }
60
61 private:
62 IGUICheckBox* AttribCheckBox;
63 };
64
65} // namespace gui
66} // namespace irr
67
68#endif