diff options
| author | Mirrorbot <mirrorbot@cogarr.net> | 2025-12-27 17:53:06 -0600 |
|---|---|---|
| committer | Mirrorbot <mirrorbot@cogarr.net> | 2025-12-27 17:53:06 -0600 |
| commit | 71e94ee161447b84c0eaabf6567f8fa62262cd3e (patch) | |
| tree | 391064cc6173a6fe75069af2fdc1978af12f623e /tools/GUIEditor/CGUIBoolAttribute.h | |
| download | irrlicht-master.tar.gz irrlicht-master.tar.bz2 irrlicht-master.zip | |
Diffstat (limited to 'tools/GUIEditor/CGUIBoolAttribute.h')
| -rw-r--r-- | tools/GUIEditor/CGUIBoolAttribute.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tools/GUIEditor/CGUIBoolAttribute.h b/tools/GUIEditor/CGUIBoolAttribute.h new file mode 100644 index 0000000..b0521db --- /dev/null +++ b/tools/GUIEditor/CGUIBoolAttribute.h @@ -0,0 +1,68 @@ +#ifndef __C_GUI_BOOL_ATTRIBUTE_H_INCLUDED__
+#define __C_GUI_BOOL_ATTRIBUTE_H_INCLUDED__
+
+#include "CGUIAttribute.h"
+#include "IGUICheckBox.h"
+#include "EGUIEditTypes.h"
+
+namespace irr
+{
+namespace gui
+{
+
+ class CGUIBoolAttribute : public CGUIAttribute
+ {
+ public:
+ //
+ CGUIBoolAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) :
+ CGUIAttribute(environment, parent, myParentID), AttribCheckBox(0)
+ {
+
+ core::rect<s32> r = getAbsolutePosition();
+ core::rect<s32> r2(0, Environment->getSkin()->getFont()->getDimension(L"A").Height + 10,
+ r.getWidth() - 5,
+ Environment->getSkin()->getFont()->getDimension(L"A").Height*2 + 15 );
+
+ AttribCheckBox = environment->addCheckBox(false, r2, this);
+ AttribCheckBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
+ AttribCheckBox->setSubElement(true);
+ AttribCheckBox->grab();
+ }
+
+ virtual ~CGUIBoolAttribute()
+ {
+ if (AttribCheckBox)
+ AttribCheckBox->drop();
+ }
+
+ virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex)
+ {
+ AttribCheckBox->setChecked(attribs->getAttributeAsBool(attribIndex));
+ CGUIAttribute::setAttrib(attribs, attribIndex);
+ }
+
+ // save the attribute and possibly post the event to its parent
+ virtual bool updateAttrib(bool sendEvent=true)
+ {
+ if (!Attribs)
+ return true;
+
+ Attribs->setAttribute(Index, AttribCheckBox->isChecked());
+
+ return CGUIAttribute::updateAttrib(sendEvent);
+ }
+
+ //! Returns the type name of the gui element.
+ virtual const c8* getTypeName() const
+ {
+ return GUIEditElementTypeNames[EGUIEDIT_BOOLATTRIBUTE];
+ }
+
+ private:
+ IGUICheckBox* AttribCheckBox;
+ };
+
+} // namespace gui
+} // namespace irr
+
+#endif
|
