Hi jules,
This code shows the problem. Each time a different Tab is selected the tab background and text colour changes and the field names need to change to show the fields appropriate for the newly selected tab. As you can see after a few tabs are selected the text commands and mesh commands just add to the plot as expected. Obviously I will have the same issue when I start displaying data for each field. So, I need a way to delete some or all of the text and mesh plot objects.
using version 1.8.2 and vscode under windows 10.
apologies for the amateur standard coding.
Thanks
Steve
function Spreadsheet_cellCountX(s::Spread)
return max(size(s.columnLabels,1),size(s.columnLabels,2))
end
function Spreadsheet_gridWidth(s::Spread)
return s.cellWidth * Spreadsheet_cellCountX(s)
end
function Spreadsheet_gridHeight(s::Spread)
return s.cellHeight * s.cellCountY
end
function Spreadsheet_cellTextXOffset(s::Spread)
return floor(s.cellWidth*s.textPaddingX)
end
function Spreadsheet_cellTextYOffset(s::Spread)
return floor(s.cellHeight*s.textPaddingY)
end
function drawSpreadsheet(s::Spread)
vertices = [0.0 0.0;s.cellWidth 0.0;s.cellWidth Spreadsheet_gridHeight(s)-2*s.cellHeight; 0.0 Spreadsheet_gridHeight(s)-2*s.cellHeight]
faces = [1 2 3;3 4 1]
mesh!(s.axis,vertices, faces, color = (:gray,0.3), shading = false)
vertices = [0.0 Spreadsheet_gridHeight(s)-2*s.cellHeight;
Spreadsheet_gridWidth(s) Spreadsheet_gridHeight(s)-2*s.cellHeight;
Spreadsheet_gridWidth(s) Spreadsheet_gridHeight(s)-s.cellHeight;
0.0 Spreadsheet_gridHeight(s)-s.cellHeight]
faces = [1 2 3;3 4 1]
mesh!(s.axis,vertices, faces, color = (:gray,0.3), shading = false)
vlines = [vlines!(s.axis,i, color=(:black, 0.90)) for i=0:s.cellWidth:Spreadsheet_gridWidth(s)]
hlines = [hlines!(s.axis,i, color=(:black, 0.90)) for i=0:s.cellHeight:Spreadsheet_gridHeight(s)]
drawTabs(s,s.defaultTab)
drawColumnHeaders(s,s.defaultTab)
end
function drawTabs(s::Spread,tab::Int)
#define tab labels
for i=1:size(columnLabels,2)
if i==tab
text!(s.axis,s.tabLabels[i], position = ((i-1)*s.cellWidth+(s.textPaddingX*s.cellWidth),Spreadsheet_gridHeight(s)-s.cellHeight+(s.textPaddingY*s.cellHeight)), color = (:black,0.99), textsize = s.fontSize)
else
text!(s.axis,s.tabLabels[i], position = ((i-1)*s.cellWidth+(s.textPaddingX*s.cellWidth),Spreadsheet_gridHeight(s)-s.cellHeight+(s.textPaddingY*s.cellHeight)), color = (:black,0.4), textsize = s.fontSize)
end
end
vertices = [(tab-1)*s.cellWidth Spreadsheet_gridHeight(s)-s.cellHeight;
tab*s.cellWidth Spreadsheet_gridHeight(s)-s.cellHeight;
tab*s.cellWidth Spreadsheet_gridHeight(s);
(tab-1)*s.cellWidth Spreadsheet_gridHeight(s)]
faces = [1 2 3;3 4 1]
mesh!(s.axis,vertices, faces, color = (:gray,0.3), shading = false)
end
function drawColumnHeaders(s::Spread,tab::Int)
for i=1:size(columnLabels,1)
text!(s.axis,s.columnLabels[tab,i], position = ((i-1)*s.cellWidth+(s.textPaddingX*s.cellWidth),Spreadsheet_gridHeight(s)-2*s.cellHeight+(s.textPaddingY*s.cellHeight)), color = (:black,0.99), textsize = s.fontSize)
end
end