Exemple #1
0
void MakeMenu()		/* Put up a menu */
{
    Handle	menuBar;
    MenuRef	menu;
    long	response;
    OSErr	err;
	
    menuBar = GetNewMBar(rMenuBar);	/* read menus into menu bar */
    if ( menuBar != nil )
    {
        SetMenuBar(menuBar);	/* install menus */
        // AppendResMenu(GetMenuHandle(mApple), 'DRVR');
        
        err = Gestalt(gestaltMenuMgrAttr, &response);
	if ((err == noErr) && (response & gestaltMenuMgrAquaLayoutMask))
        {
            menu = GetMenuHandle( mFile );
            DeleteMenuItem( menu, iQuit );
            DeleteMenuItem( menu, iQuitSeparator );
        }
        
        DrawMenuBar();
    }
    else
    	ExitToShell();
}
Exemple #2
0
/*-------------------------------------------------------------
Save the New Menu Item Options - From the Menu Item Details Tab
-------------------------------------------------------------*/
void SaveNewMenuOptions(HWND hDlg)
{
	/// @note : on next backward incompatible change, also change how we store QuickyMenu
	wchar_t key[TNY_BUFF];
	int offset = 9;
	wchar_t szmText[TNY_BUFF];
	wchar_t szmTarget[LRG_BUFF];
	wchar_t szmSwitches[LRG_BUFF];
	GetDlgItemText(hDlg, IDC_MID_MENUTEXT, szmText, _countof(szmText));
	GetDlgItemText(hDlg, IDC_MID_TARGET,   szmTarget, _countof(szmTarget));
	GetDlgItemText(hDlg, IDC_MID_SWITCHES, szmSwitches, _countof(szmSwitches));
	memcpy(key, L"MenuItem-", offset*sizeof(wchar_t));
	offset += wsprintf(key+offset, FMT("%i"), GetWindowLong(hDlg,GWLP_USERDATA));
	if((wcslen(szmText)) && (wcslen(szmTarget))) {
		api.SetInt(L"QuickyMenu\\MenuItems", key, 1);
		
		wcscpy(key+offset, L"-Text");
		api.SetStr(L"QuickyMenu\\MenuItems", key, szmText);
		
		wcscpy(key+offset, L"-Target");
		api.SetStr(L"QuickyMenu\\MenuItems", key, szmTarget);
		
		wcscpy(key+offset, L"-Switches");
		api.SetStr(L"QuickyMenu\\MenuItems", key, szmSwitches);
		
		EndQuickyEdit(hDlg);
	} else {
		DeleteMenuItem(hDlg);
		wsprintf(szmSwitches, FMT("%s%s"),
			(!wcslen(szmText)?L"* Menu text can't be empty!\n":L""),
			(!wcslen(szmTarget)?L"* Target file must be filled!":L""));
		MessageBox(0, szmSwitches, L"ERROR: Missing Information!", MB_OK|MB_ICONERROR|MB_SETFOREGROUND);
	}
}
Exemple #3
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);
}
Exemple #4
0
 virtual void Remove( wxMenuItem *pItem )
 {
     wxMenuItemCarbonImpl* impl = (wxMenuItemCarbonImpl*) pItem->GetPeer();
     if ( impl )
     {
         MenuItemIndex i = impl->FindMenuItemIndex();
         if ( i > 0 )
         {
             DeleteMenuItem(m_osxMenu , i);
             impl->AttachToParent( NULL, 0 );
         }
     }
 }
