AWind
TextExampleWindow.h
1 /*
2  AWind.h - Arduino window library support for Color TFT LCD Boards
3  Copyright (C)2014 Andrei Degtiarev. All right reserved
4 
5  You can find the latest version of the library at
6  https://github.com/AndreiDegtiarev/AWind
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the CC BY-NC-SA 3.0 license.
10  Please see the included documents for further information.
11 
12  Commercial use of this library requires you to buy a license that
13  will allow commercial use. This includes using the library,
14  modified or not, as a tool to sell products.
15 
16  The license applies to all part of the library including the
17  examples and tools supplied with the library.
18 */
19 #pragma once
20 
21 #include "TextBoxString.h"
22 #include "TextBoxNumber.h"
23 #include "DecoratorPrimitives.h"
24 
26 {
27  TextBoxNumber *_textNumber;
28 public:
29  TextExampleWindow(int width,int height):MainWindow(width,height)
30  {
31  AddDecorator(new DecoratorRectFill(Color::Black));
32  AddDecorator(new DecoratorColor(Color::SkyBlue));
33  int x=0;
34  int y=40;
35  TextBoxFString *label=new TextBoxFString(x,y,width/2,25,F("This is label: "));
36  label->SetFont(BigFont);
37  x=width*3.0/4;
38  _textNumber=new TextBoxNumber(x,y,width-x,25,0);
39  _textNumber->SetDecorators(GetDecorators()); // here we save one decorator beacuse main window and text window have thae same decorator properties: black background
40  _textNumber->SetFont(BigFont);
41  _textNumber->SetMargins(20,2);
42  _textNumber->SetNumber(4);
43  _textNumber->SetIsReadOnly(false);
44 
45  AddChild(label);
46  AddChild(_textNumber);
47  }
48  void Create()
49  {
50  }
51  void Notify(Window * wnd)
52  {
53  if(wnd == _textNumber)
54  {
55  out<<F("Value changed")<<((TextBoxNumber *)_textNumber)->GetNumber()<<endln;
56  }
57  }
58 };
DecoratorList * GetDecorators()
Returns window decorators list.
Definition: Window.h:81
Base class for all window objects. Provides basic window functionality.
Definition: Window.h:34
void SetFont(uint8_t *font)
Sets font.
Definition: TextBox.h:64
void SetIsReadOnly(bool isReadOnly)
Defines whether window is readonly.
Definition: TextBoxNumber.h:64
Text box for numbers.
Definition: TextBoxNumber.h:24
Decorator primitive that sets current color. Overriden members description see Decorator class docume...
Definition: DecoratorPrimitives.h:24
Definition: TextExampleWindow.h:25
Decorator primitive for round rect filled area. Overriden members description see Decorator class doc...
Definition: DecoratorPrimitives.h:79
void AddChild(Window *window)
Adds window child window.
Definition: Window.h:194
void SetNumber(float number)
Initialize window with number.
Definition: TextBoxNumber.h:74
void AddDecorator(Decorator *decorator)
Adds decorator to the decaorator list.
Definition: Window.h:86
MainWindow(int width, int height)
Constructor.
Definition: MainWindow.h:52
virtual void SetDecorators(DecoratorList *decorators)
Sets window decorators list.
Definition: Window.h:76
Base class for main application window. Each application has to have one main window, which is root parent for all other application windows.
Definition: MainWindow.h:38
void SetMargins(int offset_x, int offset_y)
Defines offset from left and top for text.
Definition: TextBox.h:58