wxDataViewListCtrl bug about scrollbar

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
Ronald
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Mar 05, 2018 4:17 am

wxDataViewListCtrl bug about scrollbar

Post by Ronald » Sat Feb 09, 2019 6:01 am

I can't upload image on https://trac.wxwidgets.org, so I posted here for a image link. trac: https://trac.wxwidgets.org/ticket/18343
Capture.PNG
Capture.PNG (6.72 KiB) Viewed 509 times
MainFrame.h

Code: Select all

#pragma once

class MainFrame : public wxFrame
{
    DECLARE_EVENT_TABLE()
public:
    MainFrame(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(709, 463), long style = wxDEFAULT_FRAME_STYLE);
    ~MainFrame();
private:
    void InitDataViewListCtrl(wxDataViewListCtrl * dvlc);
private:
    wxDataViewListCtrl * dvlc;
};
MainFrame.cpp

Code: Select all

#include "stdafx.h"
#include "MainFrame.h"

BEGIN_EVENT_TABLE(MainFrame, wxFrame)
END_EVENT_TABLE()

MainFrame::MainFrame(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style)
{
    wxBoxSizer * sizer = new wxBoxSizer(wxVERTICAL);
    dvlc = new wxDataViewListCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(400, 100));
    InitDataViewListCtrl(dvlc);
    sizer->Add(dvlc, 1);
    SetSizer(sizer);
}

MainFrame::~MainFrame()
{
}

void MainFrame::InitDataViewListCtrl(wxDataViewListCtrl * dvlc)
{
    wxDataViewColumn * col = nullptr;
    dvlc->AppendTextColumn(L"aaa");
    dvlc->AppendTextColumn(L"bbb");
    dvlc->AppendTextColumn(L"ccc");
    dvlc->AppendTextColumn(L"ddd");
    dvlc->AppendTextColumn(L"eee");

    wxVector<wxVariant> data;
    data.push_back("aaaaaaaa");
    data.push_back("bbbbbbbb");
    data.push_back("cccccccc");
    data.push_back("dddddddd");
    data.push_back("eeeeeeee");
    dvlc->AppendItem(data);    
}

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2005
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxDataViewListCtrl bug about scrollbar

Post by PB » Sat Feb 09, 2019 8:00 am

I just skimmed through the post, but where is the bug? According to the screenshot, there is no reason to display scrollbars, all the columns are fully displayed (fit to the control's width), the value of the last one being ellipsized (you can see the right border of the last column)? The horizontal scrollbar logically appears only when necessary, i.e., the sum of columns' widths < the control's width, this is not the case in the screenshot.

You can see that the scrollbar appear when you pass a long width when appending a column:

Code: Select all

#include <wx/wx.h>
#include <wx/dataview.h>

class MyFrame : public wxFrame
{
public:
    MyFrame() : wxFrame(NULL, wxID_ANY, "Test")
    {               
        wxDataViewListCtrl* dvlc = new wxDataViewListCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(400, 100));
        
        dvlc->AppendTextColumn("aaa");
        dvlc->AppendTextColumn("bbb");
        dvlc->AppendTextColumn("ccc");
        dvlc->AppendTextColumn("ddd");
        dvlc->AppendTextColumn("eee", wxDATAVIEW_CELL_INERT, 300);

        wxVector<wxVariant> data;
        
        data.push_back("aaaaaaaa");
        data.push_back("bbbbbbbb");
        data.push_back("cccccccc");
        data.push_back("dddddddd");
        data.push_back("eeeeeeee");
        dvlc->AppendItem(data);
    }
};

class MyApp : public wxApp
{
public:	
	bool OnInit()
	{
        wxInitAllImageHandlers();
        (new MyFrame)->Show();
        return true;
	}
}; wxIMPLEMENT_APP(MyApp);
dvcscroll.png
dvcscroll.png (2.52 KiB) Viewed 500 times
Last edited by PB on Sat Feb 09, 2019 8:08 am, edited 1 time in total.

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

Re: wxDataViewListCtrl bug about scrollbar

Post by doublemax » Sat Feb 09, 2019 8:08 am

You also didn't let the control expand in horizontal direction.

Replace

Code: Select all

sizer->Add(dvlc, 1);
with

Code: Select all

sizer->Add(dvlc, 1, wxEXPAND);
Use the source, Luke!

