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.
I've implemented a drag and drop operation in the wxTreeListCtrl, but I'm not sure if it's correct. When the method wxTreeListCtrl->GetDataView()->HitTest() was called, it returned the element following the element under the cursor. So I adjusted the Y coordinate with wxRendererNative. Could you tell me if I'm done the right thing for this task?
I have only one form in the project. "Drag and drop" is organized only in one wxTreeListCtrl. I think that this situation may be due to the fact that the column header is accepted as the "first displayed element", but did not find a way to hide the header in order to test this hypothesis.
It's look like true. In the archive there is a simplified and "dirty" project that demonstrates this problem. I use Code::Block 16.01 and wxWidgets-3.1.0.
Lines 74 and 75 of the TestHitTestMain.cpp file are describe the initialization options wxTreeListCtrl with and without header. In the files TreeListCtrlWithHeader.gif and TreeListCtrlWithoutHeader.gif the are outputs of this project on my system is shown.
Returning to the original question, please tell me if the modification in line 137 of the TestHitTestMain.cpp file is correct?
Yes, it's work! Thank you.
But how you do it? Could you tell in a few words the algorithm for solving such problems? I have little experience with wxWidgets, and it seems to me that I will face similar problems in the future.
There is no general plan how to solve these kind of problems. And this was a very specific one.
wxTreeListCtrl uses wxDataViewControl which is a composite control that consists of several sub-windows. The problem was that the drop event handler got coordinates from the wxTreeListCtrl , because that's where you assigned the drop targer. But wxDVC needed the coordinates of the subwindow that displays the actual items.
FWIW, i think this is a bug in wxDataViewControl, IMHO it should perform the necessary coordinate transformation. When i have some more time, i might take a closer look and open a bug report, if it really turns out to be a bug.