You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __SDL_CORE_LABEL_HEADERS__
  2. #define __SDL_CORE_LABEL_HEADERS__
  3. #include <vector>
  4. #include "../../components/base/basicMutex.h"
  5. #include "../gui_sdl.h"
  6. #include "coreWidget.h"
  7. #define SDL_DEFAULT_TEXT_SIZE 256
  8. #define SDL_DEFAULT_FONT_SIZE 12
  9. typedef enum E_TEXT_ALIGN{
  10. ALIGN_LEFT = 0,
  11. ALIGN_CENTER = 1,
  12. ALIGN_RIGHT
  13. } TEXT_ALIGN;
  14. class sdlLabel :public sdlCoreWidget{
  15. private:
  16. char m_pText[SDL_DEFAULT_TEXT_SIZE];
  17. TTF_Font * m_pFont;
  18. SDL_Texture * m_pFontTexture;
  19. SDL_Color m_sColor;
  20. int m_nMargin;
  21. int m_nLabelWidth;
  22. int m_nLabelHeight;
  23. sdlColorStyle m_sColorStyle;
  24. TEXT_ALIGN m_bTextAlign;
  25. protected:
  26. virtual void drawBefore(SDL_Renderer *pRenderer);
  27. public:
  28. explicit sdlLabel(CSTR text, int x, int y, int w, int h, sdlCoreWidget *wPtr=NULL, int fsize = SDL_DEFAULT_FONT_SIZE, CSTR fontName = NULL);
  29. virtual ~sdlLabel();
  30. void setText( CSTR pStr );
  31. void setFont( TTF_Font *tPtr );
  32. void setColor( SDL_Color *tC );
  33. void setColor(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha = 255 );
  34. void setBlendMode(SDL_BlendMode blending );
  35. void setAlpha( uint8_t alpha );
  36. void setAlign(TEXT_ALIGN tA){ m_bTextAlign = tA; };
  37. CSTR getText(void){ return m_pText; };
  38. };
  39. typedef std::vector<sdlLabel*> vectorLabels;
  40. #endif