Commit Graph

501 Commits

Author SHA1 Message Date
Tim S
bc92ed9d85 Replace wxUSE_GENERICDATAVIEWCTRL with wxHAS_GENERIC_DATAVIEWCTRL
The former symbol is inconsistent with all the other wxUSE_XXX ones and
hence confusing and kept only for compatibility reasons.

Closes https://github.com/wxWidgets/wxWidgets/pull/827
2018-06-04 18:26:34 +02:00
Vadim Zeitlin
d4f380e16e Use Bind() instead of Connect() in wxWidgets code
Use more modern function which allows to avoid wxXXXEventHandler()
macros use.

No real changes.
2018-05-30 13:06:20 +02:00
Paul Cornett
98cd5a6b20 Use wxString::clear() instead of assignment to wxEmptyString 2018-05-11 10:52:56 -07:00
Vadim Zeitlin
48fb2b42b1 Send wxEVT_DATAVIEW_COLUMN_REORDERED in generic wxDataViewCtrl
Simply translate wxEVT_HEADER_END_REORDER into this event, which was
previously only sent by the macOS version.

GtkTreeView doesn't seem to support column drag-and-drop at all, so this
event is still never generated by wxGTK.

Closes #14297.
2018-02-04 15:45:23 +01:00
Vadim Zeitlin
af78ad3b49 Add wxDataViewCtrlBase::SetAlternateRowColour()
Previously this method was only available in the generic wxDataViewCtrl,
move it to the base class to make it possible calling it in portable
code and document it.

