GridPrinter: Minor rework in multi-language demo.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8615 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-11-12 22:38:55 +00:00
parent 998ea63b35
commit 3af3022fac
2 changed files with 19 additions and 16 deletions

View File

@ -2,10 +2,10 @@ object MainForm: TMainForm
Left = 331 Left = 331
Height = 491 Height = 491
Top = 127 Top = 127
Width = 656 Width = 651
Caption = 'Multi-Language Demonstration of TGridPrinter' Caption = 'Multi-Language Demonstration of TGridPrinter'
ClientHeight = 491 ClientHeight = 491
ClientWidth = 656 ClientWidth = 651
OnCreate = FormCreate OnCreate = FormCreate
LCLVersion = '2.3.0.0' LCLVersion = '2.3.0.0'
object StringGrid1: TStringGrid object StringGrid1: TStringGrid
@ -18,7 +18,7 @@ object MainForm: TMainForm
Left = 8 Left = 8
Height = 411 Height = 411
Top = 39 Top = 39
Width = 640 Width = 635
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 8 BorderSpacing.Around = 8
ColCount = 6 ColCount = 6
@ -85,7 +85,7 @@ object MainForm: TMainForm
Left = 348 Left = 348
Height = 22 Height = 22
Top = 459 Top = 459
Width = 300 Width = 295
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 8 BorderSpacing.Around = 8
DropDownCount = 24 DropDownCount = 24
@ -110,13 +110,13 @@ object MainForm: TMainForm
Left = 8 Left = 8
Height = 23 Height = 23
Top = 8 Top = 8
Width = 640 Width = 635
Align = alTop Align = alTop
AutoSize = True AutoSize = True
BorderSpacing.Around = 8 BorderSpacing.Around = 8
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 23 ClientHeight = 23
ClientWidth = 640 ClientWidth = 635
TabOrder = 5 TabOrder = 5
object Label1: TLabel object Label1: TLabel
AnchorSideLeft.Control = Panel1 AnchorSideLeft.Control = Panel1
@ -137,7 +137,7 @@ object MainForm: TMainForm
Left = 61 Left = 61
Height = 23 Height = 23
Top = 0 Top = 0
Width = 579 Width = 574
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
ItemHeight = 15 ItemHeight = 15
@ -148,9 +148,9 @@ object MainForm: TMainForm
end end
object GridPrinter1: TGridPrinter object GridPrinter1: TGridPrinter
Grid = StringGrid1 Grid = StringGrid1
Footer.Font.Height = -11 Footer.FontSize = 0
Header.Font.Height = -11 Header.Text = 'Test||'
Header.Text = 'test||' Header.FontSize = 0
Left = 168 Left = 168
Top = 96 Top = 96
end end

View File

@ -30,7 +30,7 @@ type
StringGrid1: TStringGrid; StringGrid1: TStringGrid;
procedure btnPrintClick(Sender: TObject); procedure btnPrintClick(Sender: TObject);
procedure btnPreviewClick(Sender: TObject); procedure btnPreviewClick(Sender: TObject);
procedure ccbPreviewOptionsItemChange(Sender: TObject; AIndex: Integer); procedure ccbPreviewOptionsItemChange(Sender: TObject; {%H-}AIndex: Integer);
procedure cmbLanguagesChange(Sender: TObject); procedure cmbLanguagesChange(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
private private
@ -115,15 +115,15 @@ const
var var
i, r, c: Integer; i, r, c: Integer;
begin begin
FLanguagesDir := ExpandFileName(Application.Location + '../../languages/');
PopulateLanguages;
SelectLanguage(cmbLanguages.ItemIndex);
cmbDialogs.ItemIndex := 2; cmbDialogs.ItemIndex := 2;
ccbPreviewOptions.ItemIndex := 0; ccbPreviewOptions.ItemIndex := 0;
for i := 0 to ccbPreviewOptions.Count-1 do for i := 0 to ccbPreviewOptions.Count-1 do
ccbPreviewOptions.Checked[i] := TGridPrintPreviewOption(i) in DEFAULT_GRIDPRN_OPTIONS; ccbPreviewOptions.Checked[i] := TGridPrintPreviewOption(i) in DEFAULT_GRIDPRN_OPTIONS;
FLanguagesDir := ExpandFileName(Application.Location + '../../languages/');
PopulateLanguages;
SelectLanguage(cmbLanguages.ItemIndex);
StringGrid1.BeginUpdate; StringGrid1.BeginUpdate;
try try
StringGrid1.Clear; StringGrid1.Clear;
@ -149,10 +149,12 @@ var
List: TStringList; List: TStringList;
s, lang: String; s, lang: String;
i, j: Integer; i, j: Integer;
appLangMask: String;
begin begin
List := TStringList.Create; List := TStringList.Create;
try try
FindAllFiles(List, FLanguagesDir, 'multilanguage_demo.*.po'); appLangMask := ChangeFileExt(ExtractFileName(Application.ExeName), '.*.po');
FindAllFiles(List, FLanguagesDir, appLangMask);
for i := 0 to List.Count-1 do for i := 0 to List.Count-1 do
begin begin
s := List[i]; s := List[i];
@ -166,6 +168,7 @@ begin
case lowercase(lang) of case lowercase(lang) of
'de': List[i] := 'de - Deutsch'; 'de': List[i] := 'de - Deutsch';
'en': List[i] := 'en - English'; 'en': List[i] := 'en - English';
// Add more cases when translations are available...
end; end;
end; end;
List.Sort; List.Sort;