Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

MSW, wxListbook: why the icons are shifted in the listview control

321 views
Skip to first unread message

AsmWarrior

unread,
Jan 9, 2016, 8:55:22 AM1/9/16
to wx-users
Hi, when migration CodeBlocks' base library from wx 2.8 to wx3.0.2, I meet a layout issue, that is the icons in the listbook is not in the center of the listview. Please have a look at the image below. The left image is a screen shot from the wx 3.0.2(or wx trunk) build of C::B, and the right image is from a wx2.8 build of C::B.

When I test the wx trunk's sample notebook, it does not have the layout issue. So, my question is: what cause such layout issue? Thanks?

BTW: the full issue is explained in a C::B's ticket, see:https://sourceforge.net/p/codeblocks/tickets/234/, I even wrote a very simple listbook which have only one panel, but the opened wxListbook still have such issue if opened inside C::B.

Thanks.

Asmwarrior

Vadim Zeitlin

unread,
Jan 14, 2016, 10:29:05 AM1/14/16
to wx-u...@googlegroups.com
On Sat, 9 Jan 2016 05:55:22 -0800 (PST) AsmWarrior wrote:

A> Hi, when migration CodeBlocks' base library from wx 2.8 to wx3.0.2, I meet
A> a layout issue, that is the icons in the listbook is not in the center of
A> the listview. Please have a look at the image below. The left image is a
A> screen shot from the wx 3.0.2(or wx trunk) build of C::B, and the right
A> image is from a wx2.8 build of C::B.
A>
A> When I test the wx trunk's sample notebook, it does not have the layout
A> issue. So, my question is: what cause such layout issue? Thanks?

I suspect the fact that the listbook is created initially without the
images and they are added to it later (if I understood the C::B ticket
correctly) triggers the problem, but I have no idea why.

Have you tried adding a PostSizeEvent() call to see if it can help to work
around the problem? If it doesn't, it would be really great if you could
find a way to reproduce this in the notebook or, perhaps, the xrc sample so
that I could debug it there.

Thanks,
VZ

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

asmwarrior

unread,
Jan 14, 2016, 8:04:48 PM1/14/16
to wx-u...@googlegroups.com
On 2016-1-14 23:28, Vadim Zeitlin wrote:
> On Sat, 9 Jan 2016 05:55:22 -0800 (PST) AsmWarrior wrote:
>
> A> Hi, when migration CodeBlocks' base library from wx 2.8 to wx3.0.2, I meet
> A> a layout issue, that is the icons in the listbook is not in the center of
> A> the listview. Please have a look at the image below. The left image is a
> A> screen shot from the wx 3.0.2(or wx trunk) build of C::B, and the right
> A> image is from a wx2.8 build of C::B.
> A>
> A> When I test the wx trunk's sample notebook, it does not have the layout
> A> issue. So, my question is: what cause such layout issue? Thanks?
>
> I suspect the fact that the listbook is created initially without the
> images and they are added to it later (if I understood the C::B ticket
> correctly) triggers the problem, but I have no idea why.

Thanks for the reply. You are 100% correct here. Our C::B's menu event handler looks like below:

void MainFrame::OnSettingsEditor(cb_unused wxCommandEvent& event)
{
EditorConfigurationDlg dlg(Manager::Get()->GetAppWindow());
// dlg.SendSizeEvent(wxSEND_EVENT_POST);
// dlg.SendSizeEvent();

if (dlg.ShowModal() == wxID_OK)
{
......
}
}

In the constructor of the EditorConfigurationDlg, it load the XRC file(at this time, only text in listview, no icons is added), and after that, we set the images by calling SetPageImage() function of wxListBook, and later SetImageList(). Whether first call SetImageList(), and later call
SetPageImage() or call them in reverse order does not change the issue status.

