home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / desklib / Libraries / Menu / c / Show < prev   
Encoding:
Text File  |  1993-04-29  |  1.7 KB  |  68 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Menu.AddSubMenu.c
  12.     Author:  Copyright © 1993 Shaun Blackmore and Jason Williams
  13.     Version: 1.00 (30 Apr 1993)
  14.     Purpose: Adds one menu to another as a submenu
  15. */
  16.  
  17. #include "Wimp.h"
  18. #include "WimpSWIs.h"
  19.  
  20.  
  21. wimp_point menu_currentpos;
  22. menu_ptr   menu_currentopen = NULL;
  23.  
  24.  
  25. int Menu_CalcHeight(menu_ptr menu)
  26. {
  27.   int       itemheight, count = 0;
  28.   menu_item *item;
  29.  
  30.   item = (menu_item *) (((int) menu) + sizeof(menu_block));
  31.   itemheight = menu->height + menu->gap;
  32.  
  33.   while(TRUE)
  34.   {
  35.     if (item->menuflags.data.dotted)         /* Count height of dotted line  */
  36.       count += 24;
  37.  
  38.     count += itemheight;                     /* Plus the height of each item */
  39.  
  40.     if (item->menuflags.data.last)
  41.       break;
  42.  
  43.     item++;
  44.   }
  45.  
  46.   return(count);
  47. }
  48.  
  49.  
  50. void Menu_Show(menu_ptr menu, int x, int y)
  51. {                    
  52.   x -= 64;
  53.   if (y < 0)
  54.     y = 96 + Menu_CalcHeight(menu);            /* Calculate iconbar position */
  55.  
  56.   menu_currentopen  = menu;
  57.   menu_currentpos.x = x;
  58.   menu_currentpos.y = y;
  59.  
  60.   Wimp_CreateMenu(menu, x, y);
  61. }
  62.  
  63.  
  64. void Menu_ShowLast(void)
  65. {
  66.   Wimp_CreateMenu(menu_currentopen, menu_currentpos.x, menu_currentpos.y);
  67. }
  68.