Esempio n. 1
0
//-----------------------------------------------------------------------------
void list_dat_cb(Fl_Widget*, void*v)
{
	TableWindow* e = (TableWindow*)v;
	HMDT d = dynamic_cast<HMDT>(e->var);
	if(!d)
	{	fl_message(mgl_gettext("Incorrect type of base data"));	return;	}
	if(d->nx*d->ny+d->ny>1020)
	{	fl_message(mgl_gettext("Too many numbers (>1000) on slice"));	return;	}
	if(d->nz>1)	fl_message(mgl_gettext("Only current slice will be inserted"));
	char *list = new char[16384];
	strcpy(list,"list\t");
	register long i,j;
	char s[32];
	for(j=0;j<d->ny;j++)
	{
		for(i=0;i<d->nx;i++)
		{
			snprintf(s,32,"%g\t",d->a[i+d->nx*(j+e->get_slice()*d->ny)]);
			strcat(list,s);
		}
		if(j<d->ny-1)	strcat(list,"|\t");
	}
	textbuf->insert(0,list);
	delete []list;
}
Esempio n. 2
0
int SC_File_Manager::copy(const char *src_filename, const char *dst_filename)
{
    FILE *in = fopen(src_filename, "rb");
    if (!in) {
        fl_message("Can't open file for reading\n%s\n%s", src_filename, strerror(errno));
        return -1;
    }
    FILE *out = fopen(dst_filename, "wb");
    if (!out) {
        fl_message("Can't open file for writing\n%s\n%s", dst_filename, strerror(errno));
        fclose(in);
        return -1;
    }

    errno = 0;
    char buf[1024];
    for (;;) {
        size_t n = fread(buf, 1, 1024, in);
        if (n<=0) break;
        fwrite(buf, 1, n, out);
    }
    if (errno!=0) {
        fl_message("Error copying file\n%s\nto\n%s\n%s", src_filename, dst_filename, strerror(errno));
        fclose(in);
        fclose(out);
        return -1;
    }

    fclose(in);
    fclose(out);

    return 0;
}
Esempio n. 3
0
void load_callback(Fl_Widget *w, void *data) {

  //xfprintf(stderr,"load callback called\n");
  policyFile = fl_file_chooser("choose policy value file",NULL,NULL,1);
  //  fprintf(stderr,"file chosen: %s\n",policyFile);
  if (!policyFile) {
    policyFile = NULL;
    return;
  }
  
  DdNode **UPList= (DdNode **)malloc(2*(sizeof(DdNode *)));

  //load from this file into dd: act[numpolicies] and val[numpolicies]
  //load a new file into the gui...
  int numread = readDualOptimal(dd,policyFile,&UPList);
  if (numread == 0) {
    fl_message("Whoops! - that file didn't correspond to the problem you are working on");
    return;
  } else if (numpolicies+1 >= MAXNUMPOLICIES) {
    fl_message("Whoops! - too many policies");
    return;
  } 
    
  act[numpolicies] = UPList[0];
  Cudd_Ref(act[numpolicies]);
  
  val[numpolicies] = UPList[1];
  Cudd_Ref(val[numpolicies]);
  free(UPList);
  
  // resize window
  window_width += 150;
  window->resize(window->x(),window->y(),window_width,window_height);
  menu_bar->resize(menu_bar->x(),menu_bar->y(),window_width,menubar_height-10);
  
  
  // add a new action_out[numpolicies] and value_out[numpolicies] and ask[numpolicies] field
  policyName[numpolicies] =new Fl_Text_Display(2*field_width+120+numpolicies*150,menubar_height,150,40);
  policyNameBuf[numpolicies] =new Fl_Text_Buffer(10);
  policyNameBuf[numpolicies]->append(policyFile);
  policyName[numpolicies]->buffer(policyNameBuf[numpolicies]);
  
  ask[numpolicies] = new Fl_Button(2*field_width+120+numpolicies*150,menubar_height+40,150,30,"query");
  askindex[numpolicies] = numpolicies;
  ask[numpolicies]->callback(ask_callback, askindex+numpolicies);
  window->add(ask[numpolicies]);
  // position of this? 
  action_out[numpolicies] = new Fl_Output(2*field_width+120+numpolicies*150,menubar_height+70,150,40);
  value_out[numpolicies] = new Fl_Output(2*field_width+120+numpolicies*150,menubar_height+110,150,40);

  window->add(action_out[numpolicies]);
  window->add(value_out[numpolicies]);
  window->add(policyName[numpolicies]);
  // increment numpolicies
  numpolicies++;


  window->redraw();
}
Esempio n. 4
0
void StructureManager::AddFile(const char* filename)
{
    if (!filename)
	return;

    char* localCopy = strdup(filename);
    if (!localCopy)
	return;

    // Strip any trailing directory markers. Maybe we could load all files in the directory in this case,
    // but it hardly seems worth the effort.
    while (strlen(localCopy) > 0 && localCopy[strlen(localCopy) - 1] == '/')
    	localCopy[strlen(localCopy) - 1] = 0;

    // Get the base file name
    const char* basename = strrchr(localCopy, '/');
    if (!basename)
	basename = localCopy;
    else
	basename++;

    // TODO: Check for duplicate file name.

    // Figure out what kind of file we have and try to load it.
    const char* extension = strrchr(basename, '.');
    RNAStructure* structure = 0;
    if (extension && !strncmp(extension, ".bpseq", 6))
    {
	structure = RNAStructure::CreateFromFile(localCopy, true);
    }
    else if (extension && !strncmp(extension, ".ct", 3))
    {
	structure = RNAStructure::CreateFromFile(localCopy, false);
    }
    else
    {
	if (strlen(filename) > 1000)
	    fl_message("Unknown file type: <file name too long>");
	else
	    fl_message("Unknown file type: %s", filename);
	return;
    }

    if (structure)
    {
	// TODO: Check for duplicates.

	int index = AddFirstEmpty(structure);
	MainWindow::AddStructure(structure->GetFilename(), index, false);
    }

    free(localCopy);
}
Esempio n. 5
0
void dlg_garmindl::cb_btn_download_ex(Fl_Widget *widget)
{
    m_btn_download->deactivate();
    m_btn_ok->deactivate();
    m_btn_cancel->deactivate();
    m_choice_device->deactivate();

    m_dlstatus = false;

    std::ostringstream os;
    int idx = m_choice_device->value();
    os << "gpsbabel -vs -t -i garmin -f usb:" << idx << " -x track,name=\"ACTIVE*\" -o gpx -F " << m_path;

    florb::shell sh;
    sh.run(os.str());

    std::string line;
    while (sh.readln(line))
    {
        std::vector<std::string> progress = florb::utils::str_split(line, "/");
        if (progress.size() != 3)
            continue;

        std::istringstream is(progress[0]);
        float v;
        is >> v;
        m_progress_status->value(v);

        progress[0] += " %";
        m_progress_status->label(progress[0].c_str());
        Fl::check();
    }

    m_progress_status->value(100);
    m_progress_status->label("100 %");

    m_btn_download->activate();
    m_btn_ok->activate();
    m_btn_cancel->activate();
    m_choice_device->activate();

    if (sh.wait())
    {
        fl_message("%s", _("Download OK"));
        m_dlstatus = true;
    }
    else
        fl_message("%s", _("Download Failed!"));
}
void ImpressionistUI::cb_setFilterKernalSize(Fl_Widget *o, void *v) {
    ImpressionistUI *pUI = (ImpressionistUI*)o->user_data();
    int width = atoi(pUI->m_filterWidthInput->value());
    int height = atoi(pUI->m_filterHeightInput->value());
    if (width <= 0 || height <= 0) {
        fl_message("Width or Height cannot be less than 0");
        return;
    } else {
        pUI->m_filterSizeDialog->hide();
        pUI->m_nFilterWidth = width;
        pUI->m_nFilterHeight = height;
        pUI->m_filterKernalDialog = new Fl_Window(60 + 30 * width + 10 * (width - 1), 60 + 30 * width + 10 * (width - 1) + 50, "Filter Kernal");
        pUI->m_filterKernalEntries.clear();
        for (int j = 0; j < height; j++) {
            for (int i = 0; i < width; i++) {
                Fl_Input *filterEntry = new Fl_Input(60 + 30 * i + 10 * i, 30 * j + 10 * j, 30, 30, "");
                filterEntry->value("1.0");
                pUI->m_filterKernalEntries.push_back(filterEntry);
            }
        }
        pUI->m_applyFilterKernalButton = new Fl_Button(0, 60 + 30 * width + 10 * (width - 1) + 20, 50, 20, "Apply");
        pUI->m_applyFilterKernalButton->user_data((void *)(pUI));
        pUI->m_applyFilterKernalButton->callback(cb_applyFilterKernal);
        pUI->m_filterKernalDialog->end();
        pUI->m_filterKernalDialog->show();
    }
}
Esempio n. 7
0
File: Main.cpp Progetto: aib/glito
void saveImage_cb( Fl_Widget* w, void* f ) {
    const Image::imageFormat format = (Image::imageFormat)(int)f;
    fl_message( _("Format: '%s'\nResolution: %d x %d\nUse the arrows on the keyboard to move the image.\nPress space bar to save the calculated image."),
		Image::formatToString(format).c_str(),
		glito->imageSavedWidth, glito->imageSavedHeight );
    glito->startSave(format);
}
Esempio n. 8
0
// usage : ray [option] in.ray out.bmp
// Simply keying in ray will invoke a graphics mode version.
// Use "ray --help" to see the detailed usage.
// OK. I am lying. any illegal option such as "ray blahbalh" will print
// out the usage
//
// Graphics mode will be substantially slower than text mode because of
// event handling overhead.
int main(int argc, char **argv) {
	progname=argv[0];
	srand((unsigned)time(NULL));

	if (argc!=1) {
		// text mode
		if (!processArgs(argc, argv)) {
			usage();
			exit(1);
		}
		
		theRayTracer=new RayTracer();
		theRayTracer->loadScene(rayName);
	
		if (theRayTracer->sceneLoaded()) {
			g_height = (int)(g_width / theRayTracer->aspectRatio() + 0.5);

			theRayTracer->traceSetup(g_width, g_height, 2, 1.0, 0.0001);
		
			clock_t start, end;
			start=clock();

			theRayTracer->traceLines(0, g_height);
		
			end=clock();

			// save image
			unsigned char* buf;

			theRayTracer->getBuffer(buf, g_width, g_height);
			if (buf)
				writeBMP(imgName, g_width, g_height, buf); 

			if (bReport) {
				double t=(double)(end-start)/CLOCKS_PER_SEC;
#ifdef WIN32
				fl_message( "total time = %.3f seconds\n", t); 
#else
				fprintf( stderr, "total time = %.3f seconds\n", t); 
#endif
			}
		}

		return 1;
	} else {
		// graphics mode
		traceUI=new TraceUI();
		theRayTracer=new RayTracer();

		traceUI->setRayTracer(theRayTracer);

		Fl::visual(FL_DOUBLE|FL_INDEX);

		traceUI->show();

		return Fl::run();
	}
}
Esempio n. 9
0
void JetpackUI::cb_about_editor(Fl_Menu_* o, void* v) 
{
	fl_message("Jetpack (Early alpha)\n\n"
				"Controls\n"
				"\tArrow Keys......Move Curser.\n"
				"\tEnter...........Show/Hide menu of placable items.\n"
				"\tSpace...........Place the selected Item, choose an item from the menu.\n"
				"\tShift...........Delete an item.\n"
				"\tJ...............Place the hero.\n"
				"\tD...............Place the door.\n\n\n"
				"Use the menu bar to save, load, or try out your new level or any saved level.\n"
				"This has always been the most fun part of the game for me, hope you enjoy!\n"
				"\t-Justin\n\n\n\n\n");
}
Esempio n. 10
0
void CFLTKEditor::ReplaceAll()
{
	char *pcFind = (char *) m_pReplaceFind->value();
	char *pcReplace = (char *) m_pReplaceWith->value();

	if (pcFind[0] == 0) 
	{
		// Search string is blank; get a new one...
		m_pReplaceDlg->show();
		return;
	}

	m_pReplaceDlg->hide();

	GetEditor()->insert_position(0);

	// Loop through the whole string
	int iFound;
	int iTimes = 0;

	do 
	{
		int iPos = GetEditor()->insert_position();
		iFound = GetTextBuffer()->search_forward(iPos, pcFind, &iPos);

		if (iFound) 
		{
			// Found a match; update the position and pcReplace text...
			GetTextBuffer()->select(iPos, iPos + (int) strlen(pcFind));
			GetTextBuffer()->remove_selection();
			GetTextBuffer()->insert(iPos, pcReplace);
			GetEditor()->insert_position(iPos + (int) strlen(pcReplace));
			GetEditor()->show_insert_position();
			iTimes++;
		}
	} while (iFound);

	if (iTimes) 
	{
		fl_message("Replaced %d occurrences.", iTimes);
	}
	else 
	{
		fl_alert("No occurrences of \'%s\' found!", pcFind);
	}
}
Esempio n. 11
0
void JetpackUI::cb_about_gameplay(Fl_Menu_* o, void* v) 
{
	fl_message("Jetpack  (Early alpha)\n\n"
				"Controls\n"
				"\tArrow Keys.....Move hero.\n"
				"\tSpace..........Jump.\n"
				"\tZ..............Use Jetpack.\n"
				"\tX..............Use Phaser.\n\n\n"
				"The goal of the game is to collect all the gems, avoid enemys, and make it to the door.\n"
				"You can accomplish this by using your handy jetpack (which runs on a rare fuel), and by using your\n"
				"trusty phaser, which can vaporize certain blocks temporarily. Note: The device, however, has not.\n"
				"Do not touch the operational end of the device. Do not look directly at the operational end of the\n"
				"device. Do not submerge the device in liquid, even partially. Most importantly, under no circumstances\n"
				"should you.. use it as a weapon.\n\n "
				"\tGood Luck and Enjoy!\n "
				"\t-Justin\n\n\n\n\n");
}
Esempio n. 12
0
File: Main.cpp Progetto: aib/glito
void saveAnimation_cb( Fl_Widget* w, void* f ) {
    const int anim = (int)f; 
    if ( anim == 0 ) { // zoom
	if ( Function::system == LINEAR ) {
	    if ( glito->skel.selected() == 0 ) {
		fl_alert( _("To zoom inside the general frame is not allowed!") );
		return;
	    }
	} else {
	    fl_alert( _("The zoom animation requires a \"linear\" system.") );
	    return;
	}
    }
    const Image::imageFormat format = Image::MNG;
    fl_message( _("Format: '%s'\nResolution: %d x %d\n\nPress space bar to cancel calculation."),
		Image::formatToString(format).c_str(),
		glito->animationSavedWidth, glito->animationSavedHeight );
    glito->startSave( format, anim );
}
void CAppManager::StartUninstall()
{
    if (m_AppVec.empty())
        return;

    if (!m_pUninstallWindow->Start(m_pCurrentAppEntry))
        return;
    
    m_pAppList->remove(m_pAppList->value());
    
    std::vector<app_entry_s *>::iterator it = std::find(m_AppVec.begin(), m_AppVec.end(), m_pCurrentAppEntry);
    if (it != m_AppVec.end())
        m_AppVec.erase(it);
    
    fl_message(GetTranslation("Uninstallation of %s complete!"), m_pCurrentAppEntry->name.c_str());

    delete m_pCurrentAppEntry;
    UpdateInfo(false);
}
Esempio n. 14
0
/*
=========================================================================
Checks for errors and updates icon.
=========================================================================
*/
void VTLpt::ShowErrors(void)
{
	int		c, count;

	if (m_pActivePrinter == NULL)
		return;

	count = m_pActivePrinter->GetErrorCount();

	if (count == 1)
	{
		fl_message("%s", (const char *) m_pActivePrinter->GetError(0));
	}
	else
	{
		Fl_Text_Buffer* tb = new Fl_Text_Buffer();
		for (c = 0; c < count; c++)
		{
			tb->append(m_pActivePrinter->GetError(c));
			tb->append("\n");
		}
		Fl_Window*	o = new Fl_Window(500, 300, "Printer Errors");
		Fl_Text_Display* td = new Fl_Text_Display(0, 0, 500, 300, "");
		td->buffer(tb);
		o->show();
	}

	// Clear the errors
	m_pActivePrinter->ClearErrors();

	// Set the icon back to normal
	gpPrint->set_image(&gPrinterIcon);
	gpPrint->label("Idle");
	m_PortStatus = LPT_STATUS_IDLE;
	gPrintMenu[3].flags = FL_MENU_INVISIBLE;
	gAnimationNeeded = FALSE;
	m_animIconIndex = 1;

	// Report port status change
	if (m_pMonCallback != NULL)
		m_pMonCallback(LPT_MON_PORT_STATUS_CHANGE, 0);
}
Esempio n. 15
0
		void MainWindow::StartGame() {
			SPADES_MARK_FUNCTION();
			
			hide();
			
			std::string host = hostEdit->value();
#if 0
			SDLRunner r(host);
			r.Run();
#else
			
			try{
				SDLRunner r(host, playerNameInput->value());
				r.Run();
			}catch(const std::exception& ex){
				puts("-------- UNHANDLED EXCEPTION --------");
				puts(ex.what());
				fl_message("Error occured:\n\n%s", ex.what());
			}
#endif
		}