>
> Have you tried adding a PostSizeEvent() call to see if it can help to work
> around the problem? If it doesn't, it would be really great if you could
> find a way to reproduce this in the notebook or, perhaps, the xrc sample so
> that I could debug it there.
>
>
Adding PostSizeEvent() call with arguments 0 or wxSEND_EVENT_POST does not solve my problem. Also, I have already created a small wxDialog based app. That is: when I hit a button on the dialog, a new wxDialog opened and loads the whole XRC file(which is the same thing used in the C::B) is loaded, I also post the screen shot in C::B ticket, see(https://sourceforge.net/p/codeblocks/tickets/_discuss/thread/81546138/bcbc/attachment/wx-sample-show-listbook-xrc.png)and the strange thing is, I can't reproduce such issue. I have have tested the wx's notebook sample, and it still can't expose this issue.

In our C::B's code, I can even reduce the XRC file used in EditorConfigurationDlg to only one panel with one button, but the issue still happens, see the imageshot(https://sourceforge.net/p/codeblocks/tickets/_discuss/thread/81546138/84a5/attachment/a-simple-listbook-error.png)

So, I really don't know how to reproduce this bug to a simple wx code, sorry.

Thanks.
Asmwarrior


Vadim Zeitlin

unread,
Jan 16, 2016, 7:29:03 AM1/16/16
to wx-u...@googlegroups.com
On Fri, 15 Jan 2016 09:17:47 +0800 asmwarrior wrote:

a> In the constructor of the EditorConfigurationDlg, it load the XRC
a> file(at this time, only text in listview, no icons is added), and after
a> that, we set the images by calling SetPageImage() function of
a> wxListBook, and later SetImageList(). Whether first call SetImageList(),
a> and later call SetPageImage() or call them in reverse order does not
a> change the issue status.

In principle, you must call SetImageList() first so that the code could
(even if it doesn't do it now) verify that correct image indexes are used.
Also, if you look at wxListbook::GetListCtrlFlags() you can see that it
does different things depending on whether there is an image list or not,
so maybe you should try defining a dummy image list in XRC (and replace it
with the real one later) to work around the problem?

a> So, I really don't know how to reproduce this bug to a simple wx code,
a> sorry.

It will have to be debugged in C::B itself then, but not by me, I'm
afraid. To begin with, you probably want to look at what does
wxListCtrl::MSWGetBestViewRect() return.

Good luck,

asmwarrior

unread,
Jan 17, 2016, 9:46:40 AM1/17/16
to wx-u...@googlegroups.com
Hi, VZ, thanks, I just did what you suggested, and I create a very tiny XRC file which contains a wxListBook, with one panel and one icon.
I even't don't call any function, just load the XRC file when in the constructor of the dialog. I still see difference when the dialog is opened from a tiny wx sample and the C::B.

Here is the image shot when opened from tiny wx sample, looks quite good



Here is the image shot when opened from C::B's menu event handler



Look, it is already different. The second image shot shows the issue now.

BTW, I see some alert when open the dialog from the C::B. One is:



If I click the "Cancel", the dialog just opened, but the icon is not shown quite well(as you can see in the second image shot).
Now, when I click the "X" button in the dialog, the whole C::B hangs. I don't know the reason, but maybe, the Debug Alert shows something, but I really don't know what does this Debug Alert means. (I'm building both wx sample program and C::B against wx git master head).

In the attachment, there is an XRC file and the dummy png file.

Thanks.

Asmwarrior



NewDialog.xrc
compiler.png

Vadim Zeitlin

unread,
Jan 18, 2016, 9:43:42 AM1/18/16
to wx-u...@googlegroups.com
On Sun, 17 Jan 2016 22:59:37 +0800 asmwarrior wrote:

a> Here is the image shot when opened from C::B's menu event handler
a>
a> Look, it is already different.

I have no idea how is this possible :-( Could you be using a modified
version of wxListbook or its XRC handler in C::B?

a> BTW, I see some alert when open the dialog from the C::B.
[A hint: press Ctrl+C to copy the message box test instead of making a
screen shot, this is faster]

This is definitely a problem. You need to break into the debugger and find
out why is AddChild() being called twice.

Regards,

asmwarrior

unread,
Jan 19, 2016, 7:54:01 AM1/19/16
to wx-u...@googlegroups.com
On 2016-1-18 22:43, Vadim Zeitlin wrote:
> On Sun, 17 Jan 2016 22:59:37 +0800 asmwarrior wrote:
>
> a> Here is the image shot when opened from C::B's menu event handler
> a>
> a> Look, it is already different.
>
> I have no idea how is this possible :-( Could you be using a modified
> version of wxListbook or its XRC handler in C::B?

Thanks for the reply. It looks like this issue is NOT related the XRC handler in C::B, because I can reproduce this issue by just running C++ code inside the constructor of the dialog, such as:

MyDialog1::MyDialog1( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );

wxBoxSizer* bSizer1;
bSizer1 = new wxBoxSizer( wxVERTICAL );

m_listbook1 = new wxListbook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLB_DEFAULT );
wxSize m_listbook1ImageSize = wxSize( 80,80 );
int m_listbook1Index = 0;
wxImageList* m_listbook1Images = new wxImageList( m_listbook1ImageSize.GetWidth(), m_listbook1ImageSize.GetHeight() );
m_listbook1->AssignImageList( m_listbook1Images );
wxBitmap m_listbook1Bitmap;
wxImage m_listbook1Image;
m_panel6 = new wxPanel( m_listbook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_listbook1->AddPage( m_panel6, wxT("hihiihi"), false );
m_listbook1Bitmap = wxBitmap( wxT("compiler.png"), wxBITMAP_TYPE_ANY );
if ( m_listbook1Bitmap.Ok() )
{
m_listbook1Image = m_listbook1Bitmap.ConvertToImage();
m_listbook1Images->Add( m_listbook1Image.Scale( m_listbook1ImageSize.GetWidth(), m_listbook1ImageSize.GetHeight() ) );
m_listbook1->SetPageImage( m_listbook1Index, m_listbook1Index );
m_listbook1Index++;
}

bSizer1->Add( m_listbook1, 1, wxEXPAND | wxALL, 5 );


this->SetSizer( bSizer1 );
this->Layout();

this->Centre( wxBOTH );
}


The the result dialog also have shifted icons, but at this time, I don't see the alert message box shown, and close the dialog dose not hang the C::B.


>
> a> BTW, I see some alert when open the dialog from the C::B.
> [A hint: press Ctrl+C to copy the message box test instead of making a
> screen shot, this is faster]

Thanks, I never know CTRL+C in the message box can copy the text content. Just tried and it works fine.


>
> This is definitely a problem. You need to break into the debugger and find
> out why is AddChild() being called twice.
>

This may be a little beyond my ability, because I need to at least know all the logic about window construction.
But I will try it.

BTW, I have reported some wx bug in wx-user maillist:
help: wired crash issue which only happens in Windows XP system with release build of wx 3.0.2
https://groups.google.com/d/topic/wx-users/6sAlKVVpQiI/discussion

Maybe, this is an related issue under WinXP, currently I can only tested on WinXP.

Asmwarrior


Vadim Zeitlin

unread,
Jan 20, 2016, 12:32:06 PM1/20/16
to wx-u...@googlegroups.com
On Tue, 19 Jan 2016 21:07:04 +0800 asmwarrior wrote:

a> Thanks for the reply. It looks like this issue is NOT related the XRC
a> handler in C::B, because I can reproduce this issue by just running C++
a> code inside the constructor of the dialog, such as:

Thanks, this is useful to know as we can eliminate a lot of things from
consideration now.

But, just to be sure: if you use this code in e.g. the minimal sample it
still doesn't show the problem? This seems completely incredible :-(

asmwarrior

unread,
Jan 20, 2016, 7:58:14 PM1/20/16
to wx-u...@googlegroups.com
On 2016-1-21 1:31, Vadim Zeitlin wrote:
> On Tue, 19 Jan 2016 21:07:04 +0800 asmwarrior wrote:
>
> a> Thanks for the reply. It looks like this issue is NOT related the XRC
> a> handler in C::B, because I can reproduce this issue by just running C++
> a> code inside the constructor of the dialog, such as:
>
> Thanks, this is useful to know as we can eliminate a lot of things from
> consideration now.
>
> But, just to be sure: if you use this code in e.g. the minimal sample it
> still doesn't show the problem? This seems completely incredible :-(
>
> VZ
>
Hi, VZ, thanks.
I just created a very simple wx minimal sample, and when I click on the menu item, I just open the wxDialog.
I use the C++ code to construct this dialog, so no XRC related code.

You have to add two member declaration inside the Header file, such as:

wxListbook *m_listbook1;
wxPanel *m_panel6;

I see that the application just crashed. It has such call stack

Program received signal SIGSEGV, Segmentation fault.
At F:\wx\wxWidgets_trunk\src\generic\listbkg.cpp:277
----------------------------------------------
[debug]> bt 30
[debug]#0 0x00829369 in wxListbook::SetImageList (this=0xe891338, imageList=0xe88c9b8) at F:\wx\wxWidgets_trunk\src\generic\listbkg.cpp:277
[debug]#1 0x004051a9 in wxWithImages::AssignImageList (this=0xe8914c4, imageList=0xe88c9b8) at F:\wx\wxWidgets_trunk\include\wx\withimages.h:50
[debug]#2 0x004017e2 in NewDialog::NewDialog (this=0x22f424, parent=0xe8d5d58) at D:\temp\test-listbook-load-xrc2\NewDialog.cpp:241
[debug]#3 0x00402840 in test_listbook_load_xrc2Frame::OnAbout (this=0xe8d5d58, event=...) at D:\temp\test-listbook-load-xrc2\test_listbook_load_xrc2Main.cpp:106
[debug]#4 0x005a387a in wxAppConsoleBase::HandleEvent (this=0xe83b898, handler=0xe8d5d58, func=(void (wxEvtHandler::*)(wxEvtHandler * const, wxEvent &)) 0x40281a <test_listbook_load_xrc2Frame::OnAbout(wxCommandEvent&)>, event=...) at F:\wx\wxWidgets_trunk\src\common\appbase.cpp:657
[debug]#5 0x005a38d6 in wxAppConsoleBase::CallEventHandler (this=0xe83b898, handler=0xe8d5d58, functor=..., event=...) at F:\wx\wxWidgets_trunk\src\common\appbase.cpp:669
[debug]#6 0x0066c4cf in wxEvtHandler::ProcessEventIfMatchesId (entry=..., handler=0xe8d5d58, event=...) at F:\wx\wxWidgets_trunk\src\common\event.cpp:1381
[debug]#7 0x0066b507 in wxEventHashTable::HandleEvent (this=0x41308c <test_listbook_load_xrc2Frame::sm_eventHashTable>, event=..., self=0xe8d5d58) at F:\wx\wxWidgets_trunk\src\common\event.cpp:989
[debug]#8 0x0066c93f in wxEvtHandler::TryHereOnly (this=0xe8d5d58, event=...) at F:\wx\wxWidgets_trunk\src\common\event.cpp:1578
[debug]#9 0x00cb6c04 in wxEvtHandler::TryBeforeAndHere (this=0xe8d5d58, event=...) at F:\wx\wxWidgets_trunk\include\wx\event.h:3662
[debug]#10 0x0066c78b in wxEvtHandler::ProcessEventLocally (this=0xe8d5d58, event=...) at F:\wx\wxWidgets_trunk\src\common\event.cpp:1511
[debug]#11 0x0066c72c in wxEvtHandler::ProcessEvent (this=0xe8d5d58, event=...) at F:\wx\wxWidgets_trunk\src\common\event.cpp:1484
[debug]#12 0x0081084f in wxWindowBase::TryAfter (this=0xe889bf0, event=...) at F:\wx\wxWidgets_trunk\src\common\wincmn.cpp:3468
[debug]#13 0x0066c757 in wxEvtHandler::ProcessEvent (this=0xe889bf0, event=...) at F:\wx\wxWidgets_trunk\src\common\event.cpp:1497
[debug]#14 0x0066c9cb in wxEvtHandler::SafelyProcessEvent (this=0xe889bf0, event=...) at F:\wx\wxWidgets_trunk\src\common\event.cpp:1602
[debug]#15 0x0080b89c in wxWindowBase::HandleWindowEvent (this=0xe889bf0, event=...) at F:\wx\wxWidgets_trunk\src\common\wincmn.cpp:1542
[debug]#16 0x007d1419 in wxMenuBase::DoProcessEvent (menu=0xe890d88, event=..., win=0xe8d5d58) at F:\wx\wxWidgets_trunk\src\common\menucmn.cpp:676
[debug]#17 0x007d1362 in wxMenuBase::SendEvent (this=0xe890d88, itemid=101, checked=-1) at F:\wx\wxWidgets_trunk\src\common\menucmn.cpp:646
[debug]#18 0x00794851 in wxFrameBase::ProcessCommand (this=0xe8d5d58, item=0xe890e50) at F:\wx\wxWidgets_trunk\src\common\framecmn.cpp:294
[debug]#19 0x0070585e in wxFrame::HandleCommand (this=0xe8d5d58, id=101, cmd=0, control=0x0) at F:\wx\wxWidgets_trunk\src\msw\frame.cpp:799
[debug]#20 0x00705a58 in wxFrame::MSWWindowProc (this=0xe8d5d58, message=273, wParam=101, lParam=0) at F:\wx\wxWidgets_trunk\src\msw\frame.cpp:849
[debug]#21 0x006da75f in wxWndProc(HWND__*, unsigned int, unsigned int, long)@16 (hWnd=0x60178, message=273, wParam=101, lParam=0) at F:\wx\wxWidgets_trunk\src\msw\window.cpp:2649
[debug]#22 0x7e418734 in USER32!GetDC () from C:\WINDOWS\system32\user32.dll
[debug]#23 0x00060178 in ?? ()
[debug]#24 0x00000111 in ?? ()
[debug]#25 0x00000065 in ?? ()
[debug]#26 0x00000000 in ?? ()
[debug]>>>>>>cb_gdb:

----------------------------------------------
NOTE that I see the in the function:

----------------------------------------------
void wxListbook::SetImageList(wxImageList *imageList)
{
const long flagsOld = GetListCtrlFlags();

wxBookCtrlBase::SetImageList(imageList);

const long flagsNew = GetListCtrlFlags();

wxListView * const list = GetListView();

// We may need to change the list control mode if the image list presence
// has changed.
if ( flagsNew != flagsOld )
{
// Preserve the selection which is lost when changing the mode
const int oldSel = GetSelection();

list->SetWindowStyleFlag(flagsNew);
if ( list->InReportView() )
list->InsertColumn(0, wxS("Pages"));

// Restore selection
if ( oldSel != wxNOT_FOUND )
SetSelection(oldSel);
}

list->SetImageList(imageList, wxIMAGE_LIST_NORMAL);
}

----------------------------------------------
The list is just NULL.

BTW: I'm using wx git master HEAD version, which I cloned at 2015-12-27.
I first guess that the function call

m_listbook1->AssignImageList( m_listbook1Images );

should be put after initialization of m_listbook1Images, but If I adjust the code to something like below:

----------------------------------------------
this->SetSizeHints( wxDefaultSize, wxDefaultSize );

wxBoxSizer* bSizer1;
bSizer1 = new wxBoxSizer( wxVERTICAL );

m_listbook1 = new wxListbook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLB_DEFAULT );
wxSize m_listbook1ImageSize = wxSize( 80,80 );
int m_listbook1Index = 0;
wxImageList* m_listbook1Images = new wxImageList( m_listbook1ImageSize.GetWidth(), m_listbook1ImageSize.GetHeight() );
//m_listbook1->AssignImageList( m_listbook1Images );
wxBitmap m_listbook1Bitmap;
wxImage m_listbook1Image;
m_panel6 = new wxPanel( m_listbook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_listbook1->AddPage( m_panel6, wxT("hihiihi"), false );
m_listbook1Bitmap = wxBitmap( wxT("compiler.png"), wxBITMAP_TYPE_ANY );


m_listbook1Image = m_listbook1Bitmap.ConvertToImage();
m_listbook1Images->Add( m_listbook1Image.Scale( m_listbook1ImageSize.GetWidth(), m_listbook1ImageSize.GetHeight() ) );

m_listbook1->AssignImageList( m_listbook1Images );

m_listbook1->SetPageImage( m_listbook1Index, m_listbook1Index );
m_listbook1Index++;


bSizer1->Add( m_listbook1, 1, wxEXPAND | wxALL, 5 );


this->SetSizer( bSizer1 );
this->Layout();

this->Centre( wxBOTH );

----------------------------------------------
The crash still happens due to the empty pointer. The crash call stack is:

[debug]> bt 30
[debug]#0 0x00d9079c in wxWindowBase::HasFlag (this=0x0, flag=512) at F:\wx\wxWidgets_trunk\include\wx\window.h:668
[debug]#1 0x00d944ee in wxListCtrlBase::IsVirtual (this=0x0) at F:\wx\wxWidgets_trunk\include\wx\listbase.h:453
[debug]#2 0x0070f19a in wxListCtrl::InsertItem (this=0x0, info=...) at F:\wx\wxWidgets_trunk\src\msw\listctrl.cpp:1684
[debug]#3 0x0070f4ae in wxListCtrl::InsertItem (this=0x0, index=0, label=L"hihiihi", imageIndex=-1) at F:\wx\wxWidgets_trunk\src\msw\listctrl.cpp:1751
[debug]#4 0x008295bc in wxListbook::InsertPage (this=0xe891338, n=0, page=0xe88c078, text=L"hihiihi", bSelect=false, imageId=-1) at F:\wx\wxWidgets_trunk\src\generic\listbkg.cpp:325
[debug]#5 0x00cc9d83 in wxBookCtrlBase::AddPage (this=0xe891338, page=0xe88c078, text=L"hihiihi", bSelect=false, imageId=-1) at F:\wx\wxWidgets_trunk\include\wx\bookctrl.h:186
[debug]#6 0x004018c9 in NewDialog::NewDialog (this=0x22f424, parent=0xe8d5d58) at D:\temp\test-listbook-load-xrc2\NewDialog.cpp:210
[debug]#7 0x0040282c in test_listbook_load_xrc2Frame::OnAbout (this=0xe8d5d58, event=...) at D:\temp\test-listbook-load-xrc2\test_listbook_load_xrc2Main.cpp:106
[debug]#8 0x005a387a in wxAppConsoleBase::HandleEvent (this=0xe83b898, handler=0xe8d5d58, func=(void (wxEvtHandler::*)(wxEvtHandler * const, wxEvent &)) 0x402806 <test_listbook_load_xrc2Frame::OnAbout(wxCommandEvent&)>, event=...) at F:\wx\wxWidgets_trunk\src\common\appbase.cpp:657
[debug]#9 0x005a38d6 in wxAppConsoleBase::CallEventHandler (this=0xe83b898, handler=0xe8d5d58, functor=..., event=...) at F:\wx\wxWidgets_trunk\src\common\appbase.cpp:669
[debug]#10 0x0066c4cf in wxEvtHandler::ProcessEventIfMatchesId (entry=..., handler=0xe8d5d58, event=...) at F:\wx\wxWidgets_trunk\src\common\event.cpp:1381
[debug]#11 0x0066b507 in wxEventHashTable::HandleEvent (this=0x41308c <test_listbook_load_xrc2Frame::sm_eventHashTable>, event=..., self=0xe8d5d58) at F:\wx\wxWidgets_trunk\src\common\event.cpp:989
[debug]#12 0x0066c93f in wxEvtHandler::TryHereOnly (this=0xe8d5d58, event=...) at F:\wx\wxWidgets_trunk\src\common\event.cpp:1578
[debug]#13 0x00cb6c04 in wxEvtHandler::TryBeforeAndHere (this=0xe8d5d58, event=...) at F:\wx\wxWidgets_trunk\include\wx\event.h:3662
[debug]#14 0x0066c78b in wxEvtHandler::ProcessEventLocally (this=0xe8d5d58, event=...) at F:\wx\wxWidgets_trunk\src\common\event.cpp:1511
[debug]#15 0x0066c72c in wxEvtHandler::ProcessEvent (this=0xe8d5d58, event=...) at F:\wx\wxWidgets_trunk\src\common\event.cpp:1484
[debug]#16 0x0081084f in wxWindowBase::TryAfter (this=0xe889bf0, event=...) at F:\wx\wxWidgets_trunk\src\common\wincmn.cpp:3468
[debug]#17 0x0066c757 in wxEvtHandler::ProcessEvent (this=0xe889bf0, event=...) at F:\wx\wxWidgets_trunk\src\common\event.cpp:1497
[debug]#18 0x0066c9cb in wxEvtHandler::SafelyProcessEvent (this=0xe889bf0, event=...) at F:\wx\wxWidgets_trunk\src\common\event.cpp:1602
[debug]#19 0x0080b89c in wxWindowBase::HandleWindowEvent (this=0xe889bf0, event=...) at F:\wx\wxWidgets_trunk\src\common\wincmn.cpp:1542
[debug]#20 0x007d1419 in wxMenuBase::DoProcessEvent (menu=0xe890d88, event=..., win=0xe8d5d58) at F:\wx\wxWidgets_trunk\src\common\menucmn.cpp:676
[debug]#21 0x007d1362 in wxMenuBase::SendEvent (this=0xe890d88, itemid=101, checked=-1) at F:\wx\wxWidgets_trunk\src\common\menucmn.cpp:646
[debug]#22 0x00794851 in wxFrameBase::ProcessCommand (this=0xe8d5d58, item=0xe890e50) at F:\wx\wxWidgets_trunk\src\common\framecmn.cpp:294
[debug]#23 0x0070585e in wxFrame::HandleCommand (this=0xe8d5d58, id=101, cmd=0, control=0x0) at F:\wx\wxWidgets_trunk\src\msw\frame.cpp:799
[debug]#24 0x00705a58 in wxFrame::MSWWindowProc (this=0xe8d5d58, message=273, wParam=101, lParam=0) at F:\wx\wxWidgets_trunk\src\msw\frame.cpp:849
[debug]#25 0x006da75f in wxWndProc(HWND__*, unsigned int, unsigned int, long)@16 (hWnd=0xd013a, message=273, wParam=101, lParam=0) at F:\wx\wxWidgets_trunk\src\msw\window.cpp:2649
[debug]#26 0x7e418734 in USER32!GetDC () from C:\WINDOWS\system32\user32.dll
[debug]#27 0x000d013a in ?? ()
[debug]#28 0x00000111 in ?? ()
[debug]#29 0x00000065 in ?? ()
[debug](More stack frames follow...)
[debug]>>>>>>cb_gdb:

and it is because in the function:
----------------------------------------------
bool
wxListbook::InsertPage(size_t n,
wxWindow *page,
const wxString& text,
bool bSelect,
int imageId)
{
if ( !wxBookCtrlBase::InsertPage(n, page, text, bSelect, imageId) )
return false;

GetListView()->InsertItem(n, text, imageId);

// if the inserted page is before the selected one, we must update the
// index of the selected page
if ( int(n) <= m_selection )
{
// one extra page added
m_selection++;
GetListView()->Select(m_selection);
GetListView()->Focus(m_selection);
}

if ( !DoSetSelectionAfterInsertion(n, bSelect) )
page->Hide();

UpdateSize();

return true;
}

----------------------------------------------
GetListView() returned a NULL pointer.


So, I guess there are something wrong inside the wxListBook.

BTW: all the above testing C++ code of construction dialog is generated from the wxFormBuilder 3.5 RC1.

asmwarrior

PB

unread,
Jan 21, 2016, 1:58:51 AM1/21/16
to wx-users
Regarding the last crashing/asserting example code.

I may have got lost somewhere in the thread, but when I compile and run the most recent example, I get no crash. I also cannot see any image shift: screenshot?

I used slightly modified code to create a minimal self-contained example (still a long way to SSCE though) and used wxwin.png from the dnd sample as the bitmap.
My setup: wxWidgets master from 17.12.2015, VC 2008 Express, Win7 32-bit

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

class MyDialog1 : public wxDialog
{
public:
    wxListbook
*m_listbook1;
    wxPanel
*m_panel6;    

   
MyDialog1::MyDialog1()
       
: wxDialog(NULL, wxID_ANY, "MyDialog")
   
{

           
this->SetSizeHints( wxDefaultSize, wxDefaultSize );

            wxBoxSizer
* bSizer1;
            bSizer1
= new wxBoxSizer( wxVERTICAL );

            m_listbook1
= new wxListbook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLB_DEFAULT );
            wxSize m_listbook1ImageSize
= wxSize( 80,80 );
           
int m_listbook1Index = 0;
            wxImageList
* m_listbook1Images = new wxImageList( m_listbook1ImageSize.GetWidth(), m_listbook1ImageSize.GetHeight() );

            m_listbook1
->AssignImageList( m_listbook1Images );
            wxBitmap m_listbook1Bitmap
;
            wxImage m_listbook1Image
;
            m_panel6
= new wxPanel( m_listbook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
            m_listbook1
->AddPage( m_panel6, wxT("hihiihi"), false );

            m_listbook1Bitmap
= wxBitmap( wxT("wxwin.png"), wxBITMAP_TYPE_ANY );
           
if ( m_listbook1Bitmap.Ok() )

           
{
                    m_listbook1Image
= m_listbook1Bitmap.ConvertToImage();
                    m_listbook1Images
->Add( m_listbook1Image.Scale( m_listbook1ImageSize.GetWidth(), m_listbook1ImageSize.GetHeight() ) );

                    m_listbook1
->SetPageImage( m_listbook1Index, m_listbook1Index );
                    m_listbook1Index
++;
           
}

            bSizer1
->Add( m_listbook1, 1, wxEXPAND | wxALL, 5 );


           
this->SetSizer( bSizer1 );
           
this->Layout();

           
this->Centre( wxBOTH );
   
}
};

class MyApp : public wxApp
{
public:    
   
virtual bool OnInit()
   
{
        wxInitAllImageHandlers
();
       
       
MyDialog1 dlg;

        dlg
.ShowModal();
       
return false;
   
}
};
IMPLEMENT_APP
(MyApp)

asmwarrior

unread,
Jan 21, 2016, 9:49:50 AM1/21/16
to wx-u...@googlegroups.com
On 2016-1-21 14:58, PB wrote:
> Regarding the last crashing/asserting example code.
>
> I may have got lost somewhere in the thread, but when I compile and run the most recent example, I get no crash. I also cannot see any image shift: screenshot <http://imgur.com/tXzSWzf>?
>
> I used slightly modified code to create a minimal self-contained example (still a long way to SSCE though) and used wxwin.png from the dnd sample as the bitmap.
> My setup: wxWidgets master from 17.12.2015, VC 2008 Express, Win7 32-bit
>
> |
> #include<wx/wx.h>
> #include<wx/listbook.h>
>
> classMyDialog1:publicwxDialog
> {
> public:
> wxListbook *m_listbook1;
> wxPanel *m_panel6;
>
> MyDialog1::MyDialog1()
> :wxDialog(NULL,wxID_ANY,"MyDialog")
> {
> this->SetSizeHints(wxDefaultSize,wxDefaultSize );
>
> wxBoxSizer*bSizer1;
> bSizer1 =newwxBoxSizer(wxVERTICAL );
>
> m_listbook1 =newwxListbook(this,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxLB_DEFAULT );
> wxSize m_listbook1ImageSize =wxSize(80,80);
> intm_listbook1Index =0;
> wxImageList*m_listbook1Images =newwxImageList(m_listbook1ImageSize..GetWidth(),m_listbook1ImageSize.GetHeight());
> m_listbook1->AssignImageList(m_listbook1Images );
> wxBitmap m_listbook1Bitmap;
> wxImage m_listbook1Image;
> m_panel6 =newwxPanel(m_listbook1,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL );
> m_listbook1->AddPage(m_panel6,wxT("hihiihi"),false);
> m_listbook1Bitmap =wxBitmap(wxT("wxwin.png"),wxBITMAP_TYPE_ANY );
> if(m_listbook1Bitmap.Ok())
> {
> m_listbook1Image =m_listbook1Bitmap.ConvertToImage();
> m_listbook1Images->Add(m_listbook1Image.Scale(m_listbook1ImageSize.GetWidth(),m_listbook1ImageSize.GetHeight()));
> m_listbook1->SetPageImage(m_listbook1Index,m_listbook1Index );
> m_listbook1Index++;
> }
>
> bSizer1->Add(m_listbook1,1,wxEXPAND |wxALL,5);
>
>
> this->SetSizer(bSizer1 );
> this->Layout();
>
> this->Centre(wxBOTH );
> }
> };
>
> classMyApp:publicwxApp
> {
> public:
> virtualboolOnInit()
> {
> wxInitAllImageHandlers();
>
> MyDialog1dlg;
>
> dlg.ShowModal();
> returnfalse;
> }
> };
> IMPLEMENT_APP(MyApp)
> |
>
>
>
>

Hi, PB, thanks.
I can reproduce this issue on your code(you code does not build successfully, and I need to change ".." to "." and remove the "MyDialog1::", and use my own png file, so here is a minimal sample code to reproduce the shifted icon issue.

My environment is: windows xp, mingw-build 5.2, wx-git-master(cloned 2015-12-27).
Here is the code:


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


class MyDialog1 : public wxDialog
{
public:
wxListbook *m_listbook1;
wxPanel *m_panel6;

MyDialog1()
: wxDialog(NULL, wxID_ANY, "MyDialog")
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );

wxBoxSizer* bSizer1;
bSizer1 = new wxBoxSizer( wxVERTICAL );

m_listbook1 = new wxListbook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLB_DEFAULT );
wxSize m_listbook1ImageSize = wxSize( 80,80 );
int m_listbook1Index = 0;
wxImageList* m_listbook1Images = new wxImageList( m_listbook1ImageSize.GetWidth(), m_listbook1ImageSize.GetHeight() );
m_listbook1->AssignImageList( m_listbook1Images );
wxBitmap m_listbook1Bitmap;
wxImage m_listbook1Image;
m_panel6 = new wxPanel( m_listbook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_listbook1->AddPage( m_panel6, wxT("hihiihi"), false );
m_listbook1Bitmap = wxBitmap( wxT("compiler.png"), wxBITMAP_TYPE_ANY );
if ( m_listbook1Bitmap.Ok() )
{
m_listbook1Image = m_listbook1Bitmap.ConvertToImage();
m_listbook1Images->Add( m_listbook1Image.Scale( m_listbook1ImageSize.GetWidth(), m_listbook1ImageSize.GetHeight() ) );
m_listbook1->SetPageImage( m_listbook1Index, m_listbook1Index );
m_listbook1Index++;
}

bSizer1->Add( m_listbook1, 1, wxEXPAND | wxALL, 5 );


this->SetSizer( bSizer1 );
this->Layout();

this->Centre( wxBOTH );
}
};

class MyApp : public wxApp
{
public:
virtual bool OnInit()
{
wxInitAllImageHandlers();

MyDialog1 dlg;

dlg.ShowModal();
return false;
}
};
IMPLEMENT_APP(MyApp)


And Here is the result screen shot (in attachment).

@VZ, I think this is the minimal sample to reproduce this bug.

Asmwarrior



shift-icon.png

PB

unread,
Jan 21, 2016, 1:23:25 PM1/21/16
to wx-users
AsmWarrior,

FWIW I took the code from and verbatim pasted it into my VC2015 Express project. It was on a different computer than in my previous post, but the wxWidgets version and OS was the same; now I even used the compiler.png from C::B (SVN 10376).

Code compiled and run just fine. No crash, no image shift even when I tried running it in Windows XP Mode (Windows XP Virtual PC available for Win7 Pro users), still the same: http://i.imgur.com/HF8P87I.png

I have also pulled the current master from the GitHub, rebuild wxWidgets and your code. Everything still works as it did before.

So it looks to me like there is no problem with the code? Can you test it with a MS Visual C++ or perhaps also run it on another computer? I unfortunately do not have a working GCC wxWdgets build at hand atm...

PB

Vadim Zeitlin

unread,
Jan 21, 2016, 5:15:24 PM1/21/16
to wx-u...@googlegroups.com
On Thu, 21 Jan 2016 23:02:55 +0800 asmwarrior wrote:

a> I can reproduce this issue on your code(you code does not build
a> successfully, and I need to change ".." to "." and remove the
a> "MyDialog1::",

I'm not sure where there was a ".." in the original version, but I do see
the "MyDialog1::" problem, it's a MSVC bug (it should refuse to compile
such code but it allows it), but it doesn't change anything.

a> and use my own png file,

Do you mean that you can't reproduce the bug with another PNG file, e.g.
something returned from wxArtProvider (so that we could eliminate the
external file)?

a> @VZ, I think this is the minimal sample to reproduce this bug.

Could you please put the final version in a gist on GitHub to make it
easier to track it if you change it again (e.g. to get rid of the
compiler.png)? I'll try to test it with MinGW, it's not impossible that
it's compiler-dependent... Which version of MinGW (and which distribution,
i.e. MinGW-w64, TDM-GCC, something else?) do you use?

Thanks,

asmwarrior

unread,
Jan 22, 2016, 8:50:37 AM1/22/16
to wx-u...@googlegroups.com
On 2016-1-22 6:15, Vadim Zeitlin wrote:
> On Thu, 21 Jan 2016 23:02:55 +0800 asmwarrior wrote:
>
> a> I can reproduce this issue on your code(you code does not build
> a> successfully, and I need to change ".." to "." and remove the
> a> "MyDialog1::",
>
> I'm not sure where there was a ".." in the original version, but I do see
> the "MyDialog1::" problem, it's a MSVC bug (it should refuse to compile
> such code but it allows it), but it doesn't change anything.
>
> a> and use my own png file,
>
> Do you mean that you can't reproduce the bug with another PNG file, e.g.
> something returned from wxArtProvider (so that we could eliminate the
> external file)?

I think I can reproduce this issue by the wxArtProvider's icon. I have created a github gist test code, see here:

https://gist.github.com/asmwarrior/3d1e618a32789476fd59

>
> a> @VZ, I think this is the minimal sample to reproduce this bug.
>
> Could you please put the final version in a gist on GitHub to make it
> easier to track it if you change it again (e.g. to get rid of the
> compiler.png)? I'll try to test it with MinGW, it's not impossible that
> it's compiler-dependent... Which version of MinGW (and which distribution,
> i.e. MinGW-w64, TDM-GCC, something else?) do you use?
>
> Thanks,
> VZ

I use this one:

http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/5.2.0/threads-posix/dwarf/i686-5.2.0-release-posix-dwarf-rt_v4-rev0.7z/download

I build the wx trunk with the following command: (I build a debug version of wx 3.x, because the release version of 3.0.2 wx will make C::B crash under windows xp)

mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=debug UNICODE=1 USE_OPENGL=1 VENDOR=cb CXXFLAGS="-Wno-unused-local-typedefs -Wno-deprecated-declarations -fno-keep-inline-dllexport" >log-debug.txt 2>&1


I hope you can find the reason.

Asmwarrior


Igor Korot

unread,
Jan 22, 2016, 9:36:04 AM1/22/16
to wx-u...@googlegroups.com
Hi,
Can you try to build with MSVC?

Thank you.

>
>
> I hope you can find the reason.
>
> Asmwarrior
>
>
> --
> Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
>
> To unsubscribe, send email to wx-users+u...@googlegroups.com
> or visit http://groups.google.com/group/wx-users

asmwarrior

unread,
Jan 22, 2016, 10:11:32 AM1/22/16
to wx-u...@googlegroups.com
Hi, Sorry, I don't have any MSVC at hand...And MSVC is quite a big software, I'm not sure how slow it will run on my windows XP.

Asmwarrior

asmwarrior

unread,
Jan 23, 2016, 12:01:43 AM1/23/16
to wx-u...@googlegroups.com
On 2016-1-22 22:36, Igor Korot wrote:
> Hi,
>
> On Fri, Jan 22, 2016 at 9:03 AM, asmwarrior <asmwa...@gmail.com> wrote:
>> On 2016-1-22 6:15, Vadim Zeitlin wrote:
>>> On Thu, 21 Jan 2016 23:02:55 +0800 asmwarrior wrote:
>>>
>>> a> I can reproduce this issue on your code(you code does not build
>>> a> successfully, and I need to change ".." to "." and remove the
>>> a> "MyDialog1::",
>>>
>>> I'm not sure where there was a ".." in the original version, but I do see
>>> the "MyDialog1::" problem, it's a MSVC bug (it should refuse to compile
>>> such code but it allows it), but it doesn't change anything.
>>>
>>> a> and use my own png file,
>>>
>>> Do you mean that you can't reproduce the bug with another PNG file, e.g.
>>> something returned from wxArtProvider (so that we could eliminate the
>>> external file)?
>>
>> I think I can reproduce this issue by the wxArtProvider's icon. I have created a github gist test code, see here:
>>
>> https://gist.github.com/asmwarrior/3d1e618a32789476fd59
>>

I just tested by the wx-git-master HEAD:

SHA-1: a03df746f0573b374ddf06a69af969cbf2db850c

* Fix harmless parameter shadowing warnings

Rename local variables to avoid clashes with the function parameters.

Closes #17343, #17344.

And with the latest mingw-build version:
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/5.3.0/threads-posix/dwarf/i686-5.3.0-release-posix-dwarf-rt_v4-rev0.7z/download

But I still get the same bad result. The icon looks like get re-sized, see attachment.

It looks like the icons are centered, but the image just does not show correctly.

Here is the test code:

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


class MyDialog1 : public wxDialog
{
public:
wxListbook *m_listbook1;
wxPanel *m_panel6;
wxPanel *m_panel7;

MyDialog1()
: wxDialog(NULL, wxID_ANY, "MyDialog")
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );

wxBoxSizer* bSizer1;
bSizer1 = new wxBoxSizer( wxVERTICAL );

m_listbook1 = new wxListbook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLB_DEFAULT );
wxSize m_listbook1ImageSize = wxSize( 80,80 );
int m_listbook1Index = 0;
wxImageList* m_listbook1Images = new wxImageList( m_listbook1ImageSize.GetWidth(), m_listbook1ImageSize.GetHeight() );
m_listbook1->AssignImageList( m_listbook1Images );
wxBitmap m_listbook1Bitmap;
wxImage m_listbook1Image;
m_panel6 = new wxPanel( m_listbook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_listbook1->AddPage( m_panel6, wxT("test11111 1111111111"), false );
m_panel7 = new wxPanel( m_listbook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_listbook1->AddPage( m_panel7, wxT("test22222 2222222222"), false );
m_listbook1Bitmap = wxBitmap( wxT("compiler.png"), wxBITMAP_TYPE_ANY );
if ( m_listbook1Bitmap.Ok() )
{
m_listbook1Image = m_listbook1Bitmap.ConvertToImage();
m_listbook1Images->Add( m_listbook1Image.Scale( m_listbook1ImageSize.GetWidth(), m_listbook1ImageSize.GetHeight() ) );
m_listbook1->SetPageImage( 0, 0 );
m_listbook1->SetPageImage( 1, 0 );
}

bSizer1->Add( m_listbook1, 1, wxEXPAND | wxALL, 5 );


this->SetSizer( bSizer1 );
this->Layout();

this->Centre( wxBOTH );
}
};

