Remove: Non-labeled controls. You can achieve the same functionality with labeled controls and an empty label.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2039 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
jujibo
2011-09-30 10:09:57 +00:00
parent 443623d258
commit cbbf1e2cfc
26 changed files with 39 additions and 3997 deletions

View File

@ -18,149 +18,89 @@
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Files Count="29">
<Files Count="17">
<Item1>
<Filename Value="src/jdbintegeredit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="jdbintegeredit"/>
</Item1>
<Item2>
<Filename Value="src/jdblabeledintegeredit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="jdblabeledintegeredit"/>
</Item2>
<Item3>
<Filename Value="src/jdbcurrencyedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="jdbcurrencyedit"/>
</Item3>
<Item4>
</Item1>
<Item2>
<Filename Value="src/jdblabeledcurrencyedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="jdblabeledcurrencyedit"/>
</Item4>
<Item5>
<Filename Value="src/jdbdateedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="jdbdateedit"/>
</Item5>
<Item6>
</Item2>
<Item3>
<Filename Value="src/jdblabeleddateedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="jdblabeleddateedit"/>
</Item6>
<Item7>
</Item3>
<Item4>
<Filename Value="src/jcontrolutils.pas"/>
<UnitName Value="jcontrolutils"/>
</Item7>
<Item8>
<Filename Value="src/jintegeredit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JIntegerEdit"/>
</Item8>
<Item9>
</Item4>
<Item5>
<Filename Value="src/jlabeledintegeredit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JLabeledIntegerEdit"/>
</Item9>
<Item10>
<Filename Value="src/jcurrencyedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JCurrencyEdit"/>
</Item10>
<Item11>
</Item5>
<Item6>
<Filename Value="src/jlabeledcurrencyedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JLabeledCurrencyEdit"/>
</Item11>
<Item12>
<Filename Value="src/jdateedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JDateEdit"/>
</Item12>
<Item13>
</Item6>
<Item7>
<Filename Value="src/jlabeleddateedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JLabeledDateEdit"/>
</Item13>
<Item14>
</Item7>
<Item8>
<Filename Value="src/jdbgridcontrol.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JDBGridControl"/>
</Item14>
<Item15>
</Item8>
<Item9>
<Filename Value="src/jdbgridutils.pas"/>
<UnitName Value="jdbgridutils"/>
</Item15>
<Item16>
</Item9>
<Item10>
<Filename Value="src/jdblabelededit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JDBLabeledEdit"/>
</Item16>
<Item17>
<Filename Value="src/jtimeedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JTimeEdit"/>
</Item17>
<Item18>
</Item10>
<Item11>
<Filename Value="src/jlabeledtimeedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JLabeledTimeEdit"/>
</Item18>
<Item19>
<Filename Value="src/jdbtimeedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JDBTimeEdit"/>
</Item19>
<Item20>
</Item11>
<Item12>
<Filename Value="src/jdblabeledtimeedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JDBLabeledTimeEdit"/>
</Item20>
<Item21>
<Filename Value="src/jdatetimeedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JDateTimeEdit"/>
</Item21>
<Item22>
</Item12>
<Item13>
<Filename Value="src/jlabeleddatetimeedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JLabeledDateTimeEdit"/>
</Item22>
<Item23>
<Filename Value="src/jdbdatetimeedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JDBDateTimeEdit"/>
</Item23>
<Item24>
</Item13>
<Item14>
<Filename Value="src/jdblabeleddatetimeedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JDBLabeledDateTimeEdit"/>
</Item24>
<Item25>
<Filename Value="src/jfloatedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JFloatEdit"/>
</Item25>
<Item26>
</Item14>
<Item15>
<Filename Value="src/jlabeledfloatedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JLabeledFloatEdit"/>
</Item26>
<Item27>
<Filename Value="src/jdbfloatedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JDBFloatEdit"/>
</Item27>
<Item28>
</Item15>
<Item16>
<Filename Value="src/jdblabeledfloatedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JDBLabeledFloatEdit"/>
</Item28>
<Item29>
</Item16>
<Item17>
<Filename Value="src/jinputconsts.pas"/>
<UnitName Value="jinputconsts"/>
</Item29>
</Item17>
</Files>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="2">

View File

@ -7,44 +7,29 @@ unit jujibocontrols;
interface
uses
jdbintegeredit, jdblabeledintegeredit, jdbcurrencyedit,
jdblabeledcurrencyedit, jdbdateedit, jdblabeleddateedit, jcontrolutils,
JIntegerEdit, JLabeledIntegerEdit, JCurrencyEdit, JLabeledCurrencyEdit,
JDateEdit, JLabeledDateEdit, JDBGridControl, jdbgridutils, JDBLabeledEdit,
JTimeEdit, JLabeledTimeEdit, JDBTimeEdit, JDBLabeledTimeEdit, JDateTimeEdit,
JLabeledDateTimeEdit, JDBDateTimeEdit, JDBLabeledDateTimeEdit, JFloatEdit,
JLabeledFloatEdit, JDBFloatEdit, JDBLabeledFloatEdit, jinputconsts,
LazarusPackageIntf;
jdblabeledintegeredit, jdblabeledcurrencyedit, jdblabeleddateedit,
jcontrolutils, JLabeledIntegerEdit, JLabeledCurrencyEdit, JLabeledDateEdit,
JDBGridControl, jdbgridutils, JDBLabeledEdit, JLabeledTimeEdit,
JDBLabeledTimeEdit, JLabeledDateTimeEdit, JDBLabeledDateTimeEdit,
JLabeledFloatEdit, JDBLabeledFloatEdit, jinputconsts, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('jdbintegeredit', @jdbintegeredit.Register);
RegisterUnit('jdblabeledintegeredit', @jdblabeledintegeredit.Register);
RegisterUnit('jdbcurrencyedit', @jdbcurrencyedit.Register);
RegisterUnit('jdblabeledcurrencyedit', @jdblabeledcurrencyedit.Register);
RegisterUnit('jdbdateedit', @jdbdateedit.Register);
RegisterUnit('jdblabeleddateedit', @jdblabeleddateedit.Register);
RegisterUnit('JIntegerEdit', @JIntegerEdit.Register);
RegisterUnit('JLabeledIntegerEdit', @JLabeledIntegerEdit.Register);
RegisterUnit('JCurrencyEdit', @JCurrencyEdit.Register);
RegisterUnit('JLabeledCurrencyEdit', @JLabeledCurrencyEdit.Register);
RegisterUnit('JDateEdit', @JDateEdit.Register);
RegisterUnit('JLabeledDateEdit', @JLabeledDateEdit.Register);
RegisterUnit('JDBGridControl', @JDBGridControl.Register);
RegisterUnit('JDBLabeledEdit', @JDBLabeledEdit.Register);
RegisterUnit('JTimeEdit', @JTimeEdit.Register);
RegisterUnit('JLabeledTimeEdit', @JLabeledTimeEdit.Register);
RegisterUnit('JDBTimeEdit', @JDBTimeEdit.Register);
RegisterUnit('JDBLabeledTimeEdit', @JDBLabeledTimeEdit.Register);
RegisterUnit('JDateTimeEdit', @JDateTimeEdit.Register);
RegisterUnit('JLabeledDateTimeEdit', @JLabeledDateTimeEdit.Register);
RegisterUnit('JDBDateTimeEdit', @JDBDateTimeEdit.Register);
RegisterUnit('JDBLabeledDateTimeEdit', @JDBLabeledDateTimeEdit.Register);
RegisterUnit('JFloatEdit', @JFloatEdit.Register);
RegisterUnit('JLabeledFloatEdit', @JLabeledFloatEdit.Register);
RegisterUnit('JDBFloatEdit', @JDBFloatEdit.Register);
RegisterUnit('JDBLabeledFloatEdit', @JDBLabeledFloatEdit.Register);
end;

View File

@ -1,29 +0,0 @@
LazarusResources.Add('TJDBCurrencyEdit','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#8
+'6'#30#134#145'!'#226#0#0#2#23'IDATH'#199#213#148#191'k'#19'a'#24#199'?o'#169
+#21'!'#180#182#160#130#208#128#129'b'#7#219#14'9'#16#9'8'#196#213#127'@;8T'
+#151'7'#131#184#164#131' ]'#28#226#160#22#188'S'#8#25':'#248'c'#21#234#152#14
+#154#226#146')'#22','#4#130#182#232'pBLJ'#10'IL'#242':'#180'w'#190'w'#151#132
+'&'#213#193#7'^'#238'}'#30#222#251'~'#238#251#240#220#11#255'8'#132#158#188
+'~'#255']'#165#215'K]'#15#222#185#30#225#198#213#243'b('#128'.'#188#154'X'
+#224'R8'#196#214'N'#13#187#210#192#174'6'#177'+'#13#222#230#190#13#5#26#5'H'
+#175#151#152#159#153#226#194#185'S'#216#149#6'['#224#17#183#171'M'#230'g'#166
+#168#213'['#244'r'#216#23#16#153#30#167'P,S('#194#217#211#17#0#143#248'~'#189
+'M'#161'X'#198'9'#187'1('#0'`'#182#246#10#128#15'o`;t'#147#141'G1'#226#201'M'
+#247#224#149#185'3'#236#215#219#212#234#173#193#29#140'}~'#129'iZn1'#145#128
+#213#175#11#216#149'Y'#143#19#128#210#238#222'@'#128#17')'#165#210#197#1'L'
+#211#226'yj'#217'S'#251#248#233#7#133'b'#153#200#244#248#224#14#18#9#233's '
+#1'x'#248'r'#251#239#180#200'4-WT'#207#239'/'#30#191'E'#163#186#168'?'#190
+#228#223#1#16':\'#140#192#220'EX'#204#172#169#163#136'/-'#221#18'BJ'#169#252
+#0#199#205#201#19#205#161#175#136#149#149#7'LL'#134'E'#223#22'=~'#154#30#26
+#176'W'#217'='#216'H)'#149'R'#4#214'A]'#169'x2'#167#244#136'''sn'#237'W'#171
+#237#201#163#209#168#251#172#254#220'Q.'#192#15#249'S'#11#2'tP'#167#211#241
+#228':'#196#1#244'mQ'#183'PJ!'#132#240#228'COQ/'#225'k'#203#155'dS1w'#15#184
+'y'#224'O'#214#167#198'?E'#158'{'#253'P'#220#255#245#217'T'#140'l*'#230#130#2
+#14','#203#18'RJ'#229#23'}'#242#204#236#250#130#254#245':'#172#231']'#4#16
+#141'^'#14#136#143#137#160#176#190'wrg'#159'M'#197'0'#12#131'|>'#143'a'#24
+#253#169#153#204#154#186'w'#247'v`j'#6#9'g'#138#186'ztg'#248#152'11'#25#22
+#252#247#241#27#224#191#193'Dc2"&'#0#0#0#0'IEND'#174'B`'#130
]);

View File

