wxScrolledWindow - Scrollbars don't appear automatically

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
Morfio
Experienced Solver
Experienced Solver
Posts: 67
Joined: Thu Jul 07, 2005 4:35 pm

wxScrolledWindow - Scrollbars don't appear automatically

Post by Morfio » Tue Jun 20, 2006 9:39 am

Hi,

I'm using wxWidgets 2.6.3 on Mac OS X and startet to write a little program to do database selections.

Now I'm at the point, that if the inner sizer is bigger than the ScrolledWindow, automatically the scrollbars appear. But they only appear, if I resize the window manually. Refresh doesn't work. Here the code:

Code: Select all

CSelektionen::CSelektionen(wxWindow *parent, wxWindowID id) : wxScrolledWindow(parent,
                                                                                                                                               
                        id,
                                                                                                                                               
                        wxDefaultPosition,
                                                                                                                                               
                        wxDefaultSize,
                                                                                                                                               
                        wxVSCROLL | wxALWAYS_SHOW_SB | wxFULL_REPAINT_ON_RESIZE) {

        SetScrollbars(10, 10, 100, 100);
        
        fgsDaten = new wxFlexGridSizer(5, 5, 5);
        fgsDaten->AddGrowableCol(4);
        SetSizer(fgsDaten);


        selektionen = new TSelektion(this, fgsDaten, _("gna"));
}

// and

void CSelektionen::hinzufuegen(int komponente) {
        TZeile *zeile = new TZeile(this, komponente);

        fgsDaten->Add(zeile->cmbFeld);
        fgsDaten->Add(zeile->cmbOperator);
        fgsDaten->Add(zeile->kKomponente);
        fgsDaten->Add(zeile->cmbVergleich);
        zeile->bbtnEntfernen->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(CSelektionen::entfernen), NULL, this);
        fgsDaten->Add(zeile->bbtnEntfernen, 0, wxALIGN_RIGHT);
        fgsDaten->Layout();
        fgsDaten->RecalcSizes();
        
        selektionen->zeilen.push_back(zeile);

        fgsDaten->FitInside(this);
        
        Refresh();
}
Can anybody tell me, what I did wrong?

Thx,

Morfio ...

Morfio
Experienced Solver
Experienced Solver
Posts: 67
Joined: Thu Jul 07, 2005 4:35 pm

Post by Morfio » Tue Jun 20, 2006 10:40 am

Hi,

I found out now, that the problem only exists if CSelektionen was added to a sizer in the Frame. Can't I use ScrolledWindows in Sizers?

Thx, Morfio ...

phlox81
wxWorld Domination!
wxWorld Domination!
Posts: 1387
Joined: Thu Aug 18, 2005 7:49 pm
Location: Germany
Contact:

Post by phlox81 » Tue Jun 20, 2006 10:46 am

Maybe you should call SetScrollbars after you called SetSizer, maybe also a call to SetLayout() helps.

Morfio
Experienced Solver
Experienced Solver
Posts: 67
Joined: Thu Jul 07, 2005 4:35 pm

Post by Morfio » Tue Jun 20, 2006 11:46 am

Now it works. I called after adding such a row always Layout in the main sizer. Without Layout() it works.

But there is now an other problem. If I scroll, the lines in the FlexGridSizers are displaced. Is there any possibility to avoid this problem?

Morfio
Experienced Solver
Experienced Solver
Posts: 67
Joined: Thu Jul 07, 2005 4:35 pm

Post by Morfio » Tue Jun 20, 2006 12:01 pm

I got it: I wrote an event, that recalcs the sizer, this seems (under Mac OS X) to work:

Code: Select all

void CSelektionen::refresh(wxScrollWinEvent &event) {
        fgsDaten->Layout();
        fgsDaten->RecalcSizes();
        fgsDaten->FitInside(this);
        Refresh();
        event.Skip();
}

Post Reply