From e08f7104d067fcea1398d6c376b732a8b227e49c Mon Sep 17 00:00:00 2001 From: macpgmr Date: Sun, 2 Mar 2008 20:26:09 +0000 Subject: [PATCH] 20080301 release: Minor adjustments to converters; expanded notes to help users who are new to Lazarus. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@366 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/xdev_toolkit/CvtHelp.pas | 7 ++ components/xdev_toolkit/RtfDoc.pas | 4 + components/xdev_toolkit/TestRtfDoc.pas | 7 ++ components/xdev_toolkit/ViewDoc.pas | 4 + components/xdev_toolkit/ViewWith.pas | 7 ++ components/xdev_toolkit/XDevStatus.html | 99 +++++++++++++++---- .../{DfmToLfm.ini => dfmtolfm.ini} | 2 + .../{DfmToLfm.pas => dfmtolfm.pas} | 16 ++- .../{MakePasX.pas => makepasx.pas} | 9 +- .../xdev_toolkit/{MakeVer.pas => makever.pas} | 9 +- 10 files changed, 141 insertions(+), 23 deletions(-) rename components/xdev_toolkit/{DfmToLfm.ini => dfmtolfm.ini} (98%) rename components/xdev_toolkit/{DfmToLfm.pas => dfmtolfm.pas} (97%) rename components/xdev_toolkit/{MakePasX.pas => makepasx.pas} (98%) rename components/xdev_toolkit/{MakeVer.pas => makever.pas} (95%) diff --git a/components/xdev_toolkit/CvtHelp.pas b/components/xdev_toolkit/CvtHelp.pas index 7b6a5593c..f7f5ff943 100644 --- a/components/xdev_toolkit/CvtHelp.pas +++ b/components/xdev_toolkit/CvtHelp.pas @@ -14,6 +14,13 @@ program CvtHelp; License: Modified LGPL. } +{$IFDEF FPC} + {$MODE Delphi} +{$ELSE} + {$APPTYPE CONSOLE} +{$ENDIF} +{$R+,Q+} + uses SysUtils, Classes; diff --git a/components/xdev_toolkit/RtfDoc.pas b/components/xdev_toolkit/RtfDoc.pas index 09c5010fc..1d164acbe 100644 --- a/components/xdev_toolkit/RtfDoc.pas +++ b/components/xdev_toolkit/RtfDoc.pas @@ -13,6 +13,10 @@ unit RtfDoc; interface +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + uses SysUtils, RtfPars; diff --git a/components/xdev_toolkit/TestRtfDoc.pas b/components/xdev_toolkit/TestRtfDoc.pas index 4cf68d74c..64ce199b2 100644 --- a/components/xdev_toolkit/TestRtfDoc.pas +++ b/components/xdev_toolkit/TestRtfDoc.pas @@ -4,6 +4,13 @@ program TestRtfDoc; Test program for RtfDoc unit. } +{$IFDEF FPC} + {$MODE Delphi} +{$ELSE} + {$APPTYPE CONSOLE} +{$ENDIF} +{$R+,Q+} + uses SysUtils, RtfPars, {Free Pascal unit with TRtfParser class and rtf constants} diff --git a/components/xdev_toolkit/ViewDoc.pas b/components/xdev_toolkit/ViewDoc.pas index 12f63894d..2aeecf323 100644 --- a/components/xdev_toolkit/ViewDoc.pas +++ b/components/xdev_toolkit/ViewDoc.pas @@ -15,6 +15,10 @@ unit ViewDoc; interface +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + uses SysUtils, Classes, diff --git a/components/xdev_toolkit/ViewWith.pas b/components/xdev_toolkit/ViewWith.pas index 16589dea8..dc904c05d 100644 --- a/components/xdev_toolkit/ViewWith.pas +++ b/components/xdev_toolkit/ViewWith.pas @@ -4,6 +4,13 @@ program ViewWith; Test program for ViewDoc unit. } +{$IFDEF FPC} + {$MODE Delphi} +{$ELSE} + {$APPTYPE CONSOLE} +{$ENDIF} +{$R+,Q+} + uses SysUtils, ViewDoc; diff --git a/components/xdev_toolkit/XDevStatus.html b/components/xdev_toolkit/XDevStatus.html index 1644ccf30..1014f7ddd 100644 --- a/components/xdev_toolkit/XDevStatus.html +++ b/components/xdev_toolkit/XDevStatus.html @@ -17,6 +17,7 @@

