callight: Use copy of FormatSettings in calendar.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6773 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-12-27 17:06:09 +00:00
parent f822a3d475
commit 7d36353fbd
4 changed files with 71 additions and 42 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="10"/> <Version Value="11"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<General> <General>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
@ -20,9 +20,10 @@
<Version Value="2"/> <Version Value="2"/>
</PublishOptions> </PublishOptions>
<RunParams> <RunParams>
<local> <FormatVersion Value="2"/>
<FormatVersion Value="1"/> <Modes Count="1">
</local> <Mode0 Name="default"/>
</Modes>
</RunParams> </RunParams>
<RequiredPackages Count="2"> <RequiredPackages Count="2">
<Item1> <Item1>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="10"/> <Version Value="11"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<General> <General>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
@ -19,13 +19,12 @@
</BuildModes> </BuildModes>
<PublishOptions> <PublishOptions>
<Version Value="2"/> <Version Value="2"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
</PublishOptions> </PublishOptions>
<RunParams> <RunParams>
<local> <FormatVersion Value="2"/>
<FormatVersion Value="1"/> <Modes Count="1">
</local> <Mode0 Name="default"/>
</Modes>
</RunParams> </RunParams>
<RequiredPackages Count="2"> <RequiredPackages Count="2">
<Item1> <Item1>

View File

