示例#1
0
/* to reflect the shift in position */
void StMObDeleteItem(LVAL menu, LVAL item)
{
  HMENU addr;
  int n, i, j, id, flags;
  LVAL items;
  char *s;

  if (StMObAllocated(menu)) {
    addr = get_menu_address(menu);
    id = get_menu_id(menu);
    i = get_item_position(menu, item);
    for (j = 0, items = slot_value(menu, s_items);
	 j < i && consp(items);
	 j++, items = cdr(items));
    n = GetMenuItemCount((HMENU) addr);
    for (; i < n; n--) DeleteMenu((HMENU) addr, i, MF_BYPOSITION);
    if (consp(items)) items = cdr(items);
    for (; consp(items); items = cdr(items), i++) {
      item = car(items);
      s = get_item_string(item);
      if (s[0] == '-') AppendMenu((HMENU) addr, MF_SEPARATOR, 0, NULL);
      else {
	flags = MF_STRING;
	if (slot_value(item, s_mark) != NIL) flags |= MF_CHECKED;
	if (slot_value(item, s_enabled) == NIL) flags |= MF_GRAYED;
	AppendMenu((HMENU) addr, flags, MAKEITEMINDEX(id, i), s);
      }
    }
  }
}
示例#2
0
/* add items to a macintosh internal menu */
void StMObAppendItems(LVAL menu, LVAL items)
{
  LVAL item;
  char *s;
  int i, flags, id;
  HMENU theMenu;
  
  if (StMObAllocated(menu)) {
    theMenu = get_menu_address(menu);
    id = get_menu_id(menu);
    i = llength(slot_value(menu, s_items)) - llength(items);
    if (i < 0) xlfail("append list should not exceed item list");
    
    for (; consp(items); items = cdr(items), i++) {
      item = car(items);
      s = get_item_string(item);
      if (s[0] == '-') AppendMenu((HMENU) theMenu, MF_SEPARATOR, 0, NULL);
      else {
	flags = MF_STRING;
	if (slot_value(item, s_mark) != NIL) flags |= MF_CHECKED;
	if (slot_value(item, s_enabled) == NIL) flags |= MF_GRAYED;
	AppendMenu((HMENU) theMenu, flags, MAKEITEMINDEX(id, i), s);
      }
    }
  }
}
示例#3
0
/* allocate an internal menu */
static int id_in_use(int id)
{
  LVAL next;
  
  for (next = GetMenuList(); consp(next); next = cdr(next)) {
    if (id == get_menu_id(car(next))) return(TRUE);
  }
  return(FALSE);
}
示例#4
0
Menu *make_menu(const char *title, module* m)
{
#ifndef COMMON_MENU
	if (BBVERSION_LEAN != BBVersion)
		return MakeMenu(title);
#endif
	char menu_id[300];
	get_menu_id(menu_id, NULL, m, title);
	return MakeNamedMenu(title, menu_id, menu_pop_global);
}
示例#5
0
BOOL IsLispMenuItem(WORD wParam)
{
  LVAL next;
  int m;

  m = MENUITEMMENU(wParam);
  for (next = GetMenuList(); consp(next); next = cdr(next))
    if (StMObAllocated(car(next)) && m == get_menu_id(car(next)))
      return(TRUE);
  return(FALSE);
}
示例#6
0
static bool menu_exists(control *c)
{
	static bool (*pMenuExists)(LPCSTR IDString_start);
	if (NULL == pMenuExists)
	{
		*(FARPROC*)&pMenuExists = GetProcAddress(GetModuleHandle(NULL), "MenuExists");
		if (NULL == pMenuExists) pMenuExists = defMenuExists;
	}

	char menu_id[200];
	get_menu_id(menu_id, c, NULL, NULL);
	return pMenuExists(menu_id);
}
示例#7
0
void LispMenuSelect(WORD wParam)
{
  LVAL next;
  int m, i;

  m = MENUITEMMENU(wParam);
  i = MENUITEMITEM(wParam);
  for (next = GetMenuList(); consp(next); next = cdr(next)) {
    if (StMObAllocated(car(next)) && m == get_menu_id(car(next))) {
      if (InPopup) PopupItem = i + 1;
      else send_callback_message1(car(next), sk_select, i + 1);
      return;
    }
  }
}
示例#8
0
/* adjust internal implementation of allocated menu to new instance value */
void StMObSetItemProp(LVAL item, int which)
{
  char *s;
  HMENU theMenu;
  LVAL menu, title;
  int i, flags, id;

  menu = slot_value(item, s_menu);
  if (menu != NIL && StMObAllocated(menu)) {
    theMenu = get_menu_address(menu);
    id = get_menu_id(menu);
    i = get_item_position(menu, item);
    title = slot_value(item, s_title);
    if (! stringp(title))
      xlerror("title is not a string", title);
    s = (char *) getstring(title);
    if (s[0] == '-' && which != 'T') return;
    switch (which) {
    case 'T':
      if (s[0] == '-') {
	flags = MF_SEPARATOR | MF_BYPOSITION;
	ModifyMenu((HMENU) theMenu, i, flags, 0, NULL);
      }
      else {
	flags = MF_STRING | MF_BYPOSITION;
	flags |= (slot_value(item, s_mark) != NIL) ? MF_CHECKED : MF_UNCHECKED;
	flags |= (slot_value(item, s_enabled) != NIL) ? MF_ENABLED : MF_GRAYED;
	ModifyMenu((HMENU) theMenu, i, flags, MAKEITEMINDEX(id, i), s);
      }
      break;
    case 'K': break;
    case 'M':
      flags = (slot_value(item, s_mark) != NIL) ? MF_CHECKED : MF_UNCHECKED;
      flags |= MF_BYPOSITION;
      CheckMenuItem((HMENU) theMenu, i, flags);
      break;
    case 'A': break;
    case 'E':
      flags = (slot_value(item, s_enabled) != NIL) ? MF_ENABLED : MF_GRAYED;
      flags |= MF_BYPOSITION;
      EnableMenuItem((HMENU) theMenu, i, flags);
      break;
    default:  xlfail("unknown item instance variable");
    }
  }
}