Class TArgusDataEntry

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TArgusDataEntry = class(TComboBox)

Description

EArgusMinMaxError is raised if there is an attempt to set the Max to a value less than Min or vice versa.

Hierarchy

Overview

Fields

Private FOutput: string;
Private FDataType: TDataType;
Private FMax: extended;
Private FMin: extended;
Private FCheckMax: boolean;
Private FCheckMin: boolean;
Private FOnStyleChanged: TNotifyEvent;
Private FOnDataTypeChanged: TNotifyEvent;
Private FOnExceededBounds: TNotifyEvent;
Private FOnExceedingBounds: TNotifyEvent;
Private FStyle: TComboBoxStyle;
Private FChangeDisabledColor: boolean;
Private FDisabledColor: TColor;
Private FEnabledColor: TColor;
Private FDecimalDelimiter: Char;
Private FAppEvents: TApplicationEvents;

Methods

Private function GetText: TCaption;
Private procedure SetText(const Value: TCaption);
Private procedure LocalizeString(var ANumberString : string);
Private function ReadOutput : string ;
Private function LocalStrToFloat(const S: string): Extended;
Private procedure SetChangeDisabledColor(const Value: boolean);
Private procedure SetDisabledColor(const Value: TColor);
Private procedure SetEnabledColor(Value: TColor);
Private function GetRealValue: Double;
Private procedure SetRealValue(const Value: Double);
Private function GetIntegerValue: Integer;
Private procedure SetIntegerValue(const Value: Integer);
Protected procedure SetDataType(ADataType : TDataType); virtual;
Protected procedure SetEnabled(Value: Boolean); override;
Protected procedure SetStyle(Value: TComboBoxStyle); override;
Protected procedure SetMax(Value : extended); virtual;
Protected procedure SetMin(Value : extended); virtual;
Protected procedure SetCheckMax(Value : boolean); virtual;
Protected procedure SetCheckMin(Value : boolean); virtual;
Protected procedure DoExit ; override;
Protected procedure Change; override;
Protected procedure StyleChanged; dynamic;
Protected procedure DataTypeChanged; dynamic;
Protected procedure ExceedingBounds; dynamic;
Protected procedure ExceededBounds; dynamic;
Protected procedure TextChanged; virtual;
Protected procedure ChangeColor;
Protected procedure SettingsChanged(Sender: TObject; Flag: Integer; const Section: string; var Result: Longint);
Public constructor Create(AOwner: TComponent); override;
Public function ChangeTextToInteger : String; virtual;
Public function ChangeTextToReal : string; virtual;
Public function ChangeTextToBoolean : string; virtual;
Public procedure CheckRange; virtual;

Properties

Public property RealValue: Double read GetRealValue write SetRealValue;
Public property IntegerValue: Integer read GetIntegerValue write SetIntegerValue;
Published property DataType: TDataType read FDataType write SetDataType default dtString;
Published property Max : extended read FMax write SetMax;
Published property Min : extended read FMin write SetMin;
Published property CheckMax: boolean read FCheckMax write SetCheckMax default False;
Published property CheckMin: boolean read FCheckMin write SetCheckMin default False;
Published property Output: string read ReadOutput ;
Published property Style: TComboBoxStyle read FStyle write SetStyle default csSimple;
Published property OnStyleChanged : TNotifyEvent read FOnStyleChanged write FOnStyleChanged ;
Published property OnDataTypeChanged : TNotifyEvent read FOnDataTypeChanged write FOnDataTypeChanged ;
Published property OnExceededBounds : TNotifyEvent read FOnExceededBounds write FOnExceededBounds ;
Published property OnExceedingBounds : TNotifyEvent read FOnExceedingBounds write FOnExceedingBounds ;
Published property Text: TCaption read GetText write SetText;
Published property ChangeDisabledColor : boolean read FChangeDisabledColor write SetChangeDisabledColor;
Published property DisabledColor : TColor read FDisabledColor write SetDisabledColor default clBtnFace;
Published property EnabledColor: TColor read FEnabledColor write SetEnabledColor default clWindow;

Description

Fields

Private FOutput: string;

Private declarations

Private FDataType: TDataType;
 
Private FMax: extended;
 
Private FMin: extended;
 
Private FCheckMax: boolean;
 
Private FCheckMin: boolean;
 
Private FOnStyleChanged: TNotifyEvent;
 
Private FOnDataTypeChanged: TNotifyEvent;
 
Private FOnExceededBounds: TNotifyEvent;
 
Private FOnExceedingBounds: TNotifyEvent;
 
Private FStyle: TComboBoxStyle;
 
