Files
openglplayground/TextWidget.hh
2015-03-10 00:48:25 +01:00

39 lines
846 B
C++

#ifndef __OPENGLPLAYGROUND_TEXTWIDGET_HH__
#define __OPENGLPLAYGROUND_TEXTWIDGET_HH__
#include <string>
#include "common.hh"
#include "Widget.hh"
class Font;
class TextWidget final : public Widget {
public:
TextWidget(TTF_Font *font, std::string text = "",
int width = WRAP_CONTENT, int height = WRAP_CONTENT,
std::string name = "");
TextWidget(TextWidget const& copy) = delete;
TextWidget& operator=(TextWidget const& copy) = delete;
~TextWidget();
void setText(std::string text);
std::string const& getText() const { return text_; }
void setForegroundColor(SDL_Color fg) override;
void render(SDL_Surface *dst, SDL_Rect *dstRect) const override;
protected:
void layout(Widget* caller = nullptr) override;
private:
std::string text_;
TTF_Font *font_;
SDLSurfaceUPtr textSurf_;
};
#endif