wxListview header obscures first row when using wxNotebook

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
ReddishShift
In need of some credit
In need of some credit
Posts: 8
Joined: Tue Mar 30, 2021 11:31 pm

wxListview header obscures first row when using wxNotebook

Post by ReddishShift »

When I create a wxListview with wxLC_REPORT on a wxNotebook tab the first row is obscured by the column header. Changing the wxNotebook to wxListbook corrects this. I would prefer to use wxNotebook tho, can anyone suggest a fix?
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxListview header obscures first row when using wxNotebook

Post by PB »

You did not provide basic information such as platform or wxWidgets version.

I cannot reproduce the behaviour on Windows 10 with wxWidgets master:
notebook+listctrl.png
notebook+listctrl.png (5.38 KiB) Viewed 1903 times

Code: Select all

#include <wx/wx.h>
#include <wx/listctrl.h>
#include <wx/notebook.h>

class MyApp : public wxApp
{
public:	
    bool OnInit() override
    {
        wxFrame*    frame = new wxFrame(nullptr, wxID_ANY, "Test");
        wxNotebook* notebook = new wxNotebook(frame, wxID_ANY);

        for ( size_t i = 0; i < 5; ++i )
        {
            wxListView* listView = new wxListView(notebook);

            notebook->AddPage(listView, wxString::Format("Page %zu", i));
            for ( size_t j = 0; j < 5; ++j )
                listView->AppendColumn(wxString::Format("Column %zu", j));
            for ( size_t j = 0; j < 5; ++j )
                listView->InsertItem(listView->GetItemCount(), wxString::Format("Item %zu", j));        
        }

        frame->Show();
        return true;
    }
}; wxIMPLEMENT_APP(MyApp);
Are you sure the parent for the list control is the notebook and you added it as the notebook's page?
ReddishShift
In need of some credit
In need of some credit
Posts: 8
Joined: Tue Mar 30, 2021 11:31 pm

Re: wxListview header obscures first row when using wxNotebook

Post by ReddishShift »

This is happeneing on wXWidgets 3.1.4 running under Fedora Linux. The error does not appear under Windows 10.

Thanks to your code PB I have determined the problem happens size is set when the listview is created. When I change your code to:

Code: Select all

wxListView* listView = new wxListView(notebook, wxID_ANY, wxDefaultPosition, wxSize(600, 600));
the error occurs. It also causes the follwing message to be repeatedly sent to the console:

Code: Select all

(wxListview:179089): Gtk-CRITICAL **: 00:24:53.167: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkNotebook
The error does not happen when the size is set immediately agter using SetSize (shown on the second tab in the code below). This is fine for me as a fix/work around.

The modified code below shows the problem on the first tab.
Screenshot 2021-04-02 00.05.05.png
Screenshot 2021-04-02 00.05.05.png (8.22 KiB) Viewed 1852 times

Code: Select all

#include <wx/wx.h>
#include <wx/listctrl.h>
#include <wx/notebook.h>

class MyApp : public wxApp
{
public:
    bool OnInit() override
    {
        wxFrame*    frame = new wxFrame(nullptr, wxID_ANY, "Test");
        wxNotebook* notebook = new wxNotebook(frame, wxID_ANY);

        {
            wxListView* listView = new wxListView(notebook, wxID_ANY, wxDefaultPosition, wxSize(600, 600));

            notebook->AddPage(listView, wxString::Format("Page %zu", 0));
            for ( size_t j = 0; j < 5; ++j )
                listView->AppendColumn(wxString::Format("Column %zu", j));
            for ( size_t j = 0; j < 5; ++j )
                listView->InsertItem(listView->GetItemCount(), wxString::Format("Item %zu", j));
        }
        {
            wxListView* listView = new wxListView(notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize);
            listView->SetSize(600, 600);

            notebook->AddPage(listView, wxString::Format("Page %zu", 1));
            for ( size_t j = 0; j < 5; ++j )
                listView->AppendColumn(wxString::Format("Column %zu", j));
            for ( size_t j = 0; j < 5; ++j )
                listView->InsertItem(listView->GetItemCount(), wxString::Format("Item %zu", j));
        }
        for ( size_t i = 2; i < 5; ++i )
        {
            wxListView* listView = new wxListView(notebook);

            notebook->AddPage(listView, wxString::Format("Page %zu", i));
            for ( size_t j = 0; j < 5; ++j )
                listView->AppendColumn(wxString::Format("Column %zu", j));
            for ( size_t j = 0; j < 5; ++j )
                listView->InsertItem(listView->GetItemCount(), wxString::Format("Item %zu", j));
        }

        frame->Show();
        return true;
    }
}; wxIMPLEMENT_APP(MyApp);
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxListview header obscures first row when using wxNotebook

Post by doublemax »

Code: Select all

