Allow explicit position of menus; from Murali Krishnan
authorhpa <hpa>
Thu, 22 Apr 2004 05:42:58 +0000 (05:42 +0000)
committerhpa <hpa>
Thu, 22 Apr 2004 05:42:58 +0000 (05:42 +0000)
menu/complex.c
menu/menu.c
menu/menu.h
menu/simple.c

index 9496347..dcdba8a 100644 (file)
@@ -137,9 +137,11 @@ int menumain(char *cmdline)
   //set_title_info  (-1,-1); 
   //set_misc_info(-1,-1,-1,-1);
 
+  // Register the menusystem handler
   reg_handler(&msys_handler);
   
   TESTING = add_menu(" Testing ");
+  set_menu_pos(5,60);
   add_item("Memory Test","Perform extensive memory testing",OPT_RUN, "memtest",0);
   add_item("Exit this menu","Go one level up",OPT_EXITMENU,"exit",0);
 
index 20fb70d..35288c1 100644 (file)
@@ -217,7 +217,7 @@ pt_menuitem runmenusystem(char top, char left, pt_menu cmenu)
 {
     pt_menuitem opt,choice;
     int numitems;
-    char startopt;
+    char startopt,row,col;
 
     startopt = 0;
     if (cmenu == NULL) return NULL;
@@ -245,7 +245,11 @@ startover:
     // Call recursively for submenu
     // Position the submenu below the current item,
     // covering half the current window (horizontally)
-    choice = runmenusystem(top+opt->index+2, left+3+(cmenu->menuwidth >> 1), ms->menus[opt->itemdata.submenunum]);
+    row = ms->menus[opt->itemdata.submenunum]->row;
+    col = ms->menus[opt->itemdata.submenunum]->col;
+    if (row == 0xFF) row = top+opt->index+2;
+    if (col == 0xFF) col = left+3+(cmenu->menuwidth >> 1);
+    choice = runmenusystem(row, col, ms->menus[opt->itemdata.submenunum]);
     if (choice==NULL) // User hit Esc in submenu
     {
        // Startover
@@ -402,6 +406,8 @@ char add_menu(const char *title) // Create a new menu and return its position
    if (m == NULL) return -1;
    ms->menus[num] = m;
    m->numitems = 0;
+   m->row = 0xFF;
+   m->col = 0xFF;
    for (i=0; i < MAXMENUSIZE; i++) m->items[i] = NULL;
    
    if (title)
@@ -416,6 +422,14 @@ char add_menu(const char *title) // Create a new menu and return its position
    return ms->nummenus - 1;
 }
 
+void set_menu_pos(char row,char col) // Set the position of this menu.
+{
+pt_menu m;
+
+    m = ms->menus[ms->nummenus-1];
+    m->row = row;
+    m->col = col;
+}
 
 pt_menuitem add_sep() // Add a separator to current menu
 {
index dd15320..291787a 100644 (file)
@@ -140,6 +140,7 @@ typedef struct s_menu {
     const char *title;
     char numitems;
     char menuwidth;
+    char row,col; // Position where this menu should be displayed
 } t_menu;
 
 typedef t_menu *pt_menu; // Pointer to type menu
@@ -208,6 +209,8 @@ char add_menu(const char *title); // This pointer value is stored internally
 // Add item to the "current" menu // pointer values are stored internally
 pt_menuitem add_item(const char *item, const char *status, t_action action, const char *data, char itemdata);
 
+void set_menu_pos(char row,char col); // Set the position of this menu.
+
 // Add a separator to the "current" menu
 pt_menuitem add_sep();
 
index aeaa6b7..b23da42 100644 (file)
@@ -49,6 +49,7 @@ int menumain(char *cmdline)
   //         unused otherwise.
 
   TESTING = add_menu(" Testing ");
+  add_item("Self Loop","Go to testing",OPT_SUBMENU,NULL,TESTING);
   add_item("Memory Test","Perform extensive memory testing",OPT_RUN, "memtest",0);
   add_item("Exit this menu","Go one level up",OPT_EXITMENU,"exit",0);
 
@@ -78,4 +79,3 @@ int menumain(char *cmdline)
   }
   return 0;
 }
-