Recent

Author Topic: TsWorksheetGrid recursive drawcell  (Read 6499 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
TsWorksheetGrid recursive drawcell
« on: May 25, 2016, 11:56:36 pm »
Hello boys in a TsWorksheetGrid within the DrawCell event going to draw the canvas as well as making the merge cell and noticed that these two things trigger the recursive function calls. In fact, when I go to the cell-click the program it is slow. Someone tells me how to fix it?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: TsWorksheetGrid recursive drawcell
« Reply #1 on: May 26, 2016, 12:47:58 am »
within the DrawCell event...
Do you call OnDrawCell? Hmmh... I don't know what happens, at least it may destroy much of the infrastructure of the spreadsheet grid. Normally there is no need to call OnDrawCell. The grid gets everything it needs from the worksheet in the background. I think I should remove much of the functionality people know from TStringGrid. What are you trying to achieve by the OnDrawCell?

trigger the recursive function calls.
What do you mean by this? Please give an example with step-by-step instructions how to reproduce the issue.

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TsWorksheetGrid recursive drawcell
« Reply #2 on: May 26, 2016, 10:41:37 am »
Hello, I have an example to make you understand what I mean.

Run the source that you have attached. They should comparirti two green areas on the grid. Then click on the button1 button and you'll see that the first edit is filled with numbers. I thought it would be increased by two. Instead increased by 16. Try it out by clicking on different cells.

For me it is a problem if you call progressively from just because more people the grid and becomes sluggish.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TsWorksheetGrid recursive drawcell
« Reply #3 on: May 26, 2016, 10:47:46 am »
If comments row

TsWorksheetGrid(sender).MergeCells(aCol, aRow, aCol, aRow+1); 

you'll see that the increases are lower.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TsWorksheetGrid recursive drawcell
« Reply #4 on: May 26, 2016, 08:59:03 pm »
I solved. I extracted the MergeCell from DrawCell event and I solved. Ignore well what I wrote above.

What I do not understand is how do I remove the merge of three cells should you redesign the data differently.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TsWorksheetGrid recursive drawcell
« Reply #5 on: May 27, 2016, 10:39:48 am »
I realized that I can have a new sheet as:

Self.DG.NewWorkbook(Self.DG.ColCount,Self.DG.RowCount);

But in this way I get flickering while drawing and I do not like. How can I fix?

Also have you ever tried to draw one of these grids on a frame? Try it, saves close the project and then reopen it and you'll see that there's a bug. At least on linux.

Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: TsWorksheetGrid recursive drawcell
« Reply #6 on: May 27, 2016, 05:25:22 pm »
Fixed the bug related to using the grid in frames. Thanks for reporting.

As for the other things that you mention I am a bit helpless since I do not understand what you are trying to achieve. I also do not understand what you mean by "merging of cells": In the WorksheetGrid it combines several cells to a big one, but in your other post I get the impression that you want to create a color gradient between two colors which is a completely different thing.

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TsWorksheetGrid recursive drawcell
« Reply #7 on: May 28, 2016, 11:58:20 am »
Do not even mention it. Thank you for having fixed the bug. Where can I find the updated version?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: TsWorksheetGrid recursive drawcell
« Reply #8 on: May 28, 2016, 12:36:12 pm »
https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/fpspreadsheet/. Best use svn to have an updated version.

In case you don't want to switch to trunk, open your copy of fpspreadsheetgrid.pas and make the following modifications:

In the interface part, change these lines in TsCustomWorksheetGrid, section protected
Code: Pascal  [Select][+][-]
  1.   procedure CreateHandle; override;   // <-- add
  2.   //procedure Loaded; override;    // <--- remove the procedure

Then, in the implemenation section
- remove the Loaded procedure
- add this new method:
Code: Pascal  [Select][+][-]
  1. procedure TsCustomWorksheetGrid.CreateHandle;
  2. begin
  3.   inherited;
  4.   Setup;
  5. end;

Re-install the package laz_fpspreadsheet_visual.

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TsWorksheetGrid recursive drawcell
« Reply #9 on: May 29, 2016, 05:43:25 pm »
Wp Hello, I have one more question. I have a problem of the grid to flicker when I upgrade. I created a test to make you understand. Press the button1 after selecting a different cell from cells [0,0].

I have to figure out how to eliminate flicker.


The problem I think is related to the use of: NewWorkbook

I have to be able to clean the grill and then update it! Flicker.

Thanks
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TsWorksheetGrid recursive drawcell
« Reply #10 on: May 31, 2016, 03:51:14 pm »
Any advice?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: TsWorksheetGrid recursive drawcell
« Reply #11 on: May 31, 2016, 04:23:14 pm »
I did not see this post, sorry... But: I cannot reproduce the flicker on my machine. Since the "NewWorksheet" may trigger several repaints I nevertheless added a TsWorksheet.Clear and a TsWorksheetGrid.Clear which removes any content from the grid, but leaves the grid size intact. Besides your issue, these are useful methods anyway. Maybe the flickering is better as well.

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TsWorksheetGrid recursive drawcell
« Reply #12 on: May 31, 2016, 04:36:11 pm »
Sorry, but I did not understand. So I recommended to change
DG.NewWorkbook (100, 100);
in
DG.Clear;

Because the clear I had already tried, but does not remove me merge the cells!

Test the attachment
« Last Edit: May 31, 2016, 04:43:31 pm by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: TsWorksheetGrid recursive drawcell
« Reply #13 on: May 31, 2016, 05:07:27 pm »
The old Clear was the one inherited from TCustomGrid which does not work correctly here. The new Clear erases all cell content, cell formats, merged cells, hyperlinks, comments, images etc.

The reasone why the merged cells in your demo do not disappear is that you recreate them after clearing the grid. Please look at your code.

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TsWorksheetGrid recursive drawcell
« Reply #14 on: May 31, 2016, 05:12:40 pm »
I make the merge only when the app variable is mod 2. So you should let me once and a no. I then at the end of the growth process lavariabile app. So I do not understand why me see forever. Look at the code:


  if ((app mod 2)=0) then
  begin
    DG.MergeCells(1,4,1,5);
    DG.MergeCells(2,4,2,5);
  end; 
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

 

TinyPortal © 2005-2018