Array of elelemts with different sizes Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
wyo
In need of some credit
In need of some credit
Posts: 9
Joined: Thu Apr 21, 2005 8:03 pm
Contact:

Array of elelemts with different sizes

Post by wyo » Mon Jul 03, 2006 10:51 am

I'm still looking for the best solution to display an array of elements. These elements all have the same structure (some texts and an image) but all the texts and the image are different sizes. It would be best if I simply could use a wxScrolledWindow but could layout each element with sizers. Has anybody done something similar or knows how? Any better ideas?

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Mon Jul 03, 2006 11:30 am

This screams for an owner drawn list box with variable sizes. Most toolkits have one.

One suggestion is keeping a class pointer to your element per entry in a wxScrolledWindow. Then simply ask for the Y height of every class element and draw it. This is how I deal with variying sizes in wxTreeMultiCtrl.

Using sizers or not, I do not know what the best solution is. It depends on what you want to display. If you want to display window controls inside a container window it would be useful. If you want to display some list entry that is owner drawn, I would not use sizers.

Also if you are going to display a lot of entries in this window, a virtual solution would be better where the controls are created only when in view. To lower resource hogging.

Anyway, I am also interested in a solution as I want to have some kind of owner drawn semi grid based component. And my solution was going to be sizers also, but I'm still looking..

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

wyo
In need of some credit
In need of some credit
Posts: 9
Joined: Thu Apr 21, 2005 8:03 pm
Contact:

Post by wyo » Tue Jul 04, 2006 6:08 am

Jorg wrote:One suggestion is keeping a class pointer to your element per entry in a wxScrolledWindow. Then simply ask for the Y height of every class element and draw it. This is how I deal with variying sizes in wxTreeMultiCtrl.
wxTreeMultiCtrl has some nice ideas.
Jorg wrote:Using sizers or not, I do not know what the best solution is. It depends on what you want to display. If you want to display window controls inside a container window it would be useful. If you want to display some list entry that is owner drawn, I would not use sizers.
Well IMO sizers are very useful to layout any kind of content in a standard way.
Jorg wrote:Also if you are going to display a lot of entries in this window, a virtual solution would be better where the controls are created only when in view. To lower resource hogging.
I envision something like a wxArraySizer which handles all the virtualisation inside, you only have to add/delete controls to it. This way it should be possible to get a rather efficient layout even for many objects.

My problem is now where to start. Shall I create a control based on wxScrolledWindow and ObjArray or does any wxGridSizer class have this feature?

O. Wyss

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Tue Jul 04, 2006 7:02 am

If you foresee scrolling functionality I would say the wxScrolledWindow is the best starting point. If you do prefer not to expose all the wxScrolledWindow functionality you can place it on a wxPanel and expose that to the outside, e.g. wxScrolledWindow will become a child of the wxPanel.
Well IMO sizers are very useful to layout any kind of content in a standard way.
Well yes and no. When you are going to display 10.000 records (or even over a 100) then it will be a real drain on the graphics system to create them in a sizer because that means they are all visual controls (wxWindow derived controls). In that case it is better to virtualize it and implement an event handler that requests the next / previous element all the time. They can be created on the fly and scrolled into view, or owner drawn which means there is no real control(s) created for the entry but simply a representation with wxDC. The only downside is that you must know the Y size in advance to calculate the virtual area, but I see no problem why controls cannot be created on the fly and deleted when they are out of context. It surely saves a lot of strain on the graphics system.
I envision something like a wxArraySizer which handles all the virtualisation inside, you only have to add/delete controls to it. This way it should be possible to get a rather efficient layout even for many objects.
How is this different from a V sizer with e.g. nested H sizers? The way you describe it the sizer should layout itself based upon the controls? Wasn't that where wxGridBagSizer was for ? I never used it though.

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

User avatar
tierra
Site Admin
Site Admin
Posts: 1343
Joined: Sun Aug 29, 2004 7:14 pm
Location: Salt Lake City, Utah, USA
Contact:

Post by tierra » Wed Jul 05, 2006 3:19 pm

Jorg wrote:If you foresee scrolling functionality I would say the wxScrolledWindow is the best starting point. If you do prefer not to expose all the wxScrolledWindow functionality you can place it on a wxPanel and expose that to the outside, e.g. wxScrolledWindow will become a child of the wxPanel.
The wx[H]VScrolledWindow classes could come in rather handy. Their main saving grace is a scrolled window with virtual row/column sizes.

wxVScrolledWindow should do what you want and has been in wxWidgets since 2.5 days I think, but wxHVScrolledWindow is only available via a patch right now though:
https://sourceforge.net/tracker/?func=d ... tid=309863

We've been using both not only for some of the main windows in our application, but also for a custom control containing rows with controls like wxChoice, wxRadioButton, wxCheckbox, wxDatePickerCtrl, etc much like the Filter Rules dialog in Thunderbird when creating a new Message Filter.

wyo
In need of some credit
In need of some credit
Posts: 9
Joined: Thu Apr 21, 2005 8:03 pm
Contact:

Post by wyo » Wed Jul 05, 2006 8:01 pm

tierra wrote:wxVScrolledWindow should do what you want ...
Hmm, I've seen wxVScrolledWindow but didn't trust it. Well ist there any sample code in the patch or could you post some?

O. Wyss

Post Reply