Empty wxListCtrl is not shown Topic is solved

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
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Empty wxListCtrl is not shown

Post by ONEEYEMAN »

Hi, ALL,
I have a weird issue.
I am trying to create 2 wxListCtrl's on the wxNotebook page (wxPanel) - one on the right and on the left.
One on the left should be populated with data and one on the right should be empty.

On Windows everything works as expected. I do see both those controls.
On *nix/GTK I see only the one that has data. Instead of seeing the control on the right I see an empty space.

Is it an expected behavior?

I am using wxWidgets 3.1.3 built against GTK+3 in C++11 mode and on Windows 8.1.

I did see the same thing on Windows when both controls were empty.

I didn't try the OSX yet.

Controls are created as:

Code: Select all

    m_source = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_NO_HEADER );
    m_dest = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_NO_HEADER );
Control on the right will be populated from the data from the control on the left.

I will have a screenshot available if needed.

Is this a known issue? Should I file a bug?

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Empty wxListCtrl is not shown

Post by doublemax »

That doesn't sound right. I assume both controls are inside a sizer? Are both set to expand? Maybe the "invisible" one just has a size of 0?
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Empty wxListCtrl is not shown

Post by ONEEYEMAN »

doublemax,
Yes, both are in the horizontal sizer and both are expanding:

Code: Select all

    auto sizer1 = new wxBoxSizer( wxVERTICAL );
    auto sizer2 = new wxBoxSizer( wxHORIZONTAL );
    sizer1->Add( m_label, 0, wxEXPAND, 0 );
    sizer1->Add( 5, 5, 0, wxEXPAND, 0 );
    sizer2->Add( m_source, 0, wxEXPAND, 0 );
    sizer2->Add( m_dest, 0, wxEXPAND, 0 );
    sizer1->Add( sizer2 );
    SetSizer( sizer1 );
Maybe the initial size is 0? But how does it happen?

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Empty wxListCtrl is not shown

Post by doublemax »

Try

Code: Select all

sizer1->Add( sizer2, 1, wxEXPAND );
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Empty wxListCtrl is not shown

Post by ONEEYEMAN »

doublemax,
I tried following code:

Code: Select all

    auto sizer1 = new wxBoxSizer( wxVERTICAL );
    auto sizer2 = new wxBoxSizer( wxHORIZONTAL );
    sizer1->Add( m_label, 0, wxEXPAND, 0 );
    sizer1->Add( 5, 5, 0, wxEXPAND, 0 );
    sizer2->Add( m_source, 1, wxEXPAND, 0 );
    sizer2->Add( m_dest, 1, wxEXPAND, 0 );
    sizer1->Add( sizer2, 1, wxEXPAND );
    SetSizer( sizer1 );
Attached are the result of running on both Windows and *nix (GTK).

Thank you.
Attachments
Screenshot for Windows.PNG
Screenshot for Windows.PNG (9.17 KiB) Viewed 887 times
Screenshot from 2020-01-06 18-18-27.png
Screenshot from 2020-01-06 18-18-27.png (22.88 KiB) Viewed 889 times
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Empty wxListCtrl is not shown

Post by doublemax »

I overlooked the wxLC_NO_HEADER flag.

I'd say the second list control is invisible under Windows, too. The only difference is that under Windows you can see the scrollbars on the left one. And AFAIK under some Linux desktops you only see the scrollbars if you hover over them. Could that be the case here?
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Empty wxListCtrl is not shown

Post by ONEEYEMAN »

doublemax,
At least under Windows I have a visible border for the right wxListCtrl.
On *nix - I don't.

What worries me most is that I won't be able to do DnD between them on *nix, since the control on the right is "not visible".

BTW, same thing happens on Mac as it also uses generic implementation.

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Empty wxListCtrl is not shown

Post by doublemax »

For testing I have only one old Linux installation in a VM, with wx3.0.4 and GTK2. It seems to work there.
linux-listctrl.gif
linux-listctrl.gif (12.66 KiB) Viewed 834 times
However, i had to set a default size, otherwise the left one grabbed too much space.

Code: Select all

wxPanel *panel = new wxPanel(this, wxID_ANY);

wxBoxSizer *main_sizer = new wxBoxSizer(wxHORIZONTAL);

  wxListCtrl *m_source = new wxListCtrl( panel, wxID_ANY, wxDefaultPosition, wxSize(80,-1), wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_NO_HEADER );
  m_source->SetBackgroundColour(*wxRED);
  main_sizer->Add(m_source, 1, wxEXPAND, 0);

  wxListCtrl* m_dest = new wxListCtrl( panel, wxID_ANY, wxDefaultPosition, wxSize(80,-1), wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_NO_HEADER );
  m_dest->SetBackgroundColour(*wxGREEN);
  main_sizer->Add(m_dest, 1, wxEXPAND, 0);

panel->SetSizer(main_sizer);
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Empty wxListCtrl is not shown

Post by ONEEYEMAN »

doublemax,
Thank you for testing.
So hopefully this is just a visual thing and the control is there.

I will try to see if the DnD will work tonight and hopefully close it.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Empty wxListCtrl is not shown

Post by ONEEYEMAN »

doublemax,
Everything is OK.
Looks like on *nix it just a missing border (visual cue).

Thank you.
Post Reply