Esempio n. 16
0
void GraphicalUI::cb_about(Fl_Menu_* o, void* v) 
{
	fl_message("RayTracer Project, FLTK version for CS384g Fall 2005.");
}
Esempio n. 17
0
/*
=========================================================================
Generates a Printer Properties dialog box based on the current emulation
mode with parameters appropriate for the "printer" needs.
=========================================================================
*/
void VTLpt::PrinterProperties(int useActivePrinter)
{
	int			count, c;
	int			found;
	VTPrinter*	pPrint = NULL;

	// Test if printer emulation is enabled
	if (useActivePrinter)
	{
		if (m_EmulationMode == LPT_MODE_NONE)
		{
			fl_message("Printer emulation not enabled");
			return;
		}
		if (m_pActivePrinter == NULL)
		{
			fl_message("Printer not selected");
			return;
		}
	}
	else
	{
		if (!gLptCtrl.pEmul->value())
		{
			fl_message("Printer emulation not enabled");
			return;
		}
		if (gLptCtrl.pEmulPrint->value() == -1)
		{
			fl_message("Printer not selected");
			return;
		}
	}

	// Create a dialog box first
	m_pProp = new Fl_Window(400, 350, "Printer Properties");
	
	// Create property page from selected printer
	count = GetPrinterCount();
	for (c = 0; c < count; c++)
	{
		// Get pointer to next printer
		pPrint = GetPrinter(c);

		found = 0;
		if (useActivePrinter)
		{
			if (pPrint == m_pActivePrinter)
				found = 1;
		}
		else
		{
			if (strcmp(gLptCtrl.pEmulPrint->text(), (const char *) 
				pPrint->GetName()) == 0)
					found = 1;
		}
		if (found)
		{
			if (pPrint != m_pActivePrinter)
				pPrint->Init(m_pPref);
			pPrint->BuildPropertyDialog(m_pProp);
			if (pPrint != m_pActivePrinter)
				pPrint->Deinit();
			break;
		}
	}

	// Create Ok and Cancel button
	m_pCancel = new Fl_Button(m_pProp->w() - 165, m_pProp->h()-40, 60, 30, "Cancel");
	m_pCancel->callback(cb_PrintProp_Cancel);

	m_pOk = new Fl_Return_Button(m_pProp->w()-90, m_pProp->h()-40, 60, 30, "Ok");
	m_pOk->callback(cb_PrintProp_Ok, pPrint);

	// Show the dialog box
	m_pProp->end();
	m_pProp->show();
	m_pProp->redraw();
}
Esempio n. 18
0
void
process_find_messages(int, void*)
{
    static char *buffer, line[256];
    static int nothing_found;
    char *filename;

    buffer = line;

    while (1)
    {
        if (!read (pfd[0], buffer, 1))
            return;
        if (buffer[0] == '\n')
        {
            buffer[1] = (char) 0;
            if (strncmp(line, "GLOB DONE=", strlen ("GLOB DONE=")) == 0)
            {
                fl_message(_("Search finished."));
                Gpid = 0;
                if (nothing_found)
                    fl_message(_("Nothing found."));
                if (findCount)
                {
                    char mess[128];
                    snprintf(mess, 127, _("Found %d files."), findCount);
                    if (findCount >= fileLimit)
                        fl_message(_("Interrupted because maximum limit exceded."));
                    fl_alert(mess);
                }
                return;
            }

            if ((strncmp (line, "PID=", 4) == 0))
            {
                Gpid = atoi (line + 4);
                //printf("Glob PID=%d\n",Gpid);
                //	      fflush(NULL);
                nothing_found = TRUE;
                return;
            }
            if (cancelled)
                return;

            if (line[0] == '/')  /* strstr for : and strtok and send to cuenta */
            {
                if (findCount >= fileLimit)
                    abort_glob1();
                else
                {
                    char *path, *linecount = NULL, *textos[6], cuenta[32],
                        sizeF[64], permF[16];
                    struct stat st;
                    int *data;

                    path = line;
                    char *ptr = path;
                    while(*ptr) { if(*ptr=='\n') *ptr='\0'; ptr++; }
                    statusLine->copy_label(fl_trim(path));
                    statusLine->redraw();

                    if (strstr(path, ":"))
                    {
                        path = strtok(path, ":");
                        linecount = strtok (NULL, ":");
                        if (strcmp(linecount, "0") == 0)
                        {
                            linecount = NULL;
                            return;
                        }
                    }

                    findCount++;
                    data=(int *)malloc(3*sizeof(int));
                    data[0]=findCount;
                    data[1]=data[2]=0;

                    if (linecount)
                        snprintf(cuenta, sizeof(cuenta)-1, "%d (%s %s)", findCount, linecount, "lines");
                    else
                        snprintf (cuenta, sizeof(cuenta)-1, "%d", findCount);

                    textos[0] = cuenta;
                    textos[1] = filename = (char*)fl_file_filename(path);
                    textos[2] = path;

                    Fl_Image *resultImage=0;

                    if (lstat (path, &st) == 0)
                    {
                        data[1]=st.st_size;
                        data[2]=st.st_ctime;

                        snprintf (sizeF, sizeof(sizeF)-1,"%ld", st.st_size);
                        snprintf (permF, sizeof(permF)-1,"0%o", st.st_mode & 07777);
                        textos[3] = sizeF;
                        textos[4] = ctime (&(st.st_ctime));
                        textos[5] = permF;

                        if (S_ISREG (st.st_mode))
                        {
                            resultImage = &page_pix;
                        }
                        if ((st.st_mode & 0100) || (st.st_mode & 010)
                            || (st.st_mode & 01))
                        {
                            resultImage = &exe_pix;
                        }
                        if (st.st_mode & 04000)
                        {
                            resultImage = &sexe_pix;
                        }
                        if (S_ISDIR (st.st_mode))
                        {
                            resultImage = &dir_close_pix;
                        }
                        if (S_ISCHR (st.st_mode))
                        {
                            resultImage = &char_dev_pix;
                        }
                        if (S_ISBLK (st.st_mode))
                        {
                            resultImage = &block_dev_pix;
                        }
                        if (S_ISFIFO (st.st_mode))
                        {
                            resultImage = &fifo_pix;
                        }
                        if (S_ISLNK (st.st_mode))
                        {
                            resultImage = &page_lnk_pix;
                        }
                        if (S_ISSOCK (st.st_mode))
                        {
                            resultImage = &socket_pix;
                        }
                    }
                    else
                    {
                        textos[2] = textos[3] = textos[4] = "-";
                    }
                    {
                                 // leave just directory
                        *(strrchr(path,'/'))=0;
                        if (!strlen(path))
                            textos[2]="/";
                        char output[FL_PATH_MAX];
                        snprintf(output, sizeof(output)-1, "%s/%s", textos[2], textos[1]);
                        searchList->begin();
                        Fl_ListView_Item *resultItem = new Fl_ListView_Item();

                        // Copy labels, so item destructor knows to de-allocate them
                        resultItem->copy_label(0, output);
                        resultItem->copy_label(1, textos[3]);
                        resultItem->copy_label(2, textos[4]);
                        resultItem->copy_label(3, textos[5]);

                        resultItem->image(resultImage);
                        searchList->end();
                        searchList->relayout();
                        searchList->redraw();
                    }
                }
            }
            //else {}
            nothing_found = FALSE;
            buffer = line;
            return;  ;           /* continue here causes main loop blocking */
        }
        buffer++;
    }
    return;
}
Esempio n. 19
0
void GraphicalUI::cb_about(Fl_Menu_* o, void* v) 
{
	fl_message("RayTracer Project, FLTK version for CSEP557 Winter 2013.");
}
Esempio n. 20
0
//-----------------------------------------------------------
// Brings up an about dialog box
// Called by the UI when the about menu item is chosen
//-----------------------------------------------------------
void ImpressionistUI::cb_about(Fl_Menu_* o, void* v) 
{
	fl_message("Impressionist FLTK version 1.1.4 for CS 384G, Fall 2005");
}
Esempio n. 21
0
//-----------------------------------------------------------
// Brings up an about dialog box
// Called by the UI when the about menu item is chosen
//-----------------------------------------------------------
void ImpressionistUI::cb_about(Fl_Menu_* o, void* v) 
{
	fl_message("Impressionist FLTK version for CS341, Spring 2002");
}
Esempio n. 22
0
void hint_callback(Fl_Widget* w)
{
    fl_message(Hint_text);
}
Esempio n. 23
0
File: Main.cpp Progetto: aib/glito
void about_cb( Fl_Widget* w, void* ) {
    fl_message( "Glito v%s Copyright (C) 2002-2003 Emmanuel Debanne\n%s", VERSION,
		_("Glito comes with absolutely no warranty.\nGlito is free software.\nFor details, click on Help -> Documentation.") );
}
Esempio n. 24
0
/*
============================================================================
Loads the log data from a file.
============================================================================
*/
int VTTpddServerLog::LoadFile(MString filename)
{
	FILE*			fd;
	int				c, lineNo, rxTx;
	//VTTpddLogEntry*	pEntry;
	//MString			fmt, hexFmt;
	char			line[256];
	char			*ptr;

	// Test if we are loading from the root window
	if (this == gpLog)
	{
		// Don't load files from the root window.  Create a new window
		VTTpddServerLog* pLog = new VTTpddServerLog(w(), h(), "TPDD Log Viewer");
		
		// Validate the window was created
		if (pLog == NULL)
			return FALSE;

		// Let the new window open the log
		if (!pLog->LoadFile(filename))
		{
			// Load was not successful.  Destroy the window
			delete pLog;
			return FALSE;
		}

		// Now show the new window
		pLog->show();
		pLog->resize(x()+MENU_HEIGHT, y()+MENU_HEIGHT, w(), h());
		return TRUE;
	}

	// Try to open the file
	if ((fd = fopen(filename, "r")) == NULL)
	{
		fl_message("Unable to open file %s", fl_filename_name((const char *) filename)); return FALSE;
	}

	// Loop for all data in the file
	lineNo = 0;
	while (fgets(line, sizeof(line), fd) != NULL)
	{
		// Start at beginning of line
		ptr = line;
		c = 0;
		lineNo++;
		
		// Search for a reference.  This means we log the existing entry and start a new one
		while (*ptr == ' ')
		{
			// Increment ptr and c
			ptr++;
			c++;
		}

		// Test if a reference found
		if (c < 4)
		{
			// Validate the file format
			if (*ptr < '0' || *ptr > '9')
			{
				// Not a trace file!!
				fl_message("This does not appear to be a valid file on line %d", lineNo);
				return FALSE;
			}

			// Reference found.  This entry and start a new one
			if (m_rxCount > 0)
				AddNewEntry(TPDD_LOG_RX, m_rxCount, m_rxBuffer);
			if (m_txCount > 0)
				AddNewEntry(TPDD_LOG_TX, m_txCount, m_txBuffer);
			m_txCount = 0;
			m_rxCount = 0;

			// Skip past the reference and find the ':'
			while (*ptr != ':' && c < sizeof(line))
			{
				// Increment pointer and index
				ptr++;
				c++;
			}

			// Test if ':' found
			if (c >= sizeof(line) || *ptr != ':')
			{
				// Not a trace file!!
				fl_message("This does not appear to be a valid file on line %d", lineNo);
				return FALSE;
			}

			// Skip the ':' and spaces after it
			ptr += 2;
			c += 2;

			// Now get RX/TX marker
			if (*ptr == 'T')
				rxTx = 1;
			else if (*ptr == 'R')
				rxTx = 0;
			else
			{
				// Not a trace file!!
				fl_message("This does not appear to be a valid file on line %d", lineNo);
				return FALSE;
			}

			// Skip past "RX: " or "TX: "
			ptr += 4;
			c += 4;
		}

		// Now we are pointing at the HEX data.  Read all data from this line into
		// either the m_rxBuffer or m_txBuffer
		while (*ptr != ' ' && *ptr != '\0' && c < sizeof(line))
		{
			unsigned char val;

			val = (*ptr > '9' ? *ptr = 'A' + 10 : *ptr - '0') << 4;
			ptr++;
			val += *ptr > '9' ? *ptr = 'A' + 10 : *ptr - '0';
			ptr += 2;
			c += 3;

			// Now save val in either rx or tx buffer
			if (rxTx)
			{
				m_txBuffer[m_txCount++] = val;
				if (m_txCount >= sizeof(m_txBuffer))
				{
					AddNewEntry(TPDD_LOG_TX, m_txCount, m_txBuffer);
					m_txCount = 0;
				}
			}
			else
			{
				m_rxBuffer[m_rxCount++] = val;
				if (m_rxCount >= sizeof(m_rxBuffer))
				{
					AddNewEntry(TPDD_LOG_RX, m_rxCount, m_rxBuffer);
					m_rxCount = 0;
				}
			}
		}
	}

	// Log any remaining data
	if (m_rxCount > 0)
		AddNewEntry(TPDD_LOG_RX, m_rxCount, m_rxBuffer);
	if (m_txCount > 0)
		AddNewEntry(TPDD_LOG_TX, m_txCount, m_txBuffer);
	m_txCount = 0;
	m_rxCount = 0;

	// Close the file
	fclose(fd);
	return TRUE;
}
Esempio n. 25
0
void about_callback(Fl_Widget* w)
{
    fl_message(About_text, Version_str);
}
Esempio n. 26
0
/*
============================================================================
Saves the log data to a file using the current window width
============================================================================
*/
void VTTpddServerLog::SaveFile(MString filename)
{
	FILE*			fd;
	int				count, c, i, dataIdx;
	VTTpddLogEntry*	pEntry;
	MString			fmt, hexFmt;

	// Validate we have data
	if (m_log.GetSize() == 0)
		return;

	// Test if the file exists
	if ((fd = fopen((const char *) filename, "r")) != NULL)
	{
		// Close the file
		fclose(fd);
		int ans = fl_choice("Overwrite existing file %s?", "Ok", "Cancel", NULL, 
				fl_filename_name((const char *) filename));	
		if (ans == 1)
			return;
	}

	// Try to open the file
	if ((fd = fopen((const char *) filename, "w")) == NULL)
	{
		MString err;

		err.Format("Unable to create file %s\n", (const char *) filename);
		fl_message("%s", (const char *) err);
		return;
	}

	// Test if any leftover RX or TX data not logged to an entry yet
	if (m_rxCount > 0)
		AddNewEntry(TPDD_LOG_RX, m_rxCount, m_rxBuffer);
	if (m_txCount > 0)
		AddNewEntry(TPDD_LOG_TX, m_txCount, m_txBuffer);
	m_txCount = 0;
	m_rxCount = 0;
	
	// Now loop for all entries
	count = m_log.GetSize();
	for (c = 0; c < count; c++)
	{
		// Get the next entry
		pEntry = (VTTpddLogEntry *) m_log[c];
		fmt.Format("%4d: %s: ", pEntry->m_ref, pEntry->m_rxTx ? "TX" : "RX");
		i = 0;
		dataIdx = 0;
		while (dataIdx < pEntry->m_count)
		{
			if (dataIdx != 0)
				fmt = "          ";
			// "Print" the HEX data to the line
			for (i = 0; i < m_bytesPerLine && dataIdx + i < pEntry->m_count; i++)
			{
				hexFmt.Format("%02X ", (unsigned char) pEntry->m_pData[dataIdx + i]);
				fmt += hexFmt;
			}

			// Pad with spaces if less then m_bytesPerLine
			for ( ; i < m_bytesPerLine; i++)
				fmt += (char *) "   ";

			// "Print" the ASCII data to the line
			fmt += (char *) "  ";
			for (i = 0; i < m_bytesPerLine && dataIdx + i < pEntry->m_count; i++)
			{
				// Test if it's actual ASCII data or not
				if (pEntry->m_pData[dataIdx + i] >= ' ' && pEntry->m_pData[dataIdx + i] <= '~')
					hexFmt.Format("%c", (unsigned char) pEntry->m_pData[dataIdx + i]);
				else
					hexFmt = '.';
				fmt += hexFmt;
			}

			// Save to the file
			fprintf(fd, "%s\n", (const char *) fmt);
			dataIdx += i;
		}
	}

	// Close the file
	fclose(fd);
}
Esempio n. 27
0
//-----------------------------------------------------------
// Brings up an about dialog box
// Called by the UI when the about menu item is chosen
//-----------------------------------------------------------
  void ImpressionistUI::cb_about(Fl_Menu_* o, void* v) 
  {
    fl_message("Impressionist FLTK version for CSE 457");
  }
