eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_console.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 
50 // Internal API
52 
53 
54 
55 static void D4D_CnslNewLine(D4D_OBJECT_PTR pObj, D4D_BOOL returnCarrier);
57 static void D4D_CnslUpdateScrollbars(D4D_OBJECT* pThis);
58 static void D4D_CnslOnInit(D4D_MESSAGE* pMsg);
59 static void D4D_ConsoleTimeTick(D4D_MESSAGE* pMsg);
60 static D4D_INDEX D4D_CnslFindMaxTextLenght(D4D_TCHAR* pText, D4D_FONT font, D4D_INDEX startOffset, D4D_INDEX maxLenght);
61 
63 {
64  D4D_DEFSTR("Console"),
66  NULL,
67  NULL
68 };
69 
70 typedef struct
71 {
72  D4D_POINT position;
73  D4D_SIZE size;
74  D4D_GEOMETRY txtGeom;
75  D4D_SIZE lineSize;
76  D4D_SIZE charArrSize;
77 } D4D_CNSL_TMP_VAL;
78 
79 #define _calc (*((D4D_CNSL_TMP_VAL*)d4d_scratchPad))
80 //static D4D_CNSL_TMP_VAL _calc;
81 
82 static void D4D_CnslValue2Coor(D4D_OBJECT* pThis)
83 {
84  D4D_CONSOLE* pCnsl = D4D_GET_CONSOLE(pThis);
85  _calc.position = D4D_GetClientToScreenPoint(pThis, &pThis->position);
86 
87 
88  //margin (bevels :-) )
89  D4D_ComputeGeometry(&(_calc.txtGeom), pThis);
90 
91 #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE
92  _calc.txtGeom.pnt.y += (D4D_COOR)(pThis->radius / 2);
93  _calc.txtGeom.pnt.x += (D4D_COOR)(pThis->radius / 2);
94 
95  _calc.txtGeom.sz.cx -= (D4D_COOR)(pThis->radius / 2);
96  _calc.txtGeom.sz.cy -= (D4D_COOR)(pThis->radius / 2);
97 #endif
98 
99  _calc.charArrSize.cx = (D4D_COOR) (_calc.txtGeom.sz.cx / D4D_GetFontWidth(pCnsl->textFontId));
100 
101 
102  // check if the
103  if(_calc.charArrSize.cx < pCnsl->txtArrSize.cx)
104  _calc.txtGeom.sz.cy -= D4D_CNSL_SCRLBR_WIDTH;
105  else
106  _calc.charArrSize.cx = pCnsl->txtArrSize.cx;
107 
108  _calc.charArrSize.cy = (D4D_COOR) (_calc.txtGeom.sz.cy / D4D_GetFontHeight(pCnsl->textFontId));
109 
110  if(_calc.charArrSize.cy < pCnsl->txtArrSize.cy)
111  {
112  _calc.txtGeom.sz.cx -= D4D_CNSL_SCRLBR_WIDTH;
113  _calc.charArrSize.cx = (D4D_COOR) (_calc.txtGeom.sz.cx / D4D_GetFontWidth(pCnsl->textFontId));
114  }else
115  _calc.charArrSize.cy = pCnsl->txtArrSize.cy;
116 }
117 
118 static D4D_INDEX D4D_CnslFindMaxTextLenght(D4D_TCHAR* pText, D4D_FONT font, D4D_INDEX startOffset, D4D_INDEX maxLenght)
119 {
120  D4D_INDEX result;// = _calc.charArrSize.cx;
121  D4D_COOR tmp_textWidth;
122 
123  result = 0;
124  tmp_textWidth = 0;
125 
126  while((pText[result] != 0) && ((result + startOffset) < maxLenght))
127  {
128  if(tmp_textWidth >= (_calc.txtGeom.sz.cx - 4))
129  break;
130 
131  result++;
132  tmp_textWidth += D4D_GetCharWidth(font, pText[result]);
133  }
134 
135  return result;
136 }
137 
138 
139 /*******************************************************
140 *
141 * CONSOLE Drawing routine
142 *
143 *******************************************************/
144 
145 static void D4D_ConsoleOnDraw(D4D_MESSAGE* pMsg)
146 {
147  D4D_OBJECT* pThis = pMsg->pObject;
148  D4D_CONSOLE* pCnsl = D4D_GET_CONSOLE(pThis);
149  D4D_CNSL_DATA* pData = pCnsl->pData;
150  D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw;
151  D4D_COLOR clrT, clrB;
152  D4D_INDEX line_cnt, tmp_realLine;
153  D4D_POINT tmp_point;
154  D4D_SIZE tmp_size, tmp_winOff;
155  D4D_STRING tmp_txtbuff;
156  D4D_STR_PROPERTIES tmp_strPrties;
157  D4D_BOOL tmp_font_proporcional = D4D_FALSE;
158 
159 
160  D4D_CnslValue2Coor(pThis);
161 
162  clrT = D4D_ObjectGetForeFillColor(pThis);
163  clrB = D4D_ObjectGetBckgFillColor(pThis);
164 
165  // draw the rectangle around the text
167  {
168  D4D_FillRRect(&_calc.position, &pThis->size, clrB, pThis->radius);
169 
171  }
172 
173  // Draw the frame
174  if(draw & (D4D_OBJECT_DRAWFLAGS_COMPLETE | D4D_OBJECT_DRAWFLAGS_STATE))
175  D4D_DrawFrame(pThis, clrT, clrB);
176 
179  tmp_strPrties.font_properties = 0;
180  tmp_strPrties.text_properties = 0;
181  tmp_txtbuff.fontId = pCnsl->textFontId;
182  tmp_txtbuff.str_properties = &tmp_strPrties;
183  tmp_txtbuff.printOff = 0;
184 
185 
187  {
188  // Draw all lines of console
189  tmp_point = _calc.txtGeom.pnt;
190  tmp_size.cx = _calc.txtGeom.sz.cx;
191  tmp_size.cy = D4D_GetFontHeight(pCnsl->textFontId);
192 
193 
195  tmp_font_proporcional = D4D_TRUE;
196 
197  for(line_cnt = 0; line_cnt < _calc.charArrSize.cy; line_cnt++)
198  {
199  if(!(pData->flags & D4D_CNSL_FLAGS_REDRAWALL))
200  if(line_cnt != pData->cursorPos.y)
201  {
202  tmp_point.y += tmp_size.cy;
203  continue;
204  }
205 
206  // Compute the real line in memory
207  tmp_realLine = (D4D_INDEX)((pData->lastLineIx + line_cnt + tmp_winOff.cy) % pCnsl->txtArrSize.cy);
208 
209  // found the right pointer of the text to draw in the text array
210  tmp_txtbuff.pText = (D4D_TCHAR*)(pCnsl->pTxtArr + tmp_realLine * (pCnsl->txtArrSize.cx + 1) + tmp_winOff.cx);
211 
212  if((tmp_winOff.cx + _calc.charArrSize.cx) <= pCnsl->txtArrSize.cx)
213  {
214  if(tmp_font_proporcional)
215  tmp_txtbuff.printLen = D4D_CnslFindMaxTextLenght(tmp_txtbuff.pText, pCnsl->textFontId, tmp_winOff.cx, pCnsl->txtArrSize.cx);
216  else
217  tmp_txtbuff.printLen = _calc.charArrSize.cx;
218 
219  tmp_txtbuff.buffSize = 0;
220 
221  }
222  D4D_DrawTextRect(&tmp_point, &tmp_size, &tmp_txtbuff, clrT, clrB);
223 
224  tmp_point.y += tmp_size.cy;
225  }
226  }
227 
228  // redraw cursor
229  if(((D4D_INDEX_DELTA)(pData->cursorPos.y - tmp_winOff.cy) >= 0) && ((pData->cursorPos.y - tmp_winOff.cy) < _calc.charArrSize.cy) && (pData->cursorPos.x >= tmp_winOff.cx)) //cursor is on screen - check line and also and check the axis X
230  {
231  D4D_BOOL cursorVisible = D4D_FALSE;
232 
233  // Compute the real line in memory
234  tmp_realLine = (D4D_INDEX)((pData->lastLineIx + pData->cursorPos.y) % pCnsl->txtArrSize.cy);
235 
236  // found the right pointer of the text to draw in the text array
237  tmp_txtbuff.pText = (D4D_TCHAR*)(pCnsl->pTxtArr + tmp_realLine * (pCnsl->txtArrSize.cx + 1) + tmp_winOff.cx);
238 
239  // Check if the cursor is visible on the line
240 
241  tmp_txtbuff.printLen = D4D_CnslFindMaxTextLenght(tmp_txtbuff.pText, pCnsl->textFontId, tmp_winOff.cx, pData->cursorPos.x);
242 
243  if(*(tmp_txtbuff.pText + pData->cursorPos.x))
244  tmp_size.cx = D4D_GetCharWidth(pCnsl->textFontId, *(tmp_txtbuff.pText + pData->cursorPos.x));
245  else
246  tmp_size.cx = D4D_GetCharWidth(pCnsl->textFontId, ' ');
247 
248  tmp_point.x = D4D_GetTextBuffWidthTab(&tmp_txtbuff, NULL);
249 
250  if(tmp_font_proporcional)
251  {
252  if(tmp_point.x < (D4D_COOR)( _calc.txtGeom.sz.cx - tmp_size.cx))
253  cursorVisible = D4D_TRUE;
254  }
255  else
256  {
257  if(pData->cursorPos.x < (D4D_INDEX)(_calc.charArrSize.cx + tmp_winOff.cx))
258  cursorVisible = D4D_TRUE;
259  }
260 
261  if(cursorVisible)
262  {
263  tmp_point.y = (D4D_COOR)((pData->cursorPos.y - tmp_winOff.cy) * D4D_GetFontHeight(pCnsl->textFontId) + _calc.txtGeom.pnt.y);//??+1
264  tmp_point.x += _calc.txtGeom.pnt.x;
266 
267 
268 
269  // check the state of cursor and selected right color
270  if((!(pData->flags & D4D_CNSL_FLAGS_CURSORSTATE)) || (!tmp_txtbuff.pText[0]))
271  {// draw cursor
272  D4D_COLOR clr;
273 
274  if(pData->flags & D4D_CNSL_FLAGS_CURSORSTATE)
275  clr = clrB;
276  else
277  clr = clrT;
278 
279  tmp_point.y += (D4D_GetFontHeight(pCnsl->textFontId) - D4D_CNSL_CURSOR_HEIGHT - 1);
280  tmp_size.cy = D4D_CNSL_CURSOR_HEIGHT;
281 
282  D4D_FillRect(&tmp_point, &tmp_size, clr);
283  }
284  else
285  {
286  // Draw the original char
287  tmp_txtbuff.printOff = pData->cursorPos.x;
288  tmp_txtbuff.printLen = 1;
289  D4D_DrawTextRect(&tmp_point, &tmp_size, &tmp_txtbuff, clrT, clrB);
290  }
291  }
292  }
293 
295 }
296 
297 static void D4D_CnslOnInit(D4D_MESSAGE* pMsg)
298 {
299  D4D_OBJECT* pThis = pMsg->pObject;
300  D4D_CONSOLE* pCnsl = D4D_GET_CONSOLE(pMsg->pObject);
301 
302  D4D_CnslValue2Coor(pThis);
303 
304  if((_calc.charArrSize.cy < pCnsl->txtArrSize.cy)||(_calc.charArrSize.cx < pCnsl->txtArrSize.cx))
305  {
309 
313  }
314  else
315  {
318  }
319 
320 }
321 
322 
324 {
325 
326  D4D_CONSOLE* pCnsl = D4D_GET_CONSOLE(pMsg->pObject);
327 
328  pCnsl->pData->tickCounter++;
330  {
331  pCnsl->pData->tickCounter = 0;
334 
337  else
339  }
340 }
341 
342 /**************************************************************/
353  D4D_CONSOLE* pCnsl = D4D_GET_CONSOLE(pObj);
354  D4D_CNSL_DATA* pData = pCnsl->pData;
355  D4D_INDEX tmp_realLine;
356 
357  // Compute the real line in memory
358  tmp_realLine = (D4D_INDEX)((pData->lastLineIx + pData->cursorPos.y) % pCnsl->txtArrSize.cy);
359 
360  if(pData->flags & D4D_CNSL_FLAGS_CHECKLINE) {
361  pData->flags &= ~D4D_CNSL_FLAGS_CHECKLINE;
362  if(pData->cursorPos.x)
363  {
364  D4D_INDEX i;
365  D4D_TCHAR* pCh;
366 
367  pCh = (D4D_TCHAR*)(pCnsl->pTxtArr + tmp_realLine * (pCnsl->txtArrSize.cx + 1));
368 
369  for(i = 0; i < pData->cursorPos.x; i++) {
370  if(*pCh == 0) {
371  *pCh = ' ';
372  }
373  pCh++;
374  }
375  }
376  }
377 
378  // found the right pointer of the text to put new char in text array
379  *((D4D_TCHAR*)((pCnsl->pTxtArr + tmp_realLine * (pCnsl->txtArrSize.cx + 1)) + pData->cursorPos.x)) = ch;
380 
381  // move cursor on new char position
382  pData->cursorPos.x++;
383 
384 
385  // Check if printed char was last on line
386  if(pData->cursorPos.x >= pCnsl->txtArrSize.cx) {
387  D4D_CnslNewLine(pObj, D4D_TRUE);
388  return D4D_TRUE;
389  }
390 
391  return D4D_FALSE;
392 }
393 
394 void D4D_CnslScrollBarsFeedBack(D4D_OBJECT* pThis, D4D_INDEX old_position, D4D_INDEX new_position)
395 {
396  D4D_UNUSED(old_position);
397  D4D_UNUSED(new_position);
398 
400 
402 }
403 
404 
406 {
407  D4D_CNSL_DATA* pData = D4D_GET_CONSOLE_DATA(pThis);
408 
409 
411  return;
412 
413  D4D_CnslValue2Coor(pThis);
414 
416  {
417  if(pData->cursorPos.x < _calc.charArrSize.cx)
419  else
420  D4D_ScrlBrSetPosition(D4D_GET_LIST_BOX_SCROLL_BAR_HOR(pThis), (D4D_INDEX)(pData->cursorPos.x - _calc.charArrSize.cx / 2));
421  }
422 
424  {
425  if(pData->cursorPos.y < _calc.charArrSize.cy)
427  else
428  D4D_ScrlBrSetPosition(D4D_GET_LIST_BOX_SCROLL_BAR_VER(pThis), (D4D_INDEX)(pData->cursorPos.y - _calc.charArrSize.cy + 1));
429  }
430 
431 }
432 
433 //-----------------------------------------------------------------------------
434 // FUNCTION: D4D_CnslNewLine
435 // SCOPE: Console object external API function
436 // DESCRIPTION: The function move cursor on new line
437 //
438 // PARAMETERS: D4D_OBJECT_PTR pObj - pointer on console object
439 // D4D_BOOL returnCarrier - return carrier flag
440 //
441 // RETURNS: none
442 //-----------------------------------------------------------------------------
443 static void D4D_CnslNewLine(D4D_OBJECT_PTR pObj, D4D_BOOL returnCarrier) {
444  D4D_CONSOLE* pCnsl = D4D_GET_CONSOLE(pObj);
445  D4D_CNSL_DATA* pData = pCnsl->pData;
446 
447  // Check if the new line is last, so whole console will be scrolled by one line
448  if((pData->cursorPos.y + 1) >= pCnsl->txtArrSize.cy) {
449  // Increment the last line pointer
450  pData->lastLineIx++;
451 
452  // Check the overroll the buffer runs
453  if(pData->lastLineIx >= pCnsl->txtArrSize.cy)
454  pData->lastLineIx = 0;
455 
456  D4D_CnslClearLine(pObj, (D4D_INDEX)(pCnsl->txtArrSize.cy - 1));
457 
458  }else {
459  // Increment the cursor position
460  pData->cursorPos.y++;
461  }
462 
463 
464  if(returnCarrier)
465  {
466  pData->cursorPos.x = 0;
467  }else {
469  }
472 }
473 
474 /**************************************************************/
485 /******************************************************************************
486 * Begin of D4D_CONSOLE public functions
487 */
491 /**************************************************************************/
499 {
500 
501  D4D_INDEX i, j;
502  D4D_CONSOLE* pCnsl = D4D_GET_CONSOLE(pObj);
503  D4D_CNSL_DATA* pData = D4D_GET_CONSOLE_DATA(pObj);
504  D4D_BOOL wrap = D4D_FALSE;
505 
506  if(ch >= ' ') {
507  wrap = D4D_CnslPutCharInt(pObj, ch); //Put New char
508  }else {
509  switch(ch) {
510  case '\n': // new line
511  D4D_CnslNewLine(pObj, D4D_FALSE);
512  wrap = D4D_TRUE;
513  break;
514 
515  case '\r': // return carrier
516  pData->cursorPos.x = 0;
517  break;
518 
519  case '\t': // Tab
520  j = (D4D_INDEX)(pData->cursorPos.x % pCnsl->tabSize);
521 
522  if(!j)
523  j = pCnsl->tabSize;
524 
525  for(i = 0; i < j; j++)
526  if(D4D_CnslPutCharInt(pObj, ' ')) // if the tab go to new line end operation
527  {
528  wrap = D4D_TRUE;
529  break;
530  }
531  break;
532 
533  case '\b': // backspace
534  // if there is no needed return back to previous line
535  if(pData->cursorPos.x)
536  {
537  pData->cursorPos.x--; //Go back one char
538  D4D_CnslPutCharInt(pObj, ' '); //And put space char
539  }else
540  {
541  // needed return to previous line
542  if(pData->cursorPos.y)
543  {
544  D4D_INDEX i;
545  D4D_TCHAR* pCh;
546 
547  pData->cursorPos.y--;
548  pData->cursorPos.x = pCnsl->txtArrSize.cx;
549 
550  pCh = (D4D_TCHAR*)(pCnsl->pTxtArr + ((pData->lastLineIx + pData->cursorPos.y) % pCnsl->txtArrSize.cy) * (pCnsl->txtArrSize.cx + 1));
551 
552  // This setup all non space character including the last one
553  for(i = 0; i <= pData->cursorPos.x; i++)
554  {
555  if(*pCh == 0)
556  *pCh = ' ';
557  pCh++;
558  }
559  }
560  }
561 
562  break;
563  }
564  }
565 
569  return wrap;
570 }
571 
572 /**************************************************************************/
580 
581 D4D_BOOL wrap = D4D_FALSE;
582 D4D_POINT tmp_scrollbars;
583 
584  if(pText == NULL)
585  return D4D_FALSE;
586 
587  if(D4D_GET_LIST_BOX_SCROLL_BAR_HOR(pObj)->pData->flags & D4D_OBJECT_F_VISIBLE)
589 
590  tmp_scrollbars.y = D4D_GET_CONSOLE_DATA(pObj)->cursorPos.y;
591 
592 
593  while(*pText) {
594  if(D4D_CnslPutChar(pObj, *pText))
595  wrap = D4D_TRUE;
596 
597  pText++;
598  }
599 
600  if(tmp_scrollbars.y == D4D_GET_CONSOLE_DATA(pObj)->cursorPos.y)
601  {
602  if(D4D_GET_LIST_BOX_SCROLL_BAR_VER(pObj)->pData->flags & D4D_OBJECT_F_VISIBLE)
603  if(tmp_scrollbars.x != D4D_ScrlBrGetPosition(D4D_GET_LIST_BOX_SCROLL_BAR_VER(pObj)))
604  return wrap;
605 
607  }
608 
609  return wrap;
610 }
611 
612 /**************************************************************************/
620  D4D_CONSOLE* pCnsl = D4D_GET_CONSOLE(pObj);
621  D4D_CNSL_DATA* pData = pCnsl->pData;
622  D4D_INDEX tmp_realLine, ix;
623  D4D_TCHAR* tmp_charAdrr;
624 
625  if(line >= pCnsl->txtArrSize.cy)
626  return;
627 
628  // Compute the real line in memory
629  tmp_realLine = (D4D_INDEX)((pData->lastLineIx + line) % pCnsl->txtArrSize.cy);
630  tmp_charAdrr = (D4D_TCHAR*)((tmp_realLine * (pCnsl->txtArrSize.cx + 1)) + pCnsl->pTxtArr);
631 
632  for(ix = 0;ix <= pCnsl->txtArrSize.cx; ix++)
633  *(tmp_charAdrr++) = 0;
634 }
635 
636 /**************************************************************************/
643 void D4D_CnslGoToXY(D4D_OBJECT_PTR pObj, D4D_POINT newPosition) {
644  D4D_CONSOLE* pCnsl = D4D_GET_CONSOLE(pObj);
645  D4D_CNSL_DATA* pData = pCnsl->pData;
646 
647  if(newPosition.x >= pCnsl->txtArrSize.cx)
648  return;
649 
650  if(newPosition.y >= pCnsl->txtArrSize.cy)
651  return;
652 
653  pData->cursorPos = newPosition;
654 
656 }
657 
658 /**************************************************************************/
665 {
666  D4D_CNSL_DATA* pData = D4D_GET_CONSOLE_DATA(pObj);
667 
668  if(pObj == NULL)
669  return d4d_point_zero;
670 
671  return pData->cursorPos;
672 }
673 
674 /**************************************************************************/
681 {
682  if(pObj == NULL)
683  return;
684 
686 }
687 
688 /**************************************************************************/
697 {
698  if(pObj == NULL)
699  return;
700 
701  if(D4D_GET_LIST_BOX_SCROLL_BAR_HOR(pObj)->pData->flags & D4D_OBJECT_F_VISIBLE)
703 
704  if(D4D_GET_LIST_BOX_SCROLL_BAR_VER(pObj)->pData->flags & D4D_OBJECT_F_VISIBLE)
706 
707 }
708 
709 /**************************************************************************/
716 {
717  D4D_POINT res;
718 
719  if(pObj == NULL)
720  return d4d_point_zero;
721 
724 
725  return res;
726 }
727 
728 /**************************************************************************/
735  D4D_CONSOLE* pCnsl = D4D_GET_CONSOLE(pObj);
736  D4D_CNSL_DATA* pData = pCnsl->pData;
737 
738  LWord i,i_max;
739 
740  // Init the text array
741  i_max = (LWord)(pCnsl->txtArrSize.cy * (pCnsl->txtArrSize.cx + 1));
742 
743  for(i=0;i<i_max;i++)
744  pCnsl->pTxtArr[i] = 0;
745 
746  pData->cursorPos.x =0;
747  pData->cursorPos.y =0;
748 
749  pData->flags &= ~D4D_CNSL_FLAGS_CHECKLINE;
752 
753 }
754 /******************************************************************************
755 * End of public functions */
757 /******************************************************************************/
758 /**************************************************************/
768 /*******************************************************
769 *
770 * The CONSOLE message handler
771 *
772 *******************************************************/
773 
775 {
776  D4D_OBJECT* pThis = pMsg->pObject;
777 
778  switch(pMsg->nMsgId)
779  {
780  case D4D_MSG_DRAW:
781  D4D_ConsoleOnDraw(pMsg);
782  break;
783 
784  case D4D_MSG_ONINIT:
786  D4D_CnslOnInit(pMsg);
787  break;
788 
789 #ifdef D4D_LLD_MOUSE
791  D4D_FocusSet(pMsg->pScreen, pThis);
792  D4D_CaptureKeys(pThis);
793  break;
794 
796  if(D4D_GET_LIST_BOX_SCROLL_BAR_VER(pThis)->pData->flags & D4D_OBJECT_F_VISIBLE)
798  break;
800  if(D4D_GET_LIST_BOX_SCROLL_BAR_VER(pThis)->pData->flags & D4D_OBJECT_F_VISIBLE)
802  break;
803 #endif
804 
805 
806 #ifdef D4D_LLD_TCH
807  case D4D_MSG_TOUCHED:
808  D4D_FocusSet(pMsg->pScreen, pThis);
809  D4D_CaptureKeys(pThis);
810  break;
811 #endif
812  case D4D_MSG_KEYUP:
813  {
814  D4D_KEY_SCANCODE tmp_key = pMsg->prm.key;
815  // capture the keyboard if enter is pressed
816  if(tmp_key == D4D_KEY_SCANCODE_ENTER)
817  D4D_CaptureKeys(pThis);
818 
819  // exit capture
820  if(tmp_key == D4D_KEY_SCANCODE_ESC)
822  }
823  break;
824 
825  case D4D_MSG_TIMETICK:
826  #if (D4D_CNSL_CURSOR_BLINK_TICK_COUNTER > 0)
827  D4D_ConsoleTimeTick(pMsg);
828  #endif
829  break;
830 
831  case D4D_MSG_KILLFOCUS:
833  case D4D_MSG_SETFOCUS:
834  case D4D_MSG_SETCAPTURE:
835  case D4D_MSG_KILLCAPTURE:
837  break;
838 
839 
840  default:
841  // call the default behavior of all objects
842  D4D_ObjOnMessage(pMsg);
843  }
844 }
D4D_INDEX buffSize
size of text buffer array
Definition: d4d_string.h:103
static void D4D_ConsoleTimeTick(D4D_MESSAGE *pMsg)
Definition: d4d_console.c:323
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
D4D_OBJECT * D4D_GetParentObject(D4D_OBJECT *pObject)
Definition: d4d_object.c:498
#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
D4D_COLOR D4D_ObjectGetBckgFillColor(D4D_OBJECT *pObj)
Function return object current fill background color.
Definition: d4d_scheme.c:225
static void D4D_CnslUpdateScrollbars(D4D_OBJECT *pThis)
Definition: d4d_console.c:405
D4D_FONT_TYPE * D4D_GetFont(D4D_FONT ix)
Definition: d4d_font.c:340
#define _calc
Definition: d4d_console.c:79
D4D_TEXT_PROPERTIES text_properties
Text properties structure.
Definition: d4d_string.h:96
void D4D_FillRect(D4D_POINT *ppt, D4D_SIZE *psz, D4D_COLOR color)
Function draw filled rectangle on the screen.
void D4D_CnslEnsureVisible(D4D_OBJECT_PTR pObj)
The function update automatically the scroll bars to ensure visible position of cursor.
Definition: d4d_console.c:680
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
On Init message - is send for first time when the object is inicialized.
Definition: d4d_base.h:370
#define D4D_CNSL_CURSOR_BLINK_TICK_COUNTER
This is definition of console cursor blink time (in ticks of eGUI time ticks - D4D_TimeTickPut). If not defined, it sets to ( 1 ) as a default.
Definition: d4d_console.h:117
D4D object messages structure.
Definition: d4d_base.h:400
#define D4D_CNSL_CURSOR_HEIGHT
This is definition of console cursor height . If not defined, it sets to ( 1 ) as a default...
Definition: d4d_console.h:87
D4D_OBJECT_DATA_PTR pData
Pointer on runtime object data.
Definition: d4d_object.h:180
Mouse Whell Move Down message - is send in case that mouse whell move down is detected on this object...
Definition: d4d_base.h:390
D4D_POINT cursorPos
Definition: d4d_console.h:133
#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
D4D_COLOR D4D_ObjectGetForeFillColor(D4D_OBJECT *pObj)
Function return object current fill fore color.
Definition: d4d_scheme.c:208
#define D4D_DrawTextRect(ppt, psz, buffText, colorText, colorBkgd)
Function that draw text into defined rectangle on the screen.
void D4D_ScrlBrSetPosition(D4D_OBJECT_PTR pObj, D4D_INDEX position)
The function sets the scroll bar position.
D4D_FONT fontId
index of used font
Definition: d4d_string.h:104
void D4D_CnslSetScrollBarPosition(D4D_OBJECT_PTR pObj, D4D_INDEX hor, D4D_INDEX ver)
The function move the scroll bars on to new position if it&#39;s applicable.
Definition: d4d_console.c:696
#define D4D_CNSL_FLAGS_CHECKLINE
Definition: d4d_console.h:124
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.
void D4D_CnslGoToXY(D4D_OBJECT_PTR pObj, D4D_POINT newPosition)
The function move cursor on new position if possible.
Definition: d4d_console.c:643
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
Key Up message - is send when the object get new Key Up event.
Definition: d4d_base.h:377
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
The string properties type. This structure contains as Font as Text properties.
Definition: d4d_string.h:93
void D4D_ConsoleOnMessage(D4D_MESSAGE *pMsg)
Definition: d4d_console.c:774
#define D4D_OBJECT_DRAWFLAGS_COMPLETE
Draw complete flag.
Definition: d4d_base.h:361
void D4D_ScrlBrSetRange(D4D_OBJECT_PTR pObj, D4D_INDEX minimum, D4D_INDEX maximum)
The function sets the range of scroll bar scale.
void D4D_CnslClearLine(D4D_OBJECT_PTR pObj, D4D_INDEX line)
The function clear one line in console.
Definition: d4d_console.c:619
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_COOR lastLineIx
Definition: d4d_console.h:132
Mouse Left Button Release message - is send in case that mouse left release is detected on this objec...
Definition: d4d_base.h:384
D4D Driver private header file.
#define D4D_DEFSTR(str)
Macro that helps declare the strings in eGUI.
Definition: d4d_string.h:246
D4D_COOR cx
Size in axis X (width)
Definition: d4d_types.h:232
D4D_POINT D4D_CnslGetCursor(D4D_OBJECT_PTR pObj)
The function returns the cursor position.
Definition: d4d_console.c:664
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
D4D_FONT_FLAGS flags
Definition: d4d_font.h:189
D4D_FONT textFontId
Definition: d4d_console.h:145
#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
#define D4D_CNSL_SCRLBR_STEP_H
This is definition of console horizontal scroll bar step (in characters). If not defined, it sets to ( 8 ) as a default.
Definition: d4d_console.h:111
void D4D_ScrlBrSetStep(D4D_OBJECT_PTR pObj, D4D_INDEX page, D4D_INDEX step)
The function sets the step and page of scroll bar scale.
#define D4D_CNSL_SCRLBR_WIDTH
This is definition of console scroll bars height . If not defined, it sets to ( 20 ) as a default...
Definition: d4d_console.h:99
void D4D_ObjOnMessage(D4D_MESSAGE *pMsg)
Definition: d4d_object.c:443
void D4D_ShowObject(D4D_OBJECT_PTR pObject, D4D_BOOL bShow)
Function control visibility of object on screen.
Definition: d4d_object.c:92
D4D_FONT_DESCRIPTOR * pFontDescriptor
Definition: d4d_font.h:210
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
D4D_CNSL_DATA * pData
Definition: d4d_console.h:147
#define NULL
Type definition of null pointer.
Definition: d4d_types.h:184
#define D4D_FONT_FLAGS_FNT_WIDTH_PROPORTIONAL
Definition: d4d_font.h:154
#define D4D_GET_LIST_BOX_SCROLL_BAR_HOR(pObj)
Definition: d4d_console.h:161
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
D4D_STR_PROPERTIES * str_properties
pointer to string properties
Definition: d4d_string.h:105
D4D_COOR y
Coordination in axis Y.
Definition: d4d_types.h:226
#define D4D_OBJECT_F_NOTINIT
Definition: d4d_object.h:113
D4D_MSGID nMsgId
Type of message.
Definition: d4d_base.h:404
D4D_SIZE size
Size of the object.
Definition: d4d_object.h:170
D4D_INDEX tabSize
Definition: d4d_console.h:146
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_CNSL_FLAGS flags
Definition: d4d_console.h:134
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
#define D4D_GET_LIST_BOX_SCROLL_BAR_VER(pObj)
Definition: d4d_console.h:162
void D4D_CnslClearAll(D4D_OBJECT_PTR pObj)
The function clear whole console data.
Definition: d4d_console.c:734
#define D4D_CNSL_FLAGS_REDRAWLINE
Definition: d4d_console.h:126
#define D4D_GET_CONSOLE(pObj)
Definition: d4d_console.h:159
void D4D_ComputeGeometry(D4D_GEOMETRY *pGeometry, D4D_OBJECT *pObject)
Definition: d4d_base.c:1047
D4D_INDEX D4D_ScrlBrGetPosition(D4D_OBJECT_PTR pObj)
The function gets the scroll bar position.
D4D_TCHAR * pTxtArr
Definition: d4d_console.h:143
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 D4D_INDEX D4D_CnslFindMaxTextLenght(D4D_TCHAR *pText, D4D_FONT font, D4D_INDEX startOffset, D4D_INDEX maxLenght)
Definition: d4d_console.c:118
#define D4D_OBJECT_F_VISIBLE
Object after initialization is visible on the screen.
Definition: d4d_object.h:72
D4D_POINT D4D_CnslGetScrollBarPosition(D4D_OBJECT_PTR pObj)
The function returns the scroll bars position.
Definition: d4d_console.c:715
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
#define D4D_UNUSED(x)
Macro used just for notify compiler that the input parameter is not used.
Definition: d4d_base.h:504
static void D4D_CnslNewLine(D4D_OBJECT_PTR pObj, D4D_BOOL returnCarrier)
Definition: d4d_console.c:443
Type definition of eGUI size structure.
Definition: d4d_types.h:230
const D4D_OBJECT_SYS_FUNCTION d4d_consoleSysFunc
Definition: d4d_console.c:62
D4D_BOOL D4D_CnslPutString(D4D_OBJECT_PTR pObj, D4D_TCHAR *pText)
The function puts string on cursor position and updates cursor.
Definition: d4d_console.c:579
D4D_FONT_SIZE D4D_GetFontWidth(D4D_FONT ix)
Definition: d4d_font.c:398
static void D4D_ConsoleOnDraw(D4D_MESSAGE *pMsg)
Definition: d4d_console.c:145
void D4D_ScrlBrChangePosition(D4D_OBJECT_PTR pObj, D4D_INDEX_DELTA change)
The function change the scroll bar position.
sLWord D4D_INDEX_DELTA
Type definition of eGUI general index variables for signed offsets.
Definition: d4d_types.h:208
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
#define D4D_GET_CONSOLE_DATA(pObj)
Definition: d4d_console.h:160
D4D_OBJECT_DRAWFLAGS draw
Contains draw flags - is valid with D4D_MSG_DRAW and D4D_MSG_DRAWDONE message.
Definition: d4d_base.h:408
const D4D_POINT d4d_point_zero
Definition: d4d_base.c:75
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.
static void D4D_CnslValue2Coor(D4D_OBJECT *pThis)
Definition: d4d_console.c:82
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
static D4D_BOOL D4D_CnslPutCharInt(D4D_OBJECT_PTR pObj, D4D_TCHAR ch)
Definition: d4d_console.c:352
#define D4D_CNSL_FLAGS_CURSORSTATE
Definition: d4d_console.h:128
void D4D_InvalidateObject(D4D_OBJECT_PTR pObject, D4D_BOOL bComplete)
Function invalidate object to redraw on screen.
Definition: d4d_object.c:71
void D4D_CnslScrollBarsFeedBack(D4D_OBJECT *pThis, D4D_INDEX old_position, D4D_INDEX new_position)
Definition: d4d_console.c:394
Byte D4D_KEY_SCANCODE
Type definition of eGUI keys scan code.
Definition: d4d_types.h:304
D4D_INDEX tickCounter
Definition: d4d_console.h:135
#define D4D_CNSL_FLAGS_REDRAWCURSOR
Definition: d4d_console.h:127
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
D4D_BOOL D4D_CnslPutChar(D4D_OBJECT_PTR pObj, D4D_TCHAR ch)
The function puts one char on cursor position and updates cursor.
Definition: d4d_console.c:498
struct D4D_SCREEN_S * pScreen
Pointer to screen who is receiver of this message.
Definition: d4d_base.h:403
D4D_FONT_PROPERTIES font_properties
Font properties structure.
Definition: d4d_string.h:95
D4D_SIZE txtArrSize
Definition: d4d_console.h:144
static void D4D_CnslOnInit(D4D_MESSAGE *pMsg)
Definition: d4d_console.c:297
D4D_FONT_SIZE D4D_GetFontHeight(D4D_FONT ix)
Definition: d4d_font.c:381
Mouse Whell Move Up message - is send in case that mouse whell move up is detected on this object...
Definition: d4d_base.h:389
D4D_INDEX printOff
Offset of string that should be used (printed).
Definition: d4d_string.h:107
#define D4D_CNSL_SCRLBR_STEP_V
This is definition of console vertical scroll bar step (in lines on text). If not defined...
Definition: d4d_console.h:105
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
#define D4D_CNSL_FLAGS_REDRAWALL
Definition: d4d_console.h:125
union D4D_MESSAGE_S::@0 prm
Additional data for some type of messages.