class MyApp : public wxApp
{
public:
virtual bool OnInit()
{
wxInitAllImageHandlers();

MyDialog1 dlg;

dlg.ShowModal();
return false;
}
};
IMPLEMENT_APP(MyApp)

And the 80*80 icon png file is also in attachment.

Thanks.

Asmwarrior




show-icons.png
compiler.png

asmwarrior

unread,
Jan 24, 2016, 1:39:10 AM1/24/16
to wx-users
FYI, today, I have a bad news, because I see this issue on our wx 2.8.12 based C::B release, see this post:

Bad icons of C::B in the 16.01 release - http://forums.codeblocks.org/index.php/topic,20871.msg142502/topicseen.html#msg142502

So, this is an issue which exists for a long time.

Asmwarrior

Catalin

unread,
Jan 24, 2016, 3:59:55 AM1/24/16
to wx-u...@googlegroups.com
Hello,

The attached patch to minimal sample shows what could be the same issue.

To see the issue apply the patch, run the sample, enlarge the main frame until the vertical scrollbar disappears, then slowly shrink it until the vertical scrollbar is needed again. I see an intense scrollbar flicker, and after that sometimes the list is correctly shown but after the immediately following size event the images look badly aligned. So you get a 50-50% chances of catching either behaviour.
One problem is with the toolbar flicker, which leads to another painting issue that makes the listbook look like it is wider than it really is.

