EasyGUI
gui_private.h
1 
6 /*
7  * Copyright (c) 2019 Tilen MAJERLE
8  *
9  * Permission is hereby granted, free of charge, to any person
10  * obtaining a copy of this software and associated documentation
11  * files (the "Software"), to deal in the Software without restriction,
12  * including without limitation the rights to use, copy, modify, merge,
13  * publish, distribute, sublicense, and/or sell copies of the Software,
14  * and to permit persons to whom the Software is furnished to do so,
15  * subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
23  * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  *
29  * This file is part of EasyGUI library.
30  *
31  * Author: Tilen Majerle <tilen@majerle.eu>
32  */
33 #ifndef GUI_HDR_PRIVATE_H
34 #define GUI_HDR_PRIVATE_H
35 
36 /* C++ detection */
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
47 #include "gui/gui.h"
48 #include "gui/gui_text.h"
49 
50 #if GUI_CFG_OS
51 #include "system/gui_sys.h"
52 
53 #define GUI_SYS_MBOX_TYPE_TOUCH 0x01
54 #define GUI_SYS_MBOX_TYPE_KEYBOARD 0x02
55 #define GUI_SYS_MBOX_TYPE_REMOVE 0x03
56 #define GUI_SYS_MBOX_TYPE_TIMER 0x04
57 #define GUI_SYS_MBOX_TYPE_WIDGET_CREATED 0x05
58 #define GUI_SYS_MBOX_TYPE_INVALIDATE 0x06
59 
63 typedef struct {
64  uint32_t type;
65 } gui_mbox_msg_t;
66 
70 typedef struct {
71  gui_sys_thread_t thread_id;
72  gui_sys_mbox_t mbox;
73 } GUI_OS_t;
74 #endif /* GUI_CFG_OS */
75 
79 typedef struct {
83  uint32_t flags;
88  gui_handle_p window_active;
89  gui_handle_p focused_widget;
90  gui_handle_p focused_widget_prev;
97  gui_evt_param_t evt_param;
98  gui_evt_result_t evt_result;
99 
100 #if GUI_CFG_USE_TOUCH || __DOXYGEN__
103  gui_handle_p active_widget;
104  gui_handle_p active_widget_prev;
105 #endif /* GUI_CFG_USE_TOUCH */
106 
107 #if GUI_CFG_USE_TRANSLATE
108  gui_translate_t translate;
109 #endif /* GUI_CFG_USE_TRANSLATE */
110 
111 #if GUI_CFG_OS
112  GUI_OS_t OS;
113 #endif /* GUI_CFG_OS */
114 
117  uint8_t initialized;
118 } gui_t;
119 
120 extern gui_t GUI;
121 
126 #define GUI_RECT_MATCH(h1x1, h1y1, h1x2, h1y2, h2x1, h2y1, h2x2, h2y2) \
127  !( \
128  (h1x1) > (h2x2) || \
129  (h1y1) > (h2y2) || \
130  (h2x1) > (h1x2) || \
131  (h2y1) > (h1y2) \
132  )
133 
138 #define GUI_RECT_IS_INSIDE(h1x1, h1y1, h1x2, h1y2, h2x1, h2y1, h2x2, h2y2) (((h1x1) >= (h2x1)) && ((h1x2) <= (h2x2)) && ((h1y1) >= (h2y1)) && ((h1y2) <= (h2y2)))
139 
145 #define __GH(x) ((struct gui_handle *)(x))
146 
151 #define GUI_ASSERTPARAMS(c) do { \
152  if (!(c) || !(GUI.initialized)) { \
153  GUI_DEBUG("Assert param failed in file %s and line %d\r\n", (const char *)__FILE__, (int)__LINE__); \
154  return 0; \
155  } \
156 } while (0)
157 
162 #define GUI_ASSERTACTIVEWIN() do { \
163  if (GUI.window_active == NULL) { \
164  GUI_DEBUG("There is no active window for widget in file %s on line %d\r\n", (const char *)__FILE__, (int)__LINE__); \
165  return NULL; \
166  } \
167 } while (0)
168 
173 /* C++ detection */
174 #ifdef __cplusplus
175 }
176 #endif
177 
178 #endif /* GUI_HDR_PRIVATE_H */
GUI LCD structure.
Definition: gui_defs.h:389
Single touch data structure.
Definition: gui_defs.h:300
Linked list root structure for start and end widget in structure.
Definition: gui_defs.h:196
gui_linkedlistroot_t root
Definition: gui_private.h:92
gui_lcd_t lcd
Definition: gui_private.h:80
Structure of output results for widget callback.
Definition: gui_defs.h:1084
gui_timer_core_t timers
Definition: gui_private.h:93
gui_touch_data_t touch_old
Definition: gui_private.h:101
gui_linkedlistroot_t root_fonts
Definition: gui_private.h:95
GUI main object structure.
Definition: gui_private.h:79
gui_t GUI
GUI global structure.
Definition: gui.c:41
gui_handle_p focused_widget
Definition: gui_private.h:89
uint32_t flags
Definition: gui_private.h:83
GUI clipping management.
Definition: gui_defs.h:364
gui_handle_p active_widget_prev
Definition: gui_private.h:104
osMessageQId gui_sys_mbox_t
ESP system message queue ID type.
Definition: gui_sys_template.h:69
uint8_t initialized
Definition: gui_private.h:117
gui_display_t display
Definition: gui_private.h:85
gui_handle_p window_active
Definition: gui_private.h:88
osThreadId gui_sys_thread_t
ESP system thread ID type.
Definition: gui_sys_template.h:75
Internal touch structure used for widget callbacks.
Definition: gui_defs.h:311
gui_ll_t ll
Definition: gui_private.h:81
gui_handle_p active_widget
Definition: gui_private.h:103
gui_eventcallback_t evt_cb
Definition: gui_private.h:115
Structure of input parameters for widget callback.
Definition: gui_defs.h:1069
Core timer structure for GUI timers.
Definition: gui_defs.h:204
gui_handle_p focused_widget_prev
Definition: gui_private.h:90
Basic translation structure for internal use.
Definition: gui_defs.h:1209
void(* gui_eventcallback_t)(void)
Global event callback function declaration.
Definition: gui_defs.h:270
gui_display_t display_temp
Definition: gui_private.h:86
GUI Low-Level structure for drawing operations.
Definition: gui_defs.h:435
guii_touch_data_t touch
Definition: gui_private.h:102