Recent

Author Topic: Lazarus Cross-Platform Project  (Read 27530 times)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Lazarus Cross-Platform Project
« on: September 03, 2016, 11:53:35 pm »
Here's something I was working on earlier this summer. Realized today that summer is almost over and it's time to post this thing!

See this short article for more info and source code:

https://dl.dropboxusercontent.com/u/28343282/MacXPlatform/LazXProj.html

-Phil

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Lazarus Cross-Platform Project
« Reply #1 on: September 04, 2016, 03:59:17 pm »
Phil, we're in your debt.

This is how the (strange and inflexible) ProjTemplates package that ships with Lazarus should have been done.

There is obviously scope for giving it more of an expert (i.e. what used to be called wizard) interface, to let the developer choose further options for the new project. Do you plan to develop this further?
Since Mattias has added project group functionality, Lazarus projects have the potential to be quite complex...

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Lazarus Cross-Platform Project
« Reply #2 on: September 04, 2016, 05:42:12 pm »
Phil, we're in your debt.

Thanks, Howard. With this first release I tried to address what looked like several obvious candidates for automating as part of a cross-platform project: version info, preferences, and installer scripts. The idea is to eliminate some of the friction of adding cross-platform support to an app for those things, particularly after the fact.

I'll add your ideas to my list of possible enhancements. I'm sure there are many other possibilities that would never occur to me. Let's see what ideas others have and the level of interest, then go from there.

-Phil

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: Lazarus Cross-Platform Project
« Reply #3 on: September 13, 2016, 10:42:27 am »
Not sure what is this or what does this do. I did read the web page and your explanations and I'm a bit confused. Is this a template, a library, a tool or what? And what does it do?
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Lazarus Cross-Platform Project
« Reply #4 on: September 14, 2016, 01:18:20 am »
Not sure what is this or what does this do.

Sorry if the article wasn't clear for you. Maybe the easiest thing to do would be just to try it out. Then if you still have questions, come back here with them or re-read the article. Here's how to set things up:

(1) appxproj.lpk - In Lazarus, open this file with Package | Open Package File, then click Compile. Or just compile the package from the command line:

  lazbuild appxproj.lpk

Once you've compiled this package, you can use its units to easily add cross-platform support for version info and/or preferences to any existing project, even non-LCL projects.

(2) fix_xproj.lpi - In Lazarus, open this project with File | Open, then choose Run | Compile. Or just compile the project from the command line:

  lazbuild fix_xproj.lpi

(3) lazxproj.lpk - In Lazarus, open this file with Package | Open Package File, then click Compile, then Install.

Once this package has been installed in Lazarus (that is, the IDE has been rebuilt), you can use File | New | Cross-Platform Desktop App to create a new project. This is analogous to using File | New | Application, but instead of just an LCL app, you get an LCL app that also has support for version info and preferences. The main form includes code that shows how that works. Edit this code as needed.

Bonus features:

- With a new cross-platform project, you can let it create install scripts too (Windows, Mac, Ubuntu). Each time you compile your project, the fix_xproj console app is run. As part of its updating of version info files, it will update these 3 scripts so they're in sync with the project.

- I always found working with FPC's XML units to be confusing, so I wrote a unit, SimplerXml, that's included as part of the AppXProj package. It's an easy unit to use for reading XML files without wading through all the FPC XML classes.
« Last Edit: September 14, 2016, 01:20:24 am by Phil »

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: Lazarus Cross-Platform Project
« Reply #5 on: September 14, 2016, 07:20:14 pm »
Ok. I think I understand now. Looks interesting. Keep it up.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Lazarus Cross-Platform Project
« Reply #6 on: October 04, 2016, 03:28:47 am »
See this short article for more info and source code:

https://dl.dropboxusercontent.com/u/28343282/MacXPlatform/LazXProj.html

As noted elsewhere, as of today (Oct. 3), you can no longer use Dropbox to serve up Web pages. So I've moved my articles and whatnots to GitHub Pages:

https://macpgmr.github.io

If you're curious about GitHub Pages, here are the instructions that I followed. Very painless to set up.

