22 #include "TextBoxNumber.h" 23 #include "TextBoxString.h" 24 #include "IDialogClosedEventReceiver.h" 25 #include "DecoratorPrimitives.h" 29 extern uint8_t BigFont[];
30 extern uint8_t SmallFont[];
42 const static int _buttonSize=39;
43 const static int _buttonDistance=5;
44 const static int _textOffset=9;
51 KeyboardWindow(
int left,
int top):
Dialog(left,top,7*(_buttonSize+_buttonDistance)+_buttonDistance,3*(_buttonSize+_buttonDistance)+_buttonDistance)
54 int x=_buttonDistance;
55 int y=_buttonDistance;
59 y+=_buttonSize+_buttonDistance;
60 _backspaceSymbol=
new Button(5*(_buttonSize+_buttonDistance)+_buttonDistance,y,_buttonSize,_buttonSize,F(
"<-"));
61 _btnOK=
new Button(6*(_buttonSize+_buttonDistance)+_buttonDistance,y,_buttonSize,_buttonSize,F(
"E"));
65 x=(i-(i<5?0:5))*(_buttonSize+_buttonDistance);
67 y+=_buttonSize+_buttonDistance;
69 _digidWindows[i].
Move(x+_buttonDistance,y,_buttonSize,_buttonSize);
72 initTextBox(&_digidWindows[i]);
74 _pointSymbol=
new Button(5*(_buttonSize+_buttonDistance)+_buttonDistance,y,_buttonSize,_buttonSize,F(
"."));
75 _btnCancel=
new Button(6*(_buttonSize+_buttonDistance)+_buttonDistance,y,_buttonSize,_buttonSize,F(
"C"));
76 initTextBox(_editField);
77 initTextBox(_backspaceSymbol);
78 _backspaceSymbol->
SetMargins(_textOffset,_textOffset*1.5);
79 _backspaceSymbol->
SetFont(SmallFont);
80 initTextBox(_pointSymbol);
96 dtostrf(value,0,precision,_editBuffer);
97 _editField->
SetText(_editBuffer);
99 _editPosition=strlen(_editBuffer);
104 return atof(_editBuffer);
119 bool needUpdate=
false;
120 if(window == _backspaceSymbol && _editPosition>0)
123 _editBuffer[_editPosition]=0;
126 else if(window == _pointSymbol && _editPosition<14)
128 _editBuffer[_editPosition++]=
'.';
129 _editBuffer[_editPosition]=0;
134 for(
int i=0;i<10;i++)
135 if(window == &_digidWindows[i] && _editPosition<14)
137 _editBuffer[_editPosition++]=
'0'+i;
138 _editBuffer[_editPosition]=0;
144 _editField->
SetText(_editBuffer);
float GetNumber()
Returns number from edit window.
Definition: KeyboardWindow.h:102
void RegisterTouchEventReceiver(ITouchEventReceiver *touchEventReceiver)
Registers receiver for touch event.
Definition: Window.h:102
Base class for all window objects. Provides basic window functionality.
Definition: Window.h:34
void SetText(T *text)
Initialize window with text.
Definition: TextBoxString.h:64
void SetFont(uint8_t *font)
Sets font.
Definition: TextBox.h:64
Base class for window with text content.
Definition: TextBox.h:30
Button * _btnCancel
Button Cancel has to be initialized in derived class.
Definition: Dialog.h:32
Text box for string. It is templat class and can be used for differnt type of string (see bellow type...
Definition: TextBoxString.h:25
Implements Keyboard window, that helps to enter text/number information into text fields...
Definition: KeyboardWindow.h:32
static Environment * Get()
Returns singltone instance of environment.
Definition: Environment.h:44
void Initialize(float value, int precision)
Initializes edit field with float value of desired precission.
Definition: KeyboardWindow.h:93
Button * _btnOK
Button OK has to be initialized in derived class.
Definition: Dialog.h:30
Text box for numbers.
Definition: TextBoxNumber.h:24
KeyboardWindow(int left, int top)
Constructor.
Definition: KeyboardWindow.h:51
virtual void Move(int left, int top, int width, int height)
Moves and resizes window relativly to the parent window.
Definition: Window.h:149
Base class for dialog objects. See Dialogs example Provides basic window functionality.
Definition: Dialog.h:25
void DoControlMessage(Window *window)
Process touch message from child controls.
Definition: KeyboardWindow.h:107
void Invalidate()
If function is called than the window manager updates the window.
Definition: Window.h:157
void AddChild(Window *window)
Adds window child window.
Definition: Window.h:194
void SetNumber(float number)
Initialize window with number.
Definition: TextBoxNumber.h:74
virtual void SetDecorators(DecoratorList *decorators)
Sets window decorators list.
Definition: Window.h:76
DecoratorList * FindDecorators(const __FlashStringHelper *id)
Finds registered decorators by the name.
Definition: Environment.h:59
int Width()
Returns window width.
Definition: Window.h:184
void SetMargins(int offset_x, int offset_y)
Defines offset from left and top for text.
Definition: TextBox.h:58