示例#1
0
wxMenuImpl* wxMenuImpl::Create( wxMenu* peer, const wxString& title )
{
    // create the menu
    static SInt16 s_macNextMenuId = 3;
    SInt16 menuId = s_macNextMenuId++;
    // save existing menu in case we're embedding into an application
    // or sharing outside UI elements.
    WXHMENU oldMenu = GetMenuHandle(menuId);
    if ( oldMenu )
        MacDeleteMenu(menuId);
    WXHMENU menu = NULL;
    CreateNewMenu( menuId , 0 , &menu ) ;
    if ( !menu )
    {
        wxLogLastError(wxT("CreateNewMenu failed"));
        if ( oldMenu )
            MacInsertMenu(oldMenu, -1);
        return NULL;
    }

    wxMenuImpl* c = new wxMenuCarbonImpl( peer, menu, oldMenu, menuId );
    c->SetTitle(title);
    wxAssociateMenuWithMacMenu( menu , peer ) ;
    return c;
}
示例#2
0
wxMenuImpl* wxMenuImpl::Create( wxMenu* peer, const wxString& title )
{
    // create the menu
    static SInt16 s_macNextMenuId = 3;
    WXHMENU menu = NULL;
    CreateNewMenu( s_macNextMenuId++ , 0 , &menu ) ;
    if ( !menu )
    {
        wxLogLastError(wxT("CreateNewMenu failed"));
        return NULL;
    }

    wxMenuImpl* c = new wxMenuCarbonImpl( peer, menu );
    c->SetTitle(title);
    wxAssociateMenuWithMacMenu( menu , peer ) ;
    return c;
}
示例#3
0
void wxMenu::Init()
{
    m_doBreak = false;
    m_startRadioGroup = -1;

    // create the menu
    m_macMenuId = s_macNextMenuId++;
    m_hMenu = UMANewMenu(m_macMenuId, m_title, wxFont::GetDefaultEncoding() );

    if ( !m_hMenu )
    {
        wxLogLastError(wxT("UMANewMenu failed"));
    }

    wxAssociateMenuWithMacMenu( (MenuRef)m_hMenu , this ) ;

    // if we have a title, insert it in the beginning of the menu
    if ( !m_title.empty() )
    {
        Append(idMenuTitle, m_title) ;
        AppendSeparator() ;
    }
}