Exemple #5
0
/*	WMDeleteMenuItems(theMenu, afterItem)

	Deletes the contents of the existing dialog popup menu after the
	specified item.
	
	afterItem is 1-based. If afterItem is zero, all items are deleted.
	
	NOTE: You should not call this routine to delete the contents of an existing
		  dialog popup menu item. Use DeletePopMenuItems instead.
	
	HR, 010427: This was previously called WMDeleteMenuItems but Apple usurped that name.
	
	Thread Safety: WMDeleteMenuItems is not thread-safe.
*/
void
WMDeleteMenuItems(MenuHandle theMenu, int afterItem)
{
	int item, items;
	
	if (!CheckRunningInMainThread("WMDeleteMenuItems"))
		return;
	
	afterItem++;						/* # of first item to delete */
	items = CountMItems(theMenu);
	
	for (item = afterItem; item <= items; item++)
		DeleteMenuItem(theMenu, afterItem);
}
void XGPopControl::ReloadItems (void)
{
	MenuHandle menu;
	int ix, len;
	char buf[256];

	if (!fControl)
		return;

	XGDraw draw(this,false);

	menu = GetMenuHandle();
	if (!menu)
		return;

#if TARGET_CARBON
	for (ix = CountMenuItems(menu); ix > 0; ix--) DeleteMenuItem(menu, ix);
#else
	for (ix = CountMItems(menu); ix > 0; ix--) DeleteMenuItem(menu, ix);
#endif

	for (ix = 0; ix < fList.GetNumStrings(); ix++) {
		fList.GetString(ix, buf);
		len = strlen(buf);
		memmove(&buf[1], buf, len);
		buf[0] = len;
		AppendMenu(menu, "\px");
		SetMenuItemText(menu, ix + 1, (unsigned char *)buf);
	}

#if TARGET_CARBON
	SetControlMaximum(fControl, CountMenuItems(menu));
#else
	SetControlMaximum(fControl, CountMItems(menu));
#endif
	SetControlValue(fControl, fValue + 1);
}
Exemple #7
0
//===============================================================================================
//----------------------------------+++--> Dialog Procedure for Menu Item Details Dialog Messages:
INT_PTR CALLBACK Page_QuickyMenu(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)   //-++-->
{
	(void)lParam;
	switch(message) {
	case WM_INITDIALOG:{
		wchar_t tmp[LRG_BUFF];
		int idx = (int)lParam;
		HWND hParent = GetParent(hDlg);
		SetWindowLongPtr(hDlg, GWLP_USERDATA, idx);
		wsprintf(tmp, FMT("Item #%i"), idx+1);
		SetDlgItemText(hDlg, IDC_MID_TASKNUM, tmp);
		ListView_GetItemText(GetDlgItem(hParent,IDC_QMEN_LIST), idx, 1, tmp, _countof(tmp));
		SetDlgItemText(hDlg, IDC_MID_TARGET, tmp);
		if(!tmp[0]){ // new item
			EnableDlgItem(hDlg, IDC_MID_DELETE, 0);
		}else
			ListView_GetItemText(GetDlgItem(hParent,IDC_QMEN_LIST), idx, 0, tmp, _countof(tmp));
		SetDlgItemText(hDlg, IDC_MID_MENUTEXT, tmp);
		ListView_GetItemText(GetDlgItem(hParent,IDC_QMEN_LIST), idx, 2, tmp, _countof(tmp));
		SetDlgItemText(hDlg, IDC_MID_SWITCHES, tmp);
		SetFocus(GetDlgItem(hDlg,IDC_MID_MENUTEXT));
		return TRUE;}
	case WM_COMMAND:
		switch(LOWORD(wParam)){
		case IDC_MID_TARGETSEL:
			BrowseForTargetFile(hDlg);
			break;
		case IDC_MID_SAVE:
			SaveNewMenuOptions(hDlg);
			break;
		case IDC_MID_DELETE:
			DeleteMenuItem(hDlg);
			/* fall through */
		case IDC_MID_CANCEL:
			EndQuickyEdit(hDlg);
		}
		return TRUE;
	}
	return FALSE;
}
EXPORT(sqInt) primitiveDeleteMenuItem(void) {
	MenuHandle menuHandle;
	sqInt menuHandleOop;
	sqInt anInteger;
	sqInt _return_value;

	menuHandleOop = interpreterProxy->stackValue(1);
	anInteger = interpreterProxy->stackIntegerValue(0);
	if (interpreterProxy->failed()) {
		return null;
	}
	menuHandle = ((MenuHandle) (interpreterProxy->positive64BitValueOf(menuHandleOop)));
	if (!(ioCheckMenuHandle(menuHandle))) {
		_return_value = interpreterProxy->success(0);
		if (interpreterProxy->failed()) {
			return null;
		}
		interpreterProxy->popthenPush(3, _return_value);
		return null;
	}
	DeleteMenuItem(menuHandle,anInteger);
	return null;
}
Exemple #9
0
void wxMenuBar::MacInstallMenuBar()
{
    if ( s_macInstalledMenuBar == this )
        return ;

    m_rootMenu->GetPeer()->MakeRoot();

    // hide items in the apple menu that don't exist in the wx menubar

    int menuid = 0;
    wxMenuItem* appleItem = NULL;
    wxMenuItem* wxItem = NULL;

    menuid = wxApp::s_macAboutMenuItemId;
    appleItem = m_appleMenu->FindItem(menuid);
    wxItem = FindItem(menuid);
    if ( appleItem != NULL )
    {
        if ( wxItem == NULL )
            appleItem->GetPeer()->Hide();
        else
            appleItem->SetItemLabel(wxItem->GetItemLabel());
    }

    menuid = wxApp::s_macPreferencesMenuItemId;
    appleItem = m_appleMenu->FindItem(menuid);
    wxItem = FindItem(menuid);
    if ( appleItem != NULL )
    {
        if ( wxItem == NULL )
            appleItem->GetPeer()->Hide();
        else
            appleItem->SetItemLabel(wxItem->GetItemLabel());
    }


#if 0

    // if we have a mac help menu, clean it up before adding new items
    MenuHandle helpMenuHandle ;
    MenuItemIndex firstUserHelpMenuItem ;

    if ( UMAGetHelpMenuDontCreate( &helpMenuHandle , &firstUserHelpMenuItem) == noErr )
    {
        for ( int i = CountMenuItems( helpMenuHandle ) ; i >= firstUserHelpMenuItem ; --i )
            DeleteMenuItem( helpMenuHandle , i ) ;
    }
    else
    {
        helpMenuHandle = NULL ;
    }

    if ( wxApp::s_macPreferencesMenuItemId)
    {
        wxMenuItem *item = FindItem( wxApp::s_macPreferencesMenuItemId , NULL ) ;
        if ( item == NULL || !(item->IsEnabled()) )
            DisableMenuCommand( NULL , kHICommandPreferences ) ;
        else
            EnableMenuCommand( NULL , kHICommandPreferences ) ;
    }

    // Unlike preferences which may or may not exist, the Quit item should be always
    // enabled unless it is added by the application and then disabled, otherwise
    // a program would be required to add an item with wxID_EXIT in order to get the
    // Quit menu item to be enabled, which seems a bit burdensome.
    if ( wxApp::s_macExitMenuItemId)
    {
        wxMenuItem *item = FindItem( wxApp::s_macExitMenuItemId , NULL ) ;
        if ( item != NULL && !(item->IsEnabled()) )
            DisableMenuCommand( NULL , kHICommandQuit ) ;
        else
            EnableMenuCommand( NULL , kHICommandQuit ) ;
    }

    wxString strippedHelpMenuTitle = wxStripMenuCodes( wxApp::s_macHelpMenuTitleName ) ;
    wxString strippedTranslatedHelpMenuTitle = wxStripMenuCodes( wxString( _("&Help") ) ) ;
    wxMenuList::compatibility_iterator menuIter = m_menus.GetFirst();
    for (size_t i = 0; i < m_menus.GetCount(); i++, menuIter = menuIter->GetNext())
    {
        wxMenuItemList::compatibility_iterator node;
        wxMenuItem *item;
        wxMenu* menu = menuIter->GetData() , *subMenu = NULL ;
        wxString strippedMenuTitle = wxStripMenuCodes(m_titles[i]);

        if ( strippedMenuTitle == wxT("?") || strippedMenuTitle == strippedHelpMenuTitle || strippedMenuTitle == strippedTranslatedHelpMenuTitle )
        {
            for (node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext())
            {
                item = (wxMenuItem *)node->GetData();
                subMenu = item->GetSubMenu() ;
                if (subMenu)
                {
                    UMAAppendMenuItem(mh, wxStripMenuCodes(item->GetText()) , wxFont::GetDefaultEncoding() );
                    MenuItemIndex position = CountMenuItems(mh);
                    ::SetMenuItemHierarchicalMenu(mh, position, MAC_WXHMENU(subMenu->GetHMenu()));
                }
                else
                {
                    if ( item->GetId() != wxApp::s_macAboutMenuItemId )
                    {
                        // we have found a user help menu and an item other than the about item,
                        // so we can create the mac help menu now, if we haven't created it yet
                        if ( helpMenuHandle == NULL )
                        {
                            if ( UMAGetHelpMenu( &helpMenuHandle , &firstUserHelpMenuItem) != noErr )
                            {
                                helpMenuHandle = NULL ;
                                break ;
                            }
                        }
                    }

                    if ( item->IsSeparator() )
                    {
                        if ( helpMenuHandle )
                            AppendMenuItemTextWithCFString( helpMenuHandle,
                                                            CFSTR(""), kMenuItemAttrSeparator, 0,NULL);
                    }
                    else
                    {
                        wxAcceleratorEntry*
                        entry = wxAcceleratorEntry::Create( item->GetItemLabel() ) ;

                        if ( item->GetId() == wxApp::s_macAboutMenuItemId )
                        {
                            // this will be taken care of below
                        }
                        else
                        {
                            if ( helpMenuHandle )
                            {
                                UMAAppendMenuItem(helpMenuHandle, wxStripMenuCodes(item->GetItemLabel()) , wxFont::GetDefaultEncoding(), entry);
                                SetMenuItemCommandID( helpMenuHandle , CountMenuItems(helpMenuHandle) , wxIdToMacCommand ( item->GetId() ) ) ;
                                SetMenuItemRefCon( helpMenuHandle , CountMenuItems(helpMenuHandle) , (URefCon) item ) ;
                            }
                        }

                        delete entry ;
                    }
                }
            }
        }

        else if ( ( m_titles[i] == wxT("Window") || m_titles[i] == wxT("&Window") )
                  && GetAutoWindowMenu() )
        {
            if ( MacGetWindowMenuHMenu() == NULL )
            {
                CreateStandardWindowMenu( 0 , (MenuHandle*) &s_macWindowMenuHandle ) ;
            }

            MenuRef wm = (MenuRef)MacGetWindowMenuHMenu();
            if ( wm == NULL )
                break;

            // get the insertion point in the standard menu
            MenuItemIndex winListStart;
            GetIndMenuItemWithCommandID(wm,
                                        kHICommandWindowListSeparator, 1, NULL, &winListStart);

            // add a separator so that the standard items and the custom items
            // aren't mixed together, but only if this is the first run
            OSStatus err = GetIndMenuItemWithCommandID(wm,
                           'WXWM', 1, NULL, NULL);

            if ( err == menuItemNotFoundErr )
            {
                InsertMenuItemTextWithCFString( wm,
                                                CFSTR(""), winListStart-1, kMenuItemAttrSeparator, 'WXWM');
            }

            wxInsertMenuItemsInMenu(menu, wm, winListStart);
        }
        else
        {
            UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i], GetFont().GetEncoding()  ) ;
            menu->MacBeforeDisplay(false) ;

            ::InsertMenu(MAC_WXHMENU(GetMenu(i)->GetHMenu()), 0);
        }
    }

    // take care of the about menu item wherever it is
    {
        wxMenu* aboutMenu ;
        wxMenuItem *aboutMenuItem = FindItem(wxApp::s_macAboutMenuItemId , &aboutMenu) ;
        if ( aboutMenuItem )
        {
            wxAcceleratorEntry*
            entry = wxAcceleratorEntry::Create( aboutMenuItem->GetItemLabel() ) ;
            UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , wxStripMenuCodes ( aboutMenuItem->GetItemLabel() ) , wxFont::GetDefaultEncoding() );
            UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 , true );
            SetMenuItemCommandID( GetMenuHandle( kwxMacAppleMenuId ) , 1 , kHICommandAbout ) ;
            SetMenuItemRefCon(GetMenuHandle( kwxMacAppleMenuId ) , 1 , (URefCon)aboutMenuItem ) ;
            UMASetMenuItemShortcut( GetMenuHandle( kwxMacAppleMenuId ) , 1 , entry ) ;
            delete entry;
        }
    }

    if ( GetAutoWindowMenu() )
    {
        if ( MacGetWindowMenuHMenu() == NULL )
            CreateStandardWindowMenu( 0 , (MenuHandle*) &s_macWindowMenuHandle ) ;

        InsertMenu( (MenuHandle) MacGetWindowMenuHMenu() , 0 ) ;
    }

    ::DrawMenuBar() ;