Contents

+What's New
Introduction
Installation
MakePasX & DfmToLfm: Delphi converters
@@ -27,6 +28,17 @@ To Do
Other Resources

+


+

What's New

+ + +

Introduction

@@ -42,6 +54,12 @@ and suggestions to be seen by the entire Lazarus community.

The XDev Toolkit source code is here: http://web.fastermac.net/~MacPgmr/XDev/downloads

+You can also download the XDev Toolkit files via Subversion:

+ +  svn co https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/xdev_toolkit [local dir]

+ +Substitute your local directory where you want the files downloaded for "[local dir]".

+ All source code included in the XDev Toolkit is released under the Modified LGPL license.


@@ -49,15 +67,23 @@ All source code included in the XDev Toolkit is released under the Modified LGPL
  1. Unzip the source files into their own folder.

    -

  2. Open a terminal window and compile each utility and test program with FPC. +
  3. Open a terminal window and change to this folder, then compile each utility and test program with FPC. For example:

    -fpc -Sd DfmToLfm.pas +With Free Pascal:

    + +  fpc dfmtolfm

    + +With Delphi:

    + +  dcc32 dfmtolfm

  4. To see a utility's syntax, simply run it in a terminal window without any parameters or switches. For example:

    - -dfmtolfm +With Windows:

    +  dfmtolfm

    +With OS X and Linux:

    +  ./dfmtolfm

@@ -73,23 +99,59 @@ and .pas). The DfmToLfm utility is used to create Lazarus form design files Once you've converted a Delphi app to Lazarus you can continue to develop the app with Delphi on Windows and use Lazarus to compile the app on other platforms. This type of app can provide the best of both -worlds: taking advantage of the Windows-specific features of Delphi while -utilizing Free Pascal and Lazarus to add cross-platform capability to the app. +worlds: taking advantage of the speed, stability and Windows-specific features +of Delphi while utilizing Free Pascal and Lazarus to add cross-platform capability +to the app.
    +
  1. Make a copy of the Delphi files you want to convert in a different directory +since MakePasX will alter the source code files.

    +

  2. Use the MakePasX utility to make the Delphi project file (.dpr) and form code files (.pas) cross-platform. This is a one-time conversion that results -in a set of source files that can be compiled by both Delphi and Lazarus.

    -

  3. Use the DfmToLfm utility to create Lazarus form files (.lfm) from the Delphi -form files (.dfm).

    -

  4. Use the Lazarus lazres utility to create the Lazarus resource file (.lrs) -from the form file (.lfm) Repeat steps 2 and 3 whenever you make changes -to the Delphi form files. If your project has a number of forms, run these -utilities for each form in a batch or shell file to automate the conversion.

    -

  5. Compile the resulting files with Lazarus on Windows +in a set of source files that can be compiled by both Delphi and Lazarus. +Examples:

    +  makepasx myprogram.dpr
    +  makepasx myform.pas

    +MakePasX tries to insert the conditionals needed to compile with Lazarus, while +retaining compatibility with Delphi. After converting you can test to see that +the files can still be compiled by Delphi. You may have to make minor manual adjustments +if the converter couldn't figure out your code. Also, you can look at the source +code of the converter to see what it's doing.

    + +

  6. Use the DfmToLfm utility to create a Lazarus form file (.lfm) from each Delphi +form file (.dfm). Example:

    +  dfmtolfm myform.dfm

    +This creates an .lfm file that should be compatible with Lazarus. With Linux you +can use the -d switch to delete the font names from the .lfm file. This generally +makes for a better look on Linux, which doesn't have the same TrueType fonts that +Windows and OS X have. Default fonts will be substituted at runtime. With Windows +you can use the -p switch to add a parent's font to controls with no font, +which generally makes for a better look on Windows.

    +Important! Make sure your .dfm files are text files. If not, save them as text +files with Delphi before attempting to convert them.

    + +

  7. Use the Lazarus LazRes utility to create a Lazarus resource file (.lrs) +from each form file (.lfm). Example:

    +  lazres myform.lrs myform.lfm

    +Note: The lazres source code is located in the Lazarus tools folder. Open +project file lazres.lpi in Lazarus and compile it in the IDE.

    + +

  8. Repeat steps 3 and 4 whenever you make changes to the Delphi form files. +If your project has a number of forms, run DfmToLfm and LazRes +for each form in a batch or shell file to automate the conversion.

    + +

  9. Open the converted .dpr file with Lazarus and allow it to create a project +file (.lpi), then compile the project with Lazarus to test the converted code and form files.

    -

  10. Move the Lazarus project's files over to OS X or Linux and compile and -test them there with that platform's version of Lazarus. + +Tip: If you run your Lazarus-compiled app and get an error message about an unknown +property, that probably means you need to add this property to the [DeleteProps] +section of dfmtolfm.ini file and rerun DfmToLfm on the .dfm file. Not all VCL components +have been tested with DfmToLfm.

    + +

  11. Move the Lazarus project's files over to other platforms and compile and +test them there with those platforms' version of Lazarus.
