Пример #1
0
	void ToolConfig::writeDefaults()
	{
		if (KMessageBox::warningContinueCancel(this, i18n("All your tool settings will be overwritten with the default settings, are you sure you want to continue?")) == KMessageBox::Continue) {
			QStringList groups = m_config->groupList();
			QRegExp re = QRegExp("Tool/(.+)/.+");
			for(int i = 0; i < groups.count(); ++i) {
				if (re.exactMatch(groups[i])) {
					m_config->deleteGroup(groups[i]);
				}
			}
			// magic names, defined in kilestdtools.rc
			m_config->deleteGroup("ToolsGUI");
			m_config->deleteGroup("Tools");

			m_manager->factory()->readStandardToolConfig();
			m_config->sync();
			updateToollist();
  			QStringList tools = KileTool::toolList(m_config, true);
			for (int i = 0; i < tools.count(); ++i) {
				switchTo(tools[i], false);// needed to retrieve the new map
 				switchTo(tools[i],true); // this writes the newly retrieved entry map (and not an perhaps changed old one)
			}
			int index = indexQuickBuild();
			if(!tools.empty()) {
				switchTo(tools[index], false);
				m_configWidget->m_lstbTools->item(index)->setSelected(true);
			}
		}
	}
Пример #2
0
void MainWindow::updateView()
{
    QSurfaceFormat format;
    format.setDepthBufferSize(16);
    format.setStencilBufferSize(8);
    if (m_transparent)
        format.setAlphaBufferSize(8);
    if (m_checkboxMultiSample->isChecked())
        format.setSamples(4);

    State state = m_radioView->isChecked() ? UseWindow : UseWidget;

    if (m_format == format && m_state == state)
        return;

    m_format = format;
    m_state = state;

    QString text = m_currentRootObject
            ? m_currentRootObject->property("currentText").toString()
            : QStringLiteral("Hello Qt");

    QUrl source("qrc:qquickviewcomparison/test.qml");

    if (m_state == UseWindow) {
        QQuickView *quickView = new QQuickView;
        // m_transparent is not supported here since many systems have problems with semi-transparent child windows
        quickView->setFormat(m_format);
        quickView->setResizeMode(QQuickView::SizeRootObjectToView);
        connect(quickView, &QQuickView::statusChanged, this, &MainWindow::onStatusChangedView);
        connect(quickView, &QQuickView::sceneGraphError, this, &MainWindow::onSceneGraphError);
        quickView->setSource(source);
        m_currentRootObject = quickView->rootObject();
        switchTo(QWidget::createWindowContainer(quickView));
    } else if (m_state == UseWidget) {
        QQuickWidget *quickWidget = new QQuickWidget;
        if (m_transparent) {
            quickWidget->setClearColor(Qt::transparent);
            quickWidget->setAttribute(Qt::WA_TranslucentBackground);
        }
        quickWidget->setFormat(m_format);
        quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
        connect(quickWidget, &QQuickWidget::statusChanged, this, &MainWindow::onStatusChangedWidget);
        connect(quickWidget, &QQuickWidget::sceneGraphError, this, &MainWindow::onSceneGraphError);
        quickWidget->setSource(source);
        m_currentRootObject = quickWidget->rootObject();
        switchTo(quickWidget);
    }

    if (m_currentRootObject) {
        m_currentRootObject->setProperty("currentText", text);
        m_currentRootObject->setProperty("multisample", m_checkboxMultiSample->isChecked());
        m_currentRootObject->setProperty("translucency", m_transparent);
    }

    m_overlayLabel->raise();
}
Пример #3
0
/**
Hides GUI and starts the game.
*/
void UserFace::launchGame(){
    hideAll();
    gameplay.theGame();
    if (gameplay.local){
        switchTo(mMain);
    }else{
        switchTo(mNetGames);
    }
    if (message != "") showMessage();
}
Пример #4
0
void BanlistDialog::saveAll() {
    for (int i = 0; i < lists.length(); i++) {
        switchTo(i);
        save();
    }
    BanPair::loadBanPairs();
}
Пример #5
0
	void ToolConfig::newTool()
	{
		//KILE_DEBUG_MAIN << "==ToolConfig::newTool()=====================";
		NewToolWizard *ntw = new NewToolWizard(this);
		if (ntw->exec()) {
			QString toolName = ntw->toolName();
			QString parentTool = ntw->parentTool();

			writeStdConfig(toolName, "Default");
			if(parentTool != ntw->customTool()) {
				//copy tool info
				KileTool::Config tempMap;
				m_manager->retrieveEntryMap(parentTool, tempMap, false, false);
				KConfigGroup toolGroup = m_config->group(KileTool::groupFor(toolName, "Default"));
				toolGroup.writeEntry("class", tempMap["class"]);
				toolGroup.writeEntry("type", tempMap["type"]);
				toolGroup.writeEntry("state", tempMap["state"]);
				toolGroup.writeEntry("close", tempMap["close"]);
				toolGroup.writeEntry("checkForRoot", tempMap["checkForRoot"]);
				toolGroup.writeEntry("autoRun", tempMap["autoRun"]);
				toolGroup.writeEntry("jumpToFirstError", tempMap["jumpToFirstError"]);
			}

			m_configWidget->m_lstbTools->blockSignals(true);
			updateToollist();
			switchTo(toolName);
			for(int i = 0; i < m_configWidget->m_lstbTools->count(); ++i) {
				if(m_configWidget->m_lstbTools->item(i)->text() == toolName) {
					m_configWidget->m_lstbTools->setCurrentRow(i);
					break;
				}
			}
			m_configWidget->m_lstbTools->blockSignals(false);
		}
	}
