On Fri, 1 Apr 2016 05:59:41 -0700 (PDT) Iwbnwif Yiw wrote:
IY> No doubt, wxTreeListCtrl has the better API. However, and with the greatest
IY> respect, there are a few reasons why I choose wxDataViewListCtrl instead:
Notice that wxTreeListCtrl is absolutely not meant to replace
wxDataViewCtrl, it's intentionally more limited, so if you need something
that it doesn't provide, using wxDataViewCtrl, or even wxDataViewListCtrl,
is the right thing to do.
IY> 1. Unless I have completely missed it, wxTreeListCtrl doesn't have a
IY> friendly 'list' API, i.e. you cannot address items by 'row'. I appreciate
IY> that you can create a 'flat' tree (as per the sample). No doubt row access
IY> can be emulated with GetRootItem(), GetFirstChild() and iterating on
IY> GetNextSibling() but IHMO it is less intuitive than GetValue (variant&, row
IY> col) or GetTextValue (row, col).
Access by row doesn't really make sense as soon as you have branches.
First of all, it's not O(1), as would be expected. Second, it's never clear
if the row is the physical row (depends on the expanded state of the
branches before it) or logical one (as if all the branches were expanded).
IY> 2. In the documentation for GetView() it says "*This method may return
IY> NULL in the future, non wxDataViewCtrl-based, versions of this class, use
IY> GetView() unless you really need to use wxDataViewCtrl methods on the
IY> returned object*". I think it also says something similar in the header.
IY> IMVHO this is possibly not a good thing to say, wxDataViewCtrl seems to be
IY> the most advanced, maintained list-like control in wxWidgets so it feels
IY> better to use it or something derived from it. If wxTreeViewCtrl is going
IY> to change substantially in the future then that's a worry, maybe I will
IY> have relied (deliberately or inadvertently) on wxDataViewCtrl behavior and
IY> something might get broken.
To be honest, this is quite unlikely to happen, but the idea is that if we
can implement wxTreeListCtrl API directly and natively on some platform
(typically this would be MSW...), then we should be able to do it. And yes,
it does mean that you shouldn't use its GetView() unless you really need
to.
IY> 3. There is something weird with wxTreeListCtrl headers. You can see
IY> this clearly in the sample (at least MSW and GTK) by repeatedly resizing
IY> the window with the mouse. Either the 1st column or the 3rd one starts to
IY> consume the whole space. I didn't see the same behavior with other
IY> wxDataViewCtrl derivatives.
This looks like a bug which should be fixed, please report it as usual.
IY> Absolutely agreed, the number of list-like controls (not to mention the
IY> third party ones) is rather confusing. I can only offer a humble suggestion
IY> and I absolutely appreciate that it all comes down to time.
IY>
IY> 1. Implement a 'list only' mode for wxTreeListCtrl which gives row,
IY> column access to data items (including appending, deleting, moving rows
IY> etc.).
I'm not sure if this wouldn't make the control more complicated to use,
thus negating the main reason for its existence...
IY> 2. Have wxVariant (or wxAny) getters and setters for data. This avoids
IY> [dare I say fiddling around with] *wxClientData etc.
I don't think wxVariant is really any better than wxClientData. The latter
is supported to make it simpler to migrate existing code using wxTreeCtrl
to wxTreeListCtrl. And wxVariant doesn't replace client data anyhow, of
course, but rather the item text... I'm really not sure what do you mean
here.
IY> 3. Allow editing (maybe this is already possible - I didn't find how to
IY> do it).
No, it isn't editable. This could indeed be added, provided the API
remains really simple.
IY> 4. Emphasize that wxTreeListCtrl is THE wxWidgets list-like control, and
IY> a simple, but multipurpose wrapper for wxDataViewCtrl (remove any hint that
IY> this may change in the future).
This is simply not the case. wxTreeListCtrl is a simple way to show (not
edit) a relatively small number of items. For anything else you need to use
something else. And, again, while editing could be added, this control
hides the use of the model, similarly to wxSimpleHtmlListBox and
wxHtmlListBox for example, so making it a general wrapper of wxDataViewCtrl
wouldn't make much sense as then it would be as complex as it.
IY> 5. Add notes that wxDataView{List,Tree}Ctrl, whilst not deprecated, are
IY> not the preferred way of displaying data lists and trees for new projects.
For this we need to be able to propose something better instead :-(