diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2013-12-20 23:28:37 +0000 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2013-12-20 23:28:37 +0000 |
commit | 39744dfed5965727374d2cf736979521407d449d (patch) | |
tree | b2d86f5deb1c3f8fc5662a47df22c67f9733ad01 /uidesigner | |
parent | 548e0111e8f5474adb967791fb713dfe71f71a42 (diff) | |
download | fpGUI-39744dfed5965727374d2cf736979521407d449d.tar.xz |
uidesigner: using inheritance to simplify setting localisation values.
Introduced virtual methods that simply need to be overwritten in
descendants, which then set localisation values.
Also moved some constants to the vfd_constants unit.
Diffstat (limited to 'uidesigner')
-rw-r--r-- | uidesigner/vfd_constants.pas | 2 | ||||
-rw-r--r-- | uidesigner/vfdforms.pas | 46 |
2 files changed, 35 insertions, 13 deletions
diff --git a/uidesigner/vfd_constants.pas b/uidesigner/vfd_constants.pas index 25fe3ee3..b39cfda0 100644 --- a/uidesigner/vfd_constants.pas +++ b/uidesigner/vfd_constants.pas @@ -33,6 +33,7 @@ const cAppName = 'fpGUI UI Designer'; cAppVersion = FPGUI_VERSION; cAppNameAndVersion = cAppName + ' v' + cAppVersion; + cDesignerINIVersion = 1; resourcestring rsOpenFormFile = 'Open form file'; @@ -44,6 +45,7 @@ resourcestring rsNewUnnamedForm = 'new'; rsDlgProductInfo = 'Product Information...'; + rsDlgSetup = 'General Settings...'; rsErrUnitNotFound = 'The unit <%s> was not found.'; rsErrLoadingForm = 'Error loading form'; diff --git a/uidesigner/vfdforms.pas b/uidesigner/vfdforms.pas index d1557fbc..f3e6a935 100644 --- a/uidesigner/vfdforms.pas +++ b/uidesigner/vfdforms.pas @@ -40,7 +40,11 @@ type TVFDDialog = class(TfpgForm) protected - procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override; + procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override; + procedure SetupCaptions; virtual; + procedure FormShow(Sender: TObject); virtual; + public + constructor Create(AOwner: TComponent); override; end; @@ -105,13 +109,15 @@ type end; - TfrmVFDSetup = class(TfpgForm) + TfrmVFDSetup = class(TVFDDialog) private FINIVersion: integer; - procedure FormShow(Sender: TObject); procedure LoadSettings; procedure SaveSettings; procedure btnOKClick(Sender: TObject); + protected + procedure FormShow(Sender: TObject); override; + procedure SetupCaptions; override; public {@VFD_HEAD_BEGIN: frmVFDSetup} lb1: TfpgLabel; @@ -132,7 +138,6 @@ type cbIndentationType: TfpgComboBox; lblIndentType: TfpgLabel; {@VFD_HEAD_END: frmVFDSetup} - constructor Create(AOwner: TComponent); override; procedure AfterCreate; override; procedure BeforeDestruction; override; end; @@ -145,11 +150,9 @@ uses fpg_main, fpg_iniutils, fpg_constants, + vfd_constants, vfdprops; // used to get Object Inspector defaults -const - cDesignerINIVersion = 1; - { TInsertCustomForm } @@ -388,6 +391,11 @@ end; { TVFDDialogBase } +procedure TVFDDialog.FormShow(Sender: TObject); +begin + SetupCaptions; +end; + procedure TVFDDialog.HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); begin if keycode = keyEscape then @@ -398,8 +406,20 @@ begin inherited HandleKeyPress(keycode, shiftstate, consumed); end; +procedure TVFDDialog.SetupCaptions; +begin + // to be implemented in descendants +end; + +constructor TVFDDialog.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + OnShow := @FormShow; +end; + procedure TfrmVFDSetup.FormShow(Sender: TObject); begin + inherited FormShow(Sender); { If it's an older version, don't load the size because the dialog dimensions probably changed in a newer version } if FINIVersion >= cDesignerINIVersion then @@ -408,6 +428,12 @@ begin gINI.ReadFormState(self, -1, -1, True); end; +procedure TfrmVFDSetup.SetupCaptions; +begin + inherited SetupCaptions; + WindowTitle := rsDlgSetup; +end; + procedure TfrmVFDSetup.LoadSettings; begin FINIVersion := gINI.ReadInteger('Designer', 'Version', 0); @@ -440,12 +466,6 @@ begin ModalResult := mrOK; end; -constructor TfrmVFDSetup.Create(AOwner: TComponent); -begin - inherited Create(AOwner); - OnShow := @FormShow; -end; - procedure TfrmVFDSetup.AfterCreate; begin {@VFD_BODY_BEGIN: frmVFDSetup} |