https://pages.github.com/

I noticed on the Mac App Store about a zillion Git clients. Any Mac users here familiar with any of these? Or used GitHub's Desktop? (Or Xcode's built-in Git support?)

esvignolo

  • Full Member
  • ***
  • Posts: 159
  • Using FPC in Windows, Linux, Macos
Re: Lazarus Cross-Platform Project
« Reply #7 on: October 04, 2016, 04:40:29 am »
See this short article for more info and source code:

https://dl.dropboxusercontent.com/u/28343282/MacXPlatform/LazXProj.html

As noted elsewhere, as of today (Oct. 3), you can no longer use Dropbox to serve up Web pages. So I've moved my articles and whatnots to GitHub Pages:

https://macpgmr.github.io

If you're curious about GitHub Pages, here are the instructions that I followed. Very painless to set up.

https://pages.github.com/

I noticed on the Mac App Store about a zillion Git clients. Any Mac users here familiar with any of these? Or used GitHub's Desktop? (Or Xcode's built-in Git support?)

Hi Phil, i use https://www.atlassian.com/software/sourcetree and i think is one of the best.

Thanks for u effort to bring more easy the multiplataform support to FPC.

I have a couple of features available that seem useful to improve the appearance on macos.

Regards!

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Lazarus Cross-Platform Project
« Reply #8 on: October 07, 2016, 01:48:11 am »
I have a couple of features available that seem useful to improve the appearance on macos.

Have you shared your ideas somewhere?


esvignolo

  • Full Member
  • ***
  • Posts: 159
  • Using FPC in Windows, Linux, Macos
Re: Lazarus Cross-Platform Project
« Reply #9 on: October 07, 2016, 06:11:45 am »
No, but it is simple. It is to change some controls such as buttons, at the height necessary to achieve the standard drawn, and also search the newest sources in all components of the form using fonts.

The changes are simple, but has much visual impact.

The carbon widgetset use olds fonts and that gives the appearance is that there seems something today or like cocoa.