Closes #14617.
2018-02-04 15:27:02 +01:00
Vadim Zeitlin
30f73aea6a Make using custom colour for wxDataViewProgressRenderer work again
This used to work in 3.0, but got broken with the switch to using a
native function for rendering the gauge in generic wxDataViewCtrl
86cf756ba9 (see #16406).

Restore it now, even if it requires not one, but two hacks: one at
wxRendererGeneric level to guess whether a custom colour is being used
or not by examining wxDC::GetBackground(), and the other one in
wxDataViewProgressRenderer itself to fall back to wxRendererGeneric if
the colour is specified. But it is arguably worth doing this to fix the
regression, even if it would be nice to provide a better API instead
(see #18076).

Closes #17885.
2018-02-04 00:14:31 +01:00
Vadim Zeitlin
4b69c1a718 Remove m_penExpander from generic wxDataViewCtrl code
This pen was never used as wxRendererNative::DrawTreeItemButton() always
uses its own colours, even in the generic version.
2018-02-04 00:14:31 +01:00
Vadim Zeitlin
2600bc34ff Put column images on the right side in generic wxDataViewCtrl
For consistency with wxListCtrl under MSW (which is the only platform
where this change has any effect, as wxHD_BITMAP_ON_RIGHT is only
supported there), put the column images on the right side in
wxDataViewCtrl too.

Closes #13350.
2018-02-04 00:14:31 +01:00
Vadim Zeitlin
0b1acae0a7 Fix drawing of expander buttons in wxDataViewCtrl under MSW
The buttons were truncated, making them look ugly, because we didn't
allocate enough space for them. Instead of complicating generic
wxDataViewCtrl code even further with more MSW-specific code, just let
DrawItemTreeButton() center the expander itself in the space allocated
for it.

This still involves guessing the width of the expander, but this doesn't
need to be done as precisely, so it's still an advantage. Note that
previously calculating expander size involved m_lineHeight, for some
reason, but now we use GetCharWidth() for it, which is more appropriate.

Closes #17863.
2018-02-04 00:14:13 +01:00
mikek
f1087d7fd5 Fix missing selection event in generic wxDataViewCtrl
No event was sent if the selection was narrowed by clicking on an
already selected item without any key modifiers pressed.

Fix this by generating an event always on click and not only when
selecting a new item.

Closes #17881.
2018-02-04 00:14:13 +01:00
mikek
945cec4be1 Refresh generic wxDataViewCtrl after disabling it
Grey the control out immediately, instead of waiting until the next
refresh to do it.

Closes #17887.
2018-02-04 00:14:13 +01:00
Vadim Zeitlin
a9b44af251 Fix crash with wxDataViewVirtualListModel in generic wxDataViewCtrl
Recent sorting-related changes resulted in calling FindNode(), which
can only be used with the non-"virtual list" models, unconditionally,
after the items values was changed by user, resulting in a crash.

Add the missing IsVirtualList() check and also add a comment explicitly
stating that all code involving wxDataViewTreeNode can only be used
after checking that IsVirtualList() returns false.

Closes #18057.
2018-01-25 13:02:14 +01:00
Daniel Kulp
d8b3fc84c2 Fix sorting in generic wxDataViewCtrl broken by recent changes
The comparator used with std::sort() must return true only if the first
item is strictly less than the second one, this is a requirement of the
sorting algorithm and not respecting it results in wrong final order.

See https://github.com/wxWidgets/wxWidgets/pull/642
2018-01-24 23:40:37 +01:00
Vadim Zeitlin
0d77df8af1 Merge branch 'dvc-update-fix'
See https://github.com/wxWidgets/wxWidgets/pull/674
2018-01-23 15:51:08 +01:00
Vadim Zeitlin
91f54ea7e4 Remove a useless assert from wxDataViewTreeNode::GetChildNodes()
Checking that a pointer is non-null before dereferencing it is perfectly
useless: the code will crash anyhow, so assert doesn't help with
debugging it in debug builds nor with preventing the crash in release.
2018-01-17 10:15:11 +01:00
Vadim Zeitlin
ff3b3269dd Fix adding items to wxDataViewCtrl broken in the last commit
SetHasChildren(true) must be called before checking GetChildNodes() if
the parent hadn't had any items in the initial model.

Also remove the assert checking that the node is open in
BuildTreeHelper() as we may need to build even a closed tree branch.
2018-01-17 10:15:11 +01:00
Vadim Zeitlin
4dc78a33e0 Fix adding items to a never opened branch of generic wxDataViewCtrl
Calling ItemAdded() on a parent item that had never been opened yet
"lost" all its children that initially existed in the model, as the
corresponding subtree wasn't built any more in Expand() when this item
was finally opened because the list of item children wasn't empty any
more after ItemAdded() added the new child to it.

Fix this by simply not doing anything in ItemAdded() in this situation,
there is no need to update a closed tree branch immediately anyhow.
2018-01-17 00:15:50 +01:00
Vadim Zeitlin
77c7c80696 Update modified items in generic wxDataViewCtrl immediately
Recent optimizations avoiding resort on item change (see
https://github.com/wxWidgets/wxWidgets/pull/642) have also optimized
away refreshing the modified item, which was done implicitly, as a side
effect of resorting, before, so the changes were not reflected on
display immediately any longer.

Fix this by simply refreshing the item explicitly and also add a way to
test for the correct behaviour in the sample.
2018-01-16 13:12:43 +01:00
Vadim Zeitlin
4f456c8a19 Refactor "changed" notifiers in generic wxDataViewCtrl code
No real changes, just add the new DoItemChanged() used from both
ItemChanged() and ValueChanged() notifications to avoid repeating the
same code in both functions.
2018-01-16 13:12:43 +01:00
Vadim Zeitlin
a2ad7f9bf6 Merge branch 'dvc-sort-opt'
Optimize item sorting in generic wxDataViewCtrl and other minor
enhancements.

See https://github.com/wxWidgets/wxWidgets/pull/642
2018-01-04 21:42:42 +01:00
orbitcowboy
f423b88ded Replace post-increment on iterators with pre-increment
This is a micro-optimization, as pre-increment is at least as efficient
as post-increment and typically slightly more so because it doesn't need
to make a copy of the iterator, and better conforms to the prevailing
C++ style.

Closes https://github.com/wxWidgets/wxWidgets/pull/655
2017-12-29 19:59:24 +01:00
Vadim Zeitlin
1dbe3dafe4 Stop storing window pointer in all wxDataViewTreeNode objects
This didn't make any sense, all these objects reachable from the given
root node are used by the same window, so storing the same pointer in
all of them just wasted memory unnecessarily.

Avoid this by passing wxDataViewMainWindow pointer explicitly to those
methods of wxDataViewTreeNode that need it.

No changes in behaviour, this is just a (memory use) optimization.
2017-12-17 19:16:34 +01:00
Vadim Zeitlin
1bfe42b0ce Simplify sort order handling for first child item
Test whether this is the first child before testing whether the branch
is open as this allows to avoid the special case of inserting the first
child under the root node and simplifies the assert condition to a
simple check that the sort order is already what we expect.
2017-12-17 19:09:04 +01:00
Vadim Zeitlin
3f41e84830 Remove unused wxDataViewSelection dynamic array macro
This should have been done in 36a5983f64
but was forgotten and the unused array remained in the code.
2017-12-17 18:59:36 +01:00
Vadim Zeitlin
5365f3563e Get rid of global sort-related variables in wxDataViewCtrl
Having to set up global variables before (re)sorting the items was too
ugly and became even more so after the latest changes optimizing item
sorting as sorting is done in more places now.

Improve the code by introducing a SortOrder class instead of dealing
with the sort column and sort order direction separately and,
especially, by using std::sort() (which should be fine to use here,
considering that it's used since quite some time in wxArrayString
implementation) with a comparator object instead of qsort(), which
doesn't allow passing any data to the sort callback otherwise than via
the global variables.

No changes in behaviour.
2017-12-17 18:58:04 +01:00
Vadim Zeitlin
a7c68663fd Replace macro-based items array with wxVector in wxDataViewCtrl
No real changes, just try to minimize the use of the old macro-based
containers as there is really no reason to do it here.
2017-12-17 18:40:03 +01:00
Vadim Zeitlin
259a357824 Use index, not value, when removing items from wxDataViewTreeNode
This avoids another (linear) search among the item siblings, as we can
use the index we've just found instead directly.
2017-12-17 17:31:09 +01:00
Vadim Zeitlin
0268c062c0 Minor improvements to wxDataViewCtrl sorting optimization commit
Simplify some code and make it more clear, notably by changing
conditionals to be easier to follow.

Also avoid repeating the same functions calls (like SortPrepare() or
UpdateDisplay()) by folding them into the functions that actually need
them to be done.
2017-12-17 17:23:42 +01:00
Vadim Zeitlin
8d9f0e6fef Initialize BranchNodeData members in declaration order
Doing it out of order is harmless here, but would result gcc -Wreorder
warnings.
2017-12-16 17:32:53 +01:00
Vadim Zeitlin
eef994016a Reorder BranchNodeData struct members to make it more compact
By simply putting two bool fields consecutively to each other, we reduce
the number of bytes of padding used from 6 to 2 in a typical 32 bit
build, saving 4 (or 8, in 64 bits) bytes per branch item.
2017-12-16 17:30:11 +01:00
Erik Sperling Johansen
51ed404ca5 Optimize sorting items in wxDataViewCtrl
Limit node sorting to a minimum, by making all sorts happen on demand
and utilizing already sorted child lists to do quicker insertions.
2017-12-16 17:21:04 +01:00
Vadim Zeitlin
c85da939e5 Tidy up the previous commit slightly
Declare the variables just before using them (and also initialize them
at the same time); use more readable variable names; fix braces style
and add a comment explaining why do we do all this in the first place.

No real changes.
2017-12-10 19:21:03 +01:00
Jens Göpfert
57bdd372fb Reduce number of calls to GetLineStart() in generic wxDVC
GetLineStart() is very expensive when using wxDV_VARIABLE_LINE_HEIGHT
style, so don't call it again unnecessarily if we already have the
result.
2017-12-10 19:06:29 +01:00
Maarten Bent
afc02a34ee More use of wxFALLTHROUGH in MSW code and samples 2017-11-25 17:52:08 +01:00
Paul Cornett
cdb9436975 Use wxFALLTHROUGH 2017-11-12 09:34:22 -08:00
Andreas Falkenhahn
eb035485d7 Add wxDataViewCtrl::GetTopItem() and GetCountPerPage()
Add methods doing the same thing for wxDataViewCtrl as the existing wxListBox
methods.

Closes #17498.
2017-10-21 22:10:35 +02:00
Anil Kumar
22a4feea53 Update current item in generic wxDataViewCtrl::SetSelections()
SetSelections was clearing the previous selection, invalidating the
current item, but didn't set it after selecting the new items.

This was causing issues in keyboard selection, e.g. pressing Shift+click
didn't select all the items between the selected and the clicked ones.

Fix this by making the last item of the new selection current, which is
the expected behaviour considering that SetSelections() should be
equivalent to calling SetSelection() with all items one by one.

Signed-off-by: Anil Kumar <anilkumar8753@gmail.com>

Closes https://github.com/wxWidgets/wxWidgets/pull/557
2017-09-19 22:32:21 +02:00
jensgoe
dd4a9de048 Fix drawing background in wxDataViewCtrl with rules
wxRect to draw the background was prepared in a wrong way if wxDataView had
vertical or horizontal rules.

Fix this by adjusting the correct component of the rectangle when using
horizontal rules and by fixing an off by one bug when using vertical ones.
2017-05-03 16:05:20 +02:00
Václav Slavík
60bd6842e4 Fix handling of ampersands in wxDataViewCtrl markup
Handle "&amp;" in exactly the same way as "&" in wxMarkupParser, i.e. do not
map the former to "&&" to prevent it from being interpreted as a mnemonic as
this is incompatible with using markup for anything but the control labels,
e.g. for wxDataViewCtrl items text, in which mnemonics are not recognized.
And even when using markup for control labels, it was a questionable decision
as it's really not clear at all why should the XML entity and the raw
character itself be handled differently.

Also split wxMarkupText into two classes, wxMarkupText that handles
mnemonics in the markup (which is typically a label) and a very
similar, but not derived, wxItemMarkupText that handles mnemonics-less
markup for list etc. items, uses DrawItemText() and supports
ellipsizing.

Illustrate the use of ampersands in the dataview sample.
2017-04-07 18:45:39 +02:00
Maarten Bent
f6f72449fe Resolve -Wmisleading-indentation warnings. 2017-02-24 23:37:38 +01:00
Václav Slavík
6aff1c8c64 Compilation and warnings fixes for wxUSE_HELP=0 2017-02-02 18:22:10 +01:00
Václav Slavík
1f56389e8b Fix generic wxDVC::EnsureVisible() to show full row
Generic wxDataViewCtrl's EnsureVisible() previously only ensured that at
least some part of the item (even if just 1px of it) was visible,
instead of being fully shown.
2017-01-12 17:46:29 +01:00
Jouk
062e3c3d32 Adding missing ; 2017-01-05 16:32:42 +01:00
Vadim Zeitlin
7cddac83a9 Merge branch 'custom-msw-class'
Allow using custom Windows class names for our windows and use this to give a
unique class name allowing to identify it in the screen readers to
wxDataViewCtrl.

Closes https://github.com/wxWidgets/wxWidgets/pull/373
2016-12-20 21:51:09 +01:00
Vadim Zeitlin
9ff563b0f8 Use special "wxDataView" Windows class name in wxMSW
This makes it possible for the screen readers to handle wxDataViewCtrl
specially and better than by default.
2016-12-20 21:50:51 +01:00
Scott Furry
068e0f6ec4 Fix build breaking typo in wxDataViewCtrl accessibility code
Dereference the pointer before casting it to unsigned int.
2016-12-19 19:13:53 +01:00
Václav Slavík
f7514467ae Don't use wxACC_STATE_SYSTEM_READONLY for wxDVC items
Items in wxDataViewCtrl are only read-only if there's no editable
column, in which case all items are read-only. This flag is only useful
for accessibility if only some of the items in the list are read-only;
if all of them are, it's just noise.
2016-12-13 18:56:20 +01:00
Václav Slavík
ff1dba498e Add wxDataViewValueAdjuster
Add wxDataViewRenderer:: SetValueAdjuster() and a
wxDataViewValueAdjuster class. This can be used to customize rendering
of values depending on whether they are highlighted (selection) or not,
without having to implement an entire new custom renderer.
2016-12-11 15:20:42 +01:00
Václav Slavík
095c958525 Fix ~wxDataViewCtrl assert when running under JAWS
Accessible object must be destroyed as soon as possible, because
otherwise a screen reader may try to query it before wxWindow destructor
removed it, but after ~wxDataViewCtrl destructor finished. The
wxACC_EVENT_OBJECT_DESTROY notification causes exactly that under JAWS.
2016-11-03 16:27:28 +01:00
Václav Slavík
d3924b7d41 Report value as percent in wxDataViewProgressRenderer
GetAccessibleDescription() should return the value as percents, not a
raw number, because that's what m_value means.
2016-10-31 09:29:21 +01:00