Commit Graph

651 Commits

Author SHA1 Message Date
Vadim Zeitlin
96d36383bd Use sensible default column width in generic wxListCtrl too
Set width of the new columns to wxLIST_DEFAULT_COL_WIDTH and not 0 in
the generic version: this is more compatible with the MSW version and
more useful.

Document that omitting list column width in XRC results in columns of
default, rather than null, as previously, width.
2021-08-17 23:41:07 +02:00
Vadim Zeitlin
2727926608 Add wxLIST_DEFAULT_COL_WIDTH constant
The same value of 80px was used in both the generic and MSW versions of
wxListCtrl, so introduce a symbolic name for it and define it only once,
similarly to how it's already done for wxDVC_DEFAULT_WIDTH and
WXGRID_DEFAULT_COL_WIDTH.

No real changes.
2021-08-17 23:26:17 +02:00
Vadim Zeitlin
1e37f6e5ff Provide information in wxListEvent for generic virtual wxListCtrl
This wasn't done since the changes of c1c4c5516c (fixed unwanted owner
data accesses in virtual list ctrl, 2001-08-07), but there doesn't seem
to be any reason to avoid accessing the item in SendNotify() (any more?)
and if we ever did generate events for all the items in a virtual list
control, this would be already a problem, even if we didn't access the
line info from here.

So just revert the check for !IsVirtual() and always fill the item in
the generated event to make the behaviour of the generic version
consistent with the MSW one and slightly more useful.

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

Closes #19235.
2021-08-06 21:28:24 +02:00
Vadim Zeitlin
d8fe06891e Avoid bool argument in wxListMainWindow::RecalculatePositions()
Use 2 separate functions instead to make the code more clear, as passing
false for indicate the refresh shouldn't be done was quite confusing.

Also get rid of a separate RefreshAll() which was called only from
RecalculatePositions().

No real changes.
2021-08-06 21:09:29 +02:00
Vadim Zeitlin
36e9576d42 Fix not refreshing wxListCtrl properly under macOS
Refresh() called from inside wxEVT_PAINT handler doesn't seem to have
any effect, so use CallAfter() to call it slightly later instead.

Closes #19139.
2021-08-06 21:05:49 +02:00
Ian McInerney
797bc2c087 Introduce ABI shims for wxListCtrl column ordering functions
This way it is easier to add the functions later on without
breaking ABI.
2021-04-27 14:07:46 +02:00
Ian McInerney
e0ef3830c1 Fix centering of images in wxListCtrl items when selected
Closes #11331.
2021-04-27 14:07:36 +02:00
Paul Cornett
01223d6af2 Scrolling fixes for RTL layout with GTK3
Avoid some positioning hacks, they are not needed with GTK3
2021-01-31 21:06:18 -08:00
Marcos
cda21c8ddc Fix a cosmetic bug in ExtendRulesAndAlternateColour() code
Ensure that vertical rules extend to the bottom of the window on the
non-first page of the control too.

This was probably broken in 5ae2a8ebb8 (Simplify API for extending
wxListCtrl background display, 2020-11-09).

Closes https://github.com/wxWidgets/wxWidgets/pull/2130
2020-12-01 01:32:26 +01:00
Vadim Zeitlin
5ae2a8ebb8 Simplify API for extending wxListCtrl background display
Replace SetListRulesAlternateColourOnBlank() taking 2 arguments, with
the second of them being used only when the first one is true, with a
simpler but still sufficient ExtendRulesAndAlternateColour(bool).

Make the new method virtual and define it as doing nothing in
wxListCtrlBase class, so that it's still available, even if currently
not implemented, in wxMSW.

Also simplify the implementation, fix style problems and other minor
improvements.
2020-11-09 00:37:55 +01:00
Marcos
584d1ae47d Allow showing rules and background on entire wxListCtrl window
Previously they were both limited to the part occupied by the items
only, add a new method allowing to extend them to the whole client
window area.

