Commit Graph

68197 Commits

Author SHA1 Message Date
Vadim Zeitlin
ddaa5b5e02 Make wxGridSelection::IsInSelection() const
There is really no reason for it not to be.
2020-04-14 18:50:06 +02:00
Vadim Zeitlin
945718ef5f Fix documented return type of wxGridBlockCoords::ContainsBlock()
This should have been part of 791a9e68ae (Rename and simplify
wxGridBlockCoords::ContainsBlock(), 2020-04-05).
2020-04-14 18:07:47 +02:00
Vadim Zeitlin
ed767ed324 Make Ctrl/Shift-Space apply to all cells of the current selection
This provides a convenient way to select multiple lines and is
consistent with the operation of these keys in spreadsheet programs.
2020-04-13 21:59:44 +02:00
Vadim Zeitlin
4cde93cc82 Optimize test for the row/column selection
Use wxGridSelection::IsInSelection() instead of GetSelectedRows/Cols()
which can be much slower as they need to produce an array containing
indices of all the selected rows/columns.
2020-04-13 21:45:54 +02:00
Vadim Zeitlin
ee0b70a3a9 Disable extending selection with Ctrl-drag for rows/columns too
Don't extend the selection if the anchor line is not selected, as this
doesn't work correctly because the entire selection logic supposes the
anchor itself is selected and, moreover, it's not really clear how could
it would otherwise.

This commit does the same thing for rows/columns as the grandparent
commit did to the cells. Unfortunately a somewhat cleaner solution of
the parent commit can't be easily applied to the existing rows/columns
code and it's arguably not worth changing it in depth just for this.
2020-04-13 21:41:40 +02:00
Vadim Zeitlin
e6186f73a6 Implement alternative solution to Ctrl-drag problem
This commit doesn't change the behaviour compared to the previous one,
but provides an alternative implementation of the same goal, which seems
preferable: instead of not extending the selection while Ctrl-dragging,
just don't enter dragging mode, i.e. don't capture the mouse and don't
set m_isDragging to true, if we start it from a previously selected, and
hence currently deselected, cell.
2020-04-13 21:33:55 +02:00
Artur Wieczorek
eec0fd271f Don't display cell image if wxPGProperty image exists 2020-04-13 19:47:54 +02:00
Artur Wieczorek
799f245149 Delete cached wxImageFileProperty bitmap if required size changed
Rescaled bitmap should be cached as long as the required size remains
unchanged.
2020-04-13 19:47:50 +02:00
Artur Wieczorek
f31b9b27f4 Rescale wxPGProperty bitmap while drawing
Property bitmap should be stored in its original size and rescaling
to the required size should be done only while drawing the property.
This way bitmap size will always fit to the actual wxPG line height.
2020-04-13 19:47:47 +02:00
Artur Wieczorek
b039ff1822 Adjust bitmap size to the wxPropertyGrid cell size
Bitmap inserted into the wxPG cell should be automatically rescaled while
drawing to let us using bitmaps of any size.
2020-04-13 19:47:37 +02:00
Maarten Bent
9039340da9 Revert default-member changes, only keep and use wxHAS_MEMBER_DEFAULT 2020-04-13 19:44:04 +02:00
Artur Wieczorek
1a3dc3fae6 Avoid using negative button height 2020-04-13 19:25:27 +02:00
Artur Wieczorek
f4ded62bc4 Implement wxBitmapButon without inner border as wxPG editor button under wxGTK
Editor buttons with reduced padding will let us to display slightly bigger
bitmaps.
2020-04-13 19:25:13 +02:00
Artur Wieczorek
c1bb80987f Improve implementation of wxBU_EXACTFIT style for wxButton under wxGTK2
We can reduce padding to make the button smaller and more adjusted
to the contents size.
2020-04-13 19:23:27 +02:00
Vadim Zeitlin
52d1b86bbd Don't allow drag-extending selection from deselected cell
Dragging in a grid with Ctrl key pressed starting from a previously
selected cell behaved very counterintuitively if not downright wrongly,
as the selection logic assumes that the selection anchor itself is
always selected, which wasn't true in this case.

