Converter: Another revamp of settings GUI

git-svn-id: trunk@29377 -
This commit is contained in:
juha 2011-02-04 17:56:01 +00:00
parent 23f651e8ad
commit 4f8d7a9757
6 changed files with 316 additions and 293 deletions

View File

@ -238,7 +238,7 @@ begin
ReadNextAtom; // name
ReadNextAtom; // semicolon
InsertPos:=CurPos.EndPos;
if fCTLink.Settings.Target in [ctLazarusDelphi, ctLazarusDelphiSameDfm] then
if fCTLink.Settings.SupportDelphi then
s:='{$IFDEF FPC}'+LineEnding+' {$MODE Delphi}'+LineEnding+'{$ENDIF}'
else
s:='{$MODE Delphi}';
@ -278,9 +278,9 @@ begin
LowKey:=LowerCase(Key);
// Form file resource rename or lowercase:
if (LowKey='dfm') or (LowKey='xfm') then begin
if fCTLink.Settings.Target in [ctLazarusDelphi, ctLazarusDelphiSameDfm] then begin
if fCTLink.Settings.SupportDelphi then begin
// Use the same dfm file. Lowercase existing key.
if (fCTLink.Settings.Target=ctLazarusDelphiSameDfm) and (Key<>LowKey) then
if fCTLink.Settings.SameDfmFile and (Key<>LowKey) then
NewKey:=LowKey;
// Later IFDEF will be added so that Delphi can still use .dfm.
fDfmDirectiveStart:=ACleanPos;
@ -302,7 +302,7 @@ begin
ACleanPos:=FindCommentEnd(Src, ACleanPos, Scanner.NestedComments);
until false;
// if there is already .lfm file, don't add IFDEF for .dfm / .lfm.
if (fCTLink.Settings.Target=ctLazarusDelphi) and (fDfmDirectiveStart<>-1)
if fCTLink.Settings.SupportDelphi and (fDfmDirectiveStart<>-1)
and not AlreadyIsLfm then begin
// Add IFDEF for .lfm and .dfm allowing Delphi to use .dfm.
s:='{$IFNDEF FPC}'+LineEnding+

View File

@ -543,7 +543,7 @@ begin
Result:=LazarusIDE.DoCloseEditorFile(ADfmFilename,[cfSaveFirst]);
if Result<>mrOk then exit;
end;
if fSettings.Target=ctLazarusDelphiSameDfm then
if fSettings.SameDfmFile then
LfmFilename:=ADfmFilename
else begin
// Create a form file name based on the unit file name.
@ -555,7 +555,7 @@ begin
DeleteFileUTF8(LfmFilename); // .lfm is older than .dfm -> remove .lfm
if not FileExistsUTF8(LfmFilename) then begin
// TODO: update project
if fSettings.Target=ctLazarusDelphi then
if fSettings.SupportDelphi and not fSettings.SameDfmFile then
Result:=CopyFileWithErrorDialogs(ADfmFilename,LfmFilename,[mbAbort])
else
Result:=fSettings.RenameFile(ADfmFilename,LfmFilename);
@ -568,7 +568,7 @@ begin
Result:=ConvertDfmToLfm(LfmFilename);
if Result<>mrOk then exit;
// Read form file code in.
if fSettings.Target<>ctLazarusDelphiSameDfm then begin
if not fSettings.SameDfmFile then begin
Result:=LoadCodeBuffer(fLFMBuffer,LfmFilename,
[lbfCheckIfText,lbfUpdateFromDisk],true);
end;
@ -692,8 +692,7 @@ begin
repeat
TryAgain:=False;
Result:=AskMissingUnits(MainUsedUnits.MissingUnits, ImplUsedUnits.MissingUnits,
ExtractFileName(fLazUnitFilename),
fSettings.Target in [ctLazarusDelphi, ctLazarusDelphiSameDfm]);
ExtractFileName(fLazUnitFilename), fSettings.SupportDelphi);
case Result of
// mrOK means: comment out.
mrOK: begin
@ -1270,7 +1269,7 @@ var
begin
// Converter for main LPR file.
fMainUnitConverter:=TConvertDelphiUnit.Create(Self,fOrigPFilename,[]);
if fSettings.Target in [ctLazarusDelphi, ctLazarusDelphiSameDfm] then
if fSettings.SupportDelphi then
fMainUnitConverter.LazFileExt:=ExtractFileExt(fOrigPFilename)
else
fMainUnitConverter.LazFileExt:='.lpr';

View File

