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/vfdforms.pas | |
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/vfdforms.pas')
-rw-r--r-- | uidesigner/vfdforms.pas | 46 |
1 files changed, 33 insertions, 13 deletions
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} |