@ -1,26 +0,0 @@
LazarusResources.Add('TJDBDateEdit','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#9
+#0'8'#220'B_]'#0#0#1#192'IDATH'#199#181'V=H'#195'@'#20#254#174#136'"'#168#20
+#7#197#161#6#11#221'D'#135'f'#171#191'uu'#169't'#16#4#135#162#147#136#186#168
+#208#185'P'#23#169'8'#138#5#133#130#131#16#4'W'#193#182#233#150#169't'#11#20
+#180#136#208#161#182'EA'#163#242#156'"I'#147#180'I'#180#15#30#151#187'w'#247
+'}w'#223'{'#199#133#17#17#186'i='#218#206'U'#254#153#206'n'#203#166#19'7'#151
+#253'X'#157#29'cN'#9#24#17#233#128'O'#182#166'19>'#128#210#227'+'#170#245#15
+'T'#27#10#170#245#15#220#136'O'#174#136#24#17'a'#233#160'@S'#129'aL'#140#246
+'c'#146#27#196#136#183'O'#7'^m(x{'#255#198#235#251#23#202#149'&'#238#142'B'
+#204#145'D~'#223#16#138'r'#13'E'#25#24#241#250#1#192#0'^'#148'kP'#231':'#150
+#232#240#240#244'O'#153'N&'#183'Y'#199'$'#239#238'F\'#129#167'R'#130#253'*'
+#178#179#192'lC'#217#156'H'#243's3'#204#22#129#219#147#216'>'#1#0'D'#18'2'#0
+'@'#136#7#12'c'#170'ic'#142#8'Z'#129#180#22']'#224#176#22#234'5'#141#165#211
+#151#134'B'#137#197#214#153#167'uP'#136#7#16']'#224'LA'#174#239#31',7P*'#230
+'u'#30']Y'#180#150#200#204'TI2'#5#5#145#132'l'#144#232'8u'#166#235'7'#235#21
+#0#128#199'.A'#166#160#180#141#243'<'#175'k'#219'&'#217'J'#30#128#179#140'K'
+#146#4#158#231'!I'#146#253'$k'#171'I'#136#7'L'#171#203'q'#21#181'['#236#4#216
+'@`'#247#6#187'"H&'#183'Y6''v'#231'i#"'#131#159#159'_'#208#222#206#6#17#17
+#133#247'E'#250#252#250#166#240#190#248#235#234#184#250'MD'#20#12#6'um'#227
+#229#145#136#168'3'#129'[S'#9#152#217#163#223#172'W'#254'E'#174'!'#175#143
+#177'n'#255'Ux'#208'e'#251#1#216#144'T='#167' '#26#22#0#0#0#0'IEND'#174'B`'
+#130
]);

View File

@ -1,28 +0,0 @@
LazarusResources.Add('TJDBIntegerEdit','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'B'#0'v'#0#196#23#5#162#29#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#18#17#13#29
+#136'a`'#250#0#0#2#1'IDATH'#199#213'V'#177'K'#27'a'#20#255'}'#161'('#133'6'
+#30#213'$8'#164'b'#160'4'#208'h'#135#28#130#136'K'#178#149#254#1'B'#160'C'
+#168#147#131'tI'#6#161#184'8'#184'H'#11'n'#226#208'A'#218#181'PG'#151#154'P'
+#144#155#162'B!4'#168'!-\'#197'&'#209#130#134#220#253':'#148#239'z'#151'\'
+#196'K'#204#208#31'|'#188#239#193#227#253#238#253#222#187#199'''H'#162#159
+#184'cw>'#236#254#224#198#167#146'k'#224#252#243#8#230'fG'#133'W'#2'A'#210
+#145#248#237#194'S'#196#30#222#195#193#201#5#244#234#21#244'Z'#3'z'#245#10#31
+'s'#149#174#136#4'I$'#179'yN>z'#128#241#208']'#196#198#238'#'#168#12':'#146
+#235#181#6'~_'#26#184#184'l'#162'T'#174'cguFx'#146'('#18#246#163'P<C'#161#8#4
+#149#8#0#180'%/'#20#207' c'#187#234#193#244'D'#0#193#161#1't'#234#193#244'D'
+#192#170#194'3A'#169'\GH'#9#0#0#150'RQ$&'#135#219'z'#160#215#26#144#177#158#9
+'"a?'#246#14'Oa'#152'Dl,'#234#26#248'e'#255'go'#18'M='#25'Aph'#0'+[_'#177#178
+#245#31'I$Hb~}'#159#199#149's'#24'&'#177#148#138#226'H'#219#190#149#191'8'
+#157'~!\%J='#6#14#10#187'=%_^~'#253'O'#162#227#202'9B'#202#160'%'#209#145#246
+#13#0#176#246'f'#163'k'#130'z'#181#12#0#240#1'@'#250#217'8'#246#14'O'#173'u`'
+'G2'#155#183#172#188'7'#13#211#225#3#128#170#170#14'k'#129#164'u'#222#127#254
+#206'D&'#199#205#205'w|'#181#248#146'$'#153#200#228'hG"'#147#163'i'#154#14'_'
+'"'#30#143'['#247#218#175#19#146#252'['#129#196#220#236#168#232#180'gZ'#215
+#186#252'(O'#235#186#19'd'#162'd6'#143#157#213#25#135't'#210#239#137'@'#8#209
+'Fh'''#186#142#196'w'#211#169#176'''j%'#236#185#130#166'a'#182#201#210'*'#145
+#170#170#208'4'#205#178#174'S$'#143'}'#138#186#133#156'"'#225'6'#9#245'j'#249
+'V^'#2'~%,D'#191'_'#21'>'#244#25#127#0#156#234#169#234'iI'#212#232#0#0#0#0'I'
+'END'#174'B`'#130
]);

View File

@ -1,232 +0,0 @@
{ JCurrencyEdit
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 JCurrencyEdit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, StdCtrls, Graphics,
Dialogs, jinputconsts;
type
{ TJCurrencyEdit }
TJCurrencyEdit = class(TCustomEdit)
private
{ Private declarations }
theValue: currency;
fFormat: string;
fDecimals: integer;
function getDecimals: integer;
function getFormat: string;
function getValue: currency;
procedure formatInput;
procedure setDecimals(const AValue: integer);
procedure setFormat(const AValue: string);
function scaleTo(const AValue: currency; const NDecimals: integer): currency;
function IsValidFloat(const Value: string): boolean;
procedure setValue(const AValue: currency);
protected
{ Protected declarations }
procedure DoEnter; override;
procedure DoExit; override;
procedure KeyPress(var Key: char); override;
public
{ Public declarations }
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property DisplayFormat: string read getFormat write setFormat;
property Decimals: integer read getDecimals write setDecimals;
property Value: currency read getValue write setValue;
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 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 jcurrencyedit_icon.lrs}
RegisterComponents('Additional', [TJCurrencyEdit]);
end;
{ TJCurrencyEdit }
function TJCurrencyEdit.getDecimals: integer;
begin
Result := fDecimals;
end;
function TJCurrencyEdit.getFormat: string;
begin
Result := fFormat;
end;
function TJCurrencyEdit.getValue: currency;
begin
Result := theValue;
end;
procedure TJCurrencyEdit.formatInput;
begin
Caption := FormatFloat(DisplayFormat, theValue);
end;
procedure TJCurrencyEdit.setDecimals(const AValue: integer);
begin
if (AValue >= 0) and (AValue < 5) then
fDecimals := AValue;
end;
procedure TJCurrencyEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
formatInput;
end;
function TJCurrencyEdit.scaleTo(const AValue: currency;
const NDecimals: integer): currency;
begin
Result := round(AValue * power(10, NDecimals)) / power(10, NDecimals);
end;
function TJCurrencyEdit.IsValidFloat(const Value: string): boolean;
begin
if StrToCurrDef(Value, MaxCurrency) = MaxCurrency then
Result := False
else
Result := True;
end;
procedure TJCurrencyEdit.setValue(const AValue: currency);
begin
if fDecimals > 0 then
theValue := scaleTo(AValue, fDecimals)
else
theValue := AValue;
formatInput;
end;
procedure TJCurrencyEdit.DoEnter;
begin
inherited DoEnter;
Text := FloatToStr(theValue);
SelectAll;
end;
procedure TJCurrencyEdit.DoExit;
begin
inherited DoExit;
if IsValidFloat(Text) then
theValue := StrToCurr(Text)
else
begin
ShowMessage(Format(SInvalidNumber, [Text]));
SetFocus;
end;
if fDecimals > 0 then
theValue := scaleTo(theValue, fDecimals);
formatInput;
end;
procedure TJCurrencyEdit.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;
inherited KeyPress(Key);
end;
constructor TJCurrencyEdit.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
Text := '';
fFormat := '#,0.00';
fDecimals := 2;
formatInput;
end;
destructor TJCurrencyEdit.Destroy;
begin
inherited Destroy;
end;
end.

View File

@ -1,29 +0,0 @@
LazarusResources.Add('tjcurrencyedit','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#20#9
+#27#2'.'#175'u'#204#0#0#2'''IDATH'#199#213#148'?h'#19'q'#20#199'?'#215#166
+#181#144#208#218'@'#29#132'f'#8#136'A'#172#29'r'#160#18'p'#136#171#139#163'v'
+'p'#168'.'#191#12#226#146#14#130'tq'#136#131'Z'#240'N'#161'D'#232#224#159'U'
+#208'1'#29'4'#193'%S'#20','#4#170#182'('#18'!MJ'#2'Il'#242'sh'#239#252#221']'
+#26#154'T'#7#31#252#184#247#30#191#251'~~'#239#221#187#31#252'c'#211#212#224
+#197#219#239','#191'^'#239#186#241#198#165'0W.'#28#31#12#160#10'/%f9'#29#10
+#240'q'#163'F'#169#210#164'TmQ'#170'4y'#149#253'6'#16'h'#24'`k'#234'2gN'#4'9'
+'w*'#136#127'l'#152'z'#179#227#16'/U['#4''''#198#240#251'G'#200#228#127#240
+'9'#247#244#192#0#31'@xz'#156'B'#177'L'#161#8#199#142#134#1#28#226#245'F'#155
+'B'#177#140#181'w'#181#143#22#249',''R{.'#1#222#189#132#181#192'Um'#245'^'
+#140'x2go<?3E'#189#209#166#214#216#233#235#27#248#0'F?='#145#134'a'#218#201
+'D'#2#185#244'u'#150'R%'#162#169#149#0#172'on'#247#5#24#18'B8'#196#1#12#195
+#228'qj'#193#145'{'#255#225''''#133'b'#153#240#244'x'#255#21'$'#18#2'g'#5#2
+#128#187#207#214#254'N'#139#12#195#180'E'#213#248#246'\'#132#195#182#200#167
+#138#186#237'K'#254#141#4#8#236'-'#134'`'#230'$'#204#165'W'#14'$>?'#127'M'
+#211#132#16#210#13#176#170'92'#210#26#248#138'X\'#188#195#196'dH'#235#217#162
+#251#15#151#7#6'lW6w'#29'!'#132#148#18#207#218#205'K'#25'Of'#165'j'#241'd'
+#214#206#253#218'i;'#226'h4j?'#171'['#27#210#6#184'!'#127'r^'#128#10#234't:'
+#142'X'#133'X'#128#158'-'#234'fRJ4Ms'#196#3'O'#209'~'#194#23#23'rdR1'#219#7
+#236#216#243''''#171'S'#227#158'"'#199#189#190''''#238'>}&'#21'#'#147#138#217
+' O'#5#166'ijB'#8#233#22'}'#240#200#232#250#130'zz'#21#182#239']'#4#16#141
+#158#245#136#143'j^a'#213#183'b'#203#207#164'b'#232#186'N>'#159'G'#215#245
+#222#212'tzE'#222#186'y'#221'35'#253#152'5E]k'#180'g'#248#144'61'#25#210#248
+#239#237'7T'#213#192'u'#139'\'#209'^'#0#0#0#0'IEND'#174'B`'#130
]);

View File

