Просмотр исходного кода

* Added TField.DisplayText, and accordingly changed all arguments called
DisplayText to ADisplayText

sg 25 лет назад
Родитель
Сommit
d6045a9d1d
2 измененных файлов с 47 добавлено и 25 удалено
  1. 16 10
      fcl/db/db.pp
  2. 31 15
      fcl/db/fields.inc

+ 16 - 10
fcl/db/db.pp

@@ -179,6 +179,7 @@ type
     FVisible : Boolean;
     Function GetIndex : longint;
     Procedure SetDataset(VAlue : TDataset);
+    function GetDisplayText: String;
   protected
     function AccessError(const TypeName: string): EDatabaseError;
     procedure CheckInactive;
@@ -194,7 +195,7 @@ type
     function GetCanModify: Boolean; virtual;
     function GetDataSize: Word; virtual;
     function GetDefaultWidth: Longint; virtual;
-    function GetDisplayName : String; 
+    function GetDisplayName : String;
     function GetIsNull: Boolean; virtual;
     function GetParentComponent: TComponent; override;
     procedure GetText(var AText: string; ADisplayText: Boolean); virtual;
@@ -234,6 +235,8 @@ type
     property DataSet: TDataSet read FDataSet write SetDataSet;
     property DataSize: Word read GetDataSize;
     property DataType: TFieldType read FDataType;
+    property DisplayName: String Read GetDisplayName; 
+    property DisplayText: String read GetDisplayText;
     property FieldNo: Longint read FFieldNo;
     property IsIndexField: Boolean read FIsIndexField;
     property IsNull: Boolean read GetIsNull;
@@ -247,7 +250,6 @@ type
     property ConstraintErrorMessage: string read FConstraintErrorMessage write FConstraintErrorMessage;
     property DefaultExpression: string read FDefaultExpression write FDefaultExpression;
     property DisplayLabel : string read FDisplayLabel write FDisplayLabel;
-    property DisplayName : String Read GetDisplayName; 
     property DisplayWidth: Longint read FDisplayWidth write FDisplayWidth;
     property FieldKind: TFieldKind read FFieldKind write FFieldKind;
     property FieldName: string read FFieldName write FFieldName;
@@ -281,7 +283,7 @@ type
     function GetAsString: string; override;
     function GetDataSize: Word; override;
     function GetDefaultWidth: Longint; override;
-    procedure GetText(var AText: string; DisplayText: Boolean); override;
+    procedure GetText(var AText: string; ADisplayText: Boolean); override;
     function GetValue(var AValue: string): Boolean;
     procedure SetAsBoolean(AValue: Boolean); override;
     procedure SetAsDateTime(AValue: TDateTime); override;
@@ -326,7 +328,7 @@ type
     function GetAsLongint: Longint; override;
     function GetAsString: string; override;
     function GetDataSize: Word; override;
-    procedure GetText(var AText: string; DisplayText: Boolean); override;
+    procedure GetText(var AText: string; ADisplayText: Boolean); override;
     function GetValue(var AValue: Longint): Boolean;
     procedure SetAsFloat(AValue: Extended); override;
     procedure SetAsLongint(AValue: Longint); override;
@@ -380,7 +382,7 @@ type
     function GetAsLongint: Longint; override;
     function GetAsString: string; override;
     function GetDataSize: Word; override;
-    procedure GetText(var theText: string; DisplayText: Boolean); override;
+    procedure GetText(var theText: string; ADisplayText: Boolean); override;
     procedure SetAsFloat(AValue: Extended); override;
     procedure SetAsLongint(AValue: Longint); override;
     procedure SetAsString(const AValue: string); override;
@@ -428,7 +430,7 @@ type
     function GetAsFloat: Extended; override;
     function GetAsString: string; override;
     function GetDataSize: Word; override;
-    procedure GetText(var theText: string; DisplayText: Boolean); override;
+    procedure GetText(var theText: string; ADisplayText: Boolean); override;
     procedure SetAsDateTime(AValue: TDateTime); override;
     procedure SetAsFloat(AValue: Extended); override;
     procedure SetAsString(const AValue: string); override;
@@ -463,7 +465,7 @@ type
   protected
     class procedure CheckTypeSize(AValue: Longint); override;
     function GetAsString: string; override;
-    procedure GetText(var TheText: string; DisplayText: Boolean); override;
+    procedure GetText(var TheText: string; ADisplayText: Boolean); override;
     procedure SetAsString(const AValue: string); override;
     procedure SetText(const AValue: string); override;
   public
@@ -501,7 +503,7 @@ type
     function GetAsString: string; override;
     function GetDataSize: Word; override;
     function GetDefaultWidth: Longint; override;
-    procedure GetText(var TheText: string; DisplayText: Boolean); override;
+    procedure GetText(var TheText: string; ADisplayText: Boolean); override;
     procedure SetAsFloat(AValue: Extended); override;
     procedure SetAsLongint(AValue: Longint); override;
     procedure SetAsString(const AValue: string); override;
@@ -528,7 +530,7 @@ type
     function GetAsString: string; override;
     function GetBlobSize: Longint; virtual;
     function GetIsNull: Boolean; override;
-    procedure GetText(var TheText: string; DisplayText: Boolean); override;
+    procedure GetText(var TheText: string; ADisplayText: Boolean); override;
     procedure SetAsString(const AValue: string); override;
     procedure SetText(const AValue: string); override;
   public