I've used for this wxW-trunk (November 2015) and MSVC 2013.

Regards,
C
listbook_icons_shifted.patch

asmwarrior

unread,
Jan 24, 2016, 9:41:54 AM1/24/16
to wx-u...@googlegroups.com
Hi, Catalin, I can confirm this bug, thanks.
But I'm not sure this is exactly the one I original reported. The long text "test11111 1111111111" are still in the same line in your test code, while in my original bug report, the long text were just wrapped, and they became two lines, see the image shot in my post: http://forums.codeblocks.org/index.php/topic,20871.0.html

I'm testing it under wx-git-master(I pulled yesterday), and mingw-build gcc 5.3 compiler(from mingw-w64 sourceforge site), windows XP sp3.
I attach three screen shots, and it looks like the 2.png is the bug, right?


Asmwarrior

1.png
2.png
3.png

Vadim Zeitlin

unread,
Jan 24, 2016, 8:57:19 PM1/24/16
to wx-u...@googlegroups.com
On Sun, 24 Jan 2016 08:59:50 +0000 (UTC) 'Catalin' via wx-users wrote:

Cvwu> The attached patch to minimal sample shows what could be the same issue.
Cvwu>
Cvwu> To see the issue apply the patch, run the sample, enlarge the main
Cvwu> frame until the vertical scrollbar disappears, then slowly shrink it
Cvwu> until the vertical scrollbar is needed again. I see an intense
Cvwu> scrollbar flicker, and after that sometimes the list is correctly
Cvwu> shown but after the immediately following size event the images look
Cvwu> badly aligned. So you get a 50-50% chances of catching either
Cvwu> behaviour. One problem is with the toolbar flicker, which leads to
Cvwu> another painting issue that makes the listbook look like it is wider
Cvwu> than it really is.