@ -1,203 +0,0 @@
{ JDateEdit
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 JDateEdit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, StdCtrls, Graphics,
Dialogs, jcontrolutils, jinputconsts;
type
{ TJDateEdit }
TJDateEdit = class(TCustomEdit)
private
{ Private declarations }
theValue: TDateTime;
fFormat: string;
function getFormat: string;
function getValue: TDateTime;
procedure formatInput;
procedure setFormat(const AValue: string);
procedure setValue(const AValue: TDateTime);
protected
{ Protected declarations }
procedure DoEnter; override;
procedure DoExit; override;
procedure KeyPress(var Key: char); override;
public
{ Public declarations }
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
function isNull: boolean;
property DisplayFormat: string read getFormat write setFormat;
property Value: TDateTime read getValue write setValue;
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 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 jdateedit_icon.lrs}
RegisterComponents('Additional', [TJDateEdit]);
end;
{ TJDateEdit }
function TJDateEdit.getFormat: string;
begin
Result := fFormat;
end;
function TJDateEdit.getValue: TDateTime;
begin
Result := theValue;
end;
procedure TJDateEdit.formatInput;
begin
if theValue <> 0 then
Text := FormatDateTime(DisplayFormat, theValue);
end;
procedure TJDateEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
formatInput;
end;
procedure TJDateEdit.setValue(const AValue: TDateTime);
begin
theValue := AValue;
formatInput;
end;
procedure TJDateEdit.DoEnter;
begin
inherited DoEnter;
if theValue <> 0 then
Text := FormatDateTime(DisplayFormat, theValue)
else
Text := '';
SelectAll;
end;
procedure TJDateEdit.DoExit;
begin
inherited DoExit;
Text := NormalizeDate(Text, theValue);
if Length(Text) = 0 then
theValue := 0
else
if IsValidDateString(Text) then
theValue := StrToDate(Text)
else
begin
ShowMessage(Format(SInvalidDate, [Text]));
SetFocus;
end;
formatInput;
end;
procedure TJDateEdit.KeyPress(var Key: char);
begin
if not (Key in ['0'..'9', #8, #9, '.', '-', '/']) then
Key := #0;
inherited KeyPress(Key);
end;
constructor TJDateEdit.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
Text := '';
fFormat := ShortDateFormat;
theValue := 0;
formatInput;
end;
destructor TJDateEdit.Destroy;
begin
inherited Destroy;
end;
function TJDateEdit.isNull: boolean;
begin
Result := theValue = 0;
end;
end.

View File

@ -1,25 +0,0 @@
LazarusResources.Add('tjdateedit','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#20#9
+#28'0'#169'9'#178#139#0#0#1#190'IDATH'#199#181'V=H'#195'@'#20#254#174#136'"'
+#168#20#7#197#161#6#11#221'D'#135'f'#171#191'uu'#169't'#16#4#135#162#147#136
+#186#168#208#185'P'#23#169'8'#138#5#133#130#131#16#4'W'#193#182#233#150#169
+'t'#11#20#180#136#208#161#182'EA'#163#242#156'"I'#147#180'I'#180#15#30#151
+#187'w'#247'}w'#223'{'#199#133#17#17#186'i='#218#206'U'#254#25'g'#183'e'#211
+#137#155#203'~'#172#206#142'9&`D'#164#3'>'#217#154#198#228#248#0'J'#143#175
+#168#214'?Pm('#168#214'?p#>'#185'"bD'#132#165#131#2#166#2#195#152#24#237#199
+'$7'#136#17'o'#159#14#188#218'P'#240#246#254#141#215#247'/'#148'+M'#220#29
+#133#156'I'#228#247#13#161'('#215'P'#148#129#17#175#31#0#12#224'E'#185#6'u'
+#174'c'#137#14#15'O'#255#148#233'dr'#155'uL'#242#238'n'#196#21'x*%'#216#175
+'";'#11#204'6'#148#205#137'4?7'#195'l'#17#184'='#137#237#19#0'@$!'#3#0#132'x'
+#192'0'#166#154'6'#230#136#160#21'Hk'#209#5#14'k'#161'^'#211'X:}i('#148'Xl'
+#157'yZ'#7#133'x'#0#209#5#206#20#228#250#254#193'r'#3#165'b^'#231#209#149'Ek'
+#137#204'L'#149'$SP'#16'I'#200#6#137#142'Sg'#186'~'#179'^'#1#0'x'#236#18'd'
+#10'J'#219'8'#207#243#186#182'm'#146#173#228#1'8'#203#184'$I'#224'y'#30#146
+'$'#217'O'#178#182#154#132'x'#192#180#186#28'WQ'#187#197'N'#128#13#4'vo'#176
+'+'#130'dr'#155'esbw'#158'6"2'#248#249#249#5#237#237'l'#16#17'Qx_'#164#207
+#175'o'#10#239#139#191#174#142#171#223'DD'#193'`P'#215'6^'#30#137#136':'#19
+#184'5'#149#128#153'='#250#205'z'#229'_'#228#26#242#250#24#235#246'_'#133#7
+']'#182#31#245#153'Q='#238'^'#250#139#0#0#0#0'IEND'#174'B`'#130
]);

View File

@ -1,209 +0,0 @@
{ TJDateTimeEdit
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 JDateTimeEdit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, StdCtrls, Graphics,
Dialogs, jcontrolutils, jinputconsts;
type
TJDateTimeEdit = class(TCustomEdit)
private
{ Private declarations }
theValue: TDateTime;
fFormat: string;
function getFormat: string;
function getValue: TDateTime;
procedure formatInput;
procedure setFormat(const AValue: string);
procedure setValue(const AValue: TDateTime);
protected
{ Protected declarations }
procedure DoEnter; override;
procedure DoExit; override;
procedure KeyPress(var Key: char); override;
public
{ Public declarations }
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
function isNull: boolean;
property DisplayFormat: string read getFormat write setFormat;
property Value: TDateTime read getValue write setValue;
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 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 jdatetimeedit_icon.lrs}
RegisterComponents('Additional', [TJDateTimeEdit]);
end;
function TJDateTimeEdit.getFormat: string;
begin
Result := fFormat;
end;
function TJDateTimeEdit.getValue: TDateTime;
begin
Result := theValue;
end;
procedure TJDateTimeEdit.formatInput;
begin
if theValue <> 0 then
Text := FormatDateTime(DisplayFormat, theValue);
end;
procedure TJDateTimeEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
formatInput;
end;
procedure TJDateTimeEdit.setValue(const AValue: TDateTime);
begin
theValue := AValue;
formatInput;
end;
procedure TJDateTimeEdit.DoEnter;
begin
inherited DoEnter;
if theValue <> 0 then
Text := FormatDateTime(DisplayFormat, theValue)
else
Text := '';
SelectAll;
end;
procedure TJDateTimeEdit.DoExit;
var
bufText: string;
begin
inherited DoExit;
bufText := Text;
Text := NormalizeDateTime(Text, theValue);
if (Length(bufText) > 0) and (Length(Text) = 0) then
begin
ShowMessage(Format(SInvalidDateTime, [bufText]));
SetFocus;
end
else
if Length(Text) = 0 then
theValue := 0
else
if IsValidDateTimeString(Text) then
theValue := StrToDateTime(Text)
else
begin
ShowMessage(Format(SInvalidDateTime, [Text]));
SetFocus;
end;
formatInput;
end;
procedure TJDateTimeEdit.KeyPress(var Key: char);
begin
if not (Key in ['0'..'9', #8, #9, '.', '-', '/', ',', ':', ' ']) then
Key := #0;
inherited KeyPress(Key);
end;
constructor TJDateTimeEdit.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
Text := '';
fFormat := ShortDateFormat + ' ' + ShortTimeFormat;
theValue := 0;
formatInput;
end;
destructor TJDateTimeEdit.Destroy;
begin
inherited Destroy;
end;
function TJDateTimeEdit.isNull: boolean;
begin
Result := theValue = 0;
end;
end.

View File

@ -1,44 +0,0 @@
LazarusResources.Add('tjdatetimeedit','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#23#8
+'-(o'#127#232#182#0#0#3'wIDATH'#199#181#150']L'#155'U'#24#199#127'o?VZ'#218
+#210'v'#2'1'#142#175'1'#162#27'e'#26' '#11'n'#160#4#22']'#252#136#212#204#197
+#196#27#227#212#152',*'#243#2#146#145'x'#179#16'G'#184#217'4'#241'f'#238'b3$'
+'SI'#26'"'#222'll'#131#173#197#10#232#134','#19'Cdk'#7#140#149'Z'#218#173#165
+#244#243'xaJZ(['#193#248'KN'#206#155#243#156#243#255'?'#239#249'x'#207'+'#9
+'!'#216'('#131#223'u7'#169#228#129#14'UN'#228'9'#185'R'#174#139#199#4#161'`'
+#200#27#12#224#8#197#212']o|'#216#249's'#178#175#148'jp'#254#218'=N'#247'Og'
+#20#253#224#181#237#188#221#240'$'#215'~'#248#226'k'#131#225#193'acI'#203#22
+#149'>'#31#149#198#136#16#9#2#190'9'#188'3'#183#152#155#188#18#244'?Tv'#29'j'
+#253#234#248#138'A'#170#240#169'#'#207'b.'#214'r'#211#21#192#237#11#227#246
+'Gp'#251#194#244#217'f'#249#188'z'#232#212#182#29#166'OL%'#175#176#176#164'c'
+#226'/?'#238#197'%bq'#129'Q'#151'Ce'#185#22#163#152#230#143#171#231#184#239
+#142#181#189'{'#236't'#183'$'#132#160#185#221#206#238#10#19'e'#133'j'#204'%:'
+#10#12#170'4q'#183'?'#194#11'X'#235#183#26'<'#151'K'#247#28'Q'#222#154'S'#225
+#241#133#217#189#195#132'A/C '#225#245#199#25#153'\@'#171#146#177'S'#255'''c'
+#253'g'#151'BrS'#189#12'`{'#145#158#223#167#188#244#217'f'#211'D'#147'up9'
+#142'<'#177'x,o['#179'r!'#164'g'#222#187#140#165#177#20#147'N'#224#13#4#208
+#234's).'#210#211#178#191#156#251#15#19'xd'#187'(,{J'#19'_Z'#252'Ljo'#255'r'
+#227#171#156'B'#241#211':'#14#190'iA'#157#147#195#197#161'a'#242#203#170#249
+#229'W'''#7#202'''q'#244'}'#127'G'#1#208#218'j'#217#148#248#201#147'Vf\..^'
+#30'bb'#252#6#205'/'#31#192'X'#160#225#158'w'#153#188#186'R'#228'H'#133#138
+#213#3#178'!5'#161'\'#173#150#137#241#27#188#218'ba'#167#185#10#167'?J4'#154
+'@$"'#136#132'@'#177#222#192'l'#169#174#173#227#153'*3'#154'<='#129'0'#220
+#157#15#162#207#149#177'8;'#206'r,'#238'Q'#172#30'`'#233#156#2#192#218'Q'#177
+#166'-Ij'#172#190'a/H'#16'O'#128'<'#7'F'#175#187'y'#177'R'#134#243#183'a'#162
+'B'#225'Pd'#18#207#196#193#198#18#222#217#183'eM'#187#20#142#130#0#151';H'
+#191'c'#158'b'#181#135#252#208#21#134#167'CH'#234#173#221#138#213#153#245#216
+'#'#244#14':'#215#8#245#14':'#233#29'L'#207#30#224#248'7'#163#196#19#2#157#6
+#158#223'%x"|'#129#145#11'#T6'#30#162#241#245#247'F'#21#217#204'sR'#180#199
+#30#193#210'9'#149'f'#242#209#254#219' b'#252'=3'#197#29#199'Mn{'#148'T5'#29
+#198#188#167#14#0'Y6'#6'='#246#200#186#177#129'sV'#6#190#253#145#129#190#235
+'h'#10#26#176#142#204#179#247#165#183'V'#226'Y'#189#193#191'SV'#146'1v>q'#148
+'K]'#251#0#168#173#173'ell,-'#190#238'"'#167#238'&kGE'#198#221#149#13#138#245
+#182#223'z'#235#176#154'd'#246#143'4'#200#246#4'g'#162#185#221#254'H'#19#197
+#137#19#31'KCWm'#155#254#224#141#254#244#152#14'B'#136'5'#229#204#153#179#226
+#232#167#239#11'!'#132'hj'#179#137'h,.'#154#218'l+%'#217#158'|'#22'B'#136#154
+#154#154#180#218#191#232#18'B'#136#199#27'l'#150#164#129#148#233#210#127#224
+#187#251#159#238#136'$zC'#145'$m'#230#175'b#'#200#248#159#249#7'P'#175#19'N'
+#224#160'"'#1#0#0#0#0'IEND'#174'B`'#130
]);

View File

@ -1,394 +0,0 @@
{ jdbcurrencyedit
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 jdbcurrencyedit;
{$mode objfpc}{$H+}
interface
uses
Classes, LResources, Controls, StdCtrls, DB, DBCtrls, LMessages, LCLType, Dialogs,
SysUtils,jinputconsts;
type
{ TJDBCurrencyEdit }
TJDBCurrencyEdit = class(TCustomEdit)
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 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 currencydbicon.lrs}
RegisterComponents('Data Controls', [TJDBCurrencyEdit]);
end;
{ TJDBCurrencyEdit }
procedure TJDBCurrencyEdit.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 TJDBCurrencyEdit.getDecimals: integer;
begin
Result := fDecimales;
end;
procedure TJDBCurrencyEdit.setDecimals(AValue: integer);
begin
if (AValue >= 0) and (AValue < 5) then
fDecimales := AValue;
end;
procedure TJDBCurrencyEdit.UpdateData(Sender: TObject);
var
theValue: currency;
begin
if FDataLink.Field <> nil then
begin
if IsValidCurrency(Text) then
begin
theValue := StrToCurr(Text);
if fDecimales > 0 then
theValue := ScaleTo(theValue, fDecimales);
Text := CurrToStr(theValue);
FDataLink.Field.Value := theValue;
end
else
begin
if FDataLink.Field <> nil then
begin
ShowMessage(Format(SInvalidNumber, [Caption]));
Caption := FDataLink.Field.AsString;
SelectAll;
SetFocus;
end;
end;
end
else
Text := '';
end;
procedure TJDBCurrencyEdit.FocusRequest(Sender: TObject);
begin
SetFocus;
end;
function TJDBCurrencyEdit.GetDataField: string;
begin
Result := FDataLink.FieldName;
end;
function TJDBCurrencyEdit.GetDataSource: TDataSource;
begin
Result := FDataLink.DataSource;
end;
function TJDBCurrencyEdit.GetField: TField;
begin
Result := FDataLink.Field;
end;
function TJDBCurrencyEdit.IsReadOnly: boolean;
begin
if FDatalink.Active then
Result := not FDatalink.CanModify
else
Result := False;
end;
function TJDBCurrencyEdit.getFormat: string;
begin
Result := fFormat;
end;
procedure TJDBCurrencyEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
if not Focused then
formatInput;
end;
procedure TJDBCurrencyEdit.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 TJDBCurrencyEdit.GetReadOnly: boolean;
begin
Result := FDataLink.ReadOnly;
end;
procedure TJDBCurrencyEdit.SetReadOnly(Value: boolean);
begin
inherited;
FDataLink.ReadOnly := Value;
end;
procedure TJDBCurrencyEdit.SetDataField(const Value: string);
begin
FDataLink.FieldName := Value;
end;
procedure TJDBCurrencyEdit.SetDataSource(Value: TDataSource);
begin
if not (FDataLink.DataSourceFixed and (csLoading in ComponentState)) then
ChangeDataSource(Self, FDataLink, Value);
end;
procedure TJDBCurrencyEdit.CMGetDataLink(var Message: TLMessage);
begin
Message.Result := PtrUInt(FDataLink); // Delphi dbctrls compatibility?
end;
function TJDBCurrencyEdit.IsValidCurrency(const Value: string): boolean;
begin
if StrToCurrDef(Value, MaxCurrency) = MaxCurrency then
Result := False
else
Result := True;
end;
function TJDBCurrencyEdit.ScaleTo(const AValue: currency;
const NDecimals: integer): currency;
begin
Result := round(AValue * power(10, NDecimals)) / power(10, NDecimals);
end;
procedure TJDBCurrencyEdit.Loaded;
begin
inherited Loaded;
if (csDesigning in ComponentState) then
DataChange(Self);
end;
procedure TJDBCurrencyEdit.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 TJDBCurrencyEdit.ActiveChange(Sender: TObject);
begin
if FDatalink.Active then
datachange(Sender)
else
Text := '';
end;
procedure TJDBCurrencyEdit.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 TJDBCurrencyEdit.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 <> #0) and (not IsReadOnly) then
FDatalink.Edit;
inherited KeyPress(Key);
end;
procedure TJDBCurrencyEdit.DoEnter;
begin
if FDataLink.Field <> nil then
Caption := FDataLink.Field.AsString;
inherited DoEnter;
end;
constructor TJDBCurrencyEdit.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 TJDBCurrencyEdit.Destroy;
begin
FDataLink.Free;
FDataLink := nil;
inherited Destroy;
end;
procedure TJDBCurrencyEdit.EditingDone;
begin
inherited EditingDone;
if DataSource.State in [dsEdit, dsInsert] then
UpdateData(self);
end;
end.

View File

@ -1,353 +0,0 @@
{ jdbdateedit
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 jdbdateedit;
{$mode objfpc}{$H+}
interface
uses
Classes, LResources, Controls, StdCtrls, DB, DBCtrls, LMessages, LCLType, Dialogs,
SysUtils, jinputconsts;
type
{ TJDBDateEdit }
TJDBDateEdit = class(TCustomEdit)
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;
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 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 datedbicon.lrs}
RegisterComponents('Data Controls', [TJDBDateEdit]);
end;
{ TJDBDateEdit }
procedure TJDBDateEdit.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 TJDBDateEdit.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(Format(SInvalidDate, [Caption]));
Caption := FDataLink.Field.AsString;
SelectAll;
SetFocus;
end;
end
else
Text := '';
end;
procedure TJDBDateEdit.FocusRequest(Sender: TObject);
begin
SetFocus;
end;
function TJDBDateEdit.GetDataField: string;
begin
Result := FDataLink.FieldName;
end;
function TJDBDateEdit.GetDataSource: TDataSource;
begin
Result := FDataLink.DataSource;
end;
function TJDBDateEdit.GetField: TField;
begin
Result := FDataLink.Field;
end;
function TJDBDateEdit.IsReadOnly: boolean;
begin
if FDatalink.Active then
Result := not FDatalink.CanModify
else
Result := False;
end;
function TJDBDateEdit.getFormat: string;
begin
Result := fFormat;
end;
procedure TJDBDateEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
if not Focused then
formatInput;
end;
procedure TJDBDateEdit.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 TJDBDateEdit.GetReadOnly: boolean;
begin
Result := FDataLink.ReadOnly;
end;
procedure TJDBDateEdit.SetReadOnly(Value: boolean);
begin
inherited;
FDataLink.ReadOnly := Value;
end;
procedure TJDBDateEdit.SetDataField(const Value: string);
begin
FDataLink.FieldName := Value;
end;
procedure TJDBDateEdit.SetDataSource(Value: TDataSource);
begin
if not (FDataLink.DataSourceFixed and (csLoading in ComponentState)) then
ChangeDataSource(Self, FDataLink, Value);
end;
procedure TJDBDateEdit.CMGetDataLink(var Message: TLMessage);
begin
Message.Result := PtrUInt(FDataLink); // Delphi dbctrls compatibility?
end;
procedure TJDBDateEdit.Loaded;
begin
inherited Loaded;
if (csDesigning in ComponentState) then
DataChange(Self);
end;
procedure TJDBDateEdit.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 TJDBDateEdit.ActiveChange(Sender: TObject);
begin
if FDatalink.Active then
datachange(Sender)
else
Text := '';
end;
procedure TJDBDateEdit.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 TJDBDateEdit.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 TJDBDateEdit.DoEnter;
begin
if FDataLink.Field <> nil then
Caption := FDataLink.Field.AsString;
inherited DoEnter;
end;
constructor TJDBDateEdit.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 TJDBDateEdit.Destroy;
begin
FDataLink.Free;
FDataLink := nil;
inherited Destroy;
end;
procedure TJDBDateEdit.EditingDone;
begin
inherited EditingDone;
if DataSource.State in [dsEdit, dsInsert] then
UpdateData(self);
end;
end.

View File

@ -1,352 +0,0 @@
{ TJDBDateTimeEdit
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 JDBDateTimeEdit;
{$mode objfpc}{$H+}
interface
uses
Classes, LResources, Controls, StdCtrls, DB, DBCtrls, LMessages, LCLType, Dialogs,
SysUtils, jinputconsts;
type
{ TJDBDateTimeEdit }
TJDBDateTimeEdit = class(TCustomEdit)
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;
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 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 jdbdatetimeedit_icon.lrs}
RegisterComponents('Data Controls', [TJDBDateTimeEdit]);
end;
procedure TJDBDateTimeEdit.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 TJDBDateTimeEdit.UpdateData(Sender: TObject);
var
theValue: string;
begin
if FDataLink.Field <> nil then
begin
theValue := NormalizeDateTime(Text, FDataLink.Field.AsDateTime);
if Text = '' then
FDataLink.Field.Text := Text
else
if IsValidDateTimeString(theValue) then
begin
FDataLink.Field.Text := theValue;
end
else
begin
ShowMessage(Format(SInvalidDateTime, [Caption]));
Caption := FDataLink.Field.AsString;
SelectAll;
SetFocus;
end;
end
else
Text := '';
end;
procedure TJDBDateTimeEdit.FocusRequest(Sender: TObject);
begin
SetFocus;
end;
function TJDBDateTimeEdit.GetDataField: string;
begin
Result := FDataLink.FieldName;
end;
function TJDBDateTimeEdit.GetDataSource: TDataSource;
begin
Result := FDataLink.DataSource;
end;
function TJDBDateTimeEdit.GetField: TField;
begin
Result := FDataLink.Field;
end;
function TJDBDateTimeEdit.IsReadOnly: boolean;
begin
if FDatalink.Active then
Result := not FDatalink.CanModify
else
Result := False;
end;
function TJDBDateTimeEdit.getFormat: string;
begin
Result := fFormat;
end;
procedure TJDBDateTimeEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
if not Focused then
formatInput;
end;
procedure TJDBDateTimeEdit.formatInput;
begin
if FDataLink.Field <> nil then
if (fFormat <> '') and (not FDataLink.Field.IsNull) then
Caption := FormatDateTime(fFormat, FDataLink.Field.AsDateTime)
else
Caption := FDataLink.Field.DisplayText
else
Caption := 'nil';
end;
function TJDBDateTimeEdit.GetReadOnly: boolean;
begin
Result := FDataLink.ReadOnly;
end;
procedure TJDBDateTimeEdit.SetReadOnly(Value: boolean);
begin
inherited;
FDataLink.ReadOnly := Value;
end;
procedure TJDBDateTimeEdit.SetDataField(const Value: string);
begin
FDataLink.FieldName := Value;
end;
procedure TJDBDateTimeEdit.SetDataSource(Value: TDataSource);
begin
if not (FDataLink.DataSourceFixed and (csLoading in ComponentState)) then
ChangeDataSource(Self, FDataLink, Value);
end;
procedure TJDBDateTimeEdit.CMGetDataLink(var Message: TLMessage);
begin
Message.Result := PtrUInt(FDataLink); // Delphi dbctrls compatibility?
end;
procedure TJDBDateTimeEdit.Loaded;
begin
inherited Loaded;
if (csDesigning in ComponentState) then
DataChange(Self);
end;
procedure TJDBDateTimeEdit.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 TJDBDateTimeEdit.ActiveChange(Sender: TObject);
begin
if FDatalink.Active then
datachange(Sender)
else
Text := '';
end;
procedure TJDBDateTimeEdit.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 TJDBDateTimeEdit.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 TJDBDateTimeEdit.DoEnter;
begin
if FDataLink.Field <> nil then
Caption := FDataLink.Field.AsString;
inherited DoEnter;
end;
constructor TJDBDateTimeEdit.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 TJDBDateTimeEdit.Destroy;
begin
FDataLink.Free;
FDataLink := nil;
inherited Destroy;
end;
procedure TJDBDateTimeEdit.EditingDone;
begin
inherited EditingDone;
if DataSource.State in [dsEdit, dsInsert] then
UpdateData(self);
end;
end.

View File

@ -1,49 +0,0 @@
LazarusResources.Add('tjdbdatetimeedit','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#23#14
+#5#13'}'#171#238#233#0#0#3#233'IDATH'#199#181#150']L'#155'U'#28#198#127'oi'
+#233'w'#161#133'A`'#3#198#16'p'#192'p'#3'D'#152#3#9's'#138#155'Qj'#212#152#24
+#227#197#212#11#141#17'c'#194'.'#184'1Q'#226#136#154#204#152'x'#161#153#201
+'LH'#156'.i6G'#22#199#220'`+'#3#17#28#31#11#3#25#155'P`PXi'#161'P'#250'y'#188
+' L'#176'lCtOrr'#206#249#231#228#249#229'}'#206#251#190#231'HB'#8'6'#162#166
+#227#159#150'+#'#220'5J'#149'og'#132'"B'#31#12#8'<'#243#30#199#188#155'6O@]'
+#247#252'['#181#173#0#210'J'#192#247#151'n'#137'oN'#223'X'#211#240#205'g'#183
+#241'JI'#130#4'p'#233#199'O'#190#138#142#158'=hL'#169#140'T'#26'6'#161#212#24
+#17'"'#132#219'9'#142'c'#180#143#241#254#11#243#174'9E'#221#203'U_~$'#9'!V'
+#25#127#241#206'#'#228'$'#235#184':'#226#198#238#244'bw'#249#176';'#189#156
+#180#142#1#240'A'#137#157#204#132'IL)'#251#153'Z'#208#211';'#228#194'>'#179
+'@ (0'#234'Ud'#167#233'0'#138#27'\'#187#248#29#147#246'@'#181'$'#132'`'#239
+#161#22#145#155'n"5^MN'#138#158#184'h'#229'*s'#187#203#199#252'b'#16#149#223
+#142'ys'#3'iEo'#211'7'#174'd'#218#233'%'#247'!'#19#209#6#25#2#9#135'+H{'#255
+#20':'#165#140#237#134#1':N'#31'['#144#1'lK2'#208'3'#232#224#164'ul'#149#233
+'J'#243#158'A'#7#169#161'NL'#201#229'Ly'#12'L8'#22'1'#151'm'#197#164#23'8'
+#220'nt'#6'-'#201'I'#6'*'#159'Lcr.'#196#180','#139#248#212#205#26'9@'#204'h'
+#19'1'#210'R'#214']'#13#191#135#229#175#4#30#149' YmCkz'#138#243#253#14#242
+#178#226'X'#8#8#20#10#5#141'?[x'#241#5'3j'#149#138#198#230#203'de'#228#209
+#218'9LEF!'#242'e'#147#170'*'#243'}'#223#156'k'#231'>C'#165'52>}'#155'}1j'
+#188'A'#129'V'#163'atd'#132#198#243#205#244'vw'#177#247#233#10#140'q'#26'n9'
+#22#137'*'#218#250'7`YG'#142'X'#238#10'(M'#245#18#10'y'#241#248'Bx'#131'K5'
+#187'k'#14#173'NGow'#23#7'*'#205'l'#207#217#193#176#203#143#223#31'B'#132'|'
+#225#128'{=I'#231#169'!\'#147#127#16#165'M'#228#230#196#2#233'['#162'@'#166
+'"'#175#160#136#135'w'#228#160#137'2'#224#246#130'mb'#30#131'V'#198#204'X7'
+#178#181#140#204#181#131#152'k'#7#195'j'#214#145#24'l}'#205#20'f'#170'i'#189
+'2'#137'B'#9'Z'#149#130'=%'#187#137'5'#26'P'#2':'#21#252'v'#197'Ni'#182#140
+#225#158#203#225#128#127#26#175'T|'#214'>F'#175#219'0'#249#219'H'#210#187#249
+#246#196#0#195'cN$'#175#31#201#227'g'#196#230#228#235#31#250'IV'#219#217#228
+'9'#131'mh~1,"KM:'#245'->N4'#13#135#1#142#183'z'#200'U?'#134#236#220'O'#236
+'*s'#147#24'S'#200#153'&'''#206#185' '#193#144'@'#175#129#226',A'#172#247','
+#237'g'#219#241'G'#198#212#201#215#251#239#177#212#164#3'P'#223#146#194#133
+#214#0#158#134'&b'#19#173'Tdd'#19#157#144#2'"'#192#237#209'A'#254'l'#187#202
+#205'i'#5#153#187'_'#162#236#185#131#31#174#27'P'#223#226#227#213#199'#'#1
+#232#245#238#164#234#181'b'#6':~'#161#185#161#27#181#188#3#191#223#143#206#24
+'G'#247#245'E'#14'}'#252'9'#26#253#210#218'u'#3#150'"K'#185'37'#197'o'#161
+#248#192#235#252':h'#225#153#253#187'x'#162't'#15#5#5#5'ttt'#0'0'#235#180#173
+#13'X'#185#201#203'cKM:'#150#154#244'U'#243#245'J~'#183#172#239#181#15#255'F'
+#242#245'|'#193#255'Er'#128#195#135#223#149#154'/Z'#197#3'!'#8'!'#194#218#209
+#163#199#196#251#239#189'!'#132#16#162#188#218'*'#252#129#160'('#175#182#222
+'i'#203#245#229#177#16'B'#228#231#231#175#234']3#B'#8'q'#127#192'F'#181#12
+#144#214':'#244'g'#157#182#255'%.Ct'#146'$m'#244'V'#177'^'#201'x'#192#250#11
+#171'TF'#11#166#129'pf'#0#0#0#0'IEND'#174'B`'#130
]);

View File

@ -1,393 +0,0 @@
{ JDBFloatEdit
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 JDBFloatEdit;
{$mode objfpc}{$H+}
interface
uses
Classes, LResources, Controls, StdCtrls, DB, DBCtrls, LMessages, LCLType, Dialogs,
SysUtils, jinputconsts;
type
{ TJDBFloatEdit }
TJDBFloatEdit = class(TCustomEdit)
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 IsValidFloat(const Value: string): boolean;
function ScaleTo(const AValue: double; const NDecimals: integer): double;
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 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 jdbfloatedit_icon.lrs}
RegisterComponents('Data Controls', [TJDBFloatEdit]);
end;
procedure TJDBFloatEdit.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 TJDBFloatEdit.getDecimals: integer;
begin
Result := fDecimales;
end;
procedure TJDBFloatEdit.setDecimals(AValue: integer);
begin
if AValue >= 0 then
fDecimales := AValue;
end;
procedure TJDBFloatEdit.UpdateData(Sender: TObject);
var
theValue: double;
begin
if FDataLink.Field <> nil then
begin
if IsValidFloat(Text) then
begin
theValue := StrToFloat(Text);
if fDecimales > 0 then
theValue := ScaleTo(theValue, fDecimales);
Text := FloatToStr(theValue);
FDataLink.Field.Value := theValue;
end
else
begin
if FDataLink.Field <> nil then
begin
ShowMessage(Format(SInvalidNumber, [Caption]));
Caption := FDataLink.Field.AsString;
SelectAll;
SetFocus;
end;
end;
end
else
Text := '';
end;
procedure TJDBFloatEdit.FocusRequest(Sender: TObject);
begin
SetFocus;
end;
function TJDBFloatEdit.GetDataField: string;
begin
Result := FDataLink.FieldName;
end;
function TJDBFloatEdit.GetDataSource: TDataSource;
begin
Result := FDataLink.DataSource;
end;
function TJDBFloatEdit.GetField: TField;
begin
Result := FDataLink.Field;
end;
function TJDBFloatEdit.IsReadOnly: boolean;
begin
if FDatalink.Active then
Result := not FDatalink.CanModify
else
Result := False;
end;
function TJDBFloatEdit.getFormat: string;
begin
Result := fFormat;
end;
procedure TJDBFloatEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
if not Focused then
formatInput;
end;
procedure TJDBFloatEdit.formatInput;
begin
if FDataLink.Field <> nil then
//FDataLink.Field.DisplayText -> formatted (tdbgridcolumns/persistent field DisplayFormat
if fFormat <> '' then
Caption := FormatFloat(fFormat, FDataLink.Field.AsFloat)
else
Caption := FDataLink.Field.DisplayText
else
Caption := 'nil';
end;
function TJDBFloatEdit.GetReadOnly: boolean;
begin
Result := FDataLink.ReadOnly;
end;
procedure TJDBFloatEdit.SetReadOnly(Value: boolean);
begin
inherited;
FDataLink.ReadOnly := Value;
end;
procedure TJDBFloatEdit.SetDataField(const Value: string);
begin
FDataLink.FieldName := Value;
end;
procedure TJDBFloatEdit.SetDataSource(Value: TDataSource);
begin
if not (FDataLink.DataSourceFixed and (csLoading in ComponentState)) then
ChangeDataSource(Self, FDataLink, Value);
end;
procedure TJDBFloatEdit.CMGetDataLink(var Message: TLMessage);
begin
Message.Result := PtrUInt(FDataLink); // Delphi dbctrls compatibility?
end;
function TJDBFloatEdit.IsValidFloat(const Value: string): boolean;
begin
if StrToFloatDef(Value, MaxDouble) = MaxDouble then
Result := False
else
Result := True;
end;
function TJDBFloatEdit.ScaleTo(const AValue: double; const NDecimals: integer): double;
begin
Result := round(AValue * power(10, NDecimals)) / power(10, NDecimals);
end;
procedure TJDBFloatEdit.Loaded;
begin
inherited Loaded;
if (csDesigning in ComponentState) then
DataChange(Self);
end;
procedure TJDBFloatEdit.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 TJDBFloatEdit.ActiveChange(Sender: TObject);
begin
if FDatalink.Active then
datachange(Sender)
else
Text := '';
end;
procedure TJDBFloatEdit.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 TJDBFloatEdit.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 <> #0) and (not IsReadOnly) then
FDatalink.Edit;
inherited KeyPress(Key);
end;
procedure TJDBFloatEdit.DoEnter;
begin
if FDataLink.Field <> nil then
Caption := FDataLink.Field.AsString;
inherited DoEnter;
end;
constructor TJDBFloatEdit.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 TJDBFloatEdit.Destroy;
begin
FDataLink.Free;
FDataLink := nil;
inherited Destroy;
end;
procedure TJDBFloatEdit.EditingDone;
begin
inherited EditingDone;
if DataSource.State in [dsEdit, dsInsert] then
UpdateData(self);
end;
end.

View File

@ -1,28 +0,0 @@
LazarusResources.Add('tjdbfloatedit','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#27#10
+#19'!'#30'4 '#185#0#0#2#14'IDATH'#199#213'V1k'#19'a'#24'~'#190' -'#130#166
+#135#154#132#14#177'4 '#6'L'#235#144'C(G'#151't'#19#127'@!'#224#16#236#228' '
+'.'#233'P'#144'.'#29'n'#17#5#183#210#161'C'#209'U'#208#241#22#155'"'#148#155
+#210#22#132'`h'#27#162'p'#150#154#164#21#218#208#220#227#160#223'y'#151'\h.m'
+#6#31#248#184'{'#143#151#231#249#190#231'}'#239#229#19'$1H\q'#7#239#214#191
+'s'#249'C'#217'7q'#238'Q'#2#179#211#163'"'#168#128' '#233'!~'#253#244'>R'#183
+#175'a{'#255#24'V'#237#20'V'#189#9#171'v'#138#247#133'j_B'#130'$f'#230'78y'
+#231#6#198'cW'#145#26#187#142#168'2'#236'!'#183#234'M'#252':i'#225#248#228#12
+#229'J'#3#134#174#137'@'#22'%'#226'a'#20'K'#135'('#150#128#168#146#0#128#14
+#242'b'#233#16'2'#183#175#26'LMD'#16#29#25'B'#183#26'LMD'#156'S'#4#22'(W'#26
+#136')'#17#0#192'B6'#137#204#228#205#142#26'X'#245'&dn`'#129'D<'#140#205#157
+#3#180'l"5'#150#244'M'#252#188#245#227'b'#22'='#184'w'#11#209#145'!,'#173'}'
+#193#210#218#127'd'#145' '#137#185'7['#220#171#30#161'e'#19#11#217'$v'#205
+#143#151#242#23#231'r'#143#133#175'E'#217#187#192'vq'#253'B'#228#139#139'/'
+#254'Y'#180'W=BL'#25'v,'#218'5'#191#2#0'^'#190'Z'#238'['#160'Q'#171#0#0'B'#0
+#144'{8'#142#205#157#3'g'#28#184'13'#191#209#17#203'og-'#219#19#171#170#234
+'y'#2#0'H:'#235#237#167'o'#204#228#11'\YY'#229#243'gOH'#146#153'|'#129'~'#200
+#228#11#180'm'#219#19#147'd:'#157'&I'#214#127#238#147#228#159#19'H'#204'N'
+#143#138#243#230'L'#251'x'#151#155#235'i\'#159'G,'#132'pl2t'#205'c'#161#140
+#219#17#234#185#159#255#146#203#167#20'5t'#13#134#174'u'#212'*'#176#128#187
+#200'r'#183'n'#177'n'#8#5'!'#246#235'$'#249'n'#232#26'TU'#133'i'#154#221#187
+'H.w'#23#181'wI'#175#144']$'#252':'#160'Q'#171'\'#202'M '#172#196#133#24#244
+#173'"'#132#1#227'7'#130#187#166#12#191#254#238#196#0#0#0#0'IEND'#174'B`'#130
]);

