Added: TJTimeEdit, TJLabeledTimeEdit

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1988 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
jujibo 2011-09-23 10:08:21 +00:00
parent 58aef337cb
commit 1abf706084
7 changed files with 504 additions and 3 deletions

View File

@ -5,7 +5,7 @@ Note: Lazarus Trunk required
Version pre-1.0
--------------------------------------------------
2011-09-23 Added: TJDBLabeledEdit
2011-09-23 Added: TJDBLabeledEdit, TJTimeEdit, TJLabeledTimeEdit
2011-09-22 Added: ftTime support (testing)
2011-09-21 Added: TJDBGridControl and example (testgridctr)
2011-09-20 Added: TJIntegerEdit, TJLabeledIntegerEdit

View File

@ -18,7 +18,7 @@
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Files Count="16">
<Files Count="18">
<Item1>
<Filename Value="src/jdbintegeredit.pas"/>
<HasRegisterProc Value="True"/>
@ -97,6 +97,16 @@
<HasRegisterProc Value="True"/>
<UnitName Value="JDBLabeledEdit"/>
</Item16>
<Item17>
<Filename Value="src/jtimeedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JTimeEdit"/>
</Item17>
<Item18>
<Filename Value="src/jlabeledtimeedit.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="JLabeledTimeEdit"/>
</Item18>
</Files>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="2">

View File

@ -11,7 +11,7 @@ uses
jdblabeledcurrencyedit, jdbdateedit, jdblabeleddateedit, jcontrolutils,
JIntegerEdit, JLabeledIntegerEdit, JCurrencyEdit, JLabeledCurrencyEdit,
JDateEdit, JLabeledDateEdit, JDBGridControl, jdbgridutils, JDBLabeledEdit,
LazarusPackageIntf;
JTimeEdit, JLabeledTimeEdit, LazarusPackageIntf;
implementation
@ -31,6 +31,8 @@ begin
RegisterUnit('JLabeledDateEdit', @JLabeledDateEdit.Register);
RegisterUnit('JDBGridControl', @JDBGridControl.Register);
RegisterUnit('JDBLabeledEdit', @JDBLabeledEdit.Register);
RegisterUnit('JTimeEdit', @JTimeEdit.Register);
RegisterUnit('JLabeledTimeEdit', @JLabeledTimeEdit.Register);
end;
initialization

View File

