Partially work around currently unimplemented cache invalidation in
wxMac and do it on the fly if an invalid index is passed to
GetDisplay() to at least avoid crashing, even if this doesn't fully
solve the problem, e.g. we still can use stale information.
Closes#18607.
Don't update the grid appearance when inside a sequence of batch
operations, it will be updated at the end of it anyhow and doing it in
the middle only results in extra flicker.
Since the changes of dda6aa6bdc wxGrid
code could ask the grid table for the data of an invalid cell due to
redrawing the old, and now possibly invalid, current cell from inside
SetCurrentCell() called from wxGrid::Redimension().
Fix this by explicitly resetting the old current cell to an invalid
value when changing it in UpdateCurrentCellOnRedim().
Also avoid calling SetCurrentCell() entirely if the current cell doesn't
change, as this is just completely unnecessary and results in a possible
unexpected wxEVT_GRID_SELECT_CELL event.
See https://github.com/wxWidgets/wxWidgets/pull/1546
The recent change of 19844d27ac fixed this
function for valid values of input/output parameters on input, but broke
it if the parameters had invalid value: in this case, we still need to
fill them even if this attribute doesn't have any specific alignment of
its own.
Account for this case too now, explain the logic of this function in the
comments inside it and extend the unit test to check for this case too.
Now the function should really conform to its documented (and expected,
including by the existing code in various grid renderers) behaviour.
Closes https://github.com/wxWidgets/wxWidgets/pull/1665
The change of 4990515aba resulted in
(disabled by default, but which may be enabled when building
applications using wxWidgets) MSVS 2017 warning C4265 ('class' : class
has virtual functions, but destructor is not virtual), so test for clang
explicitly instead of just testing for non-gcc.
Obtaining bytes per row makes sense only for bitmap image representation
so we have to ensure that the bitmap represenation exists before querying
for its row stride length. NSImage per se cannot provide this information.
Closes#18606.
In order to get access to wxBitmap's pixel data we actually have to work
with CGBitmapContext data and this context is created from NSImage by call
to wxBitmapRefData::EnsureBitmapExists() when we prepare to get access
to the data in wxBitmapRefData::GetRawAccess().
So, when we finish updating bitmap data we should update original NSImage
with actual CGBitmapContext data in wxBitmapRefData::EndRawAccess().
See #18606.
Fix positions of the checkboxes drawn by wxGridCellBoolRenderer and
shown by wxGridCellBoolEditor so that there is no jump when starting or
stopping to edit grid cells with boolean values.
See https://github.com/wxWidgets/wxWidgets/pull/1662
Using wxRendererNative::GetCheckBoxSize() as the size of wxCheckBox just
doesn't work with GTK 3, as the control has additional padding between
its actual contents and the focus rectangle, which means that its actual
size must be greater than the size to be passed to DrawCheckBox() in
order to draw a checkbox of the same size.
However it isn't really necessary to resize wxCheckBox at all, it's
enough for DrawCheckBox() to produce a check mark of the same size as
that shown in a default-sized wxCheckBox and this does work in wxGTK.
So keep the default size of wxCheckBox to make everything work.
This means wxGetGridCheckBoxRect() is not useful any more, so replace it
with wxGetContentRect() which just positions a rectangle of the given
size inside another one (this should probably be moved somewhere else,
as it's more general than wxGrid).
This makes the checkbox look ugly as it's clearly not supposed to be
rendered without the border at all, so it's better to do nothing than
mangle its CSS.
It could be better to add some virtual GTKTurnOffBorder() method that
could be overridden to do nothing in wxCheckBox and we should consider
doing this if there are other classes for which wxNO_BORDER breaks their
appearance, but for now, as long as it's the only case in which we need
to do this, just turn wxNO_BORDER off when calling PostCreation().
This results in rather ugly checkboxes when the rectangle is too small,
and even "critical" GTK warnings with wxGTK 3, but is still arguably
better than drawing outside of the provided rectangle.
Doing this makes the checkbox unusable with the default GTK 3 theme as
the default grid background colour (white) is the same as the colour of
the check mark -- so changing the checkbox background to it makes it
invisible.
Work around this by adding a new SetTransparentPartColour() method that
can be used by wxGrid (and, in the future, user code if we decide that
this is really the best solution to this problem that we can provide) to
make the checkbox blend in with its background without actually changing
its appearance.
No real changes, just extract the same code used in both GTK 2 and GTK 3
implementations of GetCheckBoxSize() and DrawCheckBox() in a helper
class which is now just used from both places.
This makes the code more clear and hopefully easier to maintain in the
future.
Put GTK 3 version first in both functions instead of putting it in the
middle (!) of GTK 2 code in the former one for some reason.
No real changes, the code was just moved around (this commit is best
viewed with "git diff --color-moved").
It doesn't make much sense to pass the size to the function supposed to
compute it, so call wxRendererNative::GetCheckBoxSize() from the
function itself instead of forcing its callers to do it.
No real changes.
Make the alignment used by default in wxGridCellBoolRenderer and
wxGridCellBoolEditor consistent and centre the checkbox vertically in
both of them: previously only the editor tried to do it, but failed,
because the code wrongly overwrote the default alignment as it used
GetAlignment() instead of GetNonDefaultAlignment(), while the renderer
didn't even try.
Remove the code in wxGrid::ShowCellEditControl() which moves grid
editors unnecessarily and also remove workarounds that were required
because of it in the editors SetSize() functions.
This helps to ensure that the editor is placed at the same position the
renderer draws the cell value, so that it doesn't jump around annoyingly
when editing starts (which was especially noticeable for boolean-valued
cells).
Make this header self-sufficient, instead of requiring wx/headerctrl.h
to be included before including it.
Remove the now unnecessary wx/headerctrl.h inclusion from
src/generic/grideditors.cpp.
Add ability to get the size of the checkbox without any margins by
passing wxCONTROL_CELL flag: this can be useful when the checkbox is
part of some "cell", e.g. wxGrid one, and doesn't need any extra margins
around it.
Currently wxCONTROL_CELL is only really used by wxGTK2 implementation.
This method of wxGtkStyleContext uses a GTK function only available
since 3.20, and so can't be implemented for the earlier versions, hence
don't even define it in this case.
Note that the caller still needs to test for the run-time version.