Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2011
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.29 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include <sfml/System.hpp>
  4. #include <sfml/Graphics.hpp>
  5.  
  6. namespace gui {
  7.  
  8.     /* Useful primitive data typedefs */
  9.     typedef sf::Uint32 uint32;
  10.     typedef sf::Uint16 uint16;
  11.     typedef sf::Uint8   uint8;
  12.  
  13.     typedef sf::Int32   int32;
  14.     typedef sf::Int16   int16;
  15.     typedef sf::Int8     int8;
  16.  
  17.     enum WidgetType {
  18.         WIDGET,
  19.         BUTTON,
  20.         LABEL,
  21.         LINE_EDIT,
  22.         CHECKBOX,
  23.         RADIOBOX,
  24.         SLIDER,
  25.         WIDGETS_COUNT
  26.     };
  27.  
  28.     enum Events {
  29.         ON_CLICK_PRESSED,
  30.         ON_CLICK_RELEASED,
  31.         ON_MOUSE_MOVED,
  32.         ON_KEY_PRESSED,
  33.         ON_KEY_RELEASED,
  34.         ON_TEXT_ENTERED,
  35.         ON_OTHER_EVENTS,
  36.  
  37.         EVENTS_COUNT,
  38.  
  39.         /* Widget specific events, not sfml events */
  40.         ON_FOCUS
  41.     };
  42.  
  43.     enum Alignment {
  44.         Left    = 0x00000001,
  45.         Right   = 0x00000010,
  46.         Top     = 0x00000100,
  47.         Bottom  = 0x00001000,
  48.         CenterHorizontal = 0x00000011,  //Left | Right
  49.         CenterVertical   = 0x00001100//Top  | Down
  50.         Center  = 0x00001111,           //Top | Down | Left | Right
  51.         LeftBottom  = 0x00001001,       //Left | Bottom
  52.         RightBottom = 0x00001010,
  53.         LeftTop     = 0x00000101,
  54.         RightTop    = 0x00000110,
  55.         None = 0
  56.  
  57.     };
  58.    
  59.     /* A useful callback structure --
  60.      * inherit it if you want to use callbacks
  61.      */
  62.     struct Functor {
  63.         virtual void operator()();
  64.     };
  65.  
  66.  
  67.  
  68.     /* A simple and useful Rect class */
  69.     struct Rect {
  70.         Rect(int X=0, int Y=0,int W=0, int H=0);
  71.         Rect(const sf::Vector2i& pos, const sf::Vector2i& size);
  72.         Rect(const sf::Vector2f& pos, const sf::Vector2f& size);
  73.         Rect(const Rect& rect);
  74.         Rect(const sf::IntRect& rect);
  75.        
  76.         //overloaded operators
  77.         const Rect operator+(const Rect& other) const;
  78.         const Rect operator+(int panning) const;
  79.         const Rect operator-(const Rect& other) const;
  80.         const Rect operator-(int panning) const;
  81.         Rect& operator+=(const Rect& other);
  82.         Rect& operator+=(int panning);
  83.         Rect& operator-=(const Rect& other);
  84.         Rect& operator-=(int panning);
  85.         bool operator==(const Rect& other) const;
  86.         bool operator!=(const Rect& other) const;
  87.         Rect& operator=(const Rect& other);
  88.         bool operator!() const;
  89.  
  90.         //conversion operator with sf::IntRect
  91.         operator sf::IntRect() const;
  92.         int x,y,w,h;
  93.     };
  94.  
  95.     /* A classic rect-collision function */
  96.     bool IsCollision(const Rect& first, const Rect& second);
  97.  
  98.     std::string ToUpper(const std::string& text);
  99.  
  100. }
  101.  
  102. std::ostream& operator<<( std::ostream& os, gui::Rect& rect);
  103. std::stringstream& operator << (std::stringstream& ss, gui::Rect& rect);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement