You've already forked lazarus-ccr
systools: Initial commit of Lazarus port of TurboPower SysTools (incomplete).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6140 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
86
components/systools/examples/expression/exexpr.lpi
Normal file
86
components/systools/examples/expression/exexpr.lpi
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<UseDefaultCompilerOptions Value="True"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="exexpr"/>
|
||||
<Scaled Value="True"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<XPManifest>
|
||||
<DpiAware Value="True"/>
|
||||
</XPManifest>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
<Modes Count="0"/>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="laz_systools"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="exexpr.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="ExExpr"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="exexpru.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="StDlg"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="ExExprU"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="exexpr"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
41
components/systools/examples/expression/exexpr.lpr
Normal file
41
components/systools/examples/expression/exexpr.lpr
Normal file
@@ -0,0 +1,41 @@
|
||||
(* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is TurboPower SysTools
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* TurboPower Software
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 1996-2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** *)
|
||||
|
||||
program ExExpr;
|
||||
|
||||
uses
|
||||
Forms, Interfaces, lclversion,
|
||||
ExExprU in 'ExExprU.pas' {StDlg};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
{$IF lcl_fullversion >= 1080000}
|
||||
Application.Scaled := True;
|
||||
{$ENDIF}
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TStDlg, StDlg);
|
||||
Application.Run;
|
||||
end.
|
477
components/systools/examples/expression/exexpru.lfm
Normal file
477
components/systools/examples/expression/exexpru.lfm
Normal file
@@ -0,0 +1,477 @@
|
||||
object StDlg: TStDlg
|
||||
Left = 693
|
||||
Height = 270
|
||||
Top = 379
|
||||
Width = 462
|
||||
BorderStyle = bsDialog
|
||||
Caption = 'Expression Evaluator (StExpr) Example'
|
||||
ClientHeight = 270
|
||||
ClientWidth = 462
|
||||
Color = clBtnFace
|
||||
Font.Color = clWindowText
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '1.9.0.0'
|
||||
object Label1: TLabel
|
||||
Left = 16
|
||||
Height = 15
|
||||
Top = 16
|
||||
Width = 128
|
||||
Caption = 'Expression to evaluate:'
|
||||
Font.Color = clWindowText
|
||||
Font.Style = [fsBold]
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 16
|
||||
Height = 15
|
||||
Top = 63
|
||||
Width = 38
|
||||
Caption = 'Result:'
|
||||
Font.Color = clWindowText
|
||||
Font.Style = [fsBold]
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 204
|
||||
Height = 141
|
||||
Top = 112
|
||||
Width = 165
|
||||
BevelOuter = bvLowered
|
||||
ClientHeight = 141
|
||||
ClientWidth = 165
|
||||
TabOrder = 4
|
||||
object DivBtn: TBitBtn
|
||||
Left = 123
|
||||
Height = 28
|
||||
Top = 9
|
||||
Width = 35
|
||||
Caption = '/'
|
||||
Font.Color = clRed
|
||||
OnClick = DivBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 15
|
||||
end
|
||||
object MulBtn: TBitBtn
|
||||
Left = 123
|
||||
Height = 28
|
||||
Top = 42
|
||||
Width = 35
|
||||
Caption = '*'
|
||||
Font.Color = clRed
|
||||
OnClick = MulBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 14
|
||||
end
|
||||
object MinusBtn: TBitBtn
|
||||
Left = 123
|
||||
Height = 28
|
||||
Top = 74
|
||||
Width = 35
|
||||
Caption = '-'
|
||||
Font.Color = clRed
|
||||
OnClick = MinusBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 13
|
||||
end
|
||||
object PlusBtn: TBitBtn
|
||||
Left = 123
|
||||
Height = 28
|
||||
Top = 107
|
||||
Width = 35
|
||||
Caption = '+'
|
||||
Font.Color = clRed
|
||||
OnClick = PlusBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 12
|
||||
end
|
||||
object EBtn: TBitBtn
|
||||
Left = 45
|
||||
Height = 28
|
||||
Top = 107
|
||||
Width = 35
|
||||
Caption = 'E'
|
||||
Font.Color = clBlue
|
||||
OnClick = EBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 11
|
||||
end
|
||||
object Nr3Btn: TBitBtn
|
||||
Left = 84
|
||||
Height = 28
|
||||
Top = 74
|
||||
Width = 35
|
||||
Caption = '3'
|
||||
Font.Color = clBlue
|
||||
OnClick = Nr3BtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 3
|
||||
end
|
||||
object Nr6Btn: TBitBtn
|
||||
Left = 84
|
||||
Height = 28
|
||||
Top = 42
|
||||
Width = 35
|
||||
Caption = '6'
|
||||
Font.Color = clBlue
|
||||
OnClick = Nr6BtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 6
|
||||
end
|
||||
object Nr9Btn: TBitBtn
|
||||
Left = 84
|
||||
Height = 28
|
||||
Top = 9
|
||||
Width = 35
|
||||
Caption = '9'
|
||||
Font.Color = clBlue
|
||||
OnClick = Nr9BtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 9
|
||||
end
|
||||
object DotBtn: TBitBtn
|
||||
Left = 84
|
||||
Height = 28
|
||||
Top = 107
|
||||
Width = 35
|
||||
Caption = '.'
|
||||
Font.Color = clBlue
|
||||
OnClick = DotBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 10
|
||||
end
|
||||
object Nr2Btn: TBitBtn
|
||||
Left = 45
|
||||
Height = 28
|
||||
Top = 74
|
||||
Width = 35
|
||||
Caption = '2'
|
||||
Font.Color = clBlue
|
||||
OnClick = Nr2BtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object Nr5Btn: TBitBtn
|
||||
Left = 45
|
||||
Height = 28
|
||||
Top = 42
|
||||
Width = 35
|
||||
Caption = '5'
|
||||
Font.Color = clBlue
|
||||
OnClick = Nr5BtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 5
|
||||
end
|
||||
object Nr8Btn: TBitBtn
|
||||
Left = 45
|
||||
Height = 28
|
||||
Top = 9
|
||||
Width = 35
|
||||
Caption = '8'
|
||||
Font.Color = clBlue
|
||||
OnClick = Nr8BtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 8
|
||||
end
|
||||
object Nr0Btn: TBitBtn
|
||||
Left = 6
|
||||
Height = 28
|
||||
Top = 107
|
||||
Width = 35
|
||||
Caption = '0'
|
||||
Font.Color = clBlue
|
||||
OnClick = Nr0BtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 0
|
||||
end
|
||||
object Nr1Btn: TBitBtn
|
||||
Left = 6
|
||||
Height = 28
|
||||
Top = 74
|
||||
Width = 35
|
||||
Caption = '1'
|
||||
Font.Color = clBlue
|
||||
OnClick = Nr1BtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object Nr4Btn: TBitBtn
|
||||
Left = 6
|
||||
Height = 28
|
||||
Top = 42
|
||||
Width = 35
|
||||
Caption = '4'
|
||||
Font.Color = clBlue
|
||||
OnClick = Nr4BtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 4
|
||||
end
|
||||
object Nr7Btn: TBitBtn
|
||||
Left = 6
|
||||
Height = 28
|
||||
Top = 9
|
||||
Width = 35
|
||||
Caption = '7'
|
||||
Font.Color = clBlue
|
||||
OnClick = Nr7BtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 7
|
||||
end
|
||||
end
|
||||
object Panel1: TPanel
|
||||
Left = 24
|
||||
Height = 141
|
||||
Top = 112
|
||||
Width = 169
|
||||
BevelOuter = bvLowered
|
||||
ClientHeight = 141
|
||||
ClientWidth = 169
|
||||
TabOrder = 5
|
||||
object SqrtBtn: TBitBtn
|
||||
Left = 48
|
||||
Height = 28
|
||||
Top = 106
|
||||
Width = 35
|
||||
Caption = 'sqrt'
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = SqrtBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 9
|
||||
end
|
||||
object PiBtn: TBitBtn
|
||||
Left = 9
|
||||
Height = 28
|
||||
Top = 9
|
||||
Width = 35
|
||||
Caption = 'pi'
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = PiBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 15
|
||||
end
|
||||
object ExpBtn: TBitBtn
|
||||
Left = 87
|
||||
Height = 28
|
||||
Top = 74
|
||||
Width = 35
|
||||
Caption = 'Exp'
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = ExpBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 7
|
||||
end
|
||||
object PowerBtn: TBitBtn
|
||||
Left = 48
|
||||
Height = 28
|
||||
Top = 41
|
||||
Width = 35
|
||||
Caption = '^'
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = PowerBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 11
|
||||
end
|
||||
object CommaBtn: TBitBtn
|
||||
Left = 126
|
||||
Height = 28
|
||||
Top = 9
|
||||
Width = 35
|
||||
Caption = ','
|
||||
Enabled = False
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = CommaBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object CosBtn: TBitBtn
|
||||
Left = 9
|
||||
Height = 28
|
||||
Top = 73
|
||||
Width = 35
|
||||
Caption = 'cos'
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = CosBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 13
|
||||
end
|
||||
object LnBtn: TBitBtn
|
||||
Left = 87
|
||||
Height = 28
|
||||
Top = 42
|
||||
Width = 35
|
||||
Caption = 'ln'
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = LnBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 8
|
||||
end
|
||||
object SqrBtn: TBitBtn
|
||||
Left = 48
|
||||
Height = 28
|
||||
Top = 74
|
||||
Width = 35
|
||||
Caption = 'sqr'
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = SqrBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 10
|
||||
end
|
||||
object RParBtn: TBitBtn
|
||||
Left = 87
|
||||
Height = 28
|
||||
Top = 9
|
||||
Width = 35
|
||||
Caption = ')'
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = RParBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object ArctanBtn: TBitBtn
|
||||
Left = 9
|
||||
Height = 28
|
||||
Top = 106
|
||||
Width = 35
|
||||
Caption = 'arctan'
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = ArctanBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 12
|
||||
end
|
||||
object IntBtn: TBitBtn
|
||||
Left = 126
|
||||
Height = 28
|
||||
Top = 106
|
||||
Width = 35
|
||||
Caption = 'int'
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = IntBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 3
|
||||
end
|
||||
object SinBtn: TBitBtn
|
||||
Left = 9
|
||||
Height = 28
|
||||
Top = 41
|
||||
Width = 35
|
||||
Caption = 'sin'
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = SinBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 14
|
||||
end
|
||||
object LParBtn: TBitBtn
|
||||
Left = 48
|
||||
Height = 28
|
||||
Top = 9
|
||||
Width = 35
|
||||
Caption = '('
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = LParBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 0
|
||||
end
|
||||
object AbsBtn: TBitBtn
|
||||
Left = 87
|
||||
Height = 28
|
||||
Top = 106
|
||||
Width = 35
|
||||
Caption = 'abs'
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = AbsBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 6
|
||||
end
|
||||
object FracBtn: TBitBtn
|
||||
Left = 126
|
||||
Height = 28
|
||||
Top = 74
|
||||
Width = 35
|
||||
Caption = 'frac'
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = FracBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 4
|
||||
end
|
||||
object RoundBtn: TBitBtn
|
||||
Left = 126
|
||||
Height = 28
|
||||
Top = 41
|
||||
Width = 35
|
||||
Caption = 'round'
|
||||
Font.Color = clFuchsia
|
||||
Font.Height = -11
|
||||
OnClick = RoundBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
||||
object ResultEdit: TEdit
|
||||
Left = 16
|
||||
Height = 23
|
||||
Top = 79
|
||||
Width = 432
|
||||
Color = clBtnFace
|
||||
ReadOnly = True
|
||||
TabStop = False
|
||||
TabOrder = 6
|
||||
end
|
||||
object EvaluateBtn: TBitBtn
|
||||
Left = 380
|
||||
Height = 25
|
||||
Top = 116
|
||||
Width = 65
|
||||
Caption = 'Evaluate'
|
||||
Default = True
|
||||
Font.Color = clMaroon
|
||||
OnClick = EvaluateBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object ClearBtn: TBitBtn
|
||||
Left = 380
|
||||
Height = 25
|
||||
Top = 148
|
||||
Width = 65
|
||||
Caption = 'Clear'
|
||||
Font.Color = clMaroon
|
||||
OnClick = ClearBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object ExprEdit: TStExpressionEdit
|
||||
Left = 16
|
||||
Height = 23
|
||||
Top = 32
|
||||
Width = 433
|
||||
TabOrder = 0
|
||||
OnError = ExprEditError
|
||||
end
|
||||
object BSBtn: TBitBtn
|
||||
Left = 380
|
||||
Height = 25
|
||||
Top = 180
|
||||
Width = 65
|
||||
Caption = 'Backspace'
|
||||
Font.Color = clMaroon
|
||||
OnClick = BSBtnClick
|
||||
ParentFont = False
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
368
components/systools/examples/expression/exexpru.pas
Normal file
368
components/systools/examples/expression/exexpru.pas
Normal file
@@ -0,0 +1,368 @@
|
||||
(* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is TurboPower SysTools
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* TurboPower Software
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 1996-2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** *)
|
||||
|
||||
{$mode delphi}
|
||||
|
||||
unit ExExprU;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF FPC}
|
||||
// LCLIntf, LCLType, LMessages,
|
||||
{$ELSE}
|
||||
Windows, Messages,
|
||||
{$ENDIF}
|
||||
SysUtils, Classes, Graphics, Controls,
|
||||
Forms, Dialogs, ExtCtrls, Buttons, StdCtrls,
|
||||
|
||||
StBase, StConst, StExpr;
|
||||
|
||||
type
|
||||
TStDlg = class(TForm)
|
||||
Label1: TLabel;
|
||||
ResultEdit: TEdit;
|
||||
Label2: TLabel;
|
||||
EvaluateBtn: TBitBtn;
|
||||
ClearBtn: TBitBtn;
|
||||
Panel1: TPanel;
|
||||
Panel2: TPanel;
|
||||
ExprEdit: TStExpressionEdit;
|
||||
DivBtn: TBitBtn;
|
||||
MulBtn: TBitBtn;
|
||||
MinusBtn: TBitBtn;
|
||||
PlusBtn: TBitBtn;
|
||||
EBtn: TBitBtn;
|
||||
Nr3Btn: TBitBtn;
|
||||
Nr6Btn: TBitBtn;
|
||||
Nr9Btn: TBitBtn;
|
||||
DotBtn: TBitBtn;
|
||||
Nr2Btn: TBitBtn;
|
||||
Nr5Btn: TBitBtn;
|
||||
Nr8Btn: TBitBtn;
|
||||
Nr0Btn: TBitBtn;
|
||||
Nr1Btn: TBitBtn;
|
||||
Nr4Btn: TBitBtn;
|
||||
Nr7Btn: TBitBtn;
|
||||
SqrtBtn: TBitBtn;
|
||||
PiBtn: TBitBtn;
|
||||
ExpBtn: TBitBtn;
|
||||
PowerBtn: TBitBtn;
|
||||
CommaBtn: TBitBtn;
|
||||
CosBtn: TBitBtn;
|
||||
LnBtn: TBitBtn;
|
||||
SqrBtn: TBitBtn;
|
||||
RParBtn: TBitBtn;
|
||||
ArctanBtn: TBitBtn;
|
||||
IntBtn: TBitBtn;
|
||||
SinBtn: TBitBtn;
|
||||
LParBtn: TBitBtn;
|
||||
AbsBtn: TBitBtn;
|
||||
FracBtn: TBitBtn;
|
||||
RoundBtn: TBitBtn;
|
||||
BSBtn: TBitBtn;
|
||||
procedure LParBtnClick(Sender: TObject);
|
||||
procedure RParBtnClick(Sender: TObject);
|
||||
procedure CommaBtnClick(Sender: TObject);
|
||||
procedure PowerBtnClick(Sender: TObject);
|
||||
procedure AbsBtnClick(Sender: TObject);
|
||||
procedure ArctanBtnClick(Sender: TObject);
|
||||
procedure CosBtnClick(Sender: TObject);
|
||||
procedure ExpBtnClick(Sender: TObject);
|
||||
procedure FracBtnClick(Sender: TObject);
|
||||
procedure IntBtnClick(Sender: TObject);
|
||||
procedure LnBtnClick(Sender: TObject);
|
||||
procedure PiBtnClick(Sender: TObject);
|
||||
procedure RoundBtnClick(Sender: TObject);
|
||||
procedure SinBtnClick(Sender: TObject);
|
||||
procedure SqrBtnClick(Sender: TObject);
|
||||
procedure SqrtBtnClick(Sender: TObject);
|
||||
procedure Nr0BtnClick(Sender: TObject);
|
||||
procedure Nr1BtnClick(Sender: TObject);
|
||||
procedure Nr2BtnClick(Sender: TObject);
|
||||
procedure Nr3BtnClick(Sender: TObject);
|
||||
procedure Nr4BtnClick(Sender: TObject);
|
||||
procedure Nr5BtnClick(Sender: TObject);
|
||||
procedure Nr6BtnClick(Sender: TObject);
|
||||
procedure Nr7BtnClick(Sender: TObject);
|
||||
procedure Nr8BtnClick(Sender: TObject);
|
||||
procedure Nr9BtnClick(Sender: TObject);
|
||||
procedure DotBtnClick(Sender: TObject);
|
||||
procedure EBtnClick(Sender: TObject);
|
||||
procedure PlusBtnClick(Sender: TObject);
|
||||
procedure MinusBtnClick(Sender: TObject);
|
||||
procedure MulBtnClick(Sender: TObject);
|
||||
procedure DivBtnClick(Sender: TObject);
|
||||
procedure EvaluateBtnClick(Sender: TObject);
|
||||
procedure ClearBtnClick(Sender: TObject);
|
||||
procedure ExprEditError(Sender: TObject; ErrorNumber: Longint;
|
||||
const ErrorStr: String);
|
||||
procedure BSBtnClick(Sender: TObject);
|
||||
private
|
||||
procedure AddExpr(Add : string; Parens : Boolean);
|
||||
end;
|
||||
|
||||
var
|
||||
StDlg: TStDlg;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
procedure TStDlg.AddExpr(add : string; parens : boolean);
|
||||
var
|
||||
position, sellen : integer;
|
||||
temp : string;
|
||||
begin
|
||||
position := ExprEdit.SelStart+1;
|
||||
sellen := ExprEdit.SelLength;
|
||||
temp := ExprEdit.Text;
|
||||
|
||||
if (parens) then begin
|
||||
add := add+'(';
|
||||
if (sellen > 0) then
|
||||
{surround the selection with the parentheses}
|
||||
insert(')', temp, position+sellen)
|
||||
else
|
||||
add := add+')';
|
||||
end;
|
||||
insert(add, temp, position);
|
||||
|
||||
ExprEdit.Text := temp;
|
||||
ExprEdit.SetFocus;
|
||||
|
||||
if (parens) then begin
|
||||
if (sellen > 0) then
|
||||
{position after the add}
|
||||
ExprEdit.SelStart := position+sellen+length(add)
|
||||
else
|
||||
{position before last parenthesis}
|
||||
ExprEdit.SelStart := position+length(add)-2;
|
||||
end else
|
||||
{position after the add}
|
||||
ExprEdit.SelStart := position+length(add)-1;
|
||||
ExprEdit.SelLength := 0;
|
||||
end;
|
||||
|
||||
procedure TStDlg.LParBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('(', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.RParBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr(')', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.CommaBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr(ListSeparator, False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.PowerBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('^', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.AbsBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('abs', True);
|
||||
end;
|
||||
|
||||
procedure TStDlg.ArctanBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('arctan', True);
|
||||
end;
|
||||
|
||||
procedure TStDlg.CosBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('cos', True);
|
||||
end;
|
||||
|
||||
procedure TStDlg.ExpBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('exp', True);
|
||||
end;
|
||||
|
||||
procedure TStDlg.FracBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('frac', True);
|
||||
end;
|
||||
|
||||
procedure TStDlg.IntBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('int', True);
|
||||
end;
|
||||
|
||||
procedure TStDlg.LnBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('ln', True);
|
||||
end;
|
||||
|
||||
procedure TStDlg.PiBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('pi', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.RoundBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('round', True);
|
||||
end;
|
||||
|
||||
procedure TStDlg.SinBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('sin', True);
|
||||
end;
|
||||
|
||||
procedure TStDlg.SqrBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('sqr', True);
|
||||
end;
|
||||
|
||||
procedure TStDlg.SqrtBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('sqrt', True);
|
||||
end;
|
||||
|
||||
procedure TStDlg.Nr0BtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('0', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.Nr1BtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('1', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.Nr2BtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('2', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.Nr3BtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('3', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.Nr4BtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('4', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.Nr5BtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('5', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.Nr6BtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('6', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.Nr7BtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('7', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.Nr8BtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('8', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.Nr9BtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('9', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.DotBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr(DecimalSeparator, False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.EBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('E', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.PlusBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('+', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.MinusBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('-', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.MulBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('*', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.DivBtnClick(Sender: TObject);
|
||||
begin
|
||||
AddExpr('/', False);
|
||||
end;
|
||||
|
||||
procedure TStDlg.EvaluateBtnClick(Sender: TObject);
|
||||
var
|
||||
res : double;
|
||||
begin
|
||||
res := ExprEdit.Evaluate;
|
||||
if ExprEdit.Expr.LastError = 0 then
|
||||
ResultEdit.Text := FloatToStr(res);
|
||||
ExprEdit.SetFocus;
|
||||
end;
|
||||
|
||||
procedure TStDlg.ClearBtnClick(Sender: TObject);
|
||||
begin
|
||||
ExprEdit.Text := '';
|
||||
ResultEdit.Text := '';
|
||||
ExprEdit.SetFocus;
|
||||
end;
|
||||
|
||||
procedure TStDlg.ExprEditError(Sender: TObject; ErrorNumber: Longint;
|
||||
const ErrorStr: String);
|
||||
begin
|
||||
ResultEdit.Text := 'Error ' + IntToStr(ErrorNumber) + ': ' + ErrorStr;
|
||||
end;
|
||||
|
||||
procedure TStDlg.BSBtnClick(Sender: TObject);
|
||||
var
|
||||
s: String;
|
||||
p: Integer;
|
||||
begin
|
||||
s := ExprEdit.Text;
|
||||
p := ExprEdit.CaretPos.X;
|
||||
Delete(s, p, 1);
|
||||
ExprEdit.Text := s;
|
||||
ExprEdit.SetFocus;
|
||||
if p = 0 then
|
||||
Expredit.SelStart := 0
|
||||
else
|
||||
ExprEdit.SelStart := p - 1;
|
||||
end;
|
||||
|
||||
end.
|
Reference in New Issue
Block a user