CGUIDummyEditorStub.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. This is a custom editor for stubbing problematic elements out,
  3. for example elements which include modal screens
  4. */
  5. #ifndef __C_GUI_DUMMY_EDITOR_STUB_H_INCLUDED__
  6. #define __C_GUI_DUMMY_EDITOR_STUB_H_INCLUDED__
  7. #include "IGUIElement.h"
  8. #include "IGUIEnvironment.h"
  9. #include "IGUIStaticText.h"
  10. namespace irr
  11. {
  12. namespace gui
  13. {
  14. class CGUIDummyEditorStub : public IGUIElement
  15. {
  16. public:
  17. //! constructor
  18. CGUIDummyEditorStub(IGUIEnvironment* environment, IGUIElement *parent, const char *text) :
  19. IGUIElement(EGUIET_ELEMENT, environment, parent, -1, core::rect<s32>(0, 0, 100, 100) ),
  20. TextBox(0), TypeName(text)
  21. {
  22. #ifdef _DEBUG
  23. setDebugName("CGUIDummyEditorStub");
  24. #endif
  25. core::dimension2du d = Environment->getSkin()->getFont()->getDimension(L"A");
  26. s32 h = d.Height / 2;
  27. s32 w = d.Width / 2;
  28. TextBox = environment->addStaticText(core::stringw(text).c_str(),
  29. core::rect<s32>(50-w, 50-h, 50+w, 50+h),
  30. false, false, this, -1, false);
  31. TextBox->grab();
  32. TextBox->setSubElement(true);
  33. TextBox->setAlignment(EGUIA_CENTER, EGUIA_CENTER, EGUIA_CENTER, EGUIA_CENTER);
  34. }
  35. virtual ~CGUIDummyEditorStub()
  36. {
  37. if (TextBox)
  38. TextBox->drop();
  39. }
  40. virtual const c8* getTypeName() const { return TypeName.c_str(); }
  41. protected:
  42. IGUIStaticText* TextBox;
  43. core::stringc TypeName;
  44. };
  45. } // namespace gui
  46. } // namespace irr
  47. #endif