AWind
TextBox.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 #include "Window.h"
23 #include "IContentChangedEventReceiver.h"
24 
25 extern uint8_t BigFont[];
26 extern uint8_t SmallFont[];
27 
28 
30 class TextBox : public Window
31 {
32  uint8_t *_font;
33 protected:
34  int _offset_x;
35  int _offset_y;
36  IContentChangedEventReceiver *_changedEvent;
37 public:
39 
45  TextBox(int left,int top,int width,int height):Window(F("text"),left,top,width,height)
46  {
47  _font = SmallFont;
48  _offset_x=0;
49  _offset_y=0;
50  _changedEvent=NULL;
51  }
54  {
55  _changedEvent=event;
56  }
58  void SetMargins(int offset_x,int offset_y)
59  {
60  _offset_x=offset_x;
61  _offset_y=offset_y;
62  }
64  void SetFont(uint8_t *font)
65  {
66  _font = font;
67  }
69  void OnDraw(DC *dc)
70  {
71  dc->SetFont(_font);
72  }
73 };
74 
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
Base class for window with text content.
Definition: TextBox.h:30
Interface that provides content change notifications (like text is changed in text box) from child wi...
Definition: IContentChangedEventReceiver.h:24
Device context. Abstraction layer to the device specific drawing code. Coordinates in drawing functio...
Definition: DC.h:29
void OnDraw(DC *dc)
Implements drawing code.
Definition: TextBox.h:69
TextBox(int left, int top, int width, int height)
Constructor.
Definition: TextBox.h:45
void RegisterContentChangedReceiver(IContentChangedEventReceiver *event)
Application need to call this function if it wants receive notification about this window content cha...
Definition: TextBox.h:53
void SetMargins(int offset_x, int offset_y)
Defines offset from left and top for text.
Definition: TextBox.h:58