View File

@ -1,352 +0,0 @@
{ jdbintegeredit
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 jdbintegeredit;
{$mode objfpc}{$H+}
interface
uses
Classes, LResources, Controls, StdCtrls, DB, DBCtrls, LMessages, LCLType, Dialogs,
SysUtils, jinputconsts;
type
{ TJDBIntegerEdit }
TJDBIntegerEdit = class(TCustomEdit)
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 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 integerdbicon.lrs}
RegisterComponents('Data Controls', [TJDBIntegerEdit]);
end;
{ TJDBIntegerEdit }
procedure TJDBIntegerEdit.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 TJDBIntegerEdit.UpdateData(Sender: TObject);
begin
if FDataLink.Field <> nil then
begin
if IsValidInteger(Caption) then
FDataLink.Field.Text := Text
else
begin
ShowMessage(Format(SInvalidNumber, [Caption]));
Caption := FDataLink.Field.AsString;
SelectAll;
SetFocus;
end;
end
else
Text := '';
end;
procedure TJDBIntegerEdit.FocusRequest(Sender: TObject);
begin
SetFocus;
end;
function TJDBIntegerEdit.GetDataField: string;
begin
Result := FDataLink.FieldName;
end;
function TJDBIntegerEdit.GetDataSource: TDataSource;
begin
Result := FDataLink.DataSource;
end;
function TJDBIntegerEdit.GetField: TField;
begin
Result := FDataLink.Field;
end;
function TJDBIntegerEdit.IsReadOnly: boolean;
begin
if FDatalink.Active then
Result := not FDatalink.CanModify
else
Result := False;
end;
function TJDBIntegerEdit.getFormat: string;
begin
Result := fFormat;
end;
procedure TJDBIntegerEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
if not Focused then
formatInput;
end;
procedure TJDBIntegerEdit.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 TJDBIntegerEdit.GetReadOnly: boolean;
begin
Result := FDataLink.ReadOnly;
end;
procedure TJDBIntegerEdit.SetReadOnly(Value: boolean);
begin
inherited;
FDataLink.ReadOnly := Value;
end;
procedure TJDBIntegerEdit.SetDataField(const Value: string);
begin
FDataLink.FieldName := Value;
end;
procedure TJDBIntegerEdit.SetDataSource(Value: TDataSource);
begin
if not (FDataLink.DataSourceFixed and (csLoading in ComponentState)) then
ChangeDataSource(Self, FDataLink, Value);
end;
procedure TJDBIntegerEdit.CMGetDataLink(var Message: TLMessage);
begin
Message.Result := PtrUInt(FDataLink); // Delphi dbctrls compatibility?
end;
function TJDBIntegerEdit.IsValidInteger(const Value: string): boolean;
begin
if StrToIntDef(Value, MaxInt) = MaxInt then
Result := False
else
Result := True;
end;
procedure TJDBIntegerEdit.Loaded;
begin
inherited Loaded;
if (csDesigning in ComponentState) then
DataChange(Self);
end;
procedure TJDBIntegerEdit.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 TJDBIntegerEdit.ActiveChange(Sender: TObject);
begin
if FDatalink.Active then
datachange(Sender)
else
Text := '';
end;
procedure TJDBIntegerEdit.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 TJDBIntegerEdit.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 TJDBIntegerEdit.DoEnter;
begin
if FDataLink.Field <> nil then
Caption := FDataLink.Field.AsString;
inherited DoEnter;
end;
constructor TJDBIntegerEdit.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 TJDBIntegerEdit.Destroy;
begin
FDataLink.Free;
FDataLink := nil;
inherited Destroy;
end;
procedure TJDBIntegerEdit.EditingDone;
begin
inherited EditingDone;
if DataSource.State in [dsEdit, dsInsert] then
UpdateData(self);
end;
end.

