Lazarus

Programming => Packages and Libraries => RichMemo => Topic started by: Trenatos on July 14, 2017, 01:24:41 am

Title: GetParaMetric and SetParaMetric not working on Mac?
Post by: Trenatos on July 14, 2017, 01:24:41 am
I'm trying to figure out how to get and set paragraph indents.

I'm using RichMemo on a Mac.

If I'm reading the docs correctly, the code below should work.
It should initialize the parametric variables, set a value for met firstline, apply it to the text in the editor, the second parametric is used to get the values and display firstline in the statusbar.

I get no errors, but here's what happens when I run it:

met.FirstLine is changed to 30 (Checked by outputting to statusbar at the end) but the text doesn't change.

met2.FirstLine shows 0 at the end, and has not changed since initialization.

I do see in the docs that some things aren't working for Mac, but nothing mentioned for parametric.

Am I missing something, or did I find a bug?

Code: Pascal  [Select][+][-]
  1. procedure TEbookSettingsForm.ParagraphScrollbarChange(Sender: TObject);
  2. var
  3.   met, met2: TParaMetric;
  4. begin
  5.   InitParaMetric(met);
  6.   InitParaMetric(met2);
  7.  
  8.   MainForm.Editor.GetParaMetric(0, met);
  9.  
  10.   met.FirstLine := 30;
  11.  
  12.   MainForm.Editor.SetParaMetric(0, Length(MainForm.Editor.Lines.Text), met);
  13.   MainForm.Editor.GetParaMetric(0, met2);
  14.   MainForm.StatusBar.SimpleText := FloatToStr(met2.FirstLine);
  15.  
  16.   //MainForm.Ebook.paragraphIndent := ParagraphScrollbar.Position;
  17.   //ParagraphScrollValueLabel.Caption := IntToStr(MainForm.Ebook.paragraphIndent);
  18. end;
  19.  
Title: Re: GetParaMetric and SetParaMetric not working on Mac?
Post by: Phil on July 14, 2017, 01:30:47 am
I'm trying to figure out how to get and set paragraph indents.

I'm using RichMemo on a Mac.

You're probably using the Carbon widgetset. Looking at the RichMemo source, it appears as though those are not implemented on Carbon, probably because it's, well, Carbon.

Try compiling with the Cocoa widgetset. Appears to be implemented there.

Use 1.8 for more completed Cocoa, but trunk is best.

Title: Re: GetParaMetric and SetParaMetric not working on Mac?
Post by: Trenatos on July 14, 2017, 02:00:00 am
I switched to Cocoa, and when I tried running the open project, I got this error:

Identifier not found taLeft

Line 533 in CocoaRichMemo: AStopList.Tabs.Align:=taLeft;

I changed it to tabLeft, and now I'm staring at this error:
carbonrichmemo.pas(35,3) Fatal: Cannot find CarbonDef used by CarbonRichMemo. Enable flag "Use Unit" of unit CarbonDef in package LCL.

I'm not sure what that means/how to do that
Title: Re: GetParaMetric and SetParaMetric not working on Mac?
Post by: Phil on July 14, 2017, 02:13:26 am
I switched to Cocoa, and when I tried running the open project, I got this error:

Identifier not found taLeft

Line 533 in CocoaRichMemo: AStopList.Tabs.Align:=taLeft;

I changed it to tabLeft, and now I'm staring at this error:
carbonrichmemo.pas(35,3) Fatal: Cannot find CarbonDef used by CarbonRichMemo. Enable flag "Use Unit" of unit CarbonDef in package LCL.

I'm not sure what that means/how to do that

Hmm, I guess nobody has compiled the RichMemo trunk source for Cocoa for at least a couple years.

With that typo fixed, it compiles fine here.

Make sure you can compile the package for Cocoa. Try this at command line after changing to location of rich memo source:

lazbuild --ws=cocoa richmemopackage.lpk

If that succeeds, then just change the widgetset in your project to Cocoa. That would be in Project Options | Additions and Overrides. Then compile.

What version of Lazarus are you using? Again, I would strongly recommend 1.8.
Title: Re: GetParaMetric and SetParaMetric not working on Mac?
Post by: Trenatos on July 14, 2017, 02:46:52 am
I'm using Lazarus 1.6.4, FPC 3.0.2

I rebuilt Lazarus for Cocoa, and it doesn't work well at all.

I can't use Run, it looks like it gets stuck on Compiling.

If I do a Compile, it actually does compile but gets stuck in that mode.

I can compile and the program runs, and with that the paragraph settings work.

However, it looks like Lazarus in Cocoa mode is not useable.
Title: Re: GetParaMetric and SetParaMetric not working on Mac?
Post by: Phil on July 14, 2017, 02:50:28 am
However, it looks like Lazarus in Cocoa mode is not useable.

Right, it's not useable in trunk either. That's why I did not suggest that you even build Lazarus against the Cocoa widgetset.

You can use the Carbon widgetset and do everything as you normally would and then just compile the project against Cocoa. You don't need a Cocoa IDE.

Title: Re: GetParaMetric and SetParaMetric not working on Mac?
Post by: Trenatos on July 14, 2017, 03:24:17 am
I built Lazarus IDE with Cocoa, and now I can't build it back as Carbon again, argh.

I think I can use LazBuild to rebuild it from the commandline, but what's the args?  Got a link to info how to rebuild from commandline?
Title: Re: GetParaMetric and SetParaMetric not working on Mac?
Post by: Phil on July 14, 2017, 03:25:30 am
I built Lazarus IDE with Cocoa, and now I can't build it back as Carbon again, argh.

I think I can use LazBuild to rebuild it from the commandline, but what's the args?  Got a link to info how to rebuild from commandline?

This should do it:

make LCL_PLATFORM=carbon
Title: Re: GetParaMetric and SetParaMetric not working on Mac?
Post by: Trenatos on July 14, 2017, 03:36:13 am
And win!

I just successfully rebuilt Lazarus, and the project now builds as Cocoa and it looks like (At a glance, no deep testing) that the paragraph settings work!

Thanks a bunch Phil, I really appreciate it
Title: Re: GetParaMetric and SetParaMetric not working on Mac?
Post by: Phil on July 14, 2017, 03:43:12 am
And win!

I just successfully rebuilt Lazarus, and the project now builds as Cocoa and it looks like (At a glance, no deep testing) that the paragraph settings work!

Thanks a bunch Phil, I really appreciate it

Well, Dmitry did all the work on RichMemo.

Note an unfortunate thing about the forthcoming 1.8: menus are messed up with Cocoa, so you might want to skip to trunk.

https://bugs.freepascal.org/view.php?id=32042

This bug appears to be fixed in trunk, although it doesn't say that in the bug report. It's definitely still there in 1.8 RC3, meaning Mac users who want to use Cocoa might just want to skip 1.8. But don't stay on 1.6.4.

Notes on using 64-bit Cocoa with trunk in case you're interested:

https://macpgmr.github.io/MacXPlatform/UsingCocoaFromTrunk.html


Title: Re: GetParaMetric and SetParaMetric not working on Mac?
Post by: Trenatos on July 14, 2017, 04:42:55 am
Yeah I also see that TStatusBar seems to not work under cocoa, not a huge issue for me at the moment but something to keep in mind.

I know Dmitri made RichMemo but you helped me sort this issue out, I appreciate you both   :D

I'll take a look at your 64bit link, thanks for sharing!

-- edit
Actually it just looks like the statusbar.simpletext works if I set it from Lazarus but not when I set it in code.
TinyPortal © 2005-2018