@ -1,24 +1,26 @@
object ConvertSettingsForm: TConvertSettingsForm
Left = 267
Height = 580
Top = 113
Width = 528
Left = 315
Height = 341
Top = 127
Width = 561
ActiveControl = ProjectPathEdit
Caption = 'Convert Delphi unit, project or package '
ClientHeight = 580
ClientWidth = 528
Constraints.MinHeight = 400
ClientHeight = 341
ClientWidth = 561
Constraints.MinHeight = 300
Constraints.MinWidth = 400
OnCreate = FormCreate
OnDestroy = FormDestroy
Position = poScreenCenter
LCLVersion = '0.9.29'
LCLVersion = '0.9.31'
object ProjectPathEdit: TLabeledEdit
Left = 112
Height = 21
AnchorSideLeft.Control = Owner
Left = 9
Height = 17
Hint = 'Directory where project''s main file must be'
Top = 15
Width = 372
Anchors = [akTop, akLeft, akRight]
Top = 32
Width = 287
BorderSpacing.Left = 9
BorderStyle = bsNone
Color = clBtnFace
EditLabel.AnchorSideLeft.Control = ProjectPathEdit
@ -26,13 +28,12 @@ object ConvertSettingsForm: TConvertSettingsForm
EditLabel.AnchorSideTop.Side = asrCenter
EditLabel.AnchorSideRight.Control = ProjectPathEdit
EditLabel.AnchorSideBottom.Control = ProjectPathEdit
EditLabel.Left = 27
EditLabel.Left = 9
EditLabel.Height = 16
EditLabel.Top = 17
EditLabel.Top = 9
EditLabel.Width = 78
EditLabel.Caption = 'Project Path:'
EditLabel.ParentColor = False
LabelPosition = lpLeft
LabelSpacing = 7
ParentShowHint = False
ReadOnly = True
@ -40,14 +41,15 @@ object ConvertSettingsForm: TConvertSettingsForm
TabOrder = 0
end
object BackupCheckBox: TCheckBox
AnchorSideLeft.Control = ProjectPathEdit
AnchorSideTop.Control = ProjectPathEdit
AnchorSideLeft.Control = TargetGroupBox
AnchorSideTop.Control = TargetGroupBox
AnchorSideTop.Side = asrBottom
Left = 112
Height = 21
Left = 12
Height = 20
Hint = 'Creates a Backup directory under project directory'
Top = 45
Top = 165
Width = 208
BorderSpacing.Left = 3
BorderSpacing.Top = 9
Caption = 'Make backup of changed files'
Checked = True
@ -58,9 +60,9 @@ object ConvertSettingsForm: TConvertSettingsForm
end
object ButtonPanel1: TButtonPanel
Left = 6
Height = 39
Top = 535
Width = 516
Height = 40
Top = 295
Width = 549
OKButton.Name = 'OKButton'
OKButton.Caption = '&OK'
HelpButton.Name = 'HelpButton'
@ -73,297 +75,304 @@ object ConvertSettingsForm: TConvertSettingsForm
TabOrder = 2
ShowButtons = [pbOK, pbCancel, pbHelp]
end
object TargetRadioGroup: TRadioGroup
Left = 12
Height = 80
Hint = 'Converter adds conditional compilation to support different targets'
Top = 96
Width = 507
Anchors = [akTop, akLeft, akRight]
AutoFill = True
Caption = 'Target'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 61
ClientWidth = 503
Columns = 2
ItemIndex = 0
Items.Strings = (
'Lazarus'
'Lazarus and Delphi'
'Lazarus for Windows only'
'Lazarus and Delphi with same DFM file'
)
OnClick = TargetRadioGroupClick
ParentFont = False
ParentShowHint = False
ShowHint = True
TabOrder = 3
end
object KeepFileOpenCheckBox: TCheckBox
AnchorSideLeft.Control = BackupCheckBox
AnchorSideTop.Control = BackupCheckBox
AnchorSideTop.Side = asrBottom
Left = 112
Height = 21
Left = 12
Height = 20
Hint = 'Separate form files allow different properties'
Top = 69
Top = 190
Width = 241
BorderSpacing.Top = 3
BorderSpacing.Top = 5
Caption = 'Keep converted files open in editor'
ParentShowHint = False
ShowHint = True
TabOrder = 4
TabOrder = 3
end
object UnitReplaceDivider: TDividerBevel
AnchorSideTop.Control = TargetRadioGroup
AnchorSideTop.Side = asrBottom
Left = 0
AnchorSideTop.Control = Owner
Left = 296
Height = 17
Top = 189
Width = 523
Top = 9
Width = 239
Caption = 'Unit Replacements'
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 13
BorderSpacing.Top = 9
Font.Style = [fsBold]
ParentFont = False
ParentShowHint = False
ShowHint = True
LeftIndent = 30
end
object UnknownPropsDivider: TDividerBevel
AnchorSideLeft.Control = UnitReplaceDivider
AnchorSideTop.Control = UnitReplaceDivider
AnchorSideTop.Side = asrBottom
Left = 0
AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom
Left = 296
Height = 17
Top = 256
Width = 523
Top = 65
Width = 239
Caption = 'Unknown properties'
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 50
BorderSpacing.Top = 39
Font.Style = [fsBold]
ParentFont = False
ParentShowHint = False
ShowHint = True
LeftIndent = 30
end
object UnitReplaceButton: TBitBtn
AnchorSideLeft.Control = UnitReplaceDivider
AnchorSideTop.Control = UnitReplaceDivider
AnchorSideTop.Side = asrBottom
Left = 12
Height = 30
Left = 297
Height = 25
Hint = 'Unit names in uses section of a source unit'
Top = 213
Width = 92
BorderSpacing.Top = 7
Top = 27
Width = 75
BorderSpacing.Left = 1
BorderSpacing.Top = 1
Caption = 'Edit'
OnClick = UnitReplaceButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 5
TabOrder = 4
end
object TypeReplaceDivider: TDividerBevel
AnchorSideLeft.Control = UnitReplaceDivider
AnchorSideTop.Control = UnknownPropsDivider
AnchorSideTop.Side = asrBottom
Left = 0
AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom
Left = 296
Height = 17
Top = 323
Width = 523
Top = 121
Width = 239
Caption = 'Type Replacements'
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 50
BorderSpacing.Top = 39
Font.Style = [fsBold]
ParentFont = False
ParentShowHint = False
ShowHint = True
LeftIndent = 30
end
object TypeReplaceButton: TBitBtn
AnchorSideLeft.Control = TypeReplaceDivider
AnchorSideTop.Control = TypeReplaceDivider
AnchorSideTop.Side = asrBottom
Left = 12
Height = 30
Left = 297
Height = 25
Hint = 'Unknown types in form file (DFM/LFM)'
Top = 347
Width = 92
BorderSpacing.Top = 7
Top = 139
Width = 75
BorderSpacing.Left = 1
BorderSpacing.Top = 1
Caption = 'Edit'
OnClick = TypeReplaceButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 6
TabOrder = 5
end
object TypeReplaceInfoLabel: TLabel
AnchorSideLeft.Control = TypeReplaceButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = TypeReplaceButton
AnchorSideTop.Side = asrCenter
Left = 144
Left = 395
Height = 16
Top = 354
Top = 143
Width = 67
BorderSpacing.Left = 23
Caption = 'Interactive'
ParentColor = False
end
object FuncReplaceDivider: TDividerBevel
AnchorSideLeft.Control = UnitReplaceDivider
AnchorSideTop.Control = TypeReplaceDivider
AnchorSideTop.Side = asrBottom
Left = 0
AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom
Left = 296
Height = 17
Top = 390
Width = 523
Top = 177
Width = 239
Caption = 'Function Replacements'
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 50
BorderSpacing.Top = 39
Font.Style = [fsBold]
ParentFont = False
ParentShowHint = False
ShowHint = True
LeftIndent = 30
end
object CoordOffsDivider: TDividerBevel
AnchorSideLeft.Control = UnitReplaceDivider
AnchorSideTop.Control = FuncReplaceDivider
AnchorSideTop.Side = asrBottom
Left = 0
AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom
Left = 296
Height = 17
Top = 457
Width = 523
Top = 233
Width = 239
Caption = 'Coordinate Offsets'
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 50
BorderSpacing.Top = 39
Font.Style = [fsBold]
ParentFont = False
ParentShowHint = False
ShowHint = True
LeftIndent = 30
end
object FuncReplaceButton: TBitBtn
AnchorSideLeft.Control = FuncReplaceDivider
AnchorSideTop.Control = FuncReplaceDivider
AnchorSideTop.Side = asrBottom
Left = 12
Height = 30
Left = 297
Height = 25
Hint = 'Some Delphi functions can be replaced with a LCL function'
Top = 414
Width = 92
BorderSpacing.Top = 7
Top = 195
Width = 75
BorderSpacing.Left = 1
BorderSpacing.Top = 1
Caption = 'Edit'
OnClick = FuncReplaceButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 7
TabOrder = 6
end
object CoordOffsButton: TBitBtn
AnchorSideLeft.Control = CoordOffsDivider
AnchorSideTop.Control = CoordOffsDivider
AnchorSideTop.Side = asrBottom
Left = 12
Height = 30
Left = 297
Height = 25
Hint = 'Some Delphi functions can be replaced with a LCL function'
Top = 481
Width = 92
BorderSpacing.Top = 7
Top = 251
Width = 75
BorderSpacing.Left = 1
BorderSpacing.Top = 1
Caption = 'Edit'
OnClick = CoordOffsButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 8
TabOrder = 7
end
object UnitReplaceRadioGroup: TRadioGroup
AnchorSideTop.Control = UnitReplaceDivider
object TargetGroupBox: TGroupBox
AnchorSideLeft.Control = ProjectPathEdit
AnchorSideTop.Control = ProjectPathEdit
AnchorSideTop.Side = asrBottom
Left = 144
Height = 36
Top = 207
Width = 340
AutoFill = True
BorderSpacing.Top = 1
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 17
ClientWidth = 336
Columns = 3
ItemIndex = 0
Items.Strings = (
'Disabled'
'Interactive'
'Automatic'
)
Left = 9
Height = 96
Hint = 'xxx'
Top = 60
Width = 228
BorderSpacing.Top = 11
Caption = 'Target'
ClientHeight = 77
ClientWidth = 224
ParentShowHint = False
ShowHint = True
TabOrder = 8
object SupportDelphiCheckBox: TCheckBox
AnchorSideLeft.Control = MultiPlatformCheckBox
AnchorSideTop.Control = MultiPlatformCheckBox
AnchorSideTop.Side = asrBottom
Left = 10
Height = 20
Top = 29
Width = 115
BorderSpacing.Top = 5
Caption = 'Support Delphi'
OnChange = SupportDelphiCheckBoxChange
ParentShowHint = False
ShowHint = True
TabOrder = 0
end
object SameDfmCheckBox: TCheckBox
AnchorSideLeft.Control = SupportDelphiCheckBox
AnchorSideTop.Control = SupportDelphiCheckBox
AnchorSideTop.Side = asrBottom
Left = 10
Height = 20
Top = 54
Width = 194
BorderSpacing.Top = 5
Caption = 'Use the same DFM form file'
OnChange = SameDfmCheckBoxChange
ParentShowHint = False
ShowHint = True
TabOrder = 1
end
object MultiPlatformCheckBox: TCheckBox
AnchorSideTop.Control = TargetGroupBox
Left = 10
Height = 20
Top = 4
Width = 108
BorderSpacing.Top = 4
Caption = 'Multi-Platform'
ParentShowHint = False
ShowHint = True
TabOrder = 2
end
end
object UnitReplaceComboBox: TComboBox
AnchorSideLeft.Control = UnitReplaceButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = UnitReplaceButton
AnchorSideTop.Side = asrCenter
Left = 395
Height = 21
Top = 29
Width = 136
BorderSpacing.Left = 23
ItemHeight = 0
Style = csDropDownList
TabOrder = 9
end
object UnknownPropsRadioGroup: TRadioGroup
object UnknownPropsComboBox: TComboBox
AnchorSideLeft.Control = UnitReplaceComboBox
AnchorSideTop.Control = UnknownPropsDivider
AnchorSideTop.Side = asrBottom
Left = 144
Height = 36
Top = 274
Width = 340
AutoFill = True
BorderSpacing.Top = 1
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3
ClientHeight = 17
ClientWidth = 336
Columns = 3
ItemIndex = 0
Items.Strings = (
'Disabled'
'Interactive'
'Automatic'
)
Left = 395
Height = 21
Top = 84
Width = 136
BorderSpacing.Top = 2
ItemHeight = 0
Style = csDropDownList
TabOrder = 10
end
object FuncReplaceRadioGroup: TRadioGroup
AnchorSideTop.Control = FuncReplaceDivider
AnchorSideTop.Side = asrBottom
Left = 144
Height = 36
Top = 408
Width = 340
AutoFill = True
BorderSpacing.Top = 1
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 17
ClientWidth = 336
Columns = 2
ItemIndex = 0
Items.Strings = (
'Disabled'
'Enabled'
)
object FuncReplaceComboBox: TComboBox
AnchorSideLeft.Control = FuncReplaceButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = FuncReplaceButton
AnchorSideTop.Side = asrCenter
Left = 395
Height = 21
Top = 197
Width = 136
BorderSpacing.Left = 23
ItemHeight = 0
Style = csDropDownList
TabOrder = 11
end
object CoordOffsRadioGroup: TRadioGroup
AnchorSideTop.Control = CoordOffsDivider
AnchorSideTop.Side = asrBottom
Left = 144
Height = 36
Top = 475
Width = 340
AutoFill = True
BorderSpacing.Top = 1
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 17
ClientWidth = 336
Columns = 2
ItemIndex = 0
Items.Strings = (
'Disabled'
'Enabled'
)
object CoordOffsComboBox: TComboBox
AnchorSideLeft.Control = CoordOffsButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CoordOffsButton
AnchorSideTop.Side = asrCenter
Left = 395
Height = 21
Top = 253
Width = 136
BorderSpacing.Left = 23
ItemHeight = 0
Style = csDropDownList
TabOrder = 12
end
end

