On Thu, 15 Aug 2013 02:31:18 -0700 Stefano Antonelli wrote:
SA> I've been playing with wxDataViewCtrl and have noticed some problems.
SA> This is with wxWidgets 2.9.5 on Ubuntu 10.04 (gtk 2.10.0 I believe).
SA> Looking for some advice. Please let me know if I should be posting this
SA> to another list.
Hello,
This list is fine but you may want to open tickets on our Trac for the
issues you encountered to ensure that they don't get lost. Please search
for the existing issues first if you do this though as I think that some of
the problems below may have been already reported.
SA> __Initial Column Width__
SA>
SA> wxCOL_WIDTH_AUTOSIZE provides a decent starting point for the column
SA> width (sized to the header text), but it prevents further resizing.
Yes, unfortunately this is how gtk_tree_view_column_set_sizing() behaves
when called with GTK_TREE_VIEW_COLUMN_AUTOSIZE argument. Apparently we
could still call gtk_tree_view_column_set_resizable(TRUE) in addition and
this would change the grow mode to GTK_TREE_VIEW_COLUMN_GROW_ONLY under the
hood but I didn't test what does this give in practice yet.
SA> Is there any way to provide an initial size to the header that
SA> automatically fits at least the header? Better yet, if there is data
SA> in the model when the app starts, is it possible to size the columns to
SA> the data? Or can the autosize "style" be disabled some time after the
SA> autosize has completed?
You should be able to work around this by using SetWidth() with something
different from wxCOL_WIDTH_AUTOSIZE and, maybe, SetResizeable(true). But
the real solution must be implemented inside wxGTK itself. If anybody has
time to do it, it would be great.
For the reference, we have GetBestColumnWidth() method in the generic
wxDataViewCtrl which could be reused to compute the best column width if we
decide that we need to do it ourselves because GTK+ behaviour is not
useful.
SA> __Double clicking the header separator__
SA>
SA> I expect that double clicking the header separator would either:
SA>
SA> a) resize to fit the header text or
SA> b) resize to fit the contents of the visible rows
This is definitely the native behaviour under Windows but I don't know
about Linux/GTK. The GNOME HIG doesn't say anything about this so I guess
copying Nautilus is going to be about the best thing we can do...
SA> In general I would expect that a double click on the header separator
SA> would size to fit the "cell" contents or the header text, whichever
SA> happens to be wider. Any advice on how to achieve this?
Unfortunately currently you can't as we don't even send any events when
double clicking on a separator line. It would be nice to have an equivalent
to the generic wxEVT_HEADER_SEPARATOR_DCLICK event in wxDataViewCtrl but
we'd need to check whether the native GTK+ and OS X versions are even
capable of generating it in the first place.
SA> It would seem from playing with Nautilus in List mode that gtk does not
SA> allow the header to shrink (by dragging the header separator) smaller
SA> than the text in the heading. Any idea why? Is this a limitation of
SA> gtk or just a matter of setting some extra flags?
Looks like example of the GTK_TREE_VIEW_COLUMN_GROW_ONLY mode mentioned
above... But I don't really know.
SA> __Column stretching__
SA>
SA> In the sample, the last column stretches when the window is resized.
SA> However, in Nautilus list view, the first column stretches. Is there a
SA> way to pick an arbitrary column as the stretch column?
I don't think so. Besides, this functionality is specific to GTK+ only. In
portable code you'd want to handle wxEVT_SIZE and resize the columns
manually.
SA> __Rubber band selection__
SA>
SA> As far as I know, this is not supported by the native control (ie. it
SA> frustrates me in Nautilus list view). Is it possible to fake it?
This isn't going to be simple.
SA> __Generic wxDataViewCtrl__
SA>
SA> Is it possible to use the generic version of this control on gtk? I
SA> found references to wxHAS_GENERIC_DATAVIEWCTRL, but where do I specify
SA> this?
You need to define this before including wx/dataview.h so the safest way
to do it is to add /DwxHAS_GENERIC_DATAVIEWCTRL to your compiler options in
the make/project file. *And* you also need to specify it when building
wxWidgets itself.
SA> Would it even work?
It should. But it would definitely look worse in GTK+ environment than the
native control.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/