lazarus/converter/missingpropertiesdlg.pas
mattias feac6a08fe IDE: clean up
git-svn-id: trunk@24010 -
2010-03-15 11:34:48 +00:00

201 lines
5.9 KiB
ObjectPascal

{ $Id$ }
{
/***************************************************************************
MissingPropertiesDlg.pas
------------------------
***************************************************************************/
***************************************************************************
* *
* This source is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This code 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. See the GNU *
* General Public License for more details. *
* *
* A copy of the GNU General Public License is available on the World *
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
* obtain it by writing to the Free Software Foundation, *
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
***************************************************************************
}
unit MissingPropertiesDlg;
{$mode objfpc}{$H+}
interface
uses
// FCL+LCL
Classes, SysUtils, Math, LCLProc, Forms, Controls,
Graphics, Dialogs, Buttons, StdCtrls,
// components
SynHighlighterLFM, SynEdit, SynEditMiscClasses, LFMTrees,
// codetools
BasicCodeTools, CodeCache, CodeToolManager,
// IDE
IDEDialogs, ComponentReg, PackageIntf, IDEWindowIntf,
CustomFormEditor, LazarusIDEStrConsts, IDEProcs, OutputFilter,
EditorOptions, ExtCtrls, Grids, ConvertSettings, CheckLFMDlg;
type
{ TLfmFixer }
TLFMFixer = class(TLFMChecker)
private
// References to controls in UI:
fPropReplaceGrid: TStringGrid;
protected
function ShowRepairLFMWizard: TModalResult; override;
public
constructor Create(APascalBuffer, ALFMBuffer: TCodeBuffer;
const AOnOutput: TOnAddFilteredLine);
destructor Destroy; override;
function Repair: TModalResult;
end;
{ TFixLFMDialog }
TFixLFMDialog = class(TForm)
ReplaceAllButton: TBitBtn;
CancelButton: TBitBtn;
ErrorsGroupBox: TGroupBox;
ErrorsListBox: TListBox;
PropertyReplaceGroupBox: TGroupBox;
NoteLabel: TLabel;
LFMGroupBox: TGroupBox;
LFMSynEdit: TSynEdit;
BtnPanel: TPanel;
RemoveAllButton: TBitBtn;
Splitter1: TSplitter;
PropertyReplaceGrid: TStringGrid;
SynLFMSyn1: TSynLFMSyn;
procedure ErrorsListBoxClick(Sender: TObject);
procedure RemoveAllButtonClick(Sender: TObject);
procedure ReplaceAllButtonClick(Sender: TObject);
procedure LFMSynEditSpecialLineMarkup(Sender: TObject;
Line: integer; var Special: boolean; AMarkup: TSynSelectedColor);
procedure CheckLFMDialogCREATE(Sender: TObject);
private
fLfmFixer: TLFMFixer;
procedure SetupComponents;
public
constructor Create(AOwner: TComponent; ALfmFixer: TLFMFixer); reintroduce;
destructor Destroy; override;
end;
implementation
{$R *.lfm}
{ TLFMFixer }
constructor TLFMFixer.Create(APascalBuffer, ALFMBuffer: TCodeBuffer;
const AOnOutput: TOnAddFilteredLine);
begin
inherited Create(APascalBuffer, ALFMBuffer, AOnOutput);
end;
destructor TLFMFixer.Destroy;
begin
inherited Destroy;
end;
function TLFMFixer.ShowRepairLFMWizard: TModalResult;
var
FixLFMDialog: TFixLFMDialog;
begin
Result:=mrCancel;
FixLFMDialog:=TFixLFMDialog.Create(nil, self);
try
fLFMSynEdit:=FixLFMDialog.LFMSynEdit;
fErrorsListBox:=FixLFMDialog.ErrorsListBox;
fPropReplaceGrid:=FixLFMDialog.PropertyReplaceGrid;
LoadLFM;
Result:=FixLFMDialog.ShowModal;
finally
FixLFMDialog.Free;
end;
end;
function TLFMFixer.Repair: TModalResult;
begin
Result:=inherited Repair;
end;
{ TFixLFMDialog }
constructor TFixLFMDialog.Create(AOwner: TComponent; ALfmFixer: TLFMFixer);
begin
inherited Create(AOwner);
fLfmFixer:=ALfmFixer;
end;
destructor TFixLFMDialog.Destroy;
begin
inherited Destroy;
end;
procedure TFixLFMDialog.CheckLFMDialogCREATE(Sender: TObject);
begin
Caption:=lisFixLFMFile;
Position:=poScreenCenter;
IDEDialogLayoutList.ApplyLayout(Self,600,400);
SetupComponents;
end;
procedure TFixLFMDialog.ReplaceAllButtonClick(Sender: TObject);
begin
;
end;
procedure TFixLFMDialog.RemoveAllButtonClick(Sender: TObject);
begin
ModalResult:=fLfmFixer.RemoveAll;
end;
procedure TFixLFMDialog.ErrorsListBoxClick(Sender: TObject);
begin
fLfmFixer.JumpToError(fLfmFixer.FindListBoxError);
end;
procedure TFixLFMDialog.LFMSynEditSpecialLineMarkup(Sender: TObject;
Line: integer; var Special: boolean; AMarkup: TSynSelectedColor);
var
CurError: TLFMError;
begin
CurError:=fLfmFixer.fLFMTree.FindErrorAtLine(Line);
if CurError = nil then Exit;
Special := True;
EditorOpts.SetMarkupColor(SynLFMSyn1, ahaErrorLine, AMarkup);
end;
procedure TFixLFMDialog.SetupComponents;
const // Will be moved to LazarusIDEStrConsts
lisReplaceAllProperties = 'Replace all properties';
begin
NoteLabel.Caption:=lisTheLFMLazarusFormFileContainsInvalidPropertiesThis;
ErrorsGroupBox.Caption:=lisErrors;
LFMGroupBox.Caption:=lisLFMFile;
RemoveAllButton.Caption:=lisRemoveAllInvalidProperties;
RemoveAllButton.LoadGlyphFromLazarusResource('laz_delete');
ReplaceAllButton.Caption:=lisReplaceAllProperties;
ReplaceAllButton.LoadGlyphFromLazarusResource('laz_refresh');
EditorOpts.GetHighlighterSettings(SynLFMSyn1);
EditorOpts.GetSynEditSettings(LFMSynEdit);
end;
end.