@ -12,29 +12,28 @@ object Form1: TForm1
LCLVersion = '2.1.0.0' LCLVersion = '2.1.0.0'
object PSettings: TPanel object PSettings: TPanel
Left = 0 Left = 0
Height = 432 Height = 448
Top = 0 Top = 0
Width = 753 Width = 753
Align = alTop Align = alTop
ClientHeight = 432 ClientHeight = 448
ClientWidth = 753 ClientWidth = 753
TabOrder = 0 TabOrder = 0
object cgOptions: TCheckGroup object cgOptions: TCheckGroup
Left = 24 Left = 24
Height = 384 Height = 392
Top = 40 Top = 40
Width = 160 Width = 160
AutoFill = True AutoFill = True
Caption = 'Set calendar Options' Caption = 'Set calendar Options'
ChildSizing.LeftRightSpacing = 6 ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 364 ClientHeight = 372
ClientWidth = 156 ClientWidth = 156
Items.Strings = ( Items.Strings = (
'coBoldDayNames' 'coBoldDayNames'
@ -117,20 +116,19 @@ object Form1: TForm1
end end
object rgLanguage: TRadioGroup object rgLanguage: TRadioGroup
Left = 200 Left = 200
Height = 208 Height = 216
Top = 216 Top = 216
Width = 160 Width = 160
AutoFill = True AutoFill = True
Caption = 'Language to use' Caption = 'Language to use'
ChildSizing.LeftRightSpacing = 6 ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 188 ClientHeight = 196
ClientWidth = 156 ClientWidth = 156
ItemIndex = 0 ItemIndex = 0
Items.Strings = ( Items.Strings = (
@ -155,7 +153,6 @@ object Form1: TForm1
AutoFill = True AutoFill = True
Caption = 'Starting day of the week' Caption = 'Starting day of the week'
ChildSizing.LeftRightSpacing = 6 ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds ChildSizing.ShrinkHorizontal = crsScaleChilds
@ -178,11 +175,11 @@ object Form1: TForm1
end end
object GroupBox1: TGroupBox object GroupBox1: TGroupBox
Left = 376 Left = 376
Height = 384 Height = 392
Top = 40 Top = 40
Width = 160 Width = 160
Caption = 'Colors' Caption = 'Colors'
ClientHeight = 364 ClientHeight = 372
ClientWidth = 156 ClientWidth = 156
TabOrder = 6 TabOrder = 6
object CbArrowBorder: TColorButton object CbArrowBorder: TColorButton
@ -491,7 +488,7 @@ object Form1: TForm1
end end
object SelDateListbox: TListBox object SelDateListbox: TListBox
Left = 560 Left = 560
Height = 144 Height = 152
Top = 280 Top = 280
Width = 168 Width = 168
Columns = 2 Columns = 2

View File

@ -245,9 +245,7 @@ type
FCalDrawer: TCalDrawer; FCalDrawer: TCalDrawer;
FColors: TCalColors; FColors: TCalColors;
FDate: TDateTime; FDate: TDateTime;
FDayNames: TStringList;
FDisplayTexts: TStringList; FDisplayTexts: TStringList;
FMonthNames: TStringList;
FOnDateChange: TNotifyEvent; FOnDateChange: TNotifyEvent;
FOnMonthChange: TNotifyEvent; FOnMonthChange: TNotifyEvent;
FOnGetDayText: TCalGetDayTextEvent; FOnGetDayText: TCalGetDayTextEvent;
@ -269,6 +267,7 @@ type
FClickButton: TMouseButton; FClickButton: TMouseButton;
FLanguage: TLanguage; FLanguage: TLanguage;
FDblClickTimer: TTimer; FDblClickTimer: TTimer;
FFormatSettings: TFormatSettings;
function GetDayNames: String; function GetDayNames: String;
function GetDisplayText(aTextIndex: TDisplayText): String; function GetDisplayText(aTextIndex: TDisplayText): String;
function GetDisplayTexts: String; function GetDisplayTexts: String;
@ -932,7 +931,7 @@ begin
s:= FOwner.GetDisplayText(dtToday); s:= FOwner.GetDisplayText(dtToday);
if (coShowTodayName in FOwner.Options) then if (coShowTodayName in FOwner.Options) then
s := Format('%s %s',[s, FOwner.GetDayName(TDayOfWeek(DayOfWeek(Date())))]); s := Format('%s %s',[s, FOwner.GetDayName(TDayOfWeek(DayOfWeek(Date())))]);
AppendStr(s, ' ' + FormatDateTime(FOwner.GetDisplayText(dtTodayFormat), Date())); AppendStr(s, ' ' + FormatDateTime(FOwner.GetDisplayText(dtTodayFormat), Date(), FOwner.FFormatSettings));
w1 := FCanvas.TextWidth('aaa'); w1 := FCanvas.TextWidth('aaa');
w2 := FCanvas.TextWidth(' '); w2 := FCanvas.TextWidth(' ');
w3 := FCanvas.TextWidth(s); w3 := FCanvas.TextWidth(s);
@ -1287,6 +1286,7 @@ end;
constructor TCalendarLite.Create(anOwner: TComponent); constructor TCalendarLite.Create(anOwner: TComponent);
begin begin
inherited Create(anOwner); inherited Create(anOwner);
FFormatSettings := DefaultFormatSettings;
FSelDates := TCalDateList.Create; FSelDates := TCalDateList.Create;
FColors := TCalColors.Create(self); FColors := TCalColors.Create(self);
Color := clWhite; Color := clWhite;
@ -1297,8 +1297,6 @@ begin
Constraints.MinWidth := ScaleY(DefMinWidth, DESIGNTIME_PPI); Constraints.MinWidth := ScaleY(DefMinWidth, DESIGNTIME_PPI);
Canvas.Brush.Style := bsSolid; Canvas.Brush.Style := bsSolid;
TabStop := true; TabStop := true;
FDayNames := TStringList.Create;
FMonthNames := TStringList.Create;
FDisplayTexts := TStringList.Create; FDisplayTexts := TStringList.Create;
FDisplayTexts.StrictDelimiter := True; FDisplayTexts.StrictDelimiter := True;
FDisplayTexts.Delimiter := ','; FDisplayTexts.Delimiter := ',';
@ -1321,8 +1319,6 @@ end;
destructor TCalendarLite.Destroy; destructor TCalendarLite.Destroy;
begin begin
FreeAndNil(FSelDates); FreeAndNil(FSelDates);
FreeAndNil(FDayNames);
FreeAndNil(FMonthNames);
FreeAndNil(FDisplayTexts); FreeAndNil(FDisplayTexts);
FreeAndNil(FColors); FreeAndNil(FColors);
SetLength(FCalDrawer.FRowPositions, 0); SetLength(FCalDrawer.FRowPositions, 0);
@ -1448,14 +1444,22 @@ end;
function TCalendarLite.GetDayName(ADayOfWeek: TDayOfWeek): String; function TCalendarLite.GetDayName(ADayOfWeek: TDayOfWeek): String;
begin begin
Result := SysToUTF8(DefaultFormatSettings.ShortDayNames[integer(ADayOfWeek)]); Result := FFormatSettings.ShortDayNames[integer(ADayOfWeek)];
if Pred(integer(ADayOfWeek)) < FDayNames.Count then
Result := FDayNames[Pred(integer(ADayOfWeek))];
end; end;
function TCalendarLite.GetDayNames: String; function TCalendarLite.GetDayNames: String;
var
L: TStrings;
i: Integer;
begin begin
Result := FDayNames.CommaText; L := TStringList.Create;
try
for i:= 1 to 7 do
L.Add(FFormatSettings.ShortDayNames[i]);
Result := L.CommaText;
finally
L.Free;
end;
end; end;
function TCalendarLite.GetDisplayText(aTextIndex: TDisplayText): String; function TCalendarLite.GetDisplayText(aTextIndex: TDisplayText): String;
@ -1470,14 +1474,22 @@ end;
function TCalendarLite.GetMonthName(AMonth: Integer): String; function TCalendarLite.GetMonthName(AMonth: Integer): String;
begin begin
Result := SysToUTF8(DefaultFormatSettings.LongMonthNames[AMonth]); Result := FFormatSettings.LongMonthNames[AMonth];
if pred(AMonth) < FMonthnames.Count then
Result := FMonthNames[pred(AMonth)];
end; end;
function TCalendarLite.GetMonthNames: String; function TCalendarLite.GetMonthNames: String;
var
L: TStrings;
i: Integer;
begin begin
Result := FMonthNames.CommaText; L := TStringList.Create;
try
for i:=1 to 12 do
L.Add(FFormatSettings.ShortMonthNames[i]);
Result := L.CommaText;
finally
L.Free;
end;
end; end;
procedure TCalendarLite.HolidayMenuItemClicked(Sender: TObject); procedure TCalendarLite.HolidayMenuItemClicked(Sender: TObject);
@ -1766,9 +1778,19 @@ begin
end; end;
procedure TCalendarLite.SetDayNames(const AValue: String); procedure TCalendarLite.SetDayNames(const AValue: String);
var
i: Integer;
L: TStrings;
begin begin
FDayNames.CommaText := AValue; L := TStringList.Create;
Invalidate; try
L.CommaText := AValue;
for i := 1 to 7 do
FFormatSettings.ShortDayNames[i] := L[i-1];
Invalidate;
finally
L.Free;
end;
end; end;
procedure TCalendarLite.SetDefaultDisplayTexts; procedure TCalendarLite.SetDefaultDisplayTexts;
@ -1849,9 +1871,19 @@ begin
end; end;
procedure TCalendarLite.SetMonthNames(const AValue: String); procedure TCalendarLite.SetMonthNames(const AValue: String);
var
i: Integer;
L: TStrings;
begin begin
FMonthNames.CommaText := AValue; L := TStringList.Create;
Invalidate; try
L.CommaText := AValue;
for i:= 1 to 12 do
FFormatSettings.ShortMonthNames[i] := L[i-1];
Invalidate;
finally
L.Free;
end;
end; end;
procedure TCalendarLite.SetMultiSelect(AValue: Boolean); procedure TCalendarLite.SetMultiSelect(AValue: Boolean);
@ -1910,7 +1942,7 @@ end;
procedure TCalendarLite.ShowHintWindow(APoint: TPoint; ADate: TDate); procedure TCalendarLite.ShowHintWindow(APoint: TPoint; ADate: TDate);
var var
txt: String; txt: String = '';
y, m, d: Word; y, m, d: Word;
begin begin
if Assigned(FOnHint) then begin if Assigned(FOnHint) then begin