summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2013-12-20 23:04:35 +0000
committerGraeme Geldenhuys <graemeg@gmail.com>2013-12-20 23:04:35 +0000
commit275addbe8d3581aa5ff0aff9232169c37838dffc (patch)
tree1946e8e0b0cac1d036bc5a20fd43f08824239f39
parent3b52cbcb4decd7ea192d69bc2d3ebfe53a324c72 (diff)
downloadfpGUI-275addbe8d3581aa5ff0aff9232169c37838dffc.tar.xz
uidesigner: Started enabling localisation
- Started extracting string values to resourcestring constants. - Introduced a new vfd_constants unit for all constants and resourcestring constants Still need lots to do.
-rw-r--r--uidesigner/newformdesigner.pas91
-rw-r--r--uidesigner/uidesigner.lpi11
-rw-r--r--uidesigner/uidesigner.lpr9
-rw-r--r--uidesigner/vfd_constants.pas56
-rw-r--r--uidesigner/vfdmain.pas37
5 files changed, 147 insertions, 57 deletions
diff --git a/uidesigner/newformdesigner.pas b/uidesigner/newformdesigner.pas
index eec39b12..0405f7cd 100644
--- a/uidesigner/newformdesigner.pas
+++ b/uidesigner/newformdesigner.pas
@@ -1,7 +1,7 @@
{
fpGUI - Free Pascal GUI Toolkit
- Copyright (C) 2006 - 2010 See the file AUTHORS.txt, included in this
+ Copyright (C) 2006 - 2013 See the file AUTHORS.txt, included in this
distribution, for details of the copyright.
See the file COPYING.modifiedLGPL, included in this distribution,
@@ -61,6 +61,7 @@ type
procedure miHelpAboutClick(Sender: TObject);
procedure miHelpAboutGUI(Sender: TObject);
procedure miMRUClick(Sender: TObject; const FileName: string);
+ procedure SetupCaptions;
public
{@VFD_HEAD_BEGIN: frmMain}
MainMenu: TfpgMenuBar;
@@ -148,15 +149,17 @@ type
TfrmAbout = class(TfpgForm)
private
{@VFD_HEAD_BEGIN: frmAbout}
- lblName1: TfpgLabel;
+ lblAppName: TfpgLabel;
lblVersion: TfpgLabel;
- btnName1: TfpgButton;
- lblName3: TfpgLabel;
- lblName4: TfpgHyperlink;
+ btnClose: TfpgButton;
+ lblWrittenBy: TfpgLabel;
+ lblURL: TfpgHyperlink;
lblCompiled: TfpgLabel;
{@VFD_HEAD_END: frmAbout}
+ procedure SetupCaptions;
+ procedure FormShow(Sender: TObject);
public
- procedure AfterCreate; override;
+ procedure AfterCreate; override;
class procedure Execute;
end;
@@ -172,9 +175,11 @@ implementation
uses
fpg_main,
- vfdmain,
fpg_iniutils,
- fpg_dialogs;
+ fpg_dialogs,
+ fpg_constants,
+ vfdmain,
+ vfd_constants;
// Anchor images
@@ -183,6 +188,25 @@ uses
{@VFD_NEWFORM_IMPL}
+procedure TfrmAbout.SetupCaptions;
+begin
+ WindowTitle := rsDlgProductInfo;
+ lblAppName.Text := cAppName;
+ lblVersion.Text := Format(rsVersion, [cAppVersion]);
+ lblWrittenBy.Text := Format(rsWrittenBy, ['Graeme Geldenhuys']);
+ lblURL.URL := fpGUIWebsite;
+ lblURL.Text := fpGUIWebsite;
+ lblCompiled.Text := Format(rsCompiledOn, [{$I %date%} + ' ' + {$I %time%}]);
+ btnClose.Text := rsClose;
+end;
+
+procedure TfrmAbout.FormShow(Sender: TObject);
+begin
+ SetupCaptions;
+ lblURL.HotTrackColor := clBlue;
+ lblURL.TextColor := clRoyalBlue;
+end;
+
procedure TfrmAbout.AfterCreate;
begin
{%region 'Auto-generated GUI code' -fold}
@@ -191,13 +215,14 @@ begin
SetPosition(378, 267, 276, 180);
WindowTitle := 'Product Information...';
Hint := '';
- Sizeable := False;
WindowPosition := wpScreenCenter;
+ Sizeable := False;
+ OnShow := @FormShow;
- lblName1 := TfpgLabel.Create(self);
- with lblName1 do
+ lblAppName := TfpgLabel.Create(self);
+ with lblAppName do
begin
- Name := 'lblName1';
+ Name := 'lblAppName';
SetPosition(12, 16, 255, 31);
FontDesc := 'Arial-20';
Hint := '';
@@ -215,14 +240,13 @@ begin
Text := 'Version: %s';
end;
- btnName1 := TfpgButton.Create(self);
- with btnName1 do
+ btnClose := TfpgButton.Create(self);
+ with btnClose do
begin
- Name := 'btnName1';
+ Name := 'btnClose';
SetPosition(194, 148, 75, 24);
Anchors := [anRight,anBottom];
Text := 'Close';
- Down := False;
FontDesc := '#Label1';
Hint := '';
ImageName := 'stdimg.close';
@@ -230,27 +254,28 @@ begin
TabOrder := 2;
end;
- lblName3 := TfpgLabel.Create(self);
- with lblName3 do
+ lblWrittenBy := TfpgLabel.Create(self);
+ with lblWrittenBy do
begin
- Name := 'lblName3';
+ Name := 'lblWrittenBy';
SetPosition(12, 100, 241, 14);
FontDesc := 'Arial-9';
Hint := '';
Text := 'Written by Graeme Geldenhuys';
end;
- lblName4 := TfpgHyperlink.Create(self);
- with lblName4 do
+ lblURL := TfpgHyperlink.Create(self);
+ with lblURL do
begin
- Name := 'lblName4';
+ Name := 'lblURL';
SetPosition(12, 116, 246, 14);
- Text := 'http://fpgui.sourceforge.net';
- URL := 'http://fpgui.sourceforge.net';
FontDesc := 'Arial-9:underline';
- TextColor := clRoyalBlue;
+ Hint := '';
HotTrackColor := clBlue;
HotTrackFont := 'Arial-9:underline';
+ Text := 'http://fpgui.sourceforge.net';
+ TextColor := clRoyalBlue;
+ URL := 'http://fpgui.sourceforge.net';
end;
lblCompiled := TfpgLabel.Create(self);
@@ -273,8 +298,6 @@ var
begin
frm := TfrmAbout.Create(nil);
try
- frm.lblVersion.Text := Format(frm.lblVersion.Text, [program_version]);
- frm.lblCompiled.Text := Format(frm.lblCompiled.Text, [ {$I %date%} + ' ' + {$I %time%}]);
frm.ShowModal;
finally
frm.Free;
@@ -314,7 +337,6 @@ begin
Name := 'btnNewForm';
SetPosition(4, 28, 25, 24);
Text := '';
- Down := False;
FontDesc := '#Label1';
Hint := 'Add New Form to Unit';
ImageMargin := -1;
@@ -331,9 +353,8 @@ begin
Name := 'btnOpen';
SetPosition(30, 28, 25, 24);
Text := '';
- Down := False;
FontDesc := '#Label1';
- Hint := 'Open a file';
+ Hint := '';
ImageMargin := -1;
ImageName := 'stdimg.open';
ImageSpacing := 0;
@@ -348,7 +369,6 @@ begin
Name := 'btnSave';
SetPosition(56, 28, 25, 24);
Text := '';
- Down := False;
FontDesc := '#Label1';
Hint := 'Save the current form design';
ImageMargin := -1;
@@ -377,11 +397,12 @@ begin
Name := 'chlPalette';
SetPosition(4, 67, 144, 22);
Anchors := [anLeft,anBottom];
+ ExtraHint := '';
FontDesc := '#List';
Hint := '';
Items.Add('-');
- TabOrder := 5;
FocusItem := 0;
+ TabOrder := 5;
end;
filemenu := TfpgPopupMenu.Create(self);
@@ -897,6 +918,7 @@ procedure TfrmMain.FormShow(Sender: TObject);
begin
gINI.ReadFormState(self);
UpdateWindowPosition;
+ SetupCaptions;
end;
procedure TfrmMain.PaletteBarResized(Sender: TObject);
@@ -937,6 +959,11 @@ begin
maindsgn.OnLoadFile(maindsgn);
end;
+procedure TfrmMain.SetupCaptions;
+begin
+ btnOpen.Hint := rsOpenFormFile;
+end;
+
constructor TfrmMain.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
diff --git a/uidesigner/uidesigner.lpi b/uidesigner/uidesigner.lpi
index 83bb344b..be5b651a 100644
--- a/uidesigner/uidesigner.lpi
+++ b/uidesigner/uidesigner.lpi
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
@@ -32,7 +32,7 @@
<PackageName Value="fpgui_toolkit"/>
</Item1>
</RequiredPackages>
- <Units Count="16">
+ <Units Count="17">
<Unit0>
<Filename Value="uidesigner.lpr"/>
<IsPartOfProject Value="True"/>
@@ -111,10 +111,15 @@
<Filename Value="icons.inc"/>
<IsPartOfProject Value="True"/>
</Unit15>
+ <Unit16>
+ <Filename Value="vfd_constants.pas"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="vfd_constants"/>
+ </Unit16>
</Units>
</ProjectOptions>
<CompilerOptions>
- <Version Value="9"/>
+ <Version Value="11"/>
<SearchPaths>
<UnitOutputDirectory Value="units/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
diff --git a/uidesigner/uidesigner.lpr b/uidesigner/uidesigner.lpr
index 968a45dc..90da9d39 100644
--- a/uidesigner/uidesigner.lpr
+++ b/uidesigner/uidesigner.lpr
@@ -1,7 +1,7 @@
{
fpGUI - Free Pascal GUI Library
- Copyright (C) 2006 - 2010 See the file AUTHORS.txt, included in this
+ Copyright (C) 2006 - 2013 See the file AUTHORS.txt, included in this
distribution, for details of the copyright.
See the file COPYING.modifiedLGPL, included in this distribution,
@@ -25,7 +25,8 @@ uses
{$ENDIF}{$ENDIF}
Classes, SysUtils, fpg_base, fpg_main, vfdmain, vfdresizer, vfdforms,
vfdfile, newformdesigner, vfdwidgets, vfdformparser, vfdeditors,
- vfdwidgetclass, vfdutils, vfdprops, vfddesigner, vfdpropeditgrid;
+ vfdwidgetclass, vfdutils, vfdprops, vfddesigner, vfdpropeditgrid,
+ vfd_constants;
procedure MainProc;
@@ -37,10 +38,10 @@ begin
maindsgn := TMainDesigner.Create;
maindsgn.CreateWindows;
- // Note: This needs improving!!
+ // Making sure the correct form is set as the MainForm
fpgApplication.MainForm := frmMain;
- { If file passed in as param, load it! }
+ { If a file is passed in as a parameter, then load it }
maindsgn.EditedFileName := ParamStr(1);
if FileExists(maindsgn.EditedFileName) then
maindsgn.OnLoadFile(maindsgn);
diff --git a/uidesigner/vfd_constants.pas b/uidesigner/vfd_constants.pas
new file mode 100644
index 00000000..7b49f7f5
--- /dev/null
+++ b/uidesigner/vfd_constants.pas
@@ -0,0 +1,56 @@
+{
+ fpGUI - Free Pascal GUI Toolkit
+
+ Copyright (C) 2006 - 2013 See the file AUTHORS.txt, included in this
+ distribution, for details of the copyright.
+
+ See the file COPYING.modifiedLGPL, included in this distribution,
+ for details about redistributing fpGUI.
+
+ 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.
+
+ Description:
+ This unit contains all the language resource strings used by the
+ UI Designer project. Thus making it possible to translate the UI Designer
+ to other languages.
+ }
+
+unit vfd_constants;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ fpg_constants;
+
+
+const
+ cFileFilter = '%s (%s)|%s';
+ cPascalSourceFiles = '*.pp;*.pas;*.inc;*.dpr;*.lpr';
+ cAppName = 'fpGUI UI Designer';
+ cAppVersion = FPGUI_VERSION;
+ cAppNameAndVersion = cAppName + ' v' + cAppVersion;
+
+resourcestring
+ rsOpenFormFile = 'Open form file';
+ rsPascalSourceFiles = 'Pascal source filess';
+ rsSaveFormFile = 'Save form source';
+ rsVersion = 'Version: %s';
+ rsWrittenBy = 'Written by %s';
+ rsCompiledOn = 'Compiled on: %s';
+
+ rsDlgProductInfo = 'Product Information...';
+
+ rsErrUnitNotFound = 'The unit <%s> was not found.';
+ rsErrLoadingForm = 'Error loading form';
+ rsErrFailedToFindDesignerForm = 'Failed to find Designer Form';
+ rsErrFormSaveIOError = 'Form save I/O failure in <%s>.';
+ rsErrNameConflict = 'Name Conflict';
+
+implementation
+
+end.
+
diff --git a/uidesigner/vfdmain.pas b/uidesigner/vfdmain.pas
index 1f5485dc..51622b9f 100644
--- a/uidesigner/vfdmain.pas
+++ b/uidesigner/vfdmain.pas
@@ -1,7 +1,7 @@
{
fpGUI - Free Pascal GUI Toolkit
- Copyright (C) 2006 - 2010 See the file AUTHORS.txt, included in this
+ Copyright (C) 2006 - 2013 See the file AUTHORS.txt, included in this
distribution, for details of the copyright.
See the file COPYING.modifiedLGPL, included in this distribution,
@@ -28,16 +28,12 @@ uses
fpg_main,
fpg_widget,
fpg_dialogs,
- fpg_constants,
vfdprops,
vfdforms,
vfddesigner,
vfdfile,
newformdesigner;
-const
- program_version = FPGUI_VERSION;
-
type
TMainDesigner = class(TObject)
@@ -85,9 +81,11 @@ var
implementation
uses
- vfdformparser,
+ fpg_constants,
fpg_iniutils,
- fpg_utils;
+ fpg_utils,
+ vfd_constants,
+ vfdformparser;
var
DefaultPasExt : String = '.pas';
@@ -123,8 +121,10 @@ begin
begin
afiledialog := TfpgFileDialog.Create(nil);
afiledialog.Filename := EditedFilename;
- afiledialog.WindowTitle := 'Open form file';
- afiledialog.Filter := 'Pascal source files (*.pp;*.pas;*.inc;*.dpr;*.lpr)|*.pp;*.pas;*.inc;*.dpr;*.lpr|All Files (*)|*';
+ afiledialog.WindowTitle := rsOpenFormFile;
+ afiledialog.Filter :=
+ Format(cFileFilter, [rsPascalSourceFiles, cPascalSourceFiles, cPascalSourceFiles])
+ + '|' + Format(cFileFilter, [rsAllFiles, AllFilesMask, AllFilesMask]);
if afiledialog.RunOpenFile then
begin
EditedFileName := aFileDialog.Filename;
@@ -147,7 +147,7 @@ begin
if not fpgFileExists(fname) then
begin
- ShowMessage('File does not exists.', 'Error loading form');
+ ShowMessage(Format(rsErrUnitNotFound, [fname]), rsErrLoadingForm);
Exit;
end;
@@ -186,8 +186,10 @@ begin
begin
afiledialog := TfpgFileDialog.Create(nil);
afiledialog.Filename := EditedFilename;
- afiledialog.WindowTitle := 'Save form source';
- afiledialog.Filter := 'Pascal source files (*.pp;*.pas;*.inc;*.dpr;*.lpr)|*.pp;*.pas;*.inc;*.dpr;*.lpr|All Files (*)|*';
+ afiledialog.WindowTitle := rsSaveFormFile;
+ afiledialog.Filter :=
+ Format(cFileFilter, [rsPascalSourceFiles, cPascalSourceFiles, cPascalSourceFiles])
+ + '|' + Format(cFileFilter, [rsAllFiles, AllFilesMask, AllFilesMask]);
if afiledialog.RunSaveFile then
begin
fname:=aFileDialog.Filename;
@@ -224,7 +226,7 @@ begin
fd := nil;
fd := Designer(n);
if fd = nil then
- raise Exception.Create('Failed to find Designer Form');
+ raise Exception.Create(rsErrFailedToFindDesignerForm);
FFile.SetFormData(fd.Form.Name, fd.GetFormSourceDecl, fd.GetFormSourceImpl);
end;
@@ -241,8 +243,7 @@ begin
frmMain.mru.AddItem(fname);
except
on E: Exception do
- raise Exception.Create('Form save I/O failure in TMainDesigner.OnSaveFile.' + #13 +
- E.Message);
+ raise Exception.CreateFmt(rsErrFormSaveIOError + LineEnding + E.Message, ['TMainDesigner.OnSaveFile']);
end;
end;
@@ -302,7 +303,7 @@ begin
begin
if DoesNameAlreadyExist(nfrm.edName.Text) then
begin
- TfpgMessageDialog.Critical('Name Conflict','The form name already exists in the current unit, please try again');
+ TfpgMessageDialog.Critical(rsErrNameConflict,'The form name already exists in the current unit, please try again');
exit;
end;
fd := TFormDesigner.Create;
@@ -323,7 +324,7 @@ end;
procedure TMainDesigner.CreateWindows;
begin
frmMain := TfrmMain.Create(nil);
- frmMain.WindowTitle := 'fpGUI Designer v' + program_version;
+ frmMain.WindowTitle := cAppNameAndVersion;
frmMain.Show;
frmProperties := TfrmProperties.Create(nil);
@@ -460,7 +461,7 @@ begin
s := ExtractFileName(FEditedFileName);
if s = '' then
s := '[new]';
- frmMain.WindowTitle := 'fpGUI Designer v' + program_version + ' - ' + s;
+ frmMain.WindowTitle := cAppNameAndVersion + ' - ' + s;
end;
procedure TMainDesigner.LoadDefaults;