示例#1
0
//-----------------------------------------------------------------------------
void divto_cb(Fl_Widget*, void*v)
{
	TableWindow* e = (TableWindow*)v;
	const char *s = fl_input(mgl_gettext("Enter number for division of data values"),0);
	HMDT d = dynamic_cast<HMDT>(e->var);
	if(d && s)	{	mgl_data_div_num(d, atof(s));	e->refresh();	}
}
示例#2
0
double Msg::GetValue(const char *text, double defaultval)
{
  // if a callback is given let's assume we don't want to be bothered
  // with interactive stuff
  if(CTX::instance()->noPopup || _callback) return defaultval;

#if defined(HAVE_FLTK)
  if(FlGui::available()){
    char defaultstr[256];
    sprintf(defaultstr, "%.16g", defaultval);
    const char *ret = fl_input(text, defaultstr, "");
    if(!ret)
      return defaultval;
    else
      return atof(ret);
  }
#endif

  printf("%s (default=%.16g): ", text, defaultval);
  char str[256];
  char *ret = fgets(str, sizeof(str), stdin);
  if(!ret || !strlen(str) || !strcmp(str, "\n"))
    return defaultval;
  else
    return atof(str);
}
示例#3
0
//-----------------------------------------------------------------------------
void modify_cb(Fl_Widget*, void*v)
{
	TableWindow* e = (TableWindow*)v;
	const char *eq=fl_input(mgl_gettext("Enter formula for data modification\nHere x, y, z in range [0,1], u is data value"),0);
	HMDT d = dynamic_cast<HMDT>(e->var);
	if(d && eq != NULL)	{	d->Modify(eq);	e->refresh();	}
}
void CFLTKDirDialog::MKDirCB(Fl_Widget *w, void *p)
{
    CFLTKDirDialog *dialog = static_cast<CFLTKDirDialog *>(p);
    const char *newdir = fl_input(GetTranslation("Enter name of new directory"));
        
    if (!newdir || !newdir[0])
        return;
        
    newdir = CreateText("%s/%s", dialog->m_pDirChooser->directory(), newdir);
    
    try
    {
        if (MKDirNeedsRoot(newdir))
        {
            LIBSU::CLibSU suhandler;
            const char *passwd = dialog->AskPassword(suhandler);
            MKDirRecRoot(newdir, suhandler, passwd);
        }
        else
            MKDirRec(newdir);
            
        dialog->m_pDirChooser->directory(newdir);
    }
    catch(Exceptions::CExIO &e)
    {
        fl_alert(e.what());
    }
}
示例#5
0
/*
 * React to user input.
 * This consists of the events:
 * - Rename Slot (right click)
 * - Read From Slot
 * - Write To Slot
 * - Swap Slot First Selection
 * - Swap Slot Second Selction
 *
 *   TODO restore autoclose functionality
 */
