Example #1
0
const wxMenuInfoHelperList& wxMenuBarBase::GetMenuInfos() const
{
    wxMenuInfoHelperList* list = const_cast< wxMenuInfoHelperList* > (& m_menuInfos);
    WX_CLEAR_LIST( wxMenuInfoHelperList, *list);
    for (size_t i = 0 ; i < GetMenuCount(); ++i)
    {
        wxMenuInfoHelper* info = new wxMenuInfoHelper();
        info->Create( GetMenu(i), GetMenuLabel(i));
        list->Append(info);
    }
    return m_menuInfos;
}
Example #2
0
int wxMenuBarBase::FindMenuItem(const wxString& menu, const wxString& item) const
{
    wxString label = wxMenuItem::GetLabelText(menu);

    int i = 0;
    wxMenuList::compatibility_iterator node;
    for ( node = m_menus.GetFirst(); node; node = node->GetNext(), i++ )
    {
        if ( label == wxMenuItem::GetLabelText(GetMenuLabel(i)) )
            return node->GetData()->FindItem(item);
    }

    return wxNOT_FOUND;
}
Example #3
0
int wxMenuBarBase::FindMenu(const wxString& title) const
{
    wxString label = wxMenuItem::GetLabelText(title);

    size_t count = GetMenuCount();
    for ( size_t i = 0; i < count; i++ )
    {
        wxString title2 = GetMenuLabel(i);
        if ( (title2 == title) ||
             (wxMenuItem::GetLabelText(title2) == label) )
        {
            // found
            return (int)i;
        }
    }

    return wxNOT_FOUND;

}
Example #4
0
char *GetMenuLabel( unsigned size,
                    gui_menu_struct *menu, unsigned id, char *buff, bool strip_amp )
{
    char        *p;

    while( size != 0 ) {
        if( menu->id == id ) {
            for( p = menu->label; *p != '\0'; ++p ) {
                if( *p == '&' && strip_amp ) continue;
                if( *p == '\t' ) break;
                *buff++ = *p;
            }
            *buff = '\0';
            return( buff );
        }
        if( menu->num_child_menus != 0 ) {
            p = GetMenuLabel( menu->num_child_menus, menu->child, id, buff, strip_amp );
            if( p != NULL ) return( p );
        }
        --size;
        ++menu;
    }
    return( NULL );
}
Example #5
0
WXHMENU wxMenuBar::Create()
{
    // Note: this doesn't work at all on Smartphone,
    // since you have to use resources.
    // We'll have to find another way to add a menu
    // by changing/adding menu items to an existing menu.
#if defined(WINCE_WITHOUT_COMMANDBAR)
    if ( m_hMenu != 0 )
        return m_hMenu;

    wxToolMenuBar * const bar = static_cast<wxToolMenuBar *>(GetToolBar());
    if ( !bar )
        return NULL;

    HWND hCommandBar = GetHwndOf(bar);

    // notify comctl32.dll about the version of the headers we use before using
    // any other TB_XXX messages
    SendMessage(hCommandBar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);

    TBBUTTON tbButton;
    wxZeroMemory(tbButton);
    tbButton.iBitmap = I_IMAGENONE;
    tbButton.fsState = TBSTATE_ENABLED;
    tbButton.fsStyle = TBSTYLE_DROPDOWN |
                       TBSTYLE_NO_DROPDOWN_ARROW |
                       TBSTYLE_AUTOSIZE;

    for ( unsigned i = 0; i < GetMenuCount(); i++ )
    {
        HMENU hPopupMenu = (HMENU) GetMenu(i)->GetHMenu();
        tbButton.dwData = (DWORD)hPopupMenu;
        wxString label = wxStripMenuCodes(GetMenuLabel(i));
        tbButton.iString = (int) label.wx_str();

        tbButton.idCommand = NewControlId();
        if ( !::SendMessage(hCommandBar, TB_INSERTBUTTON, i, (LPARAM)&tbButton) )
        {
            wxLogLastError(wxT("TB_INSERTBUTTON"));
        }
    }

    m_hMenu = bar->GetHMenu();
    return m_hMenu;
#else // !__WXWINCE__
    if ( m_hMenu != 0 )
        return m_hMenu;

    m_hMenu = (WXHMENU)::CreateMenu();

    if ( !m_hMenu )
    {
        wxLogLastError(wxT("CreateMenu"));
    }
    else
    {
        for ( wxMenuList::iterator it = m_menus.begin();
              it != m_menus.end();
              ++it )
        {
            if ( !::AppendMenu((HMENU)m_hMenu, MF_POPUP | MF_STRING,
                               (UINT_PTR)(*it)->GetHMenu(),
                               (*it)->GetTitle().wx_str()) )
            {
                wxLogLastError(wxT("AppendMenu"));
            }
        }
    }

    return m_hMenu;
#endif // __WXWINCE__/!__WXWINCE__
}