Recent

Author Topic: [SOLVED] ChartListBox: Check and Radio not showing in COCOA  (Read 3739 times)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1071
  • Former Delphi 1-7, 10.2 User
Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #15 on: February 12, 2020, 11:06:01 pm »
Removing the themes bypass... see attached.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6, Xcode 11.3.1
o Lazarus v2.1.0 r64160, FPC v3.3.1 Nov 27 21:16:31, macOS 11.0.1 (aarch64), Xcode 12.2
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (PD VM)

wp

  • Hero Member
  • *****
  • Posts: 7750
Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #16 on: February 13, 2020, 12:13:39 am »
Wow!

In r62628 I committed a version of TChartListbox in which the ThemesEnabled check has been removed, too. It should work now.

Could you finally test also the attached modified demo in which two paintboxes with checkboxes are compared again: in the left paintbox the ThemesEnabled is NOT checked while it IS checked in the right paintbox. On Windows, the checkboxes are painted in both, but on the Mac only the left checkbox should appear with the current bug.
« Last Edit: February 13, 2020, 12:35:28 am by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1071
  • Former Delphi 1-7, 10.2 User
Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #17 on: February 13, 2020, 12:55:23 am »
No attachment  :(
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6, Xcode 11.3.1
o Lazarus v2.1.0 r64160, FPC v3.3.1 Nov 27 21:16:31, macOS 11.0.1 (aarch64), Xcode 12.2
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (PD VM)

wp

  • Hero Member
  • *****
  • Posts: 7750
Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #18 on: February 13, 2020, 01:02:26 am »
Grrrrh...
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1071
  • Former Delphi 1-7, 10.2 User
Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #19 on: February 13, 2020, 01:23:05 am »
Results attached.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6, Xcode 11.3.1
o Lazarus v2.1.0 r64160, FPC v3.3.1 Nov 27 21:16:31, macOS 11.0.1 (aarch64), Xcode 12.2
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (PD VM)

AL

  • Full Member
  • ***
  • Posts: 209
[SOLVED] Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #20 on: February 13, 2020, 03:42:21 am »
Wow!

In r62628 I committed a version of TChartListbox in which the ThemesEnabled check has been removed, too. It should work now.
Thank you Werner,  what is the best way to get this update.  FpcUpDeluxe does not list the "r",  should I get the trunk?
I tried downloading the TChartlistbox.pas and adding to the component/tachart directory and recompile, but that does not make any difference, the checkbox are still not showing.
 
« Last Edit: February 18, 2020, 12:56:07 am by AL »
Laz 2.1.0, fpc 3.3.1, Win10
Laz 2.1.0, fpc 3.3.1, Mac OS Mojave running on VMWare
Laz 2.1.0  fpc 3.3.1 Ubuntu 20.04

wp

  • Hero Member
  • *****
  • Posts: 7750
Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #21 on: February 13, 2020, 09:52:02 am »
The "r" is just the svn revision numbers, changes are always found in trunk. So when you install Lazarus trunk via fpcupdeluxe, or use svn to update your trunk, you will get the change.

Alternatively, if you have the current or an older release version, you can patch the unit easily yourself:
  • Load the unit TAChartListbox.pas into Lazarus. You find it in folder "components/tachart" of your Lazarus installation. (Make sure to have a backup copy in case that something goes wrong).
  • Find the implementation of the method TChartlistbox.DrawItem (near line 290) and replace it by the following code:
Code: Pascal  [Select][+][-]
  1. procedure TChartListbox.DrawItem(
  2.   AIndex: Integer; ARect: TRect; AState: TOwnerDrawState);
  3. { draws the listbox item }
  4. const
  5.   THEMED_FLAGS: array [TCheckboxesStyle, Boolean] of TThemedButton = (
  6.     (tbCheckBoxUncheckedNormal, tbCheckBoxCheckedNormal),
  7.     (tbRadioButtonUnCheckedNormal, tbRadioButtonCheckedNormal)
  8.   );
  9. var
  10.   id: IChartDrawer;
  11.   rcb, ricon: TRect;
  12.   te: TThemedElementDetails;
  13.   x: Integer;
  14.   ch: Boolean;
  15. begin
  16.   if Assigned(OnDrawItem) then begin
  17.     OnDrawItem(Self, AIndex, ARect, AState);
  18.     exit;
  19.   end;
  20.   if (FChart = nil) or not InRange(AIndex, 0, Count - 1) then
  21.     exit;
  22.  
  23.   Canvas.FillRect(ARect);
  24.   CalcRects(ARect, rcb, ricon);
  25.  
  26.   if cloShowCheckboxes in Options then begin
  27.     ch := Checked[AIndex];
  28.     te := ThemeServices.GetElementDetails(THEMED_FLAGS[FCheckStyle, ch]);
  29.     ThemeServices.DrawElement(Canvas.Handle, te, rcb);
  30.     x := rcb.Right;
  31.   end
  32.   else
  33.     x := ARect.Left;
  34.  
  35.   Canvas.Brush.Style := bsClear;
  36.   if cloShowIcons in Options then begin
  37.     id := TCanvasDrawer.Create(Canvas);
  38.     id.Pen := Chart.Legend.SymbolFrame;
  39.     FLegendItems[AIndex].Draw(id, ricon);
  40.   end
  41.   else
  42.     Canvas.TextOut(x + 2, ARect.Top, FLegendItems.Items[AIndex].Text);
  43. end;
  • Compile the TAChart package ("Package" > "Open package file (.lpk) > Find tachartlazaruspkg.lpk in folder components/tachart of your Lazarus installation > "Compile"), or rebuild the IDE ("Tools" > "Build Lazarus with profile...")
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

AL

  • Full Member
  • ***
  • Posts: 209
Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #22 on: February 13, 2020, 05:49:34 pm »
Not sure if I am doing something wrong, I did follow the instructions and recompile the package  but the check boxes still do not show!
Laz 2.1.0, fpc 3.3.1, Win10
Laz 2.1.0, fpc 3.3.1, Mac OS Mojave running on VMWare
Laz 2.1.0  fpc 3.3.1 Ubuntu 20.04

wp

  • Hero Member
  • *****
  • Posts: 7750
Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #23 on: February 13, 2020, 06:04:15 pm »
Just to make sure: Create a new form. Add a TChartListbox. Find the ChartListbox1 in the declaration section of the form. Hold the CTRL key down and left-click on the identifier "TChartlistbox" in the editor. This opens the unit TAChartListbox which is used by your program. Scroll down and find the "DrawItem" method. Is it the same as in my post?

If yes make sure that the editor has this unit in its active window. Go to "Package" > "Open package of current unit". This opens the TAChart package used by your program. In the package editor do a clean compilation of the package now: Click "More" > "Recompile clean". Then do "Use" > "Install" to rebuild the IDE.

If it still does not work my fix was useless. I wonder then why checkboxes were displayed in the simple demo as seen by trev because it used the same code.
« Last Edit: February 13, 2020, 06:29:21 pm by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

AL

  • Full Member
  • ***
  • Posts: 209
Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #24 on: February 13, 2020, 08:15:08 pm »
Used the instructions, except I used my actual program. The link goes to the new drawitem method.  I had not made a use / install  which I did this time.  But no luck I still get the same (see attached )
Now, I said may be it is my program. 
So I created a new project with one chart with 2 series (empties).  Put a chart listbox.
It compile fine in Windows.  But when cross compiling to Darwin I get a strange error.
See attached screen capture.
I tried clean and rebuild with same result.
Laz 2.1.0, fpc 3.3.1, Win10
Laz 2.1.0, fpc 3.3.1, Mac OS Mojave running on VMWare
Laz 2.1.0  fpc 3.3.1 Ubuntu 20.04

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1071
  • Former Delphi 1-7, 10.2 User
Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #25 on: February 14, 2020, 12:43:01 am »
From the Free Pascal ref docs (https://www.freepascal.org/docs-html/3.0.0/user/usersu7.html):

Quote
Also, unit names that are longer than 8 characters will first be looked for with their full length. If the unit is not found with this name, the name will be truncated to 8 characters, and the compiler will look again in the same directories, but with the truncated name.

I think this explains your issue.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6, Xcode 11.3.1
o Lazarus v2.1.0 r64160, FPC v3.3.1 Nov 27 21:16:31, macOS 11.0.1 (aarch64), Xcode 12.2
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (PD VM)

wp

  • Hero Member
  • *****
  • Posts: 7750
Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #26 on: February 14, 2020, 01:02:44 am »
Maybe it was not enough to just do a clean recompilation of TAChart. Do a clean recompilation of the IDE, too: "Tools" > "Configure Build Lazarus" > in the "Clean up" box check "Clean all" and "Switch after building to automatically". Then click "Build".
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

AL

  • Full Member
  • ***
  • Posts: 209
Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #27 on: February 14, 2020, 01:33:36 am »
From the Free Pascal ref docs (https://www.freepascal.org/docs-html/3.0.0/user/usersu7.html):

Quote
I think this explains your issue.
Possibly, it does not do that error in my regular program.
Laz 2.1.0, fpc 3.3.1, Win10
Laz 2.1.0, fpc 3.3.1, Mac OS Mojave running on VMWare
Laz 2.1.0  fpc 3.3.1 Ubuntu 20.04

AL

  • Full Member
  • ***
  • Posts: 209
Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #28 on: February 14, 2020, 02:04:21 am »
Did try the IDe recompilation.
Also got rid of my new problem by shortening the names.

Still the same also in a new simple program.
Laz 2.1.0, fpc 3.3.1, Win10
Laz 2.1.0, fpc 3.3.1, Mac OS Mojave running on VMWare
Laz 2.1.0  fpc 3.3.1 Ubuntu 20.04

wp

  • Hero Member
  • *****
  • Posts: 7750
Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #29 on: February 18, 2020, 12:44:43 am »
The issue should be fixed now in the trunk version.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

 

TinyPortal © 2005-2018