Archon

ScreenElement.h

Jan 4th, 2011
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.85 KB | None | 0 0
  1. // (C) 2010 Tim Gurto
  2.  
  3. #ifndef SCREEN_ELEMENT_H
  4. #define SCREEN_ELEMENT_H
  5.  
  6. #include <vector>
  7. #include <string>
  8. #include "Point.h"
  9. #include "Surface.h"
  10.  
  11. enum Anchor{
  12.    ANCHOR_TOP,
  13.    ANCHOR_BOTTOM,
  14.    ANCHOR_LEFT,
  15.    ANCHOR_RIGHT,
  16.    ANCHOR_TOP_RIGHT,
  17.    ANCHOR_BOTTOM_RIGHT,
  18.    ANCHOR_BOTTOM_LEFT,
  19.    ANCHOR_TOP_LEFT,
  20.    ANCHOR_CENTER
  21. };
  22.  
  23. enum ScreenElementType{
  24.    ELEM_LABEL,
  25.    ELEM_BUTTON //can be clicked to return its id_
  26. };
  27.  
  28. class ScreenElement;
  29. typedef std::vector<ScreenElement> elements_t;
  30.  
  31. class ScreenElement{
  32.    friend class Screen;
  33.  
  34.    //The identifier to return if this element is activated
  35.    //(eg. a button click)
  36.    int id_;
  37.  
  38.    //location of the element
  39.    Point loc_;
  40.  
  41.    //whether the element has the mouse over it
  42.    bool rollover_;
  43.    
  44.    //the element's type (button, label, etc.)
  45.    ScreenElementType type_;
  46.  
  47.    //element's complete images
  48.    Surface image_, altImage_;
  49.  
  50.    //the text that appears on the element
  51.    std::string text_;
  52.  
  53.    static SDL_Color defaultLabelColor_;
  54.    static SDL_Color defaultButtonColor_;
  55.    static SDL_Color defaultButtonAltColor_; //rollover
  56.    static int defaultFontSize_;
  57.    static std::string defaultFontName_;
  58.  
  59. public:
  60.    static const int NO_ID;
  61.  
  62.    ScreenElement(ScreenElementType type,
  63.                  std::string text = "",
  64.  
  65.                  //which corner the element is anchored to
  66.                  Anchor anchor = ANCHOR_CENTER,
  67.                  //offset from the anchor
  68.                  Point offset = Point(),
  69.  
  70.                  int id = NO_ID,
  71.                  Point dim = Point(0, 0),
  72.                  const Surface *background = 0,
  73.                  int fontSize = defaultFontSize_,
  74.                  SDL_Color fontColor = NO_COLOR, //use default for type
  75.                  std::string fontName = defaultFontName_);
  76.  
  77.    void draw() const;
  78. };
  79.  
  80. #endif
Add Comment
Please, Sign In to add comment