wxListView* listView = new wxListView(notebook, wxID_ANY, wxDefaultPosition, wxSize(600, 600));
If you pass a non-default size to the constructor of any wxWindow, this size will be also set as minimum size for the window. But the frame doesn't look big enough to display the whole control. Maybe that's the issue here.
Use the source, Luke!
ReddishShift
In need of some credit
In need of some credit
Posts: 8
Joined: Tue Mar 30, 2021 11:31 pm

Re: wxListview header obscures first row when using wxNotebook

Post by ReddishShift »

doublemax wrote: Fri Apr 02, 2021 1:26 am If you pass a non-default size to the constructor of any wxWindow, this size will be also set as minimum size for the window. But the frame doesn't look big enough to display the whole control. Maybe that's the issue here.
Setting the frame to be bigger (800 x 800) doesn't stop the problem. And if it did, shouldn't the issue be occuring under Windows and with wxListBook?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxListview header obscures first row when using wxNotebook

Post by ONEEYEMAN »

Gi,
Why do you need to set the size? Use sizes with default size and everything will work.

Thank you
ReddishShift
In need of some credit
In need of some credit
Posts: 8
Joined: Tue Mar 30, 2021 11:31 pm

Re: wxListview header obscures first row when using wxNotebook

Post by ReddishShift »

ONEEYEMAN wrote: Fri Apr 02, 2021 12:02 pm Why do you need to set the size? Use sizes with default size and everything will work.
Because I want the listview to be a different size from the default.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxListview header obscures first row when using wxNotebook

Post by PB »

I know nothing about Linux but I cannot reproduce the issue even when setting the listview size to (1024,900) on Ubuntu 20.04 under VirtualBox with wxWidgets 3.1.4 built for GTK3 (3.24.20):
gtk-notebook-listview.png
gtk-notebook-listview.png (14.4 KiB) Viewed 1794 times
even when I also get those gtk_box_gadget_distribute asserts.

Are you building for GTK3 as well?

Normally, I would say if you experience this, it must be a bug regardless of what size you pass to the ctor and as such should be reported on wxTrac, assuming it is reproducible with the master. But I do not understand Linux, so who knows. But even if it is distribution specific, it looks like a bug to me.
Last edited by PB on Fri Apr 02, 2021 2:16 pm, edited 2 times in total.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxListview header obscures first row when using wxNotebook

Post by ONEEYEMAN »

Hi,
ReddishShift wrote: Fri Apr 02, 2021 1:26 pm
ONEEYEMAN wrote: Fri Apr 02, 2021 12:02 pm Why do you need to set the size? Use sizes with default size and everything will work.
Because I want the listview to be a different size from the default.
You can override DpGetBestSize() and use any calculation you want.
And then use default size with sizer.

Try it and see if it helps.

Thank you.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxListview header obscures first row when using wxNotebook

Post by ONEEYEMAN »

@PB,
It also could be a different theme.
@OP,
What theme do you use and what exact GTK+ version?
Do you see it under GNOME or K?

Thank you.
ReddishShift
In need of some credit
In need of some credit
Posts: 8
Joined: Tue Mar 30, 2021 11:31 pm

Re: wxListview header obscures first row when using wxNotebook

Post by ReddishShift »

ONEEYEMAN wrote: Fri Apr 02, 2021 2:12 pm You can override DpGetBestSize() and use any calculation you want.
And then use default size with sizer.
I'm using SetMinSize and this is working fine.
ReddishShift
In need of some credit
In need of some credit
Posts: 8
Joined: Tue Mar 30, 2021 11:31 pm

Re: wxListview header obscures first row when using wxNotebook

Post by ReddishShift »

ONEEYEMAN wrote: Fri Apr 02, 2021 2:58 pm @PB,
It also could be a different theme.
@OP,
What theme do you use and what exact GTK+ version?
Do you see it under GNOME or K?
Interesting. It is on a Linux machine that is set at run-level 3. I run it from a Windows desktop via putty. Firing up GNOME on the linux machine and running it there doesn't exhibit this problem.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxListview header obscures first row when using wxNotebook

Post by ONEEYEMAN »

Hi,
You say it is on level 3.
Why? Is there a reason you don't want a full blown os?

Thank you
ReddishShift
In need of some credit
In need of some credit
Posts: 8
Joined: Tue Mar 30, 2021 11:31 pm

Re: wxListview header obscures first row when using wxNotebook

Post by ReddishShift »

ONEEYEMAN wrote: Sat Apr 03, 2021 2:31 pm Why? Is there a reason you don't want a full blown os?
Yes
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxListview header obscures first row when using wxNotebook

Post by ONEEYEMAN »

Hi,
So you are seeing it under GNOME.
What about the GTK+ version? You also didn't say what theme do you use?

Thank you.
Post Reply