eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_console.h
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 #ifndef __D4D_CONSOLE_H
47 #define __D4D_CONSOLE_H
48 
50 void D4D_CnslScrollBarsFeedBack(D4D_OBJECT* pThis, D4D_INDEX old_position, D4D_INDEX new_position);
51 
52 
53 /******************************************************************************
54 * D4D CONSOLE setting constants
55 *
56 */
62 #ifndef D4D_CNSL_F_DEFAULT
63  #define D4D_CNSL_F_DEFAULT (D4D_OBJECT_F_VISIBLE | D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_FOCUSRECT | D4D_OBJECT_F_TOUCHENABLE | D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_MOUSE_NORMAL | D4D_OBJECT_F_BEVEL_DENTED)
64 #endif
65 
68 #ifndef D4D_CNSL_F_SCRLBRS_DEFAULT
69  #define D4D_CNSL_F_SCRLBRS_DEFAULT (D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_TOUCHENABLE | D4D_OBJECT_F_FASTTOUCH | D4D_OBJECT_F_FOCUSRECT | D4D_OBJECT_F_MOUSE_NORMAL | D4D_OBJECT_F_BEVEL_RAISED)
70 #endif
71 
74 #ifndef D4D_CNSL_TXT_PRTY_DEFAULT
75  #define D4D_CNSL_TXT_PRTY_DEFAULT (D4D_ALIGN_H_LEFT_MASK | D4D_ALIGN_V_CENTER_MASK)
76 #endif
77 
80 #ifndef D4D_CNSL_FNT_PRTY_DEFAULT
81  #define D4D_CNSL_FNT_PRTY_DEFAULT ( 0 )
82 #endif
83 
86 #ifndef D4D_CNSL_CURSOR_HEIGHT
87  #define D4D_CNSL_CURSOR_HEIGHT ( 1 )
88 #endif
89 
92 #ifndef D4D_CNSL_STD_TAB_SIZE
93  #define D4D_CNSL_STD_TAB_SIZE ( 8 )
94 #endif
95 
98 #ifndef D4D_CNSL_SCRLBR_WIDTH
99  #define D4D_CNSL_SCRLBR_WIDTH ( 20 )
100 #endif
101 
104 #ifndef D4D_CNSL_SCRLBR_STEP_V
105  #define D4D_CNSL_SCRLBR_STEP_V ( 2 )
106 #endif
107 
110 #ifndef D4D_CNSL_SCRLBR_STEP_H
111  #define D4D_CNSL_SCRLBR_STEP_H ( 8 )
112 #endif
113 
116 #ifndef D4D_CNSL_CURSOR_BLINK_TICK_COUNTER
117  #define D4D_CNSL_CURSOR_BLINK_TICK_COUNTER ( 10 )
118 #endif
119 
123 
124 #define D4D_CNSL_FLAGS_CHECKLINE (0x01)
125 #define D4D_CNSL_FLAGS_REDRAWALL (0x02)
126 #define D4D_CNSL_FLAGS_REDRAWLINE (0x04)
127 #define D4D_CNSL_FLAGS_REDRAWCURSOR (0x10)
128 #define D4D_CNSL_FLAGS_CURSORSTATE (0x20)
129 
130 typedef struct D4D_CNSL_DATA_S
131 {
132  D4D_COOR lastLineIx; // index of last line
136  D4D_FONT_PROPERTIES fnt_properties; // propertis of used font for object strings
138 
139 // label configuration (goes to ROM by default)
140 
141 typedef struct
142 {
143  D4D_TCHAR* pTxtArr; // Pointer on text array that will use Console to store all lines
144  D4D_SIZE txtArrSize; // Size of two dimensional array for text
145  D4D_FONT textFontId; // Used font for whole text
146  D4D_INDEX tabSize; // TAb Size of console object
147  D4D_CNSL_DATA* pData; // Run time data needed for Console
148 } D4D_CONSOLE;
149 
150 
151 #define D4D_LIST_BOX_CHILD_SCROLL_BAR_HOR_IX 1
152 #define D4D_LIST_BOX_CHILD_SCROLL_BAR_VER_IX 2
153 
154 /******************************************************************************
155 * Macros
156 ******************************************************************************/
157 
158 // getting the CONSOLE structure from general OBJECT
159 #define D4D_GET_CONSOLE(pObj) ((D4D_CONSOLE*)((pObj)->pParam))
160 #define D4D_GET_CONSOLE_DATA(pObj) (D4D_GET_CONSOLE(pObj)->pData)
161 #define D4D_GET_LIST_BOX_SCROLL_BAR_HOR(pObj) ((D4D_OBJECT*)((pObj)->pRelations[D4D_LIST_BOX_CHILD_SCROLL_BAR_HOR_IX]))
162 #define D4D_GET_LIST_BOX_SCROLL_BAR_VER(pObj) ((D4D_OBJECT*)((pObj)->pRelations[D4D_LIST_BOX_CHILD_SCROLL_BAR_VER_IX]))
163 
164 /******************************************************************************
165 * D4D CONSOLE setting public macros
166 *
167 */
171 /**************************************************************************/
195 #define _D4D_DECLARE_CONSOLE(type, name, x, y, cx, cy, radius, pMargin, pParent, line_cnt, char_cnt, tabSize, flags, pScheme, fontId, pUser, pOnUsrMsg) \
196  static D4D_CNSL_DATA name##_data = { 0, {0, 0}, 0, 0, 0};\
197  static D4D_TCHAR name##_txtArray[line_cnt][char_cnt + 1];\
198  extern type D4D_OBJECT name##_scrollBarHor;\
199  extern type D4D_OBJECT name##_scrollBarVer;\
200  static const D4D_OBJECT * const name##_relations[] = {pParent, &name##_scrollBarHor, &name##_scrollBarVer, NULL};\
201  static type D4D_CONSOLE name##_params = \
202  { \
203  (D4D_TCHAR*)&name##_txtArray[0][0], /* pTextArr */ \
204  { char_cnt, line_cnt }, /* txtArrSize */ \
205  fontId, /* textFontId */ \
206  tabSize, /* tabSize */ \
207  &name##_data, /* pData */ \
208  }; \
209  \
210  D4D_DECLARE_OBJECT(type, name, x, y, cx, cy, radius, pMargin, name##_relations, pOnUsrMsg, &d4d_consoleSysFunc, &(name##_params), ((flags) | D4D_OBJECT_F_TIMETICK), pUser, pScheme)\
211  \
212  static const D4D_OBJECT* const name##_scrollBarsRelations[] = {&name, NULL};\
213  \
214  _D4D_DECLARE_SCROLL_BAR(type, name##_scrollBarHor, D4D_BORDER_WIDTH(flags), (D4D_COOR)(cy - 2*D4D_BORDER_WIDTH(flags) - D4D_CNSL_SCRLBR_WIDTH + 1), (D4D_COOR)(cx - D4D_CNSL_SCRLBR_WIDTH - 2 * D4D_BORDER_WIDTH(flags)), D4D_CNSL_SCRLBR_WIDTH, \
215  radius, NULL, name##_scrollBarsRelations, D4D_CNSL_F_SCRLBRS_DEFAULT, pScheme, (void*)&name, D4D_CnslScrollBarsFeedBack, NULL) \
216  \
217  _D4D_DECLARE_SCROLL_BAR(type, name##_scrollBarVer, (D4D_COOR)(cx - D4D_CNSL_SCRLBR_WIDTH - 2 * D4D_BORDER_WIDTH(flags) + 1), D4D_BORDER_WIDTH(flags), D4D_LIST_BOX_SCRLBR_WIDTH, (D4D_COOR)(cy - D4D_LIST_BOX_SCRLBR_WIDTH - 2*D4D_BEVEL_WIDTH),\
218  radius, NULL, name##_scrollBarsRelations, D4D_CNSL_F_SCRLBRS_DEFAULT, pScheme, (void*)&name, D4D_CnslScrollBarsFeedBack, NULL)
219 
220 /**************************************************************************/
241 #define D4D_DECLARE_CONSOLE(name, x, y, cx, cy, line_cnt, char_cnt, tabSize, flags, pScheme, fontId, pUser, pOnUsrMsg) \
242  _D4D_DECLARE_CONSOLE(D4D_CONST, name, x, y, cx, cy, 0, (D4D_MARGIN*)&d4d_marginDefault, NULL, line_cnt, char_cnt, tabSize, flags, pScheme, fontId, pUser, pOnUsrMsg)
243 
244 /**************************************************************************/
260 #define D4D_DECLARE_STD_CONSOLE(name, x, y, cx, cy, line_cnt, char_cnt, fontId) \
261  D4D_DECLARE_CONSOLE(name, x, y, cx, cy, line_cnt, char_cnt, D4D_CNSL_STD_TAB_SIZE, D4D_CNSL_F_DEFAULT, NULL, fontId, NULL, NULL)
262 
263 /**************************************************************************/
285 #define D4D_DECLARE_RCONSOLE(name, x, y, cx, cy, radius, line_cnt, char_cnt, tabSize, flags, pScheme, fontId, pUser, pOnUsrMsg) \
286  _D4D_DECLARE_CONSOLE(D4D_CONST, name, x, y, cx, cy, radius, (D4D_MARGIN*)&d4d_marginDefault, NULL, line_cnt, char_cnt, tabSize, flags, pScheme, fontId, pUser, pOnUsrMsg)
287 
288 /**************************************************************************/
305 #define D4D_DECLARE_STD_RCONSOLE(name, x, y, cx, cy, radius, line_cnt, char_cnt, fontId) \
306  D4D_DECLARE_RCONSOLE(name, x, y, cx, cy, radius, line_cnt, char_cnt, D4D_CNSL_STD_TAB_SIZE, D4D_CNSL_F_DEFAULT, NULL, fontId, NULL, NULL)
307 
308 
309 // IN RAM instantions macro
310 /**************************************************************************/
313 #define D4D_DECLARE_CONSOLE_INRAM(name, x, y, cx, cy, line_cnt, char_cnt, tabSize, flags, pScheme, fontId, pUser, pOnUsrMsg) \
314  _D4D_DECLARE_CONSOLE(D4D_NO_CONST, name, x, y, cx, cy, 0, (D4D_MARGIN*)&d4d_marginDefault, NULL, line_cnt, char_cnt, tabSize, flags, pScheme, fontId, pUser, pOnUsrMsg)
315 
316 /**************************************************************************/
319 #define D4D_DECLARE_STD_CONSOLE_INRAM(name, x, y, cx, cy, line_cnt, char_cnt, fontId) \
320  D4D_DECLARE_CONSOLE_INRAM(name, x, y, cx, cy, line_cnt, char_cnt, D4D_CNSL_STD_TAB_SIZE, D4D_CNSL_F_DEFAULT, NULL, fontId, NULL, NULL)
321 
322 // Rounded console definition
323 /**************************************************************************/
326 #define D4D_DECLARE_RCONSOLE_INRAM(name, x, y, cx, cy, radius, line_cnt, char_cnt, tabSize, flags, pScheme, fontId, pUser, pOnUsrMsg) \
327  _D4D_DECLARE_CONSOLE(D4D_NO_CONST, name, x, y, cx, cy, radius, (D4D_MARGIN*)&d4d_marginDefault, NULL, line_cnt, char_cnt, tabSize, flags, pScheme, fontId, pUser, pOnUsrMsg)
328 
329 /**************************************************************************/
332 #define D4D_DECLARE_STD_RCONSOLE_INRAM(name, x, y, cx, cy, radius, line_cnt, char_cnt, fontId) \
333  D4D_DECLARE_RCONSOLE_INRAM(name, x, y, cx, cy, radius, line_cnt, char_cnt, D4D_CNSL_STD_TAB_SIZE, D4D_CNSL_F_DEFAULT, NULL, fontId, NULL, NULL)
334 
336 /******************************************************************************
337 * Global variables
338 ******************************************************************************/
339 
340 
341 /******************************************************************************
342 * Global functions
343 ******************************************************************************/
344 
348 void D4D_CnslGoToXY(D4D_OBJECT_PTR pObj, D4D_POINT newPosition);
354 /*********************************************************
355 *
356 * Object API
357 *
358 *********************************************************/
359 
360 
361 #endif /* __D4D_CONSOLE_H */
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
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
Type definition of eGUI point structure.
Definition: d4d_types.h:223
D4D_POINT cursorPos
Definition: d4d_console.h:133
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
void D4D_CnslGoToXY(D4D_OBJECT_PTR pObj, D4D_POINT newPosition)
The function move cursor on new position if possible.
Definition: d4d_console.c:643
void D4D_CnslClearLine(D4D_OBJECT_PTR pObj, D4D_INDEX line)
The function clear one line in console.
Definition: d4d_console.c:619
D4D_COOR lastLineIx
Definition: d4d_console.h:132
Byte D4D_CNSL_FLAGS
Definition: d4d_console.h:122
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_FONT textFontId
Definition: d4d_console.h:145
unsigned char Byte
Type definition of Byte (unsigned 8-bit).
Definition: d4d_types.h:151
D4D_CNSL_DATA * pData
Definition: d4d_console.h:147
D4D_FONT_PROPERTIES fnt_properties
Definition: d4d_console.h:136
D4D_INDEX tabSize
Definition: d4d_console.h:146
D4D_CNSL_FLAGS flags
Definition: d4d_console.h:134
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_CnslClearAll(D4D_OBJECT_PTR pObj)
The function clear whole console data.
Definition: d4d_console.c:734
D4D_TCHAR * pTxtArr
Definition: d4d_console.h:143
The object system function needed for each object - this is part of D4D_OBJECT main structure...
Definition: d4d_object.h:134
D4D_POINT D4D_CnslGetScrollBarPosition(D4D_OBJECT_PTR pObj)
The function returns the scroll bars position.
Definition: d4d_console.c:715
LWord D4D_BOOL
Type definition of eGUI boolean.
Definition: d4d_types.h:204
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
void D4D_CnslScrollBarsFeedBack(D4D_OBJECT *pThis, D4D_INDEX old_position, D4D_INDEX new_position)
Definition: d4d_console.c:394
D4D_INDEX tickCounter
Definition: d4d_console.h:135
struct D4D_CNSL_DATA_S D4D_CNSL_DATA
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
D4D_SIZE txtArrSize
Definition: d4d_console.h:144
Byte D4D_FONT_PROPERTIES
Definition: d4d_font.h:116