Пример #6
0
	void ToolConfig::removeTool()
	{
// 		KILE_DEBUG_MAIN << "==ToolConfig::removeTool()=====================";
		if(KMessageBox::warningContinueCancel(this, i18n("Are you sure you want to remove the tool %1?", m_current)) == KMessageBox::Continue) {
			QStringList cfgs = KileTool::configNames(m_current, m_config);
// 			KILE_DEBUG_MAIN << "cfgs " <<  cfgs.join(", ");
			for(int i = 0; i < cfgs.count(); ++i) {
// 				KILE_DEBUG_MAIN << "group " << KileTool::groupFor(m_current, cfgs[i]);
				m_config->deleteGroup(KileTool::groupFor(m_current, cfgs[i]));
			}
			m_config->group("Tools").deleteEntry(m_current);
			m_config->group("ToolsGUI").deleteEntry(m_current);
			m_config->sync();

			int index = m_configWidget->m_lstbTools->currentRow() - 1;
			if(index < 0) {
				index = 0;
			}
			QString tool = m_configWidget->m_lstbTools->item(index)->text();
// 			KILE_DEBUG_MAIN << "tool is " << tool;
			m_configWidget->m_lstbTools->blockSignals(true);
			updateToollist();
			m_configWidget->m_lstbTools->setCurrentRow(index);
			switchTo(tool, false);
			m_configWidget->m_lstbTools->blockSignals(false);
		}
	}
