예제 #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));
                }
            }
        }
    }
예제 #2
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
	}
}