View File

@ -37,7 +37,6 @@ uses
type
TConvertTarget = (ctLazarus, ctLazarusDelphi, ctLazarusWin, ctLazarusDelphiSameDfm);
TReplaceModeLong = (rlDisabled, rlInteractive, rlAutomatic);
TReplaceModeShort = (rsDisabled, rsEnabled);
@ -58,7 +57,9 @@ type
// Actual user settings.
fBackupFiles: boolean;
fKeepFileOpen: boolean;
fTarget: TConvertTarget;
fMultiPlatform: boolean;
fSupportDelphi: boolean;
fSameDfmFile: boolean;
// Modes for replacements:
fUnitsReplaceMode: TReplaceModeLong;
fUnknownPropsMode: TReplaceModeLong;
@ -104,7 +105,9 @@ type
property BackupFiles: boolean read fBackupFiles;
property KeepFileOpen: boolean read fKeepFileOpen;
property Target: TConvertTarget read fTarget;
property MultiPlatform: boolean read fMultiPlatform;
property SupportDelphi: boolean read fSupportDelphi;
property SameDfmFile: boolean read fSameDfmFile;
property UnitsReplaceMode: TReplaceModeLong read fUnitsReplaceMode;
property UnknownPropsMode: TReplaceModeLong read fUnknownPropsMode;
property FuncReplaceMode: TReplaceModeShort read fFuncReplaceMode;
@ -119,9 +122,14 @@ type
{ TConvertSettingsForm }
TConvertSettingsForm = class(TForm)
CoordOffsRadioGroup: TRadioGroup;
UnitReplaceRadioGroup: TRadioGroup;
UnknownPropsRadioGroup: TRadioGroup;
CoordOffsComboBox: TComboBox;
UnitReplaceComboBox: TComboBox;
MultiPlatformCheckBox: TCheckBox;
SameDfmCheckBox: TCheckBox;
SupportDelphiCheckBox: TCheckBox;
TargetGroupBox: TGroupBox;
FuncReplaceComboBox: TComboBox;
UnknownPropsComboBox: TComboBox;
UnknownPropsDivider: TDividerBevel;
UnitReplaceDivider: TDividerBevel;
TypeReplaceDivider: TDividerBevel;
@ -129,7 +137,6 @@ type
CoordOffsDivider: TDividerBevel;
FuncReplaceButton: TBitBtn;
KeepFileOpenCheckBox: TCheckBox;
TargetRadioGroup: TRadioGroup;
BackupCheckBox: TCheckBox;
ButtonPanel1: TButtonPanel;
TypeReplaceButton: TBitBtn;
@ -137,14 +144,14 @@ type
UnitReplaceButton: TBitBtn;
ProjectPathEdit: TLabeledEdit;
CoordOffsButton: TBitBtn;
FuncReplaceRadioGroup: TRadioGroup;
procedure SameDfmCheckBoxChange(Sender: TObject);
procedure SupportDelphiCheckBoxChange(Sender: TObject);
procedure TypeReplaceButtonClick(Sender: TObject);
procedure FuncReplaceButtonClick(Sender: TObject);
procedure CoordOffsButtonClick(Sender: TObject);
procedure UnitReplaceButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure TargetRadioGroupClick(Sender: TObject);
private
fSettings: TConvertSettings;
public
@ -356,7 +363,9 @@ begin
fConfigStorage:=GetIDEConfigStorage('delphiconverter.xml', true);
fBackupFiles :=fConfigStorage.GetValue('BackupFiles', true);
fKeepFileOpen :=fConfigStorage.GetValue('KeepFileOpen', false);
fTarget :=TConvertTarget(fConfigStorage.GetValue('ConvertTarget', 0));
fMultiPlatform :=fConfigStorage.GetValue('MultiPlatform', true);
fSupportDelphi :=fConfigStorage.GetValue('SupportDelphi', false);
fSameDfmFile :=fConfigStorage.GetValue('SameDfmFile', false);
fUnitsReplaceMode:=TReplaceModeLong(fConfigStorage.GetValue('UnitsReplaceMode', 2));
fUnknownPropsMode:=TReplaceModeLong(fConfigStorage.GetValue('UnknownPropsMode', 2));
fFuncReplaceMode:=TReplaceModeShort(fConfigStorage.GetValue('FuncReplaceMode', 1));
@ -480,7 +489,9 @@ begin
// Save possibly modified settings to ConfigStorage.
fConfigStorage.SetDeleteValue('BackupFiles', fBackupFiles, true);
fConfigStorage.SetDeleteValue('KeepFileOpen', fKeepFileOpen, false);
fConfigStorage.SetDeleteValue('ConvertTarget', integer(fTarget), 0);
fConfigStorage.SetDeleteValue('MultiPlatform', fMultiPlatform, true);
fConfigStorage.SetDeleteValue('SupportDelphi', fSupportDelphi, false);
fConfigStorage.SetDeleteValue('SameDfmFile', fSameDfmFile, false);
fConfigStorage.SetDeleteValue('UnitsReplaceMode', integer(fUnitsReplaceMode), 2);
fConfigStorage.SetDeleteValue('UnknownPropsMode', integer(fUnknownPropsMode), 2);
fConfigStorage.SetDeleteValue('FuncReplaceMode', integer(fFuncReplaceMode), 1);
@ -509,22 +520,27 @@ begin
// Settings --> UI. Loaded from ConfigSettings earlier.
BackupCheckBox.Checked :=fBackupFiles;
KeepFileOpenCheckBox.Checked :=fKeepFileOpen;
TargetRadioGroup.ItemIndex :=integer(fTarget);
UnitReplaceRadioGroup.ItemIndex :=integer(fUnitsReplaceMode);
UnknownPropsRadioGroup.ItemIndex:=integer(fUnknownPropsMode);
FuncReplaceRadioGroup.ItemIndex :=integer(fFuncReplaceMode);
CoordOffsRadioGroup.ItemIndex :=integer(fCoordOffsMode);
TargetRadioGroupClick(TargetRadioGroup);
MultiPlatformCheckBox.Checked :=fMultiPlatform;
SupportDelphiCheckBox.Checked :=fSupportDelphi;
SameDfmCheckBox.Checked :=fSameDfmFile;
UnitReplaceComboBox.ItemIndex :=integer(fUnitsReplaceMode);
UnknownPropsComboBox.ItemIndex :=integer(fUnknownPropsMode);
FuncReplaceComboBox.ItemIndex :=integer(fFuncReplaceMode);
CoordOffsComboBox.ItemIndex :=integer(fCoordOffsMode);
SupportDelphiCheckBoxChange(SupportDelphiCheckBox);
SameDfmCheckBoxChange(SameDfmCheckBox);
Result:=ShowModal; // Let the user change settings in a form.
if Result=mrOK then begin
// UI --> Settings. Will be saved to ConfigSettings later.
fBackupFiles :=BackupCheckBox.Checked;
fKeepFileOpen :=KeepFileOpenCheckBox.Checked;
fTarget :=TConvertTarget(TargetRadioGroup.ItemIndex);
fUnitsReplaceMode:=TReplaceModeLong(UnitReplaceRadioGroup.ItemIndex);
fUnknownPropsMode:=TReplaceModeLong(UnknownPropsRadioGroup.ItemIndex);
fFuncReplaceMode :=TReplaceModeShort(FuncReplaceRadioGroup.ItemIndex);
fCoordOffsMode :=TReplaceModeShort(CoordOffsRadioGroup.ItemIndex);
fMultiPlatform :=MultiPlatformCheckBox.Checked;
fSupportDelphi :=SupportDelphiCheckBox.Checked;
fSameDfmFile :=SameDfmCheckBox.Checked;
fUnitsReplaceMode:=TReplaceModeLong(UnitReplaceComboBox.ItemIndex);
fUnknownPropsMode:=TReplaceModeLong(UnknownPropsComboBox.ItemIndex);
fFuncReplaceMode :=TReplaceModeShort(FuncReplaceComboBox.ItemIndex);
fCoordOffsMode :=TReplaceModeShort(CoordOffsComboBox.ItemIndex);
end;
end;
finally
@ -645,57 +661,51 @@ begin
ProjectPathEdit.Text:='';
ProjectPathEdit.EditLabel.Caption:=lisProjectPath;
ProjectPathEdit.Hint:=lisProjectPathHint;
BackupCheckBox.Caption:=lisBackupChangedFiles;
BackupCheckBox.Hint:=lisBackupHint;
KeepFileOpenCheckBox.Caption:=lisKeepFileOpen;
KeepFileOpenCheckBox.Hint:=lisKeepFileOpenHint;
TargetRadioGroup.Items.Clear;
TargetRadioGroup.Items.Add(lisConvertTargetLaz);
TargetRadioGroup.Items.Add(lisConvertTargetLazAndDelphi);
TargetRadioGroup.Items.Add(lisConvertTargetLazWinOnly);
TargetRadioGroup.Items.Add(lisConvertTargetLazAndDelphiSameDfm);
TargetRadioGroup.ItemIndex:=0;
TargetRadioGroup.Hint:=lisConvertTargetHint;
// Target
MultiPlatformCheckBox.Caption:=lisConvertTargetMultiPlatform;
MultiPlatformCheckBox.Hint:=lisConvertTargetMultiPlatformHint;
SupportDelphiCheckBox.Caption:=lisConvertTargetSupportDelphi;
SupportDelphiCheckBox.Hint:=lisConvertTargetSupportDelphiHint;
SameDfmCheckBox.Caption:=lisConvertTargetSameDfmFile;
SameDfmCheckBox.Hint:=lisConvertTargetSameDfmFileHint;
TargetGroupBox.Hint:=lisConvertTargetHint;
// Unit Replacements
UnitReplaceDivider.Caption:=lisConvUnitReplacements;
UnitReplaceButton.Caption:=lisCodeToolsDefsEdit; // Recycled string.
UnitReplaceDivider.Hint:=lisConvUnitReplHint;
UnitReplaceButton.Hint:=lisConvUnitReplHint;
UnitReplaceRadioGroup.Items.Clear;
UnitReplaceRadioGroup.Items.Add(lisDisabled); // 'Disabled'
UnitReplaceRadioGroup.Items.Add(lisInteractive); // 'Interactive'
UnitReplaceRadioGroup.Items.Add(lisAutomatic); // 'Automatic'
UnitReplaceComboBox.Items.Add(lisDisabled); // 'Disabled'
UnitReplaceComboBox.Items.Add(lisInteractive); // 'Interactive'
UnitReplaceComboBox.Items.Add(lisAutomatic); // 'Automatic'
// Unknown Properties
UnknownPropsDivider.Caption:=lisConvUnknownProps;
UnknownPropsRadioGroup.Items.Clear;
UnknownPropsRadioGroup.Items.Add(lisDisabled);
UnknownPropsRadioGroup.Items.Add(lisInteractive);
UnknownPropsRadioGroup.Items.Add(lisAutomatic);
UnknownPropsComboBox.Items.Add(lisDisabled);
UnknownPropsComboBox.Items.Add(lisInteractive);
UnknownPropsComboBox.Items.Add(lisAutomatic);
// Type Replacements
TypeReplaceDivider.Caption:=lisConvTypeReplacements;
TypeReplaceButton.Caption:=lisCodeToolsDefsEdit;
TypeReplaceDivider.Hint:=lisConvTypeReplHint;
TypeReplaceButton.Hint:=lisConvTypeReplHint;
TypeReplaceInfoLabel.Caption:=lisInteractive;
// Func Replacements
FuncReplaceDivider.Caption:=lisConvFuncReplacements;
FuncReplaceButton.Caption:=lisCodeToolsDefsEdit;
FuncReplaceDivider.Hint:=lisConvFuncReplHint;
FuncReplaceButton.Hint:=lisConvFuncReplHint;
FuncReplaceRadioGroup.Items.Clear;
FuncReplaceRadioGroup.Items.Add(lisDisabled); // 'Disabled'
FuncReplaceRadioGroup.Items.Add(lisEnabled); // 'Enabled'
FuncReplaceComboBox.Items.Add(lisDisabled); // 'Disabled'
FuncReplaceComboBox.Items.Add(lisEnabled); // 'Enabled'
// Coordinate Offsets
CoordOffsDivider.Caption:=lisConvCoordOffs;
CoordOffsButton.Caption:=lisCodeToolsDefsEdit;
CoordOffsDivider.Hint:=lisConvCoordHint;
CoordOffsButton.Hint:=lisConvCoordHint;
CoordOffsRadioGroup.Items.Clear;
CoordOffsRadioGroup.Items.Add(lisDisabled);
CoordOffsRadioGroup.Items.Add(lisEnabled);
CoordOffsComboBox.Items.Add(lisDisabled);
CoordOffsComboBox.Items.Add(lisEnabled);
ButtonPanel1.OKButton.Caption:=lisStartConversion;
ButtonPanel1.HelpButton.Caption:=lisMenuHelp;
@ -707,20 +717,24 @@ begin
;
end;
procedure TConvertSettingsForm.TargetRadioGroupClick(Sender: TObject);
// Delphi compatibility doesn't allow renaming the form file.
procedure TConvertSettingsForm.SupportDelphiCheckBoxChange(Sender: TObject);
var
Trg: TConvertTarget;
Chk: boolean;
begin
Trg:=TConvertTarget((Sender as TRadioGroup).ItemIndex);
// Function names are not replaced for Windows only target.
if Trg=ctLazarusWin then
FuncReplaceRadioGroup.ItemIndex:=integer(rsDisabled);
FuncReplaceRadioGroup.Enabled:=Trg<>ctLazarusWin;
// Coordinates are not adjusted when the same DFM form file is used.
if Trg=ctLazarusDelphiSameDfm then
CoordOffsRadioGroup.ItemIndex:=integer(rsDisabled);
CoordOffsRadioGroup.Enabled:=Trg<>ctLazarusDelphiSameDfm;
Chk:=(Sender as TCheckBox).Checked;
SameDfmCheckBox.Enabled:=Chk;
if not Chk then
SameDfmCheckBox.Checked:=Chk;
end;
procedure TConvertSettingsForm.SameDfmCheckBoxChange(Sender: TObject);
var
Chk: boolean;
begin
Chk:=(Sender as TCheckBox).Checked;
if Chk then
CoordOffsComboBox.ItemIndex:=integer(rsDisabled);
CoordOffsComboBox.Enabled:=not Chk;
end;
// Edit replacements in grids