Пример #7
0
QList<QAction*> SwitchDesktop::contextualActions()
{
    QList<QAction*> list;

    const int numDesktops = KWindowSystem::numberOfDesktops();
    const int currentDesktop = KWindowSystem::currentDesktop();

    //Is it either the first time or the desktop number changed?
    if (m_actions.count() < numDesktops) {
        for (int i = m_actions.count() + 1; i <= numDesktops; ++i) {
            QString name = KWindowSystem::desktopName(i);
            QAction *action = new QAction(QString("%1: %2").arg(i).arg(name), this);
            connect(action, SIGNAL(triggered()), this, SLOT(switchTo()));
            action->setData(i);
            m_actions[i] = action;
        }

    } else if (m_actions.count() > numDesktops) {
        for (int i = numDesktops +1; i <= m_actions.count(); ++i) {
            delete m_actions[i];
            m_actions.remove(i);
        }
    }

    for (int i = 1; i <= numDesktops; ++i) {
        QAction *action = m_actions.value(i);
        action->setEnabled(i != currentDesktop);
        list << action;
    }

    return list;
}
Пример #8
0
int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);

    setlinebuf(stdout);
    setlinebuf(stderr);

    printf("triambience: starting daemon version %s\n", APPVERSION);

    switcher *sw;
    UinputEvPoll *uin;
    QThread *uinThread;

    uin = new UinputEvPoll();
    sw = new switcher();
    uinThread = new QThread();

    int fd = uin->openDevice("/dev/input/event0");
    if (fd == -1)
    {
        printf("triambience: error opening input device\n");
        return EXIT_FAILURE;
    }

    uin->moveToThread(uinThread);

    QObject::connect(uin, SIGNAL(tristateChanged(QString)), sw, SLOT(switchTo(QString)));
    QObject::connect(uin, SIGNAL(pollingRequested()), uinThread, SLOT(start()));
    QObject::connect(uinThread, SIGNAL(started()), uin, SLOT(doPoll()));
    QObject::connect(uin, SIGNAL(finished()), uinThread, SLOT(quit()), Qt::DirectConnection);

    uin->requestPolling(fd);

    return app.exec();
}
Пример #9
0
//------------------------------------------------------------------------------------------------
void Window::switchProc()
{
    QString gw = nextGateway();
    if (!gw.isEmpty())
        switchTo(gw);
    else
        runClearGateway();
}
Пример #10
0
bool Directory::createByPath( Directory dir )
{
  Path saveDir = current();
  bool result=true;

  StringArray path = utils::split( dir.toString(), "/" );
  std::string current;
  try
  {
#if  defined(CAESARIA_PLATFORM_UNIX) || defined(CAESARIA_PLATFORM_HAIKU)
    switchTo( "/" );
#endif

    foreach( iter, path )
    {
      current += *iter;
      Path path = current;
      if( path.exist() )
      {
        if( !path.isFolder() )
        {
          Logger::warning( "Current path %s not a directory " + current );
          result = false;
          break;
        }
      }
      else
      {
        if( !create( current ) )
        {
          Logger::warning( "Some error on create directory " + current );
        }
      }
      current += "/";
    }
  }
  catch(...)
  {

  }

  switchTo( saveDir );

  return result;
}
Пример #11
0
void GraphicsZone::updatePoke(int spot)
{
    const auto &fieldInfo = info()->fieldPoke(spot);
    if (fieldInfo.showing && fieldInfo.onTheField && !info()->poke(spot).isKoed()) {
        switchTo(info()->poke(spot), spot, fieldInfo.substitute, fieldInfo.alternateSprite);
    } else {
        switchToNaught(spot);
    }
}
Пример #12
0
void BlockExplorer::forward()
{
    int NewIndex = m_HistoryIndex + 1;
    if (0 <= NewIndex && NewIndex < m_History.size()) {
        m_HistoryIndex = NewIndex;
        ui->searchBox->setText(m_History[NewIndex]);
        switchTo(m_History[NewIndex]);
        updateNavButtons();
    }
}
Пример #13
0
void BlockExplorer::goTo(const QString& query)
{
    if (switchTo(query)) {
        ui->searchBox->setText(query);
        while (m_History.size() > m_HistoryIndex + 1)
            m_History.pop_back();
        m_History.push_back(query);
        m_HistoryIndex = m_History.size() - 1;
        updateNavButtons();
    }
}
Пример #14
0
//------------------------------------------------------------------------------------------------
void Window::applySwitchMode()
{
    int index = switchType->currentIndex();
    switch (index)
    {
    case 0:
        switchMode = mAutoSwitch;
        break;
    case 1:
        switchMode = mUpperGateway;
        break;
    case 2:
        switchMode = mAnyGateway;
        break;
    case 3:
        switchMode = mNoGateway;
        break;
    default:
        switchMode = mOnlyGateway;
        break;
    }

    switch (switchMode)
    {
    case mNoGateway:
        prioTimer->stop();
        switchTimer->stop();
        pingTimer->stop();
        canSwitch = false;
        currentGw.clear();
        runClearGateway();
        forceSwitchButton->setEnabled(false);
        break;
    case mAutoSwitch:
    case mUpperGateway:
    case mAnyGateway:
        indexGateway = -1;
        canSwitch = (gwList->count() > 1);
        switchProc();
        break;
    case mOnlyGateway:
    {
        prioTimer->stop();
        switchTimer->stop();
        canSwitch = false;
        QListWidgetItem * item = gwList->item(index - 4);
        if (item)
            switchTo(item->text());
        forceSwitchButton->setEnabled(false);
    }
    break;
    }
}
void
MSTLLogicControl::check2Switch(SUMOTime step) {
    for (std::vector<WAUTSwitchProcess>::iterator i = myCurrentlySwitched.begin(); i != myCurrentlySwitched.end();) {
        const WAUTSwitchProcess& proc = *i;
        if (proc.proc->trySwitch(step)) {
            delete proc.proc;
            switchTo((*i).to->getID(), (*i).to->getProgramID());
            i = myCurrentlySwitched.erase(i);
        } else {
            ++i;
        }
    }
}
Пример #16
0
int main(int argc, char * argv[]) {
	int running = GL_TRUE;
	glewExperimental = GL_TRUE;
	glfwInit();
	glfwOpenWindow(1000, 1000, 0,0,0,0,0,0, GLFW_WINDOW);
	glewInit();
	glEnable(GL_DEPTH_TEST);

	//Obj triangle = Obj(triangle_verts, 3, triangle_elements, 3, "v.vert", "t.tessc", "t.tesse", "g.geom", "f.frag");	
	//Obj square =  Obj(square_verts, 4, square_elements, 6, "v.vert", NULL, NULL, "g.geom", "f.frag");
	Obj wireframe_sphere = Obj(tetra_verts, 4, tetra_elements, 12 , "v.vert", "t.tessc", "t.tesse", "g.geom", "f.frag");
	Obj wireframe_cone = *generateCone(20);//Obj(cone_verts, 6, cone_elements, 24 , "v.vert", NULL, NULL, "g.geom", "f.frag");
	Obj hedgehog_sphere = Obj(tetra_verts, 4, tetra_elements, 12, "v.vert", "t.tessc", "t.tesse", "hedgehog.geom", "f.frag");
	Obj lit_sphere = Obj(tetra_verts, 4, tetra_elements, 12, "v.vert", "t.tessc", "t.tesse", "lit.geom", "lit.frag");



	
	switchTo(&wireframe_sphere);
	while(running) {
		glClearColor(0.0,0.0, 0.0, 1.0);
		glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

		render(drawing, glfwGetTime()*30);
		glfwSwapBuffers();
		running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED);
		if(glfwGetKey('A')){switchTo(&wireframe_sphere);}
		if(glfwGetKey('B')){switchTo(&wireframe_cone);}
		if(glfwGetKey('C')){switchTo(&hedgehog_sphere);}
		if(glfwGetKey('D')){switchTo(&lit_sphere);}
		if(glfwGetKey('E')){}

	}

	glfwTerminate();
}
Пример #17
0
	void ToolConfig::newConfig()
	{
		//KILE_DEBUG_MAIN << "==ToolConfig::newConfig()=====================";
		writeConfig();
		bool ok;
		QString cfg = QInputDialog::getText(this, i18n("New Configuration"), i18n("Enter new configuration name:"), QLineEdit::Normal, "", &ok);
		if (ok && (!cfg.isEmpty())) {
			//copy config
			KConfigGroup toolGroup = m_config->group(KileTool::groupFor(m_current, cfg));
			for (QMap<QString,QString>::Iterator it  = m_map.begin(); it != m_map.end(); ++it) {
				toolGroup.writeEntry(it.key(), it.value());
			}
			KileTool::setConfigName(m_current, cfg, m_config);
			switchTo(m_current, false);
			switchConfig(cfg);
		}
	}