#endif

    s_macInstalledMenuBar = this;
}
Exemple #10
0
static void
sync_menu_shell (GtkMenuShell *menu_shell,
                 MenuRef       carbon_menu,
		 gboolean      toplevel,
		 gboolean      debug)
{
  GList         *children;
  GList         *l;
  MenuItemIndex  carbon_index = 1;

  if (debug)
    g_printerr ("%s: syncing shell %p\n", G_STRFUNC, menu_shell);

  carbon_menu_connect (GTK_WIDGET (menu_shell), carbon_menu, toplevel);

  children = gtk_container_get_children (GTK_CONTAINER (menu_shell));

  for (l = children; l; l = l->next)
    {
      GtkWidget      *menu_item = l->data;
      CarbonMenuItem *carbon_item;

      if (GTK_IS_TEAROFF_MENU_ITEM (menu_item))
	continue;

      if (toplevel && g_object_get_data (G_OBJECT (menu_item),
					 "gtk-empty-menu-item"))
	continue;

      carbon_item = carbon_menu_item_get (menu_item);

      if (debug)
	g_printerr ("%s: carbon_item %d for menu_item %d (%s, %s)\n",
		    G_STRFUNC, carbon_item ? carbon_item->index : -1,
		    carbon_index, get_menu_label_text (menu_item, NULL),
		    g_type_name (G_TYPE_FROM_INSTANCE (menu_item)));

      if (carbon_item && carbon_item->index != carbon_index)
	{
	  if (debug)
	    g_printerr ("%s:   -> not matching, deleting\n", G_STRFUNC);

	  DeleteMenuItem (carbon_item->menu, carbon_index);
	  carbon_item = NULL;
	}

      if (!carbon_item)
	{
	  GtkWidget          *label      = NULL;
	  const gchar        *label_text;
	  CFStringRef         cfstr      = NULL;
	  MenuItemAttributes  attributes = 0;

	  if (debug)
	    g_printerr ("%s:   -> creating new\n", G_STRFUNC);

	  label_text = get_menu_label_text (menu_item, &label);
	  if (label_text)
	    cfstr = CFStringCreateWithCString (NULL, label_text,
					       kCFStringEncodingUTF8);

	  if (GTK_IS_SEPARATOR_MENU_ITEM (menu_item))
	    attributes |= kMenuItemAttrSeparator;

	  if (!gtk_widget_is_sensitive (menu_item))
	    attributes |= kMenuItemAttrDisabled;

	  if (!gtk_widget_get_visible (menu_item))
	    attributes |= kMenuItemAttrHidden;

	  InsertMenuItemTextWithCFString (carbon_menu, cfstr,
					  carbon_index - 1,
					  attributes, 0);
	  SetMenuItemProperty (carbon_menu, carbon_index,
			       IGE_QUARTZ_MENU_CREATOR,
			       IGE_QUARTZ_ITEM_WIDGET,
			       sizeof (menu_item), &menu_item);

	  if (cfstr)
	    CFRelease (cfstr);

	  carbon_item = carbon_menu_item_connect (menu_item, label,
						  carbon_menu,
						  carbon_index);

	  if (GTK_IS_CHECK_MENU_ITEM (menu_item))
	    carbon_menu_item_update_active (carbon_item, menu_item);

	  carbon_menu_item_update_accel_closure (carbon_item, menu_item);

	  if (gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu_item)))
	    carbon_menu_item_update_submenu (carbon_item, menu_item);
	}

      carbon_index++;
    }

  g_list_free (children);
}
Exemple #11
0
static void
sync_menu_shell (GtkMenuShell *menu_shell,
                 MenuRef       carbon_menu,
                 gboolean      toplevel)
{
    GList         *children;
    GList         *l;
    MenuItemIndex  carbon_index = 1;

    carbon_menu_connect (GTK_WIDGET (menu_shell), carbon_menu);

    children = gtk_container_get_children (GTK_CONTAINER (menu_shell));

    UInt16 carbon_item_count = CountMenuItems(carbon_menu);

    for (l = children; l; l = l->next)
    {
        GtkWidget      *menu_item = l->data;
        CarbonMenuItem *carbon_item;

        if (GTK_IS_TEAROFF_MENU_ITEM (menu_item))
            continue;

        if (toplevel && g_object_get_data (G_OBJECT (menu_item),
                                           "gtk-empty-menu-item"))
            continue;

        GtkWidget *label = NULL;
        const gchar *label_text = NULL;

        label_text = get_menu_label_text (menu_item, &label);
        if (label_text && strcmp(label_text, "_SKIP_") == 0)
        {
            carbon_index++;
            continue;
        }
        else if (!label_text)
            label_text = "";

        MenuItemAttributes  attributes = 0;
        if (GTK_IS_SEPARATOR_MENU_ITEM (menu_item))
            attributes |= kMenuItemAttrSeparator;
        if (!GTK_WIDGET_IS_SENSITIVE (menu_item))
            attributes |= kMenuItemAttrDisabled;
        if (!GTK_WIDGET_VISIBLE (menu_item))
            attributes |= kMenuItemAttrHidden;

        CFStringRef cfstr = CFStringCreateWithCString (NULL, label_text,
                                                       kCFStringEncodingUTF8);
        if (carbon_index > carbon_item_count)
            AppendMenuItemTextWithCFString(carbon_menu, cfstr, attributes, 0,
                                           NULL);
        else if (!toplevel && (carbon_index > carbon_item_count))
            InsertMenuItemTextWithCFString (carbon_menu, cfstr, 
                                            carbon_index, attributes, 0);
        else
            SetMenuItemTextWithCFString(carbon_menu, carbon_index, cfstr);
        CFRelease (cfstr);

        MenuItemAttributes c_attributes = kMenuItemAttrSectionHeader |
                                          kMenuItemAttrAutoDisable;
        if (!(attributes & kMenuItemAttrDisabled))
            c_attributes |= kMenuItemAttrDisabled;
        if (!(attributes & kMenuItemAttrSeparator))
            c_attributes |= kMenuItemAttrSeparator;
        if (!(attributes & kMenuItemAttrHidden))
            c_attributes |= kMenuItemAttrHidden;
        ChangeMenuItemAttributes(carbon_menu, carbon_index,
                                 attributes, c_attributes);
        SetMenuItemProperty (carbon_menu, carbon_index,
                             GTK_QUARTZ_MENU_CREATOR,
                             GTK_QUARTZ_ITEM_WIDGET,
                             sizeof (menu_item), &menu_item);

        carbon_item = carbon_menu_item_connect (menu_item, label,
                                                carbon_menu,
                                                carbon_index);

        if (GTK_IS_CHECK_MENU_ITEM (menu_item))
            carbon_menu_item_update_active (carbon_item, menu_item);

        carbon_menu_item_update_accel_closure (carbon_item, menu_item);
        
        if (gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu_item)))
            carbon_menu_item_update_submenu (carbon_item, menu_item);

        carbon_index++;
    }

    while (carbon_index <= carbon_item_count)
    {
        DeleteMenuItem (carbon_menu, carbon_index);
        carbon_index++;
    }

    g_list_free (children);
}
Exemple #12
0
static void MenuBarInit(void) {

	Handle		hdl;
	MenuHandle	hmenu;

	hdl = GetNewMBar(IDM_MAINMENU);
	if (hdl == NULL) {
		ExitToShell();
	}
	SetMenuBar(hdl);
	hmenu = GetMenuHandle(IDM_APPLE);
	if (hmenu) {
		AppendResMenu(hmenu, 'DRVR');
	}
#if !defined(SUPPORT_SCSI)
	hmenu = GetMenuHandle(IDM_HARDDISK);
	if (hmenu) {
		DeleteMenuItem(hmenu, 7);
		DeleteMenuItem(hmenu, 6);
		DeleteMenuItem(hmenu, 5);
		DeleteMenuItem(hmenu, 4);
		DeleteMenuItem(hmenu, 3);
	}
#endif
	if (!np2oscfg.I286SAVE) {
		hmenu = GetMenuHandle(IDM_OTHER);
		if (hmenu) {
			DeleteMenuItem(hmenu, 9);
		}
	}
	InsertMenu(GetMenu(IDM_SASI1), -1);
	InsertMenu(GetMenu(IDM_SASI2), -1);
#if defined(SUPPORT_SCSI)
	InsertMenu(GetMenu(IDM_SCSI0), -1);
	InsertMenu(GetMenu(IDM_SCSI1), -1);
	InsertMenu(GetMenu(IDM_SCSI2), -1);
	InsertMenu(GetMenu(IDM_SCSI3), -1);
#endif
	InsertMenu(GetMenu(IDM_KEYBOARD), -1);
	InsertMenu(GetMenu(IDM_SOUND), -1);
	InsertMenu(GetMenu(IDM_MEMORY), -1);

#if TARGET_API_MAC_CARBON
	hmenu = GetMenuHandle(IDM_FDD2);
	SetItemCmd(hmenu, LoWord(IDM_FDD2OPEN), 'D');
	SetMenuItemModifiers(hmenu, LoWord(IDM_FDD2OPEN), kMenuShiftModifier);
	SetItemCmd(hmenu, LoWord(IDM_FDD2EJECT), 'E');
	SetMenuItemModifiers(hmenu, LoWord(IDM_FDD2EJECT), kMenuShiftModifier);
	hmenu = GetMenuHandle(IDM_SASI2);
	SetItemCmd(hmenu, LoWord(IDM_SASI2OPEN), 'O');
	SetMenuItemModifiers(hmenu, LoWord(IDM_SASI2OPEN), kMenuShiftModifier);
#else
	EnableItem(GetMenuHandle(IDM_DEVICE), LoWord(IDM_MOUSE));
	EnableItem(GetMenuHandle(IDM_KEYBOARD), LoWord(IDM_F12MOUSE));
#endif

	if (!(np2cfg.fddequip & 1)) {
		DeleteMenu(IDM_FDD1);
	}
	if (!(np2cfg.fddequip & 2)) {
		DeleteMenu(IDM_FDD2);
	}
	if (!(np2cfg.fddequip & 4)) {
		DeleteMenu(IDM_FDD3);
	}
	if (!(np2cfg.fddequip & 8)) {
		DeleteMenu(IDM_FDD4);
	}

#if defined(SUPPORT_STATSAVE)
	if (!np2oscfg.statsave) {
#endif
		DeleteMenu(IDM_STATSAVE);
#if defined(SUPPORT_STATSAVE)
	}
#endif

	DrawMenuBar();
}
Exemple #13
0
void wxMenuBar::MacInstallMenuBar()
{
    if ( s_macInstalledMenuBar == this )
        return ;

    MenuBarHandle menubar = NULL ;

#if TARGET_API_MAC_OSX
    menubar = NewHandleClear( 6 /* sizeof( MenuBarHeader ) */ ) ;
#else
    menubar = NewHandleClear( 12 ) ;
    (*menubar)[3] = 0x0a ;
#endif

    ::SetMenuBar( menubar ) ;
    DisposeMenuBar( menubar ) ;
    MenuHandle appleMenu = NULL ;

    verify_noerr( CreateNewMenu( kwxMacAppleMenuId , 0 , &appleMenu ) ) ;
    verify_noerr( SetMenuTitleWithCFString( appleMenu , CFSTR( "\x14" ) ) );

    // Add About/Preferences separator only on OS X
    // KH/RN: Separator is always present on 10.3 but not on 10.2
    // However, the change from 10.2 to 10.3 suggests it is preferred
#if TARGET_API_MAC_OSX
    InsertMenuItemTextWithCFString( appleMenu,
                CFSTR(""), 0, kMenuItemAttrSeparator, 0); 
#endif
    InsertMenuItemTextWithCFString( appleMenu,
                CFSTR("About..."), 0, 0, 0); 
    MacInsertMenu( appleMenu , 0 ) ;

    // clean-up the help menu before adding new items
    static MenuHandle mh = NULL ;

    if ( mh != NULL )
    {
        MenuItemIndex firstUserHelpMenuItem ;
        if ( UMAGetHelpMenu( &mh , &firstUserHelpMenuItem) == noErr )
        {
            for ( int i = CountMenuItems( mh ) ; i >= firstUserHelpMenuItem ; --i )
                DeleteMenuItem( mh , i ) ;
        }
        else
        {
            mh = NULL ;
        }
    }

#if TARGET_CARBON
    if ( UMAGetSystemVersion() >= 0x1000 && wxApp::s_macPreferencesMenuItemId)
    {
        wxMenuItem *item = FindItem( wxApp::s_macPreferencesMenuItemId , NULL ) ;
        if ( item == NULL || !(item->IsEnabled()) )
            DisableMenuCommand( NULL , kHICommandPreferences ) ;
        else
            EnableMenuCommand( NULL , kHICommandPreferences ) ;
    }

    // Unlike preferences which may or may not exist, the Quit item should be always
    // enabled unless it is added by the application and then disabled, otherwise
    // a program would be required to add an item with wxID_EXIT in order to get the
    // Quit menu item to be enabled, which seems a bit burdensome.
    if ( UMAGetSystemVersion() >= 0x1000 && wxApp::s_macExitMenuItemId)
    {
        wxMenuItem *item = FindItem( wxApp::s_macExitMenuItemId , NULL ) ;
        if ( item != NULL && !(item->IsEnabled()) )
            DisableMenuCommand( NULL , kHICommandQuit ) ;
        else
            EnableMenuCommand( NULL , kHICommandQuit ) ;
    }
#endif

    wxMenuList::compatibility_iterator menuIter = m_menus.GetFirst();
    for (size_t i = 0; i < m_menus.GetCount(); i++, menuIter = menuIter->GetNext())
    {
        wxMenuItemList::compatibility_iterator node;
        wxMenuItem *item;
        wxMenu* menu = menuIter->GetData() , *subMenu = NULL ;

        if ( m_titles[i] == wxT("?") || m_titles[i] == wxT("&?")  || m_titles[i] == wxApp::s_macHelpMenuTitleName )
        {
            for (node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext())
            {
                item = (wxMenuItem *)node->GetData();
                subMenu = item->GetSubMenu() ;
                if (subMenu)
                {
                    // we don't support hierarchical menus in the help menu yet
                }
                else
                {
                    if ( item->GetId() != wxApp::s_macAboutMenuItemId )
                    {
                        if ( mh == NULL )
                        {
                            MenuItemIndex firstUserHelpMenuItem ;
                            if ( UMAGetHelpMenu( &mh , &firstUserHelpMenuItem) != noErr )
                            {
                                mh = NULL ;
                                break ;
                            }
                        }
                    }

                    if ( item->IsSeparator() )
                    {
                        if ( mh )
                            AppendMenuItemTextWithCFString( mh,
                                CFSTR(""), kMenuItemAttrSeparator, 0,NULL); 
                    }
                    else
                    {
                        wxAcceleratorEntry*
                            entry = wxAcceleratorEntry::Create( item->GetText() ) ;

                        if ( item->GetId() == wxApp::s_macAboutMenuItemId )
                        {
                            // this will be taken care of below
                        }
                        else
                        {
                            if ( mh )
                            {
                                UMAAppendMenuItem(mh, wxStripMenuCodes(item->GetText()) , wxFont::GetDefaultEncoding(), entry);
                                SetMenuItemCommandID( mh , CountMenuItems(mh) , wxIdToMacCommand ( item->GetId() ) ) ;
                                SetMenuItemRefCon( mh , CountMenuItems(mh) , (URefCon) item ) ;
                            }
                        }

                        delete entry ;
                    }
                }
            }
        }
        else
        {
            UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i], m_font.GetEncoding()  ) ;
            menu->MacBeforeDisplay(false) ;
            ::InsertMenu(MAC_WXHMENU(_wxMenuAt(m_menus, i)->GetHMenu()), 0);
        }
    }

    // take care of the about menu item wherever it is
    {
        wxMenu* aboutMenu ;
        wxMenuItem *aboutMenuItem = FindItem(wxApp::s_macAboutMenuItemId , &aboutMenu) ;
        if ( aboutMenuItem )
        {
            wxAcceleratorEntry*
                entry = wxAcceleratorEntry::Create( aboutMenuItem->GetText() ) ;
            UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , wxStripMenuCodes ( aboutMenuItem->GetText() ) , wxFont::GetDefaultEncoding() );
            UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 , true );
            SetMenuItemCommandID( GetMenuHandle( kwxMacAppleMenuId ) , 1 , kHICommandAbout ) ;
            SetMenuItemRefCon(GetMenuHandle( kwxMacAppleMenuId ) , 1 , (URefCon)aboutMenuItem ) ;
            UMASetMenuItemShortcut( GetMenuHandle( kwxMacAppleMenuId ) , 1 , entry ) ;
        }
    }

    if ( GetAutoWindowMenu() )
    {
        if ( MacGetWindowMenuHMenu() == NULL )
            CreateStandardWindowMenu( 0 , (MenuHandle*) &s_macWindowMenuHandle ) ;

        InsertMenu( (MenuHandle) MacGetWindowMenuHMenu() , 0 ) ;
    }

    ::DrawMenuBar() ;
    s_macInstalledMenuBar = this;
}
// --------------------------------------------------------------------------------------
static pascal OSErr openApplicationAEHandler(const AppleEvent *appleEvent, AppleEvent *reply, 
												long refcon)
{
	OSErr error;
	DescType returnedType;
	Size actualSize;
	
	error = AEGetAttributePtr(appleEvent, keyMissedKeywordAttr, typeWildCard, &returnedType,
								NULL, 0, &actualSize);
	if (error == noErr)
		error = errAEParamMissed;
	else if (error == errAEDescNotFound)
	{
		MenuRef menu;
		CFStringRef aboutString;
		EventTypeSpec applicationEvents[] = {
												{kEventClassCommand, kEventCommandProcess}
		                                    };
		
			/* For our program running in Carbon, a Quit Application Apple Event handler 
			   is unnecessary because RunApplicationEventLoop installs one for us that 
			   calls QuitApplicationEventLoop.  However we will leave ours here in case 
			   we ever need it to do something different so that we know where it 
			   belongs. */
		gQuitAppAEHandler = NewAEEventHandlerUPP(quitApplicationAEHandler);
		error = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, gQuitAppAEHandler, 
										0, false);
		if (error != noErr)		// if we can't allow the user a mechanism to quit
		{						// we'd better just quit right now
			DisposeAEEventHandlerUPP(gOpenAppAEHandler);
			DisposeAEEventHandlerUPP(gQuitAppAEHandler);
			
			ExitToShell();
		}
		gViewsFontChangedAEHandler = NewAEEventHandlerUPP(viewsFontChangedAEHandler);
		error = AEInstallEventHandler(kAppearanceEventClass, kAEViewsFontChanged, 
										gViewsFontChangedAEHandler, 0, false);
		
#if TARGET_API_MAC_OSX
#pragma unused (reply, refcon)
		menu = GetMenuRef(mAppleApplication);
		aboutString = CFCopyLocalizedString(CFSTR("About Item"), NULL);
		SetMenuItemTextWithCFString(menu, iAbout, aboutString);		// get rid of the "..."
		CFRelease(aboutString);									// if we're running in OS X
		
		menu = GetMenuRef(mFile);
		ChangeMenuAttributes(menu, kMenuAttrAutoDisable, 0);
		DeleteMenuItem(menu, iQuit);				// remove the Quit item and separator
		DeleteMenuItem(menu, iQuitSeparator);		// if we're running in OS X
#else
#pragma unused (reply, refcon, menu, aboutString)
#endif
		
		gAppEventHandler = NewEventHandlerUPP(appEventHandler);
		InstallApplicationEventHandler(gAppEventHandler, GetEventTypeCount(applicationEvents), 
										applicationEvents, NULL, NULL);
		
		InitIconDataBrowser();
		
		error = noErr;
	}
	
	return error;
}