okz::Widget -- Header


SUBMITTED BY: Guest

DATE: April 24, 2013, 11:31 p.m.

FORMAT: C++

SIZE: 2.4 kB

HITS: 1331

  1. //
  2. // Okzoniom::RPG
  3. // Copyright (C) 2010 - 2013
  4. //
  5. // - Louis SCHNELLBACH
  6. //
  7. #ifndef WIDGET_H_INCLUDED
  8. #define WIDGET_H_INCLUDED
  9. #include <SFML/Window/Mouse.hpp>
  10. #include <SFML/Window/Event.hpp>
  11. #include "Callback.h"
  12. #include "../Drawable.h"
  13. #include "../TexCoord.h"
  14. namespace okz
  15. {
  16. class UI;
  17. class Widget : public Drawable, public priv::Callback
  18. {
  19. friend class UI;
  20. public:
  21. static float Z_DECREMENT;
  22. Widget(const std::string& id, Widget* parent=NULL);
  23. virtual ~Widget();
  24. virtual void update(const sf::Event& event);
  25. virtual void call(const sf::Event& event);
  26. void setID(const std::string&);
  27. std::string getID() const;
  28. Widget* getParent();
  29. void addChild(Widget* w);
  30. void removeChild(Widget* w);
  31. Widget* getRootParent();
  32. virtual void visible(bool b);
  33. bool isVisible() const;
  34. virtual void focus(bool b);
  35. void focusable(bool);
  36. bool isFocused() const;
  37. bool isKeepingFocus() const;
  38. bool isFocusable() const;
  39. void movable(bool);
  40. bool isMovable() const;
  41. float setZ(float);
  42. virtual void setSize(const okz::fVertex&);
  43. virtual okz::fVertex getSize() const;
  44. virtual void setOffset(const okz::fVertex&);
  45. virtual okz::fVertex getOffset() const;
  46. virtual void setPosition(const okz::fVertex&);
  47. virtual okz::fVertex getPosition() const;
  48. virtual bool contains(float x, float y) const;
  49. virtual void initialize();
  50. virtual void render();
  51. virtual void createVBO();
  52. protected:
  53. std::string _id;
  54. std::string _type;
  55. //----------------------
  56. bool _visible;
  57. bool _focus;
  58. bool _keepFocus;
  59. bool _focusable;
  60. bool _movable;
  61. std::vector<Widget*> _child;
  62. Widget* _parent;
  63. okz::fVertex _offset;
  64. okz::fVertex _size;
  65. //Specific OpenGL texture attribute
  66. okz::VBOTemplate<okz::TexCoord> _texCoords;
  67. float _shaderTime;
  68. private:
  69. //Used by UI
  70. bool _destroyMe;
  71. void __propagateDestruction();
  72. };
  73. //Comparison functor
  74. struct pWidget_comp
  75. {
  76. bool operator() (const Widget*, const Widget*) const;
  77. };
  78. }
  79. #endif // WIDGET_H_INCLUDED

comments powered by Disqus