diff --git a/components/jujiboutils/jujiboutils.lpk b/components/jujiboutils/jujiboutils.lpk index ebbf5ebd1..d85f7c9c7 100644 --- a/components/jujiboutils/jujiboutils.lpk +++ b/components/jujiboutils/jujiboutils.lpk @@ -1,6 +1,6 @@ - + @@ -15,8 +15,8 @@ different kinds of data, floats, dates, etc. while working with db and non db controls."/> - - + + @@ -128,7 +128,74 @@ db and non db controls."/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/jujiboutils/jujiboutils.pas b/components/jujiboutils/jujiboutils.pas index 753e2013c..028b4fe23 100644 --- a/components/jujiboutils/jujiboutils.pas +++ b/components/jujiboutils/jujiboutils.pas @@ -4,6 +4,7 @@ unit jujiboutils; +{$warn 5023 off : no warning about unused units} interface uses @@ -12,7 +13,10 @@ uses JLabeledIntegerEdit, JLabeledFloatEdit, JLabeledCurrencyEdit, JLabeledDateEdit, jdbgridutils, JLabeledTimeEdit, JDBLabeledTimeEdit, JLabeledDateTimeEdit, JDBLabeledDateTimeEdit, jinputconsts, JDbEnumCombo, - JDBImageBlob, JLabel, JDbLabel, JButton, jdbutils, LazarusPackageIntf; + JDBImageBlob, JLabel, JDbLabel, JButton, jdbutils, JIntegerEdit, JFloatEdit, + JCurrencyEdit, JDateEdit, JTimeEdit, JDateTimeEdit, JDBEdit, jdbintegeredit, + JDBFloatEdit, jdbcurrencyedit, jdbdateedit, JDBTimeEdit, JDBDateTimeEdit, + LazarusPackageIntf; implementation @@ -37,6 +41,19 @@ begin RegisterUnit('JLabel', @JLabel.Register); RegisterUnit('JDbLabel', @JDbLabel.Register); RegisterUnit('JButton', @JButton.Register); + RegisterUnit('JIntegerEdit', @JIntegerEdit.Register); + RegisterUnit('JFloatEdit', @JFloatEdit.Register); + RegisterUnit('JCurrencyEdit', @JCurrencyEdit.Register); + RegisterUnit('JDateEdit', @JDateEdit.Register); + RegisterUnit('JTimeEdit', @JTimeEdit.Register); + RegisterUnit('JDateTimeEdit', @JDateTimeEdit.Register); + RegisterUnit('JDBEdit', @JDBEdit.Register); + RegisterUnit('jdbintegeredit', @jdbintegeredit.Register); + RegisterUnit('JDBFloatEdit', @JDBFloatEdit.Register); + RegisterUnit('jdbcurrencyedit', @jdbcurrencyedit.Register); + RegisterUnit('jdbdateedit', @jdbdateedit.Register); + RegisterUnit('JDBTimeEdit', @JDBTimeEdit.Register); + RegisterUnit('JDBDateTimeEdit', @JDBDateTimeEdit.Register); end; initialization diff --git a/components/jujiboutils/src/jdblabeledtimeedit.pas b/components/jujiboutils/src/jdblabeledtimeedit.pas index 28e2cb04e..66b601cd5 100644 --- a/components/jujiboutils/src/jdblabeledtimeedit.pas +++ b/components/jujiboutils/src/jdblabeledtimeedit.pas @@ -1,3 +1,20 @@ +{ JDBLabeledTimeEdit + + Copyright (C) 2011 Julio Jiménez Borreguero + Contact: jujibo at gmail dot com + + This library is free software; you can redistribute it and/or modify it + under the same terms as the Lazarus Component Library (LCL) + + See the file license-jujiboutils.txt and COPYING.LGPL, included in this distribution, + for details about the license. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +} + unit JDBLabeledTimeEdit; {$mode objfpc}{$H+} diff --git a/components/jujiboutils/src/jlabeledcurrencyedit.pas b/components/jujiboutils/src/jlabeledcurrencyedit.pas index 2fe48347f..0f98f26ee 100644 --- a/components/jujiboutils/src/jlabeledcurrencyedit.pas +++ b/components/jujiboutils/src/jlabeledcurrencyedit.pas @@ -40,6 +40,7 @@ type function getDecimals: integer; function getFormat: string; function getValue: currency; + function getCurrentValue: Currency; procedure formatInput; procedure setDecimals(const AValue: integer); procedure setFormat(const AValue: string); @@ -54,6 +55,7 @@ type public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; + property CurrentValue: currency read getCurrentValue; published property DisplayFormat: string read getFormat write setFormat; property EditFormat: string read fEFormat write fEFormat; @@ -140,6 +142,11 @@ begin Result := theValue; end; +function TJLabeledCurrencyEdit.getCurrentValue: Currency; +begin + Result := StrToCurrDef(Text, Value); +end; + procedure TJLabeledCurrencyEdit.formatInput; begin if Font.Color <> fNColor then diff --git a/components/jujiboutils/src/jlabeleddateedit.pas b/components/jujiboutils/src/jlabeleddateedit.pas index 8ea2f73b4..f8d016c26 100644 --- a/components/jujiboutils/src/jlabeleddateedit.pas +++ b/components/jujiboutils/src/jlabeleddateedit.pas @@ -39,6 +39,7 @@ type function GetButtonWidth: integer; function getFormat: string; function getValue: TDateTime; + function getCurrentValue: TDateTime; procedure formatInput; procedure SetButtonWidth(AValue: integer); procedure setFormat(const AValue: string); @@ -63,6 +64,7 @@ type public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; + property CurrentValue: TDateTime read getCurrentValue; published function isNull: boolean; property DisplayFormat: string read getFormat write setFormat; @@ -146,6 +148,21 @@ begin Result := theValue; end; +function TJLabeledDateEdit.getCurrentValue: TDateTime; +var + aText: string; + aValue: TDateTime; +begin + aText := NormalizeDate(Text, theValue); + if Length(aText) = 0 then + aValue := 0 + else + if not ValidateDateString(aText, aValue) then + Result:= Value + else + Result:= aValue; +end; + procedure TJLabeledDateEdit.formatInput; begin if theValue <> 0 then diff --git a/components/jujiboutils/src/jlabeleddatetimeedit.pas b/components/jujiboutils/src/jlabeleddatetimeedit.pas index 0c3ad0a95..b51f4b657 100644 --- a/components/jujiboutils/src/jlabeleddatetimeedit.pas +++ b/components/jujiboutils/src/jlabeleddatetimeedit.pas @@ -41,6 +41,7 @@ type function GetButtonWidth: integer; function getFormat: string; function getValue: TDateTime; + function getCurrentValue: TDateTime; procedure formatInput; procedure SetButtonWidth(AValue: integer); procedure setFormat(const AValue: string); @@ -66,6 +67,7 @@ type public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; + property CurrentValue: TDateTime read getCurrentValue; published function isNull: boolean; property DisplayFormat: string read getFormat write setFormat; @@ -150,6 +152,24 @@ begin Result := theValue; end; +function TJLabeledDateTimeEdit.getCurrentValue: TDateTime; +var + aText: string; + aValue: TDateTime; +begin + aText := NormalizeDateTime(Text, theValue); + if Length(aText) = 0 then + aValue := 0 + else + if IsValidDateTimeString(aText) then + aValue := StrToDateTime(aText) + else + begin + aValue:= Value; + end; + Result:= aValue; +end; + procedure TJLabeledDateTimeEdit.formatInput; begin if theValue <> 0 then diff --git a/components/jujiboutils/src/jlabeledtimeedit.pas b/components/jujiboutils/src/jlabeledtimeedit.pas index 5d0f23bcd..1a9e51c3e 100644 --- a/components/jujiboutils/src/jlabeledtimeedit.pas +++ b/components/jujiboutils/src/jlabeledtimeedit.pas @@ -26,6 +26,9 @@ uses Dialogs, jcontrolutils, jinputconsts; type + + { TJLabeledTimeEdit } + TJLabeledTimeEdit = class(TCustomLabeledEdit) private theValue: TTime; @@ -33,6 +36,7 @@ type fFormat: string; function getFormat: string; function getValue: TTime; + function getCurrentValue: TTime; procedure setFormat(const AValue: string); procedure setValue(const AValue: TTime); procedure FormatInput; @@ -43,6 +47,7 @@ type public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; + property CurrentValue: TTime read getCurrentValue; published function isNull: boolean; property DisplayFormat: string read getFormat write setFormat; @@ -118,6 +123,28 @@ begin Result := theValue; end; +function TJLabeledTimeEdit.getCurrentValue: TTime; +var + aText: string; + aValue: TTime; +begin + aText := NormalizeTime(Text, theValue); + if Length(aText) = 0 then + begin + aValue := 0; + end + else + if IsValidTimeString(aText) then + begin + aValue := StrToTime(aText); + end + else + begin + aValue := Value; + end; + Result:= aValue; +end; + procedure TJLabeledTimeEdit.setFormat(const AValue: string); begin fFormat := AValue;