Exemple #1
0
void MainDlg::OnFile()
{
	FileSel dlg;
	dlg.ReadOnlyOption();
	dlg.ExecuteOpen( t_("Test") );
	dlg.ExecuteSaveAs( t_("Test") );
	dlg.ExecuteSelectDir( t_("Test") );
}
Exemple #2
0
void IdeFs(FileSel& fs)
{
	fs.WhenIcon = callback(IdeFileIcon);
	fs.AllFilesType();
	fs.Multi();
	fs.NoAsking();
	fs.ReadOnlyOption();
}
Exemple #3
0
void DlgCompareDir::DoBrowse(Ctrl *field)
{
	FileSel fsel;
	fsel.AllFilesType();
	static String recent_dir;
	fsel <<= Nvl((String)~*field, recent_dir);
	if(fsel.ExecuteSelectDir())
		*field <<= recent_dir = ~fsel;
}
Exemple #4
0
FileSel& sSD()
{
	static bool b;
	static FileSel fs;
	if(!b) {
		fs.AllFilesType();
		b = true;
	}
	return fs;
}
Exemple #5
0
void LoggerCtrl::Save()
{
	FileSel fs;
	fs.Type("Text file", "*.txt");
	if(!fs.ExecuteSaveAs("Save Log to file")) return;
	String fn = fs.Get();
	if(fn.IsEmpty()) return;
	FileOut out(fn);
	Flush();
	DocEdit::Save(out);
}
Exemple #6
0
FileSel& AnyPackageFs()
{
	static FileSel fs;
	static bool b;
	if(!b) {
		fs.Type("Ultimate++ package (*.upp)", "*.upp");
		fs.AllFilesType();
		b = true;
	}
	return fs;
}
Exemple #7
0
void ReportWindow::Pdf()
{
	static FileSel fs;
	static bool b;
	if(!b) {
		fs.Type(t_("PDF file"), "*.pdf");
		fs.AllFilesType();
	}
	if(!fs.ExecuteSaveAs(t_("Output PDF file")))
		return;
	SaveFile(~fs, UPP::Pdf(*report));
}
Exemple #8
0
void Ide::CreateMakefile()
{
    const Workspace& wspc = IdeWorkspace();
    if(wspc.GetCount() == 0) {
        PutConsole("Project is empty!");
        return;
    }
    FileSel mfout;
    mfout.AllFilesType();
    mfout <<= AppendFileName(GetFileDirectory(PackagePath(wspc[0])), "Makefile");
    if(!mfout.ExecuteSaveAs("Save makefile as"))
        return;
    SaveMakeFile(~mfout, true);
}
void bigmailer::onOpenList()
{
	FileSel fs;
	fs.ActiveDir(ConfigFile("")) ;
	fs.Type("list files", "*.list") ;

	if ( ! fs.ExecuteOpen(t_("select a list file") ) )
		return;

	onCloseList() ;

	theDefList.Load(fs.Get()) ;
	SetTitle() ;
}
Exemple #10
0
void WorkspaceWork::AddFile(ADDFILE af)
{
	String active = GetActivePackage();
	if(active.IsEmpty()) return;
	FileSel *fs = &OutputFs();
	RealizeDirectory(GetLocalDir());
	switch(af)
	{
	case PACKAGE_FILE: fs = &BasedSourceFs(); fs->BaseDir(GetFileFolder(PackagePathA(active))); break;
	case ANY_FILE:     fs = &AnySourceFs(); break;
	case OUTPUT_FILE:  fs->ActiveDir(GetOutputDir()); break;
	case CONFIG_FILE:  fs->ActiveDir(GetConfigDir()); break;
	case HOME_FILE:    fs->ActiveDir(GetHomeDirectory()); break;
	case LOCAL_FILE:   fs->ActiveDir(GetLocalDir()); break;
	default: ; // GCC warns otherwise
	}
	if(!fs->ExecuteOpen("Add files to package..")) return;
	int fci = filelist.GetCursor();
	int cs = filelist.GetSbPos();
	int ci = fci >= 0 && fci < fileindex.GetCount() ? fileindex[fci] : -1;
	for(int i = 0; i < fs->GetCount(); i++) {
		Package::File& f = ci >= 0 ? actual.file.Insert(ci++) : actual.file.Add();
		f = (*fs)[i];
		f.readonly = fs->GetReadOnly();
	}
	SaveLoadPackage(false);
	filelist.SetSbPos(cs);
	filelist.SetCursor(fci >= 0 ? fci : filelist.GetCount() - 1);
	FileSelected();
}
Exemple #11
0
void AnimatedClip::Browse() {
	FileSel fs;
	
	fs.PreSelect(~fileName);
	fs.Type("Animation type", "*.gif, *.tif, *.tiff");
	
	if (fs.ExecuteOpen("Choose animation file"))
		fileName <<= ~fs;

	if (!clip.Load(~fileName)) {
		Exclamation("Invalid input");
		return;
	}
	numberPages = FormatInt(clip.GetPageCount());
	openedPage = FormatInt(clip.GetPage());
}
Exemple #12
0
void ImageMT::LoadImage()
{
	FileSel dlg;
	dlg.Type("Image files","*.bmp *.png *.tif *.jpg");
	dlg.Type("Image: JPEG","*.jpg");
	dlg.Type("Image: Portable Nework Graphics","*.png");
	dlg.Type("Image: Tagged Image Format","*.tif");
	dlg.Type("Image: Windows Bitmap (24bit)","*.bmp");
	dlg.ActiveDir(GetCurrentDirectory());

	if(!dlg.ExecuteOpen("Open Image"))return;

	SetCurrentDirectory(dlg.GetActiveDir());

	String path = ~dlg;

	FileIn in(path);

	if(in.IsError())
	{
		String s = Format("Error opening image file %s",path);
		PromptOK(s);
		return;
	}

	One<StreamRaster> r = StreamRaster::OpenAny(in);

	if(!r)
	{
		String s = Format("Error opening streamraster file %s",path);
		PromptOK(s);
		return;
	}

	Layer* pLayer = new Layer;

	Size sz = GetSize();

	pLayer->m_img = r->GetImage();
	pLayer->m_rc.left = 0;
	pLayer->m_rc.right = 1;
	pLayer->m_rc.top = 0;
	pLayer->m_rc.bottom = 1;

	m_pLayers.Add(pLayer);
}
Exemple #13
0
void BaseSetupDlg::OnBrowseUpp()
{
    String s = ~upp;
    int b, e;
    if(upp.HasFocus())
        upp.GetSelection(b, e);
    else
        e = s.GetLength();
    b = e;
    while(b > 0 && s[b - 1] != ';')
        b--;
    while(e < s.GetLength() && s[e] != ';')
        e++;
    FileSel fsel;
    String pre = s.Left(b), post = s.Mid(e);
    fsel.ActiveDir(s.Mid(b, e - b));
    if(fsel.ExecuteSelectDir()) {
        String newdir = ~fsel;
        upp <<= pre + newdir + Nvl(post, ";");
        upp.SetWantFocus();
        OnUpp();
    }
}
// image selection callback
void XMLBarEditor::imageSelCb(void)
{
	static String lastPath = "";
	
	// opens a file selector, allows selection of some
	// kind of image formats
	FileSel fs;
	fs.ActiveDir(lastPath);
	fs.Type(t_("Image files"), "*.png,*.jpg,*.ico,*.bmp");
	if(!fs.ExecuteOpen(t_("Select icon file")))
		return;
	String path = fs.Get();
	lastPath = GetFileFolder(path);
	String ext = ToUpper(GetFileExt(path));
	Image img;
	if(ext != ".ICO")
		img = StreamRaster::LoadFileAny(path);
	else
	{
		String data = LoadFile(path);
		Vector<Image> imgVec;
		try
		{
		 	imgVec = ReadIcon(data);
		}
		catch(...)
		{
		}
		if(imgVec.GetCount())
			img = imgVec[0];
		else
			img = Null;
	}
	curIcon = img;
	itemPane.icon.SetImage(img);
	fieldsModCb();
}
/////////////////////////////////////////////////////////////////////////////////////
// create handler
void TPdfFrontend::onCreate(void)
{

	FileSel fs;
	
	// if no documents, just do nothing
	if(!Documents.GetCount())
		return;
	
	// first, gets last browsed path (if any)
	String cfgPath = GetPdfConfigPath() + "lastpath";
	if(FileExists(cfgPath))
	{
		FileIn f(cfgPath);
		fs.Set(f.GetLine());
	}
	
	// gets the output file name, returns if cancelled
	fs.DefaultExt(".pdf").Type("documenti pdf", "*.pdf");
	if(!fs.ExecuteSaveAs("Nome del documento pdf:"))
		return;

	// stores last active output path
	RealizeDirectory(GetPdfConfigPath());
	FileOut f(cfgPath);
	f.PutLine(fs.Get());

	// creates the command line and executes ghostscript
	String FileName = fs.Get();
    String args =
		"-q -dBATCH -dAutoFilterColorImages=false -sColorImageFilter=FlateEncode -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=\"" +
    	FileName + "\" \"" +
    	Documents[0] + "\"";
    for(int i = 1 ; i < Documents.GetCount(); i++)
    	args = args + " \"" + Documents[i] + "\"";
    String OutStr, ErrStr;
	bool res = SysExec("gs", args, Environment(), OutStr, ErrStr);

	// creates progress bar and hooks inside client
//	Progress progress("Creazione pdf in corso....");
//	Client.setProgress(progress);
//	progress.Create();
	
//	Client.setProgress(0);
//	if(progress.Canceled())
//		res = false;
	// if error, does nothing	
	if(!res)
		return;
	
	// clear collected documents
	ClearDocuments();
	
	// closes application
	Break(0);
	
} // END TPdfFrontend::onCreate()
Exemple #16
0
void AddressBook::Open()
{
	if(!fs.ExecuteOpen()) return;
	filename = fs;
	FileIn in(filename);
	if(!in) {
		Exclamation("Unable to open [* " + DeQtf(filename));
		return;
	}
	array.Clear();
	while(!in.IsEof()) {
		Vector<Value> q;
		for(int i = 0; i < 4; i++)
			q.Add(in.GetLine());
		array.Add(q);
	}
}
Exemple #17
0
FileSel& OutputFs()
{
	static FileSel *fsp;
	if(!fsp) {
		static FileSel fs;
		fs.AllFilesType();
		fs.Type("Various (*.log *.map *.ini *.sql)", "*.log *.map *.ini *.sql");
		fs.Type("Log files (*.log)", "*.log");
		fs.Type("Map files (*.map)", "*.map");
		fs.Type("Ini files (*.ini)", "*.ini");
		fs.Type("SQL scripts (*.sql)", "*.sql");
		IdeFs(fs);
		fsp = &fs;
	}
	fsp->Multi();
	return *fsp;
}
Exemple #18
0
void AddressBook::SaveAs()
{
	if(!fs.ExecuteSaveAs()) return;
	filename = fs;
	Save();
}
void bigmailer::DataPageImportCSV()
{
	FileSel fs ;
	fs.ActiveDir(ConfigFile("")) ;
	fs.Type("csv files", "*.csv") ;

	if ( ! fs.ExecuteOpen(t_("")) )
		return;

	csvResult csv ;
	if ( ! csv.ImportFrom(fs.Get()) )
		return ;


	WithcsvToDefLayout<TopWindow> dlg;
	CtrlLayout(dlg, "Import From CSV");
	for (int i = 0; i < csv.fields.GetCount(); i++)
	{
		dlg.dropName.Add( csv.fields[i] ) ;
		dlg.dropEmail.Add( csv.fields[i] ) ;
	}
	dlg.dropName.SetIndex(0) ;
	dlg.dropEmail.SetIndex(1) ;
	dlg.btOk.WhenAction = Breaker(IDOK) ;
	dlg.btCancel.WhenAction = Breaker( IDCANCEL ) ;
	if (dlg.Execute() == IDOK)
	{
		if (PromptOKCancel("Con esta operación se van a eliminar [* TODOS]") == IDOK)
		{
			// añadimos la cabecera
			theDefList.fields.Clear() ;
			theDefList.fields.Add( dlg.dropName.GetValue() ) ;
			theDefList.fields.Add( dlg.dropEmail.GetValue() ) ;

			for (int i = 0; i < csv.fields.GetCount(); i++)
			{
				String f = csv.fields[i] ;
				if (f != theDefList.fields[0] && f != theDefList.fields[1])
					theDefList.fields.Add(f) ;
			}


			theDefList.data.Clear() ;
			for (int i = 0; i < csv.values.GetCount(); i++) // para cada registro
			{
				Vector<String>& line = csv.values[i] ;
				Vector<String>& record = theDefList.data.Add() ;

				for (int j = 0; j < theDefList.fields.GetCount(); j++)
				{
					String fieldName = theDefList.fields[j] ;
					for (int k = 0; k < csv.fields.GetCount(); k++)
					{
						if (fieldName == csv.fields[k])
						{
							record.Add( line[k] ) ;
							break ;
						}
					}
				}
			}

			theDefList.Save() ;
			DataPageFill() ;

		}
	}

}
Exemple #20
0
void DlgSqlExport::Run(Sql& cursor, String command, String tablename)
{
	Title(Nvl(tablename, t_("SQL query")) + t_(" export"));
	object_name <<= tablename;
	if(!cursor.Execute(command)) {
		Exclamation(NFormat(t_("Error executing [* \1%s\1]: \1%s"), command, cursor.GetLastError()));
		return;
	}
	for(int i = 0; i < cursor.GetColumns(); i++) {
		const SqlColumnInfo& sci = cursor.GetColumnInfo(i);
		String type;
		switch(sci.valuetype) {
			case BOOL_V:
			case INT_V: type = t_("integer"); break;
			case DOUBLE_V: type = t_("real number"); break;
			case STRING_V:
			case WSTRING_V: type = t_("string"); break;
			case DATE_V: type = t_("date"); break;
			case TIME_V: type = t_("date/time"); break;
			case /*ORA_BLOB_V*/-1: type = t_("BLOB"); break;
			case /*ORA_CLOB_V*/-2: type = t_("CLOB"); break;
			default: type = FormatInt(sci.valuetype); break;
		}
		columns.Add(sci.name, sci.valuetype, sci.width, 1);
	}
	static String cfg;
	LoadFromString(*this, cfg);
	SyncUI();
	while(TopWindow::Run() == IDOK)
		try {
			String out_table = ~object_name;
			String delim;
			switch((int)~delimiters) {
				case DELIM_TAB: delim = "\t"; break;
				case DELIM_SEMICOLON: delim = ";"; break;
			}
			Vector<int> out;
			String colstr;
			String title;
			for(int i = 0; i < columns.GetCount(); i++)
				if(columns.Get(i, 3)) {
					out.Add(i);
					String cname = cursor.GetColumnInfo(i).name;
					colstr << (i ? ", " : "") << cname;
					if(i) title << delim;
					title << cname;
				}
			if(out.IsEmpty()) {
				throw Exc(t_("No columns selected!"));
				continue;
			}
			String rowbegin, rowend;
			int fmt = ~format;
			FileSel fsel;
			String ext;
			switch(fmt) {
				case FMT_TEXT: {
					rowend = "";
					ext = ".txt";
					fsel.Type(t_("Text files (*.txt)"), "*.txt");
					break;
				}
				case FMT_SQL: {
					if(identity_insert)
						rowbegin << "set identity_insert " << out_table << " on ";
					rowbegin << "insert into " << out_table << "(" << colstr << ") values (";
					rowend = ");";
					ext = ".sql";
					fsel.Type(t_("SQL scripts (*.sql)"), "*.sql");
					break;
				}
			}
			fsel.AllFilesType().DefaultExt(ext.Mid(1));
			if(!IsNull(recent_file))
				fsel <<= ForceExt(recent_file, ext);
			if(!fsel.ExecuteSaveAs(t_("Save export as")))
				continue;
			recent_file = ~fsel;
			FileOut fo;
			if(!fo.Open(recent_file)) {
				Exclamation(NFormat(t_("Error creating file [* \1%s\1]."), recent_file));
				continue;
			}
			if(fmt == FMT_TEXT)
				fo.PutLine(title);
			Progress progress(t_("Exporting row %d"));
			while(cursor.Fetch()) {
				String script = rowbegin;
				for(int i = 0; i < out.GetCount(); i++) {
					Value v = cursor[out[i]];
					switch(fmt) {
						case FMT_TEXT: {
							if(i)
								script.Cat(delim);
							if(IsString(v) && quote) {
								String s = v;
								script << '\"';
								for(const char *p = s, *e = s.End(); p < e; p++)
									if(*p == '\"')
										script.Cat("\"\"");
									else
										script.Cat(*p);
								script << '\"';
							}
							else
								script << StdFormat(v);
							break;
						}
						case FMT_SQL: {
							if(i) script.Cat(", ");
//							script << SqlCompile(SQLD_ORACLE, SqlFormat(v));
							break;
						}
					}
				}
				script << rowend;
				fo.PutLine(script);
/*
				if(autocommit && --left <= 0) {
					fo.PutLine("commit;");
					left = autocommit;
				}
*/
				if(progress.StepCanceled()) {
					Exclamation(t_("Export aborted!"));
					return;
				}
			}
			fo.Close();
			if(fo.IsError())
				throw Exc(NFormat(t_("Error writing file %s."), recent_file));
			break;
		}
		catch(Exc e) {
			ShowExc(e);
		}

	cfg = StoreAsString(*this);
}
Exemple #21
0
void SourceFs(FileSel& fs)
{
	fs.Type("C/C++ files (*.cpp *.h *.hpp *.c *.C *.cc *.cxx *.icpp)", "*.cpp *.h *.hpp *.c *.C *.cc *.cxx *.icpp");
	fs.Type("Diff/Patch files (*.diff *.patch)", "*.diff *.patch");
	fs.Type("Image files (*.iml)", "*.iml");
	fs.Type("Java files (*.java)", "*.java");
	fs.Type("Json files (*.json)", "*.json");
	fs.Type("Language files (*.lng)", "*.lng");
	fs.Type("Layout files (*.lay)", "*.lay");
	fs.Type("Python files (*.py *.pyc *.pyd *.pyo)", "*.py *.pyc *.pyd *.pyo");
	fs.Type("Web development files (*.html *.js *.css *.witz)", "*.html *.js *.css *.witz");
	fs.Type("Xml files (*.xml *.xsd)", "*.xml *.xsd");
	fs.Type("Other special files (*.sch *.usc *.rc *.brc *.upt)", "*.sch *.usc *.rc *.brc *.upt");
	String mask = "*.cpp *.h *.hpp *.c *.C *.cc *.cxx *.icpp *.diff *.patch *.lay *.py *.pyc *.pyd *.pyo *.iml *.java *.json *.lng *.sch *.usc *.rc *.brc *.upt *.html *.js *.css *.witz *.xml *.xsd *.qtf";
	fs.Type("All source files (" + mask + ")", mask);
	IdeFs(fs);
}