I am stuck on this "project" I took the below project and I am trying to convert it to a B4X project.
B4J Breadboard by Use Wonder
Wonder uses B4J and creates the canvas as a Node. (Everything Works Great)
I followed Erel's example and created a Class Module, "cust_grd.bas". The layout file "GridPanel" contains one view of a Pane, "pnlGrid".
The issue seems to be in Wonder's example he draws the Grid Cells and uses the code below which is commented with my substitution for B4X code.
I have this in Class_Globals
Dim R As B4XRect
Also, I am not sure what this line does in the InitializeGrid Sub ?
So far I have it somewhat working. It draws the grid if I initializes it with ( InitializeGrid(0, 0, 20) )
But, I am only able to draw colors and fill/clear the Grid Block in the upper right Block at 0,0. I uploaded my "project" as a zip file.
It does log all the Grid Coordinates correctly, but does not fill in the blocks with a color other than bock 0,0.
My attached code has comments from the differences from his project to mine as well as my message test logging to try and fix my code.
I am pretty sure it is the way the grid coordinates are different and calculated between B4J and B4X or the creation of the B4Xrect.
This is my first B4J project and it looks like I picked a good one. I have spent hours trying to get it to work.
Any suggestions would be appreciated. Thanks !
B4J Breadboard by Use Wonder
Wonder uses B4J and creates the canvas as a Node. (Everything Works Great)
I followed Erel's example and created a Class Module, "cust_grd.bas". The layout file "GridPanel" contains one view of a Pane, "pnlGrid".
The issue seems to be in Wonder's example he draws the Grid Cells and uses the code below which is commented with my substitution for B4X code.
B4X:
'cvs.DrawRect(gX, gY, testGrid.gridStep, testGrid.gridStep, colorMap.Get(testGrid.matrix(x, y)), True, 0)
R.Initialize(gX,gY,testGrid.gridStep, testGrid.gridStep)
cvs.DrawRect(R, colorMap.Get(testGrid.matrix(x, y)), True, 0)
I have this in Class_Globals
Dim R As B4XRect
Also, I am not sure what this line does in the InitializeGrid Sub ?
B4X:
Dim matrix(sizeX, sizeY) As Int : testGrid.matrix = matrix
So far I have it somewhat working. It draws the grid if I initializes it with ( InitializeGrid(0, 0, 20) )
But, I am only able to draw colors and fill/clear the Grid Block in the upper right Block at 0,0. I uploaded my "project" as a zip file.
It does log all the Grid Coordinates correctly, but does not fill in the blocks with a color other than bock 0,0.
My attached code has comments from the differences from his project to mine as well as my message test logging to try and fix my code.
I am pretty sure it is the way the grid coordinates are different and calculated between B4J and B4X or the creation of the B4Xrect.
This is my first B4J project and it looks like I picked a good one. I have spent hours trying to get it to work.
Any suggestions would be appreciated. Thanks !