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.

42 lines
1.2 KiB

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