summaryrefslogtreecommitdiff
path: root/extras/tiopf/demos/Common/Model_View.pas
diff options
context:
space:
mode:
Diffstat (limited to 'extras/tiopf/demos/Common/Model_View.pas')
-rw-r--r--extras/tiopf/demos/Common/Model_View.pas50
1 files changed, 49 insertions, 1 deletions
diff --git a/extras/tiopf/demos/Common/Model_View.pas b/extras/tiopf/demos/Common/Model_View.pas
index 7cc68e8a..82a9027b 100644
--- a/extras/tiopf/demos/Common/Model_View.pas
+++ b/extras/tiopf/demos/Common/Model_View.pas
@@ -14,11 +14,23 @@ uses
;
type
- { TEdit - Name }
+ { TfpgEdit - Name }
TPerson_Name_TextEdit_View = class(TMediatorEditView)
+ private
+ procedure OnTextChanged(Sender: TObject);
protected
procedure SetupGUIandObject; override;
end;
+
+ { TfpgEdit - Age }
+ TPerson_Age_TextEdit_View = class(TMediatorEditView)
+ private
+ procedure OnTextChanged(Sender: TObject);
+ protected
+ procedure SetupGUIandObject; override;
+ procedure GuiToObject; override;
+ procedure ObjectToGui; override;
+ end;
{ TSpinEdit - Age }
@@ -66,14 +78,22 @@ type
implementation
+uses
+ Model, SysUtils;
{ TPersonNameView }
+procedure TPerson_Name_TextEdit_View.OnTextChanged(Sender: TObject);
+begin
+ GUIChanged;
+end;
+
procedure TPerson_Name_TextEdit_View.SetupGUIandObject;
begin
inherited;
{ The Name field my only contain 25 characters max. }
EditControl.MaxLength := 25;
+ EditControl.OnChange := @OnTextChanged;
end;
@@ -133,6 +153,34 @@ begin
EditControl.Max := 100;
end;
+{ TPerson_Age_TextEdit_View }
+
+procedure TPerson_Age_TextEdit_View.OnTextChanged(Sender: TObject);
+begin
+ GUIChanged;
+end;
+
+procedure TPerson_Age_TextEdit_View.SetupGUIandObject;
+begin
+ inherited SetupGUIandObject;
+ EditControl.MaxLength := 3;
+ EditControl.OnChange := @OnTextChanged;
+end;
+
+procedure TPerson_Age_TextEdit_View.GuiToObject;
+begin
+ inherited GuiToObject;
+ // manual example without RTTI
+// TPerson(Subject).Age := StrToInt(EditControl.Text);
+end;
+
+procedure TPerson_Age_TextEdit_View.ObjectToGui;
+begin
+ inherited ObjectToGui;
+ // manual example without RTTI
+// EditControl.Text := IntToStr(TPerson(Subject).Age);
+end;
+
initialization
{-----------------------------------------------------------------------------
Register all your Mediator Views here