Пример #1
0
MainWindow::MainWindow(char *loc, char *rem, QWidget *parent) :
    QMainWindow(parent),
    loadingWidget(this),
    dc1394Thread(loc,rem),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

//    ui->tabWidget->setTabEnabled(ui->tabWidget->indexOf(ui->tabCamera), false);

    initMainWindow();
    initFeatureTab();
    initFeatureAdvTab();
    dc1394Thread.doTask(_initFormatTab);

    dc1394Thread.doTask(_init);
    dc1394Thread.doTask(_reload);

    connect(ui->tabWidget,SIGNAL(currentChanged(int)),
            this,SLOT(onTabClicked(int)));

}
Пример #2
0
/**
 * Class constructor.
 * @param	pParent	The parent widget
 * @param	szName	The widget's name
 */
KScope::KScope(QWidget* pParent, const char* szName) :
	KParts::DockMainWindow(pParent, szName),
	m_pCscopeBuild(NULL),	
	m_sCurFilePath(""),
	m_nCurLine(0),
	m_pProgressDlg(NULL),
	m_bUpdateGUI(true),
	m_bCscopeVerified(false),
	m_bRebuildDB(false),
	m_pMakeDlg(NULL)
{
	QString sPath;

	// Load configuration
	Config().load();
	
	// Create the main child widgets
	m_pEditTabs = new EditorTabs(this, NULL);
	m_pQueryWidget = new QueryWidget(this);
	m_pFileView = new FileView(this);
	m_pFileList = m_pFileView->getFileList();
	m_pMsgDlg = new CscopeMsgDlg(this);
	m_pQueryDock = createDockWidget("Query Window", QPixmap());
	m_pFileViewDock = createDockWidget("File List Window", QPixmap());

	// Connect menu and toolbar items with the object's slots
	m_pActions = new KScopeActions(this);
	m_pActions->init();
	m_pActions->slotEnableProjectActions(false);
	
	// Show a toolbar show/hide menu
	setStandardToolBarMenuEnabled(true);
	
	// Create the initial GUI (no active part)
	setXMLFile("kscopeui.rc");
	createShellGUI();
	
	// Create all child widgets
	initMainWindow();

	// Create control objects
	m_pProjMgr = new ProjectManager();
	m_pEditMgr = new EditorManager(this);
	m_pCallTreeMgr = new CallTreeManager(this);

	// Initialise the icon manager	
	Pixmaps().init();
	
	// Open a file for editing when selected in the project's file list or the
	// file tree
	connect(m_pFileView, SIGNAL(fileRequested(const QString&, uint)), this,
		SLOT(slotShowEditor(const QString&, uint)));

	// Delete an editor page object after it is removed
	connect(m_pEditTabs, SIGNAL(editorRemoved(EditorPage*)),
		this, SLOT(slotDeleteEditor(EditorPage*)));
	
	connect(m_pEditTabs, SIGNAL(filesDropped(QDropEvent*)), this,
		SLOT(slotDropEvent(QDropEvent*)));
	
	// Set an editor as the active part whenever its owner tab is selected
	connect(m_pEditTabs, SIGNAL(editorChanged(EditorPage*, EditorPage*)),
		this, SLOT(slotChangeEditor(EditorPage*, EditorPage*)));

	// Display a file at a specific line when selected in a query list
	connect(m_pQueryWidget, SIGNAL(lineRequested(const QString&, uint)),
		this, SLOT(slotQueryShowEditor(const QString&, uint)));
	
	// Display the symbol dialogue when the user opens a new query page
	connect(m_pQueryWidget, SIGNAL(newQuery()), 
		this, SLOT(slotQueryReference()));

	// Rebuild the project database after a certain time period has elapsed
	// since the last save
	connect(&m_timerRebuild, SIGNAL(timeout()), this, SLOT(slotRebuildDB()));

	// Display a file at a specific line when selected in a call tree dialogue
	connect(m_pCallTreeMgr, SIGNAL(lineRequested(const QString&, uint)),
		this, SLOT(slotQueryShowEditor(const QString&, uint)));
		
	// Store main window settings when closed
	setAutoSaveSettings();
	
	// Initialise arrow head drawing
	GraphWidget::setArrowInfo(20, 15);
	
	// Use a maximised window the first time
	if (Config().isFirstTime())
		showMaximized();

	// Show the Welcome message
	if (Config().showWelcomeDlg()) {
		show();
		slotShowWelcome();
	}

	// If this is the first time the user has launched KScope, prompt him/her
	// to configure the global parameters
	if (Config().isFirstTime())
		slotConfigure();		
}
Пример #3
0
void GuiManager::runNewMatch(const char *stageName, char **teamNames,
                             int numUserTeams) {
  tpsFactor_ = 0.5;
  nextDrawTime_ = 1;
  showedResults_ = false;

  sf::RenderWindow *window;
  bool maintainWindowScale = false;
  double prevScale = 1.0;
  double backingScale = getBackingScaleFactor();
  int screenWidth =
      backingScale * sf::VideoMode::getDesktopMode().width;
  int screenHeight =
      backingScale * sf::VideoMode::getDesktopMode().height;
  int dockSize = backingScale * DOCK_SIZE;

  if (window_ != 0) {
    if (restarting_) {
      prevScale = ((double) (window_->getSize().x - dockSize)) / viewWidth_;
      maintainWindowScale = true;
    }
  }
  
  // On Mac OS X, we need to init SFML before the wxWidgets stuff below or we
  // hit some unexplainable crashes when we delete an SFML window. I don't know
  // why, I've merely devised a work-around. Judging from some SFML forum
  // threads, it sounds likely to be an issue with nightmare-ish video drivers.
  if (window_ == 0) {
    window = initMainWindow(backingScale * screenWidth,
                            backingScale * (screenHeight - 75));
  } else {
    window = window_;
  }

  if (!restarting_) {
    saveCurrentMatchSettings(stageName, teamNames, numUserTeams);
  }
  if (engine_ != 0) {
    delete engine_;
    engine_ = 0;
  }

  if (restarting_) {
    stageConsole_->clear();
    guiPrintHandler_->restartMode();
  } else {
    destroyStageConsole();
    stageConsole_ = new OutputConsole(stageName, CONSOLE_SHIP_STAGE,
                                      menuBarMaker_);
    stageConsole_->Hide();

    if (guiPrintHandler_ != 0) {
      delete guiPrintHandler_;
      guiPrintHandler_ = 0;
    }
    guiPrintHandler_ = new GuiPrintHandler(stageConsole_, 0, menuBarMaker_);
  }

  engine_ = new BerryBotsEngine(guiPrintHandler_, fileManager_,
                                resourcePath().c_str());

  Stage *stage = engine_->getStage();
  if (restarting_) {
    stage->setGfxEnabled(stageConsole_->isChecked());
  }
  stageConsole_->setListener(new StageConsoleListener(stage));
  try {
    engine_->initStage(getStagesDir().c_str(), stageName,
                       getCacheDir().c_str());
    engine_->initShips(getShipsDir().c_str(), teamNames, numUserTeams,
                       getCacheDir().c_str());
    teamConsoles_ = guiPrintHandler_->getTeamConsoles();
  } catch (EngineException *e) {
    errorConsole_->print(stageName);
    errorConsole_->print(": ");
    errorConsole_->println(e->what());
    wxMessageDialog errorMessage(NULL, e->what(),
        "BerryBots engine init failed", wxOK | wxICON_EXCLAMATION);
    errorMessage.ShowModal();
    delete engine_;
    engine_ = 0;
    restarting_ = false;
    newMatchDialog_->Show();
    delete e;
    return;
  }

  viewWidth_ = stage->getWidth() + (STAGE_MARGIN * 2);
  viewHeight_ = stage->getHeight() + (STAGE_MARGIN * 2);
  double windowScale;
  if (restarting_ && maintainWindowScale) {
    windowScale = prevScale;
  } else {
    windowScale =
        std::min(backingScale, std::min(
            ((double) screenWidth - dockSize) / viewWidth_,
            ((double) screenHeight) / viewHeight_));
  }
  unsigned int targetWidth = round(windowScale * viewWidth_) + dockSize;
  unsigned int targetHeight = round(windowScale * viewHeight_);

  window->setSize(sf::Vector2u(targetWidth, targetHeight));

  interrupted_ = false;
  paused_ = false;
  newMatchDialog_->Hide();
  packageStageDialog_->Hide();
  packageShipDialog_->Hide();
  gfxHandler_ = new GfxEventHandler();
  stage->addEventHandler((EventHandler*) gfxHandler_);

  // TODO: If/when SFML getPosition() works, adjust the window position to
  //       keep the whole window on the screen (if necessary). Might be worth
  //       platform-specific implementations using getSystemHandle() if that
  //       doesn't happen in a reasonable timeframe.
  //       We could just set it to (0, 0) or centered on screen every time, but
  //       that seems potentially super annoying to a user - less annoying than
  //       having to move the window occasionally if you switch to a bigger
  //       stage that goes off-screen.

  gfxManager_->initBbGfx(window, backingScale, viewHeight_, stage,
                         engine_->getTeams(), engine_->getNumTeams(),
                         engine_->getShips(), engine_->getNumShips());
  gfxManager_->initViews(window, viewWidth_, viewHeight_);
  window->setVisible(true);
  drawFrame(window);

#ifdef __WXOSX__
  // SFML 2.1+ has a weird scaling issue. Some of it is documented here:
  // https://github.com/SFML/SFML/issues/474
  // Basically, OS X caps the window height, but SFML reports the requested
  // height instead of the actual height. My work-around is to manually trigger
  // a resize after drawing one frame.
  processMainWindowEvents(window, gfxManager_, viewWidth_, viewHeight_);
  gfxManager_->onResize(window, viewWidth_, viewHeight_);
#endif

  runCurrentMatch();
}
Пример #4
0
int WINAPI
WinMain(HINSTANCE instance, HINSTANCE, LPSTR cmdLine, int nCmdShow)
{
	CArch arch(instance);
	CLOG;
	CArgs args;

	s_instance = instance;

	// if "/uninstall" is on the command line then just stop and
	// uninstall the service and quit.  this is the only option
	// but we ignore any others.
	if (CString(cmdLine).find("/uninstall") != CString::npos) {
		CAutoStart::uninstallDaemons(false);
		CAutoStart::uninstallDaemons(true);
		return 0;
	}

	// register main window (dialog) class
	WNDCLASSEX classInfo;
	classInfo.cbSize        = sizeof(classInfo);
	classInfo.style         = CS_HREDRAW | CS_VREDRAW;
	classInfo.lpfnWndProc   = &mainWndProc;
	classInfo.cbClsExtra    = 0;
	classInfo.cbWndExtra    = DLGWINDOWEXTRA;
	classInfo.hInstance     = instance;
	classInfo.hIcon         = (HICON)LoadImage(instance,
									MAKEINTRESOURCE(IDI_SYNERGY),
									IMAGE_ICON,
									32, 32, LR_SHARED);
	classInfo.hCursor       = LoadCursor(NULL, IDC_ARROW);
	classInfo.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_3DFACE + 1);
	classInfo.lpszMenuName  = NULL;
	classInfo.lpszClassName = s_mainClass;
	classInfo.hIconSm       = (HICON)LoadImage(instance,
									MAKEINTRESOURCE(IDI_SYNERGY),
									IMAGE_ICON,
									16, 16, LR_SHARED);
	RegisterClassEx(&classInfo);

	// create main window
	HWND mainWindow = CreateDialog(s_instance,
							MAKEINTRESOURCE(IDD_MAIN), 0, NULL);

	// prep windows
	initMainWindow(mainWindow);
	s_globalOptions   = new CGlobalOptions(mainWindow, &ARG->m_config);
	s_advancedOptions = new CAdvancedOptions(mainWindow, &ARG->m_config);
	s_screensLinks    = new CScreensLinks(mainWindow, &ARG->m_config);

	// show window
	ShowWindow(mainWindow, nCmdShow);

	// main loop
	MSG msg;
	bool done = false;
	do {
		switch (GetMessage(&msg, NULL, 0, 0)) {
		case -1:
			// error
			break;

		case 0:
			// quit
			done = true;
			break;

		default:
			if (!IsDialogMessage(mainWindow, &msg)) {
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
			break;
		}
	} while (!done);

	return msg.wParam;
}
Пример #5
0
void Window::initApp()
{
	initMainWindow();
	initDirect3D();
}
Пример #6
0
int WINAPI
WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int nCmdShow)
{
	CArch arch(instance);
	CLOG;
	CArgs args;

	s_instance = instance;

	// register main window (dialog) class
	WNDCLASSEX classInfo;
	classInfo.cbSize        = sizeof(classInfo);
	classInfo.style         = CS_HREDRAW | CS_VREDRAW;
	classInfo.lpfnWndProc   = &mainWndProc;
	classInfo.cbClsExtra    = 0;
	classInfo.cbWndExtra    = DLGWINDOWEXTRA;
	classInfo.hInstance     = instance;
	classInfo.hIcon         = (HICON)LoadImage(instance,
									MAKEINTRESOURCE(IDI_SYNERGY),
									IMAGE_ICON,
									32, 32, LR_SHARED);
	classInfo.hCursor       = LoadCursor(NULL, IDC_ARROW);
	classInfo.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_3DFACE + 1);
	classInfo.lpszMenuName  = NULL;
	classInfo.lpszClassName = s_mainClass;
	classInfo.hIconSm       = (HICON)LoadImage(instance,
									MAKEINTRESOURCE(IDI_SYNERGY),
									IMAGE_ICON,
									16, 16, LR_SHARED);
	RegisterClassEx(&classInfo);

	// create main window
	HWND mainWindow = CreateDialog(s_instance,
							MAKEINTRESOURCE(IDD_MAIN), 0, NULL);

	// prep windows
	initMainWindow(mainWindow);
	s_globalOptions = new CGlobalOptions(mainWindow, &ARG->m_config);
	s_advancedOptions = new CAdvancedOptions(mainWindow, &ARG->m_config);

	// show window
	ShowWindow(mainWindow, nCmdShow);

	// main loop
	MSG msg;
	bool done = false;
	do {
		switch (GetMessage(&msg, NULL, 0, 0)) {
		case -1:
			// error
			break;

		case 0:
			// quit
			done = true;
			break;

		default:
			if (!IsDialogMessage(mainWindow, &msg)) {
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
			break;
		}
	} while (!done);

	// save values to registry
	saveMainWindow(mainWindow);

	return msg.wParam;
}