1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
unit lr_expres;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
Buttons, ExtCtrls, ButtonPanel, SynEdit, LR_Const;
type
{ TlrExpresionEditorForm }
TlrExpresionEditorForm = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
Button1: TButton;
Button10: TButton;
Button11: TButton;
Button12: TButton;
Button13: TButton;
Button14: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
ButtonPanel1: TButtonPanel;
GroupBox1: TGroupBox;
Label1: TLabel;
Panel1: TPanel;
Memo1: TSynEdit;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure Button13Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
procedure AddWord(S:string);
public
function ResultExpresion:string;
end;
implementation
{$R *.lfm}
uses LR_Var, LR_Flds, lr_funct_editor_unit, lr_funct_editor_unit1, LR_Class;
{ TlrExpresionEditorForm }
procedure TlrExpresionEditorForm.Button13Click(Sender: TObject);
begin
AddWord((Sender as TButton).Caption);
end;
procedure TlrExpresionEditorForm.FormCreate(Sender: TObject);
begin
Caption := sInsertExpression;
Label1.Caption := sVar2;
GroupBox1.Caption := sInsert;
BitBtn3.Caption := sDBField;
BitBtn2.Caption := sVariable;
BitBtn1.Caption := sEditorFormFunction;
end;
procedure TlrExpresionEditorForm.BitBtn2Click(Sender: TObject);
begin
frVarForm := TfrVarForm.Create(nil);
try
with frVarForm do
if ShowModal = mrOk then
begin
if SelectedItem <> '' then
AddWord('[' + SelectedItem + ']');
end;
finally
frVarForm.Free;
end;
end;
procedure TlrExpresionEditorForm.BitBtn1Click(Sender: TObject);
var
LR_FunctEditorForm: TLR_FunctEditorForm;
FD:TfrFunctionDescription;
LR_FunctEditor1Form: TLR_FunctEditor1Form;
begin
FD:=nil;
LR_FunctEditorForm:=TLR_FunctEditorForm.Create(Application);
try
if LR_FunctEditorForm.ShowModal = mrOk then
FD:=LR_FunctEditorForm.CurentFunctionDescription;
finally
LR_FunctEditorForm.Free;
end;
if Assigned(FD) then
begin
LR_FunctEditor1Form:=TLR_FunctEditor1Form.Create(Application);
try
LR_FunctEditor1Form.SetFunctionDescription(FD);
if LR_FunctEditor1Form.ShowModal = mrOk then
AddWord(LR_FunctEditor1Form.ResultText);
finally
LR_FunctEditor1Form.Free;
end;
end;
end;
procedure TlrExpresionEditorForm.BitBtn3Click(Sender: TObject);
begin
frFieldsForm := TfrFieldsForm.Create(nil);
try
with frFieldsForm do
begin
if ShowModal = mrOk then
begin
if DBField <> '' then
AddWord('[' + DBField + ']');
end;
end;
finally
frFieldsForm.Free;
end;
end;
procedure TlrExpresionEditorForm.AddWord(S: string);
begin
if Memo1.Lines.Count = 0 then
Memo1.Lines.Add(S)
else
begin
Memo1.Lines[Memo1.Lines.Count-1]:=Memo1.Lines[Memo1.Lines.Count-1] + S;
end;
Memo1.CaretY:=Memo1.Lines.Count-1;
Memo1.CaretX:=Length(Memo1.Lines[Memo1.Lines.Count-1])+1;
Memo1.SetFocus;
end;
function TlrExpresionEditorForm.ResultExpresion: string;
begin
Result:=Trim(Memo1.Text);
end;
end.
|