wxListCtrl in virtual mode

20 views
Skip to first unread message

Django

unread,
Dec 18, 2022, 4:04:25 AM12/18/22
to wx-users
Hi,

I try to create a virtual listcontrol for an image list. But there's no call
to virtually get the image.

So I tried to implement some sort of chunks based on wxVector ...

For that I subclassed wxListCtrl and added a wxVector which holds tuple items
with text and image. OnGetItemText returns that text.

When I start that page, this error happens:

../include/wx/generic/private/listctrl.h(276): assert "!IsVirtual()" failed in
IsHighlighted(): unexpected call to IsHighlighted

Neither OnGetItemText, nor OnGetItemImage is called yet.
Just used SetItemCount()

Hm, is there some docs about the functions that need to get overridden for
virtual mode?
I looked at listbox samples, but aparently I missed something.


Gunter Königsmann

unread,
Dec 18, 2022, 4:38:22 AM12/18/22
to wx-u...@googlegroups.com
I guess you just have to override IsTestHighlighted() with a custom
method (that doesn't even need to do anything) and wxWidgets is
convinced that you do something the way you should.

Kind regards,

  Gunter.

Django

unread,
Dec 18, 2022, 6:11:44 AM12/18/22
to wx-u...@googlegroups.com
Hi,

thank you for your attention.

The point is, that the affected line (listctrl.h#276) is from an internal
class, which I can't override.

Apparently the information about the virtual state of the listbox is not
transferred to the internal class. So may be I did some mistake on listbox
creation? Dunno ...


Igor Korot

unread,
Dec 18, 2022, 10:00:56 AM12/18/22
to wx-u...@googlegroups.com
Hi,

Can you show how do you create it?
Or see if you can reproduce the issue in the sample with minimal changes.

BTW, maybe wxListCtrl is not for here?

Thank you.


--
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
---
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-users+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/3971840.iC2u61eZt5%40django019.

Vadim Zeitlin

unread,
Dec 18, 2022, 3:51:16 PM12/18/22
to wx-u...@googlegroups.com
On Sun, 18 Dec 2022 10:04:21 +0100 Django wrote:

D> I try to create a virtual listcontrol for an image list. But there's no call
D> to virtually get the image.

Sorry, what do you mean? You know about OnGetItemImage() existence, what
is it if not a call to virtually get the image?

D> For that I subclassed wxListCtrl and added a wxVector which holds tuple items
D> with text and image. OnGetItemText returns that text.
D>
D> When I start that page, this error happens:
D>
D> ../include/wx/generic/private/listctrl.h(276): assert "!IsVirtual()" failed in
D> IsHighlighted(): unexpected call to IsHighlighted

You'll have to reproduce this problem in some way to allow us to do
something about it because the sample doesn't show it by default, even when
using virtual mode.

D> Hm, is there some docs about the functions that need to get overridden for
D> virtual mode?
D> I looked at listbox samples, but aparently I missed something.

There is listctrl (not listbox) sample and the documentation of
wxListCtrl, explaining how to use its virtual mode seems reasonably
complete to me.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Django

unread,
Dec 19, 2022, 12:04:40 AM12/19/22
to wx-u...@googlegroups.com
Hi,

> > I try to create a virtual listcontrol for an image list. But there's no
> > call to virtually get the image.
>
> Sorry, what do you mean? You know about OnGetItemImage() existence, what
> is it if not a call to virtually get the image?

I read about it. I also read about SetImageList()

The point is, I read items from Database, which contain text as well as an
image. So I already have a list, that contains the images.
Therefore I expected something similar than OnGetItemText() - which returns
text from custom storage.

Unfortunately the return value of OnGetItemImage is only an index for an
internal list (which I have to create and populate). A function that directly
returns the image/bitmap would have been more helpful.

With your API I always have to copy images ...

> > Hm, is there some docs about the functions that need to get overridden
> > virtual mode?
> > I looked at listbox samples, but aparently I missed something.
>
> There is listctrl (not listbox) sample and the documentation of
> wxListCtrl, explaining how to use its virtual mode seems reasonably
> complete to me.

Well, when you know everything and just need the docs to refresh your memory
its an absolutely different situation.
For a beginner *imho* documentation is not complete

> > For that I subclassed wxListCtrl and added a wxVector which holds tuple
> > items with text and image. OnGetItemText returns that text.
> >
> > When I start that page, this error happens:
> >
> > ../include/wx/generic/private/listctrl.h(276): assert "!IsVirtual()"
> > failed in IsHighlighted(): unexpected call to IsHighlighted
>
> You'll have to reproduce this problem in some way to allow us to do
> something about it because the sample doesn't show it by default, even when
> using virtual mode.

Ok. You find my prototype at https://github.com/DjangoReinhard/wxProto

The prototype is to become an application that is operated in full screen mode
via touchscreen - so the Frame-controls are just to ease development.

The screen is divided into three areas (from top to bottom):
- title area
- client area
- button bar

Title area contains some static texts, that should reflect current application
status (instead of using a status bar). The central static text widget shall
show the title of the current client area page.
That static text has style horizontally centered text.

The client area is a wxSimpleBook control, which flips the pages at button
press or application signal.

Buttons lead to these pages:
1) list control to show list of images (crashes the app)
2) login screen
3) calculator
4) input control

