BsGUIToggleField.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "BsGUIToggleField.h"
  2. #include "BsGUIArea.h"
  3. #include "BsGUILayout.h"
  4. #include "BsGUILabel.h"
  5. #include "BsGUIToggle.h"
  6. #include "BsBuiltinResources.h"
  7. #include "BsGUIWidget.h"
  8. #include "BsGUIMouseEvent.h"
  9. #include "BsGUIWidget.h"
  10. namespace BansheeEngine
  11. {
  12. GUIToggleField::GUIToggleField(const PrivatelyConstruct& dummy, const GUIContent& labelContent,
  13. UINT32 labelWidth, const String& labelStyle, const String& toggleStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
  14. :TGUIField(dummy, labelContent, labelWidth, labelStyle, layoutOptions, withLabel), mToggle(nullptr)
  15. {
  16. mToggle = GUIToggle::create(HString(L""), toggleStyle);
  17. mLayout->addElement(mToggle);
  18. }
  19. bool GUIToggleField::getValue() const
  20. {
  21. return mToggle->isToggled();
  22. }
  23. void GUIToggleField::setValue(bool value)
  24. {
  25. if(value)
  26. mToggle->toggleOn();
  27. else
  28. mToggle->toggleOff();
  29. }
  30. const String& GUIToggleField::getGUITypeName()
  31. {
  32. static String typeName = "GUIToggleField";
  33. return typeName;
  34. }
  35. }