private: bool isVegetarian(std::string name, Iterator<MenuItem>* iterator) { while (iterator->hasNext()) { MenuItem* menuItem = iterator->next(); if (menuItem->getName().compare(name) == 0) { if (menuItem->isVegetarian()) { return true; } } } return false; }
void Menu::OnHoverItem( Gwen::Controls::Base* pControl ) { if ( !ShouldHoverOpenMenu() ) return; MenuItem* pItem = gwen_cast<MenuItem>(pControl); if (!pItem) return; if ( pItem->IsMenuOpen() ) return; CloseAll(); pItem->OpenMenu(); }
bool MenuProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const { QModelIndex index = sourceModel()->index( source_row, 0, source_parent ); MenuItem * mItem = index.data( Qt::UserRole ).value<MenuItem*>(); // accept only systemsettings categories that have children if ( mItem->children().isEmpty() && mItem->service()->serviceTypes().contains( "SystemSettingsCategory" ) ) { return false; } else { return true; // Items matching the regexp are disabled, not hidden } }
void Menu::CloseSubMenus() { for (auto i = _inner_panel->GetChildren().begin(); i != _inner_panel->GetChildren().end(); ++i) { MenuItem* item = dynamic_cast<MenuItem*>(*i); if (item != nullptr) { item->Close(); } } }
bool TMenu::init() { Layer::init(); Menu * menu = Menu::create(); addChild(menu); for (int i = 0; i < sizeof(title) / sizeof(*title); ++i) { MenuItemFont * item = MenuItemFont::create(title[i], [](Ref * sender){ MenuItem * item = (MenuItem *)sender; int i = item->getTag() - 1000; Layer * l = NULL; if (title[i] == "T01CPP11") l = T01CPP11::create(); else if (title[i] == "T02Vector") l = T02Vector::create(); else if (title[i] == "T03Map") l = T03Map::create(); else if (title[i] == "T04Label") l = T04Label::create(); else if (title[i] == "T05Touch") l = T05Touch::create(); else if (title[i] == "T06Box2D") l = T06Box2D::create(); else if (title[i] == "T07PhysicsWorld") l = T07PhysicsWorld::create(); else if (title[i] == "T08RayCast") l = T08RayCast::create(); else if (title[i] == "T09Joint") l = T09Joint::create(); else if (title[i] == "T10MultiShapes") l = T10MultiShapes::create(); else if (title[i] == "T11FlyppyBird") l = T11FlyppyBird::create(); if (l != NULL) { TBack * b = TBack::create(); //Scene * s = Scene::create(); Scene * s = Scene::createWithPhysics(); // 3.x ÎïÀíÊÀ½ç PhysicsWorld * world = s->getPhysicsWorld(); world->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); s->addChild(b); s->addChild(l); Director::getInstance()->pushScene(s); } }); menu->addChild(item); item->setTag(1000 + i); } menu->alignItemsVertically(); // ´¥Ãþ auto ev = EventListenerTouchOneByOne::create(); //ev->onTouchBegan = std::bind(&TMenu::touchBegan, this, std::placeholders::_1, std::placeholders::_2); ev->onTouchBegan = CC_CALLBACK_2(TMenu::touchBegan, this); ev->onTouchMoved = [&](Touch * touch, Event *){ setPositionY(getPositionY() + touch->getDelta().y); }; _eventDispatcher->addEventListenerWithSceneGraphPriority(ev, this); return true; }
void Menu::CloseAll() { for ( Base::List::iterator it = m_InnerPanel->Children.begin(); it != m_InnerPanel->Children.end(); ++it ) { Base* pChild = *it; MenuItem* pItem = gwen_cast<MenuItem>(pChild); if ( !pItem ) continue; pItem->CloseMenu(); } }
MenuItem* Menu::AddItem(const std::string& name, const std::string& icon_name, const std::string& accelerator) { MenuItem* item = new MenuItem(this); item->SetPadding(Padding(2, 4, 4, 4)); item->SetText(name); item->SetImage(icon_name); item->SetAccelerator(accelerator); _OnAddItem(item); return item; }
int MenuBar::calculateWidth(SizeConstraint inSizeConstraint) const { int result = 0; std::vector<Element *> items; el()->getElementsByTagName(XMLMenuItem::TagName(), items); for (size_t idx = 0; idx != items.size(); ++idx) { MenuItem * item = items[idx]->component()->downcast<MenuItem>(); result += item->calculateWidth(inSizeConstraint) + Defaults::menuBarSpacing(); } return result; }
Menu* App::menubar(CmdInfo* info, WidgetKit& kit, const LayoutKit& layout) { Menu* m = kit.menubar(); for (CmdInfo* i = info; i->str != nil; i++) { MenuItem* mi = kit.menubar_item(kit.fancy_label(i->str)); mi->menu(pulldown(i->submenu, i->options, kit, layout)); m->append_item(mi); } m->item(0)->menu()->item(1)->state()->set( TelltaleState::is_enabled, false ); return m; }
/** * @brief * Adds a standard item with a text */ MenuItem *Menu::AddItem(const String &sText) { // Create item MenuItem *pItem = new MenuItem(*m_pGui); pItem->SetText(sText); // Add item AddItem(pItem); // Return item return pItem; }
status_t Menu::AddSeparatorItem() { MenuItem *item = new(nothrow) MenuItem(); if (item == NULL) return B_NO_MEMORY; item->SetType(MENU_ITEM_SEPARATOR); AddItem(item); return B_OK; }
void printVegetarianMenu( Iterator<MenuItem>* iterator ) const { assert( iterator ); HUM_TRACE(ACE_TEXT("Waitress::printVegetarianMenu")); while( iterator->hasNext() ) { MenuItem* menuItem = dynamic_cast< MenuItem* >(iterator->next() ); if( menuItem->isVegetarian() ) { std::cout << menuItem->getName() << ", "; std::cout << menuItem->getPrice() << " -- "; std::cout << menuItem->getDescription() << std::endl; } } }
MenuItem* MenuItemList::getNextMenuItem(void) { int size = getMenuItems().size(); if (size == 0) { return 0; } else { int newIndex = (getActiveItemIndex() + 1) % size; MenuItem* nextItem = getMenuItem(newIndex); getMenuItem(getActiveItemIndex())->setActive(false); nextItem->setActive(true); setActiveItemIndex(newIndex); return nextItem; } }
bool Menu::GetOpen() const { for (auto i = _inner_panel->GetChildren().begin(); i != _inner_panel->GetChildren().end(); ++i) { MenuItem* item = dynamic_cast<MenuItem*>(*i); if (item != nullptr && item->GetOpen()) { return true; } } return false; }
MenuItem* ComboBox::AddItem( const UnicodeString& strLabel, const String& strName, Gwen::Event::Handler* pHandler, Gwen::Event::Handler::Function fn ) { MenuItem* pItem = m_Menu->AddItem( strLabel, L"", pHandler, fn ); pItem->SetName( strName ); pItem->onMenuItemSelected.Add( this, &ComboBox::OnItemSelected ); //Default if ( m_SelectedItem == NULL ) OnItemSelected( pItem ); return pItem; }
void PlayScene::OnClikMenu(Ref * pSender) { MenuItem * nmitem = (MenuItem *)pSender; auto sc = Scene::create(); auto layer = MyAction::create(); layer->setTag(nmitem->getTag()); sc->addChild(layer); auto reScene = TransitionSlideInR::create(1.0f, sc); Director::getInstance()->replaceScene(reScene); }
void Menu::mousePressEvent(MouseEvent& event) { if(event.button() == MouseEvent::Button::Left) { cursor->resetTransformation().translate( Vector2::yScale(-1.0f)*(Vector2(event.position())/Vector2(defaultFramebuffer.viewport().size())-Vector2(0.5f))*camera->projectionSize()); MenuItem* item = static_cast<MenuItem*>(shapes.firstCollision(*cursor)); if(item) item->clicked(); } else return; event.setAccepted(); redraw(); }
MenuItem* Menu::AddItem( const TextObject& strName, const TextObject& strIconName, const TextObject& strAccelerator ) { MenuItem* pItem = new MenuItem( this ); pItem->SetPadding( Padding( 2, 4, 4, 4 ) ); pItem->SetText( strName ); pItem->SetImage( strIconName ); pItem->SetAccelerator( strAccelerator ); OnAddItem( pItem ); return pItem; }
MenuItem *MenuItem::newMenu(const char *text){ MenuItem *p; p = (MenuItem*)malloc( sizeof(MenuItem) ); if (p == NULL) return NULL; //Error, no more memory for this MenuItem if (!p->initialize(text)){ free(p); //there was no memory left for the text so let's free the object, it's useless without the text return NULL; //Error no memory left for the text in MenuItem"); } return p; }
void MapAreaLayer::mapAreaMenuItemCallback(cocos2d::Ref *pSender) { MenuItem* menuItem = static_cast<MenuItem*>(pSender); if(menuItem->getTag() == 999) { Director::getInstance()->replaceScene(SqliteTestScene::scene()); } else { if(MapManager::getInstance()->playable(mSize, menuItem->getTag())) { Director::getInstance() ->replaceScene(MainGameLayer::createScene(mSize, menuItem->getTag())); } } }
void onDropDown() { SharedPtr<Menu> menu(new Menu()); MenuItem* item = new MenuItem("Use Current Sprite"); item->Click.connect(&ImportSpriteSheetWindow::onUseCurrentSprite, this); if (m_editor || !current_editor || current_editor->getDocument() == NULL) item->setEnabled(false); menu->addChild(item); menu->showPopup(m_selectFile.rc->x1, m_selectFile.rc->y2); }
MenuItem* Menu::itemForPosition(const fzPoint& point) { MenuItem *item; FZ_LIST_FOREACH(m_children, item) { if ( item->isVisible() && item->isEnabled() ) { fzRect rect = item->getBoundingBox(); if( rect.contains(point) ) return item; } } return NULL; }
void VoxGame::CharacterPullDownChanged() { MenuItem* pMenuItem = m_pCharacterPulldown->GetSelectedMenuItem(); if (pMenuItem != NULL) { m_pPlayer->UnloadWeapon(false); m_pPlayer->UnloadWeapon(true); m_pPlayer->LoadCharacter(pMenuItem->GetLabel().GetText().c_str(), false); AnimationPullDownChanged(); } }
MenuItem * Menu::FindMarked() { MenuItemIterator iterator = ItemIterator(); MenuItem *item; while ((item = iterator.Next()) != NULL) { if (item->IsMarked()) return item; } return NULL; }
MenuItem * Menu::FindItem(const char *label) { MenuItemIterator iterator = ItemIterator(); MenuItem *item; while ((item = iterator.Next()) != NULL) { if (item->Label() != NULL && !strcmp(item->Label(), label)) return item; } return NULL; }
MenuItem* MenuItem::copy() const { MenuItem* root = new MenuItem; root->setCommand(command()); QList<MenuItem*> items = getItems(); for (QList<MenuItem*>::ConstIterator it = items.begin(); it != items.end(); ++it) { root->appendItem((*it)->copy()); } return root; }
void GameLayer::setSelectedPunishCat(PunishCat type) { for (int i= 0; i < mPunishCatMenuItems.size() ; i++) { MenuItem* item = mPunishCatMenuItems.at(i); if ((PunishCat)item->getTag() == type) { mPunishCatMenuItems.at(i)->selected(); } else { mPunishCatMenuItems.at(i)->unselected(); } } mSelectedPunishCat = type; }
void SceneGame::startServer(Ref* sender) { _bRedSide = true; NetBattle::Listen(); schedule(schedule_selector(SceneGame::CheckListen)); MenuItem* item = (MenuItem*)sender; item->setEnabled(false); Ref* obj = item->getUserObject(); item = (MenuItem*)obj; item->setEnabled(false); }
bool Menu::IsMenuOpen() { for ( Base::List::iterator it = m_InnerPanel->Children.begin(); it != m_InnerPanel->Children.end(); ++it ) { Base* pChild = *it; MenuItem* pItem = gwen_cast<MenuItem>(pChild); if ( !pItem ) continue; if ( pItem->IsMenuOpen() ) return true; } return false; }
bool isVegetarian( std::string name, Iterator<MenuItem>* iterator) const { assert(iterator); HUM_TRACE(ACE_TEXT("Waitress::isVegetarian")); while( iterator->hasNext() ) { MenuItem* menuItem = iterator->next(); if( menuItem->getName().compare( name ) == 0 ) { if( menuItem->isVegetarian() ) { return true; } } } return false; }