In my apps i use something like this (is copy and paste, but i want to share the idea)
Code: Pascal  [Select][+][-]
  1. const
  2.       {$ifdef Darwin}
  3.       csFont='San Francisco';
  4.       csFont2='Helvetica Neue';
  5.       ciFontSize=11;
  6.       ciFontSize2=12;
  7.       {$endif}
  8.       {$ifdef Linux}
  9.       csFont='Roboto';
  10.       csFont2='Ubuntu';
  11.       ciFontSize=9;
  12.       ciFontSize2=11;
  13.       {$endif}
  14.       {$ifdef windows}
  15.       csFont='Roboto';
  16.       csFont2='Segou UI';
  17.       ciFontSize=9;
  18.       ciFontSize2=11;
  19.  
  20. Procedure ImproveAppearance(aForm: TForm);
  21. var i:integer;
  22. begin
  23.  if gsFont='' then
  24.      begin
  25.        if Screen.Fonts.IndexOf(csFont) <> -1 then
  26.           gsFont:=csFont;
  27.        if (gsFont='') then
  28.        begin
  29.           if (CargarFuente(csFont)) then
  30.              gsFont:=csFont;
  31.        end;
  32.        if (gsFont='') and (Screen.Fonts.IndexOf(csFont2) <> -1) then
  33.           gsFont:=csFont2;
  34.        if (gsFont='') then
  35.        begin
  36.           if (CargarFuente(csFont2)) then
  37.              gsFont:=csFont2;
  38.        end;
  39.        if gsFont='' then
  40.           gsFont:='default';
  41.      end;
  42.  for i:=0 to aForm.ComponentCount-1 do
  43.  begin
  44.        if aForm.Components[i] is TSpeedButton then
  45.            if TSpeedButton(aForm.Components[i]).Tag>0 then //omito los tag=-1 para mantener preferencias e diseno
  46.            begin
  47.               TSpeedButton(aForm.Components[i]).Font.Name:=gsFont;
  48.               TSpeedButton(aForm.Components[i]).Font.Size:=ciFontSize;
  49.               TSpeedButton(aForm.Components[i]).Font.Color:=gFontColor1;
  50.               TSpeedButton(aForm.Components[i]).Font.Color:=
  51.                                     ConfigurarColorFuente(TSpeedButton(aForm.Components[i]).Font.Color,
  52.                                     TSpeedButton(aForm.Components[i]).Tag);
  53.            end;
  54.  
  55.            if aForm.Components[i] is TButton then
  56.            begin
  57.               {$ifdef Darwin}
  58.               TSpeedButton(aForm.Components[i]).Height:=22;
  59.               {$endif}
  60.               //if TSpeedButton(aForm.Components[i]).Tag>0 then //omito los tag=-1 para mantener preferencias e diseno
  61.            end;
  62.  
  63.            if aForm.Components[i] is TDatetimePicker then
  64.            begin
  65.               {$ifdef Darwin}
  66.               TDatetimePicker(aForm.Components[i]).DateMode:=dmNone;
  67.               {$endif}
  68.               if TDatetimePicker(aForm.Components[i]).Tag>0 then //omito los tag=-1 para mantener preferencias e diseno
  69.                  TDatetimePicker(aForm.Components[i]).Font.Color:=
  70.                                     ConfigurarColorFuente(TDatetimePicker(aForm.Components[i]).Font.Color,
  71.                                     TDatetimePicker(aForm.Components[i]).Tag);
  72.            end;
  73.  
  74.            if aForm.Components[i] is TMemo then
  75.            if TMemo(aForm.Components[i]).Tag<>-1 then
  76.            begin
  77.               TMemo(aForm.Components[i]).Font.Name:=gsFont;
  78.               TMemo(aForm.Components[i]).Font.Size:=ciFontSize2;
  79.               TMemo(aForm.Components[i]).Font.Color:=gFontColor2;
  80.               TMemo(aForm.Components[i]).Font.Color:=
  81.                     ConfigurarColorFuente(TEdit(aForm.Components[i]).Font.Color,
  82.                                     TMemo(aForm.Components[i]).Tag);
  83.               TMemo(aForm.Components[i]).Color:=
  84.                           ConfigurarColorFondo(TEdit(aForm.Components[i]).Color,
  85.                                     TMemo(aForm.Components[i]).Tag);
  86.            end;
  87.  
  88.            if aForm.Components[i] is TEdit then
  89.            if TEdit(aForm.Components[i]).Tag<>-1 then
  90.            begin
  91.               TEdit(aForm.Components[i]).Font.Name:=gsFont;
  92.               TEdit(aForm.Components[i]).Font.Size:=ciFontSize2;
  93.               TEdit(aForm.Components[i]).Font.Color:=
  94.                     ConfigurarColorFuente(TEdit(aForm.Components[i]).Font.Color,
  95.                                     TEdit(aForm.Components[i]).Tag);
  96.               TEdit(aForm.Components[i]).Color:=
  97.                           ConfigurarColorFondo(TEdit(aForm.Components[i]).Color,
  98.                                     TEdit(aForm.Components[i]).Tag);
  99.            end;
  100.  
  101.            if aForm.Components[i] is tDateEdit then
  102.            begin
  103.               tDateEdit(aForm.Components[i]).width:=90;
  104.               tDateEdit(aForm.Components[i]).Font.Color:=
  105.                  ConfigurarColorFuente(tDateEdit(aForm.Components[i]).Font.Color,
  106.                                     tDateEdit(aForm.Components[i]).Tag);
  107.               tDateEdit(aForm.Components[i]).Color:=
  108.                  ConfigurarColorFondo(tDateEdit(aForm.Components[i]).Color,
  109.                                     TEdit(aForm.Components[i]).Tag);
  110.            end;
  111.  
  112.            if aForm.Components[i] is TBCButtonFocus then
  113.            begin
  114.                 TBCButtonFocus(aForm.Components[i]).StateNormal.FontEx.name:=gsFont;
  115.                 TBCButtonFocus(aForm.Components[i]).StateHover.FontEx.name:=gsFont;
  116.                 TBCButtonFocus(aForm.Components[i]).StateClicked.FontEx.name:=gsFont;
  117.                 TBCButtonFocus(aForm.Components[i]).StateHover.Background.Color:=
  118.                          Bright(TBCButtonFocus(aForm.Components[i]).StateNormal.Background.Color,20);//boton de acceso rapido hover
  119.                 TBCButtonFocus(aForm.Components[i]).StateNormal.FontEx.Color:=
  120.                          GetContrastColor(TBCButtonFocus(aForm.Components[i]).StateNormal.Background.Color);
  121.                 TBCButtonFocus(aForm.Components[i]).StateHover.FontEx.Color:=
  122.                          GetContrastColor(TBCButtonFocus(aForm.Components[i]).StateNormal.Background.Color);
  123.                 TBCButtonFocus(aForm.Components[i]).StateClicked.FontEx.Color:=
  124.                         GetContrastColor(TBCButtonFocus(aForm.Components[i]).StateNormal.Background.Color);
  125.  
  126.            end;
  127.  
  128.            if aForm.Components[i] is TBCButton then
  129.            begin
  130.                 TBCButton(aForm.Components[i]).StateNormal.FontEx.name:=gsFont;
  131.                 TBCButton(aForm.Components[i]).StateHover.FontEx.name:=gsFont;
  132.                 TBCButton(aForm.Components[i]).StateClicked.FontEx.name:=gsFont;
  133.                 TBCButton(aForm.Components[i]).StateHover.Background.Color:=
  134.                          Bright(TBCButton(aForm.Components[i]).StateNormal.Background.Color,20);//boton de acceso rapido hover
  135.                 TBCButton(aForm.Components[i]).StateNormal.FontEx.Color:=
  136.                          GetContrastColor(TBCButton(aForm.Components[i]).StateNormal.Background.Color);
  137.                 TBCButton(aForm.Components[i]).StateHover.FontEx.Color:=
  138.                          GetContrastColor(TBCButton(aForm.Components[i]).StateNormal.Background.Color);
  139.                 TBCButton(aForm.Components[i]).StateClicked.FontEx.Color:=
  140.                         GetContrastColor(TBCButton(aForm.Components[i]).StateNormal.Background.Color);
  141.            end;
  142.  
  143.            if aForm.Components[i] is TLabel then
  144.               if TLabel(aForm.Components[i]).Tag<>-1 then
  145.               begin
  146.                   TLabel(aForm.Components[i]).Font.name:=gsFont;
  147.                   TLabel(aForm.Components[i]).Font.Color:=ConfigurarColorFuente(TLabel(aForm.Components[i]).Font.Color,
  148.                                                    TLabel(aForm.Components[i]).Tag);
  149.               end;
  150.  
  151.            if aForm.Components[i] is TStaticText then
  152.            begin
  153.              TStaticText(aForm.Components[i]).Font.Name:=gsFont;
  154.              if TStaticText(aForm.Components[i]).Tag<>-1 then
  155.              begin
  156.                   TStaticText(aForm.Components[i]).Font.name:=gsFont;
  157.                   TStaticText(aForm.Components[i]).Font.Color:=cFontColor1;
  158.                   TStaticText(aForm.Components[i]).Font.Color:=
  159.                      ConfigurarColorFuente(TStaticText(aForm.Components[i]).Font.Color,
  160.                                       TStaticText(aForm.Components[i]).Tag);
  161.              end;
  162.            end;
  163.  
  164.            if aForm.Components[i] is TBCLabel then
  165.            begin
  166.                  TBCLabel(aForm.Components[i]).FontEx.name:=gsFont;
  167.                  if TBCLabel(aForm.Components[i]).Tag>0 then
  168.                  begin
  169.                       TBCLabel(aForm.Components[i]).Font.name:=gsFont;
  170.                       TBCLabel(aForm.Components[i]).FontEx.Color:=
  171.                            ConfigurarColorFuente(TBCLabel(aForm.Components[i]).FontEx.Color,
  172.                                               TBCLabel(aForm.Components[i]).Tag);
  173.                  end;
  174.            end;
  175.  
  176.            if aForm.Components[i] is TPanel then
  177.            begin
  178.                  if TPanel(aForm.Components[i]).Tag<>-1 then
  179.                  begin
  180.                       TPanel(aForm.Components[i]).Font.Color:=cFontColor1;
  181.                       TPanel(aForm.Components[i]).Font.Color:=
  182.                            ConfigurarColorFuente(TPanel(aForm.Components[i]).Font.Color,
  183.                                             TPanel(aForm.Components[i]).Tag);
  184.                       TPanel(aForm.Components[i]).Color:=
  185.                            ConfigurarColorFondo(TPanel(aForm.Components[i]).Color,
  186.                                             TPanel(aForm.Components[i]).Tag);
  187.                  end;
  188.            end;
  189.  
  190.            if aForm.Components[i] is TBCPanel then
  191.            begin
  192.                  if TBCPanel(aForm.Components[i]).Tag<>-1 then
  193.                  begin
  194.                       TBCPanel(aForm.Components[i]).Font.Color:=cFontColor1;
  195.                       TBCPanel(aForm.Components[i]).Background.Gradient1.StartColor:=gBackColorDeg1;
  196.                       TBCPanel(aForm.Components[i]).Background.Gradient1.EndColor:=gBackColorDeg2;
  197.                       TBCPanel(aForm.Components[i]).Background.Gradient2.StartColor:=gBackColorDeg2;
  198.                       TBCPanel(aForm.Components[i]).Background.Gradient2.EndColor:=gBackColorDeg3;
  199.                  end;
  200.            end;
  201.  
  202.  
  203.            if aForm.Components[i] is TRxDBGrid then
  204.            begin
  205.                 {$ifndef windows}
  206.                 TRxDBGrid(aForm.Components[i]).Font.name:=gsFont;
  207.                 {$endif}
  208.                 for j:=0 to TRxDBGrid(aForm.Components[i]).Columns.Count-1 do
  209.                 begin
  210.                      {$ifndef windows}
  211.                      TRxDBGrid(aForm.Components[i]).Columns[j].Font.name:=gsFont;
  212.                      {$endif}
  213.                      TRxDBGrid(aForm.Components[i]).Columns[j].Font.Color:=clBlack;
  214.                 end;
  215.            end;
  216.  
  217.            if aForm.Components[i] is TDBGrid then
  218.            begin
  219.                 {$ifndef windows}
  220.                 TDBGrid(aForm.Components[i]).Font.name:=gsFont;
  221.                 {$endif}
  222.                 for j:=0 to TDBGrid(aForm.Components[i]).Columns.Count-1 do
  223.                 begin
  224.                      {$ifndef windows}
  225.                      TDBGrid(aForm.Components[i]).Columns[j].Font.name:=gsFont;
  226.                      {$endif}
  227.                      TDBGrid(aForm.Components[i]).Columns[j].Font.color:=clBlack;
  228.                 end;
  229.            end;
  230.      end;        
  231.  end
  232.  