View File

@ -1,350 +0,0 @@
{ TJDBTimeEdit
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 JDBTimeEdit;
{$mode objfpc}{$H+}
interface
uses
Classes, LResources, Controls, StdCtrls, DB, DBCtrls, LMessages, LCLType, Dialogs,
SysUtils, jcontrolutils, jinputconsts;
type
TJDBTimeEdit = class(TCustomEdit)
private
{ Private declarations }
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;
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 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 jdbtimeedit_icon.lrs}
RegisterComponents('Data Controls', [TJDBTimeEdit]);
end;
{ TJDBDateEdit }
procedure TJDBTimeEdit.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 TJDBTimeEdit.UpdateData(Sender: TObject);
var
theValue: string;
begin
if FDataLink.Field <> nil then
begin
theValue := NormalizeTime(Text, FDataLink.Field.AsDateTime);
if Text = '' then
begin
Field.Value := Null;
end
else
if IsValidTimeString(theValue) then
begin
FDataLink.Field.Text := theValue;
end
else
begin
ShowMessage(Format(SInvalidTime, [Text]));
Caption := FDataLink.Field.AsString;
SelectAll;
SetFocus;
end;
end
else
Text := '';
end;
procedure TJDBTimeEdit.FocusRequest(Sender: TObject);
begin
SetFocus;
end;
function TJDBTimeEdit.GetDataField: string;
begin
Result := FDataLink.FieldName;
end;
function TJDBTimeEdit.GetDataSource: TDataSource;
begin
Result := FDataLink.DataSource;
end;
function TJDBTimeEdit.GetField: TField;
begin
Result := FDataLink.Field;
end;
function TJDBTimeEdit.IsReadOnly: boolean;
begin
if FDatalink.Active then
Result := not FDatalink.CanModify
else
Result := False;
end;
function TJDBTimeEdit.getFormat: string;
begin
Result := fFormat;
end;
procedure TJDBTimeEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
if not Focused then
formatInput;
end;
procedure TJDBTimeEdit.formatInput;
begin
if FDataLink.Field <> nil then
if (fFormat <> '') and (not FDataLink.Field.IsNull) then
Caption := FormatDateTime(fFormat, FDataLink.Field.AsDateTime)
else
Caption := FDataLink.Field.DisplayText
else
Caption := 'nil';
end;
function TJDBTimeEdit.GetReadOnly: boolean;
begin
Result := FDataLink.ReadOnly;
end;
procedure TJDBTimeEdit.SetReadOnly(Value: boolean);
begin
inherited;
FDataLink.ReadOnly := Value;
end;
procedure TJDBTimeEdit.SetDataField(const Value: string);
begin
FDataLink.FieldName := Value;
end;
procedure TJDBTimeEdit.SetDataSource(Value: TDataSource);
begin
if not (FDataLink.DataSourceFixed and (csLoading in ComponentState)) then
ChangeDataSource(Self, FDataLink, Value);
end;
procedure TJDBTimeEdit.CMGetDataLink(var Message: TLMessage);
begin
Message.Result := PtrUInt(FDataLink); // Delphi dbctrls compatibility?
end;
procedure TJDBTimeEdit.Loaded;
begin
inherited Loaded;
if (csDesigning in ComponentState) then
DataChange(Self);
end;
procedure TJDBTimeEdit.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 TJDBTimeEdit.ActiveChange(Sender: TObject);
begin
if FDatalink.Active then
datachange(Sender)
else
Text := '';
end;
procedure TJDBTimeEdit.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 TJDBTimeEdit.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 TJDBTimeEdit.DoEnter;
begin
if FDataLink.Field <> nil then
Caption := FDataLink.Field.AsString;
inherited DoEnter;
end;
constructor TJDBTimeEdit.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 TJDBTimeEdit.Destroy;
begin
FDataLink.Free;
FDataLink := nil;
inherited Destroy;
end;
procedure TJDBTimeEdit.EditingDone;
begin
inherited EditingDone;
if DataSource.State in [dsEdit, dsInsert] then
UpdateData(self);
end;
end.

