eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_menu.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_MENU_H
47 #define __D4D_MENU_H
48 
50 void D4D_MenuScrollBarsFeedBack(D4D_OBJECT* pThis, D4D_INDEX old_position, D4D_INDEX new_position);
51 /******************************************************************************
52 * D4D MENU setting constants
53 *
54 */
58 //********************* Menu flags for button specific flags *****************
69  #define D4D_MENU_F_INDEX (0x01 << D4D_OBJECT_F_OBJECT_SHIFT)
70  #define D4D_MENU_F_SIDEBAR (0x02 << D4D_OBJECT_F_OBJECT_SHIFT)
71 
75 #ifndef D4D_MENU_F_DEFAULT
76  #define D4D_MENU_F_DEFAULT (D4D_OBJECT_F_VISIBLE | D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_TOUCHENABLE | D4D_OBJECT_F_MOUSE_NORMAL | D4D_OBJECT_F_BEVEL_RAISED | D4D_MENU_F_INDEX | D4D_MENU_F_SIDEBAR)
77 #endif
78 
81 #ifndef D4D_MENU_F_SCRLBRS_DEFAULT
82  #define D4D_MENU_F_SCRLBRS_DEFAULT (D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_TOUCHENABLE | D4D_OBJECT_F_FASTTOUCH | D4D_OBJECT_F_MOUSE_NORMAL)
83 #endif
84 
87 #ifndef D4D_MENU_SCRLBR_WIDTH
88  #define D4D_MENU_SCRLBR_WIDTH ( 20 )
89 #endif
90 
93 #ifndef D4D_MENU_SCRLBR_STEP
94  #define D4D_MENU_SCRLBR_STEP ( 1 )
95 #endif
96 
99 #ifndef D4D_MENU_TXT_PRTY_DEFAULT
100  #define D4D_MENU_TXT_PRTY_DEFAULT (D4D_ALIGN_H_CENTER_MASK | D4D_ALIGN_V_CENTER_MASK)
101 #endif
102 
105 #ifndef D4D_MENU_FNT_PRTY_DEFAULT
106  #define D4D_MENU_FNT_PRTY_DEFAULT ( 0 )
107 #endif
108 
111 #ifndef D4D_MENU_IX_FNT_PRTY_DEFAULT
112  #define D4D_MENU_IX_FNT_PRTY_DEFAULT ( 0 )
113 #endif
114 
117 #ifndef D4D_MENU_IX_TXT_PRTY_DEFAULT
118  #define D4D_MENU_IX_TXT_PRTY_DEFAULT ( D4D_ALIGN_H_CENTER_MASK | D4D_ALIGN_V_CENTER_MASK )
119 #endif
120 
123 #ifndef D4D_MENU_ITEM_FNT_PRTY_DEFAULT
124  #define D4D_MENU_ITEM_FNT_PRTY_DEFAULT ( 0 )
125 #endif
126 
129 #ifndef D4D_MENU_ITEM_TXT_PRTY_DEFAULT
130  #define D4D_MENU_ITEM_TXT_PRTY_DEFAULT ( D4D_ALIGN_V_CENTER_MASK | D4D_ALIGN_H_LEFT_MASK )
131 #endif
132 
135 /******************************************************************************
136 * D4D MENU setting public types
137 *
138 */
144 
145 /**************************************************************************/
152 typedef void (*D4D_MENU_ON_CLICK)(D4D_OBJECT* pThis, D4D_MENU_INDEX ix);
153 
154 
157 /******************************************************************************
158 * Private Types
159 ******************************************************************************/
160 
161 // Menu configuration (goes to ROM by default)
162 typedef struct
163 {
165  const D4D_BMP* pIcon; // Item Icon
166  void* pUser;
168 
169 typedef struct
170 {
173 } D4D_MENU_DATA;
174 
175 typedef struct
176 {
177  D4D_STRING title_text; // menu title text
180  D4D_MENU_INDEX posCnt; // Number of visiable position
181  D4D_COOR textOff; // text offset between individual item on screen
182  const D4D_BMP* pIcon; // Title Icon
183  D4D_MENU_DATA* pData; // Menu volatile data struct
186 } D4D_MENU;
187 
188 
189 /******************************************************************************
190 * Macros
191 ******************************************************************************/
192 #define D4D_MENU_CHILD_SCROLL_BAR_VER_IX 1
193 
194 // getting the MENU structure from general OBJECT
195 #define D4D_GET_MENU(pObj) ((D4D_MENU*)((pObj)->pParam))
196 
197 #define D4D_GET_MENU_SCROLL_BAR_HOR(pObj) ((D4D_OBJECT*)((pObj)->pRelations[D4D_MENU_CHILD_SCROLL_BAR_VER_IX]))
198 
199 /******************************************************************************
200 * D4D MENU setting public macros
201 *
202 */
206 /**************************************************************************/
235 #define _D4D_DECLARE_MENU_BEGIN(type, name, title_text, title_font, x, y, cx, cy, radius, pMargin, pParent, flags, pScheme,\
236  indexFontId, itemsFontId, posCnt, menuItemsOff, pIcon, pUser, pOnClick, pOnUsrMsg) \
237  extern type D4D_MENU_ITEM name##_items[];\
238  extern D4D_OBJECT name##_scrollBarVer;\
239  static const D4D_OBJECT * name##_relations[] = {pParent, &name##_scrollBarVer, NULL};\
240  static D4D_MENU_DATA name##_data = { 0, 0};\
241  static D4D_STR_PROPERTIES name##_strPrties = { D4D_MENU_FNT_PRTY_DEFAULT , D4D_MENU_TXT_PRTY_DEFAULT }; \
242  static type D4D_MENU name##_params = \
243  { \
244  { title_text, D4D_TEXT_LEN(title_text), title_font, &name##_strPrties, D4D_OBJECT_MAX_TEXT_LEN(title_text), 0}, \
245  indexFontId, \
246  itemsFontId, \
247  posCnt, \
248  menuItemsOff, \
249  pIcon, \
250  &(name##_data), \
251  (const D4D_MENU_ITEM*)&(name##_items[0]),\
252  pOnClick, \
253  }; \
254  \
255  D4D_DECLARE_OBJECT(type, name, x, y, cx, cy, radius, pMargin, name##_relations, pOnUsrMsg, &d4d_menuSysFunc, &(name##_params), flags, pUser, pScheme)\
256  \
257  static const D4D_OBJECT* const name##_scrollBarRelations[] = {&name, NULL};\
258  \
259  _D4D_DECLARE_SCROLL_BAR(D4D_NO_CONST, name##_scrollBarVer, 20, 100, 100, 20, radius, NULL, name##_scrollBarRelations, D4D_MENU_F_SCRLBRS_DEFAULT, pScheme, NULL, D4D_MenuScrollBarsFeedBack, NULL) \
260  \
261  type D4D_MENU_ITEM name##_items[] = {
262 
263 /**************************************************************************/
276 #define D4D_DECLARE_MENU_ITEM(pText, pIcon) { {(pText), D4D_TEXT_LEN(pText), 0, NULL, D4D_OBJECT_MAX_TEXT_LEN(pText), 0}, pIcon, NULL},
277 
278 /**************************************************************************/
292 #define D4D_DECLARE_MENU_ITEM_FULL(pText, pIcon, pUser) { {(pText), D4D_TEXT_LEN(pText), 0, NULL, D4D_OBJECT_MAX_TEXT_LEN(pText), 0}, pIcon, (void*)pUser},
293 
294 /**************************************************************************/
305 #define _D4D_DECLARE_MENU_END() { {NULL, 0, 0, NULL, 0, 0}, NULL, NULL} };
306 
307 /**************************************************************************/
319 #define D4D_DECLARE_MENU_END(name) _D4D_DECLARE_MENU_END()
320 
321 
322 /**************************************************************************/
348 #define D4D_DECLARE_MENU_BEGIN(name, title_text, title_font, x, y, cx, cy, flags, pScheme,\
349  indexFontId, itemsFontId, posCnt, menuItemsOff, pIcon, pUser, pOnClick, pOnUsrMsg) \
350  _D4D_DECLARE_MENU_BEGIN(D4D_CONST, name, title_text, title_font, x, y, cx, cy, 0, NULL, NULL, flags, pScheme,\
351  indexFontId, itemsFontId, posCnt, menuItemsOff, pIcon, pUser, pOnClick, pOnUsrMsg)
352 
353 /**************************************************************************/
373 #define D4D_DECLARE_STD_MENU_BEGIN(name, title_text, title_font, x, y, cx, cy, indexFontId, itemsFontId, pIcon, pOnClick) \
374  D4D_DECLARE_MENU_BEGIN(name, title_text, title_font, x, y, cx, cy, (D4D_MENU_F_DEFAULT), NULL,\
375  IndexFontId, ItemsFontId, 0, 0, pIcon, NULL, pOnClick, NULL)
376 
377 // Rounded menu definition
378 /**************************************************************************/
405 #define D4D_DECLARE_RMENU_BEGIN(name, title_text, title_font, x, y, cx, cy, radius, flags, pScheme,\
406  indexFontId, itemsFontId, posCnt, menuItemsOff, pIcon, pUser, pOnClick, pOnUsrMsg) \
407  _D4D_DECLARE_MENU_BEGIN(D4D_CONST, name, title_text, title_font, x, y, cx, cy, radius, NULL, NULL, flags, pScheme,\
408  indexFontId, itemsFontId, posCnt, menuItemsOff, pIcon, pUser, pOnClick, pOnUsrMsg)
409 
410 
411 
412 /**************************************************************************/
433 #define D4D_DECLARE_STD_RMENU_BEGIN(name, title_text, title_font, x, y, cx, cy, radius, indexFontId, itemsFontId, pIcon, pOnClick) \
434  D4D_DECLARE_RMENU_BEGIN(name, title_text, title_font, x, y, cx, cy, radius, (D4D_MENU_F_DEFAULT), NULL,\
435  indexFontId, itemsFontId, 0, 0, pIcon, NULL, pOnClick, NULL)
436 
437 
438 //IN RAM instantions macros
439 /**************************************************************************/
442 #define D4D_DECLARE_MENU_BEGIN_INRAM(name, title_text, title_font, x, y, cx, cy, flags, pScheme,\
443  indexFontId, itemsFontId, posCnt, menuItemsOff, pIcon, pUser, pOnClick, pOnUsrMsg) \
444  _D4D_DECLARE_MENU_BEGIN(D4D_NO_CONST, name, title_text, title_font, x, y, cx, cy, 0, NULL, NULL, flags, pScheme,\
445  indexFontId, itemsFontId, posCnt, menuItemsOff, pIcon, pUser, pOnClick, pOnUsrMsg)
446 
447 
448 /**************************************************************************/
451 #define D4D_DECLARE_STD_MENU_BEGIN_INRAM(name, title_text, title_font, x, y, cx, cy, IndexFontId, ItemsFontId, pIcon, pOnClick) \
452  D4D_DECLARE_MENU_BEGIN_INRAM(name, title_text, title_font, x, y, cx, cy, (D4D_MENU_F_DEFAULT), NULL,\
453  IndexFontId, ItemsFontId, 0, 0, pIcon, NULL, pOnClick, NULL)
454 
455 
456 // Rounded menu definition
457 /**************************************************************************/
460 #define D4D_DECLARE_RMENU_BEGIN_INRAM(name, title_text, title_font, x, y, cx, cy, radius, flags, pScheme,\
461  indexFontId, itemsFontId, posCnt, menuItemsOff, pIcon, pUser, pOnClick, pOnUsrMsg) \
462  _D4D_DECLARE_MENU_BEGIN(D4D_NO_CONST, name, title_text, title_font, x, y, cx, cy, radius, NULL, NULL, flags, pScheme,\
463  indexFontId, itemsFontId, posCnt, menuItemsOff, pIcon, pUser, pOnClick, pOnUsrMsg)
464 
465 
466 
467 /**************************************************************************/
470 #define D4D_DECLARE_STD_RMENU_BEGIN_INRAM(name, title_text, title_font, x, y, cx, cy, radius, IndexFontId, ItemsFontId, pIcon, pOnClick) \
471  D4D_DECLARE_RMENU_BEGIN_INRAM(name, title_text, title_font, x, y, cx, cy, radius, (D4D_MENU_F_DEFAULT), NULL,\
472  IndexFontId, ItemsFontId, 0, 0, pIcon, NULL, pOnClick, NULL)
473 
476  /* Obsolete macros */
477 
478  #define D4D_DECLARE_RMENU_END(name) D4D_DECLARE_MENU_END(name)
479  #define D4D_DECLARE_MENU_END_INRAM(name) _D4D_DECLARE_MENU_END()
480  #define D4D_DECLARE_RMENU_END_INRAM(name) D4D_DECLARE_MENU_END_INRAM(name)
481 /******************************************************************************
482 * Global functions
483 ******************************************************************************/
485 
491 
492 
493 #endif /* __D4D_MENU_H */
494 
495 
496 
497 
Byte D4D_FONT
Definition: d4d_font.h:171
D4D_MENU_INDEX D4D_MenuGetItemCount(D4D_OBJECT_PTR pThis)
Function gets the count of menu items.
Definition: d4d_menu.c:661
D4D_MENU_INDEX ix
Definition: d4d_menu.h:171
D4D_MENU_INDEX D4D_MenuGetIndex(D4D_OBJECT *pThis)
Function returns the current selected item index.
Definition: d4d_menu.c:620
D4D_STRING text
Definition: d4d_menu.h:164
The string type. This structure contains all properties about string in eGUI.
Definition: d4d_string.h:100
void(* D4D_MENU_ON_CLICK)(D4D_OBJECT *pThis, D4D_MENU_INDEX ix)
Type definition of menu on click callback function.
Definition: d4d_menu.h:152
void * pUser
Definition: d4d_menu.h:166
Byte D4D_COOR
Type definition of eGUI coordination variables.
Definition: d4d_types.h:219
D4D_MENU_ON_CLICK OnClicked
Definition: d4d_menu.h:185
D4D_STRING * D4D_MenuGetItemText(D4D_OBJECT_PTR pThis)
Function gets the selected item text.
Definition: d4d_menu.c:708
void D4D_MenuSetIndex(D4D_OBJECT *pThis, D4D_MENU_INDEX ix)
Function select new item by index.
Definition: d4d_menu.c:638
void D4D_MenuScrollBarsFeedBack(D4D_OBJECT *pThis, D4D_INDEX old_position, D4D_INDEX new_position)
Definition: d4d_menu.c:597
D4D_BMP eGUI main image structure.
Definition: d4d_bmp.h:100
D4D_STRING title_text
Definition: d4d_menu.h:177
D4D_MENU_INDEX page_ix
Definition: d4d_menu.h:172
void * D4D_MenuGetItemUserData(D4D_OBJECT_PTR pThis)
Function gets the selected item user data.
Definition: d4d_menu.c:696
const D4D_MENU_ITEM * pItems
Definition: d4d_menu.h:184
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
signed char sByte
Type definition of sByte (signed 8-bit).
Definition: d4d_types.h:155
The object system function needed for each object - this is part of D4D_OBJECT main structure...
Definition: d4d_object.h:134
sByte D4D_MENU_INDEX
This is menu item index variable type.
Definition: d4d_menu.h:143
D4D_MENU_INDEX posCnt
Definition: d4d_menu.h:180
D4D_MENU_INDEX D4D_MenuFindUserDataItem(D4D_OBJECT_PTR pThis, void *pUser)
Function finds the index of items with specified user data.
Definition: d4d_menu.c:675
D4D_MENU_DATA * pData
Definition: d4d_menu.h:183
D4D_FONT itemsFontId
Definition: d4d_menu.h:179
const D4D_BMP * pIcon
Definition: d4d_menu.h:182
const D4D_OBJECT_SYS_FUNCTION d4d_menuSysFunc
Definition: d4d_menu.c:56
D4D_COOR textOff
Definition: d4d_menu.h:181
const D4D_BMP * pIcon
Definition: d4d_menu.h:165
D4D_FONT indexFontId
Definition: d4d_menu.h:178