AWind
TextBoxString.h
1 /*
2  AWind.h - Arduino window library support for Color TFT LCD Boards
3  Copyright (C)2015 Andrei Degtiarev. All right reserved
4 
5 
6  You can always find the latest version of the library at
7  https://github.com/AndreiDegtiarev/AWind
8 
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the CC BY-NC-SA 3.0 license.
12  Please see the included documents for further information.
13 
14  Commercial use of this library requires you to buy a license that
15  will allow commercial use. This includes using the library,
16  modified or not, as a tool to sell products.
17 
18  The license applies to all part of the library including the
19  examples and tools supplied with the library.
20 */
21 #pragma once
22 
23 #include "TextBox.h"
25 template <class T> class TextBoxTString : public TextBox
26 {
27  const T * _text;
28 public:
30 
37  TextBoxTString(int left,int top,int width,int height,T *text):TextBox(left,top,width,height)
38  {
39  _text=text;
40  //_type=F("TextBoxString");
41  }
43 
51  TextBoxTString(int left,int top,int width,int height,T *text,const __FlashStringHelper *decorators):TextBox(left,top,width,height)
52  {
53  _text=text;
54  SetDecorators(Environment::Get()->FindDecorators(decorators));
55  //_type=F("TextBoxString");
56  }
58  virtual void OnDraw(DC *dc)
59  {
60  TextBox::OnDraw(dc);
61  dc->DrawText(_text,_offset_x,_offset_y);
62  }
64  void SetText(T *text)
65  {
66  _text=text;
67  if(_changedEvent!=NULL)
68  _changedEvent->NotifyContentChanged(this);
69  Invalidate();
70  }
71 };
void DrawText(const __FlashStringHelper *text, int x, int y)
Draws PROGMEM string. Input coordinates have to be defined in the window coordinate system...
Definition: DC.h:177
void SetText(T *text)
Initialize window with text.
Definition: TextBoxString.h:64
virtual void OnDraw(DC *dc)
Implements drawing code.
Definition: TextBoxString.h:58
Base class for window with text content.
Definition: TextBox.h:30
Text box for string. It is templat class and can be used for differnt type of string (see bellow type...
Definition: TextBoxString.h:25
static Environment * Get()
Returns singltone instance of environment.
Definition: Environment.h:44
TextBoxTString(int left, int top, int width, int height, T *text)
Constructor.
Definition: TextBoxString.h:37
Device context. Abstraction layer to the device specific drawing code. Coordinates in drawing functio...
Definition: DC.h:29
void Invalidate()
If function is called than the window manager updates the window.
Definition: Window.h:157
void OnDraw(DC *dc)
Implements drawing code.
Definition: TextBox.h:69
virtual void NotifyContentChanged(Window *window)=0
Has to be implemented in target class.
virtual void SetDecorators(DecoratorList *decorators)
Sets window decorators list.
Definition: Window.h:76
TextBoxTString(int left, int top, int width, int height, T *text, const __FlashStringHelper *decorators)
Constructor.
Definition: TextBoxString.h:51