View File

@ -1,53 +0,0 @@
LazarusResources.Add('tjdbtimeedit','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#23#14
+#4#1'm'#6#147#131#0#0#4'KIDATH'#199#181#150'mLSW'#24#199#127#183'/'#180#244
+#189'E'#218#225'DT|A('#206'h'#135'/h'#230#192')q.'#147'mQ'#19#191','#190#236
+#195#246'a/'#31'`'#153#31'7'#179#17#179'e'#203#150'}1'#146'hb6'#183'%'#142
+#197#152'ME'#167#22'$'#216'M'#17'T'#156#10#2#130'Pk'#161#208#210#23#218'{'
+#246#129#148#180#163'.'#234#178#127'rr'#238#185#185#247#249'?'#247'w'#158'{'
+#206#145#132#16'<'#169'~?'#186#191'B'#163#12#238#213'hcK'#149'j'#165'1'#17#23
+#132'Ca'#127'(HK8'#158']'#247#234'['#251'.&'#159#149'R'#13#190#191'p_'#28'8'
+#222#149'1'#232#158#205#243#216#190'6O'#186#240#227#167#223'Z,'#163#187#172#5
+'['#178'4'#166'\4:+B'#200#4'G'#6#240#223#187#206'@'#231#217'P`L]'#183#245#189
+#175'?'#158'2H'#13#252#213';'#207#225#156'm'#160#163'7'#136'w$'#138'7'#16#195
+';'#18#165#193#221#207#198'Y'#183'y}u'#24'['#193'&'#30#140#27'i'#191#19#192
+';<N<!'#176#26#181#148#20#26#176#138'.n'#156'?'#204#144'7^'#243#230'G'#7#246
+'KB'#8'*k'#155#196#146#5'6'#230':'#178'q'#22#24#177'[4i'#193#189#129#24'YQ/U'
+#246'_(\'#241'6'#215#7'4'#248'F'#162','#153'o'#195'bR '#144#240#7#18#180'v>'
+#192#160'Q'#176#216't'#19#207#241'C'#227'a'#165'm'#141#2'`^'#190#137#171#183
+#252'4'#184#251#211#130'&'#251'P$'#193'3'#145'Vl'#249#21'<'#8#155#24#244'G'
+#168'^7'#7#155'Q'#224#15#6'1'#152#244#204#206'7'#177'e}!Cc2>E1'#142#185#207
+#234#18#227#195#31#168#146#140'W'#149#230'b7g'#241#168'9'#216#232#244#162#183
+'m'#224'L'#167#159'e'#197'v'#198#227#2#181'Z'#205#169#223#142#241#198'k'#213
+'dk'#181#156':'#215'L'#241#194'e\'#252#163#135#170#133'e'#220#189#241#195#26
+#21'@W'#223'('#14'K.'#0'{w'#20'Q'#177'$g'#218#28'('#135'#h'#245'V'#6'|'#15'y'
+')'''#155'hB'#160#215#233#184#215#219#203#169'3'#231'ho'#187'B'#229#198'*'
+#172'v'#29#247#253#17#204'+'#231#160'Dr'#168#146#136'Z'#175#249'H'#200#2'gAQ'
+#198'/'#136#133'c'#200'r'#148'pL&'#154#152#188#231#13#140#161'7'#24'ho'#187
+#194#203'['#170'Y'#236','#165'''0'#193#196#132#140#144'c'#8'Y0'#133#168#172
+'d'#6'vs'#22#251#142't'#178#239#200't'#131#221'3U'#4#134#254#194#172#159'I'
+#247#224'8'#11'f'#153'A'#161'e'#153'k%E'#165'Ntf'#19#193'('#244#13#134'0'#233
+#21#12#247#183#17#137'''|'#143#141#200#215'U@'#223#245's'#148#21#237#228#252
+#229'!'#138#11#205'h'#149'j'#214#172']'#13#18'$dPj'#225#210'e//'#148'('#232
+#249#179#153#9#161'j'#201#136#168#190#254'pZ'#246#6#0#173#142#158#155'='#172
+'(l!'#223'XB'#253'O7'#217#240#188#131#249#14'='#8#232#245#134'8'#222'2'#200
+#236'l'#31#185#225#179'4w'#133#145#178's&'#255#131'='#223#180#11#135'E'#131
+#221#156'E'#131#187#159#29#139#238#208'q'#245#194'4L9Z'#153'y'#214'1'#150#174
+'{'#145'!E'#25#23#175#197#25#25'K'#144#144#5'F'#29#172'*'#22#204#136#158#228
+#210#201'V'#22#149'oe'#221'+;%'#21'@O'#255#24#14#139'f'#10#209']'#207#29#0
+#190#248#242#192'4'#19#207#217#159'i9q'#148#156'<7U'#11'K'#176#228#21#128#136
+#243#240#222'-'#238#182't'#208#237'SSZ'#177#11'g'#217'J'#128#201'I'#222#185
+'i.'#245''''#186'3VQem'#19#141'u'#229'S'#227#218'_s'#177'J'#219#216'e'#236
+#166#173#169#131#208#168#7#0#189#201'J'#219#237#8#181#159'|'#206#230#234'm'
+#156'9}l'#242#5'!'#196'T'#251#238#252#128#168#168'q'#139#131#7#15#137#247#223
+#221'-'#132#16#162#162#198#157#214'''UQ'#227#22#178','#167#141#133#16'b'#249
+#242#229'B'#8'!'#2#195#189'B'#8#129'"5'#219#237'k'#243#164#198#186'r'#233#223
+#150#234#127'.'#239#201#228#30'%'#213#227#238#1#167'?['#157#17'[em'#19'@'#26
+#198'T)'#30#215'`'#253#135#205#147#27#136'$'#165'e'#223'XWNc]'#249#148#209'S'
+#27'd'#202'>'#213#236'?#JE'#144#138'%'#245#218#229'r'#225#241'xp'#185'\'#153
+#171'('#217'R'#171#232'i'#149#172'")S'#5#140#142#244'='#249'I '#131'L'#150'|'
+'Iz'#154'S'#197#147'H'#193#255#172#191#1#24#252#148'+'#194#194#231'$'#0#0#0#0
+'IEND'#174'B`'#130
]);

