From 8b8e6e91c58d73b8bd543433f789c43d062fd10a Mon Sep 17 00:00:00 2001 From: graemeg Date: Thu, 21 Aug 2008 13:03:20 +0000 Subject: * Applied UI Designer patch from MvC. Adding improved support of OI property undo feature. Behaviour is also adjustable in General Options dialog. * Fixed tab order of General Options dialog in UI Designer. --- examples/apps/uidesigner/vfdforms.pas | 50 ++++++++++++++++++++++------------- examples/apps/uidesigner/vfdmain.pas | 4 ++- examples/apps/uidesigner/vfdprops.pas | 17 +++++++++++- 3 files changed, 51 insertions(+), 20 deletions(-) (limited to 'examples/apps') diff --git a/examples/apps/uidesigner/vfdforms.pas b/examples/apps/uidesigner/vfdforms.pas index 576b65c7..61ce43c2 100644 --- a/examples/apps/uidesigner/vfdforms.pas +++ b/examples/apps/uidesigner/vfdforms.pas @@ -119,6 +119,7 @@ TfrmVFDSetup = class(TfpgForm) lblName2: TfpgLabel; eDefaultExt: TfpgEdit; lblName3: TfpgLabel; + cbUndoOnExit: TfpgCheckBox; {@VFD_HEAD_END: frmVFDSetup} procedure AfterCreate; override; procedure BeforeDestruction; override; @@ -131,7 +132,8 @@ implementation uses fpgfx, gui_iniutils, - gfx_constants; + gfx_constants, + vfdprops; // used to get Object Inspector defaults { TInsertCustomForm } @@ -415,7 +417,8 @@ procedure TfrmVFDSetup.LoadSettings; chlGrid.FocusItem := gINI.ReadInteger('Options', 'GridResolution', 2); tbMRUFileCount.Position := gINI.ReadInteger('Options', 'MRUFileCount', 4); cbFullPath.Checked := gINI.ReadBool('Options', 'ShowFullPath', True); - eDefaultExt.Text:=gINI.ReadString('Options','DefaultFileExt','.pas'); + eDefaultExt.Text := gINI.ReadString('Options', 'DefaultFileExt', '.pas'); + cbUndoOnExit.Checked := gINI.ReadBool('Options', 'UndoOnExit', UndoOnPropExit); end; procedure TfrmVFDSetup.SaveSettings; @@ -423,7 +426,8 @@ procedure TfrmVFDSetup.SaveSettings; gINI.WriteInteger('Options', 'GridResolution', chlGrid.FocusItem); gINI.WriteInteger('Options', 'MRUFileCount', tbMRUFileCount.Position); gINI.WriteBool('Options', 'ShowFullPath', cbFullPath.Checked); - gINI.WriteString('Options','DefaultFileExt',eDefaultExt.Text); + gINI.WriteString('Options', 'DefaultFileExt', eDefaultExt.Text); + gINI.WriteBool('Options', 'UndoOnExit', cbUndoOnExit.Checked); end; procedure TfrmVFDSetup.btnOKClick(Sender: TObject); @@ -436,7 +440,7 @@ procedure TfrmVFDSetup.AfterCreate; begin {@VFD_BODY_BEGIN: frmVFDSetup} Name := 'frmVFDSetup'; - SetPosition(394, 399, 252, 217); + SetPosition(394, 399, 253, 225); WindowTitle := 'General settings'; WindowPosition := wpScreenCenter; gINI.ReadFormState(self); @@ -467,12 +471,12 @@ procedure TfrmVFDSetup.AfterCreate; with btnOK do begin Name := 'btnOK'; - SetPosition(92, 187, 75, 24); + SetPosition(93, 195, 75, 24); Anchors := [anRight,anBottom]; Text := 'OK'; FontDesc := '#Label1'; ImageName := 'stdimg.ok'; - TabOrder := 2; + TabOrder := 6; OnClick := @btnOKClick; end; @@ -480,20 +484,20 @@ procedure TfrmVFDSetup.AfterCreate; with btnCancel do begin Name := 'btnCancel'; - SetPosition(171, 187, 75, 24); + SetPosition(172, 195, 75, 24); Anchors := [anRight,anBottom]; Text := 'Cancel'; FontDesc := '#Label1'; ImageName := 'stdimg.cancel'; ModalResult := -1; - TabOrder := 3; + TabOrder := 7; end; lblRecentFiles := TfpgLabel.Create(self); with lblRecentFiles do begin Name := 'lblRecentFiles'; - SetPosition(28, 88, 136, 16); + SetPosition(28, 92, 124, 16); FontDesc := '#Label1'; Text := 'Recent files count:'; end; @@ -502,21 +506,21 @@ procedure TfrmVFDSetup.AfterCreate; with tbMRUFileCount do begin Name := 'tbMRUFileCount'; - SetPosition(156, 80, 76, 30); + SetPosition(156, 84, 76, 30); Max := 10; Min := 2; Position := 4; ShowPosition := True; - TabOrder := 5; + TabOrder := 3; end; cbFullPath := TfpgCheckBox.Create(self); with cbFullPath do begin Name := 'cbFullPath'; - SetPosition(24, 108, 204, 20); + SetPosition(24, 112, 204, 20); FontDesc := '#Label1'; - TabOrder := 6; + TabOrder := 4; Text := 'Show the full file path'; end; @@ -533,7 +537,7 @@ procedure TfrmVFDSetup.AfterCreate; with lblName2 do begin Name := 'lblName2'; - SetPosition(8, 64, 232, 16); + SetPosition(8, 72, 232, 16); FontDesc := '#Label2'; Text := 'Open Recent menu settings'; end; @@ -542,8 +546,8 @@ procedure TfrmVFDSetup.AfterCreate; with eDefaultExt do begin Name := 'eDefaultExt'; - SetPosition(28, 152, 120, 20); - TabOrder := 9; + SetPosition(28, 160, 68, 22); + TabOrder := 5; Text := ''; FontDesc := '#Edit1'; end; @@ -552,9 +556,19 @@ procedure TfrmVFDSetup.AfterCreate; with lblName3 do begin Name := 'lblName3'; - SetPosition(12, 132, 152, 14); + SetPosition(12, 140, 152, 16); + FontDesc := '#Label2'; + Text := 'Default file extension'; + end; + + cbUndoOnExit := TfpgCheckBox.Create(self); + with cbUndoOnExit do + begin + Name := 'cbUndoOnExit'; + SetPosition(24, 48, 204, 18); FontDesc := '#Label1'; - Text := 'Default file extension:'; + TabOrder := 2; + Text := 'Undo on property editor exit'; end; {@VFD_BODY_END: frmVFDSetup} diff --git a/examples/apps/uidesigner/vfdmain.pas b/examples/apps/uidesigner/vfdmain.pas index 4713b7c8..b11a5f02 100644 --- a/examples/apps/uidesigner/vfdmain.pas +++ b/examples/apps/uidesigner/vfdmain.pas @@ -26,6 +26,7 @@ interface SysUtils, gfx_widget, gui_dialogs, + vfdprops, vfdforms, vfddesigner, vfdfile, @@ -436,7 +437,8 @@ procedure TMainDesigner.LoadDefaults; 1: GridResolution := 4; 2: GridResolution := 8; end; - DefaultPasExt:=gINI.ReadString('Options','DefaultFileExt', '.pas'); + DefaultPasExt := gINI.ReadString('Options', 'DefaultFileExt', '.pas'); + UndoOnPropExit := gINI.ReadBool('Options', 'UndoOnExit', DefUndoOnPropExit); end; end. diff --git a/examples/apps/uidesigner/vfdprops.pas b/examples/apps/uidesigner/vfdprops.pas index 7e033d24..a46b73c5 100644 --- a/examples/apps/uidesigner/vfdprops.pas +++ b/examples/apps/uidesigner/vfdprops.pas @@ -139,6 +139,11 @@ TExternalPropertyEditor = class(TVFDPropertyEditor) procedure EditStringList(sl: TStringList); procedure GetEnumPropValueList(wg: TObject; const APropName: string; sl: TStringList); +const + DefUndoOnPropExit = False; + +var + UndoOnPropExit: Boolean = DefUndoOnPropExit; implementation @@ -280,7 +285,13 @@ function TPropertyInteger.ParseSourceLine(wg: TfpgWidget; const line: string): b procedure TGeneralPropertyEditor.EditExit(Sender: TObject); begin if FOrigValue <> edit.Text then - edit.Text := FOrigvalue; + if UndoOnPropExit then + edit.Text := FOrigvalue + else + begin + UpdateProperty(nil); + FOrigValue := edit.Text; + end; end; procedure TGeneralPropertyEditor.EditKeyPressed(Sender: TObject; @@ -291,6 +302,10 @@ procedure TGeneralPropertyEditor.EditKeyPressed(Sender: TObject; UpdateProperty(nil); FOrigValue := edit.Text; end + else if (keycode=keyEscape) then + begin + edit.Text := FOrigValue; + end else inherited; end; -- cgit v1.2.3-54-g00ecf