Page 1 of 1

wxgrid problems

Posted: Wed Dec 03, 2008 3:03 am
by knightmare0
anyone notice wxGrid have some weird issues? for example when we call ->GetSelectedCells() it only returns the cells thats being selected using crt + click method, when shift or other methods are used it dose not register or counted in the array. This just dont make much sense.

my suggestion is this should be fixed in the up coming version, if you search related words in the forum about this issue you will find that most ppl have the same issue.

Re: wxgrid problems

Posted: Mon Mar 12, 2018 4:50 pm
by macsinus
I do understand the developers' documented reason for this:
Please notice this behaviour is by design and is needed in order to support grids of arbitrary size...
However, very often this is indeed what is desired and many people have to write the same code.
Suggestion: would it be possible to implement the desired function in the form of an iterator instead of returning a wxGridCellCoordsArray?

My reason for wanting this was in order to generalize the solution given for "Delete the contents of multiple cells in wxGrid" (viewtopic.php?f=1&t=44215&p=181627&hili ... te#p181606).

Re: wxgrid problems

Posted: Mon Mar 12, 2018 5:12 pm
by doublemax
Suggestion: would it be possible to implement the desired function in the form of an iterator instead of returning a wxGridCellCoordsArray?
Of course it's possible. And if someone wrote this code and made a pull request, it might even make it into the official code. But otherwise it's unlikely to happen.

Re: wxgrid problems

Posted: Tue Mar 13, 2018 8:10 am
by macsinus
Understood! 8)
The problem is a little more difficult than I thought, though (apart from the fact that I have no experience of working on open-source code).
I was thinking in terms of 2 methods: GetFirstSelectedCell() and GetNextSelectedCell() which go through the individually selected cells, rows, columns and rectangular blocks.
However, to do this properly (no cell more than once), GetNextSelectedCell() would need to check for overlaps in all combinations: difficult.
Holding a list of cells already returned in order to exclude them would a no-go for the same reason as in GetSelectedCells().
An alternative would be to iterate through every cell in the grid and check with IsInSelection(): easy, but inefficient for large grid with sparse selection.
I need to think about this for a while, maybe there's a better way...