//-----------------------------------------------------------
// Brings up an about dialog box
// Called by the UI when the about menu item is chosen
//-----------------------------------------------------------
void ImpressionistUI::cb_about(Fl_Menu_* o, void* v)
{
    fl_message("Impressionist FLTK version for COMP4411, Fall 2015");
}
Esempio n. 29
0
void StructureManager::AddFile(const char* filename)
{
    if (!filename)
	    return;

    char* localCopy = strdup(filename);
    if (!localCopy) {
        return;
    }

    // Get the base file name
    const char* basename = strrchr(localCopy, '/');
    if (!basename)
		basename = localCopy;
    else
		basename++;
    
    // Don't load if it shares a filename with another loaded structure
    for (int i = 0; i < m_structureCount; ++i)
    {
        if (m_structures[i])
        {
            if (!strcmp(m_structures[i]->GetFilename(), basename))
            {
            	fl_message("Already have a structure loaded with filename: %s", 
			   basename);
            	free(localCopy);
		return;
            }
        }
    }
    
    // Figure out what kind of file we have and try to load it.
    const char* extension = strrchr(basename, '.');
    extension = extension ? extension : "";
    RNAStructure* structure = NULL;
    if (extension && !strncasecmp(extension, ".bpseq", 6)) {
        structure = RNAStructure::CreateFromFile(localCopy, true);
    }
    else if (extension && !strncasecmp(extension, ".ct", 3)) {
	structure = RNAStructure::CreateFromFile(localCopy, false);
    }
    else if (extension && !strncasecmp(extension, ".nopct", 6)) {
	structure = RNAStructure::CreateFromFile(localCopy, false);
    }
    else if(extension && (!strncasecmp(extension, ".dot", 4) || 
			  !strncasecmp(extension, ".bracket", 8) || 
			  !strncasecmp(extension, ".dbn", 4))) {
	structure = RNAStructure::CreateFromDotBracketFile(localCopy);
    }
    else {
		if (strlen(filename) > 1000)
		    fl_message("Unknown file type: <file name too long>");
		else
		    fl_message("Unknown file type: %s . %s [%s]", filename, extension, basename);
		return;
    }

    if (structure)
    {
    	int count = (int)folders.size();
	AddFirstEmpty(structure);
        if(count == (int) folders.size()-1)
        {
            InputWindow* input_window = new InputWindow(400, 150, 
			 "New Folder Added", folders[count]->folderName, 
			 InputWindow::FOLDER_INPUT);
            while (input_window->visible() && !GUI_USE_DEFAULT_FOLDER_NAMES)
            {
                Fl::wait();
            }
            
            bool same = false;
            for(unsigned int ui = 0; ui < folders.size(); ui++)
            {
            	if (!strcmp(folders[ui]->folderName,input_window->getName())
                    && strcmp(input_window->getName(),""))
            	{
            		same = true;
            		break;
            	}
            }
            
            while (same) {
                fl_message("Already have a folder with the name: %s, please choose another name.", 
                           input_window->getName());
                delete input_window;
                input_window = new InputWindow(400, 150, "New Folder Added", 
	            	               folders[count]->folderName, InputWindow::FOLDER_INPUT);
                while (input_window->visible() && !GUI_USE_DEFAULT_FOLDER_NAMES)
                {
                    Fl::wait();
                }
                same = false;
                for(unsigned int ui = 0; ui < folders.size(); ui++)
            	{
            		if (!strcmp(folders[ui]->folderName, input_window->getName()))
	            	{
    	        		same = true;
        	    		break;
            		}
	            }
            }
                        
            if(strcmp(input_window->getName(), ""))
            	strcpy(folders[count]->folderName, input_window->getName());

            MainWindow::AddFolder(folders[count]->folderName, count, false);
	    delete input_window;
        }

    }
    else {
         fl_alert("Error adding structure \"%s\"! Could not parse the specified format for this file.\n", 
	          localCopy);
    }
    Free(localCopy); 

}
Esempio n. 30
0
void StructureManager::AddFile(const char* filename)
{
    if (!filename)
	return;

    char* localCopy = strdup(filename);
    if (!localCopy)
    {
		return;
    }

    // Strip any trailing directory markers. Maybe we could load all files in the directory in this case,
    // but it hardly seems worth the effort.
    while (strlen(localCopy) > 0 && localCopy[strlen(localCopy) - 1] == '/')
    	localCopy[strlen(localCopy) - 1] = 0;

    // Get the base file name
    const char* basename = strrchr(localCopy, '/');
    if (!basename)
		basename = localCopy;
    else
		basename++;
    
    // Don't load if it shares a filename with another loaded structure
    // TODO: Check whether to allow multiple structures with the same filename
    for (int i = 0; i < m_structureCount; ++i)
    {
        if (m_structures[i])
        {
            if (!strcmp(m_structures[i]->GetFilename(), basename))
            {
            	fl_message("Already have a structure loaded with the filename: %s", basename);
            	return;
            }
        }
    }
    
    // Figure out what kind of file we have and try to load it.
    const char* extension = strrchr(basename, '.');
    RNAStructure* structure = 0;
    if (extension && !strncmp(extension, ".bpseq", 6))
    {
		structure = RNAStructure::CreateFromFile(localCopy, true);
    }
    else if (extension && !strncmp(extension, ".ct", 3))
    {
		structure = RNAStructure::CreateFromFile(localCopy, false);
    }
    else if (extension && !strncmp(extension, ".nopct", 6))
    {
		structure = RNAStructure::CreateFromFile(localCopy, false);
    }
    else
    {
		if (strlen(filename) > 1000)
		    fl_message("Unknown file type: <file name too long>");
		else
		    fl_message("Unknown file type: %s", filename);
		return;
    }

    if (structure)
    {
	// TODO: Check for duplicates.

    	int count = (int)folders.size();
		AddFirstEmpty(structure);
        if(count == (int) folders.size()-1)
        {
            InputWindow* input_window = new InputWindow(400, 150, "New Folder Added", 
            	folders[count]->folderName, InputWindow::FOLDER_INPUT);
            while (input_window->visible())
            {
                Fl::wait();
            }
            
            bool same = false;
            
            for(unsigned int ui = 0; ui < folders.size(); ui++)
            {
            	if (!strcmp(folders[ui]->folderName,input_window->getName())
                    && strcmp(input_window->getName(),""))
            	{
            		same = true;
            		break;
            	}
            }
            
            while (same) {
                fl_message("Already have a folder with the name: %s, please choose another name.", input_window->getName());
                delete input_window;
                input_window = new InputWindow(400, 150, "New Folder Added", 
	            	folders[count]->folderName, InputWindow::FOLDER_INPUT);
                while (input_window->visible())
                {
                    Fl::wait();
                }
                same = false;
                for(unsigned int ui = 0; ui < folders.size(); ui++)
            	{
            		if (!strcmp(folders[ui]->folderName,input_window->getName()))
	            	{
    	        		same = true;
        	    		break;
            		}
	            }
            }
                        
            if(strcmp(input_window->getName(), ""))
            	strcpy(folders[count]->folderName,input_window->getName());

            MainWindow::AddFolder(folders[count]->folderName, count, false);
            delete input_window;
        }
	//MainWindow::AddStructure(structure->GetFilename(), index, false);
    }

    free(localCopy); localCopy = NULL;
}