Improving my two panel gui

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

Improving my two panel gui

Post by runeight » Mon Apr 20, 2020 2:56 am

Man, I hate to have to ask these questions, but there is so much information out there....

I have a two panel frame that looks like this. It is intended to be a simple start to integrating the ui with the already coded app. The first pass works, although with minimal functionality.

The first pass had two list boxes because, at first, I only really needed to print text (with clickable events on the left side). After getting this far I've decided to use dataviewlistctrl elements instead as there could be some useful editing features later. Also, sometimes your toys tend to fill the size of the bag you've got. :D

1) For the left side, what is the correct way to highlight on mouse hover?

2) For the right side, how to initialize the columns to at least be as wide as the labeling text? wxFormBuilder doesn't seem to show an option for this. I can add, of course, my code somewhere where it will not be overwritten, but it would be handier if FormBuilder could add this option.

I have, in getting up to speed, sometimes missed selections in wxFormBuider, so I apologize ahead of time if that is the case here. The dataivew sample does not seem to include hover events.

Thanks.
Attachments
wx.PNG
wx.PNG (79.34 KiB) Viewed 277 times

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

Re: Improving my two panel gui

Post by doublemax » Mon Apr 20, 2020 5:51 am

For the left side, what is the correct way to highlight on mouse hover?
It's still not clear to me what kind of content you're displaying on the left. Any kind of list control (wxListBox, wxListCtrl, wxDataViewCtrl) or just free text (e.g. wxTextCtrl)?

There is no list control that generates hover events. You have to catch the wxEVT_MOTION event, and then there is usually a HitTest() method in any list control that you can use to find the item under the mouse pointer. https://docs.wxwidgets.org/trunk/classw ... event.html
Use the source, Luke!

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

Re: Improving my two panel gui

Post by runeight » Mon Apr 20, 2020 3:23 pm

Yes. Fair enough.

Originally, I thought just plain lines of text that could be clicked on to show further information. Single selection only. But as I worked on that implementation, I realized that I might want to give the user ability to edit the text. Not anything that needs to be done now, but possibly a good feature in the future.

So, then I decided to move from from the simple list box to a data view control for the right panel.

The other reason was that the right side, to be really functional, needs to be text on a grid. I also realized this after the first quick mockup. It's still lines of text, but there are 4 columns to each line and one of the columns needs to be clickable to bring up a popup. Data view seemed like the right choice for this. Yes? No?

The data view has a header with column names. The list box doesn't seem to have one. I couldn't figure out how to put a header on the list box and while trying to figure that out, I realized that editability might be a useful feature.

In the left list the current selection is highlighted. It seems useful to have a rollover highlight when the user moves about to select the next item.

And, another Q pls. When an item is selected, it appears that the only info provided to the handler for determining what was clicked is the line number in the list. The text in the list is not useful for the action that needs to be taken without a lot of reverse searching. For quicker handling I'd like to attach my own identifier to each element of this list and receive that in the handler. Can I do that?

Thanks.

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

Re: Improving my two panel gui

Post by doublemax » Mon Apr 20, 2020 5:28 pm

Data view seemed like the right choice for this. Yes? No?
Yes.
For quicker handling I'd like to attach my own identifier to each element of this list and receive that in the handler. Can I do that?
All InserItem/AddItem methods take a "wxUIntPtr data" which you can use to add custom data. You can retrieve it later with wxDataViewListCtrl::GetItemData()
https://docs.wxwidgets.org/trunk/classw ... 154f69e63f
Use the source, Luke!

Post Reply