Hi,

Thanks for the patch, I do indeed see the problem with it. AFAICS there
are in fact 2 problems: the first one is that wxListCtrl is made too wide
when relying on its width-from-height computation (it would be the same in
the other direction, i.e. too tall for the given width, too) because we
account for the size of its borders twice. This seems to be the originally
reported bug which results in a shift by 4 pixels which, while hardly
catastrophic, is indeed annoying. But this is easy to fix and I just did it
in a358c898c55bcda640cfc21da2fa7fbca663914c: Asmwarrior, please let me know
if it fixes your problem.

The second problem is with the incorrect control size due to scrollbar
hysteresis. This one is more mysterious and is difficult to debug. I am not
sure what exactly is going on here, but I suspect we might need to stop
relying on WS_[HV]SCROLL flag bits which don't seem to be always getting
set in sync, and use GetItemRect() to check if the last item fits into the
returned space. Unfortunately I ran out of time to try this today and I'm
not sure when I'm going to be able to get back to it, so if somebody wants
to try doing it, it would be most welcome.

Regards,

Igor Korot

unread,
Jan 24, 2016, 9:38:02 PM1/24/16
to wx-u...@googlegroups.com
Vadim et al,
In the meantime it would be nice if someone check the trac and open a new ticket
for a second issue if its not already there.

