diff --git a/chemCollection/chemCollection.ico b/chemCollection/chemCollection.ico new file mode 100644 index 0000000..0341321 Binary files /dev/null and b/chemCollection/chemCollection.ico differ diff --git a/chemCollection/chemCollection.lpi b/chemCollection/chemCollection.lpi new file mode 100644 index 0000000..aadb4ae --- /dev/null +++ b/chemCollection/chemCollection.lpi @@ -0,0 +1,83 @@ + + + + + + + + + <Scaled Value="True"/> + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <XPManifest> + <DpiAware Value="True"/> + </XPManifest> + <Icon Value="0"/> + </General> + <BuildModes Count="1"> + <Item1 Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + <Modes Count="0"/> + </RunParams> + <RequiredPackages Count="2"> + <Item1> + <PackageName Value="RunTimeTypeInfoControls"/> + </Item1> + <Item2> + <PackageName Value="LCL"/> + </Item2> + </RequiredPackages> + <Units Count="2"> + <Unit0> + <Filename Value="chemCollection.lpr"/> + <IsPartOfProject Value="True"/> + </Unit0> + <Unit1> + <Filename Value="mainchemform.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="ChemForm"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="mainChemForm"/> + </Unit1> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <Target> + <Filename Value="chemCollection"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Debugging> + <DebugInfoType Value="dsDwarf2"/> + </Debugging> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/chemCollection/chemCollection.lpr b/chemCollection/chemCollection.lpr new file mode 100644 index 0000000..e2de06e --- /dev/null +++ b/chemCollection/chemCollection.lpr @@ -0,0 +1,22 @@ +program chemCollection; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, runtimetypeinfocontrols, mainChemForm + { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource:=True; + Application.Scaled:=True; + Application.Initialize; + Application.CreateForm(TChemForm, ChemForm); + Application.Run; +end. + diff --git a/chemCollection/mainchemform.lfm b/chemCollection/mainchemform.lfm new file mode 100644 index 0000000..cef8301 --- /dev/null +++ b/chemCollection/mainchemform.lfm @@ -0,0 +1,23 @@ +object ChemForm: TChemForm + Left = 604 + Height = 240 + Top = 270 + Width = 320 + Caption = 'ChemForm' + ClientHeight = 240 + ClientWidth = 320 + OnCreate = FormCreate + OnDestroy = FormDestroy + LCLVersion = '2.0.12.0' + object chemGrid: TTIGrid + Left = 162 + Height = 100 + Top = 110 + Width = 200 + Color = clWindow + Filter = [tkInteger, tkChar, tkEnumeration, tkFloat, tkSString, tkLString, tkAString, tkWString, tkVariant, tkWChar, tkBool, tkInt64, tkQWord] + ParentColor = False + TabOrder = 0 + TIOptions = [] + end +end diff --git a/chemCollection/mainchemform.pas b/chemCollection/mainchemform.pas new file mode 100644 index 0000000..3e1ae27 --- /dev/null +++ b/chemCollection/mainchemform.pas @@ -0,0 +1,99 @@ +unit mainChemForm; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, RTTIGrids, grids; + +type + TElementItem = class(TCollectionItem) + private + FNumber: cardinal; + FName: string; + FSymbol: string; + FGroup: string; + published + property AtomicNo: cardinal read FNumber write FNumber; + property Name: string read FName write FName; + property Symbol: string read FSymbol write FSymbol; + property Group: string read FGroup write FGroup; + end; + + { TChemForm } + TChemForm = class(TForm) + chemGrid: TTIGrid; + procedure FormCreate(Sender: TObject); + procedure FormDestroy(Sender: TObject); + private + Felements: TCollection; + procedure SetupChemGrid; + end; + +var + ChemForm: TChemForm; + +implementation + +{$R *.lfm} + +{ TChemForm } + +procedure TChemForm.FormCreate(Sender: TObject); +begin + SetupChemGrid; +end; + +procedure TChemForm.FormDestroy(Sender: TObject); +begin + // Free up the collection's memory! + Felements.Free; +end; + +procedure TChemForm.SetupChemGrid; + procedure AddElement(aNumber: cardinal; const aName, aSymbol, aGroup: string); + var ei: TElementItem; + begin + ei := TElementItem(Felements.Add); + ei.AtomicNo := aNumber; + ei.Name := aName; + ei.Symbol := aSymbol; + ei.Group := aGroup; + end; + + procedure AddElements; + begin + AddElement(1, 'Hydrogen', 'H', '"I"'); + AddElement(2, 'Helium', 'He', '"II"'); + AddElement(3, 'Lithium', 'Li', 'I'); + AddElement(4, 'Beryllium', 'Be', 'II'); + AddElement(5, 'Boron', 'B', 'III'); + AddElement(6, 'Carbon', 'C', 'IV'); + AddElement(7, 'Nitrogen', 'N', 'V'); + AddElement(8, 'Oxygen', 'O', 'VI'); + AddElement(9, 'Fluorine', 'F', 'VII'); + AddElement(10, 'Neon', 'Ne', 'VIII'); + end; + + procedure InitalizeChemGrid; + begin + Self.Height := 310; + Self.Width := 340; + chemGrid.Align := alClient; + chemGrid.TIOptions := chemGrid.TIOptions + [tgoStartIndexAtOne]; + chemGrid.Options := chemGrid.Options + [goDrawFocusSelected]; + chemGrid.FixedColor := clMoneyGreen; + chemGrid.DefaultDrawing := True; + chemGrid.AutoFillColumns := True; + end; + +begin + Felements := TCollection.Create(TElementItem); + AddElements; + InitalizeChemGrid; + chemGrid.ListObject := Felements; +end; + +end. +