home *** CD-ROM | disk | FTP | other *** search
- # ifdef THINK_C
- /*
- * FILE: menubar.c
- * AUTHOR: R. Gonzalez
- * CREATED: August 28, 1990
- *
- * Defines menu bar methods, for Macintosh applications. Requires
- * Macintosh header files defined in MacHeaders; calls Macintosh Toolbox
- * ROM routines.
- */
-
- # include <string.h>
- # include "menubar.h"
-
- # define MAX_LENGTH 80
-
- /************************************************************************
- * set menu bar
- ************************************************************************/
- void Menu_Bar::set(Menu *menu)
- {
- MenuHandle menu_hand;
- int menu_num,
- item;
- char name[MAX_LENGTH];
-
- ClearMenuBar();
-
- for (menu_num=1 ; menu_num<=menu->num_menus ; menu_num++)
- {
- strcpy(name,menu->command[menu_num][0]);
- menu_hand = NewMenu(menu_num,CtoPstr(name));
- InsertMenu(menu_hand,0);
- for (item=1 ; item<menu->num_items[menu_num] ; item++)
- {
- strcpy(name,menu->command[menu_num][item]);
- AppendMenu(menu_hand,CtoPstr(name));
- }
- }
-
- DrawMenuBar();
- }
-
- /************************************************************************
- * get command name
- ************************************************************************/
- void Menu_Bar::get_command(char command[],EventRecord theEvent)
- {
- long int menuChoice;
- int theMenu,
- theItem;
- char selection[MAX_LENGTH];
-
- menuChoice = MenuSelect(theEvent.where);
-
- if (menuChoice == 0)
- strcpy(command,"");
- else
- {
- theMenu = HiWord(menuChoice);
- theItem = LoWord(menuChoice);
- GetItem(GetMHandle(theMenu),theItem,selection);
- strcpy(command,PtoCstr(selection));
- }
- }
- # endif
-