-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathufVarSelect.pas
More file actions
131 lines (110 loc) · 3.44 KB
/
Copy pathufVarSelect.pas
File metadata and controls
131 lines (110 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
unit ufVarSelect;
// Contains a plot
interface
uses
System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, Vcl.Controls, WEBLib.ExtCtrls, Vcl.StdCtrls,
WEBLib.StdCtrls, Types, VCL.TMSFNCTypes, VCL.TMSFNCUtils, VCL.TMSFNCGraphics, VCL.TMSFNCGraphicsTypes;
type
TVarSelectForm = class(TWebForm)
okButton1: TWebButton;
SpPlotCG: TWebCheckGroup;
procedure plotFormCreate(Sender: TObject);
procedure okButton1Click(Sender: TObject);
procedure SpPlotCGCheckClick(Sender: TObject; AIndex: Integer);
procedure setSpPlotCGFontColor( newColor: TColor);
procedure unCheckGroup();
procedure checkGroup();
private
function setChkGrpWidth(): integer; // adjusts width based on longest string in speciesList
procedure setWidths();
procedure setHeights();
public
speciesList: array of String;
ParentFormHeight: integer; // Height of main form, do not want form to be taller
PlotWForm: TVarSelectForm;
procedure fillSpeciesCG();
procedure chkSpecies(index: integer);
procedure unChkSpecies(index: integer);
end;
implementation
{$R *.dfm}
// Close Plot:
procedure TVarSelectForm.okButton1Click(Sender: TObject);
var lForm: TWebForm;
begin
lForm := TWebForm((Sender as TWebButton).Parent);
lForm.Close;
lForm.Free;
end;
procedure TVarSelectForm.plotFormCreate(Sender: TObject);
begin
//console.log('Species select form created');
self.ParentFormHeight := 200; // default
end;
procedure TVarSelectForm.SpPlotCGCheckClick(Sender: TObject; AIndex: Integer);
begin
// TODO ??
end;
procedure TVarSelectForm.setHeights();
var tmpHt: integer;
begin
self.SpPlotCG.height := round(2.6 * self.SpPlotCG.Font.Size * self.SpPlotCG.Items.Count);
tmpHt := self.SpPlotCG.Height + 30;
if tmpHt < self.ParentFormHeight then self.Height := tmpHt
else self.Height := trunc(self.ParentFormHeight - self.ParentFormHeight * 0.2);
end;
function TVarSelectForm.setChkGrpWidth(): integer;
var i, maxLength: integer;
begin
maxLength := 0;
for i := 0 to length(self.speciesList) -1 do
begin
if length(self.speciesList[i]) > maxLength then
maxLength := length(self.speciesList[i]);
end;
if maxLength < 10 then
maxLength := 10;
result := maxLength * 10;
end;
procedure TVarSelectForm.setWidths();
begin
self.SpPlotCG.Width := self.setChkGrpWidth ;// Adjust chkgrp width to fit longest string
self.okButton1.Left := self.SpPlotCG.Width + self.SpPlotCG.Left + 5;
self.Width := self.SpPlotCG.Width + self.okButton1.Width + 25; // adjust form width
end;
procedure TVarSelectForm.fillSpeciesCG();
var i : integer;
begin
self.setWidths;
for i := 0 to length(speciesList)-1 do
SpPlotCG.Items.Add (' ' + speciesList[i]);
self.setHeights;
end;
procedure TVarSelectForm.unCheckGroup();
var i: integer;
begin
for i := 0 to length(speciesList)-1 do
SpPlotCG.Checked[i] := false;
end;
procedure TVarSelectForm.checkGroup();
var i: integer;
begin
for i := 0 to length(speciesList)-1 do
SpPlotCG.Checked[i] := true;
end;
procedure TVarSelectForm.chkSpecies(index: integer);
begin
if index < self.SpPlotCG.Items.Count then
self.SpPlotCG.Checked[index] := true;
end;
procedure TVarSelectForm.unChkSpecies(index: integer);
begin
if index < self.SpPlotCG.Items.Count then
self.SpPlotCG.Checked[index] := false;
end;
procedure TVarSelectForm.setSpPlotCGFontColor(newColor: TColor);
begin
self.SpPlotCG.font.color := newColor;
end;
end.