Test of all menu features
authorhpa <hpa>
Tue, 18 May 2004 05:57:05 +0000 (05:57 +0000)
committerhpa <hpa>
Tue, 18 May 2004 05:57:05 +0000 (05:57 +0000)
menu/menutest.c [new file with mode: 0644]

diff --git a/menu/menutest.c b/menu/menutest.c
new file mode 100644 (file)
index 0000000..8dd7069
--- /dev/null
@@ -0,0 +1,79 @@
+/* -*- c -*- ------------------------------------------------------------- *
+ *   
+ *   Copyright 2004 Murali Krishnan Ganapathy - All Rights Reserved
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ *   Bostom MA 02111-1307, USA; either version 2 of the License, or
+ *   (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+#include "menu.h"
+#include "biosio.h"
+#include "string.h"
+#include "syslinux.h"
+
+char ONE,TWO,THREE,FOUR,MAIN;
+
+int menumain(void)
+{
+  t_menuitem * curr;
+
+  // Choose the default title and setup default values for all attributes....
+  init_menusystem(NULL);
+  
+  // Choose the default values for all attributes and char's
+  // -1 means choose defaults (Actually the next 4 lines are not needed)
+  //set_normal_attr (-1,-1,-1,-1); 
+  //set_status_info (-1,-1); 
+  //set_title_info  (-1,-1); 
+  //set_misc_info(-1,-1,-1,-1);
+  
+  // menuindex = add_menu(" Menu Title ");
+  // add_item("Item string","Status String",TYPE,"any string",NUM)
+  //   TYPE = OPT_RUN | OPT_EXITMENU | OPT_SUBMENU | OPT_CHECKBOX | OPT_INACTIVE
+  //   "any string" not used by the menu system, useful for storing kernel names
+  //   NUM = index of submenu if OPT_SUBMENU, 
+  //         0/1 default checked state if OPT_CHECKBOX
+  //         unused otherwise.
+
+  FOUR = add_menu(" LEVEL 4 ");
+  add_item("Exit to prompt", "Exit the menu system", OPT_EXITMENU, "exit", 0);
+
+  THREE = add_menu(" 1234567890123456789012 ");
+  add_item("GOTO LEVEL 4","Go one level up",OPT_SUBMENU,NULL,FOUR);
+  add_item("Exit to prompt", "Exit the menu system", OPT_EXITMENU, "exit", 0);
+
+  TWO = add_menu(" LEVEL 2 ");
+  add_item("GOTO LEVEL 3","Go one level up",OPT_SUBMENU,NULL,THREE);
+  add_item("Exit to prompt", "Exit the menu system", OPT_EXITMENU, "exit", 0);
+
+  ONE = add_menu(" LEVEL 1 ");
+  add_item("GOTO LEVEL 2","Go one level up",OPT_SUBMENU,NULL,TWO);
+  add_item("Exit to prompt", "Exit the menu system", OPT_EXITMENU, "exit", 0);
+
+  MAIN = add_menu(" Main Menu ");  
+  add_item("Begin Menu Depth Test","Only Allows Depth Of Two",OPT_SUBMENU,NULL,ONE);
+  add_item("Exit to prompt", "Exit the menu system", OPT_EXITMENU, "exit", 0);
+
+  curr = showmenus(MAIN); // Initial menu is the one with index MAIN
+  if (curr)
+  {
+        if (curr->action == OPT_EXIT) return 0;
+        if (curr->action == OPT_RUN)
+        {
+            if (syslinux) runcommand(curr->data);
+            else csprint(curr->data);
+            return 1;
+        }
+        csprint("Error in programming!");
+  }
+  return 0;
+}
+