[SOLVED] ChartListBox: Check and Radio not showing in COCOA lazarus / 55-TAChart ---------------------------------------------------------------------- AL · 2020-01-30 14:54 The Chart listBox component does not show the checkbox in Cocoa the icon (line) is shown. With the radio button activated.  The radio button is not shown and the icon (line) not shown. This is with cross compiling win10-Darwin FPC 3.3.1 Laz 2.1.0 Tested in VMWare Mac 10.14 ---------------------------------------------------------------------- wp · 2020-01-30 15:53 The ChartListBox is similar to a TCheckListBox (on palette "Additional"). Does is show the same issue? Or are the checkboxes drawn correctly, but the radion buttons not? Again, could you also post the screenshot taken on Windows so that I can see what you are expecting? (Or post the entire project). ---------------------------------------------------------------------- AL · 2020-01-30 17:28 The listbox is drawn correctly, only the checkbox is not shown when checkbox is selected and the radiobutton and icon are not shown when radio button is selected. Here is a windows version for comparison. This is an empty project just to demonstrate the behavior. Would it be better to post this in COCOA? ---------------------------------------------------------------------- wp · 2020-01-30 19:01 And is the checkbox displayed correctly for the CheckListBox? If yes I could look for the differences. ---------------------------------------------------------------------- AL · 2020-01-30 21:19 The check square is not displayed but the icon is displayed. ---------------------------------------------------------------------- wp · 2020-01-31 00:24 Icon in the TCheckListbox? You probably don't understand what I mean. I am talking of the TCheckListbox on palette "Additional" - see screenshot. It is as standard component with similar functionality as TChartListbox but it draws the checkbox a bit differently. ---------------------------------------------------------------------- AL · 2020-01-31 00:45 Oh, sorry my bad, checklistbox, chartlistbox with check,... confusing. Yes the CHECKlistbox show properly in MacOS as you can see on the attached. ---------------------------------------------------------------------- wp · 2020-01-31 08:47 Here's another test: Could you show me how the attached demo behaves in MacOS? It shows two more LCL controls, a TStringGrid with checkbox column, and a TCheckCombobox. In both controls, the checkboxes are drawn using the theme services, like in TChartlistbox. If checks are not displayed here again then this is an argument that theme services for checkboxes are not correctly implemented for MacOS. (TCheckListBox that you already tested passes the drawing task to the widget set). ---------------------------------------------------------------------- AL · 2020-01-31 14:28 Here is the result in VM MacOS and Win64 Edit:   added new printscreen with combobox drop down. There is a little glitch when not dropdown but it show the checkbox correctly ---------------------------------------------------------------------- AL · 2020-02-12 00:35 WP, could you make sense of why this is happening? Would it be better to make a bug report in Cocoa? Thanks ---------------------------------------------------------------------- wp · 2020-02-12 15:05 Could you try the attached project on Mac? It draws a checked and an unchecked checkbox onto two paintboxes. In the first paintbox the checkbox size is determined by the code as is done in TChartListbox, in the second it is determined by the theme services as is done by the other LCL controls. It's hard to believe that this would make a difference, but beyond that the drawing code looks fairly similar. ---------------------------------------------------------------------- AL · 2020-02-12 21:06 You were right! There is no difference. None of them show a check. Also the Mac does not show the label. This is on a virtual Mac.  May be we need someone to try it on a real Mac. Trev has been very helpfull in another problem, I will send a PM and ask him to try the attached. ---------------------------------------------------------------------- trev · 2020-02-12 21:39 Result of the test.zip project on a 2018 Mac mini running  Mojave 10.14.6 is attached. ---------------------------------------------------------------------- AL · 2020-02-12 21:47 Thank you Trev,  this give the same as in my Vm MAC. It look like this is more work for the Cocoa team! ---------------------------------------------------------------------- wp · 2020-02-12 21:57 "No themes enabled" in the title? How is that? I thought themes are always enabled nowadays... Comparing with the TCustomStringGrid code I see that the check for "ThemeServices.ThemesEnabled" is skipped. Could you please remove the line "if ThemeServices.ThemesEnabled" (and the associated "else" block) so that the entire OnPaint handler of the paintboxes is like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.PaintBox1Paint(Sender: TObject);const  THEMED_FLAGS: array [Boolean] of TThemedButton = (    tbCheckBoxUncheckedNormal, tbCheckBoxCheckedNormal  );var  rcb: TRect;  te: TThemedElementDetails;  ch: Boolean;  sz: TSize;  paintbox: TPaintBox;  lbl: TLabel;begin  paintbox := TPaintBox(Sender);  if Sender = Paintbox1 then    lbl := Label1  else    lbl := Label2;   paintbox.Canvas.Brush.Color := clWhite;  paintbox.Canvas.FillRect(Rect(0, 0, paintbox.Width, paintbox.Height));   //if ThemeServices.ThemesEnabled then begin   // <---------- REMOVE THIS LINE ...    ch := true;    te := ThemeServices.GetElementDetails(THEMED_FLAGS[ch]);    if Sender = Paintbox1 then      sz := Size(30, 30)    else      sz := ThemeServices.GetDetailSize(te);;    rcb := Rect(0, 0, sz.CX, sz.CY);    lbl.Caption := Format('rcb = %d %d %d %d', [rcb.Left, rcb.Top, rcb.Right, rcb.Bottom]);    ThemeServices.DrawElement(paintbox.Canvas.Handle, te, rcb);     OffsetRect(rcb, 40, 0);    ch := false;    te := ThemeServices.GetElementDetails(THEMED_FLAGS[ch]);    ThemeServices.DrawElement(paintbox.Canvas.Handle, te, rcb);  //end                                // <-------------- AND THESE  //else  //  Caption := 'NO THEMES ENABLED';end; ---------------------------------------------------------------------- trev · 2020-02-12 22:06 Removing the themes bypass... see attached. ---------------------------------------------------------------------- wp · 2020-02-12 23:13 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. ---------------------------------------------------------------------- trev · 2020-02-12 23:55 No attachment ---------------------------------------------------------------------- wp · 2020-02-13 00:02 Grrrrh... ---------------------------------------------------------------------- trev · 2020-02-13 00:23 Results attached. ---------------------------------------------------------------------- AL · 2020-02-13 02:42 Quote from: wp on February 13, 2020, 12:13:39 amWow! 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. ---------------------------------------------------------------------- wp · 2020-02-13 08:52 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TChartListbox.DrawItem(  AIndex: Integer; ARect: TRect; AState: TOwnerDrawState);{ draws the listbox item }const  THEMED_FLAGS: array [TCheckboxesStyle, Boolean] of TThemedButton = (    (tbCheckBoxUncheckedNormal, tbCheckBoxCheckedNormal),    (tbRadioButtonUnCheckedNormal, tbRadioButtonCheckedNormal)  );var  id: IChartDrawer;  rcb, ricon: TRect;  te: TThemedElementDetails;  x: Integer;  ch: Boolean;begin  if Assigned(OnDrawItem) then begin    OnDrawItem(Self, AIndex, ARect, AState);    exit;  end;  if (FChart = nil) or not InRange(AIndex, 0, Count - 1) then    exit;   Canvas.FillRect(ARect);  CalcRects(ARect, rcb, ricon);   if cloShowCheckboxes in Options then begin    ch := Checked[AIndex];    te := ThemeServices.GetElementDetails(THEMED_FLAGS[FCheckStyle, ch]);    ThemeServices.DrawElement(Canvas.Handle, te, rcb);    x := rcb.Right;  end  else    x := ARect.Left;   Canvas.Brush.Style := bsClear;  if cloShowIcons in Options then begin    id := TCanvasDrawer.Create(Canvas);    id.Pen := Chart.Legend.SymbolFrame;  FLegendItems[AIndex].Draw(id, ricon);  end  else    Canvas.TextOut(x + 2, ARect.Top, FLegendItems.Items[AIndex].Text);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 · 2020-02-13 16:49 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! ---------------------------------------------------------------------- wp · 2020-02-13 17:04 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. ---------------------------------------------------------------------- AL · 2020-02-13 19:15 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. ---------------------------------------------------------------------- trev · 2020-02-13 23:43 From the Free Pascal ref docs (https://www.freepascal.org/docs- html/3.0.0/user/usersu7.html): QuoteAlso, 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 · 2020-02-14 00:02 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 · 2020-02-14 00:33 Quote from: trev on February 14, 2020, 12:43:01 amFrom the Free Pascal ref docs (https://www.freepascal.org/docs- html/3.0.0/user/usersu7.html): QuoteI think this explains your issue. Possibly, it does not do that error in my regular program. ---------------------------------------------------------------------- AL · 2020-02-14 01:04 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. ---------------------------------------------------------------------- wp · 2020-02-17 23:44 The issue should be fixed now in the trunk version. ---------------------------------------------------------------------- AL · 2020-03-05 03:31 Sure it is, Thank you