Recent

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

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • 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.

wp

  • Hero Member
  • *****
  • Posts: 11857
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 »

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • 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  :(

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: ChartListBox: Check and Radio not showing in COCOA
« Reply #18 on: February 13, 2020, 01:02:26 am »
Grrrrh...

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • 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.

AL

  • Sr. Member
  • ****
  • Posts: 261
[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 3.1, fpc 3.2.2, Win10
Laz 3.1  fpc 3.2.2, MacOS Monterey running on VMWare/Win 10
Laz 3.1  fpc 3.2.2 Ubuntu 20.04

wp

  • Hero Member
  • *****
  • Posts: 11857
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...")

AL

  • Sr. Member
  • ****
  • Posts: 261
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 3.1, fpc 3.2.2, Win10
Laz 3.1  fpc 3.2.2, MacOS Monterey running on VMWare/Win 10
Laz 3.1  fpc 3.2.2 Ubuntu 20.04

wp

  • Hero Member
  • *****
  • Posts: 11857
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 »

AL

  • Sr. Member
  • ****
  • Posts: 261
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 3.1, fpc 3.2.2, Win10
Laz 3.1  fpc 3.2.2, MacOS Monterey running on VMWare/Win 10
Laz 3.1  fpc 3.2.2 Ubuntu 20.04

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • 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.

wp

  • Hero Member
  • *****
  • Posts: 11857
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".

AL

  • Sr. Member
  • ****
  • Posts: 261
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 3.1, fpc 3.2.2, Win10
Laz 3.1  fpc 3.2.2, MacOS Monterey running on VMWare/Win 10
Laz 3.1  fpc 3.2.2 Ubuntu 20.04

AL

  • Sr. Member
  • ****
  • Posts: 261
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 3.1, fpc 3.2.2, Win10
Laz 3.1  fpc 3.2.2, MacOS Monterey running on VMWare/Win 10
Laz 3.1  fpc 3.2.2 Ubuntu 20.04

wp

  • Hero Member
  • *****
  • Posts: 11857
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.

 

TinyPortal © 2005-2018