Thank you.

asmwarrior

unread,
Jan 25, 2016, 9:06:38 AM1/25/16
to wx-u...@googlegroups.com
On 2016-1-25 9:57, Vadim Zeitlin wrote:
> On Sun, 24 Jan 2016 08:59:50 +0000 (UTC) 'Catalin' via wx-users wrote:
>
> Cvwu> The attached patch to minimal sample shows what could be the same issue.
> Cvwu>
> Cvwu> To see the issue apply the patch, run the sample, enlarge the main
> Cvwu> frame until the vertical scrollbar disappears, then slowly shrink it
> Cvwu> until the vertical scrollbar is needed again. I see an intense
> Cvwu> scrollbar flicker, and after that sometimes the list is correctly
> Cvwu> shown but after the immediately following size event the images look
> Cvwu> badly aligned. So you get a 50-50% chances of catching either
> Cvwu> behaviour. One problem is with the toolbar flicker, which leads to
> Cvwu> another painting issue that makes the listbook look like it is wider
> Cvwu> than it really is.
>
> Hi,
>
> Thanks for the patch, I do indeed see the problem with it. AFAICS there
> are in fact 2 problems: the first one is that wxListCtrl is made too wide
> when relying on its width-from-height computation (it would be the same in
> the other direction, i.e. too tall for the given width, too) because we
> account for the size of its borders twice. This seems to be the originally
> reported bug which results in a shift by 4 pixels which, while hardly
> catastrophic, is indeed annoying. But this is easy to fix and I just did it
> in a358c898c55bcda640cfc21da2fa7fbca663914c: Asmwarrior, please let me know
> if it fixes your problem.
>