Пример #18
0
void ToolConfig::removeConfig()
{
    //KILE_DEBUG() << "==ToolConfig::removeConfig()=====================" << endl;
    writeConfig();
    if ( m_configWidget->m_cbConfig->count() > 1)
    {
        if ( KMessageBox::warningContinueCancel(this, i18n("Are you sure you want to remove this configuration?") ) == KMessageBox::Continue )
        {
            m_config->deleteGroup(KileTool::groupFor(m_current, m_configWidget->m_cbConfig->currentText()));
            updateConfiglist();
            KileTool::setConfigName(m_current, m_configWidget->m_cbConfig->text(0), m_config);
            switchTo(m_current, false);
        }
    }
    else
        KMessageBox::error(this, i18n("You need at least one configuration for each tool."), i18n("Cannot Remove Configuration"));
}
Пример #19
0
void GUIManager::createUI() {
	startMessage = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText", "Game/StartMenu");
	startMessage->setText("FOR A SINGLE PLAYER GAME, PRESS 1.\nFOR A MULTIPLAYER GAME, PRESS 2.\n\n" + instructions);
	startMessage->setSize(CEGUI::USize(CEGUI::UDim(0.5, 0), CEGUI::UDim(0.3, 0)));
	startMessage->setPosition(CEGUI::UVector2(CEGUI::UDim(0.25,0), CEGUI::UDim(0.5, 0)));
	CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->addChild(startMessage);

	pointsScored = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Editbox", "Game/PointsScored");
	pointsScored->setText("Player 1 Points Scored:   0");
	pointsScored->setSize(CEGUI::USize(CEGUI::UDim(.4,0), CEGUI::UDim(.1, 0)));
	pointsScored->setPosition(CEGUI::UVector2(CEGUI::UDim(0.7, 0), CEGUI::UDim(0, 0)));
	CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->addChild(pointsScored);

	oppScored = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Editbox", "Game/OppScored");
	oppScored->setText("Player 2 Points Scored:   0");
	oppScored->setSize(CEGUI::USize(CEGUI::UDim(.4,0), CEGUI::UDim(.1, 0)));
	oppScored->setPosition(CEGUI::UVector2(CEGUI::UDim(0.7, 0), CEGUI::UDim(0.9, 0)));
	CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->addChild(oppScored);

	timeView = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Editbox", "Game/TimeLeft");
	timeView->setText("Time Remaining: 60");
	timeView->setSize(CEGUI::USize(CEGUI::UDim(.3,0), CEGUI::UDim(.1, 0)));
	timeView->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0)));
	CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->addChild(timeView);

	gameOver = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText", "Game/GameOver");
	gameOver->setText("Your fish has been cooked! Game Over!");
	gameOver->setSize(CEGUI::USize(CEGUI::UDim(.5,0), CEGUI::UDim(.1, 0)));
	gameOver->setPosition(CEGUI::UVector2(CEGUI::UDim(0.25, 0), CEGUI::UDim(0.4, 0)));
	CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->addChild(gameOver);

	enterIPBox = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Editbox", "Game/IPBox");
	enterIPBox->setText("Enter Host IP Address: ");
	enterIPBox->setSize(CEGUI::USize(CEGUI::UDim(.5,0), CEGUI::UDim(.1, 0)));
	enterIPBox->setPosition(CEGUI::UVector2(CEGUI::UDim(0.25, 0), CEGUI::UDim(0.4, 0)));
	CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->addChild(enterIPBox);

	connection = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Editbox", "Game/Connecting");
	connection->setText("Waiting for client to join...   ");
	connection->setSize(CEGUI::USize(CEGUI::UDim(.5,0), CEGUI::UDim(.1, 0)));
	connection->setPosition(CEGUI::UVector2(CEGUI::UDim(0.25, 0), CEGUI::UDim(0.4, 0)));
	CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->addChild(connection);
	
	switchTo(MAIN); // inital UI on startup

}
Пример #20
0
void ToolConfig::newConfig()
{
    //KILE_DEBUG() << "==ToolConfig::newConfig()=====================" << endl;
    writeConfig();
    bool ok;
    QString cfg = KInputDialog::getText(i18n("New Configuration"), i18n("Enter new configuration name:"), "", &ok, this);
    if (ok && (!cfg.isEmpty()))
    {
        //copy config
        m_config->setGroup(KileTool::groupFor(m_current, cfg));
        for (QMap<QString,QString>::Iterator it  = m_map.begin(); it != m_map.end(); ++it)
        {
            m_config->writeEntry(it.key(), it.data());
        }
        KileTool::setConfigName(m_current, cfg, m_config);
        switchTo(m_current, false);
        switchConfig(cfg);
    }
}
Пример #21
0
void
MSTLLogicControl::TLSLogicVariants::setStateInstantiatingOnline(MSTLLogicControl& tlc,
        const std::string& state) {
    // build only once...
    MSTrafficLightLogic* logic = getLogic("online");
    if (logic == nullptr) {
        MSPhaseDefinition* phase = new MSPhaseDefinition(DELTA_T, state, -1);
        std::vector<MSPhaseDefinition*> phases;
        phases.push_back(phase);
        logic = new MSSimpleTrafficLightLogic(tlc, myCurrentProgram->getID(), "online", TLTYPE_STATIC, phases, 0,
                                              MSNet::getInstance()->getCurrentTimeStep() + DELTA_T,
                                              std::map<std::string, std::string>());
        addLogic("online", logic, true, true);
        MSNet::getInstance()->createTLWrapper(logic);
    } else {
        MSPhaseDefinition nphase(DELTA_T, state, -1);
        *(dynamic_cast<MSSimpleTrafficLightLogic*>(logic)->getPhases()[0]) = nphase;
        switchTo(tlc, "online");
    }
}
Пример #22
0
	void ToolConfig::removeConfig()
	{
		//KILE_DEBUG_MAIN << "==ToolConfig::removeConfig()=====================";
		writeConfig();
		if ( m_configWidget->m_cbConfig->count() > 1) {
			if(KMessageBox::warningContinueCancel(this, i18n("Are you sure that you want to remove this configuration?") )
			   == KMessageBox::Continue) {
				m_config->deleteGroup(KileTool::groupFor(m_current, m_configWidget->m_cbConfig->currentText()));
				int currentIndex = m_configWidget->m_cbConfig->currentIndex();
				int newIndex = 0;
				if(currentIndex == 0 )
					newIndex = 1;
				KileTool::setConfigName(m_current, m_configWidget->m_cbConfig->itemText(newIndex), m_config);
				m_config->reparseConfiguration(); // FIXME should be not needed
				updateConfiglist();
				switchTo(m_current, false);
			}
		}
		else {
			KMessageBox::error(this, i18n("You need at least one configuration for each tool."), i18n("Cannot Remove Configuration"));
		}
	}
