Beispiel #1
0
bool wxFrame::HandleMenuSelect( WXWORD nItem,
                                WXWORD nFlags,
                                WXHMENU hMenu )
{
    if( !nFlags )
    {
        MENUITEM mItem;
        MRESULT  rc;

        rc = ::WinSendMsg(hMenu, MM_QUERYITEM, MPFROM2SHORT(nItem, TRUE), (MPARAM)&mItem);

        if(rc && !(mItem.afStyle & (MIS_SUBMENU | MIS_SEPARATOR)))
        {
            wxMenuEvent                     vEvent(wxEVT_MENU_HIGHLIGHT, nItem);

            vEvent.SetEventObject(this);
            HandleWindowEvent(vEvent); // return value would be ignored by PM
        }
        else
        {
            DoGiveHelp(wxEmptyString, true);
            return false;
        }
    }
    return true;
} // end of wxFrame::HandleMenuSelect
Beispiel #2
0
bool
wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU WXUNUSED(hMenu))
{
    // sign extend to int from unsigned short we get from Windows
    int item = (signed short)nItem;

    // WM_MENUSELECT is generated for both normal items and menus, including
    // the top level menus of the menu bar, which can't be represented using
    // any valid identifier in wxMenuEvent so use an otherwise unused value for
    // them
    if ( flags & (MF_POPUP | MF_SEPARATOR) )
        item = wxID_NONE;

    wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item);
    event.SetEventObject(this);

    if ( HandleWindowEvent(event) )
        return true;

    // by default, i.e. if the event wasn't handled above, clear the status bar
    // text when an item which can't have any associated help string in wx API
    // is selected
    if ( item == wxID_NONE )
        DoGiveHelp(wxEmptyString, true);

    return false;
}
Beispiel #3
0
bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu)
{
    int item;
    if ( flags == 0xFFFF && hMenu == 0 )
    {
        // menu was removed from screen
        item = -1;
    }
#ifndef __WXMICROWIN__
    else if ( !(flags & MF_POPUP) && !(flags & MF_SEPARATOR) )
    {
        item = nItem;
    }
#endif
    else
    {
        // don't give hints for separators (doesn't make sense) nor for the
        // items opening popup menus (they don't have them anyhow) but do clear
        // the status line - otherwise, we would be left with the help message
        // for the previous item which doesn't apply any more
        DoGiveHelp(wxEmptyString, false);

        return false;
    }

    wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item);
    event.SetEventObject(this);

    return GetEventHandler()->ProcessEvent(event);
}
Beispiel #4
0
bool wxFrameBase::ShowMenuHelp(wxStatusBar *WXUNUSED(statbar), int menuId)
{
#if wxUSE_MENUS
    // if no help string found, we will clear the status bar text
    wxString helpString;
    bool show = menuId != wxID_SEPARATOR && menuId != -2 /* wxID_TITLE */;

    if ( show )
    {
        wxMenuBar *menuBar = GetMenuBar();
        if ( menuBar )
        {
            // it's ok if we don't find the item because it might belong
            // to the popup menu
            wxMenuItem *item = menuBar->FindItem(menuId);
            if ( item )
                helpString = item->GetHelp();
        }
    }

    DoGiveHelp(helpString, show);

    return !helpString.empty();
#else // !wxUSE_MENUS
    return false;
#endif // wxUSE_MENUS/!wxUSE_MENUS
}
Beispiel #5
0
bool
wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU WXUNUSED(hMenu))
{
    // WM_MENUSELECT is generated for both normal items and menus, including
    // the top level menus of the menu bar, which can't be represented using
    // any valid identifier in wxMenuEvent so use -1 for them
    // the menu highlight events for n
    const int item = flags & (MF_POPUP | MF_SEPARATOR) ? -1 : nItem;

    wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item);
    event.SetEventObject(this);

    if ( HandleWindowEvent(event) )
        return true;

    // by default, i.e. if the event wasn't handled above, clear the status bar
    // text when an item which can't have any associated help string in wx API
    // is selected
    if ( item == -1 )
        DoGiveHelp(wxEmptyString, true);

    return false;
}
Beispiel #6
0
bool wxFrameBase::ShowMenuHelp(int menuId)
{
#if wxUSE_MENUS
    // if no help string found, we will clear the status bar text
    //
    // NB: wxID_NONE is used for (sub)menus themselves by wxMSW
    wxString helpString;
    if ( menuId != wxID_SEPARATOR && menuId != wxID_NONE )
    {
        const wxMenuItem * const item = FindItemInMenuBar(menuId);
        if ( item && !item->IsSeparator() )
            helpString = item->GetHelp();

        // notice that it's ok if we don't find the item because it might
        // belong to the popup menu, so don't assert here
    }

    DoGiveHelp(helpString, true);

    return !helpString.empty();
#else // !wxUSE_MENUS
    return false;
#endif // wxUSE_MENUS/!wxUSE_MENUS
}
Beispiel #7
0
void wxFrameBase::OnMenuClose(wxMenuEvent& WXUNUSED(event))
{
    DoGiveHelp(wxEmptyString, false);
}
Beispiel #8
0
void wxFrameBase::OnMenuClose(wxMenuEvent& event)
{
    event.Skip();

    DoGiveHelp(wxEmptyString, false);
}