source: npl/mediabox/lcdproc_edwin/src/tests/menutest.c @ 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: 1.8 KB
Line 
1#include "lcd.h"
2#include "menu.h"
3
4
5
6extern menu_item MainMenu[];
7extern menu_item OptionsMenu[];
8extern int Shutdown_func();
9extern int Close_func();
10extern int OK_func();
11extern int Time24_func();
12extern int Contrast_func();
13
14
15menu_item MainMenu[] = {
16   "MAIN MENU",    0,              0,   // Title
17   "Options",      TYPE_MENU,      (void *)OptionsMenu,
18   "Kill LCDproc", TYPE_FUNC,      (void *)Shutdown_func,
19   "OK",           TYPE_FUNC,      (void *)OK_func,
20   0,              0,              0,
21   
22};
23
24menu_item OptionsMenu[] = {
25   "OPTIONS MENU", TYPE_TITL,      0,   // Title
26   "24-hour Time", TYPE_CHEK,      (void *)Time24_func,
27   "Contrast...",  TYPE_SLID,      (void *)Contrast_func,
28   "OK",           TYPE_FUNC,      (void *)OK_func,
29   "Close Menu",   TYPE_FUNC,      (void *)Close_func,
30   "Exit Program", TYPE_FUNC,      (void *)Shutdown_func,
31   "Another Title",TYPE_TITL,      0,
32   0,              0,              0,
33};
34
35
36///////////////// Elsewhere, we declare these...
37
38int Shutdown_func()
39{
40   // Do something here...
41   return MENU_KILL;
42}
43
44int Close_func()
45{
46   return MENU_CLOSE;
47}
48
49int OK_func()
50{
51   return MENU_OK;
52}
53
54
55int Time24_func(int input)
56{
57   static int status=0;
58 
59   if(input == MENU_READ) return status;
60   if(input == MENU_CHECK) status ^= 1;  // does something.
61   return (status | MENU_OK);
62   // The status is "or"-ed with the MENU value to let do_menu()
63   // know what to do after selecting the item.  (two return
64   // values in one.  :)
65
66   // Also, "MENU_OK" happens to be zero, so it does not matter
67   // unless you want something else (like MENU_CLOSE)
68}
69
70int Contrast_func(int input)
71{
72   static int status=128;
73 
74
75   if(input == MENU_READ) return status;
76   if(input == MENU_PLUS) status++; // does something.
77   if(input == MENU_MINUS) status--; // does something.
78   return (status | MENU_OK);
79}
80
81
82void main()
83{
84   lcd_init("", "curses");
85 
86   do_menu(MainMenu);
87 
88}
Note: See TracBrowser for help on using the repository browser.