AWind
Dialog2.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 #include <Dialog.h>
21 #include <Label.h>
22 #include <TextBoxNumber.h>
24 class Dialog2 : public Dialog
25 {
26  TextBoxNumber *_txtNumber2;
27 public:
29 
36  Dialog2(const __FlashStringHelper * caption,int left,int top,int width,int height):Dialog(caption,left,top,width,height)
37  {
38  _txtNumber2=InitNumberFields(0,F("Enter number 1:"));
39  _txtNumber2->SetIsReadOnly(false);
40  _btnOK=new Button(0,0,0,0,F("OK"));
41  InitButton(_btnOK,10,80,60);
42  _btnCancel=new Button(0,0,0,0,F("Cancel"));
43  InitButton(_btnCancel,80,80,110);
44  }
46  void SetNumber(float number2)
47  {
48  _txtNumber2->SetNumber(number2);
49  }
51  float GetNumber()
52  {
53  return _txtNumber2->GetNumber();
54  }
55 protected:
57  TextBoxNumber *InitNumberFields(int offset,const __FlashStringHelper * text)
58  {
59  Label *label=new Label(10,43+offset,150,25,text);
60  AddChild(label);
61  TextBoxNumber * txtNumber=new TextBoxNumber(130,40+offset,40,20,0);
62  AddChild(txtNumber);
63  return txtNumber;
64  }
66  void InitButton(Button *btn,int left,int top,int width)
67  {
68  btn->Move(left,top,width,25);
69  btn->SetMargins(5,5);
70  btn->RegisterTouchEventReceiver(this);
71  AddChild(btn);
72  }
74  void DoControlMessage(Window *window)
75  {
76  //out<<F("Button pressed: ")<<sel_index<<endl;
77  }
78 };
void RegisterTouchEventReceiver(ITouchEventReceiver *touchEventReceiver)
Registers receiver for touch event.
Definition: Window.h:102
Dialog2(const __FlashStringHelper *caption, int left, int top, int width, int height)
Constructor.
Definition: Dialog2.h:36
Base class for all window objects. Provides basic window functionality.
Definition: Window.h:34
void SetIsReadOnly(bool isReadOnly)
Defines whether window is readonly.
Definition: TextBoxNumber.h:64
float GetNumber()
Return value from text box.
Definition: Dialog2.h:51
Button * _btnCancel
Button Cancel has to be initialized in derived class.
Definition: Dialog.h:32
void DoControlMessage(Window *window)
Process touch message from child controls.
Definition: Dialog2.h:74
Button * _btnOK
Button OK has to be initialized in derived class.
Definition: Dialog.h:30
Text box for numbers.
Definition: TextBoxNumber.h:24
virtual void Move(int left, int top, int width, int height)
Moves and resizes window relativly to the parent window.
Definition: Window.h:149
void SetNumber(float number2)
Init text box value.
Definition: Dialog2.h:46
Example window with yellow background.
Definition: Dialog2.h:24
Base class for dialog objects. See Dialogs example Provides basic window functionality.
Definition: Dialog.h:25
TextBoxNumber * InitNumberFields(int offset, const __FlashStringHelper *text)
create child text box fields
Definition: Dialog2.h:57
void AddChild(Window *window)
Adds window child window.
Definition: Window.h:194
void SetNumber(float number)
Initialize window with number.
Definition: TextBoxNumber.h:74
Implement button control.
Definition: Button.h:24
void InitButton(Button *btn, int left, int top, int width)
Create child button.
Definition: Dialog2.h:66
Implement Label control.
Definition: Label.h:24
void SetMargins(int offset_x, int offset_y)
Defines offset from left and top for text.
Definition: TextBox.h:58