Browse Source

+ Fixes from Jesus Reyes to implement DisplayWith, DisplayLabel, Visibility

michael 21 years ago
parent
commit
e605893f0d
2 changed files with 80 additions and 8 deletions
  1. 17 7
      fcl/db/db.pp
  2. 63 1
      fcl/db/fields.inc

+ 17 - 7
fcl/db/db.pp

@@ -215,8 +215,15 @@ type
     FValidating : Boolean;
     FValidating : Boolean;
     FVisible : Boolean;
     FVisible : Boolean;
     Function GetIndex : longint;
     Function GetIndex : longint;
+    procedure SetAlignment(const AValue: TAlignMent);
     Procedure SetDataset(VAlue : TDataset);
     Procedure SetDataset(VAlue : TDataset);
     function GetDisplayText: String;
     function GetDisplayText: String;
+    procedure SetDisplayLabel(const AValue: string);
+    procedure SetDisplayWidth(const AValue: Longint);
+    function GetDisplayWidth: integer;
+    procedure SetReadOnly(const AValue: Boolean);
+    procedure SetVisible(const AValue: Boolean);
+    function IsDisplayStored : Boolean;
   protected
   protected
     function AccessError(const TypeName: string): EDatabaseError;
     function AccessError(const TypeName: string): EDatabaseError;
     procedure CheckInactive;
     procedure CheckInactive;
@@ -245,7 +252,7 @@ type
     procedure SetAsDateTime(AValue: TDateTime); virtual;
     procedure SetAsDateTime(AValue: TDateTime); virtual;
     procedure SetAsFloat(AValue: Double); virtual;
     procedure SetAsFloat(AValue: Double); virtual;
     procedure SetAsLongint(AValue: Longint); virtual;
     procedure SetAsLongint(AValue: Longint); virtual;
-    procedure SetAsInteger(AValue: Longint); virtual;
+    procedure SetAsInteger(AValue: Integer); virtual;
     procedure SetAsString(const AValue: string); virtual;
     procedure SetAsString(const AValue: string); virtual;
     procedure SetDataType(AValue: TFieldType);
     procedure SetDataType(AValue: TFieldType);
     procedure SetSize(AValue: Word); virtual;
     procedure SetSize(AValue: Word); virtual;
@@ -285,12 +292,12 @@ type
     property Text: string read FEditText write FEditText;
     property Text: string read FEditText write FEditText;
     property ValidChars : TFieldChars Read FValidChars;
     property ValidChars : TFieldChars Read FValidChars;
   published
   published
-    property AlignMent : TAlignMent Read FAlignMent write FAlignment;
+    property AlignMent : TAlignMent Read FAlignMent write SetAlignment;
     property CustomConstraint: string read FCustomConstraint write FCustomConstraint;
     property CustomConstraint: string read FCustomConstraint write FCustomConstraint;
     property ConstraintErrorMessage: string read FConstraintErrorMessage write FConstraintErrorMessage;
     property ConstraintErrorMessage: string read FConstraintErrorMessage write FConstraintErrorMessage;
     property DefaultExpression: string read FDefaultExpression write FDefaultExpression;
     property DefaultExpression: string read FDefaultExpression write FDefaultExpression;
-    property DisplayLabel : string read FDisplayLabel write FDisplayLabel;
-    property DisplayWidth: Longint read FDisplayWidth write FDisplayWidth;
+    property DisplayLabel : string read GetDisplayName write SetDisplayLabel stored IsDisplayStored;
+    property DisplayWidth: Longint read GetDisplayWidth write SetDisplayWidth;
     property FieldKind: TFieldKind read FFieldKind write FFieldKind;
     property FieldKind: TFieldKind read FFieldKind write FFieldKind;
     property FieldName: string read FFieldName write FFieldName;
     property FieldName: string read FFieldName write FFieldName;
     property HasConstraints: Boolean read FHasConstraints;
     property HasConstraints: Boolean read FHasConstraints;
@@ -302,9 +309,9 @@ type
     property KeyFields: string read FKeyFields write FKeyFields;
     property KeyFields: string read FKeyFields write FKeyFields;
     property LookupCache: Boolean read FLookupCache write FLookupCache;
     property LookupCache: Boolean read FLookupCache write FLookupCache;
     property Origin: string read FOrigin write FOrigin;
     property Origin: string read FOrigin write FOrigin;