Thanks!
I just pull the wx git repo, and build the wx library, and rebuild c::b.
I see my reported issue still exists.

Asmwarrior

Vadim Zeitlin

unread,
Jan 25, 2016, 10:17:03 AM1/25/16
to wx-u...@googlegroups.com
On Mon, 25 Jan 2016 22:19:49 +0800 asmwarrior wrote:

a> I just pull the wx git repo, and build the wx library, and rebuild c::b.
a> I see my reported issue still exists.

I'd really like to reduce the amount of uncertainty here, so could you
please check if this fixes the problem with the extra pixels in Catalin's
example for you first?

Also, perhaps I'm misunderstanding you from the beginning: what exactly is
the problem you're trying to fix? I saw that the icon was offset by 2
pixels horizontally due to the extra 4 pixels being added to the control
width compared to its best width. Are you speaking about the same thing or
something else entirely?

asm warrior

unread,
Jan 25, 2016, 9:26:31 PM1/25/16
to wx-users


2016-1-25 下午11:17,"Vadim Zeitlin" <va...@wxwidgets.org>写道:
>
> On Mon, 25 Jan 2016 22:19:49 +0800 asmwarrior wrote:
>
> a> I just pull the wx git repo, and build the wx library, and rebuild c::b.
> a> I see my reported issue still exists.
>
>  I'd really like to reduce the amount of uncertainty here, so could you
> please check if this fixes the problem with the extra pixels in Catalin's
> example for you first?

OK, I will test and report back.
I use phone now.


>
>  Also, perhaps I'm misunderstanding you from the beginning: what exactly is
> the problem you're trying to fix? I saw that the icon was offset by 2
> pixels horizontally due to the extra 4 pixels being added to the control
> width compared to its best width. Are you speaking about the same thing or
> something else entirely?
>

There are three issues in my original post.
1. icon get shifted
2. icon get resized, so it's blur
3. the label text under icon get wrapped

THANKS

asmwarrior

