[c5c522c] | 1 | #ifndef MENU_H |
---|
| 2 | #define MENU_H |
---|
| 3 | |
---|
| 4 | ////////////////////////////////////////////// |
---|
| 5 | // THIS IS NOT READY YET! |
---|
| 6 | ////////////////////////////////////////////// |
---|
| 7 | |
---|
| 8 | /* |
---|
| 9 | |
---|
| 10 | Pull-down menus... |
---|
| 11 | |
---|
| 12 | To use a menu, first define it; then call menu(). |
---|
| 13 | |
---|
| 14 | To define a menu, just declare an array of MenuItems. The last element |
---|
| 15 | must have all NULL fields. |
---|
| 16 | |
---|
| 17 | MenuItem FileMenu[] = |
---|
| 18 | { |
---|
| 19 | "Open", OpenFile_proc, NULL, |
---|
| 20 | "Close", CloseFile_proc, NULL, |
---|
| 21 | "Save", SaveFile_proc, NULL, |
---|
| 22 | "Save As...", NULL, SaveAsMenu, |
---|
| 23 | "Quit", Quit_proc, NULL, |
---|
| 24 | NULL, NULL, NULL, |
---|
| 25 | }; |
---|
| 26 | |
---|
| 27 | The first field is the text for the menu item. |
---|
| 28 | The second field is a function to call when the item is picked. |
---|
| 29 | The function should take no parameters, and return an int. |
---|
| 30 | The return values are: |
---|
| 31 | MENU_OK Normal return value. Menu will close. |
---|
| 32 | MENU_CONT Menu will stay up after function returns. |
---|
| 33 | The third field is the child menu to display when the item is picked. |
---|
| 34 | |
---|
| 35 | Note that either the second or third field must be NULL. If both are |
---|
| 36 | NULL, the item is considered to be just a label. (for example, a title) |
---|
| 37 | It will be non-pickable if both are NULL. |
---|
| 38 | |
---|
| 39 | */ |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | #define MENU_OK 1 |
---|
| 43 | #define MENU_CONT 2 |
---|
| 44 | |
---|
| 45 | typedef struct MenuItem |
---|
| 46 | { |
---|
| 47 | char *text; |
---|
| 48 | int (*func)(); |
---|
| 49 | struct MenuItem *child; |
---|
| 50 | } MenuItem; |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | // This does a pull-down menu... |
---|
| 55 | int menu(MenuItem *menu); |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | #endif |
---|