-    property ReadOnly: Boolean read FReadOnly write FReadOnly;
+    property ReadOnly: Boolean read FReadOnly write SetReadOnly;
     property Required: Boolean read FRequired write FRequired;
     property Required: Boolean read FRequired write FRequired;
-    property Visible: Boolean read FVisible write FVisible;
+    property Visible: Boolean read FVisible write SetVisible;
     property OnChange: TFieldNotifyEvent read FOnChange write FOnChange;
     property OnChange: TFieldNotifyEvent read FOnChange write FOnChange;
     property OnGetText: TFieldGetTextEvent read FOnGetText write FOnGetText;
     property OnGetText: TFieldGetTextEvent read FOnGetText write FOnGetText;
     property OnSetText: TFieldSetTextEvent read FOnSetText write FOnSetText;
     property OnSetText: TFieldSetTextEvent read FOnSetText write FOnSetText;
@@ -1492,7 +1499,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.17  2004-07-18 13:16:50  michael
+  Revision 1.18  2004-07-19 20:27:28  michael
+  + Fixes from Jesus Reyes to implement DisplayWith, DisplayLabel, Visibility
+
+  Revision 1.17  2004/07/18 13:16:50  michael
   + Changed extended to double for better Delphi compatibility
   + Changed extended to double for better Delphi compatibility
 
 
   Revision 1.16  2004/05/02 21:23:18  peter
   Revision 1.16  2004/05/02 21:23:18  peter

+ 63 - 1
fcl/db/fields.inc

@@ -387,6 +387,12 @@ begin
     Result:=FFieldName;
     Result:=FFieldName;
 end;
 end;
 
 
+Function TField.IsDisplayStored : Boolean;
+
+begin
+  Result:=(DisplayLabel<>FieldName);
+end;
+
 function TField.getIndex : longint;
 function TField.getIndex : longint;
 
 
 begin
 begin
@@ -396,6 +402,15 @@ begin
     Result:=-1;
     Result:=-1;
 end;
 end;
 
 
+procedure TField.SetAlignment(const AValue: TAlignMent);
+begin
+  if FAlignment <> AValue then 
+    begin
+    FAlignment := Avalue;
+    PropertyChanged(false);
+    end;
+end;
+
 function TField.GetIsNull: Boolean;
 function TField.GetIsNull: Boolean;
 
 
 begin
 begin
@@ -585,6 +600,50 @@ begin
     GetText(Result, True);
     GetText(Result, True);
 end;
 end;
 
 
+procedure TField.SetDisplayLabel(const AValue: string);
+begin
+  if FDisplayLabel<>Avalue then 
+    begin
+    FDisplayLabel:=Avalue;
+    PropertyChanged(true);
+    end;
+end;
+
+procedure TField.SetDisplayWidth(const AValue: Longint);
+begin
+  if FDisplayWidth<>AValue then 
+    begin
+    FDisplayWidth:=AValue;
+    PropertyChanged(True);
+    end;
+end;
+
+function TField.GetDisplayWidth: integer;
+begin
+  if FDisplayWidth=0 then
+    result:=GetDefaultWidth
+  else
+    result:=FDisplayWidth;
+end;
+
+procedure TField.SetReadOnly(const AValue: Boolean);
+begin
+  if (FReadOnly<>Avalue) then 
+    begin
+    FReadOnly:=AValue;
+    PropertyChanged(True);
+    end;
+end;
+
+procedure TField.SetVisible(const AValue: Boolean);
+begin
+  if FVisible<>Avalue then 
+    begin
+    FVisible:=AValue;
+    PropertyChanged(True);
+    end;
+end;
+
 
 
 { ---------------------------------------------------------------------
 { ---------------------------------------------------------------------
     TStringField
     TStringField
@@ -1806,7 +1865,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.12  2004-07-18 13:16:50  michael
+  Revision 1.13  2004-07-19 20:27:29  michael
+  + Fixes from Jesus Reyes to implement DisplayWith, DisplayLabel, Visibility
+
+  Revision 1.12  2004/07/18 13:16:50  michael
   + Changed extended to double for better Delphi compatibility
   + Changed extended to double for better Delphi compatibility
 
 
   Revision 1.11  2004/05/02 21:23:18  peter
   Revision 1.11  2004/05/02 21:23:18  peter