Reputation: 1035
In order to refresh a part of the grid, i.e., when font or alignment changes, I was using the following approach:
wxRect rect1=CellToRect(TopLeft);
wxRect rect2=CellToRect(BottomRight);
wxRect r(rect1.GetTopLeft(), rect2.GetBottomRight());
RefreshRect(r);
This was refreshing only a part of the intended block and was not working correctly.
From the suggestions of intellisense I came across RefreshBlock
function and it works correctly. I searched the docs and have not found any information on it. I wonder if it is not recommended to use RefreshBlock
for some reason? What does RefreshBlock
do, does it refresh a block (as the name suggests) or is it equivalent to Refresh
?
I am using wxWidgets 3.2 on Win10.
Thanks in advance.
Upvotes: 0
Views: 44
Reputation: 22688
The function RefreshBlock()
is indeed the best way to do what you want and it was only undocumented by mistake, i.e. we simply forgot to do it. I've added documentation for it only now, so it will only get included in 3.2.1, but you can still use it in your code, the function itself is available since 3.1.3.
Upvotes: 1
Reputation: 1035
It seems from the source code that, depending on the location of its parameters, RefreshBlock
refreshes any of the following:
Since the area I wanted to refresh was on the main grid the following approach works (the idea is similar to RefreshBlock's approach):
auto GridWnd = CellToGridWindow(TL);
wxRect rect = BlockToDeviceRect(TL, BR, GridWnd);
GetGridWindow()->RefreshRect(rect);
Now everything is refreshed correctly.
Notes:
RefreshRect(rect)
is called, things will NOT work as expected.BlockToDeviceRect(TL, BR)
also works, therefore eliminating the need for auto GridWnd = CellToGridWindow(TL);
Upvotes: 0