Main::Main(QGraphicsScene& c, QWidget* parent, const char* name, Qt::WindowFlags f) : Q3MainWindow(parent,name,f), canvas(c) { editor = new FigureEditor(canvas,this); QMenuBar* menu = menuBar(); Q3PopupMenu* file = new Q3PopupMenu( menu ); file->insertItem("&Fill canvas", this, SLOT(init()), Qt::CTRL+Qt::Key_F); file->insertItem("&Erase canvas", this, SLOT(clear()), Qt::CTRL+Qt::Key_E); file->insertItem("&New view", this, SLOT(newView()), Qt::CTRL+Qt::Key_N); file->insertSeparator(); file->insertItem("&Print...", this, SLOT(print()), Qt::CTRL+Qt::Key_P); file->insertSeparator(); file->insertItem("E&xit", qApp, SLOT(quit()), Qt::CTRL+Qt::Key_Q); menu->insertItem("&File", file); Q3PopupMenu* edit = new Q3PopupMenu( menu ); edit->insertItem("Add &Circle", this, SLOT(addCircle()), Qt::ALT+Qt::Key_C); edit->insertItem("Add &Hexagon", this, SLOT(addHexagon()), Qt::ALT+Qt::Key_H); edit->insertItem("Add &Polygon", this, SLOT(addPolygon()), Qt::ALT+Qt::Key_P); edit->insertItem("Add Spl&ine", this, SLOT(addSpline()), Qt::ALT+Qt::Key_I); edit->insertItem("Add &Text", this, SLOT(addText()), Qt::ALT+Qt::Key_T); edit->insertItem("Add &Line", this, SLOT(addLine()), Qt::ALT+Qt::Key_L); edit->insertItem("Add &Rectangle", this, SLOT(addRectangle()), Qt::ALT+Qt::Key_R); edit->insertItem("Add &Sprite", this, SLOT(addSprite()), Qt::ALT+Qt::Key_S); edit->insertItem("Create &Mesh", this, SLOT(addMesh()), Qt::ALT+Qt::Key_M ); edit->insertItem("Add &Alpha-blended image", this, SLOT(addButterfly()), Qt::ALT+Qt::Key_A); menu->insertItem("&Edit", edit); Q3PopupMenu* view = new Q3PopupMenu( menu ); view->insertItem("&Enlarge", this, SLOT(enlarge()), Qt::SHIFT+Qt::CTRL+Qt::Key_Plus); view->insertItem("Shr&ink", this, SLOT(shrink()), Qt::SHIFT+Qt::CTRL+Qt::Key_Minus); view->insertSeparator(); view->insertItem("&Rotate clockwise", this, SLOT(rotateClockwise()), Qt::CTRL+Qt::Key_PageDown); view->insertItem("Rotate &counterclockwise", this, SLOT(rotateCounterClockwise()), Qt::CTRL+Qt::Key_PageUp); view->insertItem("&Zoom in", this, SLOT(zoomIn()), Qt::CTRL+Qt::Key_Plus); view->insertItem("Zoom &out", this, SLOT(zoomOut()), Qt::CTRL+Qt::Key_Minus); view->insertItem("Translate left", this, SLOT(moveL()), Qt::CTRL+Qt::Key_Left); view->insertItem("Translate right", this, SLOT(moveR()), Qt::CTRL+Qt::Key_Right); view->insertItem("Translate up", this, SLOT(moveU()), Qt::CTRL+Qt::Key_Up); view->insertItem("Translate down", this, SLOT(moveD()), Qt::CTRL+Qt::Key_Down); view->insertItem("&Mirror", this, SLOT(mirror()), Qt::CTRL+Qt::Key_Home); menu->insertItem("&View", view); menu->insertSeparator(); Q3PopupMenu* help = new Q3PopupMenu( menu ); help->insertItem("&About", this, SLOT(help()), Qt::Key_F1); help->setItemChecked(dbf_id, TRUE); menu->insertItem("&Help",help); statusBar(); setCentralWidget(editor); printer = 0; init(); }
NDArrayViewPtr NDArrayView::DeepClone(bool readOnly/* = false*/) const { NDArrayViewPtr newView(new NDArrayView(this->GetDataType(), this->GetStorageFormat(), this->Shape(), this->Device()), [](_ReferenceCounter* ptr) { delete ptr; }); switch (m_dataType) { case DataType::Float: { auto newMatrix = newView->GetWritableMatrix<float>(); auto thisMatrix = GetMatrix<float>(); newMatrix->AssignValuesOf(*thisMatrix); break; } case DataType::Double: { auto newMatrix = newView->GetWritableMatrix<double>(); auto thisMatrix = GetMatrix<double>(); newMatrix->AssignValuesOf(*thisMatrix); break; } default: LogicError("Unsupported DataType %s", DataTypeName(m_dataType)); break; } newView->m_isReadOnly = readOnly; return NDArrayViewPtr(newView, [](_ReferenceCounter* ptr) { delete ptr; }); }
void MenuState::handleEvents(Game *game) { //The user has made a selection if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Return)) select(game); sf::Event event; while (game->getWindow()->pollEvent(event)) { if (event.type == sf::Event::Resized) { // update the view to the new size of the window sf::FloatRect newView(0, 0, event.size.width, event.size.height); newView.left = game->getWindow()->getView().getCenter().x - game->getWindow()->getView().getSize().x / 2.0f; newView.top = game->getWindow()->getView().getCenter().y - game->getWindow()->getView().getSize().y / 2.0f; game->getWindow()->setView(sf::View(newView)); } // Close window: exit if (event.type == sf::Event::Closed) game->getWindow()->close(); if (event.type == sf::Event::KeyPressed) { if (event.key.code == sf::Keyboard::Key::Down) if (selection != choices.size() - 1) selection++; else selection = 0; if (event.key.code == sf::Keyboard::Key::Up) if (selection != 0) selection--; else selection = choices.size() - 1; } } }
void ViewTableListWidget::createRightMenuActions() { //创建右键菜单 lookupView_action = new QAction(tr("查看"),this); newview_action = new QAction(tr("新建"),this); editview_aciton = new QAction(tr("编辑"),this); sendview_action = new QAction(tr("发送"),this); deleteview_action = new QAction(tr("删除"),this); addto_action = new QAction(tr("添加到..."),this); detailinfolist_action = new QAction(tr("详细信息"),this); listmode_action = new QAction(tr("列表"),this); iconmode_action = new QAction(tr("图标"),this); sortbyname_aciton = new QAction(tr("名称"),this); sortbytype_action = new QAction(tr("类型"),this); sortbyfrequency_action = new QAction(tr("使用次数"),this); sortbymoditime_action = new QAction(tr("访问时间"),this); connect(lookupView_action,SIGNAL(triggered()),this,SLOT(lookupView())); connect(newview_action,SIGNAL(triggered()),this,SLOT(newView())); connect(editview_aciton,SIGNAL(triggered()),this,SLOT(editView())); connect(sendview_action,SIGNAL(triggered()),this,SLOT(sendView())); connect(deleteview_action,SIGNAL(triggered()),this,SLOT(deleteViewRequest())); connect(addto_action,SIGNAL(triggered()),this,SLOT(addViewTo())); connect(detailinfolist_action,SIGNAL(triggered()),this,SLOT(detailInfoPermutation())); connect(listmode_action,SIGNAL(triggered()),this,SLOT(listPermutation())); connect(iconmode_action,SIGNAL(triggered()),this,SLOT(iconPermutation())); connect(sortbyname_aciton,SIGNAL(triggered()),this,SLOT(sortByName())); connect(sortbytype_action,SIGNAL(triggered()),this,SLOT(sortByType())); connect(sortbyfrequency_action,SIGNAL(triggered()),this,SLOT(sortByFrequency())); connect(sortbymoditime_action,SIGNAL(triggered()),this,SLOT(sortByModiTime())); }
void KWrite::setupActions() { m_closeAction = actionCollection()->addAction(KStandardAction::Close, QStringLiteral("file_close"), this, SLOT(slotFlush())); m_closeAction->setWhatsThis(i18n("Use this command to close the current document")); m_closeAction->setDisabled(true); // setup File menu actionCollection()->addAction(KStandardAction::New, QStringLiteral("file_new"), this, SLOT(slotNew())) ->setWhatsThis(i18n("Use this command to create a new document")); actionCollection()->addAction(KStandardAction::Open, QStringLiteral("file_open"), this, SLOT(slotOpen())) ->setWhatsThis(i18n("Use this command to open an existing document for editing")); m_recentFiles = KStandardAction::openRecent(this, SLOT(slotOpen(QUrl)), this); actionCollection()->addAction(m_recentFiles->objectName(), m_recentFiles); m_recentFiles->setWhatsThis(i18n("This lists files which you have opened recently, and allows you to easily open them again.")); QAction *a = actionCollection()->addAction(QStringLiteral("view_new_view")); a->setIcon(QIcon::fromTheme(QStringLiteral("window-new"))); a->setText(i18n("&New Window")); connect(a, SIGNAL(triggered()), this, SLOT(newView())); a->setWhatsThis(i18n("Create another view containing the current document")); actionCollection()->addAction(KStandardAction::Quit, this, SLOT(close())) ->setWhatsThis(i18n("Close the current document view")); // setup Settings menu setStandardToolBarMenuEnabled(true); m_paShowMenuBar = KStandardAction::showMenubar(this, SLOT(toggleMenuBar()), actionCollection()); m_paShowStatusBar = KStandardAction::showStatusbar(this, SLOT(toggleStatusBar()), this); actionCollection()->addAction(m_paShowStatusBar->objectName(), m_paShowStatusBar); m_paShowStatusBar->setWhatsThis(i18n("Use this command to show or hide the view's statusbar")); m_paShowPath = new KToggleAction(i18n("Sho&w Path in Titlebar"), this); actionCollection()->addAction(QStringLiteral("set_showPath"), m_paShowPath); connect(m_paShowPath, SIGNAL(triggered()), this, SLOT(documentNameChanged())); m_paShowPath->setWhatsThis(i18n("Show the complete document path in the window caption")); a = actionCollection()->addAction(KStandardAction::KeyBindings, this, SLOT(editKeys())); a->setWhatsThis(i18n("Configure the application's keyboard shortcut assignments.")); a = actionCollection()->addAction(KStandardAction::ConfigureToolbars, QStringLiteral("options_configure_toolbars"), this, SLOT(editToolbars())); a->setWhatsThis(i18n("Configure which items should appear in the toolbar(s).")); a = actionCollection()->addAction(QStringLiteral("help_about_editor")); a->setText(i18n("&About Editor Component")); connect(a, SIGNAL(triggered()), this, SLOT(aboutEditor())); }
void SvCreator::loadFile(const QString& _path) { if (_path == NULL) { newView(); } else { Parser parser(_path, &m_cdata); if (! parser.process(false)) { ngrt4n::alert(parser.lastErrorMsg()); exit(1); } else { m_activeConfig = ngrt4n::getAbsolutePath(_path); refreshUIWidgets(); } } }
void KMixWindow::initActionsAfterInitMixer() { // Only show the new tab widget if Pulseaudio is not used. Hint: The Pulseaudio backend always // runs with 4 fixed Tabs. if (!Mixer::pulseaudioPresent()) { QPixmap cornerNewPM = KIconLoader::global()->loadIcon("tab-new", KIconLoader::Toolbar, KIconLoader::SizeSmall); QPushButton* _cornerLabelNew = new QPushButton(); _cornerLabelNew->setIcon(cornerNewPM); //cornerLabelNew->setSizePolicy(QSizePolicy()); m_wsMixers->setCornerWidget(_cornerLabelNew, Qt::TopLeftCorner); connect(_cornerLabelNew, SIGNAL(clicked()), SLOT (newView())); } }
TestNSPlugin::TestNSPlugin() { m_loader = NSPluginLoader::instance(); // client area m_client = new QWidget( this, "m_client" ); setCentralWidget( m_client ); m_client->show(); m_layout = new QHBoxLayout( m_client ); // file menu KStdAction::openNew( this, SLOT(newView()), actionCollection()); KStdAction::close( this, SLOT(closeView()), actionCollection()); KStdAction::quit( kapp, SLOT(quit()), actionCollection()); createGUI( "testnspluginui.rc" ); }
void Schema::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { QString display_setting = mainwin->getDisplaySetting(); QMenu menu; menu.addAction(tr("Refresh")); if(display_setting.compare("view") == 0){ //menu.addAction(tr("New view")); } else if(display_setting.compare("function") == 0) menu.addAction(tr("New function")); else if (display_setting.compare("table") == 0) { //menu.addAction(tr("New table")); } QAction *a = menu.exec(event->screenPos()); if(a && QString::compare(a->text(),tr("Refresh")) == 0) { if(display_setting.compare("view") == 0) resetViewsVertically2(); else if(display_setting.compare("function") == 0) resetFunctionsVertically2(); else if(display_setting.compare("table") == 0) resetTablesVertically2(); } else if(a && QString::compare(a->text(),tr("New view")) == 0) { emit newView(this); } else if(a && QString::compare(a->text(),tr("New function")) == 0) { emit newFunction(this); } else if(a && QString::compare(a->text(),tr("New table")) == 0) { emit newTable(this); } }
void Schema::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { MainWin::DisplayMode display_mode = mainwin->displayMode(); QMenu menu; menu.addAction(tr("Refresh")); if(display_mode == MainWin::Views){ //menu.addAction(tr("New view")); } else if(display_mode == MainWin::Functions) { //menu.addAction(tr("New function")); } else if (display_mode == MainWin::Tables) { menu.addAction(tr("New table")); } QAction *a = menu.exec(event->screenPos()); if(a && QString::compare(a->text(),tr("Refresh")) == 0) { if(display_mode == MainWin::Views) resetViewsVertically2(); else if(display_mode == MainWin::Functions) resetFunctionsVertically2(); else if(display_mode == MainWin::Tables) resetTablesVertically2(); } else if(a && QString::compare(a->text(),tr("New view")) == 0) { emit newView(this); } else if(a && QString::compare(a->text(),tr("New function")) == 0) { emit newFunction(this); } else if(a && QString::compare(a->text(),tr("New table")) == 0) { emit newTable(this); } }
void Tilemap::update(const sf::View& view, int margin) { sf::IntRect newView((view.getCenter().x - (view.getSize().x / 2.f)) / tilesize, (view.getCenter().y - (view.getSize().y / 2.f)) / tilesize, (view.getSize().x) / tilesize, (view.getSize().y) / tilesize); // @TODO Handle rotations & all the shizzle because SFML. sf::IntRect maprect(0, 0, wid, hei); newView = clip(newView, maprect); const sf::Vector2i topleft(newView.left, newView.top), bottomright(newView.left + newView.width, newView.top + newView.height); if (wasTilemapChanged || !vboview.contains(topleft) || !vboview.contains(bottomright)) // if a VBO update is required { vboview = sf::IntRect(newView.left - margin, newView.top - margin, newView.width + (margin * 2), newView.height + (margin * 2)); vboview = clip(vboview, maprect); vbo = buildVertexArray(vboview); } }
void KoView::setupGlobalActions() { actionNewView = new KAction( i18n( "&New View" ), "window_new", 0, this, SLOT( newView() ), actionCollection(), "view_newview" ); }
Main::Main(QCanvas& c, QWidget* parent, const char* name, WFlags f) : QMainWindow(parent,name,f), canvas(c) { editor = new FigureEditor(canvas,this); // 繼承canvas view而來 QMenuBar* menu = menuBar(); QPopupMenu* file = new QPopupMenu( menu ); // 當parent被刪除,則子類別也會被刪除 file->insertItem("&Fill canvas", this, SLOT(init()), CTRL+Key_F); file->insertItem("&Erase canvas", this, SLOT(clear()), CTRL+Key_E); file->insertItem("&New view", this, SLOT(newView()), CTRL+Key_N); file->insertSeparator(); file->insertItem("&Print...", this, SLOT(print()), CTRL+Key_P); file->insertSeparator(); file->insertItem("E&xit", qApp, SLOT(quit()), CTRL+Key_Q); menu->insertItem("&File", file); // 建立一個工具列名為File的label QPopupMenu* edit = new QPopupMenu( menu ); edit->insertItem("Add &Circle", this, SLOT(addCircle()), ALT+Key_C); edit->insertItem("Add &Hexagon", this, SLOT(addHexagon()), ALT+Key_H); edit->insertItem("Add &Polygon", this, SLOT(addPolygon()), ALT+Key_P); edit->insertItem("Add Spl&ine", this, SLOT(addSpline()), ALT+Key_I); edit->insertItem("Add &Text", this, SLOT(addText()), ALT+Key_T); edit->insertItem("Add &Line", this, SLOT(addLine()), ALT+Key_L); edit->insertItem("Add &Rectangle", this, SLOT(addRectangle()), ALT+Key_R); edit->insertItem("Add &Sprite", this, SLOT(addSprite()), ALT+Key_S); edit->insertItem("Create &Mesh", this, SLOT(addMesh()), ALT+Key_M ); edit->insertItem("Add &Alpha-blended image", this, SLOT(addButterfly()), ALT+Key_A); menu->insertItem("&Edit", edit); QPopupMenu* view = new QPopupMenu( menu ); view->insertItem("&Enlarge", this, SLOT(enlarge()), SHIFT+CTRL+Key_Plus); view->insertItem("Shr&ink", this, SLOT(shrink()), SHIFT+CTRL+Key_Minus); view->insertSeparator(); view->insertItem("&Rotate clockwise", this, SLOT(rotateClockwise()), CTRL+Key_PageDown); view->insertItem("Rotate &counterclockwise", this, SLOT(rotateCounterClockwise()), CTRL+Key_PageUp); view->insertItem("&Zoom in", this, SLOT(zoomIn()), CTRL+Key_Plus); view->insertItem("Zoom &out", this, SLOT(zoomOut()), CTRL+Key_Minus); view->insertItem("Translate left", this, SLOT(moveL()), CTRL+Key_Left); view->insertItem("Translate right", this, SLOT(moveR()), CTRL+Key_Right); view->insertItem("Translate up", this, SLOT(moveU()), CTRL+Key_Up); view->insertItem("Translate down", this, SLOT(moveD()), CTRL+Key_Down); view->insertItem("&Mirror", this, SLOT(mirror()), CTRL+Key_Home); menu->insertItem("&View", view); options = new QPopupMenu( menu ); dbf_id = options->insertItem("Double buffer", this, SLOT(toggleDoubleBuffer())); options->setItemChecked(dbf_id, TRUE); menu->insertItem("&Options",options); menu->insertSeparator(); QPopupMenu* help = new QPopupMenu( menu ); help->insertItem("&About", this, SLOT(help()), Key_F1); help->setItemChecked(dbf_id, TRUE); // 很奇怪,當TRUE時,把dbf_id打勾,不懂 menu->insertItem("&Help",help); statusBar(); // 返回這個窗口的狀態條。如果沒有的話 // statusBar()會創建一個空的狀態條,並且如果需要也創建一個工具提示組。 setCentralWidget(editor); printer = 0; init(); }
int main (int argc, const char * argv[]) { mainWindow = new sf::RenderWindow(sf::VideoMode(1440,900), "Alpha & Omega",sf::Style::Fullscreen); ezCursor cursor; std::vector<std::string> klm; getFileList(getResourcePath(0), "ttf", klm); // std::cout<<klm.size()<<std::endl; sf::Texture texture; if (!texture.loadFromFile(getResourcePath(1) + "davsan.png")) return EXIT_FAILURE; sf::Texture background; if(!background.loadFromFile(getResourcePath(1)+"ConfusedOrc.png")) return EXIT_FAILURE; sf::Sprite backSprite(background); backSprite.setPosition(0, 0); sf::Sprite back1(background); back1.setPosition(backSprite.getPosition().x+backSprite.getGlobalBounds().width, backSprite.getPosition().y); sf::Sprite back2(background); back2.setPosition(back1.getPosition().x+back1.getGlobalBounds().width, back1.getPosition().y); sf::Sprite sprite(texture); sprite.setPosition(720, 450); sf::Clock frameClock; int i=0,j=0; sf::View view = mainWindow->getView(); sf::View newView(sf::FloatRect(0,0,1440,900)); mainWindow->setFramerateLimit(90); while (mainWindow->isOpen()) { // Process events mainWindow->clear(); sf::Event event; while (mainWindow->pollEvent(event)) { // Close window : exit if (event.type == sf::Event::Closed) mainWindow->close(); // Escape pressed : exit if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) mainWindow->close(); if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Left) { newView.move(-10,0); } if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Right) { newView.move(10,0); } if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Up) { newView.move(0,-10); } if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Down) { newView.move(0,10); } } //sf::FloatRect rect(sf::Vector2f(view.getCenter() - sf::Vector2f(view.getSize().x/2, view.getSize().y/2)), sf::Vector2f(view.getSize())); //sprite.setPosition(rect.left+(rect.width/2), rect.top+(rect.height/2)); // sf::Vector2f paka=mainWindow->convertCoords(sf::Vector2i(ty,kl), view); // sf::Mouse::setPosition(sf::Vector2i(paka.x,paka.y)); if(sf::Mouse::isButtonPressed(sf::Mouse::Left)) { std::cout<<"Mouse = "<<cursor.getPosition(newView).x<<" "<<cursor.getPosition(newView).y<<std::endl; std::cout<<"img = "<<back2.getGlobalBounds().left<<" "<<back2.getGlobalBounds().top<<std::endl; } //sprite.move(8.f*frameClock.getElapsedTime().asSeconds(),0.f*frameClock.getElapsedTime().asSeconds()); if(frameClock.getElapsedTime().asMilliseconds() >= 10000/100) { frameClock.restart(); i++; if(i==11) { j++; i=0; } if(j==5) { j=0; } } // std::cout<<i<<" "<<j<<std::endl; sprite.setTextureRect(sf::IntRect(100*i,120*0,100,120)); //sprite2.setTextureRect(sf::IntRect(100*i,120*0,100,120)); // Clear screen mainWindow->setView(newView); mainWindow->draw(backSprite); mainWindow->draw(back1); mainWindow->draw(back2); // Draw the sprite mainWindow->setView(mainWindow->getDefaultView()); mainWindow->draw(sprite); cursor.render(); mainWindow->display(); } return EXIT_SUCCESS; }
Manager::View * Manager::newView(Expr::Manager::View & exprView, string solver) { return newView(exprView, toSolver(solver)); }