Ronald
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Mar 05, 2018 4:17 am

Re: wxDataViewListCtrl bug about scrollbar

Post by Ronald » Sat Feb 09, 2019 8:11 am

PB wrote:The horizontal scrollbar logically appears only when necessary, i.e., the sum of columns' widths < the control's width, this is not the case in the screenshot.
When the sum of columns' width is not enough, still no horizontal scrollbar.

original
Capture1.PNG
Capture1.PNG (5.12 KiB) Viewed 492 times
after resizing manually
Capture2.PNG
Capture2.PNG (3.35 KiB) Viewed 492 times
Last edited by Ronald on Sat Feb 09, 2019 8:20 am, edited 1 time in total.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2005
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxDataViewListCtrl bug about scrollbar

Post by PB » Sat Feb 09, 2019 8:14 am

What wxWidgets version you have, the behaviour regarding the last column width in wxDVC was changed not so long ago, see e.g.
https://github.com/wxWidgets/wxWidgets/ ... af0771f21c
https://github.com/wxWidgets/wxWidgets/ ... 076a11e257

I used the master for my test above.

EDIT
The width of the column is not the same as the width of the strings displayed in the column header or rows. You can see whether the column is fully displayed when you see the line of the right border of its head. If you need a different column width you need to adjust it.
Last edited by PB on Sat Feb 09, 2019 8:19 am, edited 1 time in total.

Ronald
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Mar 05, 2018 4:17 am

Re: wxDataViewListCtrl bug about scrollbar

Post by Ronald » Sat Feb 09, 2019 8:19 am

doublemax wrote:You also didn't let the control expand in horizontal direction.

Replace

Code: Select all

sizer->Add(dvlc, 1);
with

Code: Select all

sizer->Add(dvlc, 1, wxEXPAND);
It's fine, but there is a bug
Capture3.PNG
Capture3.PNG (5.36 KiB) Viewed 481 times

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2005
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxDataViewListCtrl bug about scrollbar

Post by PB » Sat Feb 09, 2019 8:24 am

Ronald wrote:It's fine, but there is a bug
Once again, wxWidgets version? As I already wrote above, I believe there were quite a few changes regarding the last column resizing
https://github.com/wxWidgets/wxWidgets/ ... pe=Commits

I.e., can you reproduce "the bug" with the GIT master head?

Ronald
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Mar 05, 2018 4:17 am

Re: wxDataViewListCtrl bug about scrollbar

Post by Ronald » Sat Feb 09, 2019 10:18 am

PB wrote:What wxWidgets version you have
3.1.2
PB wrote: The width of the column is not the same as the width of the strings displayed in the column header or rows. You can see whether the column is fully displayed when you see the line of the right border of its head. If you need a different column width you need to adjust it.
In my last, the first image shows that the total wxDataViewCtrl shows as expected, but when I resize the frame, the horizontal scrollbar doesn't show until the last-1 col (titled "ddd") has not enough space to show.

BTW, I'm trying the master commit of git repository.

Ronald
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Mar 05, 2018 4:17 am

Re: wxDataViewListCtrl bug about scrollbar

Post by Ronald » Sat Feb 09, 2019 11:30 am

PB wrote:
Ronald wrote:It's fine, but there is a bug
Once again, wxWidgets version? As I already wrote above, I believe there were quite a few changes regarding the last column resizing
https://github.com/wxWidgets/wxWidgets/ ... pe=Commits

I.e., can you reproduce "the bug" with the GIT master head?
This bug doesn't exist in the master commit
Image

However, the bug about scroll bar remains the same.

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

Re: wxDataViewListCtrl bug about scrollbar

Post by doublemax » Sat Feb 09, 2019 12:32 pm

...but when I resize the frame, the horizontal scrollbar doesn't show until the last-1 col (titled "ddd") has not enough space to show.
Please add this to the ticket on Trac. Before that it wasn't clear (at least to me) what the bug was.
Use the source, Luke!

Ronald
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Mar 05, 2018 4:17 am

Re: wxDataViewListCtrl bug about scrollbar

Post by Ronald » Sat Feb 09, 2019 2:41 pm

doublemax wrote:
...but when I resize the frame, the horizontal scrollbar doesn't show until the last-1 col (titled "ddd") has not enough space to show.
Please add this to the ticket on Trac. Before that it wasn't clear (at least to me) what the bug was.
added

Post Reply