Game Development Reference
In-Depth Information
Now let's take a look at the implementation of the TextBlock class:
class TextBlock :
public ControlBase
{
private:
std::wstring _text;
std::shared_ptr<SpriteFont> _font;
DirectX::XMVECTOR _color, _focusCol;
std::function<void (TextBlock*)>
_clickHandler;
public:
TextBlock(std::wstring fontPath);
~TextBlock(void);
void SetText(std::wstring &text) { _text =
text; };
std::wstring& GetText() { return _text; };
virtual void
Draw(std::shared_ptr<SpriteBatch> sb,
FocusState focused);
virtual void HandleClick();
virtual bool PointInBounds(float x, float y);
void MeasureString(std::wstring &str, int
*width, int *height);
void MeasureString(int *width, int *height);
void SetColor(DirectX::FXMVECTOR color) {
_color = color; };
void SetFocusColor(DirectX::FXMVECTOR color)
{ _focusCol = color; };
void SetClickHandler(std::function<void
(TextBlock*)> func) { _clickHandler = func; };
Search WWH ::




Custom Search