@ -0,0 +1,187 @@
unit JLabeledTimeEdit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, ExtCtrls, Graphics,
Dialogs, jcontrolutils;
type
TJLabeledTimeEdit = class(TCustomLabeledEdit)
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 AutoSelect;
property AutoSize;
property BidiMode;
property BorderSpacing;
property BorderStyle;
property CharCase;
property Color;
property Constraints;
property DragCursor;
property DragMode;
property EditLabel;
property Enabled;
property Font;
property LabelPosition;
property LabelSpacing;
property MaxLength;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ReadOnly;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnChange;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEditingDone;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDrag;
property OnUTF8KeyPress;
end;
procedure Register;
implementation
procedure Register;
begin
{$I jlabeledtimeedit_icon.lrs}
RegisterComponents('Additional',[TJLabeledTimeEdit]);
end;
function TJLabeledTimeEdit.getFormat: string;
begin
Result := fFormat;
end;
function TJLabeledTimeEdit.getValue: TTime;
begin
Result := theValue;
end;
procedure TJLabeledTimeEdit.setFormat(const AValue: string);
begin
fFormat := AValue;
formatInput;
end;
procedure TJLabeledTimeEdit.setValue(const AValue: TTime);
begin
theValue := AValue;
hasValue:= True;
formatInput;
end;
procedure TJLabeledTimeEdit.FormatInput;
begin
if hasValue then
Text := FormatDateTime(fFormat, theValue)
else Text := '';
end;
procedure TJLabeledTimeEdit.DoEnter;
begin
inherited DoEnter;
if not hasValue then
Text := ''
else
Text := TimeToStr(theValue);
SelectAll;
end;
procedure TJLabeledTimeEdit.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(Text + ' no es una hora válida');
SetFocus;
end;
formatInput;
end;
procedure TJLabeledTimeEdit.KeyPress(var Key: char);
begin
if not (Key in ['0'..'9', #8, #9, ':']) then
Key := #0;
inherited KeyPress(Key);
end;
constructor TJLabeledTimeEdit.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
Text := '';
DisplayFormat := 'hh:mm:ss';
Value := 0;
hasValue:= True;
end;
destructor TJLabeledTimeEdit.Destroy;
begin
inherited Destroy;
end;
function TJLabeledTimeEdit.isNull: boolean;
begin
Result := not hasValue;
end;
end.

View File

@ -0,0 +1,54 @@
LazarusResources.Add('tjlabeledtimeedit','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#9
+'7'#2#5'+'#177#140#0#0#4'vIDATH'#199#181#150'kL'#147'W'#28#198#127'oK)'#8#148
+#150#10#29#222#16't'#232#164'03k'#149#128#6#139#206#201#220#212'd^6'#190','
+#168#219#7#19'w'#201'RR]'#182','#11'k'#208'l'#243#182'e'#9#147'L'#19#183#25
+'?L"'#154'yalR-'#211'j'#162#8#178#24#1#197'"'#150'Z'#202#253'b'#219#179#15'M'
+#155'*l'#243#146'='#201#201'{'#206'{N'#158#231#156#255#255'9'#23'I'#8#193#147
+#226#247#195';MJy'#255've'#204#232'\'#185'B'#158#224#247#9#134#6#134'<'#3#253
+#212#15#249'b'#203'W'#189'Sf'#15#141#149'"'#5'~'#174#187'KEu'#203#184#164#155
+'Wf'#176'aQ*uG'#172#223#170#213#189#27'5i'#171#163#149#170'd'#148#19'4'#8#17
+#160#223#219#129#231'N'#19#29#205#181#3'=}'#138#242'u'#239#239#253'<,'#16'I'
+#188'{'#203#139#232#167#197's'#237'v?.'#239#8#174#158'Q\'#222#17#170'lN>y'
+#233#143#221'Sf&mMJ+'#162'k0'#129#134#155'='#184#186#7#241#249#5#154#132#24
+#178'f'#196#163#17'-\?{'#144'{.'#159#249#237'm'#21';%!'#4#133#165#231#200'y>'
+#137't],'#250#180#4'R'#212#202#135#200']='#163','#230#151'|'#173#218#253#219
+'t'#227#22'ES'#135#18#183'w'#132#156#153'I'#168'U2'#4#18#158#30'?'#23#154#187
+#136'W'#202'xA'#245#23#142#234#3#131'C'#242#164'|'#25'@'#198'T'#21'Wox'#168
+#178'9'#195#164#230#146#229'"D>0'#236'G'#30#232#222#150'8'#165'P'#209'5'#164
+#162#211'3'#204#154#130#233'$%'#8'<'#253#253#196#171#226#152'6U'#197'.'#203
+'z'#238#245#5'p'#203#230#160'K'#159'<'#193'?'#216#253#161','#20#227#220#236
+'dV'#229'O'#166#162#186#5's'#201'r'#1'p'#240#179'7'#132#189#161#139'|M'#147
+'('#221'sf'#197#134'M'#31#211#232#168'E'#159#169#197'`0'#160'P(8}'#242'W'#242
+#13#6#242#13#6#0'*>]'#143#189#201#203's'#153'F'#228'b4'#184#130#150#246#222
+'p2'#183#23#207#198#225'pH'#0';*OJ'#155'Wf`'#181'Z'#217#177'5w'#248#244#201
+'*'#172'V+Zm,'#22#139#133#130#197#139#169#252'f'#31#22#139#133#165'+_'#7#224
+#135#26';w='#195'$&OG'#142#164#11#135#232'B'#163#155'*'#155#243#31#173'i'#222
+'c'#143'Y'#182'|'#21#0'#~XT'#180'&'#220'w'#177#161#145'WW'#7#219'#>x'#240' '
+#128#8#12'#'#2#130#168#208' c'#214'DR'#18#163');'#212'L'#217#161#224#191#178
+'C'#205'a'#146'm'#197'Y'#173's'#151#189#153'~'#236#250'$Z;'#7#233#186'r&'#220
+'7?;'#139#204#236'l'#0#218';'#7'P'#197#201#232'v^a'#216#231'w'#135']'#148#155
+#157'LJb4'#250#180#4'L9Z'#12#6#131#0#248#232#235'c'#146#194'u^X'#173#214'0'
+#225#218#210#31'9R'#254#22#167#237#14#162#228#176#196'h'#224#204#159#14#150
+'.'#8#230#225#139#189#223'1|'#249'KZ'#219'|G$!'#4#155#247'5p'#203#217#135'? '
+#216'^<'#155'6'#199#241#177#219#251#193#0'Q'#174':'#22#20#173#224'RW'#22'w'
+#250#226'xy'#190#142#153#186'8'#16#208#226#26#160#186#190#19#173#194#141'QS'
+#203#249#227#151#240#199'j'#141'a'#1#157'ZIJb4U6'''#197#179'n'#138'kW'#235
+#198'hhc'#2'dh'#250#152'['#176#132'{2#'#246'F'#31#222'>?'#254#128' a'#2#228
+#206#17'L'#28'9'#197#197'S'#23#152#149#183#142#130#215'J'#164'('#128'['#206
+'>tje'#216'Em'#142#155#0'|'#181#171'b'#140#136#163#246'('#245''''#14#163'M'
+#181#241'Jf'#22#234#212'4'#16'>'#238#223#185'A['#253'5Z'#221#10#178'M'#27#209
+#27#23#2#4#147'\R'#148'N'#229#137'V'#252#1#129'>m'#246'C'#132#133#165#231#168
+')'#207#163#176#244#28#0'5'#229#171#153'4C'#207#174'}'#149'L'#188#209#132'&'
+#250'2'#0#247'{'#135#200'Yh'#226#251#19'Gy'#215#186#150'^o{'#144'@'#8#17'.?'
+#157#237#192'd'#182#177#127#255#1#241#193'{'#155#132#16'B'#152#204'6'#17#9
+#147#217'&'#2#129#192'C'#237#16#230#205#155#23#174#247't'#223#22'B'#8'd'#145
+#179#221#176'('#149#154#242#188'q'#247#193#163#199'zhR'#255#133#168#199'9'
+#255'CD'#161'p'#133#234#193#144#229'='#187#128'$Ic'#4'#'#133#254'MD'#246#184
+#183'X$'#209#163#130#207#188#2#159'?0&,'#143#134#200'`0'#224'p8'#194#223'1'
+#201#138','#145'.zZ'#132'\$'#141#231#132'^o'#251#147#191#4#198#129'J=U'#146
+#158#230'U'#241'$'#144#241'?'#227'o`'#243#144'E'#203#179'B'#154#0#0#0#0'IEND'
+#174'B`'#130
]);

View File

@ -0,0 +1,195 @@
unit JTimeEdit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, StdCtrls, Graphics,
Dialogs, jcontrolutils;
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(Text + ' no es una hora válida');
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

@ -0,0 +1,53 @@
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
]);