Igor Korot

unread,
Jan 25, 2016, 11:51:12 PM1/25/16
to wx-u...@googlegroups.com
asmwarrior/Vadim,
Is ticket 4379 covers one of this problem?

Thank you.

>
> THANKS
>
> asmwarrior

asmwarrior

unread,
Jan 26, 2016, 12:29:17 AM1/26/16
to wx-u...@googlegroups.com
Hi, Igor Korot, thanks.

I just create a minimal sample code to run the test code in http://trac.wxwidgets.org/ticket/4379
(BTW: the associated forum discussion is: https://forums.wxwidgets.org/viewtopic.php?f=1&t=15999)

Here is the code: (I just merge the .h and .cpp file in one cpp file, see below)
---------------------------------------------
#include <wx/wx.h>
#include <wx/listbook.h>


#include <wx/dialog.h>

class wxCheckBox;
class wxSpinCtrl;
class wxListbook;
class wxComboBox;

#define BFSETTINGSDLG_ID_BUTTONOK 1 + wxID_HIGHEST
#define BFSETTINGSDLG_ID_BUTTONCANCEL 2 + wxID_HIGHEST

///
class BFSettingsDlg2 : public wxDialog
{
private:

public:
/// constructor
BFSettingsDlg2 (wxWindow* pParent);

/// virtual destructor
virtual ~BFSettingsDlg2 ();

///
void OnClose (wxCloseEvent& event);

DECLARE_EVENT_TABLE();
}; // class BFSettingsDlg2


#include <wx/listbook.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/stattext.h>
#include <wx/spinctrl.h>
#include <wx/listctrl.h>
#include <wx/imaglist.h>
#include <wx/statline.h>
#include <wx/treebook.h>
#include <limits.h>

BEGIN_EVENT_TABLE(BFSettingsDlg2, wxDialog)
EVT_CLOSE (BFSettingsDlg2::OnClose)
END_EVENT_TABLE()

//
BFSettingsDlg2::BFSettingsDlg2 (wxWindow* pParent)
: wxDialog(pParent, wxID_ANY, wxString(_("Global Settings")))
{
// the book
wxTreebook* pBook = new wxTreebook(this,
wxID_ANY,
wxDefaultPosition,
wxDefaultSize,
wxNB_LEFT);

// *** PROJECT-page ***
wxPanel* pPageProject = new wxPanel(pBook);
wxBoxSizer* pPageProjectSizerTop = new wxBoxSizer(wxVERTICAL);

// custom ctrl
wxPanel* pPrjCtrl = new wxPanel(pPageProject);
wxStaticBoxSizer* pStopStaticSizer = new wxStaticBoxSizer(wxVERTICAL, pPrjCtrl);
wxStaticText* pLabelA = new wxStaticText(pPrjCtrl, wxID_ANY, _("ABCD"));
pStopStaticSizer->Add(pLabelA, wxSizerFlags(0).Expand());
pPrjCtrl->SetSizer(pStopStaticSizer);

pPageProjectSizerTop->Add(pPrjCtrl, wxSizerFlags(0).Expand());
pPageProject->SetSizer(pPageProjectSizerTop);
pBook->AddPage(pPageProject, _("Default Project"));

// sizer and arrange
wxBoxSizer* pDlgSizer = new wxBoxSizer(wxVERTICAL);
pDlgSizer->Add(pBook, wxSizerFlags(0).Expand().Border());
SetSizerAndFit(pDlgSizer);
ShowModal();
}


//
/*virtual*/ BFSettingsDlg2::~BFSettingsDlg2 ()
{
}


void BFSettingsDlg2::OnClose (wxCloseEvent& event)
{
Destroy();
}

class MyApp : public wxApp
{
public:
virtual bool OnInit()
{
wxInitAllImageHandlers();

BFSettingsDlg2 dlg(NULL);

dlg.ShowModal();
return false;
}
};
IMPLEMENT_APP(MyApp)
---------------------------------------------

I don't see any issue here, see the screen shot as attachment.

So, I think it is not related to my reported issue.

Asmwarrior




ticket-4379.png

asmwarrior

unread,
Jan 26, 2016, 7:57:01 AM1/26/16
to wx-u...@googlegroups.com
On 2016-1-25 23:16, Vadim Zeitlin wrote:
> On Mon, 25 Jan 2016 22:19:49 +0800 asmwarrior wrote:
>
> a> I just pull the wx git repo, and build the wx library, and rebuild c::b.
> a> I see my reported issue still exists.
>
> I'd really like to reduce the amount of uncertainty here, so could you
> please check if this fixes the problem with the extra pixels in Catalin's
> example for you first?
>

Just tested, and I still see the Catalin reported issue. I mean sometimes, I see see the extra whitespace in the right margin(at this time, no scroll bar is shown)

Asmwarrior

Vadim Zeitlin

unread,
Jan 26, 2016, 3:14:02 PM1/26/16
to wx-u...@googlegroups.com
On Tue, 26 Jan 2016 10:26:28 +0800 asm warrior wrote:

aw> There are three issues in my original post.
aw> 1. icon get shifted
aw> 2. icon get resized, so it's blur
aw> 3. the label text under icon get wrapped

I don't think (2) is a problem at all, i.e. this is the expected behaviour
AFAICS. I didn't realize (3) was a problem. But (1) should be fixed by my
change.

On Tue, 26 Jan 2016 21:10:11 +0800 asmwarrior wrote:

a> On 2016-1-25 23:16, Vadim Zeitlin wrote:
a> > On Mon, 25 Jan 2016 22:19:49 +0800 asmwarrior wrote:
a> >
a> > a> I just pull the wx git repo, and build the wx library, and rebuild c::b.
a> > a> I see my reported issue still exists.
a> >
a> > I'd really like to reduce the amount of uncertainty here, so could you
a> > please check if this fixes the problem with the extra pixels in Catalin's
a> > example for you first?
a>
a> Just tested, and I still see the Catalin reported issue. I mean
a> sometimes, I see see the extra whitespace in the right margin(at this
a> time, no scroll bar is shown)

Yes, I explicitly wrote that this bug still remains. Again, my fix was for
your problem (1) above only.

Anyhow, to go forward, it would be great if you could produce the same
patch as Catalin made for your issue (3). Although, to be honest, this
seems like a rather low priority problem to me.

asmwarrior

unread,
Feb 3, 2016, 9:22:50 PM2/3/16
to wx-u...@googlegroups.com
HI, VZ, it looks like my reported issues (1,2,3) only exist on Windows XP, and I have the same program (the Code::Blocks release 16.01) has different results. On WinXP, it has the issues, but it does not have issues on Windows 7(64bit) system.

Asmwarrior

Vadim Zeitlin

unread,
Feb 3, 2016, 10:04:16 PM2/3/16
to wx-u...@googlegroups.com
On Thu, 04 Feb 2016 10:36:10 +0800 asmwarrior wrote:

a> HI, VZ, it looks like my reported issues (1,2,3) only exist on Windows
a> XP, and I have the same program (the Code::Blocks release 16.01) has
a> different results. On WinXP, it has the issues, but it does not have
a> issues on Windows 7(64bit) system.

Sorry, I'm afraid I just can't muster the motivation to debug XP-specific
problems. Any patches would still be welcome, of course, as long as we
support it, but I don't have any users under XP since a very long time any
more...

asmwarrior

unread,
Feb 4, 2016, 8:47:14 AM2/4/16