I attach a screeenshot from my application on macos, so u can see

I have a couple of features available that seem useful to improve the appearance on macos.

Have you shared your ideas somewhere?

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Lazarus Cross-Platform Project
« Reply #10 on: October 15, 2016, 05:25:02 pm »
No, but it is simple. It is to change some controls such as buttons, at the height necessary to achieve the standard drawn, and also search the newest sources in all components of the form using fonts.

Yes, that's a good idea. There are two ways to go about this:

(1) Modify the .lfm form file before compiling on Mac.

(2) Modify the control properties at runtime.

Years ago, I used a simple converter to do (1) on Delphi .dfm and Lazarus .lfm form design files:

http://wiki.freepascal.org/XDev_Toolkit

The converter fixes up the fonts as well as makes other changes to the .lfm such as setting TabStop=False for controls that cannot receive focus on Mac (TButton, etc.).

Now I think that perhaps doing this at runtime, like you're doing, might be a better approach. You can see that the template main form in LazXProj already has a method that swaps the position of Ok/Cancel buttons on a form with Mac.

Thanks!

-Phil

esvignolo

  • Full Member
  • ***
  • Posts: 159
  • Using FPC in Windows, Linux, Macos
Re: Lazarus Cross-Platform Project
« Reply #11 on: November 15, 2016, 03:08:00 pm »
Hi Phil, this is a another makedmg.sh using the same variables from your script.

