コード例 #1
0
ファイル: menu.cpp プロジェクト: beanhome/dev
bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title, int pos)
{
    wxString str( wxReplaceUnderscore( title ) );

    // This doesn't have much effect right now.
    menu->SetTitle( str );

    // The "m_owner" is the "menu item"
    menu->m_owner = gtk_menu_item_new_with_label( wxGTK_CONV( str ) );
    GtkLabel *label = GTK_LABEL( GTK_BIN(menu->m_owner)->child );
    // set new text
    gtk_label_set_text( label, wxGTK_CONV( str ) );
    // reparse key accel
    guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( str ) );
    if (accel_key != GDK_VoidSymbol)
    {
        gtk_widget_add_accelerator (menu->m_owner,
                                    "activate_item",
                                    m_accel, //gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menubar)),
                                    accel_key,
                                    GDK_MOD1_MASK,
                                    GTK_ACCEL_LOCKED);
    }

    gtk_widget_show( menu->m_owner );

    gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu->m_owner), menu->m_menu );

    if (pos == -1)
        gtk_menu_shell_append( GTK_MENU_SHELL(m_menubar), menu->m_owner );
    else
        gtk_menu_shell_insert( GTK_MENU_SHELL(m_menubar), menu->m_owner, pos );

    gtk_signal_connect( GTK_OBJECT(menu->m_owner), "activate",
                        GTK_SIGNAL_FUNC(gtk_menu_open_callback),
                        (gpointer)menu );

    if (m_menuBarFrame)
    {
        AttachToFrame( menu, m_menuBarFrame );

            // OPTIMISE ME:  we should probably cache this, or pass it
            //               directly, but for now this is a minimal
            //               change to validate the new dynamic sizing.
            //               see (and refactor :) similar code in Remove
            //               below.

            m_menuBarFrame->UpdateMenuBarSize();
    }

    return true;
}
コード例 #2
0
ファイル: menu.cpp プロジェクト: mael15/wxWidgets
void wxMenuBar::GtkAppend(wxMenu* menu, const wxString& title, int pos)
{
    menu->SetLayoutDirection(GetLayoutDirection());

#if wxUSE_LIBHILDON || wxUSE_LIBHILDON2
    // if the menu has only one item, append it directly to the top level menu
    // instead of inserting a useless submenu
    if ( menu->GetMenuItemCount() == 1 )
    {
        wxMenuItem * const item = menu->FindItemByPosition(0);

        // remove both mnemonics and accelerator: neither is useful under Maemo
        const wxString str(wxStripMenuCodes(item->GetItemLabel()));

        if ( item->IsSubMenu() )
        {
            GtkAppend(item->GetSubMenu(), str, pos);
            return;
        }

        menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) );

        g_signal_connect(menu->m_owner, "activate",
                         G_CALLBACK(menuitem_activate), item);
        item->SetMenuItem(menu->m_owner);
    }
    else
#endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2 /!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2
    {
        const wxString str(wxConvertMnemonicsToGTK(title));

        // This doesn't have much effect right now.
        menu->SetTitle( str );

        // The "m_owner" is the "menu item"
        menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) );

        gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu->m_owner), menu->m_menu );
    }
    g_object_ref(menu->m_owner);

    gtk_widget_show( menu->m_owner );

    if (pos == -1)
        gtk_menu_shell_append( GTK_MENU_SHELL(m_menubar), menu->m_owner );
    else
        gtk_menu_shell_insert( GTK_MENU_SHELL(m_menubar), menu->m_owner, pos );

    if ( m_menuBarFrame )
        AttachToFrame( menu, m_menuBarFrame );
}
コード例 #3
0
ファイル: menu.cpp プロジェクト: Annovae/Dolphin-Core
void wxMenuBar::Attach(wxFrame *frame)
{
    wxMenuBarBase::Attach(frame);

    wxMenuList::compatibility_iterator node = m_menus.GetFirst();
    while (node)
    {
        wxMenu *menu = node->GetData();
        AttachToFrame( menu, frame );
        node = node->GetNext();
    }

    SetLayoutDirection(wxLayout_Default);
}
コード例 #4
0
ファイル: menu.cpp プロジェクト: beanhome/dev
static void AttachToFrame( wxMenu *menu, wxWindow *win )
{
    wxWindow *top_frame = win;
    while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
        top_frame = top_frame->GetParent();

    // support for native hot keys
    ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget);
    if ( !g_slist_find( ACCEL_OBJECTS(menu->m_accel), obj ) )
        gtk_accel_group_attach( menu->m_accel, obj );

    wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst();
    while (node)
    {
        wxMenuItem *menuitem = node->GetData();
        if (menuitem->IsSubMenu())
            AttachToFrame( menuitem->GetSubMenu(), win );
        node = node->GetNext();
    }
}
コード例 #5
0
ファイル: menu.cpp プロジェクト: beanhome/dev
void wxMenuBar::Attach( wxFrame *win )
{
    wxMenuBarBase::Attach(win);

    wxWindow *top_frame = win;
    while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
        top_frame = top_frame->GetParent();

    // support for native key accelerators indicated by underscroes
    ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget);
    if ( !g_slist_find( ACCEL_OBJECTS(m_accel), obj ) )
        gtk_accel_group_attach( m_accel, obj );

    wxMenuList::compatibility_iterator node = m_menus.GetFirst();
    while (node)
    {
        wxMenu *menu = node->GetData();
        AttachToFrame( menu, win );
        node = node->GetNext();
    }
}