Private FChangeDisabledColor: boolean;
 
Private FDisabledColor: TColor;
 
Private FEnabledColor: TColor;
 
Private FDecimalDelimiter: Char;
 
Private FAppEvents: TApplicationEvents;
 

Methods

Private function GetText: TCaption;
 
Private procedure SetText(const Value: TCaption);
 
Private procedure LocalizeString(var ANumberString : string);

function GetDecChar : char;

Private function ReadOutput : string ;
 
Private function LocalStrToFloat(const S: string): Extended;
 
Private procedure SetChangeDisabledColor(const Value: boolean);
 
Private procedure SetDisabledColor(const Value: TColor);
 
Private procedure SetEnabledColor(Value: TColor);
 
Private function GetRealValue: Double;
 
Private procedure SetRealValue(const Value: Double);
 
Private function GetIntegerValue: Integer;
 
Private procedure SetIntegerValue(const Value: Integer);
 
Protected procedure SetDataType(ADataType : TDataType); virtual;

function GetText: TCaption;

procedure SetText(const Value: TCaption);

Protected procedure SetEnabled(Value: Boolean); override;

SetDataType sets the DataType property. It also changes the Style of the TArgusDataEntry depending on the Data type. dtString, dtInteger, and dtReal result in the style being set to csSimple. dtBoolean results in the Style being set to csDropDownList. If the data type is set to dtCustom, an Style is allowed. It also changes the text to make sure it is consistent with the data type and updates Output to be consistent with Text. Items[0] and Items[1] are reset to 'False' and 'True' respectively every time the data type is set to dtBoolean. If the new DataType is different from the existing DataType, an OnChangeDataType event occurs.

Protected procedure SetStyle(Value: TComboBoxStyle); override;

SetEnabled calls the inherited SetEnabled and then ChangeColor

Protected procedure SetMax(Value : extended); virtual;

SetStyle changes to Style of the TArgusDataEntry and checks that the style is consistent with the DataType. If the new Style is different from the existing Style, an OnChangeStyle event occurs.

Protected procedure SetMin(Value : extended); virtual;

SetMax changes Max and then calls CheckRange

Protected procedure SetCheckMax(Value : boolean); virtual;

SetMin changes Min and then calls CheckRange

Protected procedure SetCheckMin(Value : boolean); virtual;

SetCheckMax changes CheckMax and then if CheckMax is true calls CheckRange

Protected procedure DoExit ; override;

SetCheckMin changes CheckMin and then if CheckMin is true calls CheckRange

Protected procedure Change; override;

DoExit implements the OnExit event; It calls the inherited method and then CheckRange

Protected procedure StyleChanged; dynamic;

Change implements the OnChange event; It calls the inherited method and then TextChanged.

Protected procedure DataTypeChanged; dynamic;

StyleChanged implements the OnStyleChanged event; It is called whenever the application changes the data type.

Protected procedure ExceedingBounds; dynamic;

DataTypeChanged implements the OnDataTypeChanged event;

Protected procedure ExceededBounds; dynamic;

ExceedingBounds implements the OnExceedingBounds event;

Protected procedure TextChanged; virtual;

StyleChanged implements the OnStyleChanged event;

Protected procedure ChangeColor;

TextChanged is called before the event handler for the OnChanged event. It checks that the data entered in the TArgusDataEntry is valid. It does not reject '-' even though that is not a valid integer or real number. However, if the text is '-' when OnExit occurs, the CheckRange procedure will catch the error.

Protected procedure SettingsChanged(Sender: TObject; Flag: Integer; const Section: string; var Result: Longint);

ChangeColor changes the color of the control depending on whether the control is enabled or not and the ChangeDisabledColor property.

Public constructor Create(AOwner: TComponent); override;

Public declarations

Public function ChangeTextToInteger : String; virtual;

Create creates and initializes a TArgusDataEntry instance.

Public function ChangeTextToReal : string; virtual;

ChangeTextToInteger takes the string in the Text property and attempts to convert it to an integer. If it fails, it strips one character at a time from the end of Text until it does succeed. It converts '' to '0'. The end result is a string that can be converted to an integer.

Public function ChangeTextToBoolean : string; virtual;

ChangeTextToReal takes the string in the Text property and attempts to convert it to an extended real number. If it fails, it strips one character at a time from the end of Text until it does succeed. It converts '' to '0'. The end result is a string that can be converted to an real number.

Public procedure CheckRange; virtual;

ChangeTextToBoolean converts the string in the Text property to '0' if the Text is '', '0' or 'false'. The check that the Text is equal to 'false' is case insensitive.