This one, use a background.png and don't need run sudo,

regards!

Code: Pascal  [Select][+][-]
  1. #!/bin/bash
  2. set -e
  3.  
  4. if ! [ ${OSTYPE:0:6} = "darwin" ]; then
  5.   echo " This script is for OS X only"
  6.   exit 1
  7. fi
  8.  
  9. if [ -e "macOS" ]; then
  10.   rm -R macOS
  11. fi
  12.  
  13.  
  14. appname=LazPaint
  15. appversion=6.4.1
  16. pkgversion=0
  17.  
  18. appnamenospaces=LazPaint
  19. dskimage="$appnamenospaces"
  20. appbundle="$appname.app"
  21.  
  22. DMG_BACKGROUND_IMG="background.png"
  23.  
  24.  
  25.  
  26. VOL_NAME="${appname}"  
  27. DMG_TMP="${VOL_NAME}-temp.dmg"
  28. DMG_FINAL="${VOL_NAME}.dmg"        
  29. STAGING_DIR="./macOS"             # we copy all our stuff into this dir
  30.  
  31. # Check the background image DPI and convert it if it isn't 72x72
  32. _BACKGROUND_IMAGE_DPI_H=`sips -g dpiHeight ${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+'`
  33. _BACKGROUND_IMAGE_DPI_W=`sips -g dpiWidth ${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+'`
  34.  
  35. if [ $(echo " $_BACKGROUND_IMAGE_DPI_H != 72.0 " | bc) -eq 1 -o $(echo " $_BACKGROUND_IMAGE_DPI_W != 72.0 " | bc) -eq 1 ]; then
  36.   echo "WARNING: The background image's DPI is not 72.  This will result in distorted backgrounds on Mac OS X 10.7+."
  37.    echo "         I will convert it to 72 DPI for you."
  38.    
  39.    _DMG_BACKGROUND_TMP="${DMG_BACKGROUND_IMG%.*}"_dpifix."${DMG_BACKGROUND_IMG##*.}"
  40.  
  41.    sips -s dpiWidth 72 -s dpiHeight 72 ${DMG_BACKGROUND_IMG} --out ${_DMG_BACKGROUND_TMP}
  42.    
  43.    DMG_BACKGROUND_IMG="${_DMG_BACKGROUND_TMP}"
  44. fi
  45.  
  46. # clear out any old data
  47. rm -rf "${STAGING_DIR}" "${DMG_TMP}" "${DMG_FINAL}"
  48.  
  49. # copy over the stuff we want in the final disk image to our staging dir
  50. mkdir -p "${STAGING_DIR}"
  51. cp -rpf ./LazPaint.app "${STAGING_DIR}"
  52. # ... cp anything else you want in the DMG - documentation, etc.
  53.  
  54. pushd "${STAGING_DIR}"
  55.  
  56. # ... perform any other stripping/compressing of libs and executables
  57.  
  58. popd
  59.  
  60. # figure out how big our DMG needs to be
  61. #  assumes our contents are at least 1M!
  62. SIZE=`du -sh "${STAGING_DIR}" | sed 's/\([0-9\.]*\)M\(.*\)/\1/'`
  63. SIZE=`echo "${SIZE} + 1.0" | bc | awk '{print int($1+0.5)}'`
  64.  
  65. if [ $? -ne 0 ]; then
  66.    echo "Error: Cannot compute size of staging dir"
  67.    exit
  68. fi
  69.  
  70. # create the temp DMG file
  71. hdiutil create -srcfolder "${STAGING_DIR}" -volname "${VOL_NAME}" -fs HFS+ \
  72.       -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${SIZE}M "${DMG_TMP}"
  73.  
  74. echo "Created DMG: ${DMG_TMP}"
  75.  
  76. # mount it and save the device
  77. DEVICE=$(hdiutil attach -readwrite -noverify "${DMG_TMP}" | \
  78.          egrep '^/dev/' | sed 1q | awk '{print $1}')
  79.  
  80. sleep 2
  81.  
  82. # add a link to the Applications dir
  83. echo "Add link to /Applications"
  84. pushd /Volumes/"${VOL_NAME}"
  85. ln -s /Applications
  86. popd
  87.  
  88. # add a background image
  89. mkdir /Volumes/"${VOL_NAME}"/.background
  90. cp "${DMG_BACKGROUND_IMG}" /Volumes/"${VOL_NAME}"/.background/
  91.  
  92. # tell the Finder to resize the window, set the background,
  93. #  change the icon size, place the icons in the right position, etc.
  94. echo '
  95.   tell application "Finder"
  96.     tell disk "'${VOL_NAME}'"
  97.           open
  98.           set current view of container window to icon view
  99.           set toolbar visible of container window to false
  100.           set statusbar visible of container window to false
  101.           set the bounds of container window to {400, 100, 920, 440}
  102.           set viewOptions to the icon view options of container window
  103.           set arrangement of viewOptions to not arranged
  104.           set icon size of viewOptions to 72
  105.           set background picture of viewOptions to file ".background:'${DMG_BACKGROUND_IMG}'"
  106.           set position of item "'${appname}'.app" of container window to {160, 205}
  107.           set position of item "Applications" of container window to {360, 205}
  108.           close
  109.           open
  110.           update without registering applications
  111.           delay 2
  112.     end tell
  113.   end tell
  114. ' | osascript
  115.  
  116. sync
  117.  
  118. # unmount it
  119. hdiutil detach "${DEVICE}"
  120.  
  121. # now make the final image a compressed disk image
  122. echo "Creating compressed image"
  123. hdiutil convert "${DMG_TMP}" -format UDZO -imagekey zlib-level=9 -o "${DMG_FINAL}"
  124.  
  125. # clean up
  126. rm -rf "${DMG_TMP}"
  127. rm -rf "${STAGING_DIR}"
  128.  
  129. echo 'Done.'
  130.  
  131. exit
  132.  
  133.  
