├── package ├── Delphi7 │ └── .gitignore ├── Delphi2007 │ └── .gitignore ├── Delphi2009 │ └── .gitignore ├── QDSEquationsD7.dpk ├── QDSEquationsD2009.dpk ├── QDSEquationsD2007.dpk ├── qdsequationslaz.lpk ├── QDSEquationsD7.dof ├── QDSEquationsD2007.dproj └── QDSEquationsD2009.dproj ├── docs ├── snapshot.PNG ├── EquationsModel.mpb └── classes ├── resources ├── localize.rc ├── images │ ├── 00.bmp │ ├── 01.bmp │ ├── 02.bmp │ ├── 03.bmp │ ├── 04.bmp │ ├── 05.bmp │ ├── 06.bmp │ ├── 07.bmp │ ├── 08.bmp │ ├── 09.bmp │ ├── 10.bmp │ ├── 11.bmp │ ├── 12.bmp │ ├── 13.bmp │ ├── 14.bmp │ ├── 15.bmp │ ├── 16.bmp │ ├── 17.bmp │ ├── 18.bmp │ ├── 19.bmp │ ├── bann.gif │ ├── logoext.bmp │ ├── TQDSEQUATION.BMP │ ├── TSELECTEQUATION.BMP │ └── TSELECTEQUATION32.bmp ├── QDSEquations.rc ├── cmpres.cmd ├── cmpres_windres.cmd └── images.rc ├── .gitignore ├── demo ├── QDSEqDemo.dpr ├── QDSEqDemo.lpi ├── main.pas ├── main.dfm ├── QDSEqDemo2007.dproj ├── main.lfm └── QDSEqDemo2009.dproj ├── release.cmd ├── README.md └── source ├── UsefulUtils.pas ├── SelectEquation.pas └── Equations.pas /package/Delphi7/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /package/Delphi2007/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /package/Delphi2009/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/snapshot.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/docs/snapshot.PNG -------------------------------------------------------------------------------- /resources/localize.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/localize.rc -------------------------------------------------------------------------------- /docs/EquationsModel.mpb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/docs/EquationsModel.mpb -------------------------------------------------------------------------------- /resources/images/00.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/00.bmp -------------------------------------------------------------------------------- /resources/images/01.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/01.bmp -------------------------------------------------------------------------------- /resources/images/02.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/02.bmp -------------------------------------------------------------------------------- /resources/images/03.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/03.bmp -------------------------------------------------------------------------------- /resources/images/04.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/04.bmp -------------------------------------------------------------------------------- /resources/images/05.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/05.bmp -------------------------------------------------------------------------------- /resources/images/06.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/06.bmp -------------------------------------------------------------------------------- /resources/images/07.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/07.bmp -------------------------------------------------------------------------------- /resources/images/08.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/08.bmp -------------------------------------------------------------------------------- /resources/images/09.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/09.bmp -------------------------------------------------------------------------------- /resources/images/10.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/10.bmp -------------------------------------------------------------------------------- /resources/images/11.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/11.bmp -------------------------------------------------------------------------------- /resources/images/12.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/12.bmp -------------------------------------------------------------------------------- /resources/images/13.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/13.bmp -------------------------------------------------------------------------------- /resources/images/14.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/14.bmp -------------------------------------------------------------------------------- /resources/images/15.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/15.bmp -------------------------------------------------------------------------------- /resources/images/16.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/16.bmp -------------------------------------------------------------------------------- /resources/images/17.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/17.bmp -------------------------------------------------------------------------------- /resources/images/18.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/18.bmp -------------------------------------------------------------------------------- /resources/images/19.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/19.bmp -------------------------------------------------------------------------------- /resources/images/bann.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/bann.gif -------------------------------------------------------------------------------- /resources/images/logoext.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/logoext.bmp -------------------------------------------------------------------------------- /resources/QDSEquations.rc: -------------------------------------------------------------------------------- 1 | TQDSEQUATION BITMAP images\TQDSEQUATION.BMP 2 | TSELECTEQUATION BITMAP images\TSELECTEQUATION.BMP -------------------------------------------------------------------------------- /resources/images/TQDSEQUATION.BMP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/TQDSEQUATION.BMP -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.~bpl 2 | *.~ddp 3 | *.~dfm 4 | *.~dpr 5 | *.~pas 6 | *.bpl 7 | *.dcp 8 | *.dcr 9 | *.dcu 10 | *.exe 11 | -------------------------------------------------------------------------------- /resources/images/TSELECTEQUATION.BMP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/TSELECTEQUATION.BMP -------------------------------------------------------------------------------- /resources/images/TSELECTEQUATION32.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karser/QDSEquations/HEAD/resources/images/TSELECTEQUATION32.bmp -------------------------------------------------------------------------------- /resources/cmpres.cmd: -------------------------------------------------------------------------------- 1 | brcc32 images.rc -fo images.res 2 | brcc32 localize.rc -fo localize.res 3 | brcc32 QDSEquations.rc -fo QDSEquations.dcr 4 | pause -------------------------------------------------------------------------------- /resources/cmpres_windres.cmd: -------------------------------------------------------------------------------- 1 | windres -i images.rc -o images.res 2 | windres -i localize.rc -o localize.res 3 | windres -i QDSEquations.rc -o QDSEquations.dcr 4 | pause 5 | -------------------------------------------------------------------------------- /demo/QDSEqDemo.dpr: -------------------------------------------------------------------------------- 1 | program QDSEqDemo; 2 | 3 | uses 4 | Forms, 5 | main in 'main.pas' {frmMain}, 6 | UsefulUtils in 'UsefulUtils.pas'; 7 | 8 | {$R *.res} 9 | 10 | begin 11 | Application.Initialize; 12 | Application.Title := 'QDS Eqations'; 13 | Application.CreateForm(TfrmMain, frmMain); 14 | Application.Run; 15 | end. 16 | -------------------------------------------------------------------------------- /resources/images.rc: -------------------------------------------------------------------------------- 1 | BT00 BITMAP images\00.bmp 2 | BT01 BITMAP images\01.bmp 3 | BT02 BITMAP images\02.bmp 4 | BT03 BITMAP images\03.bmp 5 | BT04 BITMAP images\04.bmp 6 | BT05 BITMAP images\05.bmp 7 | BT06 BITMAP images\06.bmp 8 | BT07 BITMAP images\07.bmp 9 | BT08 BITMAP images\08.bmp 10 | BT09 BITMAP images\09.bmp 11 | BT10 BITMAP images\10.bmp 12 | BT11 BITMAP images\11.bmp 13 | BT12 BITMAP images\12.bmp 14 | BT13 BITMAP images\13.bmp 15 | BT14 BITMAP images\14.bmp 16 | BT15 BITMAP images\15.bmp 17 | BT16 BITMAP images\16.bmp 18 | BT17 BITMAP images\17.bmp 19 | BT18 BITMAP images\18.bmp 20 | BT19 BITMAP images\19.bmp -------------------------------------------------------------------------------- /release.cmd: -------------------------------------------------------------------------------- 1 | set package=".\package" 2 | set demo=".\demo" 3 | set release=".\release" 4 | set releasefile=".\QDSEqations.zip" 5 | 6 | 7 | set exerar="C:\Program Files\WinRAR\Rar.exe" 8 | 9 | 10 | IF EXIST %release% ( 11 | DEL /Q %release%\*.* 12 | RMDIR /S /Q %release% 13 | ) 14 | 15 | MKDIR %release% 16 | MKDIR %release%\demo 17 | MKDIR %release%\package 18 | MKDIR %release%\package\Delphi7 19 | MKDIR %release%\package\Delphi2007 20 | MKDIR %release%\package\Delphi2009 21 | 22 | COPY %demo% %release%\demo 23 | 24 | COPY %package%\Delphi7 %release%\package\Delphi7 25 | COPY %package%\Delphi2007 %release%\package\Delphi2007 26 | COPY %package%\Delphi2009 %release%\package\Delphi2009 27 | 28 | DEL /Q %releasefile% 29 | 30 | %exerar% a -ep1 -r %releasefile% %release%\ 31 | 32 | 33 | 34 | pause 35 | -------------------------------------------------------------------------------- /package/QDSEquationsD7.dpk: -------------------------------------------------------------------------------- 1 | package QDSEquationsD7; 2 | 3 | {$R *.res} 4 | {$R 'QDSEquations.dcr'} 5 | {$ALIGN 8} 6 | {$ASSERTIONS ON} 7 | {$BOOLEVAL OFF} 8 | {$DEBUGINFO ON} 9 | {$EXTENDEDSYNTAX ON} 10 | {$IMPORTEDDATA ON} 11 | {$IOCHECKS ON} 12 | {$LOCALSYMBOLS ON} 13 | {$LONGSTRINGS ON} 14 | {$OPENSTRINGS ON} 15 | {$OPTIMIZATION ON} 16 | {$OVERFLOWCHECKS OFF} 17 | {$RANGECHECKS OFF} 18 | {$REFERENCEINFO ON} 19 | {$SAFEDIVIDE OFF} 20 | {$STACKFRAMES OFF} 21 | {$TYPEDADDRESS OFF} 22 | {$VARSTRINGCHECKS ON} 23 | {$WRITEABLECONST OFF} 24 | {$MINENUMSIZE 1} 25 | {$IMAGEBASE $400000} 26 | {$DESCRIPTION 'QDS Equations'} 27 | {$IMPLICITBUILD OFF} 28 | 29 | requires 30 | rtl, 31 | vcl; 32 | 33 | contains 34 | Equations in '..\Source\Equations.pas', 35 | SelectEquation in '..\Source\SelectEquation.pas', 36 | UsefulUtils in '..\Source\UsefulUtils.pas'; 37 | 38 | end. 39 | -------------------------------------------------------------------------------- /package/QDSEquationsD2009.dpk: -------------------------------------------------------------------------------- 1 | package QDSEquationsD2009; 2 | 3 | {$R *.res} 4 | {$R 'QDSEquations.dcr'} 5 | {$ALIGN 8} 6 | {$ASSERTIONS ON} 7 | {$BOOLEVAL OFF} 8 | {$DEBUGINFO ON} 9 | {$EXTENDEDSYNTAX ON} 10 | {$IMPORTEDDATA ON} 11 | {$IOCHECKS ON} 12 | {$LOCALSYMBOLS ON} 13 | {$LONGSTRINGS ON} 14 | {$OPENSTRINGS ON} 15 | {$OPTIMIZATION ON} 16 | {$OVERFLOWCHECKS OFF} 17 | {$RANGECHECKS OFF} 18 | {$REFERENCEINFO ON} 19 | {$SAFEDIVIDE OFF} 20 | {$STACKFRAMES OFF} 21 | {$TYPEDADDRESS OFF} 22 | {$VARSTRINGCHECKS ON} 23 | {$WRITEABLECONST OFF} 24 | {$MINENUMSIZE 1} 25 | {$IMAGEBASE $400000} 26 | {$DESCRIPTION 'QDS Equations'} 27 | {$IMPLICITBUILD OFF} 28 | 29 | requires 30 | rtl, 31 | vcl; 32 | 33 | contains 34 | Equations in '..\Source\Equations.pas', 35 | SelectEquation in '..\Source\SelectEquation.pas', 36 | UsefulUtils in '..\Source\UsefulUtils.pas'; 37 | 38 | end. 39 | 40 | -------------------------------------------------------------------------------- /package/QDSEquationsD2007.dpk: -------------------------------------------------------------------------------- 1 | package QDSEquationsD2007; 2 | 3 | {$R *.res} 4 | {$R 'QDSEquations.dcr'} 5 | {$ALIGN 8} 6 | {$ASSERTIONS ON} 7 | {$BOOLEVAL OFF} 8 | {$DEBUGINFO OFF} 9 | {$EXTENDEDSYNTAX ON} 10 | {$IMPORTEDDATA ON} 11 | {$IOCHECKS ON} 12 | {$LOCALSYMBOLS OFF} 13 | {$LONGSTRINGS ON} 14 | {$OPENSTRINGS ON} 15 | {$OPTIMIZATION ON} 16 | {$OVERFLOWCHECKS OFF} 17 | {$RANGECHECKS OFF} 18 | {$REFERENCEINFO OFF} 19 | {$SAFEDIVIDE OFF} 20 | {$STACKFRAMES OFF} 21 | {$TYPEDADDRESS OFF} 22 | {$VARSTRINGCHECKS ON} 23 | {$WRITEABLECONST OFF} 24 | {$MINENUMSIZE 1} 25 | {$IMAGEBASE $400000} 26 | {$DESCRIPTION 'QDS Equations'} 27 | {$IMPLICITBUILD OFF} 28 | {$DEFINE RELEASE} 29 | 30 | requires 31 | rtl, 32 | vcl; 33 | 34 | contains 35 | Equations in '..\Source\Equations.pas', 36 | SelectEquation in '..\Source\SelectEquation.pas', 37 | UsefulUtils in '..\Source\UsefulUtils.pas'; 38 | 39 | end. 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | QDSEquations 2 | ============ 3 | 4 | Delphi component equation editor that allow you to enter and display math formulas of any complexity, from simple Greek symbols to matrixes and complex integral expressions. 5 | You can use the equation editor in your projects written in the Delphi environment, for example, in programs testing knowledge of different mathematics fields (mathematical analysis, discrete mathematics, probability theory and so on), physics and other. 6 | 7 | It’s quite easy to enter formulas in it: 8 | * simple symbols are entered similarly to entering data in a text field 9 | * special symbols and formula elements are entered with the help of an additional menu 10 | 11 | ![Qds Equations](docs/snapshot.PNG) 12 | 13 | 14 | ## How to compile resources 15 | 16 | - If you have Delphi installed (brcc32) just run `cmpres.cmd` in resources folder. 17 | - For Lazarus run `cmpres_windres.cmd`. In requires `windres` which can be obtained by [installing MinGW](https://sourceforge.net/projects/mingw-w64/) and selecting `mingw32-base`. 18 | 19 | Contributions Welcome! 20 | -------------------------------------------------------------------------------- /package/qdsequationslaz.lpk: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /source/UsefulUtils.pas: -------------------------------------------------------------------------------- 1 | unit UsefulUtils; 2 | 3 | interface 4 | 5 | uses 6 | SysUtils, Windows; 7 | 8 | function GetCharFromVirtualKey(AKey: Word): string; 9 | function GetCharFromVirtualKey2(Key: Word): Char; 10 | function GetString(const Index: String) : String; 11 | function IntToStrZero(Value: Integer; Size: Integer): String; 12 | 13 | 14 | implementation 15 | 16 | function GetCharFromVirtualKey(AKey: Word): string; 17 | var 18 | KeyboardState: Windows.TKeyboardState; // keyboard state codes 19 | const 20 | MAPVK_VK_TO_VSC = 0; // parameter passed to MapVirtualKey 21 | begin 22 | Windows.GetKeyboardState(KeyboardState); 23 | SetLength(Result, 2); // max number of returned chars 24 | case Windows.ToAscii( 25 | AKey, 26 | Windows.MapVirtualKey(AKey, MAPVK_VK_TO_VSC), 27 | KeyboardState, 28 | @Result[1], 29 | 0 30 | ) of 31 | 0: Result := ''; // no translation available 32 | 1: SetLength(Result, 1); // single char returned 33 | 2: {Do nothing}; // two chars returned: leave Length(Result) = 2 34 | else Result := ''; // probably dead key 35 | end; 36 | end; 37 | 38 | function GetCharFromVirtualKey2(Key: Word): Char; 39 | var 40 | keyboardState: TKeyboardState; 41 | asciiResult: Integer; 42 | begin 43 | GetKeyboardState(keyboardState) ; 44 | 45 | asciiResult := ToAscii(Key, MapVirtualKey(Key, 0), keyboardState, @Result, 0) ; 46 | case asciiResult of 47 | 0: Result := #0; 48 | 1:; 49 | 2:; 50 | else 51 | Result := #0; 52 | end; 53 | end; 54 | 55 | function GetString(const Index: String) : String; 56 | var 57 | buffer : array[0..255] of Char; 58 | ls : integer; 59 | begin 60 | Result := ''; 61 | ls := LoadString(hInstance, StrToInt(Index), buffer, sizeof(buffer)); 62 | if ls <> 0 then Result := buffer; 63 | end; 64 | 65 | function IntToStrZero(Value: Integer; Size: Integer): String; 66 | begin 67 | Result:=IntToStr(Value); 68 | while Length(Result) 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | <Scaled Value="True"/> 13 | <ResourceType Value="res"/> 14 | <UseXPManifest Value="True"/> 15 | <XPManifest> 16 | <DpiAware Value="True"/> 17 | </XPManifest> 18 | <Icon Value="0"/> 19 | </General> 20 | <BuildModes Count="1"> 21 | <Item1 Name="Default" Default="True"/> 22 | </BuildModes> 23 | <PublishOptions> 24 | <Version Value="2"/> 25 | <UseFileFilters Value="True"/> 26 | </PublishOptions> 27 | <RunParams> 28 | <FormatVersion Value="2"/> 29 | </RunParams> 30 | <RequiredPackages Count="2"> 31 | <Item1> 32 | <PackageName Value="QDSEquationsLaz"/> 33 | </Item1> 34 | <Item2> 35 | <PackageName Value="LCL"/> 36 | </Item2> 37 | </RequiredPackages> 38 | <Units Count="2"> 39 | <Unit0> 40 | <Filename Value="QDSEqDemo.lpr"/> 41 | <IsPartOfProject Value="True"/> 42 | </Unit0> 43 | <Unit1> 44 | <Filename Value="main.pas"/> 45 | <IsPartOfProject Value="True"/> 46 | <ComponentName Value="frmMain"/> 47 | <HasResources Value="True"/> 48 | <ResourceBaseClass Value="Form"/> 49 | </Unit1> 50 | </Units> 51 | </ProjectOptions> 52 | <CompilerOptions> 53 | <Version Value="11"/> 54 | <PathDelim Value="\"/> 55 | <Target> 56 | <Filename Value="QDSEqDemo"/> 57 | </Target> 58 | <SearchPaths> 59 | <IncludeFiles Value="$(ProjOutDir)"/> 60 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 61 | </SearchPaths> 62 | <Linking> 63 | <Options> 64 | <Win32> 65 | <GraphicApplication Value="True"/> 66 | </Win32> 67 | </Options> 68 | </Linking> 69 | </CompilerOptions> 70 | <Debugging> 71 | <Exceptions Count="3"> 72 | <Item1> 73 | <Name Value="EAbort"/> 74 | </Item1> 75 | <Item2> 76 | <Name Value="ECodetoolError"/> 77 | </Item2> 78 | <Item3> 79 | <Name Value="EFOpenError"/> 80 | </Item3> 81 | </Exceptions> 82 | </Debugging> 83 | </CONFIG> 84 | -------------------------------------------------------------------------------- /demo/main.pas: -------------------------------------------------------------------------------- 1 | unit main; 2 | 3 | {$IFDEF FPC} 4 | {$MODE Delphi} 5 | {$ENDIF} 6 | 7 | interface 8 | 9 | uses 10 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 11 | Dialogs, Equations, SelectEquation, StdCtrls, ToolWin, ComCtrls, ImgList, 12 | ExtCtrls, Spin, Grids, DBGrids; 13 | 14 | type 15 | TfrmMain = class(TForm) 16 | FontDialog1: TFontDialog; 17 | ColorDialog1: TColorDialog; 18 | Panel1: TPanel; 19 | Memo1: TMemo; 20 | Label1: TLabel; 21 | Label2: TLabel; 22 | ComboBox1: TComboBox; 23 | Button1: TButton; 24 | Button2: TButton; 25 | SelectEquation1: TSelectEquation; 26 | QDSEquation1: TQDSEquation; 27 | procedure FormCreate(Sender: TObject); 28 | procedure Button1Click(Sender: TObject); 29 | procedure Button2Click(Sender: TObject); 30 | procedure QDSEquation1Change(Sender: TObject); 31 | procedure Memo1Change(Sender: TObject); 32 | procedure ComboBox1Change(Sender: TObject); 33 | private 34 | { Private declarations } 35 | public 36 | { Public declarations } 37 | end; 38 | 39 | var 40 | frmMain: TfrmMain; 41 | 42 | QDSEquation1: TQDSEquation; 43 | SelectEquation1: TSelectEquation; 44 | 45 | implementation 46 | 47 | {$IFDEF FPC} 48 | {$R *.lfm} 49 | {$ELSE} 50 | {$R *.dfm} 51 | {$ENDIF} 52 | 53 | procedure TfrmMain.FormCreate(Sender: TObject); 54 | //var Canvas: TCanvas; 55 | 56 | begin 57 | QDSEquation1.Data:='EditArea(IntLimitBottomTopOne(EditArea(Simple(x)Simple(d)Simple(x))EditArea(Simple(0))EditArea(ExtSymbol(8734))))'; 58 | ComboBox1Change(Self); 59 | Caption:=Format('%s v%s',[Caption,QDSEquation1.Version]); 60 | end; 61 | 62 | procedure TfrmMain.Button1Click(Sender: TObject); 63 | begin 64 | FontDialog1.Font.Assign(QDSEquation1.Font); 65 | if FontDialog1.Execute then QDSEquation1.Font.Assign(FontDialog1.Font); 66 | end; 67 | 68 | procedure TfrmMain.Button2Click(Sender: TObject); 69 | begin 70 | ColorDialog1.Color:=QDSEquation1.BkColor; 71 | if ColorDialog1.Execute then QDSEquation1.BkColor:=ColorDialog1.Color; 72 | end; 73 | 74 | procedure TfrmMain.QDSEquation1Change(Sender: TObject); 75 | begin 76 | Memo1.Text:=QDSEquation1.Data; 77 | end; 78 | 79 | procedure TfrmMain.Memo1Change(Sender: TObject); 80 | begin 81 | if QDSEquation1.Data<>Memo1.Text then 82 | QDSEquation1.Data:=Memo1.Text; 83 | end; 84 | 85 | procedure TfrmMain.ComboBox1Change(Sender: TObject); 86 | begin 87 | case ComboBox1.ItemIndex of 88 | 0: SelectEquation1.Language:=lRussian; 89 | 1: SelectEquation1.Language:=lDeutsche; 90 | 2: SelectEquation1.Language:=lEnglish; 91 | end; 92 | end; 93 | 94 | end. 95 | 96 | 97 | -------------------------------------------------------------------------------- /demo/main.dfm: -------------------------------------------------------------------------------- 1 | object frmMain: TfrmMain 2 | Left = 200 3 | Top = 129 4 | Width = 1000 5 | Height = 476 6 | Caption = 'QDS Eqations' 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -11 11 | Font.Name = 'MS Sans Serif' 12 | Font.Style = [] 13 | OldCreateOrder = False 14 | OnCreate = FormCreate 15 | PixelsPerInch = 96 16 | TextHeight = 13 17 | object Panel1: TPanel 18 | Left = 0 19 | Top = 316 20 | Width = 984 21 | Height = 121 22 | Align = alBottom 23 | TabOrder = 0 24 | DesignSize = ( 25 | 984 26 | 121) 27 | object Label1: TLabel 28 | Left = 8 29 | Top = 20 30 | Width = 23 31 | Height = 13 32 | Anchors = [akLeft, akBottom] 33 | Caption = 'Data' 34 | end 35 | object Label2: TLabel 36 | Left = 657 37 | Top = 1 38 | Width = 48 39 | Height = 13 40 | Anchors = [akRight, akBottom] 41 | Caption = 'Language' 42 | end 43 | object Memo1: TMemo 44 | Left = 1 45 | Top = 40 46 | Width = 982 47 | Height = 80 48 | Align = alBottom 49 | TabOrder = 0 50 | WantReturns = False 51 | OnChange = Memo1Change 52 | end 53 | object ComboBox1: TComboBox 54 | Left = 655 55 | Top = 14 56 | Width = 127 57 | Height = 24 58 | Style = csDropDownList 59 | Anchors = [akRight, akBottom] 60 | Font.Charset = DEFAULT_CHARSET 61 | Font.Color = clWindowText 62 | Font.Height = -16 63 | Font.Name = 'Courier' 64 | Font.Style = [] 65 | ItemHeight = 16 66 | ItemIndex = 0 67 | ParentFont = False 68 | TabOrder = 1 69 | Text = 'Russian' 70 | OnChange = ComboBox1Change 71 | Items.Strings = ( 72 | 'Russian' 73 | 'Deutsche' 74 | 'English') 75 | end 76 | object Button1: TButton 77 | Left = 802 78 | Top = 13 79 | Width = 75 80 | Height = 25 81 | Anchors = [akRight, akBottom] 82 | Caption = 'Font..' 83 | TabOrder = 2 84 | OnClick = Button1Click 85 | end 86 | object Button2: TButton 87 | Left = 901 88 | Top = 13 89 | Width = 75 90 | Height = 25 91 | Anchors = [akRight, akBottom] 92 | Caption = 'BkColor..' 93 | TabOrder = 3 94 | OnClick = Button2Click 95 | end 96 | end 97 | object SelectEquation1: TSelectEquation 98 | Left = 0 99 | Top = 0 100 | Width = 984 101 | Height = 121 102 | Align = alTop 103 | Equation = QDSEquation1 104 | Language = lRussian 105 | end 106 | object QDSEquation1: TQDSEquation 107 | Left = 0 108 | Top = 121 109 | Width = 984 110 | Height = 195 111 | Align = alClient 112 | BkColor = clWhite 113 | Data = 'EditArea()' 114 | Font.Charset = RUSSIAN_CHARSET 115 | Font.Color = clBlack 116 | Font.Height = -27 117 | Font.Name = 'Times New Roman' 118 | Font.Style = [] 119 | OnChange = QDSEquation1Change 120 | end 121 | object FontDialog1: TFontDialog 122 | Font.Charset = DEFAULT_CHARSET 123 | Font.Color = clWindowText 124 | Font.Height = -11 125 | Font.Name = 'MS Sans Serif' 126 | Font.Style = [] 127 | end 128 | object ColorDialog1: TColorDialog 129 | Left = 32 130 | end 131 | end 132 | -------------------------------------------------------------------------------- /docs/classes: -------------------------------------------------------------------------------- 1 | TSelectEquation 2 | The component represents a menu and when choosing a formula element adds it in Equation: TQDSEquation. 3 | 4 | TQDSEquation. 5 | Component – equation editor. Includes the EditAreaList 6 | 7 | Properties 8 | ActiveEditArea: TEditArea 9 | Includes a link to an active TEditArea 10 | Data: String 11 | Includes an object tree in a text form. For example, the integral from 0 to infinity along xdx looks like: 12 | EditArea(IntLimitBottomTopOne(EditArea(Simple(x)Simple(d)Simple(x))EditArea(Simple(0))EditArea(ExtSymbol(8734)))) 13 | 14 | Methods 15 | AddEditArea 16 | Adds EditArea to the position EditAreaIndex+1 17 | InsertEditArea 18 | Adds EditArea to the position EditAreaIndex 19 | DeleteEditArea 20 | Deletes EditArea with the Index 21 | 22 | TEditArea – Class-container that visually looks like a field for text insertion. It includes a cursor and a list of pointers to the exemplars of TEquation class descendants. The TEditArea class is the most functional, as it manages their coordinates and sizes depending on a specified font, and comprises the methods that allow adding any symbol and element in it. Any element is placed at the position pointed out in EquationIndex, i.e. current cursor position. 23 | Methods: 24 | AddEqSimple(Ch: Char); Add ANSI symbol. Ch is a symbol. 25 | 26 | AddEqExtSymbol(SymbolCode: Integer); 27 | Add Unicode symbol. 28 | SymbolCode is a symbol code. 29 | 30 | AddEqBrackets(kb: TKindBracket); 31 | Add element “Brackets”. 32 | kb is a brackets type. 33 | 34 | AddEqIndex(go: TGroupOptions); 35 | Add element “Index” 36 | go is indexes options. 37 | 38 | AddEqSumma(go: TGroupOptions); 39 | Add element “Sum” 40 | go is indexes options. 41 | 42 | AddEqIntegral(go: TGroupOptions; Size: Integer; Ring: Boolean); 43 | Add element “Integral” 44 | go is indexes options, Size[1..3] – is an integral order, Ring – to draw a circumference. 45 | AddEqMultiply(go: TGroupOptions); 46 | Add element “Product” 47 | go is indexes options. 48 | 49 | AddEqCoMult(go: TGroupOptions); 50 | Add element “Coproduct” 51 | go is indexes options. 52 | 53 | AddEqIntersection(go: TGroupOptions); 54 | Add element “Intersection” 55 | go is indexes options. 56 | 57 | AddEqJoin (go: TGroupOptions); 58 | Add element “Integrating” 59 | go is indexes options. 60 | 61 | AddEqVector(ka: TKindArrow; ae: TAlignEA); 62 | Add element “Vector” 63 | ka is arrow options, ae is a position of a text field. 64 | 65 | AddEqArrow(ka: TKindArrow; ae: TAlignEA); 66 | Add element “Arrow” 67 | ka is arrow options, ae is a position of a text field. 68 | 69 | AddEqMatrix(km: TKindMatrix; CountEA: Integer); 70 | Add element “Matrix” 71 | km is a matrix type, CountEA is quantity of elements 72 | 73 | 74 | Additional types and sets 75 | 76 | TKindBracket = (kbRound, kbSquare, kbFigure, kbCorner, kbModule, kbDModule) 77 | Brackets type. 78 | kbRound - Round 79 | kbSquare - Square 80 | kbFigure - Figure 81 | kbCorner - Corner 82 | kbModule - Modular 83 | kbDModule – Double module 84 | 85 | TGroupOptions = (goIndexTop, goIndexBottom, goLimitTop, goLimitBottom) 86 | Indexes options 87 | goIndexTop – Index at the top 88 | goIndexBottom – Index in the bottom 89 | goLimitTop – Limit at the top 90 | goLimitBottom – Limit in the bottom 91 | 92 | TKindArrow = set of (kaRight, kaLeft, kaDouble); 93 | Arrow options 94 | kaRight – Arrow to the left 95 | kaLeft – Arrow to the right 96 | kaDouble – Double arrow 97 | 98 | TAlignEA = (aeTop, aeBottom); 99 | Position of a text field 100 | aeTop – At the top 101 | aeBottom – In the bottom 102 | 103 | TKindMatrix = (kmHoriz, kmVert, kmSquare); 104 | Matrix type 105 | kmHoriz - Horizontal 106 | kmVert - Vertical 107 | kmSquare - Square 108 | -------------------------------------------------------------------------------- /demo/QDSEqDemo2007.dproj: -------------------------------------------------------------------------------- 1 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 2 | <PropertyGroup> 3 | <ProjectGuid>{49e1f505-bce9-4252-8c09-329a6b6c5239}</ProjectGuid> 4 | <MainSource>QDSEqDemo.dpr</MainSource> 5 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 6 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 7 | <DCC_DCCCompiler>DCC32</DCC_DCCCompiler> 8 | <DCC_DependencyCheckOutputName>QDSEqDemo.exe</DCC_DependencyCheckOutputName> 9 | </PropertyGroup> 10 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> 11 | <Version>7.0</Version> 12 | <DCC_DebugInformation>False</DCC_DebugInformation> 13 | <DCC_LocalDebugSymbols>False</DCC_LocalDebugSymbols> 14 | <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo> 15 | <DCC_Define>RELEASE</DCC_Define> 16 | </PropertyGroup> 17 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> 18 | <Version>7.0</Version> 19 | <DCC_Define>DEBUG</DCC_Define> 20 | </PropertyGroup> 21 | <ProjectExtensions> 22 | <Borland.Personality>Delphi.Personality</Borland.Personality> 23 | <Borland.ProjectType>VCLApplication</Borland.ProjectType> 24 | <BorlandProject> 25 | <BorlandProject xmlns=""> <Delphi.Personality> <Parameters> 26 | <Parameters Name="UseLauncher">False</Parameters> 27 | <Parameters Name="LoadAllSymbols">True</Parameters> 28 | <Parameters Name="LoadUnspecifiedSymbols">False</Parameters> 29 | </Parameters> 30 | <Language> 31 | <Language Name="RootDir">C:\Program Files\Borland\Delphi7\Bin\</Language> 32 | </Language> 33 | <VersionInfo> 34 | <VersionInfo Name="IncludeVerInfo">True</VersionInfo> 35 | <VersionInfo Name="AutoIncBuild">False</VersionInfo> 36 | <VersionInfo Name="MajorVer">0</VersionInfo> 37 | <VersionInfo Name="MinorVer">5</VersionInfo> 38 | <VersionInfo Name="Release">0</VersionInfo> 39 | <VersionInfo Name="Build">0</VersionInfo> 40 | <VersionInfo Name="Debug">False</VersionInfo> 41 | <VersionInfo Name="PreRelease">False</VersionInfo> 42 | <VersionInfo Name="Special">False</VersionInfo> 43 | <VersionInfo Name="Private">False</VersionInfo> 44 | <VersionInfo Name="DLL">False</VersionInfo> 45 | <VersionInfo Name="Locale">1049</VersionInfo> 46 | <VersionInfo Name="CodePage">1251</VersionInfo> 47 | </VersionInfo> 48 | <VersionInfoKeys> 49 | <VersionInfoKeys Name="CompanyName"></VersionInfoKeys> 50 | <VersionInfoKeys Name="FileDescription"></VersionInfoKeys> 51 | <VersionInfoKeys Name="FileVersion">0.5.0.0</VersionInfoKeys> 52 | <VersionInfoKeys Name="InternalName"></VersionInfoKeys> 53 | <VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys> 54 | <VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys> 55 | <VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys> 56 | <VersionInfoKeys Name="ProductName"></VersionInfoKeys> 57 | <VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys> 58 | <VersionInfoKeys Name="Comments"></VersionInfoKeys> 59 | </VersionInfoKeys> 60 | <Source> 61 | <Source Name="MainSource">QDSEqDemo.dpr</Source> 62 | </Source> 63 | </Delphi.Personality> </BorlandProject></BorlandProject> 64 | </ProjectExtensions> 65 | <ItemGroup /> 66 | <ItemGroup> 67 | <DelphiCompile Include="QDSEqDemo.dpr"> 68 | <MainSource>MainSource</MainSource> 69 | </DelphiCompile> 70 | <DCCReference Include="main.pas"> 71 | <Form>frmMain</Form> 72 | </DCCReference> 73 | <DCCReference Include="UsefulUtils.pas" /> 74 | </ItemGroup> 75 | <Import Project="$(MSBuildBinPath)\Borland.Delphi.Targets" /> 76 | </Project> -------------------------------------------------------------------------------- /package/QDSEquationsD7.dof: -------------------------------------------------------------------------------- 1 | [FileVersion] 2 | Version=7.0 3 | [Compiler] 4 | A=8 5 | B=0 6 | C=1 7 | D=1 8 | E=0 9 | F=0 10 | G=1 11 | H=1 12 | I=1 13 | J=0 14 | K=0 15 | L=1 16 | M=0 17 | N=1 18 | O=1 19 | P=1 20 | Q=0 21 | R=0 22 | S=0 23 | T=0 24 | U=0 25 | V=1 26 | W=0 27 | X=1 28 | Y=1 29 | Z=1 30 | ShowHints=1 31 | ShowWarnings=1 32 | UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; 33 | NamespacePrefix= 34 | SymbolDeprecated=1 35 | SymbolLibrary=1 36 | SymbolPlatform=1 37 | UnitLibrary=1 38 | UnitPlatform=1 39 | UnitDeprecated=1 40 | HResultCompat=1 41 | HidingMember=1 42 | HiddenVirtual=1 43 | Garbage=1 44 | BoundsError=1 45 | ZeroNilCompat=1 46 | StringConstTruncated=1 47 | ForLoopVarVarPar=1 48 | TypedConstVarPar=1 49 | AsgToTypedConst=1 50 | CaseLabelRange=1 51 | ForVariable=1 52 | ConstructingAbstract=1 53 | ComparisonFalse=1 54 | ComparisonTrue=1 55 | ComparingSignedUnsigned=1 56 | CombiningSignedUnsigned=1 57 | UnsupportedConstruct=1 58 | FileOpen=1 59 | FileOpenUnitSrc=1 60 | BadGlobalSymbol=1 61 | DuplicateConstructorDestructor=1 62 | InvalidDirective=1 63 | PackageNoLink=1 64 | PackageThreadVar=1 65 | ImplicitImport=1 66 | HPPEMITIgnored=1 67 | NoRetVal=1 68 | UseBeforeDef=1 69 | ForLoopVarUndef=1 70 | UnitNameMismatch=1 71 | NoCFGFileFound=1 72 | MessageDirective=1 73 | ImplicitVariants=1 74 | UnicodeToLocale=1 75 | LocaleToUnicode=1 76 | ImagebaseMultiple=1 77 | SuspiciousTypecast=1 78 | PrivatePropAccessor=1 79 | UnsafeType=0 80 | UnsafeCode=0 81 | UnsafeCast=0 82 | [Linker] 83 | MapFile=0 84 | OutputObjs=0 85 | ConsoleApp=1 86 | DebugInfo=0 87 | RemoteSymbols=0 88 | MinStackSize=16384 89 | MaxStackSize=1048576 90 | ImageBase=4194304 91 | ExeDescription=QDS Equations 92 | [Directories] 93 | OutputDir= 94 | UnitOutputDir=Delphi7\ 95 | PackageDLLOutputDir=Delphi7\ 96 | PackageDCPOutputDir=Delphi7\ 97 | SearchPath=Delphi7\;D:\Prog_Lazarus\git\QDSEquations\source;D:\Prog_Lazarus\git\QDSEquations\resources 98 | Packages=vcl;rtl;vclx;indy;inet;xmlrtl;vclie;inetdbbde;inetdbxpress;dbrtl;dsnap;dsnapcon;vcldb;soaprtl;VclSmp;dbexpress;dbxcds;inetdb;bdertl;vcldbx;webdsnap;websnap;adortl;ibxpress;teeui;teedb;tee;dss;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;Rave50CLX;Rave50VCL;dclOfficeXP;CoolTrayIcon_D5;vclAbsDBd7;QDSEquationsD7 99 | Conditionals= 100 | DebugSourceDirs= 101 | UsePackages=0 102 | [Parameters] 103 | RunParams= 104 | HostApplication= 105 | Launcher= 106 | UseLauncher=0 107 | DebugCWD= 108 | [Language] 109 | ActiveLang= 110 | ProjectLang= 111 | RootDir=C:\Program Files\Borland\Delphi7\Bin\ 112 | [Version Info] 113 | IncludeVerInfo=1 114 | AutoIncBuild=0 115 | MajorVer=1 116 | MinorVer=0 117 | Release=0 118 | Build=0 119 | Debug=0 120 | PreRelease=0 121 | Special=0 122 | Private=0 123 | DLL=0 124 | Locale=1049 125 | CodePage=1251 126 | [Version Info Keys] 127 | CompanyName=Qds 128 | FileDescription=Qds Equations 129 | FileVersion=1.0.0.0 130 | InternalName=Equations 131 | LegalCopyright=Qds 132 | LegalTrademarks=Qds 133 | OriginalFilename=QdsEquations 134 | ProductName=Qds Equations 135 | ProductVersion=1.0.0.0 136 | Comments=Qds Equations 137 | [HistoryLists\hlUnitAliases] 138 | Count=1 139 | Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; 140 | [HistoryLists\hlSearchPath] 141 | Count=4 142 | Item0=Delphi7\;D:\Prog_Lazarus\git\QDSEquations\source;D:\Prog_Lazarus\git\QDSEquations\resources 143 | Item1=Delphi7\;D:\Prog_Lazarus\git\QDSEquations\source 144 | Item2=Delphi7\ 145 | Item3=..\package\Delphi7\ 146 | [HistoryLists\hlUnitOutputDirectory] 147 | Count=2 148 | Item0=Delphi7\ 149 | Item1=..\package\Delphi7\ 150 | [HistoryLists\hlBPLOutput] 151 | Count=2 152 | Item0=Delphi7\ 153 | Item1=..\package\Delphi7\ 154 | [HistoryLists\hlDCPOutput] 155 | Count=2 156 | Item0=Delphi7\ 157 | Item1=..\package\Delphi7\ 158 | -------------------------------------------------------------------------------- /demo/main.lfm: -------------------------------------------------------------------------------- 1 | object frmMain: TfrmMain 2 | Left = 317 3 | Height = 437 4 | Top = 151 5 | Width = 874 6 | Caption = 'QDS Eqations' 7 | ClientHeight = 437 8 | ClientWidth = 874 9 | Color = clBtnFace 10 | Font.Color = clWindowText 11 | Font.Height = -11 12 | Font.Name = 'MS Sans Serif' 13 | OnCreate = FormCreate 14 | LCLVersion = '2.1.0.0' 15 | object Panel1: TPanel 16 | Left = 0 17 | Height = 121 18 | Top = 316 19 | Width = 874 20 | Align = alBottom 21 | ClientHeight = 121 22 | ClientWidth = 874 23 | Font.Color = clWindowText 24 | ParentFont = False 25 | TabOrder = 0 26 | object Label1: TLabel 27 | Left = 8 28 | Height = 15 29 | Top = 18 30 | Width = 24 31 | Anchors = [akLeft, akBottom] 32 | Caption = 'Data' 33 | ParentColor = False 34 | end 35 | object Label2: TLabel 36 | Left = 549 37 | Height = 15 38 | Top = -1 39 | Width = 52 40 | Anchors = [akRight, akBottom] 41 | Caption = 'Language' 42 | ParentColor = False 43 | end 44 | object Memo1: TMemo 45 | Left = 1 46 | Height = 80 47 | Top = 40 48 | Width = 872 49 | Align = alBottom 50 | OnChange = Memo1Change 51 | TabOrder = 0 52 | WantReturns = False 53 | end 54 | object ComboBox1: TComboBox 55 | Left = 545 56 | Height = 23 57 | Top = 15 58 | Width = 127 59 | Anchors = [akRight, akBottom] 60 | Font.Color = clWindowText 61 | ItemHeight = 15 62 | ItemIndex = 0 63 | Items.Strings = ( 64 | 'Russian' 65 | 'Deutsche' 66 | 'English' 67 | ) 68 | OnChange = ComboBox1Change 69 | ParentFont = False 70 | Style = csDropDownList 71 | TabOrder = 1 72 | Text = 'Russian' 73 | end 74 | object Button1: TButton 75 | Left = 692 76 | Height = 25 77 | Top = 13 78 | Width = 75 79 | Anchors = [akRight, akBottom] 80 | Caption = 'Font..' 81 | OnClick = Button1Click 82 | TabOrder = 2 83 | end 84 | object Button2: TButton 85 | Left = 791 86 | Height = 25 87 | Top = 13 88 | Width = 75 89 | Anchors = [akRight, akBottom] 90 | Caption = 'BkColor..' 91 | OnClick = Button2Click 92 | TabOrder = 3 93 | end 94 | end 95 | object SelectEquation1: TSelectEquation 96 | Left = 0 97 | Height = 121 98 | Top = 0 99 | Width = 874 100 | Align = alTop 101 | Equation = QDSEquation1 102 | Language = lRussian 103 | end 104 | object QDSEquation1: TQDSEquation 105 | Left = 0 106 | Height = 195 107 | Top = 121 108 | Width = 874 109 | Align = alClient 110 | BkColor = clWhite 111 | Data = 'EditArea()' 112 | Font.CharSet = ANSI_CHARSET 113 | Font.Color = clBlack 114 | OnChange = QDSEquation1Change 115 | end 116 | object FontDialog1: TFontDialog 117 | Font.Color = clWindowText 118 | Font.Height = -11 119 | Font.Name = 'MS Sans Serif' 120 | MinFontSize = 0 121 | MaxFontSize = 0 122 | Left = 712 123 | Top = 248 124 | end 125 | object ColorDialog1: TColorDialog 126 | Color = clBlack 127 | CustomColors.Strings = ( 128 | 'ColorA=000000' 129 | 'ColorB=000080' 130 | 'ColorC=008000' 131 | 'ColorD=008080' 132 | 'ColorE=800000' 133 | 'ColorF=800080' 134 | 'ColorG=808000' 135 | 'ColorH=808080' 136 | 'ColorI=C0C0C0' 137 | 'ColorJ=0000FF' 138 | 'ColorK=00FF00' 139 | 'ColorL=00FFFF' 140 | 'ColorM=FF0000' 141 | 'ColorN=FF00FF' 142 | 'ColorO=FFFF00' 143 | 'ColorP=FFFFFF' 144 | 'ColorQ=C0DCC0' 145 | 'ColorR=F0CAA6' 146 | 'ColorS=F0FBFF' 147 | 'ColorT=A4A0A0' 148 | ) 149 | Left = 808 150 | Top = 248 151 | end 152 | end 153 | -------------------------------------------------------------------------------- /package/QDSEquationsD2007.dproj: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 3 | <PropertyGroup> 4 | <ProjectGuid>{1a3c4c68-a18c-42f3-826a-c209e87041cd}</ProjectGuid> 5 | <MainSource>QDSEquationsD2007.dpk</MainSource> 6 | <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration> 7 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 8 | <DCC_DCCCompiler>DCC32</DCC_DCCCompiler> 9 | <DCC_DependencyCheckOutputName>Delphi2007\QDSEquationsD2007.bpl</DCC_DependencyCheckOutputName> 10 | </PropertyGroup> 11 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> 12 | <Version>7.0</Version> 13 | <DCC_DebugInformation>False</DCC_DebugInformation> 14 | <DCC_LocalDebugSymbols>False</DCC_LocalDebugSymbols> 15 | <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo> 16 | <DCC_DcuOutput>Delphi2007\</DCC_DcuOutput> 17 | <DCC_ObjOutput>Delphi2007\</DCC_ObjOutput> 18 | <DCC_HppOutput>Delphi2007\</DCC_HppOutput> 19 | <DCC_BplOutput>Delphi2007\</DCC_BplOutput> 20 | <DCC_DcpOutput>Delphi2007\</DCC_DcpOutput> 21 | <DCC_UnitSearchPath>Delphi2007\</DCC_UnitSearchPath> 22 | <DCC_ResourcePath>Delphi2007\</DCC_ResourcePath> 23 | <DCC_ObjPath>Delphi2007\</DCC_ObjPath> 24 | <DCC_IncludePath>Delphi2007\</DCC_IncludePath> 25 | <DCC_Define>RELEASE</DCC_Define> 26 | </PropertyGroup> 27 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> 28 | <Version>7.0</Version> 29 | <DCC_DcuOutput>Delphi2007\</DCC_DcuOutput> 30 | <DCC_ObjOutput>Delphi2007\</DCC_ObjOutput> 31 | <DCC_HppOutput>Delphi2007\</DCC_HppOutput> 32 | <DCC_BplOutput>Delphi2007\</DCC_BplOutput> 33 | <DCC_DcpOutput>Delphi2007\</DCC_DcpOutput> 34 | <DCC_UnitSearchPath>Delphi2007\</DCC_UnitSearchPath> 35 | <DCC_ResourcePath>Delphi2007\</DCC_ResourcePath> 36 | <DCC_ObjPath>Delphi2007\</DCC_ObjPath> 37 | <DCC_IncludePath>Delphi2007\</DCC_IncludePath> 38 | </PropertyGroup> 39 | <ProjectExtensions> 40 | <Borland.Personality>Delphi.Personality</Borland.Personality> 41 | <Borland.ProjectType>Package</Borland.ProjectType> 42 | <BorlandProject> 43 | <BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><Package_Options><Package_Options Name="PackageDescription">QDS Equations</Package_Options><Package_Options Name="ImplicitBuild">False</Package_Options><Package_Options Name="DesigntimeOnly">False</Package_Options><Package_Options Name="RuntimeOnly">False</Package_Options></Package_Options><Language><Language Name="RootDir">C:\Program Files\Borland\Delphi7\Bin\</Language></Language><VersionInfo><VersionInfo Name="IncludeVerInfo">True</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">1</VersionInfo><VersionInfo Name="MinorVer">0</VersionInfo><VersionInfo Name="Release">0</VersionInfo><VersionInfo Name="Build">0</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1049</VersionInfo><VersionInfo Name="CodePage">1251</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName">Qds</VersionInfoKeys><VersionInfoKeys Name="FileDescription">Qds Equations</VersionInfoKeys><VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="InternalName">Equations</VersionInfoKeys><VersionInfoKeys Name="LegalCopyright">Qds</VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks">Qds</VersionInfoKeys><VersionInfoKeys Name="OriginalFilename">QdsEquations</VersionInfoKeys><VersionInfoKeys Name="ProductName">Qds Equations</VersionInfoKeys><VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="Comments">Qds Equations</VersionInfoKeys></VersionInfoKeys><Source><Source Name="MainSource">QDSEquationsD2007.dpk</Source></Source></Delphi.Personality></BorlandProject></BorlandProject> 44 | </ProjectExtensions> 45 | <Import Project="$(MSBuildBinPath)\Borland.Delphi.Targets" /> 46 | <ItemGroup> 47 | <DelphiCompile Include="QDSEquationsD2007.dpk"> 48 | <MainSource>MainSource</MainSource> 49 | </DelphiCompile> 50 | <DCCReference Include="..\Source\Equations.pas" /> 51 | <DCCReference Include="..\Source\SelectEquation.pas" /> 52 | <DCCReference Include="..\Source\UsefulUtils.pas" /> 53 | <DCCReference Include="C:\Documents and Settings\Admin\rtl.dcp" /> 54 | <DCCReference Include="C:\Documents and Settings\Admin\vcl.dcp" /> 55 | <DCCReference Include="QDSEquations.dcr" /> 56 | <DCCReference Include="QDSEquations.dcr" /> 57 | </ItemGroup> 58 | </Project> -------------------------------------------------------------------------------- /demo/QDSEqDemo2009.dproj: -------------------------------------------------------------------------------- 1 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 2 | <PropertyGroup> 3 | <ProjectGuid>{B2D7023A-4BC0-4AEB-9F9C-A0907E5E7B4C}</ProjectGuid> 4 | <MainSource>QDSEqDemo.dpr</MainSource> 5 | <Config Condition="'$(Config)'==''">Debug</Config> 6 | <DCC_DCCCompiler>DCC32</DCC_DCCCompiler> 7 | <ProjectVersion>12.0</ProjectVersion> 8 | </PropertyGroup> 9 | <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''"> 10 | <Base>true</Base> 11 | </PropertyGroup> 12 | <PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''"> 13 | <Cfg_1>true</Cfg_1> 14 | <CfgParent>Base</CfgParent> 15 | <Base>true</Base> 16 | </PropertyGroup> 17 | <PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''"> 18 | <Cfg_2>true</Cfg_2> 19 | <CfgParent>Base</CfgParent> 20 | <Base>true</Base> 21 | </PropertyGroup> 22 | <PropertyGroup Condition="'$(Base)'!=''"> 23 | <DCC_DependencyCheckOutputName>QDSEqDemo.exe</DCC_DependencyCheckOutputName> 24 | <DCC_UsePackage>vcl;rtl;vclx;vclactnband;xmlrtl;dbrtl;vcldb;vcldbx;bdertl;dsnap;dsnapcon;TeeUI;TeeDB;Tee;adortl;vclib;ibxpress;IndyCore;IndySystem;IndyProtocols;inet;intrawebdb_100_120;Intraweb_100_120;VclSmp;vclie;websnap;webdsnap;inetdbbde;inetdbxpress;soaprtl;vclribbon;dbexpress;DbxCommonDriver;DataSnapIndy10ServerTransport;DataSnapProviderClient;DataSnapServer;DbxClientDriver;DBXInterBaseDriver;DBXMySQLDriver;dbxcds;DBXSybaseASEDriver;DBXSybaseASADriver;DBXOracleDriver;DBXMSSQLDriver;DBXInformixDriver;DBXDb2Driver;QDSEquationsD2009</DCC_UsePackage> 25 | <DCC_ImageBase>00400000</DCC_ImageBase> 26 | <DCC_Platform>x86</DCC_Platform> 27 | </PropertyGroup> 28 | <PropertyGroup Condition="'$(Cfg_1)'!=''"> 29 | <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols> 30 | <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define> 31 | <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo> 32 | <DCC_DebugInformation>false</DCC_DebugInformation> 33 | </PropertyGroup> 34 | <PropertyGroup Condition="'$(Cfg_2)'!=''"> 35 | <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define> 36 | </PropertyGroup> 37 | <ItemGroup> 38 | <DelphiCompile Include="QDSEqDemo.dpr"> 39 | <MainSource>MainSource</MainSource> 40 | </DelphiCompile> 41 | <DCCReference Include="main.pas"> 42 | <Form>frmMain</Form> 43 | </DCCReference> 44 | <DCCReference Include="UsefulUtils.pas"/> 45 | <BuildConfiguration Include="Base"> 46 | <Key>Base</Key> 47 | </BuildConfiguration> 48 | <BuildConfiguration Include="Debug"> 49 | <Key>Cfg_2</Key> 50 | <CfgParent>Base</CfgParent> 51 | </BuildConfiguration> 52 | <BuildConfiguration Include="Release"> 53 | <Key>Cfg_1</Key> 54 | <CfgParent>Base</CfgParent> 55 | </BuildConfiguration> 56 | </ItemGroup> 57 | <Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/> 58 | <ProjectExtensions> 59 | <Borland.Personality>Delphi.Personality.12</Borland.Personality> 60 | <Borland.ProjectType>VCLApplication</Borland.ProjectType> 61 | <BorlandProject> 62 | <Delphi.Personality> 63 | <Source> 64 | <Source Name="MainSource">QDSEqDemo.dpr</Source> 65 | </Source> 66 | <Parameters> 67 | <Parameters Name="UseLauncher">False</Parameters> 68 | <Parameters Name="LoadAllSymbols">True</Parameters> 69 | <Parameters Name="LoadUnspecifiedSymbols">False</Parameters> 70 | </Parameters> 71 | <VersionInfo> 72 | <VersionInfo Name="IncludeVerInfo">True</VersionInfo> 73 | <VersionInfo Name="AutoIncBuild">False</VersionInfo> 74 | <VersionInfo Name="MajorVer">0</VersionInfo> 75 | <VersionInfo Name="MinorVer">5</VersionInfo> 76 | <VersionInfo Name="Release">0</VersionInfo> 77 | <VersionInfo Name="Build">0</VersionInfo> 78 | <VersionInfo Name="Debug">False</VersionInfo> 79 | <VersionInfo Name="PreRelease">False</VersionInfo> 80 | <VersionInfo Name="Special">False</VersionInfo> 81 | <VersionInfo Name="Private">False</VersionInfo> 82 | <VersionInfo Name="DLL">False</VersionInfo> 83 | <VersionInfo Name="Locale">1049</VersionInfo> 84 | <VersionInfo Name="CodePage">1251</VersionInfo> 85 | </VersionInfo> 86 | <VersionInfoKeys> 87 | <VersionInfoKeys Name="CompanyName"/> 88 | <VersionInfoKeys Name="FileDescription"/> 89 | <VersionInfoKeys Name="FileVersion">0.5.0.0</VersionInfoKeys> 90 | <VersionInfoKeys Name="InternalName"/> 91 | <VersionInfoKeys Name="LegalCopyright"/> 92 | <VersionInfoKeys Name="LegalTrademarks"/> 93 | <VersionInfoKeys Name="OriginalFilename"/> 94 | <VersionInfoKeys Name="ProductName"/> 95 | <VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys> 96 | <VersionInfoKeys Name="Comments"/> 97 | </VersionInfoKeys> 98 | </Delphi.Personality> 99 | </BorlandProject> 100 | <ProjectFileVersion>12</ProjectFileVersion> 101 | </ProjectExtensions> 102 | </Project> 103 | -------------------------------------------------------------------------------- /package/QDSEquationsD2009.dproj: -------------------------------------------------------------------------------- 1 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 2 | <PropertyGroup> 3 | <ProjectGuid>{F03092BA-4D87-446A-A9A3-241E158C9C1F}</ProjectGuid> 4 | <MainSource>QDSEquationsD2009.dpk</MainSource> 5 | <ProjectVersion>12.0</ProjectVersion> 6 | <Config Condition="'$(Config)'==''">Debug</Config> 7 | <DCC_DCCCompiler>DCC32</DCC_DCCCompiler> 8 | </PropertyGroup> 9 | <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''"> 10 | <Base>true</Base> 11 | </PropertyGroup> 12 | <PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''"> 13 | <Cfg_1>true</Cfg_1> 14 | <CfgParent>Base</CfgParent> 15 | <Base>true</Base> 16 | </PropertyGroup> 17 | <PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''"> 18 | <Cfg_2>true</Cfg_2> 19 | <CfgParent>Base</CfgParent> 20 | <Base>true</Base> 21 | </PropertyGroup> 22 | <PropertyGroup Condition="'$(Base)'!=''"> 23 | <DCC_UnitSearchPath>Delphi2009\;$(DCC_UnitSearchPath)</DCC_UnitSearchPath> 24 | <DCC_Description>QDS Equations</DCC_Description> 25 | <DCC_DcuOutput>Delphi2009\</DCC_DcuOutput> 26 | <DesignOnlyPackage>false</DesignOnlyPackage> 27 | <DCC_BplOutput>Delphi2009\</DCC_BplOutput> 28 | <DCC_DcpOutput>Delphi2009\</DCC_DcpOutput> 29 | <BRCC_OutputDir>Delphi2009\</BRCC_OutputDir> 30 | <DCC_OutputNeverBuildDcps>true</DCC_OutputNeverBuildDcps> 31 | <DCC_ImageBase>00400000</DCC_ImageBase> 32 | <DCC_SymbolReferenceInfo>1</DCC_SymbolReferenceInfo> 33 | <GenPackage>true</GenPackage> 34 | <DCC_UnitAlias>WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;$(DCC_UnitAlias)</DCC_UnitAlias> 35 | <DCC_Platform>x86</DCC_Platform> 36 | <DCC_DependencyCheckOutputName>Delphi2009\QDSEquationsD2009.bpl</DCC_DependencyCheckOutputName> 37 | <DCC_N>false</DCC_N> 38 | <DCC_S>false</DCC_S> 39 | <GenDll>true</GenDll> 40 | <DCC_E>false</DCC_E> 41 | <DCC_F>false</DCC_F> 42 | <DCC_K>false</DCC_K> 43 | </PropertyGroup> 44 | <PropertyGroup Condition="'$(Cfg_1)'!=''"> 45 | <BRCC_OutputDir>Delphi2009\</BRCC_OutputDir> 46 | <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols> 47 | <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define> 48 | <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo> 49 | <DCC_DebugInformation>false</DCC_DebugInformation> 50 | </PropertyGroup> 51 | <PropertyGroup Condition="'$(Cfg_2)'!=''"> 52 | <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define> 53 | </PropertyGroup> 54 | <ItemGroup> 55 | <DelphiCompile Include="QDSEquationsD2009.dpk"> 56 | <MainSource>MainSource</MainSource> 57 | </DelphiCompile> 58 | <DCCReference Include="QDSEquations.dcr"/> 59 | <DCCReference Include="rtl.dcp"/> 60 | <DCCReference Include="vcl.dcp"/> 61 | <DCCReference Include="..\Source\Equations.pas"/> 62 | <DCCReference Include="..\Source\SelectEquation.pas"/> 63 | <DCCReference Include="..\Source\UsefulUtils.pas"/> 64 | <DCCReference Include="QDSEquations.dcr"/> 65 | <BuildConfiguration Include="Base"> 66 | <Key>Base</Key> 67 | </BuildConfiguration> 68 | <BuildConfiguration Include="Debug"> 69 | <Key>Cfg_2</Key> 70 | <CfgParent>Base</CfgParent> 71 | </BuildConfiguration> 72 | <BuildConfiguration Include="Release"> 73 | <Key>Cfg_1</Key> 74 | <CfgParent>Base</CfgParent> 75 | </BuildConfiguration> 76 | </ItemGroup> 77 | <Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/> 78 | <ProjectExtensions> 79 | <Borland.Personality>Delphi.Personality.12</Borland.Personality> 80 | <Borland.ProjectType>Package</Borland.ProjectType> 81 | <BorlandProject> 82 | <Delphi.Personality> 83 | <Parameters> 84 | <Parameters Name="UseLauncher">False</Parameters> 85 | <Parameters Name="LoadAllSymbols">True</Parameters> 86 | <Parameters Name="LoadUnspecifiedSymbols">False</Parameters> 87 | </Parameters> 88 | <VersionInfo> 89 | <VersionInfo Name="IncludeVerInfo">True</VersionInfo> 90 | <VersionInfo Name="AutoIncBuild">False</VersionInfo> 91 | <VersionInfo Name="MajorVer">1</VersionInfo> 92 | <VersionInfo Name="MinorVer">0</VersionInfo> 93 | <VersionInfo Name="Release">0</VersionInfo> 94 | <VersionInfo Name="Build">0</VersionInfo> 95 | <VersionInfo Name="Debug">False</VersionInfo> 96 | <VersionInfo Name="PreRelease">False</VersionInfo> 97 | <VersionInfo Name="Special">False</VersionInfo> 98 | <VersionInfo Name="Private">False</VersionInfo> 99 | <VersionInfo Name="DLL">False</VersionInfo> 100 | <VersionInfo Name="Locale">1049</VersionInfo> 101 | <VersionInfo Name="CodePage">1251</VersionInfo> 102 | </VersionInfo> 103 | <VersionInfoKeys> 104 | <VersionInfoKeys Name="CompanyName">Qds</VersionInfoKeys> 105 | <VersionInfoKeys Name="FileDescription">Qds Equations</VersionInfoKeys> 106 | <VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys> 107 | <VersionInfoKeys Name="InternalName">Equations</VersionInfoKeys> 108 | <VersionInfoKeys Name="LegalCopyright">Qds</VersionInfoKeys> 109 | <VersionInfoKeys Name="LegalTrademarks">Qds</VersionInfoKeys> 110 | <VersionInfoKeys Name="OriginalFilename">QdsEquations</VersionInfoKeys> 111 | <VersionInfoKeys Name="ProductName">Qds Equations</VersionInfoKeys> 112 | <VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys> 113 | <VersionInfoKeys Name="Comments">Qds Equations</VersionInfoKeys> 114 | </VersionInfoKeys> 115 | <Source> 116 | <Source Name="MainSource">QDSEquationsD2009.dpk</Source> 117 | </Source> 118 | </Delphi.Personality> 119 | </BorlandProject> 120 | <ProjectFileVersion>12</ProjectFileVersion> 121 | </ProjectExtensions> 122 | </Project> 123 | -------------------------------------------------------------------------------- /source/SelectEquation.pas: -------------------------------------------------------------------------------- 1 | unit SelectEquation; 2 | 3 | {$IFDEF FPC} 4 | {$MODE Delphi} 5 | {$ENDIF} 6 | 7 | interface 8 | 9 | uses 10 | {$IFDEF FPC} 11 | LCLVersion, 12 | {$IFEND} 13 | SysUtils, Classes, Controls, ExtCtrls, ComCtrls, Contnrs, ImgList, Dialogs, 14 | Graphics, StdCtrls, Equations, UsefulUtils; 15 | 16 | type 17 | TLanguage = (lEnglish, lRussian, lDeutsche); 18 | TEqData = record 19 | Count: Integer; 20 | Height: Integer; 21 | Width: Integer; 22 | Visible: String; 23 | DescrList: array of String; 24 | end; 25 | 26 | TImageLists = class(TObjectList) 27 | private 28 | function GetItem(Index: Integer): TImageList; 29 | procedure SetItem(Index: Integer; AImageList: TImageList); 30 | public 31 | property Items[Index: Integer]: TImageList read GetItem write SetItem; 32 | end; 33 | 34 | TSelectEquation = class(TCustomPanel) 35 | private 36 | { Private declarations } 37 | FEqDataList: array of TEqData; 38 | FImageLists: TImageLists; 39 | FLabel: TLabel; 40 | FPageControl: TPageControl; 41 | FToolBar: TToolBar; 42 | FQDSEquation: TQDSEquation; 43 | FLanguage: TLanguage; 44 | procedure BtMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); 45 | procedure BtPanelClick(Sender: TObject); 46 | procedure BtTabSheetClick(Sender: TObject); 47 | procedure CreateDescript; 48 | procedure CreateImageLists; 49 | procedure CreateLabel; 50 | procedure CreatePageControl; 51 | procedure CreateToolBar(AParent: TWinControl; Index: Integer); 52 | procedure SetQDSEquation(AQDSEquation: TQDSEquation); 53 | procedure SetLanguage(const Value: TLanguage); 54 | protected 55 | { Protected declarations } 56 | public 57 | { Public declarations } 58 | constructor Create(AOwner: TComponent); override; 59 | destructor Destroy; override; 60 | procedure CreateWnd; override; 61 | published 62 | { Published declarations } 63 | property Align; 64 | property Anchors; 65 | property AutoSize; 66 | property BevelInner; 67 | property BevelOuter; 68 | property BevelWidth; 69 | property Constraints; 70 | {$IFNDEF FPC} 71 | property Ctl3D; 72 | {$ENDIF} 73 | property Enabled; 74 | property Equation: TQDSEquation read FQDSEquation write SetQDSEquation; 75 | property Language: TLanguage read FLanguage write SetLanguage; 76 | property PopupMenu; 77 | property Visible; 78 | property OnClick; 79 | property OnDblClick; 80 | property OnEnter; 81 | property OnExit; 82 | property OnMouseDown; 83 | property OnMouseMove; 84 | property OnMouseUp; 85 | property OnResize; 86 | end; 87 | 88 | procedure Register; 89 | 90 | implementation 91 | 92 | {$IFDEF FPC} 93 | {$R ../resources/images.res} 94 | {$R ../resources/localize.res} 95 | {$ELSE} 96 | {$R images.res} 97 | {$R localize.res} 98 | {$ENDIF} 99 | 100 | procedure Register; 101 | begin 102 | RegisterComponents('QDS Equations', [TSelectEquation]); 103 | end; 104 | 105 | { TImageLists } 106 | 107 | function TImageLists.GetItem(Index: Integer): TImageList; 108 | begin 109 | Result := TImageList(inherited Items[Index]); 110 | end; 111 | 112 | procedure TImageLists.SetItem(Index: Integer; AImageList: TImageList); 113 | begin 114 | inherited Items[Index] := AImageList; 115 | end; 116 | 117 | { TSelectEquaion } 118 | 119 | procedure TSelectEquation.BtMouseMove(Sender: TObject; Shift: TShiftState; X, 120 | Y: Integer); 121 | var 122 | AToolButton: TToolButton; 123 | begin 124 | AToolButton:=(Sender as TToolButton); 125 | if AToolButton.Parent=FToolBar then begin 126 | AToolButton.Hint:={Format('0 %d %s',[AToolButton.Tag, }FEqDataList[0].DescrList[AToolButton.Tag]{])}; 127 | end else begin 128 | AToolButton.Hint:={Format('%d %d %s',[AToolButton.Tag, AToolButton.ImageIndex, }FEqDataList[AToolButton.Tag].DescrList[AToolButton.ImageIndex]{])}; 129 | end; 130 | 131 | FLabel.Caption:=AToolButton.Hint; 132 | end; 133 | 134 | procedure TSelectEquation.BtPanelClick(Sender: TObject); 135 | var 136 | AToolButton: TToolButton; 137 | begin 138 | FToolBar.Buttons[FPageControl.ActivePageIndex].Down:=False; 139 | AToolButton:=(Sender as TToolButton); 140 | FPageControl.ActivePageIndex := AToolButton.Tag; 141 | AToolButton.Down:=True; 142 | end; 143 | 144 | procedure TSelectEquation.BtTabSheetClick(Sender: TObject); 145 | var 146 | AToolButton: TToolButton; 147 | begin 148 | AToolButton:=(Sender as TToolButton); 149 | if Assigned(FQDSEquation) then begin 150 | case AToolButton.Tag of 151 | 1: 152 | case AToolButton.ImageIndex of 153 | 0: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8804); 154 | 1: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8805); 155 | 6: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8800); 156 | 7: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8801); 157 | 8: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8776); 158 | end; 159 | 2: 160 | case AToolButton.ImageIndex of 161 | 2: FQDSEquation.ActiveEditArea.AddEqExtSymbol(160); 162 | 6: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8230); 163 | end; 164 | 4: 165 | case AToolButton.ImageIndex of 166 | 0: FQDSEquation.ActiveEditArea.AddEqExtSymbol(177); 167 | 2: FQDSEquation.ActiveEditArea.AddEqExtSymbol(215); 168 | 3: FQDSEquation.ActiveEditArea.AddEqExtSymbol(247); 169 | 4: FQDSEquation.ActiveEditArea.AddEqExtSymbol(42); 170 | 5: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8729); 171 | 6: FQDSEquation.ActiveEditArea.AddEqExtSymbol(9675);//9702 172 | 7: FQDSEquation.ActiveEditArea.AddEqExtSymbol(9679); 173 | 10: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8249); 174 | 11: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8250); 175 | 176 | end; 177 | 5: 178 | case AToolButton.ImageIndex of 179 | 0: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8594); 180 | 1: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8592); 181 | 2: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8596); 182 | 3: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8593); 183 | 4: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8595); 184 | 5: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8597); 185 | end; 186 | 6: 187 | case AToolButton.ImageIndex of 188 | 5: FQDSEquation.ActiveEditArea.AddEqExtSymbol(9488); 189 | end; 190 | 7: 191 | case AToolButton.ImageIndex of 192 | 3: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8745); 193 | end; 194 | 195 | 8: 196 | case AToolButton.ImageIndex of 197 | 0: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8706); 198 | 2: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8734); 199 | 7: FQDSEquation.ActiveEditArea.AddEqExtSymbol(9524); 200 | 8: FQDSEquation.ActiveEditArea.AddEqExtSymbol(9674); 201 | 9: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8467); 202 | 11: FQDSEquation.ActiveEditArea.AddEqExtSymbol(176); 203 | 12: FQDSEquation.ActiveEditArea.AddEqExtSymbol(295); 204 | 14: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8747); 205 | 15: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8721);//931 206 | 16: FQDSEquation.ActiveEditArea.AddEqExtSymbol(8719); 207 | end; 208 | 9: 209 | case AToolButton.ImageIndex of 210 | 0: FQDSEquation.ActiveEditArea.AddEqExtSymbol(945); 211 | 1: FQDSEquation.ActiveEditArea.AddEqExtSymbol(946); 212 | 2: FQDSEquation.ActiveEditArea.AddEqExtSymbol(967); 213 | 3: FQDSEquation.ActiveEditArea.AddEqExtSymbol(948); 214 | 4: FQDSEquation.ActiveEditArea.AddEqExtSymbol(949); 215 | 5: FQDSEquation.ActiveEditArea.AddEqExtSymbol(966);// 216 | 6: FQDSEquation.ActiveEditArea.AddEqExtSymbol(966); 217 | 7: FQDSEquation.ActiveEditArea.AddEqExtSymbol(947); 218 | 8: FQDSEquation.ActiveEditArea.AddEqExtSymbol(951); 219 | 9: FQDSEquation.ActiveEditArea.AddEqExtSymbol(953); 220 | 10: FQDSEquation.ActiveEditArea.AddEqExtSymbol(954); 221 | 11: FQDSEquation.ActiveEditArea.AddEqExtSymbol(955); 222 | 12: FQDSEquation.ActiveEditArea.AddEqExtSymbol(956); 223 | 13: FQDSEquation.ActiveEditArea.AddEqExtSymbol(957); 224 | 14: FQDSEquation.ActiveEditArea.AddEqExtSymbol(959); 225 | 15: FQDSEquation.ActiveEditArea.AddEqExtSymbol(960); 226 | 16: FQDSEquation.ActiveEditArea.AddEqExtSymbol(969);// 227 | 17: FQDSEquation.ActiveEditArea.AddEqExtSymbol(952); 228 | 18: FQDSEquation.ActiveEditArea.AddEqExtSymbol(952);// 229 | 19: FQDSEquation.ActiveEditArea.AddEqExtSymbol(961); 230 | 20: FQDSEquation.ActiveEditArea.AddEqExtSymbol(963); 231 | 21: FQDSEquation.ActiveEditArea.AddEqExtSymbol(962); 232 | 22: FQDSEquation.ActiveEditArea.AddEqExtSymbol(964); 233 | 23: FQDSEquation.ActiveEditArea.AddEqExtSymbol(965); 234 | 24: FQDSEquation.ActiveEditArea.AddEqExtSymbol(969); 235 | 25: FQDSEquation.ActiveEditArea.AddEqExtSymbol(958); 236 | 26: FQDSEquation.ActiveEditArea.AddEqExtSymbol(968); 237 | 27: FQDSEquation.ActiveEditArea.AddEqExtSymbol(950); 238 | end; 239 | 10: 240 | case AToolButton.ImageIndex of 241 | 0: FQDSEquation.ActiveEditArea.AddEqExtSymbol(913); 242 | 1: FQDSEquation.ActiveEditArea.AddEqExtSymbol(914); 243 | 2: FQDSEquation.ActiveEditArea.AddEqExtSymbol(935); 244 | 3: FQDSEquation.ActiveEditArea.AddEqExtSymbol(916); 245 | 4: FQDSEquation.ActiveEditArea.AddEqExtSymbol(917); 246 | 5: FQDSEquation.ActiveEditArea.AddEqExtSymbol(934); 247 | 6: FQDSEquation.ActiveEditArea.AddEqExtSymbol(915); 248 | 7: FQDSEquation.ActiveEditArea.AddEqExtSymbol(919); 249 | 8: FQDSEquation.ActiveEditArea.AddEqExtSymbol(921); 250 | 9: FQDSEquation.ActiveEditArea.AddEqExtSymbol(922); 251 | 10: FQDSEquation.ActiveEditArea.AddEqExtSymbol(923); 252 | 11: FQDSEquation.ActiveEditArea.AddEqExtSymbol(924); 253 | 12: FQDSEquation.ActiveEditArea.AddEqExtSymbol(925); 254 | 13: FQDSEquation.ActiveEditArea.AddEqExtSymbol(927); 255 | 14: FQDSEquation.ActiveEditArea.AddEqExtSymbol(928); 256 | 15: FQDSEquation.ActiveEditArea.AddEqExtSymbol(920); 257 | 16: FQDSEquation.ActiveEditArea.AddEqExtSymbol(929); 258 | 17: FQDSEquation.ActiveEditArea.AddEqExtSymbol(931); 259 | 18: FQDSEquation.ActiveEditArea.AddEqExtSymbol(932); 260 | 19: FQDSEquation.ActiveEditArea.AddEqExtSymbol(933); 261 | 20: FQDSEquation.ActiveEditArea.AddEqExtSymbol(937); 262 | 21: FQDSEquation.ActiveEditArea.AddEqExtSymbol(926); 263 | 22: FQDSEquation.ActiveEditArea.AddEqExtSymbol(936); 264 | 23: FQDSEquation.ActiveEditArea.AddEqExtSymbol(918); 265 | end; 266 | 11: 267 | case AToolButton.ImageIndex of 268 | 0: FQDSEquation.ActiveEditArea.AddEqBrackets(kbRound); 269 | 1: FQDSEquation.ActiveEditArea.AddEqBrackets(kbSquare); 270 | 2: FQDSEquation.ActiveEditArea.AddEqBrackets(kbFigure); 271 | 3: FQDSEquation.ActiveEditArea.AddEqBrackets(kbCorner); 272 | 4: FQDSEquation.ActiveEditArea.AddEqBrackets(kbModule); 273 | 5: FQDSEquation.ActiveEditArea.AddEqBrackets(kbDModule); 274 | end; 275 | 12: 276 | case AToolButton.ImageIndex of 277 | 0: FQDSEquation.ActiveEditArea.AddEqDivision; 278 | 5: FQDSEquation.ActiveEditArea.AddEqSquare; 279 | 280 | end; 281 | 13: 282 | case AToolButton.ImageIndex of 283 | 0: FQDSEquation.ActiveEditArea.AddEqIndex([goIndexTop]); 284 | 1: FQDSEquation.ActiveEditArea.AddEqIndex([goIndexBottom]); 285 | 2: FQDSEquation.ActiveEditArea.AddEqIndex([goIndexTop, goIndexBottom]); 286 | end; 287 | 14: 288 | case AToolButton.ImageIndex of 289 | 0: FQDSEquation.ActiveEditArea.AddEqSumma([]); 290 | 1: FQDSEquation.ActiveEditArea.AddEqSumma([goLimitBottom]); 291 | 2: FQDSEquation.ActiveEditArea.AddEqSumma([goLimitTop, goLimitBottom]); 292 | 3: FQDSEquation.ActiveEditArea.AddEqSumma([goIndexBottom]); 293 | 4: FQDSEquation.ActiveEditArea.AddEqSumma([goIndexTop, goIndexBottom]); 294 | end; 295 | 15: 296 | case AToolButton.ImageIndex of 297 | 0: FQDSEquation.ActiveEditArea.AddEqIntegral([], 1, False); 298 | 1: FQDSEquation.ActiveEditArea.AddEqIntegral([goLimitTop, goLimitBottom], 1, False); 299 | 2: FQDSEquation.ActiveEditArea.AddEqIntegral([goIndexTop, goIndexBottom], 1, False); 300 | 3: FQDSEquation.ActiveEditArea.AddEqIntegral([], 1, False); 301 | 4: FQDSEquation.ActiveEditArea.AddEqIntegral([goLimitBottom], 1, False); 302 | 5: FQDSEquation.ActiveEditArea.AddEqIntegral([goIndexBottom], 1, False); 303 | 6: FQDSEquation.ActiveEditArea.AddEqIntegral([], 2, False); 304 | 7: FQDSEquation.ActiveEditArea.AddEqIntegral([goLimitBottom], 2, False); 305 | 8: FQDSEquation.ActiveEditArea.AddEqIntegral([goIndexBottom], 2, False); 306 | 9: FQDSEquation.ActiveEditArea.AddEqIntegral([], 3, False); 307 | 10: FQDSEquation.ActiveEditArea.AddEqIntegral([goLimitBottom], 3, False); 308 | 11: FQDSEquation.ActiveEditArea.AddEqIntegral([goIndexBottom], 3, False); 309 | 12: FQDSEquation.ActiveEditArea.AddEqIntegral([], 1, True); 310 | 13: FQDSEquation.ActiveEditArea.AddEqIntegral([goLimitBottom], 1, True); 311 | 14: FQDSEquation.ActiveEditArea.AddEqIntegral([goIndexBottom], 1, True); 312 | 15: FQDSEquation.ActiveEditArea.AddEqIntegral([], 2, True); 313 | 16: FQDSEquation.ActiveEditArea.AddEqIntegral([goLimitBottom], 2, True); 314 | 17: FQDSEquation.ActiveEditArea.AddEqIntegral([goIndexBottom], 2, True); 315 | 18: FQDSEquation.ActiveEditArea.AddEqIntegral([], 3, True); 316 | 19: FQDSEquation.ActiveEditArea.AddEqIntegral([goLimitBottom], 3, True); 317 | 20: FQDSEquation.ActiveEditArea.AddEqIntegral([goIndexBottom], 3, True); 318 | end; 319 | 16: 320 | case AToolButton.ImageIndex of 321 | 0: FQDSEquation.ActiveEditArea.AddEqVector([], aeBottom); 322 | 1: FQDSEquation.ActiveEditArea.AddEqVector([kaDouble], aeBottom); 323 | 2: FQDSEquation.ActiveEditArea.AddEqVector([], aeTop); 324 | 3: FQDSEquation.ActiveEditArea.AddEqVector([kaDouble], aeTop); 325 | 4: FQDSEquation.ActiveEditArea.AddEqVector([kaRight], aeBottom); 326 | 5: FQDSEquation.ActiveEditArea.AddEqVector([kaLeft], aeBottom); 327 | 6: FQDSEquation.ActiveEditArea.AddEqVector([kaRight, kaLeft], aeBottom); 328 | 7: FQDSEquation.ActiveEditArea.AddEqVector([kaRight], aeTop); 329 | 8: FQDSEquation.ActiveEditArea.AddEqVector([kaLeft], aeTop); 330 | 9: FQDSEquation.ActiveEditArea.AddEqVector([kaRight, kaLeft], aeTop); 331 | end; 332 | 17: 333 | case AToolButton.ImageIndex of 334 | 0: FQDSEquation.ActiveEditArea.AddEqArrow([kaRight], aeTop); 335 | 1: FQDSEquation.ActiveEditArea.AddEqArrow([kaLeft], aeTop); 336 | 2: FQDSEquation.ActiveEditArea.AddEqArrow([kaLeft, kaRight], aeTop); 337 | 3: FQDSEquation.ActiveEditArea.AddEqArrow([kaRight], aeBottom); 338 | 4: FQDSEquation.ActiveEditArea.AddEqArrow([kaLeft], aeBottom); 339 | 5: FQDSEquation.ActiveEditArea.AddEqArrow([kaLeft, kaRight], aeBottom); 340 | end; 341 | 18: 342 | case AToolButton.ImageIndex of 343 | 0: FQDSEquation.ActiveEditArea.AddEqMultiply([]); 344 | 1: FQDSEquation.ActiveEditArea.AddEqMultiply([goLimitBottom]); 345 | 2: FQDSEquation.ActiveEditArea.AddEqMultiply([goLimitTop, goLimitBottom]); 346 | 3: FQDSEquation.ActiveEditArea.AddEqMultiply([goIndexBottom]); 347 | 4: FQDSEquation.ActiveEditArea.AddEqMultiply([goIndexTop, goIndexBottom]); 348 | 5: FQDSEquation.ActiveEditArea.AddEqCoMult([]); 349 | 6: FQDSEquation.ActiveEditArea.AddEqCoMult([goLimitBottom]); 350 | 7: FQDSEquation.ActiveEditArea.AddEqCoMult([goLimitTop, goLimitBottom]); 351 | 8: FQDSEquation.ActiveEditArea.AddEqCoMult([goIndexBottom]); 352 | 9: FQDSEquation.ActiveEditArea.AddEqCoMult([goIndexTop, goIndexBottom]); 353 | 10: FQDSEquation.ActiveEditArea.AddEqIntersection([]); 354 | 11: FQDSEquation.ActiveEditArea.AddEqIntersection([goLimitBottom]); 355 | 12: FQDSEquation.ActiveEditArea.AddEqIntersection([goLimitTop, goLimitBottom]); 356 | 13: FQDSEquation.ActiveEditArea.AddEqIntersection([goIndexBottom]); 357 | 14: FQDSEquation.ActiveEditArea.AddEqIntersection([goIndexTop, goIndexBottom]); 358 | 15: FQDSEquation.ActiveEditArea.AddEqJoin([]); 359 | 16: FQDSEquation.ActiveEditArea.AddEqJoin([goLimitBottom]); 360 | 17: FQDSEquation.ActiveEditArea.AddEqJoin([goLimitTop, goLimitBottom]); 361 | 18: FQDSEquation.ActiveEditArea.AddEqJoin([goIndexBottom]); 362 | 19: FQDSEquation.ActiveEditArea.AddEqJoin([goIndexTop, goIndexBottom]); 363 | end; 364 | 19: {(kmHoriz, kmVert, kmSquare)} 365 | case AToolButton.ImageIndex of 366 | 0: FQDSEquation.ActiveEditArea.AddEqMatrix(kmHoriz, 2); 367 | 1: FQDSEquation.ActiveEditArea.AddEqMatrix(kmVert, 2); 368 | 2: FQDSEquation.ActiveEditArea.AddEqMatrix(kmSquare, 4); 369 | 3: FQDSEquation.ActiveEditArea.AddEqMatrix(kmHoriz, 3); 370 | 4: FQDSEquation.ActiveEditArea.AddEqMatrix(kmVert, 3); 371 | 5: FQDSEquation.ActiveEditArea.AddEqMatrix(kmSquare, 9); 372 | 6: FQDSEquation.ActiveEditArea.AddEqMatrix(kmHoriz, 4); 373 | 7: FQDSEquation.ActiveEditArea.AddEqMatrix(kmVert, 4); 374 | 8: FQDSEquation.ActiveEditArea.AddEqMatrix(kmSquare, 16); 375 | end; 376 | end; 377 | if FQDSEquation.Enabled then FQDSEquation.SetFocus; 378 | end; 379 | end; 380 | 381 | procedure TSelectEquation.CreateDescript; 382 | var 383 | i, j, LangID: Integer; 384 | function EqData(Count, Height, Width: Integer; AVisible: String): TEqData; 385 | begin 386 | Result.Count:=Count; 387 | Result.Height:=Height; 388 | Result.Width:=Width; 389 | Result.Visible:=AVisible; 390 | end; 391 | begin 392 | SetLength(FEqDataList, 20); 393 | FEqDataList[ 0]:=EqData(19,20,40,'1101111111111111111'); 394 | FEqDataList[ 1]:=EqData(11,10,10,'11000011100'); 395 | FEqDataList[ 2]:=EqData(11,15,15,'00100010000'); 396 | FEqDataList[ 3]:=EqData(20,15,15,'00000000000000000000'); 397 | FEqDataList[ 4]:=EqData(12,10,10,'101111110011'); 398 | FEqDataList[ 5]:=EqData(14,15,15,'11111100000000'); 399 | FEqDataList[ 6]:=EqData( 8,10,10,'00000100'); 400 | FEqDataList[ 7]:=EqData(12,10,10,'000100000000'); 401 | FEqDataList[ 8]:=EqData(18,10,10,'101000011101101111'); 402 | FEqDataList[ 9]:=EqData(28,15,15,'1111111111111111111111111111'); 403 | FEqDataList[10]:=EqData(24,10,10,'111111111111111111111111'); 404 | FEqDataList[11]:=EqData(30,20,20,'111111000000000000000000000000'); 405 | FEqDataList[12]:=EqData( 9,20,20,'100001000'{'101011100'}); 406 | FEqDataList[13]:=EqData(15,20,20,'111000000000000'); 407 | FEqDataList[14]:=EqData( 5,20,20,'11111'); 408 | FEqDataList[15]:=EqData(21,20,20,'111111111111111111111'); 409 | FEqDataList[16]:=EqData(10,15,15,'1111111111'); 410 | FEqDataList[17]:=EqData( 6,15,15,'111111'); 411 | FEqDataList[18]:=EqData(20,20,20,'11111111111111111111'); 412 | FEqDataList[19]:=EqData(12,20,20,'111111111000'); 413 | LangID:=1; 414 | case FLanguage of 415 | lEnglish: LangID:=3; 416 | lRussian: LangID:=1; 417 | lDeutsche: LangID:=2; 418 | end; 419 | 420 | for i:=0 to Length(FEqDataList)-1 do begin 421 | SetLength(FEqDataList[i].DescrList, FEqDataList[i].Count); 422 | for j:=0 to Length(FEqDataList[i].DescrList)-1 do 423 | FEqDataList[i].DescrList[j]:=GetString(Format('%d%s%s',[LangID,IntToStrZero(i,2),IntToStrZero(j,2)])); 424 | end; 425 | end; 426 | 427 | procedure TSelectEquation.CreateImageLists; 428 | var 429 | i: Integer; 430 | {$IFDEF FPC} 431 | bmp: TBitmap; 432 | {$ENDIF} 433 | begin 434 | FImageLists:=TImageLists.Create; 435 | for i:=0 to Length(FEqDataList)-1 do begin 436 | FImageLists.Insert(i, TImageList.Create(Self)); 437 | FImageLists.Items[i].Width:=FEqDataList[i].Width; 438 | FImageLists.Items[i].Height:=FEqDataList[i].Height; 439 | {$IFDEF FPC} 440 | bmp := TBitmap.Create; 441 | bmp.Transparent := true; 442 | bmp.TransparentColor := clWhite; 443 | bmp.LoadFromResourceName(HINSTANCE, 'BT'+IntToStrZero(i, 2)); 444 | FImageLists.Items[i].AddSliced(bmp, FEqDataList[i].Count, 1); 445 | bmp.Free; 446 | {$ELSE} 447 | FImageLists.Items[i].GetResource(rtBitmap,'BT'+IntToStrZero(i, 2),FImageLists.Items[i].Width,[lrTransparent],clWhite); 448 | {$ENDIF} 449 | end; 450 | end; 451 | 452 | procedure TSelectEquation.CreateLabel; 453 | begin 454 | FLabel:=TLabel.Create(Self); 455 | FLabel.Parent:=Self; 456 | FLabel.Align:=alTop; 457 | FLabel.Caption:=''; 458 | FLabel.WordWrap:=True; 459 | end; 460 | 461 | procedure TSelectEquation.CreatePageControl; 462 | var 463 | TabSheet: TTabSheet; 464 | i: Integer; 465 | begin 466 | FPageControl:=TPageControl.Create(Self); 467 | FPageControl.Parent:=Self; 468 | FPageControl.Align:=alClient; 469 | {$IFDEF FPC} 470 | {$IF LCL_FullVersion >= 2010000} 471 | FPageControl.Style:=tsButtons; 472 | {$IFEND} 473 | {$ENDIF} 474 | for i:=1 to Length(FEqDataList)-1 do begin 475 | TabSheet:=TTabSheet.Create(FPageControl); 476 | TabSheet.Parent:=FPageControl; 477 | TabSheet.PageControl:=FPageControl; 478 | FPageControl.Pages[i-1].TabVisible := False; 479 | CreateToolBar(TabSheet, i); 480 | end; 481 | FPageControl.ActivePageIndex:=0; 482 | end; 483 | 484 | procedure TSelectEquation.CreateToolBar(AParent: TWinControl; Index: Integer); 485 | var 486 | ToolButton: TToolButton; 487 | i: Integer; 488 | begin 489 | FToolBar:=TToolBar.Create(Self); 490 | FToolBar.Parent:=AParent; 491 | FToolBar.AutoSize:=True; 492 | FToolBar.Flat:=True; 493 | FToolBar.ButtonHeight:=FEqDataList[Index].Height + 8; 494 | FToolBar.ButtonWidth:=FEqDataList[Index].Width; 495 | FToolBar.Images:=FImageLists.Items[Index]; 496 | for i:=FEqDataList[Index].Count-1 downto 0 do begin 497 | ToolButton:=TToolButton.Create(FToolBar); 498 | ToolButton.Parent:=FToolBar; 499 | ToolButton.Hint:=FEqDataList[Index].DescrList[i]; 500 | ToolButton.ShowHint:=True; 501 | ToolButton.ImageIndex:=i; 502 | ToolButton.OnMouseMove:=BtMouseMove; 503 | if AParent is TSelectEquation then begin 504 | ToolButton.Tag:=i; 505 | ToolButton.Enabled:=FPageControl.PageCount>i; 506 | ToolButton.OnClick:=BtPanelClick; 507 | end; 508 | if AParent is TTabSheet then begin 509 | ToolButton.Tag:=Index; 510 | ToolButton.Enabled:=True; 511 | ToolButton.OnClick:=BtTabSheetClick; 512 | end; 513 | ToolButton.AutoSize:=True; 514 | ToolButton.Visible:=FEqDataList[Index].Visible[i+1]='1'; 515 | 516 | end; 517 | end; 518 | 519 | constructor TSelectEquation.Create(AOwner: TComponent); 520 | begin 521 | inherited; 522 | FLanguage:=lRussian; 523 | CreateDescript; 524 | CreateImageLists; 525 | end; 526 | 527 | destructor TSelectEquation.Destroy; 528 | begin 529 | FLabel.Free; 530 | FPageControl.Free; 531 | FImageLists.Free; 532 | inherited; 533 | end; 534 | 535 | 536 | procedure TSelectEquation.SetQDSEquation(AQDSEquation: TQDSEquation); 537 | begin 538 | FQDSEquation:=AQDSEquation; 539 | end; 540 | 541 | procedure TSelectEquation.CreateWnd; 542 | begin 543 | inherited CreateWnd; 544 | CreatePageControl; 545 | CreateLabel; 546 | CreateToolBar(Self, 0); 547 | //AutoSize:=True; 548 | FToolBar.Buttons[0].Click; 549 | end; 550 | 551 | 552 | procedure TSelectEquation.SetLanguage(const Value: TLanguage); 553 | begin 554 | FLanguage := Value; 555 | CreateDescript; 556 | end; 557 | 558 | end. 559 | -------------------------------------------------------------------------------- /source/Equations.pas: -------------------------------------------------------------------------------- 1 | //{$Define DEMO} 2 | unit Equations; 3 | 4 | {$IFDEF FPC} 5 | {$MODE Delphi} 6 | {$ENDIF} 7 | 8 | interface 9 | 10 | uses 11 | SysUtils, Windows, Messages, Classes, Graphics, Controls, ExtCtrls, Forms, 12 | Dialogs, Contnrs, UsefulUtils, Math; 13 | 14 | type 15 | TKindBracket=(kbRound, kbSquare, kbFigure, kbCorner, kbModule, kbDModule); 16 | TKindArrow = set of (kaRight, kaLeft, kaDouble); 17 | TAlignEA = (aeTop, aeBottom); 18 | TGroupOptions = set of (goLimitTop, goLimitBottom, goIndexTop, goIndexBottom); 19 | TKindMatrix = (kmHoriz, kmVert, kmSquare); 20 | 21 | TExpression = record 22 | ClassName: string; 23 | ExprData: string; 24 | end; 25 | 26 | TExprArray = array of TExpression; 27 | TEditArea = class; 28 | TEquation = class; 29 | TEditAreaList = class(TObjectList) 30 | private 31 | function GetItem(Index: Integer): TEditArea; 32 | procedure SetItem(Index: Integer; AValue: TEditArea); 33 | public 34 | property Items[Index: Integer]: TEditArea read GetItem write SetItem; 35 | end; 36 | 37 | TEquationList = class(TStringList) 38 | private 39 | function GetItem(Index: Integer): TEquation; 40 | procedure PutItem(Index: Integer; AValue: TEquation); 41 | public 42 | property Items[Index: Integer]: TEquation read GetItem write PutItem; 43 | end; 44 | 45 | TQDSGraphic = class(TCustomControl) 46 | private 47 | FBkColor: TColor; 48 | procedure SetBkColor(AValue: TColor); virtual; 49 | protected 50 | function GetExprData(const ExprData: String): TExprArray; 51 | procedure RefreshDimensions; virtual; abstract; 52 | property BkColor: TColor read FBkColor write SetBkColor; 53 | property Canvas; 54 | property Font; 55 | public 56 | constructor Create(AOwner: TComponent); override; 57 | end; 58 | 59 | TEquatStore = class(TQDSGraphic) 60 | private 61 | FEditAreaIndex: Integer; 62 | FEditAreaList: TEditAreaList; 63 | FLevel: Integer; 64 | FUpdateCount: Integer; 65 | Kp: Double; 66 | procedure SetEditAreaIndex(AValue: Integer); 67 | procedure SetEditAreaList(AValue: TEditAreaList); 68 | procedure SetUpdateState(Updating: Boolean); virtual; abstract; 69 | protected 70 | procedure EditAreaDown; dynamic; 71 | procedure EditAreaUp; dynamic; 72 | procedure RefreshEditArea(AEditAreaIndex: Integer = 0); dynamic; 73 | property EditAreaIndex: Integer read FEditAreaIndex write SetEditAreaIndex; 74 | property Level: Integer read FLevel write FLevel; 75 | property UpdateCount: Integer read FUpdateCount; 76 | public 77 | procedure BeginUpdate; 78 | procedure DeleteEditArea; dynamic; 79 | procedure EndUpdate; 80 | procedure InsertEditArea; dynamic; 81 | property EditAreaList: TEditAreaList read FEditAreaList write 82 | SetEditAreaList; 83 | end; 84 | 85 | TQDSEquation = class(TEquatStore) 86 | private 87 | FActiveEditArea: TEditArea; 88 | FOnChange: TNotifyEvent; 89 | FVersion: String; 90 | function GetData: string; 91 | procedure SetBkColor(AValue: TColor); override; 92 | procedure SetData(const AValue: string); 93 | procedure SetUpdateState(Updating: Boolean); override; 94 | procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE; 95 | procedure WMLButtonDown(var Message: TWMLButtonDown); message 96 | WM_LBUTTONDOWN; 97 | protected 98 | function CalcHeight(AIndex: Integer): Integer; 99 | function CalcWidth: Integer; 100 | procedure Change; virtual; 101 | procedure EditAreaDown; override; 102 | procedure EditAreaUp; override; 103 | procedure FontChanged(Sender: TObject); dynamic; 104 | procedure KeyDown(var Key: Word; Shift: TShiftState); override; 105 | procedure RefreshEditArea(AEditAreaIndex: Integer = 0); override; 106 | procedure RefreshDimensions; override; 107 | public 108 | constructor Create(AOwner: TComponent); override; 109 | destructor Destroy; override; 110 | procedure AddEditArea; 111 | procedure DeleteEditArea; override; 112 | procedure InsertEditArea; override; 113 | procedure Paint; override; 114 | property ActiveEditArea: TEditArea read FActiveEditArea write 115 | FActiveEditArea; 116 | property Canvas; 117 | published 118 | property Align; 119 | property Anchors; 120 | property BkColor; 121 | property Data: String read GetData write SetData; 122 | property Enabled; 123 | property Font; 124 | property Version: String read FVersion; 125 | property OnChange: TNotifyEvent read FOnChange write FOnChange; 126 | end; 127 | 128 | TEACursor = class(TQDSGraphic) 129 | private 130 | FComVisible: Boolean; 131 | Timer: TTimer; 132 | function GetParent: TEditArea; 133 | procedure PutParent(AValue: TEditArea); 134 | procedure RefreshVisible; 135 | procedure SetComVisible(Value: Boolean); 136 | protected 137 | procedure Paint; override; 138 | procedure RefreshDimensions; override; 139 | procedure Time(Sender: TObject); 140 | public 141 | constructor Create(AOwner: TComponent); override; 142 | destructor Destroy; override; 143 | property ComVisible: Boolean read FComVisible write SetComVisible; 144 | property Parent: TEditArea read GetParent write PutParent; 145 | end; 146 | 147 | TEditArea = class(TQDSGraphic) 148 | private 149 | FActive: Boolean; 150 | FCursor: TEACursor; 151 | FEquationIndex: Integer; 152 | FEquationList: TEquationList; 153 | Index: Integer; 154 | MainArea: TQDSEquation; 155 | function GetData: string; 156 | function GetIsEmpty: Boolean; 157 | function GetParent: TEquatStore; 158 | procedure OnActive; 159 | procedure OnDeactive; 160 | procedure PutParent(AValue: TEquatStore); 161 | procedure RefreshCursor; 162 | procedure RefreshEquations; 163 | procedure RefreshRecurse; 164 | procedure SetActive(AValue: Boolean); 165 | procedure SetBkColor(AValue: TColor); override; 166 | procedure SetData(const AValue: string); 167 | procedure SetEquationIndex(AValue: Integer); 168 | procedure SetEquationList(AValue: TEquationList); 169 | procedure WMLButtonDown(var Message: TWMLButtonDown); message 170 | WM_LBUTTONDOWN; 171 | protected 172 | 173 | function CalcWidth(AIndex: Integer): Integer; 174 | procedure RefreshDimensions; override; 175 | public 176 | function CalcHeight: Integer; 177 | constructor Create(AOwner: TComponent); override; 178 | destructor Destroy; override; 179 | procedure AddEqBrackets(kb: TKindBracket); 180 | procedure AddEqExtSymbol(SymbolCode: Integer); 181 | procedure AddEqIndex(go: TGroupOptions); 182 | procedure AddEqIntegral(go: TGroupOptions; Size: Integer; Ring: Boolean); 183 | procedure AddEqSimple(Ch: Char); 184 | procedure AddEqVector(ka: TKindArrow; ae: TAlignEA); 185 | procedure AddEqSumma(go: TGroupOptions); 186 | procedure AddEqMultiply(go: TGroupOptions); 187 | procedure AddEqJoin(go: TGroupOptions); 188 | procedure AddEqIntersection(go: TGroupOptions); 189 | procedure AddEqCoMult(go: TGroupOptions); 190 | procedure AddEqArrow(ka: TKindArrow; ae: TAlignEA); 191 | procedure AddEqSquare; 192 | procedure AddEqDivision; 193 | procedure AddEqMatrix(km: TKindMatrix; CountEA: Integer); 194 | procedure DelEquation(AEquationIndex: Integer); 195 | procedure Paint; override; 196 | property Active: Boolean read FActive write SetActive; 197 | property Cursor: TEACursor read FCursor write FCursor; 198 | property Data: string read GetData write SetData; 199 | property EquationIndex: Integer read FEquationIndex write SetEquationIndex; 200 | property EquationList: TEquationList read FEquationList write 201 | SetEquationList; 202 | property IsEmpty: Boolean read GetIsEmpty; 203 | property Parent: TEquatStore read GetParent write PutParent; 204 | end; 205 | 206 | TEquation = class(TEquatStore) 207 | private 208 | Index: Integer; 209 | function GetData: string; virtual; 210 | function GetMidLine: Integer; virtual; 211 | function GetParent: TEditArea; 212 | procedure PutParent(AValue: TEditArea); 213 | procedure SetData(const AValue: string); virtual; 214 | procedure SetUpdateState(Updating: Boolean); override; 215 | procedure WMLButtonDown(var Message: TWMLButtonDown); message 216 | WM_LBUTTONDOWN; 217 | property Data: string read GetData write SetData; 218 | protected 219 | function CalcHeight: Integer; dynamic; 220 | function CalcWidth: Integer; dynamic; 221 | procedure SetCanvasFont; 222 | public 223 | constructor Create(AOwner: TComponent); override; 224 | procedure Paint; override; 225 | property MidLine: Integer read GetMidLine; 226 | property Parent: TEditArea read GetParent write PutParent; 227 | end; 228 | 229 | TEqSimple = class(TEquation) 230 | private 231 | function GetData: string; override; 232 | protected 233 | Ch: Char; 234 | function CalcHeight: Integer; override; 235 | function CalcWidth: Integer; override; 236 | procedure RefreshDimensions; override; 237 | public 238 | procedure Paint; override; 239 | end; 240 | 241 | TEqExtSymbol = class(TEquation) 242 | private 243 | function GetData: string; override; 244 | protected 245 | Symbol: WideChar; 246 | function CalcHeight: Integer; override; 247 | function CalcWidth: Integer; override; 248 | procedure RefreshDimensions; override; 249 | public 250 | procedure Paint; override; 251 | end; 252 | 253 | TEqParent = class(TEquation) 254 | private 255 | function GetData: string; override; 256 | procedure SetBkColor(AValue: TColor); override; 257 | procedure SetData(const AValue: string); override; 258 | public 259 | constructor Create(AOwner: TComponent); override; 260 | destructor Destroy; override; 261 | procedure InsertEditArea; override; 262 | end; 263 | 264 | TEqGroupOp = class(TEqParent) 265 | private 266 | FRing: Boolean; 267 | FSize: Integer; 268 | FSymbol: WideChar; 269 | FGroupOptions: TGroupOptions; 270 | FLimitTop, FLimitBottom, FIndexTop, FIndexBottom: TEditArea; 271 | function GetCommonHeight: Integer; 272 | function GetCommonWidth: Integer; 273 | function GetData: string; override; 274 | procedure SetData(const AValue: string); override; 275 | function GetMidLine: Integer; override; 276 | function GetSymbolHeight: Integer; 277 | function GetSymbolWidth: Integer; 278 | function GetTopMargin: Integer; 279 | procedure SetGroupOptions(Value: TGroupOptions); 280 | procedure SetRing(ARing: Boolean); 281 | procedure SetSize(ASize: Integer); 282 | procedure SetSymbol(Value: WideChar); 283 | protected 284 | function CalcHeight: Integer; override; 285 | function CalcSymbolHeight: Integer; 286 | function CalcSymbolWidth: Integer; 287 | function CalcWidth: Integer; override; 288 | procedure RefreshDimensions; override; 289 | procedure RefreshEA(AEditArea: TEditArea; AKp: Double); 290 | procedure RefreshEditArea(AEditAreaIndex: Integer = 0); override; 291 | public 292 | constructor Create(AOwner: TComponent); override; 293 | property GroupOptions: TGroupOptions read FGroupOptions write SetGroupOptions; 294 | procedure Paint; override; 295 | property Ring: Boolean read FRing write SetRing; 296 | property Size: Integer read FSize write SetSize; 297 | property Symbol: WideChar read FSymbol write SetSymbol; 298 | property SymbolHeight: Integer read GetSymbolHeight; 299 | property SymbolWidth: Integer read GetSymbolWidth; 300 | property TopMargin: Integer read GetTopMargin; 301 | end; 302 | 303 | TEqIntegral = class(TEqGroupOp) 304 | public 305 | constructor Create(AOwner: TComponent); override; 306 | end; 307 | 308 | TEqSumma = class(TEqGroupOp) 309 | public 310 | constructor Create(AOwner: TComponent); override; 311 | end; 312 | 313 | TEqMultiply = class(TEqGroupOp) 314 | public 315 | constructor Create(AOwner: TComponent); override; 316 | end; 317 | 318 | TEqIntersection = class(TEqGroupOp) 319 | public 320 | constructor Create(AOwner: TComponent); override; 321 | end; 322 | 323 | TEqJoin = class(TEqGroupOp) 324 | public 325 | constructor Create(AOwner: TComponent); override; 326 | end; 327 | 328 | TEqCoMult = class(TEqGroupOp) 329 | public 330 | constructor Create(AOwner: TComponent); override; 331 | end; 332 | 333 | TEqIndex = class(TEqParent) 334 | private 335 | FIndexTop, FIndexBottom: TEditArea; 336 | FGroupOptions: TGroupOptions; 337 | function GetData: String; override; 338 | procedure SetData(const AValue: String); override; 339 | procedure SetGroupOptions(const Value: TGroupOptions); 340 | protected 341 | function CalcHeight: Integer; override; 342 | function CalcWidth: Integer; override; 343 | procedure RefreshDimensions; override; 344 | procedure RefreshEA(AEditArea: TEditArea); 345 | procedure RefreshEditArea(AEditAreaIndex: Integer = 0); override; 346 | public 347 | constructor Create(AOwner: TComponent); override; 348 | procedure Paint; override; 349 | property GroupOptions: TGroupOptions read FGroupOptions write SetGroupOptions; 350 | end; 351 | 352 | TEqBrackets = class(TEqParent) 353 | private 354 | FLSymbol: WideChar; 355 | FRSymbol: WideChar; 356 | FKindBracket: TKindBracket; 357 | procedure SetKindBracket(AValue: TKindBracket); 358 | procedure SetLSymbol(Value: WideChar); 359 | procedure SetRSymbol(Value: WideChar); 360 | protected 361 | function CalcSymbolWidth: Integer; 362 | function CalcSymbolHeight: Integer; 363 | function CalcHeight: Integer; override; 364 | function CalcWidth: Integer; override; 365 | function GetCommonHeight: Integer; 366 | procedure RefreshDimensions; override; 367 | procedure RefreshEditArea(AEditAreaIndex: Integer = 0); override; 368 | property KindBracket: TKindBracket read FKindBracket write SetKindBracket; 369 | public 370 | constructor Create(AOwner: TComponent); override; 371 | procedure Paint; override; 372 | property LSymbol: WideChar read FLSymbol write SetLSymbol; 373 | property RSymbol: WideChar read FRSymbol write SetRSymbol; 374 | end; 375 | 376 | TEqArrow = class(TEqParent) 377 | private 378 | ArrowHeight, LineHeight: Integer; 379 | FAlignEA: TAlignEA; 380 | FKindArrow: TKindArrow; 381 | 382 | function GetMidLine: Integer; override; 383 | procedure SetKindArrow(Value: TKindArrow); 384 | procedure SetAlignEA(const Value: TAlignEA); 385 | protected 386 | function CalcHeight: Integer; override; 387 | function CalcWidth: Integer; override; 388 | procedure RefreshDimensions; override; 389 | procedure RefreshEditArea(AEditAreaIndex: Integer = 0); override; 390 | public 391 | constructor Create(AOwner: TComponent); override; 392 | procedure Paint; override; 393 | property AlignEA: TAlignEA read FAlignEA write SetAlignEA; 394 | property KindArrow: TKindArrow read FKindArrow write SetKindArrow; 395 | end; 396 | 397 | TEqSquare = class(TEqParent) 398 | private 399 | LineHeight: Integer; 400 | GalkaLeft: Integer; 401 | function GetMidLine: Integer; override; 402 | protected 403 | function CalcHeight: Integer; override; 404 | function CalcWidth: Integer; override; 405 | procedure RefreshDimensions; override; 406 | procedure RefreshEditArea(AEditAreaIndex: Integer = 0); override; 407 | public 408 | constructor Create(AOwner: TComponent); override; 409 | procedure Paint; override; 410 | end; 411 | 412 | TEqDivision = class(TEqParent) 413 | private 414 | ArrowHeight, LineHeight: Integer; 415 | function GetData: String; override; 416 | procedure SetData(const AValue: String); override; 417 | function GetMidLine: Integer; override; 418 | protected 419 | function CalcHeight: Integer; override; 420 | function CalcWidth: Integer; override; 421 | procedure RefreshDimensions; override; 422 | procedure RefreshEA(AEditArea: TEditArea); 423 | procedure RefreshEditArea(AEditAreaIndex: Integer = 0); override; 424 | public 425 | constructor Create(AOwner: TComponent); override; 426 | procedure Paint; override; 427 | end; 428 | 429 | TEqVector = class(TEqParent) 430 | private 431 | ArrowHeight, LineHeight: Integer; 432 | FAlignEA: TAlignEA; 433 | FKindArrow: TKindArrow; 434 | 435 | function GetMidLine: Integer; override; 436 | procedure SetKindArrow(Value: TKindArrow); 437 | procedure SetAlignEA(const Value: TAlignEA); 438 | protected 439 | function CalcHeight: Integer; override; 440 | function CalcWidth: Integer; override; 441 | procedure RefreshDimensions; override; 442 | procedure RefreshEditArea(AEditAreaIndex: Integer = 0); override; 443 | public 444 | constructor Create(AOwner: TComponent); override; 445 | procedure Paint; override; 446 | property AlignEA: TAlignEA read FAlignEA write SetAlignEA; 447 | property KindArrow: TKindArrow read FKindArrow write SetKindArrow; 448 | end; 449 | 450 | TEqMatrix = class(TEqParent) 451 | private 452 | FCountEA: Integer; 453 | FKindMatrix: TKindMatrix; 454 | procedure SetData(const AValue: String); override; 455 | function GetData: String; override; 456 | function GetDX: Integer; 457 | function GetDY: Integer; 458 | function GetColWidth(ACol: Integer): Integer; 459 | function GetRowHeight(ARow: Integer): Integer; 460 | function GetMidLine: Integer; override; 461 | procedure SetKindMatrix(const Value: TKindMatrix); 462 | procedure SetCountEA(const Value: Integer); 463 | protected 464 | function CalcHeight: Integer; override; 465 | function CalcWidth: Integer; override; 466 | procedure RefreshDimensions; override; 467 | procedure RefreshEA(AEditArea: TEditArea); 468 | procedure RefreshEditArea(AEditAreaIndex: Integer = 0); override; 469 | public 470 | constructor Create(AOwner: TComponent); override; 471 | procedure Paint; override; 472 | property CountEA: Integer read FCountEA write SetCountEA; 473 | property KindMatrix: TKindMatrix read FKindMatrix write SetKindMatrix; 474 | end; 475 | procedure Register; 476 | 477 | 478 | implementation 479 | 480 | uses Types; 481 | 482 | 483 | procedure Register; 484 | begin 485 | RegisterComponents('QDS Equations', [TQDSEquation]); 486 | end; 487 | 488 | 489 | { 490 | ******************************** TEquationList ********************************* 491 | } 492 | function TEquationList.GetItem(Index: Integer): TEquation; 493 | begin 494 | Result := TEquation(inherited Objects[Index]); 495 | end; 496 | 497 | procedure TEquationList.PutItem(Index: Integer; AValue: TEquation); 498 | begin 499 | inherited Objects[Index] := AValue; 500 | end; 501 | 502 | 503 | { 504 | ******************************** TEditAreaList ********************************* 505 | } 506 | function TEditAreaList.GetItem(Index: Integer): TEditArea; 507 | begin 508 | Result := TEditArea(inherited Items[Index]); 509 | end; 510 | 511 | procedure TEditAreaList.SetItem(Index: Integer; AValue: TEditArea); 512 | begin 513 | inherited Items[Index] := AValue; 514 | end; 515 | 516 | { 517 | ********************************* TQDSGraphic ********************************** 518 | } 519 | constructor TQDSGraphic.Create(AOwner: TComponent); 520 | begin 521 | inherited; 522 | end; 523 | 524 | function TQDSGraphic.GetExprData(const ExprData: String): TExprArray; 525 | var 526 | i, ExprCount: Integer; 527 | 528 | function StandOnLetter: Boolean; 529 | begin 530 | while (not(AnsiChar(ExprData[i]) in ['a'..'z', 'A'..'Z']))and(i<Length(ExprData)) do Inc(i); 531 | Result:=(AnsiChar(ExprData[i]) in ['a'..'z', 'A'..'Z']); 532 | end; 533 | function GetNextClass: String; 534 | begin 535 | Result:=''; 536 | while (AnsiChar(ExprData[i]) in ['a'..'z', 'A'..'Z']) do begin 537 | Result:=Result+ExprData[i]; 538 | Inc(i); 539 | end; 540 | Result:=Trim(Result); 541 | end; 542 | function StandOnBracket: Integer; 543 | begin 544 | Result:=0; 545 | while (not(AnsiChar(ExprData[i]) in ['(', ')']))and(i<Length(ExprData)) do Inc(i); 546 | if ExprData[i]='(' then Result:=1; 547 | if ExprData[i]=')' then Result:=-1; 548 | end; 549 | function GetNextExpr: String; 550 | var BracketsCount, ExprBegin, ExprEnd: Integer; 551 | begin 552 | Result:=''; 553 | BracketsCount:=StandOnBracket; 554 | ExprBegin:=Succ(i); 555 | while BracketsCount<>0 do begin 556 | Inc(i); 557 | Inc(BracketsCount, StandOnBracket); 558 | end; 559 | ExprEnd:=i; 560 | Result:=Trim(Copy(ExprData, ExprBegin, ExprEnd-ExprBegin)); 561 | end; 562 | 563 | begin 564 | ExprCount:=0; 565 | SetLength(Result, ExprCount); 566 | i:=1; 567 | if Length(ExprData)>0 then while StandOnLetter do begin 568 | Inc(ExprCount); 569 | SetLength(Result, ExprCount); 570 | Result[ExprCount-1].ClassName:=GetNextClass; 571 | Result[ExprCount-1].ExprData:=GetNextExpr; 572 | end; 573 | end; 574 | 575 | 576 | procedure TQDSGraphic.SetBkColor(AValue: TColor); 577 | begin 578 | FBkColor := AValue; 579 | Repaint; 580 | end; 581 | 582 | { 583 | ********************************* TEquatStore ********************************** 584 | } 585 | procedure TEquatStore.BeginUpdate; 586 | begin 587 | if FUpdateCount = 0 then SetUpdateState(True); 588 | Inc(FUpdateCount); 589 | end; 590 | 591 | procedure TEquatStore.DeleteEditArea; 592 | begin 593 | end; 594 | 595 | procedure TEquatStore.EditAreaDown; 596 | begin 597 | end; 598 | 599 | procedure TEquatStore.EditAreaUp; 600 | begin 601 | end; 602 | 603 | procedure TEquatStore.EndUpdate; 604 | begin 605 | Dec(FUpdateCount); 606 | if FUpdateCount = 0 then SetUpdateState(False); 607 | end; 608 | 609 | procedure TEquatStore.InsertEditArea; 610 | begin 611 | end; 612 | 613 | procedure TEquatStore.RefreshEditArea(AEditAreaIndex: Integer = 0); 614 | begin 615 | end; 616 | 617 | procedure TEquatStore.SetEditAreaIndex(AValue: Integer); 618 | begin 619 | if (AValue<>FEditAreaIndex)and(AValue>=0)and(AValue<FEditAreaList.Count) then 620 | FEditAreaIndex := AValue; 621 | end; 622 | 623 | procedure TEquatStore.SetEditAreaList(AValue: TEditAreaList); 624 | begin 625 | FEditAreaList := AValue; 626 | end; 627 | 628 | 629 | { 630 | ********************************* TQDSEquation ********************************* 631 | } 632 | constructor TQDSEquation.Create(AOwner: TComponent); 633 | begin 634 | inherited; 635 | Height:=400; 636 | Width:=600; 637 | FEditAreaIndex:=0; 638 | FBkColor:=clWhite; 639 | FLevel:=0; 640 | Kp:=1; 641 | FEditAreaList:=TEditAreaList.Create; 642 | Font.Name:='Times New Roman'; 643 | Font.Charset:=Russian_Charset; 644 | Font.Color:=clBlack; 645 | Font.OnChange := FontChanged; 646 | InsertEditArea; 647 | Font.Size:=20; 648 | {$IfDef DEMO} 649 | FVersion:='1.0.0.0 Demo'; 650 | MessageBox(Application.Handle, 'This is demo version of component. Please, visit site http://qdsequations.com for more information.', 'Qds Equations', 48); 651 | {$Else} 652 | FVersion:='1.0.0.0 '; 653 | {$EndIf} 654 | end; 655 | 656 | destructor TQDSEquation.Destroy; 657 | begin 658 | FEditAreaList.Free; 659 | inherited Destroy; 660 | end; 661 | 662 | procedure TQDSEquation.AddEditArea; 663 | var 664 | AEditAreaIndex: Integer; 665 | begin 666 | AEditAreaIndex:=FEditAreaIndex+1; 667 | FEditAreaList.Insert(AEditAreaIndex, TEditArea.Create(Self)); 668 | FEditAreaList.Items[AEditAreaIndex].Parent:=Self; 669 | FEditAreaList.Items[AEditAreaIndex].MainArea:=Self; 670 | FEditAreaList.Items[AEditAreaIndex].Font:=Font; 671 | FEditAreaList.Items[AEditAreaIndex].Font.Size:=Round(Font.Size*Kp); 672 | FEditAreaList.Items[AEditAreaIndex].Index:=AEditAreaIndex; 673 | FEditAreaList.Items[AEditAreaIndex].RefreshDimensions; 674 | EditAreaIndex:=AEditAreaIndex; 675 | RefreshEditArea(FEditAreaIndex); 676 | FEditAreaList.Items[FEditAreaIndex].Active:=True; 677 | Change; 678 | end; 679 | 680 | function TQDSEquation.CalcHeight(AIndex: Integer): Integer; 681 | var 682 | i: Integer; 683 | begin 684 | Result:=Font.Size; 685 | for i:=0 to AIndex-1 do 686 | Inc(Result, FEditAreaList.Items[i].Height+Font.Size); 687 | end; 688 | 689 | function TQDSEquation.CalcWidth: Integer; 690 | var 691 | i: Integer; 692 | begin 693 | Result:=0; 694 | for i:=0 to FEditAreaList.Count-1 do 695 | if FEditAreaList.Items[i].Width>Result then 696 | Result:=FEditAreaList.Items[i].Width; 697 | end; 698 | 699 | procedure TQDSEquation.Change; 700 | begin 701 | inherited Changed; 702 | if Assigned(FOnChange) then FOnChange(Self); 703 | end; 704 | 705 | procedure TQDSEquation.DeleteEditArea; 706 | begin 707 | if FEditAreaList.Count>1 then FEditAreaList.Delete(FEditAreaIndex); 708 | if FEditAreaIndex>=FEditAreaList.Count then Dec(FEditAreaIndex); 709 | RefreshEditArea(FEditAreaIndex); 710 | FEditAreaList.Items[FEditAreaIndex].Active:=True; 711 | Change; 712 | end; 713 | 714 | procedure TQDSEquation.EditAreaDown; 715 | begin 716 | EditAreaIndex:=EditAreaIndex+1; 717 | FEditAreaList.Items[FEditAreaIndex].Active:=True; 718 | end; 719 | 720 | procedure TQDSEquation.EditAreaUp; 721 | begin 722 | EditAreaIndex:=EditAreaIndex-1; 723 | FEditAreaList.Items[FEditAreaIndex].Active:=True; 724 | end; 725 | 726 | procedure TQDSEquation.FontChanged(Sender: TObject); 727 | begin 728 | RefreshEditArea; 729 | end; 730 | 731 | function TQDSEquation.GetData: String; 732 | var 733 | i: Integer; 734 | begin 735 | Result:=''; 736 | for i:=0 to FEditAreaList.Count-1 do begin 737 | Result:=Format('%sEditArea(%s)',[Result, FEditAreaList.Items[i].Data]); 738 | end; 739 | end; 740 | 741 | procedure TQDSEquation.InsertEditArea; 742 | begin 743 | FEditAreaList.Insert(FEditAreaIndex, TEditArea.Create(Self)); 744 | FEditAreaList.Items[FEditAreaIndex].Parent:=Self; 745 | FEditAreaList.Items[FEditAreaIndex].MainArea:=Self; 746 | FEditAreaList.Items[FEditAreaIndex].Font:=Font; 747 | FEditAreaList.Items[FEditAreaIndex].Font.Size:=Round(Font.Size*Kp); 748 | FEditAreaList.Items[FEditAreaIndex].Index:=FEditAreaIndex; 749 | FEditAreaList.Items[FEditAreaIndex].RefreshDimensions; 750 | RefreshEditArea(FEditAreaIndex); 751 | FEditAreaList.Items[FEditAreaIndex].Active:=True; 752 | Change; 753 | end; 754 | 755 | procedure TQDSEquation.KeyDown(var Key: Word; Shift: TShiftState); 756 | begin 757 | if Assigned(ActiveEditArea) then case Key of 758 | VK_UP: 759 | ActiveEditArea.Parent.EditAreaUp; 760 | VK_DOWN: 761 | ActiveEditArea.Parent.EditAreaDown; 762 | VK_DELETE: begin 763 | if ActiveEditArea.IsEmpty then ActiveEditArea.Parent.DeleteEditArea else 764 | ActiveEditArea.DelEquation(ActiveEditArea.EquationIndex); 765 | end; 766 | VK_BACK: begin 767 | if ActiveEditArea.EquationIndex=0 then begin 768 | if EditAreaIndex>0 then begin 769 | EditAreaIndex:=EditAreaIndex-1; 770 | DeleteEditArea; 771 | end; 772 | end else if not ActiveEditArea.IsEmpty then begin 773 | ActiveEditArea.EquationIndex:=ActiveEditArea.EquationIndex-1; 774 | ActiveEditArea.DelEquation(ActiveEditArea.EquationIndex); 775 | end; 776 | end; 777 | VK_RETURN: begin 778 | if ActiveEditArea.EquationIndex=0 then InsertEditArea 779 | else AddEditArea; 780 | end; 781 | VK_HOME: 782 | ActiveEditArea.EquationIndex:=0; 783 | VK_END: 784 | ActiveEditArea.EquationIndex:=ActiveEditArea.EquationList.Count; 785 | VK_LEFT: 786 | ActiveEditArea.EquationIndex:=ActiveEditArea.EquationIndex-1; 787 | VK_RIGHT: 788 | ActiveEditArea.EquationIndex:=ActiveEditArea.EquationIndex+1; 789 | 790 | VK_NUMPAD0..VK_NUMPAD9, 48..90, 166..228, VK_MULTIPLY, VK_ADD, 791 | VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL, VK_DIVIDE: begin 792 | ActiveEditArea.AddEqSimple(GetCharFromVirtualKey(Key)[1]); 793 | ActiveEditArea.EquationIndex:=ActiveEditArea.EquationIndex+1; 794 | end; 795 | //else ShowMessage(IntToStr(Key)); 796 | end; 797 | inherited KeyDown(Key, Shift); 798 | end; 799 | 800 | procedure TQDSEquation.Paint; 801 | {$IfDef DEMO} 802 | var 803 | demo: string; 804 | {$EndIf} 805 | begin 806 | Canvas.Pen.Style := psInsideFrame; 807 | Canvas.Pen.Color:=clBlack; 808 | Canvas.Brush.Style := bsClear; 809 | Canvas.Brush.Color := FBkColor; 810 | Canvas.Rectangle(0, 0, Width, Height); 811 | 812 | {$IfDef DEMO} 813 | demo:='DEMO VERSION, VISIT http://qdsequations.com'; 814 | Canvas.TextOut(3,2,demo); 815 | Canvas.TextOut(3,Height-Canvas.TextHeight('demo')-2, demo); 816 | {$EndIf} 817 | end; 818 | 819 | procedure TQDSEquation.RefreshEditArea(AEditAreaIndex: Integer = 0); 820 | var 821 | i: Integer; 822 | begin 823 | for i:=AEditAreaIndex to FEditAreaList.Count-1 do begin 824 | FEditAreaList.Items[i].Left:=Font.Size div 2; 825 | FEditAreaList.Items[i].Top:=CalcHeight(i); 826 | FEditAreaList.Items[i].Font.Assign(Font); 827 | FEditAreaList.Items[i].Font.Size:=Round(Font.Size*Kp); 828 | FEditAreaList.Items[i].RefreshDimensions; 829 | 830 | FEditAreaList.Items[i].Index:=i; 831 | FEditAreaList.Items[i].BkColor:=BkColor; 832 | end; 833 | end; 834 | 835 | procedure TQDSEquation.RefreshDimensions; 836 | begin 837 | end; 838 | 839 | procedure TQDSEquation.SetBkColor(AValue: TColor); 840 | var 841 | i: Integer; 842 | begin 843 | FBkColor := AValue; 844 | for i:=0 to FEditAreaList.Count-1 do begin 845 | FEditAreaList.Items[i].BkColor:=FBkColor; 846 | end; 847 | Repaint; 848 | end; 849 | 850 | procedure TQDSEquation.SetData(const AValue: string); 851 | var 852 | i: Integer; 853 | ExprArray: TExprArray; 854 | begin 855 | FEditAreaList.Clear; 856 | FEditAreaIndex:=0; 857 | ExprArray:=GetExprData(AValue); 858 | for i:=0 to Length(ExprArray)-1 do begin 859 | if ExprArray[i].ClassName = 'EditArea' then begin 860 | if FEditAreaList.Count>0 then AddEditArea else InsertEditArea; 861 | FEditAreaList.Items[i].Data:=ExprArray[i].ExprData; 862 | //EditAreaIndex:=EditAreaIndex+1; 863 | end; 864 | end; 865 | end; 866 | 867 | procedure TQDSEquation.SetUpdateState(Updating: Boolean); 868 | begin 869 | if not Updating then Change; 870 | end; 871 | 872 | procedure TQDSEquation.WMGetDlgCode(var Message: TWMGetDlgCode); 873 | begin 874 | Message.Result:=DLGC_WANTARROWS; 875 | end; 876 | 877 | procedure TQDSEquation.WMLButtonDown(var Message: TWMLButtonDown); 878 | begin 879 | SetFocus; 880 | end; 881 | 882 | { 883 | ********************************** TEACursor *********************************** 884 | } 885 | constructor TEACursor.Create(AOwner: TComponent); 886 | begin 887 | inherited Create(AOwner); 888 | Timer:=TTimer.Create(Self); 889 | Timer.Interval:=500; 890 | Timer.OnTimer:=Time; 891 | end; 892 | 893 | destructor TEACursor.Destroy; 894 | begin 895 | Timer.Free; 896 | inherited Destroy; 897 | end; 898 | 899 | function TEACursor.GetParent: TEditArea; 900 | begin 901 | Result := TEditArea(inherited Parent); 902 | end; 903 | 904 | procedure TEACursor.Paint; 905 | begin 906 | Canvas.Pen.Style := psSolid; 907 | Canvas.Brush.Style := bsClear; 908 | Canvas.Brush.Color := clBlack; 909 | Canvas.Rectangle(0, 0, Width, Height); 910 | end; 911 | 912 | procedure TEACursor.PutParent(AValue: TEditArea); 913 | begin 914 | inherited Parent := AValue; 915 | end; 916 | 917 | procedure TEACursor.RefreshDimensions; 918 | begin 919 | Width:=2; 920 | Height:=Font.Size; 921 | RefreshVisible; 922 | end; 923 | 924 | procedure TEACursor.RefreshVisible; 925 | begin 926 | Visible:= not Visible and FComVisible and Parent.MainArea.Enabled; 927 | end; 928 | 929 | procedure TEACursor.SetComVisible(Value: Boolean); 930 | begin 931 | Timer.Enabled:=Value; 932 | FComVisible:=Value; 933 | RefreshVisible; 934 | end; 935 | 936 | procedure TEACursor.Time(Sender: TObject); 937 | begin 938 | RefreshVisible; 939 | end; 940 | 941 | { 942 | ********************************** TEditArea *********************************** 943 | } 944 | constructor TEditArea.Create(AOwner: TComponent); 945 | begin 946 | inherited Create(AOwner); 947 | FEquationList:=TEquationList.Create; 948 | FEquationIndex:=0; 949 | FBkColor:=clWhite; 950 | 951 | FCursor:=TEACursor.Create(Self); 952 | FCursor.Parent:=Self; 953 | end; 954 | 955 | destructor TEditArea.Destroy; 956 | begin 957 | FCursor.Free; 958 | FEquationList.Free; 959 | if Active then MainArea.ActiveEditArea:=nil; 960 | inherited Destroy; 961 | end; 962 | 963 | procedure TEditArea.AddEqBrackets(kb: TKindBracket); 964 | var TempStr: String; 965 | begin 966 | TempStr:='Brackets'; 967 | case kb of 968 | kbRound: TempStr:=TempStr+'Round'; 969 | kbSquare: TempStr:=TempStr+'Square'; 970 | kbFigure: TempStr:=TempStr+'Figure'; 971 | kbCorner: TempStr:=TempStr+'Corner'; 972 | kbModule: TempStr:=TempStr+'Module'; 973 | kbDModule: TempStr:=TempStr+'DModule'; 974 | end; 975 | FEquationList.InsertObject(FEquationIndex, TempStr, TEqBrackets.Create(Self)); 976 | (FEquationList.Items[FEquationIndex] as TEqBrackets).KindBracket:=kb; 977 | RefreshRecurse; 978 | MainArea.Change; 979 | end; 980 | 981 | procedure TEditArea.AddEqExtSymbol(SymbolCode: Integer); 982 | begin 983 | FEquationList.InsertObject(FEquationIndex, 'ExtSymbol', TEqExtSymbol.Create(Self)); 984 | (FEquationList.Items[FEquationIndex] as TEqExtSymbol).Symbol:=WideChar(SymbolCode); 985 | RefreshRecurse; 986 | MainArea.Change; 987 | end; 988 | 989 | procedure TEditArea.AddEqIndex(go: TGroupOptions); 990 | var TempStr: String; 991 | begin 992 | TempStr:='Index'; 993 | if goIndexTop in go then TempStr:=TempStr+'Top'; 994 | if goIndexBottom in go then TempStr:=TempStr+'Bottom'; 995 | FEquationList.InsertObject(FEquationIndex, TempStr, TEqIndex.Create(Self)); 996 | (FEquationList.Items[FEquationIndex] as TEqIndex).GroupOptions:=go; 997 | RefreshRecurse; 998 | MainArea.Change; 999 | end; 1000 | 1001 | procedure TEditArea.AddEqIntegral(go: TGroupOptions; Size: Integer; Ring: Boolean); 1002 | var TempStr: String; 1003 | begin 1004 | TempStr:='Int'; 1005 | if go=[goLimitBottom] then TempStr:=TempStr+'LimitBottom'; 1006 | if go=[goIndexBottom] then TempStr:=TempStr+'IndexBottom'; 1007 | if go=[goLimitBottom, goLimitTop] then TempStr:=TempStr+'LimitBottomTop'; 1008 | if go=[goIndexBottom, goIndexTop] then TempStr:=TempStr+'IndexBottomTop'; 1009 | 1010 | case Size of 1011 | 1: TempStr:=TempStr+'One'; 1012 | 2: TempStr:=TempStr+'Two'; 1013 | 3: TempStr:=TempStr+'Three'; 1014 | end; 1015 | 1016 | if Ring then TempStr:=TempStr+'Ring'; 1017 | 1018 | FEquationList.InsertObject(FEquationIndex, TempStr, TEqIntegral.Create(Self)); 1019 | 1020 | (FEquationList.Items[FEquationIndex] as TEqIntegral).Ring:=Ring; 1021 | (FEquationList.Items[FEquationIndex] as TEqIntegral).Size:=Size; 1022 | (FEquationList.Items[FEquationIndex] as TEqIntegral).GroupOptions:=go; 1023 | 1024 | RefreshRecurse; 1025 | MainArea.Change; 1026 | end; 1027 | 1028 | procedure TEditArea.AddEqVector(ka: TKindArrow; ae: TAlignEA); 1029 | var TempStr: String; 1030 | begin 1031 | TempStr:='Vector'; 1032 | if kaRight in ka then TempStr:=TempStr+'kaRight'; 1033 | if kaLeft in ka then TempStr:=TempStr+'kaLeft'; 1034 | if kaDouble in ka then TempStr:=TempStr+'kaDouble'; 1035 | case ae of 1036 | aeTop: TempStr:=TempStr+'aeTop'; 1037 | aeBottom: TempStr:=TempStr+'aeBottom'; 1038 | end; 1039 | FEquationList.InsertObject(FEquationIndex, TempStr, TEqVector.Create(Self)); 1040 | (FEquationList.Items[FEquationIndex] as TEqVector).AlignEA:=ae; 1041 | (FEquationList.Items[FEquationIndex] as TEqVector).KindArrow:=ka; 1042 | RefreshRecurse; 1043 | MainArea.Change; 1044 | end; 1045 | 1046 | procedure TEditArea.AddEqSimple(Ch: Char); 1047 | begin 1048 | FEquationList.InsertObject(FEquationIndex, 'Simple', TEqSimple.Create(Self)); 1049 | (FEquationList.Items[FEquationIndex] as TEqSimple).Ch:=Ch; 1050 | RefreshRecurse; 1051 | MainArea.Change; 1052 | end; 1053 | 1054 | procedure TEditArea.AddEqSumma(go: TGroupOptions); 1055 | var TempStr: String; 1056 | begin 1057 | TempStr:='Sum'; 1058 | if go=[goLimitBottom] then TempStr:=TempStr+'LimitBottom'; 1059 | if go=[goIndexBottom] then TempStr:=TempStr+'IndexBottom'; 1060 | if go=[goLimitBottom, goLimitTop] then TempStr:=TempStr+'LimitBottomTop'; 1061 | if go=[goIndexBottom, goIndexTop] then TempStr:=TempStr+'IndexBottomTop'; 1062 | 1063 | 1064 | FEquationList.InsertObject(FEquationIndex, TempStr, TEqSumma.Create(Self)); 1065 | (FEquationList.Items[FEquationIndex] as TEqSumma).GroupOptions:=go; 1066 | 1067 | RefreshRecurse; 1068 | MainArea.Change; 1069 | end; 1070 | 1071 | procedure TEditArea.AddEqMultiply(go: TGroupOptions); 1072 | var TempStr: String; 1073 | begin 1074 | TempStr:='Multiply'; 1075 | if go=[goLimitBottom] then TempStr:=TempStr+'LimitBottom'; 1076 | if go=[goIndexBottom] then TempStr:=TempStr+'IndexBottom'; 1077 | if go=[goLimitBottom, goLimitTop] then TempStr:=TempStr+'LimitBottomTop'; 1078 | if go=[goIndexBottom, goIndexTop] then TempStr:=TempStr+'IndexBottomTop'; 1079 | 1080 | 1081 | FEquationList.InsertObject(FEquationIndex, TempStr, TEqMultiply.Create(Self)); 1082 | (FEquationList.Items[FEquationIndex] as TEqMultiply).GroupOptions:=go; 1083 | 1084 | RefreshRecurse; 1085 | MainArea.Change; 1086 | end; 1087 | 1088 | procedure TEditArea.AddEqIntersection(go: TGroupOptions); 1089 | var TempStr: String; 1090 | begin 1091 | TempStr:='Intersection'; 1092 | if go=[goLimitBottom] then TempStr:=TempStr+'LimitBottom'; 1093 | if go=[goIndexBottom] then TempStr:=TempStr+'IndexBottom'; 1094 | if go=[goLimitBottom, goLimitTop] then TempStr:=TempStr+'LimitBottomTop'; 1095 | if go=[goIndexBottom, goIndexTop] then TempStr:=TempStr+'IndexBottomTop'; 1096 | FEquationList.InsertObject(FEquationIndex, TempStr, TEqIntersection.Create(Self)); 1097 | (FEquationList.Items[FEquationIndex] as TEqIntersection).GroupOptions:=go; 1098 | RefreshRecurse; 1099 | MainArea.Change; 1100 | end; 1101 | 1102 | procedure TEditArea.AddEqJoin(go: TGroupOptions); 1103 | var TempStr: String; 1104 | begin 1105 | TempStr:='Join'; 1106 | if go=[goLimitBottom] then TempStr:=TempStr+'LimitBottom'; 1107 | if go=[goIndexBottom] then TempStr:=TempStr+'IndexBottom'; 1108 | if go=[goLimitBottom, goLimitTop] then TempStr:=TempStr+'LimitBottomTop'; 1109 | if go=[goIndexBottom, goIndexTop] then TempStr:=TempStr+'IndexBottomTop'; 1110 | FEquationList.InsertObject(FEquationIndex, TempStr, TEqJoin.Create(Self)); 1111 | (FEquationList.Items[FEquationIndex] as TEqJoin).GroupOptions:=go; 1112 | RefreshRecurse; 1113 | MainArea.Change; 1114 | end; 1115 | 1116 | procedure TEditArea.AddEqCoMult(go: TGroupOptions); 1117 | var TempStr: String; 1118 | begin 1119 | TempStr:='CoMult'; 1120 | if go=[goLimitBottom] then TempStr:=TempStr+'LimitBottom'; 1121 | if go=[goIndexBottom] then TempStr:=TempStr+'IndexBottom'; 1122 | if go=[goLimitBottom, goLimitTop] then TempStr:=TempStr+'LimitBottomTop'; 1123 | if go=[goIndexBottom, goIndexTop] then TempStr:=TempStr+'IndexBottomTop'; 1124 | FEquationList.InsertObject(FEquationIndex, TempStr, TEqCoMult.Create(Self)); 1125 | (FEquationList.Items[FEquationIndex] as TEqCoMult).GroupOptions:=go; 1126 | RefreshRecurse; 1127 | MainArea.Change; 1128 | end; 1129 | 1130 | procedure TEditArea.AddEqArrow(ka: TKindArrow; ae: TAlignEA); 1131 | var TempStr: String; 1132 | begin 1133 | TempStr:='Arrow'; 1134 | if kaRight in ka then TempStr:=TempStr+'kaRight'; 1135 | if kaLeft in ka then TempStr:=TempStr+'kaLeft'; 1136 | case ae of 1137 | aeTop: TempStr:=TempStr+'aeTop'; 1138 | aeBottom: TempStr:=TempStr+'aeBottom'; 1139 | end; 1140 | FEquationList.InsertObject(FEquationIndex, TempStr, TEqArrow.Create(Self)); 1141 | (FEquationList.Items[FEquationIndex] as TEqArrow).AlignEA:=ae; 1142 | (FEquationList.Items[FEquationIndex] as TEqArrow).KindArrow:=ka; 1143 | 1144 | RefreshRecurse; 1145 | MainArea.Change; 1146 | end; 1147 | 1148 | procedure TEditArea.AddEqSquare; 1149 | begin 1150 | FEquationList.InsertObject(FEquationIndex, 'Square', TEqSquare.Create(Self)); 1151 | RefreshRecurse; 1152 | MainArea.Change; 1153 | end; 1154 | 1155 | procedure TEditArea.AddEqDivision; 1156 | begin 1157 | FEquationList.InsertObject(FEquationIndex, 'Division', TEqDivision.Create(Self)); 1158 | RefreshRecurse; 1159 | MainArea.Change; 1160 | end; 1161 | 1162 | procedure TEditArea.AddEqMatrix(km: TKindMatrix; CountEA: Integer); 1163 | var TempStr: String; 1164 | begin 1165 | TempStr:='Matrix'; 1166 | case km of 1167 | kmHoriz: TempStr:=TempStr+'kmHoriz'; 1168 | kmVert: TempStr:=TempStr+'kmVert'; 1169 | kmSquare: TempStr:=TempStr+'kmSquare'; 1170 | end; 1171 | 1172 | FEquationList.InsertObject(FEquationIndex, TempStr, TEqMatrix.Create(Self)); 1173 | (FEquationList.Items[FEquationIndex] as TEqMatrix).KindMatrix:=km; 1174 | (FEquationList.Items[FEquationIndex] as TEqMatrix).CountEA:=CountEA; 1175 | RefreshRecurse; 1176 | MainArea.Change; 1177 | end; 1178 | 1179 | 1180 | function TEditArea.CalcHeight: Integer; 1181 | var 1182 | i, SumHeight: Integer; 1183 | begin 1184 | Result:=FCursor.Height; 1185 | for i:=0 to EquationList.Count-1 do begin 1186 | SumHeight:=5+Round(EquationList.Items[i].CalcHeight+ 1187 | Abs(EquationList.Items[i].CalcHeight/2-EquationList.Items[i].MidLine)); 1188 | if Result<SumHeight then 1189 | Result:=SumHeight; 1190 | end; 1191 | end; 1192 | 1193 | function TEditArea.CalcWidth(AIndex: Integer): Integer; 1194 | var 1195 | i: Integer; 1196 | begin 1197 | Result:=0; 1198 | for i:=0 to AIndex-1 do begin 1199 | Result:=Result+FCursor.Width+EquationList.Items[i].CalcWidth; 1200 | end; 1201 | end; 1202 | 1203 | procedure TEditArea.DelEquation(AEquationIndex: Integer); 1204 | begin 1205 | if (AEquationIndex>=0)and(AEquationIndex<EquationList.Count) then begin 1206 | EquationList.Items[AEquationIndex].Free; 1207 | EquationList.Delete(AEquationIndex); 1208 | RefreshRecurse; 1209 | end; 1210 | MainArea.Change; 1211 | end; 1212 | 1213 | function TEditArea.GetData: string; 1214 | var 1215 | i: Integer; 1216 | begin 1217 | Result:=''; 1218 | for i:=0 to FEquationList.Count-1 do begin 1219 | Result:=Format('%s%s(%s)',[Result, FEquationList.Strings[i],FEquationList.Items[i].Data]); 1220 | end; 1221 | end; 1222 | 1223 | function TEditArea.GetIsEmpty: Boolean; 1224 | begin 1225 | Result:=FEquationList.Count=0; 1226 | end; 1227 | 1228 | function TEditArea.GetParent: TEquatStore; 1229 | begin 1230 | Result := TEquatStore(inherited Parent); 1231 | end; 1232 | 1233 | procedure TEditArea.OnActive; 1234 | begin 1235 | if Assigned(MainArea.ActiveEditArea) then if MainArea.ActiveEditArea<>Self then 1236 | MainArea.ActiveEditArea.Active:=False; 1237 | MainArea.ActiveEditArea:=Self; 1238 | Parent.EditAreaIndex:=Index; 1239 | Repaint; 1240 | FCursor.ComVisible:=True; 1241 | end; 1242 | 1243 | procedure TEditArea.OnDeactive; 1244 | begin 1245 | Repaint; 1246 | FCursor.ComVisible:=False; 1247 | end; 1248 | 1249 | procedure TEditArea.Paint; 1250 | begin 1251 | if MainArea.Enabled and (FActive or GetIsEmpty) then begin 1252 | Canvas.Pen.Color := clBlack; 1253 | Canvas.Pen.Style := psDot; 1254 | end else begin 1255 | Canvas.Pen.Color := FBkColor; 1256 | Canvas.Pen.Style := psSolid; 1257 | end; 1258 | Canvas.Brush.Style := bsClear; 1259 | Canvas.Brush.Color := FBkColor; 1260 | Canvas.Rectangle(0, 0, Width, Height); 1261 | end; 1262 | 1263 | procedure TEditArea.PutParent(AValue: TEquatStore); 1264 | begin 1265 | inherited Parent := AValue; 1266 | end; 1267 | 1268 | procedure TEditArea.RefreshCursor; 1269 | begin 1270 | FCursor.Font:=Font; 1271 | FCursor.RefreshDimensions; 1272 | FCursor.Top:=Round((Height-FCursor.Height)/2); 1273 | FCursor.Left:=CalcWidth(FEquationIndex); 1274 | end; 1275 | 1276 | procedure TEditArea.RefreshDimensions; 1277 | begin 1278 | Height:=CalcHeight+2; 1279 | if IsEmpty then begin 1280 | Width:=Font.Size; 1281 | end else begin 1282 | Width:=CalcWidth(EquationList.Count)+Font.Size div 3; 1283 | RefreshEquations; 1284 | end; 1285 | RefreshCursor; 1286 | end; 1287 | 1288 | procedure TEditArea.RefreshEquations; 1289 | var 1290 | i: Integer; 1291 | begin 1292 | for i:=0 to FEquationList.Count-1 do begin 1293 | FEquationList.Items[i].Index:=i; 1294 | FEquationList.Items[i].Font:=Font; 1295 | FEquationList.Items[i].BkColor:=FBkColor; 1296 | FEquationList.Items[i].RefreshDimensions; 1297 | FEquationList.Items[i].Level:=Parent.Level+1; 1298 | FEquationList.Items[i].Left:=CalcWidth(i)+FCursor.Width; 1299 | 1300 | FEquationList.Items[i].Top:=Round(Height/2-FEquationList.Items[i].MidLine); 1301 | end; 1302 | end; 1303 | 1304 | procedure TEditArea.RefreshRecurse; 1305 | begin 1306 | Parent.RefreshEditArea(Index); 1307 | if Parent.ClassName<>'TQDSEquation' then begin 1308 | (Parent as TEquation).Parent.RefreshRecurse; 1309 | end; 1310 | end; 1311 | 1312 | procedure TEditArea.SetActive(AValue: Boolean); 1313 | begin 1314 | FActive := AValue; 1315 | if AValue then OnActive 1316 | else OnDeactive; 1317 | end; 1318 | 1319 | procedure TEditArea.SetBkColor(AValue: TColor); 1320 | var 1321 | i: Integer; 1322 | begin 1323 | FBkColor := AValue; 1324 | for i:=0 to FEquationList.Count-1 do begin 1325 | FEquationList.Items[i].BkColor:=FBkColor; 1326 | FEquationList.Items[i].RefreshDimensions; 1327 | end; 1328 | Repaint; 1329 | end; 1330 | 1331 | procedure TEditArea.SetData(const AValue: string); 1332 | var 1333 | i: Integer; 1334 | ExprArray: TExprArray; 1335 | begin 1336 | for i:=0 to FEquationList.Count-1 do FEquationList.Items[i].Free; 1337 | FEquationList.Clear; 1338 | FEquationIndex:=0; 1339 | ExprArray:=GetExprData(AValue); 1340 | for i:=0 to Length(ExprArray)-1 do begin 1341 | if ExprArray[i].ClassName = 'Simple' then begin 1342 | AddEqSimple(ExprArray[i].ExprData[1]); 1343 | EquationIndex:=EquationIndex+1; 1344 | end; 1345 | if ExprArray[i].ClassName = 'ExtSymbol' then begin 1346 | AddEqExtSymbol(StrToInt(ExprArray[i].ExprData)); 1347 | EquationIndex:=EquationIndex+1; 1348 | end; 1349 | if ExprArray[i].ClassName = 'IndexTop' then begin 1350 | AddEqIndex([goIndexTop]); 1351 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1352 | EquationIndex:=EquationIndex+1; 1353 | end; 1354 | if ExprArray[i].ClassName = 'IndexBottom' then begin 1355 | AddEqIndex([goIndexBottom]); 1356 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1357 | EquationIndex:=EquationIndex+1; 1358 | end; 1359 | if ExprArray[i].ClassName = 'IndexTopBottom' then begin 1360 | AddEqIndex([goIndexTop, goIndexBottom]); 1361 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1362 | EquationIndex:=EquationIndex+1; 1363 | end; 1364 | if ExprArray[i].ClassName = 'BracketsRound' then begin 1365 | AddEqBrackets(kbRound); 1366 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1367 | EquationIndex:=EquationIndex+1; 1368 | end; 1369 | if ExprArray[i].ClassName = 'BracketsSquare' then begin 1370 | AddEqBrackets(kbSquare); 1371 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1372 | EquationIndex:=EquationIndex+1; 1373 | end; 1374 | if ExprArray[i].ClassName = 'BracketsFigure' then begin 1375 | AddEqBrackets(kbFigure); 1376 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1377 | EquationIndex:=EquationIndex+1; 1378 | end; 1379 | if ExprArray[i].ClassName = 'BracketsCorner' then begin 1380 | AddEqBrackets(kbCorner); 1381 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1382 | EquationIndex:=EquationIndex+1; 1383 | end; 1384 | if ExprArray[i].ClassName = 'BracketsModule' then begin 1385 | AddEqBrackets(kbModule); 1386 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1387 | EquationIndex:=EquationIndex+1; 1388 | end; 1389 | if ExprArray[i].ClassName = 'BracketsDModule' then begin 1390 | AddEqBrackets(kbDModule); 1391 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1392 | EquationIndex:=EquationIndex+1; 1393 | end; 1394 | if ExprArray[i].ClassName = 'IntOne' then begin 1395 | AddEqIntegral([], 1, False); 1396 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1397 | EquationIndex:=EquationIndex+1; 1398 | end; 1399 | if ExprArray[i].ClassName = 'IntLimitBottomTopOne' then begin 1400 | AddEqIntegral([goLimitTop, goLimitBottom], 1, False); 1401 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1402 | EquationIndex:=EquationIndex+1; 1403 | end; 1404 | if ExprArray[i].ClassName = 'IntIndexBottomTopOne' then begin 1405 | AddEqIntegral([goIndexTop, goIndexBottom], 1, False); 1406 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1407 | EquationIndex:=EquationIndex+1; 1408 | end; 1409 | if ExprArray[i].ClassName = 'IntLimitBottomOne' then begin 1410 | AddEqIntegral([goLimitBottom], 1, False); 1411 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1412 | EquationIndex:=EquationIndex+1; 1413 | end; 1414 | if ExprArray[i].ClassName = 'IntIndexBottomOne' then begin 1415 | AddEqIntegral([goIndexBottom], 1, False); 1416 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1417 | EquationIndex:=EquationIndex+1; 1418 | end; 1419 | if ExprArray[i].ClassName = 'IntTwo' then begin 1420 | AddEqIntegral([], 2, False); 1421 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1422 | EquationIndex:=EquationIndex+1; 1423 | end; 1424 | if ExprArray[i].ClassName = 'IntLimitBottomTwo' then begin 1425 | AddEqIntegral([goLimitBottom], 2, False); 1426 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1427 | EquationIndex:=EquationIndex+1; 1428 | end; 1429 | if ExprArray[i].ClassName = 'IntIndexBottomTwo' then begin 1430 | AddEqIntegral([goIndexBottom], 2, False); 1431 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1432 | EquationIndex:=EquationIndex+1; 1433 | end; 1434 | if ExprArray[i].ClassName = 'IntThree' then begin 1435 | AddEqIntegral([], 3, False); 1436 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1437 | EquationIndex:=EquationIndex+1; 1438 | end; 1439 | if ExprArray[i].ClassName = 'IntLimitBottomThree' then begin 1440 | AddEqIntegral([goLimitBottom], 3, False); 1441 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1442 | EquationIndex:=EquationIndex+1; 1443 | end; 1444 | if ExprArray[i].ClassName = 'IntIndexBottomThree' then begin 1445 | AddEqIntegral([goIndexBottom], 3, False); 1446 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1447 | EquationIndex:=EquationIndex+1; 1448 | end; 1449 | if ExprArray[i].ClassName = 'IntOneRing' then begin 1450 | AddEqIntegral([], 1, True); 1451 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1452 | EquationIndex:=EquationIndex+1; 1453 | end; 1454 | if ExprArray[i].ClassName = 'IntLimitBottomOneRing' then begin 1455 | AddEqIntegral([goLimitBottom], 1, True); 1456 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1457 | EquationIndex:=EquationIndex+1; 1458 | end; 1459 | if ExprArray[i].ClassName = 'IntIndexBottomOneRing' then begin 1460 | AddEqIntegral([goIndexBottom], 1, True); 1461 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1462 | EquationIndex:=EquationIndex+1; 1463 | end; 1464 | if ExprArray[i].ClassName = 'IntTwoRing' then begin 1465 | AddEqIntegral([], 2, True); 1466 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1467 | EquationIndex:=EquationIndex+1; 1468 | end; 1469 | if ExprArray[i].ClassName = 'IntLimitBottomTwoRing' then begin 1470 | AddEqIntegral([goLimitBottom], 2, True); 1471 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1472 | EquationIndex:=EquationIndex+1; 1473 | end; 1474 | if ExprArray[i].ClassName = 'IntIndexBottomTwoRing' then begin 1475 | AddEqIntegral([goIndexBottom], 2, True); 1476 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1477 | EquationIndex:=EquationIndex+1; 1478 | end; 1479 | if ExprArray[i].ClassName = 'IntThreeRing' then begin 1480 | AddEqIntegral([], 3, True); 1481 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1482 | EquationIndex:=EquationIndex+1; 1483 | end; 1484 | if ExprArray[i].ClassName = 'IntLimitBottomThreeRing' then begin 1485 | AddEqIntegral([goLimitBottom], 3, True); 1486 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1487 | EquationIndex:=EquationIndex+1; 1488 | end; 1489 | if ExprArray[i].ClassName = 'IntIndexBottomThreeRing' then begin 1490 | AddEqIntegral([goIndexBottom], 3, True); 1491 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1492 | EquationIndex:=EquationIndex+1; 1493 | end; 1494 | if ExprArray[i].ClassName = 'Sum' then begin 1495 | AddEqSumma([]); 1496 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1497 | EquationIndex:=EquationIndex+1; 1498 | end; 1499 | if ExprArray[i].ClassName = 'SumLimitBottom' then begin 1500 | AddEqSumma([goLimitBottom]); 1501 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1502 | EquationIndex:=EquationIndex+1; 1503 | end; 1504 | if ExprArray[i].ClassName = 'SumLimitBottomTop' then begin 1505 | AddEqSumma([goLimitTop, goLimitBottom]); 1506 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1507 | EquationIndex:=EquationIndex+1; 1508 | end; 1509 | if ExprArray[i].ClassName = 'SumIndexBottom' then begin 1510 | AddEqSumma([goIndexBottom]); 1511 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1512 | EquationIndex:=EquationIndex+1; 1513 | end; 1514 | if ExprArray[i].ClassName = 'SumIndexBottomTop' then begin 1515 | AddEqSumma([goIndexTop, goIndexBottom]); 1516 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1517 | EquationIndex:=EquationIndex+1; 1518 | end; 1519 | if ExprArray[i].ClassName = 'Multiply' then begin 1520 | AddEqMultiply([]); 1521 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1522 | EquationIndex:=EquationIndex+1; 1523 | end; 1524 | if ExprArray[i].ClassName = 'MultiplyLimitBottom' then begin 1525 | AddEqMultiply([goLimitBottom]); 1526 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1527 | EquationIndex:=EquationIndex+1; 1528 | end; 1529 | if ExprArray[i].ClassName = 'MultiplyLimitBottomTop' then begin 1530 | AddEqMultiply([goLimitTop, goLimitBottom]); 1531 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1532 | EquationIndex:=EquationIndex+1; 1533 | end; 1534 | if ExprArray[i].ClassName = 'MultiplyIndexBottom' then begin 1535 | AddEqMultiply([goIndexBottom]); 1536 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1537 | EquationIndex:=EquationIndex+1; 1538 | end; 1539 | if ExprArray[i].ClassName = 'MultiplyBottomTop' then begin 1540 | AddEqMultiply([goIndexTop, goIndexBottom]); 1541 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1542 | EquationIndex:=EquationIndex+1; 1543 | end; 1544 | if ExprArray[i].ClassName = 'CoMult' then begin 1545 | AddEqCoMult([]); 1546 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1547 | EquationIndex:=EquationIndex+1; 1548 | end; 1549 | if ExprArray[i].ClassName = 'CoMultLimitBottom' then begin 1550 | AddEqCoMult([goLimitBottom]); 1551 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1552 | EquationIndex:=EquationIndex+1; 1553 | end; 1554 | if ExprArray[i].ClassName = 'CoMultLimitBottomTop' then begin 1555 | AddEqCoMult([goLimitTop, goLimitBottom]); 1556 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1557 | EquationIndex:=EquationIndex+1; 1558 | end; 1559 | if ExprArray[i].ClassName = 'CoMultIndexBottom' then begin 1560 | AddEqCoMult([goIndexBottom]); 1561 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1562 | EquationIndex:=EquationIndex+1; 1563 | end; 1564 | if ExprArray[i].ClassName = 'CoMultBottomTop' then begin 1565 | AddEqCoMult([goIndexTop, goIndexBottom]); 1566 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1567 | EquationIndex:=EquationIndex+1; 1568 | end; 1569 | if ExprArray[i].ClassName = 'Intersection' then begin 1570 | AddEqIntersection([]); 1571 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1572 | EquationIndex:=EquationIndex+1; 1573 | end; 1574 | if ExprArray[i].ClassName = 'IntersectionLimitBottom' then begin 1575 | AddEqIntersection([goLimitBottom]); 1576 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1577 | EquationIndex:=EquationIndex+1; 1578 | end; 1579 | if ExprArray[i].ClassName = 'IntersectionLimitBottomTop' then begin 1580 | AddEqIntersection([goLimitTop, goLimitBottom]); 1581 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1582 | EquationIndex:=EquationIndex+1; 1583 | end; 1584 | if ExprArray[i].ClassName = 'IntersectionIndexBottom' then begin 1585 | AddEqIntersection([goIndexBottom]); 1586 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1587 | EquationIndex:=EquationIndex+1; 1588 | end; 1589 | if ExprArray[i].ClassName = 'IntersectionBottomTop' then begin 1590 | AddEqIntersection([goIndexTop, goIndexBottom]); 1591 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1592 | EquationIndex:=EquationIndex+1; 1593 | end; 1594 | if ExprArray[i].ClassName = 'Join' then begin 1595 | AddEqJoin([]); 1596 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1597 | EquationIndex:=EquationIndex+1; 1598 | end; 1599 | if ExprArray[i].ClassName = 'JoinLimitBottom' then begin 1600 | AddEqJoin([goLimitBottom]); 1601 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1602 | EquationIndex:=EquationIndex+1; 1603 | end; 1604 | if ExprArray[i].ClassName = 'JoinLimitBottomTop' then begin 1605 | AddEqJoin([goLimitTop, goLimitBottom]); 1606 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1607 | EquationIndex:=EquationIndex+1; 1608 | end; 1609 | if ExprArray[i].ClassName = 'JoinIndexBottom' then begin 1610 | AddEqJoin([goIndexBottom]); 1611 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1612 | EquationIndex:=EquationIndex+1; 1613 | end; 1614 | if ExprArray[i].ClassName = 'JoinBottomTop' then begin 1615 | AddEqJoin([goIndexTop, goIndexBottom]); 1616 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1617 | EquationIndex:=EquationIndex+1; 1618 | end; 1619 | 1620 | if ExprArray[i].ClassName = 'ArrowkaRightaeTop' then begin 1621 | AddEqArrow([kaRight], aeTop); 1622 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1623 | EquationIndex:=EquationIndex+1; 1624 | end; 1625 | if ExprArray[i].ClassName = 'ArrowkaLeftaeTop' then begin 1626 | AddEqArrow([kaLeft], aeTop); 1627 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1628 | EquationIndex:=EquationIndex+1; 1629 | end; 1630 | if ExprArray[i].ClassName = 'ArrowkaRightkaLeftaeTop' then begin 1631 | AddEqArrow([kaRight, kaLeft], aeTop); 1632 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1633 | EquationIndex:=EquationIndex+1; 1634 | end; 1635 | if ExprArray[i].ClassName = 'ArrowkaRightaeBottom' then begin 1636 | AddEqArrow([kaRight], aeBottom); 1637 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1638 | EquationIndex:=EquationIndex+1; 1639 | end; 1640 | if ExprArray[i].ClassName = 'ArrowkaLeftaeBottom' then begin 1641 | AddEqArrow([kaLeft], aeBottom); 1642 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1643 | EquationIndex:=EquationIndex+1; 1644 | end; 1645 | if ExprArray[i].ClassName = 'ArrowkaRightkaLeftaeBottom' then begin 1646 | AddEqArrow([kaRight, kaLeft], aeBottom); 1647 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1648 | EquationIndex:=EquationIndex+1; 1649 | end; 1650 | if ExprArray[i].ClassName = 'Square' then begin 1651 | AddEqSquare; 1652 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1653 | EquationIndex:=EquationIndex+1; 1654 | end; 1655 | if ExprArray[i].ClassName = 'Division' then begin 1656 | AddEqDivision; 1657 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1658 | EquationIndex:=EquationIndex+1; 1659 | end; 1660 | if ExprArray[i].ClassName = 'VectoraeBottom' then begin 1661 | AddEqVector([], aeBottom); 1662 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1663 | EquationIndex:=EquationIndex+1; 1664 | end; 1665 | if ExprArray[i].ClassName = 'VectorkaDoubleaeBottom' then begin 1666 | AddEqVector([kaDouble], aeBottom); 1667 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1668 | EquationIndex:=EquationIndex+1; 1669 | end; 1670 | if ExprArray[i].ClassName = 'VectoraeTop' then begin 1671 | AddEqVector([], aeTop); 1672 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1673 | EquationIndex:=EquationIndex+1; 1674 | end; 1675 | if ExprArray[i].ClassName = 'VectorkaDoubleaeTop' then begin 1676 | AddEqVector([kaDouble], aeTop); 1677 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1678 | EquationIndex:=EquationIndex+1; 1679 | end; 1680 | if ExprArray[i].ClassName = 'VectorkaRightaeBottom' then begin 1681 | AddEqVector([kaRight], aeBottom); 1682 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1683 | EquationIndex:=EquationIndex+1; 1684 | end; 1685 | if ExprArray[i].ClassName = 'VectorkaLeftaeBottom' then begin 1686 | AddEqVector([kaLeft], aeBottom); 1687 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1688 | EquationIndex:=EquationIndex+1; 1689 | end; 1690 | if ExprArray[i].ClassName = 'VectorkaRightkaLeftaeBottom' then begin 1691 | AddEqVector([kaRight, kaLeft], aeBottom); 1692 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1693 | EquationIndex:=EquationIndex+1; 1694 | end; 1695 | if ExprArray[i].ClassName = 'VectorkaRightaeTop' then begin 1696 | AddEqVector([kaRight], aeTop); 1697 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1698 | EquationIndex:=EquationIndex+1; 1699 | end; 1700 | if ExprArray[i].ClassName = 'VectorkaLeftaeTop' then begin 1701 | AddEqVector([kaLeft], aeTop); 1702 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1703 | EquationIndex:=EquationIndex+1; 1704 | end; 1705 | if ExprArray[i].ClassName = 'VectorkaRightkaLeftaeTop' then begin 1706 | AddEqVector([kaRight, kaLeft], aeTop); 1707 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1708 | EquationIndex:=EquationIndex+1; 1709 | end; 1710 | if ExprArray[i].ClassName = 'MatrixkmHoriz' then begin 1711 | AddEqMatrix(kmHoriz, 0); 1712 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1713 | EquationIndex:=EquationIndex+1; 1714 | end; 1715 | if ExprArray[i].ClassName = 'MatrixkmVert' then begin 1716 | AddEqMatrix(kmVert, 0); 1717 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1718 | EquationIndex:=EquationIndex+1; 1719 | end; 1720 | if ExprArray[i].ClassName = 'MatrixkmSquare' then begin 1721 | AddEqMatrix(kmSquare, 0); 1722 | FEquationList.Items[FEquationIndex].Data:=ExprArray[i].ExprData; 1723 | EquationIndex:=EquationIndex+1; 1724 | end; 1725 | end; 1726 | end; 1727 | 1728 | procedure TEditArea.SetEquationIndex(AValue: Integer); 1729 | begin 1730 | if (AValue>=0)and(AValue<=EquationList.Count) then FEquationIndex := AValue; 1731 | RefreshCursor; 1732 | end; 1733 | 1734 | procedure TEditArea.SetEquationList(AValue: TEquationList); 1735 | begin 1736 | FEquationList := AValue; 1737 | end; 1738 | 1739 | procedure TEditArea.WMLButtonDown(var Message: TWMLButtonDown); 1740 | begin 1741 | MainArea.SetFocus; 1742 | Active:=True; 1743 | end; 1744 | 1745 | 1746 | { 1747 | ********************************** TEquation *********************************** 1748 | } 1749 | constructor TEquation.Create(AOwner: TComponent); 1750 | begin 1751 | inherited Create(AOwner); 1752 | Parent:=AOwner as TEditArea; 1753 | Kp:=1; 1754 | end; 1755 | 1756 | function TEquation.CalcHeight: Integer; 1757 | begin 1758 | Result := 0; 1759 | end; 1760 | 1761 | function TEquation.CalcWidth: Integer; 1762 | begin 1763 | Result := 0; 1764 | end; 1765 | 1766 | function TEquation.GetData: string; 1767 | begin 1768 | end; 1769 | 1770 | function TEquation.GetMidLine: Integer; 1771 | begin 1772 | Result:=Height div 2; 1773 | end; 1774 | 1775 | function TEquation.GetParent: TEditArea; 1776 | begin 1777 | Result := TEditArea(inherited Parent); 1778 | end; 1779 | 1780 | procedure TEquation.Paint; 1781 | begin 1782 | end; 1783 | 1784 | procedure TEquation.PutParent(AValue: TEditArea); 1785 | begin 1786 | inherited Parent := AValue; 1787 | end; 1788 | 1789 | procedure TEquation.SetCanvasFont; 1790 | begin 1791 | Canvas.Pen.Style := psSolid; 1792 | Canvas.Pen.Color:=BkColor; 1793 | Canvas.Brush.Style := bsClear; 1794 | Canvas.Brush.Color:=BkColor; 1795 | Canvas.Font.Assign(Font); 1796 | end; 1797 | 1798 | procedure TEquation.SetData(const AValue: string); 1799 | begin 1800 | end; 1801 | 1802 | procedure TEquation.SetUpdateState(Updating: Boolean); 1803 | begin 1804 | if not Updating then RefreshEditArea; 1805 | end; 1806 | 1807 | procedure TEquation.WMLButtonDown(var Message: TWMLButtonDown); 1808 | begin 1809 | Parent.WMLButtonDown(Message); 1810 | end; 1811 | 1812 | { 1813 | ********************************** TEqSimple *********************************** 1814 | } 1815 | function TEqSimple.CalcHeight: Integer; 1816 | begin 1817 | SetCanvasFont; 1818 | Result:=Canvas.TextHeight(Ch); 1819 | end; 1820 | 1821 | function TEqSimple.CalcWidth: Integer; 1822 | begin 1823 | SetCanvasFont; 1824 | Result:=Canvas.TextWidth(Ch); 1825 | end; 1826 | 1827 | function TEqSimple.GetData: string; 1828 | begin 1829 | Result:=Ch; 1830 | end; 1831 | 1832 | procedure TEqSimple.Paint; 1833 | begin 1834 | Canvas.TextOut(0,0,Ch); 1835 | end; 1836 | 1837 | procedure TEqSimple.RefreshDimensions; 1838 | begin 1839 | Height:=CalcHeight; 1840 | Width:=CalcWidth; 1841 | end; 1842 | 1843 | { 1844 | ********************************* TEqExtSymbol ********************************* 1845 | } 1846 | function TEqExtSymbol.CalcHeight: Integer; 1847 | var 1848 | Size: TSize; 1849 | begin 1850 | SetCanvasFont; 1851 | GetTextExtentPoint32W(Canvas.Handle,@Symbol,1,Size); 1852 | Result:=Size.CY 1853 | end; 1854 | 1855 | function TEqExtSymbol.CalcWidth: Integer; 1856 | var 1857 | Size: TSize; 1858 | begin 1859 | SetCanvasFont; 1860 | GetTextExtentPoint32W(Canvas.Handle,@Symbol,1,Size); 1861 | Result:=Size.CX; 1862 | end; 1863 | 1864 | function TEqExtSymbol.GetData: string; 1865 | begin 1866 | Result:=IntToStr(Integer(Symbol)); 1867 | end; 1868 | 1869 | procedure TEqExtSymbol.Paint; 1870 | begin 1871 | TextOutW(Canvas.Handle,0,0,@Symbol,1) 1872 | end; 1873 | 1874 | procedure TEqExtSymbol.RefreshDimensions; 1875 | begin 1876 | Height:=CalcHeight; 1877 | Width:=CalcWidth; 1878 | end; 1879 | 1880 | { 1881 | ********************************** TEqParent *********************************** 1882 | } 1883 | constructor TEqParent.Create(AOwner: TComponent); 1884 | begin 1885 | inherited Create(AOwner); 1886 | FEditAreaList:=TEditAreaList.Create; 1887 | FEditAreaIndex:=0; 1888 | end; 1889 | 1890 | destructor TEqParent.Destroy; 1891 | begin 1892 | FEditAreaList.Free; 1893 | inherited; 1894 | end; 1895 | 1896 | function TEqParent.GetData: string; 1897 | begin 1898 | Result:=Format('EditArea(%s)',[EditAreaList.Items[0].Data]); 1899 | end; 1900 | 1901 | procedure TEqParent.InsertEditArea; 1902 | begin 1903 | FEditAreaList.Insert(FEditAreaIndex, TEditArea.Create(Self)); 1904 | FEditAreaList.Items[FEditAreaIndex].Parent:=Self; 1905 | FEditAreaList.Items[FEditAreaIndex].MainArea:=Parent.MainArea; 1906 | FEditAreaList.Items[FEditAreaIndex].Font:=Font; 1907 | FEditAreaList.Items[FEditAreaIndex].Font.Size:=Round(Font.Size*Kp); 1908 | FEditAreaList.Items[FEditAreaIndex].BkColor:=Parent.BkColor; 1909 | FEditAreaList.Items[FEditAreaIndex].Index:=FEditAreaIndex; 1910 | FEditAreaList.Items[FEditAreaIndex].RefreshDimensions; 1911 | RefreshEditArea(FEditAreaIndex); 1912 | FEditAreaList.Items[FEditAreaIndex].Active:=True; 1913 | end; 1914 | 1915 | procedure TEqParent.SetBkColor(AValue: TColor); 1916 | var 1917 | i: Integer; 1918 | begin 1919 | FBkColor := AValue; 1920 | for i:=0 to FEditAreaList.Count-1 do begin 1921 | FEditAreaList.Items[i].BkColor:=FBkColor; 1922 | end; 1923 | Repaint; 1924 | end; 1925 | 1926 | procedure TEqParent.SetData(const AValue: string); 1927 | var 1928 | ExprArray: TExprArray; 1929 | begin 1930 | FEditAreaIndex:=0; 1931 | ExprArray:=GetExprData(AValue); 1932 | if Length(ExprArray)>0 then begin 1933 | if ExprArray[0].ClassName = 'EditArea' then begin 1934 | FEditAreaList.Items[0].Data:=ExprArray[0].ExprData; 1935 | end; 1936 | end; 1937 | end; 1938 | 1939 | { 1940 | ********************************** TEqGroupOp ********************************** 1941 | } 1942 | function TEqGroupOp.CalcHeight: Integer; 1943 | begin 1944 | Result:=TopMargin+GetCommonHeight; 1945 | if goIndexBottom in FGroupOptions then Result:=Result+FIndexBottom.Height div 2; 1946 | if goLimitBottom in FGroupOptions then Result:=Result+FLimitBottom.Height; 1947 | end; 1948 | 1949 | function TEqGroupOp.CalcSymbolHeight: Integer; 1950 | var 1951 | Sz: TSize; 1952 | begin 1953 | SetCanvasFont; 1954 | GetTextExtentPoint32W(Canvas.Handle,@FSymbol,1,Sz); 1955 | Result:=Sz.cy; 1956 | end; 1957 | 1958 | function TEqGroupOp.CalcSymbolWidth: Integer; 1959 | var 1960 | Sz: TSize; 1961 | begin 1962 | SetCanvasFont; 1963 | GetTextExtentPoint32W(Canvas.Handle,@FSymbol,1,Sz); 1964 | Result:=Sz.cx*FSize+FSize; 1965 | end; 1966 | 1967 | function TEqGroupOp.CalcWidth: Integer; 1968 | begin 1969 | Result:=GetCommonWidth+FEditAreaList.Items[0].Width; 1970 | end; 1971 | 1972 | constructor TEqGroupOp.Create(AOwner: TComponent); 1973 | begin 1974 | inherited Create(AOwner); 1975 | Symbol:=WideChar(0); 1976 | FGroupOptions:=[]; 1977 | FRing:=False; 1978 | FSize:=1; 1979 | FEditAreaIndex:=0; 1980 | InsertEditArea; 1981 | end; 1982 | 1983 | function TEqGroupOp.GetCommonHeight: Integer; 1984 | begin 1985 | Result:=Max(SymbolHeight,EditAreaList.Items[0].Height); 1986 | end; 1987 | 1988 | function TEqGroupOp.GetCommonWidth: Integer; 1989 | var EAWidth: Integer; 1990 | begin 1991 | Result:=SymbolWidth; 1992 | EAWidth:=0; 1993 | if (goLimitTop in FGroupOptions)or(goLimitBottom in FGroupOptions) then begin 1994 | if goLimitTop in FGroupOptions then EAWidth:=Max(EAWidth, FLimitTop.Width); 1995 | if goLimitBottom in FGroupOptions then EAWidth:=Max(EAWidth, FLimitBottom.Width); 1996 | Result:=Max(Result, EAWidth); 1997 | end; 1998 | if (goIndexTop in FGroupOptions)or(goIndexBottom in FGroupOptions) then begin 1999 | if goIndexTop in FGroupOptions then EAWidth:=Max(EAWidth, FIndexTop.Width); 2000 | if goIndexBottom in FGroupOptions then EAWidth:=Max(EAWidth, FIndexBottom.Width); 2001 | Result:=Result+EAWidth; 2002 | end; 2003 | end; 2004 | 2005 | function TEqGroupOp.GetMidLine: Integer; 2006 | begin 2007 | Result:=TopMargin+CalcSymbolHeight div 2; 2008 | end; 2009 | 2010 | function TEqGroupOp.GetTopMargin: Integer; 2011 | begin 2012 | Result:=0; 2013 | if goIndexTop in FGroupOptions then Result:=FIndexTop.Height div 2; 2014 | if goLimitTop in FGroupOptions then Result:=FLimitTop.Height; 2015 | end; 2016 | 2017 | function TEqGroupOp.GetSymbolHeight: Integer; 2018 | begin 2019 | Result:=CalcSymbolHeight; 2020 | end; 2021 | 2022 | function TEqGroupOp.GetSymbolWidth: Integer; 2023 | begin 2024 | Result:=CalcSymbolWidth; 2025 | end; 2026 | 2027 | procedure TEqGroupOp.Paint; 2028 | var 2029 | Sz: TSize; 2030 | SymbolLeft, SymbolTop: Integer; 2031 | procedure DrawSymbol; 2032 | var i: Integer; 2033 | begin 2034 | for i:=0 to FSize-1 do begin 2035 | TextOutW(Canvas.Handle,SymbolLeft+(Sz.cx+1)*i,SymbolTop,@Symbol,1); 2036 | end; 2037 | end; 2038 | procedure DrawRing(); 2039 | var MLine: Integer; 2040 | begin 2041 | MLine:=SymbolTop+SymbolHeight div 2; 2042 | Canvas.Pen.Style:=psSolid; 2043 | Canvas.Pen.Width:=Font.Size div 15; 2044 | Canvas.Pen.Color:=Font.Color; 2045 | Canvas.Brush.Style:=bsClear; 2046 | Canvas.Ellipse(SymbolLeft, 2047 | MLine-Font.Size div 3, 2048 | SymbolLeft+Sz.cx*FSize+FSize, 2049 | MLine+Font.Size div 3); 2050 | end; 2051 | begin 2052 | SetCanvasFont; 2053 | GetTextExtentPoint32W(Canvas.Handle,@Symbol,1,Sz); 2054 | SymbolLeft:=0; 2055 | if (goLimitTop in FGroupOptions)or(goLimitBottom in FGroupOptions) then 2056 | SymbolLeft:=(GetCommonWidth-SymbolWidth) div 2; 2057 | if (goIndexTop in FGroupOptions)or(goIndexBottom in FGroupOptions) then 2058 | SymbolLeft:=0; 2059 | SymbolTop:=TopMargin+(GetCommonHeight-SymbolHeight) div 2; 2060 | Canvas.Rectangle(0, 0, Width, Height); 2061 | DrawSymbol; 2062 | if FRing then DrawRing; 2063 | end; 2064 | 2065 | procedure TEqGroupOp.RefreshDimensions; 2066 | begin 2067 | Height:=CalcHeight; 2068 | Width:=CalcWidth; 2069 | end; 2070 | 2071 | procedure TEqGroupOp.RefreshEA(AEditArea: TEditArea; AKp: Double); 2072 | begin 2073 | AEditArea.BkColor:=Parent.BkColor; 2074 | AEditArea.Font.Assign(Font); 2075 | AEditArea.Font.Size:=Round(Font.Size*Kp*AKp); 2076 | AEditArea.RefreshDimensions; 2077 | AEditArea.Index:=FEditAreaList.IndexOf(AEditArea); 2078 | end; 2079 | 2080 | procedure TEqGroupOp.RefreshEditArea(AEditAreaIndex: Integer = 0); 2081 | var 2082 | CommonHeight, CommonWidth: Integer; 2083 | begin 2084 | if FUpdateCount>0 then Exit; 2085 | if goLimitTop in FGroupOptions then RefreshEA(FLimitTop, 0.8); 2086 | if goLimitBottom in FGroupOptions then RefreshEA(FLimitBottom, 0.8); 2087 | if goIndexTop in FGroupOptions then RefreshEA(FIndexTop, 0.8); 2088 | if goIndexBottom in FGroupOptions then RefreshEA(FIndexBottom, 0.8); 2089 | CommonWidth:=GetCommonWidth; 2090 | RefreshEA(EditAreaList.Items[0], 1); 2091 | CommonHeight:=GetCommonHeight; 2092 | if goLimitTop in FGroupOptions then begin 2093 | FLimitTop.Top:=0; 2094 | FLimitTop.Left:=(CommonWidth-FLimitTop.Width) div 2; 2095 | end; 2096 | if goIndexTop in FGroupOptions then begin 2097 | FIndexTop.Top:=0; 2098 | FIndexTop.Left:=SymbolWidth; 2099 | end; 2100 | if goLimitBottom in FGroupOptions then begin 2101 | FLimitBottom.Top:=TopMargin+CommonHeight; 2102 | FLimitBottom.Left:=(CommonWidth-FLimitBottom.Width) div 2; 2103 | end; 2104 | if goIndexBottom in FGroupOptions then begin 2105 | FIndexBottom.Top:=TopMargin+CommonHeight-FIndexBottom.Height div 2; 2106 | FIndexBottom.Left:=SymbolWidth; 2107 | end; 2108 | EditAreaList.Items[0].Left:=CommonWidth; 2109 | EditAreaList.Items[0].Top:=TopMargin+(CommonHeight-EditAreaList.Items[0].Height) div 2; 2110 | Parent.RefreshEquations; 2111 | end; 2112 | 2113 | function TEqGroupOp.GetData: string; 2114 | begin 2115 | Result:=Format('EditArea(%s)',[EditAreaList.Items[0].Data]); 2116 | if goLimitBottom in FGroupOptions then Result:=Result+Format('EditArea(%s)',[FLimitBottom.Data]); 2117 | if goLimitTop in FGroupOptions then Result:=Result+Format('EditArea(%s)',[FLimitTop.Data]); 2118 | if goIndexBottom in FGroupOptions then Result:=Result+Format('EditArea(%s)',[FIndexBottom.Data]); 2119 | if goIndexTop in FGroupOptions then Result:=Result+Format('EditArea(%s)',[FIndexTop.Data]); 2120 | end; 2121 | 2122 | procedure TEqGroupOp.SetData(const AValue: String); 2123 | var 2124 | i: Integer; 2125 | ExprArray: TExprArray; 2126 | begin 2127 | ExprArray:=GetExprData(AValue); 2128 | for i:=0 to Length(ExprArray)-1 do begin 2129 | if ExprArray[i].ClassName = 'EditArea' then if i<FEditAreaList.Count then begin 2130 | FEditAreaList.Items[i].Data:=ExprArray[i].ExprData; 2131 | end; 2132 | end; 2133 | end; 2134 | 2135 | procedure TEqGroupOp.SetGroupOptions(Value: TGroupOptions); 2136 | begin 2137 | FGroupOptions:=Value; 2138 | BeginUpdate; 2139 | FEditAreaIndex:=1; 2140 | if goLimitTop in FGroupOptions then begin 2141 | InsertEditArea; 2142 | FLimitTop:=EditAreaList.Items[EditAreaIndex]; 2143 | end; 2144 | if goIndexTop in FGroupOptions then begin 2145 | InsertEditArea; 2146 | FIndexTop:=EditAreaList.Items[EditAreaIndex]; 2147 | end; 2148 | if goLimitBottom in FGroupOptions then begin 2149 | InsertEditArea; 2150 | FLimitBottom:=EditAreaList.Items[EditAreaIndex]; 2151 | end; 2152 | if goIndexBottom in FGroupOptions then begin 2153 | InsertEditArea; 2154 | FIndexBottom:=EditAreaList.Items[EditAreaIndex]; 2155 | end; 2156 | EndUpdate; 2157 | RefreshEditArea; 2158 | end; 2159 | 2160 | procedure TEqGroupOp.SetRing(ARing: Boolean); 2161 | begin 2162 | FRing := ARing; 2163 | Repaint; 2164 | end; 2165 | 2166 | procedure TEqGroupOp.SetSize(ASize: Integer); 2167 | begin 2168 | if ASize in [1..3] then FSize:=ASize; 2169 | Repaint; 2170 | end; 2171 | 2172 | procedure TEqGroupOp.SetSymbol(Value: WideChar); 2173 | begin 2174 | FSymbol := Value; 2175 | Repaint; 2176 | end; 2177 | 2178 | { 2179 | ********************************* TEqIntegral ********************************** 2180 | } 2181 | constructor TEqIntegral.Create(AOwner: TComponent); 2182 | begin 2183 | inherited Create(AOwner); 2184 | Symbol:=WideChar(8747); 2185 | end; 2186 | { 2187 | ********************************** TEqSumma ************************************ 2188 | } 2189 | constructor TEqSumma.Create(AOwner: TComponent); 2190 | begin 2191 | inherited Create(AOwner); 2192 | Symbol:=WideChar(8721); 2193 | end; 2194 | { 2195 | ********************************* TEqMultiply ********************************** 2196 | } 2197 | constructor TEqMultiply.Create(AOwner: TComponent); 2198 | begin 2199 | inherited Create(AOwner); 2200 | Symbol:=WideChar(8719); 2201 | end; 2202 | { 2203 | ******************************* TEqIntersection ******************************** 2204 | } 2205 | constructor TEqIntersection.Create(AOwner: TComponent); 2206 | begin 2207 | inherited Create(AOwner); 2208 | Symbol:=WideChar(8745); 2209 | end; 2210 | { 2211 | *********************************** TEqJoin ************************************ 2212 | } 2213 | constructor TEqJoin.Create(AOwner: TComponent); 2214 | begin 2215 | inherited Create(AOwner); 2216 | Symbol:=WideChar(85); 2217 | end; 2218 | { 2219 | ********************************** TEqCoMult *********************************** 2220 | } 2221 | constructor TEqCoMult.Create(AOwner: TComponent); 2222 | begin 2223 | inherited Create(AOwner); 2224 | Symbol:=WideChar(1062); 2225 | end; 2226 | { 2227 | *********************************** TEqIndex************************************ 2228 | } 2229 | constructor TEqIndex.Create(AOwner: TComponent); 2230 | begin 2231 | inherited Create(AOwner); 2232 | Kp:=0.7; 2233 | FGroupOptions:=[]; 2234 | end; 2235 | 2236 | function TEqIndex.CalcHeight: Integer; 2237 | begin 2238 | Result:=Font.Size div 2; 2239 | if goIndexTop in FGroupOptions then Result:=Result+FIndexTop.Height; 2240 | if goIndexBottom in FGroupOptions then Result:=Result+FIndexBottom.Height; 2241 | end; 2242 | 2243 | function TEqIndex.CalcWidth: Integer; 2244 | begin 2245 | Result:=0; 2246 | if goIndexTop in FGroupOptions then Result:=FIndexTop.Width; 2247 | if goIndexBottom in FGroupOptions then Result:=Max(Result, FIndexBottom.Width); 2248 | end; 2249 | 2250 | procedure TEqIndex.Paint; 2251 | begin 2252 | SetCanvasFont; 2253 | Canvas.Rectangle(0, 0, Width, Height); 2254 | end; 2255 | 2256 | procedure TEqIndex.RefreshDimensions; 2257 | begin 2258 | Height:=CalcHeight; 2259 | Width:=CalcWidth; 2260 | end; 2261 | 2262 | procedure TEqIndex.RefreshEA(AEditArea: TEditArea); 2263 | begin 2264 | AEditArea.BkColor:=Parent.BkColor; 2265 | AEditArea.Font.Assign(Font); 2266 | AEditArea.Font.Size:=Round(Font.Size*Kp); 2267 | AEditArea.RefreshDimensions; 2268 | AEditArea.Index:=FEditAreaList.IndexOf(AEditArea); 2269 | end; 2270 | 2271 | procedure TEqIndex.RefreshEditArea(AEditAreaIndex: Integer = 0); 2272 | begin 2273 | if FUpdateCount>0 then Exit; 2274 | if goIndexTop in FGroupOptions then begin 2275 | RefreshEA(FIndexTop); 2276 | FIndexTop.Top:=0; 2277 | FIndexTop.Left:=0; 2278 | end; 2279 | if goIndexBottom in FGroupOptions then begin 2280 | RefreshEA(FIndexBottom); 2281 | FIndexBottom.Top:=Font.Size div 2; 2282 | if goIndexTop in FGroupOptions then FIndexBottom.Top:=FIndexBottom.Top+FIndexTop.Height; 2283 | FIndexBottom.Left:=0; 2284 | end; 2285 | Parent.RefreshEquations; 2286 | end; 2287 | 2288 | procedure TEqIndex.SetGroupOptions(const Value: TGroupOptions); 2289 | begin 2290 | FGroupOptions := Value; 2291 | BeginUpdate; 2292 | if goIndexTop in FGroupOptions then begin 2293 | InsertEditArea; 2294 | FIndexTop:=EditAreaList.Items[EditAreaIndex]; 2295 | end; 2296 | if goIndexBottom in FGroupOptions then begin 2297 | InsertEditArea; 2298 | FIndexBottom:=EditAreaList.Items[EditAreaIndex]; 2299 | end; 2300 | EndUpdate; 2301 | end; 2302 | 2303 | function TEqIndex.GetData: string; 2304 | begin 2305 | Result:=''; 2306 | if goIndexBottom in FGroupOptions then Result:=Result+Format('EditArea(%s)',[FIndexBottom.Data]); 2307 | if goIndexTop in FGroupOptions then Result:=Result+Format('EditArea(%s)',[FIndexTop.Data]); 2308 | end; 2309 | 2310 | procedure TEqIndex.SetData(const AValue: String); 2311 | var 2312 | i: Integer; 2313 | ExprArray: TExprArray; 2314 | begin 2315 | ExprArray:=GetExprData(AValue); 2316 | for i:=0 to Length(ExprArray)-1 do begin 2317 | if ExprArray[i].ClassName = 'EditArea' then if i<FEditAreaList.Count then begin 2318 | FEditAreaList.Items[i].Data:=ExprArray[i].ExprData; 2319 | end; 2320 | end; 2321 | end; 2322 | { 2323 | ********************************* TEqBrackets ********************************** 2324 | } 2325 | constructor TEqBrackets.Create(AOwner: TComponent); 2326 | begin 2327 | inherited Create(AOwner); 2328 | InsertEditArea; 2329 | RefreshEditArea; 2330 | end; 2331 | 2332 | function TEqBrackets.CalcSymbolHeight: Integer; 2333 | var 2334 | Sz: TSize; 2335 | begin 2336 | SetCanvasFont; 2337 | GetTextExtentPoint32W(Canvas.Handle,@FLSymbol,1,Sz); 2338 | Result:=Sz.cy; 2339 | end; 2340 | 2341 | function TEqBrackets.CalcSymbolWidth: Integer; 2342 | var 2343 | Sz: TSize; 2344 | begin 2345 | SetCanvasFont; 2346 | GetTextExtentPoint32W(Canvas.Handle,@FLSymbol,1,Sz); 2347 | Result:=Sz.cx; 2348 | end; 2349 | 2350 | function TEqBrackets.CalcHeight: Integer; 2351 | begin 2352 | SetCanvasFont; 2353 | Result:=Max(FEditAreaList.Items[0].Height,CalcSymbolHeight); 2354 | end; 2355 | 2356 | function TEqBrackets.CalcWidth: Integer; 2357 | begin 2358 | SetCanvasFont; 2359 | Result:=FEditAreaList.Items[0].Width+CalcSymbolWidth*2; 2360 | end; 2361 | 2362 | function TEqBrackets.GetCommonHeight: Integer; 2363 | begin 2364 | Result:=Max(CalcSymbolHeight,EditAreaList.Items[0].Height); 2365 | end; 2366 | 2367 | procedure TEqBrackets.Paint; 2368 | var CommonHeight: Integer; 2369 | begin 2370 | CommonHeight:=GetCommonHeight; 2371 | Canvas.Rectangle(0, 0, Width, Height); 2372 | TextOutW(Canvas.Handle,0,(CommonHeight-CalcSymbolHeight) div 2,@FLSymbol,1); 2373 | TextOutW(Canvas.Handle,CalcSymbolWidth+FEditAreaList.Items[0].Width, 2374 | (CommonHeight-CalcSymbolHeight) div 2,@FRSymbol,1); 2375 | end; 2376 | 2377 | procedure TEqBrackets.RefreshDimensions; 2378 | begin 2379 | Height:=CalcHeight; 2380 | Width:=CalcWidth; 2381 | end; 2382 | 2383 | procedure TEqBrackets.RefreshEditArea(AEditAreaIndex: Integer = 0); 2384 | begin 2385 | FEditAreaList.Items[0].BkColor:=Parent.BkColor; 2386 | FEditAreaList.Items[0].Font:=Font; 2387 | FEditAreaList.Items[0].Font.Size:=Round(Font.Size*Kp); 2388 | FEditAreaList.Items[0].RefreshDimensions; 2389 | FEditAreaList.Items[0].Index:=0; 2390 | FEditAreaList.Items[0].Left:=CalcSymbolWidth; 2391 | FEditAreaList.Items[0].Top:=(GetCommonHeight-FEditAreaList.Items[0].Height) div 2; 2392 | Parent.RefreshEquations; 2393 | end; 2394 | 2395 | procedure TEqBrackets.SetKindBracket(AValue: TKindBracket); 2396 | begin 2397 | FKindBracket:=AValue; 2398 | case FKindBracket of 2399 | kbRound: begin 2400 | FLSymbol:=WideChar(64830); 2401 | FRSymbol:=WideChar(64831); 2402 | end; 2403 | kbSquare: begin 2404 | FLSymbol:=WideChar(91); 2405 | FRSymbol:=WideChar(93); 2406 | end; 2407 | kbFigure: begin 2408 | FLSymbol:=WideChar(123); 2409 | FRSymbol:=WideChar(125); 2410 | end; 2411 | kbCorner: begin 2412 | FLSymbol:=WideChar(8249); 2413 | FRSymbol:=WideChar(8250); 2414 | end; 2415 | kbModule: begin 2416 | FLSymbol:=WideChar(9474); 2417 | FRSymbol:=WideChar(9474); 2418 | end; 2419 | kbDModule: begin 2420 | FLSymbol:=WideChar(9553); 2421 | FRSymbol:=WideChar(9553); 2422 | end; 2423 | end; 2424 | RefreshEditArea; 2425 | end; 2426 | 2427 | procedure TEqBrackets.SetLSymbol(Value: WideChar); 2428 | begin 2429 | FLSymbol:=Value; 2430 | Repaint; 2431 | end; 2432 | 2433 | procedure TEqBrackets.SetRSymbol(Value: WideChar); 2434 | begin 2435 | FRSymbol:=Value; 2436 | Repaint; 2437 | end; 2438 | { 2439 | *********************************** TEqArrow *********************************** 2440 | } 2441 | function TEqArrow.CalcHeight: Integer; 2442 | begin 2443 | Result:=FEditAreaList.Items[0].Height+ArrowHeight+7; 2444 | end; 2445 | 2446 | function TEqArrow.CalcWidth: Integer; 2447 | begin 2448 | Result:=FEditAreaList.Items[0].Width * 2; 2449 | end; 2450 | 2451 | constructor TEqArrow.Create(AOwner: TComponent); 2452 | begin 2453 | inherited; 2454 | Kp:=0.7; 2455 | FKindArrow:=[]; 2456 | FAlignEA:=aeTop; 2457 | InsertEditArea; 2458 | RefreshEditArea; 2459 | end; 2460 | 2461 | function TEqArrow.GetMidLine: Integer; 2462 | begin 2463 | Result:=Height div 2; 2464 | case FAlignEA of 2465 | aeTop: Result:=FEditAreaList.Items[0].Height+3; 2466 | aeBottom: Result:=3; 2467 | end; 2468 | end; 2469 | 2470 | procedure TEqArrow.Paint; 2471 | var LineTop: Integer; 2472 | procedure DrawArrow; 2473 | begin 2474 | Canvas.Pen.Color := Font.Color; 2475 | Canvas.Pen.Style := psSolid; 2476 | Canvas.Rectangle(0, LineTop, Width, LineTop+LineHeight); 2477 | if kaRight in FKindArrow then begin 2478 | Canvas.MoveTo(Width-15, LineTop - ArrowHeight div 2); 2479 | Canvas.LineTo(Width, LineTop); 2480 | Canvas.MoveTo(Width, LineTop+LineHeight div 2); 2481 | Canvas.LineTo(Width-15, LineTop+LineHeight div 2 + ArrowHeight div 2); 2482 | end; 2483 | if kaLeft in FKindArrow then begin 2484 | Canvas.MoveTo(15, LineTop - ArrowHeight div 2); 2485 | Canvas.LineTo(0, LineTop); 2486 | Canvas.MoveTo(0, LineTop+LineHeight div 2); 2487 | Canvas.LineTo(15, LineTop+LineHeight div 2 + ArrowHeight div 2); 2488 | end; 2489 | end; 2490 | begin 2491 | case FAlignEA of 2492 | aeTop: LineTop:=FEditAreaList.Items[0].Height+ArrowHeight div 2; 2493 | aeBottom: LineTop:=3; 2494 | end; 2495 | SetCanvasFont; 2496 | Canvas.Rectangle(0, 0, Width, Height); 2497 | DrawArrow; 2498 | end; 2499 | 2500 | procedure TEqArrow.RefreshDimensions; 2501 | begin 2502 | Height:=CalcHeight; 2503 | Width:=CalcWidth; 2504 | ArrowHeight:=Font.Size div 5; 2505 | LineHeight:=Font.Size div 10; 2506 | end; 2507 | 2508 | procedure TEqArrow.RefreshEditArea(AEditAreaIndex: Integer = 0); 2509 | begin 2510 | FEditAreaList.Items[0].BkColor:=Parent.BkColor; 2511 | FEditAreaList.Items[0].Font:=Font; 2512 | FEditAreaList.Items[0].Font.Size:=Round(Font.Size*Kp); 2513 | FEditAreaList.Items[0].RefreshDimensions; 2514 | FEditAreaList.Items[0].Index:=0; 2515 | FEditAreaList.Items[0].Left:=(CalcWidth-FEditAreaList.Items[0].Width) div 2; 2516 | case FAlignEA of 2517 | aeTop: FEditAreaList.Items[0].Top:=0; 2518 | aeBottom: FEditAreaList.Items[0].Top:=ArrowHeight+4; 2519 | end; 2520 | Parent.RefreshEquations; 2521 | end; 2522 | 2523 | procedure TEqArrow.SetAlignEA(const Value: TAlignEA); 2524 | begin 2525 | FAlignEA := Value; 2526 | RefreshEditArea; 2527 | end; 2528 | 2529 | procedure TEqArrow.SetKindArrow(Value: TKindArrow); 2530 | begin 2531 | FKindArrow:=Value; 2532 | Repaint; 2533 | end; 2534 | { 2535 | ********************************** TEqSquare *********************************** 2536 | } 2537 | function TEqSquare.CalcHeight: Integer; 2538 | begin 2539 | Result:=FEditAreaList.Items[0].Height+LineHeight; 2540 | end; 2541 | 2542 | function TEqSquare.CalcWidth: Integer; 2543 | begin 2544 | Result:=FEditAreaList.Items[0].Width + GalkaLeft + LineHeight; 2545 | end; 2546 | 2547 | constructor TEqSquare.Create(AOwner: TComponent); 2548 | begin 2549 | inherited; 2550 | Kp:=0.9; 2551 | 2552 | InsertEditArea; 2553 | RefreshDimensions; 2554 | RefreshEditArea; 2555 | end; 2556 | 2557 | function TEqSquare.GetMidLine: Integer; 2558 | begin 2559 | Result:=Height div 2 - LineHeight; 2560 | end; 2561 | 2562 | procedure TEqSquare.Paint; 2563 | 2564 | procedure DrawSquare; 2565 | begin 2566 | Canvas.Pen.Color := Font.Color; 2567 | Canvas.Pen.Style := psSolid; 2568 | Canvas.Pen.Width:=LineHeight; 2569 | Canvas.MoveTo(0, FEditAreaList.Items[0].Height div 2); 2570 | Canvas.LineTo(GalkaLeft div 2, FEditAreaList.Items[0].Height); 2571 | Canvas.LineTo(GalkaLeft, 0); 2572 | Canvas.LineTo(FEditAreaList.Items[0].Width+GalkaLeft+LineHeight, 0); 2573 | end; 2574 | 2575 | begin 2576 | SetCanvasFont; 2577 | Canvas.Rectangle(0, 0, Width, Height); 2578 | DrawSquare; 2579 | end; 2580 | 2581 | procedure TEqSquare.RefreshDimensions; 2582 | begin 2583 | Height:=CalcHeight; 2584 | Width:=CalcWidth; 2585 | GalkaLeft:=Font.Size div 2; 2586 | LineHeight:=Font.Size div 8; 2587 | end; 2588 | 2589 | procedure TEqSquare.RefreshEditArea(AEditAreaIndex: Integer = 0); 2590 | begin 2591 | FEditAreaList.Items[0].BkColor:=Parent.BkColor; 2592 | FEditAreaList.Items[0].Font:=Font; 2593 | FEditAreaList.Items[0].Font.Size:=Round(Font.Size*Kp); 2594 | FEditAreaList.Items[0].RefreshDimensions; 2595 | FEditAreaList.Items[0].Index:=0; 2596 | FEditAreaList.Items[0].Left:=GalkaLeft+LineHeight;//(CalcWidth-FEditAreaList.Items[0].Width) div 2; 2597 | FEditAreaList.Items[0].Top:=LineHeight;//+Font.Size div 2;//;ArrowHeight+4; 2598 | 2599 | Parent.RefreshEquations; 2600 | end; 2601 | 2602 | { 2603 | ********************************* TEqDivision ********************************** 2604 | } 2605 | function TEqDivision.CalcHeight: Integer; 2606 | begin 2607 | Result:=FEditAreaList.Items[0].Height+ArrowHeight+FEditAreaList.Items[1].Height; 2608 | end; 2609 | 2610 | function TEqDivision.CalcWidth: Integer; 2611 | begin 2612 | Result:=Max(FEditAreaList.Items[0].Width, FEditAreaList.Items[1].Width); 2613 | end; 2614 | 2615 | constructor TEqDivision.Create(AOwner: TComponent); 2616 | begin 2617 | inherited; 2618 | Kp:=0.7; 2619 | BeginUpdate; 2620 | InsertEditArea; 2621 | InsertEditArea; 2622 | EndUpdate; 2623 | RefreshEditArea; 2624 | end; 2625 | 2626 | function TEqDivision.GetMidLine: Integer; 2627 | begin 2628 | Result:=FEditAreaList.Items[0].Height+ArrowHeight div 2; 2629 | end; 2630 | 2631 | procedure TEqDivision.Paint; 2632 | var LineTop: Integer; 2633 | procedure DrawArrow; 2634 | begin 2635 | Canvas.Pen.Color := Font.Color; 2636 | Canvas.Pen.Style := psSolid; 2637 | Canvas.Rectangle(0, LineTop, Width, LineTop+LineHeight); 2638 | end; 2639 | begin 2640 | LineTop:=FEditAreaList.Items[0].Height+ArrowHeight div 2; 2641 | SetCanvasFont; 2642 | Canvas.Rectangle(0, 0, Width, Height); 2643 | DrawArrow; 2644 | end; 2645 | 2646 | procedure TEqDivision.RefreshDimensions; 2647 | begin 2648 | Height:=CalcHeight; 2649 | Width:=CalcWidth; 2650 | ArrowHeight:=Font.Size div 5; 2651 | LineHeight:=Font.Size div 10; 2652 | end; 2653 | 2654 | procedure TEqDivision.RefreshEA(AEditArea: TEditArea); 2655 | begin 2656 | AEditArea.BkColor:=Parent.BkColor; 2657 | AEditArea.Font:=Font; 2658 | AEditArea.Font.Size:=Round(Font.Size*Kp); 2659 | AEditArea.RefreshDimensions; 2660 | AEditArea.Left:=(CalcWidth-AEditArea.Width) div 2; 2661 | end; 2662 | 2663 | procedure TEqDivision.RefreshEditArea(AEditAreaIndex: Integer = 0); 2664 | begin 2665 | if FUpdateCount>0 then Exit; 2666 | RefreshEA(FEditAreaList.Items[0]); 2667 | FEditAreaList.Items[0].Top:=0; 2668 | RefreshEA(FEditAreaList.Items[1]); 2669 | FEditAreaList.Items[1].Top:=FEditAreaList.Items[0].Height+ArrowHeight; 2670 | 2671 | Parent.RefreshEquations; 2672 | end; 2673 | 2674 | function TEqDivision.GetData: String; 2675 | begin 2676 | Result:=Format('EditArea(%s)',[EditAreaList.Items[0].Data])+Format('EditArea(%s)',[EditAreaList.Items[1].Data]); 2677 | end; 2678 | 2679 | procedure TEqDivision.SetData(const AValue: String); 2680 | var 2681 | i: Integer; 2682 | ExprArray: TExprArray; 2683 | begin 2684 | ExprArray:=GetExprData(AValue); 2685 | for i:=0 to Length(ExprArray)-1 do begin 2686 | if ExprArray[i].ClassName = 'EditArea' then if i<FEditAreaList.Count then begin 2687 | FEditAreaList.Items[i].Data:=ExprArray[i].ExprData; 2688 | end; 2689 | end; 2690 | end; 2691 | 2692 | { 2693 | ********************************** TEqVector *********************************** 2694 | } 2695 | function TEqVector.CalcHeight: Integer; 2696 | begin 2697 | Result:=FEditAreaList.Items[0].Height+ArrowHeight+7; 2698 | end; 2699 | 2700 | function TEqVector.CalcWidth: Integer; 2701 | begin 2702 | Result:=FEditAreaList.Items[0].Width; 2703 | end; 2704 | 2705 | constructor TEqVector.Create(AOwner: TComponent); 2706 | begin 2707 | inherited; 2708 | FKindArrow:=[]; 2709 | FAlignEA:=aeTop; 2710 | InsertEditArea; 2711 | RefreshEditArea; 2712 | end; 2713 | 2714 | function TEqVector.GetMidLine: Integer; 2715 | begin 2716 | Result:=Height div 2; 2717 | case FAlignEA of 2718 | aeTop: Result:=FEditAreaList.Items[0].Height div 2; 2719 | aeBottom: Result:=ArrowHeight+4+FEditAreaList.Items[0].Height div 2; 2720 | end; 2721 | end; 2722 | 2723 | procedure TEqVector.Paint; 2724 | var LineTop: Integer; 2725 | procedure DrawArrow; 2726 | begin 2727 | Canvas.Pen.Color := Font.Color; 2728 | Canvas.Pen.Style := psSolid; 2729 | Canvas.Rectangle(0, LineTop, Width, LineTop+LineHeight); 2730 | if kaRight in FKindArrow then begin 2731 | Canvas.MoveTo(Width-15, LineTop - ArrowHeight div 2); 2732 | Canvas.LineTo(Width, LineTop); 2733 | Canvas.MoveTo(Width, LineTop+LineHeight div 2); 2734 | Canvas.LineTo(Width-15, LineTop+LineHeight div 2 + ArrowHeight div 2); 2735 | end; 2736 | if kaLeft in FKindArrow then begin 2737 | Canvas.MoveTo(15, LineTop - ArrowHeight div 2); 2738 | Canvas.LineTo(0, LineTop); 2739 | Canvas.MoveTo(0, LineTop+LineHeight div 2); 2740 | Canvas.LineTo(15, LineTop+LineHeight div 2 + ArrowHeight div 2); 2741 | end; 2742 | if kaDouble in FKindArrow then begin 2743 | Canvas.Rectangle(0, LineTop+ArrowHeight, Width, LineTop+ArrowHeight+LineHeight); 2744 | end; 2745 | end; 2746 | begin 2747 | case FAlignEA of 2748 | aeTop: 2749 | if kaDouble in FKindArrow then 2750 | LineTop:=FEditAreaList.Items[0].Height 2751 | else 2752 | LineTop:=FEditAreaList.Items[0].Height+ArrowHeight div 2; 2753 | aeBottom: 2754 | if kaDouble in FKindArrow then 2755 | LineTop:=1 2756 | else 2757 | LineTop:=3; 2758 | end; 2759 | SetCanvasFont; 2760 | Canvas.Rectangle(0, 0, Width, Height); 2761 | DrawArrow; 2762 | end; 2763 | 2764 | procedure TEqVector.RefreshDimensions; 2765 | begin 2766 | Height:=CalcHeight; 2767 | Width:=CalcWidth; 2768 | ArrowHeight:=Font.Size div 5; 2769 | LineHeight:=Font.Size div 10; 2770 | end; 2771 | 2772 | procedure TEqVector.RefreshEditArea(AEditAreaIndex: Integer = 0); 2773 | begin 2774 | FEditAreaList.Items[0].BkColor:=Parent.BkColor; 2775 | FEditAreaList.Items[0].Font:=Font; 2776 | FEditAreaList.Items[0].Font.Size:=Round(Font.Size*Kp); 2777 | FEditAreaList.Items[0].RefreshDimensions; 2778 | FEditAreaList.Items[0].Index:=0; 2779 | FEditAreaList.Items[0].Left:=0; 2780 | case FAlignEA of 2781 | aeTop: FEditAreaList.Items[0].Top:=0; 2782 | aeBottom: FEditAreaList.Items[0].Top:=ArrowHeight+4; 2783 | end; 2784 | Parent.RefreshEquations; 2785 | end; 2786 | 2787 | procedure TEqVector.SetAlignEA(const Value: TAlignEA); 2788 | begin 2789 | FAlignEA := Value; 2790 | RefreshEditArea; 2791 | end; 2792 | 2793 | procedure TEqVector.SetKindArrow(Value: TKindArrow); 2794 | begin 2795 | FKindArrow:=Value; 2796 | RefreshEditArea; 2797 | end; 2798 | 2799 | { 2800 | ********************************** TEqMatrix *********************************** 2801 | } 2802 | function TEqMatrix.CalcHeight: Integer; 2803 | var i, dy: Integer; 2804 | begin 2805 | Result:=0; 2806 | dy:=GetDY; 2807 | for i:=0 to dy-1 do Result:=Result+GetRowHeight(i)+10; 2808 | end; 2809 | 2810 | function TEqMatrix.CalcWidth: Integer; 2811 | var i, dx: Integer; 2812 | begin 2813 | Result:=0; 2814 | dx:=GetDX; 2815 | for i:=0 to dx-1 do Result:=Result+GetColWidth(i)+10; 2816 | end; 2817 | 2818 | constructor TEqMatrix.Create(AOwner: TComponent); 2819 | begin 2820 | inherited; 2821 | InsertEditArea; 2822 | FCountEA:=0; 2823 | FKindMatrix:=kmSquare; 2824 | end; 2825 | 2826 | function TEqMatrix.GetColWidth(ACol: Integer): Integer; 2827 | var i, dx: Integer; 2828 | begin 2829 | dx:=GetDX; 2830 | i:=ACol; 2831 | Result:=FEditAreaList.Items[i].Width; 2832 | while i<FCountEA do begin 2833 | Result:=Max(Result, FEditAreaList.Items[i].Width); 2834 | Inc(i, dx); 2835 | end; 2836 | end; 2837 | 2838 | function TEqMatrix.GetRowHeight(ARow: Integer): Integer; 2839 | var i, dy: Integer; 2840 | begin 2841 | dy:=GetDY; 2842 | i:=ARow; 2843 | Result:=FEditAreaList.Items[i].Height; 2844 | while i<FCountEA do begin 2845 | Result:=Max(Result, FEditAreaList.Items[i].Height); 2846 | Inc(i, dy); 2847 | end; 2848 | end; 2849 | 2850 | function TEqMatrix.GetData: string; 2851 | var i: Integer; 2852 | begin 2853 | Result:=''; 2854 | for i:=0 to FEditAreaList.Count-1 do Result:=Result+Format('EditArea(%s)',[EditAreaList.Items[i].Data]); 2855 | end; 2856 | 2857 | procedure TEqMatrix.SetData(const AValue: String); 2858 | var 2859 | i: Integer; 2860 | ExprArray: TExprArray; 2861 | begin 2862 | ExprArray:=GetExprData(AValue); 2863 | CountEA:=Length(ExprArray); 2864 | for i:=0 to Length(ExprArray)-1 do begin 2865 | if ExprArray[i].ClassName = 'EditArea' then if i<FEditAreaList.Count then begin 2866 | FEditAreaList.Items[i].Data:=ExprArray[i].ExprData; 2867 | end; 2868 | end; 2869 | Parent.RefreshRecurse; 2870 | Parent.MainArea.Change; 2871 | end; 2872 | 2873 | function TEqMatrix.GetDX: Integer; 2874 | begin 2875 | Result:=0; 2876 | case FKindMatrix of 2877 | kmHoriz: Result:=FCountEA; 2878 | kmVert: Result:=1; 2879 | kmSquare: begin 2880 | Result:=Round(Sqrt(FCountEA)); 2881 | end; 2882 | end; 2883 | end; 2884 | 2885 | function TEqMatrix.GetDY: Integer; 2886 | begin 2887 | Result:=0; 2888 | case FKindMatrix of 2889 | kmHoriz: Result:=1; 2890 | kmVert: Result:=FCountEA; 2891 | kmSquare: begin 2892 | Result:=Round(Sqrt(FCountEA)); 2893 | end; 2894 | end; 2895 | end; 2896 | 2897 | function TEqMatrix.GetMidLine: Integer; 2898 | begin 2899 | Result:=Height div 2; 2900 | end; 2901 | 2902 | procedure TEqMatrix.Paint; 2903 | begin 2904 | SetCanvasFont; 2905 | Canvas.Rectangle(0, 0, Width, Height); 2906 | end; 2907 | 2908 | procedure TEqMatrix.RefreshDimensions; 2909 | begin 2910 | Height:=CalcHeight; 2911 | Width:=CalcWidth; 2912 | end; 2913 | 2914 | procedure TEqMatrix.RefreshEditArea(AEditAreaIndex: Integer = 0); 2915 | var i,j, dx, dy, CommonHeight, CommonWidth, RowHeight, ColWidth: Integer; 2916 | begin 2917 | if FUpdateCount>0 then Exit; 2918 | dx:=GetDX; dy:=GetDY; 2919 | for i:=0 to FCountEA-1 do RefreshEA(FEditAreaList.Items[i]); 2920 | CommonHeight:=0; 2921 | for i:=0 to dy-1 do begin 2922 | RowHeight:=GetRowHeight(i); 2923 | for j:=0 to dx-1 do 2924 | FEditAreaList.Items[i*dx+j].Top:=CommonHeight+(RowHeight-FEditAreaList.Items[i*dx+j].Height) div 2; 2925 | 2926 | Inc(CommonHeight,RowHeight+10); 2927 | end; 2928 | CommonWidth:=0; 2929 | for j:=0 to dx-1 do begin 2930 | ColWidth:=GetColWidth(j); 2931 | for i:=0 to dy-1 do begin 2932 | FEditAreaList.Items[i*dx+j].Left:=CommonWidth+(ColWidth-FEditAreaList.Items[i*dx+j].Width) div 2; 2933 | end; 2934 | Inc(CommonWidth,ColWidth+10); 2935 | end; 2936 | 2937 | Parent.RefreshEquations; 2938 | end; 2939 | 2940 | procedure TEqMatrix.RefreshEA(AEditArea: TEditArea); 2941 | begin 2942 | AEditArea.BkColor:=Parent.BkColor; 2943 | AEditArea.Font.Assign(Font); 2944 | AEditArea.Font.Size:=Round(Font.Size*Kp); 2945 | AEditArea.RefreshDimensions; 2946 | AEditArea.Index:=FEditAreaList.IndexOf(AEditArea); 2947 | end; 2948 | 2949 | procedure TEqMatrix.SetKindMatrix(const Value: TKindMatrix); 2950 | begin 2951 | FKindMatrix := Value; 2952 | RefreshEditArea; 2953 | end; 2954 | 2955 | procedure TEqMatrix.SetCountEA(const Value: Integer); 2956 | begin 2957 | FCountEA:=EditAreaList.Count; 2958 | BeginUpdate; 2959 | while FCountEA < Value do begin 2960 | FEditAreaIndex:=FCountEA-1; 2961 | InsertEditArea; 2962 | Inc(FCountEA); 2963 | end; 2964 | EndUpdate; 2965 | end; 2966 | 2967 | 2968 | end. 2969 | --------------------------------------------------------------------------------