@@ -1401,7 +1403,11 @@ end.
 
 {
   $Log$
-  Revision 1.1.2.2  2000-12-23 10:10:22  michael
+  Revision 1.1.2.3  2000-12-23 23:26:45  sg
+  * Added TField.DisplayText, and accordingly changed all arguments called
+    DisplayText to ADisplayText
+
+  Revision 1.1.2.2  2000/12/23 10:10:22  michael
   + Added missing TDatasource support
 
   Revision 1.1.2.1  2000/08/05 14:39:16  michael

+ 31 - 15
fcl/db/fields.inc

@@ -44,10 +44,10 @@ begin
   // Correct sizes.
   If FDataType=ftFloat then
     begin
-    If Not FSize in [4,8,10] then FSize:=10
+    If Not (FSize in [4,8,10]) then FSize:=10
     end
   else If FDataType in [ftWord,ftsmallint,ftinteger] Then
-    If Not FSize in [1,2,4] then FSize:=4;
+    If Not (FSize in [1,2,4]) then FSize:=4;
   FFieldNo:=AFieldNo;
   AOwner.FItems.Add(Self);
 end;
@@ -532,6 +532,18 @@ begin
     DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
 end;
 
+// TField private methods
+
+function TField.GetDisplayText: String;
+begin
+  SetLength(Result, 0);
+  if Assigned(OnGetText) then
+    OnGetText(Self, Result, True)
+  else
+    GetText(Result, True);
+end;
+
+
 { ---------------------------------------------------------------------
     TStringField
   ---------------------------------------------------------------------}
@@ -598,7 +610,7 @@ begin
   result:=Size;
 end;
 
-Procedure TStringField.GetText(var AText: string; DisplayText: Boolean); 
+Procedure TStringField.GetText(var AText: string; ADisplayText: Boolean); 
 
 begin
     AText:=GetAsString;
@@ -700,8 +712,8 @@ constructor TLongintField.Create(AOwner: TComponent);
 begin
   Inherited Create(AOwner);
   SetDatatype(ftinteger);
-  FMinRange:=$80000000;
-  FMaxRange:=$7fffffff;
+  FMinRange:=Low(LongInt);
+  FMaxRange:=High(LongInt);
   FValidchars:=['+','-','0'..'9'];
 end;
 
@@ -735,7 +747,7 @@ begin
   Result:=SizeOf(Longint);
 end;
 
-procedure TLongintField.GetText(var AText: string; DisplayText: Boolean); 
+procedure TLongintField.GetText(var AText: string; ADisplayText: Boolean); 
 
 var l : longint;
     fmt : string;
@@ -743,7 +755,7 @@ var l : longint;
 begin
   Atext:='';
   If Not GetData(@l) then exit;
-  If DisplayText or (FEditFormat='') then
+  If ADisplayText or (FEditFormat='') then
     fmt:=FDisplayFormat
   else
     fmt:=FEditFormat;
@@ -918,7 +930,7 @@ begin
   Result:=SizeOf(Extended);
 end;
 
-procedure TFloatField.GetText(var TheText: string; DisplayText: Boolean); 
+procedure TFloatField.GetText(var TheText: string; ADisplayText: Boolean); 
 
 Var 
     fmt : string;
@@ -927,7 +939,7 @@ Var
 begin
   text:='';
   If Not GetData(@E) then exit;
-  If DisplayText or (Length(FEditFormat) = 0) Then
+  If ADisplayText or (Length(FEditFormat) = 0) Then
     Fmt:=FDisplayFormat 
   else
     Fmt:=FEditFormat;
@@ -1098,7 +1110,7 @@ begin
 end;
 
 
-procedure TDateTimeField.GetText(var TheText: string; DisplayText: Boolean); 
+procedure TDateTimeField.GetText(var TheText: string; ADisplayText: Boolean); 
 
 Var R : TDateTime;
     F : String;
@@ -1108,7 +1120,7 @@ begin
     TheText:=''
   else
     begin
-    If (DisplayText) and (Length(FDisplayFormat)<>0) then 
+    If (ADisplayText) and (Length(FDisplayFormat)<>0) then 
       F:=FDisplayFormat
     else
       Case DataType of
@@ -1209,7 +1221,7 @@ begin
 end;
 
 
-procedure TBinaryField.GetText(var TheText: string; DisplayText: Boolean); 
+procedure TBinaryField.GetText(var TheText: string; ADisplayText: Boolean); 
 
 begin
   TheText:=GetAsString;
@@ -1334,7 +1346,7 @@ begin
 end;
 
 
-procedure TBCDField.GetText(var TheText: string; DisplayText: Boolean); 
+procedure TBCDField.GetText(var TheText: string; ADisplayText: Boolean); 
 
 begin
   //!! To be implemented
@@ -1431,7 +1443,7 @@ begin
 end;
 
 
-procedure TBlobField.GetText(var TheText: string; DisplayText: Boolean); 
+procedure TBlobField.GetText(var TheText: string; ADisplayText: Boolean); 
 
 begin
   TheText:=GetAsString;
@@ -1752,7 +1764,11 @@ end;
 
 {
   $Log$
-  Revision 1.1.2.1  2000-08-05 14:39:16  michael
+  Revision 1.1.2.2  2000-12-23 23:27:25  sg
+  * Added TField.DisplayText, and accordingly changed all arguments called
+    DisplayText to ADisplayText
+
+  Revision 1.1.2.1  2000/08/05 14:39:16  michael
   + Changes in streaming applied here too
 
   Revision 1.1  2000/07/13 06:31:27  michael