Fix undefined preprocessor symbol.
[bertos.git] / mware / menu.h
1 /*!
2  * \file
3  * <!--
4  * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
5  * Copyright 2000 Bernardo Innocenti <bernie@codewiz.org>
6  * All Rights Reserved.
7  * -->
8  *
9  * \version $Id$
10  *
11  * \author Bernardo Innocenti <bernie@develer.com>
12  * \author Stefano Fedrigo <aleph@develer.com>
13  *
14  * \brief Common menu handling API
15  */
16
17 /*#*
18  *#* $Log$
19  *#* Revision 1.1  2006/02/10 12:29:36  bernie
20  *#* Add menu system.
21  *#*
22  *#* Revision 1.20  2005/11/16 18:10:19  bernie
23  *#* Move top-level headers to cfg/ as in DevLib.
24  *#*
25  *#* Revision 1.19  2005/02/11 19:11:38  aleph
26  *#* Move menu_displaymsg() in new displaymsg module
27  *#*
28  *#* Revision 1.18  2005/01/13 16:56:36  aleph
29  *#* Fix progmem includes.
30  *#*
31  *#* Revision 1.17  2004/12/14 12:52:45  aleph
32  *#* Add exclude menu flags
33  *#*
34  *#* Revision 1.16  2004/10/01 14:04:59  customer_pw
35  *#* Add accessor functions for menu flags
36  *#*
37  *#* Revision 1.15  2004/09/09 08:31:36  customer_pw
38  *#* Add disabled item type
39  *#*
40  *#* Revision 1.14  2004/08/29 21:46:12  bernie
41  *#* CVSSILENT: Mark CVS log blocks.
42  *#*
43  *#* Revision 1.13  2004/08/25 15:35:23  customer_pw
44  *#* IPTR -> iptr_t conversion.
45  *#*
46  *#* Revision 1.12  2004/08/25 13:23:45  bernie
47  *#* IPTR -> iptr_t conversion.
48  *#*/
49 #ifndef MWARE_MENU_H
50 #define MWARE_MENU_H
51
52 #include <cfg/compiler.h>
53
54 /* Fwd decl */
55 struct Bitmap;
56
57 /*! Menu callback function */
58 typedef void (*MenuHook)(iptr_t userdata);
59
60 /*! Menu item description */
61 typedef struct MenuItem
62 {
63         const_iptr_t label;    /*!< Item label (ID or ptr to string, 0 to disable) */
64         int          flags;    /*!< See MIF_#? definitions below */
65         MenuHook     hook;     /*!< Callback function (NULL to terminate item list) */
66         iptr_t       userdata; /*!< User data to be passed back to the hook */
67 } MenuItem;
68
69 /*! Flags for MenuItem.flags */
70 #define MIF_EXCLUDE_MASK    0x00FF
71 #define MIF_EXCLUDE_0       BV(0)  /*!< Exclude item 0 when this item is checked */
72 #define MIF_EXCLUDE_1       BV(1)  /*!< Exclude item 1 when this item is checked */
73 #define MIF_EXCLUDE_2       BV(2)  /*!< Exclude item 2 when this item is checked */
74 #define MIF_EXCLUDE_3       BV(3)  /*!< Exclude item 3 when this item is checked */
75 #define MIF_EXCLUDE_4       BV(4)  /*!< Exclude item 4 when this item is checked */
76 #define MIF_EXCLUDE_5       BV(5)  /*!< Exclude item 5 when this item is checked */
77 #define MIF_EXCLUDE_6       BV(6)  /*!< Exclude item 6 when this item is checked */
78 #define MIF_EXCLUDE_7       BV(7)  /*!< Exclude item 7 when this item is checked */
79 #define MIF_CHECKED         BV(8)  /*!< Item is currently checked */
80 #define MIF_CHECKIT         BV(9)  /*!< Automatically check this item when selected */
81 #define MIF_TOGGLE          BV(10) /*!< Toggle MIF_CHECKED when item is selected */
82 #define MIF_HIDDEN          BV(11) /*!< This menu item is not visible */
83 #define MIF_DISABLED        BV(12) /*!< This menu item is not visible */
84 #define MIF_RAMLABEL        BV(13) /*!< Item label is stored in RAM, not in program memory */
85
86
87 /*! Menu description */
88 typedef struct Menu
89 {
90         MenuItem        *items;    /*!< Array of items (end with a NULL hook) */
91         const_iptr_t     title;    /*!< Menu title (ID or ptr to string, 0 to disable) */
92         int              flags;    /*!< See MF_#? definitions below */
93         struct Bitmap   *bitmap;   /*!< Bitmap where the menu is rendered */
94         int              startrow; /*!< Display starting row */
95 } Menu;
96
97
98 #define MF_STICKY    BV(0)  /*!< Stay in the menu when the items called return */
99 #define MF_TOPLEVEL  BV(1)  /*!< Top-level menu (do not display "back" label) */
100
101
102 /* Function prototypes */
103 iptr_t menu_handle(const struct Menu *menu);
104 int menu_setFlags(struct Menu *menu, int idx, int flags);
105 int menu_clearFlags(struct Menu *menu, int idx, int flags);
106
107 #endif /* MWARE_MENU_H */