wxScrolledWindow stretch problem

B. Carrupt capt at digicapt.ch
Thu May 10 00:45:19 PDT 2007


Hi all,

I posted a question with this subject : wxScrolledWindow and Sizer.

I tried to find the smallest example to show you the problem and it seems to be a bug (or I didn't understand some change from version 2.4 to 2.6) : wxScrooledWindow is not able to reduce its size when SetScrollRate is used.

Please check out the following example. Run it, extand the frame and then reduce it. You will see that the scrolled window expands with the frame but does not reduce. If you comment the SetScrollRate, it works fine... but I will have no chance to have scroll bars in the scrolled window. Or is it another way ?

I use Fedora Core 6 and compiled version 2.6.4 of wxWidgets with gtk. I have the same problem with version 2.8.3. It works fine on Fedora Core 2 an version 2.4.2 of wxWidgets with gtk.

Thanks
Blaise




#include <wx/wxprec.h>
#ifndef WX_PRECOMP
	#include <wx/wx.h>
#endif

class DcApp : public wxApp {
public :
	virtual bool OnInit();
};

DECLARE_APP(DcApp)
IMPLEMENT_APP(DcApp)

bool DcApp::OnInit() {
  wxFrame		*frame;
  wxFlexGridSizer	*flexgridsizer;
  wxScrolledWindow	*panel;
  wxTextCtrl		*edit;
  wxButton		*button;
  

  flexgridsizer = new wxFlexGridSizer(1, 2);
  flexgridsizer->AddGrowableCol(0, 1);
  flexgridsizer->AddGrowableRow(0, 1);
  frame = new wxFrame((wxFrame*) NULL, -1, "", wxDefaultPosition, wxSize(500, 300));
  frame->SetSizer(flexgridsizer);

  flexgridsizer = new wxFlexGridSizer(4, 1);
  flexgridsizer->AddGrowableCol(0, 1);
  panel = new wxScrolledWindow(frame);
  panel->SetSizer(flexgridsizer);
  panel->SetScrollRate(5, 5);	// COMMENT THIS TO SEE...
  frame->GetSizer()->Add(panel, 1, wxEXPAND);

  edit = new wxTextCtrl(panel,
			wxID_ANY,
			"This stands in growable row/col");
  panel->GetSizer()->Add(edit, 1, wxEXPAND);
  
  button = new wxButton(frame,
			wxID_ANY,
			"Should follow the frame border");
  frame->GetSizer()->Add(button);

  frame->Show(TRUE);
  return true;
}



--
B. Carrupt





More information about the wx-dev mailing list