eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_edit_box.c
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * Copyright 2014 by Petr Gargulak. eGUI Community.
4 * Copyright 2009-2013 by Petr Gargulak. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License Version 3
9 * or later (the "LGPL").
10 *
11 * As a special exception, the copyright holders of the eGUI project give you
12 * permission to link the eGUI sources with independent modules to produce an
13 * executable, regardless of the license terms of these independent modules,
14 * and to copy and distribute the resulting executable under terms of your
15 * choice, provided that you also meet, for each linked independent module,
16 * the terms and conditions of the license of that module.
17 * An independent module is a module which is not derived from or based
18 * on this library.
19 * If you modify the eGUI sources, you may extend this exception
20 * to your version of the eGUI sources, but you are not obligated
21 * to do so. If you do not wish to do so, delete this
22 * exception statement from your version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 *
28 * You should have received a copy of the GNU General Public License
29 * and the GNU Lesser General Public License along with this program.
30 * If not, see <http://www.gnu.org/licenses/>.
31 *
32 ***************************************************************************/
46 #include "d4d.h"
48 
49 //Internal API
52 static void D4D_EditBoxTimeTick(D4D_MESSAGE* pMsg);
53 
54 static void D4D_EditBoxOnInit(D4D_MESSAGE* pMsg);
55 
57 {
58  D4D_DEFSTR("Edit Box"),
60  NULL,
61  NULL
62 };
63 
64 // temporary structure for editBox temporary value calculation
65 typedef struct
66 {
67  D4D_POINT position;
68  D4D_GEOMETRY contentGeom;
69 } D4D_EDIT_BOX_TMP_VAL;
70 
71 #define _calc (*((D4D_EDIT_BOX_TMP_VAL*)d4d_scratchPad))
72 
73 
74 
75 
76 /*******************************************************
77 *
78 * EDIT_BOX Helper computing routines
79 *
80 *******************************************************/
81 
82 static void D4D_EditBoxValue2Coor(D4D_OBJECT* pThis)
83 {
84  _calc.position = D4D_GetClientToScreenPoint(pThis, &pThis->position);
85  D4D_ComputeGeometry(&(_calc.contentGeom), pThis);
86 }
87 
88 /*******************************************************
89 *
90 * EDIT_BOX Drawing routine
91 *
92 *******************************************************/
93 
94 static void D4D_EditBoxOnDraw(D4D_MESSAGE* pMsg)
95 {
96  D4D_OBJECT* pThis = pMsg->pObject;
97  D4D_EDIT_BOX* pEditBox = D4D_GET_EDIT_BOX(pThis);
98  D4D_EDIT_BOX_DATA* pEditBoxData = D4D_GET_EDIT_BOX_DATA(pEditBox);
99  D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw;
100  D4D_COLOR clrT, clrB;
101 
102  // Get background simple color
103  clrT = D4D_ObjectGetForeColor(pThis, draw);
104  clrB = D4D_ObjectGetScheme(pThis)->bckgFocus;
105 
106  #ifdef D4D_DEBUG
107  // sanity check
109  #endif
110 
111  // Compute all tempoarary values
112  D4D_EditBoxValue2Coor(pThis);
113 
114  // draw just a color rectangle instead of bitmap
116  {
117  // Draw the background
118  #if D4D_ROUND_CORNER_ENABLE != D4D_FALSE
119  if(pThis->radius)
120  D4D_FillRRect(&_calc.position, &pThis->size, clrB, pThis->radius);
121  else
122  #endif
123  D4D_FillRect(&_calc.position, &pThis->size, clrB);
124 
126  }
127 
128  // Draw the frame
129  if(draw & (D4D_OBJECT_DRAWFLAGS_COMPLETE | D4D_OBJECT_DRAWFLAGS_STATE))
130  D4D_DrawFrame(pThis, clrT, clrB);
131 
132  // Draw text
133  if(pEditBoxData->flags & D4D_EDIT_BOX_FLAGS_REDRAWTEXT)
134  {
135  pEditBoxData->flags &= ~D4D_EDIT_BOX_FLAGS_REDRAWTEXT;
136  // draw the text
137  #if D4D_ROUND_CORNER_ENABLE != D4D_FALSE
138  if(pThis->radius)
139  D4D_DrawTextRRect(&_calc.contentGeom.pnt, &_calc.contentGeom.sz, &pEditBoxData->string, clrT, clrB, pThis->radius);
140  else
141  #endif
142  D4D_DrawTextRect(&_calc.contentGeom.pnt, &_calc.contentGeom.sz, &pEditBoxData->string, clrT, clrB);
143  }
144 
145  // Draw cursor
146  if(pEditBoxData->flags & D4D_EDIT_BOX_FLAGS_REDRAWCURSOR)
147  {
148  D4D_STRING tmp_textbuff = pEditBoxData->string;
149  D4D_POINT tmp_point = _calc.contentGeom.pnt;
150  D4D_SIZE tmp_size = _calc.contentGeom.sz;
151  D4D_COOR widthChar, widthText;
152  pEditBoxData->flags &= ~D4D_EDIT_BOX_FLAGS_REDRAWCURSOR;
153 
154  tmp_textbuff.printLen = (D4D_INDEX)(pEditBoxData->curPos - tmp_textbuff.printOff);
155  widthText = D4D_GetTextBuffWidthTab(&tmp_textbuff, NULL);
156  tmp_point.x += widthText;
157 
158  widthChar = D4D_GetCharWidth(tmp_textbuff.fontId, *(tmp_textbuff.pText + pEditBoxData->curPos));
159 
160  if((widthText + widthChar) > _calc.contentGeom.sz.cx)
161  widthChar = 0;
162 
163  if(((pEditBoxData->flags & D4D_EDIT_BOX_FLAGS_CURSORSTATE) && !(pEditBoxData->flags & D4D_EDIT_BOX_FLAGS_MOVECURSOR)) || (widthChar == 0))
164  {
165 
166  //Draw the cursor
167  tmp_size.cy = D4D_GetFontHeight(tmp_textbuff.fontId);
168  tmp_size.cx = 2;
169 
170  // moed to cursor to right position in Y
171  if (_calc.contentGeom.sz.cy > tmp_size.cy)
172  tmp_point.y += ( _calc.contentGeom.sz.cy - tmp_size.cy) / 2;
173 
174  if (pThis->radius > 0)
175  {
176  // if rounded box we need to move the cursor to the right slightly if it will fit
177  if ((tmp_point.x + pThis->radius/2) < (_calc.contentGeom.pnt.x + _calc.contentGeom.sz.cx - 1))
178  tmp_point.x += pThis->radius/2;
179  }
180 
181 
182  if(pEditBoxData->flags & D4D_EDIT_BOX_FLAGS_CURSORSTATE)
183  D4D_FillRect(&tmp_point, &tmp_size, clrT);
184  else
185  D4D_FillRect(&tmp_point, &tmp_size, clrB);
186  }else
187  {
188  // Hide the Cursor
189  pEditBoxData->flags &= ~D4D_EDIT_BOX_FLAGS_MOVECURSOR;
190 
191  tmp_size.cx = widthChar;
192  tmp_textbuff.printLen = 1;
193  tmp_textbuff.printOff = pEditBoxData->curPos;
194  D4D_DrawTextRect(&tmp_point, &tmp_size, &tmp_textbuff, clrT, clrB);
195  }
196  }
197 
198 
199 }
200 
201 
202 /*******************************************************
203 *
204 * EDIT_BOX key handling routine
205 *
206 *******************************************************/
207 
208 static void D4D_EditBoxOnKeyUp(D4D_MESSAGE* pMsg)
209 {
210  D4D_OBJECT* pThis = pMsg->pObject;
211  D4D_EDIT_BOX* pEditBox = D4D_GET_EDIT_BOX(pThis);
212  D4D_EDIT_BOX_DATA* pEditBoxData = D4D_GET_EDIT_BOX_DATA(pEditBox);
213 
214  if(D4D_GetCapturedObject() == pMsg->pObject)
215  {
216  switch(pMsg->prm.key)
217  {
219  // move cursor on new char position
220  if(pEditBoxData->curPos)
221  D4D_EditBoxSetCursor(pThis, (D4D_INDEX)(pEditBoxData->curPos - 1));
222  break;
223 
225  D4D_EditBoxSetCursor(pThis, (D4D_INDEX)(pEditBoxData->curPos + 1));
226  break;
227 
230  break;
231 
233  case D4D_KEY_SCANCODE_UP:
235  break;
236 
237  default:
238  // Standard keys input
239  D4D_EditBoxPutChar(pThis, pMsg->prm.key);
240  break;
241  }
242  }else
243  if(pMsg->prm.key == D4D_KEY_SCANCODE_ENTER)
244  D4D_CaptureKeys(pMsg->pObject);
245 
246 
247 }
248 
249 /*******************************************************
250 *
251 * EDIT_BOX touch screen handling routine
252 *
253 *******************************************************/
254 #ifdef D4D_LLD_TCH
255 static void D4D_EditBoxOnTouch(D4D_MESSAGE* pMsg)
256 {
257  D4D_OBJECT* pThis = pMsg->pObject;
258 
259  if(D4D_GetFocusedObject(pMsg->pScreen) != pThis)
260  {
261  if(pMsg->nMsgId == D4D_MSG_TOUCHED)
262  D4D_FocusSet(pMsg->pScreen, pThis);
263  }
264 }
265 #endif
266 
267 static void D4D_EditBoxOnInit(D4D_MESSAGE* pMsg)
268 {
269  D4D_OBJECT* pThis = pMsg->pObject;
270  D4D_EDIT_BOX* pEditBox = D4D_GET_EDIT_BOX(pThis);
271  D4D_EDIT_BOX_DATA* pEditBoxData = D4D_GET_EDIT_BOX_DATA(pEditBox);
272 
273 
274  // If there is any init text just copy it into work buffer
275  if(pEditBox->pInitText)
276  {
277  D4D_INDEX i = (D4D_INDEX)(pEditBoxData->string.buffSize - 1);
278  D4D_TCHAR* s = pEditBox->pInitText;
279  D4D_TCHAR* d = pEditBoxData->string.pText;
280  D4D_INDEX cnt = 0;
281  D4D_COOR maxWidth = (D4D_COOR)(pThis->size.cx - 1);
282 
283  if(pThis->pMargin)
284  {
285  maxWidth -= pThis->pMargin->left;
286  maxWidth -= pThis->pMargin->right;
287  }
288 
289  while((i--) && *s)
290  {
291  *d++ = *s++;
292  cnt++;
293  }
294 
295  *d = '\0'; // And terminate string
296  pEditBoxData->string.printLen = cnt;
297  pEditBoxData->string.printLen = D4D_GetTextMaxLength(&(pEditBoxData->string), maxWidth);
298 
299  if(pEditBoxData->string.printLen != cnt)
300  pEditBoxData->flags |= D4D_EDIT_BOX_FLAGS_FULL;
301 
302  D4D_EditBoxSetCursor(pThis, cnt);
303 
304  pEditBoxData->flags &= ~D4D_EDIT_BOX_FLAGS_CHANGETEXT;
305 
306  if(pEditBox->pOnEvent)
307  pEditBox->pOnEvent(pThis, D4D_EVENT_ONCHANGEDONE);
308 
309  }
310 
311  // set flag to redraw screen
313 }
314 
315 
317 {
318  D4D_OBJECT* pThis = pMsg->pObject;
319  D4D_EDIT_BOX* pEditBox = D4D_GET_EDIT_BOX(pThis);
320  D4D_EDIT_BOX_DATA* pEditBoxData = D4D_GET_EDIT_BOX_DATA(pEditBox);
321 
322  pEditBoxData->tickCounter++;
324  {
325  pEditBoxData->tickCounter = 0;
326  pEditBoxData->flags |= D4D_EDIT_BOX_FLAGS_REDRAWCURSOR;
328 
329  if(pEditBoxData->flags & D4D_EDIT_BOX_FLAGS_CURSORSTATE)
330  pEditBoxData->flags &= ~D4D_EDIT_BOX_FLAGS_CURSORSTATE;
331  else
332  pEditBoxData->flags |= D4D_EDIT_BOX_FLAGS_CURSORSTATE;
333  }
334 }
335 
336 /**************************************************************/
347 {
348  D4D_EDIT_BOX* pEditBox = D4D_GET_EDIT_BOX(pObj);
349  D4D_EDIT_BOX_DATA* pData = pEditBox->pData;
350 
351  D4D_INDEX max_size = (D4D_INDEX)(pData->string.buffSize - 1);
352  D4D_COOR maxWidth = (D4D_COOR)(pObj->size.cx - 1);
353 
354  if(pData->curPos >= max_size)
355  return D4D_FALSE;
356 
357  // Place new character
358  pData->string.pText[pData->curPos] = ch;
359 
360  if(pObj->pMargin)
361  {
362  maxWidth -= pObj->pMargin->left;
363  maxWidth -= pObj->pMargin->right;
364  }
365  // just for case
366  pData->string.printLen++;
367  pData->string.printLen = D4D_GetTextMaxLength(&(pData->string), maxWidth);
368 
369  // move cursor on new char position
370  D4D_EditBoxSetCursor(pObj, (D4D_INDEX)(pData->curPos + 1));
371 
373 
374  if(pEditBox->pOnEvent)
375  pEditBox->pOnEvent((D4D_OBJECT*)pObj, D4D_EVENT_ONCHANGE);
376 
377  return D4D_TRUE;
378 }
379 
380 /******************************************************************************
381 * Begin of D4D_EDIT_BOX public functions
382 */
386 /**************************************************************************/
394 {
395  D4D_EDIT_BOX* pEditBox = D4D_GET_EDIT_BOX(pObj);
396  D4D_EDIT_BOX_DATA* pData = pEditBox->pData;
397  D4D_BOOL res = D4D_TRUE;
398 
399  if(ch >= ' ') {
400  res = D4D_EditBoxPutCharInt(pObj, ch); //Put New char
401  }else {
402  switch(ch) {
403  case '\r': // return carrier
404  D4D_EditBoxSetCursor(pObj, 0);
405  break;
406 
407  case '\b': // backspace
408  if(pData->curPos)
409  {
410  D4D_TCHAR* pText = pData->string.pText;
411  D4D_COOR maxWidth = (D4D_COOR)(pObj->size.cx - 1);
412  D4D_INDEX i = pData->curPos; //Go back one char
413 
414  i--;
415 
416  while(pText[i])
417  {
418  pText[i] = pText[i+1];
419  i++;
420  }
421 
422  if(pObj->pMargin)
423  {
424  maxWidth -= pObj->pMargin->left;
425  maxWidth -= pObj->pMargin->right;
426  }
427 
428  pData->string.printLen = D4D_GetTextMaxLength(&(pData->string), maxWidth);
429 
430  // move cursor on new char position
431  D4D_EditBoxSetCursor(pObj, (D4D_INDEX)(pData->curPos - 1));
432 
434 
435  if(pEditBox->pOnEvent)
436  pEditBox->pOnEvent((D4D_OBJECT*)pObj, D4D_EVENT_ONCHANGE);
437 
438  }else
439  res = D4D_FALSE;
440  break;
441  }
442  }
445  return res;
446 }
447 
448 /**************************************************************************/
456 {
457  D4D_TCHAR* pIntText = D4D_GetInternalStringPointer(pText);
458 
459  if(pIntText == NULL)
460  return D4D_FALSE;
461 
462  while(*pIntText) {
463  if(!D4D_EditBoxPutChar(pObj, *pIntText))
464  return D4D_FALSE;
465  pIntText++;
466  }
467 
469  {
470  D4D_EDIT_BOX* pEditBox = D4D_GET_EDIT_BOX(pObj);
471  D4D_EDIT_BOX_DATA* pData = pEditBox->pData;
472 
474 
475  if(pEditBox->pOnEvent)
476  pEditBox->pOnEvent((D4D_OBJECT*)pObj, D4D_EVENT_ONCHANGEDONE);
477  }
478 
479 
480  return D4D_TRUE;
481 }
482 
483 /**************************************************************************/
491 {
492  D4D_EDIT_BOX* pEditBox = D4D_GET_EDIT_BOX(pObj);
493  D4D_EDIT_BOX_DATA* pData = pEditBox->pData;
494  D4D_COOR maxWidth = (D4D_COOR)(pObj->size.cx - 1);
495 
496 
497  // Object exists?
498  if(pObj == NULL)
499  return 0;
500 
501  // Check if the cursor is not out of range
502  if(newPos >= pData->string.buffSize)
503  return pData->curPos;
504 
505  // Check if the cursor in on requested position
506  if(pData->curPos == newPos)
507  return newPos;
508 
509  if(pObj->pMargin)
510  {
511  maxWidth -= pObj->pMargin->left;
512  maxWidth -= pObj->pMargin->right;
513  }
514 
515  // In case that the cursor overjump non text , fill up overjumped palce by spaces
516  if(pData->curPos < newPos)
517  {
518  D4D_INDEX i = (D4D_INDEX)(newPos - 1);
519  D4D_TCHAR* pText = pData->string.pText;
520  // D4D_INDEX cnt = pData->string.printLen;
521  while(i && (!pText[i]))
522  {
523  pText[i--] = ' ';
524  // cnt++;
525  }
526 
527  // the visible area is not full
528  if(!(pData->flags & D4D_EDIT_BOX_FLAGS_FULL))
529  {
530  // D4D_INDEX len = pData->string.printLen;
531  if(pData->string.printLen < newPos)
532  {
533  pData->string.printLen = newPos;
534  pData->string.printLen = D4D_GetTextMaxLength(&(pData->string), maxWidth);
535 
536  if(pData->string.printLen != newPos)
537  pData->flags |= D4D_EDIT_BOX_FLAGS_FULL;
538  }
539  }
540 
541  }
542 
543  // Check if the cursor is in visible range
544  if((newPos >= pData->string.printOff) && (newPos <= (pData->string.printLen + pData->string.printOff - 0)))
545  {
546  pData->curPos = newPos;
547  }else
548  {
549  // requested position is not in visible area
550  if(pData->curPos > newPos)
551  {
552  // Go back with visible area
553  pData->string.printOff = newPos;
554  // Temporary fill up printLen with maximal possible value to be used by function D4D_GetTextMaxLength(...)
555  pData->string.printLen = (D4D_INDEX)(pData->string.buffSize - newPos - 1);
556  // Compute real printLen
557  pData->string.printLen = D4D_GetTextMaxLength(&(pData->string), maxWidth);
558  }else
559  {
560  // Go forward with visible area
561  D4D_COOR currentWidth = D4D_GetTextBuffWidthTab(&(pData->string), NULL);
562  D4D_INDEX currentLast = (D4D_INDEX)(pData->string.printOff + pData->string.printLen);
563  D4D_COOR width;
564  D4D_FONT fontIx = pData->string.fontId;
565 
566  while(currentLast < newPos)
567  {
568  currentWidth -= D4D_GetCharWidth(fontIx, pData->string.pText[pData->string.printOff]);
569  pData->string.printOff++;
570  pData->string.printLen--;
571  while(1)
572  {
573  if(!pData->string.pText[currentLast])
574  break;
575 
576  width = D4D_GetCharWidth(fontIx, pData->string.pText[currentLast]);
577 
578  if((width + currentWidth) > maxWidth)
579  break;
580 
581  currentWidth += width;
582  currentLast++;
583  pData->string.printLen++;
584  }
585  }
586  }
587  pData->curPos = newPos;
588  }
589 
592  return pData->curPos;
593 }
594 
595 
596 
597 
598 /**************************************************************************/
605 {
606  D4D_EDIT_BOX* pEditBox = D4D_GET_EDIT_BOX(pObj);
607  D4D_EDIT_BOX_DATA* pData = pEditBox->pData;
608 
609  if(pObj == NULL)
610  return 0;
611 
612  return pData->curPos;
613 }
614 
615 /**************************************************************************/
622 {
623  D4D_EDIT_BOX* pEditBox = D4D_GET_EDIT_BOX(pObj);
624  D4D_EDIT_BOX_DATA* pData = pEditBox->pData;
625 
626  LWord i,i_max;
627 
628  // Init the text array
629  i_max = pData->string.buffSize;
630 
631  for(i=0;i<i_max;i++)
632  pData->string.pText[i] = '\0';
633 
634  pData->curPos = 0;
635  pData->string.printOff = 0;
636  pData->string.printLen = 0;
638 
639  if(pEditBox->pOnEvent)
640  pEditBox->pOnEvent((D4D_OBJECT*)pObj, D4D_EVENT_ONCLEAR);
641 
644 }
645 
646 /**************************************************************************/
653 {
654  D4D_EDIT_BOX* pEditBox = D4D_GET_EDIT_BOX(pObj);
655  D4D_EDIT_BOX_DATA* pData = pEditBox->pData;
656 
657  return pData->string.pText;
658 }
659 
660 /******************************************************************************
661 * End of public functions */
663 /******************************************************************************/
664 
665 /**************************************************************/
675 /*******************************************************
676 *
677 * The EDIT_BOX message handler
678 *
679 *******************************************************/
680 
682 {
683  D4D_EDIT_BOX* pEditBox = D4D_GET_EDIT_BOX(pMsg->pObject);
684  D4D_EDIT_BOX_DATA* pData = pEditBox->pData;
685 
686  switch(pMsg->nMsgId)
687  {
688  case D4D_MSG_DRAW:
689  D4D_EditBoxOnDraw(pMsg);
690  break;
691 
692  case D4D_MSG_KEYDOWN:
693  D4D_EditBoxOnKeyUp(pMsg);
694  break;
695 
696 #ifdef D4D_LLD_TCH
697  case D4D_MSG_TOUCHED:
698  case D4D_MSG_TOUCH_AUTO:
699  D4D_EditBoxOnTouch(pMsg);
700  break;
701 #endif
702  case D4D_MSG_ONINIT:
704  D4D_EditBoxOnInit(pMsg);
705  break;
706 
707  case D4D_MSG_TIMETICK:
708  #if (D4D_EDIT_BOX_CURSOR_BLINK_TICK_COUNTER > 0)
709  D4D_EditBoxTimeTick(pMsg);
710  #endif
711  break;
712 
713  case D4D_MSG_KILLFOCUS:
714 
716 
718  {
720 
721  if(pEditBox->pOnEvent)
722  pEditBox->pOnEvent(pMsg->pObject, D4D_EVENT_ONCHANGEDONE);
723  }
724 
725  case D4D_MSG_KILLCAPTURE:
726  case D4D_MSG_SETFOCUS:
727  case D4D_MSG_SETCAPTURE:
729 
733  break;
734 
735  default:
736  // call the default behavior of all objects
737  D4D_ObjOnMessage(pMsg);
738  }
739 }
D4D_INDEX buffSize
size of text buffer array
Definition: d4d_string.h:103
D4D_WCHAR D4D_TCHAR
Type definition of eGUI character (it depends on UNICODE setting if this is D4D_CHAR or D4D_WCHAR)...
Definition: d4d_types.h:284
Byte D4D_FONT
Definition: d4d_font.h:171
static void D4D_EditBoxTimeTick(D4D_MESSAGE *pMsg)
Definition: d4d_edit_box.c:316
#define D4D_KEY_SCANCODE_ESC
This macro is used to specify Key Scan Code ESC. If not defined, it sets to 0x01 as a default...
Definition: d4d_base.h:305
#define D4D_KEY_SCANCODE_RIGHT
This macro is used to specify Key Scan Code RIGHT. If not defined, it sets to 0x4D as a default...
Definition: d4d_base.h:295
#define D4D_GET_EDIT_BOX_DATA(pEditBox)
Definition: d4d_edit_box.h:142
D4D_COLOR D4D_ObjectGetForeColor(D4D_OBJECT *pObj, D4D_OBJECT_DRAWFLAGS draw)
Function return object current fore color.
Definition: d4d_scheme.c:161
#define D4D_KEY_SCANCODE_UP
This macro is used to specify Key Scan Code UP. If not defined, it sets to 0x51 as a default...
Definition: d4d_base.h:280
void D4D_FillRect(D4D_POINT *ppt, D4D_SIZE *psz, D4D_COLOR color)
Function draw filled rectangle on the screen.
D4D_INDEX printLen
Length of string that should be used (printed).
Definition: d4d_string.h:106
Type definition of eGUI point structure.
Definition: d4d_types.h:223
D4D_COOR left
Margin of left side.
Definition: d4d_types.h:246
On Init message - is send for first time when the object is inicialized.
Definition: d4d_base.h:370
#define _calc
Definition: d4d_edit_box.c:71
D4D object messages structure.
Definition: d4d_base.h:400
D4D_OBJECT_DATA_PTR pData
Pointer on runtime object data.
Definition: d4d_object.h:180
#define D4D_EDIT_BOX_FLAGS_CURSORSTATE
Definition: d4d_edit_box.h:113
#define D4D_EDIT_BOX_CURSOR_BLINK_TICK_COUNTER
This is definition of edit box cursor blink time (in ticks of eGUI time ticks - D4D_TimeTickPut). If not defined, it sets to ( 10 ) as a default.
Definition: d4d_edit_box.h:78
#define D4D_FALSE
This is definition of boolean operation value in eGUI - FALSE.
Definition: d4d_types.h:104
The string type. This structure contains all properties about string in eGUI.
Definition: d4d_string.h:100
#define D4D_DrawTextRect(ppt, psz, buffText, colorText, colorBkgd)
Function that draw text into defined rectangle on the screen.
const D4D_OBJECT_SYS_FUNCTION d4d_editBoxSysFunc
Definition: d4d_edit_box.c:56
D4D_EDIT_BOX_FLAGS flags
Definition: d4d_edit_box.h:125
D4D_TCHAR * D4D_GetInternalStringPointer(const D4D_TCHAR *originTxt)
The function gets the real internal pointer to string.
Definition: d4d_string.c:108
On Change done (complete change is finished.
Definition: d4d_base.h:434
D4D_FONT fontId
index of used font
Definition: d4d_string.h:104
Time Tick Occur message - is send with each time tick to object.
Definition: d4d_base.h:393
Set Focus message - is send when the object is getting focus.
Definition: d4d_base.h:373
#define D4D_TRUE
This is definition of boolean operation value in eGUI - TRUE.
Definition: d4d_types.h:106
void D4D_DrawFrame(D4D_OBJECT *pObject, D4D_COLOR clrT, D4D_COLOR clrB)
Function draw standard object frame based on the object settings and current state.
D4D_INDEX D4D_GetTextMaxLength(D4D_STRING *pString, D4D_COOR maxWidth)
The function find out the maximal text length that fits to maximal pixel width.
Definition: d4d_string.c:492
struct D4D_OBJECT_S * pObject
Pointer to object who is receiver of this message. If the receiver is just screen this field must be ...
Definition: d4d_base.h:402
D4D Driver main header file.
#define D4D_KEY_SCANCODE_ENTER
This macro is used to specify Key Scan Code ENTER. If not defined, it sets to 0x1C as a default...
Definition: d4d_base.h:300
D4D_OBJECT_FLAGS flags
runtime object flags
Definition: d4d_object.h:145
D4D_TCHAR * pInitText
Definition: d4d_edit_box.h:131
void D4D_EditBoxOnMessage(D4D_MESSAGE *pMsg)
Definition: d4d_edit_box.c:681
Auto Touched message - is send when the object is still keep touch by touch screen driver ...
Definition: d4d_base.h:380
#define D4D_OBJECT_DRAWFLAGS_COMPLETE
Draw complete flag.
Definition: d4d_base.h:361
#define D4D_SCRATCHPAD_SIZE
Call back function raised by any new input event (touch, mouse, keys).
Definition: d4d_base.h:579
D4D_COOR D4D_GetTextBuffWidthTab(D4D_STRING *text_buffer, D4D_TAB *pTab)
The function returns width of text in pixels, also with tab table.
Definition: d4d_string.c:403
D4D Driver private header file.
#define D4D_KEY_SCANCODE_DOWN
This macro is used to specify Key Scan Code DOWN. If not defined, it sets to 0x50 as a default...
Definition: d4d_base.h:285
#define D4D_DEFSTR(str)
Macro that helps declare the strings in eGUI.
Definition: d4d_string.h:246
#define D4D_EDIT_BOX_FLAGS_REDRAWTEXT
Definition: d4d_edit_box.h:110
D4D_COOR cx
Size in axis X (width)
Definition: d4d_types.h:232
Byte D4D_COOR
Type definition of eGUI coordination variables.
Definition: d4d_types.h:219
D4D_POINT position
Position on the screen/object.
Definition: d4d_object.h:169
static void D4D_EditBoxOnDraw(D4D_MESSAGE *pMsg)
Definition: d4d_edit_box.c:94
#define D4D_OBJECT_DRAWFLAGS_STATE
Draw just change of state flag.
Definition: d4d_base.h:364
D4D_COOR radius
Object corners radius.
Definition: d4d_object.h:171
void D4D_ObjOnMessage(D4D_MESSAGE *pMsg)
Definition: d4d_object.c:443
static void D4D_EditBoxValue2Coor(D4D_OBJECT *pThis)
Definition: d4d_edit_box.c:82
D4D_INDEX tickCounter
Definition: d4d_edit_box.h:124
D4D_COOR right
Margin of right side.
Definition: d4d_types.h:248
void D4D_FocusSet(const D4D_SCREEN *pScreen, D4D_OBJECT_PTR pObject)
The function set the obejct focus to new object.
Definition: d4d_screen.c:430
#define NULL
Type definition of null pointer.
Definition: d4d_types.h:184
#define D4D_ASSERT(cond)
Definition: d4d_base.h:583
D4D_CLR_SCHEME * D4D_ObjectGetScheme(D4D_OBJECT *pObj)
Function return the pointer to current use object scheme of object.
Definition: d4d_scheme.c:109
D4D_TCHAR * pText
pointer to text array
Definition: d4d_string.h:102
unsigned long LWord
Type definition of LWord (unsigned 32-bit).
Definition: d4d_types.h:167
void D4D_EditBoxClearAll(D4D_OBJECT_PTR pObj)
The function clear whole edit box data.
Definition: d4d_edit_box.c:621
D4D_COOR y
Coordination in axis Y.
Definition: d4d_types.h:226
D4D_COLOR bckgFocus
The object background color in focused state.
Definition: d4d_scheme.h:583
D4D_SCREEN * D4D_GetActiveScreen(void)
Returns pointer to current active screen.
Definition: d4d_screen.c:78
#define D4D_OBJECT_F_NOTINIT
Definition: d4d_object.h:113
D4D_STRING string
Definition: d4d_edit_box.h:122
D4D_OBJECT_PTR D4D_GetFocusedObject(const D4D_SCREEN *pScreen)
The function returns pointer to object that is focused in given screen.
Definition: d4d_screen.c:266
#define D4D_EDIT_BOX_FLAGS_MOVECURSOR
Definition: d4d_edit_box.h:111
D4D_INDEX D4D_EditBoxSetCursor(D4D_OBJECT_PTR pObj, D4D_INDEX newPos)
The function chenge the cursor position to new one.
Definition: d4d_edit_box.c:490
D4D_MSGID nMsgId
Type of message.
Definition: d4d_base.h:404
D4D_SIZE size
Size of the object.
Definition: d4d_object.h:170
#define D4D_KEY_SCANCODE_LEFT
This macro is used to specify Key Scan Code LEFT. If not defined, it sets to 0x4B as a default...
Definition: d4d_base.h:290
D4D_TCHAR * D4D_EditBoxGetText(D4D_OBJECT_PTR pObj)
The function returns the pointer to the edit box text buffer.
Definition: d4d_edit_box.c:652
D4D_KEY_SCANCODE key
There will be stored only code of key without release / press information - is valid with D4D_MSG_KEY...
Definition: d4d_base.h:409
D4D_POINT D4D_GetClientToScreenPoint(D4D_OBJECT *pObject, D4D_POINT *nClientPoint)
The function convert client point on the screen to the global screen point.
Definition: d4d_screen.c:536
LWord D4D_INDEX
Type definition of eGUI general index variables.
Definition: d4d_types.h:206
The object main structure type definition.
Definition: d4d_object.h:167
void D4D_CaptureKeys(D4D_OBJECT_PTR pObj)
Function switch on capturing the keys to objects.
Definition: d4d_object.c:190
Draw message - is send when the object should be redrawed.
Definition: d4d_base.h:371
static D4D_BOOL D4D_EditBoxPutCharInt(D4D_OBJECT_PTR pObj, D4D_TCHAR ch)
Definition: d4d_edit_box.c:346
D4D_EDIT_BOX_DATA * pData
Definition: d4d_edit_box.h:132
void D4D_ComputeGeometry(D4D_GEOMETRY *pGeometry, D4D_OBJECT *pObject)
Definition: d4d_base.c:1047
D4D_COOR cy
Size in axis Y (height)
Definition: d4d_types.h:233
The object system function needed for each object - this is part of D4D_OBJECT main structure...
Definition: d4d_object.h:134
static void D4D_EditBoxOnKeyUp(D4D_MESSAGE *pMsg)
Definition: d4d_edit_box.c:208
static void D4D_EditBoxOnInit(D4D_MESSAGE *pMsg)
Definition: d4d_edit_box.c:267
D4D_EDIT_BOX_ON_EVENT pOnEvent
Definition: d4d_edit_box.h:133
Touched message - is send when the object is touched by touch screen driver.
Definition: d4d_base.h:379
LWord D4D_BOOL
Type definition of eGUI boolean.
Definition: d4d_types.h:204
Type definition of eGUI size structure.
Definition: d4d_types.h:230
#define D4D_EDIT_BOX_FLAGS_CHANGETEXT
Definition: d4d_edit_box.h:115
#define D4D_DrawTextRRect(ppt, psz, buffText, colorText, colorBkgd, radius)
Function that draw text into defined rectangle on the screen with corner radius.
D4D_FONT_SIZE D4D_GetCharWidth(D4D_FONT ix, D4D_TCHAR ch)
Definition: d4d_font.c:415
Kill Capture message - is send when the object is losing capture keys status.
Definition: d4d_base.h:376
D4D_BOOL D4D_EditBoxPutString(D4D_OBJECT_PTR pObj, D4D_TCHAR *pText)
The function puts string on cursor position and updates cursor.
Definition: d4d_edit_box.c:455
D4D_OBJECT_DRAWFLAGS draw
Contains draw flags - is valid with D4D_MSG_DRAW and D4D_MSG_DRAWDONE message.
Definition: d4d_base.h:408
void D4D_EnableTimeTicks(D4D_OBJECT_PTR pObj, D4D_BOOL bEnable)
Function enable or diasble receiving timeticks for an OBJECT.
Definition: d4d_object.c:172
void D4D_FillRRect(D4D_POINT *ppt, D4D_SIZE *psz, D4D_COLOR color, D4D_COOR radius)
Function draw filled rectangle on the screen with round corners.
#define D4D_EDIT_BOX_FLAGS_REDRAWCURSOR
Definition: d4d_edit_box.h:112
Type definition of eGUI geometry structure.
Definition: d4d_types.h:237
Set Capture message - is send when the object is getting capture keys status.
Definition: d4d_base.h:375
D4D_BOOL D4D_EditBoxPutChar(D4D_OBJECT_PTR pObj, D4D_TCHAR ch)
The function puts one char on cursor position and updates cursor.
Definition: d4d_edit_box.c:393
On Change Event.
Definition: d4d_base.h:433
#define D4D_GET_EDIT_BOX(pObj)
Definition: d4d_edit_box.h:141
void D4D_InvalidateObject(D4D_OBJECT_PTR pObject, D4D_BOOL bComplete)
Function invalidate object to redraw on screen.
Definition: d4d_object.c:71
D4D_MARGIN * pMargin
Object inner margin.
Definition: d4d_object.h:172
Key Down message - is send when the object get new Key Down event.
Definition: d4d_base.h:378
Byte D4D_OBJECT_DRAWFLAGS
Drawing object flags type, handled to object in D4D_MSG_DRAW events.
Definition: d4d_base.h:359
LWord D4D_COLOR
Type definition of eGUI color variables.
Definition: d4d_types.h:262
struct D4D_SCREEN_S * pScreen
Pointer to screen who is receiver of this message.
Definition: d4d_base.h:403
D4D_FONT_SIZE D4D_GetFontHeight(D4D_FONT ix)
Definition: d4d_font.c:381
D4D_INDEX printOff
Offset of string that should be used (printed).
Definition: d4d_string.h:107
#define D4D_EDIT_BOX_FLAGS_FULL
Definition: d4d_edit_box.h:114
D4D_INDEX D4D_EditBoxGetCursor(D4D_OBJECT_PTR pObj)
The function returns the cursor position.
Definition: d4d_edit_box.c:604
D4D_COOR x
Coordination in axis X.
Definition: d4d_types.h:225
Kill Focus message - is send when the object is losing focus.
Definition: d4d_base.h:374
union D4D_MESSAGE_S::@0 prm
Additional data for some type of messages.
D4D_OBJECT * D4D_GetCapturedObject(void)
Function returns the current keys capturing object pointer.
Definition: d4d_object.c:241