144 lines
3.1 KiB
ObjectPascal
144 lines
3.1 KiB
ObjectPascal
unit cfdgui;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Interfaces,
|
|
ExtCtrls, Menus, StdCtrls, Process;
|
|
|
|
type
|
|
|
|
{ Tmain }
|
|
|
|
Tmain = class(TForm)
|
|
genButton: TButton;
|
|
varEdit: TEdit;
|
|
img: TImage;
|
|
varLabel: TLabel;
|
|
Fmenu: TMenuItem;
|
|
openMenu: TMenuItem;
|
|
quitMenu: TMenuItem;
|
|
saveimgMenu: TMenuItem;
|
|
saveasMenu: TMenuItem;
|
|
saveMenu: TMenuItem;
|
|
openDiag: TOpenDialog;
|
|
saveDiag: TSaveDialog;
|
|
srcText: TMemo;
|
|
MMenu: TMainMenu;
|
|
GenMenu: TMenuItem;
|
|
procedure GenMenuClick(Sender: TObject);
|
|
procedure openMenuClick(Sender: TObject);
|
|
procedure quitMenuClick(Sender: TObject);
|
|
procedure saveimgMenuClick(Sender: TObject);
|
|
procedure saveasMenuClick(Sender: TObject);
|
|
procedure saveMenuClick(Sender: TObject);
|
|
procedure refresh;
|
|
procedure genButtonClick(Sender: TObject);
|
|
private
|
|
{ private declarations }
|
|
public
|
|
{ public declarations }
|
|
end;
|
|
|
|
var
|
|
main: Tmain;
|
|
tmpsrc: String = 'tmpsrc.cfdg';
|
|
tmpimg: String = 'tmpimg.png';
|
|
title: String = 'CFDG Gui';
|
|
exename: String = 'cfdg';
|
|
savename: String = '';
|
|
|
|
implementation
|
|
|
|
{ Tmain }
|
|
|
|
// Esta parte es la que controla al cfdg
|
|
procedure Tmain.refresh;
|
|
var
|
|
pro: TProcess;
|
|
begin
|
|
srcText.Lines.SaveToFile(tmpsrc);
|
|
pro := TProcess.Create(nil);
|
|
if (varEdit.Text='') then
|
|
pro.CommandLine := exename+' '+tmpsrc+' -o'+tmpimg
|
|
else
|
|
pro.CommandLine := exename+' -v'+varEdit.Text+' '+tmpsrc+' -o'+tmpimg;
|
|
|
|
pro.Options := pro.Options + [poWaitOnExit];
|
|
pro.Execute;
|
|
pro.Free;
|
|
if (img.tag = 1) then
|
|
img.Picture.Clear;
|
|
if (FileExists(tmpimg)) then begin
|
|
img.Picture.LoadFromFile(tmpimg);
|
|
img.tag:=1;
|
|
end else
|
|
img.tag:=0;
|
|
|
|
end;
|
|
|
|
procedure Tmain.GenMenuClick(Sender: TObject);
|
|
begin
|
|
refresh;
|
|
end;
|
|
|
|
procedure Tmain.openMenuClick(Sender: TObject);
|
|
begin
|
|
if (openDiag.Execute) then begin
|
|
savename := openDiag.FileName;
|
|
srcText.Lines.LoadFromFile(savename);
|
|
main.caption := title+' - ['+savename+']';
|
|
end;
|
|
end;
|
|
|
|
procedure Tmain.quitMenuClick(Sender: TObject);
|
|
begin
|
|
halt(0);
|
|
end;
|
|
|
|
procedure Tmain.saveimgMenuClick(Sender: TObject);
|
|
begin
|
|
if (img.tag = 1) then begin
|
|
if (saveDiag.Execute) then
|
|
img.Picture.SaveToFile(saveDiag.FileName,'png');
|
|
end;
|
|
end;
|
|
|
|
procedure Tmain.saveasMenuClick(Sender: TObject);
|
|
var
|
|
n_savename: String = '';
|
|
begin
|
|
if (saveDiag.Execute) then
|
|
n_savename := saveDiag.FileName;
|
|
if (n_savename <> '' ) then begin
|
|
savename := n_savename;
|
|
main.caption := title+' - ['+savename+']';
|
|
srcText.Lines.SaveToFile(savename);
|
|
end;
|
|
end;
|
|
|
|
procedure Tmain.saveMenuClick(Sender: TObject);
|
|
begin
|
|
if (savename = '') then begin
|
|
if (saveDiag.Execute) then
|
|
savename := saveDiag.FileName;
|
|
end;
|
|
if (savename <> '') then begin
|
|
srcText.Lines.SaveToFile(savename);
|
|
main.caption := title+' - ['+savename+']';
|
|
end;
|
|
end;
|
|
|
|
procedure Tmain.genButtonClick(Sender: TObject);
|
|
begin
|
|
refresh;
|
|
end;
|
|
|
|
initialization
|
|
{$I cfdgui.lrs}
|
|
|
|
end.
|
|
|