void BankView::react(int event, int nslot)
{
    BankSlot &slot = *slots[nslot];
    const bool isempty = slot.empty();
    const int  mode    = bvc->mode();

    //Rename slot
    if (event==2 && !isempty && mode!=4) {
        if(const char *name=fl_input("Slot (instrument) name:", slot.name())) {
            osc->write("/bank-rename", "is", nslot, name);
            osc->write("/refresh_bank", "i", nslot);
        }
    }

    //Reads from slot
    if ((event==1)&&(mode==1)&&(!slot.empty())){
        printf("Loading a part #%d with file '%s'\n", nslot, slot.filename());
        osc->write("/load-part", "is", *npart, slot.filename());
        osc->writeValue("/part"+to_s(*npart)+"/name", slot.name());
        if(cbwig_)
            cbwig_->do_callback();
    }

    //save(write) to slot
    if(event==1 && mode==2){
        if(!isempty && !fl_choice("Overwrite the slot no. %d ?","No","Yes",NULL,nslot+1))
            return;

        osc->write("/save-bank-part", "ii", *npart, nslot);
        osc->write("/refresh_bank", "i", nslot);
        //pthread_mutex_lock(&master->part[*npart]->load_mutex);
        //bank->savetoslot(slot,master->part[*npart]);
        //pthread_mutex_unlock(&master->part[*npart]->load_mutex);

        bvc->mode(1);
    }


    //Clears the slot
    if(event==1 && mode==3 && !isempty) {
        if (fl_choice("Clear the slot no. %d ?","No","Yes",NULL, nslot+1)) {
            osc->write("/clear-bank-slot", "i", nslot);
            osc->write("/refresh_bank", "i", nslot);
        }
    }

    //Swap
    if(mode==4) {
        if(event==1 && nselected>=0){
            osc->write("/swap-bank-slots", "ii", nselected, nslot);
            osc->write("/refresh_bank", "i", nslot);
            osc->write("/refresh_bank", "i", nselected);
            //bank->swapslot(nselected,slot);
            nselected=-1;
        } else if(nselected<0 || event==2) {
            nselected=nslot;
        };
    };
}
示例#6
0
inline void svmUI::cb_invertScene_i(Fl_Menu_*, void*) {
    const char *zScale_str = fl_input("Please enter the Z scale factor");

    if (zScale_str) {
        double zScale = atof(zScale_str);
        imgView->invertScene(zScale);
    }
}
示例#7
0
void UserInterface::menuJoinChannel(Fl_Widget *w, void* d)
{
    UserInterface * ui = static_cast<UserInterface*>(d);
    char const * str = fl_input("Join channel");
    if (str)
    {
        ui->model_.joinChannel(str);
    }
}
示例#8
0
//-----------------------------------------------------------------------------
void exp_dat_cb(Fl_Widget*, void*v)
{
	TableWindow* e = (TableWindow*)v;
	const char *scheme, *newfile = fl_file_chooser(mgl_gettext("Export Data?"),
		mgl_gettext("PNG Files (*.png)\tAll Files (*)"), 0);
	if(newfile != NULL)
	{
		scheme = fl_input(mgl_gettext("Enter color scheme"),MGL_DEF_SCH);
		if(scheme)	e->var->Export(newfile,scheme);
	}
}
示例#9
0
void saveSchemeAs()
{
    const char *schemeName = fl_input(_("Save scheme as:"), _("New scheme"));
    if (schemeName) 
    {
	Fl_String pathScheme; 
	pathScheme.printf("%s/.ede/schemes/%s.scheme", fl_homedir().c_str(), schemeName);
	saveScheme(pathScheme);
	schemeListBox->add(fl_file_filename(pathScheme));
    }	
}
示例#10
0
//-----------------------------------------------------------------------------
void imp_dat_cb(Fl_Widget*, void*v)
{
	TableWindow* e = (TableWindow*)v;
	const char *scheme, *newfile = fl_file_chooser(mgl_gettext("Import Data?"),
		mgl_gettext("PNG Files (*.png)\tAll Files (*)"), 0);
	HMDT d = dynamic_cast<HMDT>(e->var);
	if(d && newfile != NULL)
	{
		scheme = fl_input(mgl_gettext("Enter color scheme"),MGL_DEF_SCH);
		if(scheme)
		{	d->Import(newfile,scheme);	e->refresh();	}
	}
}
示例#11
0
void CFLTKEditor::Find()
{
	char *pcVal;

	pcVal = (char *) fl_input("Search String:", GetSearchString());

	if (pcVal != NULL) 
	{
		// User entered a string - go find it!
		strcpy(GetSearchString(), pcVal);
		Find2();
	}
}
示例#12
0
void OnRenameCommunity(Fl_Widget* pWidget,void * pParam)
{
    Fl_Tabs* pTab = (Fl_Tabs*)(pParam);
    const char * scName=fl_input("Enter a new name", "");
    if(scName==NULL)
        return ;
    
    char * sName = new char[strlen(scName)*2];
    strcpy(sName,scName);
    Fl_Widget* pW = (Fl_Widget*)pTab->value();
    
    pW->label(scName);
}
示例#13
0
void rename_cb(Fl_Widget*, void* ic)
{
	Icon* icon = (Icon*)ic;
	assert(icon != NULL);
	const char* val = fl_input(_("Rename icon:"), icon->label().c_str());

	if(val)
	{
		if(strlen(val) == 0)
			fl_alert(_("Please do not use empty values as icon names"));
		else
			icon->update_label(val);
	}
}
示例#14
0
static void mol_rename_cb(Fl_Widget *w, void *v) {
  VMDApp *app = (VMDApp *)w->user_data();
  MolBrowser *browser = (MolBrowser *)v;
  int molid=-1;
  for (int i=0; i<browser->size(); i++)
    if (browser->selected(i+1)) {
      molid = app->molecule_id(i);
      break;
    }
  if (molid < 0) return;
  
  // this code snippet is replicated in MolBrowser.C:
  const char *oldname = app->molecule_name(molid);
  const char *newname = fl_input("Enter a new name for molecule %d:", 
      oldname, molid);
  if (newname) app->molecule_rename(molid, newname);
}
示例#15
0
//callback for add Community
void OnAddCommunity(Fl_Widget* pWidget,void * pParam)
{
    const char * scName=fl_input("New Community Name", "");
    if(scName==NULL)
        return ;
    
    char * sName = new char[strlen(scName)*2];
    strcpy(sName,scName);
    
    Fl_Tabs* pTab = (Fl_Tabs*)(pParam);
    Fl_Group* pG = (Fl_Group*)pTab->value();
    
    pTab->begin();
    MakeCommunityPane(10,30,pG->w()-20,pG->h()-10,sName);
    pTab->end();
    
}
示例#16
0
文件: Main.cpp 项目: aib/glito
void skeleton_new_cb( Fl_Widget* w, void* ) {
    static int nb_tot = 2;
    const char* p = fl_input( _("Number of functions (1->%d) ?"),
			      IS::translate(nb_tot).c_str(),
			      Skeleton::NBM - 1 );
    if ( p != NULL ) {
	nb_tot = atoi(p);
	if ( 1 <= nb_tot && nb_tot <= Skeleton::NBM - 1) {
	    glito->skel = Skeleton( nb_tot );
	    glito->state = PREVIEW;
	    glito->needRedraw = true;
	} else {
	    fl_alert( _("The number of functions must be between 1 and %d"),
		      Skeleton::NBM - 1 );
	}
    }
}
示例#17
0
文件: Main.cpp 项目: aib/glito
void calibrate_param( Fl_Button* w, void* m ) {
    const int measureTime = 8; // 8 seconds
    static int frames = 16; // 16 frames per second
    if ( fl_ask( _("Do you want the program to calibrate the number\nof pixels to calculate for each frame?\n\n(Esc to cancel the process)") ) ) {
	const char* answer = fl_input( _("How many frames per second?"),
				       IS::translate(frames).c_str() );
	if ( answer ) {
	    frames = atoi(answer);
	    Glito* glito = (Glito*)m;
	    glito->state = CALIBRATE;
	    glito->calibrate( measureTime, frames );
	    glito->state = PREVIEW;
 	    glito->redraw();
	    const int index = w->parent()->find(*w);
	    Fl_Int_Input* input = (Fl_Int_Input*)w->parent()->child( index - 1 );
	    input->value( IS::translate(glito->pointsPerFrame).c_str() );
	}
    }
}
示例#18
0
int create_new_icon()
{
    int ix=Fl::event_x_root();
    int iy=Fl::event_y_root();
    Icon *icon=0;
    const char *i = fl_input(_("Enter the name of the new icon:"), "The Gimp");
    if (i)
    {
        char config[FL_PATH_MAX];
        snprintf(config, sizeof(config)-1, "%s/.ede/desktop/%s.desktop", getenv("HOME"), i);

        if(!fl_file_exists(config))
        {
            Fl_Config cfg(config);
            cfg.set_section("Desktop Entry");
            cfg.write("Icon", "no icon");
            cfg.write("X", ix);
            cfg.write("Y", iy);
            cfg.write(get_localized_string(), i);
            cfg.write("Exec", "Executable Here");
            //const char *u = fl_input(_("Enter the program name or the location to open:"), "gimp");
            cfg.flush();

            desktop->begin();
            icon = new Icon(config);
            desktop->end();
        }
        else {
            fl_alert(_("The icon with the same name already exists."));
        }
    }
    if(icon) {
        property_dialog(0, icon, true);
        icon->position(ix,iy);
        icon->show();

        desktop->redraw();
        desktop->relayout();
    }
    return 0;
}
示例#19
0
void cb_trace_files::cb_renumber(void)
{
	/* Openファイルのフルパスを得る */
	const std::string filepath = this->get_open_path( 1 );
	if (filepath.empty()) {
		fl_alert( "Not set Open Folder or File name" );
		return;
	}

	/* 連番ファイルの存在チェックして必要な情報に変える */
	std::string dpath , head , num , ext;
	int number=-1;
	std::vector<int> nums;
	ids::path::level_from_files(
		filepath ,dpath ,head ,num ,number ,ext ,nums
	);
	if (head.empty() || nums.size() <= 0) {
		fl_alert( "Not exist files" );
		return;
	}

	/* ユーザーから新しいStart番号を得る */
	const char* new_start_num_ptr = fl_input(
		"Enter New Start Number" ,std::to_string(nums.at(0)).c_str()
	);
	if (new_start_num_ptr == nullptr
	||  std::stoi(std::string(new_start_num_ptr))==nums.at(0)) {
		return; /* Cancel or 同じ名前なら何もしない */
	}
	const std::string new_start_num( new_start_num_ptr );

	/* 新しいStart番号との差 */
	const int diff_num = std::stoi(new_start_num) - nums.at(0);

	/* エラー数値をチェックしつつ番号を文字列に入れる */
	std::ostringstream numost;
	bool error_sw = false;
	for (auto nu : nums) {
		numost << nu + diff_num;
		numost << " ";
		if ( nu + diff_num < 0 || 9999 < nu + diff_num ) {
			error_sw = true;
		}
	}

	/* ゼロ以下数値があるとエラーメッセージダイオローグを出して終わる */
	if (error_sw) {
		std::string opa( this->get_open_path( nums.at(0) ) );
		std::string npa( this->get_open_path(
				nums.at(0) + diff_num ) );
		fl_alert(
"Error : Number need 0...9999 range\nFrom\n %s\nTo\n %s\nNumber List\n %s\n"
			,opa.c_str()
			,npa.c_str()
			,numost.str().c_str()
		);
		return;
	}

	/* ファイル毎名前を変更する */
	for (size_t ii=0; ii<nums.size() ; ++ii) {
		std::string opa( this->get_open_path( nums.at(ii) ) );
		std::string npa( this->get_open_path(
				nums.at(ii) + diff_num ) );
		/* 最初にこれでいいかユーザーに確認する */
		if (ii==0) {
			if (fl_ask(
"Renumber\nFrom\n %s\nTo\n %s\nNumber List\n %s\nOK?"
				,opa.c_str()
				,npa.c_str()
				,numost.str().c_str()
			) != 1) {
				return; // Cancel
			}
		}

#ifdef _WIN32
		std::string opa2( osapi::cp932_from_utf8( opa ) );
		std::string npa2( osapi::cp932_from_utf8( npa ) );
		if (opa2.empty() || npa2.empty()) {
			fl_alert("Error:rename \"%s\" \"%s\""
				,opa.c_str() ,npa.c_str() );
			return;
		}
		std::rename( opa2.c_str() ,npa2.c_str() );
#else
		std::rename( opa.c_str() ,npa.c_str() );
#endif
	}

	/* renumber成功したら、新しいStart,End,Numberに表示変更 */
	this->cb_set_number();
	this->cb_check_existing_saved_file();
}
示例#20
0
文件: Track.C 项目: shanipribadi/non
void
Track::menu_cb ( const Fl_Menu_ *m )
{
    char picked[256];

    m->item_pathname( picked, sizeof( picked ) );

    DMESSAGE( "Picked: %s", picked );

    Logger log( this );

    if ( ! strcmp( picked, "Type/Mono" ) )
    {
        command_configure_channels( 1 );
    }
    else if ( ! strcmp( picked, "Type/Stereo" ) )
    {
        command_configure_channels( 2 );
    }
    else if ( ! strcmp( picked, "Type/Quad" ) )
    {
        command_configure_channels( 4 );
    }
    else if ( ! strcmp( picked, "Type/..." ) )
    {
        const char *s = fl_input( "How many channels?", "3" );
        if ( s )
        {

            int c = atoi( s );

            if ( c <= 0 || c > 10 )
                fl_alert( "Invalid number of channels." );
            else
            {
                command_configure_channels(c);
            }
        }
    }
    else if ( ! strcmp( picked, "/Add Control" ) )
    {
        /* add audio track */
        char *name = get_unique_control_name( "Control" );

        timeline->wrlock();
        new Control_Sequence( this, name );
        timeline->unlock();
    }
    else if ( ! strcmp( picked, "/Overlay controls" ) )
    {
        overlay_controls( ! m->mvalue()->value() );
    }
    else if ( ! strcmp( picked, "/Add Annotation" ) )
    {
        add( new Annotation_Sequence( this ) );
    }
    else if ( ! strcmp( picked, "/Color" ) )
    {
        unsigned char r, g, b;

        Fl::get_color( color(), r, g, b );

        if ( fl_color_chooser( "Track Color", r, g, b ) )
        {
            color( fl_rgb_color( r, g, b ) );
        }

        redraw();
    }
    else if ( ! strcmp( picked, "Flags/Record" ) )
    {
        armed( m->mvalue()->flags & FL_MENU_VALUE );
    }
    else if ( ! strcmp( picked, "Flags/Mute" ) )
    {
        mute( m->mvalue()->flags & FL_MENU_VALUE );
    }
    else if ( ! strcmp( picked, "Flags/Solo" ) )
    {
        solo( m->mvalue()->flags & FL_MENU_VALUE );
    }
    else if ( ! strcmp( picked, "Size/Small" ) )
    {
        size( 0 );
    }
    else if ( ! strcmp( picked, "Size/Medium" ) )
    {
        size( 1 );
    }
    else if ( ! strcmp( picked, "Size/Large" ) )
    {
        size( 2 );
    }
    else if ( ! strcmp( picked, "Size/Huge" ) )
    {
        size( 3 );
    }
    else if ( ! strcmp( picked, "/Remove" ) )
    {
        int r = fl_choice( "Are you certain you want to remove track \"%s\"?", "Cancel", NULL, "Remove", name() );

        if ( r == 2 )
        {
            timeline->command_remove_track( this );
             Fl::delete_widget( this );
        }
    }
    else if ( ! strcmp( picked, "/Rename" ) )
    {
        ((Fl_Sometimes_Input*)name_field)->take_focus();
    }
    else if ( ! strcmp( picked, "/Move Up" ) )
    {
        timeline->command_move_track_up( this );
    }
    else if ( ! strcmp( picked, "/Move Down" ) )
    {
        timeline->command_move_track_down( this );
    }
    else if ( !strcmp( picked, "Takes/Show all takes" ) )
    {
        show_all_takes( ! m->mvalue()->value() );
    }
    else if ( !strcmp( picked, "Takes/New" ) )
    {
        timeline->wrlock();
        sequence( (Audio_Sequence*)sequence()->clone_empty() );
        timeline->unlock();
    }
    else if ( !strcmp( picked, "Takes/Remove" ) )
    {
            if ( takes->children() )
            {
                Loggable::block_start();

                timeline->wrlock();

                Audio_Sequence *s = sequence();

                sequence( (Audio_Sequence*)takes->child( 0 ) );

                delete s;

                timeline->unlock();

                Loggable::block_end();
            }
    }
    else if ( !strcmp( picked, "Takes/Remove others" ))
    {
        if ( takes->children() )
            {
                Loggable::block_start();

                takes->clear();

                Loggable::block_end();
            }
    }
    else if ( !strncmp( picked, "Takes/", sizeof( "Takes/" ) - 1 ) )
    {
        Audio_Sequence* s = (Audio_Sequence*)m->mvalue()->user_data();

        timeline->wrlock();
        sequence( s );
        timeline->unlock();
    }
}
示例#21
0
文件: Mixer.C 项目: imv/non
void Mixer::cb_menu(Fl_Widget* o) {
    Fl_Menu_Bar *menu = (Fl_Menu_Bar*)o;

/*     const Fl_Menu_Item *mi = &menu->menu()[menu->value()]; */

     char picked[256];
     // const char *picked = menu->text();

    menu->item_pathname( picked, sizeof( picked ) );

    if (! strcmp( picked, "&Project/&New") )
    {
        DMESSAGE( "New project" );
        const char *templates[] = { "Default", NULL };

        char *default_path;
        char *selected_template;

        read_line( user_config_dir, "default_path", &default_path );

        char *path = new_project_chooser( templates, &default_path, &selected_template );

        if ( path )
        {
            if ( ! Project::create( path, selected_template ) )
                fl_alert( "Error creating project!" );
            free( path );
            free( selected_template );
        }

        update_menu();

        if ( default_path )
        {
            write_line( user_config_dir, "default_path", default_path );
            free( default_path );
        }

    }
    else if (! strcmp( picked, "&Project/&Open" ) )
    {
        char *path = NULL;

//        read_line( user_config_dir, "default_path", &path );

        const char *name = fl_dir_chooser( "Open Project", path );

        free( path );

        mixer->hide();

        if ( int err = Project::open( name ) )
        {
            fl_alert( "Error opening project: %s", Project::errstr( err ) );
        }

        update_menu();

        mixer->show();
    }
    else if (! strcmp( picked, "&Project/&Save" ) )
    {
        command_save();
    }
    else if (! strcmp( picked, "&Project/&Quit") )
    {
        command_quit();
    }
    else if ( !strcmp( picked, "&Mixer/&Add Strip" ) )
    {
        command_add_strip();
    }
    else if ( !strcmp( picked, "&Mixer/Add &N Strips" ) )
    {
        const char *s = fl_input( "Enter number of strips to add" );

        if ( s )
        {
            for ( int i = atoi( s ); i > 0; i-- )
                command_add_strip();
        }
    }
    else if ( !strcmp( picked, "&Mixer/&Import Strip" ) )
    {
        const char *s = fl_file_chooser( "Export strip to filename:", "*.strip", NULL, 0 );

        if ( s )
        {
            if (! Mixer_Strip::import_strip( s ) )
                fl_alert( "%s", "Failed to import strip!" );
        }
    }
    else if (! strcmp( picked, "&Mixer/&Rows/One") )
    {
        rows( 1 );
    }
    else if (! strcmp( picked, "&Mixer/&Rows/Two") )
    {
        rows( 2 );
    }
    else if (! strcmp( picked, "&Mixer/&Rows/Three") )
    {
        rows( 3 );
    }
    else if (! strcmp( picked, "&View/&Theme") )
    {
        fl_theme_chooser();
    }
    else if (! strcmp( picked, "&Options/&Display/&Knobs/&Burnished") )
    {
        Fl_Dial::default_style( Fl_Dial::BURNISHED_DIAL );
        redraw_windows();
    }
    else if (! strcmp( picked, "&Options/&Display/&Knobs/&Arc") )
    {
        Fl_Dial::default_style( Fl_Dial::ARC_DIAL );
        redraw_windows();
    }
    else if (! strcmp( picked, "&Options/&Display/&Knobs/&Plastic") )
    {
        Fl_Dial::default_style( Fl_Dial::PLASTIC_DIAL );
        redraw_windows();
    }
    else if (! strcmp( picked, "&Options/&Display/&Sliders/&Nice") )
    {
        Fl_Value_SliderX::default_style( Fl_Value_SliderX::NICE_SLIDER );
        redraw_windows();
    }
    else if (! strcmp( picked, "&Options/&Display/&Sliders/&Fill") )
    {
        Fl_Value_SliderX::default_style( Fl_Value_SliderX::FILL_SLIDER );
        redraw_windows();
    }
    else if (! strcmp( picked, "&Options/&Display/&Sliders/&Simple") )
    {
        Fl_Value_SliderX::default_style( Fl_Value_SliderX::SIMPLE_SLIDER );
        redraw_windows();
    }
    else if ( ! strcmp( picked, "&Help/&About" ) )
    {
        About_Dialog ab( PIXMAP_PATH "/non-mixer/icon-256x256.png" );

        ab.logo_box->label( VERSION );

        ab.title->label( "The Non Mixer" );

        ab.copyright->label( "Copyright (C) 2008-2010 Jonathan Moore Liles" );
        ab.credits->label(
            "Non-Mixer was written from scratch by\n"
            "Jonathan Moore Liles for his own use\n"
            "(see the manual).\n"
            "\n"
            "Nobody planned. Nobody helped.\n"
            "You can help now by donating time, money,\n"
            "and/or replacing the rest of Linux Audio\n"
            "with fast, light, reliable alternatives.\n" );

        ab.website_url->label( "http://non-mixer.tuxfamily.org" );

        ab.run();
    }
    else if ( !strcmp( picked, "&Help/&Manual" ))
    {
        char *pat;

        asprintf( &pat, "file://%s.html", DOCUMENT_PATH "/non-mixer/MANUAL" );

        open_url( pat );

        free( pat );
    }
}
示例#22
0
void saveCB(Fl_Widget*, TrainWindow* tw)
{
	const char* fname = fl_input("File name for save (should be *.txt)","TrackFiles/");
	if (fname)
		tw->world.writePoints(fname);
}
void gtsfbro06cb_level::cb_mkdir( void )
{
	const char *ccp_dir, *ccp_subdir;
	char ca_msg[PTBL_PATH_MAX];
	char ca_subdir[PTBL_PATH_MAX];

	/* Dirを得る */
	if (cl_gts_gui.ligbut_level_rgb_scan_browse_sw->value()) {
		ccp_dir = cl_gts_gui.filinp_level_rgb_scan_dir->value();
	} else {
		ccp_dir = cl_gts_gui.filinp_level_dir->value();
	}

	/* Dialogのメッセージ生成 */
	snprintf(ca_msg,PTBL_PATH_MAX,"In\n %s\nNew directory name",
			ccp_dir);

	/* Dialogを使いユーザーによるDir名変更 */
	ccp_subdir = fl_input( ca_msg );
	if (NULL == ccp_subdir) { return; /* ユーザーによるcancel */ }

	/* 入力した名前のチェック-------------------------- */
	ca_subdir[0] = '\0';
	sscanf(ccp_subdir,"%s",ca_subdir); /* space文字をとる */
	if ('\0' == ca_subdir[0]) {
		return; /* 空文字 */
	}
	ca_subdir[PTBL_PATH_MAX-1] = '\0';

	/* 有効でない文字がある */
	if (NG == this->_is_valid_string( ca_subdir )) {
		snprintf( ca_msg,PTBL_PATH_MAX,
		"bad string.\n %s\ninclude bad character",
			ca_subdir);
		fl_alert(ca_msg);
		return;
	}

	/* 同じ名前がある */
	if (NULL != this->stp_dir_or_file_search(ca_subdir)) {
		if (E_DIR_OR_FILE_IS_DIR ==
		this->stp_dir_or_file_search(ca_subdir)->e_type) {
			snprintf( ca_msg,PTBL_PATH_MAX,
			"Can not makedir.\nDirectory\n %s\nis exist",
				ca_subdir);
		} else {
			snprintf( ca_msg,PTBL_PATH_MAX,
			"Can not makedir.\nFile\n %s\nis exist",
				ca_subdir);
		}
		fl_alert(ca_msg);
		return;
	}

	/* 新しいDirパス生成 */
	if (OK != this->i_path_dir_down(
			ccp_dir, ca_subdir
	)) {
		pri_funct_err_bttvr(
	"Error : this->i_path_dir_down(%s,%s) returns NG",
			ccp_dir, ca_subdir
		);
		return;
	}

	if (ptbl_mkdir( this->cp_path() )) {
		pri_funct_err_bttvr(
   "Error : ptbl_mkdir(%s) returns not zero",  this->cp_path() );
		return;
	}

	/* ファイルandディレクトリリスト再表示 */
	if (OK != this->change_level_list() ) {
		pri_funct_err_bttvr(
	 "Error : this->change_level_list() returns NG");
		return;
	}

	/* 新しいものを選択状態にする */
	this->_select_new_dir_or_file_or_level( ca_subdir );
}
/* 実行する(OK(0))か否(NG(-1))かを返す */
int gtsfbro06cb_level::_rename_file_tif( int i_num, const char *ccp_old, char *cp_new )
{
	ST_DIR_OR_FILE_INFO *stp_dir_or_file;
	const char *ccp_dir, *ccp_new;
	char ca_msg[PTBL_PATH_MAX];
	char ca_path[PTBL_PATH_MAX];

	stp_dir_or_file = this->stp_dir_or_file_info(i_num);
	if (NULL == stp_dir_or_file) { return NG; }

	if (E_DIR_OR_FILE_IS_NOT_TRACEING_RGB_IMAGE ==
	stp_dir_or_file->e_type) {
		ccp_dir =cl_gts_gui.filinp_level_rgb_scan_dir->value();
	} else {
		ccp_dir =cl_gts_gui.filinp_level_dir->value();
	}

	/* Dialogのメッセージ生成 */
	snprintf(ca_msg,PTBL_PATH_MAX,"In\n %s\nRename File\n %s",
			ccp_dir,ccp_old);

	/* Dialogを使いユーザーによるDir名変更 */
	ccp_new = fl_input( ca_msg, ccp_old );

	/* ユーザーによるcancel */
	if (NULL == ccp_new) {
		strcpy( cp_new,ccp_old );
		return NG;
	}

	/* 入力した名前のチェック-------------------------- */
	// cp_new[0] = '\0';
	sscanf(ccp_new,"%s",cp_new); /* space文字をとる */

	/* 空文字か変更なし */
	if (('\0' == cp_new[0]) || !strcmp( ccp_old,cp_new )) {
		strcpy( cp_new,ccp_old );
		return NG;
	}

	/* 有効でない文字がある */
	if (NG == this->_is_valid_string( cp_new )) {
		snprintf( ca_msg,PTBL_PATH_MAX,
		"bad string.\n %s\ninclude bad character",
			cp_new);
		fl_alert(ca_msg);
		strcpy( cp_new,ccp_old );
		return NG;
	}

	/* 同じ名前がある */
	if (NULL != this->stp_dir_or_file_search(cp_new)) {
		if (E_DIR_OR_FILE_IS_DIR ==
		this->stp_dir_or_file_search(cp_new)->e_type) {
			snprintf( ca_msg,PTBL_PATH_MAX,
			"Can not rename.\nDirectory\n %s\nis exist",
				cp_new);
		} else {
			snprintf( ca_msg,PTBL_PATH_MAX,
			"Can not rename.\nFile\n %s\nis exist",
				cp_new);
		}
		fl_alert(ca_msg);
		strcpy( cp_new,ccp_old );
		return NG;
	}

	/* 拡張子の確認 */
	const char *ccp_n,*ccp_o;
	ccp_o = strrchr( ccp_old, '.' );
	ccp_n = strrchr( cp_new, '.' );
	if (	(NULL != ccp_o) && /* 元もと、拡張子があって */
		(	(NULL == ccp_n) || /* 拡張子がないか... */
			strcmp(ccp_o,ccp_n) /* あるいは違う拡張子名 */
		)
	) {
		snprintf(ca_msg,PTBL_PATH_MAX,
			"Do Not change extention\n %s",
			cp_new);
		fl_alert(ca_msg);
		strcpy( cp_new,ccp_old );
		return NG;
	}
	/* 接尾語".0000.tif"の確認 */
	if (NULL == this->ccp_num4_and_ext( cp_new )) {
		snprintf(ca_msg,PTBL_PATH_MAX,
			"Do Not change number or extention\n %s",
			cp_new);
		fl_alert(ca_msg);
		strcpy( cp_new,ccp_old );
		return NG;
	}

	/* 新しいDirパス生成 */
	if (OK != this->i_path_dir_file( ccp_dir, cp_new )) {
		pri_funct_err_bttvr(
	 "Error : this->i_path_dir_file(%s,%s) returns NG",
			ccp_dir, cp_new
		);
		strcpy( cp_new,ccp_old );
		return NG;
	}
	strcpy( ca_path, this->cp_path() );

#if 0
	/* Dialogを使い実行確認 */
	snprintf(ca_msg,PTBL_PATH_MAX,
		"In\n %s\nRename File\n %s --> %s ok?",
		ccp_dir,ccp_old,cp_new
	);
	if (0 == fl_ask(ca_msg)) {
		strcpy( cp_new,ccp_old );
		return NG; /* ユーザーによるcancel */
	}
#endif

	/* 古いDirパス設定 */
	if (OK != this->i_path_dir_file( ccp_dir, ccp_old )) {
		pri_funct_err_bttvr(
	 "Error : this->i_path_dir_file(%s,%s) returns NG",
			ccp_dir, ccp_old
		);
		strcpy( cp_new,ccp_old );
		return NG;
	}

	/* 変更 */
	if (rename( this->cp_path(), ca_path )) {
		pri_funct_err_bttvr(
   "Error : rename(%s,%s) returns not zero",
			this->cp_path(), ca_path
		);
		/* rename()に失敗してもリスト再表示はする */
		strcpy( cp_new,ccp_old );
		return NG;
	}
	return OK;
}
示例#25
0
void UserList::userClicked(int rowIndex, int button)
{
    if (button == FL_RIGHT_MOUSE)
    {
        StringTableRow const & row = getRow(static_cast<std::size_t>(rowIndex));

        std::string const userName = row.id_;
        User const * user = 0;
        PopupMenu menu;

        try
        {
            user = &model_.getUser(row.id_);
        }
        catch (std::invalid_argument const & e)
        {
            LOG(ERROR)<< e.what();
            return;
        }

        std::string const userInfo = user->info();
        menu.add(userInfo, 1);
        menu.add("Open chat", 2);

        int const battleId = user->joinedBattle();

        if (battleId != -1)
        {
            try
            {
                Battle const& battle = model_.getBattle(battleId);
                std::string joinText = "Join " + battle.title();
                menu.add(joinText, 3);
            }
            catch (std::invalid_argument const& e)
            {
                LOG(WARNING) << e.what();
            }
        }

        std::string const zkAccountID = user->zkAccountID();
        if (!zkAccountID.empty()) {
            menu.add("Open user web page", 4);
        }

        if (menu.size() > 0)
        {
            int const id = menu.show();
            switch (id)
            {
            case 1:
                Fl::copy(userInfo.c_str(), userInfo.size(), 1 /* clipboard */);
                break;
            case 2:
                try
                {
                    model_.getUser(userName); // to make sure user still exist
                    iTabs_.openPrivateChat(userName);
                }
                catch (std::invalid_argument const & e)
                {
                    LOG(WARNING)<< e.what();
                }
                break;

            case 3:
                try
                {
                    Battle const& battle = model_.getBattle(battleId);
                    if (battle.passworded())
                    {
                        char const * password = fl_input("Enter battle password");
                        if (password != NULL)
                        {
                            model_.joinBattle(battleId, password);
                        }
                    }
                    else
                    {
                        model_.joinBattle(battleId);
                    }
                }
                catch (std::invalid_argument const & e)
                {
                    LOG(WARNING)<< e.what();
                }
                break;

            case 4: {
                std::string const link("http://zero-k.info/Users/Detail/" + zkAccountID);
                flOpenUri(link);
                break;
            }
            }
        }
    }
}
示例#26
0
void load_tiles(Fl_Widget*,void*o){
	//if o=0 load if o=1 append if o=2 load at
	if(!currentProject->containsData(pjHaveTiles)){
		currentProject->haveMessage(pjHaveTiles);
		return;
	}
	size_t file_size;
	unsigned mode=(uintptr_t)o;
	char * returned=(char*)fl_input("What row should these tiles use?\nEnter 0 to 3 to selected a row or -1 to -4 to auto determine based on tilemap\nWhen specifing a negative number to figure out what the default will be use this formula abs(row)-1","-1");
	if (unlikely(!returned))
		return;
	if (unlikely(!verify_str_number_only(returned)))
		return;
	int row=atoi(returned);
	if (unlikely((row > 3) || (row < -4))){
		fl_alert("You entered %d which is out of range it must be in range of -4 to 3",row);
		return;
	}
	uint8_t defaultRow=row >= 0 ? row:abs(row)-1;
	int compression=compressionAsk();
	bool alphaZero=fl_ask("Set color #0 to alpha 0 instead of 255")?true:false;
	void*output;
	filereader f=filereader("Load tiles");
	if(f.amt==0)
		return;
	unsigned idx=f.selDat();
	file_size = f.lens[idx];
	unsigned truecolor_multiplier;
	truecolor_multiplier=256/currentProject->tileC->tileSize;
	if(compression)
		output=decodeTypeRam((uint8_t*)f.dat[idx],f.lens[idx],file_size,compression);
	else{
		if (file_size%currentProject->tileC->tileSize){
			fl_alert("Error: This is not a valid tile file each tile is %d bytes and this file is not a multiple of %d so it is not a valid tile file",currentProject->tileC->tileSize,currentProject->tileC->tileSize);
			return;
		}
	}
	uint32_t offset_tiles;
	uint32_t offset_tiles_bytes;
	if(mode==2){
		const char * str=fl_input("Counting from zero which tile should this start at?");
		if(!str){
			return;
		}
		if(!verify_str_number_only((char*)str)){
			return;
		}
		int off=atoi(str);
		if(off>=0){
			offset_tiles=off;
			offset_tiles_bytes=offset_tiles*currentProject->tileC->tileSize;
		}else{
			fl_alert("You must enter a number greater than or equal to zero");
			return;
		}
	}else if(mode==1){
		offset_tiles=currentProject->tileC->amt;
		offset_tiles_bytes=offset_tiles*currentProject->tileC->tileSize;
	}else{
		offset_tiles=0;
		offset_tiles_bytes=0;
	}
	if(mode==2){
		if(offset_tiles+(file_size/currentProject->tileC->tileSize)>=currentProject->tileC->amt)
			currentProject->tileC->tDat.resize(offset_tiles_bytes+file_size);
	}else
		currentProject->tileC->tDat.resize(offset_tiles_bytes+file_size);
	if(compression){
		memcpy(currentProject->tileC->tDat.data()+offset_tiles_bytes,output,file_size);
		free(output);
	}else
		memcpy(currentProject->tileC->tDat.data()+offset_tiles_bytes,f.dat[idx],file_size);
	if(currentProject->getTileType()!=PLANAR_TILE)
		currentProject->tileC->toPlanar(currentProject->getTileType(),offset_tiles,offset_tiles+(file_size/currentProject->tileC->tileSize));
	if(mode==2){
		if(offset_tiles+(file_size/currentProject->tileC->tileSize)>=currentProject->tileC->amt)
			currentProject->tileC->truetDat.resize((file_size*truecolor_multiplier)+(offset_tiles_bytes*truecolor_multiplier));
	}else
		currentProject->tileC->truetDat.resize((file_size*truecolor_multiplier)+(offset_tiles_bytes*truecolor_multiplier));
	for(uint32_t c=offset_tiles;c<(file_size/currentProject->tileC->tileSize)+offset_tiles;c++) {
		if(row < 0){
			uint32_t x,y;
			uint8_t foundRow=defaultRow;
			for(y=0;y<currentProject->tms->maps[currentProject->curPlane].mapSizeHA;++y){
				for(x=0;x<currentProject->tms->maps[currentProject->curPlane].mapSizeW;++x){
					if(currentProject->tms->maps[currentProject->curPlane].get_tile(x,y) == c) {
						foundRow=currentProject->tms->maps[currentProject->curPlane].getPalRow(x,y);
						goto doTile;
					}
				}
			}
doTile:
			currentProject->tileC->tileToTrueCol(&currentProject->tileC->tDat[(c*currentProject->tileC->tileSize)],&currentProject->tileC->truetDat[(c*256)],foundRow,true,alphaZero);
		}else
			currentProject->tileC->tileToTrueCol(&currentProject->tileC->tDat[(c*currentProject->tileC->tileSize)],&currentProject->tileC->truetDat[(c*256)],defaultRow,true,alphaZero);
	}
	if(mode==2){
		if(offset_tiles+(file_size/currentProject->tileC->tileSize)>=currentProject->tileC->amt){
			currentProject->tileC->amt=(file_size/currentProject->tileC->tileSize);
			currentProject->tileC->amt+=offset_tiles;
		}
	}else{
		currentProject->tileC->amt=(file_size/currentProject->tileC->tileSize);
		currentProject->tileC->amt+=offset_tiles;
	}
	updateTileSelectAmt();
	window->tile_select->value(0);
	window->tile_select_2->value(0);
	window->redraw();
}
示例#27
0
int MolBrowser::handle(int type) {
#if 1
  // handle paste operations
  if (type == FL_PASTE) {
    // ignore paste operations that weren't due to drag-and-drop 
    // since they could be any arbitrary data/text, and not just filenames.
    if (dragpending) {
      int len = Fl::event_length();

      // ignore zero-length paste events (why do these occur???)
      if (len > 0) {
        int numfiles, i;
        const char *lastc;
        int lasti;
        FileSpec spec; 
        const char *ctext = Fl::event_text();
        char *filename = (char *) malloc((1 + len) * sizeof(char));

        for (lasti=0,lastc=ctext,numfiles=0,i=0; i<len; i++) {
          // parse out all but last filename, which doesn't have a CR
          if (ctext[i] == '\n') {
            memcpy(filename, lastc, (i-lasti)*sizeof(char));
            filename[i-lasti] = '\0';

            // attempt to load the file into a new molecule
            app->molecule_load(-1, filename, NULL, &spec);

            lasti=i+1;
            lastc=&ctext[lasti];
            numfiles++;
          }

          // special-case last filename, since there's no CR
          if (i == (len-1)) {
            memcpy(filename, lastc, (1+i-lasti)*sizeof(char));
            filename[1+i-lasti] = '\0';

            // attempt to load the file into a new molecule
            app->molecule_load(-1, filename, NULL, &spec);
            numfiles++;
          }
        }

        free(filename);
      }

      dragpending = 0; // no longer waiting for drag-and-drop paste
    }

    return 1; // indicate that we handled the paste operation
  }

  // handle drag-and-drop operations
  if (type == FL_DND_ENTER || type == FL_DND_DRAG) {
    return 1; // indicate that we want the drag-and-drop operation
  }
  if (type == FL_DND_RELEASE) {
    Fl::paste(*this);
    dragpending = 1; // flag to expect incoming paste due to DND operation
    return 1;
  }
#endif

  if (type == FL_RELEASE) {
    // update the MainMenu gui in case the molecule selections have changed
    if (mainmenu) mainmenu->update_gui_state();
  }
  
  if (type == FL_PUSH && Fl::event_button() == FL_LEFT_MOUSE 
      && Fl::event_clicks()) {
    // figure out which line is selected; since it's a double click there
    // can be only one.
    int molid = -1; //unique ID of selected mol
    int selmol= -1; //GUI index of the selected mol
    
    for (int i=1; i<=size(); i++) {
      if (selected(i)) { 
        selmol = i-1;
        molid = app->molecule_id(selmol); 
        break;
      }
    }
 
    if (molid >= 0) {
      char need_more_clicks = FALSE;
      
      // figure out where on the line the double click occurred. 
      int mx = Fl::event_x();
      if (mx >= 30 && mx < 48) {
        if ( Fl::event_clicks() > 1){ // triple click: single A/T/D molecule
          for (int j=1; j<= size(); j++) {
            int id = app->molecule_id(j-1);
            app->molecule_activate(id, molid == id);
            app->molecule_display(id, molid == id);
            app->menu_select_mol("graphics", selmol);
          }
          app->molecule_make_top(molid);
          app->scene_resetview();
        }
        else {
          app->molecule_make_top(molid);
          need_more_clicks = TRUE;
        }
      } else if (mx >= 48 && mx < 66) {
        app->molecule_activate(molid, !app->molecule_is_active(molid));
      } else if (mx >= 66 && mx < 84) {
        app->molecule_display(molid, !app->molecule_is_displayed(molid));
      } else if (mx >= 84 && mx < 102) {
        app->molecule_fix(molid, !app->molecule_is_fixed(molid));
      } else if (mx >= 102 && mx < 262) { //rename
        // this code snippet is an exact copy of code in MainFltkMenu.C:
        const char *oldname = app->molecule_name(molid);
        const char *newname = fl_input("Enter a new name for molecule %d:", 
          oldname, molid);
        if (newname) app->molecule_rename(molid, newname);
      } else if (mx >= 332 && mx < 412) { //delete frames
        // this code snippet is an exact copy of code in MainFltkMenu.C:
        int numframes = app->molecule_numframes(molid);
        if (!numframes) {
          fl_alert("Molecule %d has no frames to delete!", molid);
        } else {
          const char *molname = app->molecule_name(molid);
          int frst=0, lst=numframes-1, stride=0;
          int ok = frame_delete_selector(molname, numframes-1, &frst, &lst, &stride);
          if (ok) app->molecule_deleteframes(molid, frst, lst, stride);
        }
      } 
      else need_more_clicks = TRUE;
      if (!need_more_clicks) Fl::event_is_click(0);
    }
  }

  if (mainmenu && type == FL_PUSH && Fl::event_button() == FL_RIGHT_MOUSE) {
    const Fl_Menu_Item *menuitem;
    menuitem=mainmenu->browserpopup_menuitems->popup(Fl::event_x(), Fl::event_y());
    if (menuitem && menuitem->callback()) 
      menuitem->do_callback((Fl_Widget *) mainmenu->menubar, menuitem->user_data());
    return 1; // do not allow parent to process event
  }

  return Fl_Multi_Browser::handle(type);
}
示例#28
0
/* rename/renumber処理実行 */
void cb_trace_files::cb_rename(void)
{
	/* Openファイルのフルパスを得る */
	const std::string filepath = this->get_open_path( 1 );
	if (filepath.empty()) {
		fl_alert( "Not set Open Folder or File name" );
		return;
	}

	/* 連番ファイルの存在チェックして必要な情報に変える */
	std::string dpath , head , num , ext;
	int number=-1;
	std::vector<int> nums;
	ids::path::level_from_files(
		filepath ,dpath ,head ,num ,number ,ext ,nums
	);
	if (head.empty() || nums.size() <= 0) {
		fl_alert( "Not exist files" );
		return;
	}
	std::ostringstream numost;
	for (auto nu : nums) {
		numost << nu;
		numost << " ";
	}

	/* ユーザーから新しい名前を得る */
	const char* new_head_ptr = fl_input(
		"Enter New Level Name" ,head.c_str()
	);
	if (new_head_ptr == nullptr || head == new_head_ptr ) {
		return; /* Cancel or 同じ名前なら何もしない */
	}
	const std::string new_head(new_head_ptr);

	/* ファイル毎名前を変更する */
	for (size_t ii=0; ii<nums.size() ; ++ii) {
		std::string opa( this->get_open_path( nums.at(ii) ) );
		std::string npa( this->get_open_path_from_head_and_number_(
			new_head.c_str() ,nums.at(ii)
		));
		/* 最初にこれでいいかユーザーに確認する */
		if (ii==0) {
			if (fl_ask(
 "Rename\nFrom\n %s\nTo\n %s\nNumber List\n %s\nOK?"
				,opa.c_str()
				,npa.c_str()
				,numost.str().c_str()
			) != 1) {
				return; // Cancel
			}
		}

#ifdef _WIN32
		std::string opa2( osapi::cp932_from_utf8( opa ) );
		std::string npa2( osapi::cp932_from_utf8( npa ) );
		if (opa2.empty() || npa2.empty()) {
			fl_alert("Error:rename \"%s\" \"%s\""
				,opa.c_str() ,npa.c_str() );
			return;
		}
		std::rename( opa2.c_str() ,npa2.c_str() );
#else
		std::rename( opa.c_str() ,npa.c_str() );
#endif
	}

	/* rename成功したら、新しい名前に表示変更 */
	cl_gts_gui.strinp_trace_open_file_head->value( new_head.c_str() );
}