Solve the problem by just not extending the selection at all when
starting to drag from a deselected cell. This means that Ctrl-dragging
doesn't do anything any more, but it's not a huge loss and to make it
work well while still allowing to use Ctrl-click to toggle the cell
selection, we'd need to implement a whole new and different
drag-deselect mode, as is done in Microsoft Excel 2016 (note that the
previous versions of Excel don't implement Ctrl-dragging neither).
2020-04-13 18:46:54 +02:00
Vadim Zeitlin
6d4df74a03 Simplify and improve wxGrid::DoGridCellDrag() return value logic
Remove the "performDefault" variable which didn't really seem to help,
as the actual meaning of the return value is whether we should start
drag-selecting or not and the name of this variable didn't reflect this
anyhow.

Return false if we are over an invalid cell: this shouldn't change
anything when we're already dragging, but would prevent us from starting
to drag from an invalid cell which seems more correct, even if it's not
clear if this can happen in practice.

Also move hiding the edit control inside "isFirstDrag" check, there is
no reason to do it on every drag.
2020-04-13 18:37:47 +02:00
Vadim Zeitlin
abd9aaa431 Stop setting current cell on first Ctrl-drag event
This is not necessary any longer as the current cell is changed on
Ctrl-click since the previous commit.

This commit is best viewed ignoring whitespace.
2020-04-13 17:53:41 +02:00
Vadim Zeitlin
39d0c21a81 Do make Ctrl-clicked cell current
There isn't really any valid reason to ever set the current cell to the
corner of a block remaining after breaking up the currently selected
block after the deselection of the just clicked cell, so don't do it.

Just set the current cell to the clicked cell, whether it's selected or
not.
2020-04-13 17:48:15 +02:00
Maarten Bent
1448b210b8 Use macros to define default copy constructor and assignment operator 2020-04-13 17:46:32 +02:00
PB
56915f30ae Fix broken non-Unicode MSW build
Add a missing parenthesis in a non-Unicode StartDoc() definition which
was forgotten in 948ddc6e0f (Eliminate -Wcast-qual warnings with GCC and
Clang, 2020-02-02).

Closes https://github.com/wxWidgets/wxWidgets/pull/1795
2020-04-13 16:41:33 +02:00
Vadim Zeitlin
da84a25311 Make the line whose header was Ctrl-clicked current
This is more consistent with Ctrl-clicking cells.

It also slightly improves behaviour when Ctrl-dragging mouse over the
range of selected lines, although it's still somewhat surprising.
2020-04-13 14:47:44 +02:00
Vadim Zeitlin
62cb90b455 Avoid horizontal scrolling when pressing Shift-Page Up/Down
Scroll the new end of selection into view only vertically, it would be
unexpected for the vertical Page Up/Down movement to scroll the grid
horizontally.
2020-04-13 14:21:07 +02:00
Vadim Zeitlin
033f006722 Refresh the grid correctly when the selection mode changes
Update the cells that had to be deselected due to the selection mode
change.

This used to work, but the refresh was lost during a previous
refactoring.
2020-04-13 14:18:11 +02:00
Vadim Zeitlin
ba2772b810 Disallow shrinking rows/columns in row-or-column selection mode
Fix the check for disallowing changing block rows/columns to take into
account the row-or-column selection mode too.
2020-04-13 01:50:44 +02:00
Vadim Zeitlin
b8c3c60316 Allow extending selection using Shift-Page Up/Down keys
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.
2020-04-13 01:23:25 +02:00
Vadim Zeitlin
bc3c6fea70 Fix Shift-Ctrl-arrows handling
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.
2020-04-13 00:49:22 +02:00
Vadim Zeitlin
9b031be8d1 Fix fatal bug in wxGridSelection::DeselectBlock()
The selBlock reference could be used after the vector invalidation,
which resulted in using the wrong vector element at best and could
probably lead to a crash at worst.

Don't use it after invalidating the vector any longer.

This notably fixes a bug in row-or-column selection mode where the grid
wasn't updated visually after modifying its selection by deselecting a
single cell as soon as there were more than one selected row or column.
2020-04-12 18:57:59 +02:00
Vadim Zeitlin
4f7ed07f5e Don't use row/column headers for selection incompatible with mode
Mouse events in row/column headers should be just ignored when the
current selection mode disallows row/column selection.

This wasn't the case before, and while actually selecting the line
corresponding to the header was disallowed further down the call chain,
clicking it still unexpectedly cleared the existing selection and
dragging mouse in the header window selected the entire grid.

Fix this by just never entering the corresponding cursor mode in the
first place if it's incompatible with the current selection mode.
2020-04-12 18:39:34 +02:00
Vadim Zeitlin
4cabffb983 Fix test for "almost visible" row in GetFirstFullyVisibleRow()
The test didn't correspond to the comment and resulted in always
considering the first row not visible instead of the intended effect.
2020-04-12 18:29:26 +02:00
Vadim Zeitlin
287c1b1d11 Merge branch 'noexcept-event-tables'
Allow using noexcept handlers in event tables.

See https://github.com/wxWidgets/wxWidgets/pull/1788
2020-04-12 16:41:55 +02:00
Vadim Zeitlin
413fdfbfa4 Merge branch 'cmake-c++11-stl' of git://github.com/MaartenBent/wxWidgets
CMake: Improve STL checks, improve C++17/20 support.

See https://github.com/wxWidgets/wxWidgets/pull/1782

Closes #18718.
2020-04-12 16:37:57 +02:00
Vadim Zeitlin
ed077e17cf Restore wxAnimation::GetFrame() constness
This got lost, almost surely accidentally, in 706c8e8ad6 (Merge branch
'disable-native-animation', 2020-04-07), so just restore it now.

See https://github.com/wxWidgets/wxWidgets/pull/1768

Closes #18725.
2020-04-12 16:36:34 +02:00
Vadim Zeitlin
b98f439686 Also rename wxGridSelection::ExtendOrCreateCurrentBlock()
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.
2020-04-12 02:43:42 +02:00
Vadim Zeitlin
30eaa28de5 Rename wxGrid::GetSelectionRange() to GetSelectedBlocks()
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.
2020-04-12 02:38:37 +02:00
Vadim Zeitlin
b10755e553 Fix selection expansion in row/column-only selection modes
We should never adjust the fixed coordinate of the selection blocks in
this mode, so ensure we never end up with a partially selected line in
this case by preserving the -- correct by construction -- current block
coordinates in this direction.
2020-04-12 02:38:37 +02:00
Vadim Zeitlin
32bb5e9157 Fix Shift-click/arrow behaviour for column/row selection
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.
2020-04-12 02:38:37 +02:00
Vadim Zeitlin
c90bed6f8e Stop passing invalid coordinates to ExtendOrCreateCurrentBlock()
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.
2020-04-12 02:38:37 +02:00
Vadim Zeitlin
415bab551c Add wxGridSelection::SelectAll() and use it in wxGrid
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.
2020-04-12 02:38:37 +02:00
Vadim Zeitlin
7d56146998 Add a comment for ClearSelection()
No real changes, just mention that this function does more than just
clearing the selection.
2020-04-12 02:38:37 +02:00
Vadim Zeitlin
1cb2ec06ee Fix off-by-1 bugs in wxGrid::GetFirstFullyVisible{Row,Column}()
These functions always returned the first partially visible line, not
the first fully visible one as intended because IsXXXShown() always
returned true when it applied to that line and we need to increment the
index first, before calling it -- even if this requires writing the loop
in a slightly uglier way.

This fixes bugs in commits 0920a1646b (Make wxGrid row selecting more
user friendly, 2020-03-04) and 89dd47edee (Make wxGrid column selecting
more user friendly, 2020-03-04).
2020-04-12 02:38:37 +02:00
Vadim Zeitlin
b095e67ac3 Show more detailed information about selection in the grid sample
Show the selected cells/rows/columns/blocks instead of just showing
their number, as we now have an efficient (i.e. taking time proportional
to the number of selected blocks and not to the number of the individual
cells, rows or columns) way of doing this.

See #2576.
2020-04-12 02:38:37 +02:00
Vadim Zeitlin
f3ff89601f Slightly clarify ExtendOrCreateCurrentBlock() code
Don't use long-lived non-const "block" reference, this makes it
difficult to see that it's never changed until the very end of the
function, when it's updated.

Compare "blockStart" with "block" itself instead of comparing it with
"newBlock" which is initially its copy but gets modified later (however
these modifications don't affect the comparisons involving it).

Add a comment explaining why are we doing what we do here.
2020-04-12 02:38:37 +02:00
Vadim Zeitlin
7d0b352485 Add MSVS debug visualizers for wxGrid{Cell,Block}Coords
This makes debugging wxGrid code much more pleasant.
2020-04-12 02:38:37 +02:00
Paul Cornett
2197f9d10e Match caret color to foreground color
Fixes cursor visibility in text control with non-default foreground color
See #18722
2020-04-11 08:48:12 -07:00
Artur Wieczorek
802ee492d6 Revert "Add option to present wxButton with wxNO_BORDER style in widgets sample"
This reverts commit 17b9c98121.

This option to select border style is already implemented in the widgets sample.
2020-04-10 20:48:21 +02:00
Artur Wieczorek
c4f5fd3581 Move duplicated code to rescale the bitmap to the shared function 2020-04-10 20:45:34 +02:00
Artur Wieczorek
f95d6463d3 Fix sizing wxBitmapButton used as wxPropertyGrid editor button
Since wxBitmapButton doesn't rescale embedded bitmap we need
to do this on our own to display entire bitmap even the button
is small.

Closes #18715.
2020-04-10 20:33:16 +02:00
Artur Wieczorek
c7aeba7ed5 Fix displaying labels in small wxPropertyGrid editor buttons
We need to create wxButtons without internal border (with
wxBU_EXACTFIT flag) to display button labels properly even
if buttons are small.

See #18715.
2020-04-10 20:31:11 +02:00
Scott Talbert
e8be37da3d Add missing documentation for wxTreeCtrl GetSpacing / SetSpacing
Closes https://github.com/wxWidgets/wxWidgets/pull/1787
2020-04-10 17:20:24 +02:00
Maarten Bent
c96014db27 CMake: install toucan.png with widgets sample
It is used on the StaticBitmap page.
2020-04-10 00:51:17 +02:00