source: npl/mediabox/lcdproc_edwin/src/server/menu.h @ c5c522c

gcc484ntopperl-5.22
Last change on this file since c5c522c was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 4.0 KB
Line 
1#ifndef MENU_H
2#define MENU_H
3
4
5#if 0
6/*************************************************************************
7                                Menus!
8
9This is how the LCDproc menu stuff works...
10
11Each item has three values:
12
13        Title           -- Text
14        Type            -- menu,  function, checkbox,  slider,   mover
15        Data            -- Child, ExecFunc, CheckFunc, SlidFunc, ???
16
17When an item is picked, do_menu() decides what to do based on type.
18--"Menus" will recurse into the "data", assuming it is a child menu.
19--"Function"-type items will have their function called. 
20--CheckBox-type items will have their function called with a "read"
21  parameter to get an on/off signal, and called with a "set" signal when
22  picked.
23--Sliders will have the same "read" thing, and the "set" function will
24  take a plus or minus parameter.
25--The Movers will act like a label until picked, and then the +/- keys
26  will both rearrange the menu, and send the item a signal of some sort
27  to indicate what happened.  It will act like a label again after the
28  user presses Enter again.
29
30The "Data" field will really be a "void *", which is the "generic"
31data type in C...
32
33Anyway, this sort of thing would be declared this way:
34
35========================================================================
36
37menu_item MainMenu[] = {
38        "MENU",         0,              0,   // Title
39        "Options",      TYPE_MENU,      (void *)OptionsMenu,
40        "Kill LCDproc", TYPE_FUNC,      (void *)Shutdown_func,
41        0,              0,              0,
42};
43
44menu_item OptionsMenu[] = {
45        "OPTIONS",      TYPE_TITL,       0,   // Title
46        "24-hour Time", TYPE_CHEK,      (void *)Time24_func,
47        "Contrast...",  TYPE_SLID,      (void *)Contrast_func,
48        0,              0,              0,
49};
50
51
52///////////////// Elsewhere, we declare these...
53
54void Shutdown_func()
55{
56  // Do something here...
57  return MENU_KILL;     // or MENU_CLOSE, or MENU_OK, or MENU_ERROR
58}
59
60int Time24_func(int input)
61{
62  if(input == MENU_READ) return status;
63  if(input == MENU_CHECK) toggle_status();  // does something.
64  return (status | MENU_OK);
65        // The status is "or"-ed with the MENU value to let do_menu()
66        // know what to do after selecting the item.  (two return
67        // values in one.  :)
68
69        // Also, "MENU_OK" happens to be zero, so it does not matter
70        // unless you want something else (like MENU_CLOSE)
71}
72
73int Contrast_func(int input)
74{
75  if(input == MENU_READ) return status;
76  if(input == MENU_PLUS) increment_status(); // does something.
77  if(input == MENU_MINUS) decrement_status();// does something.
78  return (status | MENU_OK);
79}
80
81=====================================================================
82
83Function return values:
84    MENU_OK        Keeps menu open.
85    MENU_CLOSE     Closes menu after item is picked.
86                   Leaves the parent menus open.
87    MENU_QUIT      Closes all menus after item is picked.
88                   Like a normal pulldown menu.
89    MENU_KILL      Same as MENU_QUIT, so far.
90    MENU_ERROR     Um, for errors?  :)
91
92Also, functions for sliders and checkboxes should return a status value
93binary OR-ed with the MENU_ return value.  Checkboxes should return 0 or 1,
94and sliders should return 0-255.
95
96**************************************************************************/
97#endif
98
99
100// Return codes from selected menu items...
101#define MENU_ERROR -0x7FFF0000
102#define MENU_OK 0
103#define MENU_CLOSE 0x10000
104#define MENU_QUIT 0x20000
105#define MENU_KILL 0x20000
106
107// Menu item Types...
108#define TYPE_TITL 0
109#define TYPE_MENU 1
110#define TYPE_FUNC 2
111#define TYPE_CHEK 3
112#define TYPE_SLID 4
113#define TYPE_MOVE 5
114
115#define CLIENT_MENU 0x100
116#define CLIENT_FUNC 0x101
117#define CLIENT_CHEK 0x102
118#define CLIENT_SLID 0x103
119#define CLIENT_MOVE 0x104
120
121// User actions, sent to item-handling functions as input.
122#define MENU_SELECT 1
123#define MENU_CHECK 2
124#define MENU_PLUS 3
125#define MENU_MINUS 4
126#define MENU_READ 5
127
128
129typedef struct menu_item
130{
131  char *text;
132  int type;
133  void *data;
134} menu_item;
135
136
137#define Menu menu_item *
138
139
140int do_menu(Menu menu);
141
142
143#endif
Note: See TracBrowser for help on using the repository browser.