mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 19:29:34 +02:00
TAChart: Add input validation to Datapoints editor.
git-svn-id: trunk@60494 -
This commit is contained in:
parent
d0c12bd673
commit
cc5f16814e
@ -16,6 +16,7 @@ object DataPointsEditorForm: TDataPointsEditorForm
|
||||
Width = 276
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 6
|
||||
ColCount = 4
|
||||
Columns = <
|
||||
item
|
||||
Alignment = taRightJustify
|
||||
@ -58,6 +59,7 @@ object DataPointsEditorForm: TDataPointsEditorForm
|
||||
Width = 276
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
OKButton.OnClick = OKButtonClick
|
||||
HelpButton.Name = 'HelpButton'
|
||||
HelpButton.DefaultCaption = True
|
||||
CloseButton.Name = 'CloseButton'
|
||||
|
@ -31,6 +31,7 @@ type
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure miDeleteRowClick(Sender: TObject);
|
||||
procedure miInsertRowClick(Sender: TObject);
|
||||
procedure OKButtonClick(Sender: TObject);
|
||||
procedure pmRowsPopup(Sender: TObject);
|
||||
procedure sgDataButtonClick(ASender: TObject; ACol, ARow: Integer);
|
||||
procedure sgDataDrawCell(
|
||||
@ -43,6 +44,7 @@ type
|
||||
FDataPoints: TStrings;
|
||||
FXCount: Integer;
|
||||
FYCount: Integer;
|
||||
function ValidData(out ACol, ARow: Integer; out AMsg: String): Boolean;
|
||||
public
|
||||
procedure InitData(AXCount, AYCount: Integer; ADataPoints: TStrings);
|
||||
procedure ExtractData(out AModified: Boolean);
|
||||
@ -170,6 +172,20 @@ begin
|
||||
sgData.InsertColRow(false, FCurrentRow);
|
||||
end;
|
||||
|
||||
procedure TDataPointsEditorForm.OKButtonClick(Sender: TObject);
|
||||
var
|
||||
c, r: Integer;
|
||||
msg: String;
|
||||
begin
|
||||
if not ValidData(c, r, msg) then begin
|
||||
sgData.Row := r;
|
||||
sgData.Col := c;
|
||||
sgData.SetFocus;
|
||||
MessageDlg(msg, mtError, [mbOK], 0);
|
||||
ModalResult := mrNone;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDataPointsEditorForm.pmRowsPopup(Sender: TObject);
|
||||
begin
|
||||
FCurrentRow := sgData.MouseToCell(sgData.ScreenToClient(Mouse.CursorPos)).Y;
|
||||
@ -216,6 +232,38 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TDataPointsEditorForm.ValidData(out ACol, ARow: Integer;
|
||||
out AMsg: String): Boolean;
|
||||
var
|
||||
x: Double;
|
||||
i: Integer;
|
||||
r, c: Integer;
|
||||
s: String;
|
||||
begin
|
||||
Result := false;
|
||||
for r := 1 to sgData.RowCount-1 do begin
|
||||
for c := 1 to sgData.ColCount-3 do begin
|
||||
s := sgData.Cells[c, r];
|
||||
if (s <> '') and not TryStrToFloat(s, x) and not TryStrToFloat(s, x, DefSeparatorSettings) then
|
||||
begin
|
||||
ACol := c;
|
||||
ARow := r;
|
||||
AMsg := desNoNumber;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
s := sgData.Cells[sgData.ColCount - 2, r];
|
||||
if (s <> '') and not TryStrToInt(s, i) then begin
|
||||
ACol := sgData.ColCount - 2;
|
||||
ARow := r;
|
||||
AMsg := desNoInteger;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
Result := true;
|
||||
end;
|
||||
|
||||
|
||||
{ TDataPointsPropertyEditor }
|
||||
|
||||
procedure TDataPointsPropertyEditor.Edit;
|
||||
|
@ -29,6 +29,14 @@ msgstr "Zeile löschen"
|
||||
msgid "Insert row"
|
||||
msgstr "Zeile einfügen"
|
||||
|
||||
#: tachartstrconsts.desnointeger
|
||||
msgid "Value must be an integer."
|
||||
msgstr "Wert muss eine ganze Zahl sein."
|
||||
|
||||
#: tachartstrconsts.desnonumber
|
||||
msgid "Non-numeric value."
|
||||
msgstr "Kein numerischer Wert."
|
||||
|
||||
#: tachartstrconsts.destext
|
||||
msgid "Text"
|
||||
msgstr "Text"
|
||||
|
@ -17,6 +17,14 @@ msgstr "Poista rivi"
|
||||
msgid "Insert row"
|
||||
msgstr "Lisää rivi"
|
||||
|
||||
#: tachartstrconsts.desnointeger
|
||||
msgid "Value must be an integer."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.desnonumber
|
||||
msgid "Non-numeric value."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.destext
|
||||
msgid "Text"
|
||||
msgstr "Teksti"
|
||||
|
@ -27,6 +27,14 @@ msgstr "Supprimer la ligne"
|
||||
msgid "Insert row"
|
||||
msgstr "Insérer une ligne"
|
||||
|
||||
#: tachartstrconsts.desnointeger
|
||||
msgid "Value must be an integer."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.desnonumber
|
||||
msgid "Non-numeric value."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.destext
|
||||
msgid "Text"
|
||||
msgstr "Texte"
|
||||
|
@ -27,6 +27,14 @@ msgstr "Sor törlése"
|
||||
msgid "Insert row"
|
||||
msgstr "Sor beszúrása"
|
||||
|
||||
#: tachartstrconsts.desnointeger
|
||||
msgid "Value must be an integer."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.desnonumber
|
||||
msgid "Non-numeric value."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.destext
|
||||
msgid "Text"
|
||||
msgstr "Szöveg"
|
||||
|
@ -28,6 +28,14 @@ msgstr "Šalinti eilutę"
|
||||
msgid "Insert row"
|
||||
msgstr "Įterpti eilutę"
|
||||
|
||||
#: tachartstrconsts.desnointeger
|
||||
msgid "Value must be an integer."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.desnonumber
|
||||
msgid "Non-numeric value."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.destext
|
||||
msgid "Text"
|
||||
msgstr "Tekstas"
|
||||
|
@ -28,6 +28,14 @@ msgstr "Usuń wiersz"
|
||||
msgid "Insert row"
|
||||
msgstr "Wstaw wiersz"
|
||||
|
||||
#: tachartstrconsts.desnointeger
|
||||
msgid "Value must be an integer."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.desnonumber
|
||||
msgid "Non-numeric value."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.destext
|
||||
msgid "Text"
|
||||
msgstr "Tekst"
|
||||
|
@ -17,6 +17,14 @@ msgstr ""
|
||||
msgid "Insert row"
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.desnointeger
|
||||
msgid "Value must be an integer."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.desnonumber
|
||||
msgid "Non-numeric value."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.destext
|
||||
msgid "Text"
|
||||
msgstr ""
|
||||
|
@ -27,6 +27,14 @@ msgstr "Excluir linha"
|
||||
msgid "Insert row"
|
||||
msgstr "Inserir linha"
|
||||
|
||||
#: tachartstrconsts.desnointeger
|
||||
msgid "Value must be an integer."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.desnonumber
|
||||
msgid "Non-numeric value."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.destext
|
||||
msgid "Text"
|
||||
msgstr "Texto"
|
||||
|
@ -27,6 +27,14 @@ msgstr "Удалить строку"
|
||||
msgid "Insert row"
|
||||
msgstr "Вставить строку"
|
||||
|
||||
#: tachartstrconsts.desnointeger
|
||||
msgid "Value must be an integer."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.desnonumber
|
||||
msgid "Non-numeric value."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.destext
|
||||
msgid "Text"
|
||||
msgstr "Текст"
|
||||
|
@ -28,6 +28,14 @@ msgstr ""
|
||||
msgid "Insert row"
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.desnointeger
|
||||
msgid "Value must be an integer."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.desnonumber
|
||||
msgid "Non-numeric value."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.destext
|
||||
msgid "Text"
|
||||
msgstr "Text"
|
||||
|
@ -30,6 +30,14 @@ msgstr "Видалити рядок"
|
||||
msgid "Insert row"
|
||||
msgstr "Вставити рядок"
|
||||
|
||||
#: tachartstrconsts.desnointeger
|
||||
msgid "Value must be an integer."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.desnonumber
|
||||
msgid "Non-numeric value."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.destext
|
||||
msgid "Text"
|
||||
msgstr "Текст"
|
||||
|
@ -28,6 +28,14 @@ msgstr "删除行"
|
||||
msgid "Insert row"
|
||||
msgstr "插入行"
|
||||
|
||||
#: tachartstrconsts.desnointeger
|
||||
msgid "Value must be an integer."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.desnonumber
|
||||
msgid "Non-numeric value."
|
||||
msgstr ""
|
||||
|
||||
#: tachartstrconsts.destext
|
||||
msgid "Text"
|
||||
msgstr "文本"
|
||||
|
@ -36,6 +36,8 @@ resourcestring
|
||||
desText = 'Text';
|
||||
desInsertRow = 'Insert row';
|
||||
desDeleteRow = 'Delete row';
|
||||
desNoNumber = 'Non-numeric value.';
|
||||
desNoInteger = 'Value must be an integer.';
|
||||
|
||||
// Axis
|
||||
rsLeft = 'Left';
|
||||
|
Loading…
Reference in New Issue
Block a user