2 #include "TextBoxString.h" 3 #include "TextBoxEditString.h" 4 #include "TextBoxChar.h" 5 #include "IDialogClosedEventReceiver.h" 6 #include "DecoratorPrimitives.h" 9 extern uint8_t BigFont[];
10 extern uint8_t SmallFont[];
12 static const char mkbCaps[31] PROGMEM =
"QWERTYUIOPASDFGHJKL\"ZXCVBNM;,.";
13 static const char mkbSm[31] PROGMEM =
"qwertyuiopasdfghjkl\"zxcvbnm;,.";
14 static const char mkbNumSym[31] PROGMEM =
"1234567890@#$%&-+_=/[]{}()<>,.";
30 const static int _butSize=22;
31 const static int _butSpace=4;
32 const static int _butSizeSpace=_butSize+_butSpace;
33 const static int _textOffset=3;
34 const static int _btn2W = _butSize*2 + _butSpace;
35 const static int _btn10W = 10*_butSizeSpace+_butSpace;
37 MobileKBWindow(
int left,
int top):
Dialog(left,top,12*_butSizeSpace+_butSpace,5*_butSizeSpace+_butSpace)
39 int i,k, len=30, p=0, x=_butSpace, y=_butSpace, tSmOff=5;
42 GetLetters(mkbCaps, 30);
46 initTextBox(_editField);
51 y+=_butSize+_butSpace;
56 x=i*(_butSize+_butSpace);
58 _btnWins[p]=
new TextBoxChar(x+_butSpace,y,_butSize,_butSize,c);
60 initTextBox(_btnWins[p]);
63 y+=_butSize+_butSpace;
66 y=_butSizeSpace+_butSpace;
67 _btnBckSpc=
new Button(_btn10W,y,_btn2W,_butSize,F(
"BckSpc"));
68 initTextBox(_btnBckSpc);
72 y+=_butSize+_butSpace;
78 y+=2*(_butSize+_butSpace);
79 _btnCaps=
new Button(_butSpace,y,_btn2W,_butSize,F(
"aA"));
80 initTextBox(_btnCaps);
83 _btnNumSym=
new Button(2*_butSizeSpace+_butSpace,y,_btn2W,_butSize,F(
"1&"));
84 initTextBox(_btnNumSym);
87 _btnSpaceBar=
new Button(4*_butSizeSpace+_butSpace,y,_btn2W*2+_butSpace,_butSize,F(
"Space"));
88 initTextBox(_btnSpaceBar);
89 _btnSpaceBar->
SetFont(SmallFont);
92 _btnClear=
new Button(8*_butSizeSpace+_butSpace,y,_btn2W,_butSize,F(
"Clear"));
93 initTextBox(_btnClear);
104 void initTextBox(
TextBox *text)
118 _btnWins[i]->SetChar(c);
121 void GetLetters(
const char* buf,
int len=28)
125 let[i] = pgm_read_byte_near(buf + i);
130 void Initialize(
char *txt)
132 _editField->SetText(txt);
137 _editField->Closed();
141 return _editField->GetText();
153 if ((window == _btnCaps) || (window == _btnNumSym))
155 if (window == _btnCaps)
157 if (*let == *mkbNumSym)
158 (curLetters == 1)? GetLetters(mkbSm) : GetLetters(mkbCaps);
161 (*let == *mkbCaps)? GetLetters(mkbSm) : GetLetters(mkbCaps);
162 curLetters = !curLetters;
167 if (*let == *mkbNumSym)
169 GetLetters(mkbNumSym);
176 if (window == _btnBckSpc) b = 8;
else 177 if (window == _btnClear) b = 13;
else 178 if (window == _btnSpaceBar) b = (byte)
' ';
else 180 for(
int i=0;i<30;i++)
181 if (window == _btnWins[i])
183 b = (byte)_btnWins[i]->GetChar();
187 _editField->UpdateEdit(b);
void DoControlMessage(Window *window)
Need to be redefinded in derived class.
Definition: MobileKBWindow.h:143
void RegisterTouchEventReceiver(ITouchEventReceiver *touchEventReceiver)
Registers receiver for touch event.
Definition: Window.h:102
Definition: MobileKBWindow.h:16
Base class for all window objects. Provides basic window functionality.
Definition: Window.h:34
Definition: TextBoxChar.h:4
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
Definition: TextBoxEditString.h:4
static Environment * Get()
Returns singltone instance of environment.
Definition: Environment.h:44
Button * _btnOK
Button OK has to be initialized in derived class.
Definition: Dialog.h:30
Base class for dialog objects. See Dialogs example Provides basic window functionality.
Definition: Dialog.h:25
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
virtual void SetDecorators(DecoratorList *decorators)
Sets window decorators list.
Definition: Window.h:76
Dialog(const __FlashStringHelper *caption, int left, int top, int width, int height)
Constructor for dialog with caption.
Definition: Dialog.h:42
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