hitting leftmost button (1) will crash app.

------------------------------------------------------------------------
There are several issues found with this prototype:
------------------------------------------------------------------------
- static text control looses style (about centering its text)
change pages by clicking on some buttons from button bar. Whenever you hit
the same page for second time, static text in title control looses its
style information and text will be displayed left oriented instead of
centered.

- grid layout does not calculate growing columns
hit button 3 to display a page to enter a number. The number buttons are
all in a resizable grid column, thus all should have the same width.

- listCtrl
leftmost button starts a page, that should display a list created in
MainWindow (simulated database access).




Vadim Zeitlin

unread,
Dec 19, 2022, 10:52:21 AM12/19/22
to wx-u...@googlegroups.com
On Mon, 19 Dec 2022 06:04:36 +0100 Django wrote:

D> Unfortunately the return value of OnGetItemImage is only an index for an
D> internal list (which I have to create and populate). A function that directly
D> returns the image/bitmap would have been more helpful.

This is a limitation of the native MSW List View control, it needs a fixed
set of images to use to be specified in advance. If you can't live with
this, you'll have to use some other control, e.g. wxGrid or wxDataViewCtrl.

D> Ok. You find my prototype at https://github.com/DjangoReinhard/wxProto

I'm sorry and I don't want to sound harsh, but you must realize that you
can't expect people to go look at a project containing dozens of files.
What is invariably meant by "showing how to reproduce the problem" is "to
provide a simple/trivial example or the smallest possible change to the
existing sample showing it".

Django

unread,
Dec 19, 2022, 11:53:47 AM12/19/22
to wx-u...@googlegroups.com
Am Montag, 19. Dezember 2022, 16:52:17 CET schrieb Vadim Zeitlin:
> This is a limitation of the native MSW List View control, it needs a fixed
> set of images to use to be specified in advance. If you can't live with
> this, you'll have to use some other control, e.g. wxGrid or wxDataViewCtrl.

Thank you for that explanation!
I'll follow your advice

> > Ok. You find my prototype at https://github.com/DjangoReinhard/wxProto
>
> I'm sorry and I don't want to sound harsh, but you must realize that you
> can't expect people to go look at a project containing dozens of files.

No problem. Its not harsh.

But if you take the lines of code, its not more than your examples.
I don't like big files, so I split the prototype into many small chunks, which
are easy to get rid of and which are easy to find/understand by filename.

So the issue with page title may be related to titlePane.cpp and listCtrl will
be in listPane.cpp with listCtrl.cpp as subclass of wxListCtrl.

Grid-layout issue will be found in numberInput.cpp

You can look at the other files, but you don't need to. In any way, the sample
is compilable and runnable.



Reply all
Reply to author
Forward
0 new messages