View File

@ -225,7 +225,7 @@ begin
// Omit Windows specific units from the list if target is "Windows only",
// needed if work-platform is different from Windows (kind of a hack).
slo:=LowerCase(NewUnitName);
if (Settings.Target<>ctLazarusWin) or
if Settings.MultiPlatform or
((slo<>'windows') and (slo<>'variants') and (slo<>'shellapi')) then
fMissingUnits.Add(s); // unit not found
end;
@ -563,7 +563,7 @@ begin
if not CodeTool.AddUnitToSpecificUsesSection(
fUsesSection, fUnitsToAdd[i], '', SrcCache) then exit;
end;
if Settings.Target=ctLazarus then begin
if Settings.MultiPlatform and not Settings.SupportDelphi then begin
// One way conversion -> remove and rename units.
if not fMainUsedUnits.RemoveUnits then exit; // Remove
if not fImplUsedUnits.RemoveUnits then exit;
@ -571,12 +571,12 @@ begin
if not CodeTool.ReplaceUsedUnits(fMainUsedUnits.fUnitsToRename, SrcCache) then exit;
if not CodeTool.ReplaceUsedUnits(fImplUsedUnits.fUnitsToRename, SrcCache) then exit;
end;
if Settings.Target in [ctLazarusDelphi, ctLazarusDelphiSameDfm] then begin
if Settings.SupportDelphi then begin
// Support Delphi. Add IFDEF blocks for units.
if not fMainUsedUnits.AddDelphiAndLCLSections then exit;
if not fImplUsedUnits.AddDelphiAndLCLSections then exit;
end
else begin // [ctLazarus, ctLazarusWin] -> comment out units if needed.
else begin // Lazarus only -> comment out units if needed.
if not CodeTool.CommentUnitsInUsesSections(fMainUsedUnits.fUnitsToComment,
SrcCache) then exit;
if not CodeTool.CommentUnitsInUsesSections(fImplUsedUnits.fUnitsToComment,

View File

@ -477,18 +477,19 @@ resourcestring
lisUnableToConvertLfmToLrsAndWriteLrsFile = 'Unable to convert lfm to lrs '
+'and write lrs file.';
lisNotADelphiProject = 'Not a Delphi project';
lisTheFileIsNotADelphiProjectDpr = 'The file %s%s%s is not a Delphi '
+'project (.dpr)';
lisTheFileIsNotADelphiProjectDpr = 'The file %s%s%s is not a Delphi project (.dpr)';
lisProjectPath = 'Project Path:';
lisProjectPathHint = 'Directory where project''s main file must be';
lisBackupChangedFiles = 'Make backup of changed files';
lisBackupHint = 'Creates a Backup directory under project directory';
lisStartConversion = 'Start Conversion';
lisConvertTargetLaz = 'Lazarus';
lisConvertTargetLazWinOnly = 'Lazarus for Windows only';
lisConvertTargetLazAndDelphi = 'Lazarus and Delphi';
lisConvertTargetLazAndDelphiSameDfm = 'Lazarus and Delphi with same DFM file';
lisConvertTargetHint = 'Converter adds conditional compilation to support different targets';
lisConvertTargetMultiPlatform = 'Multi-Platform';
lisConvertTargetMultiPlatformHint = 'Multi-Platform versus Windows-only';
lisConvertTargetSupportDelphi = 'Support Delphi';
lisConvertTargetSupportDelphiHint = 'Use conditional compilation to support Delphi';
lisConvertTargetSameDfmFile = 'Use the same DFM form file';
lisConvertTargetSameDfmFileHint = 'Same DFM file for Lazarus and Delphi instead of copying it to LFM';
lisKeepFileOpen = 'Keep converted files open in editor';
lisKeepFileOpenHint = 'All project files will be open in editor after conversion';
lisConvUnknownProps = 'Unknown properties';