Problems with wxScrolledWindow with wxWidgets 3.1.2

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
User avatar
Parduz
Experienced Solver
Experienced Solver
Posts: 71
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Problems with wxScrolledWindow with wxWidgets 3.1.2

Post by Parduz » Wed Nov 13, 2019 4:57 pm

This is how i create a "file browser", listing all the files by adding a button for each in a wxScrolledWindow:

Code: Select all

	wxStaticBoxSizer* szrFileBrowserAll;
	size_t FileCount;
	do {
		// Posso aggiornare il browser
		Freeze();

		// Cancello la roba pre-esistente
		if (m_ScrollFiles) {
			m_ScrollFiles->Destroy();
		}
		m_ScrollFiles = nullptr;
		ButtonSelected = nullptr;

		// Creo la nuova finestra di Scroll
		szrFileBrowserAll 		= (wxStaticBoxSizer*)m_pageFile->GetSizer();
		m_ScrollFiles 			= new wxScrolledWindow(m_pageFile, wxID_ANY, wxDefaultPosition, wxSize(-1,-1), wxVSCROLL);
		m_ScrollFiles->			SetBackgroundColour( m_pageFile->GetBackgroundColour() );
		m_ScrollFiles->			SetForegroundColour( m_pageFile->GetForegroundColour() );
		m_ScrollFiles->			SetFont(m_pageFile->GetFont());
		m_ScrollFiles->			ShowScrollbars(wxSHOW_SB_NEVER,wxSHOW_SB_NEVER);
		m_ScrollFiles->			SetScrollRate(0, 5);

		// La aggiungo al sizer della pagina
		szrFileBrowserAll->		Add(m_ScrollFiles, 1, wxLEFT|wxEXPAND, 5);

		// Ora creo la sua griglia
		wxFlexGridSizer* szr_ScrollFiles = new wxFlexGridSizer(0, 2, 5, 3);
		szr_ScrollFiles->		SetFlexibleDirection( wxHORIZONTAL ); //wxBOTH );
		szr_ScrollFiles->		SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
		szr_ScrollFiles->		AddGrowableCol(1);
		m_ScrollFiles->			SetSizer(szr_ScrollFiles);

		// Conto i files presenti nella cartella
		wxArrayString			FileList;
		wxStaticText*			m_lFileCount;
		wxString				str;

		FileCount = wxDir::GetAllFiles(
		  *DirName,
		  &FileList,
		  FB_Filter,
		  wxDIR_FILES
		);
		if (FileCount<1) {
			// Nessun file trovato: avviso ed esco
			str.Printf("No files available in\n\%s",DirName->c_str());
			m_lFileCount 			= new wxStaticText(m_ScrollFiles, wxID_ANY, str);
			m_lFileCount->			SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
			//m_lFileCount->		SetMinSize(wxSize(60,-1));
			szr_ScrollFiles->		AddGrowableCol(0);
			szr_ScrollFiles->		Add(m_lFileCount, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
			break;
		}

		// Giro tutti i files e creo la relativa etichetta e pulsante
		wxGradientSwitch*	m_bFileButton;
		wxFont				ButtonFont(
			12						,
			wxFONTFAMILY_MODERN		,
			wxFONTSTYLE_NORMAL		,
			wxFONTWEIGHT_BOLD		,
			false					,
			wxT("Liberation Mono")
		);

		for (size_t i=0; i<FileCount; i++) {

			// Creo l'etichetta col contatore dei files
			str.Printf("%d/%d",i+1,FileCount);
			m_lFileCount = new wxStaticText(
				m_ScrollFiles, wxID_ANY, str
				, wxDefaultPosition, wxSize(-1,-1), wxST_NO_AUTORESIZE|wxALIGN_RIGHT
			);

			m_lFileCount->			SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
			m_lFileCount->			SetMinSize(wxSize(60,-1));
			szr_ScrollFiles->		Add(m_lFileCount, 1, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);

			// Creo il pulsante di selezione del file
			str = FileList[i].substr(DirName->Length()+1,1000);
			m_bFileButton 			= new wxGradientSwitch(
											m_ScrollFiles,
											wxID_BCONFLOADUSB,
											str,
											wxDefaultPosition,
											wxSize(-1,50),
											wxBU_EXACTFIT
									);
			m_bFileButton->			SetFont(ButtonFont);
			m_bFileButton->			SetMinSize(wxSize(-1,50));
			m_bFileButton->			SetColours_Normal	(ButtonNormal	);
			m_bFileButton->			SetColours_Down		(ButtonDown		);
			m_bFileButton->			SetValue(false);
			m_bFileButton->			SetGroupIndex(-1);

			m_bFileButton->			Bind(wxEVT_COMMAND_BUTTON_CLICKED, &GUI_MainForm::OnBFileSelected, this);
			szr_ScrollFiles->		Add(m_bFileButton, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5);
			//szr_ScrollFiles->		Add(m_bFileButton, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5);
		}
	} while (false);
	// filterbox->SetAutoLayout(true);
	szrFileBrowserAll->Layout();
	Thaw();


With wxWidgets 3.0.4, it shows like this.
2019-11-13-164433_480x272_scrot.png
2019-11-13-164433_480x272_scrot.png (15.16 KiB) Viewed 316 times

With wxWidgets 3.1.2, instead it shows like this (notice the last visible button).
2019-11-13-164320_480x272_scrot.png
2019-11-13-164320_480x272_scrot.png (16.13 KiB) Viewed 316 times
What should i do to have the buttons correctly placed and showed like in the first picture?

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

Re: Problems with wxScrolledWindow with wxWidgets 3.1.2

Post by doublemax » Wed Nov 13, 2019 5:34 pm

I'm not aware of any changes between 3.1.2 and 3.1.3 that could explain this. And there is just too much code to read. Please try to create a minimal compilable sample that shows the problem.
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3607
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Problems with wxScrolledWindow with wxWidgets 3.1.2

Post by ONEEYEMAN » Wed Nov 13, 2019 6:09 pm

Hi,
Did you also update the system libraries? (GTK+ in particular)?

Thank you.

User avatar
Parduz
Experienced Solver
Experienced Solver
Posts: 71
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Re: Problems with wxScrolledWindow with wxWidgets 3.1.2

Post by Parduz » Thu Nov 14, 2019 11:06 am

doublemax wrote:
Wed Nov 13, 2019 5:34 pm
3.1.3
?
The differences i see are between 3.0.4 and 3.1.2... i don't understand.

I'll build a compilable file, ok.
ONEEYEMAN wrote:
Wed Nov 13, 2019 6:09 pm
Did you also update the system libraries? (GTK+ in particular)?
I'm a linux noob, so i'm trying to answer you... hope i get it.

This is what the command dpkg -l | grep libgtk returns:

On the Debian9 PC where i develop and (cross)compile:

Code: Select all

ii  libgtk-vnc-2.0-0:i386        0.6.0-3      i386    VNC viewer widget for GTK+3 (runtime libraries)
ii  libgtkmm-3.0-1v5:i386        3.22.0-1     i386    C++ wrappers for GTK+ (shared libraries)
ii  libgtksourceview-3.0-1:i386  3.22.2-1     i386    shared libraries for the GTK+ syntax highlighting widget
ii  libgtksourceview-3.0-common  3.22.2-1     all     common files for the GTK+ syntax highlighting widget
ii  libgtk-3-0:i386              3.22.11-1    i386    GTK+ graphical user interface library
ii  libgtk-3-bin                 3.22.11-1    i386    programs for the GTK+ graphical user interface library
ii  libgtk-3-common              3.22.11-1    all     common files for the GTK+ graphical user interface library
rc  libgtk2.0-0:armhf            2.24.31-2    armhf   GTK+ graphical user interface library
ii  libgtk2.0-0:i386             2.24.31-2    i386    GTK+ graphical user interface library
ii  libgtk2.0-bin                2.24.31-2    i386    programs for the GTK+ graphical user interface library
ii  libgtk2.0-common             2.24.31-2    all     common files for the GTK+ graphical user interface library
ii  libgtk2.0-dev                2.24.31-2    i386    development files for the GTK+ library
ii  libgtk2.0-doc                2.24.31-2    all     documentation for the GTK+ graphical user interface library
ii  libgtkmm-2.4-1v5:i386        1:2.24.5-1   i386    C++ wrappers for GTK+ (shared libraries)
ii  libgtk2-perl                 2:1.2499-1   i386    Perl interface to the 2.x series of the Gimp Toolkit library
ii  libgtkspell0                 2.0.16-1.1   i386    a spell-checking addon for GTK's TextView widget
ii  libgtkspell3-3-0:i386        3.0.9-1      i386    spell-checking addon for GTK+'s TextView widget
And this on my BeaglebonesBlack (also running Debian9)

Code: Select all

ii  libgtk-3-0:armhf             3.22.11-1    armhf   GTK+ graphical user interface library
ii  libgtk-3-bin                 3.22.11-1    armhf   programs for the GTK+ graphical user interface library
ii  libgtk-3-common              3.22.11-1    all     common files for the GTK+ graphical user interface library
ii  libgtk2.0-0:armhf            2.24.31-2    armhf   GTK+ graphical user interface library
ii  libgtk2.0-bin                2.24.31-2    armhf   programs for the GTK+ graphical user interface library
ii  libgtk2.0-common             2.24.31-2    all     common files for the GTK+ graphical user interface library
ii  libgtk2.0-dev                2.24.31-2    armhf   development files for the GTK+ library

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3607
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Problems with wxScrolledWindow with wxWidgets 3.1.2

Post by ONEEYEMAN » Thu Nov 14, 2019 3:21 pm

Hi,
You did say that you are working with both 3.0.4 and 3.1.2.
So, my question was more to the extent - what else did you upgrade besides wxWidgets?

Thank you.

User avatar
Parduz
Experienced Solver
Experienced Solver
Posts: 71
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Re: Problems with wxScrolledWindow with wxWidgets 3.1.2

Post by Parduz » Fri Nov 15, 2019 8:39 am

ONEEYEMAN wrote:
Thu Nov 14, 2019 3:21 pm
You did say that you are working with both 3.0.4 and 3.1.2.
Well, i upgraded from 3.0.4 to 3.1.2 and noticed the old code did'nt have that problem.
ONEEYEMAN wrote:
Thu Nov 14, 2019 3:21 pm
So, my question was more to the extent - what else did you upgrade besides wxWidgets?
Nothing else.

I have both wxWidgets versions compiled on a Debian PC, both compiled for armhf also, both with this commands:
PC for debug:

Code: Select all

  $ ../configure --disable-shared --enable-debug --with-gtk=2 --with-libtiff=no --with-opengl=no --enable-unicode --with-libpng=builtin --with-libjpeg=builtin --enable-std_string_conv_in_wxstring
ARM release:

Code: Select all

  $ ../configure --disable-shared --disable-debug --with-gtk=2 --with-libtiff=no --with-opengl=no --enable-unicode --with-libpng=builtin --with-libjpeg=builtin --enable-std_string_conv_in_wxstring --host=arm-linux-gnueabihf
The screenshots of my app that i attached in the first post are the two binary files compiled using the two version (compiled in the same moment), from the same Beaglebone, one after the other.

So the widgets and the binaries are compiled and executed in the same exact way on the same exact machines.

User avatar
Parduz
Experienced Solver
Experienced Solver
Posts: 71
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Re: Problems with wxScrolledWindow with wxWidgets 3.1.2

Post by Parduz » Thu Nov 28, 2019 9:41 am

Ok, i've finally managed to strip everything out and produce a buildable example, which is attached.

The difference is still there: compiled with wx3.0.4 works as expected
wxScrollWindow304.png
wxScrollWindow304.png (15.89 KiB) Viewed 129 times
with 3.1.2 the last buttons is overlapping the previous.
wxScrollWindow312.png
wxScrollWindow312.png (16.05 KiB) Viewed 129 times
I don't know if the problem is from the wxScrollWindow or from the wxFlexGridSizer (i'm having other cases of bad alignement and i'm investigating) but if someone can tell me if this is my fault or a wxWidgets problem it could be a great help.

--

I use codeblocks, and the compile/build commands are:
wx304

Code: Select all

g++ -O0 -g -D__WXDEBUG__ -Wall -pedantic -pthread -std=gnu++11 -Wall -D_FILE_OFFSET_BITS=64 -D__WXGTK__ -I"/home/fc/wxWidgets/wxWidgets-3.0.4/build-GTK2-686-d/lib/wx/include/gtk2-unicode-static-3.0" -I/home/fc/wxWidgets/wxWidgets-3.0.4/include -c /home/fc/_TEST_DEBUG_WXAPP_/TestDebug_wxScrolledWindow.cpp -o obj/686/dd304/TestDebug_wxScrolledWindow.o
g++ -L"/home/fc/wxWidgets/wxWidgets-3.0.4/build-GTK2-686-d/lib" -L/home/fc/wxWidgets/wxWidgets-3.0.4/lib -o bin/686/TestDebug_wxScrolledWindow_304 obj/686/dd304/TestDebug_wxScrolledWindow.o  -pthread -lgthread-2.0 -lX11 -lXxf86vm -lSM -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lpng -lexpat -lwxregexu-3.0 -lwxjpeg-3.0 -lz -ldl -lm  -lwx_baseu_net-3.0 -lwx_gtk2u_xrc-3.0 -lwx_gtk2u_adv-3.0 -lwx_gtk2u_propgrid-3.0 -lwx_gtk2u_ribbon-3.0 -lwx_gtk2u_richtext-3.0 -lwx_gtk2u_stc-3.0 -lwx_baseu_xml-3.0 -lwxregexu-3.0 -lwxscintilla-3.0 -lwx_gtk2u_aui-3.0 -lwx_gtk2u_html-3.0 -lwx_gtk2u_core-3.0 -lwxjpeg-3.0 -lwxpng-3.0 -lwx_baseu-3.0
wx312

Code: Select all

g++ -Wall -pedantic -O0 -g -D__WXDEBUG__ -pthread -std=gnu++11 -Wall -D_FILE_OFFSET_BITS=64 -D__WXGTK__ -I"/home/fc/wxWidgets/wxWidgets-3.1.2/build-GTK2-686-d/lib/wx/include/gtk2-unicode-static-3.1" -I"/home/fc/wxWidgets/wxWidgets-3.1.2/include" -c /home/fc/_TEST_DEBUG_WXAPP_/TestDebug_wxScrolledWindow.cpp -o obj/686/dd312/TestDebug_wxScrolledWindow.o
g++ -L"/home/fc/wxWidgets/wxWidgets-3.1.2/build-GTK2-686-d/lib" -L"/home/fc/wxWidgets/wxWidgets-3.1.2/lib" -o bin/686/TestDebug_wxScrolledWindow_312 obj/686/dd312/TestDebug_wxScrolledWindow.o  -pthread -lgthread-2.0 -lX11 -lXxf86vm -lSM -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lpng -lexpat -lz -ldl -lm  -lwx_baseu_net-3.1 -lwx_gtk2u_xrc-3.1 -lwx_gtk2u_adv-3.1 -lwx_gtk2u_propgrid-3.1 -lwx_gtk2u_ribbon-3.1 -lwx_gtk2u_richtext-3.1 -lwx_gtk2u_stc-3.1 -lwx_baseu_xml-3.1 -lwxregexu-3.1 -lwxscintilla-3.1 -lwx_gtk2u_aui-3.1 -lwx_gtk2u_html-3.1 -lwx_gtk2u_core-3.1 -lwxjpeg-3.1 -lwxpng-3.1 -lwx_baseu-3.1
The PC i'm using is a Debian9, and for building i don't use "wxConfig" 'cause i have two wxWidgets folders (304 and 312) with build folders for this PC and ARMHF, so i have to "manual" set the compiler/linker parameters.

Thanks
Attachments
TestDebug_wxScrolledWindow.cpp
Example source file.
(9.79 KiB) Downloaded 5 times

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

Re: Problems with wxScrolledWindow with wxWidgets 3.1.2

Post by doublemax » Thu Nov 28, 2019 4:36 pm

I see it even under Windows, but i still have no idea what causes it. Will take a deeper look when i have some more time.

If you're willing to put some time into it, could you make a GIT bisect in order to find the exact code change that caused the change in behavior?
Use the source, Luke!

User avatar
Parduz
Experienced Solver
Experienced Solver
Posts: 71
Joined: Fri Jan 30, 2015 1:48 pm
Location: Bologna, Italy

Re: Problems with wxScrolledWindow with wxWidgets 3.1.2

Post by Parduz » Fri Nov 29, 2019 11:03 am

doublemax wrote:
Thu Nov 28, 2019 4:36 pm
I see it even under Windows, but i still have no idea what causes it. Will take a deeper look when i have some more time.

If you're willing to put some time into it, could you make a GIT bisect in order to find the exact code change that caused the change in behavior?
I don't even understand what are you asking for :oops:

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

Re: Problems with wxScrolledWindow with wxWidgets 3.1.2

Post by doublemax » Fri Nov 29, 2019 11:24 am

https://www.metaltoad.com/blog/beginner ... limination

If you work with GIT, you should look into it. It's quite useful.
Use the source, Luke!

Post Reply