Files
yapetavi/frmadd.pas
2022-10-24 22:07:20 +02:00

112 lines
2.9 KiB
ObjectPascal

{
********************************************************************************
YaPeTaVi - Yet another Periodic Table Viewer
Copyright (C) 1997, 2009 Geoffray Levasseur <geoffray.levasseurbrandin@numericable.fr>.
All rights reserved.
http://www.geoffray-levasseur.org/
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
********************************************************************************
Description:
Add element dialog unit
}
{$warning Todo: This form should have a drop-down element to select in wich tool
the atom is added}
unit frmAdd;
{$mode objfpc}{$H+}
interface
uses
SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, ComCtrls, LResources, Spin, Buttons;
type
{ TAddForm }
TAddForm = class(TForm)
btnCancel: TBitBtn;
btnOk: TBitBtn;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit: TSpinEdit;
procedure btnOkClick(Sender: TObject);
procedure EditKeyPress(Sender: TObject; var Key: Char);
procedure btnCancelClick(Sender: TObject);
procedure EditChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
AddForm: TAddForm;
implementation
uses
frmMassCalculator, uIconManager;
procedure TAddForm.btnOkClick(Sender: TObject);
begin { $warning MassCalcForm can be unintialised!}
if MassCalcForm = nil then
MassCalcForm := TMassCalcForm.Create(Application);
if (StrToInt(Edit.Text) > 0) and (StrToInt(Edit.Text) <= 99) then
begin
if Edit.Text = '1' then
MassCalcForm.Edit.Text := MassCalcForm.Edit.Text + Label2.Caption
else MassCalcForm.Edit.Text := MassCalcForm.Edit.Text + Label2.Caption +
Trim(Edit.Text);
Close;
end;
end;
procedure TAddForm.EditKeyPress(Sender: TObject; var Key: Char);
begin
If (Key = #13) and (Trim(Edit.Text) <> '') then
btnOkClick(Self);
end;
procedure TAddForm.btnCancelClick(Sender: TObject);
begin
Close;
end;
procedure TAddForm.EditChange(Sender: TObject);
begin
if Trim(Edit.Text) = '' then
btnOk.Enabled := False
else btnOk.Enabled := True;
end;
procedure TAddForm.FormCreate(Sender: TObject);
begin
InitBtnGlyphs(Self);
end;
initialization
{$i frmadd.lrs}
end.