summaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-08-25 05:44:26 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-08-25 05:44:26 +0000
commit6cbfa3bf5499d5e2d55489d04380d36c177a6f1b (patch)
treee06357e92cb23aeb1332caa4030f5ee7eccbde15 /extras
parent077c5684054df2a5ca86c281029cc906b1f52a6c (diff)
downloadfpGUI-6cbfa3bf5499d5e2d55489d04380d36c177a6f1b.tar.xz
* Started updating the tiOPF mediator demos using the new MGM implementation.
Diffstat (limited to 'extras')
-rw-r--r--extras/tiopf/demos/Common/Model_View.pas77
-rw-r--r--extras/tiopf/demos/EditControlsDemo/frmMain.pas46
2 files changed, 72 insertions, 51 deletions
diff --git a/extras/tiopf/demos/Common/Model_View.pas b/extras/tiopf/demos/Common/Model_View.pas
index 82a9027b..d50762fd 100644
--- a/extras/tiopf/demos/Common/Model_View.pas
+++ b/extras/tiopf/demos/Common/Model_View.pas
@@ -7,10 +7,10 @@ unit Model_View;
interface
uses
- Classes
- ,tiGenericEditMediators
- ,tiGenericListMediators
-// ,tiCompositeMediators
+ Classes, tiMediators
+// , tiListMediators
+// ,tiGenericEditMediators
+// ,tiGenericListMediators
;
type
@@ -28,8 +28,8 @@ type
procedure OnTextChanged(Sender: TObject);
protected
procedure SetupGUIandObject; override;
- procedure GuiToObject; override;
- procedure ObjectToGui; override;
+ procedure DoGuiToObject; override;
+ procedure DoObjectToGui; override;
end;
@@ -64,11 +64,11 @@ type
{ TPersonList_ComboBox_Mediator }
- TPersonList_ComboBox_Mediator = class(TComboBoxMediator)
- protected
- procedure SetupGUIandObject; override;
- end;
-
+ //TPersonList_ComboBox_Mediator = class(TComboBoxMediator)
+ //protected
+ //procedure SetupGUIandObject; override;
+ //end;
+
(*
TPersonList_ListView_CompositeMediator = class(TCompositeListViewMediator)
protected
@@ -79,7 +79,23 @@ type
implementation
uses
- Model, SysUtils;
+ Model, SysUtils, tiBaseMediator, TypInfo, tiObject;
+
+
+procedure RegisterMediators;
+begin
+ // Fallbacks (generic)
+ gMediatorManager.RegisterMediator(TMediatorEditView,TTiObject,[tkSstring,tkAstring,tkinteger,tkFloat]);
+ gMediatorManager.RegisterMediator(TMediatorCheckBoxView,TTiObject,[tkBool]);
+ gMediatorManager.RegisterMediator(TMediatorComboboxView,TTiObject,[tkSString,tkAString]);
+ gMediatorManager.RegisterMediator(TMediatorStaticTextView,TTiObject);
+ gMediatorManager.RegisterMediator(TMediatorTrackBarView,TTiObject,[tkInteger]);
+ gMediatorManager.RegisterMediator(TMediatorDynamicComboBoxView,TTiObject,[tkClass]);
+ gMediatorManager.RegisterMediator(TMediatorMemoView,TTiObject,[tksString,tkAString]);
+ // Specific
+// gMediatorManager.RegisterMediator(TMediatorCalendarComboView,TLeerling,'DateOfBirth');
+// gMediatorManager.RegisterMediator(TMediatorComboboxView,TLeerling,'Gender');
+end;
{ TPersonNameView }
@@ -120,12 +136,12 @@ end;
{ TPersonList_ComboBox_Mediator }
-procedure TPersonList_ComboBox_Mediator.SetupGUIandObject;
-begin
- inherited SetupGUIandObject;
-// View.Style := csDropDownList;
-// View.ReadOnly := True;
-end;
+//procedure TPersonList_ComboBox_Mediator.SetupGUIandObject;
+//begin
+ //inherited SetupGUIandObject;
+//// View.Style := csDropDownList;
+//// View.ReadOnly := True;
+//end;
{ TPersonList_ListView_CompositeMediator }
@@ -167,33 +183,24 @@ begin
EditControl.OnChange := @OnTextChanged;
end;
-procedure TPerson_Age_TextEdit_View.GuiToObject;
+procedure TPerson_Age_TextEdit_View.DoGuiToObject;
begin
- inherited GuiToObject;
+ inherited DoGuiToObject;
// manual example without RTTI
// TPerson(Subject).Age := StrToInt(EditControl.Text);
end;
-procedure TPerson_Age_TextEdit_View.ObjectToGui;
+procedure TPerson_Age_TextEdit_View.DoObjectToGui;
begin
- inherited ObjectToGui;
+ inherited DoObjectToGui;
// manual example without RTTI
// EditControl.Text := IntToStr(TPerson(Subject).Age);
end;
+
initialization
- {-----------------------------------------------------------------------------
- Register all your Mediator Views here
- Params: ClassName and Property name of the business object as a string
- Mediator View class
- -----------------------------------------------------------------------------}
+ { Register all your Mediator Views here }
+ RegisterMediators;
- // This is not used anymore and needs to be removed
-{
- gMediatorFactory.RegisterMediatorClass('TPerson.Name' ,TPerson_Name_TextEdit_View);
- gMediatorFactory.RegisterMediatorClass('TPerson.Age' ,TPerson_Age_SpinEdit_View);
- gMediatorFactory.RegisterMediatorClass('TPerson.Age' ,TPerson_Age_TrackBar_Mediator);
- gMediatorFactory.RegisterMediatorClass('TPerson.Name' ,TPerson_Name_Memo_Mediator);
- gMediatorFactory.RegisterMediatorClass('TPerson.GenderGUI',TPerson_Gender_ComboBox_Mediator);
-}
end.
+
diff --git a/extras/tiopf/demos/EditControlsDemo/frmMain.pas b/extras/tiopf/demos/EditControlsDemo/frmMain.pas
index 83d25adc..d6e416de 100644
--- a/extras/tiopf/demos/EditControlsDemo/frmMain.pas
+++ b/extras/tiopf/demos/EditControlsDemo/frmMain.pas
@@ -6,7 +6,7 @@ interface
uses
Classes, SysUtils, gui_form, gui_button, gui_label, gui_edit, gui_trackbar,
- gui_combobox, gui_memo, Model, tiGenericEditMediators;
+ gui_combobox, gui_memo, Model, tiFormMediator, Model_View;
type
TMainForm = class(TfpgForm)
@@ -25,12 +25,14 @@ type
{ The object we will be working with. }
FPerson: TPerson;
+ { Form Mediator }
+ FMediator: TFormMediator;
{ Edit mediators }
- FEditNameMediator: TMediatorEditView;
-// FSpinEditAgeMediator: TMediatorSpinEditView;
- FTrackBarAgeMediator: TMediatorTrackBarView;
- FMemoNameMediator: TMediatorMemoView;
- FComboBoxGenderMediator: TMediatorComboBoxView;
+// FEditNameMediator: TMediatorEditView;
+//// FSpinEditAgeMediator: TMediatorSpinEditView;
+// FTrackBarAgeMediator: TMediatorTrackBarView;
+// FMemoNameMediator: TMediatorMemoView;
+// FComboBoxGenderMediator: TMediatorComboBoxView;
procedure btnCloseClick(Sender: TObject);
procedure btnShowModelClick(Sender: TObject);
@@ -52,7 +54,6 @@ implementation
uses
gui_dialogs
- ,Model_View
;
{ TMainForm }
@@ -77,7 +78,7 @@ end;
procedure TMainForm.edtNameChange(Sender: TObject);
begin
- FEditNameMediator.GUIChanged;
+ //FEditNameMediator.GUIChanged;
end;
procedure TMainForm.edtAgeChange(Sender: TObject);
@@ -87,13 +88,13 @@ end;
procedure TMainForm.AgeTrackBarChange(Sender: TObject; APosition: integer);
begin
- FTrackBarAgeMediator.GUIChanged;
+ //FTrackBarAgeMediator.GUIChanged;
end;
procedure TMainForm.cbGenderChange(Sender: TObject);
begin
- writeln('cbGenderChange');
- FComboBoxGenderMediator.GUIChanged;
+ //writeln('cbGenderChange');
+ //FComboBoxGenderMediator.GUIChanged;
end;
procedure TMainForm.InitializeComponents;
@@ -227,11 +228,24 @@ end;
procedure TMainForm.SetupMediators;
begin
+{
FEditNameMediator := TPerson_Name_TextEdit_View.CreateCustom(edtName, FPerson, 'Name', 'Text');
// FSpinEditAgeMediator := TPerson_Age_SpinEdit_View.CreateCustom(edtAge, FPerson, 'Age', 'Value');
FTrackBarAgeMediator := TPerson_Age_TrackBar_Mediator.CreateCustom(AgeTrackBar, FPerson, 'Age', 'Position');
FMemoNameMediator := TPerson_Name_Memo_Mediator.CreateCustom(memMemo, FPerson, 'Name', '');
FComboBoxGenderMediator := TPerson_Gender_ComboBox_Mediator.CreateCustom(cbGender, FPerson, 'GenderGUI', 'Text');
+}
+ if not Assigned(FMediator) then
+ begin
+ FMediator := TFormMediator.Create(self);
+ FMediator.Name := 'DemoMediator';
+ FMediator.AddProperty('Name', edtName);
+ FMediator.AddProperty('Age', AgeTrackBar);
+ FMediator.AddProperty('Name', memMemo);
+ FMediator.AddProperty('GenderGUI', cbGender);
+ end;
+ FMediator.Subject := FPerson;
+ FMediator.Active := True;
end;
procedure TMainForm.SetupEventHandlers;
@@ -266,11 +280,11 @@ end;
destructor TMainForm.Destroy;
begin
{ free mediators - they will detach themselves }
- FEditNameMediator.Free;
-// FSpinEditAgeMediator.Free;
- FTrackBarAgeMediator.Free;
- FMemoNameMediator.Free;
- FComboBoxGenderMediator.Free;
+// FEditNameMediator.Free;
+//// FSpinEditAgeMediator.Free;
+// FTrackBarAgeMediator.Free;
+// FMemoNameMediator.Free;
+// FComboBoxGenderMediator.Free;
FPerson.Free;
inherited Destroy;