From 61c30095ef5aa99362e4bd6d6f99115d0aa93de5 Mon Sep 17 00:00:00 2001 From: jujibo Date: Thu, 11 Feb 2016 09:35:02 +0000 Subject: [PATCH] Fixing deprecated code git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4492 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/jujiboutils/src/jcontrolutils.pas | 76 ++++++++++--------- components/jujiboutils/src/jdbgridutils.pas | 19 +++-- .../src/jdblabeledcurrencyedit.pas | 8 +- .../src/jdblabeleddatetimeedit.pas | 5 +- .../jujiboutils/src/jdblabeledfloatedit.pas | 8 +- components/jujiboutils/src/jlabel.pas | 2 +- .../jujiboutils/src/jlabeledcurrencyedit.pas | 9 ++- .../jujiboutils/src/jlabeleddateedit.pas | 2 +- .../jujiboutils/src/jlabeleddatetimeedit.pas | 3 +- .../jujiboutils/src/jlabeledfloatedit.pas | 7 +- 10 files changed, 74 insertions(+), 65 deletions(-) diff --git a/components/jujiboutils/src/jcontrolutils.pas b/components/jujiboutils/src/jcontrolutils.pas index dd4047a96..f31d44a22 100644 --- a/components/jujiboutils/src/jcontrolutils.pas +++ b/components/jujiboutils/src/jcontrolutils.pas @@ -77,7 +77,8 @@ var ms := tokens[1]; if (tokens.Count > 2) and (tokens[2] <> '') then ys := tokens[2]; - texto := ds + DateSeparator + ms + DateSeparator + ys; + texto := ds + DefaultFormatSettings.DateSeparator + ms + + DefaultFormatSettings.DateSeparator + ys; end; procedure MiddleEndianForm; @@ -88,7 +89,8 @@ var ds := tokens[1]; if (tokens.Count > 2) and (tokens[2] <> '') then ys := tokens[2]; - texto := ms + DateSeparator + ds + DateSeparator + ys; + texto := ms + DefaultFormatSettings.DateSeparator + ds + + DefaultFormatSettings.DateSeparator + ys; end; procedure BigEndianForm; @@ -99,12 +101,13 @@ var ms := tokens[1]; if (tokens.Count > 2) and (tokens[2] <> '') then ds := tokens[2]; - texto := ys + DateSeparator + ms + DateSeparator + ds; + texto := ys + DefaultFormatSettings.DateSeparator + ms + + DefaultFormatSettings.DateSeparator + ds; end; begin if theFormat = '' then - aDateFormat := ShortDateFormat + aDateFormat := DefaultFormatSettings.ShortDateFormat else aDateFormat := theFormat; if theValue = 0 then @@ -118,7 +121,7 @@ begin texto := NormalizeDateSeparator(texto); Result := texto; // default value tokens := TStringList.Create; - Split(DateSeparator, texto, tokens); + Split(DefaultFormatSettings.DateSeparator, texto, tokens); if tokens.Count > 0 then begin aChar := aDateFormat[1]; @@ -149,7 +152,8 @@ var function TimeString: string; begin - Result := hhs + TimeSeparator + mms + TimeSeparator + sss;// + TimeSeparator + mss; + Result := hhs + DefaultFormatSettings.TimeSeparator + mms + + DefaultFormatSettings.TimeSeparator + sss;// + TimeSeparator + mss; end; procedure TimeForm; @@ -167,7 +171,7 @@ var begin if theFormat = '' then - aTimeFormat := ShortTimeFormat + aTimeFormat := DefaultFormatSettings.ShortTimeFormat else aTimeFormat := theFormat; if theValue = 0 then @@ -186,7 +190,7 @@ begin texto := Value; Result := texto; // default value tokens := TStringList.Create; - Split(TimeSeparator, texto, tokens); + Split(DefaultFormatSettings.TimeSeparator, texto, tokens); if tokens.Count > 0 then begin TimeForm; @@ -194,7 +198,7 @@ begin begin aTime := StrToTime(texto); Result := TimeString;// FormatDateTime(aTimeFormat, aTime); - end + end; end; tokens.Free; //ShowMessage('Hora normalizada: ' + Result); @@ -235,14 +239,14 @@ begin Result := s; for i := 1 to length(Result) do if Result[i] in ['.', ',', '/', '-'] then // valid date separators - Result[i] := DateSeparator; + Result[i] := DefaultFormatSettings.DateSeparator; end; function IsValidDateString(const Value: string): boolean; var bTime: TDateTime; begin - Result:= TryStrToDate(Value, bTime); + Result := TryStrToDate(Value, bTime); end; function IsValidTimeString(const Value: string): boolean; @@ -260,30 +264,28 @@ begin end; initialization - LazarusResources.Add('JCalendarIcon','PNG',[ - #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#16#0#0#0#16#8#6#0#0#0#31#243#255'a' - +#0#0#0#4'gAMA'#0#0#175#200'7'#5#138#233#0#0#0#25'tEXtSoftware'#0'Adobe Image' - +'Readyq'#201'e<'#0#0#1#206'IDAT8'#203#165#147#177'kTA'#16#135#191'w'#247#188 - +#20#167#133#16#13#136#24#21#130' &X'#5'!'#18#4'!`'#149'@'#210#8#150'ZD'#16'[' - +'+Q'#208#210#206'?A'#9'B'#130#130#157#160#16'='#177'Pl'#132' DL#Q'#137'E ' - +#228#240#237#236#204'X'#236'{'#151'w'#24#4#201#194#176#203'2|'#243#251#205 - +#236'f'#238#206'^V'#14#240#232#205#230'mw'#174#169#219'Q3C'#13#162#25#170#134 - +#154#19#213'j'#161'ht'#212#236#253#253'+#'#227'9'#128#185#223#152#29'?0'#248 - +'?'#149#239'<'#249'2'#214'S'#160'f'#131#0#237#165#235#224#14#26#193#20'D'#210 - +'9'#20' '#1#10#1#17#182'o'#189'BD'#7'j'#128#170#15#14'G'#14#129#197#20#30'KH' - +#1'R@'#12#176#242#29#0#137#186#211#3'U+'#1#25#172'o'#128'[Rb'#150#148'h'#181 - +#3'CC'#0#132': '#150#128#133#225'{\>'#127#248#159#222#23#223#173's!'#196'~'#5 - +#162#134#185#147'7S'#210#179'O'#139't'#214#150#185'zn'#158#207'?Wx'#185#250 - +#130#139'#S'#204#140#206'Q'#136#179#213#21#130'$@'#163#178#224'@'#222#204#0 - +#152#25#157#163#27#186#0#252#218#222#224#193#244'C:k'#203#0#20'Q'#9'b'#196'h' - +';'#0'Q'#195#13#242#198#223#146#187#161'K'#171#217#234#1#11#177#178#221'u@4' - +#220#157'}'#165#133#206#215'T'#237#227#183#15#28';8'#204#205#167#243'L'#157 - +#186'D'#149#11#208#30#200'kM'#180't'#217'l$'#11#19'''&'#153'89Y'#206'%c'#250 - +#204',Y'#150#245#1#170#201'%@'#140'x)'#231#241#235#31'ij'#238#136#130#168#18 - +#212#8#146#188#183#154'U1'#250#167#224#238#140#29#223#207'i'#173#222#190#247 - +#254#194'n'#203#204#173#246#144#252#237#221#133#213#179'A'#173'-Q'#145#168'h' - +'4D'#141#168'qW'#192#230#214#239#231#0#217'^'#191#243#31#2'<4&'#179'.'#211 - +#208#0#0#0#0'IEND'#174'B`'#130 -]); + LazarusResources.Add('JCalendarIcon', 'PNG', [ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#16#0#0#0#16#8#6#0#0#0#31#243#255'a' + + #0#0#0#4'gAMA'#0#0#175#200'7'#5#138#233#0#0#0#25'tEXtSoftware'#0'Adobe Image' + + 'Readyq'#201'e<'#0#0#1#206'IDAT8'#203#165#147#177'kTA'#16#135#191'w'#247#188 + + #20#167#133#16#13#136#24#21#130' &X'#5'!'#18#4'!`'#149'@'#210#8#150'ZD'#16'[' + + '+Q'#208#210#206'?A'#9'B'#130#130#157#160#16'='#177'Pl'#132' DL#Q'#137'E ' + + #228#240#237#236#204'X'#236'{'#151'w'#24#4#201#194#176#203'2|'#243#251#205 + + #236'f'#238#206'^V'#14#240#232#205#230'mw'#174#169#219'Q3C'#13#162#25#170#134 + + #154#19#213'j'#161'ht'#212#236#253#253'+#'#227'9'#128#185#223#152#29'?0'#248 + + '?'#149#239'<'#249'2'#214'S'#160'f'#131#0#237#165#235#224#14#26#193#20'D'#210 + + '9'#20' '#1#10#1#17#182'o'#189'BD'#7'j'#128#170#15#14'G'#14#129#197#20#30'KH' + + #1'R@'#12#176#242#29#0#137#186#211#3'U+'#1#25#172'o'#128'[Rb'#150#148'h'#181 + + #3'CC'#0#132': '#150#128#133#225'{\>'#127#248#159#222#23#223#173's!'#196'~'#5 + + #162#134#185#147'7S'#210#179'O'#139't'#214#150#185'zn'#158#207'?Wx'#185#250 + + #130#139'#S'#204#140#206'Q'#136#179#213#21#130'$@'#163#178#224'@'#222#204#0 + + #152#25#157#163#27#186#0#252#218#222#224#193#244'C:k'#203#0#20'Q'#9'b'#196'h' + + ';'#0'Q'#195#13#242#198#223#146#187#161'K'#171#217#234#1#11#177#178#221'u@4' + + #220#157'}'#165#133#206#215'T'#237#227#183#15#28';8'#204#205#167#243'L'#157 + + #186'D'#149#11#208#30#200'kM'#180't'#217'l$'#11#19'''&'#153'89Y'#206'%c'#250 + + #204',Y'#150#245#1#170#201'%@'#140'x)'#231#241#235#31'ij'#238#136#130#168#18 + + #212#8#146#188#183#154'U1'#250#167#224#238#140#29#223#207'i'#173#222#190#247 + + #254#194'n'#203#204#173#246#144#252#237#221#133#213#179'A'#173'-Q'#145#168'h' + + '4D'#141#168'qW'#192#230#214#239#231#0#217'^'#191#243#31#2'<4&'#179'.'#211 + + #208#0#0#0#0'IEND'#174'B`'#130]); end. - diff --git a/components/jujiboutils/src/jdbgridutils.pas b/components/jujiboutils/src/jdbgridutils.pas index 35b4e2ed6..4746fb07d 100644 --- a/components/jujiboutils/src/jdbgridutils.pas +++ b/components/jujiboutils/src/jdbgridutils.pas @@ -313,8 +313,8 @@ begin if Field.IsNull then Result := '' else - Result := FormatDateTime(ShortDateFormat, Field.AsDateTime) + - ' ' + FormatDateTime(ShortTimeFormat, Field.AsDateTime); + Result := FormatDateTime(DefaultFormatSettings.ShortDateFormat, Field.AsDateTime) + + ' ' + FormatDateTime(DefaultFormatSettings.ShortTimeFormat, Field.AsDateTime); end; procedure TJDbGridDateTimeCtrl.myEditEnter(Sender: TObject); @@ -510,7 +510,8 @@ begin CellEditor.OnKeyDown := @OnKeyDown; CellEditor.OnEditingDone := @myEditOnEditingDone; CellEditor.OnKeyPress := @OnKeyPress; - DisplayFormat := ShortDateFormat + ' ' + ShortTimeFormat; + DisplayFormat := DefaultFormatSettings.ShortDateFormat + ' ' + + DefaultFormatSettings.ShortTimeFormat; end; destructor TJDbGridDateTimeCtrl.Destroy; @@ -704,7 +705,7 @@ begin CellEditor.OnKeyDown := @OnKeyDown; CellEditor.OnEditingDone := @myEditOnEditingDone; CellEditor.OnKeyPress := @OnKeyPress; // se sobreescribe por el Grid :( - DisplayFormat := ShortTimeFormat; + DisplayFormat := DefaultFormatSettings.ShortTimeFormat; end; destructor TJDbGridTimeCtrl.Destroy; @@ -937,7 +938,7 @@ begin CellEditor.OnKeyDown := @OnKeyDown; CellEditor.OnEditingDone := @myEditOnEditingDone; CellEditor.OnKeyPress := @OnKeyPress; // se sobreescribe por el Grid :( - DisplayFormat := ShortDateFormat; + DisplayFormat := DefaultFormatSettings.ShortDateFormat; end; destructor TJDbGridDateCtrl.Destroy; @@ -1035,10 +1036,12 @@ end; procedure TJDbGridDoubleCtrl.OnKeyPress(Sender: TObject; var key: char); begin if (Key in ['.', ',']) then - Key := Decimalseparator; - if (key = DecimalSeparator) and (Pos(key, CellEditor.Caption) > 0) then + Key := DefaultFormatSettings.Decimalseparator; + if (key = DefaultFormatSettings.DecimalSeparator) and + (Pos(key, CellEditor.Caption) > 0) then key := #0; - if not (Key in ['0'..'9', DecimalSeparator, '+', '-', #8, #9]) then + if not (Key in ['0'..'9', DefaultFormatSettings.DecimalSeparator, + '+', '-', #8, #9]) then Key := #0; //if (Key = DecimalSeparator) and (fDecimals = 0) then // Key := #0; // Note: decimal=0 avoids rounding diff --git a/components/jujiboutils/src/jdblabeledcurrencyedit.pas b/components/jujiboutils/src/jdblabeledcurrencyedit.pas index 2c6c15c0f..0bcbd4868 100644 --- a/components/jujiboutils/src/jdblabeledcurrencyedit.pas +++ b/components/jujiboutils/src/jdblabeledcurrencyedit.pas @@ -350,10 +350,11 @@ begin if not FieldIsEditable(Field) or not FDatalink.Edit then Key := #0; if (Key in ['.', ',']) then - Key := Decimalseparator; - if (key = DecimalSeparator) and (Pos(key, Text) > 0) then + Key := DefaultFormatSettings.Decimalseparator; + if (key = DefaultFormatSettings.DecimalSeparator) and (Pos(key, Text) > 0) then key := #0; - if not (Key in ['0'..'9', DecimalSeparator, '+', '-', #8, #9]) then + if not (Key in ['0'..'9', DefaultFormatSettings.DecimalSeparator, + '+', '-', #8, #9]) then Key := #0; if (Key <> #0) and (not IsReadOnly) then @@ -403,4 +404,3 @@ begin end; end. - diff --git a/components/jujiboutils/src/jdblabeleddatetimeedit.pas b/components/jujiboutils/src/jdblabeleddatetimeedit.pas index ed4e5219d..3245f6f1d 100644 --- a/components/jujiboutils/src/jdblabeleddatetimeedit.pas +++ b/components/jujiboutils/src/jdblabeleddatetimeedit.pas @@ -249,8 +249,9 @@ begin if Field.IsNull then Result := '' else - Result := FormatDateTime(ShortDateFormat, FDataLink.Field.AsDateTime) + - ' ' + FormatDateTime(ShortTimeFormat, FDataLink.Field.AsDateTime); + Result := FormatDateTime(DefaultFormatSettings.ShortDateFormat, + FDataLink.Field.AsDateTime) + ' ' + + FormatDateTime(DefaultFormatSettings.ShortTimeFormat, FDataLink.Field.AsDateTime); end; function TJDBLabeledDateTimeEdit.getFormat: string; diff --git a/components/jujiboutils/src/jdblabeledfloatedit.pas b/components/jujiboutils/src/jdblabeledfloatedit.pas index 6625f5b94..082bffc6a 100644 --- a/components/jujiboutils/src/jdblabeledfloatedit.pas +++ b/components/jujiboutils/src/jdblabeledfloatedit.pas @@ -360,10 +360,11 @@ begin if not FieldIsEditable(Field) or not FDatalink.Edit then Key := #0; if (Key in ['.', ',']) then - Key := Decimalseparator; - if (key = DecimalSeparator) and (Pos(key, Text) > 0) then + Key := DefaultFormatSettings.Decimalseparator; + if (key = DefaultFormatSettings.DecimalSeparator) and (Pos(key, Text) > 0) then key := #0; - if not (Key in ['0'..'9', DecimalSeparator, '+', '-', #8, #9]) then + if not (Key in ['0'..'9', DefaultFormatSettings.DecimalSeparator, + '+', '-', #8, #9]) then Key := #0; if (Key <> #0) and (not IsReadOnly) then FDatalink.Edit; @@ -417,4 +418,3 @@ end; end. - diff --git a/components/jujiboutils/src/jlabel.pas b/components/jujiboutils/src/jlabel.pas index c0b4c3d32..cac1965db 100644 --- a/components/jujiboutils/src/jlabel.pas +++ b/components/jujiboutils/src/jlabel.pas @@ -42,7 +42,6 @@ type protected { Protected declarations } procedure SetShadowColor(Value: TColor); - procedure Paint; override; property ShadowColor: TColor read FShadowColor write SetShadowColor; property ShadowColor2: TColor read FShadowColor2 write SetShadowColor2; @@ -91,6 +90,7 @@ type public { Public declarations } constructor Create(TheOwner: TComponent); override; + procedure Paint; override; end; TJLabel = class(TJCustomLabel) diff --git a/components/jujiboutils/src/jlabeledcurrencyedit.pas b/components/jujiboutils/src/jlabeledcurrencyedit.pas index 5483b92ce..78e147b73 100644 --- a/components/jujiboutils/src/jlabeledcurrencyedit.pas +++ b/components/jujiboutils/src/jlabeledcurrencyedit.pas @@ -206,12 +206,13 @@ end; procedure TJLabeledCurrencyEdit.KeyPress(var Key: char); begin if (Key in ['.', ',']) then - Key := Decimalseparator; - if (key = DecimalSeparator) and (Pos(key, Text) > 0) then + Key := DefaultFormatSettings.Decimalseparator; + if (key = DefaultFormatSettings.DecimalSeparator) and (Pos(key, Text) > 0) then key := #0; - if not (Key in ['0'..'9', DecimalSeparator, '+', '-', #8, #9]) then + if not (Key in ['0'..'9', DefaultFormatSettings.DecimalSeparator, + '+', '-', #8, #9]) then Key := #0; - if (Key = DecimalSeparator) and (fDecimals = 0) then + if (Key = DefaultFormatSettings.DecimalSeparator) and (fDecimals = 0) then Key := #0; inherited KeyPress(Key); end; diff --git a/components/jujiboutils/src/jlabeleddateedit.pas b/components/jujiboutils/src/jlabeleddateedit.pas index ec9c3a620..b6286e649 100644 --- a/components/jujiboutils/src/jlabeleddateedit.pas +++ b/components/jujiboutils/src/jlabeleddateedit.pas @@ -314,7 +314,7 @@ constructor TJLabeledDateEdit.Create(TheOwner: TComponent); begin inherited Create(TheOwner); Text := ''; - fFormat := ShortDateFormat; + fFormat := DefaultFormatSettings.ShortDateFormat; theValue := 0; FButton := TSpeedButton.Create(self); FButton.Height := Self.Height; diff --git a/components/jujiboutils/src/jlabeleddatetimeedit.pas b/components/jujiboutils/src/jlabeleddatetimeedit.pas index bcbfa39a2..189495076 100644 --- a/components/jujiboutils/src/jlabeleddatetimeedit.pas +++ b/components/jujiboutils/src/jlabeleddatetimeedit.pas @@ -336,7 +336,8 @@ constructor TJLabeledDateTimeEdit.Create(TheOwner: TComponent); begin inherited Create(TheOwner); Text := ''; - fFormat := ShortDateFormat + ' ' + ShortTimeFormat; + fFormat := DefaultFormatSettings.ShortDateFormat + ' ' + + DefaultFormatSettings.ShortTimeFormat; theValue := 0; formatInput; FButton := TSpeedButton.Create(self); diff --git a/components/jujiboutils/src/jlabeledfloatedit.pas b/components/jujiboutils/src/jlabeledfloatedit.pas index 4d7790420..f2b0a766d 100644 --- a/components/jujiboutils/src/jlabeledfloatedit.pas +++ b/components/jujiboutils/src/jlabeledfloatedit.pas @@ -216,10 +216,11 @@ end; procedure TJLabeledFloatEdit.KeyPress(var Key: char); begin if (Key in ['.', ',']) then - Key := Decimalseparator; - if (key = DecimalSeparator) and (Pos(key, Text) > 0) then + Key := DefaultFormatSettings.Decimalseparator; + if (key = DefaultFormatSettings.DecimalSeparator) and (Pos(key, Text) > 0) then key := #0; - if not (Key in ['0'..'9', DecimalSeparator, '+', '-', #8, #9]) then + if not (Key in ['0'..'9', DefaultFormatSettings.DecimalSeparator, + '+', '-', #8, #9]) then Key := #0; inherited KeyPress(Key); end;