No, but it is simple. It is to change some controls such as buttons, at the height necessary to achieve the standard drawn, and also search the newest sources in all components of the form using fonts.

Yes, that's a good idea. There are two ways to go about this:

(1) Modify the .lfm form file before compiling on Mac.

(2) Modify the control properties at runtime.

Years ago, I used a simple converter to do (1) on Delphi .dfm and Lazarus .lfm form design files:

http://wiki.freepascal.org/XDev_Toolkit

The converter fixes up the fonts as well as makes other changes to the .lfm such as setting TabStop=False for controls that cannot receive focus on Mac (TButton, etc.).

Now I think that perhaps doing this at runtime, like you're doing, might be a better approach. You can see that the template main form in LazXProj already has a method that swaps the position of Ok/Cancel buttons on a form with Mac.

Thanks!

-Phil
« Last Edit: November 16, 2016, 03:47:26 am by esvignolo »

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Lazarus Cross-Platform Project
« Reply #12 on: November 16, 2016, 02:57:58 am »
Hi Phil, this is a another makedmg.sh using the same variables from your script.

Thanks for the insights. I'll take a look at your script when I have some time.

I assume the "debian" lines at the end are just an artifact that crept in from somewhere else?

-Phil

esvignolo

  • Full Member
  • ***
  • Posts: 159
  • Using FPC in Windows, Linux, Macos
Re: Lazarus Cross-Platform Project
« Reply #13 on: November 16, 2016, 03:48:01 am »
Yes u are rigth with the debian part, i remove it.


Hi Phil, this is a another makedmg.sh using the same variables from your script.

Thanks for the insights. I'll take a look at your script when I have some time.

I assume the "debian" lines at the end are just an artifact that crept in from somewhere else?

-Phil

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: Lazarus Cross-Platform Project
« Reply #14 on: November 20, 2016, 11:35:14 pm »
Name "lazarus cross platform project" reads not good, it is like some property of some project. Okay name is "LazarusX" or like it...

 

TinyPortal © 2005-2018