Exemplo n.º 1
0
    static void on_pick_button_click(Fl_Widget *sender, void *obj)
    {
        Fl_Native_File_Chooser native;
        native.title("Pick a file");
        native.type(Fl_Native_File_Chooser::BROWSE_MULTI_FILE);
        native.filter("CSV\t*.csv");

        if (native.show() == 0)
        {
            bool encode = (((window *)obj)->encode_check->value() == 1);
            bool open = (((window *)obj)->open_file_check->value() == 1);
            int count = native.count();
            for (int i = 0; i < count; ++i)
            {
                std::string filename = native.filename(i);
                if (csv2html(filename, encode) && open)
                {
                    std::string uri("file://");
                    if (filename[0] != '/')
                    {
                        uri.push_back('/'); // Windows
                    }
                    uri += filename + ".html";

                    char errmsg[512];
                    fl_open_uri(uri.c_str(), errmsg, sizeof(errmsg));
                }
            }
        }
    }
Exemplo n.º 2
0
void on_txt_save(Fl_Widget* w,void* data)
{
	Fl_Native_File_Chooser c;
	c.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE);
	c.title("Сохранить");
	c.preset_file("result.txt");
	
	c.filter("Text (*.txt)");
	c.show();
	txt_out->buffer()->savefile(c.filename());
}
Exemplo n.º 3
0
int FractureBox::LoadFractureMapDialog()
{
        Fl_Native_File_Chooser fileBrowser = Fl_Native_File_Chooser(Fl_Native_File_Chooser::BROWSE_FILE);
        fileBrowser.title("Select a fracture map");
        fileBrowser.filter("Image\t*.{fracmap}\n");
        fileBrowser.directory(Global::gMainWindow->GetTextureDirectory());
        if(fileBrowser.show() == 0)
        {
            // LoadFractureMap(fileBrowser.filename(), true);
            Global::gScene->LoadFractureMap(fileBrowser.filename());
            return 1;
        }
        return 0;
}
Exemplo n.º 4
0
void DialogMain::loadImage()
{
    if ( cbUseThreshold != NULL )
    {
        if ( cbUseThreshold->value() > 0 )
        {
            cbUseThreshold->value( 0 );
            thresholdControl();
        }
    }

    Fl_Native_File_Chooser nFC;

    nFC.title( "Choose a RAW image file to open" );
    nFC.type( Fl_Native_File_Chooser::BROWSE_FILE );
    nFC.filter( " RAW Image\t*.raw\n" );
    nFC.directory( currentPath );
    nFC.preset_file(NULL);

    int retVal = nFC.show();
    if ( retVal == 0 )
    {
        if ( strlen(nFC.filename()) == 0 )
        {
            boxImageFileName->label(" ");
            fl_alert("No image selected.");
            return;
        }

        if ( dentalRAW == NULL )
        {
            dentalRAW = new DentalRAWReader();
        }

        if ( dentalRAW != NULL )
        {
            fl_cursor( FL_CURSOR_WAIT, 0, 0 );

#if( UNICODE && DEBUG )
            if ( sizeof(TCHAR) != 2 )
            {
                fl_alert("What's wrong? why it is not unicode ?");
                return;
            }
#endif

            _TSTRING refPath =  _TCM2W( nFC.filename() );

            if ( dentalRAW->Load( refPath.c_str() ) == true )
            {
                rawimagefilename = nFC.filename();

                boxImageFileName->label( rawimagefilename.c_str() );
                boxImageFileName->redraw();
            }
            else
            {
                fl_alert("Failed to load RAW image:\n%s", nFC.filename() );
            }

            if ( dentalRAW->GetAnalisysReport( weight_report ) == false )
            {
                memset( &weight_report, 0, sizeof (weight_report) );
            }

            if( vsThresholdMin != NULL )
            {
                vsThresholdMin->range( 0.0f, float( dentalRAW->getMaximumLevel() ) - 1.0f );
                vsThresholdMin->value( 0 );
            }

            if( vsThresholdMax != NULL )
            {
                vsThresholdMax->range( 1.0f, float( dentalRAW->getMaximumLevel() ) );
                vsThresholdMax->value( dentalRAW->getMaximumLevel() );
            }

            updateImageInfo();
            drawHistogram();
            importRAWimage();

            fl_cursor( FL_CURSOR_DEFAULT, 0, 0 );
        }
    }
}
Exemplo n.º 5
0
int main(int argc, char **argv)
{
  Fl::lock();
#ifndef WIN32
  Plus4Emu::setGUIColorScheme(0);
#else
  Plus4Emu::setGUIColorScheme(1);
#endif
  bool    forceInstallFlag = false;
  std::string installDirectory = "";
  {
    int     i = 0;
    while (++i < argc) {
      if (argv[i][0] == '-') {
        if (argv[i][1] == '-' && argv[i][2] == '\0')
          break;
        if (argv[i][1] == 'f' && argv[i][2] == '\0') {
          forceInstallFlag = true;
          continue;
        }
      }
      installDirectory = argv[i];
    }
    if (i < (argc - 1))
      installDirectory = argv[argc - 1];
  }
#ifndef WIN32
  if (installDirectory.length() == 0 && forceInstallFlag)
    installDirectory = Plus4Emu::getPlus4EmuHomeDirectory();
#endif
  if (installDirectory.length() == 0) {
    std::string tmp = "";
#ifndef WIN32
    tmp = Plus4Emu::getPlus4EmuHomeDirectory();
#endif
    Fl_Native_File_Chooser  *w = new Fl_Native_File_Chooser();
    w->type(Fl_Native_File_Chooser::BROWSE_SAVE_DIRECTORY);
    w->title("Select installation directory for plus4emu data files");
    w->filter("*");
    w->directory(tmp.c_str());
    if (w->show() == 0) {
      if (w->filename() != (char *) 0)
        installDirectory = w->filename();
    }
    delete w;
  }
  Plus4Emu::stripString(installDirectory);
  if (installDirectory.length() == 0)
    return -1;
#ifndef WIN32
  while (installDirectory[installDirectory.length() - 1] == '/' &&
         installDirectory.length() > 1) {
    installDirectory.resize(installDirectory.length() - 1);
  }
  {
    mkdir(installDirectory.c_str(), 0755);
    std::string tmp = installDirectory;
    if (tmp[tmp.length() - 1] != '/')
      tmp += '/';
    std::string tmp2 = tmp + "config";
    mkdir(tmp2.c_str(), 0755);
    tmp2 = tmp + "demo";
    mkdir(tmp2.c_str(), 0755);
    tmp2 = tmp + "disk";
    mkdir(tmp2.c_str(), 0755);
    tmp2 = tmp + "progs";
    mkdir(tmp2.c_str(), 0755);
    tmp2 = tmp + "roms";
    mkdir(tmp2.c_str(), 0755);
    tmp2 = tmp + "tape";
    mkdir(tmp2.c_str(), 0755);
  }
#else
  while ((installDirectory[installDirectory.length() - 1] == '/' ||
          installDirectory[installDirectory.length() - 1] == '\\') &&
         !(installDirectory.length() <= 1 ||
           (installDirectory.length() == 3 && installDirectory[1] == ':'))) {
    installDirectory.resize(installDirectory.length() - 1);
  }
  {
    _mkdir(installDirectory.c_str());
    std::string tmp = installDirectory;
    if (tmp[tmp.length() - 1] != '/' && tmp[tmp.length() - 1] != '\\')
      tmp += '\\';
    std::string tmp2 = tmp + "config";
    _mkdir(tmp2.c_str());
    tmp2 = tmp + "demo";
    _mkdir(tmp2.c_str());
    tmp2 = tmp + "disk";
    _mkdir(tmp2.c_str());
    tmp2 = tmp + "progs";
    _mkdir(tmp2.c_str());
    tmp2 = tmp + "roms";
    _mkdir(tmp2.c_str());
    tmp2 = tmp + "tape";
    _mkdir(tmp2.c_str());
  }
#endif
#ifdef WIN32
  uint8_t c = '\\';
#else
  uint8_t c = '/';
#endif
  if (installDirectory[installDirectory.length() - 1] != c)
    installDirectory += c;
  std::string configDirectory = installDirectory + "config";
  configDirectory += c;
  std::string romDirectory = installDirectory + "roms";
  romDirectory += c;
  Plus4EmuConfigInstallerGUI  *gui = new Plus4EmuConfigInstallerGUI();
  if (!forceInstallFlag) {
    gui->mainWindow->show();
    do {
      Fl::wait(0.05);
    } while (gui->mainWindow->shown());
  }
  else
    gui->enableCfgInstall = true;
  try {
    Plus4Emu::ConfigurationDB     *config = (Plus4Emu::ConfigurationDB *) 0;
    Plus4EmuMachineConfiguration  *mCfg = (Plus4EmuMachineConfiguration *) 0;
    if (gui->enableCfgInstall) {
      Plus4EmuDisplaySndConfiguration   *dsCfg =
          (Plus4EmuDisplaySndConfiguration *) 0;
      config = new Plus4Emu::ConfigurationDB();
      {
        Plus4EmuGUIConfiguration  *gCfg =
            new Plus4EmuGUIConfiguration(*config, installDirectory);
        try {
          Plus4Emu::File  f;
          config->saveState(f);
          f.writeFile("gui_cfg.dat", true);
        }
        catch (std::exception& e) {
          gui->errorMessage(e.what());
        }
        delete gCfg;
      }
      delete config;
      config = new Plus4Emu::ConfigurationDB();
      mCfg = new Plus4EmuMachineConfiguration(*config, 6, romDirectory);
      dsCfg = new Plus4EmuDisplaySndConfiguration(*config);
      setKeyboardConfiguration(*config, (gui->keyboardMapHU ? 5 : 4));
      try {
        Plus4Emu::File  f;
        config->saveState(f);
        f.writeFile("plus4cfg.dat", true);
      }
      catch (std::exception& e) {
        gui->errorMessage(e.what());
      }
      delete config;
      delete mCfg;
      delete dsCfg;
      config = (Plus4Emu::ConfigurationDB *) 0;
      mCfg = (Plus4EmuMachineConfiguration *) 0;
    }
    for (int i = 0; i < 16; i++) {
      config = new Plus4Emu::ConfigurationDB();
      mCfg = new Plus4EmuMachineConfiguration(*config, i, romDirectory);
      try {
        std::string fileName = configDirectory;
        fileName += machineConfigFileNames[i];
        config->saveState(fileName.c_str(), false);
      }
      catch (std::exception& e) {
        gui->errorMessage(e.what());
      }
      delete config;
      delete mCfg;
      config = (Plus4Emu::ConfigurationDB *) 0;
      mCfg = (Plus4EmuMachineConfiguration *) 0;
    }
    for (int i = 0; i < 8; i++) {
      if (keyboardConfigFileNames[i] != (char *) 0) {
        config = new Plus4Emu::ConfigurationDB();
        try {
          setKeyboardConfiguration(*config, i);
          std::string fileName = configDirectory;
          fileName += keyboardConfigFileNames[i];
          config->saveState(fileName.c_str(), false);
        }
        catch (std::exception& e) {
          gui->errorMessage(e.what());
        }
        delete config;
        config = (Plus4Emu::ConfigurationDB *) 0;
      }
    }
  }
  catch (std::exception& e) {
    gui->errorMessage(e.what());
    delete gui;
    return -1;
  }
  delete gui;
  return 0;
}
Exemplo n.º 6
0
void RightPanel::onCallback(FlLayout::Widget const& w, Fl_Widget * pWidget, int userData)
{
#ifdef USE_LUABIND
	try
	{
		if(L)
		{
			bool res=luabind::call_function<bool>(L->L, "onCallback", w, userData);
			if (res) return;
		}
	}
	CATCH_LUABIND_ERROR("onCallBack", *this)
#else
		if(L)
		{
			lunaStack l(L);
			l.getglobal("onCallback");
			l.push<FlLayout::Widget>(&w);
			l<<userData;
			l.call(2,1);
			bool res;
			l>>res;
			if(res) return;
		}
#endif
	if(w.mId=="update")
	{
		mPDFwin->pageChanged();
		mPDFwin->redraw();
	}
	else if(w.mId=="Use automatic segmentation")
	{
		if(w.checkButton()->value())
		{
			findLayout("Automatic segmentation")->activate();
			redraw();
		}
		else
		{
			findLayout("Automatic segmentation")->deactivate();
			redraw();
		}
	}
	else if(w.mId=="Option")
	{
		TString fn=FlChooseFile("Choose option", "script","*.lua");
		if(fn.length())
		{
			TString ff, dir;
			ff=sz1::filename(fn, dir);
			find<Fl_Input>("Option_Input")->value(processOption(ff.left(-4)));
			redraw();
		}

	}
	else if(w.mId=="Load a PDF file")
	{
#ifndef NO_SHOW_WIN
		Fl_Native_File_Chooser *chooser = new Fl_Native_File_Chooser();
		chooser->type(Fl_Native_File_Chooser::BROWSE_FILE);   // let user browse a single file
		chooser->title("Open a file");                        // optional title
		//chooser->preset_file("/var/tmp/somefile.txt");        // optional filename preset
		chooser->filter("PDF Files\t*.pdf");                 // optional filter
		TString fn;
		switch ( chooser->show() ) {
			case -1:    // ERROR
			fprintf(stderr, "*** ERROR show() failed:%s\n", chooser->errmsg());
			break;
			case 1:     // CANCEL
			fprintf(stderr, "*** CANCEL\n");
			break;
			default:    // USER PICKED A FILE
			fn=chooser->filename();
			break;
		}
		//TString fn=fl_file_chooser("Choose a PDF file", "*.pdf", NULL);
		if(fn.length())
		{
			mPDFwin->load(fn);

		}
#endif
	}
	else if(w.mId=="Batch process")
	{
#ifndef NO_SHOW_WIN
		Fl_Native_File_Chooser *chooser = new Fl_Native_File_Chooser();
		chooser->type(Fl_Native_File_Chooser::BROWSE_MULTI_FILE);   // let user browse a single file
		chooser->title("Open files");                        // optional title
		//chooser->preset_file("/var/tmp/somefile.txt");        // optional filename preset
		chooser->filter("PDF Files\t*.pdf");                 // optional filter
		TStrings fn;
		switch ( chooser->show() ) {
			case -1:    // ERROR
			fprintf(stderr, "*** ERROR show() failed:%s\n", chooser->errmsg());
			break;
			case 1:     // CANCEL
			fprintf(stderr, "*** CANCEL\n");
			break;
			default:    // USER PICKED A FILE
				{
					fn.resize(chooser->count());
					for (int n = 0; n < chooser->count(); n++ ) 
      				fn[n]=chooser->filename(n);
				}
			break;
		}
		//TString fn=fl_file_chooser("Choose a PDF file", "*.pdf", NULL);
		if(fn.size())
		{

			for(int i=0; i<fn.size(); i++)
			{
				mPDFwin->load(fn[i]);
				onCallback(findWidget("Process all pages"), w.widgetRaw(), 0);
			}
		}
#endif
	}
}