Esempio n. 1
0
void SuggestionsSidebarBlock::UpdateSuggestionsMenu()
{
    ClearSuggestionsMenu();

    bool isRTL = m_parent->GetCurrentLanguage().IsRTL();
    wxString formatMask;
    if (isRTL)
        formatMask = L"\u202b%s\u202c\tCtrl+%d";
    else
        formatMask = L"\u202a%s\u202c\tCtrl+%d";

    int index = 0;
    for (auto s: m_suggestions)
    {
        if (index >= SUGGESTIONS_MENU_ENTRIES)
            break;

        auto text = wxString::Format(formatMask, s.text, index+1);

        auto item = m_suggestionMenuItems[index];
        m_suggestionsMenu->Append(item);

        item->SetItemLabel(text);
        item->SetBitmap(GetIconForSuggestion(s));

        index++;
    }
}
Esempio n. 2
0
void wxMenuItemBase::SetAccel(wxAcceleratorEntry *accel)
{
    wxString text = m_text.BeforeFirst(wxT('\t'));
    if ( accel )
    {
        text += wxT('\t');
        text += accel->ToString();
    }

    SetItemLabel(text);
}
Esempio n. 3
0
wxMenuItemBase::wxMenuItemBase(wxMenu *parentMenu,
                               int itemid,
                               const wxString& text,
                               const wxString& help,
                               wxItemKind kind,
                               wxMenu *subMenu)
{
    switch ( itemid )
    {
        case wxID_ANY:
            m_id = wxWindow::NewControlId();
            break;

        case wxID_SEPARATOR:
            m_id = wxID_SEPARATOR;

            // there is a lot of existing code just doing Append(wxID_SEPARATOR)
            // and it makes sense to omit the following optional parameters,
            // including the kind one which doesn't default to wxITEM_SEPARATOR,
            // of course, so override it here
            kind = wxITEM_SEPARATOR;
            break;

        case wxID_NONE:
            // (popup) menu titles in wxMSW use this ID to indicate that
            // it's not a real menu item, so we don't want the check below to
            // apply to it
            m_id = itemid;
            break;

        default:
            // ids are limited to 16 bits under MSW so portable code shouldn't
            // use ids outside of this range (negative ids generated by wx are
            // fine though)
            wxASSERT_MSG( (itemid >= 0 && itemid < SHRT_MAX) ||
                            (itemid >= wxID_AUTO_LOWEST && itemid <= wxID_AUTO_HIGHEST),
                          wxS("invalid itemid value") );
            m_id = itemid;
    }

    // notice that parentMenu can be NULL: the item can be attached to the menu
    // later with SetMenu()

    m_parentMenu  = parentMenu;
    m_subMenu     = subMenu;
    m_isEnabled   = true;
    m_isChecked   = false;
    m_kind        = kind;

    SetItemLabel(text);
    SetHelp(help);
}