eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_base.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_BASE_H
47 #define __D4D_BASE_H
48 
49 /******************************************************************************
50 * Includes
51 ******************************************************************************/
52 
53 /******************************************************************************
54 * D4D BASE setting constants
55 *
56 */
61 #define D4D_VERSION "v3.01"
62 
65 #ifndef D4D_MCU_TYPE
66  #define D4D_MCU_TYPE D4D_MK
67  #warning "There is no definition for D4D_MCU_TYPE in configuration file. The driver is using as default D4D_MK."
68 #endif
69 
72 #ifndef D4D_SCREEN_HISTORY
73  #define D4D_SCREEN_HISTORY 5
74 #endif
75 
76 
77 #ifdef D4D_ENABLE_AUTOSIZE
78 
80  #if D4D_ENABLE_AUTOSIZE != D4D_FALSE
81  #error The D4D_ENABLE_AUTOSIZE capability had removed from eGUI since version 3.00. For update your eGUI project just define size for all objects.
82  #endif
83 #endif
84 
87 #ifndef D4D_ROUND_CORNER_ENABLE
88  #define D4D_ROUND_CORNER_ENABLE D4D_FALSE
89 #endif
90 
93 #ifndef D4D_FONT_TABLE_DISABLED
94  #define D4D_FONT_TABLE_DISABLED D4D_FALSE
95  #warning "Font table is disabled by default, set the D4D_FONT_TABLE_DISABLED to D4D_TRUE in config file."
96 #endif
97 
100 #ifndef D4D_SCREEN_SIZE_LONGER_SIDE
101  #define D4D_SCREEN_SIZE_LONGER_SIDE 320
102  #warning "The D4D configuration file doesn't contains the resolution information for longer axis. The D4D sets this value to default: 320 pixels."
103 #endif
104 
107 #ifndef D4D_SCREEN_SIZE_SHORTER_SIDE
108  #define D4D_SCREEN_SIZE_SHORTER_SIDE 240
109  #warning "The D4D configuration file doesn't contains the resolution information for shorter axis. The D4D sets this value to default: 240 pixels."
110 #endif
111 
114 #ifndef D4D_MCU_BUS_CLOCK
115  #define D4D_MCU_BUS_CLOCK 24000000L
116 #endif
117 
120 #ifndef D4D_COLOR_SYSTEM_FORE
121  #define D4D_COLOR_SYSTEM_FORE D4D_COLOR_YELLOW
122 #endif
123 
126 #ifndef D4D_COLOR_SYSTEM_BCKG
127  #define D4D_COLOR_SYSTEM_BCKG D4D_COLOR_BLACK
128 #endif
129 
132 #ifndef D4D_FONT_SYSTEM_DEFAULT
133  #define D4D_FONT_SYSTEM_DEFAULT 0
134 #endif
135 
138 #ifndef D4D_BMP_EXTSRC_SUPPORT_D4D
139  #define D4D_BMP_EXTSRC_SUPPORT_D4D D4D_FALSE
140 #endif
141 
144 #ifndef D4D_BMP_EXTSRC_SUPPORT_BMP
145  #define D4D_BMP_EXTSRC_SUPPORT_BMP D4D_FALSE
146 #endif
147 
150 #ifndef D4D_EXTSRC_TEXT_ENABLE
151  #define D4D_EXTSRC_TEXT_ENABLE D4D_FALSE
152 #endif
153 
156 #ifndef D4D_EXTSRC_FILE_ENABLE
157  #if (D4D_BMP_EXTSRC_SUPPORT_BMP != D4D_FALSE) || (D4D_BMP_EXTSRC_SUPPORT_D4D != D4D_FALSE) || (D4D_FNT_EXTSRC_SUPPORT != D4D_FALSE)
158  #define D4D_EXTSRC_FILE_ENABLE D4D_TRUE
159  #else
160  #define D4D_EXTSRC_FILE_ENABLE D4D_FALSE
161  #endif
162 #endif
163 
166 #ifndef D4D_EXTSRC_BUFF_SIZE
167  #define D4D_EXTSRC_BUFF_SIZE 64
168 #endif
169 
172 #ifndef D4D_LLD_FLUSH_ELEMENT
173  #define D4D_LLD_FLUSH_ELEMENT D4D_FALSE
174 #endif
175 
178 #ifndef D4D_DEBUG
179  #define D4D_DEBUG D4D_FALSE
180 #endif
181 
183 #define D4D_ENDIAN_BIG 0
184 
185 #define D4D_ENDIAN_LITTLE 1
186 
189 #ifndef D4D_ENDIAN
190  #if (D4D_MCU_TYPE == D4D_MK)
191  #define D4D_ENDIAN D4D_ENDIAN_LITTLE
192  #else // for other cases (this should not work for every cases)
193  #define D4D_ENDIAN D4D_ENDIAN_BIG
194  #endif
195 #endif
196 
197 /*********************************************************
198 *
199 * D4D align constants
200 *
201 *********************************************************/
202 
203 
216  #define D4D_ALIGN_MASK (0x0F)
217 
219  #define D4D_ALIGN_H_MASK (0x03)
220 
221  #define D4D_ALIGN_H_LEFT_MASK (0x00)
222 
223  #define D4D_ALIGN_H_RIGHT_MASK (0x01)
224 
225  #define D4D_ALIGN_H_CENTER_MASK (0x02)
226 
228  #define D4D_ALIGN_V_MASK (0x0C)
229 
230  #define D4D_ALIGN_V_TOP_MASK (0x00)
231 
232  #define D4D_ALIGN_V_BOTTOM_MASK (0x04)
233 
234  #define D4D_ALIGN_V_CENTER_MASK (0x08)
235 
238 /*********************************************************
239 *
240 * keys setting constants
241 *
242 *********************************************************/
243 
244 
245 
248 #ifndef D4D_KEY_UP
249  #define D4D_KEY_UP 0x01
250 #endif
251 
253 #ifndef D4D_KEY_DOWN
254  #define D4D_KEY_DOWN 0x02
255 #endif
256 
258 #ifndef D4D_KEY_LEFT
259  #define D4D_KEY_LEFT 0x04
260 #endif
261 
263 #ifndef D4D_KEY_RIGHT
264  #define D4D_KEY_RIGHT 0x08
265 #endif
266 
268 #ifndef D4D_KEY_ENTER
269  #define D4D_KEY_ENTER 0x10
270 #endif
271 
273 #ifndef D4D_KEY_ESC
274  #define D4D_KEY_ESC 0x20
275 #endif
276 
279 #ifndef D4D_KEY_SCANCODE_UP
280  #define D4D_KEY_SCANCODE_UP 0x51
281 #endif
282 
284 #ifndef D4D_KEY_SCANCODE_DOWN
285  #define D4D_KEY_SCANCODE_DOWN 0x50
286 #endif
287 
289 #ifndef D4D_KEY_SCANCODE_LEFT
290  #define D4D_KEY_SCANCODE_LEFT 0x4B
291 #endif
292 
294 #ifndef D4D_KEY_SCANCODE_RIGHT
295  #define D4D_KEY_SCANCODE_RIGHT 0x4D
296 #endif
297 
299 #ifndef D4D_KEY_SCANCODE_ENTER
300  #define D4D_KEY_SCANCODE_ENTER 0x1C
301 #endif
302 
304 #ifndef D4D_KEY_SCANCODE_ESC
305  #define D4D_KEY_SCANCODE_ESC 0x01
306 #endif
307 
309 #define D4D_KEY_SCANCODE_KEYMASK 0x7F
310 
311 #define D4D_KEY_SCANCODE_RELEASEMASK 0x80
312 
315 #ifndef D4D_KEY_FUNC_FOCUS_NEXT
316  #define D4D_KEY_FUNC_FOCUS_NEXT D4D_KEY_SCANCODE_DOWN
317 #endif
318 
321 #ifndef D4D_KEY_FUNC_FOCUS_PREV
322  #define D4D_KEY_FUNC_FOCUS_PREV D4D_KEY_SCANCODE_UP
323 #endif
324 
327 #ifndef D4D_KEYS_BUFF_LENGTH
328  #define D4D_KEYS_BUFF_LENGTH 4
329 #endif
330 
331 /*********************************************************
332 *
333 * touch screen constants
334 *
335 *********************************************************/
336 
339 #ifndef D4DTCH_CALIB_CROSS_OFFSET
340  #define D4DTCH_CALIB_CROSS_OFFSET 30
341 #endif
342 
345 /******************************************************************************
346 * Internal constants
347 ******************************************************************************/
348 #if D4D_SCREEN_SIZE_SHORTER_SIDE > D4D_SCREEN_SIZE_LONGER_SIDE
349  #warning "The D4D_SCREEN_SIZE_SHORTER_SIDE macro has greater value then D4D_SCREEN_SIZE_LONGER_SIDE in d4d_cfg.h file. Please check!"
350 #endif
351 
352 /******************************************************************************
353 * D4D Base types
354 *
355 */
360 
361 #define D4D_OBJECT_DRAWFLAGS_COMPLETE (0x01)
362 #define D4D_OBJECT_DRAWFLAGS_FOCUSED (0x02)
363 #define D4D_OBJECT_DRAWFLAGS_CAPTURING (0x04)
364 #define D4D_OBJECT_DRAWFLAGS_STATE (0x08)
365 
366 
367 typedef enum
368 {
394 } D4D_MSGID;
395 
396 /* the message object */
397 struct D4D_OBJECT_S;
398 
400 typedef struct D4D_MESSAGE_S
401 {
405 
406  union
407  {
410 
411  } prm;
412 
413 } D4D_MESSAGE;
414 
415 
416 typedef enum
417 {
421 
422 /*********************************************************
423 *
424 * global events
425 *
426 *********************************************************/
427 
429 typedef enum
430 {
437 
439 } D4D_EVENTID;
440 
442 /******************************************************************************
443 * Internal types
444 ******************************************************************************/
445 
446 // Internal keys buffer structure
447 typedef struct
448 {
453 
454 // Internal touch screen status
456 
457 #define D4D_TCHSCR_STATUS_TOUCHED (0x01) // The new touch has to be 0x01
458 #define D4D_TCHSCR_STATUS_RESERVED (0x02)
459 #define D4D_TCHSCR_STATUS_NEWTOUCH (0x04)
460 #define D4D_TCHSCR_STATUS_RESERVED1 (0x08)
461 #define D4D_TCHSCR_STATUS_LOSTTOUCH (0x10)
462 #define D4D_TCHSCR_STATUS_NEWRAWEVENT (0x20)
463 #define D4D_TCHSCR_STATUS_NEWEVENT (0x40)
464 #define D4D_TCHSCR_STATUS_CHECKTOUCH (0x80)
465 
466 #define D4D_TCHSCR_STATUS_EVENTS (0xE0)
467 
468 // System flags type
470 
471 // System flag - TimeTick
472 #define D4D_SYSTEM_F_TIMETICK (0x01)
473 #define D4D_SYSTEM_F_SYSTEM_KEYS_DISABLE (0x02)
474 
475 /******************************************************************************
476 * D4D Base macros
477 *
478 */
482 /**************************************************************************/
488 #define D4D_SWAP_WORD(x) D4D_SwapWord(x)
489 
490 /**************************************************************************/
497 #define D4D_LOG_EXOR(a,b) (!!(a) ^ !!(b))
498 
499 /**************************************************************************/
504 #define D4D_UNUSED(x) (void)(x);
505 
506 /**************************************************************************/
511 #define D4D_TEXT_LEN(txt) (sizeof((txt)) / sizeof(D4D_TCHAR))
512 
515 /*********************************************************
516 *
517 * internal macros
518 *
519 *********************************************************/
520 #define D4D_CONST const
521 #define D4D_NO_CONST
522 
523 #define D4D_GetKeys() 0 // Just for backward compatibility
524 /*********************************************************
525 *
526 * external macros
527 *
528 *********************************************************/
529 
530 /******************************************************************************
531 * Begin of D4D_BASE public functions
532 */
536 /**************************************************************************/
544 #define D4D_GetTextBuffWidthTabAdj(text_buffer, pTab) D4D_GetTextBuffWidthTab(text_buffer, pTab)
545 
546 /**************************************************************************/
553 #define D4D_GetTextBuffWidth(text_buffer) D4D_GetTextBuffWidthTab(text_buffer, NULL)
554 
555 /******************************************************************************
556 * Global call back functions
557 ******************************************************************************/
558 
559 /**************************************************************************/
564 #ifdef D4D_INPUT_EVENT_CALLBACK
565  extern void D4D_INPUT_EVENT_CALLBACK(void);
566 #endif
567 
568 
569 /******************************************************************************
570 * End of public functions */
572 /******************************************************************************/
573 
574 /******************************************************************************
575 * Global variables
576 ******************************************************************************/
577 
578 // global shared memory used by multiple modules as temporary storage
579 #define D4D_SCRATCHPAD_SIZE 48
581 
582 // assert macro
583 #define D4D_ASSERT(cond) if(!(cond)) for(;;)
584 
585 extern const D4D_MARGIN d4d_marginDefault;
586 
587 #endif /* __D4D_BASE_H */
588 
589 
590 
591 
592 
593 
594 
595 
596 
597 
UnTouched message - is send when the screen is untouched.
Definition: d4d_base.h:382
Draw Done message - is send after the object is redrawed.
Definition: d4d_base.h:372
Mouse Left Button Click message - is send in case that mouse left click is detected on this object...
Definition: d4d_base.h:383
Byte D4D_TOUCHSCREEN_STATUS
Definition: d4d_base.h:455
On Reload.
Definition: d4d_base.h:435
Mouse Middle Button Click message - is send in case that mouse middle click is detected on this objec...
Definition: d4d_base.h:387
On Init message - is send for first time when the object is inicialized.
Definition: d4d_base.h:370
D4D object messages structure.
Definition: d4d_base.h:400
Keep it on end of list (there is stored count of events)
Definition: d4d_base.h:438
Mouse Right Button Click message - is send in case that mouse right click is detected on this object...
Definition: d4d_base.h:385
Mouse Whell Move Down message - is send in case that mouse whell move down is detected on this object...
Definition: d4d_base.h:390
On Change done (complete change is finished.
Definition: d4d_base.h:434
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
struct D4D_MESSAGE_S D4D_MESSAGE
D4D object messages structure.
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
Auto Touched message - is send when the object is still keep touch by touch screen driver ...
Definition: d4d_base.h:380
Mouse Right Button Release message - is send in case that mouse right release is detected on this obj...
Definition: d4d_base.h:386
#define D4D_SCRATCHPAD_SIZE
Call back function raised by any new input event (touch, mouse, keys).
Definition: d4d_base.h:579
Mouse Left Button Release message - is send in case that mouse left release is detected on this objec...
Definition: d4d_base.h:384
const D4D_MARGIN d4d_marginDefault
Definition: d4d_base.c:77
unsigned char Byte
Type definition of Byte (unsigned 8-bit).
Definition: d4d_types.h:151
D4D_MSG_HANDLER_ACTION
Definition: d4d_base.h:416
Mouse Middle Button Release message - is send in case that mouse middle release is detected on this o...
Definition: d4d_base.h:388
Byte d4d_scratchPad[D4D_SCRATCHPAD_SIZE]
Definition: d4d_base.c:56
D4D_EVENTID
D4D events that is handled by object callback functions.
Definition: d4d_base.h:429
D4D_MSGID nMsgId
Type of message.
Definition: d4d_base.h:404
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
The object main structure type definition.
Definition: d4d_object.h:167
Draw message - is send when the object should be redrawed.
Definition: d4d_base.h:371
Lost Touch message - is send when the screen is still touch but the coordination leaves the original ...
Definition: d4d_base.h:381
The return value of user/application message function - continue handling of message by eGUI...
Definition: d4d_base.h:418
Touched message - is send when the object is touched by touch screen driver.
Definition: d4d_base.h:379
#define D4D_KEYS_BUFF_LENGTH
This macro is used to specify leght of keybord events buffer. If not defined, it sets to 4 events as ...
Definition: d4d_base.h:328
Mouse Cursor Enter message - is send in case that mouse cursor enter to object area.
Definition: d4d_base.h:391
Kill Capture message - is send when the object is losing capture keys status.
Definition: d4d_base.h:376
D4D_OBJECT_DRAWFLAGS draw
Contains draw flags - is valid with D4D_MSG_DRAW and D4D_MSG_DRAWDONE message.
Definition: d4d_base.h:408
D4D_MSGID
D4D object messages types enumeration.
Definition: d4d_base.h:367
The screen structure type. The main screen structure that contains all needed data to run the eGUI sc...
Definition: d4d_screen.h:162
The return value of user/application message function - skip handling of message by eGUI...
Definition: d4d_base.h:419
Set Capture message - is send when the object is getting capture keys status.
Definition: d4d_base.h:375
On Click Event.
Definition: d4d_base.h:431
On Change Event.
Definition: d4d_base.h:433
On Double Click Event.
Definition: d4d_base.h:432
Byte D4D_SYSTEM_FLAGS
Definition: d4d_base.h:469
Byte D4D_KEY_SCANCODE
Type definition of eGUI keys scan code.
Definition: d4d_types.h:304
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
struct D4D_SCREEN_S * pScreen
Pointer to screen who is receiver of this message.
Definition: d4d_base.h:403
Mouse Whell Move Up message - is send in case that mouse whell move up is detected on this object...
Definition: d4d_base.h:389
Dummy message - could be strached.
Definition: d4d_base.h:369
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.
Type definition of eGUI client area margin structure.
Definition: d4d_types.h:244
Mouse Cursor Leave message - is send in case that mouse cursor leave the object area.
Definition: d4d_base.h:392