wxListview header obscures first row when using wxNotebook
-
- In need of some credit
- Posts: 8
- Joined: Tue Mar 30, 2021 11:31 pm
wxListview header obscures first row when using wxNotebook
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?
Re: wxListview header obscures first row when using wxNotebook
You did not provide basic information such as platform or wxWidgets version.
I cannot reproduce the behaviour on Windows 10 with wxWidgets master:
Are you sure the parent for the list control is the notebook and you added it as the notebook's page?
I cannot reproduce the behaviour on Windows 10 with wxWidgets master:
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);
-
- In need of some credit
- Posts: 8
- Joined: Tue Mar 30, 2021 11:31 pm
Re: wxListview header obscures first row when using wxNotebook
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:
the error occurs. It also causes the follwing message to be repeatedly sent to the console:
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.
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));
Code: Select all
(wxListview:179089): Gtk-CRITICAL **: 00:24:53.167: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkNotebook
The modified code below shows the problem on the first tab.
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);
Re: wxListview header obscures first row when using wxNotebook
Code: Select all
wxListView* listView = new wxListView(notebook, wxID_ANY, wxDefaultPosition, wxSize(600, 600));
Use the source, Luke!
-
- In need of some credit
- Posts: 8
- Joined: Tue Mar 30, 2021 11:31 pm
Re: wxListview header obscures first row when using wxNotebook
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?
Re: wxListview header obscures first row when using wxNotebook
Gi,
Why do you need to set the size? Use sizes with default size and everything will work.
Thank you
Why do you need to set the size? Use sizes with default size and everything will work.
Thank you
-
- In need of some credit
- Posts: 8
- Joined: Tue Mar 30, 2021 11:31 pm
Re: wxListview header obscures first row when using wxNotebook
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):
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.
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.
Re: wxListview header obscures first row when using wxNotebook
Hi,
And then use default size with sizer.
Try it and see if it helps.
Thank you.
You can override DpGetBestSize() and use any calculation you want.ReddishShift wrote: ↑Fri Apr 02, 2021 1:26 pmBecause I want the listview to be a different size from the default.
And then use default size with sizer.
Try it and see if it helps.
Thank you.
Re: wxListview header obscures first row when using wxNotebook
@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.
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.
-
- In need of some credit
- Posts: 8
- Joined: Tue Mar 30, 2021 11:31 pm
-
- In need of some credit
- Posts: 8
- Joined: Tue Mar 30, 2021 11:31 pm
Re: wxListview header obscures first row when using wxNotebook
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.
Re: wxListview header obscures first row when using wxNotebook
Hi,
You say it is on level 3.
Why? Is there a reason you don't want a full blown os?
Thank you
You say it is on level 3.
Why? Is there a reason you don't want a full blown os?
Thank you
-
- In need of some credit
- Posts: 8
- Joined: Tue Mar 30, 2021 11:31 pm
Re: wxListview header obscures first row when using wxNotebook
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.
So you are seeing it under GNOME.
What about the GTK+ version? You also didn't say what theme do you use?
Thank you.