View File

@ -1,230 +0,0 @@
{ JFloatEdit
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 JFloatEdit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, StdCtrls, Graphics,
Dialogs, jinputconsts;
type
{ TJFloatEdit }
TJFloatEdit = class(TCustomEdit)
private
{ Private declarations }
theValue: double;
fFormat: string;
fDecimals: integer;
function getDecimals: integer;
function getFormat: string;
function getValue: double;
procedure formatInput;
procedure setDecimals(const AValue: integer);
procedure setFormat(const AValue: string);
function scaleTo(const AValue: double; const NDecimals: integer): double;
function IsValidFloat(const Value: string): boolean;
procedure setValue(const AValue: double);
protected
{ Protected declarations }
procedure DoEnter; override;
procedure DoExit; override;
procedure KeyPress(var Key: char); override;
public
{ Public declarations }
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property DisplayFormat: string read getFormat write setFormat;
property Decimals: integer read getDecimals write setDecimals;
property Value: double read getValue write setValue;
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 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 jfloatedit_icon.lrs}
RegisterComponents('Additional', [TJFloatEdit]);
end;
function TJFloatEdit.getDecimals: integer;
begin
Result := fDecimals;
end;
function TJFloatEdit.getFormat: string;
begin
Result := fFormat;
end;
function TJFloatEdit.getValue: double;
begin
Result := theValue;
end;
procedure TJFloatEdit.formatInput;
begin
Caption := FormatFloat(DisplayFormat, theValue);
end;
procedure TJFloatEdit.setDecimals(const AValue: integer);
begin
if (AValue >= 0) and (AValue < 12) then
fDecimals := AValue;
end;
procedure TJFloatEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
formatInput;
end;
function TJFloatEdit.scaleTo(const AValue: double; const NDecimals: integer): double;
begin
Result := round(AValue * power(10, NDecimals)) / power(10, NDecimals);
end;
function TJFloatEdit.IsValidFloat(const Value: string): boolean;
begin
if StrToFloatDef(Value, MaxDouble) = MaxDouble then
Result := False
else
Result := True;
end;
procedure TJFloatEdit.setValue(const AValue: double);
begin
if fDecimals > 0 then
theValue := scaleTo(AValue, fDecimals)
else
theValue := AValue;
formatInput;
end;
procedure TJFloatEdit.DoEnter;
begin
inherited DoEnter;
Text := FloatToStr(theValue);
SelectAll;
end;
procedure TJFloatEdit.DoExit;
begin
inherited DoExit;
if IsValidFloat(Text) then
theValue := StrToCurr(Text)
else
begin
ShowMessage(Format(SInvalidNumber, [Text]));
SetFocus;
end;
if fDecimals > 0 then
theValue := scaleTo(theValue, fDecimals);
formatInput;
end;
procedure TJFloatEdit.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;
inherited KeyPress(Key);
end;
constructor TJFloatEdit.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
Text := '';
fFormat := '#,0.00';
fDecimals := 2;
formatInput;
end;
destructor TJFloatEdit.Destroy;
begin
inherited Destroy;
end;
end.

View File

@ -1,28 +0,0 @@
LazarusResources.Add('tjfloatedit','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#27#9
+'.'#16'''D'#214'd'#0#0#2#10'IDATH'#199#213#150#177'K[Q'#20#198#127'7'#20#165
+#208#198#208'6'#9#14#169#24'('#13'4'#218'!'#143#130#4#151#184#149#254#1'B'
+#160'C'#168'S'#135#210'%'#14'Bqq'#200'RZ'#232'&'#14#14#162'k'#161#29#179#212
+'HA2E'#133'BhPCZH'#197'&'#209#130#6#243'N'#135#246#166'/'#230#5#243#162#25
+#250#193#229#190#243#184'|'#223#185#223'9'#239#240#148#136#208'O\'#179#6'k'
+#235#223'Y'#252'P'#176'=8'#243'$'#200#244#228#176'c'#1'%"-'#196'o'#159'?$|'
+#247#6#219#251#199#148'+'#167#148#171'u'#202#149'S'#222'gJ='#9')'#17'ajv'#131
+#241'{'#183#24#245'_''<r'#19#159'g'#176#133#188'\'#173#243#235#164#193#241
+#201#25#133'b'#141't*'#234#204#162'`'#192'M.'#127'H.'#15'>O'#16#160#141'<'
+#151'?D'#159#237#169#6#19'c^|C'#3#29'k01'#230'm'#222#194#177'@'#161'X'#195
+#239#241#2'0'#23#15#17#27#191#221'V'#131'r'#181#142'>'#235'X '#24'p'#179#185
+'s@'#195#20#194'#!'#219#131#159#183'~\'#206#162'G'#15#238#224#27#26'`a'#229
+#11#11'+'#255#145'EJD'#152'y'#183#197'^'#233#136#134')'#204#197'C'#236'f?^'
+#201#231#157'H<U'#182#22#197#239#195'vn'#253'R'#228#243#243#175#254'Y'#180'W'
+':'#194#239#25'lZ'#180#155#253#10#192#235'7'#139'='#11#212'*E'#0'\'#0#137#199
+#163'l'#238#28'4'#199#129#21'S'#179#27'm'#177'~w'#214'0[b'#195'0Zv'#0'D'#164
+#185'V?}#'#150#204#176#180#180',/_<'#19#17#145'X2#v'#136'%3b'#154'fK,"'#18
+#137'DDD'#164#250's_D'#228#207#13'4'#166''''#135'/'#156'3'#231#199#187'N'#174
+#171'q}'#17#177'R'#170'i'#147'ND'#219#211')1W'#215#253#252#151'\'#239'Z4'#157
+#138#146'NE'#219'j'#229'X'#192'Zd'#157#173'U'#172#19'\N'#136#237':I?'#167'SQ'
+#12#195' '#155#205'v'#238'"'#189#172']t'#190'K'#186#133#238'"e'#215#1#181'J'
+#241'JF'#133#219#19'P'#170#223#127#21'.'#250#140#223' -'#161#12#164#195#188
+#207#0#0#0#0'IEND'#174'B`'#130
]);

View File