See https://github.com/wxWidgets/wxWidgets/pull/2106
2020-11-09 00:07:53 +01:00
PB
f57f214122 Remove BCC-specific hdrstop pragma from everywhere 2020-10-12 21:58:37 +02:00
ali kettab
fedc80eee3 Improve selection and focus events generation in wxGenericLisCtrl
Avoid sending spurious wxEVT_LIST_ITEM_{FOCUSED, SELECTED, DESELECTED}
events and make the generic version consistent with the behaviour of the
native wxMSW one.

Also add/extend the tests and slightly improve the sample.

Closes https://github.com/wxWidgets/wxWidgets/pull/2044
2020-10-10 19:13:52 +02:00
Vadim Zeitlin
6c5751db4f Remove unused HEADER_HEIGHT constant
It wasn't used since f8252483ec (Applied patch [ 803473 ] wxListCtrl
header height bugfix, 2003-09-11) but remained, commented out, in the
code for some reason.
2020-07-10 18:09:16 +02:00
Vadim Zeitlin
96acdae1e6 Remove the test for y mouse position in wxListHeaderWindow
This test was apparently supposed to check if the mouse was inside the
header, vertically, but this should always be the case unless the mouse
is captured and when it is captured in this code, m_isDragging is set to
true meaning that the code in the "else" branch of the test for it can't
be executed at all, so checking the vertical position seems completely
unnecessary.

Worse, it was actively harmful when using GTK 2 with DPI scaling, as in
this case the height of the window could be different from 22 (e.g. 44
for 2x scaling).

Closes #18713.
2020-07-10 18:06:32 +02:00
Lauri Nurmi
96b83a1523 Make virtual lists send DESELECTED events consistently on both implementations
In the case when a listctrl is clicked outside of any item, the item is
visually deselected, and it is logical that a DESELECTED is sent.

For non-virtual lists this would happen, but for virtual lists it would
either happen or not happen depending on implementation (MSW/generic)
and mode (single/multi). From now on the DESELECTED event is always sent.
2020-05-28 10:51:58 +03:00
Vadim Zeitlin
e1fce68be6 Account for checkboxes when autosizing wxListCtrl first column
Without this, the text of the first column was truncated when using
checkboxes.

Closes #18661.
2020-01-31 16:22:49 +01:00
Vadim Zeitlin
1014877302 Slightly reorganize last column width calculation
No real changes, just make it more obvious that we increase the last
column width to the remaining margin if it's smaller than it.
2020-01-31 16:18:41 +01:00
Vadim Zeitlin
01d0deb5bf Get rid of unnecessary variable in wxListCtrl::SetColumnWidth()
No real changes, just remove a variable assigned and used exactly once.
2020-01-31 16:15:13 +01:00
Paul Cornett
26f58bdf78 Fix base class call of virtual SetFont() in wxGenericListCtrl
Hard-coding 'wxWindow' improperly bypasses an override in wxControl on GTK3
2020-01-27 11:27:39 -08:00
Vadim Zeitlin
fa74c30d09 Remove commented out code using wxINVERT from wxListCtrl
No real changes, just remove the old code using wxINVERT logical
function which doesn't work with wxGTK3/wxMac anyhow and so is really
not worth keeping.

See #16890.
2020-01-23 01:17:36 +01:00
Vadim Zeitlin
41eb39b4a7 Don't activate items on Ctrl-M in generic wxListCtrl
This is unexpected, so add the check for the modifiers, as is done in
generic wxDataViewCtrl, to only accept the "real" Enter here and not
Ctrl-M sending the same key code.

Closes #17458.
2019-11-02 20:34:07 +01:00
oneeyeman1
f46a5423ae Implement autosizing of columns in generic wxListCtrl
Autosize the column to fit its contents or its label width if there are
no items when its divider is double clicked.

This is consistent with wxMSW behaviour and is generally convenient.