Properties

Public property RealValue: Double read GetRealValue write SetRealValue;

CheckRange is called before the event handler for the OnExit event. It checks that the data in the TArgusDataEntry do not exceed the specified limits. However, it only checks the range if the DataType is dtInteger or dtReal. It also catches the invalid value of '-' for real and integer data typed in the text field. If the value in the data field should be checked as specified by CheckMin and CheckMax and is outside the limits set by Min and Max an OnExceedingBounds event occurs. If after the eventhandler for OnExceedingBounds, the numeric representation of Text is still outside the appropriate range, Text will be changed to Max or Min, whichever is closer and raises an OnExceededBounds event.

Public property IntegerValue: Integer read GetIntegerValue write SetIntegerValue;
 
Published property DataType: TDataType read FDataType write SetDataType default dtString;

Published declarations

Published property Max : extended read FMax write SetMax;

Set the DataType to an appropriate value to cause the TArgusDataEntry to check that user-entered data is the appropriate type.

Published property Min : extended read FMin write SetMin;

If CheckMax is true and the DataType is dtInteger or dtReal, the TArgusDataEntry will check the data entered and change it to Max if the entered value is larger than Max. It will also beep and set the focus to the TArgusDataEntry. To modify this behaviour, you can use the OnExceedingBounds or OnExceededBounds events.

Published property CheckMax: boolean read FCheckMax write SetCheckMax default False;

If CheckMin is true and the DataType is dtInteger or dtReal, the TArgusDataEntry will check the data entered and change it to Min if the entered value is smaller than Max. It will also beep and set the focus to the TArgusDataEntry. To modify this behaviour, you can use the OnExceedingBounds or OnExceededBounds events.

Published property CheckMin: boolean read FCheckMin write SetCheckMin default False;

If CheckMax is true and the DataType is dtInteger or dtReal, the TArgusDataEntry will check the data entered and change it to Max if the entered value is larger than Max. It will also beep and set the focus to the TArgusDataEntry. To modify this behaviour, you can use the OnExceedingBounds or OnExceededBounds events.

Published property Output: string read ReadOutput ;

If CheckMin is true and the DataType is dtInteger or dtReal, the TArgusDataEntry will check the data entered and change it to Min if the entered value is smaller than Min. It will also beep and set the focus to the TArgusDataEntry. To modify this behaviour, you can use the OnExceedingBounds or OnExceededBounds events.

Published property Style: TComboBoxStyle read FStyle write SetStyle default csSimple;

If the DataType is anything other than dtBoolean, Output will be the same as Text. For dtBoolean, Output is '0' if Text is 'False' and '1' if Text is 'True'. Output is read-only. Output always uses '.' as the decimal separator.

Published property OnStyleChanged : TNotifyEvent read FOnStyleChanged write FOnStyleChanged ;

Style is inherited but the default is changed to csSimple.

Published property OnDataTypeChanged : TNotifyEvent read FOnDataTypeChanged write FOnDataTypeChanged ;

Whenever the Style Property is changed, an OnStyleChanged event occurs.

Published property OnExceededBounds : TNotifyEvent read FOnExceededBounds write FOnExceededBounds ;

Whenever the DataType Property is changed, an OnDataTypeChanged event occurs.

Published property OnExceedingBounds : TNotifyEvent read FOnExceedingBounds write FOnExceedingBounds ;

An OnExceededBounds event occurs if 1. the DataType is dtInteger or dtReal and either 2. CheckMax is true and the numeric representation of the Text Property exceeds the Max Property or 3. CheckMin is true and the numeric representation of the Text Property is less than the Min Property. OnExceededBounds occurs after the default handling of such cases has occurred. CheckRange will be called again after your event handler. Be careful that your custom handling does not result in an infinite loop.

Published property Text: TCaption read GetText write SetText;

Property Text : TCaption read GetText Write SetText ;

Published property ChangeDisabledColor : boolean read FChangeDisabledColor write SetChangeDisabledColor;

Identical to original Text property except that setting the text generates an OnChange Event.

Published property DisabledColor : TColor read FDisabledColor write SetDisabledColor default clBtnFace;

If ChangeDisabledColor is true, the color of the control will be changed to EnabledColor when the control becomes enabled and will be set to DisabledColor when the control becomes disabled.

Published property EnabledColor: TColor read FEnabledColor write SetEnabledColor default clWindow;

DisabledColor is the color that the control will be changed to if ChangeDisabledColor is true and the control becomes disabled. By default, DisabledColor is clBtnFace.


Generated by PasDoc 0.12.1 on 2013-05-13 15:41:28