@@ -185,7 +247,8 @@ which introduces a TRtfParser descendant, TRtfDoc, which can be used to create RTF files without knowing how TRtfParser works. For information on how to use it, look at the RtfDoc.pas file and TestRtfDoc.pas example program. You'll also want to look at the Free Pascal rtfdata.inc file for -a list of constants that you'll need to use with TRtfDoc.

+a list of constants that you'll need to use with TRtfDoc (rtfdata.inc is +in Free Pascal's /packages/fcl-base/src/inc folder).

For more information on the RTF specification, refer to Microsoft's documentation.

@@ -278,7 +341,7 @@ also be able to output version information to a Lazarus .lpi file.

http://wiki.lazarus.freepascal.org/Deploying_Your_Application


-Last updated: April 15, 2007 +Last updated: March 1, 2008

diff --git a/components/xdev_toolkit/DfmToLfm.ini b/components/xdev_toolkit/dfmtolfm.ini similarity index 98% rename from components/xdev_toolkit/DfmToLfm.ini rename to components/xdev_toolkit/dfmtolfm.ini index efecaaaef..91c7bfcf2 100644 --- a/components/xdev_toolkit/DfmToLfm.ini +++ b/components/xdev_toolkit/dfmtolfm.ini @@ -24,6 +24,7 @@ HideSelection= ImeMode= ImeName= OEMConvert= +TextHeight= TRadioGroup.TabOrder= TBitBtn.ParentFont= TCheckBox.Font.Charset= @@ -105,3 +106,4 @@ TOvcTCCheckBox= TOvcTCBitmap= TOvcTCGlyphs= TOvcTCIcon= +TWPRichText= diff --git a/components/xdev_toolkit/DfmToLfm.pas b/components/xdev_toolkit/dfmtolfm.pas similarity index 97% rename from components/xdev_toolkit/DfmToLfm.pas rename to components/xdev_toolkit/dfmtolfm.pas index 8ae514ca4..59149ca8a 100644 --- a/components/xdev_toolkit/DfmToLfm.pas +++ b/components/xdev_toolkit/dfmtolfm.pas @@ -19,13 +19,20 @@ program DfmToLfm; License: Modified LGPL. } +{$IFDEF FPC} + {$MODE Delphi} +{$ELSE} + {$APPTYPE CONSOLE} +{$ENDIF} +{$R+,Q+} + uses SysUtils, IniFiles; const ProgramName = 'DfmToLfm'; - ProgramVersion = '0.01'; + ProgramVersion = '0.02'; DfmFileExt = '.dfm'; {Delphi form file extension} LfmFileExt = '.lfm'; {Lazarus form file extension} @@ -70,7 +77,8 @@ var begin {Base configuration file name on program file location and program name} - CfgFileName := ExtractFilePath(ParamStr(0)) + ProgramName + CfgFileExt; + CfgFileName := + ExtractFilePath(ParamStr(0)) + LowerCase(ProgramName) + CfgFileExt; {$IFNDEF FPC} CfgFileName := ExpandFileNameCase(CfgFileName, MatchFound); {$ENDIF} @@ -84,7 +92,7 @@ begin WriteLn(' -p Add parent''s font to controls with no font ', '(useful with Windows).'); WriteLn(' -d Delete font name from controls ', - '(useful with OS X and Linux).'); + '(useful with GTK and GTK2).'); WriteLn('Looks for configuration data in file ', CfgFileName); Halt; end; @@ -261,6 +269,7 @@ begin Copy(InStr, 1, Succ(Pos('=', InStr))), IntToStr(StrToInt(Copy(StripStr, 5, MaxInt)) - 16)) +(* This incorrect swapping has been fixed in FPC 2.2 based Lazarus releases. {Lazarus IDE appears to swap Top and Left properties for non-visual controls, so swap them for Orpheus table cell controls.} else if ((CompareText('Top=', Copy(StripStr, 1, 4)) = 0) or @@ -279,6 +288,7 @@ begin WriteLn(LfmFileVar, StringReplace(InStr, 'Left', 'Top', [rfIgnoreCase])); end +*) else {No change to property} WriteLn(LfmFileVar, InStr); diff --git a/components/xdev_toolkit/MakePasX.pas b/components/xdev_toolkit/makepasx.pas similarity index 98% rename from components/xdev_toolkit/MakePasX.pas rename to components/xdev_toolkit/makepasx.pas index ab5c8e1cc..5072ced73 100644 --- a/components/xdev_toolkit/MakePasX.pas +++ b/components/xdev_toolkit/makepasx.pas @@ -12,12 +12,19 @@ program MakePasX; License: Modified LGPL. } +{$IFDEF FPC} + {$MODE Delphi} +{$ELSE} + {$APPTYPE CONSOLE} +{$ENDIF} +{$R+,Q+} + uses SysUtils; const ProgramName = 'MakePasX'; - ProgramVersion = '0.01'; + ProgramVersion = '0.02'; PasFileExt = '.pas'; {Pascal code file extension} DelProjFileExt = '.dpr'; {Delphi project file extension} diff --git a/components/xdev_toolkit/MakeVer.pas b/components/xdev_toolkit/makever.pas similarity index 95% rename from components/xdev_toolkit/MakeVer.pas rename to components/xdev_toolkit/makever.pas index f3ca7f7d8..09a739cff 100644 --- a/components/xdev_toolkit/MakeVer.pas +++ b/components/xdev_toolkit/makever.pas @@ -8,6 +8,13 @@ program MakeVer; License: Modified LGPL. } +{$IFDEF FPC} + {$MODE Delphi} +{$ELSE} + {$APPTYPE CONSOLE} +{$ENDIF} +{$R+,Q+} + uses SysUtils, Classes, @@ -15,7 +22,7 @@ uses const ProgramName = 'MakeVer'; - ProgramVersion = '0.01'; + ProgramVersion = '0.02'; DofFileExt = '.dof'; {Delphi project options file extension} VerFileExt = '.version'; {Linux/Mac version info file extension}