From: <tw...@us...> - 2024-08-24 14:17:49
|
Revision: 4301 http://sourceforge.net/p/gexperts/code/4301 Author: twm Date: 2024-08-24 14:17:47 +0000 (Sat, 24 Aug 2024) Log Message: ----------- moved code from TfmCodeLib.OptionsExecute to TfmCodeOptions.Execute, .SetData and .GetData Modified Paths: -------------- trunk/Source/CodeLibrarian/GX_CodeLib.pas trunk/Source/CodeLibrarian/GX_CodeOpt.pas Modified: trunk/Source/CodeLibrarian/GX_CodeLib.pas =================================================================== --- trunk/Source/CodeLibrarian/GX_CodeLib.pas 2024-08-24 13:15:24 UTC (rev 4300) +++ trunk/Source/CodeLibrarian/GX_CodeLib.pas 2024-08-24 14:17:47 UTC (rev 4301) @@ -7,12 +7,13 @@ interface uses - Windows, SysUtils, + Windows, SysUtils, Forms, Controls, StdActns, Classes, ActnList, Actions, UITypes, Dialogs, Menus, ComCtrls, ToolWin, ExtCtrls, GpStructuredStorage, GX_Experts, GX_EnhancedEditor, - GX_GenericUtils, GX_StringList, GX_SharedImages, GX_BaseForm; + GX_GenericUtils, GX_StringList, GX_SharedImages, GX_BaseForm, + GX_CodeOpt; type TSearchRecord = record @@ -21,8 +22,6 @@ WholeWord: Boolean; end; - TCodeLayout = (clSide, clTop); - TGXStorageFile = class(TObject) private FStorage: IGpStructuredStorage; @@ -287,7 +286,7 @@ Clipbrd, u_dzVclUtils, u_dzStringUtils, {$IFOPT D+} GX_DbugIntf, {$ENDIF} - GX_CodeSrch, GX_CodeOpt, GX_GxUtils, + GX_CodeSrch, GX_GxUtils, GX_OtaUtils, GX_IdeUtils, GX_GExperts, GX_ConfigurationInfo, GX_MessageBox; @@ -953,59 +952,27 @@ procedure TfmCodeLib.OptionsExecute(Sender: TObject); var - frm: TfmCodeOptions; + lStoragePath: string; + lLayout: TCodeLayout; begin - frm := TfmCodeOptions.Create(nil); - try - frm.edPath.Text := StoragePath; - if Layout = clSide then - frm.rbSide.Checked := True - else - frm.rbTop.Checked := True; -{$IFOPT D+}SendDebug('Setting fcTreeView.Text to ' + tvTopics.Font.Name); {$ENDIF} - frm.fcTreeView.ItemIndex := frm.fcTreeView.Items.IndexOf(tvTopics.Font.Name); -{$IFOPT D+}SendDebug('fcTreeView.Text is ' + frm.fcTreeView.Text);{$ENDIF} - frm.udTreeView.Position := tvTopics.Font.Size; - frm.fcEditor.ItemIndex := frm.fcEditor.Items.IndexOf(FCodeText.Font.Name); - frm.udEditor.Position := FCodeText.Font.Size; - - if frm.ShowModal = mrOk then - begin - if (StoragePath <> frm.edPath.Text) then - begin - if CodeDB <> nil then - CloseDB(True); - - FreeAndNil(CodeDB); - tvTopics.Items.Clear; - FCodeText.Clear; - StoragePath := AddSlash(frm.edPath.Text); - CodeDB := OpenStorage(StoragePath + DefaultFileName); - if CodeDB = nil then - begin - MessageDlg(SCouldNotCreateStorage, mtError, [mbOK], 0); - Exit; - end; - InitializeTreeView; + lStoragePath := StoragePath; + lLayout := Layout; + if TfmCodeOptions.Execute(Self, lStoragePath, lLayout, tvTopics.Font, FCodeText.Font) then begin + if StoragePath <> lStoragePath then begin + if CodeDB <> nil then + CloseDB(True); + FreeAndNil(CodeDB); + tvTopics.Items.Clear; + FCodeText.Clear; + StoragePath := AddSlash(lStoragePath); + CodeDB := OpenStorage(StoragePath + DefaultFileName); + if CodeDB = nil then begin + MessageDlg(SCouldNotCreateStorage, mtError, [mbOK], 0); + Exit; end; - if frm.rbSide.Checked then - Layout := clSide - else - Layout := clTop; - - with tvTopics.Font do - begin - Name := frm.fcTreeView.Text; - Size := Trunc(StrToInt(frm.eTreeView.Text)); - end; - with FCodeText.Font do - begin - Name := frm.fcEditor.Text; - Size := Trunc(StrToInt(frm.eEditor.Text)); - end; + InitializeTreeView; end; - finally - FreeAndNil(frm); + Layout := lLayout; end; end; Modified: trunk/Source/CodeLibrarian/GX_CodeOpt.pas =================================================================== --- trunk/Source/CodeLibrarian/GX_CodeOpt.pas 2024-08-24 13:15:24 UTC (rev 4300) +++ trunk/Source/CodeLibrarian/GX_CodeOpt.pas 2024-08-24 14:17:47 UTC (rev 4301) @@ -3,9 +3,12 @@ interface uses - Classes, Controls, Forms, StdCtrls, ExtCtrls, ComCtrls, GX_BaseForm; + Classes, Controls, Forms, StdCtrls, ExtCtrls, ComCtrls, Graphics, GX_BaseForm; type + TCodeLayout = (clSide, clTop); + +type TfmCodeOptions = class(TfmBaseForm) btnOK: TButton; btnCancel: TButton; @@ -38,7 +41,13 @@ private procedure InitializeForm; procedure edPathOnFilesDropped(_Sender: TObject; _Files: TStrings); + procedure SetData(const _StoragePath: string; _Layout: TCodeLayout; + _TreeFont, _EditFont: TFont); + procedure GetData(out _StoragePath: string; out _Layout: TCodeLayout; + _TreeFont, _EditFont: TFont); public + class function Execute(_Owner: TWinControl; var _StoragePath: string; var _Layout: TCodeLayout; + _TreeFont, _EditFont: TFont): Boolean; constructor Create(_Owner: TComponent); override; end; @@ -49,6 +58,55 @@ uses SysUtils, GX_GenericUtils, u_dzVclUtils; +class function TfmCodeOptions.Execute(_Owner: TWinControl; var _StoragePath: string; + var _Layout: TCodeLayout; _TreeFont, _EditFont: TFont): Boolean; +var + frm: TfmCodeOptions; +begin + frm := TfmCodeOptions.Create(nil); + try + TForm_CenterOn(frm, _Owner); + frm.SetData(_StoragePath, _Layout, _TreeFont, _EditFont); + Result :=( frm.ShowModal = mrOk); + if Result then + frm.GetData(_StoragePath, _Layout, _TreeFont, _EditFont); + finally + FreeAndNil(frm); + end; +end; + +procedure TfmCodeOptions.SetData(const _StoragePath: string; _Layout: TCodeLayout; + _TreeFont, _EditFont: TFont); +begin + edPath.Text := _StoragePath; + + if _Layout = clSide then + rbSide.Checked := True + else + rbTop.Checked := True; + + fcTreeview.ItemIndex := fcTreeview.Items.IndexOf(_TreeFont.Name); + udTreeview.Position := _TreeFont.Size; + + fcEditor.ItemIndex := fcEditor.Items.IndexOf(_EditFont.Name); + udEditor.Position := _EditFont.Size; +end; + +procedure TfmCodeOptions.GetData(out _StoragePath: string; out _Layout: TCodeLayout; + _TreeFont, _EditFont: TFont); +begin + _StoragePath := edPath.Text; + if rbSide.Checked then + _Layout := clSide + else + _Layout := clTop; + + _TreeFont.Name := fcTreeview.Text; + _TreeFont.Size := Trunc(StrToInt(eTreeview.Text)); + _EditFont.Name := fcEditor.Text; + _EditFont.Size := Trunc(StrToInt(eEditor.Text)); +end; + procedure TfmCodeOptions.sbBrowseClick(Sender: TObject); var Temp: string; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |