wxListbook problem, not sizing correctly on Windows.

176 views
Skip to first unread message

Tony Kennedy

unread,
Feb 14, 2022, 9:44:07 AM2/14/22
to wx-users
I've got a problem where the listbook is not sizing correctly on Windows.

I've attached a couple of images, the box that displays the page list just just not wide enough (or tall enough if the font scaling is changed).

Is there an easy way to fix this? I've tried stepping through the code but could not figure out what to change.

Thanks in advance,

Tony.wxListbook_02.jpgwxListbook_01.jpg

Vadim Zeitlin

unread,
Feb 14, 2022, 5:41:24 PM2/14/22
to wx-u...@googlegroups.com
On Mon, 14 Feb 2022 06:44:07 -0800 (PST) Tony Kennedy wrote:

TK> I've got a problem where the listbook is not sizing correctly on Windows.

As always, it would be great to know what exactly do you do.

TK> I've attached a couple of images, the box that displays the page list just
TK> just not wide enough (or tall enough if the font scaling is changed).

Do you mean DPI scaling or just changing the font size?

TK> Is there an easy way to fix this?

I don't know. Having a patch reproducing the problem in the notebook
sample (which also shows listbook when the appropriate menu item is
selected) would be very helpful for answering this question.

Please try creating one and opening an issue if you can. TIA!
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Julian Novak

unread,
Feb 15, 2022, 2:20:10 PM2/15/22
to Tony Kennedy
I had the same problem, an unwanted horizontal scrollbar, on Windows XP and Windows 7 classic theme (!wxUxThemeIsActive()), but never looked into it in detail.

14.02.2022 15:44:14 Tony Kennedy <kenned...@gmail.com>:

> I've got a problem where the listbook is not sizing correctly on Windows.
>
> I've attached a couple of images, the box that displays the page list just just not wide enough (or tall enough if the font scaling is changed).
>
> Is there an easy way to fix this? I've tried stepping through the code but could not figure out what to change.
>
> Thanks in advance,
>
> Tony. [cid:86d1fb4e-d7d0-4ee3-bda9-1d89996219d7][wxListbook_02.jpg] [cid:967f6677-0d40-4703-aa6b-3474cc355ad5][wxListbook_01.jpg]
> --
> Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
> ---
> You received this message because you are subscribed to the Google Groups "wx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to wx-users+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/1761a3cf-a702-4d13-962e-63bc79b2f62bn%40googlegroups.com[https://groups.google.com/d/msgid/wx-users/1761a3cf-a702-4d13-962e-63bc79b2f62bn%40googlegroups.com?utm_medium=email&utm_source=footer].
wxListbook_02.jpg
wxListbook_01.jpg

Tony Kennedy

unread,
May 23, 2023, 11:13:27 AM5/23/23
to wx-users
Coming back to this, I think the list sizes itself based on the icon size in the attached image list. If I make the icons larger, things improve quite a bit.

I'll see if I can modify the notebook sample.

Tony Kennedy

unread,
May 23, 2023, 11:25:45 AM5/23/23
to wx-users
The notebook sample already shows one problem. The "Radiobuttons" tab wraps the label "Radiobuttons" across two lines.

notebookproblem1.jpg

The second issue, if I change
const wxSize imageSize(32, 32);
to 
const wxSize imageSize(16, 16);

Then you get the horizonal scroll bar.

notebookproblem2.jpg

Tony Kennedy

unread,
May 23, 2023, 11:30:13 AM5/23/23
to wx-users
I think the internal wxListCtrl is sizing itself based on the icon size, and ignoring the text.

I'm not sure what function within the wxListCtrl class to take a look at though and attempt a fix.





Andrea Asztalos

unread,
Nov 28, 2023, 10:41:50 AM11/28/23
to wx-users
Hello,
I've just run into the same issue and it is Windows specific.
If the wxListBook has the wxLB_TOP flag, and no images are tied to the list items, the text is simply not visible. Specifically, the height of the list ctrl is very narrow while the width seems to be ok.
Once images are tied to the control, everything works fine.

void CHelloWorldDlg::CreateControls()
{

    CHelloWorldDlg* itemDialog1 = this;
   
    wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
    itemDialog1->SetSizer(sizer);
   
    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
    sizer->Add(itemBoxSizer2, 0, wxALIGN_LEFT | wxALL, 5);
   
    wxStaticText* itemStaticText3 = new wxStaticText( itemDialog1, wxID_STATIC, _("Hello World!"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer2->Add(itemStaticText3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
   
    itemBoxSizer2->Add(50, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
   
    wxButton* itemButton5 = new wxButton( itemDialog1, wxID_CANCEL, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer2->Add(itemButton5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
   
    m_listbook = new wxListbook(itemDialog1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLB_TOP);
    sizer->Add(m_listbook, 1, wxEXPAND, 0);
   
    wxPanel* p1 = new wxPanel(m_listbook, wxID_ANY, wxDefaultPosition, wxSize(300, 300));
    p1->SetBackgroundColour(wxColour("MAROON"));
    m_listbook->AddPage(p1, wxT("First page"));

    wxPanel* p2 = new wxPanel(m_listbook, wxID_ANY, wxDefaultPosition, wxSize(300, 300));
    p2->SetBackgroundColour(wxColour("RED"));
    m_listbook->AddPage(p2, wxT("Second_page"));

}

Any ideas are appreciated how to fix it.
Thank you,
Andrea Asztalos

Vadim Zeitlin

unread,
Dec 2, 2023, 12:17:01 PM12/2/23
to wx-u...@googlegroups.com
On Tue, 28 Nov 2023 07:41:50 -0800 (PST) Andrea Asztalos wrote:

AA> I've just run into the same issue and it is Windows specific.
AA> If the wxListBook has the wxLB_TOP flag, and no images are tied to the list
AA> items, the text is simply not visible. Specifically, the height of the list
AA> ctrl is very narrow while the width seems to be ok.

Just for the reference, thanks to PB, there is now an issue for this at

https://github.com/wxWidgets/wxWidgets/issues/24110

I don't have time to look at this right now, unfortunately, but I might
find it in the future and at least it won't get lost/forgotten like this.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
https://www.tt-solutions.com/

Andrea Asztalos

unread,
Dec 3, 2023, 9:36:33 PM12/3/23
to wx-users
Thank you Vadim for letting me know.
PB was kind enough and he created the GitHub issue. 
I found a workaround by attaching empty images to each pages in wxListbook. It's not as neat as it used to be, but the label is readable to the user.

Best regards,
Andrea Asztalos

Reply all
Reply to author
Forward
0 new messages