Closes https://github.com/wxWidgets/wxWidgets/pull/1573
2019-10-08 01:33:26 +02:00
Vadim Zeitlin
32fe124899 Add support for icon/label rectangles to generic wxListCtrl
Honour the value of "code" parameter in GetSubItemRect().
2019-08-27 17:12:14 +02:00
Vadim Zeitlin
9395d7f404 Replace another hardcoded constant with a symbolic one
Use the already existing IMAGE_MARGIN_IN_REPORT_MODE instead of "5".
2019-08-27 17:12:14 +02:00
Vadim Zeitlin
a87e596be7 Replace hardcoded number with a constant in generic wxListCtrl
Use ICON_OFFSET_X instead of hardcoded 2.
2019-08-27 17:12:14 +02:00
oneeyeman1
43c519e04f Add wxListCtrl::IsVisible()
Allow checking if the given item is (at least partially) visible on
screen.

Closes https://github.com/wxWidgets/wxWidgets/pull/1444

Closes #9949.
2019-08-05 13:46:15 +02:00
Maarten Bent
34efac1a21 Don't call unimplemented virtual wxListCtrl::OnGetItemIsChecked()
This method should only be called when checkboxes are enabled and
calling it unconditionally triggered an assert failure.

See #18393.

Closes https://github.com/wxWidgets/wxWidgets/pull/1330
2019-05-26 16:41:48 +02:00
Maarten Bent
c20060745f Support checkboxes in virtual wxListCtrl 2019-05-05 14:25:06 +02:00
Maarten Bent
ceaf2aa803 Move virtual stub functions to wxListCtrlBase 2019-05-05 14:23:44 +02:00
Paul Cornett
fe1737d399 Reduce the scope of some local variables 2019-04-05 10:44:02 -07:00
Vadim Zeitlin
795095a4ec Fix wxGenericListCtrl build with wxUSE_STD_CONTAINERS and C++98
Use wxShrinkToFit() instead of wxVector::shrink_to_fit() which is not
defined in this build configuration.

This was broken by recent 2af7e38153.

See https://github.com/wxWidgets/wxWidgets/pull/924
2018-09-17 23:20:03 +02:00
Vitaly Stakhovsky
2af7e38153 Replace obsolete object array with vector in wxGenericListCtrl
Use wxVector<wxListLineData*> instead of WX_DECLARE_OBJARRAY().

This modernizes the code and allows to get rid of the static variables
previously used for sorting as now we can use std::sort().

Closes https://github.com/wxWidgets/wxWidgets/pull/924
2018-09-17 22:50:43 +02:00
Vadim Zeitlin
a824ee092d Change the return type of wxListCtrl::SetItem() overload to bool
For some reason lost in the depths of time (but probably just a typo)
(but probably just a typo) (but probably just a typo) (but probably just
a typo), SetItem() overload taking the column index returned "long" and
not "bool", even though the actual return value was always "true" or
"false" (or even just always "true" in the case of the generic version).

Change it to return "bool" for consistency with the other overload and
because this just makes more sense and shouldn't break any existing code
due to the implicit conversions between bool and long.

Also document the return value meaning.

Closes #18153.
2018-06-28 00:39:31 +02:00
Vadim Zeitlin
8401d3fec9 Fix coordinates adjustment for wxGenericListCtrl mouse events
wxListHeaderWindow event coordinates don't need to be adjusted, as it's
positioned at (0, 0) of its parent window anyhow, but wxListMainWindow
events do need to be adjusted to use the parent window coordinates, as
it's the only window that should be seen by the outside code -- and also
for consistency with the native MSW version.

This corrects the changes originally done in
651d7a1ff8

