Ejemplo n.º 1
0
void PythonBaseWorkbench::appendMenu(const std::list<std::string>& menu, const std::list<std::string>& items) const
{
    if ( menu.empty() || items.empty() )
        return;

    std::list<std::string>::const_iterator jt=menu.begin();
    MenuItem* item = _menuBar->findItem( *jt );
    if (!item)
    {
        item = new MenuItem;
        item->setCommand( *jt );
        Gui::MenuItem* wnd = _menuBar->findItem( "&Windows" );
        if (wnd)
            _menuBar->insertItem(wnd, item);
        else
            _menuBar->appendItem(item);
    }

    // create sub menus
    for ( jt++; jt != menu.end(); jt++ )
    {
        MenuItem* subitem = item->findItem( *jt );
        if ( !subitem )
        {
            subitem = new MenuItem(item);
            subitem->setCommand( *jt );
        }
        item = subitem;
    }

    for (std::list<std::string>::const_iterator it = items.begin(); it != items.end(); ++it)
        *item << *it;
}
Ejemplo n.º 2
0
MenuItem* TestWorkbench::setupMenuBar() const
{
    // Setup the default menu bar
    MenuItem* menuBar = StdWorkbench::setupMenuBar();

    MenuItem* item = menuBar->findItem("&Help");
    item->removeItem(item->findItem("Std_WhatsThis"));

    // Test commands
    MenuItem* test = new MenuItem;
    menuBar->insertItem( item, test );
    test->setCommand( "Test &Commands" );
    *test << "Std_Test1" << "Std_Test2" << "Std_Test3" << "Std_Test4" << "Std_Test5"
          << "Std_Test6" << "Std_Test7" << "Std_Test8";

    // Inventor View
    MenuItem* opiv = new MenuItem;
    menuBar->insertItem( item, opiv );
    opiv->setCommand("&Inventor View");
    *opiv << "Std_ViewExample1" << "Std_ViewExample2" << "Std_ViewExample3";

    return menuBar;
}
Ejemplo n.º 3
0
void PythonBaseWorkbench::appendContextMenu(const std::list<std::string>& menu, const std::list<std::string>& items) const
{
    MenuItem* item = _contextMenu;
    for (std::list<std::string>::const_iterator jt=menu.begin();jt!=menu.end();++jt) {
        MenuItem* subitem = item->findItem(*jt);
        if (!subitem) {
            subitem = new MenuItem(item);
            subitem->setCommand(*jt);
        }
        item = subitem;
    }

    for (std::list<std::string>::const_iterator it = items.begin(); it != items.end(); ++it)
        *item << *it;
}