doublemax wrote:I see two options:
a) If you don't want to change too much to your current code, you could send a GRID_CELL_CHANGED event from the table to the grid when the model data changed.
b) You move the gridChanged flag to the table and add a public method to your derived class that returns the value.
Well i followed your suggestion, for one more time
, and decided to create an event on the class that modifies the table.
More specific i added :
Code: Select all
wxDECLARE_EVENT(EVT_DATASET_CHANGED, wxGridEvent);
in the class header file. Then i added :
Code: Select all
wxDEFINE_EVENT(EVT_DATASET_CHANGED, wxGridEvent);
in the class source file and then in the code that modifies the table i added this :
Code: Select all
wxCommandEvent event(EVT_DATASET_CHANGED);
wxPostEvent(m_handler, event);
This fires the event everytime the table changes.
To handle the event i had to write a public method in my class which i called
Code: Select all
void SetEventHandler(wxEvtHandler* handler) { m_handler = handler; }
Now to catch the event in my panel that has the grid i did the following :
Code: Select all
GridTableDataSet *dataset = new GridTableDataSet();
dataset->SetEventHandler(this);
Bind(EVT_DATASET_CHANGED, &mapViewPanel::onGridValueChanged, this);
After all these changes the event works as i expected.
The only drawback is that the update of the window is a bit slow. Combined the mouse move events, cell value changing and cell background cell color changing at the same time makes it a bit slow. Especially the drawing of the background color is the most slow because it calculates color based on all the cell values. Maybe i need to find another way to do the background color, like a wxGridCellRenderer that you mentioned earlier.
Regards