Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <sfml/System.hpp>
- #include <sfml/Graphics.hpp>
- namespace gui {
- /* Useful primitive data typedefs */
- typedef sf::Uint32 uint32;
- typedef sf::Uint16 uint16;
- typedef sf::Uint8 uint8;
- typedef sf::Int32 int32;
- typedef sf::Int16 int16;
- typedef sf::Int8 int8;
- enum WidgetType {
- WIDGET,
- BUTTON,
- LABEL,
- LINE_EDIT,
- CHECKBOX,
- RADIOBOX,
- SLIDER,
- WIDGETS_COUNT
- };
- enum Events {
- ON_CLICK_PRESSED,
- ON_CLICK_RELEASED,
- ON_MOUSE_MOVED,
- ON_KEY_PRESSED,
- ON_KEY_RELEASED,
- ON_TEXT_ENTERED,
- ON_OTHER_EVENTS,
- EVENTS_COUNT,
- /* Widget specific events, not sfml events */
- ON_FOCUS
- };
- enum Alignment {
- Left = 0x00000001,
- Right = 0x00000010,
- Top = 0x00000100,
- Bottom = 0x00001000,
- CenterHorizontal = 0x00000011, //Left | Right
- CenterVertical = 0x00001100, //Top | Down
- Center = 0x00001111, //Top | Down | Left | Right
- LeftBottom = 0x00001001, //Left | Bottom
- RightBottom = 0x00001010,
- LeftTop = 0x00000101,
- RightTop = 0x00000110,
- None = 0
- };
- /* A useful callback structure --
- * inherit it if you want to use callbacks
- */
- struct Functor {
- virtual void operator()();
- };
- /* A simple and useful Rect class */
- struct Rect {
- Rect(int X=0, int Y=0,int W=0, int H=0);
- Rect(const sf::Vector2i& pos, const sf::Vector2i& size);
- Rect(const sf::Vector2f& pos, const sf::Vector2f& size);
- Rect(const Rect& rect);
- Rect(const sf::IntRect& rect);
- //overloaded operators
- const Rect operator+(const Rect& other) const;
- const Rect operator+(int panning) const;
- const Rect operator-(const Rect& other) const;
- const Rect operator-(int panning) const;
- Rect& operator+=(const Rect& other);
- Rect& operator+=(int panning);
- Rect& operator-=(const Rect& other);
- Rect& operator-=(int panning);
- bool operator==(const Rect& other) const;
- bool operator!=(const Rect& other) const;
- Rect& operator=(const Rect& other);
- bool operator!() const;
- //conversion operator with sf::IntRect
- operator sf::IntRect() const;
- int x,y,w,h;
- };
- /* A classic rect-collision function */
- bool IsCollision(const Rect& first, const Rect& second);
- std::string ToUpper(const std::string& text);
- }
- std::ostream& operator<<( std::ostream& os, gui::Rect& rect);
- std::stringstream& operator << (std::stringstream& ss, gui::Rect& rect);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement