Optimize wxGrid::AutoSizeColumns() for big grids.
This includes an optimization of wxDC::GetTextExtent() at the price of
slightly reduced precision in wxMSW.
See https://github.com/wxWidgets/wxWidgets/pull/1893
This allows to make computing the best width of numeric columns an O(1)
operation instead of O(number-of-rows), which can make a huge difference
for big grids.
Previously columns using a set of predetermined values used plain
wxGridCellStringRenderer, which didn't allow to determine their best
size efficiently, as wxGrid had to iterate over all the rows of the
table, even if they only took a couple of possible values.
Add wxGridCellChoiceRenderer (refactoring wxGridCellEnumRenderer to
extract the common code from it in the process) which implements
GetMaxBestSize() by just finding the best size of all of these values,
which is much faster for large grids.
This does result in a change in behaviour, as the column now adapts to
its "theoretical" best size and not just the size of the values actually
shown in it, but this seems to be a worthwhile trade-off and could even
be seen as an advantage, as editing a cell won't make its value overflow
the auto-sized column width any more, as it is wide enough to show any
of the column values.
This is another optimization, useful for the renderers that are used
with the values of a fixed form or part of a limited set, as it is much
faster to compute the best size for all values of the set rather than
computing them for all the cells in the column.
Extend wxAnimationCtrl XRC handler to cover wxGenericAnimationCtrl too.
Also fix a bug with wxGenericAnimationCtrl inactive bitmap background.
See https://github.com/wxWidgets/wxWidgets/pull/1889
Fix and improve DPI handling in wxStyledTextCtrl.
Fix cursor size after DPI change.
Enable handling DPI events in wxSTCPopupWindow and other popup windows
(that do not inherit from wxTopLevelWindow).
Some cleanup of STC example, and add option to select drawing
technology.
See https://github.com/wxWidgets/wxWidgets/pull/1885
This function basically only exists in order to be used in this handler,
so extend it to allow doing it by adding wxAnimationCtrlBase argument to
it, allowing it to create wxAnimation object compatible with the given
control.
This reduces code duplication and, incidentally, makes GetAnimation()
more useful for any user-defined XRC handlers.
This allows to write code using this function without any preprocessor
checks.
It should arguably be added to wxBitmapBase to ensure that it's
available in all ports, but should be done together with UseAlpha(),
which is not quite trivial, so leave it for later.
This reverts the changes of 63bcc669d8 (fixing setting initial value
under osx_cocoa for single line text controls, 2009-10-01) and fixes the
problem which this commit probably tried to fix in a different way,
using the same approach as in 98f5315405 (Don't set initial label in
wxNativeWindow on OS X, 2016-04-29) as the real root of the problem was
that the text set in CreateTextControl() was overwritten later when the
label was set from SetPeer().
This change means that the text is now set correctly before SetPeer()
calls SetInitialSize() call, which makes it possible to set the correct
initial size based on the initial text, as will be done in later
commits.
It also makes Cocoa port more consistent with iOS one, as a nice side
effect.
The old version resulted in
error: this condition has identical branches [-Werror=duplicated-branches]
| (dlg ? typeid(*dlg) : typeid(T)).name());
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
from gcc 10 when compiling with -O2.
Change the code to avoid using this condition entirely: not only this
avoids the warning, but it also makes it unnecessary to make
wxGetDialogClassDescription() function a template, so should result in
slightly faster compilation and smaller code size too.
No real changes.
This way, other windows (like wxPopupWindow) will also be able to handle DPI events.
Override InheritAttributes() and use it to set the initial DPI values.
Get rid of the unnecessarily complicated functions doing two quite
different things depending on whether their first boolean parameter was
true of false.
Instead, split their body between AutoSize{Columns,Rows}() (which used
to call them) and DoGetBestSize(), keeping just the part needed in each
case.
This is much simpler and even more efficient, as it avoids a completely
unnecessary call to CalcDimensions() and Refresh() from DoGetBestSize(),
which doesn't change the current size at all and so doesn't need to
refresh anything, but previously did it and not only once, but twice,
because both of SetOrCalc{Column,Row}Sizes() did it.
These functions are much simpler to use in the application code using
wxGrid in row- or column-only selection mode than GetSelectedBlocks()
itself because they take care of deduplicating, ordering and squashing
together the adjacent ranges, so that the application can use their
results directly, unlike with GetSelectedBlocks().
Don't generate dozens of deprecation warnings (one for each OpenGL
function used in the code) for any program using wxGLCanvas being built
using macOS 10.14 or later SDK.
Closes https://github.com/wxWidgets/wxWidgets/pull/1875
This allows to check if it's worth specifying wxAUI_MGR_LIVE_RESIZE or
not and allows to get rid of the corresponding menu item in the sample
if it doesn't do anything anyhow.
This method was added back in d3e8d3f271 (Support or disable "insert"
for drag/drop wxDataViewCtrl on OSX, 2018-07-16) but didn't appear in
the documentation at all, so describe it, at least minimally.
See #18167.
Under wxOSX the order of calls to wxItemContainer::Clear()
and wxTextEntry::Clear() matters.
Number of data objects to delete in wxItemContainer::Clear()
is obtained by call to wxComboBox::Count(). Counter of items
in wxComboBox is reset by wxTextEntry()::Clear()
so this method has to be called after wxItemContainer::Clear().
Closes#18768.
For native wxGTK implementation default spin control precision is derived
from the precision of the increment value. Fot the sake of consistency the
same should be done in the generic implementation.
Closes#18764.
Define it in wx/defs.h directly instead of conditionally including
wx/windowid.h from there just in order to get this type definition.
This has several advantages:
- wxWindowIDRef is not defined in (maybe) non-GUI code including
wx/defs.h, as it should be the case for this class defined in
core library only.
- wx/windowid.h becomes a normal header, including wx/defs.h as
(almost) all the other ones instead of being exceptional.
- wx/windowid.h doesn't need to be included by wx/utils.h at all
just to get wxWindowID definition.
Closes https://github.com/wxWidgets/wxWidgets/pull/1850
Remove separate checks for dlerror() which don't seem to be needed under
any platform any longer.
No real changes, just slim down configure/CMake a tiny bit.
This function is not used any more since e289eb07e1 (Get rid of
non-POSIX code for loading dynlibs on *nix, 2020-05-13), so don't check
for it and don't defined the corresponding HAVE_SHL_LOAD symbol.
Reduces the amount of #ifdefs scattered all over the code, thereby
simplifying the code.
The function was renamed from Error() to ReportError() to emphasize what
its purpose is.
Error messages logged on *nix are now a bit more verbose, as they are
prefixed with our own description text, which were earlier omitted on
platforms using the dlxxx() API.
This never worked correctly as using operator<<() with wchar_t pointer
just fell back to the overload for void pointers, i.e. printed out the
address of the wide string, which wasn't especially useful, but with
C++20 it doesn't even compile, as this overload is explicitly deleted.
Fix both problems at once by actually doing something useful for it
instead and printing out data in either current encoding or UTF-8 if
converting it to the current encoding failed.
In C++20 the reverse comparison operators are also considered when
searching for the operator to use and a wrong operator was selected for
comparisons between iterator and const_iterator, that would result in an
infinite recursion at run-time.
Fix this, thanks to the nice gcc 10 warning about it, by explicitly
defining the operators for this overload set too instead of relying on
implicit conversions.
Although not all these overloads are necessary, and they are only
necessary in C++20, it seems better to define all of them and always
just to be perfectly explicit and clear, as this code is not exactly
simple to follow.
When determining the entry width in wxSpinCtrlDouble, we need to account
not only for the width of the integer part, but also for the number of
digits that determines the width of the fractional part.
Do it in the overridden version of (now virtual) GtkSetEntryWidth().
See https://github.com/wxWidgets/wxWidgets/pull/1817Closes#18734.
* fixing compilation of tests that cannot build
bracket code with the corresponding wxUSE… macros
* adding directive for iOS
* adding a switch for skipping the run - not the build of tests
right now I don’t know yet, how to run the test binary in the iOS simulator, but building it is still a good test in itself
* adding skipping of tests
* increasing minimum deployment to get proper c++17 support
* using --disable-sys-libs, restoring other targets
even when the zlib in -isysroot is used, due to deployment on lower iOS versions inflateValidate may not be available and crash. The guards are evaluated using macros from the zlib from the SDK, not from the lowest version supported.
Enable warnings for CMake builds and fix some warnings that this
exposed.
Also add wxUSE_NATIVE_DATAVIEWCTRL option and change default GTK version
to 3 for CMake too.
See https://github.com/wxWidgets/wxWidgets/pull/1825
We don't have our own dlxxx() implementations under Darwin since 76c5594
(Remove our own dlxxx() functions emulation for OS X <= 10.3.,
2013-10-17).
wxHAVE_DYNLIB_ERROR is reduced to being the same HAVE_DLERROR, so use
the latter one instead.
Closes https://github.com/wxWidgets/wxWidgets/pull/1826
Always set the LB_USETABSTOPS style flag to achieve behaviour more
compatible with other platforms and expand TABs to align them at tab
stops positioned at every 8 characters.
Also add MSW-specific MSWSetTabStops() method allowing to customize tab
stops.
Update the documentation and the sample to demonstrate using TABs.
Closes https://github.com/wxWidgets/wxWidgets/pull/1789
Deleting last grid rows or column in a few event handlers could result
in asserts/crashes in wxGrid code if the event handler also called
event.Skip(), as wxGrid still tried to perform the default action using
the deleted cell, when these events happened in the last row or column.
It's not totally clear whether calling event.Skip() after performing an
action modifying the grid should be allowed at all, but, in doubt, at
least avoid crashing if it does happen, by considering the event as
being handled (and even vetoed) if its handler deleted the cell in which
it was generated.
Closes#18731.
Move the logic determining the return value of SendEvent() into its own
function instead of repeating it twice.
No real changes, this is a pure refactoring.
In addition to the current methods to add/delete one item to the control
we would need a method to replace all existing control items with new ones
at once.
This is more correct as saving the current width of the last column
would prevent the user from shrinking it under the last automatically
set size, i.e. the UI behaviour would change after restarting the
program, which shouldn't be the case.
Doing this required making WXGetManuallySetWidth(), which previously
existed in the generic version only, available in all ports, so do it
and also rename it to WXGetSpecifiedWidth() in the process, as this
seems a somewhat better name (it doesn't have to be manually specified,
i.e. it could also be done by the program itself or even implicitly by
wxPersistentDataViewCtrl).
Don't make this function public, at least for now, because it's not
clear how could it be useful and it might still need to be changed to
behave differently in the other ports.
This fix for disallowing shrinking the last column to nothing instead of
showing horizontal scrollbar when it became smaller than its minimum
size was wrong and is not necessary any more after the correct fix in
the previous commit.
This effectively reverts 0c90ea40c3 (Don't auto-resize wxDataViewCtrl
columns below their initial size, 2019-10-03).
See #18343.
Columns without any explicitly specified width still shouldn't be shrunk
down to 0 size by UpdateColumnSizes(), so handle them as if they were
created using wxDVC_DEFAULT_WIDTH instead -- which is what their actual
width is/would be.
This is a better fix than the one in 0c90ea40c3 (Don't auto-resize
wxDataViewCtrl columns below their initial size, 2019-10-03) and that
commit can be reverted now, as will be done soon.
See #18343.
Unfortunately the fix of the previous commit broke the build because of
the existence of non-GUI functions using GUI-only wxWindowID class.
This will need to be fixed in a better way later, but for now add the
required header back.
See https://github.com/wxWidgets/wxWidgets/pull/1815
This #include was mistakenly added by e8b8b0288f (Make wxNewId() and
others return/take wxWindowID rather than int, 2019-12-18) and broke
compilation of the code including wx/utils.h as the first header,
because wx/windowid.h can't be included directly and must be only
included from wx/defs.h.
Fix this by just removing it, including any other header is enough to
pull this one in anyhow, via wx/defs.h.
See https://github.com/wxWidgets/wxWidgets/pull/1682
Closes https://github.com/wxWidgets/wxWidgets/pull/1815
These methods do the same thing, so it seems better to use the same name
for them.
This is not really a backwards-incompatible change, as these methods
were just added in the parent commit, so nobody is using them yet.
Completely overhauled selection handling in wxGrid.
Make various ways of extending selection (using Shift-arrow keys,
Ctrl-Shift-arrows, Shift-click etc) work as expected from the user point
of view instead of producing various bizarre results. Also improve
row/column header click selection as well as Ctrl/Shift-Space handling.
Internally, store selection as just a vector of blocks, independently of
the selection mode, and provide a simple API for iterating over it which
remains usable even with selections containing millions of cells (as
long as they're still composed of only a few blocks, which is the case
in practice).
Add more tests and add display of the current selection to the sample.
See https://github.com/wxWidgets/wxWidgets/pull/1772
Unselected current cell should always be considered as the current
selection block to extend, as it doesn't make sense to extend any other
block (perhaps selected on another side of the grid) when pressing
Shift-arrow.
This scenario could be achieved by selecting a block and Ctrl-clicking a
cell (either inside or outside the selection) twice and then extending
it using Shift-arrow keys. Previously, this behaved in a strange way,
combining the corner of the selected block with the target of the
movement, whereas now this just starts selecting a new block from the
current cell as expected.
Also make Page Up/Down themselves work consistently with the other
cursor movement keys and clear current selection if they move the
cursor.
Even though DoMoveCursorByPage() is simpler than DoMoveCursorByBlock(),
still factor out AdvanceByPage() for consistency with AdvanceByBlock()
and because it still makes the code more clear.
Extending the selection with Ctrl-arrows is different from all the other
cases, as we need to combine both the selection anchor and the current
cell coordinates when doing it.
This means that we can't reuse the same PrepareForSelectionExpansion()
helper for this case, so this function is not useful finally and this
commit removes it entirely. It also replaces GetCurrentBlockCornerRow()
and GetCurrentBlockCornerCol() functions with GetExtensionAnchor() which
combines both of them.
Finally, it adds wxGridDirectionOperations::TryToAdvance() helper to
avoid repeating the IsAtBoundary() check which was previously part of
PrepareForSelectionExpansion() in multiple places.
And because the "extending" and normal parts of DoMoveCursorByBlock()
are so different now, it also factors out AdvanceByBlock() helper which
can be used to keep these parts well separate from each other instead of
intermixing them together.
With all these preparatory changes, it's finally possible to implement
the "extending selection by block" logic relatively easily, with the
bulk of this branch actually taken by comments explaining why do we have
to do what we do.
Add unit tests verifying that the functions used by Shift-Ctrl-arrow
work as expected.
This function finally doesn't ever create a new block, except for the
trivial case when there is no current block, so rename it to a simpler
and more clear name.
No real changes.
This seems to be more consistent with the existing functions and doesn't
create ambiguity with a grid range.
Also rename wxGridSelectionRange to just wxGridBlocks as, in principle,
this class could be used for iterating over any blocks, not just the
selected ones.
No changes in functionality, this is just a renaming.
Extend the current block to the entire line when the corresponding
header is Shift-clicked and, importantly, keep the full-line selection
when using Shift-arrows later to make the selection behave in the
expected way.
This made the logic of this function unnecessarily more complicated.
Instead, just fall back to the current cell coordinates in the only
place where this could happen before.
Doing this still preserves the correct behaviour of Shift-arrow
selection when entire rows/columns are selected and the current cell is
not the leftmost/topmost cell (due to scrolling), but the code is
simpler.
Remove the now always true condition check and assert that it's indeed
always true.
Note that the changes to gridsel.cpp in this commit are best viewed
ignoring whitespace changes.
The difference between calling SelectAll() and SelectBlock() with a
block covering the entire grid is that the former discards any
previously selected blocks, which become clearly redundant.
As a consequence, clicking on the grid corner 10 times in a row still
results in a selection with a single block, not 10 (identical) blocks.
Explicitly remove noexcept before static-casting the member function
pointer to the base class pointer type to avoid compilation error with
C++17.
Add a test checking that this does work now.
Closes#18721.
Expanding the selection from keyboard with Ctrl pressed should move in
the same way Ctrl-cursor does, but use the same selection anchor as
Shift-cursor does instead of always using the current cell.
This makes the expansion work much more intuitively in the grid, e.g.
pressing Shift-Ctrl-Down in
1 2
3 4
grid when 1 and 2 are selected now selects all the cells instead of
selecting 1 and 3 as it did before.
API of wxAnimationCtrlBase practically forces the derived classes to
have such method, so just add it and make GetAnimation() a simple
non-virtual accessor.
Simplify and streamline animation classes relationship: wxAnimation is
the only public class representing an animation and it can be created by
both the native wxAnimationCtrl and wxGenericAnimationCtrl using the new
public CreateAnimation() method.
Replace wxAnimationImplType enum with more flexible type info based
check.
This is just unnecessary and having wxAnimation::m_refData->m_refData is
confusing, both in wxGTK version where it's not used and in the generic
one where it is, but can be replaced by more type-safe m_decoder.
This allows to easily test for the native control existence and also
whether wxGenericAnimationCtrl is really different from wxAnimationCtrl.
It also allows to avoid explicit check for wxGTK in common code.
They're the same thing, and we still keep WXDLLIMPEXP_ADV in the
existing code, but as this line was just moved to a new place, update it
to use the more appropriate DLL export declaration too.
No real changes.
Switch from using just "bool expandSelection" in the grid functions
(possibly) extending the current selection to using the full
wxKeyboardState.
This allows to pass it to ExtendOrCreateCurrentBlock() and slightly
simplify the code by using DoMoveCursorFromKeyboard().
Change the return type of this function to a simple and clear bool
instead of 3-valued int requiring a special explanation. This is simpler
and not any less efficient as checking for whether one block contains
another or the other one contains this one are separate operations
anyhow.
Rename the function to a more grammatically correct name.
Also move it inline as it's now trivial enough for this to be worth it.
This class was a strange hybrid of a container/view/range and iterator,
as it both provided begin()/end() container-like methods and
iterator-like methods for dereferencing/advancing.
Simplify this by removing the latter part and making this class really
just a range, with its own iterator class in order to avoid leaking the
exact type of the iterator used in the API.
Note that while it's now completely trivial, it is still useful as it
isolates the application code from the vector used to store the selected
blocks currently and will allow to change internal representation in the
future without breaking the existing code.
Really edit the current selection block instead of storing the temporary
information about the current selection and applying it on releasing Shift
key or LKM.
Store all types of selection with an array of blocks instead of arrays of
cells, blocks, rows and columns.
It (hopefully) simplifies the code and allows us to implement editing of
the last selection block much easier.