summaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-08-25 09:35:04 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-08-25 09:35:04 +0000
commit6106c289874b0205aaebbf37a78ccc23fb7ff5c4 (patch)
treee092117b89d0a19f0ec27b472f63d1082499db9d /extras
parent65c4f0c722d95be2e4babbe2cd4cbc43d33da42a (diff)
downloadfpGUI-6106c289874b0205aaebbf37a78ccc23fb7ff5c4.tar.xz
* Implemented missing SetupGUIandObject in tiMeditaros for TfpgTrackBar.
* Moved DoObjectToGUI it Trackbar mediator from public to protected. * Minor code formatting fixes. * Implemented DoGetFieldBounds for TPerson in tiOPF demos.
Diffstat (limited to 'extras')
-rw-r--r--extras/tiopf/demos/Common/Model.pas26
-rw-r--r--extras/tiopf/gui/tiMediators.pas75
2 files changed, 71 insertions, 30 deletions
diff --git a/extras/tiopf/demos/Common/Model.pas b/extras/tiopf/demos/Common/Model.pas
index 57be1783..9d5dea39 100644
--- a/extras/tiopf/demos/Common/Model.pas
+++ b/extras/tiopf/demos/Common/Model.pas
@@ -44,7 +44,7 @@ type
procedure SetMemento(const AValue: TPersonMemento);
protected
function GetCaption: string; override;
- procedure DoGetFieldBounds(const AFieldName: String; var MinValue, MaxValue: Integer; var HasBounds: Boolean); overload;
+ procedure DoGetFieldBounds(const AFieldName: String; var MinValue, MaxValue: Integer; var HasBounds: Boolean); override;
public
constructor Create; override;
function IsValid(const pErrors: TtiObjectErrors): Boolean; override;
@@ -168,11 +168,25 @@ end;
procedure TPerson.DoGetFieldBounds(const AFieldName: String; var MinValue,
MaxValue: Integer; var HasBounds: Boolean);
begin
- inherited; // until I can figure this out
-{
- HasBounds := True;
-}
- // How do I check or set the Name property to max 25 character?
+ if AFieldName = 'Name' then
+ begin
+ writeln(' Name - DoGetFieldBounds');
+ HasBounds := True;
+ MinValue := 1;
+ MaxValue := 25;
+ end
+ else if AFieldName = 'Age' then
+ begin
+ writeln(' Age - DoGetFieldBounds');
+ HasBounds := True;
+ MinValue := 1;
+ MaxValue := 95;
+ end
+ else
+ begin
+ writeln(' unknown property <', AFieldName, '> - DoGetFieldBounds');
+ inherited DoGetFieldBounds(AFieldName, MinValue, MaxValue, HasBounds);
+ end;
end;
constructor TPerson.Create;
diff --git a/extras/tiopf/gui/tiMediators.pas b/extras/tiopf/gui/tiMediators.pas
index dd5d47e3..5c7ccb3a 100644
--- a/extras/tiopf/gui/tiMediators.pas
+++ b/extras/tiopf/gui/tiMediators.pas
@@ -103,6 +103,9 @@ type
FEditControl: TfpgTrackBar;
function GetGUIControl: TComponent; override;
procedure SetGUIControl(const AValue: TComponent);override;
+ procedure DoTrackBarChanged(Sender: TObject; APosition: integer);
+ protected
+ procedure SetupGUIandObject; override;
public
Constructor Create; override;
property EditControl: TfpgTrackBar read FEditControl write FEditControl;
@@ -118,10 +121,10 @@ type
procedure SetGUIControl(const AValue: TComponent);override;
protected
procedure UpdateGuiValidStatus(pErrors: TtiObjectErrors); override;
+ procedure DoObjectToGui; override;
public
Constructor Create; override;
property EditControl: TfpgComboBox read FEditControl write FEditControl;
- procedure DoObjectToGui; override;
class function ComponentClass: TClass; override;
end;
@@ -227,26 +230,25 @@ end;
procedure TMediatorEditView.SetupGUIandObject;
var
- Mi,Ma : Integer;
+ Mi, Ma: Integer;
begin
inherited;
if Subject.GetFieldBounds(FieldName,Mi,Ma) and (Ma>0) then
- FEditControl.MaxLength:=Ma;
- if ObjectUpdateMoment in [ouOnchange,ouCustom] then
- FeditControl.OnChange:=@DoOnChange
+ FEditControl.MaxLength := Ma;
+ if ObjectUpdateMoment in [ouOnChange,ouCustom] then
+ FeditControl.OnChange := @DoOnChange
else
- FeditControl.OnExit:=@DoOnChange
+ FeditControl.OnExit := @DoOnChange;
end;
-procedure TMediatorEditView.SetObjectUpdateMoment(
- const AValue: TObjectUpdateMoment);
+procedure TMediatorEditView.SetObjectUpdateMoment(const AValue: TObjectUpdateMoment);
begin
inherited SetObjectUpdateMoment(AValue);
- If Assigned(FEditControl) then
+ if Assigned(FEditControl) then
If ObjectUpdateMoment in [ouOnchange,ouCustom] then
- FeditControl.OnChange:=@DoOnChange
+ FeditControl.OnChange := @DoOnChange
else
- FeditControl.OnExit:=@DoOnChange
+ FeditControl.OnExit := @DoOnChange;
end;
constructor TMediatorEditView.Create;
@@ -354,10 +356,35 @@ begin
Inherited;
end;
+procedure TMediatorTrackBarView.DoTrackBarChanged(Sender: TObject; APosition: integer);
+begin
+// writeln(' executing - DoTrackBarChanged');
+ GUIChanged;
+end;
+
+procedure TMediatorTrackBarView.SetupGUIandObject;
+var
+ Mi, Ma: Integer;
+begin
+ inherited;
+ if Subject.GetFieldBounds(FieldName,Mi,Ma) and (Ma>0) then
+ begin
+ FEditControl.Min := Mi;
+ FEditControl.Max := Ma;
+ end;
+ if ObjectUpdateMoment in [ouOnChange,ouCustom] then
+ begin
+// writeln(' Trackbar: setting OnChange event handler');
+ FEditControl.OnChange := @DoTrackBarChanged;
+ end;
+// else
+// FeditControl.OnExit := @DoOnChange;
+end;
+
constructor TMediatorTrackBarView.Create;
begin
- Inherited;
- GuiFieldName:='Position';
+ inherited;
+ GuiFieldName := 'Position';
end;
class function TMediatorTrackBarView.ComponentClass: TClass;
@@ -375,13 +402,13 @@ end;
function TMediatorComboBoxView.GetGUIControl: TComponent;
begin
- Result:=FeditControl;
+ Result := FEditControl;
end;
procedure TMediatorComboBoxView.SetGUIControl(const AValue: TComponent);
begin
- FEditControl:=AValue as TfpgComboBox;
- Inherited;
+ FEditControl := AValue as TfpgComboBox;
+ inherited;
end;
procedure TMediatorComboBoxView.UpdateGuiValidStatus(pErrors: TtiObjectErrors);
@@ -629,18 +656,18 @@ end;
constructor TMediatorStaticTextView.Create;
begin
inherited Create;
- GuiFieldName:='Text';
+ GuiFieldName := 'Text';
end;
function TMediatorStaticTextView.GetGUIControl: TComponent;
begin
- Result:=FEditControl;
+ Result := FEditControl;
end;
procedure TMediatorStaticTextView.SetGUIControl(const AValue: TComponent);
begin
- FEditControl:=AValue as TfpgLabel;
- Inherited;
+ FEditControl := AValue as TfpgLabel;
+ inherited;
end;
class function TMediatorStaticTextView.ComponentClass: TClass;
@@ -653,19 +680,19 @@ end;
function TMediatorCalendarComboView.GetGUIControl: TComponent;
begin
- Result:=FEditControl;
+ Result := FEditControl;
end;
procedure TMediatorCalendarComboView.SetGUIControl(const AValue: TComponent);
begin
- FEditControl:= AValue as TfpgCalendarCombo;
- Inherited;
+ FEditControl := AValue as TfpgCalendarCombo;
+ inherited;
end;
constructor TMediatorCalendarComboView.Create;
begin
inherited Create;
- GUIFieldName:='DateValue';
+ GUIFieldName := 'DateValue';
end;
class function TMediatorCalendarComboView.ComponentClass: TClass;