AcePerl
view release on metacpan or search on metacpan
acelib/menu.c view on Meta::CPAN
/* $Id: menu.c,v 1.1 2002/11/14 20:00:06 lstein Exp $ */
#include "regular.h"
#include "call.h" /* for call() and callExists() */
#include "menu_.h" /* private header for menu package */
/****************** MENU manipulation *******************/
MENU menuCreate (char *title)
{
MENU menu = (MENU) messalloc (sizeof (struct MenuStruct)) ;
menu->title = title ;
menu->items = 0 ;
return menu ;
}
MENU menuCopy (MENU oldMenu)
{
MENU newMenu = (MENU) messalloc (sizeof (struct MenuStruct)) ;
MENUITEM newItem, oldItem ;
newMenu->title = oldMenu->title ;
for (oldItem = oldMenu->items ; oldItem ; oldItem = oldItem->down)
{ newItem = menuCreateItem (oldItem->label, oldItem->func) ;
*newItem = *oldItem ;
menuAddItem (newMenu, newItem, 0) ;
}
return newMenu ;
}
void menuDestroy (MENU menu)
{
#ifdef NO_WE_CACHE_MENUS_IN_ASS_BELOW__DONT_DESTROY_HERE
MENUITEM item = menu->items ;
while (item)
{ MENUITEM next = item->down ;
messfree (item) ;
item = next ;
acelib/menu.c view on Meta::CPAN
}
localSpec = spec ;
return menu ;
}
/******************* MENUITEM manipulation ******************/
MENUITEM menuCreateItem (char *label, MENUFUNCTION func)
{
MENUITEM item = (MENUITEM) messalloc (sizeof (struct MenuItemStruct)) ;
memset (item, 0, sizeof (struct MenuItemStruct)) ;
item->label = label ;
item->func = func ;
return item ;
}
MENUITEM menuItem (MENU menu, char *label)
{
MENUITEM item ;
for (item = menu->items ; item && strcmp (label, item->label) ; item = item->down) ;
return item ;
acelib/menu.c view on Meta::CPAN
BOOL menuSetValue (MENUITEM item, int value)
{ if (!item) return FALSE ;
item->value = value ; return TRUE ;
}
BOOL menuSetPtr (MENUITEM item, void *ptr)
{ if (!item) return FALSE ;
item->ptr = ptr ; return TRUE ;
}
BOOL menuSetMenu (MENUITEM item, MENU menu)
{ if (!item || !menu) return FALSE ;
item->submenu = menu ; return TRUE ;
}
/***************** get item properties *******************/
unsigned int menuGetFlags (MENUITEM item)
{ if (!item) return 0 ;
return item->flags ;
}
acelib/wh/menu.h view on Meta::CPAN
/* returns true if states changed - mostly for graph library to use */
/* calls to set properties of items */
/* can use by name e.g. menuSetValue (menuItem (menu, "Frame 3"), 3) */
BOOL menuSetCall (MENUITEM item, char *callName) ;
BOOL menuSetFunc (MENUITEM item, MENUFUNCTION func) ;
BOOL menuSetFlags (MENUITEM item, unsigned int flags) ;
BOOL menuUnsetFlags (MENUITEM item, unsigned int flags) ;
BOOL menuSetValue (MENUITEM item, int value) ;
BOOL menuSetPtr (MENUITEM item, void *ptr) ;
BOOL menuSetMenu (MENUITEM item, MENU menu) ; /* pulldown for boxes */
/* and to get properties */
unsigned int menuGetFlags (MENUITEM item) ;
int menuGetValue (MENUITEM item) ;
void* menuGetPtr (MENUITEM item) ;
/* extra routines */
void menuSuppress (MENU menu, char *string) ; /* HIDE block */
void menuRestore (MENU menu, char *string) ; /* reverse of Suppress */
acelib/wh/menu_.h view on Meta::CPAN
* HISTORY:
* Last edited: Jan 14 15:01 1995 (rd)
* Created: Mon Jan 9 22:54:36 1995 (rd)
*-------------------------------------------------------------------
*/
/* $Id: menu_.h,v 1.1 2002/11/14 20:00:06 lstein Exp $ */
#ifndef DEF_MENU_H
typedef struct MenuStruct *MENU ;
typedef struct MenuItemStruct *MENUITEM ;
typedef void (*MENUFUNCTION)(MENUITEM) ;
#define MENU_DEFINED
struct MenuItemStruct {
char* label ;
MENUFUNCTION func ;
unsigned int flags ;
char* call ;
int value ;
void* ptr ;
MENU submenu ;
MENUITEM up, down ;
} ;
struct MenuStruct {
char *title ;
MENUITEM items ;
} ;
#include "menu.h"
#endif /* DEF_MENU_H */
( run in 0.540 second using v1.01-cache-2.11-cpan-49f99fa48dc )