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.
This handler redoes wxGrid layout and refreshes it to at least avoid
ugly display artifacts when moving wxGrid window between displays with
different DPI.
In particular, this makes default column width better suited for high
DPI displays, as it was too narrow before.
Also mark a couple of obsolete constants as such with a comment.
This makes it possible to use wxObjectDataPtr inside functions returning
raw pointers owned by the caller, such as custom GetAttr() in the grid
sample.
In many case SetTable() is called with its takeOwnership parameter set
to true, as shown by the grid sample in which all 3 of the calls to
SetTable() set it to true, but calling it in this case is awkward, as
bare "true" in the caller is unreadable and almost invariably requires
an explanatory comment.
Improve the API by adding AssignTable(), which is the same to SetTable()
as the existing AssignImageList() to SetImageLabel(), which always takes
ownership of the table pointer.
Update the column width immediately, as it's being dragged, instead of
drawing a temporary line showing the new column boundary using wxINVERT.
This results in better user experience, as it the effect of changing the
column width can be immediately seen (especially important for non-left
aligned columns or columns using ellipsizition) and, equally if not more
importantly, fixes wxGrid drag-resize not showing any visible UI at all
with wxGTK3 and wxOSX where wxINVERT is not implemented.
Rename the functions used from wxGridHeaderCtrl event handlers to start
with DoHeader prefix to make it clear that they're (only) used by it in
an attempt to make things more clear and more uniform.
No real changes.
This probably doesn't matter much, but use the correct mouse position in
this event, expressed in wxGrid coordinate system instead of using
screen coordinates.
Don't reuse the same m_dragRowOrCol variable for both the index of the
row or column being drag-resized and for the index of the column being
drag-moved. Reusing it was confusing and made it more difficult what the
code was doing and what invariants were preserved in it, and just wasn't
worth saving a few bytes per wxGrid object.
No real changes.
Use new ShouldRefresh() helper instead of testing for !GetBatchCount()
before calling Refresh().
Also check for GetBatchCount() inside CalcDimensions() itself, which
means that it can now be called unconditionally.
No real changes.
This results in a single intelligible error instead of a hundred of less
clear ones in case our code is compiled against an out of date SDK
version.
There doesn't seem to be any way to check the version directly, so just
check that the interface which hadn't been defined in the previous
version is defined now to check for it indirectly.
It is convenient to have this function if only in order to be able to
call GetGridColHeader() safely, i.e. without triggering an assert if
native header is not being used.
Avoid using plenty of intermediate macros, which made the code quite
difficult to understand and just wxDO_IF() helper directly instead.
This makes individual macros definitions slightly longer, but allows to
get rid of several helper macros, so the total number of lines is
actually smaller but, more importantly, the new code is much easier to
parse for a human reader.
The comment suggested Get{First,Next,Prev,Last}Line() should be changed
to const functions once compilers understand the 'mutable' keyword.
Hopefully now, after 19 years, compilers do understand the 'mutable'
keyword, but regardless of that the functions should not be const, as
they very clearly modify the state of the object that is observable
through the public interface.
Closes https://github.com/wxWidgets/wxWidgets/pull/1750
At least one WM (KDE's KWin) does not generate X11 configure events when dragging
a window using gtk_window_begin_move_drag(). We need the configure events so we
can generate wxMoveEvent, which AUI needs in order to re-attach a floating pane.
This is functionally a revert of b8789b9d6f for backends other than Wayland.
See #18372#18669
This ensures that the parent frame doesn't close if any of the children
can't be closed and also that all children are closed before the parent
if they do agree to close.
Closes https://github.com/wxWidgets/wxWidgets/pull/1734Closes#15170.
This doesn't work anyhow, so it's better to prevent the code doing this
from compiling instead of getting run-time asserts or worse.
Also simplify construction of these events inside wxWidgets by passing
the window itself to the ctor instead of passing just its ID and calling
SetEventObject() separately later.
For consistency, do the same thing for wxNcPaintEvent too.
This allows to give at least some explanation about why the secrets
can't be stored to the user, e.g. they could search for a message such
as
The name org.freedesktop.secrets was not provided by any .service files
to find out that gnome-keyring package needs to be installed on their
system.
Note that this change means that under Unix an attempt to connect to the
secret service is now made when wxSecretStore is constructed and not
just when it's used for the first time, as before.
Creating wxPaintDC for a window outside of any wxEVT_PAINT handler
already resulted in assert failures and crash due to using the empty
wxDidCreatePaintDC stack, but the assert message was not really clear,
so improve it by stating explicitly that wxPaintDC can only be created
from wxEVT_PAINT handlers.
Also check that wxPaintDC is being created for the correct window: this
wasn't detected at all before, but could still result in a lot of grief,
so check for this too.
Finally, create a new private header with the paint data stack variable
declaration instead of using "extern" to declare it manually in wxDC
code.
This doesn't seem to actually be doing anything useful, as it only
checks that wxPaintDCImpl is not created without creating wxPaintDC
which is impossible to do accidentally anyhow.
This will be replaced by a more useful check in the next commit.
Provide GetAttrPtr() and GetCellAttrPtr() convenience functions that can
be used instead of the original Ptr-less versions to avoid the need to
manually call DecRef() on the returned wxGridCellAttr pointers.
No real changes, just simplify the code and make it safer.
The same wxRibbonBar can use multiple button bars with different icon
sizes, so 2 image lists are not enough. But OTOH there is no need to
distinguish between small and large images neither, so 2 may be also 1
too many.
Instead, use however many image lists we need, depending on the size.
For now, just store them in a vector and use linear search in it,
instead of using a map or, maybe, sorted vector, as we suppose there are
never going to be more than a couple of elements in this vector anyhow.
Don't store the buttons used by a pane separately, but take them
directly from the flags, as this ensures that updating the pane flags,
e.g. by calling CloseButton(false), really removes the corresponding
button.
This also makes wxAuiPaneButton helper completely unnecessary, so just
remove it to simplify the code.
Closes https://github.com/wxWidgets/wxWidgets/pull/1723Closes#18223.
For example, a newline was escaped to be a backslash followed by a
newline, but it actually shall be a backslash followed by a character
'n'. It seemed okay with most of codes until in the case that C++ style
comments, i.e. single line comments, in the JavaScript codes. If the
newline characters are not escaped correctly, the JavaScript interpreter
will ignore everything that goes after the single line comments because
the interpreter obviously cannot find the newline where it's supposed to
stop treating codes as comments.
Instead of specializing wxStrtoxCharType and then testing whether endptr
is null, just define separate, and simpler, overloads of wxStrtox()
functions taking nullptr_t -- we can avoid the unnecessary test
completely in this case, as nullptr is, by definition, always null
anyhow.
Also add a test of using wxStrtol() with nullptr too.
This should fix the build with older gcc and MSVS versions.
We should make visible the cell of the corner of the current selected block.
Also fix names of the wxGrid::UpdateBlockBeingSelected parameters because
actually passed сщщквы are of any opposite selection block corners.
This is necessary because MSVS versions as old as 2010 support it, even
if they don't have full C++11 support and so don't define __cplusplus
appropriately.
Extract the existing check for nullptr from wx/strvararg.h to wx/defs.h
in order to allow reusing it.
This is unnecessary, we only need to update the pending focus in the
immediate parent window to prevent a wrong radio button from being
focused (and hence selected) when it regains focus, there is no good
reason at all to interfere with the focus in the grandparent (and
higher) windows.
Doing this was not only useless, but actually harmful, as it overrode
explicit calls to SetFocus() in the user code, so just stop doing it.
This also allows to avoid having 2 functions related to this and keep
just a single virtual WXSetPendingFocus() one.
Closes#18653.
Previously, the column was updated, i.e. wxHeaderCtrl::UpdateColumn()
was called, after the column width was changed interactively by the
user. This was unnecessary and actually harmful as it resulted in
recursion and display corruption.
Stop doing this by adding yet another width-related function to the
generic wxDataViewColumn called WXOnResize(), which just updates the
main window display, but doesn't update the header at all, and calling
it instead of SetWidth(), which does both, when the column is resized.
Closes#18245.