More Qs about wxDataViewListCtrl and its behavior

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
runeight
Earned a small fee
Earned a small fee
Posts: 22
Joined: Sat Apr 11, 2020 5:53 pm

More Qs about wxDataViewListCtrl and its behavior

Post by runeight » Wed Apr 22, 2020 10:21 pm

There are a few things about this control which I don't yet understand, even after looking at class ref pages and some examples. As always, it is possible, even likely, that I missed something.

First, I am using the CB and the extern wxFormBuilder app. For those who know how this works, FB is editing files in the CB directory. Changes are posted there and then CB reads them as changed files. It's an easy workflow.

But, given this behavior, we don't want to edit the files modified by FB in CB bc they will be overwritten. This is just preface to one of the questions.

1. There doesn't seem to be a way to set, in FB, the minimum width of a column. I'd like the min width to be at least the size of the text in the header. In fact the params for a dataViewListColumn are sparse in FB, just some text and a type. Is there a way to set the minimum width in FB? If not, then in code? In the class ref that I found it shows that AppendTextColumn() takes multiple args. The calls created by FB have only one arg. If I mess with this call then it will be overwritten. Is there a separate call to set the min width that I can put somewhere else on init?

2. The dataViewListCtrl has quite a few events. I need to do two things. Receive and respond to a single left click and a double left click and, eventually, a right click for opening a popup menu. If I turn on pure mouse events, they don't seem to make it to the handlers. I don't think I have disabled them. Are they disabled by default? If I use the OnDataViewListCtrlSelectionChanged event then I see it. But, if I do that, I still cannot trap the double click and the ctrl only responds as a selection regardless of click count. In addition, at some point I will want to use the editing features of listctrl. Am I going to have collisions among the events? If so, should I change out the object I am using for one better suited? Or change the UI design?

The second Q means that there is something I do not understand about the behavior of the listctrl.

Would be grateful for pointers or enlightenment.

I do have to say, as someone totally new to wxW but with a fair amount of experience in multiple languages, the speed with which I have been able to create this GUI is remarkable.

Thanks.

User avatar
doublemax
Moderator
Moderator
Posts: 15176
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: More Qs about wxDataViewListCtrl and its behavior

Post by doublemax » Wed Apr 22, 2020 11:31 pm

But, given this behavior, we don't want to edit the files modified by FB in CB bc they will be overwritten.
Usually the auto-generated parts in the file are marked by special comments. Changes you make outside these markers should be untouched. I don't know FB though.

(Edit: I found an old post that says you should derive a new class from the wxFB generated class and make your changes there: viewtopic.php?p=70570#p70570 . Maybe that's the way to do it with wxFB)

wxDataViewColumn has wxSettableHeaderColumn as base class, there you'll find wxSettableHeaderColumn::SetMinWidth ()
https://docs.wxwidgets.org/trunk/classw ... 3800a3dad3
The dataViewListCtrl has quite a few events. I need to do two things. Receive and respond to a single left click and a double left click and, eventually, a right click for opening a popup menu.
Use wxEVT_DATAVIEW_SELECTION_CHANGED for single-click
wxEVT_DATAVIEW_ITEM_ACTIVATED = double click or pressing return
wxEVT_DATAVIEW_ITEM_CONTEXT_MENU = context menu

Avoid using low-level mouse events, there may be users who prefer or have to use the keyboard.
Use the source, Luke!

runeight
Earned a small fee
Earned a small fee
Posts: 22
Joined: Sat Apr 11, 2020 5:53 pm

Re: More Qs about wxDataViewListCtrl and its behavior

Post by runeight » Wed Apr 22, 2020 11:54 pm

With FB the note in the GUI file says "do not edit this file". I believe they mean the entire file, so I don't think a way to edit pieces.

I will work with a derived class. Thanks for this and the event explanations.

Post Reply