@ -1,199 +0,0 @@
{ JIntegerEdit
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 JIntegerEdit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, StdCtrls, Graphics,
Dialogs, jinputconsts;
type
{ TJIntegerEdit }
TJIntegerEdit = class(TCustomEdit)
private
{ Private declarations }
theValue: integer;
fFormat: string;
function getFormat: string;
function getValue: integer;
procedure setFormat(const AValue: string);
procedure setValue(const AValue: integer);
function IsValidInteger(const Value: string): boolean;
procedure FormatInput;
protected
{ Protected declarations }
procedure DoEnter; override;
procedure DoExit; override;
procedure KeyPress(var Key: char); override;
public
{ Public declarations }
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property DisplayFormat: string read getFormat write setFormat;
property Value: integer read getValue write setValue;
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 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 jintegeredit_icon.lrs}
RegisterComponents('Additional', [TJIntegerEdit]);
end;
{ TJIntegerEdit }
function TJIntegerEdit.getFormat: string;
begin
Result := fFormat;
end;
function TJIntegerEdit.getValue: integer;
begin
Result := theValue;
end;
procedure TJIntegerEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
formatInput;
end;
procedure TJIntegerEdit.setValue(const AValue: integer);
begin
theValue := AValue;
formatInput;
end;
function TJIntegerEdit.IsValidInteger(const Value: string): boolean;
begin
if StrToIntDef(Value, MaxInt) = MaxInt then
Result := False
else
Result := True;
end;
procedure TJIntegerEdit.FormatInput;
begin
Text := FormatFloat(fFormat, theValue);
end;
procedure TJIntegerEdit.DoEnter;
begin
inherited DoEnter;
Text := IntToStr(theValue);
SelectAll;
end;
procedure TJIntegerEdit.DoExit;
begin
inherited DoExit;
if IsValidInteger(Text) then
theValue := StrToInt(Text)
else
begin
ShowMessage(Format(SInvalidNumber, [Text]));
SetFocus;
end;
formatInput;
end;
procedure TJIntegerEdit.KeyPress(var Key: char);
begin
if not (Key in ['0'..'9', #8, #9, '-']) then
Key := #0;
inherited KeyPress(Key);
end;
constructor TJIntegerEdit.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
// Set initial values
Text := '';
DisplayFormat := '0';
Value := 0;
end;
destructor TJIntegerEdit.Destroy;
begin
inherited Destroy;
end;
end.

View File

@ -1,28 +0,0 @@
LazarusResources.Add('tjintegeredit','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#20#9
+#22'3'#202#223#11#187#0#0#1#254'IDATH'#199#213#150#177'k'#19'q'#20#199'?'#191
+' -'#130#166'AMB'#135'X'#26#16#3#166'u'#200'!'#20#233#146'l'#226#31'P'#8'8'#4
+';9'#136'K2'#20#164'K'#7#23'Qp+'#29':'#20']'#11'ut'#177#9'B'#185')mA'#8#134
+#182'!'#10#177#212'$'#173#208#134#228#158#131#220'y'#151'\'#180'I'#154#193'/'
+#252'x'#191#7#143#247#253#189#239'{'#247'8%"'#12#19#151#236#206#187#205'o,o'
+#20']'#3#231#31#134#153#155#29#239#153'@'#137#136'#'#241#235'''w'#137#222#188
+#194#206#193#9#149#234#25#149'Z'#131'J'#245#140#245'l'#185'/"%"$29'#166'o]c2'
+'x'#153#232#196'U'#2#190'QG'#242'J'#173#193#207#211#22''''#167'M'#138#165':'
+#31'^'#220#239'M'#162'p'#200'K'#190'pD'#190#0#1'_'#24#160'#y'#190'p'#132#25
+#219'W'#15'f'#166#252#4#198'F'#186#246'`f'#202'oU'#209'3A'#177'T'''#232#243#3
+#176#144#140#16#159#190#222#209#131'J'#173#129#25#219'3A8'#228'ek'#247#144
+#150'!D''"'#174#129#159#182#191#15'&'#209#189';7'#8#140#141#176#180#246#153
+#165#181#255'H"%"'#204#191#217'f'#191'|L'#203#16#22#146#17#246#244#247#23#242
+'y'#167'R'#143#148#171'D'#201#219#176#147#223#28'('#249#226#226#243'?'#18#237
+#151#143#9#250'F-'#137#246#244'/'#0#188'|'#181#220'7A'#189'Z'#2#192#3#144'z0'
+#201#214#238#161#181#14#236'Hdr'#150'5'#239#205#150#225#240#1'4MsX'#11'"b'
+#157#183#31#191#18'OgYYY'#149'gO'#31#139#136'H<'#157#21';'#226#233#172#24#134
+#225#240'M'#196'b1'#235'^'#251'q "'#242#187#2#19's'#179#227']'#247'L'#251'Z7'
+#31#213#211#186#238#6'3Q"'#147#179#30'`'#202#243#175#197'w.'#2#165'T'#7#161
+#157#232'o$'#158#243'N'#133'=Q;'#225#192#21'4[F'#135','#237#18'i'#154#134#174
+#235#150'u'#157'"'#243#216#167#168'_'#152'S'#164#220'&'#161'^-]'#200#170#240
+#250'BJ'#13#251#175#194#195#144#241#11':\'#164#234#214#16'Q'#217#0#0#0#0'IEN'
+'D'#174'B`'#130
]);

View File

@ -1,196 +0,0 @@
unit JTimeEdit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, StdCtrls, Graphics,
Dialogs, jcontrolutils, jinputconsts;
type
{ TJTimeEdit }
TJTimeEdit = class(TCustomEdit)
private
{ Private declarations }
theValue: TTime;
hasValue: boolean;
fFormat: string;
function getFormat: string;
function getValue: TTime;
procedure setFormat(const AValue: string);
procedure setValue(const AValue: TTime);
procedure FormatInput;
protected
{ Protected declarations }
procedure DoEnter; override;
procedure DoExit; override;
procedure KeyPress(var Key: char); override;
public
{ Public declarations }
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
function isNull: boolean;
property DisplayFormat: string read getFormat write setFormat;
property Value: TTime read getValue write setValue;
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 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 jtimeedit_icon.lrs}
RegisterComponents('Additional', [TJTimeEdit]);
end;
{ TJTimeEdit }
function TJTimeEdit.getFormat: string;
begin
Result := fFormat;
end;
function TJTimeEdit.getValue: TTime;
begin
Result := theValue;
end;
procedure TJTimeEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
formatInput;
end;
procedure TJTimeEdit.setValue(const AValue: TTime);
begin
theValue := AValue;
hasValue := True;
formatInput;
end;
procedure TJTimeEdit.FormatInput;
begin
if hasValue then
Text := FormatDateTime(fFormat, theValue)
else
Text := '';
end;
procedure TJTimeEdit.DoEnter;
begin
inherited DoEnter;
if not hasValue then
Text := ''
else
Text := TimeToStr(theValue);
SelectAll;
end;
procedure TJTimeEdit.DoExit;
begin
inherited DoExit;
Text := NormalizeTime(Text, theValue);
if Length(Text) = 0 then
begin
theValue := 0;
hasValue := False;
end
else
if IsValidTimeString(Text) then
begin
theValue := StrToTime(Text);
hasValue := True;
end
else
begin
ShowMessage(Format(SInvalidTime, [Text]));
SetFocus;
end;
formatInput;
end;
procedure TJTimeEdit.KeyPress(var Key: char);
begin
if not (Key in ['0'..'9', #8, #9, ':']) then
Key := #0;
inherited KeyPress(Key);
end;
constructor TJTimeEdit.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
Text := '';
DisplayFormat := 'hh:mm:ss';
Value := 0;
hasValue := True;
end;
destructor TJTimeEdit.Destroy;
begin
inherited Destroy;
end;
function TJTimeEdit.isNull: boolean;
begin
Result := not hasValue;
end;
end.

View File

@ -1,53 +0,0 @@
LazarusResources.Add('tjtimeedit','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#23#8
+','#30#185#222'Ln'#0#0#4'CIDATH'#199#181#150'[L'#211'W'#28#199'?'#189#209#210
+'B'#175'J'#135'C'#17#241#130'P'#152'C'#214#225#192#141#149']'#156#187#225#178
+#25#19'_'#22#157#219#131#201'n'#15#152'h'#178#151#197#24'b'#178'hf'#246#226
+'4q'#137#217#220#30#212'DM'#166'Q'#135'T%Z'#175'('#178#25#145#187'Pji'#233
+#141#210#254#255'g'#15#164'M'#181'l'#243#146'}'#147#147's'#201#201#247'{'#206
+#247#247';'#23#133#16#130#199#197#31#7#182#187#180#170#240#22#173'nr'#137'J'
+#163#202#151#146#130'X$'#230#143#132'i'#143'%s['#222#255't'#235#249#212'\E'
+#166#192'/m'#247#216'}'#164'{Z'#210#13#239#204'c'#205#242'B'#218'~'#219#246
+#131#217'<'#190#222'R'#220#148#163'5'#206'D'#171#183' '#132'L80'#132#127#160
+#147#161#174#211#145'`H'#211#178#250#203#239#191'M'#11'd'#18#239#220#248#28
+#142'9y'#220#232#11#227#13#196#241#6''''#241#6#226#28'v'#15#242'Mu'#235#206
+#162#249#214#207#173#197'+'#25#141#230#211'q'''#136'w,JR'#18'X'#242'uT'#148
+#230'a'#17#221#220':'#243#19'#'#222'd'#243#199#155'woW'#8'!h'#220't'#150#170
+#5'VJ'#236#185'8'#138#243')0k'#31' '#247#6'''y'#153#131#245'6'#179#239#212'\'
+#231'FM'#231#144#22'_ N'#213'|+f'#163#18#129#2#127'P'#226'B'#215'(yZ%'#139
+#141#127#226'9'#178'/'#26'SY'#235#149#0#243'f'#27#185'~'#219#207'a'#247#224#3
+#164#169':2!'#161#146#199'6'#155#138#26'5'#163'1#'#195#254#9'V5'#204#197#154
+'/'#240#135#195#228#25#13#204#153'm'#164#233#181'RFB2>e9'#246#146'g'#245'Rt'
+#236'ku'#202#227'e'#149'3)0'#229#252'c'#12#222'sD'#159'7X'#139'8'#213#229#167
+#186#188#128'hR'#160#209'h8'#241#251'A>'#252'`'#21#185':'#29'''Z'#207'Q'#190
+#176#154#243#151'zY'#177#208'I'#207#173'_'#235#213#0#221#253#227#216#205'3'#1
+#216#178#182#12'W'#149'-+'#6'bL'#152'u'#6#11'C'#190#251#188'n'#203'%.'#9#12
+'z='#3'}}'#156'8'#213'J'#199#181#171'4'#190#185#2'K'#129#158'{'#254#9'L'#181
+'sQ'#161#176#171'S'#22']'#184#233'C'#146#5#142#226#178'iw'#144#136''''#144
+#229'8'#177'I'#153#184'45'#230#13#134'0'#228#229#209'q'#237'*o7'#173'b'#177
+#163#146#222'`'#130'DBF'#200#147#8'Y'#144#182#200'Y1'#131#2'S'#14'['#247'w'
+#177'u'#127#182#192#198'gb'#247#130'#'#127#149#152#12#179#184';'#28'eA'#145#9
+#148':'#170'kj)'#171't'#160'7'#25#9#199#161#127'8'#130#209#160'dl'#240#26#19
+'I'#201#247#200#22#133':h'#237#239'l-q'#150#173#227#204#149#17#202'KM'#232'T'
+#26#234#151#191#4#10#144'dP'#233#224#226#21'/'#175'T('#233#189'|'#142#132'P'
+#183'+'#132#16'l'#216#213'A'#239'`'#8'I'#22'lY[F'#143#231'h'#246#241'NDP{'
+#219'xq'#229'[\'#26#173'` d'#224#141#23#236#204#183#27'@@'#183'7'#194#145#246
+'al'#26#31'N'#203'i'#206#29#189#132#148'ks'#166#5#236'f-'#5#166#28#14#187#7
+'Y'#187#232#142#184'q'#189'-K'#195#166#147#153'g'#9#177#164#225'UF'#148'N'
+#206#223'L'#18#8'IH'#178' _'#15#203#202#5'3'#226#199#185'x'#252#2#139#234'V'
+#211#240#238':'#133#26#160'w0'#132#221#172'M['#212#227#185#3#192'w;vg'#137'x'
+'N'#31#162#253#216#1'l'#133'nV,'#172#192'\X'#12'"'#201#253#129#219#244#180
+#223#224#174'OC'#165'k='#14'g-'#192'T'#144#215#173',a'#239#177#187#211'fQ'
+#227#166#179#156'l'#169#163'q'#211'Y'#0'N'#182'41'#171#212#193#142']{'#153'q'
+#187#19'K'#206'e'#0#238#143#199#168#170'u'#241#227#177'C|'#182#237'#'#198#3
+#253'S'#4'B'#136't'#249#249#204#16#174'f7{'#246#236#19'_}'#241#137#16'B'#8'W'
+#179'[d'#194#213#236#22#178',?'#208'Oa'#233#210#165#233'vp'#172'O'#8'!Pf'#174
+'v'#205#242'BN'#182#212'M{'#14#30#190#214'S'#139#250'/'#168#31#229#254'O'#17
+#165#236'J'#181#167','#171'{z'#1#133'B'#145'%'#152')'#244'o"'#202'G}'#197'2'
+#137#30#22'|'#234#29'$%9'#203#150#135'-'#170#169#169#193#227#241#164#235#172
+'`e'#150#204',zR'#164#178'H1]&'#140#7#250#31#255'''0'#13#140#230#217#10#197
+#147#252'*'#30#7'J'#254'g'#252#13's'#22#160#208#212'1'#24'"'#0#0#0#0'IEND'
+#174'B`'#130
]);