示例#1
0
void PopupMenu::removeItem(S32 itemPos)
{
   PopupMenu* submenu;
   itemPos++; // adjust torque -> mac menu index

   OSStatus err = GetMenuItemProperty(mData->mMenu, itemPos, 'GG2d', 'subm', sizeof(PopupMenu*),NULL,&submenu);
   if(err == noErr)
      mSubmenus->removeObject(submenu);
      
   // deleting the item decrements the ref count on the mac submenu.
   DeleteMenuItem(mData->mMenu, itemPos);
}
示例#2
0
static OSStatus
menu_event_handler_func (EventHandlerCallRef  event_handler_call_ref,
			 EventRef             event_ref,
			 void                *data)
{
  UInt32  event_class = GetEventClass (event_ref);
  UInt32  event_kind = GetEventKind (event_ref);
  MenuRef menu_ref;

  switch (event_class)
    {
    case kEventClassCommand:
      /* This is called when activating (is that the right GTK+ term?)
       * a menu item.
       */
      if (event_kind == kEventCommandProcess)
	{
	  HICommand command;
	  OSStatus  err;

	  /*g_printerr ("Menu: kEventClassCommand/kEventCommandProcess\n");*/

	  err = GetEventParameter (event_ref, kEventParamDirectObject,
				   typeHICommand, 0,
				   sizeof (command), 0, &command);

	  if (err == noErr)
	    {
	      GtkWidget *widget = NULL;

	      /* Get any GtkWidget associated with the item. */
	      err = GetMenuItemProperty (command.menu.menuRef,
					 command.menu.menuItemIndex,
					 IGE_QUARTZ_MENU_CREATOR,
					 IGE_QUARTZ_ITEM_WIDGET,
					 sizeof (widget), 0, &widget);
	      if (err == noErr && GTK_IS_WIDGET (widget))
		{
		  gtk_menu_item_activate (GTK_MENU_ITEM (widget));
		  return noErr;
		}
	    }
	}
      break;

    case kEventClassMenu:
      GetEventParameter (event_ref,
			 kEventParamDirectObject,
			 typeMenuRef,
			 NULL,
			 sizeof (menu_ref),
			 NULL,
			 &menu_ref);

      switch (event_kind)
	{
	case kEventMenuTargetItem:
	  /* This is called when an item is selected (what is the
	   * GTK+ term? prelight?)
	   */
	  /*g_printerr ("kEventClassMenu/kEventMenuTargetItem\n");*/
	  break;

	case kEventMenuOpening:
	  /* Is it possible to dynamically build the menu here? We
	   * can at least set visibility/sensitivity.
	   */
	  /*g_printerr ("kEventClassMenu/kEventMenuOpening\n");*/
	  break;

	case kEventMenuClosed:
	  /*g_printerr ("kEventClassMenu/kEventMenuClosed\n");*/
	  break;

	default:
	  break;
	}

      break;

    default:
      break;
    }

  return CallNextEventHandler (event_handler_call_ref, event_ref);
}