wxgrid problems

This forum is reserved for everything you want to talk about. It could be about programming, opinions, open source programs, development in general, or just cool stuff to share!
Post Reply
knightmare0
Experienced Solver
Experienced Solver
Posts: 65
Joined: Sat Mar 29, 2008 9:18 pm

wxgrid problems

Post 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.
macsinus
Earned a small fee
Earned a small fee
Posts: 16
Joined: Mon Feb 22, 2016 12:36 pm
Location: Leipzig, Germany

Re: wxgrid problems

Post 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).
wxWidgets 3.1.0
Boost 1.65
VS 2017
Win 7
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxgrid problems

Post 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.
Use the source, Luke!
macsinus
Earned a small fee
Earned a small fee
Posts: 16
Joined: Mon Feb 22, 2016 12:36 pm
Location: Leipzig, Germany

Re: wxgrid problems

Post 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...
wxWidgets 3.1.0
Boost 1.65
VS 2017
Win 7
Post Reply