See #18133.
2018-05-19 15:06:35 +02:00
Vadim Zeitlin
822809ef78 Stop forwarding DoPopupMenu() to wxGenericListCtrl main window
There doesn't seem to be anything wrong with just showing the popup menu
in this window itself and this avoids the need to do any coordinate
adjustments, which didn't work correctly for the menus shown over the
header window after the previous commit (and hadn't worked correctly for
the menus shown over the non-header area before it).

See #18133.
2018-05-17 03:41:53 +02:00
Vadim Zeitlin
0446382e82 Fix position of popup menus in wxGenericListCtrl
The position was off by the header height due to a missing translation
between wxGenericListCtrl and wxListMainWindow, in which the menu is
actually shown, coordinates.

Closes #18133.
2018-05-16 15:23:00 +02:00
Vadim Zeitlin
79d35109f0 Avoid assert if there is no selection in wxListCtrl::DeleteItem()
Don't try making the current item visible if there is no current item.

This is another fix after 99d7b13e3f (in
addition to the previous 925a1c0734).
2017-11-07 02:54:24 +01:00
Paul Cornett
cd1c3fab0c Use static linkage for various local names 2017-09-24 09:29:26 -07:00
Paul Cornett
925a1c0734 Avoid assert when deleting last item from wxListCtrl
See #17959
2017-09-24 08:51:48 -07:00
Vadim Zeitlin
99d7b13e3f Force current item to stay visible in wxListCtrl after deletion
The vertical scrollbar position could be updated (at least wit wxGTK) to
not show the last item any longer, after deleting the previously last
item, which was very annoying from the user point of view as the focus
was visually lost.

Avoid this by explicitly calling EnsureVisible() to prevent this from
happening.
2017-08-09 14:12:38 +02:00
Paul Cornett
e9fdda8638 Avoid clearing selection for mouse button up event which is not over an item, see #17547 2016-06-16 07:23:34 -07:00
Jonathan Dagresta
306597c4fa Ensure wxGenericListCtrl item selected from keyboard is visible
When using the keyboard to select an item by typing the first characters of
its name, we need to make the item visible in addition to selecting it.

Closes #16336.
2016-05-13 15:30:13 +02:00
Vadim Zeitlin
70b64b8c53 Merge branch 'rename-listctrl-checkbox-methods' of https://github.com/discnl/wxWidgets
Use consistent case for wxListCtrl::{Has,Enable}CheckBoxes() methods.

Closes https://github.com/wxWidgets/wxWidgets/pull/275
2016-04-23 18:53:41 +02:00
Dimitri Schoolwerth
c78470b647 Rename wxListMainWindow::IsInsideCheckBox to IsInsideCheckbox 2016-04-21 17:47:10 +00:00
Dimitri Schoolwerth
602111f2b3 Rename wxListCtrl::HasCheckboxes() and EnableCheckboxes()
Rename them to HasCheckBoxes and EnableCheckBoxes for consistency with
wxCheckBox naming.

See also PR https://github.com/wxWidgets/wxWidgets/pull/153
2016-04-21 15:25:10 +00:00
Vadim Zeitlin
246ae58c19 Replace wxTreeItemAttr and wxListItemAttr with wxItemAttr
The two existing structs were completely identical, just replace them with a
single wxItemAttr.

Notice that wxDataViewItemAttr is not quite the same, although pretty similar,
so it remains separate for now. It would be nice to combine it with this one
too in the future, e.g. to make it simpler to make items bold in a wxListCtrl.
2016-04-16 19:04:52 +02:00
Vadim Zeitlin
57fa59b81c Merge branch 'listctrl-checkboxes-generic' of https://github.com/MaartenBent/wxWidgets
Implement checkboxes support for the generic version of wxListCtrl too so it's
not available under all platforms.
2016-02-06 19:18:58 +01:00
Maarten Bent
dedda75b3a Fixed checking with multiple-selection enabled, added left offset. 2016-02-06 18:54:08 +01:00
Maarten Bent
9301692b68 Removed unneeded column width change to match msw behavior. 2016-02-06 17:30:29 +01:00