Discussion:
wxVListBox with “dynamic” data
(too old to reply)
h***@googlemail.com
2009-10-22 19:00:08 UTC
Permalink
ASked on stackoverflow but nobody is biting.

I have a continuous stream of data that I want to place into a
container. This container will either be of fixed size or dynamically
constrained to a certain size at runtime. The latter may be
preferable.

When the container is full, the oldest data will be removed.

I want to display this data using a wxVListBox because I need full
control of the display. However there is a problem: the calls to
OnDrawItem are not atomic meaning that once the container is full,
each call the OnDrawItem will be accessing moving data, the result
will be a non-contiguous display with missing elements.

This is certainly true with any container with native array-like
indexing, are required by OnDrawItem.

I can simulate array-like indexing in a std::map using iterator
indexing, if the key is sequential integer, then all the items will be
ordered and the map can be pruned quite easily, but that seems like an
inefficient hack.

How can I solve this? Any other ideas or containers I haven't thought
of?
h***@googlemail.com
2009-10-23 10:46:01 UTC
Permalink
Post by h***@googlemail.com
ASked on stackoverflow but nobody is biting.
I have a continuous stream of data that I want to place into a
container. This container will either be of fixed size or dynamically
constrained to a certain size at runtime. The latter may be
preferable.
When the container is full, the oldest data will be removed.
I want to display this data using a wxVListBox because I need full
control of the display. However there is a problem: the calls to
OnDrawItem are not atomic meaning that once the container is full,
each call the OnDrawItem will be accessing moving data, the result
will be a non-contiguous display with missing elements.
This is certainly true with any container with native array-like
indexing, are required by OnDrawItem.
I can simulate array-like indexing in a std::map using iterator
indexing, if the key is sequential integer, then all the items will be
ordered and the map can be pruned quite easily, but that seems like an
inefficient hack.
How can I solve this? Any other ideas or containers I haven't thought
of?
The best approach seems to be to manage the full container state
lazily within OnDrawBackground. That way the UI itself ensures the
data remains static in the subsequent calls to OnDrawItem, using a
deque as the container.
Vadim Zeitlin
2009-10-31 01:25:51 UTC
Permalink
Post by h***@googlemail.com
I want to display this data using a wxVListBox because I need full
control of the display. However there is a problem: the calls to
OnDrawItem are not atomic meaning that once the container is full,
each call the OnDrawItem will be accessing moving data, the result
will be a non-contiguous display with missing elements.
Sorry, I don't understand at all why would this be the case. If you
refresh the control after shifting the items everything should work just
fine. OTOH wxVListBox might not be ideal for you precisely because you need
to refresh it entirely every time a new item is appended with your approach
which is probably going to result in a noticeable flicker. But this is
another problem.

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