Added: Labeled db widgets

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1971 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
jujibo 2011-09-19 15:10:55 +00:00
parent 0f3f32ed94
commit e2a77aa3a0
7 changed files with 1163 additions and 0 deletions

View File

@ -5,6 +5,7 @@ JUJIBOUTILS
Version pre-1.0
--------------------------------------------------
2011-09-19 Added: JDBLabeledIntegerEdit, TJDBLabeledCurrencyEdit, TJDBLabeledDateEdit
2011-09-19 First package: TJDBIntegerEdit, TJDBCurrencyEdit, TJDBDateEdit and example
2011-09-14 Add Non Database input controls example
2011-09-13 Initial commit to lazarus-ccr

View File

@ -0,0 +1,380 @@
unit jdblabeledcurrencyedit;
{$mode objfpc}{$H+}
interface
uses
Classes, LResources, Controls, StdCtrls, ExtCtrls, DB, DBCtrls,
LMessages, LCLType, Dialogs,
SysUtils;
type
{ TJDBLabeledCurrencyEdit }
TJDBLabeledCurrencyEdit = class(TLabeledEdit)
private
fFormat: string;
FDataLink: TFieldDataLink;
fDecimales: integer;
procedure DataChange(Sender: TObject);
function getDecimals: integer;
procedure setDecimals(AValue: integer);
procedure UpdateData(Sender: TObject);
procedure FocusRequest(Sender: TObject);
function GetDataField: string;
function GetDataSource: TDataSource;
function GetField: TField;
function IsReadOnly: boolean;
function getFormat: string;
procedure setFormat(const AValue: string);
procedure formatInput;
procedure SetDataField(const Value: string);
procedure SetDataSource(Value: TDataSource);
procedure CMGetDataLink(var Message: TLMessage); message CM_GETDATALINK;
function IsValidCurrency(const Value: string): boolean;
function ScaleTo(const AValue: currency; const NDecimals: integer): currency;
protected
procedure Loaded; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure ActiveChange(Sender: TObject); virtual;
procedure KeyDown(var Key: word; Shift: TShiftState); override;
procedure KeyPress(var Key: char); override;
procedure DoEnter; override;
function GetReadOnly: boolean; override;
procedure SetReadOnly(Value: boolean); override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure EditingDone; override;
property Field: TField read GetField;
published
property DisplayFormat: string read getFormat write setFormat;
property DataField: string read GetDataField write SetDataField;
property DataSource: TDataSource read GetDataSource write SetDataSource;
property Decimals: integer read getDecimals write setDecimals;
property ReadOnly: boolean read GetReadOnly write SetReadOnly default False;
// From TEdit
property Action;
property Align;
property Alignment;
property Anchors;
property AutoSize;
property AutoSelect;
property BidiMode;
property BorderStyle;
property BorderSpacing;
property CharCase;
property Color;
property Constraints;
property DragCursor;
property DragKind;
property DragMode;
property EchoMode;
property Enabled;
property Font;
property HideSelection;
property MaxLength;
property ParentBidiMode;
property OnChange;
property OnChangeBounds;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEditingDone;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDrag;
property OnUTF8KeyPress;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabStop;
property TabOrder;
property Visible;
end;
procedure Register;
implementation
uses
Math;
procedure Register;
begin
{$I lcurrencydbicon.lrs}
RegisterComponents('Data Controls', [TJDBLabeledCurrencyEdit]);
end;
{ TJDBLabeledCurrencyEdit }
procedure TJDBLabeledCurrencyEdit.DataChange(Sender: TObject);
begin
if FDataLink.Field <> nil then
begin
if not Focused then
formatInput
else
Caption := FDataLink.Field.AsString;
end
else
Text := '';
end;
function TJDBLabeledCurrencyEdit.getDecimals: integer;
begin
Result := fDecimales;
end;
procedure TJDBLabeledCurrencyEdit.setDecimals(AValue: integer);
begin
if AValue >= 0 then
fDecimales := AValue;
end;
procedure TJDBLabeledCurrencyEdit.UpdateData(Sender: TObject);
var
theValue: currency;
begin
if FDataLink.Field <> nil then
begin
if IsValidCurrency(Text) then
begin
theValue := StrToCurr(Text);
theValue := ScaleTo(theValue, fDecimales);
Text := CurrToStr(theValue);
FDataLink.Field.Text := Text;
end
else
begin
if FDataLink.Field <> nil then
begin
ShowMessage(Caption + ' no es un valor válido');
Caption := FDataLink.Field.AsString;
SelectAll;
SetFocus;
end;
end;
end
else
Text := '';
end;
procedure TJDBLabeledCurrencyEdit.FocusRequest(Sender: TObject);
begin
SetFocus;
end;
function TJDBLabeledCurrencyEdit.GetDataField: string;
begin
Result := FDataLink.FieldName;
end;
function TJDBLabeledCurrencyEdit.GetDataSource: TDataSource;
begin
Result := FDataLink.DataSource;
end;
function TJDBLabeledCurrencyEdit.GetField: TField;
begin
Result := FDataLink.Field;
end;
function TJDBLabeledCurrencyEdit.IsReadOnly: boolean;
begin
if FDatalink.Active then
Result := not FDatalink.CanModify
else
Result := False;
end;
function TJDBLabeledCurrencyEdit.getFormat: string;
begin
Result := fFormat;
end;
procedure TJDBLabeledCurrencyEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
if not Focused then
formatInput;
end;
procedure TJDBLabeledCurrencyEdit.formatInput;
begin
if FDataLink.Field <> nil then
//FDataLink.Field.DisplayText -> formatted (tdbgridcolumns/persistent field DisplayFormat
if fFormat <> '' then
Caption := FormatFloat(fFormat, FDataLink.Field.AsCurrency)
else
Caption := FDataLink.Field.DisplayText
else
Caption := 'nil';
end;
function TJDBLabeledCurrencyEdit.GetReadOnly: boolean;
begin
Result := FDataLink.ReadOnly;
end;
procedure TJDBLabeledCurrencyEdit.SetReadOnly(Value: boolean);
begin
inherited;
FDataLink.ReadOnly := Value;
end;
procedure TJDBLabeledCurrencyEdit.SetDataField(const Value: string);
begin
FDataLink.FieldName := Value;
end;
procedure TJDBLabeledCurrencyEdit.SetDataSource(Value: TDataSource);
begin
if not (FDataLink.DataSourceFixed and (csLoading in ComponentState)) then
ChangeDataSource(Self, FDataLink, Value);
end;
procedure TJDBLabeledCurrencyEdit.CMGetDataLink(var Message: TLMessage);
begin
Message.Result := PtrUInt(FDataLink); // Delphi dbctrls compatibility?
end;
function TJDBLabeledCurrencyEdit.IsValidCurrency(const Value: string): boolean;
begin
if StrToCurrDef(Value, MaxCurrency) = MaxCurrency then
Result := False
else
Result := True;
end;
function TJDBLabeledCurrencyEdit.ScaleTo(const AValue: currency;
const NDecimals: integer): currency;
begin
Result := round(AValue * power(10, NDecimals)) / power(10, NDecimals);
end;
procedure TJDBLabeledCurrencyEdit.Loaded;
begin
inherited Loaded;
if (csDesigning in ComponentState) then
DataChange(Self);
end;
procedure TJDBLabeledCurrencyEdit.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
// clean up
if (Operation = opRemove) then
begin
if (FDataLink <> nil) and (AComponent = DataSource) then
DataSource := nil;
end;
end;
procedure TJDBLabeledCurrencyEdit.ActiveChange(Sender: TObject);
begin
if FDatalink.Active then
datachange(Sender)
else
Text := '';
end;
procedure TJDBLabeledCurrencyEdit.KeyDown(var Key: word; Shift: TShiftState);
begin
inherited KeyDown(Key, Shift);
if Key = VK_ESCAPE then
begin
FDataLink.Reset;
SelectAll;
Key := VK_UNKNOWN;
end
else
if Key in [VK_DELETE, VK_BACK] then
begin
if not IsReadOnly then
FDatalink.Edit
else
Key := VK_UNKNOWN;
end;
end;
procedure TJDBLabeledCurrencyEdit.KeyPress(var Key: char);
begin
if (Key in ['.', ',']) then
Key := Decimalseparator;
if (key = DecimalSeparator) and (Pos(key, Text) > 0) then
key := #0;
if not (Key in ['0'..'9', DecimalSeparator, '+', '-', #8, #9]) then
Key := #0;
if (Key = DecimalSeparator) and (fDecimales = 0) then
Key := #0;
if (Key <> #0) and (not IsReadOnly) then
FDatalink.Edit;
inherited KeyPress(Key);
end;
procedure TJDBLabeledCurrencyEdit.DoEnter;
begin
if FDataLink.Field <> nil then
Caption := FDataLink.Field.AsString;
inherited DoEnter;
end;
constructor TJDBLabeledCurrencyEdit.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
ControlStyle := ControlStyle + [csReplicatable];
FDataLink := TFieldDataLink.Create;
FDataLink.Control := Self;
FDataLink.OnDataChange := @DataChange;
FDataLink.OnUpdateData := @UpdateData;
FDataLInk.OnActiveChange := @ActiveChange;
// Set default values
//fDecimales := 2;
//fFormat := '0.00';
end;
destructor TJDBLabeledCurrencyEdit.Destroy;
begin
FDataLink.Free;
FDataLink := nil;
inherited Destroy;
end;
procedure TJDBLabeledCurrencyEdit.EditingDone;
begin
inherited EditingDone;
UpdateData(self);
end;
end.

View File

@ -0,0 +1,348 @@
unit jdblabeleddateedit;
{$mode objfpc}{$H+}
interface
uses
Classes, LResources, Controls, StdCtrls, ExtCtrls, DB, DBCtrls, LMessages, LCLType, Dialogs,
SysUtils;
type
{ TJDBLabeledDateEdit }
TJDBLabeledDateEdit = class(TLabeledEdit)
private
fFormat: string;
FDataLink: TFieldDataLink;
procedure DataChange(Sender: TObject);
procedure UpdateData(Sender: TObject);
procedure FocusRequest(Sender: TObject);
function GetDataField: string;
function GetDataSource: TDataSource;
function GetField: TField;
function IsReadOnly: boolean;
function getFormat: string;
procedure setFormat(const AValue: string);
procedure formatInput;
procedure SetDataField(const Value: string);
procedure SetDataSource(Value: TDataSource);
procedure CMGetDataLink(var Message: TLMessage); message CM_GETDATALINK;
function IsValidCurrency(const Value: string): boolean;
protected
procedure Loaded; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure ActiveChange(Sender: TObject); virtual;
procedure KeyDown(var Key: word; Shift: TShiftState); override;
procedure KeyPress(var Key: char); override;
procedure DoEnter; override;
function GetReadOnly: boolean; override;
procedure SetReadOnly(Value: boolean); override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure EditingDone; override;
property Field: TField read GetField;
published
property DisplayFormat: string read getFormat write setFormat;
property DataField: string read GetDataField write SetDataField;
property DataSource: TDataSource read GetDataSource write SetDataSource;
property ReadOnly: boolean read GetReadOnly write SetReadOnly default False;
// From TEdit
property Action;
property Align;
property Alignment;
property Anchors;
property AutoSize;
property AutoSelect;
property BidiMode;
property BorderStyle;
property BorderSpacing;
property CharCase;
property Color;
property Constraints;
property DragCursor;
property DragKind;
property DragMode;
property EchoMode;
property Enabled;
property Font;
property HideSelection;
property MaxLength;
property ParentBidiMode;
property OnChange;
property OnChangeBounds;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEditingDone;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDrag;
property OnUTF8KeyPress;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabStop;
property TabOrder;
property Visible;
end;
procedure Register;
implementation
uses
jcontrolutils;
procedure Register;
begin
{$I ldatedbicon.lrs}
RegisterComponents('Data Controls', [TJDBLabeledDateEdit]);
end;
{ TJDBLabeledDateEdit }
procedure TJDBLabeledDateEdit.DataChange(Sender: TObject);
begin
if FDataLink.Field <> nil then
begin
if not Focused then
formatInput
else
Caption := FDataLink.Field.AsString;
end
else
Text := '';
end;
procedure TJDBLabeledDateEdit.UpdateData(Sender: TObject);
var
theValue: string;
begin
if FDataLink.Field <> nil then
begin
theValue := NormalizeDate(Text, FDataLink.Field.AsDateTime);
if Text = '' then
FDataLink.Field.Text := Text
else
if IsValidDateString(theValue) then
begin
FDataLink.Field.Text := theValue;
end
else
begin
ShowMessage(Caption + ' no es un valor válido');
Caption := FDataLink.Field.AsString;
SelectAll;
SetFocus;
end;
end
else
Text := '';
end;
procedure TJDBLabeledDateEdit.FocusRequest(Sender: TObject);
begin
SetFocus;
end;
function TJDBLabeledDateEdit.GetDataField: string;
begin
Result := FDataLink.FieldName;
end;
function TJDBLabeledDateEdit.GetDataSource: TDataSource;
begin
Result := FDataLink.DataSource;
end;
function TJDBLabeledDateEdit.GetField: TField;
begin
Result := FDataLink.Field;
end;
function TJDBLabeledDateEdit.IsReadOnly: boolean;
begin
if FDatalink.Active then
Result := not FDatalink.CanModify
else
Result := False;
end;
function TJDBLabeledDateEdit.getFormat: string;
begin
Result := fFormat;
end;
procedure TJDBLabeledDateEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
if not Focused then
formatInput;
end;
procedure TJDBLabeledDateEdit.formatInput;
begin
if FDataLink.Field <> nil then
//FDataLink.Field.DisplayText -> formatted (tdbgridcolumns/persistent field DisplayFormat
if (fFormat <> '') and (not FDataLink.Field.IsNull) then
Caption := FormatDateTime(fFormat, FDataLink.Field.AsDateTime)
else
Caption := FDataLink.Field.DisplayText
else
Caption := 'nil';
end;
function TJDBLabeledDateEdit.GetReadOnly: boolean;
begin
Result := FDataLink.ReadOnly;
end;
procedure TJDBLabeledDateEdit.SetReadOnly(Value: boolean);
begin
inherited;
FDataLink.ReadOnly := Value;
end;
procedure TJDBLabeledDateEdit.SetDataField(const Value: string);
begin
FDataLink.FieldName := Value;
end;
procedure TJDBLabeledDateEdit.SetDataSource(Value: TDataSource);
begin
if not (FDataLink.DataSourceFixed and (csLoading in ComponentState)) then
ChangeDataSource(Self, FDataLink, Value);
end;
procedure TJDBLabeledDateEdit.CMGetDataLink(var Message: TLMessage);
begin
Message.Result := PtrUInt(FDataLink); // Delphi dbctrls compatibility?
end;
function TJDBLabeledDateEdit.IsValidCurrency(const Value: string): boolean;
begin
if StrToCurrDef(Value, MaxCurrency) = MaxCurrency then
Result := False
else
Result := True;
end;
procedure TJDBLabeledDateEdit.Loaded;
begin
inherited Loaded;
if (csDesigning in ComponentState) then
DataChange(Self);
end;
procedure TJDBLabeledDateEdit.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
// clean up
if (Operation = opRemove) then
begin
if (FDataLink <> nil) and (AComponent = DataSource) then
DataSource := nil;
end;
end;
procedure TJDBLabeledDateEdit.ActiveChange(Sender: TObject);
begin
if FDatalink.Active then
datachange(Sender)
else
Text := '';
end;
procedure TJDBLabeledDateEdit.KeyDown(var Key: word; Shift: TShiftState);
begin
inherited KeyDown(Key, Shift);
if Key = VK_ESCAPE then
begin
FDataLink.Reset;
SelectAll;
Key := VK_UNKNOWN;
end
else
if Key in [VK_DELETE, VK_BACK] then
begin
if not IsReadOnly then
FDatalink.Edit
else
Key := VK_UNKNOWN;
end;
end;
procedure TJDBLabeledDateEdit.KeyPress(var Key: char);
begin
if not (Key in ['0'..'9', #8, #9, '.', '-', '/']) then
Key := #0
else
if not IsReadOnly then
FDatalink.Edit;
inherited KeyPress(Key);
end;
procedure TJDBLabeledDateEdit.DoEnter;
begin
if FDataLink.Field <> nil then
Caption := FDataLink.Field.AsString;
inherited DoEnter;
end;
constructor TJDBLabeledDateEdit.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
ControlStyle := ControlStyle + [csReplicatable];
FDataLink := TFieldDataLink.Create;
FDataLink.Control := Self;
FDataLink.OnDataChange := @DataChange;
FDataLink.OnUpdateData := @UpdateData;
FDataLInk.OnActiveChange := @ActiveChange;
// Set default values
//fFormat := ShortDateFormat;
end;
destructor TJDBLabeledDateEdit.Destroy;
begin
FDataLink.Free;
FDataLink := nil;
inherited Destroy;
end;
procedure TJDBLabeledDateEdit.EditingDone;
begin
inherited EditingDone;
UpdateData(self);
end;
end.

View File

@ -0,0 +1,337 @@
unit jdblabeledintegeredit;
{$mode objfpc}{$H+}
interface
uses
Classes, LResources, Controls, StdCtrls, ExtCtrls, DB, DBCtrls,
LMessages, LCLType, Dialogs,
SysUtils;
type
{ TJDBLabeledIntegerEdit }
TJDBLabeledIntegerEdit = class(TLabeledEdit)
private
fFormat: string;
FDataLink: TFieldDataLink;
procedure DataChange(Sender: TObject);
procedure UpdateData(Sender: TObject);
procedure FocusRequest(Sender: TObject);
function GetDataField: string;
function GetDataSource: TDataSource;
function GetField: TField;
function IsReadOnly: boolean;
function getFormat: string;
procedure setFormat(const AValue: string);
procedure formatInput;
procedure SetDataField(const Value: string);
procedure SetDataSource(Value: TDataSource);
procedure CMGetDataLink(var Message: TLMessage); message CM_GETDATALINK;
function IsValidInteger(const Value: string): boolean;
protected
procedure Loaded; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure ActiveChange(Sender: TObject); virtual;
procedure KeyDown(var Key: word; Shift: TShiftState); override;
procedure KeyPress(var Key: char); override;
procedure DoEnter; override;
function GetReadOnly: boolean; override;
procedure SetReadOnly(Value: boolean); override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure EditingDone; override;
property Field: TField read GetField;
published
property DisplayFormat: string read getFormat write setFormat;
property DataField: string read GetDataField write SetDataField;
property DataSource: TDataSource read GetDataSource write SetDataSource;
property ReadOnly: boolean read GetReadOnly write SetReadOnly default False;
// From TEdit
property Action;
property Align;
property Alignment;
property Anchors;
property AutoSize;
property AutoSelect;
property BidiMode;
property BorderStyle;
property BorderSpacing;
property CharCase;
property Color;
property Constraints;
property DragCursor;
property DragKind;
property DragMode;
property EchoMode;
property Enabled;
property Font;
property HideSelection;
property MaxLength;
property ParentBidiMode;
property OnChange;
property OnChangeBounds;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEditingDone;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDrag;
property OnUTF8KeyPress;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabStop;
property TabOrder;
property Visible;
end;
procedure Register;
implementation
procedure Register;
begin
{$I lintegerdbicon.lrs}
RegisterComponents('Data Controls', [TJDBLabeledIntegerEdit]);
end;
{ TJDBLabeledIntegerEdit }
procedure TJDBLabeledIntegerEdit.DataChange(Sender: TObject);
begin
if FDataLink.Field <> nil then
begin
if not Focused then
formatInput
else
Caption := FDataLink.Field.AsString;
end
else
Text := '';
end;
procedure TJDBLabeledIntegerEdit.UpdateData(Sender: TObject);
begin
if FDataLink.Field <> nil then
begin
if IsValidInteger(Caption) then
FDataLink.Field.Text := Text
else
begin
ShowMessage(Caption + ' no es un valor válido');
Caption := FDataLink.Field.AsString;
SelectAll;
SetFocus;
end;
end
else
Text := '';
end;
procedure TJDBLabeledIntegerEdit.FocusRequest(Sender: TObject);
begin
SetFocus;
end;
function TJDBLabeledIntegerEdit.GetDataField: string;
begin
Result := FDataLink.FieldName;
end;
function TJDBLabeledIntegerEdit.GetDataSource: TDataSource;
begin
Result := FDataLink.DataSource;
end;
function TJDBLabeledIntegerEdit.GetField: TField;
begin
Result := FDataLink.Field;
end;
function TJDBLabeledIntegerEdit.IsReadOnly: boolean;
begin
if FDatalink.Active then
Result := not FDatalink.CanModify
else
Result := False;
end;
function TJDBLabeledIntegerEdit.getFormat: string;
begin
Result := fFormat;
end;
procedure TJDBLabeledIntegerEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
if not Focused then
formatInput;
end;
procedure TJDBLabeledIntegerEdit.formatInput;
begin
if FDataLink.Field <> nil then
//FDataLink.Field.DisplayText -> formatted (tdbgridcolumns/persistent field DisplayFormat
if fFormat <> '' then
Caption := FormatFloat(fFormat, FDataLink.Field.AsInteger)
else
Caption := FDataLink.Field.DisplayText
else
Caption := 'nil';
end;
function TJDBLabeledIntegerEdit.GetReadOnly: boolean;
begin
Result := FDataLink.ReadOnly;
end;
procedure TJDBLabeledIntegerEdit.SetReadOnly(Value: boolean);
begin
inherited;
FDataLink.ReadOnly := Value;
end;
procedure TJDBLabeledIntegerEdit.SetDataField(const Value: string);
begin
FDataLink.FieldName := Value;
end;
procedure TJDBLabeledIntegerEdit.SetDataSource(Value: TDataSource);
begin
if not (FDataLink.DataSourceFixed and (csLoading in ComponentState)) then
ChangeDataSource(Self, FDataLink, Value);
end;
procedure TJDBLabeledIntegerEdit.CMGetDataLink(var Message: TLMessage);
begin
Message.Result := PtrUInt(FDataLink); // Delphi dbctrls compatibility?
end;
function TJDBLabeledIntegerEdit.IsValidInteger(const Value: string): boolean;
begin
if StrToIntDef(Value, MaxInt) = MaxInt then
Result := False
else
Result := True;
end;
procedure TJDBLabeledIntegerEdit.Loaded;
begin
inherited Loaded;
if (csDesigning in ComponentState) then
DataChange(Self);
end;
procedure TJDBLabeledIntegerEdit.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
// clean up
if (Operation = opRemove) then
begin
if (FDataLink <> nil) and (AComponent = DataSource) then
DataSource := nil;
end;
end;
procedure TJDBLabeledIntegerEdit.ActiveChange(Sender: TObject);
begin
if FDatalink.Active then
datachange(Sender)
else
Text := '';
end;
procedure TJDBLabeledIntegerEdit.KeyDown(var Key: word; Shift: TShiftState);
begin
inherited KeyDown(Key, Shift);
if Key = VK_ESCAPE then
begin
FDataLink.Reset;
SelectAll;
Key := VK_UNKNOWN;
end
else
if Key in [VK_DELETE, VK_BACK] then
begin
if not IsReadOnly then
FDatalink.Edit
else
Key := VK_UNKNOWN;
end;
end;
procedure TJDBLabeledIntegerEdit.KeyPress(var Key: char);
begin
if not (Key in ['0'..'9', #8, #9, '-']) then
Key := #0
else
if not IsReadOnly then
FDatalink.Edit;
inherited KeyPress(Key);
end;
procedure TJDBLabeledIntegerEdit.DoEnter;
begin
if FDataLink.Field <> nil then
Caption := FDataLink.Field.AsString;
inherited DoEnter;
end;
constructor TJDBLabeledIntegerEdit.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
ControlStyle := ControlStyle + [csReplicatable];
FDataLink := TFieldDataLink.Create;
FDataLink.Control := Self;
FDataLink.OnDataChange := @DataChange;
FDataLink.OnUpdateData := @UpdateData;
FDataLInk.OnActiveChange := @ActiveChange;
end;
destructor TJDBLabeledIntegerEdit.Destroy;
begin
FDataLink.Free;
FDataLink := nil;
inherited Destroy;
end;
procedure TJDBLabeledIntegerEdit.EditingDone;
begin
inherited EditingDone;
UpdateData(self);
end;
end.

View File

@ -0,0 +1,34 @@
LazarusResources.Add('TJDBLabeledCurrencyEdit','PNG',[
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
+#0#0#1'sRGB'#0#174#206#28#233#0#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147
+#0#0#0#9'pHYs'#0#0#11#19#0#0#11#19#1#0#154#156#24#0#0#0#7'tIME'#7#219#9#19#14
+'4$v&'#230'`'#0#0#2'zIDATH'#199#213#149'=hSQ'#20#199#255'7'#196#138#16'Z'#218
+'M'#165#25#2'E'#7'm)7'#224#144#226#16#151#14#138#131'Y'#172#131'J#'#194#205
+#16#187#164#131' '#197'%DD[j'#162#16#130#22'A'#151#183#20'*'#184'<'#7#137#184
+#228'!'#164#130#31#129#162#149':<!'#230#137#130#137'6'#199'!'#222#215#251'>'
+#26'j'#196#193#3#151#156's'#184#249#253#207'9'#239#228#5#248#199#198#212#224
+#225#211#143'T\Y'#243#189'x'#225'x'#4#167#143#238'c='#9#168#224#133#212#24#14
+#133'Cx'#185#254#21'f'#163#9#211'j'#193'l4'#177'\'#222#232'I('#0#0#197#149'5'
+#140#142#12#225#228#196'~'#152#141#166#3'~}'#230#4'L'#171#133#209#145'!D'#134
+#251#177']'#135#170'q'#206#201'!'#16#25#238'G'#181'V'#199'ry'#195#174'X'#194
+#1#224#241#252#20#170#181':&'#247#190#133#165#167#193'9''M'#211#200#13#227
+#156#147#140#213'<'#146#139'U'#18'B'#216''''#158')'#19'@'#20#207#148#137'sN'
+#241'L'#153'.'#223#127'C'#156'sJ.V'#29#0'M'#211'H'#130#253'D'#131#0#208#247
+#234#14#242#249#130'-'#152'J'#1#11#239#199'`6'#14'"'#163#163'3:'#171#5#0'xq'
+#239#188#3#144'H$'#152#140#19#137#132#231#217#4#132#16#164#194#1' '#159'/'
+#224'vn'#214#145'{'#190#250#9#0'0~'#238'.'#12#195'`'#134'a0'#217#129#188#163
+#250#246#22#9'!HB'#183':'#16#0#128#215#161')Xz'#26#0'0y'#233#1#198#247#172'"'
+#155#205#218#247#12#195'`'#156's'#146'b'#210#151#29#25#134#193#152#236'@B'
+#165'X*%p'#234#226'U'#199'C'#255#246'}'#19#213'Z'#29'O'#174'M'#236'xM'#131'*'
+#212'm'#239'*'#143#0#0#161#223#7#1#224#240#1#224'Li'#137'v'#2#159#158'>'#203
+#186#142'h'#247#174'V'#207#175#136#185#185'+'#24#24#12#179#160':'#18#247#136
+'n'#204#23'{'#22#248#210#248#208'q'#132#16'D'#4#207#233#228';'#191#5#213#226
+#153#178#157#251#241's'#211#17's'#206#237'O'#235#243':'#217#2'n'#145#173#156
+'W@'#21'j'#183#219#142'X'#21#145#2']G'#228'gD'#4#198#152'#'#238'y'#139#182#3
+#31#155'}'#6'='#23#179'}'#0'v'#236#251'6uW'#235'W'#189#132#187#171#215's1'
+#232#185#152'-'#228#233#160'P(0!'#4#185#161'7o'#229'}'#191#160'V'#175#138'u'
+#253'?'#224#252#136#7#222#199#188'`'#213#151#177#244#245'\'#12#209'h'#20#149
+'J'#5#209'h'#180#187'j'#169#180'D3'#233#164'gk'#254#196#228#22#249#246'h'#239
+#240'_'#218#192'`'#152#225#191#183'_'#230#221#8#6'h'#246#197#218#0#0#0#0'IEN'
+'D'#174'B`'#130
]);

View File

@ -0,0 +1,31 @@
LazarusResources.Add('TJDBLabeledDateEdit','PNG',[
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
+#0#0#1'sRGB'#0#174#206#28#233#0#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147
+#0#0#0#9'pHYs'#0#0#11#19#0#0#11#19#1#0#154#156#24#0#0#0#7'tIME'#7#219#9#19#14
+#16''''#30#199'V|'#0#0#2'<IDATH'#199#181'V=hSQ'#20#254'^'#168'N'#18'$[+1'#16
+#200'&u'#184'7'#131#168'PK'#7#7'E'#226#203' '#10#10'E'''#145#182'K'#219#144
+#185#164#160'H'#212'1'#180#16#161#224#144'G,dpxBj'#210#237'M'#161#147#129'B'
+#27'J CM'#138'K'#162#242'9'#200'}'#190#215#188#215#180#161#249#224'p'#238'9'
+#231#221#243#221'{'#238#223#211'Hb'#148#24's'#26#159'*M'#230'J'#187#158#31
+#190#184#23#197#163#219#227#218'Y'#9'4'#146#174#196#239'^^'#199#181#171#151
+#176#179#255#19#173'v'#23#173'N'#15#173'v'#23#155#213#131#161#136#2#0#144'+'
+#237'b2'#22#194#131'[W'#208'jw]'#201#223','#220'G'#171#211#195'd,'#132'h8'#8
+#191#25':!'#165#164#139' '#26#14#162'V?'#196'f'#245#192#30#177'J'#14#0'_'#178
+#143'Q'#171#31#226#238#248'wt'#190#206'AJI'#195'0x<'#153#148#146#202'VZ#'#137
+#229#229#15#190'+m'#154'y'#204#204'<'#243'm'#199#227#19#200'd2'#0#128'T*'#5
+']'#215'5)%-'#203#210'\'#139'<?'#159#240'%P1'#211#204#195'4'#243'p'#246#201
+'f'#139#182#173#235#186'v'#226'.'#2#224#234#224#229'S3P'#164#241#248#4'L'#243
+'_'#204'0'#12#246#145#144#196#210#210'{6'#155#13'O'#17'BP'#8#193'f'#179#193
+'B'#161'`'#219#202''''#132'`y'#171'B'#146#16'B'#216'Z'#181#199#188#202#146'X'
+#169#3#0#138#233#24'J'#165#207#14'_'#8#23'n'#188#182'c'#206#25#1#128#170#187
+#210#158'%R'#201#189#144#156#138#224#201#205#139#158#177#245#245#143'}'#27'e'
+'v'#246#169#22'8'#238','#166'cHNE<'#147#20#202'{'#190#3#216#169'U\'#146'|x'
+#199'{'#6'~P%'#217#216#238'!'#177'R'#183'm'#133#183#217#156#203'>j7'#254#31
+#180#211'`c'#187'7'#232#244#186#180#239#26#248#161'P'#222#3#16#241#141'['#150
+#5')%,'#203':'#153#192'Yc'#231'n*'#166'c.{'#168#235'zP'#231#179'$'#238'#'#240
+':'#193#231#246#224#172#174#190#210#182#190'UG'#243#180#145#236#147#181#181
+'<'#23#230#158#147'$'#167#23#171#252#245#251#15#167#23#171#182'('#191'j'#147
+'TW'#131#173';?'#246'Ir0'#193#176'P'#4#154#215#163#127#212'n'#156'K'#185#130
+#151#195#154'6'#234#191#138#0'F'#140#191'H'#218#196#13'W'#138'!N'#0#0#0#0'IE'
+'ND'#174'B`'#130
]);

View File

@ -0,0 +1,32 @@
LazarusResources.Add('TJDBLabeledIntegerEdit','PNG',[
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
+#0#0#1'sRGB'#0#174#206#28#233#0#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147
+#0#0#0#9'pHYs'#0#0#11#19#0#0#11#19#1#0#154#156#24#0#0#0#7'tIME'#7#219#9#19#14
+#13'*'#159#26'F'#221#0#0#2'jIDATH'#199#213#147'=H[Q'#28#197#127'W'#130'.'#173
+'Q'#139#10#22'-'#13'H'#29#172#165#188'P(M'#29#146'A('#133'.YDJ'#253'*'#148'v'
+#144'.'#145' '#20';'#133'v('#13'.'#133' '#181'vp'#201'"'#216'1'#29'4.%'#15'!'
+#216'.'#162#248'A'#164#132'b'#19'?'#192'H'#146#235'P'#238#235'{'#249#16#155
+#180'C'#207'r'#255#255#251#30#231#220#255#185#231#194'?'#134'07s'#139#187'2'
+#180#176'Q'#242#199#199#247#29#244#247#182#137#138#4#204#196#193'g7'#232#238
+#184#192#234#246'!'#201'T'#134'd'#250#132'd*'#195'|4Q'#145'P'#13'@ha'#131#158
+#206'&'#30#184'.'#147'Le'#12'r'#223'p'#159'!'#210#211#217#132#163#189#158'r'
+#19'*h'#154'&'#139#4#28#237#245#196#215#246#152#143'&'#140#19#251#134#251#0
+#152'}'#233#229#232'8'#135#171#241#27'+3C'#164'#c'#132#195'aYH'#166'i'#154'T'
+#189'y_'#0#140'N'#197'ekC'#29'-'#246'Z'#195#10#128'td'#12#187'''h'#212'w'#159
+'|'#228#240'8'#203#202#204#16#186#174#139'p8,'#3#129#0#0'~'#191#31#175#215'+'
+'4M'#147#186#174#27#22#218#0'6v'#246'imh'#6'`b'#160#11'w'#207'%V'#183#15#25
+#140#252#242'<'#153#202'0'#27#129#165'w'#15'-v(BU'#151#189#3'G{=_'#190#254
+#176#156#190#20#236#158' 7'#7#223#163'N'#168#172'*'#172#139'Rt'#150'E'#138
+#248#233#173#239'(;'#0't]'#183#216#161'j5'#145#218#23#0'n_T'#222#190#222'L'
+#139#189#150#238'+'#23#13#139#204'1M'#166'O8:'#206#17'_'#219#227#243'k'#151
+#248#163'w0:'#21#151'['#137#3'ry'#201#196'@'#23#155#177'O'#127#229#21#143#140
+'<'#18'%-'#26#184#182#206'j|'#169'*'#242#201#201#23#216#27';'#132#13'`+q@kC'
+#157#145#162#205#216':'#0'o'#222#134'*'#22#216'O'#237#252'N'#209#240#189#171
+'eS'#228#25'_6VUgsyK'#15#224't:-kI'#204'-'#238'J'#183'/*'#167#167'?'#200#231
+'c'#163'RJ)'#221#190#168'4'#195#237#139#202'|>o'#233#21'4M3'#234#244#207'miL'
+#160#208#223#219'&'#202'%DJY'#212#23#238#149#130#237'<~*"'#207#248'2'#145'Ww'
+','#214#169#190'*'#1'!D'#145#160'Y'#232','#145#154#243#166#194'LT(X'#245#4
+#217'\'#190#200#150'B'#139#156'N'''#177'X'#204'X'#207#132'9E'#149'B'#165#168
+#228#172#234'c'#181#176'7v'#8#254'{'#156#2#250'='#180'%'#189#4'\'#190#0#0#0#0
+'IEND'#174'B`'#130
]);