Problems with changes to TGListView in ROOT 5.14

I have a working TGListView, but unfortunately it seems the behavior of the column spacing has changed between ROOT 5.12 and 5.14. In 5.12 the columns would automatically size to the largest sub-item in a column. In 5.14 the columns do not seem to automatically size. I initially create the ListView:

    TelegramSelectionListViewCont = new TGLVContainer(TelegramSelectionListView,kSunkenFrame,white);

    TelegramSelectionListViewCont->SetHeaders(5);
    TelegramSelectionListViewCont->SetHeader("Name",  kTextLeft, kTextLeft, 0);
    TelegramSelectionListViewCont->SetHeader("Group", kTextLeft, kTextLeft, 1);
    TelegramSelectionListViewCont->SetHeader("Tel ID", kTextLeft, kTextLeft, 2);
    TelegramSelectionListViewCont->SetHeader("Sensor #", kTextLeft, kTextLeft, 3);
    TelegramSelectionListViewCont->SetHeader("Data", kTextLeft, kTextLeft, 4);
    TelegramSelectionListViewCont->Resize();
    TelegramSelectionListViewCont->SetViewMode(kLVDetails);

and then fill the ListView from a list of items:

    TListIter next(TelegramList);
    while((listItem = (CustListViewItem*) next()))
    {
        entry = new TGLVEntry(TelegramSelectionListViewCont, listItem->GetTelName(), listItem->GetTelName());
        entry->SetSubnames(listItem->GetTelGroup().Data(), listItem->GetTelID().Data(),
                           listItem->GetTelSensorNum().Data(), listItem->GetTelData().Data());

        TString* entryData = new TString(listItem->GetTelData());
        entry->SetUserData((void *)entryData->Data());
        TelegramSelectionListViewCont->AddItem(entry);
    }

    TelegramSelectionListViewCont->Resize();

I’ve attached pictures of the resulting ListView in ROOT 5.12 and 5.14. I’d like the columns to resize the way they did in ROOT 5.12 but I can’t figure out how to do this in 5.14. I’d appreciate any help!
Thanks!
Tim




Hi Tim,

The TGListView class was changed between ROOT version 5.12 and 5.14. according to the added ability for resizing the space taken by each column in detailed list view and sorting the columns. Users can click and drag the borders between the column headers to resize the columns (if they want to see long file names entirely). Users can sort the list by clicking on the column headers. What you have reported is a side effect after these new developments. I will investigate this case and will let you know next week. You could help us by providing a small running example that shows the problem.

Thank you, Ilka

Hi Tim,

The method ResizeColumns() was added in TGListView class for keeping the backward compatibility. It is uploaded in cvs head. When you call it in your code, it will resize each column to the largest sub-item. According to the provided code above, you can replace: TelegramSelectionListViewCont->Resize();by: TelegramSelectionListViewCont->ResizeColumns();
There is also an interactive way for doing it - without calling ResizeColumns(), move the mouse pointer over the split line between two header buttons and double-click when the cursor shape changes for resizing (<–>). As a result, the left column will be resized up to the largest sub-item.

Cheers, Ilka

Ilka,
Thank you so much for your help! I’ve been busy for a project deadline and I’ve just gotten the chance to revisit your post. The listview does look much better now. However, I’m still having a small problem - the first column does not resize to fit the largest subitem. I’ve attached a screenshot of a small program to illustrate along with the source code.

Also, another minor issue - the last column is difficult to resize (the Data column in my example). If you move the mouse from the right side of the column until it becomes a resize cursor and then try to resize the column it doesn’t always work. If you move the mouse from the left side of the column, however, it usually does. My guess would be that the blank column button is handling the resize when the mouse comes from the right side and not doing anything and the Data column is handling the resize from the left side and resizing correctly. This isn’t really an issue for my application but I thought I’d mention it in case it’s an easy fix.

Thanks again!
Tim
guitest.cxx (3.94 KB)

Hi Tim,

Thank you for your feedback. I can reproduce what you have reported and will investigate.

Cheers, Ilka

Hi Tim,

A fix is uploaded in cvs head. Please give a try when you can and let me know. Both reported cases should be fixed (as the attached image shows): first column is resized and shows entire text, last column can be resized on the right (the dotted vertical line shows that, even the mouse coursor is not visible on the image).

Cheers, Ilka

Ilka,
Yes, my columns are resizing perfectly now. Thank you very much!

 Again, this isn't a concern for my application as it is really doesn't cause a problem, but I still experience the problem resizing the last column on the right.  I'm not sure if I explained it well enough the first time.  Taking your example screenshot with the dotted line - approach the right side of the last column, where the dotted line is, with the mouse from the right. As soon as it turns into a resize cursor, click and drag to resize the column.  For me, the column doesn't resize.  If you approach the right side of the column from the left side it usually works correctly.  In both cases, I'm trying to resize the last column on its right side.

Tim

Hi Tim,

You are welcome. Yes, I understand your explanation. Before the fix I made, it was impossible to resize last two headers to the right. Now I see that the resizing works fine if the last ‘empty’ header is big enough. If it is small, the cursor changes, but in time to time the vertical dotted line does not appear - hence no resizing available. To be investigated further when I will have time.

Cheers, Ilka