Forum > LCL

TControl and TGraphic Control creation issue

<< < (6/7) > >>

wp:
In the meantime Anton Kavalenka posted a patch to my bugreport, and the issue is fixed now in trunk (https://bugs.freepascal.org/view.php?id=38852). If you don't use trunk you can easily modify a single line in one of the gtk2 files of your installation:

* Open file gtk2winapi.inc from folder lcl/interfaces/gtk2 of your Lazarus installation (Note: there is also a file gtk2winapih.inc which would be wrong...)
* Find function TGtk2WidgetSet.Polygon, it should begin at around line number 6900.
* A few lines after the "begin" you'll see this code:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  // create the PointsArray, which is a copy of Points moved by the DCOrigin  // only if needed  if (DevCtx.IsNullPen and (DevCtx.IsNullBrush or Winding)) then    PointArray := nil
* Replace the line with the "if..." by "if DevCtx.IsNullPen and DevCtx.IsNullBrush then" (i.e. remove the "or Winding")
* Recompile the IDE, and when Lazarus restarts you can use your old code again

jcdammeyer:
So far this works on LinuxCNC and the Beaglebone.  Haven't tried it yet on the Pi3 or Pi4.
However it does raise a few questions.
1. What is Winding?  A search shows up the usage of this is poorly or not documented at all.  Like a "if the moon is full" flag.
2. The definition of DevCtx.IsNullPen is in an included file and linkage to the actual function is also obscure.  Does IsNullPen return True if psClear is set for the pen?

The reason I ask is when I was single stepping through the program after WP posted the working version with an initialized array I stumbled into that code in the Polygon method.  In fact when I went to the LinuxCNC system to add this new fix that removes winding,  the file was already loaded and the cursor was right at that point.  So I'd gotten to the point where it was in fault.

But I got lost for the reasons stated above.  Couldn't find additional information and there wasn't any documentation that explained why  it was testing for this winding flag.  (Which BTW, was TRUE when stopped at this breakpoint).

Sure glad the problem is fixed.  I'll start a new thread on the component icon issue.

So again.  Thank you, thank you, thank you.
John

jcdammeyer:
One other question.  Using fcpupdeluxe on a new device, what is selected to get this bug fix without editing the file again?

Or is this better asked on this thread?
https://forum.lazarus.freepascal.org/index.php?topic=46438.new;topicseen#new

wp:

--- Quote from: jcdammeyer on May 06, 2021, 08:55:17 pm ---1. What is Winding?  A search shows up the usage of this is poorly or not documented at all. 
--- End quote ---
It is mentioned in https://wiki.lazarus.freepascal.org/Graphics_-_Working_with_TCanvas#Self-overlapping_polygons or in https://lazarus-ccr.sourceforge.io/docs/lcl/graphics/tcanvas.polygon.html:

--- Quote ---Winding determines how the polygon is filled. When Winding is True, Polygon fills the shape using the Winding fill algorithm.
When Winding is False, Polygon uses the even-odd (alternative) fill algorithm.
--- End quote ---
But you may have to ask the internet to learn about these algorithms. It's about determining whether a point is inside a closed polygon or outside. Without going into detail, the effect of the winding parameter on a polygon fill can be seen in the attached demo project.


--- Quote from: jcdammeyer on May 06, 2021, 08:55:17 pm ---2. The definition of DevCtx.IsNullPen is in an included file and linkage to the actual function is also obscure.  Does IsNullPen return True if psClear is set for the pen?
--- End quote ---
Don't let these details confuse you. They are deep inside the heart of the gtk2 widgetset, and normally not needed by the application developer.

wp:

--- Quote from: jcdammeyer on May 06, 2021, 10:08:59 pm ---Using fcpupdeluxe on a new device, what is selected to get this bug fix without editing the file again?

--- End quote ---
In the Lazarus Version listbox select the option "trunk" - this is the development version but you should be aware that it is not as stable as the fixes or numbered release versions. The patch has been put onto the merge request list for the Fixes branch (https://wiki.lazarus.freepascal.org/Lazarus_2.0_fixes_branch#Fixes_for_2.0.14), so after some time you will find it also in the "Fixes" item of the listbox.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version