Пример #23
0
void ToolConfig::removeTool()
{
    //KILE_DEBUG() << "==ToolConfig::removeTool()=====================" << endl;
    if ( KMessageBox::warningContinueCancel(this, i18n("Are you sure you want to remove the tool %1?").arg(m_current)) == KMessageBox::Continue )
    {
        KConfig *config = m_config;
        QStringList cfgs = KileTool::configNames(m_current, config);
        for ( uint i = 0; i < cfgs.count(); ++i)
        {
            config->deleteGroup(KileTool::groupFor(m_current, cfgs[i]));
        }
        config->setGroup("Tools");
        config->deleteEntry(m_current);
        int index = m_configWidget->m_lstbTools->currentItem()-1;
        if ( index < 0 ) index=0;
        QString tool = m_configWidget->m_lstbTools->text(index);
        m_configWidget->m_lstbTools->blockSignals(true);
        updateToollist();
        m_configWidget->m_lstbTools->setCurrentItem(index);
        switchTo(tool, false);
        m_configWidget->m_lstbTools->blockSignals(false);
    }
}
Пример #24
0
/**
Pseudoconstructor of whole GUI.
Creates menus, loads font and background, initializes main menu.
*/
void UserFace::init(){

    imageMap = 0;

        SDL_FreeSurface(splashimg);

        SDLInput* input;
        SDLGraphics* graphics;

        graphics = new SDLGraphics();
        graphics->setTarget(gfx.screen);
        input = new SDLInput();

        gui = new Gui();
        gui->setGraphics(graphics);
        gui->setInput(input);

        SDLImageLoader* imgLoader = new SDLImageLoader();
        Image::setImageLoader(imgLoader);

        ImageFont* font;

    font = new ImageFont(settings.loc_fontimg," abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]_{}><");
        gcn::Widget::setGlobalFont(font);

        createMenus();

        getBkgImage();
        gui->setTop(container);

        current=mMain;
        switchTo(mMain);

    quit = false;
	
	setkey = false;
}
void
MSTLLogicControl::addWAUTJunction(const std::string &wautid,
                                  const std::string &tls,
                                  const std::string &proc,
                                  bool synchron) throw(InvalidArgument, ProcessError) {
    // try to get the waut
    if (myWAUTs.find(wautid)==myWAUTs.end()) {
        // report an error if the waut is not known
        throw InvalidArgument("Waut '" + wautid + "' was not yet defined.");
    }
    // try to get the tls to switch
    if (myLogics.find(tls)==myLogics.end()) {
        // report an error if the tls is not known
        throw InvalidArgument("TLS '" + tls + "' to switch in WAUT '" + wautid + "' was not yet defined.");
    }
    WAUTJunction j;
    j.junction = tls;
    j.procedure = proc;
    j.synchron = synchron;
    myWAUTs[wautid]->junctions.push_back(j);

    std::string initProg = myWAUTs[wautid]->startProg;
    std::vector<WAUTSwitch>::const_iterator first = myWAUTs[wautid]->switches.end();
    SUMOTime minExecTime = -1;
    int minIndex = -1;
    for (std::vector<WAUTSwitch>::const_iterator i=myWAUTs[wautid]->switches.begin(); i!=myWAUTs[wautid]->switches.end(); ++i) {
        if ((*i).when>MSNet::getInstance()->getCurrentTimeStep()&&(minExecTime==-1||(*i).when<minExecTime)) {
            minExecTime = (*i).when;
            first = i;
        }
        if (first!=myWAUTs[wautid]->switches.begin()) {
            initProg = (*(first-1)).to;
        }
    }
    // activate the first one
    switchTo(tls, initProg);
}
Пример #26
0
/**
The GUI loop. Handles SDL events and network communication.
*/
void UserFace::theGui(){

    init();

        while (!quit){

                SDL_Event event;
                while(SDL_PollEvent(&event)){
					if (event.type==SDL_QUIT) quit = true;
					else if (setkey && (event.type==SDL_KEYDOWN)){
						*(mSettings->cControls->setKey) = event.key.keysym.sym;
						mSettings->cControls->setButton->setCaption(keyname(event.key.keysym.sym));
						mSettings->cControls->setButton->adjustSize();
						userface.setkey = false;
					}else if (!setkey) ((SDLInput*)(gui->getInput()))->pushInput(event);
				}

                gui->logic();

                if (!gameplay.local){
                    network.recv(false);
                    if (network.status < 0){
                        switchTo(mConnect);
                        showMessage("Connection to server lost");
                    }
                }
                if (gameplay.approved) launchGame();

                gui->draw();
                SDL_Flip(gfx.screen);

                SDL_Delay(DELAY);

        }

}
INT_PTR CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
{
	switch (message) 
	{
		case WM_INITDIALOG :
		{
			switchTo(activeText);
			::SendDlgItemMessage(_hSelf, IDC_COL_DEC_RADIO, BM_SETCHECK, TRUE, 0);
			goToCenter();

			NppParameters *pNppParam = NppParameters::getInstance();
			ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture();
			if (enableDlgTheme)
			{
				enableDlgTheme(_hSelf, ETDT_ENABLETAB);
				redraw();
			}
			return TRUE;
		}
		case WM_COMMAND : 
		{
			switch (wParam)
			{
				case IDCANCEL : // Close
					display(false);
					return TRUE;

				case IDOK :
                {
					(*_ppEditView)->execute(SCI_BEGINUNDOACTION);
					
					const int stringSize = 1024;
					TCHAR str[stringSize];
					
					bool isTextMode = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_RADIO, BM_GETCHECK, 0, 0));
					
					if (isTextMode)
					{
						::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_EDIT, WM_GETTEXT, stringSize, (LPARAM)str);

						display(false);
						
						if ((*_ppEditView)->execute(SCI_SELECTIONISRECTANGLE) || (*_ppEditView)->execute(SCI_GETSELECTIONS) > 1)
						{
							ColumnModeInfos colInfos = (*_ppEditView)->getColumnModeSelectInfo();
							std::sort(colInfos.begin(), colInfos.end(), SortInPositionOrder());
							(*_ppEditView)->columnReplace(colInfos, str);
							std::sort(colInfos.begin(), colInfos.end(), SortInSelectOrder());
							(*_ppEditView)->setMultiSelections(colInfos);
						}
						else
						{
							int cursorPos = (*_ppEditView)->execute(SCI_GETCURRENTPOS);
							int cursorCol = (*_ppEditView)->execute(SCI_GETCOLUMN, cursorPos);
							int cursorLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, cursorPos);
							int endPos = (*_ppEditView)->execute(SCI_GETLENGTH);
							int endLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, endPos);

							int lineAllocatedLen = 1024;
							TCHAR *line = new TCHAR[lineAllocatedLen];

							for (int i = cursorLine ; i <= endLine ; ++i)
							{
								int lineBegin = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, i);
								int lineEnd = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, i);

								int lineEndCol = (*_ppEditView)->execute(SCI_GETCOLUMN, lineEnd);
								int lineLen = lineEnd - lineBegin + 1;

								if (lineLen > lineAllocatedLen)
								{
									delete [] line;
									line = new TCHAR[lineLen];
								}
								(*_ppEditView)->getGenericText(line, lineLen, lineBegin, lineEnd);
								generic_string s2r(line);

								if (lineEndCol < cursorCol)
								{
									generic_string s_space(cursorCol - lineEndCol, ' ');
									s2r.append(s_space);
									s2r.append(str);
								}
								else
								{
									int posAbs2Start = (*_ppEditView)->execute(SCI_FINDCOLUMN, i, cursorCol);
									int posRelative2Start = posAbs2Start - lineBegin;
									s2r.insert(posRelative2Start, str);
								}
								(*_ppEditView)->replaceTarget(s2r.c_str(), lineBegin, lineEnd);
							}
							delete [] line;
						}
					}
					else
					{
						int initialNumber = ::GetDlgItemInt(_hSelf, IDC_COL_INITNUM_EDIT, NULL, TRUE);
						int increaseNumber = ::GetDlgItemInt(_hSelf, IDC_COL_INCREASENUM_EDIT, NULL, TRUE);
						int repeat = ::GetDlgItemInt(_hSelf, IDC_COL_REPEATNUM_EDIT, NULL, TRUE);
						if (repeat == 0)
						{
							repeat = 1; // Without this we might get an infinite loop while calculating the set "numbers" below.
						}
						UCHAR format = getFormat();
						display(false);
						
						if ((*_ppEditView)->execute(SCI_SELECTIONISRECTANGLE) || (*_ppEditView)->execute(SCI_GETSELECTIONS) > 1)
						{
							ColumnModeInfos colInfos = (*_ppEditView)->getColumnModeSelectInfo();
							std::sort(colInfos.begin(), colInfos.end(), SortInPositionOrder());
							(*_ppEditView)->columnReplace(colInfos, initialNumber, increaseNumber, repeat, format);
							std::sort(colInfos.begin(), colInfos.end(), SortInSelectOrder());
							(*_ppEditView)->setMultiSelections(colInfos);
						}
						else
						{
							int cursorPos = (*_ppEditView)->execute(SCI_GETCURRENTPOS);
							int cursorCol = (*_ppEditView)->execute(SCI_GETCOLUMN, cursorPos);
							int cursorLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, cursorPos);
							int endPos = (*_ppEditView)->execute(SCI_GETLENGTH);
							int endLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, endPos);

							// Compute the numbers to be placed at each column.
							std::vector<int> numbers;
							{
								int curNumber = initialNumber;
								const unsigned int kiMaxSize = 1 + (unsigned int)endLine - (unsigned int)cursorLine;
								while (numbers.size() < kiMaxSize)
								{
									for (int i = 0; i < repeat; i++)
									{
										numbers.push_back(curNumber);
										if (numbers.size() >= kiMaxSize)
										{
											break;
										}
									}
									curNumber += increaseNumber;
								}
							}
							assert(numbers.size() > 0);

							int lineAllocatedLen = 1024;
							TCHAR *line = new TCHAR[lineAllocatedLen];


							UCHAR f = format & MASK_FORMAT;
							bool isZeroLeading = (MASK_ZERO_LEADING & format) != 0;
							
							int base = 10;
							if (f == BASE_16)
								base = 16;
							else if (f == BASE_08)
								base = 8;
							else if (f == BASE_02)
								base = 2;

							int endNumber = *numbers.rbegin();
							int nbEnd = getNbDigits(endNumber, base);
							int nbInit = getNbDigits(initialNumber, base);
							int nb = max(nbInit, nbEnd);


							for (int i = cursorLine ; i <= endLine ; ++i)
							{
								int lineBegin = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, i);
								int lineEnd = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, i);

								int lineEndCol = (*_ppEditView)->execute(SCI_GETCOLUMN, lineEnd);
								int lineLen = lineEnd - lineBegin + 1;

								if (lineLen > lineAllocatedLen)
								{
									delete [] line;
									line = new TCHAR[lineLen];
								}
								(*_ppEditView)->getGenericText(line, lineLen, lineBegin, lineEnd);
								generic_string s2r(line);

								//
								// Calcule generic_string
								//
								int2str(str, stringSize, numbers.at(i - cursorLine), base, nb, isZeroLeading);

								if (lineEndCol < cursorCol)
								{
									generic_string s_space(cursorCol - lineEndCol, ' ');
									s2r.append(s_space);
									s2r.append(str);
								}
								else
								{
									int posAbs2Start = (*_ppEditView)->execute(SCI_FINDCOLUMN, i, cursorCol);
									int posRelative2Start = posAbs2Start - lineBegin;
									s2r.insert(posRelative2Start, str);
								}

								(*_ppEditView)->replaceTarget(s2r.c_str(), lineBegin, lineEnd);
							}
							delete [] line;
						}
					}
					(*_ppEditView)->execute(SCI_ENDUNDOACTION);
                    (*_ppEditView)->getFocus();
                    return TRUE;
                }
				case IDC_COL_TEXT_RADIO :
				case IDC_COL_NUM_RADIO :
				{
					switchTo((wParam == IDC_COL_TEXT_RADIO)? activeText : activeNumeric);
					return TRUE;
				}

				default :
				{
					switch (HIWORD(wParam))
					{
						case EN_SETFOCUS :
						case BN_SETFOCUS :
							//updateLinesNumbers();
							return TRUE;
						default :
							return TRUE;
					}
					break;
				}
			}
		}

		default :
			return FALSE;
	}
	//return FALSE;
}
Пример #28
0
void
Scheduler::stop()
{
    // Already stopped
    if (m_rootFiber &&
        m_threadCount == 0 &&
        (m_rootFiber->state() == Fiber::TERM || m_rootFiber->state() == Fiber::INIT)) {
        MORDOR_LOG_VERBOSE(g_log) << this << " stopped";
        m_stopping = true;
        // A derived class may inhibit stopping while it has things to do in
        // its idle loop, so we can't break early
        if (stopping())
            return;
    }

    bool exitOnThisFiber = false;
    if (m_rootThread != emptytid()) {
        // A thread-hijacking scheduler must be stopped
        // from within itself to return control to the
        // original thread
        MORDOR_ASSERT(Scheduler::getThis() == this);
        if (Fiber::getThis() == m_callingFiber) {
            exitOnThisFiber = true;
            // First switch to the correct thread
            MORDOR_LOG_DEBUG(g_log) << this
                << " switching to root thread to stop";
            switchTo(m_rootThread);
        }
        if (!m_callingFiber)
            exitOnThisFiber = true;
    } else {
        // A spawned-threads only scheduler cannot be stopped from within
        // itself... who would get control?
        MORDOR_ASSERT(Scheduler::getThis() != this);
    }
    m_stopping = true;
    for (size_t i = 0; i < m_threadCount; ++i)
        tickle();
    if (m_rootFiber && (m_threadCount != 0u || Scheduler::getThis() != this))
        tickle();
    // Wait for all work to stop on this thread
    if (exitOnThisFiber) {
        while (!stopping()) {
            // Give this thread's run fiber a chance to kill itself off
            MORDOR_LOG_DEBUG(g_log) << this
                << " yielding to this thread to stop";
            yieldTo(true);
        }
    }
    // Wait for other threads to stop
    if (exitOnThisFiber ||
        Scheduler::getThis() != this) {
        MORDOR_LOG_DEBUG(g_log) << this
            << " waiting for other threads to stop";
        std::vector<boost::shared_ptr<Thread> > threads;
        {
            boost::mutex::scoped_lock lock(m_mutex);
            threads.swap(m_threads);
        }
        for (std::vector<boost::shared_ptr<Thread> >::const_iterator it
            (threads.begin());
            it != threads.end();
            ++it) {
            (*it)->join();
        }
    }
    MORDOR_LOG_VERBOSE(g_log) << this << " stopped";
}
Пример #29
0
	void ToolConfig::switchConfig(int /*index*/)
	{
		//KILE_DEBUG_MAIN << "==ToolConfig::switchConfig(int /*index*/)====================";
		switchTo(m_current);
	}
Пример #30
0
 void clear()
 {
     switchTo(nullptr);
 }